@ark-ui/solid 3.0.0-4 → 3.0.0-6
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 +304 -235
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +306 -237
- 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/clipboard-indicator.jsx +0 -1
- 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/factory.jsx +8 -11
- 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/presence/index.js +4 -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/environment/{environment.jsx → environment-provider.jsx} +4 -4
- package/dist/source/providers/environment/index.js +1 -1
- package/dist/source/providers/environment/use-environment-context.js +1 -1
- 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/checkbox-hidden-input.d.ts +1 -1
- 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/factory.d.ts +2 -3
- 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/presence/index.d.ts +4 -6
- 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/environment/{environment.d.ts → environment-provider.d.ts} +2 -2
- package/dist/types/providers/environment/index.d.ts +1 -1
- package/dist/types/providers/environment/use-environment-context.d.ts +4 -1
- package/dist/types/providers/locale/locale-provider.d.ts +3 -4
- package/package.json +48 -48
- /package/dist/source/providers/locale/{use-locale-context.jsx → use-locale-context.js} +0 -0
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { mergeProps } from '@zag-js/solid';
|
|
2
2
|
import { createMemo } from 'solid-js';
|
|
3
|
+
import { createSplitProps } from '../../utils/create-split-props';
|
|
3
4
|
import { Collapsible } from '../collapsible';
|
|
4
5
|
import { useAccordionContext } from './use-accordion-context';
|
|
5
6
|
import { useAccordionItemPropsContext } from './use-accordion-item-props-context';
|
|
7
|
+
const splitVisibilityProps = createSplitProps();
|
|
6
8
|
export const AccordionItemContent = (props) => {
|
|
7
9
|
const accordion = useAccordionContext();
|
|
8
10
|
const itemProps = useAccordionItemPropsContext();
|
|
9
11
|
const itemContentProps = createMemo(() => {
|
|
10
|
-
const
|
|
11
|
-
ownProps
|
|
12
|
+
const contentProps = accordion().getItemContentProps(itemProps);
|
|
13
|
+
const [, ownProps] = splitVisibilityProps(contentProps, [
|
|
14
|
+
'hidden',
|
|
15
|
+
'data-state',
|
|
16
|
+
]);
|
|
12
17
|
return ownProps;
|
|
13
18
|
});
|
|
14
19
|
const mergedProps = mergeProps(itemContentProps, props);
|
|
@@ -8,6 +8,7 @@ export const AccordionRoot = (props) => {
|
|
|
8
8
|
const [renderStrategyProps, accordionProps] = splitRenderStrategyProps(props);
|
|
9
9
|
const [useAccordionProps, localProps] = createSplitProps()(accordionProps, [
|
|
10
10
|
'collapsible',
|
|
11
|
+
'defaultValue',
|
|
11
12
|
'disabled',
|
|
12
13
|
'id',
|
|
13
14
|
'ids',
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import * as accordion from '@zag-js/accordion';
|
|
2
2
|
import { normalizeProps, useMachine } from '@zag-js/solid';
|
|
3
|
-
import { createMemo, createUniqueId
|
|
3
|
+
import { createMemo, createUniqueId } from 'solid-js';
|
|
4
4
|
import { useEnvironmentContext, useLocaleContext } from '../../providers';
|
|
5
5
|
export const useAccordion = (props) => {
|
|
6
|
+
const id = createUniqueId();
|
|
6
7
|
const locale = useLocaleContext();
|
|
7
8
|
const environment = useEnvironmentContext();
|
|
8
|
-
const context =
|
|
9
|
-
|
|
9
|
+
const context = createMemo(() => ({
|
|
10
|
+
id,
|
|
11
|
+
dir: locale().dir,
|
|
12
|
+
value: props.defaultValue,
|
|
13
|
+
getRootNode: environment().getRootNode,
|
|
14
|
+
...props,
|
|
15
|
+
}));
|
|
16
|
+
const [state, send] = useMachine(accordion.machine(context()), {
|
|
17
|
+
context,
|
|
18
|
+
});
|
|
10
19
|
return createMemo(() => accordion.connect(state, send, normalizeProps));
|
|
11
20
|
};
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import * as avatar from '@zag-js/avatar';
|
|
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 useAvatar = (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(avatar.machine(context()), { context });
|
|
10
16
|
return createMemo(() => avatar.connect(state, send, normalizeProps));
|
|
11
17
|
};
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import * as carousel from '@zag-js/carousel';
|
|
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 useCarousel = (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
|
+
index: props.defaultIndex,
|
|
14
|
+
...props,
|
|
15
|
+
}));
|
|
16
|
+
const [state, send] = useMachine(carousel.machine(context()), { context });
|
|
10
17
|
return createMemo(() => carousel.connect(state, send, normalizeProps));
|
|
11
18
|
};
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import * as checkbox from '@zag-js/checkbox';
|
|
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 useCheckbox = (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(checkbox.machine(context()), { context });
|
|
10
17
|
return createMemo(() => checkbox.connect(state, send, normalizeProps));
|
|
11
18
|
};
|
|
@@ -7,7 +7,6 @@ export const ClipboardIndicator = (props) => {
|
|
|
7
7
|
const [indicatorProps, localProps] = createSplitProps()(props, ['copied']);
|
|
8
8
|
const api = useClipboardContext();
|
|
9
9
|
const mergedProps = mergeProps(api().getIndicatorProps({ copied: api().copied }), localProps);
|
|
10
|
-
// @ts-expect-error TODO fix
|
|
11
10
|
const getChildren = children(() => localProps.children);
|
|
12
11
|
return (<ark.div {...mergedProps}>
|
|
13
12
|
<Show when={api().copied} fallback={getChildren()}>
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import * as clipboard from '@zag-js/clipboard';
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeProps, useMachine } from '@zag-js/solid';
|
|
3
3
|
import { createMemo, createUniqueId } from 'solid-js';
|
|
4
4
|
import { useEnvironmentContext } from '../../providers';
|
|
5
5
|
export const useClipboard = (props) => {
|
|
6
6
|
const environment = useEnvironmentContext();
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
const id = createUniqueId();
|
|
8
|
+
const context = createMemo(() => ({
|
|
9
|
+
id,
|
|
10
|
+
getRootNode: environment().getRootNode,
|
|
11
|
+
...props,
|
|
12
|
+
}));
|
|
13
|
+
const [state, send] = useMachine(clipboard.machine(context()), { context });
|
|
9
14
|
return createMemo(() => clipboard.connect(state, send, normalizeProps));
|
|
10
15
|
};
|
|
@@ -5,6 +5,7 @@ import { useCollapsible } from './use-collapsible';
|
|
|
5
5
|
import { CollapsibleProvider } from './use-collapsible-context';
|
|
6
6
|
export const CollapsibleRoot = (props) => {
|
|
7
7
|
const [useCollapsibleProps, localProps] = createSplitProps()(props, [
|
|
8
|
+
'defaultOpen',
|
|
8
9
|
'disabled',
|
|
9
10
|
'id',
|
|
10
11
|
'ids',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as collapsible from '@zag-js/collapsible';
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeProps, useMachine } from '@zag-js/solid';
|
|
3
3
|
import { createEffect, createMemo, createSignal, createUniqueId } from 'solid-js';
|
|
4
4
|
import { useEnvironmentContext, useLocaleContext } from '../../providers';
|
|
5
5
|
import { splitRenderStrategyProps } from '../../utils/render-strategy';
|
|
@@ -7,13 +7,16 @@ export const useCollapsible = (props) => {
|
|
|
7
7
|
const locale = useLocaleContext();
|
|
8
8
|
const environment = useEnvironmentContext();
|
|
9
9
|
const [renderStrategyProps, collapsibleProps] = splitRenderStrategyProps(props);
|
|
10
|
-
const
|
|
11
|
-
|
|
10
|
+
const id = createUniqueId();
|
|
11
|
+
const context = createMemo(() => ({
|
|
12
|
+
id,
|
|
12
13
|
dir: locale().dir,
|
|
13
14
|
getRootNode: environment().getRootNode,
|
|
15
|
+
open: props.defaultOpen,
|
|
14
16
|
'open.controlled': props.open !== undefined,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
...collapsibleProps,
|
|
18
|
+
}));
|
|
19
|
+
const [state, send] = useMachine(collapsible.machine(context()), { context });
|
|
17
20
|
const [wasVisible, setWasVisible] = createSignal(false);
|
|
18
21
|
createEffect(() => {
|
|
19
22
|
const isPresent = api().visible;
|
|
@@ -8,6 +8,8 @@ export const ColorPickerRoot = (props) => {
|
|
|
8
8
|
const [presenceProps, colorPickerProps] = splitPresenceProps(props);
|
|
9
9
|
const [useColorPickerProps, localProps] = createSplitProps()(colorPickerProps, [
|
|
10
10
|
'closeOnSelect',
|
|
11
|
+
'defaultOpen',
|
|
12
|
+
'defaultValue',
|
|
11
13
|
'disabled',
|
|
12
14
|
'format',
|
|
13
15
|
'id',
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import * as colorPicker from '@zag-js/color-picker';
|
|
2
|
-
import {
|
|
3
|
-
import { createMemo, createUniqueId
|
|
2
|
+
import { normalizeProps, useMachine } from '@zag-js/solid';
|
|
3
|
+
import { createMemo, createUniqueId } from 'solid-js';
|
|
4
4
|
import { useEnvironmentContext, useLocaleContext } from '../../providers';
|
|
5
5
|
export const useColorPicker = (props) => {
|
|
6
|
-
const [local, rest] = splitProps(props, ['value']);
|
|
7
6
|
const locale = useLocaleContext();
|
|
8
7
|
const environment = useEnvironmentContext();
|
|
9
|
-
const
|
|
10
|
-
|
|
8
|
+
const id = createUniqueId();
|
|
9
|
+
const context = createMemo(() => ({
|
|
10
|
+
id,
|
|
11
11
|
dir: locale().dir,
|
|
12
12
|
getRootNode: environment().getRootNode,
|
|
13
|
+
open: props.defaultOpen,
|
|
13
14
|
'open.controlled': props.open !== undefined,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
...props,
|
|
16
|
+
value: props.value
|
|
17
|
+
? colorPicker.parse(props.value)
|
|
18
|
+
: props.defaultValue
|
|
19
|
+
? colorPicker.parse(props.defaultValue)
|
|
20
|
+
: undefined,
|
|
21
|
+
}));
|
|
22
|
+
const [state, send] = useMachine(colorPicker.machine(context()), { context });
|
|
17
23
|
return createMemo(() => colorPicker.connect(state, send, normalizeProps));
|
|
18
24
|
};
|
|
@@ -10,8 +10,11 @@ export const ComboboxRoot = (props) => {
|
|
|
10
10
|
'allowCustomValue',
|
|
11
11
|
'autoFocus',
|
|
12
12
|
'closeOnSelect',
|
|
13
|
+
'composite',
|
|
14
|
+
'defaultOpen',
|
|
15
|
+
'defaultValue',
|
|
13
16
|
'disabled',
|
|
14
|
-
'
|
|
17
|
+
'disableLayer',
|
|
15
18
|
'form',
|
|
16
19
|
'getSelectionValue',
|
|
17
20
|
'highlightedValue',
|
|
@@ -40,7 +43,6 @@ export const ComboboxRoot = (props) => {
|
|
|
40
43
|
'openOnClick',
|
|
41
44
|
'openOnKeyPress',
|
|
42
45
|
'placeholder',
|
|
43
|
-
'popup',
|
|
44
46
|
'positioning',
|
|
45
47
|
'readOnly',
|
|
46
48
|
'scrollToIndexFn',
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { createSplitProps } from '../../utils/create-split-props';
|
|
2
3
|
import { ark } from '../factory';
|
|
3
4
|
import { useComboboxContext } from './use-combobox-context';
|
|
4
5
|
export const ComboboxTrigger = (props) => {
|
|
6
|
+
const [triggerProps, localProps] = createSplitProps()(props, ['focusable']);
|
|
5
7
|
const combobox = useComboboxContext();
|
|
6
|
-
const mergedProps = mergeProps(() => combobox().triggerProps,
|
|
8
|
+
const mergedProps = mergeProps(() => combobox().getTriggerProps(triggerProps), localProps);
|
|
7
9
|
return <ark.button {...mergedProps}/>;
|
|
8
10
|
};
|
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
import * as combobox from '@zag-js/combobox';
|
|
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 useCombobox = (props) => {
|
|
7
|
-
const [collectionOptions,
|
|
7
|
+
const [collectionOptions, comboboxProps] = createSplitProps()(props, [
|
|
8
8
|
'isItemDisabled',
|
|
9
9
|
'itemToValue',
|
|
10
10
|
'itemToString',
|
|
11
11
|
'items',
|
|
12
12
|
]);
|
|
13
|
-
const collection =
|
|
13
|
+
const collection = () => combobox.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
|
-
}, rest);
|
|
25
|
-
const [state, send] = useMachine(combobox.machine(context), {
|
|
25
|
+
...comboboxProps,
|
|
26
|
+
}));
|
|
27
|
+
const [state, send] = useMachine(combobox.machine(context()), {
|
|
26
28
|
context,
|
|
27
29
|
});
|
|
28
30
|
return createMemo(() => combobox.connect(state, send, normalizeProps));
|
|
@@ -8,6 +8,8 @@ export const DatePickerRoot = (props) => {
|
|
|
8
8
|
const [presenceProps, datePickerProps] = splitPresenceProps(props);
|
|
9
9
|
const [useDatePickerProps, localProps] = createSplitProps()(datePickerProps, [
|
|
10
10
|
'closeOnSelect',
|
|
11
|
+
'defaultOpen',
|
|
12
|
+
'defaultValue',
|
|
11
13
|
'disabled',
|
|
12
14
|
'fixedWeeks',
|
|
13
15
|
'focusedValue',
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import * as datePicker from '@zag-js/date-picker';
|
|
2
|
-
import {
|
|
3
|
-
import { createMemo, createUniqueId
|
|
2
|
+
import { normalizeProps, useMachine } from '@zag-js/solid';
|
|
3
|
+
import { createMemo, createUniqueId } from 'solid-js';
|
|
4
4
|
import { useEnvironmentContext, useLocaleContext } from '../../providers';
|
|
5
5
|
export const useDatePicker = (props) => {
|
|
6
6
|
const locale = useLocaleContext();
|
|
7
7
|
const environment = useEnvironmentContext();
|
|
8
|
-
const
|
|
9
|
-
const context =
|
|
10
|
-
id
|
|
8
|
+
const id = createUniqueId();
|
|
9
|
+
const context = createMemo(() => ({
|
|
10
|
+
id,
|
|
11
11
|
dir: locale().dir,
|
|
12
12
|
getRootNode: environment().getRootNode,
|
|
13
13
|
'open.controlled': props.open !== undefined,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
open: props.defaultOpen,
|
|
15
|
+
...props,
|
|
16
|
+
focusedValue: props.focusedValue ? datePicker.parse(props.focusedValue) : undefined,
|
|
17
|
+
value: props.value
|
|
18
|
+
? datePicker.parse(props.value)
|
|
19
|
+
: props.defaultValue
|
|
20
|
+
? datePicker.parse(props.defaultValue)
|
|
21
|
+
: undefined,
|
|
22
|
+
max: props.max ? datePicker.parse(props.max) : undefined,
|
|
23
|
+
min: props.min ? datePicker.parse(props.min) : undefined,
|
|
24
|
+
}));
|
|
25
|
+
const [state, send] = useMachine(datePicker.machine(context()), { context });
|
|
20
26
|
return createMemo(() => datePicker.connect(state, send, normalizeProps));
|
|
21
27
|
};
|
|
@@ -11,6 +11,7 @@ export const DialogRoot = (props) => {
|
|
|
11
11
|
'aria-label',
|
|
12
12
|
'closeOnEscape',
|
|
13
13
|
'closeOnInteractOutside',
|
|
14
|
+
'defaultOpen',
|
|
14
15
|
'finalFocusEl',
|
|
15
16
|
'id',
|
|
16
17
|
'ids',
|
|
@@ -22,6 +23,7 @@ export const DialogRoot = (props) => {
|
|
|
22
23
|
'onOpenChange',
|
|
23
24
|
'onPointerDownOutside',
|
|
24
25
|
'open',
|
|
26
|
+
'persistentElements',
|
|
25
27
|
'preventScroll',
|
|
26
28
|
'restoreFocus',
|
|
27
29
|
'role',
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import * as dialog from '@zag-js/dialog';
|
|
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 useDialog = (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(dialog.machine(context()), { context });
|
|
15
18
|
return createMemo(() => dialog.connect(state, send, normalizeProps));
|
|
16
19
|
};
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import * as editable from '@zag-js/editable';
|
|
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 useEditable = (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(editable.machine(context()), { context });
|
|
10
17
|
return createMemo(() => editable.connect(state, send, normalizeProps));
|
|
11
18
|
};
|
|
@@ -3,20 +3,17 @@ import { splitProps } from 'solid-js';
|
|
|
3
3
|
import { Dynamic } from 'solid-js/web';
|
|
4
4
|
const withAsProp = (Component) => {
|
|
5
5
|
const ArkComponent = (props) => {
|
|
6
|
-
const [localProps,
|
|
6
|
+
const [localProps, parentProps] = splitProps(props, ['asChild']);
|
|
7
7
|
if (localProps.asChild) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const fn = (userProps) => {
|
|
13
|
-
const [, restProps] = splitProps(otherProps, ['children', 'ref']);
|
|
14
|
-
return { ref: otherProps.ref, ...mergeProps(restProps, userProps) };
|
|
8
|
+
// @ts-expect-error
|
|
9
|
+
const propsFn = (userProps) => {
|
|
10
|
+
const [, restProps] = splitProps(parentProps, ['ref']);
|
|
11
|
+
return { ref: parentProps.ref, ...mergeProps(restProps, userProps) };
|
|
15
12
|
};
|
|
16
|
-
return
|
|
13
|
+
return localProps.asChild(propsFn);
|
|
17
14
|
}
|
|
18
|
-
//
|
|
19
|
-
return <Dynamic component={Component} {...
|
|
15
|
+
// @ts-expect-error
|
|
16
|
+
return <Dynamic component={Component} {...parentProps}/>;
|
|
20
17
|
};
|
|
21
18
|
return ArkComponent;
|
|
22
19
|
};
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import * as fileUpload from '@zag-js/file-upload';
|
|
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 useFileUpload = (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(fileUpload.machine(context()), { context });
|
|
10
16
|
return createMemo(() => fileUpload.connect(state, send, normalizeProps));
|
|
11
17
|
};
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import * as hoverCard from '@zag-js/hover-card';
|
|
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 useHoverCard = (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(hoverCard.machine(context()), { context });
|
|
15
18
|
return createMemo(() => hoverCard.connect(state, send, normalizeProps));
|
|
16
19
|
};
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import * as menu from '@zag-js/menu';
|
|
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 useMenu = (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, machine] = useMachine(menu.machine(context()), { context });
|
|
15
18
|
const api = createMemo(() => menu.connect(state, send, normalizeProps));
|
|
16
19
|
return {
|
|
17
20
|
api,
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import * as numberInput from '@zag-js/number-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 useNumberInput = (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(numberInput.machine(context()), { context });
|
|
10
17
|
return createMemo(() => numberInput.connect(state, send, normalizeProps));
|
|
11
18
|
};
|