@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/react-shared.mjs
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
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;
|
|
104
|
+
//#endregion
|
|
105
|
+
export { p as a, s as c, m as i, r as l, v as n, d as o, g as r, u as s, b as t };
|
|
@@ -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.o(e,r===`svg`);return n.default.createElement(n.default.Fragment,null,o,n.default.createElement(r,t.c(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.l(t.o(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 { c as e, l as t, o 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,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,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The model behind the chart primitives: every number a `<Sparkline>`, `<ProgressRing>`, `<Gauge>` or
|
|
3
|
+
* `<MiniDonut>` draws with, the palette a `<ChartContainer>` declares, and no React. Components render,
|
|
4
|
+
* models decide — which is also what makes a path string testable with no DOM. Everything is measured
|
|
5
|
+
* in one square of `VIEW` user units.
|
|
6
|
+
*/
|
|
7
|
+
declare namespace ChartUtils {
|
|
8
|
+
/** The side of the square every primitive draws inside. */
|
|
9
|
+
const VIEW = 100;
|
|
10
|
+
/** The centre of that square, where a ring or a donut is centred. */
|
|
11
|
+
const CENTRE: number;
|
|
12
|
+
/**
|
|
13
|
+
* The step a ring fraction is rounded to. A dash length lands in a *class name*, so an unrounded
|
|
14
|
+
* fraction would mean a rule per value; half a percent of a 96px ring is a third of a pixel, and the
|
|
15
|
+
* arc can still transition. Data-driven *paths* need none of this — a `d` attribute generates no CSS.
|
|
16
|
+
*/
|
|
17
|
+
const FRACTION_STEP = 0.005;
|
|
18
|
+
interface Point {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
}
|
|
22
|
+
/** The ends of the value axis. Either can be fixed, so many rows can share one scale. */
|
|
23
|
+
interface Domain {
|
|
24
|
+
min?: number;
|
|
25
|
+
max?: number;
|
|
26
|
+
}
|
|
27
|
+
/** Rounded to `FRACTION_STEP` and clamped to the path: a ring cannot be more than full. */
|
|
28
|
+
function fraction(value: number): number;
|
|
29
|
+
/**
|
|
30
|
+
* The data as points in the view box, `y` already flipped for SVG's downward axis. Two decisions rather
|
|
31
|
+
* than guards: one datum is a flat line across the box, and data that never changes sits in the middle
|
|
32
|
+
* (`max === min` has no scale) instead of collapsing onto the floor.
|
|
33
|
+
*/
|
|
34
|
+
function points(data: readonly number[], domain?: Domain): Point[];
|
|
35
|
+
/** The points as a polyline: `M x y L x y …`. */
|
|
36
|
+
function linePath(points: readonly Point[]): string;
|
|
37
|
+
/** The same line, closed down both sides to the floor of the box so it can be filled. */
|
|
38
|
+
function areaPath(points: readonly Point[]): string;
|
|
39
|
+
/**
|
|
40
|
+
* The data as bars in **one** path, because these are drawn fifty rows at a time inside a scrolling
|
|
41
|
+
* grid. `gap` is the share of each slot left empty; every bar keeps a floor of one unit, so a
|
|
42
|
+
* bottom-of-the-scale value reads as a mark on the axis rather than as missing data.
|
|
43
|
+
*/
|
|
44
|
+
function barsPath(data: readonly number[], domain?: Domain, gap?: number): string;
|
|
45
|
+
/** The radius that fits a stroke of `thickness` inside the box, without clipping either edge. */
|
|
46
|
+
function radius(thickness: number): number;
|
|
47
|
+
/** The length of a full circle of that radius. */
|
|
48
|
+
function circumference(radius: number): number;
|
|
49
|
+
/**
|
|
50
|
+
* The dash pair that reveals `value` (0–1) of a path `length` long: one dash as long as the whole path,
|
|
51
|
+
* offset backwards, so the arc grows from its own beginning. Both are Box props, so it transitions.
|
|
52
|
+
*/
|
|
53
|
+
function dash(length: number, value: number): {
|
|
54
|
+
strokeDasharray: number;
|
|
55
|
+
strokeDashoffset: number;
|
|
56
|
+
};
|
|
57
|
+
/** How long an arc of `sweep` degrees is — the path length a `dash` is measured against. */
|
|
58
|
+
function arcLength(radius: number, sweep: number): number;
|
|
59
|
+
/**
|
|
60
|
+
* An arc as a path, from `start` degrees clockwise through `sweep`. Only constants of the shape reach
|
|
61
|
+
* this, so it is the same string for every gauge alike and belongs in the `d` attribute. A full turn is
|
|
62
|
+
* split in half — one arc whose ends coincide draws nothing at all.
|
|
63
|
+
*/
|
|
64
|
+
function arcPath(radius: number, start: number, sweep: number): string;
|
|
65
|
+
/** One segment of a donut: the dash that draws it, and how far round the circle it starts. */
|
|
66
|
+
interface Segment {
|
|
67
|
+
/** The visible run and the gap that follows it, as a `strokeDasharray` value. */
|
|
68
|
+
strokeDasharray: string;
|
|
69
|
+
/** Degrees clockwise from twelve o'clock — written as the `transform` attribute. */
|
|
70
|
+
rotate: number;
|
|
71
|
+
/** The datum this segment was drawn from, and its position in the data. */
|
|
72
|
+
value: number;
|
|
73
|
+
index: number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* One segment per value, each the share of the circle it is worth: the same circle dashed to its own
|
|
77
|
+
* length and turned by an *attribute*, so the angles generate no rules. Values summing to nothing give
|
|
78
|
+
* no segments rather than a division by zero, and a negative value counts as none.
|
|
79
|
+
*/
|
|
80
|
+
function donutSegments(data: readonly number[], length: number): Segment[];
|
|
81
|
+
/**
|
|
82
|
+
* The colours a chart uses when nobody names any. Tokens rather than raw colours, so they resolve
|
|
83
|
+
* through the palette; six, because that is as many series as a tile can be told apart in — a seventh
|
|
84
|
+
* wraps round rather than inventing a colour.
|
|
85
|
+
*/
|
|
86
|
+
const PALETTE: readonly ["sky-500", "emerald-500", "amber-500", "violet-500", "rose-500", "cyan-500"];
|
|
87
|
+
/** The same six for a dark background, where a 500 reads as muddy against near-black. */
|
|
88
|
+
const DARK_PALETTE: readonly ["sky-400", "emerald-400", "amber-400", "violet-400", "rose-400", "cyan-400"];
|
|
89
|
+
/** The numbered palette as custom properties: `{ 'chart-1': 'sky-500', … }`. */
|
|
90
|
+
function paletteVariables(palette: readonly string[]): Record<string, string>;
|
|
91
|
+
/**
|
|
92
|
+
* The variables a chart's series read, named as the ecosystem names them: `{ 'color-revenue':
|
|
93
|
+
* 'var(--chart-1)' }`. A list takes the palette in order, which is the whole case for the container — a
|
|
94
|
+
* chart naming no colour has its dark mode decided by the page. A record names its own paint per series.
|
|
95
|
+
*/
|
|
96
|
+
function seriesVariables(series: readonly string[] | Readonly<Record<string, string>>, slots?: number): Record<string, string>;
|
|
97
|
+
}
|
|
98
|
+
export default ChartUtils;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Did this happen inside that?" — the question behind every popup that closes when you click away, asked
|
|
3
|
+
* identically by `useVisibility` and `useDismiss`. `ElementLike` is structural rather than
|
|
4
|
+
* `React.RefObject`, which keeps the file framework-free. Named exports rather than a namespace, for the
|
|
5
|
+
* reason in `environmentUtils.ts`: a namespace object cannot be tree-shaken a function at a time.
|
|
6
|
+
*/
|
|
7
|
+
export type ElementLike = {
|
|
8
|
+
readonly current: Element | null;
|
|
9
|
+
} | Element | null | undefined;
|
|
10
|
+
/** The element behind a ref or an element, whichever the caller happens to be holding. */
|
|
11
|
+
export declare function elementOf(value: ElementLike): Element | null;
|
|
12
|
+
/** The same, narrowed to an `HTMLElement` — for callers that need `focus()` or `style`. */
|
|
13
|
+
export declare function htmlElementOf(value: ElementLike): HTMLElement | null;
|
|
14
|
+
/**
|
|
15
|
+
* Whether an event happened inside any of these elements. `composedPath()` first, so an event from a
|
|
16
|
+
* shadow root counts as inside its host; `contains()` as the fallback, since the path is populated only
|
|
17
|
+
* while the event is being dispatched.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isEventInside(event: Event, elements: readonly ElementLike[]): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Whether this element reads right to left — the direction the browser *resolved*, which is the only
|
|
22
|
+
* form of the answer that accounts for a `dir="auto"` or a `<bdi>` above it. Nothing but
|
|
23
|
+
* `getComputedStyle` knows it, and jsdom computes no direction at all, so a test environment reads as
|
|
24
|
+
* left to right — which is the initial value anyway.
|
|
25
|
+
*/
|
|
26
|
+
export declare function isRtl(value: ElementLike): boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Is there a DOM, and what may I touch?" — asked in seven places and once answered with a hand-written
|
|
3
|
+
* `typeof` in each. The answers are not interchangeable: a server render has no `document`, a `document`
|
|
4
|
+
* may have no `<head>`, and `matchMedia` is missing from environments that look like browsers. Named
|
|
5
|
+
* exports rather than a namespace, which compiles to an IIFE that ships whole, and every chunk imports this.
|
|
6
|
+
*/
|
|
7
|
+
/** A browser: a window with a document. What an effect that touches layout needs to exist. */
|
|
8
|
+
export declare function isBrowser(): boolean;
|
|
9
|
+
/** Whether there is a document at all — false during a server render. */
|
|
10
|
+
export declare function hasDocument(): boolean;
|
|
11
|
+
/** The document, or null when there is none, so a caller can `?.` instead of branching. */
|
|
12
|
+
export declare function documentOrNull(): Document | null;
|
|
13
|
+
/** The document root (`<html>`), or null when there is no DOM. */
|
|
14
|
+
export declare function documentRoot(): Element | null;
|
|
15
|
+
/** The `<head>` to write a stylesheet into, or null when there is nothing to write to. */
|
|
16
|
+
export declare function documentHead(): HTMLHeadElement | null;
|
|
17
|
+
/** A media query, or null where `matchMedia` does not exist — a server, or a bare jsdom. */
|
|
18
|
+
export declare function matchMedia(query: string): MediaQueryList | null;
|
package/utils/memo.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface Memo<T> {
|
|
2
|
+
value: T;
|
|
3
|
+
clear(): void;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Lazily-computed cached value with explicit dependency edges. Upstream memos go in `deps` as a thunk, so
|
|
7
|
+
* they can reference siblings whatever the declaration order; clearing a dep cascades, so a mutation only
|
|
8
|
+
* has to clear the root that changed.
|
|
9
|
+
*/
|
|
10
|
+
export default function memo<T>(action: () => T, deps?: () => Memo<unknown>[]): Memo<T>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Object helpers that know nothing about the prop registry — which is what lets both packages import
|
|
3
|
+
* this file. `mergeDeep` used to live here and does not any more: it reads `pseudo2`, so it belongs in
|
|
4
|
+
* `src/core/mergeDeep.ts` (see the note there).
|
|
5
|
+
*/
|
|
6
|
+
declare namespace ObjectUtils {
|
|
7
|
+
function buildProps<T extends {
|
|
8
|
+
props?: object;
|
|
9
|
+
}, TKey extends keyof T>(props: T, keys: Readonly<TKey[]>, extraTagProps?: object): T;
|
|
10
|
+
function isObject(value: unknown): value is object;
|
|
11
|
+
function isKeyOf<T extends object>(key: any, obj: T): key is keyof T;
|
|
12
|
+
}
|
|
13
|
+
export default ObjectUtils;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fuzzy search implementation for text matching.
|
|
3
|
+
* Matches characters in order but not necessarily consecutively.
|
|
4
|
+
*/
|
|
5
|
+
export interface FuzzyMatch {
|
|
6
|
+
score: number;
|
|
7
|
+
matches: [number, number][];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Performs fuzzy matching of a pattern against a target string.
|
|
11
|
+
* Returns a match object with score and matched ranges, or null if no match.
|
|
12
|
+
*/
|
|
13
|
+
export declare function fuzzyMatch(pattern: string, target: string): FuzzyMatch | null;
|
|
14
|
+
/**
|
|
15
|
+
* Simple fuzzy search that returns true if the pattern matches the target.
|
|
16
|
+
*/
|
|
17
|
+
export declare function fuzzySearch(pattern: string, target: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Fuzzy search across multiple fields of an object.
|
|
20
|
+
* Returns true if the pattern matches any of the specified fields.
|
|
21
|
+
*/
|
|
22
|
+
export declare function fuzzySearchObject<T extends object>(pattern: string, obj: T, fields?: (keyof T)[]): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Get the best fuzzy match score across multiple fields.
|
|
25
|
+
* Returns the highest score found, or 0 if no match.
|
|
26
|
+
*/
|
|
27
|
+
export declare function fuzzySearchObjectScore<T extends object>(pattern: string, obj: T, fields?: (keyof T)[]): number;
|