Skip to content

Commit

Permalink
get rid of removeUndefined in accordion
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte committed Apr 11, 2024
1 parent 254ae58 commit 42e65e4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
children,
child,
type,
value,
value = $bindable(),
el,
...restProps
}: AccordionRootProps = $props();
Expand Down
16 changes: 6 additions & 10 deletions packages/bits-ui/src/lib/bits/accordion/state.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
dataDisabledAttrs,
kbd,
openClosedAttrs,
removeUndefined,
verifyContextDeps,
} from "$lib/internal/index.js";

Expand All @@ -33,7 +32,7 @@ class AccordionBaseState {
constructor(props: AccordionBaseStateProps = {}) {
const mergedProps = {
...defaultAccordionRootBaseProps,
...removeUndefined(props),
...props,
} satisfies AccordionBaseStateProps;
this.el = mergedProps.el;
this.disabled = mergedProps.disabled;
Expand Down Expand Up @@ -64,7 +63,7 @@ export class AccordionSingleState extends AccordionBaseState {
constructor(props: AccordionSingleStateProps = {}) {
const mergedProps = {
...defaultAccordionRootSingleProps,
...removeUndefined(props),
...props,
} satisfies AccordionSingleStateProps;
super(mergedProps);
this.value = mergedProps.value;
Expand Down Expand Up @@ -98,7 +97,7 @@ export class AccordionMultiState extends AccordionBaseState {
constructor(props: AccordionMultiStateProps = {}) {
const mergedProps = {
...defaultAccordionRootMultiProps,
...removeUndefined(props),
...props,
} satisfies AccordionMultiStateProps;
super(mergedProps);

Expand Down Expand Up @@ -329,8 +328,7 @@ export function getAccordionRootState(): AccordionState {

export function setAccordionItemState(props: Omit<AccordionItemStateProps, "rootState">) {
verifyContextDeps(ACCORDION_ROOT);
const rootState = getAccordionRootState();
const itemState = new AccordionItemState({ ...props, rootState });
const itemState = new AccordionItemState({ ...props, rootState: getAccordionRootState() });
setContext(ACCORDION_ITEM, itemState);
return itemState;
}
Expand All @@ -341,12 +339,10 @@ export function getAccordionItemState(): AccordionItemState {

export function getAccordionTriggerState(props: AccordionTriggerStateProps): AccordionTriggerState {
verifyContextDeps(ACCORDION_ITEM);
const itemState = getAccordionItemState();
return itemState.createTrigger(props);
return getAccordionItemState().createTrigger(props);
}

export function getAccordionContentState(): AccordionContentState {
verifyContextDeps(ACCORDION_ITEM);
const itemState = getAccordionItemState();
return itemState.createContent();
return getAccordionItemState().createContent();
}
6 changes: 3 additions & 3 deletions packages/bits-ui/src/lib/bits/accordion/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ interface MultipleAccordionProps extends BaseAccordionProps {
value?: string[];
}

export type AccordionRootPropsWithoutHTML = WithAsChild<
SingleAccordionProps | MultipleAccordionProps
>;
export type AccordionRootPropsWithoutHTML =
| WithAsChild<SingleAccordionProps>
| WithAsChild<MultipleAccordionProps>;

export type AccordionRootProps = AccordionRootPropsWithoutHTML & PrimitiveDivAttributes;

Expand Down

0 comments on commit 42e65e4

Please sign in to comment.