@ark-ui/react 5.17.0 → 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.
Files changed (65) hide show
  1. package/dist/components/collection/index.cjs +2 -0
  2. package/dist/components/collection/index.d.cts +1 -0
  3. package/dist/components/collection/index.d.ts +1 -0
  4. package/dist/components/collection/index.js +1 -0
  5. package/dist/components/collection/use-list-selection.cjs +96 -0
  6. package/dist/components/collection/use-list-selection.d.cts +103 -0
  7. package/dist/components/collection/use-list-selection.d.ts +103 -0
  8. package/dist/components/collection/use-list-selection.js +92 -0
  9. package/dist/components/file-upload/file-upload-root.cjs +2 -0
  10. package/dist/components/file-upload/file-upload-root.js +2 -0
  11. package/dist/components/index.cjs +10 -0
  12. package/dist/components/index.d.cts +1 -0
  13. package/dist/components/index.d.ts +1 -0
  14. package/dist/components/index.js +6 -0
  15. package/dist/components/json-tree-view/get-branch-value.cjs +19 -0
  16. package/dist/components/json-tree-view/get-branch-value.d.cts +3 -0
  17. package/dist/components/json-tree-view/get-branch-value.d.ts +3 -0
  18. package/dist/components/json-tree-view/get-branch-value.js +15 -0
  19. package/dist/components/json-tree-view/index.cjs +17 -0
  20. package/dist/components/json-tree-view/index.d.cts +5 -0
  21. package/dist/components/json-tree-view/index.d.ts +5 -0
  22. package/dist/components/json-tree-view/index.js +6 -0
  23. package/dist/components/json-tree-view/json-tree-view-key-node.cjs +18 -0
  24. package/dist/components/json-tree-view/json-tree-view-key-node.d.cts +13 -0
  25. package/dist/components/json-tree-view/json-tree-view-key-node.d.ts +13 -0
  26. package/dist/components/json-tree-view/json-tree-view-key-node.js +14 -0
  27. package/dist/components/json-tree-view/json-tree-view-node.cjs +62 -0
  28. package/dist/components/json-tree-view/json-tree-view-node.d.cts +20 -0
  29. package/dist/components/json-tree-view/json-tree-view-node.d.ts +20 -0
  30. package/dist/components/json-tree-view/json-tree-view-node.js +58 -0
  31. package/dist/components/json-tree-view/json-tree-view-props-context.cjs +15 -0
  32. package/dist/components/json-tree-view/json-tree-view-props-context.d.cts +9 -0
  33. package/dist/components/json-tree-view/json-tree-view-props-context.d.ts +9 -0
  34. package/dist/components/json-tree-view/json-tree-view-props-context.js +10 -0
  35. package/dist/components/json-tree-view/json-tree-view-root-provider.cjs +15 -0
  36. package/dist/components/json-tree-view/json-tree-view-root-provider.d.cts +6 -0
  37. package/dist/components/json-tree-view/json-tree-view-root-provider.d.ts +6 -0
  38. package/dist/components/json-tree-view/json-tree-view-root-provider.js +11 -0
  39. package/dist/components/json-tree-view/json-tree-view-root.cjs +48 -0
  40. package/dist/components/json-tree-view/json-tree-view-root.d.cts +15 -0
  41. package/dist/components/json-tree-view/json-tree-view-root.d.ts +15 -0
  42. package/dist/components/json-tree-view/json-tree-view-root.js +44 -0
  43. package/dist/components/json-tree-view/json-tree-view-tree.cjs +22 -0
  44. package/dist/components/json-tree-view/json-tree-view-tree.d.cts +6 -0
  45. package/dist/components/json-tree-view/json-tree-view-tree.d.ts +6 -0
  46. package/dist/components/json-tree-view/json-tree-view-tree.js +18 -0
  47. package/dist/components/json-tree-view/json-tree-view-value-node.cjs +26 -0
  48. package/dist/components/json-tree-view/json-tree-view-value-node.d.cts +7 -0
  49. package/dist/components/json-tree-view/json-tree-view-value-node.d.ts +7 -0
  50. package/dist/components/json-tree-view/json-tree-view-value-node.js +22 -0
  51. package/dist/components/json-tree-view/json-tree-view.cjs +13 -0
  52. package/dist/components/json-tree-view/json-tree-view.d.cts +3 -0
  53. package/dist/components/json-tree-view/json-tree-view.d.ts +3 -0
  54. package/dist/components/json-tree-view/json-tree-view.js +3 -0
  55. package/dist/components/json-tree-view/use-json-tree-view.cjs +32 -0
  56. package/dist/components/json-tree-view/use-json-tree-view.d.cts +9 -0
  57. package/dist/components/json-tree-view/use-json-tree-view.d.ts +9 -0
  58. package/dist/components/json-tree-view/use-json-tree-view.js +28 -0
  59. package/dist/components/signature-pad/signature-pad-root.cjs +2 -0
  60. package/dist/components/signature-pad/signature-pad-root.js +2 -0
  61. package/dist/components/tree-view/use-tree-view.d.cts +1 -1
  62. package/dist/components/tree-view/use-tree-view.d.ts +1 -1
  63. package/dist/index.cjs +10 -0
  64. package/dist/index.js +6 -0
  65. package/package.json +63 -62
@@ -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;
@@ -2,3 +2,4 @@ export { createGridCollection, type GridCollection, type GridCollectionOptions }
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
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, type GridCollection, type GridCollectionOptions }
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
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 };
@@ -14,8 +14,10 @@ const useFileUploadContext = require('./use-file-upload-context.cjs');
14
14
  const FileUploadRoot = react.forwardRef((props, ref) => {
15
15
  const [useFileUploadProps, localProps] = createSplitProps.createSplitProps()(props, [
16
16
  "accept",
17
+ "acceptedFiles",
17
18
  "allowDrop",
18
19
  "capture",
20
+ "defaultAcceptedFiles",
19
21
  "directory",
20
22
  "disabled",
21
23
  "id",
@@ -10,8 +10,10 @@ import { FileUploadProvider } from './use-file-upload-context.js';
10
10
  const FileUploadRoot = forwardRef((props, ref) => {
11
11
  const [useFileUploadProps, localProps] = createSplitProps()(props, [
12
12
  "accept",
13
+ "acceptedFiles",
13
14
  "allowDrop",
14
15
  "capture",
16
+ "defaultAcceptedFiles",
15
17
  "directory",
16
18
  "disabled",
17
19
  "id",
@@ -324,6 +324,11 @@ const useMenu = require('./menu/use-menu.cjs');
324
324
  const useMenuContext = require('./menu/use-menu-context.cjs');
325
325
  const useMenuItemContext = require('./menu/use-menu-item-context.cjs');
326
326
  const menu$1 = require('./menu/menu.cjs');
327
+ const jsonTreeViewRoot = require('./json-tree-view/json-tree-view-root.cjs');
328
+ const jsonTreeViewRootProvider = require('./json-tree-view/json-tree-view-root-provider.cjs');
329
+ const jsonTreeViewTree = require('./json-tree-view/json-tree-view-tree.cjs');
330
+ const useJsonTreeView = require('./json-tree-view/use-json-tree-view.cjs');
331
+ const jsonTreeView = require('./json-tree-view/json-tree-view.cjs');
327
332
  const numberInputContext = require('./number-input/number-input-context.cjs');
328
333
  const numberInputControl = require('./number-input/number-input-control.cjs');
329
334
  const numberInputDecrementTrigger = require('./number-input/number-input-decrement-trigger.cjs');
@@ -1044,6 +1049,11 @@ exports.useMenu = useMenu.useMenu;
1044
1049
  exports.useMenuContext = useMenuContext.useMenuContext;
1045
1050
  exports.useMenuItemContext = useMenuItemContext.useMenuItemContext;
1046
1051
  exports.Menu = menu$1;
1052
+ exports.JsonTreeViewRoot = jsonTreeViewRoot.JsonTreeViewRoot;
1053
+ exports.JsonTreeViewRootProvider = jsonTreeViewRootProvider.JsonTreeViewRootProvider;
1054
+ exports.JsonTreeViewTree = jsonTreeViewTree.JsonTreeViewTree;
1055
+ exports.useJsonTreeView = useJsonTreeView.useJsonTreeView;
1056
+ exports.JsonTreeView = jsonTreeView;
1047
1057
  exports.NumberInputContext = numberInputContext.NumberInputContext;
1048
1058
  exports.NumberInputControl = numberInputControl.NumberInputControl;
1049
1059
  exports.NumberInputDecrementTrigger = numberInputDecrementTrigger.NumberInputDecrementTrigger;
@@ -24,6 +24,7 @@ export * from './highlight';
24
24
  export * from './hover-card';
25
25
  export * from './listbox';
26
26
  export * from './menu';
27
+ export * from './json-tree-view';
27
28
  export * from './number-input';
28
29
  export * from './pagination';
29
30
  export * from './password-input';
@@ -24,6 +24,7 @@ export * from './highlight';
24
24
  export * from './hover-card';
25
25
  export * from './listbox';
26
26
  export * from './menu';
27
+ export * from './json-tree-view';
27
28
  export * from './number-input';
28
29
  export * from './pagination';
29
30
  export * from './password-input';
@@ -340,6 +340,12 @@ export { useMenuContext } from './menu/use-menu-context.js';
340
340
  export { useMenuItemContext } from './menu/use-menu-item-context.js';
341
341
  import * as menu from './menu/menu.js';
342
342
  export { menu as Menu };
343
+ export { JsonTreeViewRoot } from './json-tree-view/json-tree-view-root.js';
344
+ export { JsonTreeViewRootProvider } from './json-tree-view/json-tree-view-root-provider.js';
345
+ export { JsonTreeViewTree } from './json-tree-view/json-tree-view-tree.js';
346
+ export { useJsonTreeView } from './json-tree-view/use-json-tree-view.js';
347
+ import * as jsonTreeView from './json-tree-view/json-tree-view.js';
348
+ export { jsonTreeView as JsonTreeView };
343
349
  export { NumberInputContext } from './number-input/number-input-context.js';
344
350
  export { NumberInputControl } from './number-input/number-input-control.js';
345
351
  export { NumberInputDecrementTrigger } from './number-input/number-input-decrement-trigger.js';
@@ -0,0 +1,19 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
+
6
+ function getBranchValues(tree, depth) {
7
+ let values = [];
8
+ tree.visit({
9
+ onEnter: (node, indexPath) => {
10
+ if (indexPath.length === 0) return;
11
+ if (tree.isBranchNode(node) && indexPath.length <= depth) {
12
+ values.push(tree.getNodeValue(node));
13
+ }
14
+ }
15
+ });
16
+ return values;
17
+ }
18
+
19
+ exports.getBranchValues = getBranchValues;
@@ -0,0 +1,3 @@
1
+ import { TreeCollection } from '@zag-js/collection';
2
+ import { JsonNode } from '@zag-js/json-tree-utils';
3
+ export declare function getBranchValues(tree: TreeCollection<JsonNode>, depth: number): string[];
@@ -0,0 +1,3 @@
1
+ import { TreeCollection } from '@zag-js/collection';
2
+ import { JsonNode } from '@zag-js/json-tree-utils';
3
+ export declare function getBranchValues(tree: TreeCollection<JsonNode>, depth: number): string[];
@@ -0,0 +1,15 @@
1
+ 'use client';
2
+ function getBranchValues(tree, depth) {
3
+ let values = [];
4
+ tree.visit({
5
+ onEnter: (node, indexPath) => {
6
+ if (indexPath.length === 0) return;
7
+ if (tree.isBranchNode(node) && indexPath.length <= depth) {
8
+ values.push(tree.getNodeValue(node));
9
+ }
10
+ }
11
+ });
12
+ return values;
13
+ }
14
+
15
+ export { getBranchValues };
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const jsonTreeViewRoot = require('./json-tree-view-root.cjs');
6
+ const jsonTreeViewRootProvider = require('./json-tree-view-root-provider.cjs');
7
+ const jsonTreeViewTree = require('./json-tree-view-tree.cjs');
8
+ const useJsonTreeView = require('./use-json-tree-view.cjs');
9
+ const jsonTreeView = require('./json-tree-view.cjs');
10
+
11
+
12
+
13
+ exports.JsonTreeViewRoot = jsonTreeViewRoot.JsonTreeViewRoot;
14
+ exports.JsonTreeViewRootProvider = jsonTreeViewRootProvider.JsonTreeViewRootProvider;
15
+ exports.JsonTreeViewTree = jsonTreeViewTree.JsonTreeViewTree;
16
+ exports.useJsonTreeView = useJsonTreeView.useJsonTreeView;
17
+ exports.JsonTreeView = jsonTreeView;
@@ -0,0 +1,5 @@
1
+ export { JsonTreeViewRoot, type JsonTreeViewRootProps } from './json-tree-view-root';
2
+ export { JsonTreeViewRootProvider, type JsonTreeViewRootProviderProps } from './json-tree-view-root-provider';
3
+ export { JsonTreeViewTree, type JsonTreeViewTreeProps } from './json-tree-view-tree';
4
+ export { useJsonTreeView, type UseJsonTreeViewProps, type UseJsonTreeViewReturn } from './use-json-tree-view';
5
+ export * as JsonTreeView from './json-tree-view';
@@ -0,0 +1,5 @@
1
+ export { JsonTreeViewRoot, type JsonTreeViewRootProps } from './json-tree-view-root';
2
+ export { JsonTreeViewRootProvider, type JsonTreeViewRootProviderProps } from './json-tree-view-root-provider';
3
+ export { JsonTreeViewTree, type JsonTreeViewTreeProps } from './json-tree-view-tree';
4
+ export { useJsonTreeView, type UseJsonTreeViewProps, type UseJsonTreeViewReturn } from './use-json-tree-view';
5
+ export * as JsonTreeView from './json-tree-view';
@@ -0,0 +1,6 @@
1
+ export { JsonTreeViewRoot } from './json-tree-view-root.js';
2
+ export { JsonTreeViewRootProvider } from './json-tree-view-root-provider.js';
3
+ export { JsonTreeViewTree } from './json-tree-view-tree.js';
4
+ export { useJsonTreeView } from './use-json-tree-view.js';
5
+ import * as jsonTreeView from './json-tree-view.js';
6
+ export { jsonTreeView as JsonTreeView };
@@ -0,0 +1,18 @@
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 jsonTreeUtils = require('@zag-js/json-tree-utils');
8
+
9
+ const JsonTreeViewKeyNode = (props) => {
10
+ const { node, showQuotes } = props;
11
+ const key = jsonTreeUtils.keyPathToKey(node.keyPath);
12
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
13
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "data-kind": "key", suppressHydrationWarning: true, "data-non-enumerable": node.isNonEnumerable ? "" : void 0, children: showQuotes ? `"${key}"` : key }),
14
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "data-kind": "colon", children: ": " })
15
+ ] });
16
+ };
17
+
18
+ exports.JsonTreeViewKeyNode = JsonTreeViewKeyNode;
@@ -0,0 +1,13 @@
1
+ import { JsonNode } from '@zag-js/json-tree-utils';
2
+ interface JsonTreeViewKeyNodeProps {
3
+ /**
4
+ * The node to render.
5
+ */
6
+ node: JsonNode;
7
+ /**
8
+ * Whether to show quotes on the key.
9
+ */
10
+ showQuotes?: boolean;
11
+ }
12
+ export declare const JsonTreeViewKeyNode: (props: JsonTreeViewKeyNodeProps) => React.ReactNode;
13
+ export {};
@@ -0,0 +1,13 @@
1
+ import { JsonNode } from '@zag-js/json-tree-utils';
2
+ interface JsonTreeViewKeyNodeProps {
3
+ /**
4
+ * The node to render.
5
+ */
6
+ node: JsonNode;
7
+ /**
8
+ * Whether to show quotes on the key.
9
+ */
10
+ showQuotes?: boolean;
11
+ }
12
+ export declare const JsonTreeViewKeyNode: (props: JsonTreeViewKeyNodeProps) => React.ReactNode;
13
+ export {};
@@ -0,0 +1,14 @@
1
+ 'use client';
2
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
3
+ import { keyPathToKey } from '@zag-js/json-tree-utils';
4
+
5
+ const JsonTreeViewKeyNode = (props) => {
6
+ const { node, showQuotes } = props;
7
+ const key = keyPathToKey(node.keyPath);
8
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
9
+ /* @__PURE__ */ jsx("span", { "data-kind": "key", suppressHydrationWarning: true, "data-non-enumerable": node.isNonEnumerable ? "" : void 0, children: showQuotes ? `"${key}"` : key }),
10
+ /* @__PURE__ */ jsx("span", { "data-kind": "colon", children: ": " })
11
+ ] });
12
+ };
13
+
14
+ export { JsonTreeViewKeyNode };