@ark-ui/react 5.16.1 → 5.18.0
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/components/checkbox/checkbox-group-provider.cjs +19 -0
- package/dist/components/checkbox/checkbox-group-provider.d.cts +13 -0
- package/dist/components/checkbox/checkbox-group-provider.d.ts +13 -0
- package/dist/components/checkbox/checkbox-group-provider.js +15 -0
- package/dist/components/checkbox/checkbox.cjs +2 -0
- package/dist/components/checkbox/checkbox.d.cts +1 -0
- package/dist/components/checkbox/checkbox.d.ts +1 -0
- package/dist/components/checkbox/checkbox.js +1 -0
- package/dist/components/checkbox/index.cjs +2 -0
- package/dist/components/checkbox/index.d.cts +1 -0
- package/dist/components/checkbox/index.d.ts +1 -0
- package/dist/components/checkbox/index.js +1 -0
- package/dist/components/collection/index.cjs +2 -0
- package/dist/components/collection/index.d.cts +2 -1
- package/dist/components/collection/index.d.ts +2 -1
- package/dist/components/collection/index.js +1 -0
- package/dist/components/collection/use-list-selection.cjs +96 -0
- package/dist/components/collection/use-list-selection.d.cts +103 -0
- package/dist/components/collection/use-list-selection.d.ts +103 -0
- package/dist/components/collection/use-list-selection.js +92 -0
- package/dist/components/color-picker/color-picker-value-text.cjs +3 -3
- package/dist/components/color-picker/color-picker-value-text.js +3 -3
- package/dist/components/field/use-field.cjs +2 -1
- package/dist/components/field/use-field.js +2 -1
- package/dist/components/fieldset/use-fieldset.cjs +2 -1
- package/dist/components/fieldset/use-fieldset.js +2 -1
- package/dist/components/file-upload/file-upload-root.cjs +2 -0
- package/dist/components/file-upload/file-upload-root.js +2 -0
- package/dist/components/file-upload/file-upload.d.cts +1 -1
- package/dist/components/file-upload/file-upload.d.ts +1 -1
- package/dist/components/file-upload/index.d.cts +1 -1
- package/dist/components/file-upload/index.d.ts +1 -1
- package/dist/components/index.cjs +12 -0
- package/dist/components/index.d.cts +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +7 -0
- package/dist/components/json-tree-view/get-branch-value.cjs +19 -0
- package/dist/components/json-tree-view/get-branch-value.d.cts +3 -0
- package/dist/components/json-tree-view/get-branch-value.d.ts +3 -0
- package/dist/components/json-tree-view/get-branch-value.js +15 -0
- package/dist/components/json-tree-view/index.cjs +17 -0
- package/dist/components/json-tree-view/index.d.cts +5 -0
- package/dist/components/json-tree-view/index.d.ts +5 -0
- package/dist/components/json-tree-view/index.js +6 -0
- package/dist/components/json-tree-view/json-tree-view-key-node.cjs +18 -0
- package/dist/components/json-tree-view/json-tree-view-key-node.d.cts +13 -0
- package/dist/components/json-tree-view/json-tree-view-key-node.d.ts +13 -0
- package/dist/components/json-tree-view/json-tree-view-key-node.js +14 -0
- package/dist/components/json-tree-view/json-tree-view-node.cjs +62 -0
- package/dist/components/json-tree-view/json-tree-view-node.d.cts +20 -0
- package/dist/components/json-tree-view/json-tree-view-node.d.ts +20 -0
- package/dist/components/json-tree-view/json-tree-view-node.js +58 -0
- package/dist/components/json-tree-view/json-tree-view-props-context.cjs +15 -0
- package/dist/components/json-tree-view/json-tree-view-props-context.d.cts +9 -0
- package/dist/components/json-tree-view/json-tree-view-props-context.d.ts +9 -0
- package/dist/components/json-tree-view/json-tree-view-props-context.js +10 -0
- package/dist/components/json-tree-view/json-tree-view-root-provider.cjs +15 -0
- package/dist/components/json-tree-view/json-tree-view-root-provider.d.cts +6 -0
- package/dist/components/json-tree-view/json-tree-view-root-provider.d.ts +6 -0
- package/dist/components/json-tree-view/json-tree-view-root-provider.js +11 -0
- package/dist/components/json-tree-view/json-tree-view-root.cjs +48 -0
- package/dist/components/json-tree-view/json-tree-view-root.d.cts +15 -0
- package/dist/components/json-tree-view/json-tree-view-root.d.ts +15 -0
- package/dist/components/json-tree-view/json-tree-view-root.js +44 -0
- package/dist/components/json-tree-view/json-tree-view-tree.cjs +22 -0
- package/dist/components/json-tree-view/json-tree-view-tree.d.cts +6 -0
- package/dist/components/json-tree-view/json-tree-view-tree.d.ts +6 -0
- package/dist/components/json-tree-view/json-tree-view-tree.js +18 -0
- package/dist/components/json-tree-view/json-tree-view-value-node.cjs +26 -0
- package/dist/components/json-tree-view/json-tree-view-value-node.d.cts +7 -0
- package/dist/components/json-tree-view/json-tree-view-value-node.d.ts +7 -0
- package/dist/components/json-tree-view/json-tree-view-value-node.js +22 -0
- package/dist/components/json-tree-view/json-tree-view.cjs +13 -0
- package/dist/components/json-tree-view/json-tree-view.d.cts +3 -0
- package/dist/components/json-tree-view/json-tree-view.d.ts +3 -0
- package/dist/components/json-tree-view/json-tree-view.js +3 -0
- package/dist/components/json-tree-view/use-json-tree-view.cjs +32 -0
- package/dist/components/json-tree-view/use-json-tree-view.d.cts +9 -0
- package/dist/components/json-tree-view/use-json-tree-view.d.ts +9 -0
- package/dist/components/json-tree-view/use-json-tree-view.js +28 -0
- package/dist/components/signature-pad/signature-pad-root.cjs +2 -0
- package/dist/components/signature-pad/signature-pad-root.js +2 -0
- package/dist/components/tree-view/use-tree-view.d.cts +1 -1
- package/dist/components/tree-view/use-tree-view.d.ts +1 -1
- package/dist/index.cjs +12 -0
- package/dist/index.js +7 -0
- package/package.json +65 -64
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
|
+
|
|
6
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
const react = require('react');
|
|
8
|
+
const createSplitProps = require('../../utils/create-split-props.cjs');
|
|
9
|
+
const factory = require('../factory.cjs');
|
|
10
|
+
const checkbox_anatomy = require('./checkbox.anatomy.cjs');
|
|
11
|
+
const useCheckboxGroupContext = require('./use-checkbox-group-context.cjs');
|
|
12
|
+
|
|
13
|
+
const CheckboxGroupProvider = react.forwardRef((props, ref) => {
|
|
14
|
+
const [localProps, restProps] = createSplitProps.createSplitProps()(props, ["value"]);
|
|
15
|
+
return /* @__PURE__ */ jsxRuntime.jsx(useCheckboxGroupContext.CheckboxGroupContextProvider, { value: localProps.value, children: /* @__PURE__ */ jsxRuntime.jsx(factory.ark.div, { ref, role: "group", ...restProps, ...checkbox_anatomy.checkboxAnatomy.build().group.attrs }) });
|
|
16
|
+
});
|
|
17
|
+
CheckboxGroupProvider.displayName = "CheckboxGroupProvider";
|
|
18
|
+
|
|
19
|
+
exports.CheckboxGroupProvider = CheckboxGroupProvider;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Assign } from '../../types';
|
|
2
|
+
import { HTMLProps, PolymorphicProps } from '../factory';
|
|
3
|
+
import { UseCheckboxGroupContext } from './use-checkbox-group-context';
|
|
4
|
+
import { ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
5
|
+
interface ProviderProps {
|
|
6
|
+
value: UseCheckboxGroupContext;
|
|
7
|
+
}
|
|
8
|
+
export interface CheckboxGroupProviderBaseProps extends ProviderProps, PolymorphicProps {
|
|
9
|
+
}
|
|
10
|
+
export interface CheckboxGroupProviderProps extends Assign<HTMLProps<'div'>, CheckboxGroupProviderBaseProps> {
|
|
11
|
+
}
|
|
12
|
+
export declare const CheckboxGroupProvider: ForwardRefExoticComponent<CheckboxGroupProviderProps & RefAttributes<HTMLDivElement>>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Assign } from '../../types';
|
|
2
|
+
import { HTMLProps, PolymorphicProps } from '../factory';
|
|
3
|
+
import { UseCheckboxGroupContext } from './use-checkbox-group-context';
|
|
4
|
+
import { ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
5
|
+
interface ProviderProps {
|
|
6
|
+
value: UseCheckboxGroupContext;
|
|
7
|
+
}
|
|
8
|
+
export interface CheckboxGroupProviderBaseProps extends ProviderProps, PolymorphicProps {
|
|
9
|
+
}
|
|
10
|
+
export interface CheckboxGroupProviderProps extends Assign<HTMLProps<'div'>, CheckboxGroupProviderBaseProps> {
|
|
11
|
+
}
|
|
12
|
+
export declare const CheckboxGroupProvider: ForwardRefExoticComponent<CheckboxGroupProviderProps & RefAttributes<HTMLDivElement>>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { createSplitProps } from '../../utils/create-split-props.js';
|
|
5
|
+
import { ark } from '../factory.js';
|
|
6
|
+
import { checkboxAnatomy } from './checkbox.anatomy.js';
|
|
7
|
+
import { CheckboxGroupContextProvider } from './use-checkbox-group-context.js';
|
|
8
|
+
|
|
9
|
+
const CheckboxGroupProvider = forwardRef((props, ref) => {
|
|
10
|
+
const [localProps, restProps] = createSplitProps()(props, ["value"]);
|
|
11
|
+
return /* @__PURE__ */ jsx(CheckboxGroupContextProvider, { value: localProps.value, children: /* @__PURE__ */ jsx(ark.div, { ref, role: "group", ...restProps, ...checkboxAnatomy.build().group.attrs }) });
|
|
12
|
+
});
|
|
13
|
+
CheckboxGroupProvider.displayName = "CheckboxGroupProvider";
|
|
14
|
+
|
|
15
|
+
export { CheckboxGroupProvider };
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
5
5
|
const checkboxContext = require('./checkbox-context.cjs');
|
|
6
6
|
const checkboxControl = require('./checkbox-control.cjs');
|
|
7
7
|
const checkboxGroup = require('./checkbox-group.cjs');
|
|
8
|
+
const checkboxGroupProvider = require('./checkbox-group-provider.cjs');
|
|
8
9
|
const checkboxHiddenInput = require('./checkbox-hidden-input.cjs');
|
|
9
10
|
const checkboxIndicator = require('./checkbox-indicator.cjs');
|
|
10
11
|
const checkboxLabel = require('./checkbox-label.cjs');
|
|
@@ -16,6 +17,7 @@ const checkboxRootProvider = require('./checkbox-root-provider.cjs');
|
|
|
16
17
|
exports.Context = checkboxContext.CheckboxContext;
|
|
17
18
|
exports.Control = checkboxControl.CheckboxControl;
|
|
18
19
|
exports.Group = checkboxGroup.CheckboxGroup;
|
|
20
|
+
exports.GroupProvider = checkboxGroupProvider.CheckboxGroupProvider;
|
|
19
21
|
exports.HiddenInput = checkboxHiddenInput.CheckboxHiddenInput;
|
|
20
22
|
exports.Indicator = checkboxIndicator.CheckboxIndicator;
|
|
21
23
|
exports.Label = checkboxLabel.CheckboxLabel;
|
|
@@ -2,6 +2,7 @@ export type { CheckedChangeDetails, CheckedState } from '@zag-js/checkbox';
|
|
|
2
2
|
export { CheckboxContext as Context, type CheckboxContextProps as ContextProps } from './checkbox-context';
|
|
3
3
|
export { CheckboxControl as Control, type CheckboxControlBaseProps as ControlBaseProps, type CheckboxControlProps as ControlProps, } from './checkbox-control';
|
|
4
4
|
export { CheckboxGroup as Group, type CheckboxGroupBaseProps as GroupBaseProps, type CheckboxGroupProps as GroupProps, } from './checkbox-group';
|
|
5
|
+
export { CheckboxGroupProvider as GroupProvider, type CheckboxGroupProviderBaseProps as GroupProviderBaseProps, type CheckboxGroupProviderProps as GroupProviderProps, } from './checkbox-group-provider';
|
|
5
6
|
export { CheckboxHiddenInput as HiddenInput, type CheckboxHiddenInputBaseProps as HiddenInputBaseProps, type CheckboxHiddenInputProps as HiddenInputProps, } from './checkbox-hidden-input';
|
|
6
7
|
export { CheckboxIndicator as Indicator, type CheckboxIndicatorBaseProps as IndicatorBaseProps, type CheckboxIndicatorProps as IndicatorProps, } from './checkbox-indicator';
|
|
7
8
|
export { CheckboxLabel as Label, type CheckboxLabelBaseProps as LabelBaseProps, type CheckboxLabelProps as LabelProps, } from './checkbox-label';
|
|
@@ -2,6 +2,7 @@ export type { CheckedChangeDetails, CheckedState } from '@zag-js/checkbox';
|
|
|
2
2
|
export { CheckboxContext as Context, type CheckboxContextProps as ContextProps } from './checkbox-context';
|
|
3
3
|
export { CheckboxControl as Control, type CheckboxControlBaseProps as ControlBaseProps, type CheckboxControlProps as ControlProps, } from './checkbox-control';
|
|
4
4
|
export { CheckboxGroup as Group, type CheckboxGroupBaseProps as GroupBaseProps, type CheckboxGroupProps as GroupProps, } from './checkbox-group';
|
|
5
|
+
export { CheckboxGroupProvider as GroupProvider, type CheckboxGroupProviderBaseProps as GroupProviderBaseProps, type CheckboxGroupProviderProps as GroupProviderProps, } from './checkbox-group-provider';
|
|
5
6
|
export { CheckboxHiddenInput as HiddenInput, type CheckboxHiddenInputBaseProps as HiddenInputBaseProps, type CheckboxHiddenInputProps as HiddenInputProps, } from './checkbox-hidden-input';
|
|
6
7
|
export { CheckboxIndicator as Indicator, type CheckboxIndicatorBaseProps as IndicatorBaseProps, type CheckboxIndicatorProps as IndicatorProps, } from './checkbox-indicator';
|
|
7
8
|
export { CheckboxLabel as Label, type CheckboxLabelBaseProps as LabelBaseProps, type CheckboxLabelProps as LabelProps, } from './checkbox-label';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { CheckboxContext as Context } from './checkbox-context.js';
|
|
2
2
|
export { CheckboxControl as Control } from './checkbox-control.js';
|
|
3
3
|
export { CheckboxGroup as Group } from './checkbox-group.js';
|
|
4
|
+
export { CheckboxGroupProvider as GroupProvider } from './checkbox-group-provider.js';
|
|
4
5
|
export { CheckboxHiddenInput as HiddenInput } from './checkbox-hidden-input.js';
|
|
5
6
|
export { CheckboxIndicator as Indicator } from './checkbox-indicator.js';
|
|
6
7
|
export { CheckboxLabel as Label } from './checkbox-label.js';
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
5
5
|
const checkboxContext = require('./checkbox-context.cjs');
|
|
6
6
|
const checkboxControl = require('./checkbox-control.cjs');
|
|
7
7
|
const checkboxGroup = require('./checkbox-group.cjs');
|
|
8
|
+
const checkboxGroupProvider = require('./checkbox-group-provider.cjs');
|
|
8
9
|
const checkboxHiddenInput = require('./checkbox-hidden-input.cjs');
|
|
9
10
|
const checkboxIndicator = require('./checkbox-indicator.cjs');
|
|
10
11
|
const checkboxLabel = require('./checkbox-label.cjs');
|
|
@@ -22,6 +23,7 @@ const checkbox = require('./checkbox.cjs');
|
|
|
22
23
|
exports.CheckboxContext = checkboxContext.CheckboxContext;
|
|
23
24
|
exports.CheckboxControl = checkboxControl.CheckboxControl;
|
|
24
25
|
exports.CheckboxGroup = checkboxGroup.CheckboxGroup;
|
|
26
|
+
exports.CheckboxGroupProvider = checkboxGroupProvider.CheckboxGroupProvider;
|
|
25
27
|
exports.CheckboxHiddenInput = checkboxHiddenInput.CheckboxHiddenInput;
|
|
26
28
|
exports.CheckboxIndicator = checkboxIndicator.CheckboxIndicator;
|
|
27
29
|
exports.CheckboxLabel = checkboxLabel.CheckboxLabel;
|
|
@@ -2,6 +2,7 @@ export type { CheckedChangeDetails as CheckboxCheckedChangeDetails, CheckedState
|
|
|
2
2
|
export { CheckboxContext, type CheckboxContextProps } from './checkbox-context';
|
|
3
3
|
export { CheckboxControl, type CheckboxControlBaseProps, type CheckboxControlProps } from './checkbox-control';
|
|
4
4
|
export { CheckboxGroup, type CheckboxGroupBaseProps, type CheckboxGroupProps } from './checkbox-group';
|
|
5
|
+
export { CheckboxGroupProvider, type CheckboxGroupProviderBaseProps, type CheckboxGroupProviderProps, } from './checkbox-group-provider';
|
|
5
6
|
export { CheckboxHiddenInput, type CheckboxHiddenInputBaseProps, type CheckboxHiddenInputProps, } from './checkbox-hidden-input';
|
|
6
7
|
export { CheckboxIndicator, type CheckboxIndicatorBaseProps, type CheckboxIndicatorProps } from './checkbox-indicator';
|
|
7
8
|
export { CheckboxLabel, type CheckboxLabelBaseProps, type CheckboxLabelProps } from './checkbox-label';
|
|
@@ -2,6 +2,7 @@ export type { CheckedChangeDetails as CheckboxCheckedChangeDetails, CheckedState
|
|
|
2
2
|
export { CheckboxContext, type CheckboxContextProps } from './checkbox-context';
|
|
3
3
|
export { CheckboxControl, type CheckboxControlBaseProps, type CheckboxControlProps } from './checkbox-control';
|
|
4
4
|
export { CheckboxGroup, type CheckboxGroupBaseProps, type CheckboxGroupProps } from './checkbox-group';
|
|
5
|
+
export { CheckboxGroupProvider, type CheckboxGroupProviderBaseProps, type CheckboxGroupProviderProps, } from './checkbox-group-provider';
|
|
5
6
|
export { CheckboxHiddenInput, type CheckboxHiddenInputBaseProps, type CheckboxHiddenInputProps, } from './checkbox-hidden-input';
|
|
6
7
|
export { CheckboxIndicator, type CheckboxIndicatorBaseProps, type CheckboxIndicatorProps } from './checkbox-indicator';
|
|
7
8
|
export { CheckboxLabel, type CheckboxLabelBaseProps, type CheckboxLabelProps } from './checkbox-label';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { CheckboxContext } from './checkbox-context.js';
|
|
2
2
|
export { CheckboxControl } from './checkbox-control.js';
|
|
3
3
|
export { CheckboxGroup } from './checkbox-group.js';
|
|
4
|
+
export { CheckboxGroupProvider } from './checkbox-group-provider.js';
|
|
4
5
|
export { CheckboxHiddenInput } from './checkbox-hidden-input.js';
|
|
5
6
|
export { CheckboxIndicator } from './checkbox-indicator.js';
|
|
6
7
|
export { CheckboxLabel } from './checkbox-label.js';
|
|
@@ -6,6 +6,7 @@ const gridCollection = require('./grid-collection.cjs');
|
|
|
6
6
|
const listCollection = require('./list-collection.cjs');
|
|
7
7
|
const treeCollection = require('./tree-collection.cjs');
|
|
8
8
|
const useListCollection = require('./use-list-collection.cjs');
|
|
9
|
+
const useListSelection = require('./use-list-selection.cjs');
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
|
|
@@ -14,3 +15,4 @@ exports.createListCollection = listCollection.createListCollection;
|
|
|
14
15
|
exports.createFileTreeCollection = treeCollection.createFileTreeCollection;
|
|
15
16
|
exports.createTreeCollection = treeCollection.createTreeCollection;
|
|
16
17
|
exports.useListCollection = useListCollection.useListCollection;
|
|
18
|
+
exports.useListSelection = useListSelection.useListSelection;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { createGridCollection, type GridCollection, type GridCollectionOptions } from './grid-collection';
|
|
2
2
|
export { createListCollection, type CollectionItem, type CollectionOptions, type ListCollection, } from './list-collection';
|
|
3
3
|
export { createFileTreeCollection, createTreeCollection, type FilePathTreeNode, type FlatTreeNode, type TreeCollection, type TreeCollectionOptions, type TreeNode, } from './tree-collection';
|
|
4
|
-
export { useListCollection, type UseListCollectionProps } from './use-list-collection';
|
|
4
|
+
export { useListCollection, type UseListCollectionProps, type UseListCollectionReturn } from './use-list-collection';
|
|
5
|
+
export { useListSelection, type UseListSelectionProps, type UseListSelectionReturn } from './use-list-selection';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { createGridCollection, type GridCollection, type GridCollectionOptions } from './grid-collection';
|
|
2
2
|
export { createListCollection, type CollectionItem, type CollectionOptions, type ListCollection, } from './list-collection';
|
|
3
3
|
export { createFileTreeCollection, createTreeCollection, type FilePathTreeNode, type FlatTreeNode, type TreeCollection, type TreeCollectionOptions, type TreeNode, } from './tree-collection';
|
|
4
|
-
export { useListCollection, type UseListCollectionProps } from './use-list-collection';
|
|
4
|
+
export { useListCollection, type UseListCollectionProps, type UseListCollectionReturn } from './use-list-collection';
|
|
5
|
+
export { useListSelection, type UseListSelectionProps, type UseListSelectionReturn } from './use-list-selection';
|
|
@@ -2,3 +2,4 @@ export { createGridCollection } from './grid-collection.js';
|
|
|
2
2
|
export { createListCollection } from './list-collection.js';
|
|
3
3
|
export { createFileTreeCollection, createTreeCollection } from './tree-collection.js';
|
|
4
4
|
export { useListCollection } from './use-list-collection.js';
|
|
5
|
+
export { useListSelection } from './use-list-selection.js';
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
|
+
|
|
6
|
+
const collection = require('@zag-js/collection');
|
|
7
|
+
const react = require('react');
|
|
8
|
+
const useEvent = require('../../utils/use-event.cjs');
|
|
9
|
+
|
|
10
|
+
function useListSelection(props) {
|
|
11
|
+
const {
|
|
12
|
+
collection: collection$1,
|
|
13
|
+
selectionMode = "single",
|
|
14
|
+
deselectable = true,
|
|
15
|
+
initialSelectedValues = [],
|
|
16
|
+
resetOnCollectionChange = false
|
|
17
|
+
} = props;
|
|
18
|
+
const createSelection = react.useCallback(
|
|
19
|
+
(values = []) => {
|
|
20
|
+
const selection2 = new collection.Selection(values);
|
|
21
|
+
selection2.selectionMode = selectionMode;
|
|
22
|
+
selection2.deselectable = deselectable;
|
|
23
|
+
return selection2;
|
|
24
|
+
},
|
|
25
|
+
[selectionMode, deselectable]
|
|
26
|
+
);
|
|
27
|
+
const [selection, setSelectionState] = react.useState(() => createSelection(initialSelectedValues));
|
|
28
|
+
react.useEffect(() => {
|
|
29
|
+
if (resetOnCollectionChange) {
|
|
30
|
+
setSelectionState(createSelection());
|
|
31
|
+
}
|
|
32
|
+
}, [collection$1.toString(), resetOnCollectionChange, createSelection]);
|
|
33
|
+
const selectedValues = react.useMemo(() => Array.from(selection), [selection]);
|
|
34
|
+
const isEmpty = react.useMemo(() => selection.isEmpty(), [selection]);
|
|
35
|
+
const firstSelectedValue = react.useMemo(() => selection.firstSelectedValue(collection$1), [selection, collection$1]);
|
|
36
|
+
const lastSelectedValue = react.useMemo(() => selection.lastSelectedValue(collection$1), [selection, collection$1]);
|
|
37
|
+
return {
|
|
38
|
+
selectedValues,
|
|
39
|
+
isEmpty,
|
|
40
|
+
firstSelectedValue,
|
|
41
|
+
lastSelectedValue,
|
|
42
|
+
isSelected: useEvent.useEvent((value) => {
|
|
43
|
+
return selection.isSelected(value);
|
|
44
|
+
}),
|
|
45
|
+
isAllSelected: useEvent.useEvent(() => {
|
|
46
|
+
const allValues = collection$1.getValues();
|
|
47
|
+
return allValues.length > 0 && allValues.every((value) => selection.isSelected(value));
|
|
48
|
+
}),
|
|
49
|
+
isSomeSelected: useEvent.useEvent(() => {
|
|
50
|
+
const allValues = collection$1.getValues();
|
|
51
|
+
return allValues.some((value) => selection.isSelected(value));
|
|
52
|
+
}),
|
|
53
|
+
canSelect: useEvent.useEvent((value) => {
|
|
54
|
+
return selection.canSelect(collection$1, value);
|
|
55
|
+
}),
|
|
56
|
+
select: useEvent.useEvent((value, forceToggle) => {
|
|
57
|
+
setSelectionState(selection.select(collection$1, value, forceToggle));
|
|
58
|
+
}),
|
|
59
|
+
deselect: useEvent.useEvent((value) => {
|
|
60
|
+
setSelectionState(selection.deselect(value));
|
|
61
|
+
}),
|
|
62
|
+
toggle: useEvent.useEvent((value) => {
|
|
63
|
+
setSelectionState(selection.toggleSelection(collection$1, value));
|
|
64
|
+
}),
|
|
65
|
+
replace: useEvent.useEvent((value) => {
|
|
66
|
+
setSelectionState(selection.replaceSelection(collection$1, value));
|
|
67
|
+
}),
|
|
68
|
+
extend: useEvent.useEvent((anchorValue, targetValue) => {
|
|
69
|
+
setSelectionState(selection.extendSelection(collection$1, anchorValue, targetValue));
|
|
70
|
+
}),
|
|
71
|
+
setSelectedValues: useEvent.useEvent((values) => {
|
|
72
|
+
setSelectionState(selection.setSelection(values));
|
|
73
|
+
}),
|
|
74
|
+
clear: useEvent.useEvent(() => {
|
|
75
|
+
setSelectionState(selection.clearSelection());
|
|
76
|
+
}),
|
|
77
|
+
resetSelection: useEvent.useEvent(() => {
|
|
78
|
+
setSelectionState(createSelection());
|
|
79
|
+
}),
|
|
80
|
+
setSelection: useEvent.useEvent((newSelection) => {
|
|
81
|
+
setSelectionState(selection.setSelection(newSelection));
|
|
82
|
+
}),
|
|
83
|
+
setSelectionMode: useEvent.useEvent((mode) => {
|
|
84
|
+
const newSelection = selection.copy();
|
|
85
|
+
newSelection.selectionMode = mode;
|
|
86
|
+
setSelectionState(newSelection);
|
|
87
|
+
}),
|
|
88
|
+
setDeselectable: useEvent.useEvent((deselectable2) => {
|
|
89
|
+
const newSelection = selection.copy();
|
|
90
|
+
newSelection.deselectable = deselectable2;
|
|
91
|
+
setSelectionState(newSelection);
|
|
92
|
+
})
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
exports.useListSelection = useListSelection;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { SelectionMode } from '@zag-js/collection';
|
|
2
|
+
import { CollectionItem, ListCollection } from './list-collection';
|
|
3
|
+
export interface UseListSelectionProps<T extends CollectionItem> {
|
|
4
|
+
/**
|
|
5
|
+
* The selection mode.
|
|
6
|
+
*/
|
|
7
|
+
selectionMode?: SelectionMode;
|
|
8
|
+
/**
|
|
9
|
+
* Whether the selection is deselectable.
|
|
10
|
+
*/
|
|
11
|
+
deselectable?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* The initial selected values.
|
|
14
|
+
*/
|
|
15
|
+
initialSelectedValues?: string[];
|
|
16
|
+
/**
|
|
17
|
+
* Whether to reset the selection when the collection changes.
|
|
18
|
+
*/
|
|
19
|
+
resetOnCollectionChange?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The collection to use.
|
|
22
|
+
*/
|
|
23
|
+
collection: ListCollection<T>;
|
|
24
|
+
}
|
|
25
|
+
export declare function useListSelection<T extends CollectionItem>(props: UseListSelectionProps<T>): UseListSelectionReturn;
|
|
26
|
+
export interface UseListSelectionReturn {
|
|
27
|
+
/**
|
|
28
|
+
* The selected values as an array.
|
|
29
|
+
*/
|
|
30
|
+
selectedValues: string[];
|
|
31
|
+
/**
|
|
32
|
+
* Whether the selection is empty.
|
|
33
|
+
*/
|
|
34
|
+
isEmpty: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* The first selected value.
|
|
37
|
+
*/
|
|
38
|
+
firstSelectedValue: string | null;
|
|
39
|
+
/**
|
|
40
|
+
* The last selected value.
|
|
41
|
+
*/
|
|
42
|
+
lastSelectedValue: string | null;
|
|
43
|
+
/**
|
|
44
|
+
* Check if a value is selected.
|
|
45
|
+
*/
|
|
46
|
+
isSelected: (value: string | null) => boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Check if a value can be selected.
|
|
49
|
+
*/
|
|
50
|
+
canSelect: (value: string) => boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Select a value.
|
|
53
|
+
*/
|
|
54
|
+
select: (value: string, forceToggle?: boolean) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Deselect a value.
|
|
57
|
+
*/
|
|
58
|
+
deselect: (value: string) => void;
|
|
59
|
+
/**
|
|
60
|
+
* Toggle selection of a value.
|
|
61
|
+
*/
|
|
62
|
+
toggle: (value: string) => void;
|
|
63
|
+
/**
|
|
64
|
+
* Replace the selection with a single value.
|
|
65
|
+
*/
|
|
66
|
+
replace: (value: string | null) => void;
|
|
67
|
+
/**
|
|
68
|
+
* Extend the selection from anchor to target.
|
|
69
|
+
*/
|
|
70
|
+
extend: (anchorValue: string, targetValue: string) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Set the selected values.
|
|
73
|
+
*/
|
|
74
|
+
setSelectedValues: (values: string[]) => void;
|
|
75
|
+
/**
|
|
76
|
+
* Clear the selection.
|
|
77
|
+
*/
|
|
78
|
+
clear: () => void;
|
|
79
|
+
/**
|
|
80
|
+
* Clear all selections.
|
|
81
|
+
*/
|
|
82
|
+
resetSelection: () => void;
|
|
83
|
+
/**
|
|
84
|
+
* Returns true if all items from the collection are selected.
|
|
85
|
+
*/
|
|
86
|
+
isAllSelected: () => boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Returns true if at least one item from the collection is selected.
|
|
89
|
+
*/
|
|
90
|
+
isSomeSelected: () => boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Set the selection to a specific array of items.
|
|
93
|
+
*/
|
|
94
|
+
setSelection: (selection: string[]) => void;
|
|
95
|
+
/**
|
|
96
|
+
* Set the selection mode.
|
|
97
|
+
*/
|
|
98
|
+
setSelectionMode: (mode: SelectionMode) => void;
|
|
99
|
+
/**
|
|
100
|
+
* Set whether the selection is deselectable.
|
|
101
|
+
*/
|
|
102
|
+
setDeselectable: (deselectable: boolean) => void;
|
|
103
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { SelectionMode } from '@zag-js/collection';
|
|
2
|
+
import { CollectionItem, ListCollection } from './list-collection';
|
|
3
|
+
export interface UseListSelectionProps<T extends CollectionItem> {
|
|
4
|
+
/**
|
|
5
|
+
* The selection mode.
|
|
6
|
+
*/
|
|
7
|
+
selectionMode?: SelectionMode;
|
|
8
|
+
/**
|
|
9
|
+
* Whether the selection is deselectable.
|
|
10
|
+
*/
|
|
11
|
+
deselectable?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* The initial selected values.
|
|
14
|
+
*/
|
|
15
|
+
initialSelectedValues?: string[];
|
|
16
|
+
/**
|
|
17
|
+
* Whether to reset the selection when the collection changes.
|
|
18
|
+
*/
|
|
19
|
+
resetOnCollectionChange?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The collection to use.
|
|
22
|
+
*/
|
|
23
|
+
collection: ListCollection<T>;
|
|
24
|
+
}
|
|
25
|
+
export declare function useListSelection<T extends CollectionItem>(props: UseListSelectionProps<T>): UseListSelectionReturn;
|
|
26
|
+
export interface UseListSelectionReturn {
|
|
27
|
+
/**
|
|
28
|
+
* The selected values as an array.
|
|
29
|
+
*/
|
|
30
|
+
selectedValues: string[];
|
|
31
|
+
/**
|
|
32
|
+
* Whether the selection is empty.
|
|
33
|
+
*/
|
|
34
|
+
isEmpty: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* The first selected value.
|
|
37
|
+
*/
|
|
38
|
+
firstSelectedValue: string | null;
|
|
39
|
+
/**
|
|
40
|
+
* The last selected value.
|
|
41
|
+
*/
|
|
42
|
+
lastSelectedValue: string | null;
|
|
43
|
+
/**
|
|
44
|
+
* Check if a value is selected.
|
|
45
|
+
*/
|
|
46
|
+
isSelected: (value: string | null) => boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Check if a value can be selected.
|
|
49
|
+
*/
|
|
50
|
+
canSelect: (value: string) => boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Select a value.
|
|
53
|
+
*/
|
|
54
|
+
select: (value: string, forceToggle?: boolean) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Deselect a value.
|
|
57
|
+
*/
|
|
58
|
+
deselect: (value: string) => void;
|
|
59
|
+
/**
|
|
60
|
+
* Toggle selection of a value.
|
|
61
|
+
*/
|
|
62
|
+
toggle: (value: string) => void;
|
|
63
|
+
/**
|
|
64
|
+
* Replace the selection with a single value.
|
|
65
|
+
*/
|
|
66
|
+
replace: (value: string | null) => void;
|
|
67
|
+
/**
|
|
68
|
+
* Extend the selection from anchor to target.
|
|
69
|
+
*/
|
|
70
|
+
extend: (anchorValue: string, targetValue: string) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Set the selected values.
|
|
73
|
+
*/
|
|
74
|
+
setSelectedValues: (values: string[]) => void;
|
|
75
|
+
/**
|
|
76
|
+
* Clear the selection.
|
|
77
|
+
*/
|
|
78
|
+
clear: () => void;
|
|
79
|
+
/**
|
|
80
|
+
* Clear all selections.
|
|
81
|
+
*/
|
|
82
|
+
resetSelection: () => void;
|
|
83
|
+
/**
|
|
84
|
+
* Returns true if all items from the collection are selected.
|
|
85
|
+
*/
|
|
86
|
+
isAllSelected: () => boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Returns true if at least one item from the collection is selected.
|
|
89
|
+
*/
|
|
90
|
+
isSomeSelected: () => boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Set the selection to a specific array of items.
|
|
93
|
+
*/
|
|
94
|
+
setSelection: (selection: string[]) => void;
|
|
95
|
+
/**
|
|
96
|
+
* Set the selection mode.
|
|
97
|
+
*/
|
|
98
|
+
setSelectionMode: (mode: SelectionMode) => void;
|
|
99
|
+
/**
|
|
100
|
+
* Set whether the selection is deselectable.
|
|
101
|
+
*/
|
|
102
|
+
setDeselectable: (deselectable: boolean) => void;
|
|
103
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Selection } from '@zag-js/collection';
|
|
3
|
+
import { useCallback, useState, useEffect, useMemo } from 'react';
|
|
4
|
+
import { useEvent } from '../../utils/use-event.js';
|
|
5
|
+
|
|
6
|
+
function useListSelection(props) {
|
|
7
|
+
const {
|
|
8
|
+
collection,
|
|
9
|
+
selectionMode = "single",
|
|
10
|
+
deselectable = true,
|
|
11
|
+
initialSelectedValues = [],
|
|
12
|
+
resetOnCollectionChange = false
|
|
13
|
+
} = props;
|
|
14
|
+
const createSelection = useCallback(
|
|
15
|
+
(values = []) => {
|
|
16
|
+
const selection2 = new Selection(values);
|
|
17
|
+
selection2.selectionMode = selectionMode;
|
|
18
|
+
selection2.deselectable = deselectable;
|
|
19
|
+
return selection2;
|
|
20
|
+
},
|
|
21
|
+
[selectionMode, deselectable]
|
|
22
|
+
);
|
|
23
|
+
const [selection, setSelectionState] = useState(() => createSelection(initialSelectedValues));
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (resetOnCollectionChange) {
|
|
26
|
+
setSelectionState(createSelection());
|
|
27
|
+
}
|
|
28
|
+
}, [collection.toString(), resetOnCollectionChange, createSelection]);
|
|
29
|
+
const selectedValues = useMemo(() => Array.from(selection), [selection]);
|
|
30
|
+
const isEmpty = useMemo(() => selection.isEmpty(), [selection]);
|
|
31
|
+
const firstSelectedValue = useMemo(() => selection.firstSelectedValue(collection), [selection, collection]);
|
|
32
|
+
const lastSelectedValue = useMemo(() => selection.lastSelectedValue(collection), [selection, collection]);
|
|
33
|
+
return {
|
|
34
|
+
selectedValues,
|
|
35
|
+
isEmpty,
|
|
36
|
+
firstSelectedValue,
|
|
37
|
+
lastSelectedValue,
|
|
38
|
+
isSelected: useEvent((value) => {
|
|
39
|
+
return selection.isSelected(value);
|
|
40
|
+
}),
|
|
41
|
+
isAllSelected: useEvent(() => {
|
|
42
|
+
const allValues = collection.getValues();
|
|
43
|
+
return allValues.length > 0 && allValues.every((value) => selection.isSelected(value));
|
|
44
|
+
}),
|
|
45
|
+
isSomeSelected: useEvent(() => {
|
|
46
|
+
const allValues = collection.getValues();
|
|
47
|
+
return allValues.some((value) => selection.isSelected(value));
|
|
48
|
+
}),
|
|
49
|
+
canSelect: useEvent((value) => {
|
|
50
|
+
return selection.canSelect(collection, value);
|
|
51
|
+
}),
|
|
52
|
+
select: useEvent((value, forceToggle) => {
|
|
53
|
+
setSelectionState(selection.select(collection, value, forceToggle));
|
|
54
|
+
}),
|
|
55
|
+
deselect: useEvent((value) => {
|
|
56
|
+
setSelectionState(selection.deselect(value));
|
|
57
|
+
}),
|
|
58
|
+
toggle: useEvent((value) => {
|
|
59
|
+
setSelectionState(selection.toggleSelection(collection, value));
|
|
60
|
+
}),
|
|
61
|
+
replace: useEvent((value) => {
|
|
62
|
+
setSelectionState(selection.replaceSelection(collection, value));
|
|
63
|
+
}),
|
|
64
|
+
extend: useEvent((anchorValue, targetValue) => {
|
|
65
|
+
setSelectionState(selection.extendSelection(collection, anchorValue, targetValue));
|
|
66
|
+
}),
|
|
67
|
+
setSelectedValues: useEvent((values) => {
|
|
68
|
+
setSelectionState(selection.setSelection(values));
|
|
69
|
+
}),
|
|
70
|
+
clear: useEvent(() => {
|
|
71
|
+
setSelectionState(selection.clearSelection());
|
|
72
|
+
}),
|
|
73
|
+
resetSelection: useEvent(() => {
|
|
74
|
+
setSelectionState(createSelection());
|
|
75
|
+
}),
|
|
76
|
+
setSelection: useEvent((newSelection) => {
|
|
77
|
+
setSelectionState(selection.setSelection(newSelection));
|
|
78
|
+
}),
|
|
79
|
+
setSelectionMode: useEvent((mode) => {
|
|
80
|
+
const newSelection = selection.copy();
|
|
81
|
+
newSelection.selectionMode = mode;
|
|
82
|
+
setSelectionState(newSelection);
|
|
83
|
+
}),
|
|
84
|
+
setDeselectable: useEvent((deselectable2) => {
|
|
85
|
+
const newSelection = selection.copy();
|
|
86
|
+
newSelection.deselectable = deselectable2;
|
|
87
|
+
setSelectionState(newSelection);
|
|
88
|
+
})
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export { useListSelection };
|
|
@@ -10,11 +10,11 @@ const factory = require('../factory.cjs');
|
|
|
10
10
|
const useColorPickerContext = require('./use-color-picker-context.cjs');
|
|
11
11
|
|
|
12
12
|
const ColorPickerValueText = react.forwardRef((props, ref) => {
|
|
13
|
-
const { children, format, ...
|
|
13
|
+
const { children, format, ...localProps } = props;
|
|
14
14
|
const colorPicker = useColorPickerContext.useColorPickerContext();
|
|
15
|
-
const mergedProps = react$1.mergeProps(colorPicker.getValueTextProps(),
|
|
15
|
+
const mergedProps = react$1.mergeProps(colorPicker.getValueTextProps(), localProps);
|
|
16
16
|
const valueAsString = format ? colorPicker.value.toString(format) : colorPicker.valueAsString;
|
|
17
|
-
return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.span, { ...mergedProps, ref, children:
|
|
17
|
+
return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.span, { ...mergedProps, ref, children: children || valueAsString });
|
|
18
18
|
});
|
|
19
19
|
ColorPickerValueText.displayName = "ColorPickerValueText";
|
|
20
20
|
|
|
@@ -6,11 +6,11 @@ import { ark } from '../factory.js';
|
|
|
6
6
|
import { useColorPickerContext } from './use-color-picker-context.js';
|
|
7
7
|
|
|
8
8
|
const ColorPickerValueText = forwardRef((props, ref) => {
|
|
9
|
-
const { children, format, ...
|
|
9
|
+
const { children, format, ...localProps } = props;
|
|
10
10
|
const colorPicker = useColorPickerContext();
|
|
11
|
-
const mergedProps = mergeProps(colorPicker.getValueTextProps(),
|
|
11
|
+
const mergedProps = mergeProps(colorPicker.getValueTextProps(), localProps);
|
|
12
12
|
const valueAsString = format ? colorPicker.value.toString(format) : colorPicker.valueAsString;
|
|
13
|
-
return /* @__PURE__ */ jsx(ark.span, { ...mergedProps, ref, children:
|
|
13
|
+
return /* @__PURE__ */ jsx(ark.span, { ...mergedProps, ref, children: children || valueAsString });
|
|
14
14
|
});
|
|
15
15
|
ColorPickerValueText.displayName = "ColorPickerValueText";
|
|
16
16
|
|
|
@@ -16,7 +16,8 @@ const useField = (props = {}) => {
|
|
|
16
16
|
const { ids, disabled = Boolean(fieldset?.disabled), invalid = false, readOnly = false, required = false } = props;
|
|
17
17
|
const [hasErrorText, setHasErrorText] = react.useState(false);
|
|
18
18
|
const [hasHelperText, setHasHelperText] = react.useState(false);
|
|
19
|
-
const
|
|
19
|
+
const uid = react.useId();
|
|
20
|
+
const id = props.id ?? uid;
|
|
20
21
|
const rootRef = react.useRef(null);
|
|
21
22
|
const rootId = ids?.control ?? `field::${id}`;
|
|
22
23
|
const errorTextId = ids?.errorText ?? `field::${id}::error-text`;
|
|
@@ -12,7 +12,8 @@ const useField = (props = {}) => {
|
|
|
12
12
|
const { ids, disabled = Boolean(fieldset?.disabled), invalid = false, readOnly = false, required = false } = props;
|
|
13
13
|
const [hasErrorText, setHasErrorText] = useState(false);
|
|
14
14
|
const [hasHelperText, setHasHelperText] = useState(false);
|
|
15
|
-
const
|
|
15
|
+
const uid = useId();
|
|
16
|
+
const id = props.id ?? uid;
|
|
16
17
|
const rootRef = useRef(null);
|
|
17
18
|
const rootId = ids?.control ?? `field::${id}`;
|
|
18
19
|
const errorTextId = ids?.errorText ?? `field::${id}::error-text`;
|
|
@@ -14,7 +14,8 @@ const useFieldset = (props = {}) => {
|
|
|
14
14
|
const env = useEnvironmentContext.useEnvironmentContext();
|
|
15
15
|
const hasErrorText = react.useRef(false);
|
|
16
16
|
const hasHelperText = react.useRef(false);
|
|
17
|
-
const
|
|
17
|
+
const uid = react.useId();
|
|
18
|
+
const id = props.id ?? uid;
|
|
18
19
|
const rootRef = react.useRef(null);
|
|
19
20
|
const errorTextId = `fieldset::${id}::error-text`;
|
|
20
21
|
const helperTextId = `fieldset::${id}::helper-text`;
|