@box-kite/react 2.2.15 → 2.2.16
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 +177 -179
- package/components/dialog.cjs +1 -1
- package/components/dialog.d.ts +2 -64
- package/components/dialog.mjs +130 -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 +222 -218
- package/components/overlay.cjs +1 -1
- package/components/overlay.mjs +43 -43
- package/components/popover.cjs +1 -1
- package/components/popover.d.ts +1 -41
- package/components/popover.mjs +55 -51
- package/components/radioGroup.cjs +1 -1
- package/components/radioGroup.mjs +59 -55
- 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/interactionListening.cjs +1 -1
- package/interactionListening.mjs +3 -3
- package/layer.cjs +1 -1
- package/layer.mjs +1 -1
- package/package.json +31 -30
- package/placement.cjs +1 -1
- package/placement.mjs +1 -1
- package/platform.cjs +1 -1
- package/platform.mjs +17 -14
- 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
package/components/overlay.mjs
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { c as e,
|
|
3
|
-
import { t as
|
|
4
|
-
import { n as
|
|
5
|
-
import
|
|
6
|
-
import { t as
|
|
7
|
-
import { n as
|
|
8
|
-
import { forwardRef as
|
|
9
|
-
import { Fragment as
|
|
10
|
-
import { createPortal as
|
|
2
|
+
import { c as e, f as t, l as n, m as r } from "../platform.mjs";
|
|
3
|
+
import { t as i } from "../client.mjs";
|
|
4
|
+
import { n as a } from "../effects.mjs";
|
|
5
|
+
import o from "../box.mjs";
|
|
6
|
+
import { t as s } from "../placement.mjs";
|
|
7
|
+
import { n as c } from "../layer.mjs";
|
|
8
|
+
import { forwardRef as l, useCallback as u, useRef as d, useState as f } from "react";
|
|
9
|
+
import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
10
|
+
import { createPortal as g } from "react-dom";
|
|
11
11
|
//#region src/components/overlay.tsx
|
|
12
|
-
function
|
|
13
|
-
let { side:
|
|
14
|
-
side:
|
|
15
|
-
align:
|
|
16
|
-
offset:
|
|
17
|
-
flip:
|
|
18
|
-
matchWidth:
|
|
19
|
-
anchor:
|
|
20
|
-
trackSide: !!
|
|
12
|
+
function _(l, _) {
|
|
13
|
+
let { side: v = "bottom", align: y = "center", offset: b = 0, flip: x = !0, onSideChange: S, anchor: C, contentRef: w, matchWidth: T = !0, ...E } = l, [D, O] = f(null), [k, A] = f(!1), j = d(null), M = c(), N = d(null), P = i(!M), F = s({
|
|
14
|
+
side: v,
|
|
15
|
+
align: y,
|
|
16
|
+
offset: b,
|
|
17
|
+
flip: x,
|
|
18
|
+
matchWidth: T,
|
|
19
|
+
anchor: C ?? D,
|
|
20
|
+
trackSide: !!S
|
|
21
21
|
});
|
|
22
|
-
|
|
23
|
-
let t =
|
|
24
|
-
!
|
|
25
|
-
}),
|
|
26
|
-
if (
|
|
27
|
-
let e = t(
|
|
28
|
-
|
|
22
|
+
a(() => {
|
|
23
|
+
let t = N.current;
|
|
24
|
+
!M || !e() || !t || !t.isConnected || t.matches(":popover-open") || t.showPopover();
|
|
25
|
+
}), a(() => {
|
|
26
|
+
if (M) return;
|
|
27
|
+
let e = t(C) ?? D;
|
|
28
|
+
A(!!e && r(e));
|
|
29
29
|
}, [
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
]),
|
|
34
|
-
|
|
30
|
+
C,
|
|
31
|
+
D,
|
|
32
|
+
M
|
|
33
|
+
]), a(() => {
|
|
34
|
+
j.current !== F.side && (j.current = F.side, S?.(F.side));
|
|
35
35
|
});
|
|
36
|
-
let
|
|
37
|
-
|
|
38
|
-
}, [
|
|
39
|
-
...
|
|
40
|
-
ref:
|
|
36
|
+
let I = F.layerProps.ref, L = u((e) => {
|
|
37
|
+
I?.(e), N.current = e, n(_, e);
|
|
38
|
+
}, [I, _]), R = /* @__PURE__ */ m(o, {
|
|
39
|
+
...F.layerProps,
|
|
40
|
+
ref: L,
|
|
41
41
|
transition: "none",
|
|
42
|
-
props:
|
|
43
|
-
children: /* @__PURE__ */
|
|
44
|
-
ref:
|
|
45
|
-
...
|
|
42
|
+
props: M ? { popover: "manual" } : { dir: k ? "rtl" : "ltr" },
|
|
43
|
+
children: /* @__PURE__ */ m(o, {
|
|
44
|
+
ref: w,
|
|
45
|
+
...E
|
|
46
46
|
})
|
|
47
47
|
});
|
|
48
|
-
return /* @__PURE__ */
|
|
48
|
+
return /* @__PURE__ */ h(p, { children: [!C && /* @__PURE__ */ m(o, { ref: O }), M ? R : P && g(R, P)] });
|
|
49
49
|
}
|
|
50
|
-
var
|
|
51
|
-
|
|
50
|
+
var v = l(_);
|
|
51
|
+
v.displayName = "Overlay";
|
|
52
52
|
//#endregion
|
|
53
|
-
export {
|
|
53
|
+
export { v as default };
|
package/components/popover.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../
|
|
1
|
+
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../react-shared.cjs"),t=require("../platform.cjs"),n=require("../box.cjs"),r=require("../behavior.cjs"),i=require("../placement.cjs"),a=require("../layer.cjs"),o=require("./overlay.cjs");let s=require("react"),c=require("react/jsx-runtime");function l(e,l){let{trigger:u,children:d,open:f,defaultOpen:p=!1,onOpenChange:m,label:h,labelledBy:g,side:_=`bottom`,align:v=`center`,offset:y=2,flip:b=!0,matchWidth:x=!1,autoFocus:S=!0,props:C,...w}=e,T=r.a(e=>{!S||e.contains(document.activeElement)||e.focus()}),{platform:E,isOpen:D,id:O,trigger:k,triggerElement:A,setPanel:j}=a.t({haspopup:`dialog`,idPrefix:`popover`,id:w.id,interaction:{component:`popover`,type:`openChange`},open:f,defaultOpen:p,onOpenChange:m,onOpened:T}),M=i.t({side:_,align:v,offset:y,flip:b,matchWidth:x,anchor:A}),N=(0,s.useCallback)(e=>{j(e),t.l(l,e)},[j,l]),P={"aria-label":h,"aria-labelledby":g},F=w;return E?(0,c.jsxs)(c.Fragment,{children:[u(k),(0,c.jsx)(n.default,{ref:N,component:`popover`,...F,variant:[F.variant,{topLayer:!0}],...M.layerProps,id:O,props:{popover:`auto`,role:`dialog`,...P,tabIndex:-1,...C},children:d})]}):(0,c.jsxs)(c.Fragment,{children:[u(k),D&&(0,c.jsx)(o.default,{contentRef:N,anchor:A,side:_,align:v,offset:y,flip:b,matchWidth:x,component:`popover`,...F,id:O,props:{role:`dialog`,...P,tabIndex:-1,...C},children:d})]})}var u=e.f(l,`Popover`);exports.default=u;
|
package/components/popover.d.ts
CHANGED
|
@@ -56,45 +56,5 @@ interface Props<TKey extends keyof ComponentsAndVariants> extends PopoverBoxProp
|
|
|
56
56
|
*/
|
|
57
57
|
autoFocus?: boolean;
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
* A panel anchored to a trigger, on the platform's own Popover API: the top layer, light dismiss and
|
|
61
|
-
* focus return are the browser's, and the position is CSS anchor positioning.
|
|
62
|
-
*
|
|
63
|
-
* ```tsx
|
|
64
|
-
* <Popover label="Filters" trigger={(t) => <Button {...t}>Filters</Button>}>
|
|
65
|
-
* <Checkbox label="Only mine" />
|
|
66
|
-
* </Popover>
|
|
67
|
-
* ```
|
|
68
|
-
*
|
|
69
|
-
* **There is no portal.** A top-layer element paints above every stacking context and outside every
|
|
70
|
-
* clipped ancestor, which is the whole class of bug a portal exists to work around — and because the
|
|
71
|
-
* panel stays where it was declared in the DOM, it inherits the theme, the custom properties and the text
|
|
72
|
-
* direction around it, and the tab order runs trigger → panel with nothing to arrange. (Measured against a
|
|
73
|
-
* `z-index: 9999` sibling, a `transform`ed ancestor and an `overflow: hidden` one.)
|
|
74
|
-
*
|
|
75
|
-
* **The panel is always rendered**, and closed means `display: none` from the UA stylesheet. That is what
|
|
76
|
-
* lets the browser own show and hide — and what makes the exit a plain CSS transition rather than a
|
|
77
|
-
* `<Presence>`, since nothing unmounts. Content that is expensive to render should be gated by the
|
|
78
|
-
* consumer: `{open && <Heavy />}`.
|
|
79
|
-
*
|
|
80
|
-
* **The panel keeps the side it chose when it opened.** Chrome re-evaluates `position-try-fallbacks` on
|
|
81
|
-
* scroll for an ordinary positioned element and never for one in the top layer (measured in 152), so a
|
|
82
|
-
* panel left open while the page scrolls does not flip when its side runs out of room. Every open picks
|
|
83
|
-
* the right side; it is only a scroll *while* open that this affects. See `Overlay`, which shares it.
|
|
84
|
-
*
|
|
85
|
-
* Where the browser has no Popover API the panel is an `Overlay` — a portal — with `useDismiss` and
|
|
86
|
-
* `useFocusReturn` supplying what the platform otherwise would.
|
|
87
|
-
*
|
|
88
|
-
* @a11y `role="dialog"` on the panel, named by `label` or `labelledBy`; the popover attribute supplies no
|
|
89
|
-
* role at all, and a panel with none is announced as a group of orphaned content.
|
|
90
|
-
* @a11y The trigger carries `aria-expanded`, `aria-haspopup="dialog"` and `aria-controls`, so the control
|
|
91
|
-
* says what it operates and what state it is in.
|
|
92
|
-
* @a11y Focus moves into the panel on open and back to the trigger on close. Nothing is trapped: this is a
|
|
93
|
-
* non-modal dialog, so Tab leaves it, and the panel follows the trigger in the DOM either way.
|
|
94
|
-
* @keyboard Enter, Space — On the trigger, toggles the panel.
|
|
95
|
-
* @keyboard Escape — Closes it and returns focus to the trigger, from anywhere inside.
|
|
96
|
-
* @keyboard Tab — Moves into the panel from the trigger, and out of the panel to whatever follows it.
|
|
97
|
-
*/
|
|
98
|
-
declare function PopoverImpl<TKey extends keyof ComponentsAndVariants = 'popover'>(props: Props<TKey>): import("react").JSX.Element;
|
|
99
|
-
declare const Popover: typeof PopoverImpl;
|
|
59
|
+
declare const Popover: <TKey extends keyof ComponentsAndVariants = "popover">(props: Props<TKey>) => React.ReactNode;
|
|
100
60
|
export default Popover;
|
package/components/popover.mjs
CHANGED
|
@@ -1,73 +1,77 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import e from "../
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import i from "
|
|
7
|
-
import {
|
|
2
|
+
import { f as e } from "../react-shared.mjs";
|
|
3
|
+
import { l as t } from "../platform.mjs";
|
|
4
|
+
import n from "../box.mjs";
|
|
5
|
+
import { a as r } from "../behavior.mjs";
|
|
6
|
+
import { t as i } from "../placement.mjs";
|
|
7
|
+
import { t as a } from "../layer.mjs";
|
|
8
|
+
import o from "./overlay.mjs";
|
|
9
|
+
import { useCallback as s } from "react";
|
|
10
|
+
import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
8
11
|
//#region src/components/popover.tsx
|
|
9
|
-
function
|
|
10
|
-
let { trigger:
|
|
11
|
-
!
|
|
12
|
-
}), { platform:
|
|
12
|
+
function d(e, d) {
|
|
13
|
+
let { trigger: f, children: p, open: m, defaultOpen: h = !1, onOpenChange: g, label: _, labelledBy: v, side: y = "bottom", align: b = "center", offset: x = 2, flip: S = !0, matchWidth: C = !1, autoFocus: w = !0, props: T, ...E } = e, D = r((e) => {
|
|
14
|
+
!w || e.contains(document.activeElement) || e.focus();
|
|
15
|
+
}), { platform: O, isOpen: k, id: A, trigger: j, triggerElement: M, setPanel: N } = a({
|
|
13
16
|
haspopup: "dialog",
|
|
14
17
|
idPrefix: "popover",
|
|
15
|
-
id:
|
|
18
|
+
id: E.id,
|
|
16
19
|
interaction: {
|
|
17
20
|
component: "popover",
|
|
18
21
|
type: "openChange"
|
|
19
22
|
},
|
|
20
|
-
open:
|
|
21
|
-
defaultOpen:
|
|
22
|
-
onOpenChange:
|
|
23
|
-
onOpened:
|
|
24
|
-
}),
|
|
25
|
-
side:
|
|
26
|
-
align:
|
|
27
|
-
offset:
|
|
28
|
-
flip:
|
|
29
|
-
matchWidth:
|
|
30
|
-
anchor:
|
|
31
|
-
}),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
23
|
+
open: m,
|
|
24
|
+
defaultOpen: h,
|
|
25
|
+
onOpenChange: g,
|
|
26
|
+
onOpened: D
|
|
27
|
+
}), P = i({
|
|
28
|
+
side: y,
|
|
29
|
+
align: b,
|
|
30
|
+
offset: x,
|
|
31
|
+
flip: S,
|
|
32
|
+
matchWidth: C,
|
|
33
|
+
anchor: M
|
|
34
|
+
}), F = s((e) => {
|
|
35
|
+
N(e), t(d, e);
|
|
36
|
+
}, [N, d]), I = {
|
|
37
|
+
"aria-label": _,
|
|
38
|
+
"aria-labelledby": v
|
|
39
|
+
}, L = E;
|
|
40
|
+
return O ? /* @__PURE__ */ u(c, { children: [f(j), /* @__PURE__ */ l(n, {
|
|
41
|
+
ref: F,
|
|
37
42
|
component: "popover",
|
|
38
|
-
...
|
|
39
|
-
variant: [
|
|
40
|
-
...
|
|
41
|
-
id:
|
|
43
|
+
...L,
|
|
44
|
+
variant: [L.variant, { topLayer: !0 }],
|
|
45
|
+
...P.layerProps,
|
|
46
|
+
id: A,
|
|
42
47
|
props: {
|
|
43
48
|
popover: "auto",
|
|
44
49
|
role: "dialog",
|
|
45
|
-
...
|
|
50
|
+
...I,
|
|
46
51
|
tabIndex: -1,
|
|
47
|
-
...
|
|
52
|
+
...T
|
|
48
53
|
},
|
|
49
|
-
children:
|
|
50
|
-
})] }) : /* @__PURE__ */
|
|
51
|
-
contentRef:
|
|
52
|
-
anchor:
|
|
53
|
-
side:
|
|
54
|
-
align:
|
|
55
|
-
offset:
|
|
56
|
-
flip:
|
|
57
|
-
matchWidth:
|
|
54
|
+
children: p
|
|
55
|
+
})] }) : /* @__PURE__ */ u(c, { children: [f(j), k && /* @__PURE__ */ l(o, {
|
|
56
|
+
contentRef: F,
|
|
57
|
+
anchor: M,
|
|
58
|
+
side: y,
|
|
59
|
+
align: b,
|
|
60
|
+
offset: x,
|
|
61
|
+
flip: S,
|
|
62
|
+
matchWidth: C,
|
|
58
63
|
component: "popover",
|
|
59
|
-
...
|
|
60
|
-
id:
|
|
64
|
+
...L,
|
|
65
|
+
id: A,
|
|
61
66
|
props: {
|
|
62
67
|
role: "dialog",
|
|
63
|
-
...
|
|
68
|
+
...I,
|
|
64
69
|
tabIndex: -1,
|
|
65
|
-
...
|
|
70
|
+
...T
|
|
66
71
|
},
|
|
67
|
-
children:
|
|
72
|
+
children: p
|
|
68
73
|
})] });
|
|
69
74
|
}
|
|
70
|
-
var
|
|
71
|
-
l.displayName = "Popover";
|
|
75
|
+
var f = e(d, "Popover");
|
|
72
76
|
//#endregion
|
|
73
|
-
export {
|
|
77
|
+
export { f as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../
|
|
1
|
+
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../react-shared.cjs"),t=require("../platform.cjs"),n=require("../behavior.cjs"),r=require("../identity.cjs"),i=require("../reporting.cjs"),a=require("./flex.cjs"),o=require("./semantics.cjs"),s=require("./radioButton.cjs");let c=require("react"),l=require("react/jsx-runtime");var u=(0,c.createContext)(null);function d(e){return[...e?.querySelectorAll(`input[type="radio"]`)??[]].filter(e=>!e.disabled)}function f(e){return e===`ArrowDown`||e===`ArrowRight`?1:e===`ArrowUp`||e===`ArrowLeft`?-1:0}function p(e,s){let{label:p,name:m,value:h,defaultValue:g,onValueChange:_,onChange:v,orientation:y=`vertical`,children:b,props:x,...S}=e,C=r.t(`radiogroup`),w=(0,c.useRef)(null),T=(0,c.useCallback)(e=>{w.current=e,t.l(s,e)},[s]),E=(0,c.useRef)(`click`),D=n.a((e,t)=>{_?.(e,t),v?.(e,t)}),[O,k]=i.a({value:h,defaultValue:g,onChange:D,interaction:{component:`radioGroup`,type:`valueChange`}}),A=n.a(e=>{let t=f(e.key);if(t===0||e.defaultPrevented)return;let n=d(w.current),r=n.indexOf(document.activeElement);if(r===-1)return;e.preventDefault();let i=n[(r+t+n.length)%n.length];i!==n[r]&&(E.current=`keyboard`,i.focus(),i.click(),E.current=`click`)}),j=`${C}-label`,M=p!=null,N=(0,c.useMemo)(()=>({name:m??C,value:O,select:(e,t)=>k(e,{reason:E.current,event:t})}),[C,m,O,k]);return(0,l.jsx)(u.Provider,{value:N,children:(0,l.jsxs)(a.default,{ref:T,component:`radioGroup`,variant:{horizontal:y===`horizontal`},...S,props:{role:`radiogroup`,"aria-labelledby":M?j:void 0,...x,onKeyDown:A},children:[M&&(0,l.jsx)(o.Span,{component:`radioGroup.label`,id:j,children:p}),b]})})}function m(e){let t=(0,c.useContext)(u),{value:r,...i}=e,a=n.a(e=>t?.select(r,e));return t?(0,l.jsx)(s.default,{name:t.name,value:r,checked:t.value===r,onChange:a,...i}):(0,l.jsx)(s.default,{value:r,...i})}m.displayName=`RadioGroup.Item`;var h=e.f(p,`RadioGroup`);h.Item=m,h.displayName=`RadioGroup`,exports.default=h;
|
|
@@ -1,88 +1,92 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { t } from "../
|
|
4
|
-
import { a as n } from "../
|
|
5
|
-
import r from "
|
|
6
|
-
import {
|
|
7
|
-
import a from "./
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
2
|
+
import { f as e } from "../react-shared.mjs";
|
|
3
|
+
import { l as t } from "../platform.mjs";
|
|
4
|
+
import { a as n } from "../behavior.mjs";
|
|
5
|
+
import { t as r } from "../identity.mjs";
|
|
6
|
+
import { a as i } from "../reporting.mjs";
|
|
7
|
+
import a from "./flex.mjs";
|
|
8
|
+
import { Span as o } from "./semantics.mjs";
|
|
9
|
+
import s from "./radioButton.mjs";
|
|
10
|
+
import { createContext as c, useCallback as l, useContext as u, useMemo as d, useRef as f } from "react";
|
|
11
|
+
import { jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
10
12
|
//#region src/components/radioGroup.tsx
|
|
11
|
-
var
|
|
12
|
-
function
|
|
13
|
+
var h = c(null);
|
|
14
|
+
function g(e) {
|
|
13
15
|
return [...e?.querySelectorAll("input[type=\"radio\"]") ?? []].filter((e) => !e.disabled);
|
|
14
16
|
}
|
|
15
|
-
function
|
|
17
|
+
function _(e) {
|
|
16
18
|
return e === "ArrowDown" || e === "ArrowRight" ? 1 : e === "ArrowUp" || e === "ArrowLeft" ? -1 : 0;
|
|
17
19
|
}
|
|
18
|
-
function
|
|
19
|
-
let { label:
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
function v(e, s) {
|
|
21
|
+
let { label: c, name: u, value: v, defaultValue: y, onValueChange: b, onChange: x, orientation: S = "vertical", children: C, props: w, ...T } = e, E = r("radiogroup"), D = f(null), O = l((e) => {
|
|
22
|
+
D.current = e, t(s, e);
|
|
23
|
+
}, [s]), k = f("click"), A = n((e, t) => {
|
|
24
|
+
b?.(e, t), x?.(e, t);
|
|
25
|
+
}), [j, M] = i({
|
|
26
|
+
value: v,
|
|
27
|
+
defaultValue: y,
|
|
28
|
+
onChange: A,
|
|
25
29
|
interaction: {
|
|
26
30
|
component: "radioGroup",
|
|
27
31
|
type: "valueChange"
|
|
28
32
|
}
|
|
29
|
-
}),
|
|
30
|
-
let t =
|
|
33
|
+
}), N = n((e) => {
|
|
34
|
+
let t = _(e.key);
|
|
31
35
|
if (t === 0 || e.defaultPrevented) return;
|
|
32
|
-
let n =
|
|
36
|
+
let n = g(D.current), r = n.indexOf(document.activeElement);
|
|
33
37
|
if (r === -1) return;
|
|
34
38
|
e.preventDefault();
|
|
35
39
|
let i = n[(r + t + n.length) % n.length];
|
|
36
|
-
i !== n[r] && (
|
|
37
|
-
}),
|
|
38
|
-
name:
|
|
39
|
-
value:
|
|
40
|
-
select: (e, t) =>
|
|
41
|
-
reason:
|
|
40
|
+
i !== n[r] && (k.current = "keyboard", i.focus(), i.click(), k.current = "click");
|
|
41
|
+
}), P = `${E}-label`, F = c != null, I = d(() => ({
|
|
42
|
+
name: u ?? E,
|
|
43
|
+
value: j,
|
|
44
|
+
select: (e, t) => M(e, {
|
|
45
|
+
reason: k.current,
|
|
42
46
|
event: t
|
|
43
47
|
})
|
|
44
48
|
}), [
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
E,
|
|
50
|
+
u,
|
|
51
|
+
j,
|
|
52
|
+
M
|
|
49
53
|
]);
|
|
50
|
-
return /* @__PURE__ */
|
|
51
|
-
value:
|
|
52
|
-
children: /* @__PURE__ */
|
|
53
|
-
ref:
|
|
54
|
+
return /* @__PURE__ */ p(h.Provider, {
|
|
55
|
+
value: I,
|
|
56
|
+
children: /* @__PURE__ */ m(a, {
|
|
57
|
+
ref: O,
|
|
54
58
|
component: "radioGroup",
|
|
55
|
-
variant: { horizontal:
|
|
56
|
-
...
|
|
59
|
+
variant: { horizontal: S === "horizontal" },
|
|
60
|
+
...T,
|
|
57
61
|
props: {
|
|
58
62
|
role: "radiogroup",
|
|
59
|
-
"aria-labelledby":
|
|
60
|
-
...
|
|
61
|
-
onKeyDown:
|
|
63
|
+
"aria-labelledby": F ? P : void 0,
|
|
64
|
+
...w,
|
|
65
|
+
onKeyDown: N
|
|
62
66
|
},
|
|
63
|
-
children: [
|
|
67
|
+
children: [F && /* @__PURE__ */ p(o, {
|
|
64
68
|
component: "radioGroup.label",
|
|
65
|
-
id:
|
|
66
|
-
children:
|
|
67
|
-
}),
|
|
69
|
+
id: P,
|
|
70
|
+
children: c
|
|
71
|
+
}), C]
|
|
68
72
|
})
|
|
69
73
|
});
|
|
70
74
|
}
|
|
71
|
-
function
|
|
72
|
-
let
|
|
73
|
-
return
|
|
74
|
-
name:
|
|
75
|
+
function y(e) {
|
|
76
|
+
let t = u(h), { value: r, ...i } = e, a = n((e) => t?.select(r, e));
|
|
77
|
+
return t ? /* @__PURE__ */ p(s, {
|
|
78
|
+
name: t.name,
|
|
75
79
|
value: r,
|
|
76
|
-
checked:
|
|
77
|
-
onChange:
|
|
80
|
+
checked: t.value === r,
|
|
81
|
+
onChange: a,
|
|
78
82
|
...i
|
|
79
|
-
}) : /* @__PURE__ */
|
|
83
|
+
}) : /* @__PURE__ */ p(s, {
|
|
80
84
|
value: r,
|
|
81
85
|
...i
|
|
82
86
|
});
|
|
83
87
|
}
|
|
84
|
-
|
|
85
|
-
var
|
|
86
|
-
|
|
88
|
+
y.displayName = "RadioGroup.Item";
|
|
89
|
+
var b = e(v, "RadioGroup");
|
|
90
|
+
b.Item = y, b.displayName = "RadioGroup";
|
|
87
91
|
//#endregion
|
|
88
|
-
export {
|
|
92
|
+
export { b as default };
|
package/components/slider.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../
|
|
1
|
+
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../react-shared.cjs"),t=require("../platform.cjs"),n=require("../box.cjs"),r=require("../behavior.cjs"),i=require("../reporting.cjs");let a=require("react"),o=require("react/jsx-runtime");var s;(function(e){function t(e){let t=String(Math.abs(e));if(t.includes(`e`))return 12;let n=t.indexOf(`.`);return n===-1?0:t.length-n-1}e.decimals=t;function n(e,t){return Number(e.toFixed(Math.min(t,15)))}function r(e,t,n){return Math.min(Math.max(e,t),n)}e.clamp=r;function i(e,i){let{min:a,max:o,step:s}=i,c=r(e,a,o);return s>0?r(n(a+Math.round((c-a)/s)*s,t(s)+t(a)),a,o):c}e.snap=i;function a(e,t,n){return n<=t?0:(r(e,t,n)-t)*(100/(n-t))}e.percent=a;function o(e,t,n){return`${Math.round(a(e,t,n)*100)/100}%`}e.percentage=o;function s(e){return typeof e==`number`?[e]:[...e]}e.thumbs=s;function c(e,t){return typeof e==`number`?t[0]:[...t]}e.shaped=c;function l(e,t,n,a){let o=t>0?e[t-1]:a.min,s=t<e.length-1?e[t+1]:a.max,c=[...e];return c[t]=r(i(n,a),o,s),c}e.move=l;function u(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}e.same=u;function d(e,t){let n=0,r=1/0;return e.forEach((e,i)=>{let a=Math.abs(e-t);a<=r&&(n=i,r=a)}),n}e.nearest=d;function f(e,t,n,r,i){let a=r===`vertical`?e.height===0?0:(e.bottom-n)/e.height:e.width===0?0:i?(e.right-t)/e.width:(t-e.left)/e.width;return Math.min(Math.max(a,0),1)}e.valueAt=f;function p(e,t=!1){if(e===`Home`)return{kind:`edge`,delta:-1};if(e===`End`)return{kind:`edge`,delta:1};if(e===`PageUp`)return{kind:`page`,delta:1};if(e===`PageDown`)return{kind:`page`,delta:-1};if(e===`ArrowUp`)return{kind:`step`,delta:1};if(e===`ArrowDown`)return{kind:`step`,delta:-1};if(e===`ArrowRight`)return{kind:`step`,delta:t?-1:1};if(e===`ArrowLeft`)return{kind:`step`,delta:t?1:-1}}e.moveFor=p;function m(e,t,n,r){if(t.kind===`edge`)return t.delta>0?n.max:n.min;let i=t.kind===`page`?r:n.step;return e+t.delta*i}e.moved=m})(s||={});var c=s,l=`data-index`;function u(e,t,n){return{min:e,max:t,step:n}}function d(e,t){return t?{insetBlockEnd:e}:{insetInlineStart:e}}function f(e,t,n){let r=e.length>1?Math.min(...e):t.min,i=Math.max(...e),a=c.percent(r,t.min,t.max),o=`${Math.round((c.percent(i,t.min,t.max)-a)*100)/100}%`;return n?{insetBlockEnd:`${Math.round(a*100)/100}%`,blockSize:o}:{insetInlineStart:`${Math.round(a*100)/100}%`,inlineSize:o}}function p(e,s){let{value:p,defaultValue:m,onValueChange:h,onValueCommit:g,min:_=0,max:v=100,step:y=1,largeStep:b=y*10,orientation:x=`horizontal`,disabled:S=!1,label:C,labelledBy:w,thumbLabels:T,format:E,name:D,props:O,...k}=e,A=(0,a.useRef)(null),j=(0,a.useCallback)(e=>{A.current=e,t.l(s,e)},[s]),M=(0,a.useRef)(null),N=(0,a.useRef)(null),P=(0,a.useRef)(!1),[F,I]=(0,a.useState)(!1),[L,R]=r.i({value:p,defaultValue:m??_,onChange:h}),z=u(_,v,y),B=x===`vertical`,V=c.thumbs(L),H=r.o(L),U=i.r(g,`slider`,`valueCommit`),W=r.a((e,t)=>{R(t=>c.same(c.thumbs(t),e)?t:c.shaped(t,e),t)}),G=e=>{let n=M.current;if(!n)return;let r=c.valueAt(n.getBoundingClientRect(),e.clientX,e.clientY,x,t.m(n));return _+r*(v-_)},K=e=>A.current?.querySelectorAll(`[role="slider"]`)[e],q=r.a(e=>{if(S||e.button!==0||e.defaultPrevented)return;let t=G(e);if(t===void 0)return;let n=c.thumbs(H.current),r=c.nearest(n,t);N.current=r,e.preventDefault(),e.currentTarget.setPointerCapture?.(e.pointerId),K(r)?.focus(),W(c.move(n,r,t,z),{reason:`pointer`,event:e})}),J=r.a(e=>{let t=N.current;if(t===null)return;let n=G(e);n!==void 0&&(I(!0),W(c.move(c.thumbs(H.current),t,n,z),{reason:`pointer`,event:e}))}),Y=r.a(e=>{N.current!==null&&(N.current=null,I(!1),e.currentTarget.releasePointerCapture?.(e.pointerId),U(H.current,{reason:`pointer`,event:e}))}),X=r.a(e=>{if(S||e.defaultPrevented)return;let n=e.target?.closest(`[role="slider"]`),r=Number(n?.getAttribute(l)??-1);if(!n||r<0)return;let i=c.moveFor(e.key,t.m(n));if(!i)return;e.preventDefault(),P.current=!0,I(!0);let a=c.thumbs(H.current);W(c.move(a,r,c.moved(a[r],i,z,b),z),{reason:`keyboard`,event:e})}),Z=r.a(e=>{P.current&&(P.current=!1,I(!1),U(H.current,{reason:`keyboard`,event:e}))}),Q=V.length>1;return(0,o.jsxs)(n.default,{ref:j,component:`slider`,...k,variant:[k.variant,{vertical:B,disabled:S}],props:{role:Q?`group`:void 0,"aria-label":Q?C:void 0,"aria-labelledby":Q?w:void 0,...O,onPointerDown:q,onPointerMove:J,onPointerUp:Y,onPointerCancel:Y,onKeyDown:X,onKeyUp:Z},children:[(0,o.jsx)(n.default,{ref:M,component:`slider.track`,variant:{vertical:B},children:(0,o.jsx)(n.default,{component:`slider.fill`,variant:{vertical:B,tracking:F},style:f(V,z,B)})}),V.map((e,t)=>(0,o.jsx)(n.default,{component:`slider.thumb`,variant:{vertical:B,disabled:S,tracking:F},style:d(c.percentage(e,_,v),B),props:{role:`slider`,tabIndex:S?-1:0,"aria-valuemin":_,"aria-valuemax":v,"aria-valuenow":e,"aria-valuetext":E?.(e),"aria-orientation":x,"aria-label":T?.[t]??(Q?void 0:C),"aria-labelledby":T?.[t]||Q?void 0:w,"aria-disabled":S||void 0,[l]:t}},t)),D!==void 0&&V.map((e,t)=>(0,o.jsx)(`input`,{type:`hidden`,name:D,value:e,readOnly:!0},t))]})}var m=e.f(p,`Slider`);exports.default=m;
|
package/components/slider.d.ts
CHANGED
|
@@ -40,59 +40,5 @@ export interface SliderProps<TKey extends keyof ComponentsAndVariants = 'slider'
|
|
|
40
40
|
/** What the value submits under. One hidden input per thumb, so a range posts two values of that name. */
|
|
41
41
|
name?: string;
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
* A value chosen by dragging a thumb along a track.
|
|
45
|
-
* Pattern: https://www.w3.org/WAI/ARIA/apg/patterns/slider/ and .../slider-multithumb/
|
|
46
|
-
*
|
|
47
|
-
* ```tsx
|
|
48
|
-
* <Slider label="Volume" defaultValue={40} onValueChange={(value) => setVolume(value)} />
|
|
49
|
-
* <Slider label="Price" defaultValue={[20, 80]} thumbLabels={['Lowest', 'Highest']} />
|
|
50
|
-
* ```
|
|
51
|
-
*
|
|
52
|
-
* **A number in is a number out.** `defaultValue={40}` makes a one-thumb slider whose `onValueChange`
|
|
53
|
-
* hands back a `number`; `defaultValue={[20, 80]}` makes a range whose handler takes a `number[]`. The
|
|
54
|
-
* number of thumbs is the value's own shape, so there is no second prop saying which kind this is.
|
|
55
|
-
*
|
|
56
|
-
* **This is not `<input type="range">`, and that is the one place the platform loses.** A range input
|
|
57
|
-
* cannot hold two thumbs, and its track and thumb are vendor pseudo-elements (`::-webkit-slider-thumb`)
|
|
58
|
-
* that no typed prop can reach — so a styled one is a rewrite of the parts, at which point the native
|
|
59
|
-
* element is only the keyboard. `name` still submits: a hidden input per thumb, so a form posts the
|
|
60
|
-
* value whether or not JavaScript ran the drag.
|
|
61
|
-
*
|
|
62
|
-
* **The position is an inline style, deliberately.** Everything a slider paints is a shared class except
|
|
63
|
-
* where its thumbs are — that is a per-frame value, and a class for it would be a rule per frame of a
|
|
64
|
-
* drag, never freed. It is the exception `useAnchorPosition`'s anchor name and the travelling tab
|
|
65
|
-
* indicator already take, and the reason a `ProgressRing` can round its fraction into a class where this
|
|
66
|
-
* cannot: nobody drags a ring.
|
|
67
|
-
*
|
|
68
|
-
* **It mirrors for free.** The fill and the thumbs are placed with `inset-inline-start`, so a
|
|
69
|
-
* right-to-left page draws the minimum on the right with no second stylesheet. The half that is not free
|
|
70
|
-
* is the keyboard, which is why the sideways arrows swap and Up and Down never do.
|
|
71
|
-
*
|
|
72
|
-
* **A press travels; a nudge does not.** A press on the track is the one move the eye has to follow, so
|
|
73
|
-
* the thumb animates the whole way. Every other move — a drag, an arrow key, a held arrow — is the
|
|
74
|
-
* `tracking` variant instead: 60ms `ease-out` on both the thumb and the fill, which must both carry it
|
|
75
|
-
* or they come apart (#144). Short rather than *off*, because off is exact and steps — a 1-in-100 slider
|
|
76
|
-
* moves 3.2px at a time on a 320px track. **Eased out rather than linear or eased**: a repeat restarts
|
|
77
|
-
* the transition every 33ms, so only its first half is ever seen, and on this curve that half is the
|
|
78
|
-
* straight part — it glides while the key is held and still decelerates on the last transition, the one
|
|
79
|
-
* allowed to finish. Measured against linear, which rode **1.4 steps** behind the value and stopped at
|
|
80
|
-
* full speed, this rides 0.9 behind and lands at 0.6 of cruising (#146).
|
|
81
|
-
*
|
|
82
|
-
* @pattern https://www.w3.org/WAI/ARIA/apg/patterns/slider/
|
|
83
|
-
* @a11y Each thumb is a `role="slider"` carrying `aria-valuemin`, `aria-valuemax`, `aria-valuenow` and
|
|
84
|
-
* `aria-orientation`; `format` writes `aria-valuetext` for a value a bare number does not read as.
|
|
85
|
-
* @a11y A thumb has to be named, so `label` names the one on a single slider — and on a range it names
|
|
86
|
-
* the `role="group"` around the thumbs, where `thumbLabels` names them one at a time.
|
|
87
|
-
* @a11y `disabled` is `aria-disabled` rather than the attribute: a slider a reader cannot reach is a
|
|
88
|
-
* value they cannot read, and a div takes no `disabled` anyway.
|
|
89
|
-
* @keyboard Tab — Every thumb is its own tab stop, so a range is two of them.
|
|
90
|
-
* @keyboard Right / Up — One step towards the maximum. In a right-to-left page Left is the increase, and
|
|
91
|
-
* Up never changes: the block axis has no reading order.
|
|
92
|
-
* @keyboard Left / Down — One step towards the minimum.
|
|
93
|
-
* @keyboard PageUp / PageDown — `largeStep`, ten steps unless it says otherwise.
|
|
94
|
-
* @keyboard Home / End — The minimum and the maximum themselves, on or off the step grid.
|
|
95
|
-
*/
|
|
96
|
-
declare function SliderImpl<TKey extends keyof ComponentsAndVariants = 'slider', TValue extends SliderValue = number>(props: SliderProps<TKey, TValue>): import("react").JSX.Element;
|
|
97
|
-
declare const Slider: typeof SliderImpl;
|
|
43
|
+
declare const Slider: <TKey extends keyof ComponentsAndVariants = "slider", TValue extends SliderValue = number>(props: SliderProps<TKey, TValue>) => React.ReactNode;
|
|
98
44
|
export default Slider;
|