@ark-ui/solid 3.0.0-4 → 3.0.0-5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +290 -215
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +292 -217
- package/dist/esm/index.js.map +1 -1
- package/dist/source/components/accordion/accordion-item-content.jsx +7 -2
- package/dist/source/components/accordion/accordion-root.jsx +1 -0
- package/dist/source/components/accordion/use-accordion.js +12 -3
- package/dist/source/components/avatar/use-avatar.js +9 -3
- package/dist/source/components/carousel/carousel-root.jsx +1 -0
- package/dist/source/components/carousel/use-carousel.js +10 -3
- package/dist/source/components/checkbox/checkbox-root.jsx +1 -0
- package/dist/source/components/checkbox/use-checkbox.js +10 -3
- package/dist/source/components/clipboard/use-clipboard.js +8 -3
- package/dist/source/components/collapsible/collapsible-root.jsx +1 -0
- package/dist/source/components/collapsible/use-collapsible.js +8 -5
- package/dist/source/components/color-picker/color-picker-root.jsx +2 -0
- package/dist/source/components/color-picker/use-color-picker.js +14 -8
- package/dist/source/components/combobox/combobox-root.jsx +4 -2
- package/dist/source/components/combobox/combobox-trigger.jsx +3 -1
- package/dist/source/components/combobox/use-combobox.js +12 -10
- package/dist/source/components/date-picker/date-picker-root.jsx +2 -0
- package/dist/source/components/date-picker/use-date-picker.js +17 -11
- package/dist/source/components/dialog/dialog-root.jsx +2 -0
- package/dist/source/components/dialog/use-dialog.js +8 -5
- package/dist/source/components/editable/editable-root.jsx +1 -0
- package/dist/source/components/editable/use-editable.js +10 -3
- package/dist/source/components/file-upload/use-file-upload.js +9 -3
- package/dist/source/components/hover-card/hover-card-root.jsx +1 -0
- package/dist/source/components/hover-card/use-hover-card.js +8 -5
- package/dist/source/components/menu/menu-root.jsx +2 -0
- package/dist/source/components/menu/use-menu.js +8 -5
- package/dist/source/components/number-input/number-input-root.jsx +1 -0
- package/dist/source/components/number-input/use-number-input.js +10 -3
- package/dist/source/components/pagination/pagination-root.jsx +1 -0
- package/dist/source/components/pagination/use-pagination.js +10 -3
- package/dist/source/components/pin-input/pin-input-root.jsx +1 -0
- package/dist/source/components/pin-input/use-pin-input.js +10 -3
- package/dist/source/components/popover/popover-root.jsx +3 -1
- package/dist/source/components/popover/use-popover.js +8 -5
- package/dist/source/components/progress/use-progress.js +9 -3
- package/dist/source/components/radio-group/radio-group-root.jsx +1 -0
- package/dist/source/components/radio-group/use-radio-group.js +10 -3
- package/dist/source/components/rating-group/rating-group-root.jsx +1 -0
- package/dist/source/components/rating-group/use-rating-group.js +10 -3
- package/dist/source/components/segment-group/segment-group-root.jsx +1 -0
- package/dist/source/components/segment-group/use-segment-group.js +12 -5
- package/dist/source/components/select/select-item.jsx +1 -1
- package/dist/source/components/select/select-root.jsx +3 -0
- package/dist/source/components/select/use-select.js +12 -10
- package/dist/source/components/slider/slider-root.jsx +1 -0
- package/dist/source/components/slider/use-slider.js +10 -3
- package/dist/source/components/splitter/splitter-root.jsx +1 -0
- package/dist/source/components/splitter/use-splitter.js +10 -3
- package/dist/source/components/switch/switch-root.jsx +1 -0
- package/dist/source/components/switch/use-switch.js +10 -3
- package/dist/source/components/tabs/tabs-root.jsx +2 -0
- package/dist/source/components/tabs/use-tabs.js +10 -3
- package/dist/source/components/tags-input/tags-input-root.jsx +1 -0
- package/dist/source/components/tags-input/use-tags-input.js +10 -3
- package/dist/source/components/toggle-group/toggle-group-root.jsx +1 -0
- package/dist/source/components/toggle-group/use-toggle-group.js +10 -3
- package/dist/source/components/tooltip/tooltip-root.jsx +2 -1
- package/dist/source/components/tooltip/use-tooltip.js +8 -5
- package/dist/source/components/tree-view/tree-view-root.jsx +3 -1
- package/dist/source/components/tree-view/use-tree-view.js +11 -3
- package/dist/source/providers/locale/locale-provider.jsx +5 -19
- package/dist/types/components/accordion/accordion-item.d.ts +1 -2
- package/dist/types/components/accordion/use-accordion.d.ts +5 -0
- package/dist/types/components/carousel/use-carousel.d.ts +5 -0
- package/dist/types/components/checkbox/use-checkbox.d.ts +5 -0
- package/dist/types/components/collapsible/use-collapsible.d.ts +5 -0
- package/dist/types/components/color-picker/use-color-picker.d.ts +10 -0
- package/dist/types/components/combobox/combobox-trigger.d.ts +3 -1
- package/dist/types/components/combobox/use-combobox.d.ts +10 -0
- package/dist/types/components/date-picker/use-date-picker.d.ts +14 -4
- package/dist/types/components/dialog/use-dialog.d.ts +5 -0
- package/dist/types/components/editable/use-editable.d.ts +5 -0
- package/dist/types/components/hover-card/use-hover-card.d.ts +5 -0
- package/dist/types/components/menu/use-menu.d.ts +5 -0
- package/dist/types/components/number-input/use-number-input.d.ts +5 -0
- package/dist/types/components/pagination/use-pagination.d.ts +5 -0
- package/dist/types/components/pin-input/use-pin-input.d.ts +5 -0
- package/dist/types/components/popover/use-popover.d.ts +5 -0
- package/dist/types/components/radio-group/use-radio-group.d.ts +5 -0
- package/dist/types/components/rating-group/use-rating-group.d.ts +5 -0
- package/dist/types/components/segment-group/use-segment-group.d.ts +8 -3
- package/dist/types/components/select/use-select.d.ts +10 -0
- package/dist/types/components/slider/use-slider.d.ts +5 -0
- package/dist/types/components/splitter/use-splitter.d.ts +5 -0
- package/dist/types/components/switch/use-switch.d.ts +5 -0
- package/dist/types/components/tabs/use-tabs.d.ts +5 -0
- package/dist/types/components/tags-input/use-tags-input.d.ts +5 -0
- package/dist/types/components/toggle-group/use-toggle-group.d.ts +5 -0
- package/dist/types/components/tooltip/use-tooltip.d.ts +5 -0
- package/dist/types/components/tree-view/use-tree-view.d.ts +10 -0
- package/dist/types/providers/locale/locale-provider.d.ts +3 -5
- package/package.json +46 -46
- /package/dist/source/providers/locale/{use-locale-context.jsx → use-locale-context.js} +0 -0
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import * as pinInput from '@zag-js/pin-input';
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeProps, useMachine } from '@zag-js/solid';
|
|
3
3
|
import { createMemo, createUniqueId } from 'solid-js';
|
|
4
4
|
import { useEnvironmentContext, useLocaleContext } from '../../providers';
|
|
5
5
|
export const usePinInput = (props) => {
|
|
6
6
|
const locale = useLocaleContext();
|
|
7
7
|
const environment = useEnvironmentContext();
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const id = createUniqueId();
|
|
9
|
+
const context = createMemo(() => ({
|
|
10
|
+
id,
|
|
11
|
+
dir: locale().dir,
|
|
12
|
+
getRootNode: environment().getRootNode,
|
|
13
|
+
value: props.defaultValue,
|
|
14
|
+
...props,
|
|
15
|
+
}));
|
|
16
|
+
const [state, send] = useMachine(pinInput.machine(context()), { context });
|
|
10
17
|
return createMemo(() => pinInput.connect(state, send, normalizeProps));
|
|
11
18
|
};
|
|
@@ -7,8 +7,9 @@ export const PopoverRoot = (props) => {
|
|
|
7
7
|
const [presenceProps, popoverProps] = splitPresenceProps(props);
|
|
8
8
|
const [usePopoverProps, localProps] = createSplitProps()(popoverProps, [
|
|
9
9
|
'autoFocus',
|
|
10
|
-
'
|
|
10
|
+
'closeOnEscape',
|
|
11
11
|
'closeOnInteractOutside',
|
|
12
|
+
'defaultOpen',
|
|
12
13
|
'id',
|
|
13
14
|
'ids',
|
|
14
15
|
'initialFocusEl',
|
|
@@ -19,6 +20,7 @@ export const PopoverRoot = (props) => {
|
|
|
19
20
|
'onOpenChange',
|
|
20
21
|
'onPointerDownOutside',
|
|
21
22
|
'open',
|
|
23
|
+
'persistentElements',
|
|
22
24
|
'portalled',
|
|
23
25
|
'positioning',
|
|
24
26
|
]);
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import * as popover from '@zag-js/popover';
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeProps, useMachine } from '@zag-js/solid';
|
|
3
3
|
import { createMemo, createUniqueId } from 'solid-js';
|
|
4
4
|
import { useEnvironmentContext, useLocaleContext } from '../../providers';
|
|
5
5
|
export const usePopover = (props) => {
|
|
6
6
|
const locale = useLocaleContext();
|
|
7
7
|
const environment = useEnvironmentContext();
|
|
8
|
-
const
|
|
9
|
-
|
|
8
|
+
const id = createUniqueId();
|
|
9
|
+
const context = createMemo(() => ({
|
|
10
|
+
id,
|
|
10
11
|
dir: locale().dir,
|
|
11
12
|
getRootNode: environment().getRootNode,
|
|
13
|
+
open: props.defaultOpen,
|
|
12
14
|
'open.controlled': props.open !== undefined,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
...props,
|
|
16
|
+
}));
|
|
17
|
+
const [state, send] = useMachine(popover.machine(context()), { context });
|
|
15
18
|
return createMemo(() => popover.connect(state, send, normalizeProps));
|
|
16
19
|
};
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import * as progress from '@zag-js/progress';
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeProps, useMachine } from '@zag-js/solid';
|
|
3
3
|
import { createMemo, createUniqueId } from 'solid-js';
|
|
4
4
|
import { useEnvironmentContext, useLocaleContext } from '../../providers';
|
|
5
5
|
export const useProgress = (props) => {
|
|
6
6
|
const locale = useLocaleContext();
|
|
7
7
|
const environment = useEnvironmentContext();
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const id = createUniqueId();
|
|
9
|
+
const context = createMemo(() => ({
|
|
10
|
+
id,
|
|
11
|
+
dir: locale().dir,
|
|
12
|
+
getRootNode: environment().getRootNode,
|
|
13
|
+
...props,
|
|
14
|
+
}));
|
|
15
|
+
const [state, send] = useMachine(progress.machine(context()), { context });
|
|
10
16
|
return createMemo(() => progress.connect(state, send, normalizeProps));
|
|
11
17
|
};
|
|
@@ -5,6 +5,7 @@ import { useRadioGroup } from './use-radio-group';
|
|
|
5
5
|
import { RadioGroupProvider } from './use-radio-group-context';
|
|
6
6
|
export const RadioGroupRoot = (props) => {
|
|
7
7
|
const [useRadioGroupProps, localProps] = createSplitProps()(props, [
|
|
8
|
+
'defaultValue',
|
|
8
9
|
'disabled',
|
|
9
10
|
'form',
|
|
10
11
|
'id',
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import * as radio from '@zag-js/radio-group';
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeProps, useMachine } from '@zag-js/solid';
|
|
3
3
|
import { createMemo, createUniqueId } from 'solid-js';
|
|
4
4
|
import { useEnvironmentContext, useLocaleContext } from '../../providers';
|
|
5
5
|
export const useRadioGroup = (props) => {
|
|
6
6
|
const locale = useLocaleContext();
|
|
7
7
|
const environment = useEnvironmentContext();
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const id = createUniqueId();
|
|
9
|
+
const context = createMemo(() => ({
|
|
10
|
+
id,
|
|
11
|
+
dir: locale().dir,
|
|
12
|
+
getRootNode: environment().getRootNode,
|
|
13
|
+
value: props.defaultValue,
|
|
14
|
+
...props,
|
|
15
|
+
}));
|
|
16
|
+
const [state, send] = useMachine(radio.machine(context()), {
|
|
10
17
|
context,
|
|
11
18
|
});
|
|
12
19
|
return createMemo(() => radio.connect(state, send, normalizeProps));
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import * as rating from '@zag-js/rating-group';
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeProps, useMachine } from '@zag-js/solid';
|
|
3
3
|
import { createMemo, createUniqueId } from 'solid-js';
|
|
4
4
|
import { useEnvironmentContext, useLocaleContext } from '../../providers';
|
|
5
5
|
export const useRatingGroup = (props) => {
|
|
6
6
|
const locale = useLocaleContext();
|
|
7
7
|
const environment = useEnvironmentContext();
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const id = createUniqueId();
|
|
9
|
+
const context = createMemo(() => ({
|
|
10
|
+
id,
|
|
11
|
+
dir: locale().dir,
|
|
12
|
+
getRootNode: environment().getRootNode,
|
|
13
|
+
value: props.defaultValue,
|
|
14
|
+
...props,
|
|
15
|
+
}));
|
|
16
|
+
const [state, send] = useMachine(rating.machine(context()), { context });
|
|
10
17
|
return createMemo(() => rating.connect(state, send, normalizeProps));
|
|
11
18
|
};
|
|
@@ -6,6 +6,7 @@ import { useSegmentGroup } from './use-segment-group';
|
|
|
6
6
|
import { SegmentGroupProvider } from './use-segment-group-context';
|
|
7
7
|
export const SegmentGroupRoot = (props) => {
|
|
8
8
|
const [useSegmentGroupProps, localProps] = createSplitProps()(props, [
|
|
9
|
+
'defaultValue',
|
|
9
10
|
'disabled',
|
|
10
11
|
'form',
|
|
11
12
|
'id',
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import {
|
|
1
|
+
import * as segmentGroup from '@zag-js/radio-group';
|
|
2
|
+
import { normalizeProps, useMachine } from '@zag-js/solid';
|
|
3
3
|
import { createMemo, createUniqueId } from 'solid-js';
|
|
4
4
|
import { useEnvironmentContext, useLocaleContext } from '../../providers';
|
|
5
5
|
export const useSegmentGroup = (props) => {
|
|
6
6
|
const locale = useLocaleContext();
|
|
7
7
|
const environment = useEnvironmentContext();
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
8
|
+
const id = createUniqueId();
|
|
9
|
+
const context = createMemo(() => ({
|
|
10
|
+
id,
|
|
11
|
+
dir: locale().dir,
|
|
12
|
+
getRootNode: environment().getRootNode,
|
|
13
|
+
value: props.defaultValue,
|
|
14
|
+
...props,
|
|
15
|
+
}));
|
|
16
|
+
const [state, send] = useMachine(segmentGroup.machine(context()), { context });
|
|
17
|
+
return createMemo(() => segmentGroup.connect(state, send, normalizeProps));
|
|
11
18
|
};
|
|
@@ -6,7 +6,7 @@ import { useSelectContext } from './use-select-context';
|
|
|
6
6
|
import { SelectItemProvider } from './use-select-item-context';
|
|
7
7
|
import { SelectItemPropsProvider } from './use-select-item-props-context';
|
|
8
8
|
export const SelectItem = (props) => {
|
|
9
|
-
const [itemProps, localProps] = createSplitProps()(props, ['item']);
|
|
9
|
+
const [itemProps, localProps] = createSplitProps()(props, ['item', 'persistFocus']);
|
|
10
10
|
const select = useSelectContext();
|
|
11
11
|
const mergedProps = mergeProps(() => select().getItemProps(itemProps), localProps);
|
|
12
12
|
const itemState = createMemo(() => select().getItemState(itemProps));
|
|
@@ -8,6 +8,9 @@ export const SelectRoot = (props) => {
|
|
|
8
8
|
const [presenceProps, selectProps] = splitPresenceProps(props);
|
|
9
9
|
const [useSelectProps, localProps] = createSplitProps()(selectProps, [
|
|
10
10
|
'closeOnSelect',
|
|
11
|
+
'composite',
|
|
12
|
+
'defaultOpen',
|
|
13
|
+
'defaultValue',
|
|
11
14
|
'disabled',
|
|
12
15
|
'form',
|
|
13
16
|
'highlightedValue',
|
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
import * as select from '@zag-js/select';
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeProps, useMachine } from '@zag-js/solid';
|
|
3
3
|
import { createMemo, createUniqueId } from 'solid-js';
|
|
4
4
|
import { useEnvironmentContext, useLocaleContext } from '../../providers';
|
|
5
5
|
import { createSplitProps } from '../../utils/create-split-props';
|
|
6
6
|
export const useSelect = (props) => {
|
|
7
|
-
const [collectionOptions,
|
|
7
|
+
const [collectionOptions, selectProps] = createSplitProps()(props, [
|
|
8
8
|
'isItemDisabled',
|
|
9
9
|
'itemToValue',
|
|
10
10
|
'itemToString',
|
|
11
11
|
'items',
|
|
12
12
|
]);
|
|
13
|
-
const collection =
|
|
13
|
+
const collection = () => select.collection(collectionOptions);
|
|
14
14
|
const locale = useLocaleContext();
|
|
15
15
|
const environment = useEnvironmentContext();
|
|
16
|
-
const
|
|
17
|
-
|
|
16
|
+
const id = createUniqueId();
|
|
17
|
+
const context = createMemo(() => ({
|
|
18
|
+
id,
|
|
19
|
+
collection: collection(),
|
|
18
20
|
dir: locale().dir,
|
|
19
21
|
getRootNode: environment().getRootNode,
|
|
22
|
+
open: props.defaultOpen,
|
|
23
|
+
value: props.defaultValue,
|
|
20
24
|
'open.controlled': props.open !== undefined,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}, localProps);
|
|
25
|
-
const [state, send] = useMachine(select.machine(context), {
|
|
25
|
+
...selectProps,
|
|
26
|
+
}));
|
|
27
|
+
const [state, send] = useMachine(select.machine(context()), {
|
|
26
28
|
context,
|
|
27
29
|
});
|
|
28
30
|
return createMemo(() => select.connect(state, send, normalizeProps));
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import * as slider from '@zag-js/slider';
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeProps, useMachine } from '@zag-js/solid';
|
|
3
3
|
import { createMemo, createUniqueId } from 'solid-js';
|
|
4
4
|
import { useEnvironmentContext, useLocaleContext } from '../../providers';
|
|
5
5
|
export const useSlider = (props) => {
|
|
6
6
|
const locale = useLocaleContext();
|
|
7
7
|
const environment = useEnvironmentContext();
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const id = createUniqueId();
|
|
9
|
+
const context = createMemo(() => ({
|
|
10
|
+
id,
|
|
11
|
+
dir: locale().dir,
|
|
12
|
+
getRootNode: environment().getRootNode,
|
|
13
|
+
value: props.defaultValue,
|
|
14
|
+
...props,
|
|
15
|
+
}));
|
|
16
|
+
const [state, send] = useMachine(slider.machine(context()), { context });
|
|
10
17
|
return createMemo(() => slider.connect(state, send, normalizeProps));
|
|
11
18
|
};
|
|
@@ -5,6 +5,7 @@ import { useSplitter } from './use-splitter';
|
|
|
5
5
|
import { SplitterProvider } from './use-splitter-context';
|
|
6
6
|
export const SplitterRoot = (props) => {
|
|
7
7
|
const [useSplitterProps, localProps] = createSplitProps()(props, [
|
|
8
|
+
'defaultSize',
|
|
8
9
|
'id',
|
|
9
10
|
'ids',
|
|
10
11
|
'onSizeChange',
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizeProps, useMachine } from '@zag-js/solid';
|
|
2
2
|
import * as splitter from '@zag-js/splitter';
|
|
3
3
|
import { createMemo, createUniqueId } from 'solid-js';
|
|
4
4
|
import { useEnvironmentContext, useLocaleContext } from '../../providers';
|
|
5
5
|
export const useSplitter = (props) => {
|
|
6
6
|
const locale = useLocaleContext();
|
|
7
7
|
const environment = useEnvironmentContext();
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const id = createUniqueId();
|
|
9
|
+
const context = createMemo(() => ({
|
|
10
|
+
id,
|
|
11
|
+
dir: locale().dir,
|
|
12
|
+
getRootNode: environment().getRootNode,
|
|
13
|
+
size: props.defaultSize,
|
|
14
|
+
...props,
|
|
15
|
+
}));
|
|
16
|
+
const [state, send] = useMachine(splitter.machine(context()), { context });
|
|
10
17
|
return createMemo(() => splitter.connect(state, send, normalizeProps));
|
|
11
18
|
};
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizeProps, useMachine } from '@zag-js/solid';
|
|
2
2
|
import * as zagSwitch from '@zag-js/switch';
|
|
3
3
|
import { createMemo, createUniqueId } from 'solid-js';
|
|
4
4
|
import { useEnvironmentContext, useLocaleContext } from '../../providers';
|
|
5
5
|
export const useSwitch = (props) => {
|
|
6
6
|
const locale = useLocaleContext();
|
|
7
7
|
const environment = useEnvironmentContext();
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const id = createUniqueId();
|
|
9
|
+
const context = createMemo(() => ({
|
|
10
|
+
id,
|
|
11
|
+
dir: locale().dir,
|
|
12
|
+
getRootNode: environment().getRootNode,
|
|
13
|
+
checked: props.defaultChecked,
|
|
14
|
+
...props,
|
|
15
|
+
}));
|
|
16
|
+
const [state, send] = useMachine(zagSwitch.machine(context()), { context });
|
|
10
17
|
return createMemo(() => zagSwitch.connect(state, send, normalizeProps));
|
|
11
18
|
};
|
|
@@ -8,6 +8,8 @@ export const TabsRoot = (props) => {
|
|
|
8
8
|
const [renderStrategyProps, tabsProps] = splitRenderStrategyProps(props);
|
|
9
9
|
const [useTabsProps, restProps] = createSplitProps()(tabsProps, [
|
|
10
10
|
'activationMode',
|
|
11
|
+
'composite',
|
|
12
|
+
'defaultValue',
|
|
11
13
|
'id',
|
|
12
14
|
'ids',
|
|
13
15
|
'loopFocus',
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizeProps, useMachine } from '@zag-js/solid';
|
|
2
2
|
import * as tabs from '@zag-js/tabs';
|
|
3
3
|
import { createMemo, createUniqueId } from 'solid-js';
|
|
4
4
|
import { useEnvironmentContext, useLocaleContext } from '../../providers';
|
|
5
5
|
export const useTabs = (props) => {
|
|
6
6
|
const locale = useLocaleContext();
|
|
7
7
|
const environment = useEnvironmentContext();
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const id = createUniqueId();
|
|
9
|
+
const context = createMemo(() => ({
|
|
10
|
+
id,
|
|
11
|
+
dir: locale().dir,
|
|
12
|
+
getRootNode: environment().getRootNode,
|
|
13
|
+
value: props.defaultValue,
|
|
14
|
+
...props,
|
|
15
|
+
}));
|
|
16
|
+
const [state, send] = useMachine(tabs.machine(context()), { context });
|
|
10
17
|
return createMemo(() => tabs.connect(state, send, normalizeProps));
|
|
11
18
|
};
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizeProps, useMachine } from '@zag-js/solid';
|
|
2
2
|
import * as tagsInput from '@zag-js/tags-input';
|
|
3
3
|
import { createMemo, createUniqueId } from 'solid-js';
|
|
4
4
|
import { useEnvironmentContext, useLocaleContext } from '../../providers';
|
|
5
5
|
export const useTagsInput = (props) => {
|
|
6
6
|
const locale = useLocaleContext();
|
|
7
7
|
const environment = useEnvironmentContext();
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const id = createUniqueId();
|
|
9
|
+
const context = createMemo(() => ({
|
|
10
|
+
id,
|
|
11
|
+
dir: locale().dir,
|
|
12
|
+
getRootNode: environment().getRootNode,
|
|
13
|
+
value: props.defaultValue,
|
|
14
|
+
...props,
|
|
15
|
+
}));
|
|
16
|
+
const [state, send] = useMachine(tagsInput.machine(context()), { context });
|
|
10
17
|
return createMemo(() => tagsInput.connect(state, send, normalizeProps));
|
|
11
18
|
};
|
|
@@ -5,6 +5,7 @@ import { useToggleGroup } from './use-toggle-group';
|
|
|
5
5
|
import { ToggleGroupProvider } from './use-toggle-group-context';
|
|
6
6
|
export const ToggleGroupRoot = (props) => {
|
|
7
7
|
const [useToggleGroupProps, restProps] = createSplitProps()(props, [
|
|
8
|
+
'defaultValue',
|
|
8
9
|
'disabled',
|
|
9
10
|
'id',
|
|
10
11
|
'ids',
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizeProps, useMachine } from '@zag-js/solid';
|
|
2
2
|
import * as toggleGroup from '@zag-js/toggle-group';
|
|
3
3
|
import { createMemo, createUniqueId } from 'solid-js';
|
|
4
4
|
import { useEnvironmentContext, useLocaleContext } from '../../providers';
|
|
5
5
|
export const useToggleGroup = (props) => {
|
|
6
6
|
const locale = useLocaleContext();
|
|
7
7
|
const environment = useEnvironmentContext();
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const id = createUniqueId();
|
|
9
|
+
const context = createMemo(() => ({
|
|
10
|
+
id,
|
|
11
|
+
dir: locale().dir,
|
|
12
|
+
getRootNode: environment().getRootNode,
|
|
13
|
+
value: props.defaultValue,
|
|
14
|
+
...props,
|
|
15
|
+
}));
|
|
16
|
+
const [state, send] = useMachine(toggleGroup.machine(context()), {
|
|
10
17
|
context,
|
|
11
18
|
});
|
|
12
19
|
return createMemo(() => toggleGroup.connect(state, send, normalizeProps));
|
|
@@ -8,8 +8,9 @@ export const TooltipRoot = (props) => {
|
|
|
8
8
|
const [useTooltipProps, localProps] = createSplitProps()(tooltipProps, [
|
|
9
9
|
'aria-label',
|
|
10
10
|
'closeDelay',
|
|
11
|
-
'
|
|
11
|
+
'closeOnEscape',
|
|
12
12
|
'closeOnPointerDown',
|
|
13
|
+
'defaultOpen',
|
|
13
14
|
'disabled',
|
|
14
15
|
'id',
|
|
15
16
|
'ids',
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizeProps, useMachine } from '@zag-js/solid';
|
|
2
2
|
import * as tooltip from '@zag-js/tooltip';
|
|
3
3
|
import { createMemo, createUniqueId } from 'solid-js';
|
|
4
4
|
import { useEnvironmentContext, useLocaleContext } from '../../providers';
|
|
5
5
|
export const useTooltip = (props) => {
|
|
6
6
|
const locale = useLocaleContext();
|
|
7
7
|
const environment = useEnvironmentContext();
|
|
8
|
-
const
|
|
9
|
-
|
|
8
|
+
const id = createUniqueId();
|
|
9
|
+
const context = createMemo(() => ({
|
|
10
|
+
id,
|
|
10
11
|
dir: locale().dir,
|
|
11
12
|
getRootNode: environment().getRootNode,
|
|
13
|
+
open: props.defaultOpen,
|
|
12
14
|
'open.controlled': props.open !== undefined,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
...props,
|
|
16
|
+
}));
|
|
17
|
+
const [state, send] = useMachine(tooltip.machine(context()), { context });
|
|
15
18
|
return createMemo(() => tooltip.connect(state, send, normalizeProps));
|
|
16
19
|
};
|
|
@@ -5,14 +5,16 @@ import { useTreeView } from './use-tree-view';
|
|
|
5
5
|
import { TreeViewProvider } from './use-tree-view-context';
|
|
6
6
|
export const TreeViewRoot = (props) => {
|
|
7
7
|
const [useTreeViewProps, localProps] = createSplitProps()(props, [
|
|
8
|
+
'defaultExpandedValue',
|
|
9
|
+
'defaultSelectedValue',
|
|
8
10
|
'expandedValue',
|
|
11
|
+
'expandOnClick',
|
|
9
12
|
'focusedValue',
|
|
10
13
|
'id',
|
|
11
14
|
'ids',
|
|
12
15
|
'onExpandedChange',
|
|
13
16
|
'onFocusChange',
|
|
14
17
|
'onSelectionChange',
|
|
15
|
-
'openOnClick',
|
|
16
18
|
'selectedValue',
|
|
17
19
|
'selectionMode',
|
|
18
20
|
'typeahead',
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizeProps, useMachine } from '@zag-js/solid';
|
|
2
2
|
import * as treeView from '@zag-js/tree-view';
|
|
3
3
|
import { createMemo, createUniqueId } from 'solid-js';
|
|
4
4
|
import { useEnvironmentContext, useLocaleContext } from '../../providers';
|
|
5
5
|
export const useTreeView = (props) => {
|
|
6
6
|
const locale = useLocaleContext();
|
|
7
7
|
const environment = useEnvironmentContext();
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const id = createUniqueId();
|
|
9
|
+
const context = createMemo(() => ({
|
|
10
|
+
id,
|
|
11
|
+
dir: locale().dir,
|
|
12
|
+
getRootNode: environment().getRootNode,
|
|
13
|
+
selectedValue: props.defaultSelectedValue,
|
|
14
|
+
expandedValue: props.defaultExpandedValue,
|
|
15
|
+
...props,
|
|
16
|
+
}));
|
|
17
|
+
const [state, send] = useMachine(treeView.machine(context()), { context });
|
|
10
18
|
return createMemo(() => treeView.connect(state, send, normalizeProps));
|
|
11
19
|
};
|
|
@@ -1,24 +1,10 @@
|
|
|
1
|
-
import { isRTL
|
|
2
|
-
import {
|
|
3
|
-
import { useEnvironmentContext } from '../environment';
|
|
1
|
+
import { isRTL } from '@zag-js/i18n-utils';
|
|
2
|
+
import { createMemo } from 'solid-js';
|
|
4
3
|
import { LocaleContextProvider } from './use-locale-context';
|
|
5
4
|
export const LocaleProvider = (props) => {
|
|
6
|
-
const [localeProps, restProps] = splitProps(props, ['locale', 'defaultLocale']);
|
|
7
|
-
const [locale, setLocale] = createSignal(localeProps.defaultLocale || localeProps.locale || 'en-US');
|
|
8
|
-
const environment = useEnvironmentContext();
|
|
9
|
-
createEffect(() => {
|
|
10
|
-
const cleanup = trackLocale({
|
|
11
|
-
locale: localeProps.locale,
|
|
12
|
-
getRootNode: environment().getRootNode,
|
|
13
|
-
onLocaleChange(locale) {
|
|
14
|
-
setLocale(locale.locale);
|
|
15
|
-
},
|
|
16
|
-
});
|
|
17
|
-
onCleanup(cleanup);
|
|
18
|
-
});
|
|
19
5
|
const context = createMemo(() => ({
|
|
20
|
-
locale: locale
|
|
21
|
-
dir: isRTL(locale
|
|
6
|
+
locale: props.locale,
|
|
7
|
+
dir: isRTL(props.locale) ? 'rtl' : 'ltr',
|
|
22
8
|
}));
|
|
23
|
-
return <LocaleContextProvider value={context}>{
|
|
9
|
+
return <LocaleContextProvider value={context}>{props.children}</LocaleContextProvider>;
|
|
24
10
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { ItemProps } from '@zag-js/accordion';
|
|
2
2
|
import type { Assign } from '../../types';
|
|
3
|
-
import type { UseCollapsibleProps } from '../collapsible/use-collapsible';
|
|
4
3
|
import type { HTMLArkProps } from '../factory';
|
|
5
|
-
export interface AccordionItemProps extends Assign<HTMLArkProps<'div'>,
|
|
4
|
+
export interface AccordionItemProps extends Assign<HTMLArkProps<'div'>, ItemProps> {
|
|
6
5
|
}
|
|
7
6
|
export declare const AccordionItem: (props: AccordionItemProps) => import("solid-js").JSX.Element;
|
|
@@ -3,6 +3,11 @@ import { type PropTypes } from '@zag-js/solid';
|
|
|
3
3
|
import { type Accessor } from 'solid-js';
|
|
4
4
|
import type { Optional } from '../../types';
|
|
5
5
|
export interface UseAccordionProps extends Optional<Omit<accordion.Context, 'dir' | 'getRootNode'>, 'id'> {
|
|
6
|
+
/**
|
|
7
|
+
* The initial value of the accordion when it is first rendered.
|
|
8
|
+
* Use when you do not need to control the state of the color picker.
|
|
9
|
+
*/
|
|
10
|
+
defaultValue?: accordion.Context['value'];
|
|
6
11
|
}
|
|
7
12
|
export interface UseAccordionReturn extends Accessor<accordion.Api<PropTypes>> {
|
|
8
13
|
}
|
|
@@ -3,6 +3,11 @@ import { type PropTypes } from '@zag-js/solid';
|
|
|
3
3
|
import { type Accessor } from 'solid-js';
|
|
4
4
|
import type { Optional } from '../../types';
|
|
5
5
|
export interface UseCarouselProps extends Optional<Omit<carousel.Context, 'dir' | 'getRootNode'>, 'id'> {
|
|
6
|
+
/**
|
|
7
|
+
* The initial index of the carousel when it is first rendered.
|
|
8
|
+
* Use this when you do not need to control the state of the carousel.
|
|
9
|
+
*/
|
|
10
|
+
defaultIndex?: carousel.Context['index'];
|
|
6
11
|
}
|
|
7
12
|
export interface UseCarouselReturn extends Accessor<carousel.Api<PropTypes>> {
|
|
8
13
|
}
|
|
@@ -3,6 +3,11 @@ import { type PropTypes } from '@zag-js/solid';
|
|
|
3
3
|
import { type Accessor } from 'solid-js';
|
|
4
4
|
import type { Optional } from '../../types';
|
|
5
5
|
export interface UseCheckboxProps extends Optional<Omit<checkbox.Context, 'dir' | 'getRootNode'>, 'id'> {
|
|
6
|
+
/**
|
|
7
|
+
* The checked state of the checkbox when it is first rendered.
|
|
8
|
+
* Use this when you do not need to control the state of the checkbox.
|
|
9
|
+
*/
|
|
10
|
+
defaultChecked?: checkbox.Context['checked'];
|
|
6
11
|
}
|
|
7
12
|
export interface UseCheckboxReturn extends Accessor<checkbox.Api<PropTypes>> {
|
|
8
13
|
}
|
|
@@ -4,6 +4,11 @@ import { type Accessor } from 'solid-js';
|
|
|
4
4
|
import type { Optional } from '../../types';
|
|
5
5
|
import { type RenderStrategyProps } from '../../utils/render-strategy';
|
|
6
6
|
export interface UseCollapsibleProps extends Optional<Omit<collapsible.Context, 'dir' | 'getRootNode' | 'open.controlled'>, 'id'>, RenderStrategyProps {
|
|
7
|
+
/**
|
|
8
|
+
* The initial open state of the collapsible when it is first rendered.
|
|
9
|
+
* Use when you do not need to control its open state.
|
|
10
|
+
*/
|
|
11
|
+
defaultOpen?: collapsible.Context['open'];
|
|
7
12
|
}
|
|
8
13
|
export interface UseCollapsibleReturn extends Accessor<collapsible.Api<PropTypes> & {
|
|
9
14
|
/**
|