@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
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("../motion.cjs"),l=require("./semantics.cjs");let u=require("react"),d=require("react/jsx-runtime");var f=0;function p(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 f+=1,n.classList.add(o),()=>{--f,f===0&&n.classList.remove(o)}},[e,o]),a}var m=(0,u.createContext)(null);function h(e){let t=(0,u.useContext)(m);if(!t)throw Error(`<${e}> must be rendered inside a <Dialog>.`);return t}function g(e,t){return(0,d.jsx)(v,{role:`dialog`,...e,elementRef:t})}function _(e,t){return(0,d.jsx)(v,{role:`alertdialog`,...e,modal:!0,dismissible:!1,elementRef:t})}function v(e){let{role:n,trigger:l,children:f,open:h,defaultOpen:g=!1,onOpenChange:_,label:v,labelledBy:b,describedBy:x,modal:S=!0,dismissible:C=!0,lockScroll:w=S,initialFocus:T,elementRef:E,props:D,...O}=e,k=o.t(`dialog`),A=O.id??k,[j,M]=s.a({value:h,defaultValue:g,onChange:_,interaction:{component:n===`alertdialog`?`alertDialog`:`dialog`,type:`openChange`}}),[N,P]=(0,u.useState)(null),F=(0,u.useCallback)(e=>{P(e),t.l(E,e)},[E]),[I,L]=(0,u.useState)(null),[R,z]=(0,u.useState)(!1),[B,V]=(0,u.useState)({title:0,description:0}),H=p(j&&w);a.n({enabled:j,returnTo:I});let U=c.t(f,j,N),W=(0,u.useCallback)(e=>(V(t=>({...t,[e]:t[e]+1})),()=>V(t=>({...t,[e]:t[e]-1}))),[]),G=(0,u.useMemo)(()=>({titleId:`${A}-title`,descriptionId:`${A}-description`,register:W}),[A,W]);y({dialog:N,isOpen:j,domOpen:R,setDomOpen:z,setOpen:M,modal:S,dismissible:C,triggerElement:I}),r.n(()=>{let e=t.f(T);!j||!e||e.focus()},[j,T]);let K=a.a(e=>{M(e=>!e,{reason:`trigger`,event:e})}),q=(0,u.useMemo)(()=>({ref:L,props:{"aria-expanded":j,"aria-haspopup":`dialog`,"aria-controls":j?A:void 0,onClick:K}}),[A,K,j]),J=O;return(0,d.jsxs)(d.Fragment,{children:[H,l?.(q),(0,d.jsx)(m.Provider,{value:G,children:(0,d.jsx)(i.default,{ref:F,tag:`dialog`,component:`dialog`,...J,id:A,props:{role:n,"aria-label":B.title||b?void 0:v,"aria-labelledby":b??(B.title?G.titleId:void 0),"aria-describedby":x??(B.description?G.descriptionId:void 0),...D},children:U})})]})}function y(e){let{dialog:n,isOpen:i,domOpen:o,setDomOpen:s,setOpen:c,modal:l,dismissible:d,triggerElement:f}=e,p=(0,u.useRef)(`imperative`),m=t.s(),h=d?`any`:`closerequest`;r.n(()=>{!n||i===o||(s(i),i?l?n.showModal():n.show():n.close())},[n,i,o,l,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])||b(n,e)?p.current=`outside-pointer`:p.current=`imperative`}),()=>e.abort()},[i,n,f]),a.r({enabled:i&&!l&&!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])&&!b(n,e)||c(!1,{reason:`outside-pointer`,event:e})},{signal:e.signal,capture:!0}),()=>e.abort()},[n,i,d,m,f,c])}function b(e,t){let n=e.getBoundingClientRect();return t.clientX<n.left||t.clientX>n.right||t.clientY<n.top||t.clientY>n.bottom}function x(e){let t=h(`Dialog.Title`);return r.n(()=>t.register(`title`),[t]),(0,d.jsx)(l.H2,{id:t.titleId,component:`dialog.title`,...e})}function S(e){let t=h(`Dialog.Description`);return r.n(()=>t.register(`description`),[t]),(0,d.jsx)(l.P,{id:t.descriptionId,component:`dialog.description`,...e})}x.displayName=`Dialog.Title`,S.displayName=`Dialog.Description`;var C={Title:x,Description:S},w=Object.assign(e.f(g,`Dialog`),C),T=Object.assign(e.f(_,`AlertDialog`),C);exports.AlertDialog=T,exports.default=w;
|
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,166 @@
|
|
|
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 { t as m } from "../motion.mjs";
|
|
11
|
+
import { H2 as h, P as g } from "./semantics.mjs";
|
|
12
|
+
import { createContext as _, useCallback as v, useContext as y, useMemo as b, useRef as x, useState as S } from "react";
|
|
13
|
+
import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
|
|
12
14
|
//#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
|
-
--
|
|
15
|
+
var E = 0;
|
|
16
|
+
function D(e) {
|
|
17
|
+
let { classNames: t, styleElements: n } = o({ overflow: "hidden" }, !1), i = t.slice(1).join(" ");
|
|
18
|
+
return s(() => {
|
|
19
|
+
let t = r();
|
|
20
|
+
if (!(!e || !t || !i)) return E += 1, t.classList.add(i), () => {
|
|
21
|
+
--E, E === 0 && t.classList.remove(i);
|
|
20
22
|
};
|
|
21
|
-
}, [e,
|
|
23
|
+
}, [e, i]), n;
|
|
22
24
|
}
|
|
23
25
|
//#endregion
|
|
24
26
|
//#region src/components/dialog.tsx
|
|
25
|
-
var
|
|
26
|
-
function
|
|
27
|
-
let t =
|
|
27
|
+
var O = _(null);
|
|
28
|
+
function k(e) {
|
|
29
|
+
let t = y(O);
|
|
28
30
|
if (!t) throw Error(`<${e}> must be rendered inside a <Dialog>.`);
|
|
29
31
|
return t;
|
|
30
32
|
}
|
|
31
|
-
function
|
|
32
|
-
return /* @__PURE__ */
|
|
33
|
+
function A(e, t) {
|
|
34
|
+
return /* @__PURE__ */ w(M, {
|
|
33
35
|
role: "dialog",
|
|
34
|
-
...e
|
|
36
|
+
...e,
|
|
37
|
+
elementRef: t
|
|
35
38
|
});
|
|
36
39
|
}
|
|
37
|
-
function
|
|
38
|
-
return /* @__PURE__ */
|
|
40
|
+
function j(e, t) {
|
|
41
|
+
return /* @__PURE__ */ w(M, {
|
|
39
42
|
role: "alertdialog",
|
|
40
43
|
...e,
|
|
41
44
|
modal: !0,
|
|
42
|
-
dismissible: !1
|
|
45
|
+
dismissible: !1,
|
|
46
|
+
elementRef: t
|
|
43
47
|
});
|
|
44
48
|
}
|
|
45
|
-
function
|
|
46
|
-
let { role:
|
|
47
|
-
value:
|
|
48
|
-
defaultValue:
|
|
49
|
-
onChange:
|
|
49
|
+
function M(e) {
|
|
50
|
+
let { role: r, trigger: i, children: a, open: o, defaultOpen: d = !1, onOpenChange: h, label: g, labelledBy: _, describedBy: y, modal: x = !0, dismissible: E = !0, lockScroll: k = x, initialFocus: A, elementRef: j, props: M, ...P } = e, F = f("dialog"), I = P.id ?? F, [L, R] = p({
|
|
51
|
+
value: o,
|
|
52
|
+
defaultValue: d,
|
|
53
|
+
onChange: h,
|
|
50
54
|
interaction: {
|
|
51
|
-
component:
|
|
55
|
+
component: r === "alertdialog" ? "alertDialog" : "dialog",
|
|
52
56
|
type: "openChange"
|
|
53
57
|
}
|
|
54
|
-
}), [
|
|
58
|
+
}), [z, B] = S(null), V = v((e) => {
|
|
59
|
+
B(e), n(j, e);
|
|
60
|
+
}, [j]), [H, U] = S(null), [W, G] = S(!1), [K, q] = S({
|
|
55
61
|
title: 0,
|
|
56
62
|
description: 0
|
|
57
|
-
}),
|
|
58
|
-
|
|
59
|
-
enabled:
|
|
60
|
-
returnTo:
|
|
63
|
+
}), J = D(L && k);
|
|
64
|
+
u({
|
|
65
|
+
enabled: L,
|
|
66
|
+
returnTo: H
|
|
61
67
|
});
|
|
62
|
-
let
|
|
68
|
+
let Y = m(a, L, z), X = v((e) => (q((t) => ({
|
|
63
69
|
...t,
|
|
64
70
|
[e]: t[e] + 1
|
|
65
|
-
})), () =>
|
|
71
|
+
})), () => q((t) => ({
|
|
66
72
|
...t,
|
|
67
73
|
[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:
|
|
74
|
+
}))), []), Z = b(() => ({
|
|
75
|
+
titleId: `${I}-title`,
|
|
76
|
+
descriptionId: `${I}-description`,
|
|
77
|
+
register: X
|
|
78
|
+
}), [I, X]);
|
|
79
|
+
N({
|
|
80
|
+
dialog: z,
|
|
81
|
+
isOpen: L,
|
|
82
|
+
domOpen: W,
|
|
83
|
+
setDomOpen: G,
|
|
84
|
+
setOpen: R,
|
|
85
|
+
modal: x,
|
|
80
86
|
dismissible: E,
|
|
81
|
-
triggerElement:
|
|
82
|
-
}),
|
|
83
|
-
let
|
|
84
|
-
!
|
|
85
|
-
}, [
|
|
86
|
-
let
|
|
87
|
-
|
|
87
|
+
triggerElement: H
|
|
88
|
+
}), s(() => {
|
|
89
|
+
let e = t(A);
|
|
90
|
+
!L || !e || e.focus();
|
|
91
|
+
}, [L, A]);
|
|
92
|
+
let Q = l((e) => {
|
|
93
|
+
R((e) => !e, {
|
|
88
94
|
reason: "trigger",
|
|
89
95
|
event: e
|
|
90
96
|
});
|
|
91
|
-
}),
|
|
92
|
-
ref:
|
|
97
|
+
}), $ = b(() => ({
|
|
98
|
+
ref: U,
|
|
93
99
|
props: {
|
|
94
|
-
"aria-expanded":
|
|
100
|
+
"aria-expanded": L,
|
|
95
101
|
"aria-haspopup": "dialog",
|
|
96
|
-
"aria-controls":
|
|
97
|
-
onClick:
|
|
102
|
+
"aria-controls": L ? I : void 0,
|
|
103
|
+
onClick: Q
|
|
98
104
|
}
|
|
99
105
|
}), [
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
]),
|
|
104
|
-
return /* @__PURE__ */
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
/* @__PURE__ */
|
|
108
|
-
value:
|
|
109
|
-
children: /* @__PURE__ */
|
|
110
|
-
ref:
|
|
106
|
+
I,
|
|
107
|
+
Q,
|
|
108
|
+
L
|
|
109
|
+
]), ee = P;
|
|
110
|
+
return /* @__PURE__ */ T(C, { children: [
|
|
111
|
+
J,
|
|
112
|
+
i?.($),
|
|
113
|
+
/* @__PURE__ */ w(O.Provider, {
|
|
114
|
+
value: Z,
|
|
115
|
+
children: /* @__PURE__ */ w(c, {
|
|
116
|
+
ref: V,
|
|
111
117
|
tag: "dialog",
|
|
112
118
|
component: "dialog",
|
|
113
|
-
...
|
|
114
|
-
id:
|
|
119
|
+
...ee,
|
|
120
|
+
id: I,
|
|
115
121
|
props: {
|
|
116
|
-
role:
|
|
117
|
-
"aria-label":
|
|
118
|
-
"aria-labelledby":
|
|
119
|
-
"aria-describedby":
|
|
120
|
-
...
|
|
122
|
+
role: r,
|
|
123
|
+
"aria-label": K.title || _ ? void 0 : g,
|
|
124
|
+
"aria-labelledby": _ ?? (K.title ? Z.titleId : void 0),
|
|
125
|
+
"aria-describedby": y ?? (K.description ? Z.descriptionId : void 0),
|
|
126
|
+
...M
|
|
121
127
|
},
|
|
122
|
-
children:
|
|
128
|
+
children: Y
|
|
123
129
|
})
|
|
124
130
|
})
|
|
125
131
|
] });
|
|
126
132
|
}
|
|
127
|
-
function
|
|
128
|
-
let { dialog:
|
|
129
|
-
|
|
130
|
-
!
|
|
133
|
+
function N(e) {
|
|
134
|
+
let { dialog: t, isOpen: n, domOpen: r, setDomOpen: o, setOpen: c, modal: l, dismissible: u, triggerElement: f } = e, p = x("imperative"), m = a(), h = u ? "any" : "closerequest";
|
|
135
|
+
s(() => {
|
|
136
|
+
!t || n === r || (o(n), n ? l ? t.showModal() : t.show() : t.close());
|
|
131
137
|
}, [
|
|
138
|
+
t,
|
|
132
139
|
n,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if (!n) return;
|
|
140
|
+
r,
|
|
141
|
+
l,
|
|
142
|
+
o
|
|
143
|
+
]), s(() => {
|
|
144
|
+
if (!t) return;
|
|
139
145
|
let e = new AbortController();
|
|
140
|
-
return
|
|
141
|
-
|
|
146
|
+
return t.addEventListener("close", (e) => {
|
|
147
|
+
o(!1), c(!1, {
|
|
142
148
|
reason: p.current,
|
|
143
149
|
event: e
|
|
144
150
|
}), p.current = "imperative";
|
|
145
151
|
}, { signal: e.signal }), () => e.abort();
|
|
146
152
|
}, [
|
|
147
|
-
|
|
148
|
-
|
|
153
|
+
t,
|
|
154
|
+
o,
|
|
149
155
|
c
|
|
150
|
-
]),
|
|
151
|
-
if (!(!
|
|
156
|
+
]), s(() => {
|
|
157
|
+
if (!(!t || !m)) return t.setAttribute("closedby", h), () => t.removeAttribute("closedby");
|
|
152
158
|
}, [
|
|
153
|
-
|
|
159
|
+
t,
|
|
154
160
|
m,
|
|
155
161
|
h
|
|
156
|
-
]),
|
|
157
|
-
if (!
|
|
162
|
+
]), s(() => {
|
|
163
|
+
if (!n || !t) return;
|
|
158
164
|
let e = new AbortController(), r = (t, n) => document.addEventListener(t, n, {
|
|
159
165
|
signal: e.signal,
|
|
160
166
|
capture: !0
|
|
@@ -162,26 +168,26 @@ function A(e) {
|
|
|
162
168
|
return r("keydown", (e) => {
|
|
163
169
|
e.key === "Escape" && (p.current = "escape");
|
|
164
170
|
}), r("pointerdown", (e) => {
|
|
165
|
-
|
|
171
|
+
i(e, [f]) ? p.current = "trigger" : !i(e, [t]) || P(t, e) ? p.current = "outside-pointer" : p.current = "imperative";
|
|
166
172
|
}), () => e.abort();
|
|
167
173
|
}, [
|
|
168
|
-
i,
|
|
169
174
|
n,
|
|
175
|
+
t,
|
|
170
176
|
f
|
|
171
|
-
]),
|
|
172
|
-
enabled:
|
|
173
|
-
inside: [
|
|
177
|
+
]), d({
|
|
178
|
+
enabled: n && !l && !m,
|
|
179
|
+
inside: [t],
|
|
174
180
|
escapeKey: !0,
|
|
175
181
|
outsidePointer: !1,
|
|
176
182
|
onDismiss: (e, t) => c(!1, {
|
|
177
183
|
reason: "escape",
|
|
178
184
|
event: t
|
|
179
185
|
})
|
|
180
|
-
}),
|
|
181
|
-
if (!
|
|
186
|
+
}), s(() => {
|
|
187
|
+
if (!t || !n || !u || m) return;
|
|
182
188
|
let e = new AbortController();
|
|
183
189
|
return document.addEventListener("pointerdown", (e) => {
|
|
184
|
-
|
|
190
|
+
i(e, [f]) || i(e, [t]) && !P(t, e) || c(!1, {
|
|
185
191
|
reason: "outside-pointer",
|
|
186
192
|
event: e
|
|
187
193
|
});
|
|
@@ -190,39 +196,38 @@ function A(e) {
|
|
|
190
196
|
capture: !0
|
|
191
197
|
}), () => e.abort();
|
|
192
198
|
}, [
|
|
199
|
+
t,
|
|
193
200
|
n,
|
|
194
|
-
|
|
195
|
-
d,
|
|
201
|
+
u,
|
|
196
202
|
m,
|
|
197
203
|
f,
|
|
198
204
|
c
|
|
199
205
|
]);
|
|
200
206
|
}
|
|
201
|
-
function
|
|
207
|
+
function P(e, t) {
|
|
202
208
|
let n = e.getBoundingClientRect();
|
|
203
209
|
return t.clientX < n.left || t.clientX > n.right || t.clientY < n.top || t.clientY > n.bottom;
|
|
204
210
|
}
|
|
205
|
-
function
|
|
206
|
-
let t =
|
|
207
|
-
return
|
|
211
|
+
function F(e) {
|
|
212
|
+
let t = k("Dialog.Title");
|
|
213
|
+
return s(() => t.register("title"), [t]), /* @__PURE__ */ w(h, {
|
|
208
214
|
id: t.titleId,
|
|
209
215
|
component: "dialog.title",
|
|
210
216
|
...e
|
|
211
217
|
});
|
|
212
218
|
}
|
|
213
|
-
function
|
|
214
|
-
let t =
|
|
215
|
-
return
|
|
219
|
+
function I(e) {
|
|
220
|
+
let t = k("Dialog.Description");
|
|
221
|
+
return s(() => t.register("description"), [t]), /* @__PURE__ */ w(g, {
|
|
216
222
|
id: t.descriptionId,
|
|
217
223
|
component: "dialog.description",
|
|
218
224
|
...e
|
|
219
225
|
});
|
|
220
226
|
}
|
|
221
|
-
|
|
222
|
-
var
|
|
223
|
-
Title:
|
|
224
|
-
Description:
|
|
225
|
-
},
|
|
226
|
-
D.displayName = "Dialog", O.displayName = "AlertDialog";
|
|
227
|
+
F.displayName = "Dialog.Title", I.displayName = "Dialog.Description";
|
|
228
|
+
var L = {
|
|
229
|
+
Title: F,
|
|
230
|
+
Description: I
|
|
231
|
+
}, R = Object.assign(e(A, "Dialog"), L), z = Object.assign(e(j, "AlertDialog"), L);
|
|
227
232
|
//#endregion
|
|
228
|
-
export {
|
|
233
|
+
export { z as AlertDialog, R 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"),d=require("../motion.cjs");let f=require("react"),p=require("react/jsx-runtime");var m;(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})(m||={});var h=m,g=(0,f.createContext)(null);function _(e){let t=(0,f.useContext)(g);if(!t)throw Error(`<${e}> must be rendered inside a <Menu>.`);return t}function v(e){let[t,n]=(0,f.useState)([]);return{panels:t,registerLayer:(0,f.useCallback)(t=>{n(e=>[...e,t]);let r=e?.(t);return()=>{n(e=>e.filter(e=>e!==t)),r?.()}},[e])}}var y=(0,f.createContext)(null);function b(e,t){let{trigger:n,children:r,open:a,defaultOpen:o=!1,onOpenChange:s,label:c,labelledBy:u,side:d=`bottom`,align:m=`start`,offset:_=1,flip:y=!0,matchWidth:b=!1,props:S,...C}=e,w=(0,f.useRef)(`first`),T=i.a(e=>{let t=h.items(e),n=w.current===`last`?t[t.length-1]:t[0];w.current=`first`,(n??e).focus()}),{panels:E,registerLayer:D}=v(),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,f.useMemo)(()=>({ref:O.trigger.ref,props:{...O.trigger.props,onKeyDown:k}}),[k,O.trigger]),j=i.a(e=>O.setOpen(!1,e)),M=(0,f.useMemo)(()=>({open:O.isOpen,closeAll:j,registerLayer:D}),[j,O.isOpen,D]);return(0,p.jsxs)(p.Fragment,{children:[n(A),(0,p.jsx)(g.Provider,{value:M,children:(0,p.jsx)(x,{layer:O,side:d,align:m,offset:_,flip:y,matchWidth:b,label:c,labelledBy:u??(c?void 0:O.triggerId),contentProps:S,...C,elementRef:t,children:r})})]})}function x(e){let{layer:n,side:a,align:c,offset:l,flip:m,matchWidth:g,label:v,labelledBy:y,contentProps:b,closeSelf:x,elementRef:S,children:C,...w}=e,{platform:T,isOpen:E,id:D,triggerElement:O,setPanel:k}=n,A=(0,f.useCallback)(e=>{k(e),t.l(S,e)},[k,S]),j=_(`Menu`),M=(0,f.useRef)({query:``,at:0}),N=s.t({side:a,align:c,offset:l,flip:m,matchWidth:g,anchor:O}),P=d.t(C,E,n.panelElement),F={role:`menu`,"aria-label":v,"aria-labelledby":y,tabIndex:-1,onKeyDown:i.a(e=>{let n=e.currentTarget;if(!h.owns(n,e.target))return;let r=h.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(h.step(r,i,1));case`ArrowUp`:return a(h.step(r,i,-1));case`Home`:return a(r[0]);case`End`:return a(r[r.length-1]);case`Tab`:return j.closeAll({reason:`tab`,event:e});case s:return x?(e.preventDefault(),x({reason:`trigger`,event:e})):void 0}if(o.t.isPrintable(e)){let t=o.t.push(M.current,e.key,e.timeStamp);a(h.typeaheadTarget(r,t,i))}}),onPointerOver:i.a(e=>{let t=e.currentTarget,n=e.target?.closest(h.ITEM_SELECTOR);!n||!h.owns(t,n)||n===document.activeElement||n.focus()}),...b};return T?(0,p.jsx)(r.default,{ref:A,component:`menu`,...w,variant:[w.variant,{topLayer:!0}],...N.layerProps,id:D,props:{popover:`auto`,...F},children:P}):E?(0,p.jsx)(u.default,{contentRef:A,anchor:O,side:a,align:c,offset:l,flip:m,matchWidth:g,component:`menu`,...w,id:D,props:F,children:C}):null}function S(e,o){let{label:s,children:u,disabled:d,side:m=`end`,align:y=`start`,offset:b=0,flip:S=!0,itemProps:w,props:T,...E}=e,D=_(`Menu.Sub`),O=a.t(`menu-sub`),k=i.a(e=>{(h.items(e)[0]??e).focus()}),A=i.a((e,t)=>{e&&t?.focus()}),{panels:j,registerLayer:M}=v(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`;d||e.key!==n||(e.preventDefault(),P.setOpen(!0,{reason:`trigger`,event:e}),N(`openChange`,!0,{reason:`keyboard`,event:e,item:C(s)}))}),I=i.a(e=>{d||P.setOpen(!0,{reason:`trigger`,event:e})}),L=(0,f.useMemo)(()=>({open:P.isOpen,closeAll:D.closeAll,registerLayer:M}),[P.isOpen,D.closeAll,M]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(r.default,{tag:`button`,ref:d?void 0:P.trigger.ref,component:`menu.item`,variant:{sub:!0},id:O,props:{type:`button`,role:`menuitem`,tabIndex:-1,"aria-disabled":d||void 0,...P.trigger.props,...w,onKeyDown:F,onPointerEnter:I},children:[s,(0,p.jsx)(r.default,{component:`menu.arrow`})]}),!d&&(0,p.jsx)(g.Provider,{value:L,children:(0,p.jsx)(x,{layer:P,side:m,align:y,offset:b,flip:S,matchWidth:!1,labelledBy:O,contentProps:T,closeSelf:e=>P.setOpen(!1,e),...E,elementRef:o,children:u})})]})}var C=(e,t)=>t??(typeof e==`string`?e:void 0);function w(e){let{onSelect:t,disabled:n,closeOnSelect:a=!0,value:o,props:s,children:l,...u}=e,d=_(`Menu.Item`),f=c.i(`menu.item`),m=i.a(e=>{n||(t?.(e),f(`select`,C(l,o),{reason:`select`,event:e}),a&&d.closeAll({reason:`select`,event:e}))});return(0,p.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 T(e){let{checked:t,defaultChecked:n=!1,onCheckedChange:a,disabled:o,closeOnSelect:s=!1,value:l,props:u,children:d,...f}=e,m=_(`Menu.CheckboxItem`),[h,g]=i.i({value:t,defaultValue:n,onChange:a}),v=c.i(`menu.checkboxItem`),y=i.a(e=>{o||(g(!h,{reason:`select`,event:e}),v(`checkedChange`,!h,{reason:`select`,event:e,item:C(d,l)}),s&&m.closeAll({reason:`select`,event:e}))});return(0,p.jsxs)(r.default,{tag:`button`,component:`menu.item`,...f,props:{type:`button`,role:`menuitemcheckbox`,tabIndex:-1,"aria-checked":h,"aria-disabled":o||void 0,...u,onClick:y},children:[(0,p.jsx)(r.default,{component:`menu.indicator`,children:h&&(0,p.jsx)(r.default,{component:`menu.check`})}),d]})}function E(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`}}),d=i.a((e,t)=>u(e,{reason:`select`,event:t})),m=(0,f.useMemo)(()=>({value:l,select:d}),[l,d]);return(0,p.jsx)(y.Provider,{value:m,children:(0,p.jsx)(O,{label:t,...s,children:o})})}function D(e){let{value:t,disabled:n,closeOnSelect:a=!1,props:o,children:s,...c}=e,l=_(`Menu.RadioItem`),u=(0,f.useContext)(y);if(!u)throw Error(`<Menu.RadioItem> must be rendered inside a <Menu.RadioGroup>.`);let d=u.value===t,m=i.a(e=>{n||(u.select(t,e),a&&l.closeAll({reason:`select`,event:e}))});return(0,p.jsxs)(r.default,{tag:`button`,component:`menu.item`,...c,props:{type:`button`,role:`menuitemradio`,tabIndex:-1,"aria-checked":d,"aria-disabled":n||void 0,...o,onClick:m},children:[(0,p.jsx)(r.default,{component:`menu.indicator`,children:d&&(0,p.jsx)(r.default,{component:`menu.dot`})}),s]})}function O(e){let{label:t,props:n,children:i,...o}=e,s=a.t(`menu-group`);return(0,p.jsxs)(r.default,{component:`menu.group`,...o,props:{role:`group`,"aria-labelledby":t?s:void 0,...n},children:[t&&(0,p.jsx)(r.default,{component:`menu.label`,id:s,props:{role:`presentation`},children:t}),i]})}function k(e){let{props:t,...n}=e;return(0,p.jsx)(r.default,{component:`menu.separator`,...n,props:{role:`separator`,...t}})}w.displayName=`Menu.Item`,T.displayName=`Menu.CheckboxItem`,E.displayName=`Menu.RadioGroup`,D.displayName=`Menu.RadioItem`,O.displayName=`Menu.Group`,k.displayName=`Menu.Separator`;var A=Object.assign(e.f(b,`Menu`),{Item:w,CheckboxItem:T,RadioGroup:E,RadioItem:D,Group:O,Separator:k,Sub:e.f(S,`Menu.Sub`)});exports.default=A;
|