@ariakit/react-core 0.4.3 → 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 (235) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/cjs/__chunks/{7DQ2LBH2.cjs → 3HMQOCLF.cjs} +23 -5
  3. package/cjs/__chunks/{AJF5DT5A.cjs → AY5J25V7.cjs} +2 -2
  4. package/cjs/__chunks/{HFNM6QV4.cjs → DAOFDKV2.cjs} +1 -1
  5. package/cjs/__chunks/{GYHP7IYG.cjs → DFXPO2ED.cjs} +2 -2
  6. package/cjs/__chunks/{3C4RFBCG.cjs → EYZZO5IT.cjs} +1 -1
  7. package/cjs/__chunks/{3MKOUH5M.cjs → GZ2NNSLV.cjs} +4 -4
  8. package/cjs/__chunks/ISJGSS4S.cjs +16 -0
  9. package/cjs/__chunks/{A356CGND.cjs → JDCTLYQ4.cjs} +1 -1
  10. package/cjs/__chunks/{T5BWR4CB.cjs → KDTFHBKU.cjs} +2 -2
  11. package/cjs/__chunks/{NZSB7HSZ.cjs → LY4LCJM6.cjs} +2 -2
  12. package/cjs/__chunks/{DCTXNU2X.cjs → N43E53E6.cjs} +3 -3
  13. package/cjs/__chunks/{IHFGURUM.cjs → NRPEUNJB.cjs} +2 -2
  14. package/cjs/__chunks/PVLZGFP6.cjs +34 -0
  15. package/cjs/__chunks/{CWS5RZSU.cjs → QJDA4LG6.cjs} +28 -17
  16. package/cjs/__chunks/{NDVZ37O3.cjs → RG6U7KAS.cjs} +22 -4
  17. package/cjs/__chunks/YWAHOWYE.cjs +25 -0
  18. package/cjs/__chunks/{3XXW4Y4D.cjs → Z2VL7JHX.cjs} +2 -2
  19. package/cjs/checkbox/checkbox-check.cjs +2 -2
  20. package/cjs/collection/collection-renderer.d.cts +0 -2
  21. package/cjs/collection/collection-renderer.d.ts +0 -2
  22. package/cjs/combobox/combobox-cancel.cjs +4 -4
  23. package/cjs/combobox/combobox-disclosure.cjs +4 -4
  24. package/cjs/combobox/combobox-item-check.cjs +2 -2
  25. package/cjs/combobox/combobox-item.cjs +19 -9
  26. package/cjs/combobox/combobox-item.d.cts +22 -12
  27. package/cjs/combobox/combobox-item.d.ts +22 -12
  28. package/cjs/combobox/combobox-popover.cjs +41 -16
  29. package/cjs/combobox/combobox-provider.cjs +3 -2
  30. package/cjs/combobox/combobox-store.cjs +6 -2
  31. package/cjs/combobox/combobox-store.d.cts +12 -4
  32. package/cjs/combobox/combobox-store.d.ts +12 -4
  33. package/cjs/combobox/combobox-value.cjs +32 -0
  34. package/cjs/combobox/combobox-value.d.cts +41 -0
  35. package/cjs/combobox/combobox-value.d.ts +41 -0
  36. package/cjs/combobox/combobox.cjs +79 -32
  37. package/cjs/combobox/combobox.d.cts +20 -0
  38. package/cjs/combobox/combobox.d.ts +20 -0
  39. package/cjs/composite/composite-input.cjs +91 -6
  40. package/cjs/composite/composite-input.d.cts +2 -0
  41. package/cjs/composite/composite-input.d.ts +2 -0
  42. package/cjs/composite/composite-item.cjs +3 -3
  43. package/cjs/composite/composite-overflow-disclosure.cjs +3 -3
  44. package/cjs/composite/composite-overflow.cjs +12 -12
  45. package/cjs/composite/composite-renderer.d.cts +0 -2
  46. package/cjs/composite/composite-renderer.d.ts +0 -2
  47. package/cjs/dialog/dialog-backdrop.cjs +3 -3
  48. package/cjs/dialog/dialog-dismiss.cjs +2 -2
  49. package/cjs/dialog/dialog.cjs +11 -11
  50. package/cjs/dialog/dialog.d.cts +4 -0
  51. package/cjs/dialog/dialog.d.ts +4 -0
  52. package/cjs/dialog/utils/disable-tree.cjs +3 -3
  53. package/cjs/dialog/utils/use-prevent-body-scroll.cjs +3 -3
  54. package/cjs/form/form-checkbox.cjs +1 -1
  55. package/cjs/form/form-push.cjs +1 -1
  56. package/cjs/form/form-radio.cjs +4 -4
  57. package/cjs/hovercard/hovercard-disclosure.cjs +1 -1
  58. package/cjs/hovercard/hovercard-dismiss.cjs +4 -4
  59. package/cjs/hovercard/hovercard.cjs +13 -13
  60. package/cjs/menu/menu-button-arrow.cjs +2 -2
  61. package/cjs/menu/menu-dismiss.cjs +4 -4
  62. package/cjs/menu/menu-item-check.cjs +2 -2
  63. package/cjs/menu/menu-item-checkbox.cjs +4 -4
  64. package/cjs/menu/menu-item-radio.cjs +7 -7
  65. package/cjs/menu/menu-item.cjs +4 -4
  66. package/cjs/menu/menu.cjs +14 -14
  67. package/cjs/popover/popover-disclosure-arrow.cjs +2 -2
  68. package/cjs/popover/popover-dismiss.cjs +3 -3
  69. package/cjs/popover/popover.cjs +12 -12
  70. package/cjs/radio/radio.cjs +4 -4
  71. package/cjs/select/select-arrow.cjs +3 -3
  72. package/cjs/select/select-item-check.cjs +2 -2
  73. package/cjs/select/select-item.cjs +4 -4
  74. package/cjs/select/select-popover.cjs +13 -13
  75. package/cjs/select/select-value.d.cts +8 -7
  76. package/cjs/select/select-value.d.ts +8 -7
  77. package/cjs/select/select.cjs +4 -4
  78. package/cjs/tab/tab-panel.cjs +2 -2
  79. package/cjs/tab/tab.cjs +7 -7
  80. package/cjs/tag/tag-context.cjs +25 -0
  81. package/cjs/tag/tag-context.d.cts +21 -0
  82. package/cjs/tag/tag-context.d.ts +21 -0
  83. package/cjs/tag/tag-input.cjs +191 -0
  84. package/cjs/tag/tag-input.d.cts +122 -0
  85. package/cjs/tag/tag-input.d.ts +122 -0
  86. package/cjs/tag/tag-list-label.cjs +56 -0
  87. package/cjs/tag/tag-list-label.d.cts +55 -0
  88. package/cjs/tag/tag-list-label.d.ts +55 -0
  89. package/cjs/tag/tag-list.cjs +141 -0
  90. package/cjs/tag/tag-list.d.cts +58 -0
  91. package/cjs/tag/tag-list.d.ts +58 -0
  92. package/cjs/tag/tag-provider.cjs +26 -0
  93. package/cjs/tag/tag-provider.d.cts +29 -0
  94. package/cjs/tag/tag-provider.d.ts +29 -0
  95. package/cjs/tag/tag-remove.cjs +119 -0
  96. package/cjs/tag/tag-remove.d.cts +67 -0
  97. package/cjs/tag/tag-remove.d.ts +67 -0
  98. package/cjs/tag/tag-store.cjs +15 -0
  99. package/cjs/tag/tag-store.d.cts +49 -0
  100. package/cjs/tag/tag-store.d.ts +49 -0
  101. package/cjs/tag/tag-value.cjs +29 -0
  102. package/cjs/tag/tag-value.d.cts +41 -0
  103. package/cjs/tag/tag-value.d.ts +41 -0
  104. package/cjs/tag/tag-values.cjs +29 -0
  105. package/cjs/tag/tag-values.d.cts +52 -0
  106. package/cjs/tag/tag-values.d.ts +52 -0
  107. package/cjs/tag/tag.cjs +130 -0
  108. package/cjs/tag/tag.d.cts +74 -0
  109. package/cjs/tag/tag.d.ts +74 -0
  110. package/cjs/tag/utils.cjs +8 -0
  111. package/cjs/tag/utils.d.cts +1 -0
  112. package/cjs/tag/utils.d.ts +1 -0
  113. package/cjs/toolbar/toolbar-container.cjs +4 -4
  114. package/cjs/toolbar/toolbar-input.cjs +4 -8
  115. package/cjs/toolbar/toolbar-input.d.cts +3 -2
  116. package/cjs/toolbar/toolbar-input.d.ts +3 -2
  117. package/cjs/toolbar/toolbar-item.cjs +4 -4
  118. package/cjs/tooltip/tooltip.cjs +14 -14
  119. package/combobox/combobox-value/package.json +8 -0
  120. package/esm/__chunks/{LABIXQLW.js → 44PDY2W5.js} +1 -1
  121. package/esm/__chunks/{FYNSL2D5.js → 5H3YXAUC.js} +1 -1
  122. package/esm/__chunks/{6VDNHSLX.js → 65LF6MEO.js} +2 -2
  123. package/esm/__chunks/{X3V2DT2U.js → 6YVAEELE.js} +1 -1
  124. package/esm/__chunks/{JCOBPKEI.js → BY6P32UK.js} +1 -1
  125. package/esm/__chunks/{ZFEEEZVE.js → DLLQM6DZ.js} +22 -4
  126. package/esm/__chunks/{NN4HLGKS.js → F2RFUFO2.js} +1 -1
  127. package/esm/__chunks/{NQ4PTILT.js → FGHVVLPU.js} +29 -18
  128. package/esm/__chunks/{2VWKZYYT.js → H5N72W37.js} +1 -1
  129. package/esm/__chunks/L7IM35RU.js +16 -0
  130. package/esm/__chunks/{HW63KLP5.js → M354SEUF.js} +1 -1
  131. package/esm/__chunks/{RAKW656I.js → Q4PZFBSW.js} +1 -1
  132. package/esm/__chunks/QNNHZL3W.js +25 -0
  133. package/esm/__chunks/{C5HA76JU.js → QZJOXZKA.js} +1 -1
  134. package/esm/__chunks/{XK6CE2M5.js → UKDZLPKH.js} +1 -1
  135. package/esm/__chunks/{ONUY4D7O.js → VGORKDMQ.js} +26 -8
  136. package/esm/__chunks/WYDDZRWN.js +34 -0
  137. package/esm/checkbox/checkbox-check.js +1 -1
  138. package/esm/collection/collection-renderer.d.ts +0 -2
  139. package/esm/combobox/combobox-cancel.js +4 -4
  140. package/esm/combobox/combobox-disclosure.js +4 -4
  141. package/esm/combobox/combobox-item-check.js +1 -1
  142. package/esm/combobox/combobox-item.d.ts +22 -12
  143. package/esm/combobox/combobox-item.js +19 -9
  144. package/esm/combobox/combobox-popover.js +40 -15
  145. package/esm/combobox/combobox-provider.js +2 -1
  146. package/esm/combobox/combobox-store.d.ts +12 -4
  147. package/esm/combobox/combobox-store.js +5 -1
  148. package/esm/combobox/combobox-value.d.ts +41 -0
  149. package/esm/combobox/combobox-value.js +32 -0
  150. package/esm/combobox/combobox.d.ts +20 -0
  151. package/esm/combobox/combobox.js +80 -33
  152. package/esm/composite/composite-input.d.ts +2 -0
  153. package/esm/composite/composite-input.js +92 -7
  154. package/esm/composite/composite-item.js +2 -2
  155. package/esm/composite/composite-overflow-disclosure.js +2 -2
  156. package/esm/composite/composite-overflow.js +11 -11
  157. package/esm/composite/composite-renderer.d.ts +0 -2
  158. package/esm/dialog/dialog-backdrop.js +2 -2
  159. package/esm/dialog/dialog-dismiss.js +1 -1
  160. package/esm/dialog/dialog.d.ts +4 -0
  161. package/esm/dialog/dialog.js +10 -10
  162. package/esm/dialog/utils/disable-tree.js +2 -2
  163. package/esm/dialog/utils/use-prevent-body-scroll.js +2 -2
  164. package/esm/form/form-checkbox.js +1 -1
  165. package/esm/form/form-push.js +1 -1
  166. package/esm/form/form-radio.js +3 -3
  167. package/esm/hovercard/hovercard-disclosure.js +1 -1
  168. package/esm/hovercard/hovercard-dismiss.js +3 -3
  169. package/esm/hovercard/hovercard.js +12 -12
  170. package/esm/menu/menu-button-arrow.js +1 -1
  171. package/esm/menu/menu-dismiss.js +3 -3
  172. package/esm/menu/menu-item-check.js +1 -1
  173. package/esm/menu/menu-item-checkbox.js +3 -3
  174. package/esm/menu/menu-item-radio.js +5 -5
  175. package/esm/menu/menu-item.js +3 -3
  176. package/esm/menu/menu.js +12 -12
  177. package/esm/popover/popover-disclosure-arrow.js +1 -1
  178. package/esm/popover/popover-dismiss.js +2 -2
  179. package/esm/popover/popover.js +11 -11
  180. package/esm/radio/radio.js +3 -3
  181. package/esm/select/select-arrow.js +2 -2
  182. package/esm/select/select-item-check.js +1 -1
  183. package/esm/select/select-item.js +4 -4
  184. package/esm/select/select-popover.js +11 -11
  185. package/esm/select/select-value.d.ts +8 -7
  186. package/esm/select/select.js +3 -3
  187. package/esm/tab/tab-panel.js +3 -3
  188. package/esm/tab/tab.js +5 -5
  189. package/esm/tag/tag-context.d.ts +21 -0
  190. package/esm/tag/tag-context.js +25 -0
  191. package/esm/tag/tag-input.d.ts +122 -0
  192. package/esm/tag/tag-input.js +191 -0
  193. package/esm/tag/tag-list-label.d.ts +55 -0
  194. package/esm/tag/tag-list-label.js +56 -0
  195. package/esm/tag/tag-list.d.ts +58 -0
  196. package/esm/tag/tag-list.js +141 -0
  197. package/esm/tag/tag-provider.d.ts +29 -0
  198. package/esm/tag/tag-provider.js +26 -0
  199. package/esm/tag/tag-remove.d.ts +67 -0
  200. package/esm/tag/tag-remove.js +119 -0
  201. package/esm/tag/tag-store.d.ts +49 -0
  202. package/esm/tag/tag-store.js +15 -0
  203. package/esm/tag/tag-value.d.ts +41 -0
  204. package/esm/tag/tag-value.js +29 -0
  205. package/esm/tag/tag-values.d.ts +52 -0
  206. package/esm/tag/tag-values.js +29 -0
  207. package/esm/tag/tag.d.ts +74 -0
  208. package/esm/tag/tag.js +130 -0
  209. package/esm/tag/utils.d.ts +1 -0
  210. package/esm/tag/utils.js +8 -0
  211. package/esm/toolbar/toolbar-container.js +3 -3
  212. package/esm/toolbar/toolbar-input.d.ts +3 -2
  213. package/esm/toolbar/toolbar-input.js +3 -7
  214. package/esm/toolbar/toolbar-item.js +3 -3
  215. package/esm/tooltip/tooltip.js +12 -12
  216. package/package.json +86 -2
  217. package/tag/tag/package.json +8 -0
  218. package/tag/tag-context/package.json +8 -0
  219. package/tag/tag-input/package.json +8 -0
  220. package/tag/tag-list/package.json +8 -0
  221. package/tag/tag-list-label/package.json +8 -0
  222. package/tag/tag-provider/package.json +8 -0
  223. package/tag/tag-remove/package.json +8 -0
  224. package/tag/tag-store/package.json +8 -0
  225. package/tag/tag-value/package.json +8 -0
  226. package/tag/tag-values/package.json +8 -0
  227. package/tag/utils/package.json +8 -0
  228. package/cjs/__chunks/WGZQRLXV.cjs +0 -84
  229. package/esm/__chunks/RPGNBKKU.js +0 -84
  230. package/cjs/__chunks/{37BRXQN7.cjs → BX2QEIBH.cjs} +3 -3
  231. package/cjs/__chunks/{PVYTX5U5.cjs → SL55T4ZB.cjs} +2 -2
  232. package/cjs/__chunks/{TSEXNK3K.cjs → VR6GCLOV.cjs} +2 -2
  233. package/esm/__chunks/{PTPUIM7N.js → 3TEK3C5Q.js} +3 -3
  234. package/esm/__chunks/{U2L67A6K.js → BC72XE6E.js} +3 -3
  235. package/esm/__chunks/{GOXKZAQI.js → CMFBAHKI.js} +3 -3
@@ -0,0 +1,119 @@
1
+ "use client";
2
+ import {
3
+ useTouchDevice
4
+ } from "../__chunks/L7IM35RU.js";
5
+ import {
6
+ TagRemoveIdContext,
7
+ TagValueContext,
8
+ useTagContext
9
+ } from "../__chunks/WYDDZRWN.js";
10
+ import "../__chunks/QFI3MCMR.js";
11
+ import "../__chunks/6LTHW2TQ.js";
12
+ import {
13
+ Role
14
+ } from "../__chunks/4MFOHMLS.js";
15
+ import {
16
+ createElement,
17
+ createHook,
18
+ forwardRef
19
+ } from "../__chunks/GUCZNEAD.js";
20
+ import {
21
+ useBooleanEvent,
22
+ useEvent,
23
+ useId
24
+ } from "../__chunks/WOWUAP42.js";
25
+ import "../__chunks/XM66DUTO.js";
26
+ import {
27
+ __objRest,
28
+ __spreadProps,
29
+ __spreadValues
30
+ } from "../__chunks/4R3V3JGP.js";
31
+
32
+ // src/tag/tag-remove.tsx
33
+ import { useContext, useEffect } from "react";
34
+ import { invariant } from "@ariakit/core/utils/misc";
35
+ import { jsx, jsxs } from "react/jsx-runtime";
36
+ var TagName = "button";
37
+ var useTagRemove = createHook(
38
+ function useTagRemove2(_a) {
39
+ var _b = _a, {
40
+ store,
41
+ value: valueProp,
42
+ removeOnClick = true
43
+ } = _b, props = __objRest(_b, [
44
+ "store",
45
+ "value",
46
+ "removeOnClick"
47
+ ]);
48
+ const context = useTagContext();
49
+ store = store || context;
50
+ invariant(
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 = useId(props.id);
55
+ const setRemoveId = useContext(TagRemoveIdContext);
56
+ const valueFromContext = useContext(TagValueContext);
57
+ const withinTag = valueFromContext !== null;
58
+ const value = valueProp != null ? valueProp : valueFromContext;
59
+ useEffect(() => {
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 = useBooleanEvent(removeOnClick);
65
+ const onClick = useEvent((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__ */ jsxs(
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__ */ jsx("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__ */ jsx("path", { d: "M10.052 9L16 15M15.948 9L10 15" })
95
+ ]
96
+ }
97
+ );
98
+ const touchDevice = useTouchDevice() && withinTag;
99
+ props = __spreadProps(__spreadValues({
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__ */ jsx(Role.span, { render: props.render }) : props.render
108
+ });
109
+ return props;
110
+ }
111
+ );
112
+ var TagRemove = forwardRef(function TagRemove2(props) {
113
+ const htmlProps = useTagRemove(props);
114
+ return createElement(TagName, htmlProps);
115
+ });
116
+ export {
117
+ TagRemove,
118
+ useTagRemove
119
+ };
@@ -0,0 +1,49 @@
1
+ import * as Core from "@ariakit/core/tag/tag-store";
2
+ import type { CompositeStoreFunctions, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
3
+ import type { Store } from "../utils/store.js";
4
+ export declare function useTagStoreProps<T extends Core.TagStore>(store: T, update: () => void, props: TagStoreProps): T;
5
+ /**
6
+ * Creates a tag store to control the state of
7
+ * [Tag](https://ariakit.org/components/tag) components.
8
+ * @see https://ariakit.org/components/tag
9
+ * @example
10
+ * ```jsx
11
+ * const tag = useTagStore({ defaultValues: ["Apple", "Banana"]});
12
+ * const values = tag.useState("values");
13
+ *
14
+ * <TagList store={tag}>
15
+ * {values.map((value) => (
16
+ * <Tag key={value} value={value}>
17
+ * {value}
18
+ * <TagRemove />
19
+ * </Tag>
20
+ * ))}
21
+ * <TagInput />
22
+ * </TagList>
23
+ * ```
24
+ */
25
+ export declare function useTagStore(props?: TagStoreProps): TagStore;
26
+ export interface TagStoreItem extends Core.TagStoreItem {
27
+ }
28
+ export interface TagStoreState extends Core.TagStoreState, CompositeStoreState<TagStoreItem> {
29
+ }
30
+ export interface TagStoreFunctions extends Core.TagStoreFunctions, CompositeStoreFunctions<TagStoreItem> {
31
+ }
32
+ export interface TagStoreOptions extends Core.TagStoreOptions, CompositeStoreOptions<TagStoreItem> {
33
+ /**
34
+ * A callback that gets called when the
35
+ * [`value`](https://ariakit.org/reference/tag-provider#value) state
36
+ * changes.
37
+ */
38
+ setValue?: (value: TagStoreState["value"]) => void;
39
+ /**
40
+ * A callback that gets called when the
41
+ * [`values`](https://ariakit.org/reference/tag-provider#values) state
42
+ * changes.
43
+ */
44
+ setValues?: (values: TagStoreState["values"]) => void;
45
+ }
46
+ export interface TagStoreProps extends TagStoreOptions, Core.TagStoreProps {
47
+ }
48
+ export interface TagStore extends TagStoreFunctions, Store<Core.TagStore> {
49
+ }
@@ -0,0 +1,15 @@
1
+ "use client";
2
+ import {
3
+ useTagStore,
4
+ useTagStoreProps
5
+ } from "../__chunks/QNNHZL3W.js";
6
+ import "../__chunks/ZR5N62ZV.js";
7
+ import "../__chunks/LGWSZOP2.js";
8
+ import "../__chunks/PWUXK5IM.js";
9
+ import "../__chunks/WOWUAP42.js";
10
+ import "../__chunks/XM66DUTO.js";
11
+ import "../__chunks/4R3V3JGP.js";
12
+ export {
13
+ useTagStore,
14
+ useTagStoreProps
15
+ };
@@ -0,0 +1,41 @@
1
+ import type { ReactNode } from "react";
2
+ import type { TagStore, TagStoreState } from "./tag-store.js";
3
+ /**
4
+ * Renders the current
5
+ * [`value`](https://ariakit.org/reference/use-tag-store#value) state in
6
+ * the [tag store](https://ariakit.org/reference/use-tag-store).
7
+ *
8
+ * As a value component, it doesn't render any DOM elements and therefore
9
+ * doesn't accept HTML props.
10
+ *
11
+ * It takes a
12
+ * [`children`](https://ariakit.org/reference/tag-value#children) function
13
+ * that gets called with the current value as an argument. This can be used as
14
+ * an uncontrolled API to render the tag value in a custom way.
15
+ * @see https://ariakit.org/components/tag
16
+ * @example
17
+ * ```jsx {3-5}
18
+ * <TagProvider>
19
+ * <TagInput />
20
+ * <TagValue>
21
+ * {(value) => `Current value: ${value}`}
22
+ * </TagValue>
23
+ * </TagProvider>
24
+ * ```
25
+ */
26
+ export declare function TagValue({ store, children }?: TagValueProps): ReactNode;
27
+ export interface TagValueProps {
28
+ /**
29
+ * Object returned by the
30
+ * [`useTagStore`](https://ariakit.org/reference/use-tag-store)
31
+ * hook. If not provided, the closest
32
+ * [`TagProvider`](https://ariakit.org/reference/tag-provider)
33
+ * component's context will be used.
34
+ */
35
+ store?: TagStore;
36
+ /**
37
+ * A function that gets called with the current value as an argument. It can
38
+ * be used to render the tag value in a custom way.
39
+ */
40
+ children?: (value: TagStoreState["value"]) => ReactNode;
41
+ }
@@ -0,0 +1,29 @@
1
+ "use client";
2
+ import {
3
+ useTagContext
4
+ } from "../__chunks/WYDDZRWN.js";
5
+ import "../__chunks/QFI3MCMR.js";
6
+ import "../__chunks/6LTHW2TQ.js";
7
+ import "../__chunks/GUCZNEAD.js";
8
+ import "../__chunks/WOWUAP42.js";
9
+ import "../__chunks/XM66DUTO.js";
10
+ import "../__chunks/4R3V3JGP.js";
11
+
12
+ // src/tag/tag-value.tsx
13
+ import { invariant } from "@ariakit/core/utils/misc";
14
+ function TagValue({ store, children } = {}) {
15
+ const context = useTagContext();
16
+ store = store || context;
17
+ invariant(
18
+ store,
19
+ process.env.NODE_ENV !== "production" && "TagValue must receive a `store` prop or be wrapped in a TagProvider component."
20
+ );
21
+ const value = store.useState("value");
22
+ if (children) {
23
+ return children(value);
24
+ }
25
+ return value;
26
+ }
27
+ export {
28
+ TagValue
29
+ };
@@ -0,0 +1,52 @@
1
+ import type { ReactNode } from "react";
2
+ import type { TagStore, TagStoreState } from "./tag-store.js";
3
+ /**
4
+ * Renders the current
5
+ * [`values`](https://ariakit.org/reference/use-tag-store#values) state in the
6
+ * [tag store](https://ariakit.org/reference/use-tag-store).
7
+ *
8
+ * As a value component, it doesn't render any DOM elements and therefore
9
+ * doesn't accept HTML props.
10
+ *
11
+ * It takes a [`children`](https://ariakit.org/reference/tag-values#children)
12
+ * function that gets called with the current values as an argument. This can be
13
+ * used as an uncontrolled API to render
14
+ * [`Tag`](https://ariakit.org/reference/tag) components.
15
+ * @see https://ariakit.org/components/tag
16
+ * @example
17
+ * ```jsx {4-13}
18
+ * <TagProvider>
19
+ * <TagListLabel>Invitees</TagListLabel>
20
+ * <TagList>
21
+ * <TagValues>
22
+ * {(values) =>
23
+ * values.map((value) => (
24
+ * <Tag key={value} value={value}>
25
+ * {value}
26
+ * <TagRemove />
27
+ * </Tag>
28
+ * ))
29
+ * }
30
+ * </TagValues>
31
+ * <TagInput />
32
+ * </TagList>
33
+ * </TagProvider>
34
+ * ```
35
+ */
36
+ export declare function TagValues({ store, children }?: TagValuesProps): ReactNode;
37
+ export interface TagValuesProps {
38
+ /**
39
+ * Object returned by the
40
+ * [`useTagStore`](https://ariakit.org/reference/use-tag-store) hook. If not
41
+ * provided, the closest
42
+ * [`TagProvider`](https://ariakit.org/reference/tag-provider) component's
43
+ * context will be used.
44
+ */
45
+ store?: TagStore;
46
+ /**
47
+ * A function that gets called with the current values as an argument. This
48
+ * can be used as an uncontrolled API to render
49
+ * [`Tag`](https://ariakit.org/reference/tag) components.
50
+ */
51
+ children?: (values: TagStoreState["values"]) => ReactNode;
52
+ }
@@ -0,0 +1,29 @@
1
+ "use client";
2
+ import {
3
+ useTagContext
4
+ } from "../__chunks/WYDDZRWN.js";
5
+ import "../__chunks/QFI3MCMR.js";
6
+ import "../__chunks/6LTHW2TQ.js";
7
+ import "../__chunks/GUCZNEAD.js";
8
+ import "../__chunks/WOWUAP42.js";
9
+ import "../__chunks/XM66DUTO.js";
10
+ import "../__chunks/4R3V3JGP.js";
11
+
12
+ // src/tag/tag-values.tsx
13
+ import { invariant } from "@ariakit/core/utils/misc";
14
+ function TagValues({ store, children } = {}) {
15
+ const context = useTagContext();
16
+ store = store || context;
17
+ invariant(
18
+ store,
19
+ process.env.NODE_ENV !== "production" && "TagValues must receive a `store` prop or be wrapped in a TagProvider component."
20
+ );
21
+ const values = store.useState("values");
22
+ if (children) {
23
+ return children(values);
24
+ }
25
+ return values;
26
+ }
27
+ export {
28
+ TagValues
29
+ };
@@ -0,0 +1,74 @@
1
+ import type { ElementType, KeyboardEvent } from "react";
2
+ import type { BooleanOrCallback } from "@ariakit/core/utils/types";
3
+ import type { CompositeItemOptions } from "../composite/composite-item.js";
4
+ import type { Props } from "../utils/types.js";
5
+ import type { TagStore } from "./tag-store.js";
6
+ declare const TagName = "div";
7
+ type TagName = typeof TagName;
8
+ type HTMLType = HTMLElementTagNameMap[TagName];
9
+ /**
10
+ * Returns props to create a `Tag` component.
11
+ * @see https://ariakit.org/components/tag
12
+ * @example
13
+ * ```jsx
14
+ * const props = useTag();
15
+ * <Role.div {...props} />
16
+ * ```
17
+ */
18
+ export declare const useTag: import("../utils/types.js").Hook<"div", TagOptions<"div">>;
19
+ /**
20
+ * Renders a tag element inside a
21
+ * [`TagList`](https://ariakit.org/reference/tag-list) wrapper.
22
+ *
23
+ * The user can remove the tag by pressing `Backspace` or `Delete` keys when the
24
+ * tag is focused. The
25
+ * [`removeOnKeyPress`](https://ariakit.org/reference/tag#removeonkeypress) prop
26
+ * can be used to disable this behavior.
27
+ *
28
+ * When a printable key is pressed, the focus is automatically moved to the
29
+ * input element.
30
+ * @see https://ariakit.org/components/tag
31
+ * @example
32
+ * ```jsx {7-10}
33
+ * <TagProvider>
34
+ * <TagListLabel>Invitees</TagListLabel>
35
+ * <TagList>
36
+ * <TagValues>
37
+ * {(values) =>
38
+ * values.map((value) => (
39
+ * <Tag key={value} value={value}>
40
+ * {value}
41
+ * <TagRemove />
42
+ * </Tag>
43
+ * ))
44
+ * }
45
+ * </TagValues>
46
+ * <TagInput />
47
+ * </TagList>
48
+ * </TagProvider>
49
+ * ```
50
+ */
51
+ export declare const Tag: (props: TagProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
52
+ export interface TagOptions<T extends ElementType = TagName> extends CompositeItemOptions<T> {
53
+ /**
54
+ * Object returned by the
55
+ * [`useTagStore`](https://ariakit.org/reference/use-tag-store) hook. If not
56
+ * provided, the closest [`TagList`](https://ariakit.org/reference/tag-list)
57
+ * component's context will be used.
58
+ */
59
+ store?: TagStore;
60
+ /**
61
+ * The unique value of the tag. This is automatically rendered as the tag's
62
+ * content if no children are provided.
63
+ */
64
+ value: string;
65
+ /**
66
+ * Defines the behavior of the `Backspace` and `Delete` keys when the tag is
67
+ * focused. If `true`, the tag is removed. If it's a function, it's invoked
68
+ * with the key event and should return a boolean.
69
+ * @default true
70
+ */
71
+ removeOnKeyPress?: BooleanOrCallback<KeyboardEvent<HTMLType>>;
72
+ }
73
+ export type TagProps<T extends ElementType = TagName> = Props<T, TagOptions<T>>;
74
+ export {};
package/esm/tag/tag.js ADDED
@@ -0,0 +1,130 @@
1
+ "use client";
2
+ import {
3
+ useCompositeItem
4
+ } from "../__chunks/VGORKDMQ.js";
5
+ import "../__chunks/IFMAUEA7.js";
6
+ import "../__chunks/PJ7ERAIM.js";
7
+ import {
8
+ useTouchDevice
9
+ } from "../__chunks/L7IM35RU.js";
10
+ import {
11
+ TagRemoveIdContext,
12
+ TagValueContext,
13
+ useTagContext
14
+ } from "../__chunks/WYDDZRWN.js";
15
+ import "../__chunks/3IEDWLST.js";
16
+ import "../__chunks/QFI3MCMR.js";
17
+ import "../__chunks/6LTHW2TQ.js";
18
+ import "../__chunks/7JCFLN3D.js";
19
+ import "../__chunks/SHA3WOPI.js";
20
+ import {
21
+ createElement,
22
+ createHook,
23
+ forwardRef,
24
+ memo
25
+ } from "../__chunks/GUCZNEAD.js";
26
+ import "../__chunks/PWUXK5IM.js";
27
+ import {
28
+ useBooleanEvent,
29
+ useEvent,
30
+ useId,
31
+ useWrapElement
32
+ } from "../__chunks/WOWUAP42.js";
33
+ import "../__chunks/XM66DUTO.js";
34
+ import {
35
+ __objRest,
36
+ __spreadProps,
37
+ __spreadValues
38
+ } from "../__chunks/4R3V3JGP.js";
39
+
40
+ // src/tag/tag.tsx
41
+ import { useCallback, useState } from "react";
42
+ import { invariant } from "@ariakit/core/utils/misc";
43
+ import { isApple } from "@ariakit/core/utils/platform";
44
+ import { jsx } from "react/jsx-runtime";
45
+ var TagName = "div";
46
+ var useTag = createHook(function useTag2(_a) {
47
+ var _b = _a, {
48
+ store,
49
+ value,
50
+ getItem: getItemProp,
51
+ removeOnKeyPress = true
52
+ } = _b, props = __objRest(_b, [
53
+ "store",
54
+ "value",
55
+ "getItem",
56
+ "removeOnKeyPress"
57
+ ]);
58
+ const context = useTagContext();
59
+ store = store || context;
60
+ invariant(
61
+ store,
62
+ process.env.NODE_ENV !== "production" && "Tag must be wrapped in a TagList component."
63
+ );
64
+ const id = useId(props.id);
65
+ const touchDevice = useTouchDevice();
66
+ const getItem = useCallback(
67
+ (item) => {
68
+ const nextItem = __spreadProps(__spreadValues({}, item), { value });
69
+ if (getItemProp) {
70
+ return getItemProp(nextItem);
71
+ }
72
+ return nextItem;
73
+ },
74
+ [value, getItemProp]
75
+ );
76
+ const onKeyDownProp = props.onKeyDown;
77
+ const removeOnKeyPressProp = useBooleanEvent(removeOnKeyPress);
78
+ const onKeyDown = useEvent((event) => {
79
+ onKeyDownProp == null ? void 0 : onKeyDownProp(event);
80
+ if (event.defaultPrevented)
81
+ return;
82
+ const { inputElement } = store.getState();
83
+ const isBackspace = event.key === "Backspace";
84
+ const isRemoveKey = isBackspace || event.key === "Delete";
85
+ if (isRemoveKey && removeOnKeyPressProp(event)) {
86
+ event.preventDefault();
87
+ store.removeValue(value);
88
+ const nextId = isBackspace ? store.previous() || store.next() : store.next();
89
+ store.move(nextId);
90
+ }
91
+ const isPrintableKey = !event.ctrlKey && !event.metaKey && event.key.length === 1;
92
+ const pc = !isApple();
93
+ const v = event.key === "v" || event.key === "V";
94
+ const mod = pc ? event.ctrlKey : event.metaKey;
95
+ const isPaste = mod && v;
96
+ if (isPrintableKey || isPaste) {
97
+ inputElement == null ? void 0 : inputElement.focus();
98
+ }
99
+ });
100
+ const [removeId, setRemoveId] = useState();
101
+ props = useWrapElement(
102
+ props,
103
+ (element) => /* @__PURE__ */ jsx(TagValueContext.Provider, { value, children: /* @__PURE__ */ jsx(TagRemoveIdContext.Provider, { value: setRemoveId, children: element }) }),
104
+ [value]
105
+ );
106
+ props = __spreadProps(__spreadValues({
107
+ id,
108
+ role: !touchDevice ? "option" : "listitem",
109
+ children: value,
110
+ "aria-describedby": removeId
111
+ }, props), {
112
+ onKeyDown
113
+ });
114
+ props = useCompositeItem(__spreadProps(__spreadValues({
115
+ store
116
+ }, props), {
117
+ getItem
118
+ }));
119
+ return props;
120
+ });
121
+ var Tag = memo(
122
+ forwardRef(function Tag2(props) {
123
+ const htmlProps = useTag(props);
124
+ return createElement(TagName, htmlProps);
125
+ })
126
+ );
127
+ export {
128
+ Tag,
129
+ useTag
130
+ };
@@ -0,0 +1 @@
1
+ export declare function useTouchDevice(): boolean;
@@ -0,0 +1,8 @@
1
+ "use client";
2
+ import {
3
+ useTouchDevice
4
+ } from "../__chunks/L7IM35RU.js";
5
+ import "../__chunks/4R3V3JGP.js";
6
+ export {
7
+ useTouchDevice
8
+ };
@@ -4,10 +4,10 @@ import {
4
4
  } from "../__chunks/LQCUPYIB.js";
5
5
  import {
6
6
  useToolbarItem
7
- } from "../__chunks/XK6CE2M5.js";
8
- import "../__chunks/ONUY4D7O.js";
9
- import "../__chunks/PJ7ERAIM.js";
7
+ } from "../__chunks/UKDZLPKH.js";
8
+ import "../__chunks/VGORKDMQ.js";
10
9
  import "../__chunks/IFMAUEA7.js";
10
+ import "../__chunks/PJ7ERAIM.js";
11
11
  import "../__chunks/3IEDWLST.js";
12
12
  import {
13
13
  useToolbarContext
@@ -1,5 +1,4 @@
1
1
  import type { ElementType } from "react";
2
- import type { CompositeInputOptions } from "../composite/composite-input.js";
3
2
  import type { Props } from "../utils/types.js";
4
3
  import type { ToolbarItemOptions } from "./toolbar-item.js";
5
4
  declare const TagName = "input";
@@ -7,6 +6,7 @@ type TagName = typeof TagName;
7
6
  /**
8
7
  * Returns props to create a `ToolbarInput` component.
9
8
  * @see https://ariakit.org/components/toolbar
9
+ * @deprecated Use `useToolbarItem` instead.
10
10
  * @example
11
11
  * ```jsx
12
12
  * const store = useToolbarStore();
@@ -21,6 +21,7 @@ export declare const useToolbarInput: import("../utils/types.js").Hook<"input",
21
21
  * Renders a text input as a toolbar item, maintaining arrow key navigation on
22
22
  * the toolbar.
23
23
  * @see https://ariakit.org/components/toolbar
24
+ * @deprecated Use `<ToolbarItem render={<input />}>` instead.
24
25
  * @example
25
26
  * ```jsx {2}
26
27
  * <Toolbar>
@@ -29,7 +30,7 @@ export declare const useToolbarInput: import("../utils/types.js").Hook<"input",
29
30
  * ```
30
31
  */
31
32
  export declare const ToolbarInput: (props: ToolbarInputProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
32
- export interface ToolbarInputOptions<T extends ElementType = TagName> extends ToolbarItemOptions<T>, Omit<CompositeInputOptions<T>, "store"> {
33
+ export interface ToolbarInputOptions<T extends ElementType = TagName> extends ToolbarItemOptions<T> {
33
34
  }
34
35
  export type ToolbarInputProps<T extends ElementType = TagName> = Props<T, ToolbarInputOptions<T>>;
35
36
  export {};
@@ -1,13 +1,10 @@
1
1
  "use client";
2
- import {
3
- useCompositeInput
4
- } from "../__chunks/RPGNBKKU.js";
5
2
  import {
6
3
  useToolbarItem
7
- } from "../__chunks/XK6CE2M5.js";
8
- import "../__chunks/ONUY4D7O.js";
9
- import "../__chunks/PJ7ERAIM.js";
4
+ } from "../__chunks/UKDZLPKH.js";
5
+ import "../__chunks/VGORKDMQ.js";
10
6
  import "../__chunks/IFMAUEA7.js";
7
+ import "../__chunks/PJ7ERAIM.js";
11
8
  import "../__chunks/3IEDWLST.js";
12
9
  import {
13
10
  useToolbarContext
@@ -37,7 +34,6 @@ var useToolbarInput = createHook(
37
34
  var _b = _a, { store } = _b, props = __objRest(_b, ["store"]);
38
35
  const context = useToolbarContext();
39
36
  store = store || context;
40
- props = useCompositeInput(__spreadValues({ store }, props));
41
37
  props = useToolbarItem(__spreadValues({ store }, props));
42
38
  return props;
43
39
  }
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  ToolbarItem,
4
4
  useToolbarItem
5
- } from "../__chunks/XK6CE2M5.js";
6
- import "../__chunks/ONUY4D7O.js";
7
- import "../__chunks/PJ7ERAIM.js";
5
+ } from "../__chunks/UKDZLPKH.js";
6
+ import "../__chunks/VGORKDMQ.js";
8
7
  import "../__chunks/IFMAUEA7.js";
8
+ import "../__chunks/PJ7ERAIM.js";
9
9
  import "../__chunks/3IEDWLST.js";
10
10
  import "../__chunks/766APSLG.js";
11
11
  import "../__chunks/QFI3MCMR.js";