ui-ingredients 0.0.18 → 0.0.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. package/README.md +1 -1
  2. package/dist/collapsible/create-collapsible.svelte.d.ts +1 -0
  3. package/dist/collapsible/create-collapsible.svelte.js +1 -0
  4. package/dist/collapsible/root.svelte +4 -2
  5. package/dist/collapsible/trigger.svelte +2 -2
  6. package/dist/combobox/create-combobox.svelte.d.ts +1 -0
  7. package/dist/combobox/create-combobox.svelte.js +1 -0
  8. package/dist/combobox/root.svelte +2 -0
  9. package/dist/date-picker/anatomy.js +3 -0
  10. package/dist/date-picker/clear-trigger.svelte +19 -2
  11. package/dist/date-picker/clear-trigger.svelte.d.ts +3 -3
  12. package/dist/date-picker/content.svelte +19 -2
  13. package/dist/date-picker/content.svelte.d.ts +3 -3
  14. package/dist/date-picker/context.svelte.d.ts +8 -8
  15. package/dist/date-picker/context.svelte.js +6 -14
  16. package/dist/date-picker/control.svelte +19 -2
  17. package/dist/date-picker/control.svelte.d.ts +3 -3
  18. package/dist/date-picker/create-date-picker.svelte.d.ts +14 -0
  19. package/dist/date-picker/create-date-picker.svelte.js +24 -0
  20. package/dist/date-picker/date-picker.d.ts +3 -3
  21. package/dist/date-picker/date-picker.js +3 -3
  22. package/dist/date-picker/day-table-cell-trigger.svelte +21 -2
  23. package/dist/date-picker/day-table-cell-trigger.svelte.d.ts +3 -3
  24. package/dist/date-picker/day-table-cell.svelte +40 -2
  25. package/dist/date-picker/day-table-cell.svelte.d.ts +3 -3
  26. package/dist/date-picker/index.d.ts +29 -0
  27. package/dist/date-picker/index.js +2 -0
  28. package/dist/date-picker/input.svelte +18 -2
  29. package/dist/date-picker/input.svelte.d.ts +3 -3
  30. package/dist/date-picker/label.svelte +20 -2
  31. package/dist/date-picker/label.svelte.d.ts +3 -3
  32. package/dist/date-picker/month-select.svelte +40 -2
  33. package/dist/date-picker/month-select.svelte.d.ts +3 -3
  34. package/dist/date-picker/month-table-cell-trigger.svelte +21 -2
  35. package/dist/date-picker/month-table-cell-trigger.svelte.d.ts +3 -3
  36. package/dist/date-picker/month-table-cell.svelte +40 -2
  37. package/dist/date-picker/month-table-cell.svelte.d.ts +3 -3
  38. package/dist/date-picker/next-trigger.svelte +21 -2
  39. package/dist/date-picker/next-trigger.svelte.d.ts +3 -3
  40. package/dist/date-picker/positioner.svelte +19 -2
  41. package/dist/date-picker/positioner.svelte.d.ts +3 -3
  42. package/dist/date-picker/preset-trigger.svelte +21 -2
  43. package/dist/date-picker/preset-trigger.svelte.d.ts +3 -3
  44. package/dist/date-picker/prev-trigger.svelte +21 -2
  45. package/dist/date-picker/prev-trigger.svelte.d.ts +3 -3
  46. package/dist/date-picker/range-text.svelte +23 -2
  47. package/dist/date-picker/range-text.svelte.d.ts +3 -3
  48. package/dist/date-picker/root.svelte +85 -2
  49. package/dist/date-picker/root.svelte.d.ts +3 -3
  50. package/dist/date-picker/table-body.svelte +21 -2
  51. package/dist/date-picker/table-body.svelte.d.ts +3 -3
  52. package/dist/date-picker/table-head.svelte +21 -2
  53. package/dist/date-picker/table-head.svelte.d.ts +3 -3
  54. package/dist/date-picker/table-header.svelte +21 -2
  55. package/dist/date-picker/table-header.svelte.d.ts +3 -3
  56. package/dist/date-picker/table-row.svelte +21 -2
  57. package/dist/date-picker/table-row.svelte.d.ts +3 -3
  58. package/dist/date-picker/table.svelte +31 -2
  59. package/dist/date-picker/table.svelte.d.ts +3 -3
  60. package/dist/date-picker/trigger.svelte +19 -2
  61. package/dist/date-picker/trigger.svelte.d.ts +3 -3
  62. package/dist/date-picker/view-control.svelte +21 -2
  63. package/dist/date-picker/view-control.svelte.d.ts +3 -3
  64. package/dist/date-picker/view.svelte +24 -0
  65. package/dist/date-picker/{view-trigger.svelte.d.ts → view.svelte.d.ts} +5 -5
  66. package/dist/date-picker/year-select.svelte +40 -2
  67. package/dist/date-picker/year-select.svelte.d.ts +3 -3
  68. package/dist/date-picker/year-table-cell-trigger.svelte +21 -2
  69. package/dist/date-picker/year-table-cell-trigger.svelte.d.ts +3 -3
  70. package/dist/date-picker/year-table-cell.svelte +40 -2
  71. package/dist/date-picker/year-table-cell.svelte.d.ts +3 -3
  72. package/dist/dialog/create-dialog.svelte.d.ts +1 -0
  73. package/dist/dialog/create-dialog.svelte.js +1 -0
  74. package/dist/editable/create-editable.svelte.d.ts +1 -0
  75. package/dist/editable/create-editable.svelte.js +1 -0
  76. package/dist/hover-card/create-hover-card.svelte.d.ts +1 -0
  77. package/dist/hover-card/create-hover-card.svelte.js +1 -0
  78. package/dist/menu/create-menu.svelte.d.ts +1 -0
  79. package/dist/menu/create-menu.svelte.js +1 -0
  80. package/dist/menu/option-item.svelte +5 -8
  81. package/dist/popover/create-popover.svelte.d.ts +1 -0
  82. package/dist/popover/create-popover.svelte.js +1 -0
  83. package/dist/select/create-select.svelte.d.ts +1 -0
  84. package/dist/select/create-select.svelte.js +1 -0
  85. package/dist/select/root.svelte +2 -0
  86. package/dist/tooltip/create-tooltip.svelte.d.ts +1 -0
  87. package/dist/tooltip/create-tooltip.svelte.js +1 -0
  88. package/dist/types.d.ts +2 -4
  89. package/package.json +1 -1
  90. package/dist/date-picker/view-trigger.svelte +0 -3
@@ -1,3 +1,32 @@
1
- <script lang="ts" module></script>
1
+ <script lang="ts" module>
2
+ import type {Assign, HtmlProps} from '../types.js';
3
+ import type {TableProps} from '@zag-js/date-picker';
2
4
 
3
- <script lang="ts"></script>
5
+ export interface DatePickerTableProps
6
+ extends Assign<HtmlProps<'div'>, Omit<TableProps, 'view'>> {}
7
+ </script>
8
+
9
+ <script lang="ts">
10
+ import {mergeProps} from '@zag-js/svelte';
11
+ import {
12
+ datePickerContext,
13
+ datePickerTablePropsContext,
14
+ datePickerViewPropsContext,
15
+ } from './context.svelte.js';
16
+
17
+ let {id, columns, children, ...props}: DatePickerTableProps = $props();
18
+
19
+ let context = datePickerContext.get();
20
+
21
+ let viewProps = datePickerViewPropsContext.get();
22
+
23
+ let tableProps: TableProps = $derived({...viewProps, id, columns});
24
+
25
+ let attrs = $derived(mergeProps(props, context.getTableProps(tableProps)));
26
+
27
+ datePickerTablePropsContext.set(() => tableProps);
28
+ </script>
29
+
30
+ <div {...attrs}>
31
+ {@render children?.()}
32
+ </div>
@@ -2,7 +2,7 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
2
2
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
3
  $$bindings?: Bindings;
4
4
  } & Exports;
5
- (internal: unknown, props: {
5
+ (internal: unknown, props: Props & {
6
6
  $$events?: Events;
7
7
  $$slots?: Slots;
8
8
  }): Exports & {
@@ -11,8 +11,8 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
11
11
  };
12
12
  z_$$bindings?: Bindings;
13
13
  }
14
- declare const Table: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
14
+ declare const Table: $$__sveltets_2_IsomorphicComponent<DatePickerTableProps, {
15
15
  [evt: string]: CustomEvent<any>;
16
- }, {}, {}, string>;
16
+ }, {}, {}, "">;
17
17
  type Table = InstanceType<typeof Table>;
18
18
  export default Table;
@@ -1,3 +1,20 @@
1
- <script lang="ts" module></script>
1
+ <script lang="ts" module>
2
+ import type {HtmlProps} from '../types.js';
2
3
 
3
- <script lang="ts"></script>
4
+ export interface DatePickerTriggerProps extends HtmlProps<'button'> {}
5
+ </script>
6
+
7
+ <script lang="ts">
8
+ import {mergeProps} from '@zag-js/svelte';
9
+ import {datePickerContext} from './context.svelte.js';
10
+
11
+ let {children, ...props}: DatePickerTriggerProps = $props();
12
+
13
+ let context = datePickerContext.get();
14
+
15
+ let attrs = $derived(mergeProps(props, context.getTriggerProps()));
16
+ </script>
17
+
18
+ <button type="button" {...attrs}>
19
+ {@render children?.()}
20
+ </button>
@@ -2,7 +2,7 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
2
2
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
3
  $$bindings?: Bindings;
4
4
  } & Exports;
5
- (internal: unknown, props: {
5
+ (internal: unknown, props: Props & {
6
6
  $$events?: Events;
7
7
  $$slots?: Slots;
8
8
  }): Exports & {
@@ -11,8 +11,8 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
11
11
  };
12
12
  z_$$bindings?: Bindings;
13
13
  }
14
- declare const Trigger: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
14
+ declare const Trigger: $$__sveltets_2_IsomorphicComponent<DatePickerTriggerProps, {
15
15
  [evt: string]: CustomEvent<any>;
16
- }, {}, {}, string>;
16
+ }, {}, {}, "">;
17
17
  type Trigger = InstanceType<typeof Trigger>;
18
18
  export default Trigger;
@@ -1,3 +1,22 @@
1
- <script lang="ts" module></script>
1
+ <script lang="ts" module>
2
+ import type {HtmlProps} from '../types.js';
2
3
 
3
- <script lang="ts"></script>
4
+ export interface DatePickerViewControlProps extends HtmlProps<'div'> {}
5
+ </script>
6
+
7
+ <script lang="ts">
8
+ import {mergeProps} from '@zag-js/svelte';
9
+ import {datePickerContext, datePickerViewPropsContext} from './context.svelte.js';
10
+
11
+ let {children, ...props}: DatePickerViewControlProps = $props();
12
+
13
+ let context = datePickerContext.get();
14
+
15
+ let viewProps = datePickerViewPropsContext.get();
16
+
17
+ let attrs = $derived(mergeProps(props, context.getViewControlProps(viewProps)));
18
+ </script>
19
+
20
+ <div {...attrs}>
21
+ {@render children?.()}
22
+ </div>
@@ -2,7 +2,7 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
2
2
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
3
  $$bindings?: Bindings;
4
4
  } & Exports;
5
- (internal: unknown, props: {
5
+ (internal: unknown, props: Props & {
6
6
  $$events?: Events;
7
7
  $$slots?: Slots;
8
8
  }): Exports & {
@@ -11,8 +11,8 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
11
11
  };
12
12
  z_$$bindings?: Bindings;
13
13
  }
14
- declare const ViewControl: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
14
+ declare const ViewControl: $$__sveltets_2_IsomorphicComponent<DatePickerViewControlProps, {
15
15
  [evt: string]: CustomEvent<any>;
16
- }, {}, {}, string>;
16
+ }, {}, {}, "">;
17
17
  type ViewControl = InstanceType<typeof ViewControl>;
18
18
  export default ViewControl;
@@ -0,0 +1,24 @@
1
+ <script lang="ts" module>
2
+ import type {Assign, HtmlProps} from '../types.js';
3
+ import type {ViewProps} from '@zag-js/date-picker';
4
+
5
+ export interface DatePickerViewProps extends Assign<HtmlProps<'div'>, ViewProps> {}
6
+ </script>
7
+
8
+ <script lang="ts">
9
+ import {mergeProps} from '@zag-js/svelte';
10
+ import {parts} from './anatomy.js';
11
+ import {datePickerContext, datePickerViewPropsContext} from './context.svelte.js';
12
+
13
+ let {view = 'day', children, ...props}: DatePickerViewProps = $props();
14
+
15
+ let context = datePickerContext.get();
16
+
17
+ let attrs = $derived(mergeProps(props, parts.view.attrs));
18
+
19
+ datePickerViewPropsContext.set(() => ({view}));
20
+ </script>
21
+
22
+ <div hidden={context.view !== view} {...attrs}>
23
+ {@render children?.()}
24
+ </div>
@@ -2,7 +2,7 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
2
2
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
3
  $$bindings?: Bindings;
4
4
  } & Exports;
5
- (internal: unknown, props: {
5
+ (internal: unknown, props: Props & {
6
6
  $$events?: Events;
7
7
  $$slots?: Slots;
8
8
  }): Exports & {
@@ -11,8 +11,8 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
11
11
  };
12
12
  z_$$bindings?: Bindings;
13
13
  }
14
- declare const ViewTrigger: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
14
+ declare const View: $$__sveltets_2_IsomorphicComponent<DatePickerViewProps, {
15
15
  [evt: string]: CustomEvent<any>;
16
- }, {}, {}, string>;
17
- type ViewTrigger = InstanceType<typeof ViewTrigger>;
18
- export default ViewTrigger;
16
+ }, {}, {}, "">;
17
+ type View = InstanceType<typeof View>;
18
+ export default View;
@@ -1,3 +1,41 @@
1
- <script lang="ts" module></script>
1
+ <script lang="ts" module>
2
+ import type {HtmlProps} from '../types.js';
2
3
 
3
- <script lang="ts"></script>
4
+ export interface DatePickerYearSelectProps extends HtmlProps<'select'> {}
5
+ </script>
6
+
7
+ <script lang="ts">
8
+ import {mergeProps} from '@zag-js/svelte';
9
+ import {datePickerContext} from './context.svelte.js';
10
+
11
+ let {children, ...props}: DatePickerYearSelectProps = $props();
12
+
13
+ let context = datePickerContext.get();
14
+
15
+ let attrs = $derived(mergeProps(props, context.getYearSelectProps()));
16
+
17
+ function getYears() {
18
+ const currentYear = new Date().getFullYear();
19
+
20
+ const start = currentYear - 1000;
21
+ const until = currentYear + 1000;
22
+
23
+ const years = [];
24
+
25
+ for (let i = start; i <= until; i++) {
26
+ years.unshift(i);
27
+ }
28
+
29
+ return years;
30
+ }
31
+ </script>
32
+
33
+ <select {...attrs}>
34
+ {#if children}
35
+ {@render children()}
36
+ {:else}
37
+ {#each getYears() as year}
38
+ <option value={year}>{year}</option>
39
+ {/each}
40
+ {/if}
41
+ </select>
@@ -2,7 +2,7 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
2
2
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
3
  $$bindings?: Bindings;
4
4
  } & Exports;
5
- (internal: unknown, props: {
5
+ (internal: unknown, props: Props & {
6
6
  $$events?: Events;
7
7
  $$slots?: Slots;
8
8
  }): Exports & {
@@ -11,8 +11,8 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
11
11
  };
12
12
  z_$$bindings?: Bindings;
13
13
  }
14
- declare const YearSelect: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
14
+ declare const YearSelect: $$__sveltets_2_IsomorphicComponent<DatePickerYearSelectProps, {
15
15
  [evt: string]: CustomEvent<any>;
16
- }, {}, {}, string>;
16
+ }, {}, {}, "">;
17
17
  type YearSelect = InstanceType<typeof YearSelect>;
18
18
  export default YearSelect;
@@ -1,3 +1,22 @@
1
- <script lang="ts" module></script>
1
+ <script lang="ts" module>
2
+ import type {HtmlProps} from '../types.js';
2
3
 
3
- <script lang="ts"></script>
4
+ export interface DatePickerYearTableCellTriggerProps extends HtmlProps<'button'> {}
5
+ </script>
6
+
7
+ <script lang="ts">
8
+ import {mergeProps} from '@zag-js/svelte';
9
+ import {datePickerContext, datePickerTableCellPropsContext} from './context.svelte.js';
10
+
11
+ let {children, ...props}: DatePickerYearTableCellTriggerProps = $props();
12
+
13
+ let context = datePickerContext.get();
14
+
15
+ let tableCellProps = datePickerTableCellPropsContext.get();
16
+
17
+ let attrs = $derived(mergeProps(props, context.getYearTableCellTriggerProps(tableCellProps)));
18
+ </script>
19
+
20
+ <button type="button" {...attrs}>
21
+ {@render children?.()}
22
+ </button>
@@ -2,7 +2,7 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
2
2
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
3
  $$bindings?: Bindings;
4
4
  } & Exports;
5
- (internal: unknown, props: {
5
+ (internal: unknown, props: Props & {
6
6
  $$events?: Events;
7
7
  $$slots?: Slots;
8
8
  }): Exports & {
@@ -11,8 +11,8 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
11
11
  };
12
12
  z_$$bindings?: Bindings;
13
13
  }
14
- declare const YearTableCellTrigger: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
14
+ declare const YearTableCellTrigger: $$__sveltets_2_IsomorphicComponent<DatePickerYearTableCellTriggerProps, {
15
15
  [evt: string]: CustomEvent<any>;
16
- }, {}, {}, string>;
16
+ }, {}, {}, "">;
17
17
  type YearTableCellTrigger = InstanceType<typeof YearTableCellTrigger>;
18
18
  export default YearTableCellTrigger;
@@ -1,3 +1,41 @@
1
- <script lang="ts" module></script>
1
+ <script lang="ts" module>
2
+ import type {Assign, HtmlProps} from '../types.js';
3
+ import type {TableCellProps, TableCellState} from '@zag-js/date-picker';
4
+ import type {Snippet} from 'svelte';
2
5
 
3
- <script lang="ts"></script>
6
+ export interface DatePickerYearTableCellProps
7
+ extends Assign<Omit<HtmlProps<'div'>, 'children'>, TableCellProps> {
8
+ children?: Snippet<[state: TableCellState]>;
9
+ }
10
+ </script>
11
+
12
+ <script lang="ts">
13
+ import {mergeProps} from '@zag-js/svelte';
14
+ import {datePickerContext, datePickerTableCellPropsContext} from './context.svelte.js';
15
+
16
+ let {
17
+ /**/
18
+ value,
19
+ disabled,
20
+ columns,
21
+ children,
22
+ ...props
23
+ }: DatePickerYearTableCellProps = $props();
24
+
25
+ let context = datePickerContext.get();
26
+
27
+ let tableCellProps: TableCellProps = $derived({
28
+ value,
29
+ disabled,
30
+ columns,
31
+ });
32
+
33
+ let state = $derived(context.getYearTableCellState(tableCellProps));
34
+ let attrs = $derived(mergeProps(props, context.getYearTableCellProps(tableCellProps)));
35
+
36
+ datePickerTableCellPropsContext.set(() => tableCellProps);
37
+ </script>
38
+
39
+ <div {...attrs}>
40
+ {@render children?.(state)}
41
+ </div>
@@ -2,7 +2,7 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
2
2
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
3
  $$bindings?: Bindings;
4
4
  } & Exports;
5
- (internal: unknown, props: {
5
+ (internal: unknown, props: Props & {
6
6
  $$events?: Events;
7
7
  $$slots?: Slots;
8
8
  }): Exports & {
@@ -11,8 +11,8 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
11
11
  };
12
12
  z_$$bindings?: Bindings;
13
13
  }
14
- declare const YearTableCell: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
14
+ declare const YearTableCell: $$__sveltets_2_IsomorphicComponent<DatePickerYearTableCellProps, {
15
15
  [evt: string]: CustomEvent<any>;
16
- }, {}, {}, string>;
16
+ }, {}, {}, "">;
17
17
  type YearTableCell = InstanceType<typeof YearTableCell>;
18
18
  export default YearTableCell;
@@ -1,6 +1,7 @@
1
1
  import * as dialog from '@zag-js/dialog';
2
2
  export interface CreateDialogProps extends Omit<dialog.Context, 'id' | 'dir' | 'getRootNode' | 'open.controlled'> {
3
3
  id?: string | null;
4
+ defaultOpen?: boolean;
4
5
  }
5
6
  export interface CreateDialogReturn extends dialog.Api {
6
7
  }
@@ -10,6 +10,7 @@ export function createDialog(props) {
10
10
  ...props,
11
11
  id: props.id ?? createUniqueId(),
12
12
  dir: localeContext?.dir,
13
+ open: props.defaultOpen,
13
14
  getRootNode: environmentContext?.getRootNode,
14
15
  'open.controlled': props.open != null,
15
16
  }));
@@ -1,6 +1,7 @@
1
1
  import * as editable from '@zag-js/editable';
2
2
  export interface CreateEditableProps extends Omit<editable.Context, 'id' | 'dir' | 'getRootNode' | 'edit.controlled'> {
3
3
  id?: string | null;
4
+ defaultEdit?: boolean;
4
5
  }
5
6
  export interface CreateEditableReturn extends editable.Api {
6
7
  }
@@ -10,6 +10,7 @@ export function createEditable(props) {
10
10
  ...props,
11
11
  id: props.id ?? createUniqueId(),
12
12
  dir: localeContext?.dir,
13
+ edit: props.defaultEdit,
13
14
  getRootNode: environmentContext?.getRootNode,
14
15
  'edit.controlled': props.edit != null,
15
16
  }));
@@ -1,6 +1,7 @@
1
1
  import * as hoverCard from '@zag-js/hover-card';
2
2
  export interface CreateHoverCardProps extends Omit<hoverCard.Context, 'id' | 'dir' | 'getRootNode' | 'open.controlled'> {
3
3
  id?: string | null;
4
+ defaultOpen?: boolean;
4
5
  }
5
6
  export interface CreateHoverCardReturn extends hoverCard.Api {
6
7
  }
@@ -10,6 +10,7 @@ export function createHoverCard(props) {
10
10
  ...props,
11
11
  id: props.id ?? createUniqueId(),
12
12
  dir: localeContext?.dir,
13
+ open: props.defaultOpen,
13
14
  getRootNode: environmentContext?.getRootNode,
14
15
  'open.controlled': props.open != null,
15
16
  }));
@@ -1,6 +1,7 @@
1
1
  import * as menu from '@zag-js/menu';
2
2
  export interface CreateMenuProps extends Omit<menu.Context, 'id' | 'dir' | 'getRootNode' | 'open.controlled'> {
3
3
  id?: string | null;
4
+ defaultOpen?: boolean;
4
5
  }
5
6
  export interface CreateMenuReturn extends menu.Api {
6
7
  }
@@ -10,6 +10,7 @@ export function createMenu(props) {
10
10
  ...props,
11
11
  id: props.id ?? createUniqueId(),
12
12
  dir: localeContext?.dir,
13
+ open: props.defaultOpen,
13
14
  getRootNode: environmentContext?.getRootNode,
14
15
  'open.controlled': props.open != null,
15
16
  }));
@@ -1,13 +1,10 @@
1
1
  <script lang="ts" module>
2
- import type {Assign, HtmlProps, PickPartial} from '../types.js';
2
+ import type {Assign, HtmlProps} from '../types.js';
3
3
  import type {OptionItemProps, OptionItemState} from '@zag-js/menu';
4
4
  import type {Snippet} from 'svelte';
5
5
 
6
6
  export interface MenuOptionItemProps
7
- extends Assign<
8
- Omit<HtmlProps<'div'>, 'children'>,
9
- PickPartial<OptionItemProps, 'type' | 'checked'>
10
- > {
7
+ extends Assign<Omit<HtmlProps<'div'>, 'children'>, OptionItemProps> {
11
8
  children?: Snippet<[state: OptionItemState]>;
12
9
  }
13
10
  </script>
@@ -17,9 +14,9 @@
17
14
  import {menuContext, menuOptionItemPropsContext} from './context.svelte.js';
18
15
 
19
16
  let {
20
- type = 'checkbox',
17
+ type,
21
18
  value,
22
- checked = false,
19
+ checked,
23
20
  disabled,
24
21
  valueText,
25
22
  closeOnSelect,
@@ -30,7 +27,7 @@
30
27
 
31
28
  let context = menuContext.get();
32
29
 
33
- let itemProps = $derived({
30
+ let itemProps: OptionItemProps = $derived({
34
31
  type,
35
32
  value,
36
33
  checked,
@@ -1,6 +1,7 @@
1
1
  import * as popover from '@zag-js/popover';
2
2
  export interface CreatePopoverProps extends Omit<popover.Context, 'id' | 'dir' | 'getRootNode' | 'open.controlled'> {
3
3
  id?: string | null;
4
+ defaultOpen?: boolean;
4
5
  }
5
6
  export interface CreatePopoverReturn extends popover.Api {
6
7
  }
@@ -10,6 +10,7 @@ export function createPopover(props) {
10
10
  ...props,
11
11
  id: props.id ?? createUniqueId(),
12
12
  dir: localeContext?.dir,
13
+ open: props.defaultOpen,
13
14
  getRootNode: environmentContext?.getRootNode,
14
15
  'open.controlled': props.open != null,
15
16
  }));
@@ -5,6 +5,7 @@ export interface CreateSelectProps<T> extends Omit<select.Context, 'id' | 'dir'
5
5
  itemToString?: (item: T) => string;
6
6
  itemToValue?: (item: T) => string;
7
7
  isItemDisabled?: (item: T) => boolean;
8
+ defaultOpen?: boolean;
8
9
  }
9
10
  export interface CreateSelectReturn extends select.Api {
10
11
  }
@@ -16,6 +16,7 @@ export function createSelect(props) {
16
16
  ...props,
17
17
  id: props.id ?? createUniqueId(),
18
18
  dir: localeContext?.dir,
19
+ open: props.defaultOpen,
19
20
  getRootNode: environmentContext?.getRootNode,
20
21
  collection,
21
22
  'open.controlled': props.open != null,
@@ -20,6 +20,7 @@
20
20
  form,
21
21
  name,
22
22
  open,
23
+ defaultOpen,
23
24
  value,
24
25
  items,
25
26
  invalid,
@@ -52,6 +53,7 @@
52
53
  form,
53
54
  name,
54
55
  open,
56
+ defaultOpen,
55
57
  value: $state.snapshot(value),
56
58
  items,
57
59
  invalid,
@@ -1,6 +1,7 @@
1
1
  import * as tooltip from '@zag-js/tooltip';
2
2
  export interface CreateTooltipProps extends Omit<tooltip.Context, 'id' | 'dir' | 'getRootNode' | 'open.controlled'> {
3
3
  id?: string | null;
4
+ defaultOpen?: boolean;
4
5
  }
5
6
  export interface CreateTooltipReturn extends tooltip.Api {
6
7
  }
@@ -10,6 +10,7 @@ export function createTooltip(props) {
10
10
  ...props,
11
11
  id: props.id ?? createUniqueId(),
12
12
  dir: localeContext?.dir,
13
+ open: props.defaultOpen,
13
14
  getRootNode: environmentContext?.getRootNode,
14
15
  'open.controlled': props.open != null,
15
16
  }));
package/dist/types.d.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  import type { SvelteHTMLElements } from 'svelte/elements';
2
2
  export type Assign<Target, Source> = Omit<Target, keyof Source> & Source;
3
- type KnownKeys<T> = keyof {
4
- [K in keyof T as string extends K ? never : number extends K ? never : K]: string;
3
+ type IntrinsicElements = keyof {
4
+ [K in keyof SvelteHTMLElements as string extends K ? never : number extends K ? never : K]: string;
5
5
  };
6
- type IntrinsicElements = KnownKeys<SvelteHTMLElements>;
7
6
  export type HtmlProps<T extends IntrinsicElements> = SvelteHTMLElements[T];
8
- export type PickPartial<T, K extends keyof T> = Partial<Pick<T, K>> & Omit<T, K>;
9
7
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ui-ingredients",
3
3
  "type": "module",
4
- "version": "0.0.18",
4
+ "version": "0.0.20",
5
5
  "packageManager": "pnpm@9.7.0",
6
6
  "svelte": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -1,3 +0,0 @@
1
- <script lang="ts" module></script>
2
-
3
- <script lang="ts"></script>