@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
package/a11y.cjs ADDED
@@ -0,0 +1 @@
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./behavior.cjs"),t=require("./identity.cjs");exports.useControllableState=e.i,exports.useDismiss=e.r,exports.useFocusReturn=e.n,exports.useIdentifier=t.t,exports.useRovingFocus=e.t;
package/a11y.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * `@box-kite/react/a11y` — the behaviour primitives the accessible components are built from. Every
3
+ * APG pattern needs the same four mechanics (return focus, move through a list, dismiss, hold a value the
4
+ * consumer may own), none of them visible in the markup, so they live here once and are published because
5
+ * this library will never cover every pattern. Client hooks: the entry carries a `'use client'` banner.
6
+ */
7
+ export { default as useControllableState } from './react/a11y/useControllableState';
8
+ export type { ChangeDetails, ChangeHandler, ControllableStateOptions, SetControllableState } from './react/a11y/useControllableState';
9
+ export { default as useDismiss } from './react/a11y/useDismiss';
10
+ export type { DismissOptions, DismissReason, ElementLike } from './react/a11y/useDismiss';
11
+ export { default as useFocusReturn } from './react/a11y/useFocusReturn';
12
+ export type { FocusReturnOptions } from './react/a11y/useFocusReturn';
13
+ export { default as useIdentifier } from './react/identity/useIdentifier';
14
+ export { default as useRovingFocus } from './react/a11y/useRovingFocus';
15
+ export type { RovingFocus, RovingFocusItemProps, RovingFocusOptions, RovingFocusReason, RovingOrientation, } from './react/a11y/useRovingFocus';
package/a11y.mjs ADDED
@@ -0,0 +1,4 @@
1
+ "use client";
2
+ import { i as e, n as t, r as n, t as r } from "./behavior.mjs";
3
+ import { t as i } from "./identity.mjs";
4
+ export { e as useControllableState, n as useDismiss, t as useFocusReturn, i as useIdentifier, r as useRovingFocus };
package/anchor.cjs ADDED
@@ -0,0 +1 @@
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./placement.cjs");exports.useAnchorPosition=e.t;
package/anchor.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * `@box-kite/react/anchor` — where a floating layer goes. One hook: it hands the trigger a name and the
3
+ * layer the props that place it against that name, which on a browser with CSS anchor positioning is the
4
+ * whole of it — no measuring, no scroll listener, no state. Where the browser has none it measures instead,
5
+ * and the flip and the shift are the same model worked out by hand.
6
+ *
7
+ * Its own entry rather than a corner of `/a11y`, because positioning is not an accessibility mechanic: a
8
+ * consumer wanting `useDismiss` should not carry the placement model, or the other way round. A client
9
+ * hook, so the entry carries a `'use client'` banner — a layer that needs no JS at all is `positionArea`
10
+ * and the props beside it, which any Box takes.
11
+ */
12
+ export { default as useAnchorPosition } from './react/anchor/useAnchorPosition';
13
+ export type { AnchorElementProps, AnchorLayerProps, AnchorPosition, AnchorPositionOptions } from './react/anchor/useAnchorPosition';
14
+ export type { AnchorAlign, AnchorSide } from './utils/anchor/anchorUtils';
package/anchor.mjs ADDED
@@ -0,0 +1,3 @@
1
+ "use client";
2
+ import { t as e } from "./placement.mjs";
3
+ export { e as useAnchorPosition };
package/behavior.cjs ADDED
@@ -0,0 +1 @@
1
+ const e=require("./platform.cjs"),t=require("./effects.cjs"),n=require("./keyboard.cjs");let r=require("react");function i(e){let n=(0,r.useRef)(e);return t.n(()=>{n.current=e}),n}function a(e){let t=i(e);return(0,r.useCallback)((...e)=>t.current?.(...e),[t])}function o(e){let{value:t,defaultValue:n,onChange:o}=e,s=t!==void 0,[c,l]=(0,r.useState)(n),u=s?t:c,d=i(u),f=a(o);return[u,(0,r.useCallback)((e,t)=>{let n=typeof e==`function`?e(d.current):e;Object.is(n,d.current)||(l(n),f(n,t))},[f,d])]}var s=[];function c(e,t){let n=t.elements();return e.elements().some(e=>n.some(t=>e!==t&&e.contains(t)))}function l(){let e=s.filter(e=>!s.some(t=>t!==e&&c(e,t)));return e[e.length-1]}function u(n){let{enabled:r=!0,onDismiss:o,inside:c,escapeKey:u=!0,outsidePointer:d=!0}=n,f=i(c),p=a(o);t.n(()=>{if(!r)return;let t={elements:()=>(f.current??[]).map(t=>e.s(t)).filter(e=>e!==null)};s.push(t);let n=new AbortController,i=(e,t)=>document.addEventListener(e,t,{signal:n.signal});return u&&i(`keydown`,e=>{e.key!==`Escape`||e.defaultPrevented||l()===t&&p(`escape`,e)}),d&&i(`pointerdown`,t=>{e.l(t,f.current??[])||p(`outside-pointer`,t)}),()=>{n.abort();let e=s.indexOf(t);e!==-1&&s.splice(e,1)}},[r,u,d,p,f])}function d(){let t=e.t()?.activeElement;return t&&t!==document.body?t:null}function f(t={}){let{enabled:n=!0,returnTo:i,preventScroll:o}=t,[s,c]=(0,r.useState)(null),[l,u]=(0,r.useState)(!1);n!==l&&(u(n),n&&c(d()));let f=a(()=>{(e.c(i)??s)?.focus({preventScroll:o})});return(0,r.useEffect)(()=>{if(n)return()=>{let e=document.activeElement;(!e||e===document.body||!document.contains(e))&&f()}},[n,f]),{returnFocus:f}}var p=10;function m(e,t){return t<0?-1:Math.max(0,Math.min(e,t))}function h(e,t,n,r,i){if(n===0)return-1;let a=e;for(let e=0;e<n;e++){if(a+=t,a<0||a>=n){if(!r)return-1;a=(a%n+n)%n}if(!i?.(a))return a}return-1}function g(e,t,n){return h(e===1?-1:t,e,t,!1,n)}function _(t){let{count:a,columns:s,columnIndexOf:c,pageSize:l=p,defaultActiveColumn:u=0,onActiveCellChange:d,orientation:f=`vertical`,loop:_=!0,activeIndex:v,defaultActiveIndex:y=0,onActiveIndexChange:b,isDisabled:x,textOf:S,focusItems:C=!0,onSelect:w}=t,[T,E]=o({value:v,defaultValue:y,onChange:b}),D=Math.min(T,a-1),O=s!==void 0,k=(0,r.useCallback)(e=>typeof s==`function`?s(e):s??0,[s]),A=(0,r.useCallback)((e,t)=>{let n=k(e);if(!c)return m(t,n-1);if(n<=0)return-1;let r=0;for(;r+1<n&&c(e,r+1)<=t;)r++;return r},[c,k]),[j,M]=(0,r.useState)(u),N=O&&D>=0?A(D,j):-1,P=(0,r.useRef)([]),F=(0,r.useRef)(new Map),I=(0,r.useRef)(new Map),L=(0,r.useRef)(new Map),R=(0,r.useRef)({query:``,at:0}),z=(0,r.useCallback)(e=>{P.current[e]?.focus()},[]),B=(0,r.useRef)(!1),V=(0,r.useCallback)((e,t)=>{B.current=!0,I.current.get(`${e}:${t}`)?.focus(),B.current=!1},[]),H=(0,r.useCallback)(()=>O?I.current.get(`${D}:${N}`)??null:P.current[D]??null,[N,D,O]),U=i({row:D,column:N}),W=i(j),G=i(d),K=i(k),q=i(A),J=i(c),Y=(0,r.useCallback)((e,t,n)=>{let r=m(e,a-1),i=Math.max(0,t),o=r<0?-1:q.current(r,i),s=U.current;return r===s.row&&o===s.column?s:(E(r,n),M(i),G.current?.({row:r,column:o},n),{row:r,column:o})},[U,q,G,a,E]),X=(0,r.useCallback)((e,t,n)=>{let r=m(e,a-1),i=r<0?-1:m(Math.max(0,t),K.current(r)-1);return Y(r,i<0?0:J.current?.(r,i)??i,n)},[J,a,Y,K]),Z=(0,r.useCallback)((e,t)=>{let n=`${e}:${t}`;return L.current.has(n)||L.current.set(n,e=>{e?I.current.set(n,e):(I.current.delete(n),L.current.delete(n))}),{ref:L.current.get(n),tabIndex:e===D&&t===N?0:-1,onFocus:()=>{B.current||X(e,t,{reason:`focus`})}}},[N,D,X]),Q=(0,r.useCallback)(e=>(F.current.has(e)||F.current.set(e,t=>{P.current[e]=t}),{ref:F.current.get(e),tabIndex:C?e===D?0:-1:void 0,onFocus:C?()=>E(e,{reason:`focus`}):void 0}),[D,C,E]),$=(0,r.useCallback)(t=>{let{row:n,column:r}=U.current,i=(e,n)=>{t.preventDefault();let r=X(e,n,{reason:`keyboard`,event:t});C&&V(r.row,r.column)},o=e=>{t.preventDefault();let n=Y(e,W.current,{reason:`keyboard`,event:t});C&&V(n.row,n.column)},s=2**53-1,c=()=>e.u(t.currentTarget)?-1:1;switch(t.key){case`ArrowRight`:return i(n,r+c());case`ArrowLeft`:return i(n,r-c());case`ArrowDown`:return o(n+1);case`ArrowUp`:return o(n-1);case`Home`:return t.ctrlKey||t.metaKey?i(0,0):i(n,0);case`End`:return t.ctrlKey||t.metaKey?i(a-1,s):i(n,s);case`PageDown`:return o(n+l);case`PageUp`:return o(n-l)}},[U,a,W,V,C,l,Y,X]);return{activeIndex:D,activeColumn:N,setActiveIndex:E,setActiveCell:X,onKeyDown:(0,r.useCallback)(t=>{if(t.defaultPrevented)return;if(O){$(t);return}let r=f!==`horizontal`,i=f!==`vertical`,o=R.current,s=n.t.isOpen(o,t.timeStamp),c=(e,n)=>{e!==-1&&e!==D&&(t.preventDefault(),E(e,{reason:n,event:t}),C&&z(e))};if(i&&(t.key===`ArrowRight`||t.key===`ArrowLeft`)){let n=t.key===`ArrowRight`!==e.u(t.currentTarget);c(h(D,n?1:-1,a,_,x),`keyboard`);return}if(t.key===`ArrowDown`&&r){c(h(D,1,a,_,x),`keyboard`);return}if(t.key===`ArrowUp`&&r){c(h(D,-1,a,_,x),`keyboard`);return}if(t.key===`Home`){c(g(1,a,x),`keyboard`);return}if(t.key===`End`){c(g(-1,a,x),`keyboard`);return}if(t.key===`Enter`||t.key===` `&&!(s&&S)){if(!w||D===-1)return;t.preventDefault(),w(D,t);return}if(S&&n.t.isPrintable(t)){let e=n.t.push(o,t.key,t.timeStamp);c(n.t.target(e,D,a,S,x),`typeahead`)}},[D,a,z,C,x,O,_,$,w,f,E,S]),itemProps:Q,cellProps:Z,activeItem:H}}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return _}});
package/behavior.mjs ADDED
@@ -0,0 +1,277 @@
1
+ import { c as e, l as t, s as n, t as r, u as i } from "./platform.mjs";
2
+ import { n as a } from "./effects.mjs";
3
+ import { t as o } from "./keyboard.mjs";
4
+ import { useCallback as s, useEffect as c, useRef as l, useState as u } from "react";
5
+ //#region src/react/a11y/callbacks.ts
6
+ function d(e) {
7
+ let t = l(e);
8
+ return a(() => {
9
+ t.current = e;
10
+ }), t;
11
+ }
12
+ function f(e) {
13
+ let t = d(e);
14
+ return s((...e) => t.current?.(...e), [t]);
15
+ }
16
+ //#endregion
17
+ //#region src/react/a11y/useControllableState.ts
18
+ function p(e) {
19
+ let { value: t, defaultValue: n, onChange: r } = e, i = t !== void 0, [a, o] = u(n), c = i ? t : a, l = d(c), p = f(r);
20
+ return [c, s((e, t) => {
21
+ let n = typeof e == "function" ? e(l.current) : e;
22
+ Object.is(n, l.current) || (o(n), p(n, t));
23
+ }, [p, l])];
24
+ }
25
+ //#endregion
26
+ //#region src/react/a11y/useDismiss.ts
27
+ var m = [];
28
+ function h(e, t) {
29
+ let n = t.elements();
30
+ return e.elements().some((e) => n.some((t) => e !== t && e.contains(t)));
31
+ }
32
+ function g() {
33
+ let e = m.filter((e) => !m.some((t) => t !== e && h(e, t)));
34
+ return e[e.length - 1];
35
+ }
36
+ function _(e) {
37
+ let { enabled: r = !0, onDismiss: i, inside: o, escapeKey: s = !0, outsidePointer: c = !0 } = e, l = d(o), u = f(i);
38
+ a(() => {
39
+ if (!r) return;
40
+ let e = { elements: () => (l.current ?? []).map((e) => n(e)).filter((e) => e !== null) };
41
+ m.push(e);
42
+ let i = new AbortController(), a = (e, t) => document.addEventListener(e, t, { signal: i.signal });
43
+ return s && a("keydown", (t) => {
44
+ t.key !== "Escape" || t.defaultPrevented || g() === e && u("escape", t);
45
+ }), c && a("pointerdown", (e) => {
46
+ t(e, l.current ?? []) || u("outside-pointer", e);
47
+ }), () => {
48
+ i.abort();
49
+ let t = m.indexOf(e);
50
+ t !== -1 && m.splice(t, 1);
51
+ };
52
+ }, [
53
+ r,
54
+ s,
55
+ c,
56
+ u,
57
+ l
58
+ ]);
59
+ }
60
+ //#endregion
61
+ //#region src/react/a11y/useFocusReturn.ts
62
+ function v() {
63
+ let e = r()?.activeElement;
64
+ return e && e !== document.body ? e : null;
65
+ }
66
+ function y(t = {}) {
67
+ let { enabled: n = !0, returnTo: r, preventScroll: i } = t, [a, o] = u(null), [s, l] = u(!1);
68
+ n !== s && (l(n), n && o(v()));
69
+ let d = f(() => {
70
+ (e(r) ?? a)?.focus({ preventScroll: i });
71
+ });
72
+ return c(() => {
73
+ if (n) return () => {
74
+ let e = document.activeElement;
75
+ (!e || e === document.body || !document.contains(e)) && d();
76
+ };
77
+ }, [n, d]), { returnFocus: d };
78
+ }
79
+ //#endregion
80
+ //#region src/react/a11y/useRovingFocus.ts
81
+ var b = 10;
82
+ function x(e, t) {
83
+ return t < 0 ? -1 : Math.max(0, Math.min(e, t));
84
+ }
85
+ function S(e, t, n, r, i) {
86
+ if (n === 0) return -1;
87
+ let a = e;
88
+ for (let e = 0; e < n; e++) {
89
+ if (a += t, a < 0 || a >= n) {
90
+ if (!r) return -1;
91
+ a = (a % n + n) % n;
92
+ }
93
+ if (!i?.(a)) return a;
94
+ }
95
+ return -1;
96
+ }
97
+ function C(e, t, n) {
98
+ return S(e === 1 ? -1 : t, e, t, !1, n);
99
+ }
100
+ function w(e) {
101
+ let { count: t, columns: n, columnIndexOf: r, pageSize: a = b, defaultActiveColumn: c = 0, onActiveCellChange: f, orientation: m = "vertical", loop: h = !0, activeIndex: g, defaultActiveIndex: _ = 0, onActiveIndexChange: v, isDisabled: y, textOf: w, focusItems: T = !0, onSelect: E } = e, [D, O] = p({
102
+ value: g,
103
+ defaultValue: _,
104
+ onChange: v
105
+ }), k = Math.min(D, t - 1), A = n !== void 0, j = s((e) => typeof n == "function" ? n(e) : n ?? 0, [n]), M = s((e, t) => {
106
+ let n = j(e);
107
+ if (!r) return x(t, n - 1);
108
+ if (n <= 0) return -1;
109
+ let i = 0;
110
+ for (; i + 1 < n && r(e, i + 1) <= t;) i++;
111
+ return i;
112
+ }, [r, j]), [N, P] = u(c), F = A && k >= 0 ? M(k, N) : -1, I = l([]), L = l(/* @__PURE__ */ new Map()), R = l(/* @__PURE__ */ new Map()), z = l(/* @__PURE__ */ new Map()), B = l({
113
+ query: "",
114
+ at: 0
115
+ }), V = s((e) => {
116
+ I.current[e]?.focus();
117
+ }, []), H = l(!1), U = s((e, t) => {
118
+ H.current = !0, R.current.get(`${e}:${t}`)?.focus(), H.current = !1;
119
+ }, []), W = s(() => A ? R.current.get(`${k}:${F}`) ?? null : I.current[k] ?? null, [
120
+ F,
121
+ k,
122
+ A
123
+ ]), G = d({
124
+ row: k,
125
+ column: F
126
+ }), K = d(N), q = d(f), J = d(j), Y = d(M), X = d(r), Z = s((e, n, r) => {
127
+ let i = x(e, t - 1), a = Math.max(0, n), o = i < 0 ? -1 : Y.current(i, a), s = G.current;
128
+ return i === s.row && o === s.column ? s : (O(i, r), P(a), q.current?.({
129
+ row: i,
130
+ column: o
131
+ }, r), {
132
+ row: i,
133
+ column: o
134
+ });
135
+ }, [
136
+ G,
137
+ Y,
138
+ q,
139
+ t,
140
+ O
141
+ ]), Q = s((e, n, r) => {
142
+ let i = x(e, t - 1), a = i < 0 ? -1 : x(Math.max(0, n), J.current(i) - 1);
143
+ return Z(i, a < 0 ? 0 : X.current?.(i, a) ?? a, r);
144
+ }, [
145
+ X,
146
+ t,
147
+ Z,
148
+ J
149
+ ]), ee = s((e, t) => {
150
+ let n = `${e}:${t}`;
151
+ return z.current.has(n) || z.current.set(n, (e) => {
152
+ e ? R.current.set(n, e) : (R.current.delete(n), z.current.delete(n));
153
+ }), {
154
+ ref: z.current.get(n),
155
+ tabIndex: e === k && t === F ? 0 : -1,
156
+ onFocus: () => {
157
+ H.current || Q(e, t, { reason: "focus" });
158
+ }
159
+ };
160
+ }, [
161
+ F,
162
+ k,
163
+ Q
164
+ ]), te = s((e) => (L.current.has(e) || L.current.set(e, (t) => {
165
+ I.current[e] = t;
166
+ }), {
167
+ ref: L.current.get(e),
168
+ tabIndex: T ? e === k ? 0 : -1 : void 0,
169
+ onFocus: T ? () => O(e, { reason: "focus" }) : void 0
170
+ }), [
171
+ k,
172
+ T,
173
+ O
174
+ ]), $ = s((e) => {
175
+ let { row: n, column: r } = G.current, o = (t, n) => {
176
+ e.preventDefault();
177
+ let r = Q(t, n, {
178
+ reason: "keyboard",
179
+ event: e
180
+ });
181
+ T && U(r.row, r.column);
182
+ }, s = (t) => {
183
+ e.preventDefault();
184
+ let n = Z(t, K.current, {
185
+ reason: "keyboard",
186
+ event: e
187
+ });
188
+ T && U(n.row, n.column);
189
+ }, c = 2 ** 53 - 1, l = () => i(e.currentTarget) ? -1 : 1;
190
+ switch (e.key) {
191
+ case "ArrowRight": return o(n, r + l());
192
+ case "ArrowLeft": return o(n, r - l());
193
+ case "ArrowDown": return s(n + 1);
194
+ case "ArrowUp": return s(n - 1);
195
+ case "Home": return e.ctrlKey || e.metaKey ? o(0, 0) : o(n, 0);
196
+ case "End": return e.ctrlKey || e.metaKey ? o(t - 1, c) : o(n, c);
197
+ case "PageDown": return s(n + a);
198
+ case "PageUp": return s(n - a);
199
+ }
200
+ }, [
201
+ G,
202
+ t,
203
+ K,
204
+ U,
205
+ T,
206
+ a,
207
+ Z,
208
+ Q
209
+ ]);
210
+ return {
211
+ activeIndex: k,
212
+ activeColumn: F,
213
+ setActiveIndex: O,
214
+ setActiveCell: Q,
215
+ onKeyDown: s((e) => {
216
+ if (e.defaultPrevented) return;
217
+ if (A) {
218
+ $(e);
219
+ return;
220
+ }
221
+ let n = m !== "horizontal", r = m !== "vertical", a = B.current, s = o.isOpen(a, e.timeStamp), c = (t, n) => {
222
+ t !== -1 && t !== k && (e.preventDefault(), O(t, {
223
+ reason: n,
224
+ event: e
225
+ }), T && V(t));
226
+ };
227
+ if (r && (e.key === "ArrowRight" || e.key === "ArrowLeft")) {
228
+ let n = e.key === "ArrowRight" !== i(e.currentTarget);
229
+ c(S(k, n ? 1 : -1, t, h, y), "keyboard");
230
+ return;
231
+ }
232
+ if (e.key === "ArrowDown" && n) {
233
+ c(S(k, 1, t, h, y), "keyboard");
234
+ return;
235
+ }
236
+ if (e.key === "ArrowUp" && n) {
237
+ c(S(k, -1, t, h, y), "keyboard");
238
+ return;
239
+ }
240
+ if (e.key === "Home") {
241
+ c(C(1, t, y), "keyboard");
242
+ return;
243
+ }
244
+ if (e.key === "End") {
245
+ c(C(-1, t, y), "keyboard");
246
+ return;
247
+ }
248
+ if (e.key === "Enter" || e.key === " " && !(s && w)) {
249
+ if (!E || k === -1) return;
250
+ e.preventDefault(), E(k, e);
251
+ return;
252
+ }
253
+ if (w && o.isPrintable(e)) {
254
+ let n = o.push(a, e.key, e.timeStamp);
255
+ c(o.target(n, k, t, w, y), "typeahead");
256
+ }
257
+ }, [
258
+ k,
259
+ t,
260
+ V,
261
+ T,
262
+ y,
263
+ A,
264
+ h,
265
+ $,
266
+ E,
267
+ m,
268
+ O,
269
+ w
270
+ ]),
271
+ itemProps: te,
272
+ cellProps: ee,
273
+ activeItem: W
274
+ };
275
+ }
276
+ //#endregion
277
+ export { f as a, p as i, y as n, d as o, _ as r, w as t };
package/box.cjs ADDED
@@ -0,0 +1 @@
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./rolldown-runtime.cjs"),t=require("./react-shared.cjs"),n=require("./client.cjs");let r=require("react");r=e.t(r,1);let i=require("@box-kite/core");function a(e,i){let{tag:a=`div`,children:o}=e,{classNames:s,styleElements:c}=n.i(e,a===`svg`),l=(0,r.useMemo)(()=>{let n=t.d(e,s);return i&&(n.ref=i),n},[e]),[u,d]=(0,r.useState)(!1),f=typeof o==`function`,p=f?{...l,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1)}:l,m=r.default.createElement(a,p,f?o({isHover:u}):o);return c?r.default.createElement(r.default.Fragment,null,c,m):m}var o=(0,r.memo)((0,r.forwardRef)(a));o.displayName=`Box`,o.extend=i.BoxExtends.extend,o.components=i.BoxExtends.components,o.keyframes=i.BoxExtends.keyframes,o.spring=i.Springs.spring,o.Theme=n.n,o.useTheme=n.n.useTheme,o.getVariableValue=e=>(0,i.getDefaultEngine)().getVariableValue(e),o.configure=n.r.configure;function s(e,r){return t.f(n.i(e,r?.svg===!0),e.className)}exports.default=o,exports.useClassNames=s,exports.useVisibility=n.a;
package/box.d.ts ADDED
@@ -0,0 +1,46 @@
1
+ import { default as React, RefAttributes } from 'react';
2
+ import { BoxExtends, Springs } from '@box-kite/core';
3
+ import { BoxClassNames } from './react/boxClassNames';
4
+ import { BoxClassNameProps, BoxCoreProps } from './react/boxProps';
5
+ import { default as useVisibility } from './react/hooks/useVisibility';
6
+ import { ExtractElementFromTag } from './react/reactTypes';
7
+ import { default as Theme } from './react/theme/theme';
8
+ import { StylesContext } from './react/useStyles';
9
+ import { ComponentsAndVariants } from '@box-kite/core/types';
10
+ interface BoxType {
11
+ <TTag extends keyof React.JSX.IntrinsicElements = 'div', TKey extends keyof ComponentsAndVariants = never>(props: BoxCoreProps<TTag, TKey> & RefAttributes<ExtractElementFromTag<TTag>>): React.ReactNode;
12
+ extend: typeof BoxExtends.extend;
13
+ components: typeof BoxExtends.components;
14
+ keyframes: typeof BoxExtends.keyframes;
15
+ /** A spring of your own, sampled into `{ easing, duration }` — the two halves the timing and duration props take. */
16
+ spring: typeof Springs.spring;
17
+ Theme: typeof Theme;
18
+ useTheme: typeof Theme.useTheme;
19
+ getVariableValue: (name: string) => string;
20
+ /** Explicit engine configuration (class-name hashing, style sink). Call once, before the first render. */
21
+ configure: typeof StylesContext.configure;
22
+ }
23
+ declare const Box: BoxType;
24
+ export default Box;
25
+ export type BoxProps<TTag extends keyof React.JSX.IntrinsicElements = 'div', TKey extends keyof ComponentsAndVariants = never> = React.ComponentProps<typeof Box<TTag, TKey>>;
26
+ export type BoxTagProps<TTag extends keyof React.JSX.IntrinsicElements = 'div', TKey extends keyof ComponentsAndVariants = never> = Required<BoxProps<TTag, TKey>>['props'];
27
+ /**
28
+ * Box props as a class attribute, for an element Box cannot render: an icon from `lucide-react`, a
29
+ * `motion.div`, a router's `NavLink`. They take a `className` and nothing else, and `style` is what this
30
+ * library exists not to write.
31
+ *
32
+ * ```tsx
33
+ * const { className, styles } = useClassNames({ color: 'sky-500', hover: { color: 'sky-300' } });
34
+ *
35
+ * return <>{styles}<NavLink className={className} to="/" /></>;
36
+ * ```
37
+ *
38
+ * `styles` is defined in element mode only, where the CSS travels as `<style href precedence>` elements;
39
+ * elsewhere it is undefined and rendering it costs nothing, so that line is what to write either way.
40
+ * `{ svg: true }` picks the SVG reset — `Icon` is this hook plus that flag.
41
+ */
42
+ export declare function useClassNames<TKey extends keyof ComponentsAndVariants = never>(props: BoxClassNameProps<TKey>, options?: {
43
+ svg?: boolean;
44
+ }): BoxClassNames;
45
+ export { useVisibility };
46
+ export type { BoxClassNames, BoxClassNameProps };
package/box.mjs ADDED
@@ -0,0 +1,23 @@
1
+ import { d as e, f as t } from "./react-shared.mjs";
2
+ import { a as n, i as r, n as i, r as a } from "./client.mjs";
3
+ import o, { forwardRef as s, memo as c, useMemo as l, useState as u } from "react";
4
+ import { BoxExtends as d, Springs as f, getDefaultEngine as p } from "@box-kite/core";
5
+ //#region src/box.ts
6
+ function m(t, n) {
7
+ let { tag: i = "div", children: a } = t, { classNames: s, styleElements: c } = r(t, i === "svg"), d = l(() => {
8
+ let r = e(t, s);
9
+ return n && (r.ref = n), r;
10
+ }, [t]), [f, p] = u(!1), m = typeof a == "function", h = m ? {
11
+ ...d,
12
+ onMouseEnter: () => p(!0),
13
+ onMouseLeave: () => p(!1)
14
+ } : d, g = o.createElement(i, h, m ? a({ isHover: f }) : a);
15
+ return c ? o.createElement(o.Fragment, null, c, g) : g;
16
+ }
17
+ var h = c(s(m));
18
+ h.displayName = "Box", h.extend = d.extend, h.components = d.components, h.keyframes = d.keyframes, h.spring = f.spring, h.Theme = i, h.useTheme = i.useTheme, h.getVariableValue = (e) => p().getVariableValue(e), h.configure = a.configure;
19
+ function g(e, n) {
20
+ return t(r(e, n?.svg === !0), e.className);
21
+ }
22
+ //#endregion
23
+ export { h as default, g as useClassNames, n as useVisibility };
package/client.cjs ADDED
@@ -0,0 +1 @@
1
+ const e=require("./rolldown-runtime.cjs"),t=require("./react-shared.cjs"),n=require("./platform.cjs"),r=require("./effects.cjs"),i=require("./box.cjs");let a=require("react");a=e.t(a,1);let o=require("@box-kite/core"),s=require("react/jsx-runtime");function c(e){let{node:t=null,event:r=`click`,hideOnScroll:i=!1,hideOnResize:o=!1,hideOnEscape:s=!0}=e??{},[c,l]=(0,a.useState)(!1),u=(0,a.useRef)(null);return(0,a.useEffect)(()=>{function e(e){let r=t??u.current;r&&!n.l(e,[r])&&l(!1)}function a(){l(!1)}function d(e){e.key===`Escape`&&l(!1)}let f=new AbortController;return c&&(window.addEventListener(r,e,f),s&&window.addEventListener(`keydown`,d,f),o&&window.addEventListener(`resize`,a,f),i&&window.addEventListener(`scroll`,e,{signal:f.signal,capture:!0})),()=>{f.abort()}},[t,c,r,s,o,i]),[c,l,u]}var l=r.t;function u(e,n){let{classNames:r,signature:i,styleElements:a}=t.l(e,n);return l(()=>{(0,o.getDefaultEngine)().flushSync()},[i??e]),{classNames:r,styleElements:a}}function d(e,n){let r=e?(0,o.getDefaultEngine)().addGlobalStyles(e,n):void 0;return l(()=>{(0,o.getDefaultEngine)().flushSync()},[e,n]),t.u(r)}var f;(function(e){function t(){(0,o.getDefaultEngine)().flushSync()}e.flushSync=t;function n(){(0,o.getDefaultEngine)().clear()}e.clear=n;function r(){return(0,o.getDefaultEngine)().getStyles()}e.getStyles=r;function i(){return(0,o.getDefaultEngine)().styleElementId}e.styleElementId=i;function a(e){(0,o.getDefaultEngine)().configure(e)}e.configure=a})(f||={});var p=`[box-kite] The client build was loaded into a React Server Component graph, where React has no createContext. Import '@box-kite/react' by its package name — the react-server condition resolves it to a Box that renders on the server — and import the components that hold state (Dropdown, Tooltip, DataGrid, Checkbox, Select, Form) from a 'use client' module. See https://github.com/box-kite/box-kite#react-server-components-react-19`;function m(e){if(typeof e.createContext!=`function`)throw Error(p)}m(a.default);var h=a.default.createContext({theme:``,setTheme:()=>{}});function g(e){let{children:t,theme:n,use:r=`local`,storageKey:c,globalStyles:l}=e,u=d(r===`global`?l:void 0,`html`),[f,p]=(0,a.useState)(n??o.defaultThemeName),[m,g]=(0,a.useState)(n!==void 0),_=(0,a.useRef)(null),v=(0,a.useCallback)(e=>{e===null?(c&&(0,o.clearStoredTheme)(c),g(!1)):(c&&(0,o.writeStoredTheme)(c,e),p(e),g(!0))},[c]),[y,b]=(0,a.useState)(n);return n!==y&&(b(n),n===void 0?g(!1):(p(n),g(!0))),(0,a.useLayoutEffect)(()=>{if(m)return;let e=c?(0,o.readStoredTheme)(c):null;if(e){p(e),g(!0);return}return p((0,o.getSystemTheme)()),(0,o.watchSystemTheme)(p)},[m,c]),(0,a.useLayoutEffect)(()=>{if(r===`local`)return;let e=(0,o.documentRoot)();if(e)return(0,o.applyThemeToElement)(e,f)},[f,r]),(0,a.useLayoutEffect)(()=>{r!==`local`||!_.current||(0,o.setThemeAttribute)(_.current,f)},[f,r]),r===`local`?(0,s.jsxs)(h.Provider,{value:{theme:f,setTheme:v},children:[u,(0,s.jsx)(i.default,{ref:_,className:f,children:t})]}):(0,s.jsxs)(h.Provider,{value:{theme:f,setTheme:v},children:[u,t]})}(function(e){function t(){let{theme:e,setTheme:t}=(0,a.useContext)(h);return[e,t]}e.useTheme=t})(g||={});var _=g,v=new WeakMap;function y(e){let t=v.get(e);return t||(t=new Map,v.set(e,t)),t}function b(e=!0){let[t]=_.useTheme(),r=(0,a.useMemo)(()=>{if(!e)return null;let t=n.t();if(!t)return null;let r=`box-kite-portal`,i=t.getElementById(r);return i||(i=document.createElement(`div`),i.id=r,document.body.appendChild(i)),i},[e]);return(0,a.useLayoutEffect)(()=>{if(!t||!r)return;let e=y(r),n=e.get(t)??0;return e.set(t,n+1),n===0&&r.classList.add(t),()=>{let n=(e.get(t)??1)-1;n<=0?(e.delete(t),r.classList.remove(t)):e.set(t,n)}},[r,t]),r}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return b}});
package/client.mjs ADDED
@@ -0,0 +1,164 @@
1
+ import { l as e, u as t } from "./react-shared.mjs";
2
+ import { l as n, t as r } from "./platform.mjs";
3
+ import { t as i } from "./effects.mjs";
4
+ import a from "./box.mjs";
5
+ import o, { useCallback as s, useContext as c, useEffect as l, useLayoutEffect as u, useMemo as d, useRef as f, useState as p } from "react";
6
+ import { applyThemeToElement as m, clearStoredTheme as h, defaultThemeName as g, documentRoot as _, getDefaultEngine as v, getSystemTheme as y, readStoredTheme as b, setThemeAttribute as x, watchSystemTheme as S, writeStoredTheme as C } from "@box-kite/core";
7
+ import { jsx as w, jsxs as T } from "react/jsx-runtime";
8
+ //#region src/react/hooks/useVisibility.ts
9
+ function E(e) {
10
+ let { node: t = null, event: r = "click", hideOnScroll: i = !1, hideOnResize: a = !1, hideOnEscape: o = !0 } = e ?? {}, [s, c] = p(!1), u = f(null);
11
+ return l(() => {
12
+ function e(e) {
13
+ let r = t ?? u.current;
14
+ r && !n(e, [r]) && c(!1);
15
+ }
16
+ function l() {
17
+ c(!1);
18
+ }
19
+ function d(e) {
20
+ e.key === "Escape" && c(!1);
21
+ }
22
+ let f = new AbortController();
23
+ return s && (window.addEventListener(r, e, f), o && window.addEventListener("keydown", d, f), a && window.addEventListener("resize", l, f), i && window.addEventListener("scroll", e, {
24
+ signal: f.signal,
25
+ capture: !0
26
+ })), () => {
27
+ f.abort();
28
+ };
29
+ }, [
30
+ t,
31
+ s,
32
+ r,
33
+ o,
34
+ a,
35
+ i
36
+ ]), [
37
+ s,
38
+ c,
39
+ u
40
+ ];
41
+ }
42
+ //#endregion
43
+ //#region src/react/useStyles.ts
44
+ var D = i;
45
+ function O(t, n) {
46
+ let { classNames: r, signature: i, styleElements: a } = e(t, n);
47
+ return D(() => {
48
+ v().flushSync();
49
+ }, [i ?? t]), {
50
+ classNames: r,
51
+ styleElements: a
52
+ };
53
+ }
54
+ function k(e, n) {
55
+ let r = e ? v().addGlobalStyles(e, n) : void 0;
56
+ return D(() => {
57
+ v().flushSync();
58
+ }, [e, n]), t(r);
59
+ }
60
+ var A;
61
+ (function(e) {
62
+ function t() {
63
+ v().flushSync();
64
+ }
65
+ e.flushSync = t;
66
+ function n() {
67
+ v().clear();
68
+ }
69
+ e.clear = n;
70
+ function r() {
71
+ return v().getStyles();
72
+ }
73
+ e.getStyles = r;
74
+ function i() {
75
+ return v().styleElementId;
76
+ }
77
+ e.styleElementId = i;
78
+ function a(e) {
79
+ v().configure(e);
80
+ }
81
+ e.configure = a;
82
+ })(A ||= {});
83
+ //#endregion
84
+ //#region src/react/clientRuntime.ts
85
+ var j = "[box-kite] The client build was loaded into a React Server Component graph, where React has no createContext. Import '@box-kite/react' by its package name — the react-server condition resolves it to a Box that renders on the server — and import the components that hold state (Dropdown, Tooltip, DataGrid, Checkbox, Select, Form) from a 'use client' module. See https://github.com/box-kite/box-kite#react-server-components-react-19";
86
+ function M(e) {
87
+ if (typeof e.createContext != "function") throw Error(j);
88
+ }
89
+ //#endregion
90
+ //#region src/react/theme/themeContext.ts
91
+ M(o);
92
+ var N = o.createContext({
93
+ theme: "",
94
+ setTheme: () => {}
95
+ });
96
+ //#endregion
97
+ //#region src/react/theme/theme.tsx
98
+ function P(e) {
99
+ let { children: t, theme: n, use: r = "local", storageKey: i, globalStyles: o } = e, c = k(r === "global" ? o : void 0, "html"), [l, d] = p(n ?? g), [v, E] = p(n !== void 0), D = f(null), O = s((e) => {
100
+ e === null ? (i && h(i), E(!1)) : (i && C(i, e), d(e), E(!0));
101
+ }, [i]), [A, j] = p(n);
102
+ return n !== A && (j(n), n === void 0 ? E(!1) : (d(n), E(!0))), u(() => {
103
+ if (v) return;
104
+ let e = i ? b(i) : null;
105
+ if (e) {
106
+ d(e), E(!0);
107
+ return;
108
+ }
109
+ return d(y()), S(d);
110
+ }, [v, i]), u(() => {
111
+ if (r === "local") return;
112
+ let e = _();
113
+ if (e) return m(e, l);
114
+ }, [l, r]), u(() => {
115
+ r !== "local" || !D.current || x(D.current, l);
116
+ }, [l, r]), r === "local" ? /* @__PURE__ */ T(N.Provider, {
117
+ value: {
118
+ theme: l,
119
+ setTheme: O
120
+ },
121
+ children: [c, /* @__PURE__ */ w(a, {
122
+ ref: D,
123
+ className: l,
124
+ children: t
125
+ })]
126
+ }) : /* @__PURE__ */ T(N.Provider, {
127
+ value: {
128
+ theme: l,
129
+ setTheme: O
130
+ },
131
+ children: [c, t]
132
+ });
133
+ }
134
+ (function(e) {
135
+ function t() {
136
+ let { theme: e, setTheme: t } = c(N);
137
+ return [e, t];
138
+ }
139
+ e.useTheme = t;
140
+ })(P ||= {});
141
+ var F = P, I = /* @__PURE__ */ new WeakMap();
142
+ function L(e) {
143
+ let t = I.get(e);
144
+ return t || (t = /* @__PURE__ */ new Map(), I.set(e, t)), t;
145
+ }
146
+ function R(e = !0) {
147
+ let [t] = F.useTheme(), n = d(() => {
148
+ if (!e) return null;
149
+ let t = r();
150
+ if (!t) return null;
151
+ let n = "box-kite-portal", i = t.getElementById(n);
152
+ return i || (i = document.createElement("div"), i.id = n, document.body.appendChild(i)), i;
153
+ }, [e]);
154
+ return u(() => {
155
+ if (!t || !n) return;
156
+ let e = L(n), r = e.get(t) ?? 0;
157
+ return e.set(t, r + 1), r === 0 && n.classList.add(t), () => {
158
+ let r = (e.get(t) ?? 1) - 1;
159
+ r <= 0 ? (e.delete(t), n.classList.remove(t)) : e.set(t, r);
160
+ };
161
+ }, [n, t]), n;
162
+ }
163
+ //#endregion
164
+ export { E as a, O as i, F as n, A as r, R as t };
@@ -0,0 +1 @@
1
+ "use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../box.cjs"),t=require("../behavior.cjs"),n=require("../identity.cjs");let r=require("react"),i=require("react/jsx-runtime");var a;(function(e){e.ROOT_ATTRIBUTE=`data-accordion`,e.TRIGGER_ATTRIBUTE=`data-accordion-trigger`;let t=e.ROOT_SELECTOR=`[data-accordion]`,n=e.TRIGGER_SELECTOR=`[data-accordion-trigger]`;function r(e,n){return n instanceof Element&&n.closest(t)===e}e.owns=r;function i(e){return e?[...e.querySelectorAll(n)].filter(t=>r(e,t)):[]}e.triggers=i;function a(e){return e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}e.isDisabled=a;function o(e,t,n,r){let i=e.length;if(i===0)return;let o=t<0||t>=i?n>0?-1:i:t;for(let t=0;t<i;t++){if(o+=n,o<0||o>=i){if(!r)return;o=(o%i+i)%i}if(!a(e[o]))return e[o]}}e.step=o;function s(e,t){return o(e,t===1?-1:e.length,t,!1)}e.edge=s;function c(e,t){return t instanceof HTMLElement?e.indexOf(t):-1}e.indexOf=c;function l(e){if(e===`ArrowDown`)return{kind:`step`,delta:1};if(e===`ArrowUp`)return{kind:`step`,delta:-1};if(e===`Home`)return{kind:`edge`,delta:1};if(e===`End`)return{kind:`edge`,delta:-1}}e.moveFor=l;function u(e,t,n,r){return n.kind===`edge`?s(e,n.delta):o(e,t,n.delta,r)}e.target=u;function d(e,t,n){return e.includes(t)?e.filter(e=>e!==t):n?[...e,t]:[t]}e.toggle=d})(a||={});var o=a,s=[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`],c=(0,r.createContext)(null),l=(0,r.createContext)(null);function u(e){let t=(0,r.useContext)(c);if(!t)throw Error(`<${e}> has to be rendered inside an <Accordion>.`);return t}function d(e){let t=(0,r.useContext)(l);if(!t)throw Error(`<${e}> has to be rendered inside an <Accordion.Item>.`);return t}function f(n){let{children:a,value:s,defaultValue:l,onValueChange:u,multiple:d=!1,loop:f=!0,level:p=3,props:m,...h}=n,g=(0,r.useRef)(null),[_,v]=t.i({value:s,defaultValue:l??[],onChange:u}),y=t.a((e,t)=>{v(t=>o.toggle(t,e,d),t)}),b=t.a(e=>{let t=g.current;if(!t||e.defaultPrevented||!o.owns(t,e.target))return;let n=o.triggers(t),r=o.indexOf(n,e.target);if(r===-1)return;let i=o.moveFor(e.key);if(!i)return;let a=o.target(n,r,i,f);a&&(e.preventDefault(),a.focus())}),x=(0,r.useMemo)(()=>({open:_,level:p,toggle:y}),[_,p,y]);return(0,i.jsx)(c.Provider,{value:x,children:(0,i.jsx)(e.default,{ref:g,component:`accordion`,...h,props:{[o.ROOT_ATTRIBUTE]:``,...m,onKeyDown:b},children:a})})}function p(t){let{value:a,children:o,disabled:s=!1,props:c,...d}=t,{open:f}=u(`Accordion.Item`),p=n.t(`accordion`),m=f.includes(a),h=(0,r.useMemo)(()=>({value:a,open:m,disabled:s,triggerId:`${p}-trigger`,panelId:`${p}-panel`}),[a,m,s,p]);return(0,i.jsx)(l.Provider,{value:h,children:(0,i.jsx)(e.default,{component:`accordion.item`,...d,props:c,children:o})})}p.displayName=`Accordion.Item`;function m(n){let{children:r,level:a,arrow:c=!0,props:l,...f}=n,{level:p,toggle:m}=u(`Accordion.Trigger`),{value:h,open:g,disabled:_,triggerId:v,panelId:y}=d(`Accordion.Trigger`),b=t.a(e=>m(h,{reason:`trigger`,event:e}));return(0,i.jsx)(e.default,{tag:s[(a??p)-1],component:`accordion.heading`,children:(0,i.jsxs)(e.default,{tag:`button`,component:`accordion.trigger`,...f,disabled:_,id:v,props:{type:`button`,"aria-expanded":g,"aria-controls":y,[o.TRIGGER_ATTRIBUTE]:``,...l,onClick:b},children:[r,c&&(0,i.jsx)(e.default,{tag:`span`,component:`accordion.arrow`,variant:{open:g},props:{"aria-hidden":!0}})]})})}m.displayName=`Accordion.Trigger`;function h(t){let{children:n,props:r,...a}=t,{open:o,triggerId:s,panelId:c}=d(`Accordion.Panel`);return(0,i.jsx)(e.default,{component:`accordion.track`,variant:{closed:!o},children:(0,i.jsx)(e.default,{component:`accordion.clip`,children:(0,i.jsx)(e.default,{component:`accordion.panel`,...a,id:c,props:{role:`region`,"aria-labelledby":s,...r},children:n})})})}h.displayName=`Accordion.Panel`;function g(a){let{children:o,trigger:s,open:c,defaultOpen:l=!1,onOpenChange:u,props:d,...f}=a,p=n.t(`collapsible`),m=`${p}-trigger`,h=`${p}-panel`,[g,_]=t.i({value:c,defaultValue:l,onChange:u}),v=t.a(e=>_(e=>!e,{reason:`trigger`,event:e})),y=(0,r.useMemo)(()=>({props:{id:m,type:`button`,"aria-expanded":g,"aria-controls":h,onClick:v}}),[m,h,g,v]);return(0,i.jsxs)(e.default,{component:`collapsible`,...f,props:d,children:[s(y),(0,i.jsx)(e.default,{component:`collapsible.track`,variant:{closed:!g},children:(0,i.jsx)(e.default,{component:`collapsible.clip`,children:(0,i.jsx)(e.default,{component:`collapsible.panel`,id:h,children:o})})})]})}g.displayName=`Collapsible`;var _=f;_.Item=p,_.Trigger=m,_.Panel=h,_.displayName=`Accordion`,exports.Collapsible=g,exports.default=_;