ui-ingredients 0.4.2 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. package/dist/accordion/create-accordion.svelte.js +4 -4
  2. package/dist/alert-dialog/create-alert-dialog.svelte.js +3 -3
  3. package/dist/avatar/create-avatar.svelte.js +4 -4
  4. package/dist/carousel/create-carousel.svelte.js +4 -4
  5. package/dist/checkbox/create-checkbox.svelte.js +5 -5
  6. package/dist/clipboard/create-clipboard.svelte.js +4 -4
  7. package/dist/collapsible/create-collapsible.svelte.js +3 -3
  8. package/dist/color-picker/create-color-picker.svelte.js +2 -2
  9. package/dist/combobox/combobox-item-group.svelte +2 -2
  10. package/dist/combobox/create-combobox.svelte.js +2 -2
  11. package/dist/create-unique-id.d.ts +1 -0
  12. package/dist/create-unique-id.js +2 -0
  13. package/dist/date-picker/create-date-picker.svelte.d.ts +2 -2
  14. package/dist/date-picker/create-date-picker.svelte.js +2 -2
  15. package/dist/dialog/create-dialog.svelte.js +3 -3
  16. package/dist/drawer/create-drawer.svelte.js +3 -3
  17. package/dist/editable/create-editable.svelte.js +3 -3
  18. package/dist/field/create-field.svelte.js +39 -47
  19. package/dist/file-upload/create-file-upload.svelte.js +6 -6
  20. package/dist/floating-panel/create-floating-panel.svelte.js +4 -4
  21. package/dist/hover-card/create-hover-card.svelte.js +3 -3
  22. package/dist/index.d.ts +3 -1
  23. package/dist/index.js +3 -1
  24. package/dist/menu/create-menu.svelte.js +3 -3
  25. package/dist/menu/menu-item-group.svelte +2 -2
  26. package/dist/number-input/create-number-input.svelte.js +6 -6
  27. package/dist/pagination/create-pagination.svelte.js +4 -4
  28. package/dist/pin-input/create-pin-input.svelte.js +5 -5
  29. package/dist/popover/create-popover.svelte.js +3 -3
  30. package/dist/progress/create-progress.svelte.js +4 -4
  31. package/dist/qr-code/create-qr-code.svelte.js +4 -4
  32. package/dist/radio-group/create-radio-group.svelte.js +4 -4
  33. package/dist/rating-group/create-rating-group.svelte.js +5 -5
  34. package/dist/segment-group/create-segment-group.svelte.js +4 -4
  35. package/dist/select/create-select.svelte.js +2 -2
  36. package/dist/select/select-item-group.svelte +2 -2
  37. package/dist/signature-pad/create-signature-pad.svelte.js +4 -4
  38. package/dist/slider/create-slider.svelte.js +4 -4
  39. package/dist/splitter/create-splitter.svelte.js +4 -3
  40. package/dist/steps/create-steps.svelte.js +4 -4
  41. package/dist/switch/create-switch.svelte.js +5 -5
  42. package/dist/tabs/create-tabs.svelte.js +4 -4
  43. package/dist/tags-input/create-tags-input.svelte.js +5 -5
  44. package/dist/time-picker/create-time-picker.svelte.js +3 -3
  45. package/dist/timer/create-timer.svelte.js +4 -4
  46. package/dist/toast/create-toaster.svelte.js +3 -4
  47. package/dist/toggle-group/create-toggle-group.svelte.js +4 -4
  48. package/dist/tooltip/create-tooltip.svelte.js +3 -3
  49. package/dist/tour/create-tour.svelte.js +3 -3
  50. package/dist/tree-view/create-tree-view.svelte.js +4 -4
  51. package/package.json +9 -1
@@ -1,17 +1,17 @@
1
+ import { createUniqueId } from '../create-unique-id.js';
1
2
  import { getEnvironmentContext } from '../environment-provider/enviroment-provider-context.svelte.js';
2
3
  import { getLocaleContext } from '../locale-provider/local-provider-context.svelte.js';
3
4
  import * as accordion from '@zag-js/accordion';
4
5
  import { normalizeProps, reflect, useMachine } from '@zag-js/svelte';
5
- import { uid } from 'uid';
6
6
  export function createAccordion(props) {
7
7
  const locale = getLocaleContext();
8
8
  const environment = getEnvironmentContext();
9
- const id = uid();
9
+ const id = createUniqueId();
10
10
  const context = reflect(() => ({
11
- ...props,
12
- id: props.id ?? id,
11
+ id,
13
12
  dir: locale?.dir,
14
13
  getRootNode: environment?.getRootNode,
14
+ ...props,
15
15
  }));
16
16
  const [state, send] = useMachine(accordion.machine(context), { context });
17
17
  return reflect(() => accordion.connect(state, send, normalizeProps));
@@ -1,21 +1,21 @@
1
+ import { createUniqueId } from '../create-unique-id.js';
1
2
  import { getEnvironmentContext } from '../environment-provider/enviroment-provider-context.svelte.js';
2
3
  import { getLocaleContext } from '../locale-provider/local-provider-context.svelte.js';
3
4
  import { mergeProps } from '../merge-props.js';
4
5
  import * as dialog from '@zag-js/dialog';
5
6
  import { normalizeProps, reflect, useMachine } from '@zag-js/svelte';
6
- import { uid } from 'uid';
7
7
  import { parts } from './alert-dialog-anatomy.js';
8
8
  export function createAlertDialog(props) {
9
9
  const locale = getLocaleContext();
10
10
  const environment = getEnvironmentContext();
11
- const id = uid();
11
+ const id = createUniqueId();
12
12
  const context = reflect(() => ({
13
13
  id,
14
14
  dir: locale?.dir,
15
15
  role: 'alertdialog',
16
- ...props,
17
16
  getRootNode: environment?.getRootNode,
18
17
  'open.controlled': props.openControlled,
18
+ ...props,
19
19
  }));
20
20
  const [state, send] = useMachine(dialog.machine(context), { context });
21
21
  return reflect(() => {
@@ -1,17 +1,17 @@
1
+ import { createUniqueId } from '../create-unique-id.js';
1
2
  import { getEnvironmentContext } from '../environment-provider/enviroment-provider-context.svelte.js';
2
3
  import { getLocaleContext } from '../locale-provider/local-provider-context.svelte.js';
3
4
  import * as avatar from '@zag-js/avatar';
4
5
  import { normalizeProps, reflect, useMachine } from '@zag-js/svelte';
5
- import { uid } from 'uid';
6
6
  export function createAvatar(props) {
7
7
  const locale = getLocaleContext();
8
8
  const environment = getEnvironmentContext();
9
- const id = uid();
9
+ const id = createUniqueId();
10
10
  const context = reflect(() => ({
11
- ...props,
12
- id: props.id ?? id,
11
+ id,
13
12
  dir: locale?.dir,
14
13
  getRootNode: environment?.getRootNode,
14
+ ...props,
15
15
  }));
16
16
  const [state, send] = useMachine(avatar.machine(context), { context });
17
17
  return reflect(() => avatar.connect(state, send, normalizeProps));
@@ -1,17 +1,17 @@
1
+ import { createUniqueId } from '../create-unique-id.js';
1
2
  import { getEnvironmentContext } from '../environment-provider/enviroment-provider-context.svelte.js';
2
3
  import { getLocaleContext } from '../locale-provider/local-provider-context.svelte.js';
3
4
  import * as carousel from '@zag-js/carousel';
4
5
  import { normalizeProps, reflect, useMachine } from '@zag-js/svelte';
5
- import { uid } from 'uid';
6
6
  export function createCarousel(props) {
7
7
  const locale = getLocaleContext();
8
8
  const environment = getEnvironmentContext();
9
- const id = uid();
9
+ const id = createUniqueId();
10
10
  const context = reflect(() => ({
11
- ...props,
12
- id: props.id ?? id,
11
+ id,
13
12
  dir: locale?.dir,
14
13
  getRootNode: environment?.getRootNode,
14
+ ...props,
15
15
  }));
16
16
  const [state, send] = useMachine(carousel.machine(context), { context });
17
17
  return reflect(() => carousel.connect(state, send, normalizeProps));
@@ -1,15 +1,17 @@
1
+ import { createUniqueId } from '../create-unique-id.js';
1
2
  import { getEnvironmentContext } from '../environment-provider/enviroment-provider-context.svelte.js';
2
3
  import { getFieldContext } from '../field/field-context.svelte.js';
3
4
  import { getLocaleContext } from '../locale-provider/local-provider-context.svelte.js';
4
5
  import * as checkbox from '@zag-js/checkbox';
5
6
  import { normalizeProps, reflect, useMachine } from '@zag-js/svelte';
6
- import { uid } from 'uid';
7
7
  export function createCheckbox(props) {
8
8
  const field = getFieldContext();
9
9
  const locale = getLocaleContext();
10
10
  const environment = getEnvironmentContext();
11
- const id = uid();
11
+ const id = createUniqueId();
12
12
  const context = reflect(() => ({
13
+ id,
14
+ dir: locale?.dir,
13
15
  ids: {
14
16
  label: field?.ids.label,
15
17
  hiddenInput: field?.ids.control,
@@ -18,10 +20,8 @@ export function createCheckbox(props) {
18
20
  disabled: field?.disabled,
19
21
  readOnly: field?.readOnly,
20
22
  required: field?.required,
21
- ...props,
22
- id: props.id ?? id,
23
- dir: locale?.dir,
24
23
  getRootNode: environment?.getRootNode,
24
+ ...props,
25
25
  }));
26
26
  const [state, send] = useMachine(checkbox.machine(context), { context });
27
27
  return reflect(() => {
@@ -1,14 +1,14 @@
1
+ import { createUniqueId } from '../create-unique-id.js';
1
2
  import { getEnvironmentContext } from '../environment-provider/enviroment-provider-context.svelte.js';
2
3
  import * as clipboard from '@zag-js/clipboard';
3
4
  import { normalizeProps, reflect, useMachine } from '@zag-js/svelte';
4
- import { uid } from 'uid';
5
5
  export function createClipboard(props) {
6
6
  const environment = getEnvironmentContext();
7
- const id = uid();
7
+ const id = createUniqueId();
8
8
  const context = reflect(() => ({
9
- ...props,
10
- id: props.id ?? id,
9
+ id,
11
10
  getRootNode: environment?.getRootNode,
11
+ ...props,
12
12
  }));
13
13
  const [state, send] = useMachine(clipboard.machine(context), { context });
14
14
  return reflect(() => clipboard.connect(state, send, normalizeProps));
@@ -1,18 +1,18 @@
1
+ import { createUniqueId } from '../create-unique-id.js';
1
2
  import { getEnvironmentContext } from '../environment-provider/enviroment-provider-context.svelte.js';
2
3
  import { getLocaleContext } from '../locale-provider/local-provider-context.svelte.js';
3
4
  import * as collapsible from '@zag-js/collapsible';
4
5
  import { normalizeProps, reflect, useMachine } from '@zag-js/svelte';
5
- import { uid } from 'uid';
6
6
  export function createCollapsible(props) {
7
7
  const locale = getLocaleContext();
8
8
  const environment = getEnvironmentContext();
9
- const id = uid();
9
+ const id = createUniqueId();
10
10
  const context = reflect(() => ({
11
11
  id,
12
12
  dir: locale?.dir,
13
- ...props,
14
13
  getRootNode: environment?.getRootNode,
15
14
  'open.controlled': props.openControlled,
15
+ ...props,
16
16
  }));
17
17
  const [state, send] = useMachine(collapsible.machine(context), { context });
18
18
  return reflect(() => collapsible.connect(state, send, normalizeProps));
@@ -1,13 +1,13 @@
1
+ import { createUniqueId } from '../create-unique-id.js';
1
2
  import { getEnvironmentContext } from '../environment-provider/enviroment-provider-context.svelte.js';
2
3
  import { getLocaleContext } from '../locale-provider/local-provider-context.svelte.js';
3
4
  import * as colorPicker from '@zag-js/color-picker';
4
5
  import { normalizeProps, reflect, useMachine } from '@zag-js/svelte';
5
- import { uid } from 'uid';
6
6
  import { parts } from './color-picker-anatomy.js';
7
7
  export function createColorPicker(props) {
8
8
  const locale = getLocaleContext();
9
9
  const environment = getEnvironmentContext();
10
- const id = uid();
10
+ const id = createUniqueId();
11
11
  const context = $derived.by(() => ({
12
12
  id,
13
13
  dir: locale?.dir,
@@ -6,8 +6,8 @@
6
6
  </script>
7
7
 
8
8
  <script lang="ts">
9
+ import {createUniqueId} from '../create-unique-id.js';
9
10
  import {mergeProps} from '../merge-props.js';
10
- import {uid} from 'uid';
11
11
  import {
12
12
  getComboboxContext,
13
13
  setComboboxItemGroupPropsContext,
@@ -23,7 +23,7 @@
23
23
 
24
24
  let combobox = getComboboxContext();
25
25
 
26
- let id_ = uid();
26
+ let id_ = createUniqueId();
27
27
 
28
28
  let comboboxItemGroupProps = $derived({
29
29
  id: id ?? id_,
@@ -1,10 +1,10 @@
1
+ import { createUniqueId } from '../create-unique-id.js';
1
2
  import { getEnvironmentContext } from '../environment-provider/enviroment-provider-context.svelte.js';
2
3
  import { getFieldContext } from '../field/field-context.svelte.js';
3
4
  import { getLocaleContext } from '../locale-provider/local-provider-context.svelte.js';
4
5
  import * as combobox from '@zag-js/combobox';
5
6
  import { normalizeProps, reflect, useMachine } from '@zag-js/svelte';
6
7
  import { createSplitProps } from '@zag-js/utils';
7
- import { uid } from 'uid';
8
8
  export function createCombobox(props) {
9
9
  const [collectionProps, comboboxProps] = $derived(createSplitProps([
10
10
  'items',
@@ -16,7 +16,7 @@ export function createCombobox(props) {
16
16
  const field = getFieldContext();
17
17
  const locale = getLocaleContext();
18
18
  const environment = getEnvironmentContext();
19
- const id = uid();
19
+ const id = createUniqueId();
20
20
  const context = reflect(() => ({
21
21
  id,
22
22
  ids: {
@@ -0,0 +1 @@
1
+ export declare const createUniqueId: () => string;
@@ -0,0 +1,2 @@
1
+ import { uid } from 'uid';
2
+ export const createUniqueId = () => uid();
@@ -1,5 +1,5 @@
1
- import type { GenericObject } from '../types.js';
2
1
  import * as datePicker from '@zag-js/date-picker';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
3
  type Omitted = 'id' | 'dir' | 'min' | 'max' | 'value' | 'focusedValue' | 'getRootNode' | 'open.controlled';
4
4
  export interface CreateDatePickerProps extends Omit<datePicker.Context, Omitted> {
5
5
  id?: string;
@@ -10,7 +10,7 @@ export interface CreateDatePickerProps extends Omit<datePicker.Context, Omitted>
10
10
  openControlled?: boolean;
11
11
  }
12
12
  export interface CreateDatePickerReturn extends datePicker.Api {
13
- getViewProps(props: datePicker.ViewProps): GenericObject;
13
+ getViewProps(props: datePicker.ViewProps): HTMLAttributes<HTMLElement>;
14
14
  }
15
15
  export declare function createDatePicker(props: CreateDatePickerProps): CreateDatePickerReturn;
16
16
  export {};
@@ -1,13 +1,13 @@
1
+ import { createUniqueId } from '../create-unique-id.js';
1
2
  import { getEnvironmentContext } from '../environment-provider/enviroment-provider-context.svelte.js';
2
3
  import { getLocaleContext } from '../locale-provider/local-provider-context.svelte.js';
3
4
  import * as datePicker from '@zag-js/date-picker';
4
5
  import { normalizeProps, reflect, useMachine } from '@zag-js/svelte';
5
- import { uid } from 'uid';
6
6
  import { parts } from './date-picker-anatomy.js';
7
7
  export function createDatePicker(props) {
8
8
  const locale = getLocaleContext();
9
9
  const environment = getEnvironmentContext();
10
- const id = uid();
10
+ const id = createUniqueId();
11
11
  /* FIXME: use reflect */
12
12
  const context = $derived.by(() => ({
13
13
  id,
@@ -1,19 +1,19 @@
1
+ import { createUniqueId } from '../create-unique-id.js';
1
2
  import { getEnvironmentContext } from '../environment-provider/enviroment-provider-context.svelte.js';
2
3
  import { getLocaleContext } from '../locale-provider/local-provider-context.svelte.js';
3
4
  import * as dialog from '@zag-js/dialog';
4
5
  import { normalizeProps, reflect, useMachine } from '@zag-js/svelte';
5
- import { uid } from 'uid';
6
6
  export function createDialog(props) {
7
7
  const locale = getLocaleContext();
8
8
  const environment = getEnvironmentContext();
9
- const id = uid();
9
+ const id = createUniqueId();
10
10
  const context = reflect(() => ({
11
11
  id,
12
12
  dir: locale?.dir,
13
13
  role: 'dialog',
14
- ...props,
15
14
  getRootNode: environment?.getRootNode,
16
15
  'open.controlled': props.openControlled,
16
+ ...props,
17
17
  }));
18
18
  const [state, send] = useMachine(dialog.machine(context), { context });
19
19
  return reflect(() => dialog.connect(state, send, normalizeProps));
@@ -1,21 +1,21 @@
1
+ import { createUniqueId } from '../create-unique-id.js';
1
2
  import { getEnvironmentContext } from '../environment-provider/enviroment-provider-context.svelte.js';
2
3
  import { getLocaleContext } from '../locale-provider/local-provider-context.svelte.js';
3
4
  import { mergeProps } from '../merge-props.js';
4
5
  import * as dialog from '@zag-js/dialog';
5
6
  import { normalizeProps, reflect, useMachine } from '@zag-js/svelte';
6
- import { uid } from 'uid';
7
7
  import { parts } from './drawer-anatomy.js';
8
8
  export function createDrawer(props) {
9
9
  const locale = getLocaleContext();
10
10
  const environment = getEnvironmentContext();
11
- const id = uid();
11
+ const id = createUniqueId();
12
12
  const context = reflect(() => ({
13
13
  id,
14
14
  dir: locale?.dir,
15
15
  role: 'dialog',
16
- ...props,
17
16
  getRootNode: environment?.getRootNode,
18
17
  'open.controlled': props.openControlled,
18
+ ...props,
19
19
  }));
20
20
  const [state, send] = useMachine(dialog.machine(context), { context });
21
21
  return reflect(() => {
@@ -1,14 +1,14 @@
1
+ import { createUniqueId } from '../create-unique-id.js';
1
2
  import { getEnvironmentContext } from '../environment-provider/enviroment-provider-context.svelte.js';
2
3
  import { getFieldContext } from '../field/field-context.svelte.js';
3
4
  import { getLocaleContext } from '../locale-provider/local-provider-context.svelte.js';
4
5
  import * as editable from '@zag-js/editable';
5
6
  import { normalizeProps, reflect, useMachine } from '@zag-js/svelte';
6
- import { uid } from 'uid';
7
7
  export function createEditable(props) {
8
8
  const field = getFieldContext();
9
9
  const locale = getLocaleContext();
10
10
  const environment = getEnvironmentContext();
11
- const id = uid();
11
+ const id = createUniqueId();
12
12
  const context = reflect(() => ({
13
13
  id,
14
14
  ids: {
@@ -20,9 +20,9 @@ export function createEditable(props) {
20
20
  disabled: field?.disabled,
21
21
  readOnly: field?.readOnly,
22
22
  required: field?.required,
23
- ...props,
24
23
  getRootNode: environment?.getRootNode,
25
24
  'edit.controlled': props.editControlled,
25
+ ...props,
26
26
  }));
27
27
  const [state, send] = useMachine(editable.machine(context), { context });
28
28
  return reflect(() => {
@@ -1,11 +1,11 @@
1
+ import { createUniqueId } from '../create-unique-id.js';
1
2
  import { getEnvironmentContext } from '../environment-provider/enviroment-provider-context.svelte.js';
2
3
  import { ariaAttr, dataAttr, getDocument, getWindow } from '@zag-js/dom-query';
3
4
  import { reflect } from '@zag-js/svelte';
4
- import { uid } from 'uid';
5
5
  import { parts } from './field-anatomy.js';
6
6
  export function createField(props) {
7
7
  const environment = getEnvironmentContext();
8
- const id_ = uid();
8
+ const id_ = createUniqueId();
9
9
  const {
10
10
  /**/
11
11
  ids, invalid, disabled, required, readOnly, } = $derived.by(() => {
@@ -37,19 +37,6 @@ export function createField(props) {
37
37
  }
38
38
  return l.join(' ');
39
39
  });
40
- $effect(() => {
41
- const rootNode = environment?.getRootNode() ?? document;
42
- const doc = getDocument(rootNode);
43
- const win = getWindow(rootNode);
44
- function handler() {
45
- hasErrorText = invalid && doc.getElementById(ids.errorText) !== null;
46
- hasHelperText = doc.getElementById(ids.helperText) !== null;
47
- }
48
- handler();
49
- const observer = new win.MutationObserver(handler);
50
- observer.observe(rootNode, { childList: true, subtree: true });
51
- return () => observer.disconnect();
52
- });
53
40
  function getRootProps() {
54
41
  return {
55
42
  ...parts.root.attrs,
@@ -72,6 +59,16 @@ export function createField(props) {
72
59
  'data-readonly': dataAttr(readOnly),
73
60
  };
74
61
  }
62
+ function getRequiredIndicatorProps() {
63
+ return {
64
+ ...parts.requiredIndicator.attrs,
65
+ hidden: !required,
66
+ 'aria-hidden': true,
67
+ 'data-invalid': dataAttr(invalid),
68
+ 'data-disabled': dataAttr(disabled),
69
+ 'data-readonly': dataAttr(readOnly),
70
+ };
71
+ }
75
72
  function getErrorTextProps() {
76
73
  return {
77
74
  ...parts.errorText.attrs,
@@ -94,60 +91,55 @@ export function createField(props) {
94
91
  'data-readonly': dataAttr(readOnly),
95
92
  };
96
93
  }
97
- function getInputProps() {
94
+ function getControlProps() {
98
95
  return {
99
- ...parts.input.attrs,
100
96
  id: ids.control,
101
97
  disabled,
102
98
  required,
103
- readonly: readOnly,
104
- 'aria-invalid': ariaAttr(invalid),
105
99
  'aria-describedby': ariaDescribedby,
100
+ 'aria-invalid': ariaAttr(invalid),
101
+ 'aria-disabled': ariaAttr(disabled),
102
+ 'aria-required': ariaAttr(required),
103
+ 'aria-readonly': ariaAttr(readOnly),
106
104
  'data-invalid': dataAttr(invalid),
107
105
  'data-disabled': dataAttr(disabled),
108
106
  'data-required': dataAttr(required),
109
107
  'data-readonly': dataAttr(readOnly),
110
108
  };
111
109
  }
112
- function getSelectProps() {
110
+ function getInputProps() {
113
111
  return {
114
- ...parts.select.attrs,
115
- id: ids.control,
116
- disabled,
117
- required,
118
- 'aria-invalid': ariaAttr(invalid),
119
- 'aria-readonly': ariaAttr(readOnly),
120
- 'aria-describedby': ariaDescribedby,
121
- 'data-invalid': dataAttr(invalid),
122
- 'data-disabled': dataAttr(disabled),
123
- 'data-required': dataAttr(required),
124
- 'data-readonly': dataAttr(readOnly),
112
+ readonly: readOnly,
113
+ ...getControlProps(),
114
+ ...parts.input.attrs,
125
115
  };
126
116
  }
127
117
  function getTextareaProps() {
128
118
  return {
129
- ...parts.textarea.attrs,
130
- id: ids.control,
131
- disabled,
132
- required,
133
119
  readonly: readOnly,
134
- 'aria-describedby': ariaDescribedby,
135
- 'data-invalid': dataAttr(invalid),
136
- 'data-disabled': dataAttr(disabled),
137
- 'data-required': dataAttr(required),
138
- 'data-readonly': dataAttr(readOnly),
120
+ ...getControlProps(),
121
+ ...parts.textarea.attrs,
139
122
  };
140
123
  }
141
- function getRequiredIndicatorProps() {
124
+ function getSelectProps() {
142
125
  return {
143
- ...parts.requiredIndicator.attrs,
144
- hidden: !required,
145
- 'aria-hidden': true,
146
- 'data-invalid': dataAttr(invalid),
147
- 'data-disabled': dataAttr(disabled),
148
- 'data-readonly': dataAttr(readOnly),
126
+ ...getControlProps(),
127
+ ...parts.select.attrs,
149
128
  };
150
129
  }
130
+ $effect(() => {
131
+ const rootNode = environment?.getRootNode() ?? document;
132
+ const doc = getDocument(rootNode);
133
+ const win = getWindow(rootNode);
134
+ function handler() {
135
+ hasErrorText = invalid && doc.getElementById(ids.errorText) !== null;
136
+ hasHelperText = doc.getElementById(ids.helperText) !== null;
137
+ }
138
+ handler();
139
+ const observer = new win.MutationObserver(handler);
140
+ observer.observe(rootNode, { childList: true, subtree: true });
141
+ return () => observer.disconnect();
142
+ });
151
143
  return reflect(() => ({
152
144
  ids,
153
145
  disabled,
@@ -1,27 +1,27 @@
1
+ import { createUniqueId } from '../create-unique-id.js';
1
2
  import { getEnvironmentContext } from '../environment-provider/enviroment-provider-context.svelte.js';
2
3
  import { getFieldContext } from '../field/field-context.svelte.js';
3
4
  import { getLocaleContext } from '../locale-provider/local-provider-context.svelte.js';
4
5
  import * as fileUpload from '@zag-js/file-upload';
5
6
  import { normalizeProps, reflect, useMachine } from '@zag-js/svelte';
6
- import { uid } from 'uid';
7
7
  export function createFileUpload(props) {
8
8
  const field = getFieldContext();
9
9
  const locale = getLocaleContext();
10
10
  const environment = getEnvironmentContext();
11
- const id = uid();
11
+ const id = createUniqueId();
12
12
  const context = reflect(() => ({
13
+ id,
14
+ dir: locale?.dir,
13
15
  ids: {
14
16
  label: field?.ids.label,
15
17
  hiddenInput: field?.ids.control,
16
18
  },
19
+ locale: locale?.locale,
17
20
  invalid: field?.invalid,
18
21
  disabled: field?.disabled,
19
22
  required: field?.required,
20
- ...props,
21
- id: props.id ?? id,
22
- dir: locale?.dir,
23
- locale: props.locale ?? locale?.locale,
24
23
  getRootNode: environment?.getRootNode,
24
+ ...props,
25
25
  }));
26
26
  const [state, send] = useMachine(fileUpload.machine(context), { context });
27
27
  return reflect(() => {
@@ -1,17 +1,17 @@
1
+ import { createUniqueId } from '../create-unique-id.js';
1
2
  import { getEnvironmentContext } from '../environment-provider/enviroment-provider-context.svelte.js';
2
3
  import { getLocaleContext } from '../locale-provider/local-provider-context.svelte.js';
3
4
  import * as floatingPanel from '@zag-js/floating-panel';
4
5
  import { normalizeProps, reflect, useMachine } from '@zag-js/svelte';
5
- import { uid } from 'uid';
6
6
  export function createFloatingPanel(props) {
7
7
  const locale = getLocaleContext();
8
8
  const environment = getEnvironmentContext();
9
- const id = uid();
9
+ const id = createUniqueId();
10
10
  const context = reflect(() => ({
11
- ...props,
12
- id: props.id ?? id,
11
+ id,
13
12
  dir: locale?.dir,
14
13
  getRootNode: environment?.getRootNode,
14
+ ...props,
15
15
  }));
16
16
  const [state, send] = useMachine(floatingPanel.machine(context), { context });
17
17
  return reflect(() => floatingPanel.connect(state, send, normalizeProps));
@@ -1,18 +1,18 @@
1
+ import { createUniqueId } from '../create-unique-id.js';
1
2
  import { getEnvironmentContext } from '../environment-provider/enviroment-provider-context.svelte.js';
2
3
  import { getLocaleContext } from '../locale-provider/local-provider-context.svelte.js';
3
4
  import * as hoverCard from '@zag-js/hover-card';
4
5
  import { normalizeProps, reflect, useMachine } from '@zag-js/svelte';
5
- import { uid } from 'uid';
6
6
  export function createHoverCard(props) {
7
7
  const locale = getLocaleContext();
8
8
  const environment = getEnvironmentContext();
9
- const id = uid();
9
+ const id = createUniqueId();
10
10
  const context = reflect(() => ({
11
11
  id,
12
12
  dir: locale?.dir,
13
- ...props,
14
13
  getRootNode: environment?.getRootNode,
15
14
  'open.controlled': props.openControlled,
15
+ ...props,
16
16
  }));
17
17
  const [state, send] = useMachine(hoverCard.machine(context), { context });
18
18
  return reflect(() => hoverCard.connect(state, send, normalizeProps));
package/dist/index.d.ts CHANGED
@@ -21,7 +21,6 @@ export * from './highlight/index.js';
21
21
  export * from './hover-card/index.js';
22
22
  export * from './locale-provider/index.js';
23
23
  export * from './menu/index.js';
24
- export * from './merge-props.js';
25
24
  export * from './number-input/index.js';
26
25
  export * from './pagination/index.js';
27
26
  export * from './pin-input/index.js';
@@ -49,3 +48,6 @@ export * from './toggle/index.js';
49
48
  export * from './tooltip/index.js';
50
49
  export * from './tour/index.js';
51
50
  export * from './tree-view/index.js';
51
+ export * from './create-context.svelte.js';
52
+ export * from './create-unique-id.js';
53
+ export * from './merge-props.js';
package/dist/index.js CHANGED
@@ -21,7 +21,6 @@ export * from './highlight/index.js';
21
21
  export * from './hover-card/index.js';
22
22
  export * from './locale-provider/index.js';
23
23
  export * from './menu/index.js';
24
- export * from './merge-props.js';
25
24
  export * from './number-input/index.js';
26
25
  export * from './pagination/index.js';
27
26
  export * from './pin-input/index.js';
@@ -49,3 +48,6 @@ export * from './toggle/index.js';
49
48
  export * from './tooltip/index.js';
50
49
  export * from './tour/index.js';
51
50
  export * from './tree-view/index.js';
51
+ export * from './create-context.svelte.js';
52
+ export * from './create-unique-id.js';
53
+ export * from './merge-props.js';
@@ -1,18 +1,18 @@
1
+ import { createUniqueId } from '../create-unique-id.js';
1
2
  import { getEnvironmentContext } from '../environment-provider/enviroment-provider-context.svelte.js';
2
3
  import { getLocaleContext } from '../locale-provider/local-provider-context.svelte.js';
3
4
  import * as menu from '@zag-js/menu';
4
5
  import { normalizeProps, reflect, useMachine } from '@zag-js/svelte';
5
- import { uid } from 'uid';
6
6
  export function createMenu(props) {
7
7
  const locale = getLocaleContext();
8
8
  const environment = getEnvironmentContext();
9
- const id = uid();
9
+ const id = createUniqueId();
10
10
  const context = reflect(() => ({
11
11
  id,
12
12
  dir: locale?.dir,
13
- ...props,
14
13
  getRootNode: environment?.getRootNode,
15
14
  'open.controlled': props.openControlled,
15
+ ...props,
16
16
  }));
17
17
  const [state, send, machine] = useMachine(menu.machine(context), { context });
18
18
  return reflect(() => ({
@@ -6,8 +6,8 @@
6
6
  </script>
7
7
 
8
8
  <script lang="ts">
9
+ import {createUniqueId} from '../create-unique-id.js';
9
10
  import {mergeProps} from '../merge-props.js';
10
- import {uid} from 'uid';
11
11
  import {
12
12
  getMenuContext,
13
13
  setMenuItemGroupPropsContext,
@@ -23,7 +23,7 @@
23
23
 
24
24
  let menu = getMenuContext();
25
25
 
26
- let id_ = uid();
26
+ let id_ = createUniqueId();
27
27
 
28
28
  let itemGroupProps = $derived({
29
29
  id: id ?? id_,