@box-kite/react 2.2.15 → 2.2.17
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 +1 -1
- package/.claude/skills/box-kite/SKILL.md +1 -1
- package/.claude/skills/box-kite/references/styling.md +1 -1
- package/.cursor/rules/box-kite.mdc +1 -1
- package/AGENTS.md +1 -1
- package/BOX_AI_CONTEXT.md +16 -0
- package/BOX_KITE_AI_CONTEXT.md +16 -0
- package/behavior.cjs +1 -1
- package/behavior.mjs +16 -16
- package/catalog.cjs +1 -1
- package/catalog.mjs +1 -1
- package/client.cjs +1 -1
- package/client.mjs +10 -10
- package/components/accordion.cjs +1 -1
- package/components/accordion.mjs +95 -91
- package/components/calendar.cjs +1 -1
- package/components/calendar.mjs +212 -210
- package/components/chart.cjs +1 -1
- package/components/chart.d.ts +8 -3
- package/components/chart.mjs +70 -65
- package/components/combobox.cjs +1 -1
- package/components/combobox.mjs +187 -186
- package/components/dashboard.cjs +1 -1
- package/components/dashboard.d.ts +1 -44
- package/components/dashboard.mjs +202 -201
- package/components/dataGrid/components/dataGridListLayout.d.ts +1 -1
- package/components/dataGrid/contracts/dataGridContract.d.ts +1 -1
- package/components/dataGrid/models/gridModel.d.ts +1 -1
- package/components/dataGrid.cjs +2 -2
- package/components/dataGrid.mjs +10 -10
- package/components/dateField.cjs +1 -1
- package/components/dateField.mjs +96 -96
- package/components/datePicker.cjs +1 -1
- package/components/datePicker.mjs +286 -285
- package/components/dialog.cjs +1 -1
- package/components/dialog.d.ts +2 -64
- package/components/dialog.mjs +131 -126
- package/components/form.cjs +1 -1
- package/components/form.d.ts +4 -3
- package/components/form.mjs +25 -22
- package/components/menu.cjs +1 -1
- package/components/menu.d.ts +2 -73
- package/components/menu.mjs +220 -215
- package/components/overlay.cjs +1 -1
- package/components/overlay.mjs +44 -43
- package/components/popover.cjs +1 -1
- package/components/popover.d.ts +1 -41
- package/components/popover.mjs +56 -51
- package/components/presence.cjs +1 -1
- package/components/presence.mjs +1 -1
- package/components/radioGroup.cjs +1 -1
- package/components/radioGroup.mjs +59 -55
- package/components/semantics.d.ts +29 -29
- package/components/slider.cjs +1 -1
- package/components/slider.d.ts +1 -55
- package/components/slider.mjs +92 -90
- package/components/sortableList.cjs +1 -1
- package/components/sortableList.mjs +149 -148
- package/components/swipeItem.cjs +1 -1
- package/components/swipeItem.mjs +100 -100
- package/components/tabs.cjs +1 -1
- package/components/tabs.mjs +135 -132
- package/components/toaster.cjs +1 -1
- package/components/toaster.d.ts +1 -37
- package/components/toaster.mjs +130 -128
- package/components/tooltip.cjs +1 -1
- package/components/tooltip.d.ts +1 -34
- package/components/tooltip.mjs +73 -69
- package/components/virtualList.cjs +1 -1
- package/components/virtualList.mjs +88 -87
- package/docs/props.md +2 -2
- package/interactionListening.cjs +1 -1
- package/interactionListening.mjs +3 -3
- package/layer.cjs +1 -1
- package/layer.mjs +1 -1
- package/motion.cjs +1 -1
- package/motion.mjs +30 -20
- package/package.json +41 -40
- package/placement.cjs +1 -1
- package/placement.mjs +1 -1
- package/platform.cjs +1 -1
- package/platform.mjs +17 -14
- package/react/animation/useHeldContent.d.ts +6 -0
- package/react/animation/usePresence.d.ts +4 -0
- package/react/componentsContext.d.ts +1 -1
- package/react-shared.cjs +1 -1
- package/react-shared.mjs +1 -1
- package/scrolling.cjs +1 -1
- package/scrolling.mjs +1 -1
- package/utils/chart/chartUtils.d.ts +3 -2
- package/utils/dashboard/dashboardUtils.d.ts +1 -1
- package/utils/dom/domUtils.d.ts +6 -0
- package/create/src/agents.d.ts +0 -22
- package/create/src/agents.test.d.ts +0 -1
- package/create/src/index.d.ts +0 -1
- package/create/src/options.d.ts +0 -31
- package/create/src/options.test.d.ts +0 -1
- package/create/src/packageManager.d.ts +0 -5
- package/create/src/project.d.ts +0 -27
- package/create/src/project.test.d.ts +0 -1
- package/create/templates/ts/designs/azure.d.ts +0 -5
- package/create/templates/ts/designs/ember.d.ts +0 -5
- package/create/templates/ts/designs/mono.d.ts +0 -5
- package/create/templates/ts/src/App.d.ts +0 -2
- package/create/templates/ts/src/design.d.ts +0 -5
- package/create/templates/ts/src/main.d.ts +0 -0
- package/mcp/src/data.d.ts +0 -90
- package/mcp/src/data.test.d.ts +0 -1
- package/mcp/src/engine.d.ts +0 -23
- package/mcp/src/index.d.ts +0 -1
- package/mcp/src/search.d.ts +0 -38
- package/mcp/src/search.test.d.ts +0 -1
- package/mcp/src/server.d.ts +0 -18
- package/mcp/src/server.test.d.ts +0 -1
- package/mcp/src/styles.d.ts +0 -27
- package/mcp/src/styles.test.d.ts +0 -1
- package/mcp/src/tools.d.ts +0 -18
- package/mcp/src/vocabulary.d.ts +0 -41
- package/registry/blocks/dashboard-shell/dashboard-shell.d.ts +0 -24
- package/registry/blocks/dashboard-shell/dashboard-stats.d.ts +0 -13
- package/registry/blocks/data-grid/invoice-rows.d.ts +0 -15
- package/registry/blocks/data-grid/invoices-grid.d.ts +0 -1
- package/registry/blocks/settings-form/settings-form.d.ts +0 -17
- package/registry/designs/store/address-form.d.ts +0 -11
- package/registry/designs/store/cart-items.d.ts +0 -10
- package/registry/designs/store/cart-page.d.ts +0 -4
- package/registry/designs/store/checkout-page.d.ts +0 -7
- package/registry/designs/store/credit-card-form.d.ts +0 -10
- package/registry/designs/store/form-field.d.ts +0 -19
- package/registry/designs/store/order-summary.d.ts +0 -18
- package/registry/designs/store/product-art.d.ts +0 -26
- package/registry/designs/store/product-card.d.ts +0 -11
- package/registry/designs/store/product-gallery.d.ts +0 -11
- package/registry/designs/store/product-grid.d.ts +0 -10
- package/registry/designs/store/product-page.d.ts +0 -5
- package/registry/designs/store/quantity-stepper.d.ts +0 -13
- package/registry/designs/store/shipping-method.d.ts +0 -14
- package/registry/designs/store/store-data.d.ts +0 -53
- package/registry/designs/store/store-design.d.ts +0 -63
- package/registry/designs/store/store-shell.d.ts +0 -12
- package/registry/designs/store/storefront-page.d.ts +0 -4
- package/registry/designs/store/variant-picker.d.ts +0 -15
- package/supabase/functions/collect/index.d.ts +0 -30
- package/supabase/functions/collect/index.test.d.ts +0 -1
|
@@ -13,7 +13,7 @@ globs: '**/*.{ts,tsx,jsx}'
|
|
|
13
13
|
6. **Spacing divider is 4**: `p={4}` → 16px (1rem)
|
|
14
14
|
7. **Border width and lineHeight are direct px**: `b={1}` → 1px. **borderRadius uses divider 4**: `borderRadius={2}` → 8px
|
|
15
15
|
8. **A gradient fill is a value, not an attribute**: `fill="url(#sky)"`, `stroke="var(--chart-1)"`, `clipPath="url(#frame)"` — so it can be themed and hovered. **A dashboard shape is `components/chart`**: `<Sparkline data={[…]}/>`, `<ProgressRing value={0.6}/>`, `<Gauge>`, `<MiniDonut>` — Box props, no chart library
|
|
16
|
-
9. **A CSS variable is a prop too**: `vars={{ 'color-revenue': 'sky-500' }}` declares `--color-revenue` on the element and everything inside it — the answer for markup this library does not render. **A third-party chart goes in `<ChartContainer series={['revenue', 'cost']}>`** (`components/chart`), which declares `--chart-1..6` in both themes and one `--color-<series>` per series, so `<Line stroke="var(--color-revenue)"/>` is all the chart ever says about colour
|
|
16
|
+
9. **A CSS variable is a prop too**: `vars={{ 'color-revenue': 'sky-500' }}` declares `--color-revenue` on the element and everything inside it — the answer for markup this library does not render. **A third-party chart goes in `<ChartContainer series={['revenue', 'cost']}>`** (`components/chart`), which declares `--chart-1..6` in both themes and one `--color-<series>` per series, so `<Line stroke="var(--color-revenue)"/>` is all the chart ever says about colour. A record names its own paints, as anything `fill` takes: `series={{ done: 'ui-primary', open: 'ui-primary/35' }}` works with a `Box.extend()` token too.
|
|
17
17
|
10. **SVG lengths have no divider and no unit**: `strokeWidth={2}` → `stroke-width: 2` (user units), same for `strokeDasharray`/`strokeDashoffset` and the geometry props `cx`/`cy`/`r`/`rx`/`ry`/`x`/`y`. `<Rect width={40} height={40}>` and `<Path d="M…">` take those as the SVG attributes they are — the Box props of those names mean something else
|
|
18
18
|
11. **HTML attributes go in `props` prop**: `<Link props={{ href: '/about' }}>` not `<Link href>`
|
|
19
19
|
12. **Size shortcuts**: `width="fit"` = 100%, `width="fit-screen"` = 100vw, `width="1/2"` = 50%
|
|
@@ -86,7 +86,7 @@ Detect the package manager from the lock file rather than asking:
|
|
|
86
86
|
6. **Spacing divider is 4**: `p={4}` → 16px (1rem)
|
|
87
87
|
7. **Border width and lineHeight are direct px**: `b={1}` → 1px. **borderRadius uses divider 4**: `borderRadius={2}` → 8px
|
|
88
88
|
8. **A gradient fill is a value, not an attribute**: `fill="url(#sky)"`, `stroke="var(--chart-1)"`, `clipPath="url(#frame)"` — so it can be themed and hovered. **A dashboard shape is `components/chart`**: `<Sparkline data={[…]}/>`, `<ProgressRing value={0.6}/>`, `<Gauge>`, `<MiniDonut>` — Box props, no chart library
|
|
89
|
-
9. **A CSS variable is a prop too**: `vars={{ 'color-revenue': 'sky-500' }}` declares `--color-revenue` on the element and everything inside it — the answer for markup this library does not render. **A third-party chart goes in `<ChartContainer series={['revenue', 'cost']}>`** (`components/chart`), which declares `--chart-1..6` in both themes and one `--color-<series>` per series, so `<Line stroke="var(--color-revenue)"/>` is all the chart ever says about colour
|
|
89
|
+
9. **A CSS variable is a prop too**: `vars={{ 'color-revenue': 'sky-500' }}` declares `--color-revenue` on the element and everything inside it — the answer for markup this library does not render. **A third-party chart goes in `<ChartContainer series={['revenue', 'cost']}>`** (`components/chart`), which declares `--chart-1..6` in both themes and one `--color-<series>` per series, so `<Line stroke="var(--color-revenue)"/>` is all the chart ever says about colour. A record names its own paints, as anything `fill` takes: `series={{ done: 'ui-primary', open: 'ui-primary/35' }}` works with a `Box.extend()` token too.
|
|
90
90
|
10. **SVG lengths have no divider and no unit**: `strokeWidth={2}` → `stroke-width: 2` (user units), same for `strokeDasharray`/`strokeDashoffset` and the geometry props `cx`/`cy`/`r`/`rx`/`ry`/`x`/`y`. `<Rect width={40} height={40}>` and `<Path d="M…">` take those as the SVG attributes they are — the Box props of those names mean something else
|
|
91
91
|
11. **HTML attributes go in `props` prop**: `<Link props={{ href: '/about' }}>` not `<Link href>`
|
|
92
92
|
12. **Size shortcuts**: `width="fit"` = 100%, `width="fit-screen"` = 100vw, `width="1/2"` = 50%
|
|
@@ -26,7 +26,7 @@ Every prop by category, the six kinds of nesting, and the theme system. Read thi
|
|
|
26
26
|
**Theming a chart library** — `<ChartContainer>` (same entry, server-safe): the bridge for Recharts and anything
|
|
27
27
|
else that takes a colour. It declares `--chart-1` … `--chart-6` in both themes plus one `--color-<series>` per
|
|
28
28
|
series, so the chart itself names no colour at all: `series={['revenue', 'cost']}` (the palette in order) or
|
|
29
|
-
`series={{ revenue: 'emerald-600' }}` (your own paint), then `<Line stroke="var(--color-revenue)" />` inside. A
|
|
29
|
+
`series={{ revenue: 'emerald-600', cost: 'ui-primary/35' }}` (your own paint — anything `fill` takes, a `Box.extend()` token included; a colour written as CSS goes in `vars` instead), then `<Line stroke="var(--color-revenue)" />` inside. A
|
|
30
30
|
series name becomes part of a custom-property name, so it has to be a CSS identifier — a dot-path `dataKey` is
|
|
31
31
|
skipped. Overriding a slot needs no prop of its own, because the container is a Box:
|
|
32
32
|
`vars={{ 'chart-1': 'teal-600' }}`, `theme={{ dark: { vars: { 'chart-1': 'teal-400' } } }}`, and any other name
|
|
@@ -21,7 +21,7 @@ This library is not in your training data: it was renamed at 1.0.0 (September 20
|
|
|
21
21
|
6. **Spacing divider is 4**: `p={4}` → 16px (1rem)
|
|
22
22
|
7. **Border width and lineHeight are direct px**: `b={1}` → 1px. **borderRadius uses divider 4**: `borderRadius={2}` → 8px
|
|
23
23
|
8. **A gradient fill is a value, not an attribute**: `fill="url(#sky)"`, `stroke="var(--chart-1)"`, `clipPath="url(#frame)"` — so it can be themed and hovered. **A dashboard shape is `components/chart`**: `<Sparkline data={[…]}/>`, `<ProgressRing value={0.6}/>`, `<Gauge>`, `<MiniDonut>` — Box props, no chart library
|
|
24
|
-
9. **A CSS variable is a prop too**: `vars={{ 'color-revenue': 'sky-500' }}` declares `--color-revenue` on the element and everything inside it — the answer for markup this library does not render. **A third-party chart goes in `<ChartContainer series={['revenue', 'cost']}>`** (`components/chart`), which declares `--chart-1..6` in both themes and one `--color-<series>` per series, so `<Line stroke="var(--color-revenue)"/>` is all the chart ever says about colour
|
|
24
|
+
9. **A CSS variable is a prop too**: `vars={{ 'color-revenue': 'sky-500' }}` declares `--color-revenue` on the element and everything inside it — the answer for markup this library does not render. **A third-party chart goes in `<ChartContainer series={['revenue', 'cost']}>`** (`components/chart`), which declares `--chart-1..6` in both themes and one `--color-<series>` per series, so `<Line stroke="var(--color-revenue)"/>` is all the chart ever says about colour. A record names its own paints, as anything `fill` takes: `series={{ done: 'ui-primary', open: 'ui-primary/35' }}` works with a `Box.extend()` token too.
|
|
25
25
|
10. **SVG lengths have no divider and no unit**: `strokeWidth={2}` → `stroke-width: 2` (user units), same for `strokeDasharray`/`strokeDashoffset` and the geometry props `cx`/`cy`/`r`/`rx`/`ry`/`x`/`y`. `<Rect width={40} height={40}>` and `<Path d="M…">` take those as the SVG attributes they are — the Box props of those names mean something else
|
|
26
26
|
11. **HTML attributes go in `props` prop**: `<Link props={{ href: '/about' }}>` not `<Link href>`
|
|
27
27
|
12. **Size shortcuts**: `width="fit"` = 100%, `width="fit-screen"` = 100vw, `width="1/2"` = 50%
|
package/AGENTS.md
CHANGED
|
@@ -53,7 +53,7 @@ Every value there is a prop, and every prop value becomes one class the engine i
|
|
|
53
53
|
6. **Spacing divider is 4**: `p={4}` → 16px (1rem)
|
|
54
54
|
7. **Border width and lineHeight are direct px**: `b={1}` → 1px. **borderRadius uses divider 4**: `borderRadius={2}` → 8px
|
|
55
55
|
8. **A gradient fill is a value, not an attribute**: `fill="url(#sky)"`, `stroke="var(--chart-1)"`, `clipPath="url(#frame)"` — so it can be themed and hovered. **A dashboard shape is `components/chart`**: `<Sparkline data={[…]}/>`, `<ProgressRing value={0.6}/>`, `<Gauge>`, `<MiniDonut>` — Box props, no chart library
|
|
56
|
-
9. **A CSS variable is a prop too**: `vars={{ 'color-revenue': 'sky-500' }}` declares `--color-revenue` on the element and everything inside it — the answer for markup this library does not render. **A third-party chart goes in `<ChartContainer series={['revenue', 'cost']}>`** (`components/chart`), which declares `--chart-1..6` in both themes and one `--color-<series>` per series, so `<Line stroke="var(--color-revenue)"/>` is all the chart ever says about colour
|
|
56
|
+
9. **A CSS variable is a prop too**: `vars={{ 'color-revenue': 'sky-500' }}` declares `--color-revenue` on the element and everything inside it — the answer for markup this library does not render. **A third-party chart goes in `<ChartContainer series={['revenue', 'cost']}>`** (`components/chart`), which declares `--chart-1..6` in both themes and one `--color-<series>` per series, so `<Line stroke="var(--color-revenue)"/>` is all the chart ever says about colour. A record names its own paints, as anything `fill` takes: `series={{ done: 'ui-primary', open: 'ui-primary/35' }}` works with a `Box.extend()` token too.
|
|
57
57
|
10. **SVG lengths have no divider and no unit**: `strokeWidth={2}` → `stroke-width: 2` (user units), same for `strokeDasharray`/`strokeDashoffset` and the geometry props `cx`/`cy`/`r`/`rx`/`ry`/`x`/`y`. `<Rect width={40} height={40}>` and `<Path d="M…">` take those as the SVG attributes they are — the Box props of those names mean something else
|
|
58
58
|
11. **HTML attributes go in `props` prop**: `<Link props={{ href: '/about' }}>` not `<Link href>`
|
|
59
59
|
12. **Size shortcuts**: `width="fit"` = 100%, `width="fit-screen"` = 100vw, `width="1/2"` = 50%
|
package/BOX_AI_CONTEXT.md
CHANGED
|
@@ -2575,6 +2575,22 @@ import { Area, AreaChart, CartesianGrid, ResponsiveContainer, XAxis, YAxis } fro
|
|
|
2575
2575
|
| -------- | ---------------------------------------------------------------------------------------------------------- |
|
|
2576
2576
|
| `series` | `['revenue', 'cost']` takes the palette in order, or `{ revenue: 'emerald-600' }` names a paint per series |
|
|
2577
2577
|
|
|
2578
|
+
A paint is **anything `fill` takes**, and is resolved the way `fill` resolves it: a palette token, one with an
|
|
2579
|
+
opacity (`'emerald-600/40'`), a token of the app's own from `Box.extend({ variables })` with or without one,
|
|
2580
|
+
or a `var(--…)`/`url(#…)` reference. An app token is the usual case in a real dashboard:
|
|
2581
|
+
|
|
2582
|
+
```tsx
|
|
2583
|
+
Box.extend({ 'ui-primary': 'oklch(55% .2 260)' }, {}, {});
|
|
2584
|
+
|
|
2585
|
+
<ChartContainer series={{ completed: 'ui-primary', started: 'ui-primary/35' }}>
|
|
2586
|
+
{/* --color-completed: var(--ui-primary), --color-started: color-mix(in oklab, var(--ui-primary) 35%, transparent) */}
|
|
2587
|
+
</ChartContainer>;
|
|
2588
|
+
```
|
|
2589
|
+
|
|
2590
|
+
A value `fill` refuses (`'tael-500'`) declares nothing rather than an invalid colour, and says so in
|
|
2591
|
+
development with the nearest token. A colour written as CSS is not a series paint — declare it yourself,
|
|
2592
|
+
`vars={{ 'color-completed': 'hsl(var(--primary))' }}`, which the container merges over the series.
|
|
2593
|
+
|
|
2578
2594
|
Everything else is a Box prop, which is the point:
|
|
2579
2595
|
|
|
2580
2596
|
- It always declares `--chart-1` … `--chart-6` (the six `MiniDonut` cycles through) and redeclares
|
package/BOX_KITE_AI_CONTEXT.md
CHANGED
|
@@ -2575,6 +2575,22 @@ import { Area, AreaChart, CartesianGrid, ResponsiveContainer, XAxis, YAxis } fro
|
|
|
2575
2575
|
| -------- | ---------------------------------------------------------------------------------------------------------- |
|
|
2576
2576
|
| `series` | `['revenue', 'cost']` takes the palette in order, or `{ revenue: 'emerald-600' }` names a paint per series |
|
|
2577
2577
|
|
|
2578
|
+
A paint is **anything `fill` takes**, and is resolved the way `fill` resolves it: a palette token, one with an
|
|
2579
|
+
opacity (`'emerald-600/40'`), a token of the app's own from `Box.extend({ variables })` with or without one,
|
|
2580
|
+
or a `var(--…)`/`url(#…)` reference. An app token is the usual case in a real dashboard:
|
|
2581
|
+
|
|
2582
|
+
```tsx
|
|
2583
|
+
Box.extend({ 'ui-primary': 'oklch(55% .2 260)' }, {}, {});
|
|
2584
|
+
|
|
2585
|
+
<ChartContainer series={{ completed: 'ui-primary', started: 'ui-primary/35' }}>
|
|
2586
|
+
{/* --color-completed: var(--ui-primary), --color-started: color-mix(in oklab, var(--ui-primary) 35%, transparent) */}
|
|
2587
|
+
</ChartContainer>;
|
|
2588
|
+
```
|
|
2589
|
+
|
|
2590
|
+
A value `fill` refuses (`'tael-500'`) declares nothing rather than an invalid colour, and says so in
|
|
2591
|
+
development with the nearest token. A colour written as CSS is not a series paint — declare it yourself,
|
|
2592
|
+
`vars={{ 'color-completed': 'hsl(var(--primary))' }}`, which the container merges over the series.
|
|
2593
|
+
|
|
2578
2594
|
Everything else is a Box prop, which is the point:
|
|
2579
2595
|
|
|
2580
2596
|
- It always declares `--chart-1` … `--chart-6` (the six `MiniDonut` cycles through) and redeclares
|
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.d(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.p(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.f(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.m(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.m(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 { d as e, f as t,
|
|
1
|
+
import { d as e, f as t, m 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:
|
|
40
|
+
function _(t) {
|
|
41
|
+
let { enabled: n = !0, onDismiss: i, inside: o, escapeKey: s = !0, outsidePointer: c = !0 } = t, l = d(o), u = f(i);
|
|
42
42
|
a(() => {
|
|
43
43
|
if (!n) return;
|
|
44
|
-
let
|
|
45
|
-
m.push(
|
|
46
|
-
let
|
|
47
|
-
return s && a("keydown", (
|
|
48
|
-
|
|
44
|
+
let t = { elements: () => (l.current ?? []).map((t) => e(t)).filter((e) => e !== null) };
|
|
45
|
+
m.push(t);
|
|
46
|
+
let i = new AbortController(), a = (e, t) => document.addEventListener(e, t, { signal: i.signal });
|
|
47
|
+
return s && a("keydown", (e) => {
|
|
48
|
+
e.key !== "Escape" || e.defaultPrevented || g() === t && u("escape", e);
|
|
49
49
|
}), c && a("pointerdown", (e) => {
|
|
50
|
-
|
|
50
|
+
r(e, l.current ?? []) || u("outside-pointer", e);
|
|
51
51
|
}), () => {
|
|
52
|
-
|
|
53
|
-
let
|
|
54
|
-
|
|
52
|
+
i.abort();
|
|
53
|
+
let e = m.indexOf(t);
|
|
54
|
+
e !== -1 && m.splice(e, 1);
|
|
55
55
|
};
|
|
56
56
|
}, [
|
|
57
57
|
n,
|
|
@@ -64,14 +64,14 @@ function _(e) {
|
|
|
64
64
|
//#endregion
|
|
65
65
|
//#region src/react/a11y/useFocusReturn.ts
|
|
66
66
|
function v() {
|
|
67
|
-
let e =
|
|
67
|
+
let e = i()?.activeElement;
|
|
68
68
|
return e && e !== document.body ? e : null;
|
|
69
69
|
}
|
|
70
|
-
function y(
|
|
71
|
-
let { enabled: n = !0, returnTo: r, preventScroll: i } =
|
|
70
|
+
function y(e = {}) {
|
|
71
|
+
let { enabled: n = !0, returnTo: r, preventScroll: i } = e, [a, o] = u(null), [s, l] = u(!1);
|
|
72
72
|
n !== s && (l(n), n && o(v()));
|
|
73
73
|
let d = f(() => {
|
|
74
|
-
(
|
|
74
|
+
(t(r) ?? a)?.focus({ preventScroll: i });
|
|
75
75
|
});
|
|
76
76
|
return c(() => {
|
|
77
77
|
if (n) return () => {
|