@ariakit/react-core 0.4.4 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/cjs/__chunks/{QUHFOHHT.cjs → 3HMQOCLF.cjs} +10 -27
  3. package/cjs/__chunks/{YO7LLGVA.cjs → AY5J25V7.cjs} +2 -2
  4. package/cjs/__chunks/{4XVTH6OR.cjs → DFXPO2ED.cjs} +2 -2
  5. package/cjs/__chunks/{HPNCFYQJ.cjs → GZ2NNSLV.cjs} +4 -4
  6. package/cjs/__chunks/ISJGSS4S.cjs +16 -0
  7. package/cjs/__chunks/{COWKMNMZ.cjs → N43E53E6.cjs} +3 -3
  8. package/cjs/__chunks/{54YZYOPA.cjs → NRPEUNJB.cjs} +2 -2
  9. package/cjs/__chunks/PVLZGFP6.cjs +34 -0
  10. package/cjs/__chunks/{ZTAE5B6W.cjs → QJDA4LG6.cjs} +19 -16
  11. package/cjs/__chunks/{NDVZ37O3.cjs → RG6U7KAS.cjs} +22 -4
  12. package/cjs/__chunks/YWAHOWYE.cjs +25 -0
  13. package/cjs/combobox/combobox-cancel.cjs +3 -3
  14. package/cjs/combobox/combobox-disclosure.cjs +3 -3
  15. package/cjs/combobox/combobox-item.cjs +19 -9
  16. package/cjs/combobox/combobox-item.d.cts +22 -12
  17. package/cjs/combobox/combobox-item.d.ts +22 -12
  18. package/cjs/combobox/combobox-popover.cjs +22 -15
  19. package/cjs/combobox/combobox-provider.cjs +3 -2
  20. package/cjs/combobox/combobox-store.cjs +6 -2
  21. package/cjs/combobox/combobox-store.d.cts +12 -4
  22. package/cjs/combobox/combobox-store.d.ts +12 -4
  23. package/cjs/combobox/combobox-value.cjs +32 -0
  24. package/cjs/combobox/combobox-value.d.cts +41 -0
  25. package/cjs/combobox/combobox-value.d.ts +41 -0
  26. package/cjs/combobox/combobox.cjs +66 -22
  27. package/cjs/composite/composite-item.cjs +3 -3
  28. package/cjs/composite/composite-overflow-disclosure.cjs +3 -3
  29. package/cjs/composite/composite-overflow.cjs +12 -12
  30. package/cjs/dialog/dialog-backdrop.cjs +3 -3
  31. package/cjs/dialog/dialog.cjs +11 -11
  32. package/cjs/dialog/dialog.d.cts +4 -0
  33. package/cjs/dialog/dialog.d.ts +4 -0
  34. package/cjs/dialog/utils/disable-tree.cjs +3 -3
  35. package/cjs/dialog/utils/use-prevent-body-scroll.cjs +3 -3
  36. package/cjs/form/form-checkbox.cjs +1 -1
  37. package/cjs/form/form-push.cjs +1 -1
  38. package/cjs/form/form-radio.cjs +4 -4
  39. package/cjs/hovercard/hovercard.cjs +13 -13
  40. package/cjs/menu/menu-item-checkbox.cjs +4 -4
  41. package/cjs/menu/menu-item-radio.cjs +7 -7
  42. package/cjs/menu/menu-item.cjs +4 -4
  43. package/cjs/menu/menu.cjs +14 -14
  44. package/cjs/popover/popover.cjs +12 -12
  45. package/cjs/radio/radio.cjs +4 -4
  46. package/cjs/select/select-item.cjs +4 -4
  47. package/cjs/select/select-popover.cjs +13 -13
  48. package/cjs/select/select-value.d.cts +8 -7
  49. package/cjs/select/select-value.d.ts +8 -7
  50. package/cjs/select/select.cjs +1 -1
  51. package/cjs/tab/tab-panel.cjs +2 -2
  52. package/cjs/tab/tab.cjs +7 -7
  53. package/cjs/tag/tag-context.cjs +25 -0
  54. package/cjs/tag/tag-context.d.cts +21 -0
  55. package/cjs/tag/tag-context.d.ts +21 -0
  56. package/cjs/tag/tag-input.cjs +191 -0
  57. package/cjs/tag/tag-input.d.cts +122 -0
  58. package/cjs/tag/tag-input.d.ts +122 -0
  59. package/cjs/tag/tag-list-label.cjs +56 -0
  60. package/cjs/tag/tag-list-label.d.cts +55 -0
  61. package/cjs/tag/tag-list-label.d.ts +55 -0
  62. package/cjs/tag/tag-list.cjs +141 -0
  63. package/cjs/tag/tag-list.d.cts +58 -0
  64. package/cjs/tag/tag-list.d.ts +58 -0
  65. package/cjs/tag/tag-provider.cjs +26 -0
  66. package/cjs/tag/tag-provider.d.cts +29 -0
  67. package/cjs/tag/tag-provider.d.ts +29 -0
  68. package/cjs/tag/tag-remove.cjs +119 -0
  69. package/cjs/tag/tag-remove.d.cts +67 -0
  70. package/cjs/tag/tag-remove.d.ts +67 -0
  71. package/cjs/tag/tag-store.cjs +15 -0
  72. package/cjs/tag/tag-store.d.cts +49 -0
  73. package/cjs/tag/tag-store.d.ts +49 -0
  74. package/cjs/tag/tag-value.cjs +29 -0
  75. package/cjs/tag/tag-value.d.cts +41 -0
  76. package/cjs/tag/tag-value.d.ts +41 -0
  77. package/cjs/tag/tag-values.cjs +29 -0
  78. package/cjs/tag/tag-values.d.cts +52 -0
  79. package/cjs/tag/tag-values.d.ts +52 -0
  80. package/cjs/tag/tag.cjs +130 -0
  81. package/cjs/tag/tag.d.cts +74 -0
  82. package/cjs/tag/tag.d.ts +74 -0
  83. package/cjs/tag/utils.cjs +8 -0
  84. package/cjs/tag/utils.d.cts +1 -0
  85. package/cjs/tag/utils.d.ts +1 -0
  86. package/cjs/toolbar/toolbar-container.cjs +4 -4
  87. package/cjs/toolbar/toolbar-input.cjs +4 -4
  88. package/cjs/toolbar/toolbar-item.cjs +4 -4
  89. package/cjs/tooltip/tooltip.cjs +14 -14
  90. package/combobox/combobox-value/package.json +8 -0
  91. package/esm/__chunks/{XEJ23EM6.js → 65LF6MEO.js} +2 -2
  92. package/esm/__chunks/{LTYEFENI.js → 6YVAEELE.js} +1 -1
  93. package/esm/__chunks/{ZFEEEZVE.js → DLLQM6DZ.js} +22 -4
  94. package/esm/__chunks/{IOUGWXY5.js → FGHVVLPU.js} +20 -17
  95. package/esm/__chunks/L7IM35RU.js +16 -0
  96. package/esm/__chunks/{NFPDVAAW.js → M354SEUF.js} +1 -1
  97. package/esm/__chunks/QNNHZL3W.js +25 -0
  98. package/esm/__chunks/{DSUHLHLE.js → QZJOXZKA.js} +1 -1
  99. package/esm/__chunks/{NHVUMSP7.js → UKDZLPKH.js} +1 -1
  100. package/esm/__chunks/{R33ISPJY.js → VGORKDMQ.js} +11 -28
  101. package/esm/__chunks/WYDDZRWN.js +34 -0
  102. package/esm/combobox/combobox-cancel.js +3 -3
  103. package/esm/combobox/combobox-disclosure.js +3 -3
  104. package/esm/combobox/combobox-item.d.ts +22 -12
  105. package/esm/combobox/combobox-item.js +19 -9
  106. package/esm/combobox/combobox-popover.js +20 -13
  107. package/esm/combobox/combobox-provider.js +2 -1
  108. package/esm/combobox/combobox-store.d.ts +12 -4
  109. package/esm/combobox/combobox-store.js +5 -1
  110. package/esm/combobox/combobox-value.d.ts +41 -0
  111. package/esm/combobox/combobox-value.js +32 -0
  112. package/esm/combobox/combobox.js +67 -23
  113. package/esm/composite/composite-item.js +2 -2
  114. package/esm/composite/composite-overflow-disclosure.js +2 -2
  115. package/esm/composite/composite-overflow.js +11 -11
  116. package/esm/dialog/dialog-backdrop.js +2 -2
  117. package/esm/dialog/dialog.d.ts +4 -0
  118. package/esm/dialog/dialog.js +10 -10
  119. package/esm/dialog/utils/disable-tree.js +2 -2
  120. package/esm/dialog/utils/use-prevent-body-scroll.js +2 -2
  121. package/esm/form/form-checkbox.js +1 -1
  122. package/esm/form/form-push.js +1 -1
  123. package/esm/form/form-radio.js +3 -3
  124. package/esm/hovercard/hovercard.js +12 -12
  125. package/esm/menu/menu-item-checkbox.js +3 -3
  126. package/esm/menu/menu-item-radio.js +5 -5
  127. package/esm/menu/menu-item.js +3 -3
  128. package/esm/menu/menu.js +12 -12
  129. package/esm/popover/popover.js +11 -11
  130. package/esm/radio/radio.js +3 -3
  131. package/esm/select/select-item.js +4 -4
  132. package/esm/select/select-popover.js +11 -11
  133. package/esm/select/select-value.d.ts +8 -7
  134. package/esm/select/select.js +1 -1
  135. package/esm/tab/tab-panel.js +3 -3
  136. package/esm/tab/tab.js +5 -5
  137. package/esm/tag/tag-context.d.ts +21 -0
  138. package/esm/tag/tag-context.js +25 -0
  139. package/esm/tag/tag-input.d.ts +122 -0
  140. package/esm/tag/tag-input.js +191 -0
  141. package/esm/tag/tag-list-label.d.ts +55 -0
  142. package/esm/tag/tag-list-label.js +56 -0
  143. package/esm/tag/tag-list.d.ts +58 -0
  144. package/esm/tag/tag-list.js +141 -0
  145. package/esm/tag/tag-provider.d.ts +29 -0
  146. package/esm/tag/tag-provider.js +26 -0
  147. package/esm/tag/tag-remove.d.ts +67 -0
  148. package/esm/tag/tag-remove.js +119 -0
  149. package/esm/tag/tag-store.d.ts +49 -0
  150. package/esm/tag/tag-store.js +15 -0
  151. package/esm/tag/tag-value.d.ts +41 -0
  152. package/esm/tag/tag-value.js +29 -0
  153. package/esm/tag/tag-values.d.ts +52 -0
  154. package/esm/tag/tag-values.js +29 -0
  155. package/esm/tag/tag.d.ts +74 -0
  156. package/esm/tag/tag.js +130 -0
  157. package/esm/tag/utils.d.ts +1 -0
  158. package/esm/tag/utils.js +8 -0
  159. package/esm/toolbar/toolbar-container.js +3 -3
  160. package/esm/toolbar/toolbar-input.js +3 -3
  161. package/esm/toolbar/toolbar-item.js +3 -3
  162. package/esm/tooltip/tooltip.js +12 -12
  163. package/package.json +86 -2
  164. package/tag/tag/package.json +8 -0
  165. package/tag/tag-context/package.json +8 -0
  166. package/tag/tag-input/package.json +8 -0
  167. package/tag/tag-list/package.json +8 -0
  168. package/tag/tag-list-label/package.json +8 -0
  169. package/tag/tag-provider/package.json +8 -0
  170. package/tag/tag-remove/package.json +8 -0
  171. package/tag/tag-store/package.json +8 -0
  172. package/tag/tag-value/package.json +8 -0
  173. package/tag/tag-values/package.json +8 -0
  174. package/tag/utils/package.json +8 -0
  175. package/cjs/__chunks/{37BRXQN7.cjs → BX2QEIBH.cjs} +3 -3
  176. package/cjs/__chunks/{PVYTX5U5.cjs → SL55T4ZB.cjs} +2 -2
  177. package/cjs/__chunks/{TSEXNK3K.cjs → VR6GCLOV.cjs} +2 -2
  178. package/esm/__chunks/{PTPUIM7N.js → 3TEK3C5Q.js} +3 -3
  179. package/esm/__chunks/{U2L67A6K.js → BC72XE6E.js} +3 -3
  180. package/esm/__chunks/{GOXKZAQI.js → CMFBAHKI.js} +3 -3
@@ -0,0 +1,55 @@
1
+ import type { ElementType } from "react";
2
+ import type { CompositeOptions } from "../composite/composite.jsx";
3
+ import type { Props } from "../utils/types.js";
4
+ import type { TagStore } from "./tag-store.js";
5
+ declare const TagName = "label";
6
+ type TagName = typeof TagName;
7
+ /**
8
+ * Returns props to create a `TagListLabel` component.
9
+ * @see https://ariakit.org/components/tag
10
+ * @example
11
+ * ```jsx
12
+ * const props = useTagListLabel();
13
+ * <Role.label {...props} />
14
+ * ```
15
+ */
16
+ export declare const useTagListLabel: import("../utils/types.js").Hook<"label", TagListLabelOptions<"label">>;
17
+ /**
18
+ * Renders a label element for the
19
+ * [`TagInput`](https://ariakit.org/reference/tag-input) and also acts as the
20
+ * accessible name for the listbox element rendered by
21
+ * [`TagList`](https://ariakit.org/reference/tag-list).
22
+ * @see https://ariakit.org/components/tag
23
+ * @example
24
+ * ```jsx {2}
25
+ * <TagProvider>
26
+ * <TagListLabel>Invitees</TagListLabel>
27
+ * <TagList>
28
+ * <TagValues>
29
+ * {(values) =>
30
+ * values.map((value) => (
31
+ * <Tag key={value} value={value}>
32
+ * {value}
33
+ * <TagRemove />
34
+ * </Tag>
35
+ * ))
36
+ * }
37
+ * </TagValues>
38
+ * <TagInput />
39
+ * </TagList>
40
+ * </TagProvider>
41
+ * ```
42
+ */
43
+ export declare const TagListLabel: (props: TagListLabelProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
44
+ export interface TagListLabelOptions<T extends ElementType = TagName> extends CompositeOptions<T> {
45
+ /**
46
+ * Object returned by the
47
+ * [`useTagStore`](https://ariakit.org/reference/use-tag-store) hook. If not
48
+ * provided, the closest
49
+ * [`TagProvider`](https://ariakit.org/reference/tag-provider) component's
50
+ * context will be used.
51
+ */
52
+ store?: TagStore;
53
+ }
54
+ export type TagListLabelProps<T extends ElementType = TagName> = Props<T, TagListLabelOptions<T>>;
55
+ export {};
@@ -0,0 +1,55 @@
1
+ import type { ElementType } from "react";
2
+ import type { CompositeOptions } from "../composite/composite.jsx";
3
+ import type { Props } from "../utils/types.js";
4
+ import type { TagStore } from "./tag-store.js";
5
+ declare const TagName = "label";
6
+ type TagName = typeof TagName;
7
+ /**
8
+ * Returns props to create a `TagListLabel` component.
9
+ * @see https://ariakit.org/components/tag
10
+ * @example
11
+ * ```jsx
12
+ * const props = useTagListLabel();
13
+ * <Role.label {...props} />
14
+ * ```
15
+ */
16
+ export declare const useTagListLabel: import("../utils/types.js").Hook<"label", TagListLabelOptions<"label">>;
17
+ /**
18
+ * Renders a label element for the
19
+ * [`TagInput`](https://ariakit.org/reference/tag-input) and also acts as the
20
+ * accessible name for the listbox element rendered by
21
+ * [`TagList`](https://ariakit.org/reference/tag-list).
22
+ * @see https://ariakit.org/components/tag
23
+ * @example
24
+ * ```jsx {2}
25
+ * <TagProvider>
26
+ * <TagListLabel>Invitees</TagListLabel>
27
+ * <TagList>
28
+ * <TagValues>
29
+ * {(values) =>
30
+ * values.map((value) => (
31
+ * <Tag key={value} value={value}>
32
+ * {value}
33
+ * <TagRemove />
34
+ * </Tag>
35
+ * ))
36
+ * }
37
+ * </TagValues>
38
+ * <TagInput />
39
+ * </TagList>
40
+ * </TagProvider>
41
+ * ```
42
+ */
43
+ export declare const TagListLabel: (props: TagListLabelProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
44
+ export interface TagListLabelOptions<T extends ElementType = TagName> extends CompositeOptions<T> {
45
+ /**
46
+ * Object returned by the
47
+ * [`useTagStore`](https://ariakit.org/reference/use-tag-store) hook. If not
48
+ * provided, the closest
49
+ * [`TagProvider`](https://ariakit.org/reference/tag-provider) component's
50
+ * context will be used.
51
+ */
52
+ store?: TagStore;
53
+ }
54
+ export type TagListLabelProps<T extends ElementType = TagName> = Props<T, TagListLabelOptions<T>>;
55
+ export {};
@@ -0,0 +1,141 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
+
3
+
4
+ var _ISJGSS4Scjs = require('../__chunks/ISJGSS4S.cjs');
5
+
6
+
7
+
8
+ var _PVLZGFP6cjs = require('../__chunks/PVLZGFP6.cjs');
9
+
10
+
11
+ var _EKW5CERCcjs = require('../__chunks/EKW5CERC.cjs');
12
+ require('../__chunks/6ZZYUFPW.cjs');
13
+ require('../__chunks/VPI3EKVY.cjs');
14
+ require('../__chunks/NEK2UEJN.cjs');
15
+ require('../__chunks/FHRIPOYF.cjs');
16
+ require('../__chunks/75KXQZJX.cjs');
17
+
18
+
19
+
20
+
21
+ var _NGD3IQDBcjs = require('../__chunks/NGD3IQDB.cjs');
22
+
23
+
24
+
25
+ var _TW3SFX4Ccjs = require('../__chunks/TW3SFX4C.cjs');
26
+ require('../__chunks/CJDHQUBR.cjs');
27
+
28
+
29
+
30
+
31
+ var _AV6KTKLEcjs = require('../__chunks/AV6KTKLE.cjs');
32
+
33
+ // src/tag/tag-list.tsx
34
+ var _events = require('@ariakit/core/utils/events');
35
+ var _focus = require('@ariakit/core/utils/focus');
36
+ var _misc = require('@ariakit/core/utils/misc');
37
+ var _platform = require('@ariakit/core/utils/platform');
38
+ var _undo = require('@ariakit/core/utils/undo');
39
+ var _jsxruntime = require('react/jsx-runtime');
40
+ var TagName = "div";
41
+ var useTagList = _NGD3IQDBcjs.createHook.call(void 0,
42
+ function useTagList2(_a) {
43
+ var _b = _a, { store } = _b, props = _AV6KTKLEcjs.__objRest.call(void 0, _b, ["store"]);
44
+ const context = _PVLZGFP6cjs.useTagProviderContext.call(void 0, );
45
+ store = store || context;
46
+ _misc.invariant.call(void 0,
47
+ store,
48
+ process.env.NODE_ENV !== "production" && "TagList must receive a `store` prop or be wrapped in a TagProvider component."
49
+ );
50
+ const onMouseDownProp = props.onMouseDown;
51
+ const onMouseDown = _TW3SFX4Ccjs.useEvent.call(void 0, (event) => {
52
+ onMouseDownProp == null ? void 0 : onMouseDownProp(event);
53
+ if (event.defaultPrevented)
54
+ return;
55
+ const target = event.target;
56
+ const currentTarget = event.currentTarget;
57
+ const focusableTarget = _focus.getClosestFocusable.call(void 0, target);
58
+ const isSelfFocusable = focusableTarget === currentTarget;
59
+ if (!isSelfFocusable && currentTarget.contains(focusableTarget))
60
+ return;
61
+ const { inputElement } = store.getState();
62
+ _events.queueBeforeEvent.call(void 0, event.currentTarget, "mouseup", () => {
63
+ inputElement == null ? void 0 : inputElement.focus();
64
+ });
65
+ });
66
+ const onKeyDownProp = props.onKeyDown;
67
+ const onKeyDown = _TW3SFX4Ccjs.useEvent.call(void 0, (event) => {
68
+ onKeyDownProp == null ? void 0 : onKeyDownProp(event);
69
+ if (event.defaultPrevented)
70
+ return;
71
+ const pc = !_platform.isApple.call(void 0, );
72
+ const z = event.key === "z" || event.key === "Z";
73
+ const mod = pc ? event.ctrlKey : event.metaKey;
74
+ const shiftZ = event.shiftKey && z || pc && event.key === "y";
75
+ if (mod && shiftZ) {
76
+ event.preventDefault();
77
+ _undo.UndoManager.redo();
78
+ } else if (mod && z) {
79
+ event.preventDefault();
80
+ _undo.UndoManager.undo();
81
+ }
82
+ });
83
+ props = _TW3SFX4Ccjs.useWrapElement.call(void 0,
84
+ props,
85
+ (element) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _PVLZGFP6cjs.TagScopedContextProvider, { value: store, children: element }),
86
+ [store]
87
+ );
88
+ props = _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
89
+ onMouseDown,
90
+ onKeyDown
91
+ });
92
+ props = _EKW5CERCcjs.useComposite.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, { store }, props));
93
+ const orientation = store.useState(
94
+ (state) => state.orientation === "both" ? void 0 : state.orientation
95
+ );
96
+ const items = store.useState((state) => state.renderedItems);
97
+ const itemIds = items.filter((item) => !!item.value).map((item) => item.id);
98
+ const labelId = store.useState((state) => {
99
+ var _a2;
100
+ return (_a2 = state.labelElement) == null ? void 0 : _a2.id;
101
+ });
102
+ const listboxProps = {};
103
+ for (const key in props) {
104
+ if (key === "role" || key.startsWith("aria-")) {
105
+ const prop = key;
106
+ listboxProps[prop] = props[prop];
107
+ delete props[prop];
108
+ }
109
+ }
110
+ const touchDevice = _ISJGSS4Scjs.useTouchDevice.call(void 0, );
111
+ const children = /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
112
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
113
+ "div",
114
+ _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {
115
+ role: touchDevice ? "list" : "listbox",
116
+ "aria-live": "polite",
117
+ "aria-relevant": "all",
118
+ "aria-atomic": true,
119
+ "aria-labelledby": labelId,
120
+ "aria-orientation": orientation,
121
+ "aria-owns": itemIds.join(" ")
122
+ }, listboxProps), {
123
+ style: { position: "fixed" }
124
+ })
125
+ ),
126
+ props.children
127
+ ] });
128
+ props = _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
129
+ children
130
+ });
131
+ return props;
132
+ }
133
+ );
134
+ var TagList = _NGD3IQDBcjs.forwardRef.call(void 0, function TagList2(props) {
135
+ const htmlProps = useTagList(props);
136
+ return _NGD3IQDBcjs.createElement.call(void 0, TagName, htmlProps);
137
+ });
138
+
139
+
140
+
141
+ exports.TagList = TagList; exports.useTagList = useTagList;
@@ -0,0 +1,58 @@
1
+ import type { ElementType } from "react";
2
+ import type { CompositeOptions } from "../composite/composite.js";
3
+ import type { Props } from "../utils/types.js";
4
+ import type { TagStore } from "./tag-store.js";
5
+ declare const TagName = "div";
6
+ type TagName = typeof TagName;
7
+ /**
8
+ * Returns props to create a `TagList` component.
9
+ * @see https://ariakit.org/components/tag
10
+ * @example
11
+ * ```jsx
12
+ * const props = useTagList();
13
+ * <Role.div {...props} />
14
+ * ```
15
+ */
16
+ export declare const useTagList: import("../utils/types.js").Hook<"div", TagListOptions<"div">>;
17
+ /**
18
+ * Renders a wrapper for [`Tag`](https://ariakit.org/reference/tag) and
19
+ * [`TagInput`](https://ariakit.org/reference/tag-input) components. This
20
+ * component is typically styled as an input field.
21
+ *
22
+ * The [`TagListLabel`](https://ariakit.org/reference/tag-list-label) component
23
+ * can be used to provide an accessible name for the listbox element that owns
24
+ * the tags.
25
+ * @see https://ariakit.org/components/tag
26
+ * @example
27
+ * ```jsx {3-15}
28
+ * <TagProvider>
29
+ * <TagListLabel>Invitees</TagListLabel>
30
+ * <TagList>
31
+ * <TagValues>
32
+ * {(values) =>
33
+ * values.map((value) => (
34
+ * <Tag key={value} value={value}>
35
+ * {value}
36
+ * <TagRemove />
37
+ * </Tag>
38
+ * ))
39
+ * }
40
+ * </TagValues>
41
+ * <TagInput />
42
+ * </TagList>
43
+ * </TagProvider>
44
+ * ```
45
+ */
46
+ export declare const TagList: (props: TagListProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
47
+ export interface TagListOptions<T extends ElementType = TagName> extends CompositeOptions<T> {
48
+ /**
49
+ * Object returned by the
50
+ * [`useTagStore`](https://ariakit.org/reference/use-tag-store) hook. If not
51
+ * provided, the closest
52
+ * [`TagProvider`](https://ariakit.org/reference/tag-provider) component's
53
+ * context will be used.
54
+ */
55
+ store?: TagStore;
56
+ }
57
+ export type TagListProps<T extends ElementType = TagName> = Props<T, TagListOptions<T>>;
58
+ export {};
@@ -0,0 +1,58 @@
1
+ import type { ElementType } from "react";
2
+ import type { CompositeOptions } from "../composite/composite.js";
3
+ import type { Props } from "../utils/types.js";
4
+ import type { TagStore } from "./tag-store.js";
5
+ declare const TagName = "div";
6
+ type TagName = typeof TagName;
7
+ /**
8
+ * Returns props to create a `TagList` component.
9
+ * @see https://ariakit.org/components/tag
10
+ * @example
11
+ * ```jsx
12
+ * const props = useTagList();
13
+ * <Role.div {...props} />
14
+ * ```
15
+ */
16
+ export declare const useTagList: import("../utils/types.js").Hook<"div", TagListOptions<"div">>;
17
+ /**
18
+ * Renders a wrapper for [`Tag`](https://ariakit.org/reference/tag) and
19
+ * [`TagInput`](https://ariakit.org/reference/tag-input) components. This
20
+ * component is typically styled as an input field.
21
+ *
22
+ * The [`TagListLabel`](https://ariakit.org/reference/tag-list-label) component
23
+ * can be used to provide an accessible name for the listbox element that owns
24
+ * the tags.
25
+ * @see https://ariakit.org/components/tag
26
+ * @example
27
+ * ```jsx {3-15}
28
+ * <TagProvider>
29
+ * <TagListLabel>Invitees</TagListLabel>
30
+ * <TagList>
31
+ * <TagValues>
32
+ * {(values) =>
33
+ * values.map((value) => (
34
+ * <Tag key={value} value={value}>
35
+ * {value}
36
+ * <TagRemove />
37
+ * </Tag>
38
+ * ))
39
+ * }
40
+ * </TagValues>
41
+ * <TagInput />
42
+ * </TagList>
43
+ * </TagProvider>
44
+ * ```
45
+ */
46
+ export declare const TagList: (props: TagListProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
47
+ export interface TagListOptions<T extends ElementType = TagName> extends CompositeOptions<T> {
48
+ /**
49
+ * Object returned by the
50
+ * [`useTagStore`](https://ariakit.org/reference/use-tag-store) hook. If not
51
+ * provided, the closest
52
+ * [`TagProvider`](https://ariakit.org/reference/tag-provider) component's
53
+ * context will be used.
54
+ */
55
+ store?: TagStore;
56
+ }
57
+ export type TagListProps<T extends ElementType = TagName> = Props<T, TagListOptions<T>>;
58
+ export {};
@@ -0,0 +1,26 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
+
3
+
4
+ var _YWAHOWYEcjs = require('../__chunks/YWAHOWYE.cjs');
5
+
6
+
7
+ var _PVLZGFP6cjs = require('../__chunks/PVLZGFP6.cjs');
8
+ require('../__chunks/4H5ZMMOI.cjs');
9
+ require('../__chunks/Q7DU7FP7.cjs');
10
+ require('../__chunks/VPI3EKVY.cjs');
11
+ require('../__chunks/NEK2UEJN.cjs');
12
+ require('../__chunks/NGD3IQDB.cjs');
13
+ require('../__chunks/GXMZA6DT.cjs');
14
+ require('../__chunks/TW3SFX4C.cjs');
15
+ require('../__chunks/CJDHQUBR.cjs');
16
+ require('../__chunks/AV6KTKLE.cjs');
17
+
18
+ // src/tag/tag-provider.tsx
19
+ var _jsxruntime = require('react/jsx-runtime');
20
+ function TagProvider(props = {}) {
21
+ const store = _YWAHOWYEcjs.useTagStore.call(void 0, props);
22
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _PVLZGFP6cjs.TagContextProvider, { value: store, children: props.children });
23
+ }
24
+
25
+
26
+ exports.TagProvider = TagProvider;
@@ -0,0 +1,29 @@
1
+ import type { ReactNode } from "react";
2
+ import type { TagStoreProps } from "./tag-store.js";
3
+ /**
4
+ * Provides a tag store to [Tag](https://ariakit.org/components/tag) components.
5
+ * @see https://ariakit.org/components/tag
6
+ * @example
7
+ * ```jsx
8
+ * <TagProvider>
9
+ * <TagListLabel>Invitees</TagListLabel>
10
+ * <TagList>
11
+ * <TagValues>
12
+ * {(values) =>
13
+ * values.map((value) => (
14
+ * <Tag key={value} value={value}>
15
+ * {value}
16
+ * <TagRemove />
17
+ * </Tag>
18
+ * ))
19
+ * }
20
+ * </TagValues>
21
+ * <TagInput />
22
+ * </TagList>
23
+ * </TagProvider>
24
+ * ```
25
+ */
26
+ export declare function TagProvider(props?: TagProviderProps): import("react/jsx-runtime").JSX.Element;
27
+ export interface TagProviderProps extends TagStoreProps {
28
+ children?: ReactNode;
29
+ }
@@ -0,0 +1,29 @@
1
+ import type { ReactNode } from "react";
2
+ import type { TagStoreProps } from "./tag-store.js";
3
+ /**
4
+ * Provides a tag store to [Tag](https://ariakit.org/components/tag) components.
5
+ * @see https://ariakit.org/components/tag
6
+ * @example
7
+ * ```jsx
8
+ * <TagProvider>
9
+ * <TagListLabel>Invitees</TagListLabel>
10
+ * <TagList>
11
+ * <TagValues>
12
+ * {(values) =>
13
+ * values.map((value) => (
14
+ * <Tag key={value} value={value}>
15
+ * {value}
16
+ * <TagRemove />
17
+ * </Tag>
18
+ * ))
19
+ * }
20
+ * </TagValues>
21
+ * <TagInput />
22
+ * </TagList>
23
+ * </TagProvider>
24
+ * ```
25
+ */
26
+ export declare function TagProvider(props?: TagProviderProps): import("react/jsx-runtime").JSX.Element;
27
+ export interface TagProviderProps extends TagStoreProps {
28
+ children?: ReactNode;
29
+ }
@@ -0,0 +1,119 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
+
3
+
4
+ var _ISJGSS4Scjs = require('../__chunks/ISJGSS4S.cjs');
5
+
6
+
7
+
8
+
9
+ var _PVLZGFP6cjs = require('../__chunks/PVLZGFP6.cjs');
10
+ require('../__chunks/VPI3EKVY.cjs');
11
+ require('../__chunks/NEK2UEJN.cjs');
12
+
13
+
14
+ var _R6M66EKZcjs = require('../__chunks/R6M66EKZ.cjs');
15
+
16
+
17
+
18
+
19
+ var _NGD3IQDBcjs = require('../__chunks/NGD3IQDB.cjs');
20
+
21
+
22
+
23
+
24
+ var _TW3SFX4Ccjs = require('../__chunks/TW3SFX4C.cjs');
25
+ require('../__chunks/CJDHQUBR.cjs');
26
+
27
+
28
+
29
+
30
+ var _AV6KTKLEcjs = require('../__chunks/AV6KTKLE.cjs');
31
+
32
+ // src/tag/tag-remove.tsx
33
+ var _react = require('react');
34
+ var _misc = require('@ariakit/core/utils/misc');
35
+ var _jsxruntime = require('react/jsx-runtime');
36
+ var TagName = "button";
37
+ var useTagRemove = _NGD3IQDBcjs.createHook.call(void 0,
38
+ function useTagRemove2(_a) {
39
+ var _b = _a, {
40
+ store,
41
+ value: valueProp,
42
+ removeOnClick = true
43
+ } = _b, props = _AV6KTKLEcjs.__objRest.call(void 0, _b, [
44
+ "store",
45
+ "value",
46
+ "removeOnClick"
47
+ ]);
48
+ const context = _PVLZGFP6cjs.useTagContext.call(void 0, );
49
+ store = store || context;
50
+ _misc.invariant.call(void 0,
51
+ store,
52
+ process.env.NODE_ENV !== "production" && "TagRemove must receive a `store` prop or be wrapped in a TagProvider component."
53
+ );
54
+ const id = _TW3SFX4Ccjs.useId.call(void 0, props.id);
55
+ const setRemoveId = _react.useContext.call(void 0, _PVLZGFP6cjs.TagRemoveIdContext);
56
+ const valueFromContext = _react.useContext.call(void 0, _PVLZGFP6cjs.TagValueContext);
57
+ const withinTag = valueFromContext !== null;
58
+ const value = valueProp != null ? valueProp : valueFromContext;
59
+ _react.useEffect.call(void 0, () => {
60
+ setRemoveId == null ? void 0 : setRemoveId(id);
61
+ return () => setRemoveId == null ? void 0 : setRemoveId();
62
+ }, [id, setRemoveId]);
63
+ const onClickProp = props.onClick;
64
+ const removeOnClickProp = _TW3SFX4Ccjs.useBooleanEvent.call(void 0, removeOnClick);
65
+ const onClick = _TW3SFX4Ccjs.useEvent.call(void 0, (event) => {
66
+ onClickProp == null ? void 0 : onClickProp(event);
67
+ if (event.defaultPrevented)
68
+ return;
69
+ if (!store)
70
+ return;
71
+ if (!value)
72
+ return;
73
+ if (!removeOnClickProp(event))
74
+ return;
75
+ const { inputElement } = store.getState();
76
+ store.removeValue(value);
77
+ inputElement == null ? void 0 : inputElement.focus();
78
+ });
79
+ const children = /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
80
+ "svg",
81
+ {
82
+ display: "block",
83
+ viewBox: "0 0 24 24",
84
+ fill: "none",
85
+ stroke: "currentColor",
86
+ strokeWidth: 1.5,
87
+ strokeLinecap: "round",
88
+ strokeLinejoin: "round",
89
+ height: "1em",
90
+ width: "1em",
91
+ "aria-hidden": true,
92
+ children: [
93
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M7.28782 5.46243C7.80963 4.92308 8.07054 4.65341 8.37751 4.46038C8.64963 4.28926 8.94749 4.16299 9.25969 4.0864C9.61186 4 9.98709 4 10.7375 4H16.8C17.9201 4 18.4802 4 18.908 4.21799C19.2843 4.40973 19.5903 4.71569 19.782 5.09202C20 5.51984 20 6.0799 20 7.2V16.8C20 17.9201 20 18.4802 19.782 18.908C19.5903 19.2843 19.2843 19.5903 18.908 19.782C18.4802 20 17.9201 20 16.8 20H10.7512C9.99584 20 9.61818 20 9.264 19.9126C8.95004 19.8351 8.65067 19.7073 8.37748 19.5342C8.06931 19.339 7.80802 19.0663 7.28544 18.521L2.59879 13.63C2.03714 13.0439 1.75631 12.7508 1.65115 12.4158C1.55859 12.121 1.55935 11.8048 1.65332 11.5104C1.7601 11.1759 2.04233 10.8842 2.60679 10.3008L7.28782 5.46243Z" }),
94
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M10.052 9L16 15M15.948 9L10 15" })
95
+ ]
96
+ }
97
+ );
98
+ const touchDevice = _ISJGSS4Scjs.useTouchDevice.call(void 0, ) && withinTag;
99
+ props = _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {
100
+ id,
101
+ children,
102
+ role: touchDevice ? "button" : void 0,
103
+ "aria-hidden": !touchDevice,
104
+ "aria-label": touchDevice ? `Remove ${value}` : withinTag ? "Press Delete or Backspace to remove" : void 0
105
+ }, props), {
106
+ onClick,
107
+ render: withinTag ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _R6M66EKZcjs.Role.span, { render: props.render }) : props.render
108
+ });
109
+ return props;
110
+ }
111
+ );
112
+ var TagRemove = _NGD3IQDBcjs.forwardRef.call(void 0, function TagRemove2(props) {
113
+ const htmlProps = useTagRemove(props);
114
+ return _NGD3IQDBcjs.createElement.call(void 0, TagName, htmlProps);
115
+ });
116
+
117
+
118
+
119
+ exports.TagRemove = TagRemove; exports.useTagRemove = useTagRemove;
@@ -0,0 +1,67 @@
1
+ import type { ElementType, MouseEvent } from "react";
2
+ import type { BooleanOrCallback } from "@ariakit/core/utils/types";
3
+ import type { Options, Props } from "../utils/types.js";
4
+ import type { TagStore } from "./tag-store.js";
5
+ declare const TagName = "button";
6
+ type TagName = typeof TagName;
7
+ type HTMLType = HTMLElementTagNameMap[TagName];
8
+ /**
9
+ * Returns props to create a `TagRemove` component.
10
+ * @see https://ariakit.org/components/tag
11
+ * @example
12
+ * ```jsx
13
+ * const props = useTagRemove();
14
+ * <Role.button {...props} />
15
+ * ```
16
+ */
17
+ export declare const useTagRemove: import("../utils/types.js").Hook<"button", TagRemoveOptions<"button">>;
18
+ /**
19
+ * Renders a `Backspace` icon inside a
20
+ * [`Tag`](https://ariakit.org/reference/tag) component that removes the tag
21
+ * when clicked with a mouse.
22
+ * @see https://ariakit.org/components/tag
23
+ * @example
24
+ * ```jsx {9}
25
+ * <TagProvider>
26
+ * <TagListLabel>Invitees</TagListLabel>
27
+ * <TagList>
28
+ * <TagValues>
29
+ * {(values) =>
30
+ * values.map((value) => (
31
+ * <Tag key={value} value={value}>
32
+ * {value}
33
+ * <TagRemove />
34
+ * </Tag>
35
+ * ))
36
+ * }
37
+ * </TagValues>
38
+ * <TagInput />
39
+ * </TagList>
40
+ * </TagProvider>
41
+ * ```
42
+ */
43
+ export declare const TagRemove: (props: TagRemoveProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
44
+ export interface TagRemoveOptions<_T extends ElementType = TagName> extends Options {
45
+ /**
46
+ * Object returned by the
47
+ * [`useTagStore`](https://ariakit.org/reference/use-tag-store) hook. If not
48
+ * provided, the closest
49
+ * [`TagProvider`](https://ariakit.org/reference/tag-provider) component's
50
+ * context will be used.
51
+ */
52
+ store?: TagStore;
53
+ /**
54
+ * The value of the tag to remove. If not provided, the value will be inferred
55
+ * from the parent [`Tag`](https://ariakit.org/reference/tag) component.
56
+ */
57
+ value?: string;
58
+ /**
59
+ * Determines if the tag should be removed when clicked with a mouse. If a
60
+ * function is provided, it will be called with the click event and should
61
+ * return a boolean.
62
+ * @default true
63
+ */
64
+ removeOnClick?: BooleanOrCallback<MouseEvent<HTMLType>>;
65
+ }
66
+ export type TagRemoveProps<T extends ElementType = TagName> = Props<T, TagRemoveOptions<T>>;
67
+ export {};