@box-kite/react 0.0.1 → 1.0.0
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 +43 -0
- package/.claude/skills/box-kite/SKILL.md +431 -0
- package/BOX_AI_CONTEXT.md +1833 -0
- package/BOX_KITE_AI_CONTEXT.md +1833 -0
- package/LICENSE +21 -0
- package/README.md +710 -7
- package/a11y.cjs +1 -0
- package/a11y.d.ts +15 -0
- package/a11y.mjs +3 -0
- package/behavior.cjs +1 -0
- package/behavior.mjs +295 -0
- package/box.cjs +1 -0
- package/box.d.ts +46 -0
- package/box.mjs +23 -0
- package/client.cjs +1 -0
- package/client.mjs +163 -0
- package/components/baseSvg.cjs +1 -0
- package/components/baseSvg.d.ts +5 -0
- package/components/baseSvg.mjs +21 -0
- package/components/button.cjs +1 -0
- package/components/button.d.ts +16 -0
- package/components/button.mjs +19 -0
- package/components/chart.cjs +1 -0
- package/components/chart.d.ts +82 -0
- package/components/chart.mjs +261 -0
- package/components/checkbox.cjs +1 -0
- package/components/checkbox.d.ts +28 -0
- package/components/checkbox.mjs +38 -0
- package/components/dataGrid/components/dataGridBody.d.ts +7 -0
- package/components/dataGrid/components/dataGridBottomBar.d.ts +6 -0
- package/components/dataGrid/components/dataGridCell.d.ts +15 -0
- package/components/dataGrid/components/dataGridCellRowDetail.d.ts +6 -0
- package/components/dataGrid/components/dataGridCellRowSelection.d.ts +6 -0
- package/components/dataGrid/components/dataGridCellText.d.ts +6 -0
- package/components/dataGrid/components/dataGridColumnFilter.d.ts +9 -0
- package/components/dataGrid/components/dataGridColumnGroups.d.ts +7 -0
- package/components/dataGrid/components/dataGridContent.d.ts +6 -0
- package/components/dataGrid/components/dataGridDetailRow.d.ts +8 -0
- package/components/dataGrid/components/dataGridEmptyColumns.d.ts +6 -0
- package/components/dataGrid/components/dataGridFilterCell.d.ts +11 -0
- package/components/dataGrid/components/dataGridFilterRow.d.ts +6 -0
- package/components/dataGrid/components/dataGridGlobalFilter.d.ts +6 -0
- package/components/dataGrid/components/dataGridGroupRow.d.ts +8 -0
- package/components/dataGrid/components/dataGridHeader.d.ts +6 -0
- package/components/dataGrid/components/dataGridHeaderCell.d.ts +9 -0
- package/components/dataGrid/components/dataGridHeaderCellContextMenu.d.ts +11 -0
- package/components/dataGrid/components/dataGridHeaderCellResizer.d.ts +14 -0
- package/components/dataGrid/components/dataGridLoader.d.ts +11 -0
- package/components/dataGrid/components/dataGridPagination.d.ts +6 -0
- package/components/dataGrid/components/dataGridRow.d.ts +8 -0
- package/components/dataGrid/components/dataGridTopBar.d.ts +6 -0
- package/components/dataGrid/components/dataGridTopBarContextMenu.d.ts +6 -0
- package/components/dataGrid/contracts/dataGridContract.d.ts +213 -0
- package/components/dataGrid/gridNavigationContext.d.ts +24 -0
- package/components/dataGrid/models/cellModel.d.ts +18 -0
- package/components/dataGrid/models/columnModel.d.ts +150 -0
- package/components/dataGrid/models/columnVisibilityModel.d.ts +24 -0
- package/components/dataGrid/models/detailRowModel.d.ts +22 -0
- package/components/dataGrid/models/filterModel.d.ts +22 -0
- package/components/dataGrid/models/gridModel.d.ts +206 -0
- package/components/dataGrid/models/groupRowCellModel.d.ts +26 -0
- package/components/dataGrid/models/groupRowModel.d.ts +48 -0
- package/components/dataGrid/models/headerCellModel.d.ts +83 -0
- package/components/dataGrid/models/paginationModel.d.ts +32 -0
- package/components/dataGrid/models/rowModel.d.ts +34 -0
- package/components/dataGrid/models/viewportModel.d.ts +44 -0
- package/components/dataGrid/useGrid.d.ts +8 -0
- package/components/dataGrid/useGridNavigation.d.ts +21 -0
- package/components/dataGrid.cjs +1 -0
- package/components/dataGrid.d.ts +2 -0
- package/components/dataGrid.mjs +3178 -0
- package/components/dropdown/dropdownContext.d.ts +44 -0
- package/components/dropdown/dropdownItems.d.ts +22 -0
- package/components/dropdown/dropdownRowRenderer.d.ts +8 -0
- package/components/dropdown/dropdownSearch.d.ts +21 -0
- package/components/dropdown/utils.d.ts +1 -0
- package/components/dropdown.cjs +1 -0
- package/components/dropdown.d.ts +47 -0
- package/components/dropdown.mjs +479 -0
- package/components/flex.cjs +1 -0
- package/components/flex.d.ts +6 -0
- package/components/flex.mjs +16 -0
- package/components/form.cjs +1 -0
- package/components/form.d.ts +10 -0
- package/components/form.mjs +58 -0
- package/components/grid.cjs +1 -0
- package/components/grid.d.ts +6 -0
- package/components/grid.mjs +16 -0
- package/components/icon.cjs +1 -0
- package/components/icon.d.ts +36 -0
- package/components/icon.mjs +41 -0
- package/components/overlay.cjs +1 -0
- package/components/overlay.d.ts +43 -0
- package/components/overlay.mjs +82 -0
- package/components/presence.cjs +1 -0
- package/components/presence.d.ts +30 -0
- package/components/presence.mjs +11 -0
- package/components/radioButton.cjs +1 -0
- package/components/radioButton.d.ts +24 -0
- package/components/radioButton.mjs +32 -0
- package/components/radioGroup.cjs +1 -0
- package/components/radioGroup.d.ts +38 -0
- package/components/radioGroup.mjs +79 -0
- package/components/select.cjs +1 -0
- package/components/select.d.ts +42 -0
- package/components/select.mjs +36 -0
- package/components/semantics.cjs +1 -0
- package/components/semantics.d.ts +34 -0
- package/components/semantics.mjs +17 -0
- package/components/svg.cjs +1 -0
- package/components/svg.d.ts +63 -0
- package/components/svg.mjs +141 -0
- package/components/switch.cjs +1 -0
- package/components/switch.d.ts +20 -0
- package/components/switch.mjs +25 -0
- package/components/textarea.cjs +1 -0
- package/components/textarea.d.ts +27 -0
- package/components/textarea.mjs +33 -0
- package/components/textbox.cjs +1 -0
- package/components/textbox.d.ts +26 -0
- package/components/textbox.mjs +33 -0
- package/components/tooltip.cjs +1 -0
- package/components/tooltip.d.ts +63 -0
- package/components/tooltip.mjs +108 -0
- package/components/visuallyHidden.cjs +1 -0
- package/components/visuallyHidden.d.ts +6 -0
- package/components/visuallyHidden.mjs +23 -0
- package/effects.cjs +1 -0
- package/effects.mjs +6 -0
- package/forms.cjs +1 -0
- package/forms.mjs +21 -0
- package/icons/dotsIcon.d.ts +2 -0
- package/icons/expandIcon.d.ts +2 -0
- package/icons/groupingIcon.d.ts +2 -0
- package/icons/pinIcon.d.ts +2 -0
- package/icons/searchIcon.d.ts +2 -0
- package/icons/sortIcon.d.ts +2 -0
- package/motion.cjs +1 -0
- package/motion.mjs +66 -0
- package/package.json +203 -7
- package/platform.cjs +1 -0
- package/platform.mjs +32 -0
- package/react/a11y/callbacks.d.ts +12 -0
- package/react/a11y/useControllableState.d.ts +25 -0
- package/react/a11y/useDismiss.d.ts +25 -0
- package/react/a11y/useFocusReturn.d.ts +18 -0
- package/react/a11y/useIdentifier.d.ts +17 -0
- package/react/a11y/useRovingFocus.d.ts +84 -0
- package/react/animation/usePresence.d.ts +32 -0
- package/react/boxClassNames.d.ts +25 -0
- package/react/boxProps.d.ts +49 -0
- package/react/boxTagProps.d.ts +7 -0
- package/react/clientRuntime.d.ts +11 -0
- package/react/effects.d.ts +10 -0
- package/react/forms/labelledControl.d.ts +17 -0
- package/react/forms/placeholderProp.d.ts +13 -0
- package/react/hooks/usePortalContainer.d.ts +1 -0
- package/react/hooks/useVirtualization.d.ts +43 -0
- package/react/hooks/useVisibility.d.ts +9 -0
- package/react/reactTypes.d.ts +10 -0
- package/react/resolveStyles.d.ts +18 -0
- package/react/styleElements.d.ts +3 -0
- package/react/svg/attributesInProps.d.ts +4 -0
- package/react/svg/svgNaming.d.ts +15 -0
- package/react/theme/theme.d.ts +26 -0
- package/react/theme/themeContext.d.ts +7 -0
- package/react/useStyles.d.ts +22 -0
- package/react-shared.cjs +1 -0
- package/react-shared.mjs +105 -0
- package/rolldown-runtime.cjs +1 -0
- package/rsc.cjs +1 -0
- package/rsc.d.ts +27 -0
- package/rsc.mjs +18 -0
- package/ssg.cjs +1 -0
- package/ssg.d.ts +24 -0
- package/ssg.mjs +25 -0
- package/utils/animation/animationUtils.d.ts +29 -0
- package/utils/array/arrayUtils.d.ts +15 -0
- package/utils/box/boxUtils.d.ts +5 -0
- package/utils/chart/chartUtils.d.ts +98 -0
- package/utils/dom/domUtils.d.ts +26 -0
- package/utils/environment/environmentUtils.d.ts +18 -0
- package/utils/fn/fnUtils.d.ts +4 -0
- package/utils/form/formUtils.d.ts +8 -0
- package/utils/memo.d.ts +10 -0
- package/utils/object/objectUtils.d.ts +13 -0
- package/utils/string/fuzzySearch.d.ts +27 -0
- package/utils/string/stringUtils.d.ts +4 -0
package/a11y.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./behavior.cjs");exports.useControllableState=e.a,exports.useDismiss=e.i,exports.useFocusReturn=e.r,exports.useIdentifier=e.n,exports.useRovingFocus=e.t;
|
package/a11y.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@box-kite/react/a11y` — the behaviour primitives the accessible components are built from. Every
|
|
3
|
+
* APG pattern needs the same four mechanics (return focus, move through a list, dismiss, hold a value the
|
|
4
|
+
* consumer may own), none of them visible in the markup, so they live here once and are published because
|
|
5
|
+
* this library will never cover every pattern. Client hooks: the entry carries a `'use client'` banner.
|
|
6
|
+
*/
|
|
7
|
+
export { default as useControllableState } from './react/a11y/useControllableState';
|
|
8
|
+
export type { ChangeDetails, ChangeHandler, ControllableStateOptions, SetControllableState } from './react/a11y/useControllableState';
|
|
9
|
+
export { default as useDismiss } from './react/a11y/useDismiss';
|
|
10
|
+
export type { DismissOptions, DismissReason, ElementLike } from './react/a11y/useDismiss';
|
|
11
|
+
export { default as useFocusReturn } from './react/a11y/useFocusReturn';
|
|
12
|
+
export type { FocusReturnOptions } from './react/a11y/useFocusReturn';
|
|
13
|
+
export { default as useIdentifier } from './react/a11y/useIdentifier';
|
|
14
|
+
export { default as useRovingFocus } from './react/a11y/useRovingFocus';
|
|
15
|
+
export type { RovingFocus, RovingFocusItemProps, RovingFocusOptions, RovingFocusReason, RovingOrientation, } from './react/a11y/useRovingFocus';
|
package/a11y.mjs
ADDED
package/behavior.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./rolldown-runtime.cjs"),t=require("./platform.cjs"),n=require("./effects.cjs");let r=require("react");r=e.t(r,1);function i(e){let t=(0,r.useRef)(e);return n.n(()=>{t.current=e}),t}function a(e){let t=i(e);return(0,r.useCallback)((...e)=>t.current?.(...e),[t])}function o(e){let{value:t,defaultValue:n,onChange:o}=e,s=t!==void 0,[c,l]=(0,r.useState)(n),u=s?t:c,d=i(u),f=a(o);return[u,(0,r.useCallback)((e,t)=>{let n=typeof e==`function`?e(d.current):e;Object.is(n,d.current)||(l(n),f(n,t))},[f,d])]}var s=[];function c(e,t){let n=t.elements();return e.elements().some(e=>n.some(t=>e!==t&&e.contains(t)))}function l(){let e=s.filter(e=>!s.some(t=>t!==e&&c(e,t)));return e[e.length-1]}function u(e){let{enabled:r=!0,onDismiss:o,inside:c,escapeKey:u=!0,outsidePointer:d=!0}=e,f=i(c),p=a(o);n.n(()=>{if(!r)return;let e={elements:()=>(f.current??[]).map(e=>t.r(e)).filter(e=>e!==null)};s.push(e);let n=new AbortController,i=(e,t)=>document.addEventListener(e,t,{signal:n.signal});return u&&i(`keydown`,t=>{t.key!==`Escape`||t.defaultPrevented||l()===e&&p(`escape`,t)}),d&&i(`pointerdown`,e=>{t.a(e,f.current??[])||p(`outside-pointer`,e)}),()=>{n.abort();let t=s.indexOf(e);t!==-1&&s.splice(t,1)}},[r,u,d,p,f])}function d(){let e=t.t()?.activeElement;return e&&e!==document.body?e:null}function f(e={}){let{enabled:n=!0,returnTo:i,preventScroll:o}=e,[s,c]=(0,r.useState)(null),[l,u]=(0,r.useState)(!1);n!==l&&(u(n),n&&c(d()));let f=a(()=>{(t.i(i)??s)?.focus({preventScroll:o})});return(0,r.useEffect)(()=>{if(n)return()=>{let e=document.activeElement;(!e||e===document.body||!document.contains(e))&&f()}},[n,f]),{returnFocus:f}}var p=r.default.useId??(()=>void 0),m=0;function h(e){return e.replace(/[^\w-]/g,``)}function g(e=`box`){let t=p(),[n]=(0,r.useState)(()=>`${++m}`);return`${e}-${t?h(t):n}`}var _=1e3,v=10;function y(e,t){return t<0?-1:Math.max(0,Math.min(e,t))}function b(e,t,n,r,i){if(n===0)return-1;let a=e;for(let e=0;e<n;e++){if(a+=t,a<0||a>=n){if(!r)return-1;a=(a%n+n)%n}if(!i?.(a))return a}return-1}function x(e,t,n){return b(e===1?-1:t,e,t,!1,n)}function S(e,t,n,r,i){if(n===0)return-1;let a=[...e],o=a.every(e=>e===a[0]),s=(o?a[0]:e).toLowerCase(),c=o?t+1:t;for(let e=0;e<n;e++){let t=((c+e)%n+n)%n;if(!i?.(t)&&r(t).trim().toLowerCase().startsWith(s))return t}return-1}function C(e){return e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey}function w(e){let{count:n,columns:a,columnIndexOf:s,pageSize:c=v,defaultActiveColumn:l=0,onActiveCellChange:u,orientation:d=`vertical`,loop:f=!0,activeIndex:p,defaultActiveIndex:m=0,onActiveIndexChange:h,isDisabled:g,textOf:w,focusItems:T=!0,onSelect:E}=e,[D,O]=o({value:p,defaultValue:m,onChange:h}),k=Math.min(D,n-1),A=a!==void 0,j=(0,r.useCallback)(e=>typeof a==`function`?a(e):a??0,[a]),M=(0,r.useCallback)((e,t)=>{let n=j(e);if(!s)return y(t,n-1);if(n<=0)return-1;let r=0;for(;r+1<n&&s(e,r+1)<=t;)r++;return r},[s,j]),[N,P]=(0,r.useState)(l),F=A&&k>=0?M(k,N):-1,I=(0,r.useRef)([]),L=(0,r.useRef)(new Map),R=(0,r.useRef)(new Map),z=(0,r.useRef)(new Map),B=(0,r.useRef)({query:``,at:0}),V=(0,r.useCallback)(e=>{I.current[e]?.focus()},[]),H=(0,r.useRef)(!1),U=(0,r.useCallback)((e,t)=>{H.current=!0,R.current.get(`${e}:${t}`)?.focus(),H.current=!1},[]),W=(0,r.useCallback)(()=>A?R.current.get(`${k}:${F}`)??null:I.current[k]??null,[F,k,A]),G=i({row:k,column:F}),K=i(N),q=i(u),J=i(j),Y=i(M),X=i(s),Z=(0,r.useCallback)((e,t,r)=>{let i=y(e,n-1),a=Math.max(0,t),o=i<0?-1:Y.current(i,a),s=G.current;return i===s.row&&o===s.column?s:(O(i,r),P(a),q.current?.({row:i,column:o},r),{row:i,column:o})},[G,Y,q,n,O]),Q=(0,r.useCallback)((e,t,r)=>{let i=y(e,n-1),a=i<0?-1:y(Math.max(0,t),J.current(i)-1);return Z(i,a<0?0:X.current?.(i,a)??a,r)},[X,n,Z,J]),ee=(0,r.useCallback)((e,t)=>{let n=`${e}:${t}`;return z.current.has(n)||z.current.set(n,e=>{e?R.current.set(n,e):(R.current.delete(n),z.current.delete(n))}),{ref:z.current.get(n),tabIndex:e===k&&t===F?0:-1,onFocus:()=>{H.current||Q(e,t,{reason:`focus`})}}},[F,k,Q]),te=(0,r.useCallback)(e=>(L.current.has(e)||L.current.set(e,t=>{I.current[e]=t}),{ref:L.current.get(e),tabIndex:T?e===k?0:-1:void 0,onFocus:T?()=>O(e,{reason:`focus`}):void 0}),[k,T,O]),$=(0,r.useCallback)(e=>{let{row:r,column:i}=G.current,a=(t,n)=>{e.preventDefault();let r=Q(t,n,{reason:`keyboard`,event:e});T&&U(r.row,r.column)},o=t=>{e.preventDefault();let n=Z(t,K.current,{reason:`keyboard`,event:e});T&&U(n.row,n.column)},s=2**53-1,l=()=>t.o(e.currentTarget)?-1:1;switch(e.key){case`ArrowRight`:return a(r,i+l());case`ArrowLeft`:return a(r,i-l());case`ArrowDown`:return o(r+1);case`ArrowUp`:return o(r-1);case`Home`:return e.ctrlKey||e.metaKey?a(0,0):a(r,0);case`End`:return e.ctrlKey||e.metaKey?a(n-1,s):a(r,s);case`PageDown`:return o(r+c);case`PageUp`:return o(r-c)}},[G,n,K,U,T,c,Z,Q]);return{activeIndex:k,activeColumn:F,setActiveIndex:O,setActiveCell:Q,onKeyDown:(0,r.useCallback)(e=>{if(e.defaultPrevented)return;if(A){$(e);return}let r=d!==`horizontal`,i=d!==`vertical`,a=B.current,o=a.query!==``&&e.timeStamp-a.at<_,s=(t,n)=>{t!==-1&&t!==k&&(e.preventDefault(),O(t,{reason:n,event:e}),T&&V(t))};if(i&&(e.key===`ArrowRight`||e.key===`ArrowLeft`)){let r=e.key===`ArrowRight`!==t.o(e.currentTarget);s(b(k,r?1:-1,n,f,g),`keyboard`);return}if(e.key===`ArrowDown`&&r){s(b(k,1,n,f,g),`keyboard`);return}if(e.key===`ArrowUp`&&r){s(b(k,-1,n,f,g),`keyboard`);return}if(e.key===`Home`){s(x(1,n,g),`keyboard`);return}if(e.key===`End`){s(x(-1,n,g),`keyboard`);return}if(e.key===`Enter`||e.key===` `&&!(o&&w)){if(!E||k===-1)return;e.preventDefault(),E(k,e);return}w&&C(e)&&(a.query=o?a.query+e.key:e.key,a.at=e.timeStamp,s(S(a.query,k,n,w,g),`typeahead`))},[k,n,V,T,g,A,f,$,E,d,O,w]),itemProps:te,cellProps:ee,activeItem:W}}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return w}});
|
package/behavior.mjs
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { a as e, i as t, o as n, r, t as i } from "./platform.mjs";
|
|
2
|
+
import { n as a } from "./effects.mjs";
|
|
3
|
+
import o, { useCallback as s, useEffect as c, useRef as l, useState as u } from "react";
|
|
4
|
+
//#region src/react/a11y/callbacks.ts
|
|
5
|
+
function d(e) {
|
|
6
|
+
let t = l(e);
|
|
7
|
+
return a(() => {
|
|
8
|
+
t.current = e;
|
|
9
|
+
}), t;
|
|
10
|
+
}
|
|
11
|
+
function f(e) {
|
|
12
|
+
let t = d(e);
|
|
13
|
+
return s((...e) => t.current?.(...e), [t]);
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/react/a11y/useControllableState.ts
|
|
17
|
+
function p(e) {
|
|
18
|
+
let { value: t, defaultValue: n, onChange: r } = e, i = t !== void 0, [a, o] = u(n), c = i ? t : a, l = d(c), p = f(r);
|
|
19
|
+
return [c, s((e, t) => {
|
|
20
|
+
let n = typeof e == "function" ? e(l.current) : e;
|
|
21
|
+
Object.is(n, l.current) || (o(n), p(n, t));
|
|
22
|
+
}, [p, l])];
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/react/a11y/useDismiss.ts
|
|
26
|
+
var m = [];
|
|
27
|
+
function h(e, t) {
|
|
28
|
+
let n = t.elements();
|
|
29
|
+
return e.elements().some((e) => n.some((t) => e !== t && e.contains(t)));
|
|
30
|
+
}
|
|
31
|
+
function g() {
|
|
32
|
+
let e = m.filter((e) => !m.some((t) => t !== e && h(e, t)));
|
|
33
|
+
return e[e.length - 1];
|
|
34
|
+
}
|
|
35
|
+
function _(t) {
|
|
36
|
+
let { enabled: n = !0, onDismiss: i, inside: o, escapeKey: s = !0, outsidePointer: c = !0 } = t, l = d(o), u = f(i);
|
|
37
|
+
a(() => {
|
|
38
|
+
if (!n) return;
|
|
39
|
+
let t = { elements: () => (l.current ?? []).map((e) => r(e)).filter((e) => e !== null) };
|
|
40
|
+
m.push(t);
|
|
41
|
+
let i = new AbortController(), a = (e, t) => document.addEventListener(e, t, { signal: i.signal });
|
|
42
|
+
return s && a("keydown", (e) => {
|
|
43
|
+
e.key !== "Escape" || e.defaultPrevented || g() === t && u("escape", e);
|
|
44
|
+
}), c && a("pointerdown", (t) => {
|
|
45
|
+
e(t, l.current ?? []) || u("outside-pointer", t);
|
|
46
|
+
}), () => {
|
|
47
|
+
i.abort();
|
|
48
|
+
let e = m.indexOf(t);
|
|
49
|
+
e !== -1 && m.splice(e, 1);
|
|
50
|
+
};
|
|
51
|
+
}, [
|
|
52
|
+
n,
|
|
53
|
+
s,
|
|
54
|
+
c,
|
|
55
|
+
u,
|
|
56
|
+
l
|
|
57
|
+
]);
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/react/a11y/useFocusReturn.ts
|
|
61
|
+
function v() {
|
|
62
|
+
let e = i()?.activeElement;
|
|
63
|
+
return e && e !== document.body ? e : null;
|
|
64
|
+
}
|
|
65
|
+
function y(e = {}) {
|
|
66
|
+
let { enabled: n = !0, returnTo: r, preventScroll: i } = e, [a, o] = u(null), [s, l] = u(!1);
|
|
67
|
+
n !== s && (l(n), n && o(v()));
|
|
68
|
+
let d = f(() => {
|
|
69
|
+
(t(r) ?? a)?.focus({ preventScroll: i });
|
|
70
|
+
});
|
|
71
|
+
return c(() => {
|
|
72
|
+
if (n) return () => {
|
|
73
|
+
let e = document.activeElement;
|
|
74
|
+
(!e || e === document.body || !document.contains(e)) && d();
|
|
75
|
+
};
|
|
76
|
+
}, [n, d]), { returnFocus: d };
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/react/a11y/useIdentifier.ts
|
|
80
|
+
var b = o.useId ?? (() => void 0), x = 0;
|
|
81
|
+
function S(e) {
|
|
82
|
+
return e.replace(/[^\w-]/g, "");
|
|
83
|
+
}
|
|
84
|
+
function C(e = "box") {
|
|
85
|
+
let t = b(), [n] = u(() => `${++x}`);
|
|
86
|
+
return `${e}-${t ? S(t) : n}`;
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/react/a11y/useRovingFocus.ts
|
|
90
|
+
var ee = 1e3, w = 10;
|
|
91
|
+
function T(e, t) {
|
|
92
|
+
return t < 0 ? -1 : Math.max(0, Math.min(e, t));
|
|
93
|
+
}
|
|
94
|
+
function E(e, t, n, r, i) {
|
|
95
|
+
if (n === 0) return -1;
|
|
96
|
+
let a = e;
|
|
97
|
+
for (let e = 0; e < n; e++) {
|
|
98
|
+
if (a += t, a < 0 || a >= n) {
|
|
99
|
+
if (!r) return -1;
|
|
100
|
+
a = (a % n + n) % n;
|
|
101
|
+
}
|
|
102
|
+
if (!i?.(a)) return a;
|
|
103
|
+
}
|
|
104
|
+
return -1;
|
|
105
|
+
}
|
|
106
|
+
function D(e, t, n) {
|
|
107
|
+
return E(e === 1 ? -1 : t, e, t, !1, n);
|
|
108
|
+
}
|
|
109
|
+
function O(e, t, n, r, i) {
|
|
110
|
+
if (n === 0) return -1;
|
|
111
|
+
let a = [...e], o = a.every((e) => e === a[0]), s = (o ? a[0] : e).toLowerCase(), c = o ? t + 1 : t;
|
|
112
|
+
for (let e = 0; e < n; e++) {
|
|
113
|
+
let t = ((c + e) % n + n) % n;
|
|
114
|
+
if (!i?.(t) && r(t).trim().toLowerCase().startsWith(s)) return t;
|
|
115
|
+
}
|
|
116
|
+
return -1;
|
|
117
|
+
}
|
|
118
|
+
function k(e) {
|
|
119
|
+
return e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey;
|
|
120
|
+
}
|
|
121
|
+
function A(e) {
|
|
122
|
+
let { count: t, columns: r, columnIndexOf: i, pageSize: a = w, defaultActiveColumn: o = 0, onActiveCellChange: c, orientation: f = "vertical", loop: m = !0, activeIndex: h, defaultActiveIndex: g = 0, onActiveIndexChange: _, isDisabled: v, textOf: y, focusItems: b = !0, onSelect: x } = e, [S, C] = p({
|
|
123
|
+
value: h,
|
|
124
|
+
defaultValue: g,
|
|
125
|
+
onChange: _
|
|
126
|
+
}), A = Math.min(S, t - 1), j = r !== void 0, M = s((e) => typeof r == "function" ? r(e) : r ?? 0, [r]), N = s((e, t) => {
|
|
127
|
+
let n = M(e);
|
|
128
|
+
if (!i) return T(t, n - 1);
|
|
129
|
+
if (n <= 0) return -1;
|
|
130
|
+
let r = 0;
|
|
131
|
+
for (; r + 1 < n && i(e, r + 1) <= t;) r++;
|
|
132
|
+
return r;
|
|
133
|
+
}, [i, M]), [P, F] = u(o), I = j && A >= 0 ? N(A, P) : -1, L = l([]), R = l(/* @__PURE__ */ new Map()), z = l(/* @__PURE__ */ new Map()), B = l(/* @__PURE__ */ new Map()), V = l({
|
|
134
|
+
query: "",
|
|
135
|
+
at: 0
|
|
136
|
+
}), H = s((e) => {
|
|
137
|
+
L.current[e]?.focus();
|
|
138
|
+
}, []), U = l(!1), W = s((e, t) => {
|
|
139
|
+
U.current = !0, z.current.get(`${e}:${t}`)?.focus(), U.current = !1;
|
|
140
|
+
}, []), te = s(() => j ? z.current.get(`${A}:${I}`) ?? null : L.current[A] ?? null, [
|
|
141
|
+
I,
|
|
142
|
+
A,
|
|
143
|
+
j
|
|
144
|
+
]), G = d({
|
|
145
|
+
row: A,
|
|
146
|
+
column: I
|
|
147
|
+
}), K = d(P), q = d(c), J = d(M), Y = d(N), X = d(i), Z = s((e, n, r) => {
|
|
148
|
+
let i = T(e, t - 1), a = Math.max(0, n), o = i < 0 ? -1 : Y.current(i, a), s = G.current;
|
|
149
|
+
return i === s.row && o === s.column ? s : (C(i, r), F(a), q.current?.({
|
|
150
|
+
row: i,
|
|
151
|
+
column: o
|
|
152
|
+
}, r), {
|
|
153
|
+
row: i,
|
|
154
|
+
column: o
|
|
155
|
+
});
|
|
156
|
+
}, [
|
|
157
|
+
G,
|
|
158
|
+
Y,
|
|
159
|
+
q,
|
|
160
|
+
t,
|
|
161
|
+
C
|
|
162
|
+
]), Q = s((e, n, r) => {
|
|
163
|
+
let i = T(e, t - 1), a = i < 0 ? -1 : T(Math.max(0, n), J.current(i) - 1);
|
|
164
|
+
return Z(i, a < 0 ? 0 : X.current?.(i, a) ?? a, r);
|
|
165
|
+
}, [
|
|
166
|
+
X,
|
|
167
|
+
t,
|
|
168
|
+
Z,
|
|
169
|
+
J
|
|
170
|
+
]), ne = s((e, t) => {
|
|
171
|
+
let n = `${e}:${t}`;
|
|
172
|
+
return B.current.has(n) || B.current.set(n, (e) => {
|
|
173
|
+
e ? z.current.set(n, e) : (z.current.delete(n), B.current.delete(n));
|
|
174
|
+
}), {
|
|
175
|
+
ref: B.current.get(n),
|
|
176
|
+
tabIndex: e === A && t === I ? 0 : -1,
|
|
177
|
+
onFocus: () => {
|
|
178
|
+
U.current || Q(e, t, { reason: "focus" });
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
}, [
|
|
182
|
+
I,
|
|
183
|
+
A,
|
|
184
|
+
Q
|
|
185
|
+
]), re = s((e) => (R.current.has(e) || R.current.set(e, (t) => {
|
|
186
|
+
L.current[e] = t;
|
|
187
|
+
}), {
|
|
188
|
+
ref: R.current.get(e),
|
|
189
|
+
tabIndex: b ? e === A ? 0 : -1 : void 0,
|
|
190
|
+
onFocus: b ? () => C(e, { reason: "focus" }) : void 0
|
|
191
|
+
}), [
|
|
192
|
+
A,
|
|
193
|
+
b,
|
|
194
|
+
C
|
|
195
|
+
]), $ = s((e) => {
|
|
196
|
+
let { row: r, column: i } = G.current, o = (t, n) => {
|
|
197
|
+
e.preventDefault();
|
|
198
|
+
let r = Q(t, n, {
|
|
199
|
+
reason: "keyboard",
|
|
200
|
+
event: e
|
|
201
|
+
});
|
|
202
|
+
b && W(r.row, r.column);
|
|
203
|
+
}, s = (t) => {
|
|
204
|
+
e.preventDefault();
|
|
205
|
+
let n = Z(t, K.current, {
|
|
206
|
+
reason: "keyboard",
|
|
207
|
+
event: e
|
|
208
|
+
});
|
|
209
|
+
b && W(n.row, n.column);
|
|
210
|
+
}, c = 2 ** 53 - 1, l = () => n(e.currentTarget) ? -1 : 1;
|
|
211
|
+
switch (e.key) {
|
|
212
|
+
case "ArrowRight": return o(r, i + l());
|
|
213
|
+
case "ArrowLeft": return o(r, i - l());
|
|
214
|
+
case "ArrowDown": return s(r + 1);
|
|
215
|
+
case "ArrowUp": return s(r - 1);
|
|
216
|
+
case "Home": return e.ctrlKey || e.metaKey ? o(0, 0) : o(r, 0);
|
|
217
|
+
case "End": return e.ctrlKey || e.metaKey ? o(t - 1, c) : o(r, c);
|
|
218
|
+
case "PageDown": return s(r + a);
|
|
219
|
+
case "PageUp": return s(r - a);
|
|
220
|
+
}
|
|
221
|
+
}, [
|
|
222
|
+
G,
|
|
223
|
+
t,
|
|
224
|
+
K,
|
|
225
|
+
W,
|
|
226
|
+
b,
|
|
227
|
+
a,
|
|
228
|
+
Z,
|
|
229
|
+
Q
|
|
230
|
+
]);
|
|
231
|
+
return {
|
|
232
|
+
activeIndex: A,
|
|
233
|
+
activeColumn: I,
|
|
234
|
+
setActiveIndex: C,
|
|
235
|
+
setActiveCell: Q,
|
|
236
|
+
onKeyDown: s((e) => {
|
|
237
|
+
if (e.defaultPrevented) return;
|
|
238
|
+
if (j) {
|
|
239
|
+
$(e);
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
let r = f !== "horizontal", i = f !== "vertical", a = V.current, o = a.query !== "" && e.timeStamp - a.at < ee, s = (t, n) => {
|
|
243
|
+
t !== -1 && t !== A && (e.preventDefault(), C(t, {
|
|
244
|
+
reason: n,
|
|
245
|
+
event: e
|
|
246
|
+
}), b && H(t));
|
|
247
|
+
};
|
|
248
|
+
if (i && (e.key === "ArrowRight" || e.key === "ArrowLeft")) {
|
|
249
|
+
let r = e.key === "ArrowRight" !== n(e.currentTarget);
|
|
250
|
+
s(E(A, r ? 1 : -1, t, m, v), "keyboard");
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
if (e.key === "ArrowDown" && r) {
|
|
254
|
+
s(E(A, 1, t, m, v), "keyboard");
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
if (e.key === "ArrowUp" && r) {
|
|
258
|
+
s(E(A, -1, t, m, v), "keyboard");
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
if (e.key === "Home") {
|
|
262
|
+
s(D(1, t, v), "keyboard");
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (e.key === "End") {
|
|
266
|
+
s(D(-1, t, v), "keyboard");
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
if (e.key === "Enter" || e.key === " " && !(o && y)) {
|
|
270
|
+
if (!x || A === -1) return;
|
|
271
|
+
e.preventDefault(), x(A, e);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
y && k(e) && (a.query = o ? a.query + e.key : e.key, a.at = e.timeStamp, s(O(a.query, A, t, y, v), "typeahead"));
|
|
275
|
+
}, [
|
|
276
|
+
A,
|
|
277
|
+
t,
|
|
278
|
+
H,
|
|
279
|
+
b,
|
|
280
|
+
v,
|
|
281
|
+
j,
|
|
282
|
+
m,
|
|
283
|
+
$,
|
|
284
|
+
x,
|
|
285
|
+
f,
|
|
286
|
+
C,
|
|
287
|
+
y
|
|
288
|
+
]),
|
|
289
|
+
itemProps: re,
|
|
290
|
+
cellProps: ne,
|
|
291
|
+
activeItem: te
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
//#endregion
|
|
295
|
+
export { p as a, _ as i, C as n, f as o, y as r, A as t };
|
package/box.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./rolldown-runtime.cjs"),t=require("./react-shared.cjs"),n=require("./client.cjs");let r=require("react");r=e.t(r,1);let i=require("@box-kite/core");function a(e,i){let{tag:a=`div`,children:o}=e,{classNames:s,styleElements:c}=n.i(e,a===`svg`),l=(0,r.useMemo)(()=>{let n=t.c(e,s);return i&&(n.ref=i),n},[e]),[u,d]=(0,r.useState)(!1),f=typeof o==`function`,p=f?{...l,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1)}:l,m=r.default.createElement(a,p,f?o({isHover:u}):o);return c?r.default.createElement(r.default.Fragment,null,c,m):m}var o=(0,r.memo)((0,r.forwardRef)(a));o.displayName=`Box`,o.extend=i.BoxExtends.extend,o.components=i.BoxExtends.components,o.keyframes=i.BoxExtends.keyframes,o.spring=i.Springs.spring,o.Theme=n.n,o.useTheme=n.n.useTheme,o.getVariableValue=e=>(0,i.getDefaultEngine)().getVariableValue(e),o.configure=n.r.configure;function s(e,r){return t.l(n.i(e,r?.svg===!0),e.className)}exports.default=o,exports.useClassNames=s,exports.useVisibility=n.a;
|
package/box.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { default as React, RefAttributes } from 'react';
|
|
2
|
+
import { BoxExtends, Springs } from '@box-kite/core';
|
|
3
|
+
import { BoxClassNames } from './react/boxClassNames';
|
|
4
|
+
import { BoxClassNameProps, BoxCoreProps } from './react/boxProps';
|
|
5
|
+
import { default as useVisibility } from './react/hooks/useVisibility';
|
|
6
|
+
import { ExtractElementFromTag } from './react/reactTypes';
|
|
7
|
+
import { default as Theme } from './react/theme/theme';
|
|
8
|
+
import { StylesContext } from './react/useStyles';
|
|
9
|
+
import { ComponentsAndVariants } from '@box-kite/core/types';
|
|
10
|
+
interface BoxType {
|
|
11
|
+
<TTag extends keyof React.JSX.IntrinsicElements = 'div', TKey extends keyof ComponentsAndVariants = never>(props: BoxCoreProps<TTag, TKey> & RefAttributes<ExtractElementFromTag<TTag>>): React.ReactNode;
|
|
12
|
+
extend: typeof BoxExtends.extend;
|
|
13
|
+
components: typeof BoxExtends.components;
|
|
14
|
+
keyframes: typeof BoxExtends.keyframes;
|
|
15
|
+
/** A spring of your own, sampled into `{ easing, duration }` — the two halves the timing and duration props take. */
|
|
16
|
+
spring: typeof Springs.spring;
|
|
17
|
+
Theme: typeof Theme;
|
|
18
|
+
useTheme: typeof Theme.useTheme;
|
|
19
|
+
getVariableValue: (name: string) => string;
|
|
20
|
+
/** Explicit engine configuration (class-name hashing, style sink). Call once, before the first render. */
|
|
21
|
+
configure: typeof StylesContext.configure;
|
|
22
|
+
}
|
|
23
|
+
declare const Box: BoxType;
|
|
24
|
+
export default Box;
|
|
25
|
+
export type BoxProps<TTag extends keyof React.JSX.IntrinsicElements = 'div', TKey extends keyof ComponentsAndVariants = never> = React.ComponentProps<typeof Box<TTag, TKey>>;
|
|
26
|
+
export type BoxTagProps<TTag extends keyof React.JSX.IntrinsicElements = 'div', TKey extends keyof ComponentsAndVariants = never> = Required<BoxProps<TTag, TKey>>['props'];
|
|
27
|
+
/**
|
|
28
|
+
* Box props as a class attribute, for an element Box cannot render: an icon from `lucide-react`, a
|
|
29
|
+
* `motion.div`, a router's `NavLink`. They take a `className` and nothing else, and `style` is what this
|
|
30
|
+
* library exists not to write.
|
|
31
|
+
*
|
|
32
|
+
* ```tsx
|
|
33
|
+
* const { className, styles } = useClassNames({ color: 'sky-500', hover: { color: 'sky-300' } });
|
|
34
|
+
*
|
|
35
|
+
* return <>{styles}<NavLink className={className} to="/" /></>;
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* `styles` is defined in element mode only, where the CSS travels as `<style href precedence>` elements;
|
|
39
|
+
* elsewhere it is undefined and rendering it costs nothing, so that line is what to write either way.
|
|
40
|
+
* `{ svg: true }` picks the SVG reset — `Icon` is this hook plus that flag.
|
|
41
|
+
*/
|
|
42
|
+
export declare function useClassNames<TKey extends keyof ComponentsAndVariants = never>(props: BoxClassNameProps<TKey>, options?: {
|
|
43
|
+
svg?: boolean;
|
|
44
|
+
}): BoxClassNames;
|
|
45
|
+
export { useVisibility };
|
|
46
|
+
export type { BoxClassNames, BoxClassNameProps };
|
package/box.mjs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { c as e, l as t } from "./react-shared.mjs";
|
|
2
|
+
import { a as n, i as r, n as i, r as a } from "./client.mjs";
|
|
3
|
+
import o, { forwardRef as s, memo as c, useMemo as l, useState as u } from "react";
|
|
4
|
+
import { BoxExtends as d, Springs as f, getDefaultEngine as p } from "@box-kite/core";
|
|
5
|
+
//#region src/box.ts
|
|
6
|
+
function m(t, n) {
|
|
7
|
+
let { tag: i = "div", children: a } = t, { classNames: s, styleElements: c } = r(t, i === "svg"), d = l(() => {
|
|
8
|
+
let r = e(t, s);
|
|
9
|
+
return n && (r.ref = n), r;
|
|
10
|
+
}, [t]), [f, p] = u(!1), m = typeof a == "function", h = m ? {
|
|
11
|
+
...d,
|
|
12
|
+
onMouseEnter: () => p(!0),
|
|
13
|
+
onMouseLeave: () => p(!1)
|
|
14
|
+
} : d, g = o.createElement(i, h, m ? a({ isHover: f }) : a);
|
|
15
|
+
return c ? o.createElement(o.Fragment, null, c, g) : g;
|
|
16
|
+
}
|
|
17
|
+
var h = c(s(m));
|
|
18
|
+
h.displayName = "Box", h.extend = d.extend, h.components = d.components, h.keyframes = d.keyframes, h.spring = f.spring, h.Theme = i, h.useTheme = i.useTheme, h.getVariableValue = (e) => p().getVariableValue(e), h.configure = a.configure;
|
|
19
|
+
function g(e, n) {
|
|
20
|
+
return t(r(e, n?.svg === !0), e.className);
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { h as default, g as useClassNames, n as useVisibility };
|
package/client.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./rolldown-runtime.cjs"),t=require("./react-shared.cjs"),n=require("./platform.cjs"),r=require("./effects.cjs"),i=require("./box.cjs");let a=require("react");a=e.t(a,1);let o=require("@box-kite/core"),s=require("react/jsx-runtime");function c(e){let{node:t=null,event:r=`click`,hideOnScroll:i=!1,hideOnResize:o=!1,hideOnEscape:s=!0}=e??{},[c,l]=(0,a.useState)(!1),u=(0,a.useRef)(null);return(0,a.useEffect)(()=>{function e(e){let r=t??u.current;r&&!n.a(e,[r])&&l(!1)}function a(){l(!1)}function d(e){e.key===`Escape`&&l(!1)}let f=new AbortController;return c&&(window.addEventListener(r,e,f),s&&window.addEventListener(`keydown`,d,f),o&&window.addEventListener(`resize`,a,f),i&&window.addEventListener(`scroll`,e,{signal:f.signal,capture:!0})),()=>{f.abort()}},[t,c,r,s,o,i]),[c,l,u]}var l=r.t;function u(e,n){let{classNames:r,signature:i,styleElements:a}=t.o(e,n);return l(()=>{(0,o.getDefaultEngine)().flushSync()},[i??e]),{classNames:r,styleElements:a}}function d(e,n){let r=e?(0,o.getDefaultEngine)().addGlobalStyles(e,n):void 0;return l(()=>{(0,o.getDefaultEngine)().flushSync()},[e,n]),t.s(r)}var f;(function(e){function t(){(0,o.getDefaultEngine)().flushSync()}e.flushSync=t;function n(){(0,o.getDefaultEngine)().clear()}e.clear=n;function r(){return(0,o.getDefaultEngine)().getStyles()}e.getStyles=r;function i(){return(0,o.getDefaultEngine)().styleElementId}e.styleElementId=i;function a(e){(0,o.getDefaultEngine)().configure(e)}e.configure=a})(f||={});var p=`[box-kite] The client build was loaded into a React Server Component graph, where React has no createContext. Import '@box-kite/react' by its package name — the react-server condition resolves it to a Box that renders on the server — and import the components that hold state (Dropdown, Tooltip, DataGrid, Checkbox, Select, Form) from a 'use client' module. See https://github.com/box-kite/box-kite#react-server-components-react-19`;function m(e){if(typeof e.createContext!=`function`)throw Error(p)}m(a.default);var h=a.default.createContext({theme:``,setTheme:()=>{}});function g(e){let{children:t,theme:n,use:r=`local`,storageKey:c,globalStyles:l}=e,u=d(r===`global`?l:void 0,`html`),[f,p]=(0,a.useState)(n??o.defaultThemeName),[m,g]=(0,a.useState)(n!==void 0),_=(0,a.useRef)(null),v=(0,a.useCallback)(e=>{e===null?(c&&(0,o.clearStoredTheme)(c),g(!1)):(c&&(0,o.writeStoredTheme)(c,e),p(e),g(!0))},[c]),[y,b]=(0,a.useState)(n);return n!==y&&(b(n),n===void 0?g(!1):(p(n),g(!0))),(0,a.useLayoutEffect)(()=>{if(m)return;let e=c?(0,o.readStoredTheme)(c):null;if(e){p(e),g(!0);return}return p((0,o.getSystemTheme)()),(0,o.watchSystemTheme)(p)},[m,c]),(0,a.useLayoutEffect)(()=>{if(r===`local`)return;let e=(0,o.documentRoot)();if(e)return(0,o.applyThemeToElement)(e,f)},[f,r]),(0,a.useLayoutEffect)(()=>{r!==`local`||!_.current||(0,o.setThemeAttribute)(_.current,f)},[f,r]),r===`local`?(0,s.jsxs)(h.Provider,{value:{theme:f,setTheme:v},children:[u,(0,s.jsx)(i.default,{ref:_,className:f,children:t})]}):(0,s.jsxs)(h.Provider,{value:{theme:f,setTheme:v},children:[u,t]})}(function(e){function t(){let{theme:e,setTheme:t}=(0,a.useContext)(h);return[e,t]}e.useTheme=t})(g||={});var _=g,v=new WeakMap;function y(e){let t=v.get(e);return t||(t=new Map,v.set(e,t)),t}function b(){let[e]=_.useTheme(),t=(0,a.useMemo)(()=>{let e=n.t();if(!e)return null;let t=`box-kite-portal`,r=e.getElementById(t);return r||(r=document.createElement(`div`),r.id=t,document.body.appendChild(r)),r},[]);return(0,a.useLayoutEffect)(()=>{if(!e||!t)return;let n=y(t),r=n.get(e)??0;return n.set(e,r+1),r===0&&t.classList.add(e),()=>{let r=(n.get(e)??1)-1;r<=0?(n.delete(e),t.classList.remove(e)):n.set(e,r)}},[t,e]),t}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return b}});
|
package/client.mjs
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { o as e, s as t } from "./react-shared.mjs";
|
|
2
|
+
import { a as n, t as r } from "./platform.mjs";
|
|
3
|
+
import { t as i } from "./effects.mjs";
|
|
4
|
+
import a from "./box.mjs";
|
|
5
|
+
import o, { useCallback as s, useContext as c, useEffect as l, useLayoutEffect as u, useMemo as d, useRef as f, useState as p } from "react";
|
|
6
|
+
import { applyThemeToElement as m, clearStoredTheme as h, defaultThemeName as g, documentRoot as _, getDefaultEngine as v, getSystemTheme as y, readStoredTheme as b, setThemeAttribute as x, watchSystemTheme as S, writeStoredTheme as C } from "@box-kite/core";
|
|
7
|
+
import { jsx as w, jsxs as T } from "react/jsx-runtime";
|
|
8
|
+
//#region src/react/hooks/useVisibility.ts
|
|
9
|
+
function E(e) {
|
|
10
|
+
let { node: t = null, event: r = "click", hideOnScroll: i = !1, hideOnResize: a = !1, hideOnEscape: o = !0 } = e ?? {}, [s, c] = p(!1), u = f(null);
|
|
11
|
+
return l(() => {
|
|
12
|
+
function e(e) {
|
|
13
|
+
let r = t ?? u.current;
|
|
14
|
+
r && !n(e, [r]) && c(!1);
|
|
15
|
+
}
|
|
16
|
+
function l() {
|
|
17
|
+
c(!1);
|
|
18
|
+
}
|
|
19
|
+
function d(e) {
|
|
20
|
+
e.key === "Escape" && c(!1);
|
|
21
|
+
}
|
|
22
|
+
let f = new AbortController();
|
|
23
|
+
return s && (window.addEventListener(r, e, f), o && window.addEventListener("keydown", d, f), a && window.addEventListener("resize", l, f), i && window.addEventListener("scroll", e, {
|
|
24
|
+
signal: f.signal,
|
|
25
|
+
capture: !0
|
|
26
|
+
})), () => {
|
|
27
|
+
f.abort();
|
|
28
|
+
};
|
|
29
|
+
}, [
|
|
30
|
+
t,
|
|
31
|
+
s,
|
|
32
|
+
r,
|
|
33
|
+
o,
|
|
34
|
+
a,
|
|
35
|
+
i
|
|
36
|
+
]), [
|
|
37
|
+
s,
|
|
38
|
+
c,
|
|
39
|
+
u
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/react/useStyles.ts
|
|
44
|
+
var D = i;
|
|
45
|
+
function O(t, n) {
|
|
46
|
+
let { classNames: r, signature: i, styleElements: a } = e(t, n);
|
|
47
|
+
return D(() => {
|
|
48
|
+
v().flushSync();
|
|
49
|
+
}, [i ?? t]), {
|
|
50
|
+
classNames: r,
|
|
51
|
+
styleElements: a
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function k(e, n) {
|
|
55
|
+
let r = e ? v().addGlobalStyles(e, n) : void 0;
|
|
56
|
+
return D(() => {
|
|
57
|
+
v().flushSync();
|
|
58
|
+
}, [e, n]), t(r);
|
|
59
|
+
}
|
|
60
|
+
var A;
|
|
61
|
+
(function(e) {
|
|
62
|
+
function t() {
|
|
63
|
+
v().flushSync();
|
|
64
|
+
}
|
|
65
|
+
e.flushSync = t;
|
|
66
|
+
function n() {
|
|
67
|
+
v().clear();
|
|
68
|
+
}
|
|
69
|
+
e.clear = n;
|
|
70
|
+
function r() {
|
|
71
|
+
return v().getStyles();
|
|
72
|
+
}
|
|
73
|
+
e.getStyles = r;
|
|
74
|
+
function i() {
|
|
75
|
+
return v().styleElementId;
|
|
76
|
+
}
|
|
77
|
+
e.styleElementId = i;
|
|
78
|
+
function a(e) {
|
|
79
|
+
v().configure(e);
|
|
80
|
+
}
|
|
81
|
+
e.configure = a;
|
|
82
|
+
})(A ||= {});
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/react/clientRuntime.ts
|
|
85
|
+
var j = "[box-kite] The client build was loaded into a React Server Component graph, where React has no createContext. Import '@box-kite/react' by its package name — the react-server condition resolves it to a Box that renders on the server — and import the components that hold state (Dropdown, Tooltip, DataGrid, Checkbox, Select, Form) from a 'use client' module. See https://github.com/box-kite/box-kite#react-server-components-react-19";
|
|
86
|
+
function M(e) {
|
|
87
|
+
if (typeof e.createContext != "function") throw Error(j);
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/react/theme/themeContext.ts
|
|
91
|
+
M(o);
|
|
92
|
+
var N = o.createContext({
|
|
93
|
+
theme: "",
|
|
94
|
+
setTheme: () => {}
|
|
95
|
+
});
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/react/theme/theme.tsx
|
|
98
|
+
function P(e) {
|
|
99
|
+
let { children: t, theme: n, use: r = "local", storageKey: i, globalStyles: o } = e, c = k(r === "global" ? o : void 0, "html"), [l, d] = p(n ?? g), [v, E] = p(n !== void 0), D = f(null), O = s((e) => {
|
|
100
|
+
e === null ? (i && h(i), E(!1)) : (i && C(i, e), d(e), E(!0));
|
|
101
|
+
}, [i]), [A, j] = p(n);
|
|
102
|
+
return n !== A && (j(n), n === void 0 ? E(!1) : (d(n), E(!0))), u(() => {
|
|
103
|
+
if (v) return;
|
|
104
|
+
let e = i ? b(i) : null;
|
|
105
|
+
if (e) {
|
|
106
|
+
d(e), E(!0);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
return d(y()), S(d);
|
|
110
|
+
}, [v, i]), u(() => {
|
|
111
|
+
if (r === "local") return;
|
|
112
|
+
let e = _();
|
|
113
|
+
if (e) return m(e, l);
|
|
114
|
+
}, [l, r]), u(() => {
|
|
115
|
+
r !== "local" || !D.current || x(D.current, l);
|
|
116
|
+
}, [l, r]), r === "local" ? /* @__PURE__ */ T(N.Provider, {
|
|
117
|
+
value: {
|
|
118
|
+
theme: l,
|
|
119
|
+
setTheme: O
|
|
120
|
+
},
|
|
121
|
+
children: [c, /* @__PURE__ */ w(a, {
|
|
122
|
+
ref: D,
|
|
123
|
+
className: l,
|
|
124
|
+
children: t
|
|
125
|
+
})]
|
|
126
|
+
}) : /* @__PURE__ */ T(N.Provider, {
|
|
127
|
+
value: {
|
|
128
|
+
theme: l,
|
|
129
|
+
setTheme: O
|
|
130
|
+
},
|
|
131
|
+
children: [c, t]
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
(function(e) {
|
|
135
|
+
function t() {
|
|
136
|
+
let { theme: e, setTheme: t } = c(N);
|
|
137
|
+
return [e, t];
|
|
138
|
+
}
|
|
139
|
+
e.useTheme = t;
|
|
140
|
+
})(P ||= {});
|
|
141
|
+
var F = P, I = /* @__PURE__ */ new WeakMap();
|
|
142
|
+
function L(e) {
|
|
143
|
+
let t = I.get(e);
|
|
144
|
+
return t || (t = /* @__PURE__ */ new Map(), I.set(e, t)), t;
|
|
145
|
+
}
|
|
146
|
+
function R() {
|
|
147
|
+
let [e] = F.useTheme(), t = d(() => {
|
|
148
|
+
let e = r();
|
|
149
|
+
if (!e) return null;
|
|
150
|
+
let t = "box-kite-portal", n = e.getElementById(t);
|
|
151
|
+
return n || (n = document.createElement("div"), n.id = t, document.body.appendChild(n)), n;
|
|
152
|
+
}, []);
|
|
153
|
+
return u(() => {
|
|
154
|
+
if (!e || !t) return;
|
|
155
|
+
let n = L(t), r = n.get(e) ?? 0;
|
|
156
|
+
return n.set(e, r + 1), r === 0 && t.classList.add(e), () => {
|
|
157
|
+
let r = (n.get(e) ?? 1) - 1;
|
|
158
|
+
r <= 0 ? (n.delete(e), t.classList.remove(e)) : n.set(e, r);
|
|
159
|
+
};
|
|
160
|
+
}, [t, e]), t;
|
|
161
|
+
}
|
|
162
|
+
//#endregion
|
|
163
|
+
export { E as a, O as i, F as n, A as r, R as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./svg.cjs");let t=require("react"),n=require("react/jsx-runtime");function r(t,r){let{viewBox:i=`0 0 24 24`,width:a=`1.5rem`,props:o,...s}=t;return(0,n.jsx)(e.Svg,{ref:r,viewBox:i,width:a,props:{...o,fill:`none`},...s})}var i=(0,t.forwardRef)(r);i.displayName=`BaseSvg`,exports.default=i;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SvgProps } from './svg';
|
|
2
|
+
type Props = Omit<SvgProps, 'ref'>;
|
|
3
|
+
declare const BaseSvg: import('react').ForwardRefExoticComponent<Props & import('react').RefAttributes<SVGSVGElement>>;
|
|
4
|
+
export default BaseSvg;
|
|
5
|
+
export type BaseSvgProps = React.ComponentProps<typeof BaseSvg>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Svg as e } from "./svg.mjs";
|
|
2
|
+
import { forwardRef as t } from "react";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/baseSvg.tsx
|
|
5
|
+
function r(t, r) {
|
|
6
|
+
let { viewBox: i = "0 0 24 24", width: a = "1.5rem", props: o, ...s } = t;
|
|
7
|
+
return /* @__PURE__ */ n(e, {
|
|
8
|
+
ref: r,
|
|
9
|
+
viewBox: i,
|
|
10
|
+
width: a,
|
|
11
|
+
props: {
|
|
12
|
+
...o,
|
|
13
|
+
fill: "none"
|
|
14
|
+
},
|
|
15
|
+
...s
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
var i = t(r);
|
|
19
|
+
i.displayName = "BaseSvg";
|
|
20
|
+
//#endregion
|
|
21
|
+
export { i as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../rolldown-runtime.cjs"),t=require("../react-shared.cjs");let n=require("react"),r=require("react/jsx-runtime"),i=require("@box-kite/react");i=e.t(i,1);var a=[`type`,`onClick`];function o(e,n){let o=t.t.buildProps(e,a);return(0,r.jsx)(i.default,{ref:n,tag:`button`,component:`button`,...o})}var s=(0,n.forwardRef)(o);s.displayName=`Button`,exports.default=s;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RefAttributes } from 'react';
|
|
2
|
+
import { BoxProps, BoxTagProps } from '../box';
|
|
3
|
+
import { OmitTagProps } from '../react/boxProps';
|
|
4
|
+
import { ComponentsAndVariants } from '@box-kite/core/types';
|
|
5
|
+
declare const tagProps: readonly ["type", "onClick"];
|
|
6
|
+
type TagPropsType = (typeof tagProps)[number];
|
|
7
|
+
type ButtonProps<TKey extends keyof ComponentsAndVariants> = Omit<BoxProps<'button', TKey>, 'tag' | 'props'>;
|
|
8
|
+
type ButtonTagProps = OmitTagProps<BoxTagProps<'button'>, TagPropsType>;
|
|
9
|
+
type ButtonType = Required<React.ComponentProps<'button'>>['type'];
|
|
10
|
+
interface Props<TKey extends keyof ComponentsAndVariants> extends ButtonProps<TKey> {
|
|
11
|
+
props?: ButtonTagProps;
|
|
12
|
+
type?: ButtonType;
|
|
13
|
+
onClick?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
14
|
+
}
|
|
15
|
+
declare const _default: <TKey extends keyof ComponentsAndVariants = "button">(props: Props<TKey> & RefAttributes<HTMLButtonElement>) => React.ReactNode;
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { t as e } from "../react-shared.mjs";
|
|
2
|
+
import { forwardRef as t } from "react";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
import r from "@box-kite/react";
|
|
5
|
+
//#region src/components/button.tsx
|
|
6
|
+
var i = ["type", "onClick"];
|
|
7
|
+
function a(t, a) {
|
|
8
|
+
let o = e.buildProps(t, i);
|
|
9
|
+
return /* @__PURE__ */ n(r, {
|
|
10
|
+
ref: a,
|
|
11
|
+
tag: "button",
|
|
12
|
+
component: "button",
|
|
13
|
+
...o
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
var o = t(a);
|
|
17
|
+
o.displayName = "Button";
|
|
18
|
+
//#endregion
|
|
19
|
+
export { o as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../rolldown-runtime.cjs"),t=require("./svg.cjs");let n=require("react"),r=require("@box-kite/core"),i=require("react/jsx-runtime"),a=require("@box-kite/react");a=e.t(a,1);var o;(function(e){let t=e.VIEW=100,n=e.CENTRE=t/2,r=e.FRACTION_STEP=.005;function i(e){return Math.round(e*100)/100}function a(e){return Math.round(Math.min(Math.max(e,0),1)/r)*r}e.fraction=a;function o(e,r={}){if(e.length===0)return[];let a=r.min??Math.min(...e),o=(r.max??Math.max(...e))-a,s=e=>i(o===0?n:t-(e-a)/o*t);if(e.length===1)return[{x:0,y:s(e[0])},{x:t,y:s(e[0])}];let c=t/(e.length-1);return e.map((e,t)=>({x:i(t*c),y:s(e)}))}e.points=o;function s(e){return e.length===0?``:e.map((e,t)=>`${t===0?`M`:`L`}${e.x} ${e.y}`).join(``)}e.linePath=s;function c(e){if(e.length===0)return``;let n=e[e.length-1];return`${s(e)}L${n.x} ${t}L${e[0].x} ${t}Z`}e.areaPath=c;function l(e,n={},r=.25){if(e.length===0)return``;let a=t/e.length,s=i(a*(1-r)),c=i((a-s)/2);return o(e,n).map((e,n)=>{let r=Math.min(e.y,t-1);return`M${i(n*a+c)} ${r}h${s}v${i(t-r)}h${-s}Z`}).join(``)}e.barsPath=l;function u(e){return i(n-e/2)}e.radius=u;function d(e){return i(2*Math.PI*e)}e.circumference=d;function f(e,t){return{strokeDasharray:i(e),strokeDashoffset:i(e*(1-a(t)))}}e.dash=f;function p(e,t){let r=(t-90)*Math.PI/180;return{x:i(n+e*Math.cos(r)),y:i(n+e*Math.sin(r))}}function m(e,t){return i(d(e)*(Math.min(Math.abs(t),360)/360))}e.arcLength=m;function h(e,t,n){if(Math.abs(n)>=360){let n=p(e,t),r=p(e,t+180);return`M${n.x} ${n.y}A${e} ${e} 0 0 1 ${r.x} ${r.y}A${e} ${e} 0 0 1 ${n.x} ${n.y}`}let r=p(e,t),i=p(e,t+n),a=+(Math.abs(n)>180),o=n<0?0:1;return`M${r.x} ${r.y}A${e} ${e} 0 ${a} ${o} ${i.x} ${i.y}`}e.arcPath=h;function g(e,t){let n=e.reduce((e,t)=>e+Math.max(t,0),0);if(n<=0)return[];let r=0;return e.map((e,o)=>{let s=a(Math.max(e,0)/n),c=i(t*s),l=i(r*360);return r+=s,{strokeDasharray:`${c} ${i(t-c)}`,rotate:l,value:e,index:o}})}e.donutSegments=g;let _=e.PALETTE=[`sky-500`,`emerald-500`,`amber-500`,`violet-500`,`rose-500`,`cyan-500`];e.DARK_PALETTE=[`sky-400`,`emerald-400`,`amber-400`,`violet-400`,`rose-400`,`cyan-400`];function v(e){return e.reduce((e,t,n)=>(e[`chart-${n+1}`]=t,e),{})}e.paletteVariables=v;function y(e,t=_.length){return(Array.isArray(e)?e.map((e,n)=>[e,`var(--chart-${n%t+1})`]):Object.entries(e)).reduce((e,[t,n])=>(e[`color-${t}`]=n,e),{})}e.seriesVariables=y})(o||={});var s=o,c=`0 0 ${s.VIEW} ${s.VIEW}`,l=s.PALETTE;function u(e,n){let{data:r,variant:a=`line`,min:o,max:l,children:u,...d}=e,f={min:o,max:l},p=s.points(r,f);return(0,i.jsxs)(t.Svg,{viewBox:c,preserveAspectRatio:`none`,vectorEffect:`non-scaling-stroke`,width:`100%`,height:`1.5rem`,overflow:`visible`,stroke:`currentColor`,fill:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,ref:n,...d,children:[a===`bar`?(0,i.jsx)(t.Path,{d:s.barsPath(r,f),stroke:`none`}):(0,i.jsxs)(i.Fragment,{children:[a===`area`&&(0,i.jsx)(t.Path,{d:s.areaPath(p),stroke:`none`,fillOpacity:.2}),(0,i.jsx)(t.Path,{d:s.linePath(p),fill:`none`})]}),u]})}var d=(0,n.forwardRef)(u);d.displayName=`Sparkline`;function f(e,n){let{value:r,thickness:a=10,trackOpacity:o=.2,children:l,...u}=e,d=s.radius(a),f=s.circumference(d);return(0,i.jsxs)(t.Svg,{viewBox:c,width:`3rem`,height:`3rem`,stroke:`currentColor`,fill:`none`,strokeWidth:a,strokeLinecap:`round`,ref:n,...u,children:[(0,i.jsx)(t.Circle,{cx:s.CENTRE,cy:s.CENTRE,r:d,strokeOpacity:o}),(0,i.jsx)(t.Circle,{cx:s.CENTRE,cy:s.CENTRE,r:d,transform:`rotate(-90 ${s.CENTRE} ${s.CENTRE})`,...s.dash(f,r)}),l]})}var p=(0,n.forwardRef)(f);p.displayName=`ProgressRing`;function m(e,n){let{value:r,thickness:a=10,trackOpacity:o=.2,sweep:l=270,start:u=225,children:d,...f}=e,p=s.radius(a),m=s.arcLength(p,l),h=s.arcPath(p,u,l);return(0,i.jsxs)(t.Svg,{viewBox:c,width:`4rem`,height:`4rem`,stroke:`currentColor`,fill:`none`,strokeWidth:a,strokeLinecap:`round`,ref:n,...f,children:[(0,i.jsx)(t.Path,{d:h,strokeOpacity:o}),(0,i.jsx)(t.Path,{d:h,...s.dash(m,r)}),d]})}var h=(0,n.forwardRef)(m);h.displayName=`Gauge`;function g(e,n){let{data:r,colors:a=l,thickness:o=20,children:u,...d}=e,f=s.radius(o),p=s.circumference(f);return(0,i.jsxs)(t.Svg,{viewBox:c,width:`3rem`,height:`3rem`,fill:`none`,strokeWidth:o,ref:n,...d,children:[s.donutSegments(r,p).map(e=>(0,i.jsx)(t.Circle,{cx:s.CENTRE,cy:s.CENTRE,r:f,stroke:a[e.index%a.length],strokeDasharray:e.strokeDasharray,transform:`rotate(${e.rotate-90} ${s.CENTRE} ${s.CENTRE})`},e.index)),u]})}var _=(0,n.forwardRef)(g);_.displayName=`MiniDonut`;function v(e,t){let{series:n,vars:o,theme:c,...l}=e,u={...s.paletteVariables(s.PALETTE),...n?s.seriesVariables(n):{},...o},d=(0,r.mergeDeep)({dark:{vars:s.paletteVariables(s.DARK_PALETTE)}},c??{});return(0,i.jsx)(a.default,{ref:t,vars:u,theme:d,...l})}var y=(0,n.forwardRef)(v);y.displayName=`ChartContainer`;var b=y;exports.ChartContainer=b,exports.Gauge=h,exports.MiniDonut=_,exports.ProgressRing=p,exports.Sparkline=d;
|