@ariakit/core 0.4.4 → 0.4.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.
Files changed (128) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/cjs/__chunks/{Y7KNI5NS.cjs → 3HYNC3XA.cjs} +5 -5
  3. package/cjs/__chunks/{FFZYCAXA.cjs → 4W3OYRR3.cjs} +2 -2
  4. package/cjs/__chunks/{SU2BSHGB.cjs → B4AKUC4S.cjs} +2 -2
  5. package/cjs/__chunks/{7DU6YMLQ.cjs → D7M2PCAQ.cjs} +6 -6
  6. package/cjs/__chunks/LPDHSEHU.cjs +71 -0
  7. package/cjs/__chunks/{UKR6TQI3.cjs → Q2WCPTYS.cjs} +37 -39
  8. package/cjs/checkbox/checkbox-store.d.cts +2 -2
  9. package/cjs/checkbox/checkbox-store.d.ts +2 -2
  10. package/cjs/collection/collection-store.cjs +3 -3
  11. package/cjs/collection/collection-store.d.cts +2 -2
  12. package/cjs/collection/collection-store.d.ts +2 -2
  13. package/cjs/combobox/combobox-store.cjs +50 -22
  14. package/cjs/combobox/combobox-store.d.cts +20 -9
  15. package/cjs/combobox/combobox-store.d.ts +20 -9
  16. package/cjs/composite/composite-overflow-store.d.cts +2 -2
  17. package/cjs/composite/composite-overflow-store.d.ts +2 -2
  18. package/cjs/composite/composite-store.cjs +5 -5
  19. package/cjs/composite/composite-store.d.cts +3 -3
  20. package/cjs/composite/composite-store.d.ts +3 -3
  21. package/cjs/dialog/dialog-store.d.cts +2 -2
  22. package/cjs/dialog/dialog-store.d.ts +2 -2
  23. package/cjs/disclosure/disclosure-store.d.cts +2 -2
  24. package/cjs/disclosure/disclosure-store.d.ts +2 -2
  25. package/cjs/form/form-store.cjs +3 -3
  26. package/cjs/form/form-store.d.cts +4 -4
  27. package/cjs/form/form-store.d.ts +4 -4
  28. package/cjs/form/types.d.cts +3 -3
  29. package/cjs/form/types.d.ts +3 -3
  30. package/cjs/hovercard/hovercard-store.d.cts +3 -3
  31. package/cjs/hovercard/hovercard-store.d.ts +3 -3
  32. package/cjs/menu/menu-bar-store.cjs +6 -6
  33. package/cjs/menu/menu-bar-store.d.cts +2 -2
  34. package/cjs/menu/menu-bar-store.d.ts +2 -2
  35. package/cjs/menu/menu-store.cjs +7 -7
  36. package/cjs/menu/menu-store.d.cts +6 -6
  37. package/cjs/menu/menu-store.d.ts +6 -6
  38. package/cjs/menubar/menubar-store.cjs +6 -6
  39. package/cjs/menubar/menubar-store.d.cts +2 -2
  40. package/cjs/menubar/menubar-store.d.ts +2 -2
  41. package/cjs/popover/popover-store.d.cts +3 -3
  42. package/cjs/popover/popover-store.d.ts +3 -3
  43. package/cjs/radio/radio-store.cjs +5 -5
  44. package/cjs/radio/radio-store.d.cts +3 -3
  45. package/cjs/radio/radio-store.d.ts +3 -3
  46. package/cjs/select/select-store.cjs +21 -11
  47. package/cjs/select/select-store.d.cts +17 -9
  48. package/cjs/select/select-store.d.ts +17 -9
  49. package/cjs/tab/tab-store.cjs +46 -13
  50. package/cjs/tab/tab-store.d.cts +7 -6
  51. package/cjs/tab/tab-store.d.ts +7 -6
  52. package/cjs/tag/tag-store.cjs +90 -0
  53. package/cjs/tag/tag-store.d.cts +80 -0
  54. package/cjs/tag/tag-store.d.ts +80 -0
  55. package/cjs/toolbar/toolbar-store.cjs +5 -5
  56. package/cjs/toolbar/toolbar-store.d.cts +2 -2
  57. package/cjs/toolbar/toolbar-store.d.ts +2 -2
  58. package/cjs/tooltip/tooltip-store.d.cts +2 -2
  59. package/cjs/tooltip/tooltip-store.d.ts +2 -2
  60. package/cjs/utils/dom.cjs +2 -2
  61. package/cjs/utils/dom.d.cts +15 -22
  62. package/cjs/utils/dom.d.ts +15 -22
  63. package/cjs/utils/events.cjs +32 -16
  64. package/cjs/utils/events.d.cts +7 -1
  65. package/cjs/utils/events.d.ts +7 -1
  66. package/cjs/utils/focus.cjs +13 -15
  67. package/cjs/utils/focus.d.cts +1 -1
  68. package/cjs/utils/focus.d.ts +1 -1
  69. package/cjs/utils/misc.d.cts +1 -1
  70. package/cjs/utils/misc.d.ts +1 -1
  71. package/cjs/utils/platform.cjs +3 -3
  72. package/cjs/utils/store.d.cts +3 -3
  73. package/cjs/utils/store.d.ts +3 -3
  74. package/cjs/utils/undo.cjs +10 -0
  75. package/cjs/utils/undo.d.cts +19 -0
  76. package/cjs/utils/undo.d.ts +19 -0
  77. package/esm/__chunks/{VDNATJW2.js → CLSHHUGK.js} +1 -1
  78. package/esm/__chunks/EKIWAN6A.js +71 -0
  79. package/esm/__chunks/{URUD7X4C.js → EQPTKGFA.js} +1 -1
  80. package/esm/__chunks/{RRSZHCH6.js → I2NJJ3XW.js} +39 -41
  81. package/esm/__chunks/{PXYVPXSS.js → P3MTNH46.js} +1 -1
  82. package/esm/__chunks/{2H5K47H4.js → PBSSD2DM.js} +5 -5
  83. package/esm/checkbox/checkbox-store.d.ts +2 -2
  84. package/esm/collection/collection-store.d.ts +2 -2
  85. package/esm/collection/collection-store.js +2 -2
  86. package/esm/combobox/combobox-store.d.ts +20 -9
  87. package/esm/combobox/combobox-store.js +52 -24
  88. package/esm/composite/composite-overflow-store.d.ts +2 -2
  89. package/esm/composite/composite-store.d.ts +3 -3
  90. package/esm/composite/composite-store.js +4 -4
  91. package/esm/dialog/dialog-store.d.ts +2 -2
  92. package/esm/disclosure/disclosure-store.d.ts +2 -2
  93. package/esm/form/form-store.d.ts +4 -4
  94. package/esm/form/form-store.js +2 -2
  95. package/esm/form/types.d.ts +3 -3
  96. package/esm/hovercard/hovercard-store.d.ts +3 -3
  97. package/esm/menu/menu-bar-store.d.ts +2 -2
  98. package/esm/menu/menu-bar-store.js +5 -5
  99. package/esm/menu/menu-store.d.ts +6 -6
  100. package/esm/menu/menu-store.js +6 -6
  101. package/esm/menubar/menubar-store.d.ts +2 -2
  102. package/esm/menubar/menubar-store.js +5 -5
  103. package/esm/popover/popover-store.d.ts +3 -3
  104. package/esm/radio/radio-store.d.ts +3 -3
  105. package/esm/radio/radio-store.js +4 -4
  106. package/esm/select/select-store.d.ts +17 -9
  107. package/esm/select/select-store.js +20 -10
  108. package/esm/tab/tab-store.d.ts +7 -6
  109. package/esm/tab/tab-store.js +44 -11
  110. package/esm/tag/tag-store.d.ts +80 -0
  111. package/esm/tag/tag-store.js +90 -0
  112. package/esm/toolbar/toolbar-store.d.ts +2 -2
  113. package/esm/toolbar/toolbar-store.js +4 -4
  114. package/esm/tooltip/tooltip-store.d.ts +2 -2
  115. package/esm/utils/dom.d.ts +15 -22
  116. package/esm/utils/dom.js +5 -5
  117. package/esm/utils/events.d.ts +7 -1
  118. package/esm/utils/events.js +28 -12
  119. package/esm/utils/focus.d.ts +1 -1
  120. package/esm/utils/focus.js +5 -7
  121. package/esm/utils/misc.d.ts +1 -1
  122. package/esm/utils/platform.js +2 -2
  123. package/esm/utils/store.d.ts +3 -3
  124. package/esm/utils/undo.d.ts +19 -0
  125. package/esm/utils/undo.js +10 -0
  126. package/package.json +15 -1
  127. package/tag/tag-store/package.json +8 -0
  128. package/utils/undo/package.json +8 -0
@@ -1,10 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
- var _Y7KNI5NScjs = require('../__chunks/Y7KNI5NS.cjs');
4
+ var _3HYNC3XAcjs = require('../__chunks/3HYNC3XA.cjs');
5
5
 
6
6
 
7
- var _FFZYCAXAcjs = require('../__chunks/FFZYCAXA.cjs');
7
+ var _4W3OYRR3cjs = require('../__chunks/4W3OYRR3.cjs');
8
+ require('../__chunks/ULSPM3Y3.cjs');
8
9
 
9
10
 
10
11
 
@@ -15,9 +16,9 @@ var _FFZYCAXAcjs = require('../__chunks/FFZYCAXA.cjs');
15
16
  var _B4LYZ4EMcjs = require('../__chunks/B4LYZ4EM.cjs');
16
17
 
17
18
 
19
+
18
20
  var _EEDWPDM2cjs = require('../__chunks/EEDWPDM2.cjs');
19
- require('../__chunks/UKR6TQI3.cjs');
20
- require('../__chunks/ULSPM3Y3.cjs');
21
+ require('../__chunks/Q2WCPTYS.cjs');
21
22
 
22
23
 
23
24
 
@@ -38,6 +39,8 @@ function createTabStore(_a = {}) {
38
39
  "renderedItems",
39
40
  "moves",
40
41
  "orientation",
42
+ "virtualFocus",
43
+ "includesBaseElement",
41
44
  "baseElement",
42
45
  "focusLoop",
43
46
  "focusShift",
@@ -49,7 +52,17 @@ function createTabStore(_a = {}) {
49
52
  _B4LYZ4EMcjs.omit.call(void 0, combobox, independentKeys)
50
53
  );
51
54
  const syncState = store == null ? void 0 : store.getState();
52
- const composite = _Y7KNI5NScjs.createCompositeStore.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
55
+ const composite = _3HYNC3XAcjs.createCompositeStore.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
56
+ store,
57
+ // We need to explicitly set the default value of `includesBaseElement` to
58
+ // `false` since we don't want the composite store to default it to `true`
59
+ // when the activeId state is null, which could be the case when rendering
60
+ // combobox with tab.
61
+ includesBaseElement: _EEDWPDM2cjs.defaultValue.call(void 0,
62
+ props.includesBaseElement,
63
+ syncState == null ? void 0 : syncState.includesBaseElement,
64
+ false
65
+ ),
53
66
  orientation: _EEDWPDM2cjs.defaultValue.call(void 0,
54
67
  props.orientation,
55
68
  syncState == null ? void 0 : syncState.orientation,
@@ -57,13 +70,12 @@ function createTabStore(_a = {}) {
57
70
  ),
58
71
  focusLoop: _EEDWPDM2cjs.defaultValue.call(void 0, props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true)
59
72
  }));
60
- const panels = _FFZYCAXAcjs.createCollectionStore.call(void 0, );
73
+ const panels = _4W3OYRR3cjs.createCollectionStore.call(void 0, );
61
74
  const initialState = _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, composite.getState()), {
62
75
  selectedId: _EEDWPDM2cjs.defaultValue.call(void 0,
63
76
  props.selectedId,
64
77
  syncState == null ? void 0 : syncState.selectedId,
65
- props.defaultSelectedId,
66
- void 0
78
+ props.defaultSelectedId
67
79
  ),
68
80
  selectOnMove: _EEDWPDM2cjs.defaultValue.call(void 0,
69
81
  props.selectOnMove,
@@ -92,11 +104,11 @@ function createTabStore(_a = {}) {
92
104
  );
93
105
  _B4LYZ4EMcjs.setup.call(void 0,
94
106
  tab,
95
- () => _B4LYZ4EMcjs.batch.call(void 0,
96
- tab,
97
- ["selectedId"],
98
- (state) => tab.setState("activeId", state.selectedId)
99
- )
107
+ () => _B4LYZ4EMcjs.batch.call(void 0, tab, ["selectedId"], (state, prev) => {
108
+ if (parentComposite && state.selectedId === prev.selectedId)
109
+ return;
110
+ tab.setState("activeId", state.selectedId);
111
+ })
100
112
  );
101
113
  _B4LYZ4EMcjs.setup.call(void 0,
102
114
  tab,
@@ -137,6 +149,27 @@ function createTabStore(_a = {}) {
137
149
  });
138
150
  })
139
151
  );
152
+ let selectedIdFromSelectedValue = null;
153
+ _B4LYZ4EMcjs.setup.call(void 0, tab, () => {
154
+ const backupSelectedId = () => {
155
+ selectedIdFromSelectedValue = tab.getState().selectedId;
156
+ };
157
+ const restoreSelectedId = () => {
158
+ tab.setState("selectedId", selectedIdFromSelectedValue);
159
+ };
160
+ if (parentComposite && "setSelectElement" in parentComposite) {
161
+ return _EEDWPDM2cjs.chain.call(void 0,
162
+ _B4LYZ4EMcjs.sync.call(void 0, parentComposite, ["value"], backupSelectedId),
163
+ _B4LYZ4EMcjs.sync.call(void 0, parentComposite, ["open"], restoreSelectedId)
164
+ );
165
+ }
166
+ if (!combobox)
167
+ return;
168
+ return _EEDWPDM2cjs.chain.call(void 0,
169
+ _B4LYZ4EMcjs.sync.call(void 0, combobox, ["selectedValue"], backupSelectedId),
170
+ _B4LYZ4EMcjs.sync.call(void 0, combobox, ["open"], restoreSelectedId)
171
+ );
172
+ });
140
173
  return _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, composite), tab), {
141
174
  panels,
142
175
  setSelectedId: (id) => tab.setState("selectedId", id),
@@ -1,8 +1,9 @@
1
- import type { CollectionStore, CollectionStoreItem } from "../collection/collection-store.js";
2
- import type { ComboboxStore } from "../combobox/combobox-store.js";
3
- import type { CompositeStore, CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
4
- import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
5
- import type { SetState } from "../utils/types.js";
1
+ import type { CollectionStore, CollectionStoreItem } from "../collection/collection-store.ts";
2
+ import type { ComboboxStore } from "../combobox/combobox-store.ts";
3
+ import type { CompositeStore, CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.ts";
4
+ import type { SelectStore } from "../select/select-store.ts";
5
+ import type { Store, StoreOptions, StoreProps } from "../utils/store.ts";
6
+ import type { SetState } from "../utils/types.ts";
6
7
  export declare function createTabStore({ composite: parentComposite, combobox, ...props }?: TabStoreProps): TabStore;
7
8
  export interface TabStoreItem extends CompositeStoreItem {
8
9
  dimmed?: boolean;
@@ -85,7 +86,7 @@ export interface TabStoreOptions extends StoreOptions<TabStoreState, "orientatio
85
86
  * [Select](https://ariakit.org/components/select). The stores will share the
86
87
  * same state.
87
88
  */
88
- composite?: CompositeStore | null;
89
+ composite?: CompositeStore | SelectStore | null;
89
90
  /**
90
91
  * A reference to a [combobox
91
92
  * store](https://ariakit.org/reference/use-combobox-store). This is used when
@@ -1,8 +1,9 @@
1
- import type { CollectionStore, CollectionStoreItem } from "../collection/collection-store.js";
2
- import type { ComboboxStore } from "../combobox/combobox-store.js";
3
- import type { CompositeStore, CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
4
- import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
5
- import type { SetState } from "../utils/types.js";
1
+ import type { CollectionStore, CollectionStoreItem } from "../collection/collection-store.ts";
2
+ import type { ComboboxStore } from "../combobox/combobox-store.ts";
3
+ import type { CompositeStore, CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.ts";
4
+ import type { SelectStore } from "../select/select-store.ts";
5
+ import type { Store, StoreOptions, StoreProps } from "../utils/store.ts";
6
+ import type { SetState } from "../utils/types.ts";
6
7
  export declare function createTabStore({ composite: parentComposite, combobox, ...props }?: TabStoreProps): TabStore;
7
8
  export interface TabStoreItem extends CompositeStoreItem {
8
9
  dimmed?: boolean;
@@ -85,7 +86,7 @@ export interface TabStoreOptions extends StoreOptions<TabStoreState, "orientatio
85
86
  * [Select](https://ariakit.org/components/select). The stores will share the
86
87
  * same state.
87
88
  */
88
- composite?: CompositeStore | null;
89
+ composite?: CompositeStore | SelectStore | null;
89
90
  /**
90
91
  * A reference to a [combobox
91
92
  * store](https://ariakit.org/reference/use-combobox-store). This is used when
@@ -0,0 +1,90 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
+
3
+
4
+ var _3HYNC3XAcjs = require('../__chunks/3HYNC3XA.cjs');
5
+ require('../__chunks/4W3OYRR3.cjs');
6
+ require('../__chunks/ULSPM3Y3.cjs');
7
+
8
+
9
+ var _LPDHSEHUcjs = require('../__chunks/LPDHSEHU.cjs');
10
+
11
+
12
+
13
+
14
+ var _B4LYZ4EMcjs = require('../__chunks/B4LYZ4EM.cjs');
15
+
16
+
17
+
18
+ var _EEDWPDM2cjs = require('../__chunks/EEDWPDM2.cjs');
19
+ require('../__chunks/Q2WCPTYS.cjs');
20
+
21
+
22
+
23
+ var _AV6KTKLEcjs = require('../__chunks/AV6KTKLE.cjs');
24
+
25
+ // src/tag/tag-store.ts
26
+ function createTagStore(props = {}) {
27
+ var _a;
28
+ const syncState = (_a = props.store) == null ? void 0 : _a.getState();
29
+ const composite = _3HYNC3XAcjs.createCompositeStore.call(void 0, props);
30
+ const initialState = _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, composite.getState()), {
31
+ inputElement: _EEDWPDM2cjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.inputElement, null),
32
+ labelElement: _EEDWPDM2cjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.labelElement, null),
33
+ value: _EEDWPDM2cjs.defaultValue.call(void 0, props.value, syncState == null ? void 0 : syncState.value, props.defaultValue, ""),
34
+ values: _EEDWPDM2cjs.defaultValue.call(void 0,
35
+ props.values,
36
+ syncState == null ? void 0 : syncState.values,
37
+ props.defaultValues,
38
+ []
39
+ )
40
+ });
41
+ const tag = _B4LYZ4EMcjs.createStore.call(void 0, initialState, composite, props.store);
42
+ _B4LYZ4EMcjs.setup.call(void 0,
43
+ tag,
44
+ () => _B4LYZ4EMcjs.sync.call(void 0, tag, ["inputElement", "activeId"], (state) => {
45
+ if (!state.inputElement)
46
+ return;
47
+ if (state.activeId !== void 0)
48
+ return;
49
+ tag.setState("activeId", state.inputElement.id);
50
+ })
51
+ );
52
+ const setValues = (values) => {
53
+ const { values: previousValues } = tag.getState();
54
+ _LPDHSEHUcjs.UndoManager.execute(() => {
55
+ let changed = true;
56
+ tag.setState("values", (prev) => {
57
+ const next = _EEDWPDM2cjs.applyState.call(void 0, values, prev);
58
+ if (next === prev) {
59
+ changed = false;
60
+ }
61
+ return next;
62
+ });
63
+ if (!changed)
64
+ return;
65
+ return () => {
66
+ var _a2;
67
+ tag.setState("values", previousValues);
68
+ composite.move((_a2 = tag.getState().inputElement) == null ? void 0 : _a2.id);
69
+ };
70
+ });
71
+ };
72
+ return _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, composite), tag), {
73
+ setInputElement: (inputElement) => tag.setState("inputElement", inputElement),
74
+ setLabelElement: (labelElement) => tag.setState("labelElement", labelElement),
75
+ setValue: (value) => tag.setState("value", value),
76
+ resetValue: () => tag.setState("value", initialState.value),
77
+ setValues,
78
+ addValue: (value) => {
79
+ setValues((values) => {
80
+ if (values.includes(value))
81
+ return values;
82
+ return [...values, value];
83
+ });
84
+ },
85
+ removeValue: (value) => setValues((values) => values.filter((v) => v !== value))
86
+ });
87
+ }
88
+
89
+
90
+ exports.createTagStore = createTagStore;
@@ -0,0 +1,80 @@
1
+ import type { CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.ts";
2
+ import type { Store, StoreOptions, StoreProps } from "../utils/store.ts";
3
+ import type { SetState } from "../utils/types.ts";
4
+ /**
5
+ * Creates a tag store.
6
+ */
7
+ export declare function createTagStore(props?: TagStoreProps): TagStore;
8
+ export interface TagStoreItem extends CompositeStoreItem {
9
+ value?: string;
10
+ }
11
+ export interface TagStoreState extends CompositeStoreState<TagStoreItem> {
12
+ /**
13
+ * The input element.
14
+ */
15
+ inputElement: HTMLElement | null;
16
+ /**
17
+ * The label element.
18
+ */
19
+ labelElement: HTMLElement | null;
20
+ /**
21
+ * The value of the tag input.
22
+ * @default ""
23
+ */
24
+ value: string;
25
+ /**
26
+ * The values of the selected tags.
27
+ * @default []
28
+ */
29
+ values: string[];
30
+ }
31
+ export interface TagStoreFunctions extends CompositeStoreFunctions<TagStoreItem> {
32
+ /**
33
+ * Sets the `inputElement` state.
34
+ */
35
+ setInputElement: SetState<TagStoreState["inputElement"]>;
36
+ /**
37
+ * Sets the `labelElement` state.
38
+ */
39
+ setLabelElement: SetState<TagStoreState["labelElement"]>;
40
+ /**
41
+ * Sets the [`value`](https://ariakit.org/reference/tag-provider#value) state.
42
+ */
43
+ setValue: SetState<TagStoreState["value"]>;
44
+ /**
45
+ * Resets the [`value`](https://ariakit.org/reference/tag-provider#value)
46
+ * state to its initial value.
47
+ */
48
+ resetValue: () => void;
49
+ /**
50
+ * Sets the [`values`](https://ariakit.org/reference/tag-provider#values) state.
51
+ */
52
+ setValues: SetState<TagStoreState["values"]>;
53
+ /**
54
+ * Add a new value to the
55
+ * [`values`](https://ariakit.org/reference/tag-provider#values) state if it
56
+ * doesn't already exist.
57
+ */
58
+ addValue: (value: string) => void;
59
+ /**
60
+ * Remove a value from the
61
+ * [`values`](https://ariakit.org/reference/tag-provider#values) state.
62
+ */
63
+ removeValue: (value: string) => void;
64
+ }
65
+ export interface TagStoreOptions extends StoreOptions<TagStoreState, "value" | "values">, CompositeStoreOptions<TagStoreItem> {
66
+ /**
67
+ * The initial value of the tag input.
68
+ * @default ""
69
+ */
70
+ defaultValue?: TagStoreState["value"];
71
+ /**
72
+ * The initial selected tag values.
73
+ * @default []
74
+ */
75
+ defaultValues?: TagStoreState["values"];
76
+ }
77
+ export interface TagStoreProps extends TagStoreOptions, StoreProps<TagStoreState> {
78
+ }
79
+ export interface TagStore extends TagStoreFunctions, Store<TagStoreState> {
80
+ }
@@ -0,0 +1,80 @@
1
+ import type { CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.ts";
2
+ import type { Store, StoreOptions, StoreProps } from "../utils/store.ts";
3
+ import type { SetState } from "../utils/types.ts";
4
+ /**
5
+ * Creates a tag store.
6
+ */
7
+ export declare function createTagStore(props?: TagStoreProps): TagStore;
8
+ export interface TagStoreItem extends CompositeStoreItem {
9
+ value?: string;
10
+ }
11
+ export interface TagStoreState extends CompositeStoreState<TagStoreItem> {
12
+ /**
13
+ * The input element.
14
+ */
15
+ inputElement: HTMLElement | null;
16
+ /**
17
+ * The label element.
18
+ */
19
+ labelElement: HTMLElement | null;
20
+ /**
21
+ * The value of the tag input.
22
+ * @default ""
23
+ */
24
+ value: string;
25
+ /**
26
+ * The values of the selected tags.
27
+ * @default []
28
+ */
29
+ values: string[];
30
+ }
31
+ export interface TagStoreFunctions extends CompositeStoreFunctions<TagStoreItem> {
32
+ /**
33
+ * Sets the `inputElement` state.
34
+ */
35
+ setInputElement: SetState<TagStoreState["inputElement"]>;
36
+ /**
37
+ * Sets the `labelElement` state.
38
+ */
39
+ setLabelElement: SetState<TagStoreState["labelElement"]>;
40
+ /**
41
+ * Sets the [`value`](https://ariakit.org/reference/tag-provider#value) state.
42
+ */
43
+ setValue: SetState<TagStoreState["value"]>;
44
+ /**
45
+ * Resets the [`value`](https://ariakit.org/reference/tag-provider#value)
46
+ * state to its initial value.
47
+ */
48
+ resetValue: () => void;
49
+ /**
50
+ * Sets the [`values`](https://ariakit.org/reference/tag-provider#values) state.
51
+ */
52
+ setValues: SetState<TagStoreState["values"]>;
53
+ /**
54
+ * Add a new value to the
55
+ * [`values`](https://ariakit.org/reference/tag-provider#values) state if it
56
+ * doesn't already exist.
57
+ */
58
+ addValue: (value: string) => void;
59
+ /**
60
+ * Remove a value from the
61
+ * [`values`](https://ariakit.org/reference/tag-provider#values) state.
62
+ */
63
+ removeValue: (value: string) => void;
64
+ }
65
+ export interface TagStoreOptions extends StoreOptions<TagStoreState, "value" | "values">, CompositeStoreOptions<TagStoreItem> {
66
+ /**
67
+ * The initial value of the tag input.
68
+ * @default ""
69
+ */
70
+ defaultValue?: TagStoreState["value"];
71
+ /**
72
+ * The initial selected tag values.
73
+ * @default []
74
+ */
75
+ defaultValues?: TagStoreState["values"];
76
+ }
77
+ export interface TagStoreProps extends TagStoreOptions, StoreProps<TagStoreState> {
78
+ }
79
+ export interface TagStore extends TagStoreFunctions, Store<TagStoreState> {
80
+ }
@@ -1,14 +1,14 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
- var _Y7KNI5NScjs = require('../__chunks/Y7KNI5NS.cjs');
5
- require('../__chunks/FFZYCAXA.cjs');
4
+ var _3HYNC3XAcjs = require('../__chunks/3HYNC3XA.cjs');
5
+ require('../__chunks/4W3OYRR3.cjs');
6
+ require('../__chunks/ULSPM3Y3.cjs');
6
7
  require('../__chunks/B4LYZ4EM.cjs');
7
8
 
8
9
 
9
10
  var _EEDWPDM2cjs = require('../__chunks/EEDWPDM2.cjs');
10
- require('../__chunks/UKR6TQI3.cjs');
11
- require('../__chunks/ULSPM3Y3.cjs');
11
+ require('../__chunks/Q2WCPTYS.cjs');
12
12
 
13
13
 
14
14
 
@@ -18,7 +18,7 @@ var _AV6KTKLEcjs = require('../__chunks/AV6KTKLE.cjs');
18
18
  function createToolbarStore(props = {}) {
19
19
  var _a;
20
20
  const syncState = (_a = props.store) == null ? void 0 : _a.getState();
21
- return _Y7KNI5NScjs.createCompositeStore.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
21
+ return _3HYNC3XAcjs.createCompositeStore.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
22
22
  orientation: _EEDWPDM2cjs.defaultValue.call(void 0,
23
23
  props.orientation,
24
24
  syncState == null ? void 0 : syncState.orientation,
@@ -1,5 +1,5 @@
1
- import type { CompositeStoreFunctions, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
2
- import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
1
+ import type { CompositeStoreFunctions, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.ts";
2
+ import type { Store, StoreOptions, StoreProps } from "../utils/store.ts";
3
3
  /**
4
4
  * Creates a toolbar store.
5
5
  */
@@ -1,5 +1,5 @@
1
- import type { CompositeStoreFunctions, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
2
- import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
1
+ import type { CompositeStoreFunctions, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.ts";
2
+ import type { Store, StoreOptions, StoreProps } from "../utils/store.ts";
3
3
  /**
4
4
  * Creates a toolbar store.
5
5
  */
@@ -1,5 +1,5 @@
1
- import type { HovercardStoreFunctions, HovercardStoreOptions, HovercardStoreState } from "../hovercard/hovercard-store.js";
2
- import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
1
+ import type { HovercardStoreFunctions, HovercardStoreOptions, HovercardStoreState } from "../hovercard/hovercard-store.ts";
2
+ import type { Store, StoreOptions, StoreProps } from "../utils/store.ts";
3
3
  /**
4
4
  * Creates a tooltip store.
5
5
  */
@@ -1,5 +1,5 @@
1
- import type { HovercardStoreFunctions, HovercardStoreOptions, HovercardStoreState } from "../hovercard/hovercard-store.js";
2
- import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
1
+ import type { HovercardStoreFunctions, HovercardStoreOptions, HovercardStoreState } from "../hovercard/hovercard-store.ts";
2
+ import type { Store, StoreOptions, StoreProps } from "../utils/store.ts";
3
3
  /**
4
4
  * Creates a tooltip store.
5
5
  */
package/cjs/utils/dom.cjs CHANGED
@@ -18,7 +18,7 @@
18
18
 
19
19
 
20
20
 
21
- var _UKR6TQI3cjs = require('../__chunks/UKR6TQI3.cjs');
21
+ var _Q2WCPTYScjs = require('../__chunks/Q2WCPTYS.cjs');
22
22
  require('../__chunks/AV6KTKLE.cjs');
23
23
 
24
24
 
@@ -39,4 +39,4 @@ require('../__chunks/AV6KTKLE.cjs');
39
39
 
40
40
 
41
41
 
42
- exports.canUseDOM = _UKR6TQI3cjs.canUseDOM; exports.closest = _UKR6TQI3cjs.closest; exports.contains = _UKR6TQI3cjs.contains; exports.getActiveElement = _UKR6TQI3cjs.getActiveElement; exports.getDocument = _UKR6TQI3cjs.getDocument; exports.getPopupItemRole = _UKR6TQI3cjs.getPopupItemRole; exports.getPopupRole = _UKR6TQI3cjs.getPopupRole; exports.getScrollingElement = _UKR6TQI3cjs.getScrollingElement; exports.getTextboxSelection = _UKR6TQI3cjs.getTextboxSelection; exports.getWindow = _UKR6TQI3cjs.getWindow; exports.isButton = _UKR6TQI3cjs.isButton; exports.isFrame = _UKR6TQI3cjs.isFrame; exports.isPartiallyHidden = _UKR6TQI3cjs.isPartiallyHidden; exports.isTextField = _UKR6TQI3cjs.isTextField; exports.isVisible = _UKR6TQI3cjs.isVisible; exports.matches = _UKR6TQI3cjs.matches; exports.scrollIntoViewIfNeeded = _UKR6TQI3cjs.scrollIntoViewIfNeeded; exports.setSelectionRange = _UKR6TQI3cjs.setSelectionRange;
42
+ exports.canUseDOM = _Q2WCPTYScjs.canUseDOM; exports.contains = _Q2WCPTYScjs.contains; exports.getActiveElement = _Q2WCPTYScjs.getActiveElement; exports.getDocument = _Q2WCPTYScjs.getDocument; exports.getPopupItemRole = _Q2WCPTYScjs.getPopupItemRole; exports.getPopupRole = _Q2WCPTYScjs.getPopupRole; exports.getScrollingElement = _Q2WCPTYScjs.getScrollingElement; exports.getTextboxSelection = _Q2WCPTYScjs.getTextboxSelection; exports.getTextboxValue = _Q2WCPTYScjs.getTextboxValue; exports.getWindow = _Q2WCPTYScjs.getWindow; exports.isButton = _Q2WCPTYScjs.isButton; exports.isFrame = _Q2WCPTYScjs.isFrame; exports.isPartiallyHidden = _Q2WCPTYScjs.isPartiallyHidden; exports.isTextField = _Q2WCPTYScjs.isTextField; exports.isTextbox = _Q2WCPTYScjs.isTextbox; exports.isVisible = _Q2WCPTYScjs.isVisible; exports.scrollIntoViewIfNeeded = _Q2WCPTYScjs.scrollIntoViewIfNeeded; exports.setSelectionRange = _Q2WCPTYScjs.setSelectionRange;
@@ -1,4 +1,4 @@
1
- import type { AriaHasPopup, AriaRole } from "./types.js";
1
+ import type { AriaHasPopup, AriaRole } from "./types.ts";
2
2
  /**
3
3
  * It's `true` if it is running in a browser environment or `false` if it is not
4
4
  * (SSR).
@@ -45,26 +45,10 @@ export declare function isButton(element: {
45
45
  tagName: string;
46
46
  type?: string;
47
47
  }): boolean;
48
- /**
49
- * Ponyfill for `Element.prototype.matches`
50
- *
51
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/matches
52
- */
53
- export declare function matches(element: Element, selectors: string): boolean;
54
48
  /**
55
49
  * Checks if the element is visible or not.
56
50
  */
57
51
  export declare function isVisible(element: Element): boolean;
58
- /**
59
- * Ponyfill for `Element.prototype.closest`
60
- * @example
61
- * closest(document.getElementById("id"), "div");
62
- * // same as
63
- * document.getElementById("id").closest("div");
64
- */
65
- export declare function closest<K extends keyof HTMLElementTagNameMap>(element: Element, selectors: K): HTMLElementTagNameMap[K];
66
- export declare function closest<K extends keyof SVGElementTagNameMap>(element: Element, selectors: K): SVGElementTagNameMap[K];
67
- export declare function closest<T extends Element = Element>(element: Element, selectors: string): T | null;
68
52
  /**
69
53
  * Check whether the given element is a text field, where text field is defined
70
54
  * by the ability to select within the input.
@@ -76,13 +60,14 @@ export declare function closest<T extends Element = Element>(element: Element, s
76
60
  */
77
61
  export declare function isTextField(element: Element): element is HTMLInputElement | HTMLTextAreaElement;
78
62
  /**
79
- * Returns the element's role attribute, if it has one.
63
+ * Check whether the given element is a text field or a content editable
64
+ * element.
80
65
  */
81
- export declare function getPopupRole(element?: Element | null, fallback?: AriaHasPopup): AriaHasPopup;
66
+ export declare function isTextbox(element: HTMLElement): boolean;
82
67
  /**
83
- * Returns the item role attribute based on the popup's role.
68
+ * Returns the value of the text field or content editable element as a string.
84
69
  */
85
- export declare function getPopupItemRole(element?: Element | null, fallback?: AriaRole): string | undefined;
70
+ export declare function getTextboxValue(element: HTMLElement): string;
86
71
  /**
87
72
  * Returns the start and end offsets of the selection in the element.
88
73
  */
@@ -90,6 +75,14 @@ export declare function getTextboxSelection(element: HTMLElement): {
90
75
  start: number;
91
76
  end: number;
92
77
  };
78
+ /**
79
+ * Returns the element's role attribute, if it has one.
80
+ */
81
+ export declare function getPopupRole(element?: Element | null, fallback?: AriaHasPopup): AriaHasPopup;
82
+ /**
83
+ * Returns the item role attribute based on the popup's role.
84
+ */
85
+ export declare function getPopupItemRole(element?: Element | null, fallback?: AriaRole): string | undefined;
93
86
  /**
94
87
  * Calls `element.scrollIntoView()` if the element is hidden or partly hidden in
95
88
  * the viewport.
@@ -112,4 +105,4 @@ export declare function isPartiallyHidden(element: Element): boolean;
112
105
  * @see
113
106
  * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
114
107
  */
115
- export declare function setSelectionRange(element: HTMLInputElement, ...args: Parameters<typeof HTMLInputElement.prototype.setSelectionRange>): void;
108
+ export declare function setSelectionRange(element: HTMLInputElement | HTMLTextAreaElement, ...args: Parameters<typeof HTMLInputElement.prototype.setSelectionRange>): void;
@@ -1,4 +1,4 @@
1
- import type { AriaHasPopup, AriaRole } from "./types.js";
1
+ import type { AriaHasPopup, AriaRole } from "./types.ts";
2
2
  /**
3
3
  * It's `true` if it is running in a browser environment or `false` if it is not
4
4
  * (SSR).
@@ -45,26 +45,10 @@ export declare function isButton(element: {
45
45
  tagName: string;
46
46
  type?: string;
47
47
  }): boolean;
48
- /**
49
- * Ponyfill for `Element.prototype.matches`
50
- *
51
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/matches
52
- */
53
- export declare function matches(element: Element, selectors: string): boolean;
54
48
  /**
55
49
  * Checks if the element is visible or not.
56
50
  */
57
51
  export declare function isVisible(element: Element): boolean;
58
- /**
59
- * Ponyfill for `Element.prototype.closest`
60
- * @example
61
- * closest(document.getElementById("id"), "div");
62
- * // same as
63
- * document.getElementById("id").closest("div");
64
- */
65
- export declare function closest<K extends keyof HTMLElementTagNameMap>(element: Element, selectors: K): HTMLElementTagNameMap[K];
66
- export declare function closest<K extends keyof SVGElementTagNameMap>(element: Element, selectors: K): SVGElementTagNameMap[K];
67
- export declare function closest<T extends Element = Element>(element: Element, selectors: string): T | null;
68
52
  /**
69
53
  * Check whether the given element is a text field, where text field is defined
70
54
  * by the ability to select within the input.
@@ -76,13 +60,14 @@ export declare function closest<T extends Element = Element>(element: Element, s
76
60
  */
77
61
  export declare function isTextField(element: Element): element is HTMLInputElement | HTMLTextAreaElement;
78
62
  /**
79
- * Returns the element's role attribute, if it has one.
63
+ * Check whether the given element is a text field or a content editable
64
+ * element.
80
65
  */
81
- export declare function getPopupRole(element?: Element | null, fallback?: AriaHasPopup): AriaHasPopup;
66
+ export declare function isTextbox(element: HTMLElement): boolean;
82
67
  /**
83
- * Returns the item role attribute based on the popup's role.
68
+ * Returns the value of the text field or content editable element as a string.
84
69
  */
85
- export declare function getPopupItemRole(element?: Element | null, fallback?: AriaRole): string | undefined;
70
+ export declare function getTextboxValue(element: HTMLElement): string;
86
71
  /**
87
72
  * Returns the start and end offsets of the selection in the element.
88
73
  */
@@ -90,6 +75,14 @@ export declare function getTextboxSelection(element: HTMLElement): {
90
75
  start: number;
91
76
  end: number;
92
77
  };
78
+ /**
79
+ * Returns the element's role attribute, if it has one.
80
+ */
81
+ export declare function getPopupRole(element?: Element | null, fallback?: AriaHasPopup): AriaHasPopup;
82
+ /**
83
+ * Returns the item role attribute based on the popup's role.
84
+ */
85
+ export declare function getPopupItemRole(element?: Element | null, fallback?: AriaRole): string | undefined;
93
86
  /**
94
87
  * Calls `element.scrollIntoView()` if the element is hidden or partly hidden in
95
88
  * the viewport.
@@ -112,4 +105,4 @@ export declare function isPartiallyHidden(element: Element): boolean;
112
105
  * @see
113
106
  * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
114
107
  */
115
- export declare function setSelectionRange(element: HTMLInputElement, ...args: Parameters<typeof HTMLInputElement.prototype.setSelectionRange>): void;
108
+ export declare function setSelectionRange(element: HTMLInputElement | HTMLTextAreaElement, ...args: Parameters<typeof HTMLInputElement.prototype.setSelectionRange>): void;