@box-kite/react 2.2.17 → 2.3.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 +6 -4
- package/.claude/skills/box-kite/SKILL.md +6 -4
- package/.claude/skills/box-kite/references/components.md +1 -1
- package/.claude/skills/box-kite/references/patterns.md +1 -1
- package/.claude/skills/box-kite/references/styling.md +2 -2
- package/.cursor/rules/box-kite.mdc +6 -4
- package/AGENTS.md +6 -4
- package/BOX_AI_CONTEXT.md +40 -3
- package/BOX_KITE_AI_CONTEXT.md +40 -3
- package/behavior.cjs +1 -1
- package/behavior.mjs +62 -62
- package/box.cjs +1 -1
- package/box.d.ts +1 -0
- package/box.mjs +1 -1
- package/catalog.cjs +1 -1
- package/catalog.mjs +4 -4
- package/client.cjs +1 -1
- package/client.mjs +11 -11
- package/components/accordion.cjs +1 -1
- package/components/accordion.mjs +1 -1
- package/components/calendar.cjs +1 -1
- package/components/calendar.mjs +21 -20
- package/components/combobox.cjs +1 -1
- package/components/combobox.mjs +1 -1
- package/components/dashboard.cjs +1 -1
- package/components/dashboard.mjs +12 -12
- package/components/dataGrid.cjs +2 -2
- package/components/dataGrid.mjs +5 -5
- package/components/dateField.cjs +1 -1
- package/components/dateField.mjs +6 -6
- package/components/datePicker.cjs +1 -1
- package/components/datePicker.mjs +118 -116
- package/components/dialog.cjs +1 -1
- package/components/dialog.d.ts +1 -1
- package/components/dialog.mjs +108 -101
- package/components/dropdown.cjs +1 -1
- package/components/dropdown.mjs +8 -3
- package/components/form.cjs +1 -1
- package/components/form.mjs +1 -1
- package/components/menu.cjs +1 -1
- package/components/menu.mjs +10 -10
- package/components/overlay.cjs +1 -1
- package/components/overlay.mjs +5 -5
- package/components/popover.cjs +1 -1
- package/components/popover.d.ts +8 -2
- package/components/popover.mjs +58 -55
- package/components/radioGroup.cjs +1 -1
- package/components/radioGroup.mjs +1 -1
- package/components/slider.cjs +1 -1
- package/components/slider.mjs +8 -8
- package/components/sortableList.cjs +1 -1
- package/components/sortableList.mjs +1 -1
- package/components/swipeItem.cjs +1 -1
- package/components/swipeItem.mjs +10 -10
- package/components/tabs.cjs +1 -1
- package/components/tabs.mjs +9 -9
- package/components/toaster.cjs +1 -1
- package/components/toaster.mjs +133 -115
- package/components/tooltip.cjs +1 -1
- package/components/tooltip.mjs +1 -1
- package/components/virtualList.cjs +1 -1
- package/components/virtualList.mjs +1 -1
- package/docs/props.md +6 -6
- package/interactionListening.cjs +1 -1
- package/interactionListening.mjs +1 -1
- package/layer.cjs +1 -1
- package/layer.mjs +17 -14
- package/package.json +2 -2
- package/placement.cjs +1 -1
- package/placement.mjs +10 -10
- package/platform.cjs +1 -1
- package/platform.mjs +23 -11
- package/react-shared.cjs +1 -1
- package/react-shared.mjs +1 -1
- package/rsc.cjs +1 -1
- package/rsc.d.ts +1 -0
- package/rsc.mjs +1 -1
- package/scrolling.cjs +1 -1
- package/scrolling.mjs +1 -1
- package/utils/dom/domUtils.d.ts +9 -0
package/BOX_AI_CONTEXT.md
CHANGED
|
@@ -340,7 +340,7 @@ modifier, it is themed, and two elements asking for the same one share a class.
|
|
|
340
340
|
`'circle'`/`'ellipse'`/`true`; `conic` takes a start angle or `true`. Exactly one of the three.
|
|
341
341
|
- `at` centres a `radial` or `conic` gradient (not a `linear` one, which runs in a direction).
|
|
342
342
|
- `interpolate`: `'srgb'`, `'hsl'`, `'oklab'`, `'oklch'`, `'hsl-longer'`, `'oklch-longer'`.
|
|
343
|
-
- A stop is any colour value — a token, `blue-500/40`, a system colour, `var(--chart-1)` — or a
|
|
343
|
+
- A stop is any colour value — a token, `blue-500/40`, a system colour, `var(--chart-1)`, a `Box.extend()` colour — or a
|
|
344
344
|
`[colour, position]` pair. **Two stops minimum**, and the record is judged whole: one bad stop, one
|
|
345
345
|
unknown key, two kinds at once, and the whole value emits no rule and no class name.
|
|
346
346
|
- It writes `background-image`, so `bgGradient` and `bgImage` are the same property. `bgGradient` is declared
|
|
@@ -1453,6 +1453,42 @@ Full reference: `docs/a11y-primitives.md`.
|
|
|
1453
1453
|
|
|
1454
1454
|
---
|
|
1455
1455
|
|
|
1456
|
+
## Sizes: compact, normal, large
|
|
1457
|
+
|
|
1458
|
+
Every built-in component is drawn at one of three sizes, and a size is two CSS variables —
|
|
1459
|
+
`--control-height` and `--control-font-size` — so it inherits. Before 2.3.0 each control's height fell out of
|
|
1460
|
+
its own padding (a text box 46px, a button 36px, a combobox 34px), and nothing lined up.
|
|
1461
|
+
|
|
1462
|
+
| Size | Variant | Height | Text | Declared by |
|
|
1463
|
+
| ------- | ------------------- | ------ | ---- | -------------------------------------------------------- |
|
|
1464
|
+
| Compact | `variant="compact"` | 32px | 13px | `--control-height-compact`/`--control-font-size-compact` |
|
|
1465
|
+
| Normal | — (the default) | 40px | 14px | `--control-height-normal`/`--control-font-size-normal` |
|
|
1466
|
+
| Large | `variant="large"` | 48px | 16px | `--control-height-large`/`--control-font-size-large` |
|
|
1467
|
+
|
|
1468
|
+
- **What follows it.** Fields and buttons (`Button`, `Textbox`, `Dropdown`/`Select`, `Combobox`/`TimeZoneSelect`,
|
|
1469
|
+
`DateField`/`DatePicker`) take the height; items and rows (menu items, dropdown and combobox options, tabs,
|
|
1470
|
+
accordion headers, calendar days, a picker's times and presets) take it as a minimum; `Textarea` takes the text
|
|
1471
|
+
size; `Checkbox`, `RadioButton`, `Switch` and `Slider` scale whole; `Progress` changes its thickness.
|
|
1472
|
+
`Popover`, `Dialog`, `Menu`, `Tabs`, `Accordion`, `Collapsible`, `RadioGroup` and `Calendar` take the variant and
|
|
1473
|
+
pass it to everything inside. A `DataGrid` is drawn compact.
|
|
1474
|
+
- **A variant sizes the subtree**: `<Menu variant="compact">` makes every item compact, and `<DatePicker variant="large">`
|
|
1475
|
+
its calendar too (the picker hands its size to the panel, which is a sibling). `variant="normal"` restores the
|
|
1476
|
+
default inside a sized subtree.
|
|
1477
|
+
- **The project's scale is declared once**, on the app's root:
|
|
1478
|
+
|
|
1479
|
+
```tsx
|
|
1480
|
+
<Box vars={Box.sizes({ compact: 8, normal: 9, large: { height: 11, fontSize: 15 } })}>{app}</Box>
|
|
1481
|
+
```
|
|
1482
|
+
|
|
1483
|
+
A number is the ÷4 scale for a height and ÷16 for a text size; a string is CSS. `Box.sizes({ size: 'compact' })`
|
|
1484
|
+
draws a whole subtree at that size.
|
|
1485
|
+
|
|
1486
|
+
- **Never size one control by hand.** `height={9}` on one button wins as any prop does, which is how a row ends up
|
|
1487
|
+
with three heights. Padding no longer sizes a control: `py` changes nothing, `height="auto"` hands it back.
|
|
1488
|
+
- **Your own control joins** with `height="control"` (`minHeight` where it wraps) and `fontSize="control"`;
|
|
1489
|
+
`'control-compact'`/`'control-normal'`/`'control-large'` name one size outright.
|
|
1490
|
+
- `variant="square"` on a `Button` is an icon button as wide as it is tall, at whichever size.
|
|
1491
|
+
|
|
1456
1492
|
## Form controls: Checkbox, Switch, RadioGroup
|
|
1457
1493
|
|
|
1458
1494
|
All three render **real native inputs**, so focus, the checked state, the disabled state and form
|
|
@@ -1572,7 +1608,8 @@ positioning only and light-dismisses nothing.
|
|
|
1572
1608
|
| `offset` | `2` | The gap, on the ÷4 scale — 8px. |
|
|
1573
1609
|
| `flip` | `true` | Whether a side with no room is swapped for its opposite. |
|
|
1574
1610
|
| `matchWidth` | `false` | Whether the panel is at least as wide as its trigger. |
|
|
1575
|
-
| `autoFocus` | `true` | Whether opening moves focus
|
|
1611
|
+
| `autoFocus` | `true` | Whether opening moves focus onto the panel's first control (the panel if none). |
|
|
1612
|
+
| `initialFocus` | — | A ref to land on instead. React's `autoFocus` writes no attribute, so use this. |
|
|
1576
1613
|
|
|
1577
1614
|
What the component supplies, because the `popover` attribute supplies none of it: `role="dialog"`, the
|
|
1578
1615
|
name, and `aria-expanded`/`aria-haspopup="dialog"`/`aria-controls` on the trigger. What the **platform**
|
|
@@ -2398,7 +2435,7 @@ that was never on screen.
|
|
|
2398
2435
|
declared — it inherits the theme, the custom properties and the direction around it. `manual` rather
|
|
2399
2436
|
than `auto` because a stack of messages owns no dismissal: a press outside has to reach the page. The
|
|
2400
2437
|
viewport takes **no pointer events at all** and the toasts take them back, or a corner-sized fixed
|
|
2401
|
-
strip would swallow every press in its gaps.
|
|
2438
|
+
strip would swallow every press in its gaps. **While a modal `Dialog` is open the stack moves inside it**, shown after it — everything outside an open modal is inert, so a toast left on the page would sit under the backdrop, unpressable and silent — and moves back out when the dialog closes; Escape on a toast there dismisses the toast, not the dialog.
|
|
2402
2439
|
3. **Four things stop the clock**: the pointer over the stack, focus inside it, a background tab, and a
|
|
2403
2440
|
dismissal. A paused timer resumes where it left off rather than restarting. WCAG 2.2.1, and the only
|
|
2404
2441
|
reason a toast is allowed to carry a control at all.
|
package/BOX_KITE_AI_CONTEXT.md
CHANGED
|
@@ -340,7 +340,7 @@ modifier, it is themed, and two elements asking for the same one share a class.
|
|
|
340
340
|
`'circle'`/`'ellipse'`/`true`; `conic` takes a start angle or `true`. Exactly one of the three.
|
|
341
341
|
- `at` centres a `radial` or `conic` gradient (not a `linear` one, which runs in a direction).
|
|
342
342
|
- `interpolate`: `'srgb'`, `'hsl'`, `'oklab'`, `'oklch'`, `'hsl-longer'`, `'oklch-longer'`.
|
|
343
|
-
- A stop is any colour value — a token, `blue-500/40`, a system colour, `var(--chart-1)` — or a
|
|
343
|
+
- A stop is any colour value — a token, `blue-500/40`, a system colour, `var(--chart-1)`, a `Box.extend()` colour — or a
|
|
344
344
|
`[colour, position]` pair. **Two stops minimum**, and the record is judged whole: one bad stop, one
|
|
345
345
|
unknown key, two kinds at once, and the whole value emits no rule and no class name.
|
|
346
346
|
- It writes `background-image`, so `bgGradient` and `bgImage` are the same property. `bgGradient` is declared
|
|
@@ -1453,6 +1453,42 @@ Full reference: `docs/a11y-primitives.md`.
|
|
|
1453
1453
|
|
|
1454
1454
|
---
|
|
1455
1455
|
|
|
1456
|
+
## Sizes: compact, normal, large
|
|
1457
|
+
|
|
1458
|
+
Every built-in component is drawn at one of three sizes, and a size is two CSS variables —
|
|
1459
|
+
`--control-height` and `--control-font-size` — so it inherits. Before 2.3.0 each control's height fell out of
|
|
1460
|
+
its own padding (a text box 46px, a button 36px, a combobox 34px), and nothing lined up.
|
|
1461
|
+
|
|
1462
|
+
| Size | Variant | Height | Text | Declared by |
|
|
1463
|
+
| ------- | ------------------- | ------ | ---- | -------------------------------------------------------- |
|
|
1464
|
+
| Compact | `variant="compact"` | 32px | 13px | `--control-height-compact`/`--control-font-size-compact` |
|
|
1465
|
+
| Normal | — (the default) | 40px | 14px | `--control-height-normal`/`--control-font-size-normal` |
|
|
1466
|
+
| Large | `variant="large"` | 48px | 16px | `--control-height-large`/`--control-font-size-large` |
|
|
1467
|
+
|
|
1468
|
+
- **What follows it.** Fields and buttons (`Button`, `Textbox`, `Dropdown`/`Select`, `Combobox`/`TimeZoneSelect`,
|
|
1469
|
+
`DateField`/`DatePicker`) take the height; items and rows (menu items, dropdown and combobox options, tabs,
|
|
1470
|
+
accordion headers, calendar days, a picker's times and presets) take it as a minimum; `Textarea` takes the text
|
|
1471
|
+
size; `Checkbox`, `RadioButton`, `Switch` and `Slider` scale whole; `Progress` changes its thickness.
|
|
1472
|
+
`Popover`, `Dialog`, `Menu`, `Tabs`, `Accordion`, `Collapsible`, `RadioGroup` and `Calendar` take the variant and
|
|
1473
|
+
pass it to everything inside. A `DataGrid` is drawn compact.
|
|
1474
|
+
- **A variant sizes the subtree**: `<Menu variant="compact">` makes every item compact, and `<DatePicker variant="large">`
|
|
1475
|
+
its calendar too (the picker hands its size to the panel, which is a sibling). `variant="normal"` restores the
|
|
1476
|
+
default inside a sized subtree.
|
|
1477
|
+
- **The project's scale is declared once**, on the app's root:
|
|
1478
|
+
|
|
1479
|
+
```tsx
|
|
1480
|
+
<Box vars={Box.sizes({ compact: 8, normal: 9, large: { height: 11, fontSize: 15 } })}>{app}</Box>
|
|
1481
|
+
```
|
|
1482
|
+
|
|
1483
|
+
A number is the ÷4 scale for a height and ÷16 for a text size; a string is CSS. `Box.sizes({ size: 'compact' })`
|
|
1484
|
+
draws a whole subtree at that size.
|
|
1485
|
+
|
|
1486
|
+
- **Never size one control by hand.** `height={9}` on one button wins as any prop does, which is how a row ends up
|
|
1487
|
+
with three heights. Padding no longer sizes a control: `py` changes nothing, `height="auto"` hands it back.
|
|
1488
|
+
- **Your own control joins** with `height="control"` (`minHeight` where it wraps) and `fontSize="control"`;
|
|
1489
|
+
`'control-compact'`/`'control-normal'`/`'control-large'` name one size outright.
|
|
1490
|
+
- `variant="square"` on a `Button` is an icon button as wide as it is tall, at whichever size.
|
|
1491
|
+
|
|
1456
1492
|
## Form controls: Checkbox, Switch, RadioGroup
|
|
1457
1493
|
|
|
1458
1494
|
All three render **real native inputs**, so focus, the checked state, the disabled state and form
|
|
@@ -1572,7 +1608,8 @@ positioning only and light-dismisses nothing.
|
|
|
1572
1608
|
| `offset` | `2` | The gap, on the ÷4 scale — 8px. |
|
|
1573
1609
|
| `flip` | `true` | Whether a side with no room is swapped for its opposite. |
|
|
1574
1610
|
| `matchWidth` | `false` | Whether the panel is at least as wide as its trigger. |
|
|
1575
|
-
| `autoFocus` | `true` | Whether opening moves focus
|
|
1611
|
+
| `autoFocus` | `true` | Whether opening moves focus onto the panel's first control (the panel if none). |
|
|
1612
|
+
| `initialFocus` | — | A ref to land on instead. React's `autoFocus` writes no attribute, so use this. |
|
|
1576
1613
|
|
|
1577
1614
|
What the component supplies, because the `popover` attribute supplies none of it: `role="dialog"`, the
|
|
1578
1615
|
name, and `aria-expanded`/`aria-haspopup="dialog"`/`aria-controls` on the trigger. What the **platform**
|
|
@@ -2398,7 +2435,7 @@ that was never on screen.
|
|
|
2398
2435
|
declared — it inherits the theme, the custom properties and the direction around it. `manual` rather
|
|
2399
2436
|
than `auto` because a stack of messages owns no dismissal: a press outside has to reach the page. The
|
|
2400
2437
|
viewport takes **no pointer events at all** and the toasts take them back, or a corner-sized fixed
|
|
2401
|
-
strip would swallow every press in its gaps.
|
|
2438
|
+
strip would swallow every press in its gaps. **While a modal `Dialog` is open the stack moves inside it**, shown after it — everything outside an open modal is inert, so a toast left on the page would sit under the backdrop, unpressable and silent — and moves back out when the dialog closes; Escape on a toast there dismisses the toast, not the dialog.
|
|
2402
2439
|
3. **Four things stop the clock**: the pointer over the stack, focus inside it, a background tab, and a
|
|
2403
2440
|
dismissal. A paused timer resumes where it left off rather than restarting. WCAG 2.2.1, and the only
|
|
2404
2441
|
reason a toast is allowed to carry a control at all.
|
package/behavior.cjs
CHANGED
|
@@ -1 +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)||(s||(d.current=n),l(n),f(n,t))},[f,d,s])]}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.
|
|
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)||(s||(d.current=n),l(n),f(n,t))},[f,d,s])]}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.p(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.g(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.h(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._(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._(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,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as e, g as t, h as n, p as r, t as i } from "./platform.mjs";
|
|
2
2
|
import { n as a } from "./effects.mjs";
|
|
3
3
|
import { t as o } from "./keyboard.mjs";
|
|
4
4
|
import { useCallback as s, useEffect as c, useRef as l, useState as u } from "react";
|
|
@@ -37,21 +37,21 @@ function g() {
|
|
|
37
37
|
let e = m.filter((e) => !m.some((t) => t !== e && h(e, t)));
|
|
38
38
|
return e[e.length - 1];
|
|
39
39
|
}
|
|
40
|
-
function _(
|
|
41
|
-
let { enabled: n = !0, onDismiss: i, inside: o, escapeKey: s = !0, outsidePointer: c = !0 } =
|
|
40
|
+
function _(e) {
|
|
41
|
+
let { enabled: n = !0, onDismiss: i, inside: o, escapeKey: s = !0, outsidePointer: c = !0 } = e, l = d(o), u = f(i);
|
|
42
42
|
a(() => {
|
|
43
43
|
if (!n) return;
|
|
44
|
-
let
|
|
45
|
-
m.push(
|
|
44
|
+
let e = { elements: () => (l.current ?? []).map((e) => r(e)).filter((e) => e !== null) };
|
|
45
|
+
m.push(e);
|
|
46
46
|
let i = new AbortController(), a = (e, t) => document.addEventListener(e, t, { signal: i.signal });
|
|
47
|
-
return s && a("keydown", (
|
|
48
|
-
|
|
47
|
+
return s && a("keydown", (t) => {
|
|
48
|
+
t.key !== "Escape" || t.defaultPrevented || g() === e && u("escape", t);
|
|
49
49
|
}), c && a("pointerdown", (e) => {
|
|
50
|
-
|
|
50
|
+
t(e, l.current ?? []) || u("outside-pointer", e);
|
|
51
51
|
}), () => {
|
|
52
52
|
i.abort();
|
|
53
|
-
let
|
|
54
|
-
|
|
53
|
+
let t = m.indexOf(e);
|
|
54
|
+
t !== -1 && m.splice(t, 1);
|
|
55
55
|
};
|
|
56
56
|
}, [
|
|
57
57
|
n,
|
|
@@ -68,17 +68,17 @@ function v() {
|
|
|
68
68
|
return e && e !== document.body ? e : null;
|
|
69
69
|
}
|
|
70
70
|
function y(e = {}) {
|
|
71
|
-
let { enabled:
|
|
72
|
-
|
|
71
|
+
let { enabled: t = !0, returnTo: r, preventScroll: i } = e, [a, o] = u(null), [s, l] = u(!1);
|
|
72
|
+
t !== s && (l(t), t && o(v()));
|
|
73
73
|
let d = f(() => {
|
|
74
|
-
(
|
|
74
|
+
(n(r) ?? a)?.focus({ preventScroll: i });
|
|
75
75
|
});
|
|
76
76
|
return c(() => {
|
|
77
|
-
if (
|
|
77
|
+
if (t) return () => {
|
|
78
78
|
let e = document.activeElement;
|
|
79
79
|
(!e || e === document.body || !document.contains(e)) && d();
|
|
80
80
|
};
|
|
81
|
-
}, [
|
|
81
|
+
}, [t, d]), { returnFocus: d };
|
|
82
82
|
}
|
|
83
83
|
//#endregion
|
|
84
84
|
//#region src/react/a11y/useRovingFocus.ts
|
|
@@ -101,12 +101,12 @@ function S(e, t, n, r, i) {
|
|
|
101
101
|
function C(e, t, n) {
|
|
102
102
|
return S(e === 1 ? -1 : t, e, t, !1, n);
|
|
103
103
|
}
|
|
104
|
-
function w(
|
|
105
|
-
let { count:
|
|
104
|
+
function w(t) {
|
|
105
|
+
let { count: n, columns: r, columnIndexOf: i, 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 } = t, [D, O] = p({
|
|
106
106
|
value: g,
|
|
107
107
|
defaultValue: _,
|
|
108
108
|
onChange: v
|
|
109
|
-
}), k = Math.min(D,
|
|
109
|
+
}), k = Math.min(D, n - 1), A = r !== void 0, j = s((e) => typeof r == "function" ? r(e) : r ?? 0, [r]), M = s((e, t) => {
|
|
110
110
|
let n = j(e);
|
|
111
111
|
if (!i) return x(t, n - 1);
|
|
112
112
|
if (n <= 0) return -1;
|
|
@@ -127,8 +127,8 @@ function w(e) {
|
|
|
127
127
|
]), G = d({
|
|
128
128
|
row: k,
|
|
129
129
|
column: F
|
|
130
|
-
}), K = d(N), q = d(f), J = d(j), Y = d(M), X = d(i), Z = s((e,
|
|
131
|
-
let i = x(e,
|
|
130
|
+
}), K = d(N), q = d(f), J = d(j), Y = d(M), X = d(i), Z = s((e, t, r) => {
|
|
131
|
+
let i = x(e, n - 1), a = Math.max(0, t), o = i < 0 ? -1 : Y.current(i, a), s = G.current;
|
|
132
132
|
return i === s.row && o === s.column ? s : (O(i, r), P(a), q.current?.({
|
|
133
133
|
row: i,
|
|
134
134
|
column: o
|
|
@@ -140,14 +140,14 @@ function w(e) {
|
|
|
140
140
|
G,
|
|
141
141
|
Y,
|
|
142
142
|
q,
|
|
143
|
-
|
|
143
|
+
n,
|
|
144
144
|
O
|
|
145
|
-
]), Q = s((e,
|
|
146
|
-
let i = x(e,
|
|
145
|
+
]), Q = s((e, t, r) => {
|
|
146
|
+
let i = x(e, n - 1), a = i < 0 ? -1 : x(Math.max(0, t), J.current(i) - 1);
|
|
147
147
|
return Z(i, a < 0 ? 0 : X.current?.(i, a) ?? a, r);
|
|
148
148
|
}, [
|
|
149
149
|
X,
|
|
150
|
-
|
|
150
|
+
n,
|
|
151
151
|
Z,
|
|
152
152
|
J
|
|
153
153
|
]), ee = s((e, t) => {
|
|
@@ -175,35 +175,35 @@ function w(e) {
|
|
|
175
175
|
k,
|
|
176
176
|
T,
|
|
177
177
|
O
|
|
178
|
-
]), $ = s((
|
|
179
|
-
let { row: r, column: i } = G.current, o = (
|
|
180
|
-
|
|
181
|
-
let r = Q(
|
|
178
|
+
]), $ = s((t) => {
|
|
179
|
+
let { row: r, column: i } = G.current, o = (e, n) => {
|
|
180
|
+
t.preventDefault();
|
|
181
|
+
let r = Q(e, n, {
|
|
182
182
|
reason: "keyboard",
|
|
183
|
-
event:
|
|
183
|
+
event: t
|
|
184
184
|
});
|
|
185
185
|
T && U(r.row, r.column);
|
|
186
|
-
}, s = (
|
|
187
|
-
|
|
188
|
-
let n = Z(
|
|
186
|
+
}, s = (e) => {
|
|
187
|
+
t.preventDefault();
|
|
188
|
+
let n = Z(e, K.current, {
|
|
189
189
|
reason: "keyboard",
|
|
190
|
-
event:
|
|
190
|
+
event: t
|
|
191
191
|
});
|
|
192
192
|
T && U(n.row, n.column);
|
|
193
|
-
}, c = 2 ** 53 - 1, l = () =>
|
|
194
|
-
switch (
|
|
193
|
+
}, c = 2 ** 53 - 1, l = () => e(t.currentTarget) ? -1 : 1;
|
|
194
|
+
switch (t.key) {
|
|
195
195
|
case "ArrowRight": return o(r, i + l());
|
|
196
196
|
case "ArrowLeft": return o(r, i - l());
|
|
197
197
|
case "ArrowDown": return s(r + 1);
|
|
198
198
|
case "ArrowUp": return s(r - 1);
|
|
199
|
-
case "Home": return
|
|
200
|
-
case "End": return
|
|
199
|
+
case "Home": return t.ctrlKey || t.metaKey ? o(0, 0) : o(r, 0);
|
|
200
|
+
case "End": return t.ctrlKey || t.metaKey ? o(n - 1, c) : o(r, c);
|
|
201
201
|
case "PageDown": return s(r + a);
|
|
202
202
|
case "PageUp": return s(r - a);
|
|
203
203
|
}
|
|
204
204
|
}, [
|
|
205
205
|
G,
|
|
206
|
-
|
|
206
|
+
n,
|
|
207
207
|
K,
|
|
208
208
|
U,
|
|
209
209
|
T,
|
|
@@ -216,51 +216,51 @@ function w(e) {
|
|
|
216
216
|
activeColumn: F,
|
|
217
217
|
setActiveIndex: O,
|
|
218
218
|
setActiveCell: Q,
|
|
219
|
-
onKeyDown: s((
|
|
220
|
-
if (
|
|
219
|
+
onKeyDown: s((t) => {
|
|
220
|
+
if (t.defaultPrevented) return;
|
|
221
221
|
if (A) {
|
|
222
|
-
$(
|
|
222
|
+
$(t);
|
|
223
223
|
return;
|
|
224
224
|
}
|
|
225
|
-
let r = m !== "horizontal", i = m !== "vertical", a = B.current, s = o.isOpen(a,
|
|
226
|
-
|
|
225
|
+
let r = m !== "horizontal", i = m !== "vertical", a = B.current, s = o.isOpen(a, t.timeStamp), c = (e, n) => {
|
|
226
|
+
e !== -1 && e !== k && (t.preventDefault(), O(e, {
|
|
227
227
|
reason: n,
|
|
228
|
-
event:
|
|
229
|
-
}), T && V(
|
|
228
|
+
event: t
|
|
229
|
+
}), T && V(e));
|
|
230
230
|
};
|
|
231
|
-
if (i && (
|
|
232
|
-
let r =
|
|
233
|
-
c(S(k, r ? 1 : -1,
|
|
231
|
+
if (i && (t.key === "ArrowRight" || t.key === "ArrowLeft")) {
|
|
232
|
+
let r = t.key === "ArrowRight" !== e(t.currentTarget);
|
|
233
|
+
c(S(k, r ? 1 : -1, n, h, y), "keyboard");
|
|
234
234
|
return;
|
|
235
235
|
}
|
|
236
|
-
if (
|
|
237
|
-
c(S(k, 1,
|
|
236
|
+
if (t.key === "ArrowDown" && r) {
|
|
237
|
+
c(S(k, 1, n, h, y), "keyboard");
|
|
238
238
|
return;
|
|
239
239
|
}
|
|
240
|
-
if (
|
|
241
|
-
c(S(k, -1,
|
|
240
|
+
if (t.key === "ArrowUp" && r) {
|
|
241
|
+
c(S(k, -1, n, h, y), "keyboard");
|
|
242
242
|
return;
|
|
243
243
|
}
|
|
244
|
-
if (
|
|
245
|
-
c(C(1,
|
|
244
|
+
if (t.key === "Home") {
|
|
245
|
+
c(C(1, n, y), "keyboard");
|
|
246
246
|
return;
|
|
247
247
|
}
|
|
248
|
-
if (
|
|
249
|
-
c(C(-1,
|
|
248
|
+
if (t.key === "End") {
|
|
249
|
+
c(C(-1, n, y), "keyboard");
|
|
250
250
|
return;
|
|
251
251
|
}
|
|
252
|
-
if (
|
|
252
|
+
if (t.key === "Enter" || t.key === " " && !(s && w)) {
|
|
253
253
|
if (!E || k === -1) return;
|
|
254
|
-
|
|
254
|
+
t.preventDefault(), E(k, t);
|
|
255
255
|
return;
|
|
256
256
|
}
|
|
257
|
-
if (w && o.isPrintable(
|
|
258
|
-
let
|
|
259
|
-
c(o.target(
|
|
257
|
+
if (w && o.isPrintable(t)) {
|
|
258
|
+
let e = o.push(a, t.key, t.timeStamp);
|
|
259
|
+
c(o.target(e, k, n, w, y), "typeahead");
|
|
260
260
|
}
|
|
261
261
|
}, [
|
|
262
262
|
k,
|
|
263
|
-
|
|
263
|
+
n,
|
|
264
264
|
V,
|
|
265
265
|
T,
|
|
266
266
|
y,
|
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"),r=require("./interactions.cjs");let i=require("react");i=e.t(i,1);let a=require("@box-kite/core");function o({tag:e,tagProps:t,render:n}){let[r,a]=(0,i.useState)(!1);return i.default.createElement(e,{...t,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1)},n({isHover:r}))}function s(e,r){let{tag:a=`div`,children:s}=e,{classNames:c,styleElements:l}=n.i(e,a===`svg`),u=t.d(e,c);r&&(u.ref=r);let d=typeof s==`function`?i.default.createElement(o,{tag:a,tagProps:u,render:s}):i.default.createElement(a,u,s);return l?i.default.createElement(i.default.Fragment,null,l,d):d}var c=t.f(s,`Box`);c.extend=a.BoxExtends.extend,c.components=a.BoxExtends.components,c.palette=a.BoxExtends.palette,c.createComponents=a.BoxExtends.createComponents,c.Components=n.o,c.keyframes=a.BoxExtends.keyframes,c.spring=a.Springs.spring,c.Theme=n.n,c.useTheme=n.n.useTheme,c.useDesign=n.n.useDesign,c.getVariableValue=e=>(0,a.getDefaultEngine)().getVariableValue(e),c.configure=n.r.configure,c.viewTransition=a.startViewTransition,c.onInteraction=r.i,c.reportInteraction=r.r,c.flushInteractions=r.n;function l(e,r){return t.p(n.i(e,r?.svg===!0),e.className)}exports.default=c,exports.useBoxElement=s,exports.useClassNames=l,exports.useVisibility=n.a;
|
|
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"),r=require("./interactions.cjs");let i=require("react");i=e.t(i,1);let a=require("@box-kite/core");function o({tag:e,tagProps:t,render:n}){let[r,a]=(0,i.useState)(!1);return i.default.createElement(e,{...t,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1)},n({isHover:r}))}function s(e,r){let{tag:a=`div`,children:s}=e,{classNames:c,styleElements:l}=n.i(e,a===`svg`),u=t.d(e,c);r&&(u.ref=r);let d=typeof s==`function`?i.default.createElement(o,{tag:a,tagProps:u,render:s}):i.default.createElement(a,u,s);return l?i.default.createElement(i.default.Fragment,null,l,d):d}var c=t.f(s,`Box`);c.extend=a.BoxExtends.extend,c.components=a.BoxExtends.components,c.palette=a.BoxExtends.palette,c.sizes=a.BoxExtends.sizes,c.createComponents=a.BoxExtends.createComponents,c.Components=n.o,c.keyframes=a.BoxExtends.keyframes,c.spring=a.Springs.spring,c.Theme=n.n,c.useTheme=n.n.useTheme,c.useDesign=n.n.useDesign,c.getVariableValue=e=>(0,a.getDefaultEngine)().getVariableValue(e),c.configure=n.r.configure,c.viewTransition=a.startViewTransition,c.onInteraction=r.i,c.reportInteraction=r.r,c.flushInteractions=r.n;function l(e,r){return t.p(n.i(e,r?.svg===!0),e.className)}exports.default=c,exports.useBoxElement=s,exports.useClassNames=l,exports.useVisibility=n.a;
|
package/box.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ interface BoxType {
|
|
|
24
24
|
components: typeof BoxExtends.components;
|
|
25
25
|
/** The `vars` record that points the components' `accent` and `base` families at others, for an element and its subtree. */
|
|
26
26
|
palette: typeof BoxExtends.palette;
|
|
27
|
+
sizes: typeof BoxExtends.sizes;
|
|
27
28
|
/** A design for one subtree, registered nowhere: hand it to `<Box.Components value>` or `<Box.Theme components>`. */
|
|
28
29
|
createComponents: typeof BoxExtends.createComponents;
|
|
29
30
|
/** Every Box below resolves its `component` against this registry instead of the app's `Box.components()`. */
|
package/box.mjs
CHANGED
|
@@ -23,7 +23,7 @@ function v(t, n) {
|
|
|
23
23
|
return s ? d.createElement(d.Fragment, null, s, l) : l;
|
|
24
24
|
}
|
|
25
25
|
var y = t(v, "Box");
|
|
26
|
-
y.extend = p.extend, y.components = p.components, y.palette = p.palette, y.createComponents = p.createComponents, y.Components = o, y.keyframes = p.keyframes, y.spring = m.spring, y.Theme = a, y.useTheme = a.useTheme, y.useDesign = a.useDesign, y.getVariableValue = (e) => h().getVariableValue(e), y.configure = s.configure, y.viewTransition = g, y.onInteraction = c, y.reportInteraction = u, y.flushInteractions = l;
|
|
26
|
+
y.extend = p.extend, y.components = p.components, y.palette = p.palette, y.sizes = p.sizes, y.createComponents = p.createComponents, y.Components = o, y.keyframes = p.keyframes, y.spring = m.spring, y.Theme = a, y.useTheme = a.useTheme, y.useDesign = a.useDesign, y.getVariableValue = (e) => h().getVariableValue(e), y.configure = s.configure, y.viewTransition = g, y.onInteraction = c, y.reportInteraction = u, y.flushInteractions = l;
|
|
27
27
|
function b(e, t) {
|
|
28
28
|
return n(i(e, t?.svg === !0), e.className);
|
|
29
29
|
}
|