@box-kite/react 0.0.1 → 2.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 +65 -0
- package/.claude/skills/box-kite/SKILL.md +138 -0
- package/.claude/skills/box-kite/references/components.md +235 -0
- package/.claude/skills/box-kite/references/extending.md +42 -0
- package/.claude/skills/box-kite/references/patterns.md +27 -0
- package/.claude/skills/box-kite/references/styling.md +222 -0
- package/.cursor/rules/box-kite.mdc +73 -0
- package/AGENTS.md +102 -0
- package/BOX_AI_CONTEXT.md +2804 -0
- package/BOX_KITE_AI_CONTEXT.md +2804 -0
- package/LICENSE +21 -0
- package/README.md +744 -7
- package/a11y.cjs +1 -0
- package/a11y.d.ts +15 -0
- package/a11y.mjs +4 -0
- package/anchor.cjs +1 -0
- package/anchor.d.ts +14 -0
- package/anchor.mjs +3 -0
- package/behavior.cjs +1 -0
- package/behavior.mjs +277 -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 +164 -0
- package/components/accordion.cjs +1 -0
- package/components/accordion.d.ts +114 -0
- package/components/accordion.mjs +251 -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 +19 -0
- package/components/button.mjs +19 -0
- package/components/chart.cjs +1 -0
- package/components/chart.d.ts +83 -0
- package/components/chart.mjs +236 -0
- package/components/checkbox.cjs +1 -0
- package/components/checkbox.d.ts +36 -0
- package/components/checkbox.mjs +38 -0
- package/components/combobox/comboboxChips.d.ts +21 -0
- package/components/combobox/comboboxListbox.d.ts +47 -0
- package/components/combobox.cjs +1 -0
- package/components/combobox.d.ts +121 -0
- package/components/combobox.mjs +563 -0
- package/components/dataGrid/components/dataGridAggregateValue.d.ts +10 -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 +16 -0
- package/components/dataGrid/components/dataGridCellEditor.d.ts +15 -0
- package/components/dataGrid/components/dataGridCellPlaceholder.d.ts +14 -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/dataGridCellTree.d.ts +16 -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/dataGridDataSourceError.d.ts +12 -0
- package/components/dataGrid/components/dataGridDetailRow.d.ts +8 -0
- package/components/dataGrid/components/dataGridEmptyColumns.d.ts +6 -0
- package/components/dataGrid/components/dataGridExport.d.ts +10 -0
- package/components/dataGrid/components/dataGridFilterCell.d.ts +11 -0
- package/components/dataGrid/components/dataGridFilterRow.d.ts +6 -0
- package/components/dataGrid/components/dataGridFooter.d.ts +11 -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 +671 -0
- package/components/dataGrid/export/gridExport.d.ts +10 -0
- package/components/dataGrid/gridNavigationContext.d.ts +32 -0
- package/components/dataGrid/models/aggregateCellModel.d.ts +34 -0
- package/components/dataGrid/models/aggregationModel.d.ts +32 -0
- package/components/dataGrid/models/cellKeys.d.ts +11 -0
- package/components/dataGrid/models/cellModel.d.ts +44 -0
- package/components/dataGrid/models/columnModel.d.ts +160 -0
- package/components/dataGrid/models/columnVisibilityModel.d.ts +24 -0
- package/components/dataGrid/models/dataSourceModel.d.ts +177 -0
- package/components/dataGrid/models/detailRowModel.d.ts +22 -0
- package/components/dataGrid/models/editModel.d.ts +77 -0
- package/components/dataGrid/models/exportModel.d.ts +51 -0
- package/components/dataGrid/models/filterModel.d.ts +22 -0
- package/components/dataGrid/models/gridModel.d.ts +293 -0
- package/components/dataGrid/models/groupRowCellModel.d.ts +34 -0
- package/components/dataGrid/models/groupRowModel.d.ts +68 -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 +46 -0
- package/components/dataGrid/models/sourceGroupRowModel.d.ts +45 -0
- package/components/dataGrid/models/sourceLevel.d.ts +71 -0
- package/components/dataGrid/models/sourceRowModel.d.ts +29 -0
- package/components/dataGrid/models/sourceTreeRowModel.d.ts +23 -0
- package/components/dataGrid/models/treeModel.d.ts +94 -0
- package/components/dataGrid/models/treeRow.d.ts +22 -0
- package/components/dataGrid/models/treeRowModel.d.ts +50 -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 +4 -0
- package/components/dataGrid.mjs +4907 -0
- package/components/dialog.cjs +1 -0
- package/components/dialog.d.ts +151 -0
- package/components/dialog.mjs +223 -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 +77 -0
- package/components/dropdown.mjs +491 -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 +37 -0
- package/components/icon.mjs +41 -0
- package/components/menu.cjs +1 -0
- package/components/menu.d.ts +234 -0
- package/components/menu.mjs +422 -0
- package/components/overlay.cjs +1 -0
- package/components/overlay.d.ts +47 -0
- package/components/overlay.mjs +52 -0
- package/components/popover.cjs +1 -0
- package/components/popover.d.ts +100 -0
- package/components/popover.mjs +69 -0
- package/components/presence.cjs +1 -0
- package/components/presence.d.ts +36 -0
- package/components/presence.mjs +11 -0
- package/components/progress.cjs +1 -0
- package/components/progress.d.ts +47 -0
- package/components/progress.mjs +28 -0
- package/components/radioButton.cjs +1 -0
- package/components/radioButton.d.ts +32 -0
- package/components/radioButton.mjs +32 -0
- package/components/radioGroup.cjs +1 -0
- package/components/radioGroup.d.ts +51 -0
- package/components/radioGroup.mjs +83 -0
- package/components/select.cjs +1 -0
- package/components/select.d.ts +51 -0
- package/components/select.mjs +36 -0
- package/components/semantics.cjs +1 -0
- package/components/semantics.d.ts +39 -0
- package/components/semantics.mjs +17 -0
- package/components/slider.cjs +1 -0
- package/components/slider.d.ts +98 -0
- package/components/slider.mjs +250 -0
- package/components/svg.cjs +1 -0
- package/components/svg.d.ts +65 -0
- package/components/svg.mjs +141 -0
- package/components/switch.cjs +1 -0
- package/components/switch.d.ts +29 -0
- package/components/switch.mjs +25 -0
- package/components/tabs.cjs +1 -0
- package/components/tabs.d.ts +87 -0
- package/components/tabs.mjs +324 -0
- package/components/textarea.cjs +1 -0
- package/components/textarea.d.ts +41 -0
- package/components/textarea.mjs +33 -0
- package/components/textbox.cjs +1 -0
- package/components/textbox.d.ts +38 -0
- package/components/textbox.mjs +33 -0
- package/components/toaster.cjs +1 -0
- package/components/toaster.d.ts +106 -0
- package/components/toaster.mjs +295 -0
- package/components/tooltip.cjs +1 -0
- package/components/tooltip.d.ts +98 -0
- package/components/tooltip.mjs +110 -0
- package/components/visuallyHidden.cjs +1 -0
- package/components/visuallyHidden.d.ts +6 -0
- package/components/visuallyHidden.mjs +23 -0
- package/docs/a11y.md +199 -0
- package/docs/anchor.md +139 -0
- package/docs/components.md +48 -0
- package/docs/index.md +11 -0
- package/docs/props.md +1777 -0
- package/effects.cjs +1 -0
- package/effects.mjs +6 -0
- package/forms.cjs +1 -0
- package/forms.mjs +21 -0
- package/gridExport.cjs +2 -0
- package/gridExport.mjs +244 -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/identity.cjs +1 -0
- package/identity.mjs +12 -0
- package/keyboard.cjs +1 -0
- package/keyboard.mjs +30 -0
- package/layer.cjs +1 -0
- package/layer.mjs +127 -0
- package/motion.cjs +1 -0
- package/motion.mjs +66 -0
- package/package.json +327 -7
- package/placement.cjs +1 -0
- package/placement.mjs +180 -0
- package/platform.cjs +1 -0
- package/platform.mjs +45 -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/useRovingFocus.d.ts +84 -0
- package/react/anchor/useAnchorPosition.d.ts +79 -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/dialog/useScrollLock.d.ts +12 -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 +6 -0
- package/react/hooks/useVirtualization.d.ts +32 -0
- package/react/hooks/useVisibility.d.ts +9 -0
- package/react/identity/useIdentifier.d.ts +17 -0
- package/react/popover/usePopoverLayer.d.ts +87 -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 +122 -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/accordion/accordionUtils.d.ts +48 -0
- package/utils/anchor/anchorUtils.d.ts +79 -0
- package/utils/animation/animationUtils.d.ts +29 -0
- package/utils/array/arrayUtils.d.ts +15 -0
- package/utils/array/lazyList.d.ts +10 -0
- package/utils/box/boxUtils.d.ts +5 -0
- package/utils/chart/chartPalette.d.ts +15 -0
- package/utils/chart/chartUtils.d.ts +92 -0
- package/utils/combobox/comboboxUtils.d.ts +89 -0
- package/utils/dom/domUtils.d.ts +32 -0
- package/utils/environment/environmentUtils.d.ts +28 -0
- package/utils/export/csvUtils.d.ts +23 -0
- package/utils/export/downloadUtils.d.ts +12 -0
- package/utils/export/xlsxUtils.d.ts +56 -0
- package/utils/export/zipUtils.d.ts +26 -0
- package/utils/fn/fnUtils.d.ts +4 -0
- package/utils/form/formUtils.d.ts +8 -0
- package/utils/keyboard/typeaheadUtils.d.ts +31 -0
- package/utils/memo.d.ts +10 -0
- package/utils/menu/menuUtils.d.ts +25 -0
- package/utils/object/objectUtils.d.ts +13 -0
- package/utils/slider/sliderUtils.d.ts +67 -0
- package/utils/string/fuzzySearch.d.ts +27 -0
- package/utils/string/stringUtils.d.ts +4 -0
- package/utils/tabs/tabsUtils.d.ts +75 -0
- package/utils/toast/toastStore.d.ts +73 -0
- package/utils/virtual/virtualUtils.d.ts +47 -0
package/react-shared.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./rolldown-runtime.cjs");let t=require("react");t=e.t(t,1);let n=require("@box-kite/core");function r({classNames:e,styleElements:t},r){return{className:(0,n.classNames)(e,r).join(` `),styles:t}}var i={selected:`aria-selected`},a;(function(e){function t(e,t,n){e!==void 0&&e!=null&&(n[i[t]??t]=Array.isArray(e)?e[0]:e)}e.assignBooleanProp=t})(a||={});var o=a;function s(e,t){let r=e,{props:i,className:a,disabled:s,required:c,checked:l,selected:u}=r,d={...i,className:(0,n.classNames)(t,a).join(` `)};return o.assignBooleanProp(s,`disabled`,d),o.assignBooleanProp(c,`required`,d),o.assignBooleanProp(l,`checked`,d),o.assignBooleanProp(u,`selected`,d),`style`in r&&(d.style=r.style),`id`in r&&(d.id=r.id),d}var c=parseInt(t.default.version,10)>=19,l=!1;function u(e){if(e?.length)return!c&&!l&&(l=!0,console.warn(`[box-kite] Box.configure({ sink: 'element' }) needs React 19 to hoist and dedupe its <style> elements; React ${t.default.version} will render them inline. Use the default sink instead.`)),e.map(({href:e,css:n,precedence:r})=>t.default.createElement(`style`,{key:e,href:e,precedence:r,dangerouslySetInnerHTML:{__html:n}}))}function d(e,t){let{classNames:r,signature:i,styleElements:a}=(0,n.getDefaultEngine)().resolveClassNames(e,t);return{classNames:r,signature:i,styleElements:u(a)}}var f=`__boxAttributesInProps`;function p(e){return e[f]=!0,e}function m(e){return typeof e==`function`||typeof e==`object`&&e?e[f]===!0:!1}var h=[`role`,`aria-label`,`aria-labelledby`,`aria-hidden`];function g(e,t){if(e!==void 0)return{role:`img`,"aria-label":e};if(!(t&&h.some(e=>e in t)))return{"aria-hidden":!0}}var _;(function(e){function t(e){return e.charAt(0).toUpperCase()+e.slice(1)}e.capitalize=t})(_||={});var v=_,y;(function(e){function t(e,t,n){let r={...e},i=r.props||{};return t.forEach(e=>{e in r&&(i[e]=r[e],delete r[e])}),n&&Object.entries(n).forEach(([e,t])=>{i[e]=t}),r.props=i,r}e.buildProps=t;function n(e){return!!e&&typeof e==`object`}e.isObject=n;function r(e,t){return e in t}e.isKeyOf=r})(y||={});var b=y,x=[`sky-500`,`emerald-500`,`amber-500`,`violet-500`,`rose-500`,`cyan-500`],S=[`sky-400`,`emerald-400`,`amber-400`,`violet-400`,`rose-400`,`cyan-400`];function C(e){return e.reduce((e,t,n)=>(e[`chart-${n+1}`]=t,e),{})}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return u}});
|
package/react-shared.mjs
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import e from "react";
|
|
2
|
+
import { classNames as t, getDefaultEngine as n } from "@box-kite/core";
|
|
3
|
+
//#region src/react/boxClassNames.ts
|
|
4
|
+
function r({ classNames: e, styleElements: n }, r) {
|
|
5
|
+
return {
|
|
6
|
+
className: t(e, r).join(" "),
|
|
7
|
+
styles: n
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/utils/box/boxUtils.ts
|
|
12
|
+
var i = { selected: "aria-selected" }, a;
|
|
13
|
+
(function(e) {
|
|
14
|
+
function t(e, t, n) {
|
|
15
|
+
e !== void 0 && e != null && (n[i[t] ?? t] = Array.isArray(e) ? e[0] : e);
|
|
16
|
+
}
|
|
17
|
+
e.assignBooleanProp = t;
|
|
18
|
+
})(a ||= {});
|
|
19
|
+
var o = a;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/react/boxTagProps.ts
|
|
22
|
+
function s(e, n) {
|
|
23
|
+
let r = e, { props: i, className: a, disabled: s, required: c, checked: l, selected: u } = r, d = {
|
|
24
|
+
...i,
|
|
25
|
+
className: t(n, a).join(" ")
|
|
26
|
+
};
|
|
27
|
+
return o.assignBooleanProp(s, "disabled", d), o.assignBooleanProp(c, "required", d), o.assignBooleanProp(l, "checked", d), o.assignBooleanProp(u, "selected", d), "style" in r && (d.style = r.style), "id" in r && (d.id = r.id), d;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/react/styleElements.ts
|
|
31
|
+
var c = parseInt(e.version, 10) >= 19, l = !1;
|
|
32
|
+
function u(t) {
|
|
33
|
+
if (t?.length) return !c && !l && (l = !0, console.warn(`[box-kite] Box.configure({ sink: 'element' }) needs React 19 to hoist and dedupe its <style> elements; React ${e.version} will render them inline. Use the default sink instead.`)), t.map(({ href: t, css: n, precedence: r }) => e.createElement("style", {
|
|
34
|
+
key: t,
|
|
35
|
+
href: t,
|
|
36
|
+
precedence: r,
|
|
37
|
+
dangerouslySetInnerHTML: { __html: n }
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/react/resolveStyles.ts
|
|
42
|
+
function d(e, t) {
|
|
43
|
+
let { classNames: r, signature: i, styleElements: a } = n().resolveClassNames(e, t);
|
|
44
|
+
return {
|
|
45
|
+
classNames: r,
|
|
46
|
+
signature: i,
|
|
47
|
+
styleElements: u(a)
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/react/svg/attributesInProps.ts
|
|
52
|
+
var f = "__boxAttributesInProps";
|
|
53
|
+
function p(e) {
|
|
54
|
+
return e[f] = !0, e;
|
|
55
|
+
}
|
|
56
|
+
function m(e) {
|
|
57
|
+
return typeof e == "function" || typeof e == "object" && e ? e[f] === !0 : !1;
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/react/svg/svgNaming.ts
|
|
61
|
+
var h = [
|
|
62
|
+
"role",
|
|
63
|
+
"aria-label",
|
|
64
|
+
"aria-labelledby",
|
|
65
|
+
"aria-hidden"
|
|
66
|
+
];
|
|
67
|
+
function g(e, t) {
|
|
68
|
+
if (e !== void 0) return {
|
|
69
|
+
role: "img",
|
|
70
|
+
"aria-label": e
|
|
71
|
+
};
|
|
72
|
+
if (!(t && h.some((e) => e in t))) return { "aria-hidden": !0 };
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/utils/string/stringUtils.ts
|
|
76
|
+
var _;
|
|
77
|
+
(function(e) {
|
|
78
|
+
function t(e) {
|
|
79
|
+
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
80
|
+
}
|
|
81
|
+
e.capitalize = t;
|
|
82
|
+
})(_ ||= {});
|
|
83
|
+
var v = _, y;
|
|
84
|
+
(function(e) {
|
|
85
|
+
function t(e, t, n) {
|
|
86
|
+
let r = { ...e }, i = r.props || {};
|
|
87
|
+
return t.forEach((e) => {
|
|
88
|
+
e in r && (i[e] = r[e], delete r[e]);
|
|
89
|
+
}), n && Object.entries(n).forEach(([e, t]) => {
|
|
90
|
+
i[e] = t;
|
|
91
|
+
}), r.props = i, r;
|
|
92
|
+
}
|
|
93
|
+
e.buildProps = t;
|
|
94
|
+
function n(e) {
|
|
95
|
+
return !!e && typeof e == "object";
|
|
96
|
+
}
|
|
97
|
+
e.isObject = n;
|
|
98
|
+
function r(e, t) {
|
|
99
|
+
return e in t;
|
|
100
|
+
}
|
|
101
|
+
e.isKeyOf = r;
|
|
102
|
+
})(y ||= {});
|
|
103
|
+
var b = y, x = [
|
|
104
|
+
"sky-500",
|
|
105
|
+
"emerald-500",
|
|
106
|
+
"amber-500",
|
|
107
|
+
"violet-500",
|
|
108
|
+
"rose-500",
|
|
109
|
+
"cyan-500"
|
|
110
|
+
], S = [
|
|
111
|
+
"sky-400",
|
|
112
|
+
"emerald-400",
|
|
113
|
+
"amber-400",
|
|
114
|
+
"violet-400",
|
|
115
|
+
"rose-400",
|
|
116
|
+
"cyan-400"
|
|
117
|
+
];
|
|
118
|
+
function C(e) {
|
|
119
|
+
return e.reduce((e, t, n) => (e[`chart-${n + 1}`] = t, e), {});
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
export { v as a, p as c, s as d, r as f, b as i, d as l, x as n, g as o, C as r, m as s, S as t, u };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return s}});
|
package/rsc.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");let n=require("react");n=e.t(n,1);let r=require("@box-kite/core");(0,r.getDefaultEngine)().configure({sink:`element`});function i(e){let{tag:r=`div`,children:i}=e;if(typeof i==`function`)throw Error(`[box-kite] Box children as a function track hover state, which needs the client Box — render it from a 'use client' module.`);let{classNames:a,styleElements:o}=t.l(e,r===`svg`);return n.default.createElement(n.default.Fragment,null,o,n.default.createElement(r,t.d(e,a),i))}var a=i;a.extend=r.BoxExtends.extend,a.components=r.BoxExtends.components,a.keyframes=r.BoxExtends.keyframes,a.spring=r.Springs.spring,a.getVariableValue=e=>(0,r.getDefaultEngine)().getVariableValue(e),a.configure=e=>(0,r.getDefaultEngine)().configure(e);function o(e,n){return t.f(t.l(e,n?.svg===!0),e.className)}exports.default=a,exports.useClassNames=o;
|
package/rsc.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { BoxExtends, Springs, StylesConfiguration } from '@box-kite/core';
|
|
3
|
+
import { BoxClassNames } from './react/boxClassNames';
|
|
4
|
+
import { BoxClassNameProps, BoxCoreProps } from './react/boxProps';
|
|
5
|
+
import { ComponentsAndVariants } from '@box-kite/core/types';
|
|
6
|
+
interface RscBoxType {
|
|
7
|
+
<TTag extends keyof React.JSX.IntrinsicElements = 'div', TKey extends keyof ComponentsAndVariants = never>(props: BoxCoreProps<TTag, TKey>): React.ReactNode;
|
|
8
|
+
extend: typeof BoxExtends.extend;
|
|
9
|
+
components: typeof BoxExtends.components;
|
|
10
|
+
keyframes: typeof BoxExtends.keyframes;
|
|
11
|
+
/** A spring of your own, sampled into `{ easing, duration }`. Pure arithmetic, so a Server Component can call it. */
|
|
12
|
+
spring: typeof Springs.spring;
|
|
13
|
+
getVariableValue: (name: string) => string;
|
|
14
|
+
/** Explicit engine configuration. Element mode is already on; this is for the rest of it. */
|
|
15
|
+
configure: (config: StylesConfiguration) => void;
|
|
16
|
+
}
|
|
17
|
+
declare const RscBox: RscBoxType;
|
|
18
|
+
/**
|
|
19
|
+
* The Server-Component half of `useClassNames` — see the client entry for what it is for. Not a hook
|
|
20
|
+
* here and it does not need to be, since resolving in element mode produces the `<style>` elements
|
|
21
|
+
* themselves. The `use` prefix stays so a component can move between the two entries unchanged.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useClassNames<TKey extends keyof ComponentsAndVariants = never>(props: BoxClassNameProps<TKey>, options?: {
|
|
24
|
+
svg?: boolean;
|
|
25
|
+
}): BoxClassNames;
|
|
26
|
+
export default RscBox;
|
|
27
|
+
export type { BoxClassNames, BoxClassNameProps };
|
package/rsc.mjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { d as e, f as t, l as n } from "./react-shared.mjs";
|
|
2
|
+
import r from "react";
|
|
3
|
+
import { BoxExtends as i, Springs as a, getDefaultEngine as o } from "@box-kite/core";
|
|
4
|
+
//#region src/rsc.ts
|
|
5
|
+
o().configure({ sink: "element" });
|
|
6
|
+
function s(t) {
|
|
7
|
+
let { tag: i = "div", children: a } = t;
|
|
8
|
+
if (typeof a == "function") throw Error("[box-kite] Box children as a function track hover state, which needs the client Box — render it from a 'use client' module.");
|
|
9
|
+
let { classNames: o, styleElements: s } = n(t, i === "svg");
|
|
10
|
+
return r.createElement(r.Fragment, null, s, r.createElement(i, e(t, o), a));
|
|
11
|
+
}
|
|
12
|
+
var c = s;
|
|
13
|
+
c.extend = i.extend, c.components = i.components, c.keyframes = i.keyframes, c.spring = a.spring, c.getVariableValue = (e) => o().getVariableValue(e), c.configure = (e) => o().configure(e);
|
|
14
|
+
function l(e, r) {
|
|
15
|
+
return t(n(e, r?.svg === !0), e.className);
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { c as default, l as useClassNames };
|
package/ssg.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime.cjs"),t=require("./client.cjs");let n=require("react-dom/server");n=e.t(n,1);function r(){return t.r.getStyles()}function i(){t.r.clear()}function a(e,a=!0){let o=n.default.renderToStaticMarkup(e),s=r();if(a){let e=o.indexOf(`<head>`);if(e>-1){let n=e+6;o=o.substring(0,n)+`<style id="${t.r.styleElementId()}">${s}</style>`+o.substring(n)}}return i(),{html:o,styles:s}}exports.getStyles=r,exports.renderToStaticMarkup=a,exports.resetStyles=i;
|
package/ssg.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Server rendering. There is no DOM here and the engine does not pretend there is one: with no
|
|
4
|
+
* `document` in the process it writes to an in-memory string sink, and `getStyles()` reads it back.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* The CSS for everything rendered since the last reset. Flushes first, so it is safe straight after
|
|
8
|
+
* `renderToString` — no effects have run at that point. Goes in a `<style id="box-kite-styles">` in the head.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getStyles(): string;
|
|
11
|
+
/**
|
|
12
|
+
* Drop every rule, class name and variable the engine has emitted, so the next request starts blank.
|
|
13
|
+
* Registration (`Box.extend()`, `Box.components()`) survives. Call it once per request, after `getStyles()`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resetStyles(): void;
|
|
16
|
+
/**
|
|
17
|
+
* Render `element` to static HTML together with its CSS. With `addStylesToHead` (the default) and a
|
|
18
|
+
* `<head>` in the tree the styles go there; otherwise use the returned `styles`. The engine is reset
|
|
19
|
+
* before returning, so sequential calls are independent.
|
|
20
|
+
*/
|
|
21
|
+
export declare function renderToStaticMarkup(element: React.ReactElement, addStylesToHead?: boolean): {
|
|
22
|
+
html: string;
|
|
23
|
+
styles: string;
|
|
24
|
+
};
|
package/ssg.mjs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { r as e } from "./client.mjs";
|
|
2
|
+
import t from "react-dom/server";
|
|
3
|
+
//#region src/ssg.ts
|
|
4
|
+
function n() {
|
|
5
|
+
return e.getStyles();
|
|
6
|
+
}
|
|
7
|
+
function r() {
|
|
8
|
+
e.clear();
|
|
9
|
+
}
|
|
10
|
+
function i(i, a = !0) {
|
|
11
|
+
let o = t.renderToStaticMarkup(i), s = n();
|
|
12
|
+
if (a) {
|
|
13
|
+
let t = o.indexOf("<head>");
|
|
14
|
+
if (t > -1) {
|
|
15
|
+
let n = t + 6;
|
|
16
|
+
o = o.substring(0, n) + `<style id="${e.styleElementId()}">${s}</style>` + o.substring(n);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return r(), {
|
|
20
|
+
html: o,
|
|
21
|
+
styles: s
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { n as getStyles, i as renderToStaticMarkup, r as resetStyles };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** What a key means in an accordion: a step to the neighbouring header, or a jump to an end. */
|
|
2
|
+
export interface AccordionMove {
|
|
3
|
+
kind: 'step' | 'edge';
|
|
4
|
+
/** `1` forward, `-1` back — and on an `edge` move, the first header or the last. */
|
|
5
|
+
delta: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Which header an accordion's keyboard lands on, and which panels stand open, read off the DOM rather
|
|
9
|
+
* than out of a registry — B4's and B5's precedent, for the same reason: a header a consumer wrapped,
|
|
10
|
+
* rendered from a list or put behind a condition is in the order it was written.
|
|
11
|
+
*/
|
|
12
|
+
declare namespace AccordionUtils {
|
|
13
|
+
/** The root marks itself so a header can say which accordion it belongs to. Neither attribute is ARIA: an accordion has no container role. */
|
|
14
|
+
const ROOT_ATTRIBUTE = "data-accordion";
|
|
15
|
+
const TRIGGER_ATTRIBUTE = "data-accordion-trigger";
|
|
16
|
+
const ROOT_SELECTOR = "[data-accordion]";
|
|
17
|
+
const TRIGGER_SELECTOR = "[data-accordion-trigger]";
|
|
18
|
+
/** Whether this accordion is the one a node belongs to, rather than one nested in a panel inside it. */
|
|
19
|
+
function owns(root: Element, node: EventTarget | null): boolean;
|
|
20
|
+
/** The headers an accordion owns, in DOM order. A nested accordion's headers belong to their own root. */
|
|
21
|
+
function triggers(root: Element | null | undefined): HTMLElement[];
|
|
22
|
+
/**
|
|
23
|
+
* A header nothing can open. Skipped by every movement, the way a disabled tab is: it is the `disabled`
|
|
24
|
+
* attribute here, so the browser has already taken it out of the tab sequence, and arrows that still
|
|
25
|
+
* stopped on it would be reaching what Tab cannot.
|
|
26
|
+
*/
|
|
27
|
+
function isDisabled(trigger: Element): boolean;
|
|
28
|
+
/** The next enabled header in a direction, or `undefined` when there is none. */
|
|
29
|
+
function step(triggers: readonly HTMLElement[], from: number, delta: number, loop: boolean): HTMLElement | undefined;
|
|
30
|
+
/** The first (`delta: 1`) or last (`delta: -1`) enabled header. */
|
|
31
|
+
function edge(triggers: readonly HTMLElement[], delta: number): HTMLElement | undefined;
|
|
32
|
+
/** Where the header a move starts from sits, or `-1` when the node is not one of them. */
|
|
33
|
+
function indexOf(triggers: readonly HTMLElement[], node: EventTarget | null): number;
|
|
34
|
+
/**
|
|
35
|
+
* What a key does on an accordion header. An accordion stacks along the block axis whatever the reading
|
|
36
|
+
* order is, so unlike a tablist there is nothing here to mirror — and the sideways pair is left to the
|
|
37
|
+
* page, which is where APG leaves it.
|
|
38
|
+
*/
|
|
39
|
+
function moveFor(key: string): AccordionMove | undefined;
|
|
40
|
+
/** The header a move arrives at, or `undefined` when there is nowhere to go. */
|
|
41
|
+
function target(triggers: readonly HTMLElement[], from: number, move: AccordionMove, loop: boolean): HTMLElement | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* The panels standing open after one header is pressed. Closing the open one is always allowed, so a
|
|
44
|
+
* single-panel accordion needs no second prop to say whether it can stand empty.
|
|
45
|
+
*/
|
|
46
|
+
function toggle(open: readonly string[], value: string, multiple: boolean): string[];
|
|
47
|
+
}
|
|
48
|
+
export default AccordionUtils;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a floating layer goes, twice over: as the `position-area` the browser reads, and as the
|
|
3
|
+
* coordinates a browser without anchor positioning has to be given. One model rather than two, so the
|
|
4
|
+
* two paths cannot drift — the fallback is the CSS placement worked out by hand.
|
|
5
|
+
*
|
|
6
|
+
* Framework-free and layout-free: every function here takes rectangles and returns numbers, which is what
|
|
7
|
+
* makes the flip and the shift testable without a DOM (jsdom computes no layout at all).
|
|
8
|
+
*/
|
|
9
|
+
/** Which side of the anchor the layer sits on. `top`/`bottom` are the block axis, `start`/`end` the inline one. */
|
|
10
|
+
export type AnchorSide = 'top' | 'bottom' | 'start' | 'end';
|
|
11
|
+
/** Where along that side the layer lines up. */
|
|
12
|
+
export type AnchorAlign = 'start' | 'center' | 'end';
|
|
13
|
+
/** A box in viewport coordinates — what `getBoundingClientRect()` gives, narrowed to what placing needs. */
|
|
14
|
+
export interface AnchorRect {
|
|
15
|
+
top: number;
|
|
16
|
+
left: number;
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
}
|
|
20
|
+
export interface PlacementOptions {
|
|
21
|
+
side: AnchorSide;
|
|
22
|
+
align: AnchorAlign;
|
|
23
|
+
/** The gap between anchor and layer, in pixels. */
|
|
24
|
+
offset: number;
|
|
25
|
+
/** Whether a side that does not fit may be swapped for its opposite. */
|
|
26
|
+
flip: boolean;
|
|
27
|
+
/** Whether the inline axis runs right to left, which is what `start`/`end` mean. */
|
|
28
|
+
rtl: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The twelve `position-area` values a side and an alignment can name — spelled out rather than derived,
|
|
32
|
+
* so the compiler can see that each one is a value the `positionArea` prop takes.
|
|
33
|
+
*/
|
|
34
|
+
export type AnchorArea = 'block-start span-all' | 'block-start span-inline-start' | 'block-start span-inline-end' | 'block-end span-all' | 'block-end span-inline-start' | 'block-end span-inline-end' | 'span-all inline-start' | 'span-block-start inline-start' | 'span-block-end inline-start' | 'span-all inline-end' | 'span-block-start inline-end' | 'span-block-end inline-end';
|
|
35
|
+
/** Where the fallback puts the layer: viewport coordinates, and the side it settled on after flipping. */
|
|
36
|
+
export interface Placement {
|
|
37
|
+
top: number;
|
|
38
|
+
left: number;
|
|
39
|
+
side: AnchorSide;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The `position-area` for a side and an alignment — and the counter-intuitive half of the grammar, since
|
|
43
|
+
* an alignment is written as the span *away* from it: a layer whose start edge meets the anchor's start
|
|
44
|
+
* edge occupies the centre cell and the one after it, which is `span-inline-end`. Measured in Chrome 152.
|
|
45
|
+
*
|
|
46
|
+
* `center` is `span-all` rather than the `center` cell on purpose: the centre cell is only as wide as the
|
|
47
|
+
* anchor, so a layer wider than its anchor overflows it on the cross axis, and an overflow no flip can fix
|
|
48
|
+
* disqualifies every fallback position (the trap `positionTryFallbacks` documents).
|
|
49
|
+
*/
|
|
50
|
+
export declare function areaFor(side: AnchorSide, align: AnchorAlign): AnchorArea;
|
|
51
|
+
/**
|
|
52
|
+
* The side a used `position-area` names — the browser's own answer to "did you flip?", since
|
|
53
|
+
* `getComputedStyle` reports the position it settled on rather than the one that was specified.
|
|
54
|
+
*
|
|
55
|
+
* It is not the value that went in: measured in Chrome 152, a used value is normalised twice over. A
|
|
56
|
+
* `span-all` half is dropped (`block-end span-all` reads back `block-end`), and a value naming both axes
|
|
57
|
+
* comes back in the `start`/`end` shorthand family, where **position** names the axis rather than a
|
|
58
|
+
* keyword — `block-end span-inline-end` reads back `end span-end`, and `start span-end` once it has
|
|
59
|
+
* flipped. So the block axis is the first keyword and the inline axis the second, and the side is
|
|
60
|
+
* whichever of them is not a span.
|
|
61
|
+
*/
|
|
62
|
+
export declare function sideOfArea(area: string): AnchorSide | null;
|
|
63
|
+
/** The two candidate lists, spelled out so the compiler can see each is a value `positionTryFallbacks` takes. */
|
|
64
|
+
export type AnchorFallbacks = 'flip-block, flip-inline, flip-block flip-inline' | 'flip-inline, flip-block, flip-inline flip-block';
|
|
65
|
+
/**
|
|
66
|
+
* The `position-try-fallbacks` for a side: its own axis first, then the alignment's, then both. Three
|
|
67
|
+
* candidates rather than one because a candidate has to fit on **both** axes — so a single `flip-block`
|
|
68
|
+
* does nothing at all for a layer that overflows the *cross* axis, and the browser leaves it against the
|
|
69
|
+
* edge of the viewport (measured in Chrome 152, hand-written CSS). With the list, a menu aligned to its
|
|
70
|
+
* trigger's end mirrors to the other end rather than running off the page.
|
|
71
|
+
*/
|
|
72
|
+
export declare function fallbacksFor(side: AnchorSide): AnchorFallbacks;
|
|
73
|
+
/**
|
|
74
|
+
* The fallback's whole answer: flip to the opposite side when the requested one has no room and the
|
|
75
|
+
* opposite has more, then shift along the cross axis to stay in the viewport. The two are the entire
|
|
76
|
+
* middleware stack a positioning library sells, and they are twelve lines because the browser is doing
|
|
77
|
+
* neither here — this runs only where `anchor-name` is not supported.
|
|
78
|
+
*/
|
|
79
|
+
export declare function place(anchor: AnchorRect, layer: AnchorRect, viewport: AnchorRect, options: PlacementOptions): Placement;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The model behind `<Presence>`: how long the CSS already on an element says its current transition or
|
|
3
|
+
* animation lasts. No React and no DOM — it reads a `CSSStyleDeclaration`-shaped record, so CSS's
|
|
4
|
+
* list-cycling rules are testable without a browser, which is the only place they are ever exercised.
|
|
5
|
+
*/
|
|
6
|
+
declare namespace AnimationUtils {
|
|
7
|
+
/** The computed timing properties `activeDuration` reads. A `CSSStyleDeclaration` satisfies it. */
|
|
8
|
+
interface Timing {
|
|
9
|
+
transitionDuration: string;
|
|
10
|
+
transitionDelay: string;
|
|
11
|
+
animationName: string;
|
|
12
|
+
animationDuration: string;
|
|
13
|
+
animationDelay: string;
|
|
14
|
+
animationIterationCount: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* One frame of head-room on a measured wait. The timer starts in the commit that applies the leaving
|
|
18
|
+
* styles, and the browser only creates the transition on the style recalculation after it — so the
|
|
19
|
+
* exit really ends a frame later than the duration alone says.
|
|
20
|
+
*/
|
|
21
|
+
const SETTLE_FRAME = 16;
|
|
22
|
+
/**
|
|
23
|
+
* How long the element's own CSS says it has left to move, in ms. `0` means nothing is set up to run —
|
|
24
|
+
* which is also what `prefers-reduced-motion` produces, since every Box transition rides
|
|
25
|
+
* `--transitionTime` and that media query sets it to `0s`.
|
|
26
|
+
*/
|
|
27
|
+
function activeDuration(timing: Timing): number;
|
|
28
|
+
}
|
|
29
|
+
export default AnimationUtils;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type SortDirection = 'ASC' | 'DESC';
|
|
2
|
+
export interface GroupItem<TKey, T> {
|
|
3
|
+
key: TKey;
|
|
4
|
+
values: T[];
|
|
5
|
+
}
|
|
6
|
+
declare namespace ArrayUtils {
|
|
7
|
+
function take<T>(items: readonly T[], count: number, skip?: number): T[];
|
|
8
|
+
function sumBy<T>(items: readonly T[], fn: (value: T, index: number) => number, initialValue?: number): number;
|
|
9
|
+
function sortBy<T, TVal>(items: readonly T[], fn: (value: T) => TVal, direction?: SortDirection): T[];
|
|
10
|
+
function maxBy<T>(items: readonly T[], fn: (value: T) => number): number;
|
|
11
|
+
function findOrThrow<T>(items: readonly T[], predicate: (value: T) => boolean): T;
|
|
12
|
+
function toRecord<T, K extends string | number | symbol, V>(items: readonly T[], fn: (value: T) => [K, V] | undefined): Record<K, V>;
|
|
13
|
+
function groupBy<T, TKey extends string | number | symbol>(items: readonly T[], keySelector: (item: T, index: number) => TKey): GroupItem<TKey, T>[];
|
|
14
|
+
}
|
|
15
|
+
export default ArrayUtils;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An array whose elements are computed when somebody asks for one. A server row model lays out a million
|
|
3
|
+
* rows and renders fifty of them, so allocating an object per row is the one thing it must not do — and
|
|
4
|
+
* every reader of these lists indexes, slices or binary-searches rather than iterating, which is exactly
|
|
5
|
+
* what a proxy can answer. `length` is reported without the target ever holding that many elements.
|
|
6
|
+
*
|
|
7
|
+
* Iterating one (`map`, `flatMap`, a spread) materializes every element, which is the cost this exists to
|
|
8
|
+
* avoid: do that only where the length is known to be small.
|
|
9
|
+
*/
|
|
10
|
+
export default function lazyList<T>(length: number, at: (index: number) => T): T[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The chart palette, on its own so that `boxComponents.ts` can declare it without dragging the rest of
|
|
3
|
+
* `ChartUtils` — the path builders and the trigonometry — into the bundle every Box already pays for.
|
|
4
|
+
* `ChartUtils` re-exports all three, so the public names are unchanged.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* The colours a chart uses when nobody names any. Tokens rather than raw colours, so they resolve
|
|
8
|
+
* through the palette; six, because that is as many series as a tile can be told apart in — a seventh
|
|
9
|
+
* wraps round rather than inventing a colour.
|
|
10
|
+
*/
|
|
11
|
+
export declare const PALETTE: readonly ["sky-500", "emerald-500", "amber-500", "violet-500", "rose-500", "cyan-500"];
|
|
12
|
+
/** The same six for a dark background, where a 500 reads as muddy against near-black. */
|
|
13
|
+
export declare const DARK_PALETTE: readonly ["sky-400", "emerald-400", "amber-400", "violet-400", "rose-400", "cyan-400"];
|
|
14
|
+
/** The numbered palette as custom properties: `{ 'chart-1': 'sky-500', … }`. */
|
|
15
|
+
export declare function paletteVariables(palette: readonly string[]): Record<string, string>;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import * as ChartPalette from './chartPalette';
|
|
2
|
+
/**
|
|
3
|
+
* The model behind the chart primitives: every number a `<Sparkline>`, `<ProgressRing>`, `<Gauge>` or
|
|
4
|
+
* `<MiniDonut>` draws with, the palette a `<ChartContainer>` declares, and no React. Components render,
|
|
5
|
+
* models decide — which is also what makes a path string testable with no DOM. Everything is measured
|
|
6
|
+
* in one square of `VIEW` user units.
|
|
7
|
+
*/
|
|
8
|
+
declare namespace ChartUtils {
|
|
9
|
+
/** The side of the square every primitive draws inside. */
|
|
10
|
+
const VIEW = 100;
|
|
11
|
+
/** The centre of that square, where a ring or a donut is centred. */
|
|
12
|
+
const CENTRE: number;
|
|
13
|
+
/**
|
|
14
|
+
* The step a ring fraction is rounded to. A dash length lands in a *class name*, so an unrounded
|
|
15
|
+
* fraction would mean a rule per value; half a percent of a 96px ring is a third of a pixel, and the
|
|
16
|
+
* arc can still transition. Data-driven *paths* need none of this — a `d` attribute generates no CSS.
|
|
17
|
+
*/
|
|
18
|
+
const FRACTION_STEP = 0.005;
|
|
19
|
+
interface Point {
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
}
|
|
23
|
+
/** The ends of the value axis. Either can be fixed, so many rows can share one scale. */
|
|
24
|
+
interface Domain {
|
|
25
|
+
min?: number;
|
|
26
|
+
max?: number;
|
|
27
|
+
}
|
|
28
|
+
/** Rounded to `FRACTION_STEP` and clamped to the path: a ring cannot be more than full. */
|
|
29
|
+
function fraction(value: number): number;
|
|
30
|
+
/**
|
|
31
|
+
* The data as points in the view box, `y` already flipped for SVG's downward axis. Two decisions rather
|
|
32
|
+
* than guards: one datum is a flat line across the box, and data that never changes sits in the middle
|
|
33
|
+
* (`max === min` has no scale) instead of collapsing onto the floor.
|
|
34
|
+
*/
|
|
35
|
+
function points(data: readonly number[], domain?: Domain): Point[];
|
|
36
|
+
/** The points as a polyline: `M x y L x y …`. */
|
|
37
|
+
function linePath(points: readonly Point[]): string;
|
|
38
|
+
/** The same line, closed down both sides to the floor of the box so it can be filled. */
|
|
39
|
+
function areaPath(points: readonly Point[]): string;
|
|
40
|
+
/**
|
|
41
|
+
* The data as bars in **one** path, because these are drawn fifty rows at a time inside a scrolling
|
|
42
|
+
* grid. `gap` is the share of each slot left empty; every bar keeps a floor of one unit, so a
|
|
43
|
+
* bottom-of-the-scale value reads as a mark on the axis rather than as missing data.
|
|
44
|
+
*/
|
|
45
|
+
function barsPath(data: readonly number[], domain?: Domain, gap?: number): string;
|
|
46
|
+
/** The radius that fits a stroke of `thickness` inside the box, without clipping either edge. */
|
|
47
|
+
function radius(thickness: number): number;
|
|
48
|
+
/** The length of a full circle of that radius. */
|
|
49
|
+
function circumference(radius: number): number;
|
|
50
|
+
/**
|
|
51
|
+
* The dash pair that reveals `value` (0–1) of a path `length` long: one dash as long as the whole path,
|
|
52
|
+
* offset backwards, so the arc grows from its own beginning. Both are Box props, so it transitions.
|
|
53
|
+
*/
|
|
54
|
+
function dash(length: number, value: number): {
|
|
55
|
+
strokeDasharray: number;
|
|
56
|
+
strokeDashoffset: number;
|
|
57
|
+
};
|
|
58
|
+
/** How long an arc of `sweep` degrees is — the path length a `dash` is measured against. */
|
|
59
|
+
function arcLength(radius: number, sweep: number): number;
|
|
60
|
+
/**
|
|
61
|
+
* An arc as a path, from `start` degrees clockwise through `sweep`. Only constants of the shape reach
|
|
62
|
+
* this, so it is the same string for every gauge alike and belongs in the `d` attribute. A full turn is
|
|
63
|
+
* split in half — one arc whose ends coincide draws nothing at all.
|
|
64
|
+
*/
|
|
65
|
+
function arcPath(radius: number, start: number, sweep: number): string;
|
|
66
|
+
/** One segment of a donut: the dash that draws it, and how far round the circle it starts. */
|
|
67
|
+
interface Segment {
|
|
68
|
+
/** The visible run and the gap that follows it, as a `strokeDasharray` value. */
|
|
69
|
+
strokeDasharray: string;
|
|
70
|
+
/** Degrees clockwise from twelve o'clock — written as the `transform` attribute. */
|
|
71
|
+
rotate: number;
|
|
72
|
+
/** The datum this segment was drawn from, and its position in the data. */
|
|
73
|
+
value: number;
|
|
74
|
+
index: number;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* One segment per value, each the share of the circle it is worth: the same circle dashed to its own
|
|
78
|
+
* length and turned by an *attribute*, so the angles generate no rules. Values summing to nothing give
|
|
79
|
+
* no segments rather than a division by zero, and a negative value counts as none.
|
|
80
|
+
*/
|
|
81
|
+
function donutSegments(data: readonly number[], length: number): Segment[];
|
|
82
|
+
const PALETTE: readonly ["sky-500", "emerald-500", "amber-500", "violet-500", "rose-500", "cyan-500"];
|
|
83
|
+
const DARK_PALETTE: readonly ["sky-400", "emerald-400", "amber-400", "violet-400", "rose-400", "cyan-400"];
|
|
84
|
+
const paletteVariables: typeof ChartPalette.paletteVariables;
|
|
85
|
+
/**
|
|
86
|
+
* The variables a chart's series read, named as the ecosystem names them: `{ 'color-revenue':
|
|
87
|
+
* 'var(--chart-1)' }`. A list takes the palette in order, which is the whole case for the container — a
|
|
88
|
+
* chart naming no colour has its dark mode decided by the page. A record names its own paint per series.
|
|
89
|
+
*/
|
|
90
|
+
function seriesVariables(series: readonly string[] | Readonly<Record<string, string>>, slots?: number): Record<string, string>;
|
|
91
|
+
}
|
|
92
|
+
export default ChartUtils;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/** How a row's text, its identity or its disabled state is read: a key of the row, or a function. */
|
|
2
|
+
export type RowAccessor<TRow, TResult> = (keyof TRow & string) | ((row: TRow) => TResult);
|
|
3
|
+
/**
|
|
4
|
+
* What the combobox needs to know about a row to search it, tell it from its neighbours and refuse it.
|
|
5
|
+
* Only `label` is required — it is the text, and without one nothing could be typed at or read out.
|
|
6
|
+
*/
|
|
7
|
+
export interface ComboboxRowDef<TRow> {
|
|
8
|
+
/** The row's text: displayed, searched, and what a screen reader announces. */
|
|
9
|
+
label: RowAccessor<TRow, string>;
|
|
10
|
+
/** What makes two rows the same row. Defaults to the label, which is what a list of strings has. */
|
|
11
|
+
key?: RowAccessor<TRow, string | number>;
|
|
12
|
+
/** A row that cannot be chosen: skipped by the arrows and inert to a press. */
|
|
13
|
+
disabled?: RowAccessor<TRow, boolean>;
|
|
14
|
+
}
|
|
15
|
+
/** A row of the open listbox. `create` is the offer to make a row out of what was typed. */
|
|
16
|
+
export type ComboboxRow<TRow> = {
|
|
17
|
+
kind: 'option';
|
|
18
|
+
row: TRow;
|
|
19
|
+
} | {
|
|
20
|
+
kind: 'create';
|
|
21
|
+
query: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Which rows a query leaves, in the order they will be shown. It takes the whole list rather than one row
|
|
25
|
+
* so that it can rank as well as reject, and it is handed the label reader so that composing it with the
|
|
26
|
+
* built-in one costs nothing.
|
|
27
|
+
*/
|
|
28
|
+
export type ComboboxFilter<TRow> = (rows: TRow[], query: string, labelOf: (row: TRow) => string) => TRow[];
|
|
29
|
+
/**
|
|
30
|
+
* The combobox with no React in it: reading a row, filtering the list, and what the selection becomes when
|
|
31
|
+
* a row is chosen. All of it is a pure function of the data and the query, which is what lets the same
|
|
32
|
+
* answers be tested without a DOM and re-used by a virtualized listbox that renders fifty of ten thousand.
|
|
33
|
+
*/
|
|
34
|
+
declare namespace ComboboxUtils {
|
|
35
|
+
/** Resolve an accessor against a row. A key reads the property; a function is called. */
|
|
36
|
+
function read<TRow, TResult>(accessor: RowAccessor<TRow, TResult>, row: TRow): TResult;
|
|
37
|
+
/** A row's text. Coerced, so a numeric column is a legal label and a missing one is empty rather than `"undefined"`. */
|
|
38
|
+
function labelOf<TRow>(def: ComboboxRowDef<TRow>, row: TRow): string;
|
|
39
|
+
/** A row's identity. The label by default: a list of plain strings is its own set of keys. */
|
|
40
|
+
function keyOf<TRow>(def: ComboboxRowDef<TRow>, row: TRow): string | number;
|
|
41
|
+
function isDisabled<TRow>(def: ComboboxRowDef<TRow>, row: TRow): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* The form a query and a label are compared in: case-folded and stripped of accents, so that `jose`
|
|
44
|
+
* finds `José`. NFD splits a letter from its accent and the mark range is what is then dropped.
|
|
45
|
+
*/
|
|
46
|
+
function normalize(text: string): string;
|
|
47
|
+
/** Whether a label answers a query. A substring rather than a prefix: a surname is worth finding. */
|
|
48
|
+
function matches(label: string, query: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The filter a combobox uses when its caller names none, exported so that a caller who names one can
|
|
51
|
+
* still start from it — `(rows, query, labelOf) => filterRows(rows, query, labelOf).slice(0, 20)`.
|
|
52
|
+
*/
|
|
53
|
+
function filterRows<TRow>(rows: TRow[], query: string, labelOf: (row: TRow) => string): TRow[];
|
|
54
|
+
/** The selection as a list, whichever shape it arrived in. `null` and `undefined` are "nothing chosen". */
|
|
55
|
+
function toArray<TRow>(value: TRow | TRow[] | null | undefined): TRow[];
|
|
56
|
+
function isSelected<TRow>(selection: TRow[], row: TRow, keyFor: (row: TRow) => string | number): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* What the selection becomes when a row is chosen. Single-select replaces, and choosing what is already
|
|
59
|
+
* chosen keeps it — a combobox has no "unselect by reselecting", since its field would have nothing to
|
|
60
|
+
* show. Multi-select toggles, which is how a chip is removed from the listbox rather than from the chip.
|
|
61
|
+
*/
|
|
62
|
+
function toggle<TRow>(selection: TRow[], row: TRow, multiple: boolean, keyFor: (row: TRow) => string | number): TRow[];
|
|
63
|
+
interface RowsOptions<TRow> {
|
|
64
|
+
data: TRow[];
|
|
65
|
+
def: ComboboxRowDef<TRow>;
|
|
66
|
+
/** What has been typed. Only filters once the caller says it was typed rather than displayed. */
|
|
67
|
+
query: string;
|
|
68
|
+
/** `false` when the data is already filtered — a server that searched, or a caller that did. */
|
|
69
|
+
filter: ComboboxFilter<TRow> | false;
|
|
70
|
+
/** Whether the query is the user's rather than the selection's text. A displayed value filters nothing. */
|
|
71
|
+
typed: boolean;
|
|
72
|
+
/** Turns a query into the row it would create, or `null` for one that should not be offered. */
|
|
73
|
+
createRow?: (query: string) => TRow | null;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Every row the listbox shows, in keyboard order. The create row is last and appears only for a query
|
|
77
|
+
* that no row already answers by name — offering "Create Apple" beside Apple is how a list grows twins.
|
|
78
|
+
*/
|
|
79
|
+
function rowsFor<TRow>(options: RowsOptions<TRow>): ComboboxRow<TRow>[];
|
|
80
|
+
/** A row the arrows skip and a press does nothing to. The create row is always available. */
|
|
81
|
+
function isRowDisabled<TRow>(def: ComboboxRowDef<TRow>, row: ComboboxRow<TRow>): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Where the highlight goes when the listbox opens: the selected row whichever key opened it, so that
|
|
84
|
+
* Down or Up from a chosen value moves on from it rather than jumping to an end. With nothing chosen it
|
|
85
|
+
* falls back to the end the key implied. `-1` when nothing can be highlighted — no rows, or all disabled.
|
|
86
|
+
*/
|
|
87
|
+
function activeIndexFor<TRow>(rows: ComboboxRow<TRow>[], selection: TRow[], def: ComboboxRowDef<TRow>, fallback?: 'first' | 'last'): number;
|
|
88
|
+
}
|
|
89
|
+
export default ComboboxUtils;
|