@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/dialog.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("../client.cjs"),r=require("../effects.cjs"),i=require("../box.cjs"),a=require("../behavior.cjs"),o=require("../identity.cjs"),s=require("../reporting.cjs"),c=require("./semantics.cjs");let l=require("react"),u=require("react/jsx-runtime");var d=0;function f(e){let{classNames:i,styleElements:a}=n.i({overflow:`hidden`},!1),o=i.slice(1).join(` `);return r.n(()=>{let n=t.n();if(!(!e||!n||!o))return d+=1,n.classList.add(o),()=>{--d,d===0&&n.classList.remove(o)}},[e,o]),a}var p=(0,l.createContext)(null);function m(e){let t=(0,l.useContext)(p);if(!t)throw Error(`<${e}> must be rendered inside a <Dialog>.`);return t}function h(e,t){return(0,u.jsx)(_,{role:`dialog`,...e,elementRef:t})}function g(e,t){return(0,u.jsx)(_,{role:`alertdialog`,...e,modal:!0,dismissible:!1,elementRef:t})}function _(e){let{role:n,trigger:c,children:d,open:m,defaultOpen:h=!1,onOpenChange:g,label:_,labelledBy:y,describedBy:b,modal:x=!0,dismissible:S=!0,lockScroll:C=x,initialFocus:w,elementRef:T,props:E,...D}=e,O=o.t(`dialog`),k=D.id??O,[A,j]=s.a({value:m,defaultValue:h,onChange:g,interaction:{component:n===`alertdialog`?`alertDialog`:`dialog`,type:`openChange`}}),[M,N]=(0,l.useState)(null),P=(0,l.useCallback)(e=>{N(e),t.l(T,e)},[T]),[F,I]=(0,l.useState)(null),[L,R]=(0,l.useState)(!1),[z,B]=(0,l.useState)({title:0,description:0}),V=f(A&&C);a.n({enabled:A,returnTo:F});let H=(0,l.useCallback)(e=>(B(t=>({...t,[e]:t[e]+1})),()=>B(t=>({...t,[e]:t[e]-1}))),[]),U=(0,l.useMemo)(()=>({titleId:`${k}-title`,descriptionId:`${k}-description`,register:H}),[k,H]);v({dialog:M,isOpen:A,domOpen:L,setDomOpen:R,setOpen:j,modal:x,dismissible:S,triggerElement:F}),r.n(()=>{let e=t.f(w);!A||!e||e.focus()},[A,w]);let W=a.a(e=>{j(e=>!e,{reason:`trigger`,event:e})}),G=(0,l.useMemo)(()=>({ref:I,props:{"aria-expanded":A,"aria-haspopup":`dialog`,"aria-controls":A?k:void 0,onClick:W}}),[k,W,A]),K=D;return(0,u.jsxs)(u.Fragment,{children:[V,c?.(G),(0,u.jsx)(p.Provider,{value:U,children:(0,u.jsx)(i.default,{ref:P,tag:`dialog`,component:`dialog`,...K,id:k,props:{role:n,"aria-label":z.title||y?void 0:_,"aria-labelledby":y??(z.title?U.titleId:void 0),"aria-describedby":b??(z.description?U.descriptionId:void 0),...E},children:d})})]})}function v(e){let{dialog:n,isOpen:i,domOpen:o,setDomOpen:s,setOpen:c,modal:u,dismissible:d,triggerElement:f}=e,p=(0,l.useRef)(`imperative`),m=t.s(),h=d?`any`:`closerequest`;r.n(()=>{!n||i===o||(s(i),i?u?n.showModal():n.show():n.close())},[n,i,o,u,s]),r.n(()=>{if(!n)return;let e=new AbortController;return n.addEventListener(`close`,e=>{s(!1),c(!1,{reason:p.current,event:e}),p.current=`imperative`},{signal:e.signal}),()=>e.abort()},[n,s,c]),r.n(()=>{if(!(!n||!m))return n.setAttribute(`closedby`,h),()=>n.removeAttribute(`closedby`)},[n,m,h]),r.n(()=>{if(!i||!n)return;let e=new AbortController,r=(t,n)=>document.addEventListener(t,n,{signal:e.signal,capture:!0});return r(`keydown`,e=>{e.key===`Escape`&&(p.current=`escape`)}),r(`pointerdown`,e=>{t.p(e,[f])?p.current=`trigger`:!t.p(e,[n])||y(n,e)?p.current=`outside-pointer`:p.current=`imperative`}),()=>e.abort()},[i,n,f]),a.r({enabled:i&&!u&&!m,inside:[n],escapeKey:!0,outsidePointer:!1,onDismiss:(e,t)=>c(!1,{reason:`escape`,event:t})}),r.n(()=>{if(!n||!i||!d||m)return;let e=new AbortController;return document.addEventListener(`pointerdown`,e=>{t.p(e,[f])||t.p(e,[n])&&!y(n,e)||c(!1,{reason:`outside-pointer`,event:e})},{signal:e.signal,capture:!0}),()=>e.abort()},[n,i,d,m,f,c])}function y(e,t){let n=e.getBoundingClientRect();return t.clientX<n.left||t.clientX>n.right||t.clientY<n.top||t.clientY>n.bottom}function b(e){let t=m(`Dialog.Title`);return r.n(()=>t.register(`title`),[t]),(0,u.jsx)(c.H2,{id:t.titleId,component:`dialog.title`,...e})}function x(e){let t=m(`Dialog.Description`);return r.n(()=>t.register(`description`),[t]),(0,u.jsx)(c.P,{id:t.descriptionId,component:`dialog.description`,...e})}b.displayName=`Dialog.Title`,x.displayName=`Dialog.Description`;var S={Title:b,Description:x},C=Object.assign(e.f(h,`Dialog`),S),w=Object.assign(e.f(g,`AlertDialog`),S);exports.AlertDialog=w,exports.default=C;
|
package/components/dialog.d.ts
CHANGED
|
@@ -70,68 +70,6 @@ export type AlertDialogProps<TKey extends keyof ComponentsAndVariants = 'dialog'
|
|
|
70
70
|
export type DialogTitleProps<TKey extends keyof ComponentsAndVariants = 'dialog.title'> = BoxProps<'h2', TKey>;
|
|
71
71
|
/** Every Box prop, on a `<p>`. */
|
|
72
72
|
export type DialogDescriptionProps<TKey extends keyof ComponentsAndVariants = 'dialog.description'> = BoxProps<'p', TKey>;
|
|
73
|
-
/**
|
|
74
|
-
* A modal dialog on the platform's own `<dialog>`: `showModal()` supplies the top layer, the
|
|
75
|
-
* `::backdrop`, an inert page behind it, Escape, focus containment and focus return — so none of that is
|
|
76
|
-
* written here.
|
|
77
|
-
*
|
|
78
|
-
* ```tsx
|
|
79
|
-
* <Dialog trigger={(t) => <Button {...t}>Rename</Button>}>
|
|
80
|
-
* <Dialog.Title>Rename this view</Dialog.Title>
|
|
81
|
-
* <Textbox label="Name" />
|
|
82
|
-
* </Dialog>
|
|
83
|
-
* ```
|
|
84
|
-
*
|
|
85
|
-
* **The dialog is always rendered**, and closed means `display: none` — the same shape as `<Popover>`, and
|
|
86
|
-
* what lets the browser own show and hide. The exit is therefore a plain CSS transition rather than a
|
|
87
|
-
* `<Presence>`, since nothing unmounts; content that is expensive to render should be gated by the
|
|
88
|
-
* consumer with `{open && <Heavy />}`.
|
|
89
|
-
*
|
|
90
|
-
* **A close cannot be refused.** The `cancel` event is cancelable, but by the time `onOpenChange` runs the
|
|
91
|
-
* browser has closed the dialog, so a controlled `<Dialog open>` hears about a dismissal afterwards and
|
|
92
|
-
* keeping `open` true re-shows it. Say `dismissible={false}` to make a decision unavoidable instead, which
|
|
93
|
-
* is what `<AlertDialog>` does.
|
|
94
|
-
*
|
|
95
|
-
* **Nothing is portalled**, so the theme, the custom properties, the text direction and the tab order
|
|
96
|
-
* around the declaration all reach inside — a top-layer element inherits normally (measured in Chrome
|
|
97
|
-
* 152, with a local `Box.Theme` wrapper around the dialog).
|
|
98
|
-
*
|
|
99
|
-
* A non-modal dialog (`modal={false}`) is `show()`: no top layer, no backdrop, nothing inert, and the UA
|
|
100
|
-
* positions it against its containing block rather than the viewport. It is the right shape for a
|
|
101
|
-
* persistent panel; for one anchored to a trigger, reach for `<Popover>`.
|
|
102
|
-
*
|
|
103
|
-
* @a11y `role="dialog"` (`alertdialog` on `<AlertDialog>`), named by a `Dialog.Title`, `label` or
|
|
104
|
-
* `labelledBy`, and described by a `Dialog.Description` or `describedBy`.
|
|
105
|
-
* @a11y The trigger carries `aria-haspopup="dialog"`, `aria-expanded` and `aria-controls`.
|
|
106
|
-
* @a11y Focus is contained while a modal dialog is open and returns to the trigger when it closes, both
|
|
107
|
-
* from the platform. `initialFocus` is what an alert dialog needs to land on its least destructive action.
|
|
108
|
-
* @keyboard Escape — Closes it, from anywhere inside, and returns focus to the trigger.
|
|
109
|
-
* @keyboard Tab — Cycles focus inside a modal dialog and never leaves it; in a non-modal one it moves on.
|
|
110
|
-
* @keyboard Enter, Space — On the trigger, opens the dialog.
|
|
111
|
-
*/
|
|
112
|
-
declare function DialogImpl<TKey extends keyof ComponentsAndVariants = 'dialog'>(props: DialogProps<TKey>): import("react").JSX.Element;
|
|
113
|
-
/**
|
|
114
|
-
* A dialog that interrupts to ask something: `role="alertdialog"`, always modal, and **never dismissed by
|
|
115
|
-
* a press outside**, because a decision that can be clicked away is one the user did not make.
|
|
116
|
-
*
|
|
117
|
-
* ```tsx
|
|
118
|
-
* <AlertDialog trigger={(t) => <Button {...t}>Delete</Button>} initialFocus={cancelRef}>
|
|
119
|
-
* <AlertDialog.Title>Delete this view?</AlertDialog.Title>
|
|
120
|
-
* <AlertDialog.Description>Nothing here can be undone.</AlertDialog.Description>
|
|
121
|
-
* <Button ref={cancelRef}>Cancel</Button>
|
|
122
|
-
* </AlertDialog>
|
|
123
|
-
* ```
|
|
124
|
-
*
|
|
125
|
-
* Escape still closes it — a keyboard user must always have a way out (APG), and the platform's own close
|
|
126
|
-
* request is that way. `initialFocus` is what puts focus on the least destructive action.
|
|
127
|
-
*
|
|
128
|
-
* @a11y `role="alertdialog"`, which tells a screen reader the content is an alert rather than a panel, so
|
|
129
|
-
* the name and description are announced together on open.
|
|
130
|
-
* @a11y A press outside is ignored on purpose; Escape is not, so the dialog is never a trap.
|
|
131
|
-
* @keyboard Escape — Closes it and returns focus to the trigger.
|
|
132
|
-
* @keyboard Tab — Cycles focus inside it and never leaves.
|
|
133
|
-
*/
|
|
134
|
-
declare function AlertDialogImpl<TKey extends keyof ComponentsAndVariants = 'dialog'>(props: AlertDialogProps<TKey>): import("react").JSX.Element;
|
|
135
73
|
/**
|
|
136
74
|
* The dialog's heading, and what names it: rendering one is what puts `aria-labelledby` on the dialog, so
|
|
137
75
|
* a name and a visible title cannot drift apart. An `<h2>` by default — `tag` takes any of the six.
|
|
@@ -139,11 +77,11 @@ declare function AlertDialogImpl<TKey extends keyof ComponentsAndVariants = 'dia
|
|
|
139
77
|
declare function DialogTitle<TKey extends keyof ComponentsAndVariants = 'dialog.title'>(props: DialogTitleProps<TKey>): import("react").JSX.Element;
|
|
140
78
|
/** The dialog's supporting text, and what describes it: rendering one puts `aria-describedby` on the dialog. */
|
|
141
79
|
declare function DialogDescription<TKey extends keyof ComponentsAndVariants = 'dialog.description'>(props: DialogDescriptionProps<TKey>): import("react").JSX.Element;
|
|
142
|
-
declare const Dialog:
|
|
80
|
+
declare const Dialog: (<TKey extends keyof ComponentsAndVariants = "dialog">(props: DialogProps<TKey>) => React.ReactNode) & {
|
|
143
81
|
Title: typeof DialogTitle;
|
|
144
82
|
Description: typeof DialogDescription;
|
|
145
83
|
};
|
|
146
|
-
declare const AlertDialog:
|
|
84
|
+
declare const AlertDialog: (<TKey extends keyof ComponentsAndVariants = "dialog">(props: AlertDialogProps<TKey>) => React.ReactNode) & {
|
|
147
85
|
Title: typeof DialogTitle;
|
|
148
86
|
Description: typeof DialogDescription;
|
|
149
87
|
};
|
package/components/dialog.mjs
CHANGED
|
@@ -1,160 +1,165 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { i } from "../
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
2
|
+
import { f as e } from "../react-shared.mjs";
|
|
3
|
+
import { f as t, l as n, n as r, p as i, s as a } from "../platform.mjs";
|
|
4
|
+
import { i as o } from "../client.mjs";
|
|
5
|
+
import { n as s } from "../effects.mjs";
|
|
6
|
+
import c from "../box.mjs";
|
|
7
|
+
import { a as l, n as u, r as d } from "../behavior.mjs";
|
|
8
|
+
import { t as f } from "../identity.mjs";
|
|
9
|
+
import { a as p } from "../reporting.mjs";
|
|
10
|
+
import { H2 as m, P as h } from "./semantics.mjs";
|
|
11
|
+
import { createContext as g, useCallback as _, useContext as v, useMemo as y, useRef as b, useState as x } from "react";
|
|
12
|
+
import { Fragment as S, jsx as C, jsxs as w } from "react/jsx-runtime";
|
|
12
13
|
//#region src/react/dialog/useScrollLock.ts
|
|
13
|
-
var
|
|
14
|
-
function
|
|
15
|
-
let { classNames: t, styleElements:
|
|
16
|
-
return
|
|
17
|
-
let t =
|
|
18
|
-
if (!(!e || !t || !
|
|
19
|
-
--
|
|
14
|
+
var T = 0;
|
|
15
|
+
function E(e) {
|
|
16
|
+
let { classNames: t, styleElements: n } = o({ overflow: "hidden" }, !1), i = t.slice(1).join(" ");
|
|
17
|
+
return s(() => {
|
|
18
|
+
let t = r();
|
|
19
|
+
if (!(!e || !t || !i)) return T += 1, t.classList.add(i), () => {
|
|
20
|
+
--T, T === 0 && t.classList.remove(i);
|
|
20
21
|
};
|
|
21
|
-
}, [e,
|
|
22
|
+
}, [e, i]), n;
|
|
22
23
|
}
|
|
23
24
|
//#endregion
|
|
24
25
|
//#region src/components/dialog.tsx
|
|
25
|
-
var
|
|
26
|
-
function
|
|
27
|
-
let t =
|
|
26
|
+
var D = g(null);
|
|
27
|
+
function O(e) {
|
|
28
|
+
let t = v(D);
|
|
28
29
|
if (!t) throw Error(`<${e}> must be rendered inside a <Dialog>.`);
|
|
29
30
|
return t;
|
|
30
31
|
}
|
|
31
|
-
function
|
|
32
|
-
return /* @__PURE__ */
|
|
32
|
+
function k(e, t) {
|
|
33
|
+
return /* @__PURE__ */ C(j, {
|
|
33
34
|
role: "dialog",
|
|
34
|
-
...e
|
|
35
|
+
...e,
|
|
36
|
+
elementRef: t
|
|
35
37
|
});
|
|
36
38
|
}
|
|
37
|
-
function
|
|
38
|
-
return /* @__PURE__ */
|
|
39
|
+
function A(e, t) {
|
|
40
|
+
return /* @__PURE__ */ C(j, {
|
|
39
41
|
role: "alertdialog",
|
|
40
42
|
...e,
|
|
41
43
|
modal: !0,
|
|
42
|
-
dismissible: !1
|
|
44
|
+
dismissible: !1,
|
|
45
|
+
elementRef: t
|
|
43
46
|
});
|
|
44
47
|
}
|
|
45
|
-
function
|
|
46
|
-
let { role:
|
|
47
|
-
value:
|
|
48
|
-
defaultValue:
|
|
49
|
-
onChange:
|
|
48
|
+
function j(e) {
|
|
49
|
+
let { role: r, trigger: i, children: a, open: o, defaultOpen: d = !1, onOpenChange: m, label: h, labelledBy: g, describedBy: v, modal: b = !0, dismissible: T = !0, lockScroll: O = b, initialFocus: k, elementRef: A, props: j, ...N } = e, P = f("dialog"), F = N.id ?? P, [I, L] = p({
|
|
50
|
+
value: o,
|
|
51
|
+
defaultValue: d,
|
|
52
|
+
onChange: m,
|
|
50
53
|
interaction: {
|
|
51
|
-
component:
|
|
54
|
+
component: r === "alertdialog" ? "alertDialog" : "dialog",
|
|
52
55
|
type: "openChange"
|
|
53
56
|
}
|
|
54
|
-
}), [
|
|
57
|
+
}), [R, z] = x(null), B = _((e) => {
|
|
58
|
+
z(e), n(A, e);
|
|
59
|
+
}, [A]), [V, H] = x(null), [U, W] = x(!1), [G, K] = x({
|
|
55
60
|
title: 0,
|
|
56
61
|
description: 0
|
|
57
|
-
}),
|
|
58
|
-
|
|
59
|
-
enabled:
|
|
60
|
-
returnTo:
|
|
62
|
+
}), q = E(I && O);
|
|
63
|
+
u({
|
|
64
|
+
enabled: I,
|
|
65
|
+
returnTo: V
|
|
61
66
|
});
|
|
62
|
-
let
|
|
67
|
+
let J = _((e) => (K((t) => ({
|
|
63
68
|
...t,
|
|
64
69
|
[e]: t[e] + 1
|
|
65
|
-
})), () =>
|
|
70
|
+
})), () => K((t) => ({
|
|
66
71
|
...t,
|
|
67
72
|
[e]: t[e] - 1
|
|
68
|
-
}))), []),
|
|
69
|
-
titleId: `${
|
|
70
|
-
descriptionId: `${
|
|
71
|
-
register:
|
|
72
|
-
}), [
|
|
73
|
-
|
|
74
|
-
dialog:
|
|
75
|
-
isOpen:
|
|
76
|
-
domOpen:
|
|
77
|
-
setDomOpen:
|
|
78
|
-
setOpen:
|
|
79
|
-
modal:
|
|
80
|
-
dismissible:
|
|
81
|
-
triggerElement:
|
|
82
|
-
}),
|
|
83
|
-
let
|
|
84
|
-
!
|
|
85
|
-
}, [
|
|
86
|
-
let
|
|
87
|
-
|
|
73
|
+
}))), []), Y = y(() => ({
|
|
74
|
+
titleId: `${F}-title`,
|
|
75
|
+
descriptionId: `${F}-description`,
|
|
76
|
+
register: J
|
|
77
|
+
}), [F, J]);
|
|
78
|
+
M({
|
|
79
|
+
dialog: R,
|
|
80
|
+
isOpen: I,
|
|
81
|
+
domOpen: U,
|
|
82
|
+
setDomOpen: W,
|
|
83
|
+
setOpen: L,
|
|
84
|
+
modal: b,
|
|
85
|
+
dismissible: T,
|
|
86
|
+
triggerElement: V
|
|
87
|
+
}), s(() => {
|
|
88
|
+
let e = t(k);
|
|
89
|
+
!I || !e || e.focus();
|
|
90
|
+
}, [I, k]);
|
|
91
|
+
let X = l((e) => {
|
|
92
|
+
L((e) => !e, {
|
|
88
93
|
reason: "trigger",
|
|
89
94
|
event: e
|
|
90
95
|
});
|
|
91
|
-
}),
|
|
92
|
-
ref:
|
|
96
|
+
}), Z = y(() => ({
|
|
97
|
+
ref: H,
|
|
93
98
|
props: {
|
|
94
|
-
"aria-expanded":
|
|
99
|
+
"aria-expanded": I,
|
|
95
100
|
"aria-haspopup": "dialog",
|
|
96
|
-
"aria-controls":
|
|
97
|
-
onClick:
|
|
101
|
+
"aria-controls": I ? F : void 0,
|
|
102
|
+
onClick: X
|
|
98
103
|
}
|
|
99
104
|
}), [
|
|
100
|
-
|
|
105
|
+
F,
|
|
106
|
+
X,
|
|
107
|
+
I
|
|
108
|
+
]), Q = N;
|
|
109
|
+
return /* @__PURE__ */ w(S, { children: [
|
|
101
110
|
q,
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
/* @__PURE__ */ x(T.Provider, {
|
|
108
|
-
value: K,
|
|
109
|
-
children: /* @__PURE__ */ x(o, {
|
|
110
|
-
ref: L,
|
|
111
|
+
i?.(Z),
|
|
112
|
+
/* @__PURE__ */ C(D.Provider, {
|
|
113
|
+
value: Y,
|
|
114
|
+
children: /* @__PURE__ */ C(c, {
|
|
115
|
+
ref: B,
|
|
111
116
|
tag: "dialog",
|
|
112
117
|
component: "dialog",
|
|
113
|
-
...
|
|
114
|
-
id:
|
|
118
|
+
...Q,
|
|
119
|
+
id: F,
|
|
115
120
|
props: {
|
|
116
|
-
role:
|
|
117
|
-
"aria-label":
|
|
118
|
-
"aria-labelledby": g ?? (
|
|
119
|
-
"aria-describedby": v ?? (
|
|
120
|
-
...
|
|
121
|
+
role: r,
|
|
122
|
+
"aria-label": G.title || g ? void 0 : h,
|
|
123
|
+
"aria-labelledby": g ?? (G.title ? Y.titleId : void 0),
|
|
124
|
+
"aria-describedby": v ?? (G.description ? Y.descriptionId : void 0),
|
|
125
|
+
...j
|
|
121
126
|
},
|
|
122
|
-
children:
|
|
127
|
+
children: a
|
|
123
128
|
})
|
|
124
129
|
})
|
|
125
130
|
] });
|
|
126
131
|
}
|
|
127
|
-
function
|
|
128
|
-
let { dialog:
|
|
129
|
-
|
|
130
|
-
!
|
|
132
|
+
function M(e) {
|
|
133
|
+
let { dialog: t, isOpen: n, domOpen: r, setDomOpen: o, setOpen: c, modal: l, dismissible: u, triggerElement: f } = e, p = b("imperative"), m = a(), h = u ? "any" : "closerequest";
|
|
134
|
+
s(() => {
|
|
135
|
+
!t || n === r || (o(n), n ? l ? t.showModal() : t.show() : t.close());
|
|
131
136
|
}, [
|
|
137
|
+
t,
|
|
132
138
|
n,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if (!n) return;
|
|
139
|
+
r,
|
|
140
|
+
l,
|
|
141
|
+
o
|
|
142
|
+
]), s(() => {
|
|
143
|
+
if (!t) return;
|
|
139
144
|
let e = new AbortController();
|
|
140
|
-
return
|
|
141
|
-
|
|
145
|
+
return t.addEventListener("close", (e) => {
|
|
146
|
+
o(!1), c(!1, {
|
|
142
147
|
reason: p.current,
|
|
143
148
|
event: e
|
|
144
149
|
}), p.current = "imperative";
|
|
145
150
|
}, { signal: e.signal }), () => e.abort();
|
|
146
151
|
}, [
|
|
147
|
-
|
|
148
|
-
|
|
152
|
+
t,
|
|
153
|
+
o,
|
|
149
154
|
c
|
|
150
|
-
]),
|
|
151
|
-
if (!(!
|
|
155
|
+
]), s(() => {
|
|
156
|
+
if (!(!t || !m)) return t.setAttribute("closedby", h), () => t.removeAttribute("closedby");
|
|
152
157
|
}, [
|
|
153
|
-
|
|
158
|
+
t,
|
|
154
159
|
m,
|
|
155
160
|
h
|
|
156
|
-
]),
|
|
157
|
-
if (!
|
|
161
|
+
]), s(() => {
|
|
162
|
+
if (!n || !t) return;
|
|
158
163
|
let e = new AbortController(), r = (t, n) => document.addEventListener(t, n, {
|
|
159
164
|
signal: e.signal,
|
|
160
165
|
capture: !0
|
|
@@ -162,26 +167,26 @@ function A(e) {
|
|
|
162
167
|
return r("keydown", (e) => {
|
|
163
168
|
e.key === "Escape" && (p.current = "escape");
|
|
164
169
|
}), r("pointerdown", (e) => {
|
|
165
|
-
|
|
170
|
+
i(e, [f]) ? p.current = "trigger" : !i(e, [t]) || N(t, e) ? p.current = "outside-pointer" : p.current = "imperative";
|
|
166
171
|
}), () => e.abort();
|
|
167
172
|
}, [
|
|
168
|
-
i,
|
|
169
173
|
n,
|
|
174
|
+
t,
|
|
170
175
|
f
|
|
171
|
-
]),
|
|
172
|
-
enabled:
|
|
173
|
-
inside: [
|
|
176
|
+
]), d({
|
|
177
|
+
enabled: n && !l && !m,
|
|
178
|
+
inside: [t],
|
|
174
179
|
escapeKey: !0,
|
|
175
180
|
outsidePointer: !1,
|
|
176
181
|
onDismiss: (e, t) => c(!1, {
|
|
177
182
|
reason: "escape",
|
|
178
183
|
event: t
|
|
179
184
|
})
|
|
180
|
-
}),
|
|
181
|
-
if (!
|
|
185
|
+
}), s(() => {
|
|
186
|
+
if (!t || !n || !u || m) return;
|
|
182
187
|
let e = new AbortController();
|
|
183
188
|
return document.addEventListener("pointerdown", (e) => {
|
|
184
|
-
|
|
189
|
+
i(e, [f]) || i(e, [t]) && !N(t, e) || c(!1, {
|
|
185
190
|
reason: "outside-pointer",
|
|
186
191
|
event: e
|
|
187
192
|
});
|
|
@@ -190,39 +195,38 @@ function A(e) {
|
|
|
190
195
|
capture: !0
|
|
191
196
|
}), () => e.abort();
|
|
192
197
|
}, [
|
|
198
|
+
t,
|
|
193
199
|
n,
|
|
194
|
-
|
|
195
|
-
d,
|
|
200
|
+
u,
|
|
196
201
|
m,
|
|
197
202
|
f,
|
|
198
203
|
c
|
|
199
204
|
]);
|
|
200
205
|
}
|
|
201
|
-
function
|
|
206
|
+
function N(e, t) {
|
|
202
207
|
let n = e.getBoundingClientRect();
|
|
203
208
|
return t.clientX < n.left || t.clientX > n.right || t.clientY < n.top || t.clientY > n.bottom;
|
|
204
209
|
}
|
|
205
|
-
function
|
|
206
|
-
let t =
|
|
207
|
-
return
|
|
210
|
+
function P(e) {
|
|
211
|
+
let t = O("Dialog.Title");
|
|
212
|
+
return s(() => t.register("title"), [t]), /* @__PURE__ */ C(m, {
|
|
208
213
|
id: t.titleId,
|
|
209
214
|
component: "dialog.title",
|
|
210
215
|
...e
|
|
211
216
|
});
|
|
212
217
|
}
|
|
213
|
-
function
|
|
214
|
-
let t =
|
|
215
|
-
return
|
|
218
|
+
function F(e) {
|
|
219
|
+
let t = O("Dialog.Description");
|
|
220
|
+
return s(() => t.register("description"), [t]), /* @__PURE__ */ C(h, {
|
|
216
221
|
id: t.descriptionId,
|
|
217
222
|
component: "dialog.description",
|
|
218
223
|
...e
|
|
219
224
|
});
|
|
220
225
|
}
|
|
221
|
-
|
|
222
|
-
var
|
|
223
|
-
Title:
|
|
224
|
-
Description:
|
|
225
|
-
},
|
|
226
|
-
D.displayName = "Dialog", O.displayName = "AlertDialog";
|
|
226
|
+
P.displayName = "Dialog.Title", F.displayName = "Dialog.Description";
|
|
227
|
+
var I = {
|
|
228
|
+
Title: P,
|
|
229
|
+
Description: F
|
|
230
|
+
}, L = Object.assign(e(k, "Dialog"), I), R = Object.assign(e(A, "AlertDialog"), I);
|
|
227
231
|
//#endregion
|
|
228
|
-
export {
|
|
232
|
+
export { R as AlertDialog, L as default };
|
package/components/form.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("../reporting.cjs");let i=require("react");var a;(function(e){function t(e){if(!e)throw Error(`[box-kite] <Form> read its entries with no <form> element: its ref never reached the element.`);let t=Array.from(e.elements).reduce((e,t)=>{let n=t.name;return n?(e[n]||(e[n]=[]),e[n].push(t),e):e},{});return Object.entries(t).reduce((e,[t,r])=>{if(r.length===1){let i=r[0];n(e,t,i.type===`checkbox`||i.type===`radio`?i.checked:i.value)}else n(e,t,r.reduce((e,t)=>(t.type===`checkbox`||t.type===`radio`?t.checked&&e.push(t.value):e.push(t.value),e),[]));return e},{})}e.getFormEntries=t;function n(e,t,n){if(t.includes(`.`)){let r=t.split(`.`),i=e;r.forEach((e,t)=>{if(r.length>t+1){let t=e.match(/^(.+)\[(\d)\]$/);if(t){let[,e,n]=t;i[e]=i[e]||[],i[e][n]=i[e][n]||{},i=i[e][n]}else i[e]=i[e]||{},i=i[e]}else i[e]=n})}else e[t]=n}})(a||={});var o=a;function s(e,a){let{onSubmit:s,props:c,...l}=e,u=(0,i.useRef)(null),d=r.i(`form`),{ref:f,...p}=c??{},m=(0,i.useCallback)(e=>{u.current=e,t.l(a,e),t.l(f,e)},[a,f]),h=(0,i.useCallback)(e=>{e.preventDefault();let t=o.getFormEntries(u.current??e.currentTarget);s(t,e),d(`submit`,Object.keys(t),{reason:`submit`,event:e})},[s,d]);return n.useBoxElement({tag:`form`,...l,props:{...p,onSubmit:h}},m)}var c=e.f(s,`Form`);exports.default=c;
|
package/components/form.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { RefAttributes } from 'react';
|
|
1
2
|
import { BoxProps } from '../box';
|
|
2
3
|
import { OmitTagProps } from '../react/boxProps';
|
|
3
4
|
type BoxTagProps = Required<BoxProps<'form'>>['props'];
|
|
4
|
-
type FormTagProps = OmitTagProps<BoxTagProps, 'onSubmit'
|
|
5
|
+
type FormTagProps = OmitTagProps<BoxTagProps, 'onSubmit'>;
|
|
5
6
|
interface Props<T> extends Omit<BoxProps<'form'>, 'props' | 'tag'> {
|
|
6
7
|
props?: FormTagProps;
|
|
7
8
|
onSubmit: (obj: T, e: React.ChangeEvent<HTMLFormElement>) => void;
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
-
export
|
|
10
|
+
declare const _default: <T>(props: Props<T> & RefAttributes<HTMLFormElement>) => React.ReactNode;
|
|
11
|
+
export default _default;
|
package/components/form.mjs
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import e from "../
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { f as e } from "../react-shared.mjs";
|
|
3
|
+
import { l as t } from "../platform.mjs";
|
|
4
|
+
import { useBoxElement as n } from "../box.mjs";
|
|
5
|
+
import { i as r } from "../reporting.mjs";
|
|
6
|
+
import { useCallback as i, useRef as a } from "react";
|
|
6
7
|
//#region src/utils/form/formUtils.ts
|
|
7
|
-
var
|
|
8
|
+
var o;
|
|
8
9
|
(function(e) {
|
|
9
10
|
function t(e) {
|
|
11
|
+
if (!e) throw Error("[box-kite] <Form> read its entries with no <form> element: its ref never reached the element.");
|
|
10
12
|
let t = Array.from(e.elements).reduce((e, t) => {
|
|
11
13
|
let n = t.name;
|
|
12
14
|
return n ? (e[n] || (e[n] = []), e[n].push(t), e) : e;
|
|
@@ -34,29 +36,30 @@ var a;
|
|
|
34
36
|
});
|
|
35
37
|
} else e[t] = n;
|
|
36
38
|
}
|
|
37
|
-
})(
|
|
38
|
-
var
|
|
39
|
+
})(o ||= {});
|
|
40
|
+
var s = o;
|
|
39
41
|
//#endregion
|
|
40
42
|
//#region src/components/form.tsx
|
|
41
|
-
function
|
|
42
|
-
let { onSubmit:
|
|
43
|
+
function c(e, o) {
|
|
44
|
+
let { onSubmit: c, props: l, ...u } = e, d = a(null), f = r("form"), { ref: p, ...m } = l ?? {}, h = i((e) => {
|
|
45
|
+
d.current = e, t(o, e), t(p, e);
|
|
46
|
+
}, [o, p]), g = i((e) => {
|
|
43
47
|
e.preventDefault();
|
|
44
|
-
let t =
|
|
45
|
-
|
|
48
|
+
let t = s.getFormEntries(d.current ?? e.currentTarget);
|
|
49
|
+
c(t, e), f("submit", Object.keys(t), {
|
|
46
50
|
reason: "submit",
|
|
47
51
|
event: e
|
|
48
52
|
});
|
|
49
|
-
}, [
|
|
50
|
-
|
|
51
|
-
onSubmit: f,
|
|
52
|
-
ref: u
|
|
53
|
-
};
|
|
54
|
-
return /* @__PURE__ */ i(e, {
|
|
53
|
+
}, [c, f]);
|
|
54
|
+
return n({
|
|
55
55
|
tag: "form",
|
|
56
|
-
...
|
|
57
|
-
props:
|
|
58
|
-
|
|
56
|
+
...u,
|
|
57
|
+
props: {
|
|
58
|
+
...m,
|
|
59
|
+
onSubmit: g
|
|
60
|
+
}
|
|
61
|
+
}, h);
|
|
59
62
|
}
|
|
60
|
-
|
|
63
|
+
var l = e(c, "Form");
|
|
61
64
|
//#endregion
|
|
62
|
-
export {
|
|
65
|
+
export { l as default };
|
package/components/menu.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("../effects.cjs"),r=require("../box.cjs"),i=require("../behavior.cjs"),a=require("../identity.cjs"),o=require("../keyboard.cjs"),s=require("../placement.cjs"),c=require("../reporting.cjs"),l=require("../layer.cjs"),u=require("./overlay.cjs");let d=require("react"),f=require("react/jsx-runtime");var p;(function(e){let t=e.ITEM_SELECTOR=`[role="menuitem"],[role="menuitemcheckbox"],[role="menuitemradio"]`;function n(e,t){return t instanceof Element&&t.closest(`[role="menu"]`)===e}e.owns=n;function r(e){return[...e.querySelectorAll(t)].filter(t=>n(e,t))}e.items=r;function i(e){return e.getAttribute(`aria-disabled`)===`true`}e.isDisabled=i;function a(e){return e.getAttribute(`aria-haspopup`)===`menu`}e.isSubTrigger=a;function s(e,t,n){if(e.length!==0)return e[t<0?n>0?0:e.length-1:((t+n)%e.length+e.length)%e.length]}e.step=s;function c(e,t,n){let r=o.t.target(t,n,e.length,t=>e[t].textContent??``);return r<0?void 0:e[r]}e.typeaheadTarget=c})(p||={});var m=p,h=(0,d.createContext)(null);function g(e){let t=(0,d.useContext)(h);if(!t)throw Error(`<${e}> must be rendered inside a <Menu>.`);return t}function _(e){let[t,n]=(0,d.useState)([]);return{panels:t,registerLayer:(0,d.useCallback)(t=>{n(e=>[...e,t]);let r=e?.(t);return()=>{n(e=>e.filter(e=>e!==t)),r?.()}},[e])}}var v=(0,d.createContext)(null);function y(e,t){let{trigger:n,children:r,open:a,defaultOpen:o=!1,onOpenChange:s,label:c,labelledBy:u,side:p=`bottom`,align:g=`start`,offset:v=1,flip:y=!0,matchWidth:x=!1,props:S,...C}=e,w=(0,d.useRef)(`first`),T=i.a(e=>{let t=m.items(e),n=w.current===`last`?t[t.length-1]:t[0];w.current=`first`,(n??e).focus()}),{panels:E,registerLayer:D}=_(),O=l.t({haspopup:`menu`,idPrefix:`menu`,id:C.id,open:a,defaultOpen:o,onOpenChange:s,interaction:{component:`menu`,type:`openChange`},onOpened:T,inside:E}),k=i.a(e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),w.current=e.key===`ArrowUp`?`last`:`first`,O.isOpen&&O.panelElement?T(O.panelElement):O.setOpen(!0,{reason:`trigger`,event:e}))}),A=(0,d.useMemo)(()=>({ref:O.trigger.ref,props:{...O.trigger.props,onKeyDown:k}}),[k,O.trigger]),j=i.a(e=>O.setOpen(!1,e)),M=(0,d.useMemo)(()=>({open:O.isOpen,closeAll:j,registerLayer:D}),[j,O.isOpen,D]);return(0,f.jsxs)(f.Fragment,{children:[n(A),(0,f.jsx)(h.Provider,{value:M,children:(0,f.jsx)(b,{layer:O,side:p,align:g,offset:v,flip:y,matchWidth:x,label:c,labelledBy:u??(c?void 0:O.triggerId),contentProps:S,...C,elementRef:t,children:r})})]})}function b(e){let{layer:n,side:a,align:c,offset:l,flip:p,matchWidth:h,label:_,labelledBy:v,contentProps:y,closeSelf:b,elementRef:x,children:S,...C}=e,{platform:w,isOpen:T,id:E,triggerElement:D,setPanel:O}=n,k=(0,d.useCallback)(e=>{O(e),t.l(x,e)},[O,x]),A=g(`Menu`),j=(0,d.useRef)({query:``,at:0}),M=s.t({side:a,align:c,offset:l,flip:p,matchWidth:h,anchor:D}),N={role:`menu`,"aria-label":_,"aria-labelledby":v,tabIndex:-1,onKeyDown:i.a(e=>{let n=e.currentTarget;if(!m.owns(n,e.target))return;let r=m.items(n),i=r.indexOf(document.activeElement),a=t=>{t&&(e.preventDefault(),t.focus())},s=t.m(n)?`ArrowRight`:`ArrowLeft`;switch(e.key){case`ArrowDown`:return a(m.step(r,i,1));case`ArrowUp`:return a(m.step(r,i,-1));case`Home`:return a(r[0]);case`End`:return a(r[r.length-1]);case`Tab`:return A.closeAll({reason:`tab`,event:e});case s:return b?(e.preventDefault(),b({reason:`trigger`,event:e})):void 0}if(o.t.isPrintable(e)){let t=o.t.push(j.current,e.key,e.timeStamp);a(m.typeaheadTarget(r,t,i))}}),onPointerOver:i.a(e=>{let t=e.currentTarget,n=e.target?.closest(m.ITEM_SELECTOR);!n||!m.owns(t,n)||n===document.activeElement||n.focus()}),...y};return w?(0,f.jsx)(r.default,{ref:k,component:`menu`,...C,variant:[C.variant,{topLayer:!0}],...M.layerProps,id:E,props:{popover:`auto`,...N},children:S}):T?(0,f.jsx)(u.default,{contentRef:k,anchor:D,side:a,align:c,offset:l,flip:p,matchWidth:h,component:`menu`,...C,id:E,props:N,children:S}):null}function x(e,o){let{label:s,children:u,disabled:p,side:v=`end`,align:y=`start`,offset:x=0,flip:C=!0,itemProps:w,props:T,...E}=e,D=g(`Menu.Sub`),O=a.t(`menu-sub`),k=i.a(e=>{(m.items(e)[0]??e).focus()}),A=i.a((e,t)=>{e&&t?.focus()}),{panels:j,registerLayer:M}=_(D.registerLayer),N=c.i(`menu.sub`),P=l.t({haspopup:`menu`,idPrefix:`menu-sub`,id:E.id,onOpened:k,onClosing:A,inside:j});n.n(()=>{if(!(!P.isOpen||!P.panelElement))return D.registerLayer(P.panelElement)},[P.isOpen,P.panelElement,D.registerLayer]),n.n(()=>{D.open||P.setOpen(!1,{reason:`imperative`})},[D.open,P.setOpen]),n.n(()=>{if(!P.isOpen)return;let e=new AbortController;return document.addEventListener(`focusin`,e=>{t.p(e,[P.panelElement,P.triggerElement])||P.setOpen(!1,{reason:`imperative`,event:e})},{signal:e.signal}),()=>e.abort()},[P.isOpen,P.panelElement,P.triggerElement,P.setOpen]);let F=i.a(e=>{let n=t.m(e.currentTarget)?`ArrowLeft`:`ArrowRight`;p||e.key!==n||(e.preventDefault(),P.setOpen(!0,{reason:`trigger`,event:e}),N(`openChange`,!0,{reason:`keyboard`,event:e,item:S(s)}))}),I=i.a(e=>{p||P.setOpen(!0,{reason:`trigger`,event:e})}),L=(0,d.useMemo)(()=>({open:P.isOpen,closeAll:D.closeAll,registerLayer:M}),[P.isOpen,D.closeAll,M]);return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(r.default,{tag:`button`,ref:p?void 0:P.trigger.ref,component:`menu.item`,variant:{sub:!0},id:O,props:{type:`button`,role:`menuitem`,tabIndex:-1,"aria-disabled":p||void 0,...P.trigger.props,...w,onKeyDown:F,onPointerEnter:I},children:[s,(0,f.jsx)(r.default,{component:`menu.arrow`})]}),!p&&(0,f.jsx)(h.Provider,{value:L,children:(0,f.jsx)(b,{layer:P,side:v,align:y,offset:x,flip:C,matchWidth:!1,labelledBy:O,contentProps:T,closeSelf:e=>P.setOpen(!1,e),...E,elementRef:o,children:u})})]})}var S=(e,t)=>t??(typeof e==`string`?e:void 0);function C(e){let{onSelect:t,disabled:n,closeOnSelect:a=!0,value:o,props:s,children:l,...u}=e,d=g(`Menu.Item`),p=c.i(`menu.item`),m=i.a(e=>{n||(t?.(e),p(`select`,S(l,o),{reason:`select`,event:e}),a&&d.closeAll({reason:`select`,event:e}))});return(0,f.jsx)(r.default,{tag:`button`,component:`menu.item`,...u,props:{type:`button`,role:`menuitem`,tabIndex:-1,"aria-disabled":n||void 0,...s,onClick:m},children:l})}function w(e){let{checked:t,defaultChecked:n=!1,onCheckedChange:a,disabled:o,closeOnSelect:s=!1,value:l,props:u,children:d,...p}=e,m=g(`Menu.CheckboxItem`),[h,_]=i.i({value:t,defaultValue:n,onChange:a}),v=c.i(`menu.checkboxItem`),y=i.a(e=>{o||(_(!h,{reason:`select`,event:e}),v(`checkedChange`,!h,{reason:`select`,event:e,item:S(d,l)}),s&&m.closeAll({reason:`select`,event:e}))});return(0,f.jsxs)(r.default,{tag:`button`,component:`menu.item`,...p,props:{type:`button`,role:`menuitemcheckbox`,tabIndex:-1,"aria-checked":h,"aria-disabled":o||void 0,...u,onClick:y},children:[(0,f.jsx)(r.default,{component:`menu.indicator`,children:h&&(0,f.jsx)(r.default,{component:`menu.check`})}),d]})}function T(e){let{label:t,value:n,defaultValue:r=``,onValueChange:a,children:o,...s}=e,[l,u]=c.a({value:n,defaultValue:r,onChange:a,interaction:{component:`menu.radioGroup`,type:`valueChange`}}),p=i.a((e,t)=>u(e,{reason:`select`,event:t})),m=(0,d.useMemo)(()=>({value:l,select:p}),[l,p]);return(0,f.jsx)(v.Provider,{value:m,children:(0,f.jsx)(D,{label:t,...s,children:o})})}function E(e){let{value:t,disabled:n,closeOnSelect:a=!1,props:o,children:s,...c}=e,l=g(`Menu.RadioItem`),u=(0,d.useContext)(v);if(!u)throw Error(`<Menu.RadioItem> must be rendered inside a <Menu.RadioGroup>.`);let p=u.value===t,m=i.a(e=>{n||(u.select(t,e),a&&l.closeAll({reason:`select`,event:e}))});return(0,f.jsxs)(r.default,{tag:`button`,component:`menu.item`,...c,props:{type:`button`,role:`menuitemradio`,tabIndex:-1,"aria-checked":p,"aria-disabled":n||void 0,...o,onClick:m},children:[(0,f.jsx)(r.default,{component:`menu.indicator`,children:p&&(0,f.jsx)(r.default,{component:`menu.dot`})}),s]})}function D(e){let{label:t,props:n,children:i,...o}=e,s=a.t(`menu-group`);return(0,f.jsxs)(r.default,{component:`menu.group`,...o,props:{role:`group`,"aria-labelledby":t?s:void 0,...n},children:[t&&(0,f.jsx)(r.default,{component:`menu.label`,id:s,props:{role:`presentation`},children:t}),i]})}function O(e){let{props:t,...n}=e;return(0,f.jsx)(r.default,{component:`menu.separator`,...n,props:{role:`separator`,...t}})}C.displayName=`Menu.Item`,w.displayName=`Menu.CheckboxItem`,T.displayName=`Menu.RadioGroup`,E.displayName=`Menu.RadioItem`,D.displayName=`Menu.Group`,O.displayName=`Menu.Separator`;var k=Object.assign(e.f(y,`Menu`),{Item:C,CheckboxItem:w,RadioGroup:T,RadioItem:E,Group:D,Separator:O,Sub:e.f(x,`Menu.Sub`)});exports.default=k;
|