@box-kite/react 1.0.0 → 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.
- package/.claude/rules/box-kite-rules.md +23 -1
- package/.claude/skills/box-kite/SKILL.md +134 -427
- package/.claude/skills/box-kite/references/components.md +235 -0
- package/.claude/skills/box-kite/references/extending.md +42 -0
- package/.claude/skills/box-kite/references/patterns.md +27 -0
- package/.claude/skills/box-kite/references/styling.md +222 -0
- package/.cursor/rules/box-kite.mdc +73 -0
- package/AGENTS.md +102 -0
- package/BOX_AI_CONTEXT.md +1124 -153
- package/BOX_KITE_AI_CONTEXT.md +1124 -153
- package/README.md +36 -2
- package/a11y.cjs +1 -1
- package/a11y.d.ts +1 -1
- package/a11y.mjs +3 -2
- package/anchor.cjs +1 -0
- package/anchor.d.ts +14 -0
- package/anchor.mjs +3 -0
- package/behavior.cjs +1 -1
- package/behavior.mjs +118 -136
- package/box.cjs +1 -1
- package/box.mjs +1 -1
- package/client.cjs +1 -1
- package/client.mjs +15 -14
- package/components/accordion.cjs +1 -0
- package/components/accordion.d.ts +114 -0
- package/components/accordion.mjs +251 -0
- package/components/button.cjs +1 -1
- package/components/button.d.ts +3 -0
- package/components/button.mjs +1 -1
- package/components/chart.cjs +1 -1
- package/components/chart.d.ts +2 -1
- package/components/chart.mjs +159 -184
- package/components/checkbox.cjs +1 -1
- package/components/checkbox.d.ts +8 -0
- package/components/checkbox.mjs +1 -1
- package/components/combobox/comboboxChips.d.ts +21 -0
- package/components/combobox/comboboxListbox.d.ts +47 -0
- package/components/combobox.cjs +1 -0
- package/components/combobox.d.ts +121 -0
- package/components/combobox.mjs +563 -0
- package/components/dataGrid/components/dataGridAggregateValue.d.ts +10 -0
- package/components/dataGrid/components/dataGridCell.d.ts +2 -1
- package/components/dataGrid/components/dataGridCellEditor.d.ts +15 -0
- package/components/dataGrid/components/dataGridCellPlaceholder.d.ts +14 -0
- package/components/dataGrid/components/dataGridCellTree.d.ts +16 -0
- package/components/dataGrid/components/dataGridDataSourceError.d.ts +12 -0
- package/components/dataGrid/components/dataGridExport.d.ts +10 -0
- package/components/dataGrid/components/dataGridFooter.d.ts +11 -0
- package/components/dataGrid/contracts/dataGridContract.d.ts +474 -16
- package/components/dataGrid/export/gridExport.d.ts +10 -0
- package/components/dataGrid/gridNavigationContext.d.ts +9 -1
- package/components/dataGrid/models/aggregateCellModel.d.ts +34 -0
- package/components/dataGrid/models/aggregationModel.d.ts +32 -0
- package/components/dataGrid/models/cellKeys.d.ts +11 -0
- package/components/dataGrid/models/cellModel.d.ts +27 -1
- package/components/dataGrid/models/columnModel.d.ts +12 -2
- package/components/dataGrid/models/dataSourceModel.d.ts +177 -0
- package/components/dataGrid/models/editModel.d.ts +77 -0
- package/components/dataGrid/models/exportModel.d.ts +51 -0
- package/components/dataGrid/models/gridModel.d.ts +108 -21
- package/components/dataGrid/models/groupRowCellModel.d.ts +11 -3
- package/components/dataGrid/models/groupRowModel.d.ts +22 -2
- package/components/dataGrid/models/rowModel.d.ts +13 -1
- package/components/dataGrid/models/sourceGroupRowModel.d.ts +45 -0
- package/components/dataGrid/models/sourceLevel.d.ts +71 -0
- package/components/dataGrid/models/sourceRowModel.d.ts +29 -0
- package/components/dataGrid/models/sourceTreeRowModel.d.ts +23 -0
- package/components/dataGrid/models/treeModel.d.ts +94 -0
- package/components/dataGrid/models/treeRow.d.ts +22 -0
- package/components/dataGrid/models/treeRowModel.d.ts +50 -0
- package/components/dataGrid.cjs +1 -1
- package/components/dataGrid.d.ts +4 -2
- package/components/dataGrid.mjs +4484 -2755
- package/components/dialog.cjs +1 -0
- package/components/dialog.d.ts +151 -0
- package/components/dialog.mjs +223 -0
- package/components/dropdown.cjs +1 -1
- package/components/dropdown.d.ts +30 -0
- package/components/dropdown.mjs +256 -244
- package/components/icon.cjs +1 -1
- package/components/icon.d.ts +2 -1
- package/components/icon.mjs +3 -3
- package/components/menu.cjs +1 -0
- package/components/menu.d.ts +234 -0
- package/components/menu.mjs +422 -0
- package/components/overlay.cjs +1 -1
- package/components/overlay.d.ts +30 -26
- package/components/overlay.mjs +45 -75
- package/components/popover.cjs +1 -0
- package/components/popover.d.ts +100 -0
- package/components/popover.mjs +69 -0
- package/components/presence.d.ts +6 -0
- package/components/progress.cjs +1 -0
- package/components/progress.d.ts +47 -0
- package/components/progress.mjs +28 -0
- package/components/radioButton.cjs +1 -1
- package/components/radioButton.d.ts +8 -0
- package/components/radioButton.mjs +1 -1
- package/components/radioGroup.cjs +1 -1
- package/components/radioGroup.d.ts +15 -2
- package/components/radioGroup.mjs +34 -30
- package/components/select.d.ts +9 -0
- package/components/semantics.cjs +1 -1
- package/components/semantics.d.ts +33 -28
- package/components/semantics.mjs +3 -3
- package/components/slider.cjs +1 -0
- package/components/slider.d.ts +98 -0
- package/components/slider.mjs +250 -0
- package/components/svg.cjs +1 -1
- package/components/svg.d.ts +25 -23
- package/components/svg.mjs +3 -3
- package/components/switch.cjs +1 -1
- package/components/switch.d.ts +9 -0
- package/components/switch.mjs +1 -1
- package/components/tabs.cjs +1 -0
- package/components/tabs.d.ts +87 -0
- package/components/tabs.mjs +324 -0
- package/components/textarea.cjs +1 -1
- package/components/textarea.d.ts +14 -0
- package/components/textarea.mjs +1 -1
- package/components/textbox.cjs +1 -1
- package/components/textbox.d.ts +12 -0
- package/components/textbox.mjs +1 -1
- package/components/toaster.cjs +1 -0
- package/components/toaster.d.ts +106 -0
- package/components/toaster.mjs +295 -0
- package/components/tooltip.cjs +1 -1
- package/components/tooltip.d.ts +39 -4
- package/components/tooltip.mjs +56 -54
- package/docs/a11y.md +199 -0
- package/docs/anchor.md +139 -0
- package/docs/components.md +48 -0
- package/docs/index.md +11 -0
- package/docs/props.md +1777 -0
- package/effects.cjs +1 -1
- package/effects.mjs +1 -1
- package/gridExport.cjs +2 -0
- package/gridExport.mjs +244 -0
- package/identity.cjs +1 -0
- package/identity.mjs +12 -0
- package/keyboard.cjs +1 -0
- package/keyboard.mjs +30 -0
- package/layer.cjs +1 -0
- package/layer.mjs +127 -0
- package/motion.cjs +1 -1
- package/motion.mjs +1 -1
- package/package.json +134 -10
- package/placement.cjs +1 -0
- package/placement.mjs +180 -0
- package/platform.cjs +1 -1
- package/platform.mjs +18 -5
- package/react/anchor/useAnchorPosition.d.ts +79 -0
- package/react/dialog/useScrollLock.d.ts +12 -0
- package/react/hooks/usePortalContainer.d.ts +6 -1
- package/react/hooks/useVirtualization.d.ts +24 -35
- package/react/popover/usePopoverLayer.d.ts +87 -0
- package/react-shared.cjs +1 -1
- package/react-shared.mjs +19 -2
- package/rsc.cjs +1 -1
- package/rsc.mjs +1 -1
- package/utils/accordion/accordionUtils.d.ts +48 -0
- package/utils/anchor/anchorUtils.d.ts +79 -0
- package/utils/array/lazyList.d.ts +10 -0
- package/utils/chart/chartPalette.d.ts +15 -0
- package/utils/chart/chartUtils.d.ts +2 -8
- package/utils/combobox/comboboxUtils.d.ts +89 -0
- package/utils/dom/domUtils.d.ts +6 -0
- package/utils/environment/environmentUtils.d.ts +10 -0
- package/utils/export/csvUtils.d.ts +23 -0
- package/utils/export/downloadUtils.d.ts +12 -0
- package/utils/export/xlsxUtils.d.ts +56 -0
- package/utils/export/zipUtils.d.ts +26 -0
- package/utils/keyboard/typeaheadUtils.d.ts +31 -0
- package/utils/menu/menuUtils.d.ts +25 -0
- package/utils/slider/sliderUtils.d.ts +67 -0
- package/utils/tabs/tabsUtils.d.ts +75 -0
- package/utils/toast/toastStore.d.ts +73 -0
- package/utils/virtual/virtualUtils.d.ts +47 -0
- /package/react/{a11y → identity}/useIdentifier.d.ts +0 -0
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://github.com/box-kite/box-kite/actions/workflows/test.yml)
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
|
|
8
|
-
`Box` is a single React component with
|
|
8
|
+
`Box` is a single React component with 221 typed CSS props. It generates the CSS for the values you
|
|
9
9
|
pass at runtime and caches every rule by its content, so the same value anywhere in the app reuses
|
|
10
10
|
one class — a project styles itself in TypeScript, with no CSS files to write and no class-name
|
|
11
11
|
convention to remember.
|
|
@@ -684,7 +684,7 @@ A complete page — props, pseudo-classes, breakpoints, themes, `extend`, `compo
|
|
|
684
684
|
|
|
685
685
|
## Architecture
|
|
686
686
|
|
|
687
|
-
The styling engine is framework-free. Everything that generates CSS — the
|
|
687
|
+
The styling engine is framework-free. Everything that generates CSS — the 221 prop definitions,
|
|
688
688
|
the value formatters, class-name generation, rule ordering, the style sinks (CSSOM, `textContent`,
|
|
689
689
|
string for SSR, style elements for React 19), the flush scheduler, CSS variables and the theme
|
|
690
690
|
runtime — lives in `src/core/` and imports no React at all. CI fails the build if it ever does
|
|
@@ -714,3 +714,37 @@ code.
|
|
|
714
714
|
|
|
715
715
|
See [CONTRIBUTING.md](CONTRIBUTING.md#the-core-boundary) for the boundary rules and where new code
|
|
716
716
|
belongs.
|
|
717
|
+
|
|
718
|
+
## AI editors and agents
|
|
719
|
+
|
|
720
|
+
The package ships its own instructions, because an agent has priors about a library this new and they
|
|
721
|
+
are wrong. `AGENTS.md` at the package root is the file agents look for — the rules, the dividers, one
|
|
722
|
+
worked example — and `docs/` sits beside it: every prop with the CSS it writes (`docs/props.md`),
|
|
723
|
+
every component with its import and whether it renders on a server (`docs/components.md`), and the
|
|
724
|
+
behaviour hooks (`docs/a11y.md`). All of it is generated during the build from the prop registry, the
|
|
725
|
+
rules file and the built chunks' own exports, so none of it can drift from the library it describes.
|
|
726
|
+
|
|
727
|
+
```shell
|
|
728
|
+
cp node_modules/@box-kite/react/AGENTS.md ./AGENTS.md
|
|
729
|
+
```
|
|
730
|
+
|
|
731
|
+
Codex, Cursor, Copilot, VS Code, Windsurf, Cline and Zed read a root `AGENTS.md` natively; Claude
|
|
732
|
+
Code reads `CLAUDE.md`, so a file holding the one line `@AGENTS.md` points it at the same place. The
|
|
733
|
+
long-form [BOX_KITE_AI_CONTEXT.md](src/BOX_KITE_AI_CONTEXT.md) ships in the tarball too.
|
|
734
|
+
|
|
735
|
+
The same rules are also a skill, which roughly forty-five coding agents install with one command:
|
|
736
|
+
|
|
737
|
+
```shell
|
|
738
|
+
npx skills add box-kite/box-kite # Claude Code, Cursor, Codex, Copilot, Gemini CLI, Zed…
|
|
739
|
+
```
|
|
740
|
+
|
|
741
|
+
In Claude Code this repository is also a plugin marketplace — `/plugin marketplace add box-kite/box-kite`
|
|
742
|
+
then `/plugin install box-kite@box-kite` — and Cursor takes the rules as a rule file of its own:
|
|
743
|
+
|
|
744
|
+
```shell
|
|
745
|
+
mkdir -p .cursor/rules && cp node_modules/@box-kite/react/.cursor/rules/box-kite.mdc .cursor/rules/
|
|
746
|
+
```
|
|
747
|
+
|
|
748
|
+
Both are generated from the same rules file as `AGENTS.md`, and both are served by the docs site
|
|
749
|
+
([skill.md](https://www.box-kite.dev/skill.md), [box-kite.mdc](https://www.box-kite.dev/box-kite.mdc))
|
|
750
|
+
for an agent that can fetch a URL but not run a command.
|
package/a11y.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./behavior.cjs");exports.useControllableState=e.
|
|
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
CHANGED
|
@@ -10,6 +10,6 @@ export { default as useDismiss } from './react/a11y/useDismiss';
|
|
|
10
10
|
export type { DismissOptions, DismissReason, ElementLike } from './react/a11y/useDismiss';
|
|
11
11
|
export { default as useFocusReturn } from './react/a11y/useFocusReturn';
|
|
12
12
|
export type { FocusReturnOptions } from './react/a11y/useFocusReturn';
|
|
13
|
-
export { default as useIdentifier } from './react/
|
|
13
|
+
export { default as useIdentifier } from './react/identity/useIdentifier';
|
|
14
14
|
export { default as useRovingFocus } from './react/a11y/useRovingFocus';
|
|
15
15
|
export type { RovingFocus, RovingFocusItemProps, RovingFocusOptions, RovingFocusReason, RovingOrientation, } from './react/a11y/useRovingFocus';
|
package/a11y.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
|
|
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
package/behavior.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./
|
|
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
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as e, l as t, s as n, t as r, u as i } from "./platform.mjs";
|
|
2
2
|
import { n as a } from "./effects.mjs";
|
|
3
|
-
import
|
|
3
|
+
import { t as o } from "./keyboard.mjs";
|
|
4
|
+
import { useCallback as s, useEffect as c, useRef as l, useState as u } from "react";
|
|
4
5
|
//#region src/react/a11y/callbacks.ts
|
|
5
6
|
function d(e) {
|
|
6
7
|
let t = l(e);
|
|
@@ -32,24 +33,24 @@ function g() {
|
|
|
32
33
|
let e = m.filter((e) => !m.some((t) => t !== e && h(e, t)));
|
|
33
34
|
return e[e.length - 1];
|
|
34
35
|
}
|
|
35
|
-
function _(
|
|
36
|
-
let { enabled:
|
|
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);
|
|
37
38
|
a(() => {
|
|
38
|
-
if (!
|
|
39
|
-
let
|
|
40
|
-
m.push(
|
|
39
|
+
if (!r) return;
|
|
40
|
+
let e = { elements: () => (l.current ?? []).map((e) => n(e)).filter((e) => e !== null) };
|
|
41
|
+
m.push(e);
|
|
41
42
|
let i = new AbortController(), a = (e, t) => document.addEventListener(e, t, { signal: i.signal });
|
|
42
|
-
return s && a("keydown", (
|
|
43
|
-
|
|
44
|
-
}), c && a("pointerdown", (
|
|
45
|
-
e
|
|
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);
|
|
46
47
|
}), () => {
|
|
47
48
|
i.abort();
|
|
48
|
-
let
|
|
49
|
-
|
|
49
|
+
let t = m.indexOf(e);
|
|
50
|
+
t !== -1 && m.splice(t, 1);
|
|
50
51
|
};
|
|
51
52
|
}, [
|
|
52
|
-
|
|
53
|
+
r,
|
|
53
54
|
s,
|
|
54
55
|
c,
|
|
55
56
|
u,
|
|
@@ -59,14 +60,14 @@ function _(t) {
|
|
|
59
60
|
//#endregion
|
|
60
61
|
//#region src/react/a11y/useFocusReturn.ts
|
|
61
62
|
function v() {
|
|
62
|
-
let e =
|
|
63
|
+
let e = r()?.activeElement;
|
|
63
64
|
return e && e !== document.body ? e : null;
|
|
64
65
|
}
|
|
65
|
-
function y(
|
|
66
|
-
let { enabled: n = !0, returnTo: r, preventScroll: i } =
|
|
66
|
+
function y(t = {}) {
|
|
67
|
+
let { enabled: n = !0, returnTo: r, preventScroll: i } = t, [a, o] = u(null), [s, l] = u(!1);
|
|
67
68
|
n !== s && (l(n), n && o(v()));
|
|
68
69
|
let d = f(() => {
|
|
69
|
-
(
|
|
70
|
+
(e(r) ?? a)?.focus({ preventScroll: i });
|
|
70
71
|
});
|
|
71
72
|
return c(() => {
|
|
72
73
|
if (n) return () => {
|
|
@@ -76,22 +77,12 @@ function y(e = {}) {
|
|
|
76
77
|
}, [n, d]), { returnFocus: d };
|
|
77
78
|
}
|
|
78
79
|
//#endregion
|
|
79
|
-
//#region src/react/a11y/useIdentifier.ts
|
|
80
|
-
var b = o.useId ?? (() => void 0), x = 0;
|
|
81
|
-
function S(e) {
|
|
82
|
-
return e.replace(/[^\w-]/g, "");
|
|
83
|
-
}
|
|
84
|
-
function C(e = "box") {
|
|
85
|
-
let t = b(), [n] = u(() => `${++x}`);
|
|
86
|
-
return `${e}-${t ? S(t) : n}`;
|
|
87
|
-
}
|
|
88
|
-
//#endregion
|
|
89
80
|
//#region src/react/a11y/useRovingFocus.ts
|
|
90
|
-
var
|
|
91
|
-
function
|
|
81
|
+
var b = 10;
|
|
82
|
+
function x(e, t) {
|
|
92
83
|
return t < 0 ? -1 : Math.max(0, Math.min(e, t));
|
|
93
84
|
}
|
|
94
|
-
function
|
|
85
|
+
function S(e, t, n, r, i) {
|
|
95
86
|
if (n === 0) return -1;
|
|
96
87
|
let a = e;
|
|
97
88
|
for (let e = 0; e < n; e++) {
|
|
@@ -103,50 +94,38 @@ function E(e, t, n, r, i) {
|
|
|
103
94
|
}
|
|
104
95
|
return -1;
|
|
105
96
|
}
|
|
106
|
-
function
|
|
107
|
-
return
|
|
108
|
-
}
|
|
109
|
-
function O(e, t, n, r, i) {
|
|
110
|
-
if (n === 0) return -1;
|
|
111
|
-
let a = [...e], o = a.every((e) => e === a[0]), s = (o ? a[0] : e).toLowerCase(), c = o ? t + 1 : t;
|
|
112
|
-
for (let e = 0; e < n; e++) {
|
|
113
|
-
let t = ((c + e) % n + n) % n;
|
|
114
|
-
if (!i?.(t) && r(t).trim().toLowerCase().startsWith(s)) return t;
|
|
115
|
-
}
|
|
116
|
-
return -1;
|
|
117
|
-
}
|
|
118
|
-
function k(e) {
|
|
119
|
-
return e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey;
|
|
97
|
+
function C(e, t, n) {
|
|
98
|
+
return S(e === 1 ? -1 : t, e, t, !1, n);
|
|
120
99
|
}
|
|
121
|
-
function
|
|
122
|
-
let { count: t, columns:
|
|
123
|
-
value:
|
|
124
|
-
defaultValue:
|
|
125
|
-
onChange:
|
|
126
|
-
}),
|
|
127
|
-
let n =
|
|
128
|
-
if (!
|
|
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);
|
|
129
108
|
if (n <= 0) return -1;
|
|
130
|
-
let
|
|
131
|
-
for (;
|
|
132
|
-
return
|
|
133
|
-
}, [
|
|
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({
|
|
134
113
|
query: "",
|
|
135
114
|
at: 0
|
|
136
|
-
}),
|
|
137
|
-
|
|
138
|
-
}, []),
|
|
139
|
-
|
|
140
|
-
}, []),
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
|
144
123
|
]), G = d({
|
|
145
|
-
row:
|
|
146
|
-
column:
|
|
147
|
-
}), K = d(
|
|
148
|
-
let i =
|
|
149
|
-
return i === s.row && o === s.column ? s : (
|
|
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?.({
|
|
150
129
|
row: i,
|
|
151
130
|
column: o
|
|
152
131
|
}, r), {
|
|
@@ -158,138 +137,141 @@ function A(e) {
|
|
|
158
137
|
Y,
|
|
159
138
|
q,
|
|
160
139
|
t,
|
|
161
|
-
|
|
140
|
+
O
|
|
162
141
|
]), Q = s((e, n, r) => {
|
|
163
|
-
let i =
|
|
142
|
+
let i = x(e, t - 1), a = i < 0 ? -1 : x(Math.max(0, n), J.current(i) - 1);
|
|
164
143
|
return Z(i, a < 0 ? 0 : X.current?.(i, a) ?? a, r);
|
|
165
144
|
}, [
|
|
166
145
|
X,
|
|
167
146
|
t,
|
|
168
147
|
Z,
|
|
169
148
|
J
|
|
170
|
-
]),
|
|
149
|
+
]), ee = s((e, t) => {
|
|
171
150
|
let n = `${e}:${t}`;
|
|
172
|
-
return
|
|
173
|
-
e ?
|
|
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));
|
|
174
153
|
}), {
|
|
175
|
-
ref:
|
|
176
|
-
tabIndex: e ===
|
|
154
|
+
ref: z.current.get(n),
|
|
155
|
+
tabIndex: e === k && t === F ? 0 : -1,
|
|
177
156
|
onFocus: () => {
|
|
178
|
-
|
|
157
|
+
H.current || Q(e, t, { reason: "focus" });
|
|
179
158
|
}
|
|
180
159
|
};
|
|
181
160
|
}, [
|
|
182
|
-
|
|
183
|
-
|
|
161
|
+
F,
|
|
162
|
+
k,
|
|
184
163
|
Q
|
|
185
|
-
]),
|
|
186
|
-
|
|
164
|
+
]), te = s((e) => (L.current.has(e) || L.current.set(e, (t) => {
|
|
165
|
+
I.current[e] = t;
|
|
187
166
|
}), {
|
|
188
|
-
ref:
|
|
189
|
-
tabIndex:
|
|
190
|
-
onFocus:
|
|
167
|
+
ref: L.current.get(e),
|
|
168
|
+
tabIndex: T ? e === k ? 0 : -1 : void 0,
|
|
169
|
+
onFocus: T ? () => O(e, { reason: "focus" }) : void 0
|
|
191
170
|
}), [
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
171
|
+
k,
|
|
172
|
+
T,
|
|
173
|
+
O
|
|
195
174
|
]), $ = s((e) => {
|
|
196
|
-
let { row:
|
|
175
|
+
let { row: n, column: r } = G.current, o = (t, n) => {
|
|
197
176
|
e.preventDefault();
|
|
198
177
|
let r = Q(t, n, {
|
|
199
178
|
reason: "keyboard",
|
|
200
179
|
event: e
|
|
201
180
|
});
|
|
202
|
-
|
|
181
|
+
T && U(r.row, r.column);
|
|
203
182
|
}, s = (t) => {
|
|
204
183
|
e.preventDefault();
|
|
205
184
|
let n = Z(t, K.current, {
|
|
206
185
|
reason: "keyboard",
|
|
207
186
|
event: e
|
|
208
187
|
});
|
|
209
|
-
|
|
210
|
-
}, c = 2 ** 53 - 1, l = () =>
|
|
188
|
+
T && U(n.row, n.column);
|
|
189
|
+
}, c = 2 ** 53 - 1, l = () => i(e.currentTarget) ? -1 : 1;
|
|
211
190
|
switch (e.key) {
|
|
212
|
-
case "ArrowRight": return o(
|
|
213
|
-
case "ArrowLeft": return o(
|
|
214
|
-
case "ArrowDown": return s(
|
|
215
|
-
case "ArrowUp": return s(
|
|
216
|
-
case "Home": return e.ctrlKey || e.metaKey ? o(0, 0) : o(
|
|
217
|
-
case "End": return e.ctrlKey || e.metaKey ? o(t - 1, c) : o(
|
|
218
|
-
case "PageDown": return s(
|
|
219
|
-
case "PageUp": return s(
|
|
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);
|
|
220
199
|
}
|
|
221
200
|
}, [
|
|
222
201
|
G,
|
|
223
202
|
t,
|
|
224
203
|
K,
|
|
225
|
-
|
|
226
|
-
|
|
204
|
+
U,
|
|
205
|
+
T,
|
|
227
206
|
a,
|
|
228
207
|
Z,
|
|
229
208
|
Q
|
|
230
209
|
]);
|
|
231
210
|
return {
|
|
232
|
-
activeIndex:
|
|
233
|
-
activeColumn:
|
|
234
|
-
setActiveIndex:
|
|
211
|
+
activeIndex: k,
|
|
212
|
+
activeColumn: F,
|
|
213
|
+
setActiveIndex: O,
|
|
235
214
|
setActiveCell: Q,
|
|
236
215
|
onKeyDown: s((e) => {
|
|
237
216
|
if (e.defaultPrevented) return;
|
|
238
|
-
if (
|
|
217
|
+
if (A) {
|
|
239
218
|
$(e);
|
|
240
219
|
return;
|
|
241
220
|
}
|
|
242
|
-
let
|
|
243
|
-
t !== -1 && t !==
|
|
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, {
|
|
244
223
|
reason: n,
|
|
245
224
|
event: e
|
|
246
|
-
}),
|
|
225
|
+
}), T && V(t));
|
|
247
226
|
};
|
|
248
|
-
if (
|
|
249
|
-
let
|
|
250
|
-
|
|
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");
|
|
251
230
|
return;
|
|
252
231
|
}
|
|
253
|
-
if (e.key === "ArrowDown" &&
|
|
254
|
-
|
|
232
|
+
if (e.key === "ArrowDown" && n) {
|
|
233
|
+
c(S(k, 1, t, h, y), "keyboard");
|
|
255
234
|
return;
|
|
256
235
|
}
|
|
257
|
-
if (e.key === "ArrowUp" &&
|
|
258
|
-
|
|
236
|
+
if (e.key === "ArrowUp" && n) {
|
|
237
|
+
c(S(k, -1, t, h, y), "keyboard");
|
|
259
238
|
return;
|
|
260
239
|
}
|
|
261
240
|
if (e.key === "Home") {
|
|
262
|
-
|
|
241
|
+
c(C(1, t, y), "keyboard");
|
|
263
242
|
return;
|
|
264
243
|
}
|
|
265
244
|
if (e.key === "End") {
|
|
266
|
-
|
|
245
|
+
c(C(-1, t, y), "keyboard");
|
|
267
246
|
return;
|
|
268
247
|
}
|
|
269
|
-
if (e.key === "Enter" || e.key === " " && !(
|
|
270
|
-
if (!
|
|
271
|
-
e.preventDefault(),
|
|
248
|
+
if (e.key === "Enter" || e.key === " " && !(s && w)) {
|
|
249
|
+
if (!E || k === -1) return;
|
|
250
|
+
e.preventDefault(), E(k, e);
|
|
272
251
|
return;
|
|
273
252
|
}
|
|
274
|
-
|
|
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
|
+
}
|
|
275
257
|
}, [
|
|
276
|
-
|
|
258
|
+
k,
|
|
277
259
|
t,
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
260
|
+
V,
|
|
261
|
+
T,
|
|
262
|
+
y,
|
|
263
|
+
A,
|
|
264
|
+
h,
|
|
283
265
|
$,
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
266
|
+
E,
|
|
267
|
+
m,
|
|
268
|
+
O,
|
|
269
|
+
w
|
|
288
270
|
]),
|
|
289
|
-
itemProps:
|
|
290
|
-
cellProps:
|
|
291
|
-
activeItem:
|
|
271
|
+
itemProps: te,
|
|
272
|
+
cellProps: ee,
|
|
273
|
+
activeItem: W
|
|
292
274
|
};
|
|
293
275
|
}
|
|
294
276
|
//#endregion
|
|
295
|
-
export {
|
|
277
|
+
export { f as a, p as i, y as n, d as o, _ as r, w as t };
|
package/box.cjs
CHANGED
|
@@ -1 +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.
|
|
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.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as e, f as t } from "./react-shared.mjs";
|
|
2
2
|
import { a as n, i as r, n as i, r as a } from "./client.mjs";
|
|
3
3
|
import o, { forwardRef as s, memo as c, useMemo as l, useState as u } from "react";
|
|
4
4
|
import { BoxExtends as d, Springs as f, getDefaultEngine as p } from "@box-kite/core";
|
package/client.cjs
CHANGED
|
@@ -1 +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.
|
|
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
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { l as e, u as t } from "./react-shared.mjs";
|
|
2
|
+
import { l as n, t as r } from "./platform.mjs";
|
|
3
3
|
import { t as i } from "./effects.mjs";
|
|
4
4
|
import a from "./box.mjs";
|
|
5
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";
|
|
@@ -143,21 +143,22 @@ function L(e) {
|
|
|
143
143
|
let t = I.get(e);
|
|
144
144
|
return t || (t = /* @__PURE__ */ new Map(), I.set(e, t)), t;
|
|
145
145
|
}
|
|
146
|
-
function R() {
|
|
147
|
-
let [
|
|
148
|
-
let e = r();
|
|
146
|
+
function R(e = !0) {
|
|
147
|
+
let [t] = F.useTheme(), n = d(() => {
|
|
149
148
|
if (!e) return null;
|
|
150
|
-
let t =
|
|
151
|
-
|
|
152
|
-
|
|
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]);
|
|
153
154
|
return u(() => {
|
|
154
|
-
if (!
|
|
155
|
-
let
|
|
156
|
-
return
|
|
157
|
-
let r = (
|
|
158
|
-
r <= 0 ? (
|
|
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);
|
|
159
160
|
};
|
|
160
|
-
}, [
|
|
161
|
+
}, [n, t]), n;
|
|
161
162
|
}
|
|
162
163
|
//#endregion
|
|
163
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=_;
|