@box-kite/react 0.0.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (280) hide show
  1. package/.claude/rules/box-kite-rules.md +65 -0
  2. package/.claude/skills/box-kite/SKILL.md +138 -0
  3. package/.claude/skills/box-kite/references/components.md +235 -0
  4. package/.claude/skills/box-kite/references/extending.md +42 -0
  5. package/.claude/skills/box-kite/references/patterns.md +27 -0
  6. package/.claude/skills/box-kite/references/styling.md +222 -0
  7. package/.cursor/rules/box-kite.mdc +73 -0
  8. package/AGENTS.md +102 -0
  9. package/BOX_AI_CONTEXT.md +2804 -0
  10. package/BOX_KITE_AI_CONTEXT.md +2804 -0
  11. package/LICENSE +21 -0
  12. package/README.md +744 -7
  13. package/a11y.cjs +1 -0
  14. package/a11y.d.ts +15 -0
  15. package/a11y.mjs +4 -0
  16. package/anchor.cjs +1 -0
  17. package/anchor.d.ts +14 -0
  18. package/anchor.mjs +3 -0
  19. package/behavior.cjs +1 -0
  20. package/behavior.mjs +277 -0
  21. package/box.cjs +1 -0
  22. package/box.d.ts +46 -0
  23. package/box.mjs +23 -0
  24. package/client.cjs +1 -0
  25. package/client.mjs +164 -0
  26. package/components/accordion.cjs +1 -0
  27. package/components/accordion.d.ts +114 -0
  28. package/components/accordion.mjs +251 -0
  29. package/components/baseSvg.cjs +1 -0
  30. package/components/baseSvg.d.ts +5 -0
  31. package/components/baseSvg.mjs +21 -0
  32. package/components/button.cjs +1 -0
  33. package/components/button.d.ts +19 -0
  34. package/components/button.mjs +19 -0
  35. package/components/chart.cjs +1 -0
  36. package/components/chart.d.ts +83 -0
  37. package/components/chart.mjs +236 -0
  38. package/components/checkbox.cjs +1 -0
  39. package/components/checkbox.d.ts +36 -0
  40. package/components/checkbox.mjs +38 -0
  41. package/components/combobox/comboboxChips.d.ts +21 -0
  42. package/components/combobox/comboboxListbox.d.ts +47 -0
  43. package/components/combobox.cjs +1 -0
  44. package/components/combobox.d.ts +121 -0
  45. package/components/combobox.mjs +563 -0
  46. package/components/dataGrid/components/dataGridAggregateValue.d.ts +10 -0
  47. package/components/dataGrid/components/dataGridBody.d.ts +7 -0
  48. package/components/dataGrid/components/dataGridBottomBar.d.ts +6 -0
  49. package/components/dataGrid/components/dataGridCell.d.ts +16 -0
  50. package/components/dataGrid/components/dataGridCellEditor.d.ts +15 -0
  51. package/components/dataGrid/components/dataGridCellPlaceholder.d.ts +14 -0
  52. package/components/dataGrid/components/dataGridCellRowDetail.d.ts +6 -0
  53. package/components/dataGrid/components/dataGridCellRowSelection.d.ts +6 -0
  54. package/components/dataGrid/components/dataGridCellText.d.ts +6 -0
  55. package/components/dataGrid/components/dataGridCellTree.d.ts +16 -0
  56. package/components/dataGrid/components/dataGridColumnFilter.d.ts +9 -0
  57. package/components/dataGrid/components/dataGridColumnGroups.d.ts +7 -0
  58. package/components/dataGrid/components/dataGridContent.d.ts +6 -0
  59. package/components/dataGrid/components/dataGridDataSourceError.d.ts +12 -0
  60. package/components/dataGrid/components/dataGridDetailRow.d.ts +8 -0
  61. package/components/dataGrid/components/dataGridEmptyColumns.d.ts +6 -0
  62. package/components/dataGrid/components/dataGridExport.d.ts +10 -0
  63. package/components/dataGrid/components/dataGridFilterCell.d.ts +11 -0
  64. package/components/dataGrid/components/dataGridFilterRow.d.ts +6 -0
  65. package/components/dataGrid/components/dataGridFooter.d.ts +11 -0
  66. package/components/dataGrid/components/dataGridGlobalFilter.d.ts +6 -0
  67. package/components/dataGrid/components/dataGridGroupRow.d.ts +8 -0
  68. package/components/dataGrid/components/dataGridHeader.d.ts +6 -0
  69. package/components/dataGrid/components/dataGridHeaderCell.d.ts +9 -0
  70. package/components/dataGrid/components/dataGridHeaderCellContextMenu.d.ts +11 -0
  71. package/components/dataGrid/components/dataGridHeaderCellResizer.d.ts +14 -0
  72. package/components/dataGrid/components/dataGridLoader.d.ts +11 -0
  73. package/components/dataGrid/components/dataGridPagination.d.ts +6 -0
  74. package/components/dataGrid/components/dataGridRow.d.ts +8 -0
  75. package/components/dataGrid/components/dataGridTopBar.d.ts +6 -0
  76. package/components/dataGrid/components/dataGridTopBarContextMenu.d.ts +6 -0
  77. package/components/dataGrid/contracts/dataGridContract.d.ts +671 -0
  78. package/components/dataGrid/export/gridExport.d.ts +10 -0
  79. package/components/dataGrid/gridNavigationContext.d.ts +32 -0
  80. package/components/dataGrid/models/aggregateCellModel.d.ts +34 -0
  81. package/components/dataGrid/models/aggregationModel.d.ts +32 -0
  82. package/components/dataGrid/models/cellKeys.d.ts +11 -0
  83. package/components/dataGrid/models/cellModel.d.ts +44 -0
  84. package/components/dataGrid/models/columnModel.d.ts +160 -0
  85. package/components/dataGrid/models/columnVisibilityModel.d.ts +24 -0
  86. package/components/dataGrid/models/dataSourceModel.d.ts +177 -0
  87. package/components/dataGrid/models/detailRowModel.d.ts +22 -0
  88. package/components/dataGrid/models/editModel.d.ts +77 -0
  89. package/components/dataGrid/models/exportModel.d.ts +51 -0
  90. package/components/dataGrid/models/filterModel.d.ts +22 -0
  91. package/components/dataGrid/models/gridModel.d.ts +293 -0
  92. package/components/dataGrid/models/groupRowCellModel.d.ts +34 -0
  93. package/components/dataGrid/models/groupRowModel.d.ts +68 -0
  94. package/components/dataGrid/models/headerCellModel.d.ts +83 -0
  95. package/components/dataGrid/models/paginationModel.d.ts +32 -0
  96. package/components/dataGrid/models/rowModel.d.ts +46 -0
  97. package/components/dataGrid/models/sourceGroupRowModel.d.ts +45 -0
  98. package/components/dataGrid/models/sourceLevel.d.ts +71 -0
  99. package/components/dataGrid/models/sourceRowModel.d.ts +29 -0
  100. package/components/dataGrid/models/sourceTreeRowModel.d.ts +23 -0
  101. package/components/dataGrid/models/treeModel.d.ts +94 -0
  102. package/components/dataGrid/models/treeRow.d.ts +22 -0
  103. package/components/dataGrid/models/treeRowModel.d.ts +50 -0
  104. package/components/dataGrid/models/viewportModel.d.ts +44 -0
  105. package/components/dataGrid/useGrid.d.ts +8 -0
  106. package/components/dataGrid/useGridNavigation.d.ts +21 -0
  107. package/components/dataGrid.cjs +1 -0
  108. package/components/dataGrid.d.ts +4 -0
  109. package/components/dataGrid.mjs +4907 -0
  110. package/components/dialog.cjs +1 -0
  111. package/components/dialog.d.ts +151 -0
  112. package/components/dialog.mjs +223 -0
  113. package/components/dropdown/dropdownContext.d.ts +44 -0
  114. package/components/dropdown/dropdownItems.d.ts +22 -0
  115. package/components/dropdown/dropdownRowRenderer.d.ts +8 -0
  116. package/components/dropdown/dropdownSearch.d.ts +21 -0
  117. package/components/dropdown/utils.d.ts +1 -0
  118. package/components/dropdown.cjs +1 -0
  119. package/components/dropdown.d.ts +77 -0
  120. package/components/dropdown.mjs +491 -0
  121. package/components/flex.cjs +1 -0
  122. package/components/flex.d.ts +6 -0
  123. package/components/flex.mjs +16 -0
  124. package/components/form.cjs +1 -0
  125. package/components/form.d.ts +10 -0
  126. package/components/form.mjs +58 -0
  127. package/components/grid.cjs +1 -0
  128. package/components/grid.d.ts +6 -0
  129. package/components/grid.mjs +16 -0
  130. package/components/icon.cjs +1 -0
  131. package/components/icon.d.ts +37 -0
  132. package/components/icon.mjs +41 -0
  133. package/components/menu.cjs +1 -0
  134. package/components/menu.d.ts +234 -0
  135. package/components/menu.mjs +422 -0
  136. package/components/overlay.cjs +1 -0
  137. package/components/overlay.d.ts +47 -0
  138. package/components/overlay.mjs +52 -0
  139. package/components/popover.cjs +1 -0
  140. package/components/popover.d.ts +100 -0
  141. package/components/popover.mjs +69 -0
  142. package/components/presence.cjs +1 -0
  143. package/components/presence.d.ts +36 -0
  144. package/components/presence.mjs +11 -0
  145. package/components/progress.cjs +1 -0
  146. package/components/progress.d.ts +47 -0
  147. package/components/progress.mjs +28 -0
  148. package/components/radioButton.cjs +1 -0
  149. package/components/radioButton.d.ts +32 -0
  150. package/components/radioButton.mjs +32 -0
  151. package/components/radioGroup.cjs +1 -0
  152. package/components/radioGroup.d.ts +51 -0
  153. package/components/radioGroup.mjs +83 -0
  154. package/components/select.cjs +1 -0
  155. package/components/select.d.ts +51 -0
  156. package/components/select.mjs +36 -0
  157. package/components/semantics.cjs +1 -0
  158. package/components/semantics.d.ts +39 -0
  159. package/components/semantics.mjs +17 -0
  160. package/components/slider.cjs +1 -0
  161. package/components/slider.d.ts +98 -0
  162. package/components/slider.mjs +250 -0
  163. package/components/svg.cjs +1 -0
  164. package/components/svg.d.ts +65 -0
  165. package/components/svg.mjs +141 -0
  166. package/components/switch.cjs +1 -0
  167. package/components/switch.d.ts +29 -0
  168. package/components/switch.mjs +25 -0
  169. package/components/tabs.cjs +1 -0
  170. package/components/tabs.d.ts +87 -0
  171. package/components/tabs.mjs +324 -0
  172. package/components/textarea.cjs +1 -0
  173. package/components/textarea.d.ts +41 -0
  174. package/components/textarea.mjs +33 -0
  175. package/components/textbox.cjs +1 -0
  176. package/components/textbox.d.ts +38 -0
  177. package/components/textbox.mjs +33 -0
  178. package/components/toaster.cjs +1 -0
  179. package/components/toaster.d.ts +106 -0
  180. package/components/toaster.mjs +295 -0
  181. package/components/tooltip.cjs +1 -0
  182. package/components/tooltip.d.ts +98 -0
  183. package/components/tooltip.mjs +110 -0
  184. package/components/visuallyHidden.cjs +1 -0
  185. package/components/visuallyHidden.d.ts +6 -0
  186. package/components/visuallyHidden.mjs +23 -0
  187. package/docs/a11y.md +199 -0
  188. package/docs/anchor.md +139 -0
  189. package/docs/components.md +48 -0
  190. package/docs/index.md +11 -0
  191. package/docs/props.md +1777 -0
  192. package/effects.cjs +1 -0
  193. package/effects.mjs +6 -0
  194. package/forms.cjs +1 -0
  195. package/forms.mjs +21 -0
  196. package/gridExport.cjs +2 -0
  197. package/gridExport.mjs +244 -0
  198. package/icons/dotsIcon.d.ts +2 -0
  199. package/icons/expandIcon.d.ts +2 -0
  200. package/icons/groupingIcon.d.ts +2 -0
  201. package/icons/pinIcon.d.ts +2 -0
  202. package/icons/searchIcon.d.ts +2 -0
  203. package/icons/sortIcon.d.ts +2 -0
  204. package/identity.cjs +1 -0
  205. package/identity.mjs +12 -0
  206. package/keyboard.cjs +1 -0
  207. package/keyboard.mjs +30 -0
  208. package/layer.cjs +1 -0
  209. package/layer.mjs +127 -0
  210. package/motion.cjs +1 -0
  211. package/motion.mjs +66 -0
  212. package/package.json +327 -7
  213. package/placement.cjs +1 -0
  214. package/placement.mjs +180 -0
  215. package/platform.cjs +1 -0
  216. package/platform.mjs +45 -0
  217. package/react/a11y/callbacks.d.ts +12 -0
  218. package/react/a11y/useControllableState.d.ts +25 -0
  219. package/react/a11y/useDismiss.d.ts +25 -0
  220. package/react/a11y/useFocusReturn.d.ts +18 -0
  221. package/react/a11y/useRovingFocus.d.ts +84 -0
  222. package/react/anchor/useAnchorPosition.d.ts +79 -0
  223. package/react/animation/usePresence.d.ts +32 -0
  224. package/react/boxClassNames.d.ts +25 -0
  225. package/react/boxProps.d.ts +49 -0
  226. package/react/boxTagProps.d.ts +7 -0
  227. package/react/clientRuntime.d.ts +11 -0
  228. package/react/dialog/useScrollLock.d.ts +12 -0
  229. package/react/effects.d.ts +10 -0
  230. package/react/forms/labelledControl.d.ts +17 -0
  231. package/react/forms/placeholderProp.d.ts +13 -0
  232. package/react/hooks/usePortalContainer.d.ts +6 -0
  233. package/react/hooks/useVirtualization.d.ts +32 -0
  234. package/react/hooks/useVisibility.d.ts +9 -0
  235. package/react/identity/useIdentifier.d.ts +17 -0
  236. package/react/popover/usePopoverLayer.d.ts +87 -0
  237. package/react/reactTypes.d.ts +10 -0
  238. package/react/resolveStyles.d.ts +18 -0
  239. package/react/styleElements.d.ts +3 -0
  240. package/react/svg/attributesInProps.d.ts +4 -0
  241. package/react/svg/svgNaming.d.ts +15 -0
  242. package/react/theme/theme.d.ts +26 -0
  243. package/react/theme/themeContext.d.ts +7 -0
  244. package/react/useStyles.d.ts +22 -0
  245. package/react-shared.cjs +1 -0
  246. package/react-shared.mjs +122 -0
  247. package/rolldown-runtime.cjs +1 -0
  248. package/rsc.cjs +1 -0
  249. package/rsc.d.ts +27 -0
  250. package/rsc.mjs +18 -0
  251. package/ssg.cjs +1 -0
  252. package/ssg.d.ts +24 -0
  253. package/ssg.mjs +25 -0
  254. package/utils/accordion/accordionUtils.d.ts +48 -0
  255. package/utils/anchor/anchorUtils.d.ts +79 -0
  256. package/utils/animation/animationUtils.d.ts +29 -0
  257. package/utils/array/arrayUtils.d.ts +15 -0
  258. package/utils/array/lazyList.d.ts +10 -0
  259. package/utils/box/boxUtils.d.ts +5 -0
  260. package/utils/chart/chartPalette.d.ts +15 -0
  261. package/utils/chart/chartUtils.d.ts +92 -0
  262. package/utils/combobox/comboboxUtils.d.ts +89 -0
  263. package/utils/dom/domUtils.d.ts +32 -0
  264. package/utils/environment/environmentUtils.d.ts +28 -0
  265. package/utils/export/csvUtils.d.ts +23 -0
  266. package/utils/export/downloadUtils.d.ts +12 -0
  267. package/utils/export/xlsxUtils.d.ts +56 -0
  268. package/utils/export/zipUtils.d.ts +26 -0
  269. package/utils/fn/fnUtils.d.ts +4 -0
  270. package/utils/form/formUtils.d.ts +8 -0
  271. package/utils/keyboard/typeaheadUtils.d.ts +31 -0
  272. package/utils/memo.d.ts +10 -0
  273. package/utils/menu/menuUtils.d.ts +25 -0
  274. package/utils/object/objectUtils.d.ts +13 -0
  275. package/utils/slider/sliderUtils.d.ts +67 -0
  276. package/utils/string/fuzzySearch.d.ts +27 -0
  277. package/utils/string/stringUtils.d.ts +4 -0
  278. package/utils/tabs/tabsUtils.d.ts +75 -0
  279. package/utils/toast/toastStore.d.ts +73 -0
  280. package/utils/virtual/virtualUtils.d.ts +47 -0
@@ -0,0 +1,250 @@
1
+ "use client";
2
+ import { u as e } from "../platform.mjs";
3
+ import t from "../box.mjs";
4
+ import { a as n, i as r, o as i } from "../behavior.mjs";
5
+ import { useRef as a, useState as o } from "react";
6
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
7
+ //#region src/utils/slider/sliderUtils.ts
8
+ var l;
9
+ (function(e) {
10
+ function t(e) {
11
+ let t = String(Math.abs(e));
12
+ if (t.includes("e")) return 12;
13
+ let n = t.indexOf(".");
14
+ return n === -1 ? 0 : t.length - n - 1;
15
+ }
16
+ e.decimals = t;
17
+ function n(e, t) {
18
+ return Number(e.toFixed(Math.min(t, 15)));
19
+ }
20
+ function r(e, t, n) {
21
+ return Math.min(Math.max(e, t), n);
22
+ }
23
+ e.clamp = r;
24
+ function i(e, i) {
25
+ let { min: a, max: o, step: s } = i, c = r(e, a, o);
26
+ return s > 0 ? r(n(a + Math.round((c - a) / s) * s, t(s) + t(a)), a, o) : c;
27
+ }
28
+ e.snap = i;
29
+ function a(e, t, n) {
30
+ return n <= t ? 0 : (r(e, t, n) - t) * (100 / (n - t));
31
+ }
32
+ e.percent = a;
33
+ function o(e, t, n) {
34
+ return `${Math.round(a(e, t, n) * 100) / 100}%`;
35
+ }
36
+ e.percentage = o;
37
+ function s(e) {
38
+ return typeof e == "number" ? [e] : [...e];
39
+ }
40
+ e.thumbs = s;
41
+ function c(e, t) {
42
+ return typeof e == "number" ? t[0] : [...t];
43
+ }
44
+ e.shaped = c;
45
+ function l(e, t, n, a) {
46
+ let o = t > 0 ? e[t - 1] : a.min, s = t < e.length - 1 ? e[t + 1] : a.max, c = [...e];
47
+ return c[t] = r(i(n, a), o, s), c;
48
+ }
49
+ e.move = l;
50
+ function u(e, t) {
51
+ return e.length === t.length && e.every((e, n) => e === t[n]);
52
+ }
53
+ e.same = u;
54
+ function d(e, t) {
55
+ let n = 0, r = Infinity;
56
+ return e.forEach((e, i) => {
57
+ let a = Math.abs(e - t);
58
+ a <= r && (n = i, r = a);
59
+ }), n;
60
+ }
61
+ e.nearest = d;
62
+ function f(e, t, n, r, i) {
63
+ let a = r === "vertical" ? e.height === 0 ? 0 : (e.bottom - n) / e.height : e.width === 0 ? 0 : i ? (e.right - t) / e.width : (t - e.left) / e.width;
64
+ return Math.min(Math.max(a, 0), 1);
65
+ }
66
+ e.valueAt = f;
67
+ function p(e, t = !1) {
68
+ if (e === "Home") return {
69
+ kind: "edge",
70
+ delta: -1
71
+ };
72
+ if (e === "End") return {
73
+ kind: "edge",
74
+ delta: 1
75
+ };
76
+ if (e === "PageUp") return {
77
+ kind: "page",
78
+ delta: 1
79
+ };
80
+ if (e === "PageDown") return {
81
+ kind: "page",
82
+ delta: -1
83
+ };
84
+ if (e === "ArrowUp") return {
85
+ kind: "step",
86
+ delta: 1
87
+ };
88
+ if (e === "ArrowDown") return {
89
+ kind: "step",
90
+ delta: -1
91
+ };
92
+ if (e === "ArrowRight") return {
93
+ kind: "step",
94
+ delta: t ? -1 : 1
95
+ };
96
+ if (e === "ArrowLeft") return {
97
+ kind: "step",
98
+ delta: t ? 1 : -1
99
+ };
100
+ }
101
+ e.moveFor = p;
102
+ function m(e, t, n, r) {
103
+ if (t.kind === "edge") return t.delta > 0 ? n.max : n.min;
104
+ let i = t.kind === "page" ? r : n.step;
105
+ return e + t.delta * i;
106
+ }
107
+ e.moved = m;
108
+ })(l ||= {});
109
+ var u = l, d = "data-index";
110
+ function f(e, t, n) {
111
+ return {
112
+ min: e,
113
+ max: t,
114
+ step: n
115
+ };
116
+ }
117
+ function p(e, t) {
118
+ return t ? { insetBlockEnd: e } : { insetInlineStart: e };
119
+ }
120
+ function m(e, t, n) {
121
+ let r = e.length > 1 ? Math.min(...e) : t.min, i = Math.max(...e), a = u.percent(r, t.min, t.max), o = `${Math.round((u.percent(i, t.min, t.max) - a) * 100) / 100}%`;
122
+ return n ? {
123
+ insetBlockEnd: `${Math.round(a * 100) / 100}%`,
124
+ blockSize: o
125
+ } : {
126
+ insetInlineStart: `${Math.round(a * 100) / 100}%`,
127
+ inlineSize: o
128
+ };
129
+ }
130
+ function h(l) {
131
+ let { value: h, defaultValue: g, onValueChange: _, onValueCommit: v, min: y = 0, max: b = 100, step: x = 1, largeStep: S = x * 10, orientation: C = "horizontal", disabled: w = !1, label: T, labelledBy: E, thumbLabels: D, format: O, name: k, props: A, ...j } = l, M = a(null), N = a(null), P = a(null), F = a(!1), [I, L] = o(!1), [R, z] = r({
132
+ value: h,
133
+ defaultValue: g ?? y,
134
+ onChange: _
135
+ }), B = f(y, b, x), V = C === "vertical", H = u.thumbs(R), U = i(R), W = n(v), G = n((e, t) => {
136
+ z((t) => u.same(u.thumbs(t), e) ? t : u.shaped(t, e), t);
137
+ }), K = (t) => {
138
+ let n = N.current;
139
+ if (!n) return;
140
+ let r = u.valueAt(n.getBoundingClientRect(), t.clientX, t.clientY, C, e(n));
141
+ return y + r * (b - y);
142
+ }, q = (e) => M.current?.querySelectorAll("[role=\"slider\"]")[e], J = n((e) => {
143
+ if (w || e.button !== 0 || e.defaultPrevented) return;
144
+ let t = K(e);
145
+ if (t === void 0) return;
146
+ let n = u.thumbs(U.current), r = u.nearest(n, t);
147
+ P.current = r, e.preventDefault(), e.currentTarget.setPointerCapture?.(e.pointerId), q(r)?.focus(), G(u.move(n, r, t, B), {
148
+ reason: "pointer",
149
+ event: e
150
+ });
151
+ }), Y = n((e) => {
152
+ let t = P.current;
153
+ if (t === null) return;
154
+ let n = K(e);
155
+ n !== void 0 && (L(!0), G(u.move(u.thumbs(U.current), t, n, B), {
156
+ reason: "pointer",
157
+ event: e
158
+ }));
159
+ }), X = n((e) => {
160
+ P.current !== null && (P.current = null, L(!1), e.currentTarget.releasePointerCapture?.(e.pointerId), W(U.current, {
161
+ reason: "pointer",
162
+ event: e
163
+ }));
164
+ }), Z = n((t) => {
165
+ if (w || t.defaultPrevented) return;
166
+ let n = t.target?.closest("[role=\"slider\"]"), r = Number(n?.getAttribute(d) ?? -1);
167
+ if (!n || r < 0) return;
168
+ let i = u.moveFor(t.key, e(n));
169
+ if (!i) return;
170
+ t.preventDefault(), F.current = !0, L(!0);
171
+ let a = u.thumbs(U.current);
172
+ G(u.move(a, r, u.moved(a[r], i, B, S), B), {
173
+ reason: "keyboard",
174
+ event: t
175
+ });
176
+ }), Q = n((e) => {
177
+ F.current && (F.current = !1, L(!1), W(U.current, {
178
+ reason: "keyboard",
179
+ event: e
180
+ }));
181
+ }), $ = H.length > 1;
182
+ return /* @__PURE__ */ c(t, {
183
+ ref: M,
184
+ component: "slider",
185
+ ...j,
186
+ variant: [j.variant, {
187
+ vertical: V,
188
+ disabled: w
189
+ }],
190
+ props: {
191
+ role: $ ? "group" : void 0,
192
+ "aria-label": $ ? T : void 0,
193
+ "aria-labelledby": $ ? E : void 0,
194
+ ...A,
195
+ onPointerDown: J,
196
+ onPointerMove: Y,
197
+ onPointerUp: X,
198
+ onPointerCancel: X,
199
+ onKeyDown: Z,
200
+ onKeyUp: Q
201
+ },
202
+ children: [
203
+ /* @__PURE__ */ s(t, {
204
+ ref: N,
205
+ component: "slider.track",
206
+ variant: { vertical: V },
207
+ children: /* @__PURE__ */ s(t, {
208
+ component: "slider.fill",
209
+ variant: {
210
+ vertical: V,
211
+ tracking: I
212
+ },
213
+ style: m(H, B, V)
214
+ })
215
+ }),
216
+ H.map((e, n) => /* @__PURE__ */ s(t, {
217
+ component: "slider.thumb",
218
+ variant: {
219
+ vertical: V,
220
+ disabled: w,
221
+ tracking: I
222
+ },
223
+ style: p(u.percentage(e, y, b), V),
224
+ props: {
225
+ role: "slider",
226
+ tabIndex: w ? -1 : 0,
227
+ "aria-valuemin": y,
228
+ "aria-valuemax": b,
229
+ "aria-valuenow": e,
230
+ "aria-valuetext": O?.(e),
231
+ "aria-orientation": C,
232
+ "aria-label": D?.[n] ?? ($ ? void 0 : T),
233
+ "aria-labelledby": D?.[n] || $ ? void 0 : E,
234
+ "aria-disabled": w || void 0,
235
+ [d]: n
236
+ }
237
+ }, n)),
238
+ k !== void 0 && H.map((e, t) => /* @__PURE__ */ s("input", {
239
+ type: "hidden",
240
+ name: k,
241
+ value: e,
242
+ readOnly: !0
243
+ }, t))
244
+ ]
245
+ });
246
+ }
247
+ var g = h;
248
+ g.displayName = "Slider";
249
+ //#endregion
250
+ export { g as default };
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../rolldown-runtime.cjs"),t=require("../react-shared.cjs");let n=require("react"),r=require("react/jsx-runtime"),i=require("@box-kite/react");i=e.t(i,1);function a(e,t){let{props:n,...r}=e,i=r,a;for(let e of t)e in i&&((a??={})[e]=i[e],delete i[e]);return{styleProps:i,tagProps:a?{...n,...a}:n}}function o(e,o=[],s){let c=o,l=(0,n.forwardRef)((t,n)=>{let{styleProps:o,tagProps:s}=a(t,c);return(0,r.jsx)(i.default,{tag:e,ref:n,component:e,...o,props:s})});return l.displayName=s??t.a.capitalize(e),t.c(l),l}var s=`http://www.w3.org/2000/svg`,c=[`viewBox`,`preserveAspectRatio`,`width`,`height`];function l(e,n){let{label:o,...l}=e,{styleProps:u,tagProps:d}=a(l,c);return(0,r.jsx)(i.default,{tag:`svg`,ref:n,component:`svg`,...u,props:{xmlns:s,...t.o(o,d),...d}})}var u=t.c((0,n.forwardRef)(l));u.displayName=`Svg`;var d=o(`g`,[`transform`]),f=o(`defs`),p=o(`path`,[`d`,`transform`,`pathLength`]),m=o(`circle`,[`transform`,`pathLength`]),h=o(`ellipse`,[`transform`,`pathLength`]),g=o(`rect`,[`width`,`height`,`transform`,`pathLength`]),_=o(`line`,[`x1`,`y1`,`x2`,`y2`,`transform`,`pathLength`]),v=o(`polyline`,[`points`,`transform`,`pathLength`]),y=o(`polygon`,[`points`,`transform`,`pathLength`]),b=o(`text`,[`x`,`y`,`dx`,`dy`,`textLength`,`lengthAdjust`,`transform`],`SvgText`),x=o(`tspan`,[`x`,`y`,`dx`,`dy`,`textLength`,`lengthAdjust`],`TSpan`),S=o(`linearGradient`,[`x1`,`y1`,`x2`,`y2`,`gradientUnits`,`gradientTransform`,`spreadMethod`]),C=o(`radialGradient`,[`cx`,`cy`,`r`,`fx`,`fy`,`gradientUnits`,`gradientTransform`,`spreadMethod`]),w=o(`stop`,[`offset`,`stopColor`,`stopOpacity`]),T=o(`clipPath`,[`clipPathUnits`,`transform`]),E=o(`mask`,[`maskUnits`,`maskContentUnits`,`x`,`y`,`width`,`height`]),D=o(`use`,[`href`,`width`,`height`,`transform`]),O=o(`symbol`,[`viewBox`,`preserveAspectRatio`,`x`,`y`,`width`,`height`],`SvgSymbol`),k=o(`marker`,[`markerWidth`,`markerHeight`,`refX`,`refY`,`orient`,`markerUnits`,`viewBox`]);exports.Circle=m,exports.ClipPath=T,exports.Defs=f,exports.Ellipse=h,exports.G=d,exports.Line=_,exports.LinearGradient=S,exports.Marker=k,exports.Mask=E,exports.Path=p,exports.Polygon=y,exports.Polyline=v,exports.RadialGradient=C,exports.Rect=g,exports.Stop=w,exports.Svg=u,exports.SvgSymbol=O,exports.SvgText=b,exports.TSpan=x,exports.Use=D;
@@ -0,0 +1,65 @@
1
+ import { RefAttributes } from 'react';
2
+ import { BoxProps } from '../box';
3
+ import { ExtractElementFromTag } from '../react/reactTypes';
4
+ import { ComponentsAndVariants } from '@box-kite/core/types';
5
+ /**
6
+ * The SVG elements as components, so a drawing is written the way the rest of this library is —
7
+ * `<Circle cx={28} r={12} />`, never `<Box tag="circle">`. The difficulty is that SVG attribute names and
8
+ * Box prop names collide silently (a `<path>`'s `d` is Box's flex-direction; Chakra once turned `d` into
9
+ * `display` this way), so each component names the attributes it owns and lifts them off the style props —
10
+ * per element, because whether a name is CSS or an attribute is a question about the element.
11
+ */
12
+ /** A name the element accepts as an attribute. */
13
+ type Attribute<TTag extends keyof React.JSX.IntrinsicElements> = keyof React.JSX.IntrinsicElements[TTag];
14
+ /** Box's props for the tag, minus the names this element claims as attributes, plus those attributes. */
15
+ type SvgElementProps<TTag extends keyof React.JSX.IntrinsicElements, TAttribute extends Attribute<TTag>, TKey extends keyof ComponentsAndVariants> = Omit<BoxProps<TTag, TKey>, 'tag' | TAttribute> & Pick<React.JSX.IntrinsicElements[TTag], TAttribute>;
16
+ type SvgElementType<TTag extends keyof React.JSX.IntrinsicElements, TAttribute extends Attribute<TTag>> = <TKey extends keyof ComponentsAndVariants = never>(props: SvgElementProps<TTag, TAttribute, TKey> & RefAttributes<ExtractElementFromTag<TTag>>) => React.ReactNode;
17
+ interface SvgOwnProps {
18
+ /** The coordinate system every number inside the drawing is measured in — `"0 0 24 24"`. */
19
+ viewBox?: string;
20
+ /** How the drawing is fitted when the box it is given is a different shape. */
21
+ preserveAspectRatio?: string;
22
+ /** The `width` attribute: a number in user units, or any CSS length — `"100%"`, `"12rem"`. */
23
+ width?: string | number;
24
+ /** The `height` attribute: a number in user units, or any CSS length. */
25
+ height?: string | number;
26
+ /** Names the drawing — `role="img"` and this text. Without one the `<svg>` is `aria-hidden`. */
27
+ label?: string;
28
+ }
29
+ /** The `width`/`height` here are the SVG attributes, not the ÷4 layout props they are on a `<div>`. */
30
+ type Props<TKey extends keyof ComponentsAndVariants = never> = Omit<BoxProps<'svg', TKey>, 'tag' | 'width' | 'height'> & SvgOwnProps;
31
+ /** The root `<svg>`: the coordinate system, the size, and whether a screen reader is told about it. */
32
+ export declare const Svg: (<TKey extends keyof ComponentsAndVariants = never>(props: Props<TKey> & RefAttributes<SVGSVGElement>) => React.ReactNode) & {
33
+ displayName?: string;
34
+ };
35
+ export type SvgProps = Props & RefAttributes<SVGSVGElement>;
36
+ /**
37
+ * The rest of the elements, each with the attributes it owns — everything CSS styles on it stays a Box
38
+ * prop. `transform` is an attribute everywhere, because SVG's version carries its own centre of rotation
39
+ * (`rotate(-90 48 48)`) and the CSS `rotate` prop cannot say that without a `transformOrigin` we lack.
40
+ */
41
+ export declare const G: SvgElementType<"g", "transform">;
42
+ export declare const Defs: SvgElementType<"defs", keyof import('react').SVGProps<SVGDefsElement>>;
43
+ export declare const Path: SvgElementType<"path", "transform" | "d" | "pathLength">;
44
+ export declare const Circle: SvgElementType<"circle", "transform" | "pathLength">;
45
+ export declare const Ellipse: SvgElementType<"ellipse", "transform" | "pathLength">;
46
+ export declare const Rect: SvgElementType<"rect", "width" | "height" | "transform" | "pathLength">;
47
+ export declare const Line: SvgElementType<"line", "transform" | "pathLength" | "x1" | "x2" | "y1" | "y2">;
48
+ export declare const Polyline: SvgElementType<"polyline", "transform" | "pathLength" | "points">;
49
+ export declare const Polygon: SvgElementType<"polygon", "transform" | "pathLength" | "points">;
50
+ /**
51
+ * `SvgText`, not `Text`, which a future HTML text component would want. Its `x`/`y` are attributes: the
52
+ * CSS geometry properties do not apply to `<text>`, so the Box props of that name would move nothing.
53
+ */
54
+ export declare const SvgText: SvgElementType<"text", "transform" | "x" | "y" | "dx" | "dy" | "lengthAdjust" | "textLength">;
55
+ export declare const TSpan: SvgElementType<"tspan", "x" | "y" | "dx" | "dy" | "lengthAdjust" | "textLength">;
56
+ export declare const LinearGradient: SvgElementType<"linearGradient", "gradientTransform" | "gradientUnits" | "spreadMethod" | "x1" | "x2" | "y1" | "y2">;
57
+ export declare const RadialGradient: SvgElementType<"radialGradient", "cx" | "cy" | "r" | "fx" | "fy" | "gradientTransform" | "gradientUnits" | "spreadMethod">;
58
+ export declare const Stop: SvgElementType<"stop", "stopColor" | "stopOpacity" | "offset">;
59
+ export declare const ClipPath: SvgElementType<"clipPath", "transform" | "clipPathUnits">;
60
+ export declare const Mask: SvgElementType<"mask", "width" | "height" | "x" | "y" | "maskContentUnits" | "maskUnits">;
61
+ export declare const Use: SvgElementType<"use", "width" | "height" | "transform" | "href">;
62
+ /** `SvgSymbol`, not `Symbol` — the global of that name is not something a module should shadow. */
63
+ export declare const SvgSymbol: SvgElementType<"symbol", "width" | "height" | "x" | "y" | "preserveAspectRatio" | "viewBox">;
64
+ export declare const Marker: SvgElementType<"marker", "markerHeight" | "markerUnits" | "markerWidth" | "orient" | "refX" | "refY" | "viewBox">;
65
+ export {};
@@ -0,0 +1,141 @@
1
+ import { a as e, c as t, o as n } from "../react-shared.mjs";
2
+ import { forwardRef as r } from "react";
3
+ import { jsx as i } from "react/jsx-runtime";
4
+ import a from "@box-kite/react";
5
+ //#region src/components/svg.tsx
6
+ function o(e, t) {
7
+ let { props: n, ...r } = e, i = r, a;
8
+ for (let e of t) e in i && ((a ??= {})[e] = i[e], delete i[e]);
9
+ return {
10
+ styleProps: i,
11
+ tagProps: a ? {
12
+ ...n,
13
+ ...a
14
+ } : n
15
+ };
16
+ }
17
+ function s(n, s = [], c) {
18
+ let l = s, u = r((e, t) => {
19
+ let { styleProps: r, tagProps: s } = o(e, l);
20
+ return /* @__PURE__ */ i(a, {
21
+ tag: n,
22
+ ref: t,
23
+ component: n,
24
+ ...r,
25
+ props: s
26
+ });
27
+ });
28
+ return u.displayName = c ?? e.capitalize(n), t(u), u;
29
+ }
30
+ var c = "http://www.w3.org/2000/svg", l = [
31
+ "viewBox",
32
+ "preserveAspectRatio",
33
+ "width",
34
+ "height"
35
+ ];
36
+ function u(e, t) {
37
+ let { label: r, ...s } = e, { styleProps: u, tagProps: d } = o(s, l);
38
+ return /* @__PURE__ */ i(a, {
39
+ tag: "svg",
40
+ ref: t,
41
+ component: "svg",
42
+ ...u,
43
+ props: {
44
+ xmlns: c,
45
+ ...n(r, d),
46
+ ...d
47
+ }
48
+ });
49
+ }
50
+ var d = /* @__PURE__ */ t(r(u));
51
+ d.displayName = "Svg";
52
+ var f = /* @__PURE__ */ s("g", ["transform"]), p = /* @__PURE__ */ s("defs"), m = /* @__PURE__ */ s("path", [
53
+ "d",
54
+ "transform",
55
+ "pathLength"
56
+ ]), h = /* @__PURE__ */ s("circle", ["transform", "pathLength"]), g = /* @__PURE__ */ s("ellipse", ["transform", "pathLength"]), _ = /* @__PURE__ */ s("rect", [
57
+ "width",
58
+ "height",
59
+ "transform",
60
+ "pathLength"
61
+ ]), v = /* @__PURE__ */ s("line", [
62
+ "x1",
63
+ "y1",
64
+ "x2",
65
+ "y2",
66
+ "transform",
67
+ "pathLength"
68
+ ]), y = /* @__PURE__ */ s("polyline", [
69
+ "points",
70
+ "transform",
71
+ "pathLength"
72
+ ]), b = /* @__PURE__ */ s("polygon", [
73
+ "points",
74
+ "transform",
75
+ "pathLength"
76
+ ]), x = /* @__PURE__ */ s("text", [
77
+ "x",
78
+ "y",
79
+ "dx",
80
+ "dy",
81
+ "textLength",
82
+ "lengthAdjust",
83
+ "transform"
84
+ ], "SvgText"), S = /* @__PURE__ */ s("tspan", [
85
+ "x",
86
+ "y",
87
+ "dx",
88
+ "dy",
89
+ "textLength",
90
+ "lengthAdjust"
91
+ ], "TSpan"), C = /* @__PURE__ */ s("linearGradient", [
92
+ "x1",
93
+ "y1",
94
+ "x2",
95
+ "y2",
96
+ "gradientUnits",
97
+ "gradientTransform",
98
+ "spreadMethod"
99
+ ]), w = /* @__PURE__ */ s("radialGradient", [
100
+ "cx",
101
+ "cy",
102
+ "r",
103
+ "fx",
104
+ "fy",
105
+ "gradientUnits",
106
+ "gradientTransform",
107
+ "spreadMethod"
108
+ ]), T = /* @__PURE__ */ s("stop", [
109
+ "offset",
110
+ "stopColor",
111
+ "stopOpacity"
112
+ ]), E = /* @__PURE__ */ s("clipPath", ["clipPathUnits", "transform"]), D = /* @__PURE__ */ s("mask", [
113
+ "maskUnits",
114
+ "maskContentUnits",
115
+ "x",
116
+ "y",
117
+ "width",
118
+ "height"
119
+ ]), O = /* @__PURE__ */ s("use", [
120
+ "href",
121
+ "width",
122
+ "height",
123
+ "transform"
124
+ ]), k = /* @__PURE__ */ s("symbol", [
125
+ "viewBox",
126
+ "preserveAspectRatio",
127
+ "x",
128
+ "y",
129
+ "width",
130
+ "height"
131
+ ], "SvgSymbol"), A = /* @__PURE__ */ s("marker", [
132
+ "markerWidth",
133
+ "markerHeight",
134
+ "refX",
135
+ "refY",
136
+ "orient",
137
+ "markerUnits",
138
+ "viewBox"
139
+ ]);
140
+ //#endregion
141
+ export { h as Circle, E as ClipPath, p as Defs, g as Ellipse, f as G, v as Line, C as LinearGradient, A as Marker, D as Mask, m as Path, b as Polygon, y as Polyline, w as RadialGradient, _ as Rect, T as Stop, d as Svg, k as SvgSymbol, x as SvgText, S as TSpan, O as Use };
@@ -0,0 +1 @@
1
+ "use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../behavior.cjs"),t=require("./checkbox.cjs");let n=require("react"),r=require("react/jsx-runtime");function i(n,i){let{props:a,...o}=n,s=e.a(a?.onKeyDown),c=e.a(e=>{s(e),!(e.key!==`Enter`||e.defaultPrevented)&&(e.preventDefault(),e.currentTarget.click())});return(0,r.jsx)(t.default,{ref:i,component:`switch`,...o,props:{...a,role:`switch`,onKeyDown:c}})}var a=(0,n.forwardRef)(i);a.displayName=`Switch`,exports.default=a;
@@ -0,0 +1,29 @@
1
+ import { RefAttributes } from 'react';
2
+ import { BoxProps, BoxTagProps } from '../box';
3
+ import { OmitTagProps } from '../react/boxProps';
4
+ import { ComponentsAndVariants } from '@box-kite/core/types';
5
+ type SwitchProps<TKey extends keyof ComponentsAndVariants> = Omit<BoxProps<'input', TKey>, 'tag' | 'props' | 'indeterminate'>;
6
+ interface Props<TKey extends keyof ComponentsAndVariants> extends SwitchProps<TKey> {
7
+ /** What the switch submits under. Needed for a form; a controlled switch can do without one. */
8
+ name?: string;
9
+ /** Attributes for the `<input>` itself. `type` is the component's, and `role` is already `switch`. */
10
+ props?: OmitTagProps<BoxTagProps<'input'>, 'type'>;
11
+ /** Fires on every keystroke or click. On a checkbox this is the same moment as `onChange`. */
12
+ onInput?: (e: React.ChangeEvent<HTMLInputElement>) => void;
13
+ /** Fires when the switch is toggled. `e.target.checked` is the new state. */
14
+ onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
15
+ /** The value the form submits when it is on. Defaults to `"on"`, as HTML does. */
16
+ value?: string | number;
17
+ /** Focus it on mount. One per page at most — a stolen focus is a lost place in the document. */
18
+ autoFocus?: boolean;
19
+ /** Rendered and read, but not toggleable. Unlike `disabled` it stays in the tab order and submits. */
20
+ readOnly?: boolean;
21
+ /** The state it starts in when the switch is uncontrolled. Pass `checked` instead to control it. */
22
+ defaultChecked?: boolean;
23
+ /** The text beside the switch, rendered inside a label that wraps the input. */
24
+ label?: React.ReactNode;
25
+ /** Styles for the wrapping `<label>`: the row's layout, not the track's own appearance. */
26
+ labelProps?: BoxProps<'label'>;
27
+ }
28
+ declare const _default: <TKey extends keyof ComponentsAndVariants = "switch">(props: Props<TKey> & RefAttributes<HTMLInputElement>) => React.ReactNode;
29
+ export default _default;
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import { a as e } from "../behavior.mjs";
3
+ import t from "./checkbox.mjs";
4
+ import { forwardRef as n } from "react";
5
+ import { jsx as r } from "react/jsx-runtime";
6
+ //#region src/components/switch.tsx
7
+ function i(n, i) {
8
+ let { props: a, ...o } = n, s = e(a?.onKeyDown), c = e((e) => {
9
+ s(e), !(e.key !== "Enter" || e.defaultPrevented) && (e.preventDefault(), e.currentTarget.click());
10
+ });
11
+ return /* @__PURE__ */ r(t, {
12
+ ref: i,
13
+ component: "switch",
14
+ ...o,
15
+ props: {
16
+ ...a,
17
+ role: "switch",
18
+ onKeyDown: c
19
+ }
20
+ });
21
+ }
22
+ var a = n(i);
23
+ a.displayName = "Switch";
24
+ //#endregion
25
+ export { a as default };
@@ -0,0 +1 @@
1
+ "use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../platform.cjs"),t=require("../effects.cjs"),n=require("../box.cjs"),r=require("../behavior.cjs"),i=require("../identity.cjs"),a=require("../motion.cjs");let o=require("react"),s=require("react/jsx-runtime");var c;(function(e){let t=e.TAB_SELECTOR=`[role="tab"]`,n=e.LIST_SELECTOR=`[role="tablist"]`,r=e.PANEL_SELECTOR=`[role="tabpanel"]`;function i(e,t){return t instanceof Element&&t.closest(n)===e}e.owns=i;function a(e){return e?[...e.querySelectorAll(t)].filter(t=>i(e,t)):[]}e.tabs=a;function o(e){return e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}e.isDisabled=o;function s(e){return e.dataset.value}e.valueOf=s;function c(e){return e.replace(/[^A-Za-z0-9-]/g,e=>`_${e.codePointAt(0).toString(36)}_`)}e.token=c;function l(e,t,n,r){let i=e.length;if(i===0)return;let a=t<0||t>=i?n>0?-1:i:t;for(let t=0;t<i;t++){if(a+=n,a<0||a>=i){if(!r)return;a=(a%i+i)%i}if(!o(e[a]))return e[a]}}e.step=l;function u(e,t){return l(e,t===1?-1:e.length,t,!1)}e.edge=u;function d(e,t){return t instanceof HTMLElement?e.indexOf(t):-1}e.indexOf=d;function f(e,t,n=!1){if(e===`Home`)return{kind:`edge`,delta:1};if(e===`End`)return{kind:`edge`,delta:-1};let r=t===`vertical`,i=r?`ArrowDown`:n?`ArrowLeft`:`ArrowRight`,a=r?`ArrowUp`:n?`ArrowRight`:`ArrowLeft`;if(e===i)return{kind:`step`,delta:1};if(e===a)return{kind:`step`,delta:-1}}e.moveFor=f;function p(e,t,n,r){return n.kind===`edge`?u(e,n.delta):l(e,t,n.delta,r)}e.target=p;function m(e){if(e)return a(e).find(e=>e.getAttribute(`aria-selected`)===`true`)}e.selectedTab=m;function h(e,t,n){let r=e.getBoundingClientRect(),i=t.getBoundingClientRect();return n===`vertical`?{start:i.top-r.top+e.scrollTop,size:i.height}:{start:i.left-r.left+e.scrollLeft,size:i.width}}e.bounds=h;function g(e,t){return!e||!t?e===t:e.start===t.start&&e.size===t.size}e.sameBounds=g;function _(e){if(e)return[...e.querySelectorAll(r)].find(e=>!e.hasAttribute(`hidden`))}e.visiblePanel=_})(c||={});var l=c,u=(0,o.createContext)(null);function d(e){let t=(0,o.useContext)(u);if(!t)throw Error(`<${e}> has to be rendered inside a <Tabs>.`);return t}function f(e){let{children:a,value:c,defaultValue:d,onValueChange:f,orientation:p=`horizontal`,activation:m=`automatic`,loop:h=!0,keepMounted:g=!1,indicator:_=`static`,props:v,...y}=e,b=i.t(`tabs`),[x,S]=r.i({value:c,defaultValue:d,onChange:f}),[C,w]=(0,o.useState)(),[T,E]=(0,o.useState)(!1);t.n(()=>{x!==void 0&&w(x)},[x]);let D=(0,o.useMemo)(()=>({identifier:b,value:x,orientation:p,activation:m,loop:h,keepMounted:g,indicator:_,indicatorLive:T,setIndicatorLive:E,tabStop:C??x,setTabStop:w,select:S,tabId:e=>`${b}-tab-${l.token(e)}`,panelId:e=>`${b}-panel-${l.token(e)}`}),[b,x,p,m,h,g,_,T,C,S]);return(0,s.jsx)(u.Provider,{value:D,children:(0,s.jsx)(n.default,{component:`tabs`,...y,variant:[y.variant,{vertical:p===`vertical`}],props:v,children:a})})}function p(i){let{children:a,label:c,labelledBy:u,props:f,...p}=i,{value:m,orientation:h,activation:g,loop:_,indicator:v,tabStop:y,setTabStop:b,setIndicatorLive:x,select:S}=d(`Tabs.List`),C=(0,o.useRef)(null),[w,T]=(0,o.useState)(),E=v===`sliding`;t.n(()=>{let e=C.current;if(!E||!e)return;let t=()=>{let t=l.selectedTab(e),n=t&&l.bounds(e,t,h);T(e=>l.sameBounds(e,n)?e:n)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);n.observe(e);for(let t of l.tabs(e))n.observe(t);return()=>n.disconnect()},[E,h,m]);let D=E&&w&&w.size>0?w:void 0;t.n(()=>{x(D!==void 0)},[D,x]),t.n(()=>{if(y!==void 0)return;let e=l.edge(l.tabs(C.current),1),t=e&&l.valueOf(e);t!==void 0&&b(t)},[y,b]);let O=r.a(t=>{let n=C.current;if(!n||t.defaultPrevented||!l.owns(n,t.target))return;let r=l.tabs(n),i=l.indexOf(r,t.target);if(i===-1)return;if(g===`manual`&&(t.key===`Enter`||t.key===` `)){let e=l.valueOf(r[i]);if(e===void 0)return;t.preventDefault(),S(e,{reason:`keyboard`,event:t});return}let a=l.moveFor(t.key,h,e.u(n));if(!a)return;let o=l.target(r,i,a,_);if(!o)return;t.preventDefault(),o.focus();let s=l.valueOf(o);g===`automatic`&&s!==void 0&&S(s,{reason:`keyboard`,event:t})});return(0,s.jsxs)(n.default,{ref:C,component:`tabs.list`,...p,variant:[p.variant,{vertical:h===`vertical`,sliding:E}],props:{role:`tablist`,"aria-label":c,"aria-labelledby":u,"aria-orientation":h,...f,onKeyDown:O},children:[a,D&&(0,s.jsx)(n.default,{tag:`span`,component:`tabs.indicator`,variant:{vertical:h===`vertical`},style:h===`vertical`?{top:`${D.start}px`,height:`${D.size}px`}:{left:`${D.start}px`,width:`${D.size}px`},props:{"aria-hidden":!0}})]})}p.displayName=`Tabs.List`;function m(e){let{value:t,children:i,disabled:a,props:o,...c}=e,{value:l,orientation:u,keepMounted:f,indicatorLive:p,tabStop:m,setTabStop:h,select:g,tabId:_,panelId:v}=d(`Tabs.Tab`),y=l===t,b=r.a(e=>g(t,{reason:`click`,event:e})),x=r.a(()=>h(t));return(0,s.jsx)(n.default,{tag:`button`,component:`tabs.tab`,...c,variant:[c.variant,{vertical:u===`vertical`,underline:!p}],disabled:a,id:_(t),props:{type:`button`,role:`tab`,"aria-selected":y,"aria-controls":y||f?v(t):void 0,tabIndex:m===t?0:-1,"data-value":t,...o,onClick:b,onFocus:x},children:i})}m.displayName=`Tabs.Tab`;function h(e){let{children:i,props:c,...u}=e,{value:f}=d(`Tabs.Panels`),p=(0,o.useRef)(null),[m,h]=(0,o.useState)(),[g,_]=(0,o.useState)(!1),v=r.a(()=>{let e=p.current;if(!e)return;let t=l.visiblePanel(e)?.offsetHeight;t!==m&&(m!==void 0&&t!==void 0&&_(!0),h(t))});return t.n(()=>{let e=p.current;if(!e||(v(),typeof ResizeObserver>`u`))return;let t=l.visiblePanel(e);if(!t)return;let n=new ResizeObserver(v);return n.observe(t),()=>n.disconnect()},[f,v]),t.n(()=>{let e=p.current;if(!e||!g)return;let t=setTimeout(()=>_(!1),a.n.activeDuration(getComputedStyle(e))+a.n.SETTLE_FRAME);return()=>clearTimeout(t)},[g,m]),(0,s.jsx)(n.default,{ref:p,component:`tabs.panels`,...u,variant:[u.variant,{resizing:g}],style:{height:m===void 0?void 0:`${m}px`,...u.style},props:c,children:i})}h.displayName=`Tabs.Panels`;function g(e){let{value:t,children:r,props:i,...a}=e,{value:o,keepMounted:c,tabId:l,panelId:u}=d(`Tabs.Panel`),f=o===t;return!f&&!c?null:(0,s.jsx)(n.default,{component:`tabs.panel`,...a,variant:[a.variant,{hidden:!f}],id:u(t),props:{role:`tabpanel`,"aria-labelledby":l(t),hidden:!f||void 0,tabIndex:0,...i},children:r})}g.displayName=`Tabs.Panel`;var _=f;_.List=p,_.Tab=m,_.Panels=h,_.Panel=g,_.displayName=`Tabs`,exports.default=_;
@@ -0,0 +1,87 @@
1
+ import { BoxProps } from '../box';
2
+ import { ChangeHandler } from '../react/a11y/useControllableState';
3
+ import { ComponentsAndVariants } from '@box-kite/core/types';
4
+ import { TabsOrientation } from '../utils/tabs/tabsUtils';
5
+ export type { TabsOrientation };
6
+ /** Why the selection changed — a press on a tab, or the keyboard. */
7
+ export type TabsReason = 'click' | 'keyboard';
8
+ /**
9
+ * When a tab becomes the selected one. `automatic` is APG's default and what a reader expects: moving to a
10
+ * tab shows its panel. `manual` moves focus alone and waits for Enter or Space — which is what a panel too
11
+ * expensive to render on the way past needs.
12
+ */
13
+ export type TabsActivation = 'automatic' | 'manual';
14
+ /**
15
+ * Which indicator marks the selected tab. `static` is the tab's own border, which needs no JavaScript
16
+ * and is what a prerendered page paints. `sliding` is one element for the whole list that travels
17
+ * between tabs — measured, so the static one stays until the widget has run.
18
+ */
19
+ export type TabsIndicator = 'static' | 'sliding';
20
+ type TabsBoxProps<TKey extends keyof ComponentsAndVariants> = Omit<BoxProps<'div', TKey>, 'onChange'>;
21
+ export interface TabsProps<TKey extends keyof ComponentsAndVariants = 'tabs'> extends TabsBoxProps<TKey> {
22
+ /** The tabs and their panels: a `Tabs.List` of `Tabs.Tab`, then one `Tabs.Panel` per tab. */
23
+ children?: React.ReactNode;
24
+ /** Controlled selection. Leave it out and the widget owns it. */
25
+ value?: string;
26
+ /** Which tab starts selected. Left out, nothing is selected and no panel is shown until one is chosen. */
27
+ defaultValue?: string;
28
+ /** Fires with the newly selected tab and why it changed — `'click'` or `'keyboard'`. */
29
+ onValueChange?: ChangeHandler<string | undefined, TabsReason>;
30
+ /** Which way the tabs run. Horizontal is the reading axis, so its arrows mirror in a right-to-left page. */
31
+ orientation?: TabsOrientation;
32
+ /** Whether moving to a tab selects it. Default `'automatic'`, which is what APG asks for. */
33
+ activation?: TabsActivation;
34
+ /** Whether the arrows wrap around at the ends. Default `true`. */
35
+ loop?: boolean;
36
+ /**
37
+ * Which indicator marks the selected tab: the tab's own border (`'static'`, the default) or one
38
+ * element travelling between them (`'sliding'`), which animates because it is the same element.
39
+ */
40
+ indicator?: TabsIndicator;
41
+ /**
42
+ * Render every panel rather than only the selected one, hiding the rest. What a panel holding a
43
+ * half-filled form needs, since an unmounted panel loses its state.
44
+ */
45
+ keepMounted?: boolean;
46
+ }
47
+ export interface TabsListProps<TKey extends keyof ComponentsAndVariants = 'tabs.list'> extends BoxProps<'div', TKey> {
48
+ /** The tabs. */
49
+ children?: React.ReactNode;
50
+ /** The list's accessible name. A tablist has none of its own, and one page can hold several. */
51
+ label?: string;
52
+ /** Names the list after an element already on the page, instead of `label`. */
53
+ labelledBy?: string;
54
+ }
55
+ /** Every Box prop, on the `<button>` that is one tab. */
56
+ export interface TabsTabProps<TKey extends keyof ComponentsAndVariants = 'tabs.tab'> extends Omit<BoxProps<'button', TKey>, 'disabled'> {
57
+ /** Which panel this tab shows, and what the widget reports when it is chosen. */
58
+ value: string;
59
+ /** The tab's label. */
60
+ children?: React.ReactNode;
61
+ /**
62
+ * Not selectable, and stepped over by the arrows — unlike a disabled `Menu.Item`, which APG asks stay
63
+ * reachable. Selection follows focus here, so a tab focus could reach and selection could not would
64
+ * leave the widget with no state to be in.
65
+ */
66
+ disabled?: boolean;
67
+ }
68
+ export interface TabsPanelsProps<TKey extends keyof ComponentsAndVariants = 'tabs.panels'> extends BoxProps<'div', TKey> {
69
+ /** The panels. */
70
+ children?: React.ReactNode;
71
+ }
72
+ export interface TabsPanelProps<TKey extends keyof ComponentsAndVariants = 'tabs.panel'> extends BoxProps<'div', TKey> {
73
+ /** The tab this panel belongs to. */
74
+ value: string;
75
+ /** The panel's content. */
76
+ children?: React.ReactNode;
77
+ }
78
+ interface TabsType {
79
+ <TKey extends keyof ComponentsAndVariants = 'tabs'>(props: TabsProps<TKey>): React.ReactNode;
80
+ List: <TKey extends keyof ComponentsAndVariants = 'tabs.list'>(props: TabsListProps<TKey>) => React.ReactNode;
81
+ Tab: <TKey extends keyof ComponentsAndVariants = 'tabs.tab'>(props: TabsTabProps<TKey>) => React.ReactNode;
82
+ Panels: <TKey extends keyof ComponentsAndVariants = 'tabs.panels'>(props: TabsPanelsProps<TKey>) => React.ReactNode;
83
+ Panel: <TKey extends keyof ComponentsAndVariants = 'tabs.panel'>(props: TabsPanelProps<TKey>) => React.ReactNode;
84
+ displayName?: string;
85
+ }
86
+ declare const Tabs: TabsType;
87
+ export default Tabs;