@box-kite/react 2.2.3 → 2.2.5

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.
Files changed (118) hide show
  1. package/.claude/rules/box-kite-rules.md +8 -0
  2. package/.claude/skills/box-kite/SKILL.md +8 -0
  3. package/.claude/skills/box-kite/references/components.md +49 -3
  4. package/.cursor/rules/box-kite.mdc +8 -0
  5. package/AGENTS.md +8 -0
  6. package/BOX_AI_CONTEXT.md +276 -20
  7. package/BOX_KITE_AI_CONTEXT.md +276 -20
  8. package/behavior.cjs +1 -1
  9. package/behavior.mjs +57 -57
  10. package/box.cjs +1 -1
  11. package/box.d.ts +5 -0
  12. package/box.mjs +17 -17
  13. package/catalog.cjs +1 -1
  14. package/catalog.mjs +385 -0
  15. package/client.cjs +1 -1
  16. package/client.mjs +113 -87
  17. package/components/dashboard.cjs +1 -1
  18. package/components/dashboard.mjs +1 -1
  19. package/components/dataGrid/components/dataGridList.d.ts +12 -0
  20. package/components/dataGrid/components/dataGridListAggregate.d.ts +7 -0
  21. package/components/dataGrid/components/dataGridListFilter.d.ts +7 -0
  22. package/components/dataGrid/components/dataGridListFilterSheet.d.ts +11 -0
  23. package/components/dataGrid/components/dataGridListFooter.d.ts +13 -0
  24. package/components/dataGrid/components/dataGridListGroup.d.ts +13 -0
  25. package/components/dataGrid/components/dataGridListItem.d.ts +21 -0
  26. package/components/dataGrid/components/dataGridListLayout.d.ts +20 -0
  27. package/components/dataGrid/components/dataGridListRecord.d.ts +11 -0
  28. package/components/dataGrid/components/dataGridListSelectionBar.d.ts +11 -0
  29. package/components/dataGrid/components/dataGridListSheet.d.ts +30 -0
  30. package/components/dataGrid/components/dataGridListSortSheet.d.ts +10 -0
  31. package/components/dataGrid/components/dataGridListToolbar.d.ts +10 -0
  32. package/components/dataGrid/components/dataGridListValue.d.ts +12 -0
  33. package/components/dataGrid/contracts/dataGridContract.d.ts +32 -0
  34. package/components/dataGrid/models/gridModel.d.ts +3 -0
  35. package/components/dataGrid/models/listModel.d.ts +129 -0
  36. package/components/dataGrid/models/localeText.d.ts +32 -0
  37. package/components/dataGrid/models/viewportModel.d.ts +0 -2
  38. package/components/dataGrid/useListLayout.d.ts +13 -0
  39. package/components/dataGrid.cjs +3 -3
  40. package/components/dataGrid.mjs +1052 -788
  41. package/components/dialog.cjs +1 -1
  42. package/components/dialog.mjs +85 -97
  43. package/components/list/listItemParts.d.ts +9 -0
  44. package/components/list.cjs +1 -0
  45. package/components/list.d.ts +118 -0
  46. package/components/list.mjs +391 -0
  47. package/components/menu.cjs +1 -1
  48. package/components/menu.mjs +25 -25
  49. package/components/overlay.cjs +1 -1
  50. package/components/overlay.mjs +12 -12
  51. package/components/semantics.d.ts +29 -29
  52. package/components/slider.cjs +1 -1
  53. package/components/slider.mjs +1 -1
  54. package/components/sortableList.cjs +1 -0
  55. package/components/sortableList.d.ts +49 -0
  56. package/components/sortableList.mjs +384 -0
  57. package/components/swipeItem.cjs +1 -0
  58. package/components/swipeItem.d.ts +52 -0
  59. package/components/swipeItem.mjs +321 -0
  60. package/components/tabs.cjs +1 -1
  61. package/components/tabs.mjs +1 -1
  62. package/components/toaster.cjs +1 -1
  63. package/components/toaster.mjs +24 -24
  64. package/components/virtualList.cjs +1 -0
  65. package/components/virtualList.d.ts +32 -0
  66. package/components/virtualList.mjs +188 -0
  67. package/dataGridList.cjs +1 -0
  68. package/dataGridList.mjs +1351 -0
  69. package/docs/components.md +5 -1
  70. package/icons/closeIcon.d.ts +2 -0
  71. package/icons/filterIcon.d.ts +2 -0
  72. package/layer.cjs +1 -1
  73. package/layer.mjs +1 -1
  74. package/mcp/src/data.d.ts +2 -0
  75. package/package.json +86 -22
  76. package/placement.cjs +1 -1
  77. package/placement.mjs +10 -10
  78. package/platform.cjs +1 -1
  79. package/platform.mjs +4 -1
  80. package/react/a11y/useControllableState.d.ts +2 -1
  81. package/react/componentsContext.d.ts +4 -0
  82. package/react/componentsProvider.d.ts +10 -0
  83. package/react/resolveStyles.d.ts +2 -1
  84. package/react/theme/theme.d.ts +6 -1
  85. package/react-shared.cjs +1 -1
  86. package/react-shared.mjs +40 -29
  87. package/registry/blocks/dashboard-shell/dashboard-shell.d.ts +3 -1
  88. package/registry/designs/store/address-form.d.ts +11 -0
  89. package/registry/designs/store/cart-items.d.ts +10 -0
  90. package/registry/designs/store/cart-page.d.ts +4 -0
  91. package/registry/designs/store/checkout-page.d.ts +7 -0
  92. package/registry/designs/store/credit-card-form.d.ts +10 -0
  93. package/registry/designs/store/form-field.d.ts +19 -0
  94. package/registry/designs/store/order-summary.d.ts +18 -0
  95. package/registry/designs/store/product-art.d.ts +26 -0
  96. package/registry/designs/store/product-card.d.ts +11 -0
  97. package/registry/designs/store/product-gallery.d.ts +11 -0
  98. package/registry/designs/store/product-grid.d.ts +10 -0
  99. package/registry/designs/store/product-page.d.ts +5 -0
  100. package/registry/designs/store/quantity-stepper.d.ts +13 -0
  101. package/registry/designs/store/shipping-method.d.ts +14 -0
  102. package/registry/designs/store/store-data.d.ts +53 -0
  103. package/registry/designs/store/store-design.d.ts +63 -0
  104. package/registry/designs/store/store-shell.d.ts +12 -0
  105. package/registry/designs/store/storefront-page.d.ts +4 -0
  106. package/registry/designs/store/variant-picker.d.ts +15 -0
  107. package/rsc.cjs +1 -1
  108. package/rsc.d.ts +2 -0
  109. package/rsc.mjs +1 -1
  110. package/scrolling.cjs +1 -0
  111. package/scrolling.mjs +22 -0
  112. package/ssg.cjs +1 -1
  113. package/ssg.mjs +1 -1
  114. package/utils/scroll/scrollUtils.d.ts +6 -0
  115. package/utils/sortable/sortableUtils.d.ts +25 -0
  116. package/utils/swipe/swipeUtils.d.ts +53 -0
  117. package/utils/virtual/measuredWindow.d.ts +28 -0
  118. package/utils/virtual/rowSearch.d.ts +11 -0
@@ -1 +1 @@
1
- "use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../platform.cjs"),t=require("../client.cjs"),n=require("../effects.cjs"),r=require("../box.cjs"),i=require("../behavior.cjs"),a=require("../identity.cjs"),o=require("./semantics.cjs");let s=require("react"),c=require("react/jsx-runtime");var l=0;function u(r){let{classNames:i,styleElements:a}=t.i({overflow:`hidden`},!1),o=i.slice(1).join(` `);return n.n(()=>{let t=e.n();if(!(!r||!t||!o))return l+=1,t.classList.add(o),()=>{--l,l===0&&t.classList.remove(o)}},[r,o]),a}var d=(0,s.createContext)(null);function f(e){let t=(0,s.useContext)(d);if(!t)throw Error(`<${e}> must be rendered inside a <Dialog>.`);return t}function p(e){return(0,c.jsx)(h,{role:`dialog`,...e})}function m(e){return(0,c.jsx)(h,{role:`alertdialog`,...e,modal:!0,dismissible:!1})}function h(t){let{role:o,trigger:l,children:f,open:p,defaultOpen:m=!1,onOpenChange:h,label:_,labelledBy:v,describedBy:y,modal:b=!0,dismissible:x=!0,lockScroll:S=b,initialFocus:C,props:w,...T}=t,E=a.t(`dialog`),D=T.id??E,[O,k]=i.i({value:p,defaultValue:m,onChange:h}),[A,j]=(0,s.useState)(null),[M,N]=(0,s.useState)(null),[P,F]=(0,s.useState)(!1),[I,L]=(0,s.useState)({title:0,description:0}),R=u(O&&S);i.n({enabled:O,returnTo:M});let z=(0,s.useCallback)(e=>(L(t=>({...t,[e]:t[e]+1})),()=>L(t=>({...t,[e]:t[e]-1}))),[]),B=(0,s.useMemo)(()=>({titleId:`${D}-title`,descriptionId:`${D}-description`,register:z}),[D,z]);g({dialog:A,isOpen:O,domOpen:P,setDomOpen:F,setOpen:k,modal:b,dismissible:x,triggerElement:M}),n.n(()=>{let t=e.c(C);!O||!t||t.focus()},[O,C]);let V=i.a(e=>{k(e=>!e,{reason:`trigger`,event:e})}),H=(0,s.useMemo)(()=>({ref:N,props:{"aria-expanded":O,"aria-haspopup":`dialog`,"aria-controls":O?D:void 0,onClick:V}}),[D,V,O]),U=T;return(0,c.jsxs)(c.Fragment,{children:[R,l?.(H),(0,c.jsx)(d.Provider,{value:B,children:(0,c.jsx)(r.default,{ref:j,tag:`dialog`,component:`dialog`,...U,id:D,props:{role:o,"aria-label":I.title||v?void 0:_,"aria-labelledby":v??(I.title?B.titleId:void 0),"aria-describedby":y??(I.description?B.descriptionId:void 0),...w},children:f})})]})}function g(t){let{dialog:r,isOpen:a,domOpen:o,setDomOpen:c,setOpen:l,modal:u,dismissible:d,triggerElement:f}=t,p=(0,s.useRef)(`imperative`),m=e.i(),h=d?`any`:`closerequest`;n.n(()=>{!r||a===o||(c(a),a?u?r.showModal():r.show():r.close())},[r,a,o,u,c]),n.n(()=>{if(!r)return;let e=new AbortController;return r.addEventListener(`close`,e=>{c(!1),l(!1,{reason:p.current,event:e}),p.current=`imperative`},{signal:e.signal}),()=>e.abort()},[r,c,l]),n.n(()=>{if(!(!r||!m))return r.setAttribute(`closedby`,h),()=>r.removeAttribute(`closedby`)},[r,m,h]),n.n(()=>{if(!a||!r)return;let t=new AbortController,n=(e,n)=>document.addEventListener(e,n,{signal:t.signal,capture:!0});return n(`keydown`,e=>{e.key===`Escape`&&(p.current=`escape`)}),n(`pointerdown`,t=>{e.l(t,[f])?p.current=`trigger`:!e.l(t,[r])||_(r,t)?p.current=`outside-pointer`:p.current=`imperative`}),()=>t.abort()},[a,r,f]),i.r({enabled:a&&!u&&!m,inside:[r],escapeKey:!0,outsidePointer:!1,onDismiss:(e,t)=>l(!1,{reason:`escape`,event:t})}),n.n(()=>{if(!r||!a||!d||m)return;let t=new AbortController;return document.addEventListener(`pointerdown`,t=>{e.l(t,[f])||e.l(t,[r])&&!_(r,t)||l(!1,{reason:`outside-pointer`,event:t})},{signal:t.signal,capture:!0}),()=>t.abort()},[r,a,d,m,f,l])}function _(e,t){let n=e.getBoundingClientRect();return t.clientX<n.left||t.clientX>n.right||t.clientY<n.top||t.clientY>n.bottom}function v(e){let t=f(`Dialog.Title`);return n.n(()=>t.register(`title`),[t]),(0,c.jsx)(o.H2,{id:t.titleId,component:`dialog.title`,...e})}function y(e){let t=f(`Dialog.Description`);return n.n(()=>t.register(`description`),[t]),(0,c.jsx)(o.P,{id:t.descriptionId,component:`dialog.description`,...e})}v.displayName=`Dialog.Title`,y.displayName=`Dialog.Description`;var b={Title:v,Description:y},x=Object.assign(p,b),S=Object.assign(m,b);p.displayName=`Dialog`,m.displayName=`AlertDialog`,exports.AlertDialog=S,exports.default=x;
1
+ "use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../client.cjs"),t=require("../platform.cjs"),n=require("../effects.cjs"),r=require("../box.cjs"),i=require("../behavior.cjs"),a=require("../identity.cjs"),o=require("./semantics.cjs");let s=require("react"),c=require("react/jsx-runtime");var l=(0,s.createContext)(null);function u(e){let t=(0,s.useContext)(l);if(!t)throw Error(`<${e}> must be rendered inside a <Dialog>.`);return t}function d(e){return(0,c.jsx)(p,{role:`dialog`,...e})}function f(e){return(0,c.jsx)(p,{role:`alertdialog`,...e,modal:!0,dismissible:!1})}function p(o){let{role:u,trigger:d,children:f,open:p,defaultOpen:h=!1,onOpenChange:g,label:_,labelledBy:v,describedBy:y,modal:b=!0,dismissible:x=!0,lockScroll:S=b,initialFocus:C,props:w,...T}=o,E=a.t(`dialog`),D=T.id??E,[O,k]=i.i({value:p,defaultValue:h,onChange:g}),[A,j]=(0,s.useState)(null),[M,N]=(0,s.useState)(null),[P,F]=(0,s.useState)(!1),[I,L]=(0,s.useState)({title:0,description:0}),R=e.t(O&&S);i.n({enabled:O,returnTo:M});let z=(0,s.useCallback)(e=>(L(t=>({...t,[e]:t[e]+1})),()=>L(t=>({...t,[e]:t[e]-1}))),[]),B=(0,s.useMemo)(()=>({titleId:`${D}-title`,descriptionId:`${D}-description`,register:z}),[D,z]);m({dialog:A,isOpen:O,domOpen:P,setDomOpen:F,setOpen:k,modal:b,dismissible:x,triggerElement:M}),n.n(()=>{let e=t.l(C);!O||!e||e.focus()},[O,C]);let V=i.a(e=>{k(e=>!e,{reason:`trigger`,event:e})}),H=(0,s.useMemo)(()=>({ref:N,props:{"aria-expanded":O,"aria-haspopup":`dialog`,"aria-controls":O?D:void 0,onClick:V}}),[D,V,O]),U=T;return(0,c.jsxs)(c.Fragment,{children:[R,d?.(H),(0,c.jsx)(l.Provider,{value:B,children:(0,c.jsx)(r.default,{ref:j,tag:`dialog`,component:`dialog`,...U,id:D,props:{role:u,"aria-label":I.title||v?void 0:_,"aria-labelledby":v??(I.title?B.titleId:void 0),"aria-describedby":y??(I.description?B.descriptionId:void 0),...w},children:f})})]})}function m(e){let{dialog:r,isOpen:a,domOpen:o,setDomOpen:c,setOpen:l,modal:u,dismissible:d,triggerElement:f}=e,p=(0,s.useRef)(`imperative`),m=t.a(),g=d?`any`:`closerequest`;n.n(()=>{!r||a===o||(c(a),a?u?r.showModal():r.show():r.close())},[r,a,o,u,c]),n.n(()=>{if(!r)return;let e=new AbortController;return r.addEventListener(`close`,e=>{c(!1),l(!1,{reason:p.current,event:e}),p.current=`imperative`},{signal:e.signal}),()=>e.abort()},[r,c,l]),n.n(()=>{if(!(!r||!m))return r.setAttribute(`closedby`,g),()=>r.removeAttribute(`closedby`)},[r,m,g]),n.n(()=>{if(!a||!r)return;let e=new AbortController,n=(t,n)=>document.addEventListener(t,n,{signal:e.signal,capture:!0});return n(`keydown`,e=>{e.key===`Escape`&&(p.current=`escape`)}),n(`pointerdown`,e=>{t.u(e,[f])?p.current=`trigger`:!t.u(e,[r])||h(r,e)?p.current=`outside-pointer`:p.current=`imperative`}),()=>e.abort()},[a,r,f]),i.r({enabled:a&&!u&&!m,inside:[r],escapeKey:!0,outsidePointer:!1,onDismiss:(e,t)=>l(!1,{reason:`escape`,event:t})}),n.n(()=>{if(!r||!a||!d||m)return;let e=new AbortController;return document.addEventListener(`pointerdown`,e=>{t.u(e,[f])||t.u(e,[r])&&!h(r,e)||l(!1,{reason:`outside-pointer`,event:e})},{signal:e.signal,capture:!0}),()=>e.abort()},[r,a,d,m,f,l])}function h(e,t){let n=e.getBoundingClientRect();return t.clientX<n.left||t.clientX>n.right||t.clientY<n.top||t.clientY>n.bottom}function g(e){let t=u(`Dialog.Title`);return n.n(()=>t.register(`title`),[t]),(0,c.jsx)(o.H2,{id:t.titleId,component:`dialog.title`,...e})}function _(e){let t=u(`Dialog.Description`);return n.n(()=>t.register(`description`),[t]),(0,c.jsx)(o.P,{id:t.descriptionId,component:`dialog.description`,...e})}g.displayName=`Dialog.Title`,_.displayName=`Dialog.Description`;var v={Title:g,Description:_},y=Object.assign(d,v),b=Object.assign(f,v);d.displayName=`Dialog`,f.displayName=`AlertDialog`,exports.AlertDialog=b,exports.default=y;
@@ -1,89 +1,77 @@
1
1
  "use client";
2
- import { c as e, i as t, l as n, n as r } from "../platform.mjs";
3
- import { i } from "../client.mjs";
4
- import { n as a } from "../effects.mjs";
5
- import o from "../box.mjs";
6
- import { a as s, i as c, n as l, r as u } from "../behavior.mjs";
7
- import { t as d } from "../identity.mjs";
8
- import { H2 as f, P as p } from "./semantics.mjs";
9
- import { createContext as m, useCallback as h, useContext as g, useMemo as _, useRef as v, useState as y } from "react";
10
- import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
11
- //#region src/react/dialog/useScrollLock.ts
12
- var C = 0;
13
- function w(e) {
14
- let { classNames: t, styleElements: n } = i({ overflow: "hidden" }, !1), o = t.slice(1).join(" ");
15
- return a(() => {
16
- let t = r();
17
- if (!(!e || !t || !o)) return C += 1, t.classList.add(o), () => {
18
- --C, C === 0 && t.classList.remove(o);
19
- };
20
- }, [e, o]), n;
21
- }
22
- //#endregion
2
+ import { t as e } from "../client.mjs";
3
+ import { a as t, l as n, u as r } from "../platform.mjs";
4
+ import { n as i } from "../effects.mjs";
5
+ import a from "../box.mjs";
6
+ import { a as o, i as s, n as c, r as l } from "../behavior.mjs";
7
+ import { t as u } from "../identity.mjs";
8
+ import { H2 as d, P as f } from "./semantics.mjs";
9
+ import { createContext as p, useCallback as m, useContext as h, useMemo as g, useRef as _, useState as v } from "react";
10
+ import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
23
11
  //#region src/components/dialog.tsx
24
- var T = m(null);
25
- function E(e) {
26
- let t = g(T);
12
+ var S = p(null);
13
+ function C(e) {
14
+ let t = h(S);
27
15
  if (!t) throw Error(`<${e}> must be rendered inside a <Dialog>.`);
28
16
  return t;
29
17
  }
30
- function D(e) {
31
- return /* @__PURE__ */ x(k, {
18
+ function w(e) {
19
+ return /* @__PURE__ */ b(E, {
32
20
  role: "dialog",
33
21
  ...e
34
22
  });
35
23
  }
36
- function O(e) {
37
- return /* @__PURE__ */ x(k, {
24
+ function T(e) {
25
+ return /* @__PURE__ */ b(E, {
38
26
  role: "alertdialog",
39
27
  ...e,
40
28
  modal: !0,
41
29
  dismissible: !1
42
30
  });
43
31
  }
44
- function k(t) {
45
- let { role: n, trigger: r, children: i, open: u, defaultOpen: f = !1, onOpenChange: p, label: m, labelledBy: g, describedBy: v, modal: C = !0, dismissible: E = !0, lockScroll: D = C, initialFocus: O, props: k, ...j } = t, M = d("dialog"), N = j.id ?? M, [P, F] = c({
46
- value: u,
47
- defaultValue: f,
48
- onChange: p
49
- }), [I, L] = y(null), [R, z] = y(null), [B, V] = y(!1), [H, U] = y({
32
+ function E(t) {
33
+ let { role: r, trigger: l, children: d, open: f, defaultOpen: p = !1, onOpenChange: h, label: _, labelledBy: C, describedBy: w, modal: T = !0, dismissible: E = !0, lockScroll: O = T, initialFocus: k, props: A, ...j } = t, M = u("dialog"), N = j.id ?? M, [P, F] = s({
34
+ value: f,
35
+ defaultValue: p,
36
+ onChange: h
37
+ }), [I, L] = v(null), [R, z] = v(null), [B, V] = v(!1), [H, U] = v({
50
38
  title: 0,
51
39
  description: 0
52
- }), W = w(P && D);
53
- l({
40
+ }), W = e(P && O);
41
+ c({
54
42
  enabled: P,
55
43
  returnTo: R
56
44
  });
57
- let G = h((e) => (U((t) => ({
45
+ let G = m((e) => (U((t) => ({
58
46
  ...t,
59
47
  [e]: t[e] + 1
60
48
  })), () => U((t) => ({
61
49
  ...t,
62
50
  [e]: t[e] - 1
63
- }))), []), K = _(() => ({
51
+ }))), []), K = g(() => ({
64
52
  titleId: `${N}-title`,
65
53
  descriptionId: `${N}-description`,
66
54
  register: G
67
55
  }), [N, G]);
68
- A({
56
+ D({
69
57
  dialog: I,
70
58
  isOpen: P,
71
59
  domOpen: B,
72
60
  setDomOpen: V,
73
61
  setOpen: F,
74
- modal: C,
62
+ modal: T,
75
63
  dismissible: E,
76
64
  triggerElement: R
77
- }), a(() => {
78
- let t = e(O);
79
- !P || !t || t.focus();
80
- }, [P, O]);
81
- let q = s((e) => {
65
+ }), i(() => {
66
+ let e = n(k);
67
+ !P || !e || e.focus();
68
+ }, [P, k]);
69
+ let q = o((e) => {
82
70
  F((e) => !e, {
83
71
  reason: "trigger",
84
72
  event: e
85
73
  });
86
- }), J = _(() => ({
74
+ }), J = g(() => ({
87
75
  ref: z,
88
76
  props: {
89
77
  "aria-expanded": P,
@@ -96,60 +84,60 @@ function k(t) {
96
84
  q,
97
85
  P
98
86
  ]), Y = j;
99
- return /* @__PURE__ */ S(b, { children: [
87
+ return /* @__PURE__ */ x(y, { children: [
100
88
  W,
101
- r?.(J),
102
- /* @__PURE__ */ x(T.Provider, {
89
+ l?.(J),
90
+ /* @__PURE__ */ b(S.Provider, {
103
91
  value: K,
104
- children: /* @__PURE__ */ x(o, {
92
+ children: /* @__PURE__ */ b(a, {
105
93
  ref: L,
106
94
  tag: "dialog",
107
95
  component: "dialog",
108
96
  ...Y,
109
97
  id: N,
110
98
  props: {
111
- role: n,
112
- "aria-label": H.title || g ? void 0 : m,
113
- "aria-labelledby": g ?? (H.title ? K.titleId : void 0),
114
- "aria-describedby": v ?? (H.description ? K.descriptionId : void 0),
115
- ...k
99
+ role: r,
100
+ "aria-label": H.title || C ? void 0 : _,
101
+ "aria-labelledby": C ?? (H.title ? K.titleId : void 0),
102
+ "aria-describedby": w ?? (H.description ? K.descriptionId : void 0),
103
+ ...A
116
104
  },
117
- children: i
105
+ children: d
118
106
  })
119
107
  })
120
108
  ] });
121
109
  }
122
- function A(e) {
123
- let { dialog: r, isOpen: i, domOpen: o, setDomOpen: s, setOpen: c, modal: l, dismissible: d, triggerElement: f } = e, p = v("imperative"), m = t(), h = d ? "any" : "closerequest";
124
- a(() => {
125
- !r || i === o || (s(i), i ? l ? r.showModal() : r.show() : r.close());
110
+ function D(e) {
111
+ let { dialog: n, isOpen: a, domOpen: o, setDomOpen: s, setOpen: c, modal: u, dismissible: d, triggerElement: f } = e, p = _("imperative"), m = t(), h = d ? "any" : "closerequest";
112
+ i(() => {
113
+ !n || a === o || (s(a), a ? u ? n.showModal() : n.show() : n.close());
126
114
  }, [
127
- r,
128
- i,
115
+ n,
116
+ a,
129
117
  o,
130
- l,
118
+ u,
131
119
  s
132
- ]), a(() => {
133
- if (!r) return;
120
+ ]), i(() => {
121
+ if (!n) return;
134
122
  let e = new AbortController();
135
- return r.addEventListener("close", (e) => {
123
+ return n.addEventListener("close", (e) => {
136
124
  s(!1), c(!1, {
137
125
  reason: p.current,
138
126
  event: e
139
127
  }), p.current = "imperative";
140
128
  }, { signal: e.signal }), () => e.abort();
141
129
  }, [
142
- r,
130
+ n,
143
131
  s,
144
132
  c
145
- ]), a(() => {
146
- if (!(!r || !m)) return r.setAttribute("closedby", h), () => r.removeAttribute("closedby");
133
+ ]), i(() => {
134
+ if (!(!n || !m)) return n.setAttribute("closedby", h), () => n.removeAttribute("closedby");
147
135
  }, [
148
- r,
136
+ n,
149
137
  m,
150
138
  h
151
- ]), a(() => {
152
- if (!i || !r) return;
139
+ ]), i(() => {
140
+ if (!a || !n) return;
153
141
  let e = new AbortController(), t = (t, n) => document.addEventListener(t, n, {
154
142
  signal: e.signal,
155
143
  capture: !0
@@ -157,26 +145,26 @@ function A(e) {
157
145
  return t("keydown", (e) => {
158
146
  e.key === "Escape" && (p.current = "escape");
159
147
  }), t("pointerdown", (e) => {
160
- n(e, [f]) ? p.current = "trigger" : !n(e, [r]) || j(r, e) ? p.current = "outside-pointer" : p.current = "imperative";
148
+ r(e, [f]) ? p.current = "trigger" : !r(e, [n]) || O(n, e) ? p.current = "outside-pointer" : p.current = "imperative";
161
149
  }), () => e.abort();
162
150
  }, [
163
- i,
164
- r,
151
+ a,
152
+ n,
165
153
  f
166
- ]), u({
167
- enabled: i && !l && !m,
168
- inside: [r],
154
+ ]), l({
155
+ enabled: a && !u && !m,
156
+ inside: [n],
169
157
  escapeKey: !0,
170
158
  outsidePointer: !1,
171
159
  onDismiss: (e, t) => c(!1, {
172
160
  reason: "escape",
173
161
  event: t
174
162
  })
175
- }), a(() => {
176
- if (!r || !i || !d || m) return;
163
+ }), i(() => {
164
+ if (!n || !a || !d || m) return;
177
165
  let e = new AbortController();
178
166
  return document.addEventListener("pointerdown", (e) => {
179
- n(e, [f]) || n(e, [r]) && !j(r, e) || c(!1, {
167
+ r(e, [f]) || r(e, [n]) && !O(n, e) || c(!1, {
180
168
  reason: "outside-pointer",
181
169
  event: e
182
170
  });
@@ -185,39 +173,39 @@ function A(e) {
185
173
  capture: !0
186
174
  }), () => e.abort();
187
175
  }, [
188
- r,
189
- i,
176
+ n,
177
+ a,
190
178
  d,
191
179
  m,
192
180
  f,
193
181
  c
194
182
  ]);
195
183
  }
196
- function j(e, t) {
184
+ function O(e, t) {
197
185
  let n = e.getBoundingClientRect();
198
186
  return t.clientX < n.left || t.clientX > n.right || t.clientY < n.top || t.clientY > n.bottom;
199
187
  }
200
- function M(e) {
201
- let t = E("Dialog.Title");
202
- return a(() => t.register("title"), [t]), /* @__PURE__ */ x(f, {
188
+ function k(e) {
189
+ let t = C("Dialog.Title");
190
+ return i(() => t.register("title"), [t]), /* @__PURE__ */ b(d, {
203
191
  id: t.titleId,
204
192
  component: "dialog.title",
205
193
  ...e
206
194
  });
207
195
  }
208
- function N(e) {
209
- let t = E("Dialog.Description");
210
- return a(() => t.register("description"), [t]), /* @__PURE__ */ x(p, {
196
+ function A(e) {
197
+ let t = C("Dialog.Description");
198
+ return i(() => t.register("description"), [t]), /* @__PURE__ */ b(f, {
211
199
  id: t.descriptionId,
212
200
  component: "dialog.description",
213
201
  ...e
214
202
  });
215
203
  }
216
- M.displayName = "Dialog.Title", N.displayName = "Dialog.Description";
217
- var P = {
218
- Title: M,
219
- Description: N
220
- }, F = Object.assign(D, P), I = Object.assign(O, P);
221
- D.displayName = "Dialog", O.displayName = "AlertDialog";
204
+ k.displayName = "Dialog.Title", A.displayName = "Dialog.Description";
205
+ var j = {
206
+ Title: k,
207
+ Description: A
208
+ }, M = Object.assign(w, j), N = Object.assign(T, j);
209
+ w.displayName = "Dialog", T.displayName = "AlertDialog";
222
210
  //#endregion
223
- export { I as AlertDialog, F as default };
211
+ export { N as AlertDialog, M as default };
@@ -0,0 +1,9 @@
1
+ import { BoxComponentStyles } from '@box-kite/core/types';
2
+ /** How an item's spacing is set: `md` by default, `sm` for a dense list, `lg` for one with room to breathe. */
3
+ export type ListItemSize = 'sm' | 'md' | 'lg';
4
+ export declare const ITEM_FRAME: BoxComponentStyles;
5
+ /** The row an item lays its parts out in. */
6
+ export declare const ITEM_ROW: BoxComponentStyles;
7
+ export declare const ITEM_SIZES: Record<ListItemSize, BoxComponentStyles>;
8
+ /** A part's defaults under the props it was given. */
9
+ export declare function withDefaults<T extends object>(defaults: BoxComponentStyles, props: T): T;
@@ -0,0 +1 @@
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../react-shared.cjs"),t=require("./svg.cjs");let n=require("@box-kite/core"),r=require("react/jsx-runtime"),i=require("@box-kite/react");var a={position:`relative`,css:{borderRadius:`var(--list-item-radius, 0)`},before:{position:`absolute`,top:0,insetEnd:0,css:{insetInlineStart:`var(--list-divider-inset, 0px)`,height:`1px`}},after:{position:`absolute`,inset:0,pointerEvents:`none`,css:{border:`var(--list-item-frame, none)`,borderRadius:`inherit`}},nth:{first:{before:{css:{display:`var(--list-first-divider, none)`}}}}},o={display:`flex`,ai:`center`,gap:3,px:4,py:3,minHeight:14},s={sm:{gap:2,py:2,minHeight:11},md:{},lg:{gap:4,py:4,minHeight:18}},c=[`css`,`before`,`after`,`nth`];function l(e,t){let r={...e,...t},i=e;for(let e of c){let a=t[e];i[e]&&a&&(r[e]=(0,n.mergeDeep)(i[e],a))}return r}var u=[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`],d={fontVariantNumeric:`tabular-nums`},f={display:`flex`,ai:`center`,jc:`center`,flexShrink:0},p={icon:{width:10,height:10,borderRadius:2},avatar:{width:10,height:10,borderRadius:999,overflow:`hidden`,fontSize:14,fontWeight:600},image:{width:16,height:16,borderRadius:2,overflow:`hidden`}},m={display:`flex`,ai:`baseline`,jc:`space-between`,gap:2,minWidth:0},h={flexWrap:`wrap`,jc:`start`,rowGap:1},g={fontSize:14,lineHeight:20},_={"list.title":{display:`block`,minWidth:0,fontSize:16,lineHeight:22,fontWeight:500},"list.description":{display:`block`,minWidth:0,fontSize:14,lineHeight:20},"list.overline":{display:`block`,minWidth:0,fontSize:12,lineHeight:16,fontWeight:500}},v={color:`currentColor`,textDecoration:`none`,cursor:`pointer`,css:{display:`inherit`,font:`inherit`,textAlign:`inherit`,overflow:`inherit`,textOverflow:`inherit`,WebkitLineClamp:`inherit`,WebkitBoxOrient:`inherit`},after:{position:`absolute`,inset:0,css:{borderRadius:`var(--list-item-radius, 0)`}}},y={1:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},2:{overflow:`hidden`,css:{display:`-webkit-box`,WebkitBoxOrient:`vertical`,WebkitLineClamp:2}},3:{overflow:`hidden`,css:{display:`-webkit-box`,WebkitBoxOrient:`vertical`,WebkitLineClamp:3}}},b={content:{display:`flex`,d:`column`,gap:.5,flex1:!0,minWidth:0},meta:{flexShrink:0,fontSize:13,lineHeight:18,whiteSpace:`nowrap`,css:d},end:{display:`flex`,d:`column`,ai:`end`,gap:.5,flexShrink:0,maxWidth:`1/2`,textAlign:`end`,css:d},actions:{display:`flex`,ai:`center`,gap:1,flexShrink:0,position:`relative`,zIndex:1},fields:{display:`grid`,columnGap:4,rowGap:2,mt:1,css:{gridTemplateColumns:`repeat(auto-fill, minmax(min(8rem, 100%), 1fr))`}}};function x(e,t){let{props:n,...r}=e;return(0,i.useBoxElement)({tag:`ul`,component:`list`,...r,props:{role:`list`,...n}},t)}function S(e,t){let{size:n=`md`,wrap:c=!1,selected:u=!1,chevron:d=!1,variant:f,children:p,...m}=e;return(0,i.useBoxElement)({tag:`li`,component:`list.item`,...l({...a,...o,...s[n],...c?{flexWrap:`wrap`}:{}},m),variant:[f,{selected:u}],children:d?(0,r.jsxs)(r.Fragment,{children:[p,(0,r.jsx)(w,{})]}):p},t)}function C(e,n){return(0,i.useBoxElement)({tag:`span`,component:`list.muted`,display:`flex`,flexShrink:0,alignSelf:`center`,rtl:{flip:`xAxis`},...e,props:{"aria-hidden":!0,...e.props},children:(0,r.jsx)(t.Svg,{viewBox:`0 0 16 16`,width:`1rem`,fill:`none`,stroke:`currentColor`,strokeWidth:1.75,children:(0,r.jsx)(t.Path,{d:`M6 3.5 10.5 8 6 12.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})},n)}var w=e.f(C,`List.Chevron`);function T(e,t){let r=(0,n.classNames)(e.variant).find(e=>e in p);return(0,i.useBoxElement)({component:`list.media`,...f,...r?p[r]:{},...e},t)}function E(e,t){let{wrap:n=!1,secondary:r=!1,...a}=e;return(0,i.useBoxElement)({...r?{component:`list.muted`,...g}:{},...m,...n?h:{},...a},t)}function D(t,n){let r=t!==`list.title`;return e.f((e,n)=>{let{lines:a,...o}=e,s=a?l(_[t],y[a]):_[t];return(0,i.useBoxElement)({tag:`span`,...r?{component:`list.muted`}:{},...l(s,o)},n)},n)}function O(e,t){let{props:n,tag:r,onClick:a,...o}=e,s=r??(n?.href===void 0?n?.htmlFor===void 0?`button`:`label`:`a`);return(0,i.useBoxElement)({tag:s,component:`list.action`,...l(v,o),props:{...s===`button`?{type:`button`}:{},"data-list-action":``,...n,...a?{onClick:a}:{}}},t)}function k(e,t){let{label:n,children:a,...o}=e;return(0,i.useBoxElement)({minWidth:0,...o,children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(A,{children:n}),(0,r.jsx)(j,{children:a})]})},t)}function A({children:e}){return(0,i.useBoxElement)({tag:`dt`,component:`list.muted`,fontSize:12,lineHeight:16,children:e})}function j({children:e}){return(0,i.useBoxElement)({tag:`dd`,minWidth:0,fontSize:14,lineHeight:20,css:{overflowWrap:`anywhere`,...d},children:e})}function M(e,t){let{label:n,level:a,sticky:o=!1,children:s,...c}=e;return(0,i.useBoxElement)({tag:`li`,...c,children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(N,{level:a,sticky:o,children:n}),(0,r.jsx)(P,{children:s})]})},t)}function N({level:e,sticky:t,children:n}){return(0,i.useBoxElement)({tag:e?u[e-1]:`div`,component:`list.label`,px:4,py:1.5,fontSize:13,lineHeight:18,fontWeight:600,...t?{position:`sticky`,zIndex:2,css:{top:`var(--list-sticky-top, 0)`}}:{},children:n})}function P({children:e}){return(0,i.useBoxElement)({tag:`ul`,props:{role:`list`},children:e})}function F(t,n,r,a=!1){return e.f((e,r)=>(0,i.useBoxElement)({tag:t,...a?{component:`list.muted`}:{},...l(n,e)},r),r)}var I=e.f(T,`List.Media`),L=F(`div`,b.content,`List.Content`),R=D(`list.overline`,`List.Overline`),z=D(`list.title`,`List.Title`),B=D(`list.description`,`List.Description`),V=F(`span`,b.meta,`List.Meta`,!0),H=F(`div`,b.end,`List.End`),U=F(`div`,b.actions,`List.Actions`),W=F(`dl`,b.fields,`List.Fields`),G=e.f(x,`List`);G.Item=e.f(S,`List.Item`),G.Media=I,G.Content=L,G.Row=e.f(E,`List.Row`),G.Overline=R,G.Title=z,G.Description=B,G.Meta=V,G.End=H,G.Actions=U,G.Action=e.f(O,`List.Action`),G.Fields=W,G.Field=e.f(k,`List.Field`),G.Group=e.f(M,`List.Group`),G.Chevron=w,exports.default=G,exports.i=l,exports.n=o,exports.r=s,exports.t=a;
@@ -0,0 +1,118 @@
1
+ import { RefAttributes } from 'react';
2
+ import { BoxProps, BoxTagProps } from '../box';
3
+ import { ExtractElementFromTag } from '../react/reactTypes';
4
+ import { ComponentsAndVariants } from '@box-kite/core/types';
5
+ import { ListItemSize } from './list/listItemParts';
6
+ export type { ListItemSize };
7
+ /** How many lines a text part runs to: `1` ends in an ellipsis, `2` and `3` are clamped. Unset, it wraps. */
8
+ export type ListLines = 1 | 2 | 3;
9
+ /** Which heading a group's label is. It says where the group sits in the page's outline, nothing more. */
10
+ export type ListGroupLevel = 1 | 2 | 3 | 4 | 5 | 6;
11
+ type Part<TTag extends keyof React.JSX.IntrinsicElements, TKey extends keyof ComponentsAndVariants> = BoxProps<TTag, TKey> & RefAttributes<ExtractElementFromTag<TTag>>;
12
+ export interface ListProps<TKey extends keyof ComponentsAndVariants = 'list'> extends Omit<BoxProps<'ul', TKey>, 'tag'> {
13
+ /** The items: `List.Item`s, and `List.Group`s for sections. */
14
+ children?: React.ReactNode;
15
+ /** `ol` when the order means something — steps, a ranking. Default `ul`. */
16
+ tag?: 'ul' | 'ol';
17
+ }
18
+ export interface ListItemProps<TKey extends keyof ComponentsAndVariants = 'list.item'> extends BoxProps<'li', TKey> {
19
+ /** The item's parts: `List.Media`, `List.Content`, `List.End`, `List.Actions` — or anything at all, in one row. */
20
+ children?: React.ReactNode;
21
+ /** The item's spacing. Default `md`, at least 56px tall; `sm` is 44px, still a finger's width; `lg` is 72px. */
22
+ size?: ListItemSize;
23
+ /** Lets the item's parts wrap onto a second line when they do not fit, instead of squeezing. */
24
+ wrap?: boolean;
25
+ /** Tints the item as chosen. The state a reader hears belongs on the control that chose it — a checkbox, `aria-pressed`. */
26
+ selected?: boolean;
27
+ /** Ends the item with a chevron: pressing it goes somewhere with more. Decoration, so `aria-hidden`. */
28
+ chevron?: boolean;
29
+ }
30
+ /** A slot or a plain part: every Box prop, and what goes in it. `List.Media` takes `variant` `icon`, `avatar` or `image`. */
31
+ export interface ListPartProps<TKey extends keyof ComponentsAndVariants = never> extends BoxProps<'div', TKey> {
32
+ /** What goes in it. */
33
+ children?: React.ReactNode;
34
+ }
35
+ export interface ListRowProps<TKey extends keyof ComponentsAndVariants = never> extends BoxProps<'div', TKey> {
36
+ /** What sits side by side: a title and its time, a status and a count. The first takes the room, the last sits at the end. */
37
+ children?: React.ReactNode;
38
+ /** Lets the row's parts wrap onto a new line — a set of tags — instead of pushing the last to the end. */
39
+ wrap?: boolean;
40
+ /** The quieter line under the main one: smaller and muted. */
41
+ secondary?: boolean;
42
+ }
43
+ export interface ListTextProps<TKey extends keyof ComponentsAndVariants = never> extends BoxProps<'span', TKey> {
44
+ /** The text. */
45
+ children?: React.ReactNode;
46
+ /** How many lines it runs to before it stops: `1` ends in an ellipsis, `2` and `3` are clamped. Unset, it wraps. */
47
+ lines?: ListLines;
48
+ }
49
+ /** A `List.Title`: the item's name, and where its `List.Action` goes. */
50
+ export type ListTitleProps<TKey extends keyof ComponentsAndVariants = never> = ListTextProps<TKey>;
51
+ /** A `List.Description`: muted supporting text under the title. */
52
+ export type ListDescriptionProps<TKey extends keyof ComponentsAndVariants = never> = ListTextProps<TKey>;
53
+ /** A `List.Overline`: a small line above the title — an id, a date, a category. */
54
+ export type ListOverlineProps<TKey extends keyof ComponentsAndVariants = never> = ListTextProps<TKey>;
55
+ /** A button's attributes, plus the two that turn the action into a link or a label. */
56
+ export type ListActionTagProps = BoxTagProps<'button'> & Pick<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href' | 'target' | 'rel' | 'download' | 'hrefLang' | 'referrerPolicy'> & Pick<React.LabelHTMLAttributes<HTMLLabelElement>, 'htmlFor'>;
57
+ export interface ListActionProps<TKey extends keyof ComponentsAndVariants = 'list.action'> extends Omit<BoxProps<'button', TKey>, 'props' | 'tag'> {
58
+ /** What the action is called: the item's title, and nothing else, since it is the name a reader hears. */
59
+ children?: React.ReactNode;
60
+ /** The element's attributes. An `href` makes it an `<a>`, an `htmlFor` a `<label>`; neither, a `<button type="button">`. */
61
+ props?: ListActionTagProps;
62
+ /** The element, when what `props` holds does not already say: `a` with no `href` is a placeholder link. */
63
+ tag?: 'button' | 'a' | 'label';
64
+ /** Fires on a press anywhere on the item — and on Enter, and on Space for a button. */
65
+ onClick?: (event: React.MouseEvent<HTMLElement>) => void;
66
+ }
67
+ export interface ListFieldProps<TKey extends keyof ComponentsAndVariants = never> extends BoxProps<'div', TKey> {
68
+ /** What the value is: the `<dt>`. */
69
+ label: React.ReactNode;
70
+ /** The value: the `<dd>`. */
71
+ children?: React.ReactNode;
72
+ }
73
+ export interface ListGroupProps<TKey extends keyof ComponentsAndVariants = never> extends BoxProps<'li', TKey> {
74
+ /** What the items have in common: "Today", "A", "Unread". */
75
+ label: React.ReactNode;
76
+ /** The group's items. */
77
+ children?: React.ReactNode;
78
+ /** Makes the label a heading of this level, so a screen reader can jump between groups. Unset, it is plain text. */
79
+ level?: ListGroupLevel;
80
+ /** Keeps the label at the top of the screen while its items scroll under it, until the next group's pushes it off. */
81
+ sticky?: boolean;
82
+ }
83
+ interface ListType {
84
+ <TKey extends keyof ComponentsAndVariants = 'list'>(props: ListProps<TKey> & RefAttributes<HTMLUListElement>): React.ReactNode;
85
+ /** One thing in the list: a flex row of `Media`, `Content`, `End` and `Actions`. */
86
+ Item: <TKey extends keyof ComponentsAndVariants = 'list.item'>(props: ListItemProps<TKey> & RefAttributes<HTMLLIElement>) => React.ReactNode;
87
+ /** The leading slot: an icon, an avatar, a thumbnail. `variant` is `icon`, `avatar` or `image`. */
88
+ Media: <TKey extends keyof ComponentsAndVariants = 'list.media'>(props: Part<'div', TKey>) => React.ReactNode;
89
+ /** The middle, taking the room: a column of rows and text. */
90
+ Content: <TKey extends keyof ComponentsAndVariants = never>(props: Part<'div', TKey>) => React.ReactNode;
91
+ /** A row of parts inside the content — the main line, or a `secondary` one. */
92
+ Row: <TKey extends keyof ComponentsAndVariants = never>(props: ListRowProps<TKey> & RefAttributes<HTMLDivElement>) => React.ReactNode;
93
+ /** A small line above the title. */
94
+ Overline: <TKey extends keyof ComponentsAndVariants = never>(props: ListOverlineProps<TKey> & RefAttributes<HTMLSpanElement>) => React.ReactNode;
95
+ /** The item's name. */
96
+ Title: <TKey extends keyof ComponentsAndVariants = never>(props: ListTitleProps<TKey> & RefAttributes<HTMLSpanElement>) => React.ReactNode;
97
+ /** Muted supporting text. */
98
+ Description: <TKey extends keyof ComponentsAndVariants = never>(props: ListDescriptionProps<TKey> & RefAttributes<HTMLSpanElement>) => React.ReactNode;
99
+ /** A small value that never wraps: a time, a count. */
100
+ Meta: <TKey extends keyof ComponentsAndVariants = never>(props: Part<'span', TKey>) => React.ReactNode;
101
+ /** The trailing slot: a value and its label, stacked and aligned to the end. */
102
+ End: <TKey extends keyof ComponentsAndVariants = never>(props: Part<'div', TKey>) => React.ReactNode;
103
+ /** Controls of the item's own, above the action that covers it. */
104
+ Actions: <TKey extends keyof ComponentsAndVariants = never>(props: Part<'div', TKey>) => React.ReactNode;
105
+ /** The item's primary action, covering the whole item. */
106
+ Action: <TKey extends keyof ComponentsAndVariants = 'list.action'>(props: ListActionProps<TKey> & RefAttributes<HTMLButtonElement>) => React.ReactNode;
107
+ /** A `<dl>` of `List.Field`s, as many to a line as fit. */
108
+ Fields: <TKey extends keyof ComponentsAndVariants = never>(props: Part<'dl', TKey>) => React.ReactNode;
109
+ /** One labelled value. */
110
+ Field: <TKey extends keyof ComponentsAndVariants = never>(props: ListFieldProps<TKey> & RefAttributes<HTMLDivElement>) => React.ReactNode;
111
+ /** The chevron `chevron` ends an item with, for an item drawn by something else — a `SwipeItem` has the prop too. */
112
+ Chevron: <TKey extends keyof ComponentsAndVariants = never>(props: Part<'span', TKey>) => React.ReactNode;
113
+ /** A labelled section of items. */
114
+ Group: <TKey extends keyof ComponentsAndVariants = never>(props: ListGroupProps<TKey> & RefAttributes<HTMLLIElement>) => React.ReactNode;
115
+ displayName?: string;
116
+ }
117
+ declare const List: ListType;
118
+ export default List;