@box-kite/react 2.0.1 → 2.2.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 +24 -2
- package/.claude/skills/box-kite/SKILL.md +27 -5
- package/.claude/skills/box-kite/references/components.md +8 -3
- package/.claude/skills/box-kite/references/patterns.md +24 -1
- package/.claude/skills/box-kite/references/styling.md +23 -0
- package/.cursor/rules/box-kite.mdc +25 -3
- package/AGENTS.md +28 -3
- package/BOX_AI_CONTEXT.md +732 -12
- package/BOX_KITE_AI_CONTEXT.md +732 -12
- package/README.md +41 -9
- package/box.cjs +1 -1
- package/box.d.ts +13 -2
- package/box.mjs +25 -18
- package/catalog.cjs +1 -0
- package/catalog.d.ts +8 -0
- package/catalog.mjs +2347 -0
- package/client.cjs +1 -1
- package/client.mjs +59 -53
- package/components/agent.cjs +1 -0
- package/components/agent.d.ts +215 -0
- package/components/agent.mjs +405 -0
- package/components/button.cjs +1 -1
- package/components/button.mjs +10 -14
- package/components/chart.d.ts +1 -0
- package/components/dashboard.cjs +1 -0
- package/components/dashboard.d.ts +121 -0
- package/components/dashboard.mjs +690 -0
- package/components/dataGrid/components/dataGridBody.d.ts +2 -1
- package/components/dataGrid/components/dataGridDetailRow.d.ts +13 -2
- package/components/dataGrid/components/dataGridGroupRow.d.ts +13 -2
- package/components/dataGrid/components/dataGridRow.d.ts +13 -2
- package/components/dataGrid/contracts/dataGridContract.d.ts +66 -2
- package/components/dataGrid/models/cellModel.d.ts +3 -0
- package/components/dataGrid/models/editModel.d.ts +27 -0
- package/components/dataGrid/models/exportModel.d.ts +2 -1
- package/components/dataGrid/models/gridModel.d.ts +3 -0
- package/components/dataGrid/models/rangeModel.d.ts +119 -0
- package/components/dataGrid/models/viewportModel.d.ts +23 -2
- package/components/dataGrid/useGridNavigation.d.ts +10 -2
- package/components/dataGrid.cjs +4 -1
- package/components/dataGrid.d.ts +3 -0
- package/components/dataGrid.mjs +1056 -765
- package/components/flex.cjs +1 -1
- package/components/flex.mjs +10 -13
- package/components/form.cjs +1 -1
- package/components/form.mjs +7 -7
- package/components/grid.cjs +1 -1
- package/components/grid.mjs +10 -13
- package/components/markdown.cjs +1 -0
- package/components/markdown.d.ts +55 -0
- package/components/markdown.mjs +179 -0
- package/components/menu.cjs +1 -1
- package/components/menu.mjs +16 -16
- package/components/overlay.cjs +1 -1
- package/components/overlay.mjs +35 -34
- package/components/popover.cjs +1 -1
- package/components/popover.mjs +4 -4
- package/components/semantics.cjs +1 -1
- package/components/semantics.d.ts +29 -29
- package/components/semantics.mjs +9 -13
- package/components/skeleton.cjs +1 -0
- package/components/skeleton.d.ts +34 -0
- package/components/skeleton.mjs +25 -0
- package/components/svg.cjs +1 -1
- package/components/svg.mjs +38 -44
- package/components/textarea.cjs +1 -1
- package/components/textarea.mjs +12 -16
- package/components/textbox.cjs +1 -1
- package/components/textbox.mjs +12 -16
- package/components/toaster.cjs +1 -1
- package/components/toaster.mjs +42 -43
- package/components/visuallyHidden.cjs +1 -1
- package/components/visuallyHidden.mjs +10 -13
- package/dashboardSchema.cjs +1 -0
- package/dashboardSchema.mjs +78 -0
- package/docs/a11y.md +2 -3
- package/docs/catalog.md +451 -0
- package/docs/components.md +4 -0
- package/docs/index.md +3 -0
- package/docs/interop.md +237 -0
- package/docs/mcp.md +70 -0
- package/docs/props.md +135 -23
- package/interop.cjs +1 -0
- package/interop.d.ts +51 -0
- package/interop.mjs +454 -0
- package/layer.cjs +1 -1
- package/layer.mjs +61 -59
- package/mcp/src/data.d.ts +88 -0
- package/mcp/src/data.test.d.ts +1 -0
- package/mcp/src/engine.d.ts +23 -0
- package/mcp/src/index.d.ts +1 -0
- package/mcp/src/search.d.ts +26 -0
- package/mcp/src/search.test.d.ts +1 -0
- package/mcp/src/server.d.ts +18 -0
- package/mcp/src/server.test.d.ts +1 -0
- package/mcp/src/styles.d.ts +27 -0
- package/mcp/src/styles.test.d.ts +1 -0
- package/mcp/src/tools.d.ts +18 -0
- package/mcp/src/vocabulary.d.ts +41 -0
- package/package.json +170 -37
- package/react/boxComponent.d.ts +10 -0
- package/react/popover/useTopLayer.d.ts +17 -0
- package/react/spec/renderSpec.d.ts +51 -0
- package/react/spec/specBoundary.d.ts +25 -0
- package/react/spec/specRegistry.d.ts +42 -0
- package/react/spec/specRenderer.d.ts +10 -0
- package/react/theme/theme.d.ts +10 -0
- package/react/useStyles.d.ts +2 -0
- package/react-shared.cjs +1 -1
- package/react-shared.mjs +44 -37
- package/registry/blocks/dashboard-shell/dashboard-shell.d.ts +22 -0
- package/registry/blocks/dashboard-shell/dashboard-stats.d.ts +13 -0
- package/registry/blocks/data-grid/invoice-rows.d.ts +15 -0
- package/registry/blocks/data-grid/invoices-grid.d.ts +1 -0
- package/registry/blocks/settings-form/settings-form.d.ts +17 -0
- package/rsc.cjs +1 -1
- package/rsc.d.ts +11 -1
- package/rsc.mjs +15 -12
- package/spec.cjs +2 -0
- package/spec.d.ts +12 -0
- package/spec.mjs +382 -0
- package/specData.cjs +1 -0
- package/specData.mjs +69 -0
- package/specDefs.cjs +1 -0
- package/specDefs.mjs +33 -0
- package/specSchema.cjs +1 -0
- package/specSchema.mjs +88 -0
- package/ssg.cjs +1 -1
- package/ssg.d.ts +8 -2
- package/ssg.mjs +13 -9
- package/utils/agent/agentUtils.d.ts +81 -0
- package/utils/catalog/catalogContracts.d.ts +19 -0
- package/utils/catalog/catalogManifest.d.ts +8 -0
- package/utils/dashboard/dashboardSchema.d.ts +18 -0
- package/utils/dashboard/dashboardUtils.d.ts +97 -0
- package/utils/environment/environmentUtils.d.ts +5 -0
- package/utils/interop/a2uiInterop.d.ts +82 -0
- package/utils/interop/assistantUiInterop.d.ts +34 -0
- package/utils/interop/toolInterop.d.ts +30 -0
- package/utils/spec/specData.d.ts +19 -0
- package/utils/spec/specDefs.d.ts +11 -0
- package/utils/spec/specProps.d.ts +15 -0
- package/utils/spec/specSchema.d.ts +23 -0
- package/utils/spec/specTypes.d.ts +71 -0
- package/utils/spec/specValidate.d.ts +10 -0
package/react-shared.mjs
CHANGED
|
@@ -1,36 +1,43 @@
|
|
|
1
|
-
import e from "react";
|
|
2
|
-
import { classNames as
|
|
1
|
+
import e, { forwardRef as t, memo as n } from "react";
|
|
2
|
+
import { classNames as r, getDefaultEngine as i } from "@box-kite/core";
|
|
3
3
|
//#region src/react/boxClassNames.ts
|
|
4
|
-
function
|
|
4
|
+
function a({ classNames: e, styleElements: t }, n) {
|
|
5
5
|
return {
|
|
6
|
-
className:
|
|
7
|
-
styles:
|
|
6
|
+
className: r(e, n).join(" "),
|
|
7
|
+
styles: t
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
10
|
//#endregion
|
|
11
|
+
//#region src/react/boxComponent.ts
|
|
12
|
+
var o = parseInt(e.version, 10) >= 19;
|
|
13
|
+
function s(e, r) {
|
|
14
|
+
let i = o ? (t) => e(t, t.ref ?? null) : t(e), a = n(i);
|
|
15
|
+
return i.displayName = r, a.displayName = r, a;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
11
18
|
//#region src/utils/box/boxUtils.ts
|
|
12
|
-
var
|
|
19
|
+
var c = { selected: "aria-selected" }, l;
|
|
13
20
|
(function(e) {
|
|
14
21
|
function t(e, t, n) {
|
|
15
|
-
e !== void 0 && e != null && (n[
|
|
22
|
+
e !== void 0 && e != null && (n[c[t] ?? t] = Array.isArray(e) ? e[0] : e);
|
|
16
23
|
}
|
|
17
24
|
e.assignBooleanProp = t;
|
|
18
|
-
})(
|
|
19
|
-
var
|
|
25
|
+
})(l ||= {});
|
|
26
|
+
var u = l;
|
|
20
27
|
//#endregion
|
|
21
28
|
//#region src/react/boxTagProps.ts
|
|
22
|
-
function
|
|
23
|
-
let
|
|
29
|
+
function d(e, t) {
|
|
30
|
+
let n = e, { props: i, className: a, disabled: o, required: s, checked: c, selected: l } = n, d = {
|
|
24
31
|
...i,
|
|
25
|
-
className: t
|
|
32
|
+
className: r(t, a).join(" ")
|
|
26
33
|
};
|
|
27
|
-
return
|
|
34
|
+
return u.assignBooleanProp(o, "disabled", d), u.assignBooleanProp(s, "required", d), u.assignBooleanProp(c, "checked", d), u.assignBooleanProp(l, "selected", d), "style" in n && (d.style = n.style), "id" in n && (d.id = n.id), d;
|
|
28
35
|
}
|
|
29
36
|
//#endregion
|
|
30
37
|
//#region src/react/styleElements.ts
|
|
31
|
-
var
|
|
32
|
-
function
|
|
33
|
-
if (t?.length) return !
|
|
38
|
+
var f = parseInt(e.version, 10) >= 19, p = !1;
|
|
39
|
+
function m(t) {
|
|
40
|
+
if (t?.length) return !f && !p && (p = !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
41
|
key: t,
|
|
35
42
|
href: t,
|
|
36
43
|
precedence: r,
|
|
@@ -39,48 +46,48 @@ function u(t) {
|
|
|
39
46
|
}
|
|
40
47
|
//#endregion
|
|
41
48
|
//#region src/react/resolveStyles.ts
|
|
42
|
-
function
|
|
43
|
-
let { classNames:
|
|
49
|
+
function h(e, t) {
|
|
50
|
+
let { classNames: n, signature: r, styleElements: a } = i().resolveClassNames(e, t);
|
|
44
51
|
return {
|
|
45
|
-
classNames:
|
|
46
|
-
signature:
|
|
47
|
-
styleElements:
|
|
52
|
+
classNames: n,
|
|
53
|
+
signature: r,
|
|
54
|
+
styleElements: m(a)
|
|
48
55
|
};
|
|
49
56
|
}
|
|
50
57
|
//#endregion
|
|
51
58
|
//#region src/react/svg/attributesInProps.ts
|
|
52
|
-
var
|
|
53
|
-
function
|
|
54
|
-
return e[
|
|
59
|
+
var g = "__boxAttributesInProps";
|
|
60
|
+
function _(e) {
|
|
61
|
+
return e[g] = !0, e;
|
|
55
62
|
}
|
|
56
|
-
function
|
|
57
|
-
return typeof e == "function" || typeof e == "object" && e ? e[
|
|
63
|
+
function v(e) {
|
|
64
|
+
return typeof e == "function" || typeof e == "object" && e ? e[g] === !0 : !1;
|
|
58
65
|
}
|
|
59
66
|
//#endregion
|
|
60
67
|
//#region src/react/svg/svgNaming.ts
|
|
61
|
-
var
|
|
68
|
+
var y = [
|
|
62
69
|
"role",
|
|
63
70
|
"aria-label",
|
|
64
71
|
"aria-labelledby",
|
|
65
72
|
"aria-hidden"
|
|
66
73
|
];
|
|
67
|
-
function
|
|
74
|
+
function b(e, t) {
|
|
68
75
|
if (e !== void 0) return {
|
|
69
76
|
role: "img",
|
|
70
77
|
"aria-label": e
|
|
71
78
|
};
|
|
72
|
-
if (!(t &&
|
|
79
|
+
if (!(t && y.some((e) => e in t))) return { "aria-hidden": !0 };
|
|
73
80
|
}
|
|
74
81
|
//#endregion
|
|
75
82
|
//#region src/utils/string/stringUtils.ts
|
|
76
|
-
var
|
|
83
|
+
var x;
|
|
77
84
|
(function(e) {
|
|
78
85
|
function t(e) {
|
|
79
86
|
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
80
87
|
}
|
|
81
88
|
e.capitalize = t;
|
|
82
|
-
})(
|
|
83
|
-
var
|
|
89
|
+
})(x ||= {});
|
|
90
|
+
var S = x, C;
|
|
84
91
|
(function(e) {
|
|
85
92
|
function t(e, t, n) {
|
|
86
93
|
let r = { ...e }, i = r.props || {};
|
|
@@ -99,15 +106,15 @@ var v = _, y;
|
|
|
99
106
|
return e in t;
|
|
100
107
|
}
|
|
101
108
|
e.isKeyOf = r;
|
|
102
|
-
})(
|
|
103
|
-
var
|
|
109
|
+
})(C ||= {});
|
|
110
|
+
var w = C, T = [
|
|
104
111
|
"sky-500",
|
|
105
112
|
"emerald-500",
|
|
106
113
|
"amber-500",
|
|
107
114
|
"violet-500",
|
|
108
115
|
"rose-500",
|
|
109
116
|
"cyan-500"
|
|
110
|
-
],
|
|
117
|
+
], E = [
|
|
111
118
|
"sky-400",
|
|
112
119
|
"emerald-400",
|
|
113
120
|
"amber-400",
|
|
@@ -115,8 +122,8 @@ var b = y, x = [
|
|
|
115
122
|
"rose-400",
|
|
116
123
|
"cyan-400"
|
|
117
124
|
];
|
|
118
|
-
function
|
|
125
|
+
function D(e) {
|
|
119
126
|
return e.reduce((e, t, n) => (e[`chart-${n + 1}`] = t, e), {});
|
|
120
127
|
}
|
|
121
128
|
//#endregion
|
|
122
|
-
export {
|
|
129
|
+
export { S as a, _ as c, d, s as f, w as i, h as l, T as n, b as o, a as p, D as r, v as s, E as t, m as u };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The frame an admin app hangs off: a sidebar, a header with search, a theme toggle and an account
|
|
4
|
+
* menu, and the page itself. The sidebar sticks to the top of its column and folds away below the `md`
|
|
5
|
+
* breakpoint; nothing here is measured or positioned by script.
|
|
6
|
+
*
|
|
7
|
+
* `Box.Theme` is `use="local"` here, so the theme lands on this element and the block can sit inside a
|
|
8
|
+
* page that has its own. Move it to your root layout as `use="global"` for an app-wide switch.
|
|
9
|
+
*/
|
|
10
|
+
export interface NavItem {
|
|
11
|
+
id: string;
|
|
12
|
+
label: string;
|
|
13
|
+
href: string;
|
|
14
|
+
icon: ReactElement;
|
|
15
|
+
}
|
|
16
|
+
export interface DashboardShellProps {
|
|
17
|
+
/** The heading above the page, and the `id` of the nav item that is marked as current. */
|
|
18
|
+
title: string;
|
|
19
|
+
current?: string;
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
}
|
|
22
|
+
export default function DashboardShell({ title, current, children }: DashboardShellProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The row of tiles above a dashboard. The shapes are `components/chart` primitives — an SVG each, no
|
|
3
|
+
* chart library — and there is no `'use client'` here on purpose: nothing in this file holds state, so
|
|
4
|
+
* it renders in a Server Component, styles and all.
|
|
5
|
+
*/
|
|
6
|
+
export interface Stat {
|
|
7
|
+
label: string;
|
|
8
|
+
value: string;
|
|
9
|
+
delta: string;
|
|
10
|
+
up: boolean;
|
|
11
|
+
trend: number[];
|
|
12
|
+
}
|
|
13
|
+
export default function DashboardStats(): import("react").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** The rows the block is wired to. Replace this file with your own fetch — the grid reads plain objects. */
|
|
2
|
+
export interface Invoice {
|
|
3
|
+
id: number;
|
|
4
|
+
reference: string;
|
|
5
|
+
customer: string;
|
|
6
|
+
team: string;
|
|
7
|
+
status: 'paid' | 'pending' | 'overdue';
|
|
8
|
+
amount: number;
|
|
9
|
+
issued: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Two hundred invoices generated from the index, so the block has something to sort, filter, group and
|
|
13
|
+
* total without shipping a data file — and every reload shows the same table.
|
|
14
|
+
*/
|
|
15
|
+
export declare const invoices: Invoice[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function InvoicesGrid(): import("react").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A settings panel: text fields, a searchable select, a radio group, a slider and a switch, each a real
|
|
3
|
+
* form control. `Form` reads its own fields when it submits, so none of this needs state — `values` is
|
|
4
|
+
* built from the elements carrying a `name`.
|
|
5
|
+
*
|
|
6
|
+
* `<Toaster />` has to be mounted once near the root of the app for the confirmation to show.
|
|
7
|
+
*/
|
|
8
|
+
export interface Settings {
|
|
9
|
+
name: string;
|
|
10
|
+
email: string;
|
|
11
|
+
bio: string;
|
|
12
|
+
timezone: string;
|
|
13
|
+
theme: string;
|
|
14
|
+
density: string;
|
|
15
|
+
notify: boolean;
|
|
16
|
+
}
|
|
17
|
+
export default function SettingsForm(): import("react").JSX.Element;
|
package/rsc.cjs
CHANGED
|
@@ -1 +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:
|
|
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,r){let{tag:i=`div`,children:a}=e;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.`);let{classNames:o,styleElements:s}=t.l(e,i===`svg`);return n.default.createElement(n.default.Fragment,null,s,n.default.createElement(i,t.d(e,o),a))}function a(e){return i(e)}var o=a;o.extend=r.BoxExtends.extend,o.components=r.BoxExtends.components,o.keyframes=r.BoxExtends.keyframes,o.spring=r.Springs.spring,o.getVariableValue=e=>(0,r.getDefaultEngine)().getVariableValue(e),o.configure=e=>(0,r.getDefaultEngine)().configure(e),o.viewTransition=r.startViewTransition;function s(e,n){return t.p(t.l(e,n?.svg===!0),e.className)}exports.default=o,exports.useBoxElement=i,exports.useClassNames=s;
|
package/rsc.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { BoxExtends, Springs, StylesConfiguration } from '@box-kite/core';
|
|
2
|
+
import { BoxExtends, Springs, startViewTransition, StylesConfiguration } from '@box-kite/core';
|
|
3
3
|
import { BoxClassNames } from './react/boxClassNames';
|
|
4
4
|
import { BoxClassNameProps, BoxCoreProps } from './react/boxProps';
|
|
5
5
|
import { ComponentsAndVariants } from '@box-kite/core/types';
|
|
6
|
+
/**
|
|
7
|
+
* The client entry's `useBoxElement` with no hook in it, so a component built on it renders on a server too —
|
|
8
|
+
* the export condition picks the half. The `use` prefix stays for the reason `useClassNames` keeps it.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useBoxElement<TTag extends keyof React.JSX.IntrinsicElements = 'div', TKey extends keyof ComponentsAndVariants = never>(props: BoxCoreProps<TTag, TKey>, _ref?: unknown): React.ReactNode;
|
|
6
11
|
interface RscBoxType {
|
|
7
12
|
<TTag extends keyof React.JSX.IntrinsicElements = 'div', TKey extends keyof ComponentsAndVariants = never>(props: BoxCoreProps<TTag, TKey>): React.ReactNode;
|
|
8
13
|
extend: typeof BoxExtends.extend;
|
|
@@ -13,6 +18,11 @@ interface RscBoxType {
|
|
|
13
18
|
getVariableValue: (name: string) => string;
|
|
14
19
|
/** Explicit engine configuration. Element mode is already on; this is for the rest of it. */
|
|
15
20
|
configure: (config: StylesConfiguration) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Run a DOM change inside a view transition. Here for parity with the client entry — with no document
|
|
23
|
+
* there is no transition, so on a server it is the update and nothing else.
|
|
24
|
+
*/
|
|
25
|
+
viewTransition: typeof startViewTransition;
|
|
16
26
|
}
|
|
17
27
|
declare const RscBox: RscBoxType;
|
|
18
28
|
/**
|
package/rsc.mjs
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import { d as e,
|
|
1
|
+
import { d as e, l as t, p as n } from "./react-shared.mjs";
|
|
2
2
|
import r from "react";
|
|
3
|
-
import { BoxExtends as i, Springs as a, getDefaultEngine as o } from "@box-kite/core";
|
|
3
|
+
import { BoxExtends as i, Springs as a, getDefaultEngine as o, startViewTransition as s } from "@box-kite/core";
|
|
4
4
|
//#region src/rsc.ts
|
|
5
5
|
o().configure({ sink: "element" });
|
|
6
|
-
function
|
|
7
|
-
let { tag:
|
|
8
|
-
if (typeof
|
|
9
|
-
let { classNames:
|
|
10
|
-
return r.createElement(r.Fragment, null,
|
|
6
|
+
function c(n, i) {
|
|
7
|
+
let { tag: a = "div", children: o } = n;
|
|
8
|
+
if (typeof o == "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: s, styleElements: c } = t(n, a === "svg");
|
|
10
|
+
return r.createElement(r.Fragment, null, c, r.createElement(a, e(n, s), o));
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
function l(e) {
|
|
13
|
+
return c(e);
|
|
14
|
+
}
|
|
15
|
+
var u = l;
|
|
16
|
+
u.extend = i.extend, u.components = i.components, u.keyframes = i.keyframes, u.spring = a.spring, u.getVariableValue = (e) => o().getVariableValue(e), u.configure = (e) => o().configure(e), u.viewTransition = s;
|
|
17
|
+
function d(e, r) {
|
|
18
|
+
return n(t(e, r?.svg === !0), e.className);
|
|
16
19
|
}
|
|
17
20
|
//#endregion
|
|
18
|
-
export {
|
|
21
|
+
export { u as default, c as useBoxElement, d as useClassNames };
|
package/spec.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./effects.cjs"),t=require("./specSchema.cjs"),n=require("./specData.cjs");let r=require("react"),i=require("react/jsx-runtime");var a;(function(e){let t=[`__proto__`,`constructor`,`prototype`],n=new Map;function r(e){if(!n.has(e))try{n.set(e,new RegExp(e))}catch{n.set(e,null)}return n.get(e)??null}function i(e){return!t.includes(e)}e.isSafeKey=i;function a(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}e.isPlainObject=a;function o(e,t){if(!e.$ref)return e;let n=e.$ref.startsWith(`#/$defs/`)?e.$ref.slice(8):null,r=n?t.$defs?.[n]:void 0;return r?o(r,t):null}function s(e,t,n){return!a(t)||e.required?.some(e=>!(e in t))?!1:Object.keys(t).every(r=>{let a=e.properties?.[r];return a?i(r)&&c(a,t[r],n):e.additionalProperties!==!1&&i(r)})}function c(e,t,n=e){let i=o(e,n);if(!i)return!1;if(i.anyOf)return i.anyOf.some(e=>c(e,t,n));if(i.enum&&!i.enum.includes(t))return!1;switch(i.type){case`string`:return typeof t==`string`?!i.pattern||(r(i.pattern)?.test(t)??!1):!1;case`number`:return typeof t==`number`&&Number.isFinite(t);case`integer`:return typeof t==`number`&&Number.isInteger(t);case`boolean`:return typeof t==`boolean`;case`array`:return Array.isArray(t)&&(!i.items||t.every(e=>c(i.items,e,n)));case`object`:return s(i,t,n);default:return t!==void 0}}e.matches=c})(a||={});var o=a,s;(function(e){function t(e){let t=JSON.stringify(e)??`undefined`;return t.length>40?`${t.slice(0,39)}…`:t}function r(e,t){return typeof e==`string`?{action:e}:!o.isPlainObject(e)||typeof e.action!=`string`?null:{action:e.action,payload:n.t.deep(e.payload,t)}}function i(e,i,a,s){let c=typeof e.type==`string`?e.type:void 0,l=[],u={},d={},f=i.props,p=f?.properties;if(o.isPlainObject(e.props))for(let[r,i]of Object.entries(e.props)){let e=`${s}.props.${r}`;if(!o.isSafeKey(r)){l.push({code:`unknown-prop`,path:e,component:c,prop:r,message:`${r} is not a prop a spec can set.`});continue}let d=p?.[r];if(!d&&(!f||f.additionalProperties===!1)){l.push({code:`unknown-prop`,path:e,component:c,prop:r,message:`${c??`The component`} has no ${r} prop.`});continue}let m=null,h=n.t.deep(i,a,e=>{m??=e});if(m){l.push({code:`unresolved-data`,path:e,component:c,prop:r,message:`${m} resolved to nothing.`});continue}if(d&&!o.matches(d,h,f)){l.push({code:`invalid-prop`,path:e,component:c,prop:r,message:`${t(h)} is not a value ${r} takes.`});continue}u[r]=h}if(o.isPlainObject(e.on))for(let[t,n]of Object.entries(e.on)){let e=`${s}.on.${t}`,o=i.events.includes(t)?r(n,a):null;if(!o){l.push({code:`unknown-event`,path:e,component:c,prop:t,message:`${c??`The component`} has no ${t} event.`});continue}d[t]=o}return{props:u,actions:d,issues:l,missing:(f?.required??[]).filter(e=>!(e in u))}}e.resolve=i})(s||={});var c=s,l=class extends r.Component{state={message:null,resetKey:this.props.resetKey};static getDerivedStateFromProps(e,t){return e.resetKey===t.resetKey?null:{message:null,resetKey:e.resetKey}}static getDerivedStateFromError(e){return{message:e instanceof Error?e.message:String(e)}}componentDidCatch(e){this.props.onError?.(this.issue(e instanceof Error?e.message:String(e)))}issue(e){return{code:`render-error`,path:this.props.path,component:this.props.component,message:e}}render(){return this.state.message===null?this.props.children:this.props.fallback(this.issue(this.state.message))}},u=1e3,d=32;function f(e,t){e.issues.push(t)}function p(e,t,n){f(e,t);let i=e.fallback(t);return n===void 0||i==null?i??null:(0,r.createElement)(r.Fragment,{key:n},i)}function m(e,t,r,i,a){if(e==null||typeof e==`boolean`)return null;if(typeof e==`string`||typeof e==`number`)return e;if(Array.isArray(e))return e.map((e,n)=>m(e,t,r,`${i}.${n}`,a));if(n.t.isRef(e)){let a=n.t.resolve(e,r);return a.found?a.value===null||a.value===void 0||typeof a.value==`boolean`?null:typeof a.value==`string`||typeof a.value==`number`?a.value:(f(t,{code:`invalid-child`,path:i,message:`${n.t.pathOf(e)} is not text.`}),null):(f(t,{code:`unresolved-data`,path:i,message:`${n.t.pathOf(e)} resolved to nothing.`}),null)}return o.isPlainObject(e)?`type`in e?typeof e.type==`string`?e.type===``?null:g(e,t,r,i,a,e.type):(f(t,{code:`invalid-child`,path:i,message:"A node names its component in `type`."}),null):null:(f(t,{code:`invalid-child`,path:i,message:`A child is a node, text, or a reference to text.`}),null)}function h(e,t,r,i,a,o){let s=e.repeat;if(!n.t.isRef(s))return p(t,{code:`invalid-repeat`,path:`${i}.repeat`,component:o,message:`A repeat is a reference to an array.`});let c=n.t.resolve(s,r);if(!c.found)return f(t,{code:`unresolved-data`,path:`${i}.repeat`,component:o,message:`${n.t.pathOf(s)} resolved to nothing.`}),null;if(!Array.isArray(c.value))return p(t,{code:`invalid-repeat`,path:`${i}.repeat`,component:o,message:`${n.t.pathOf(s)} is not an array.`});let l=typeof e.key==`string`?e.key:i;return c.value.map((n,s)=>_(e,t,{data:r.data,item:n,index:s,repeating:!0},i,a,o,`${l}#${s}`))}function g(e,t,n,r,i,a){return i>t.maxDepth?p(t,{code:`too-deep`,path:r,component:a,message:`Nested deeper than the ${t.maxDepth} levels allowed.`}):e.repeat===void 0?_(e,t,n,r,i,a,typeof e.key==`string`?e.key:r):h(e,t,n,r,i,a)}function _(e,t,n,a,s,u,d){if(t.nodes+=1,t.nodes>t.maxNodes)return t.overflowed||(t.overflowed=!0,f(t,{code:`too-many-nodes`,path:a,component:u,message:`More than the ${t.maxNodes} nodes allowed.`})),null;let h=t.registry.get(u);if(!h)return p(t,{code:`unknown-component`,path:a,component:u,message:`${u} is not a component this app allows.`},d);let g=c.resolve(e,h,n,a),_={...g.props};t.issues.push(...g.issues);let v=t.memory?.get(`${a}:${u}`);if(g.missing.length){if(!(v&&g.missing.every(e=>e in v))){let e=g.missing.join(`, `);return p(t,{code:`missing-prop`,path:a,component:u,prop:g.missing[0],message:`${u} cannot render without ${e}.`},d)}for(let e of g.missing)_[e]=v[e]}if(t.memory){let e=h.props?.required??[];e.length&&t.memory.set(`${a}:${u}`,Object.fromEntries(e.map(e=>[e,_[e]])))}for(let[e,n]of Object.entries(g.actions))_[e]=(...r)=>t.onAction?.(n.action,{payload:n.payload,args:r,prop:e,component:u,path:a});if(e.children!==void 0&&(h.slots.includes(`default`)?_.children=m(e.children,t,n,`${a}.children`,s+1):f(t,{code:`unknown-slot`,path:`${a}.children`,component:u,message:`${u} takes no children.`})),o.isPlainObject(e.slots))for(let[r,i]of Object.entries(e.slots)){let e=`${a}.slots.${r}`;if(!o.isSafeKey(r)||!h.slots.includes(r)){f(t,{code:`unknown-slot`,path:e,component:u,message:`${u} has no ${r} slot.`});continue}_[r==="default"?`children`:r]=m(i,t,n,e,s+1)}return(0,i.jsx)(l,{path:a,component:u,resetKey:t.resetKey,fallback:t.fallback,onError:t.onError,children:(0,r.createElement)(h.component,_)},d)}function v(e,t){let n={registry:t.registry,data:t.data,onAction:t.onAction,onError:t.onError,fallback:t.fallback??(()=>null),maxNodes:t.maxNodes??u,maxDepth:t.maxDepth??d,resetKey:t.resetKey,memory:t.memory,issues:[],nodes:0,overflowed:!1};return{element:m(e,n,{data:t.data},`spec`,0),issues:n.issues}}function y(t){let n=(0,r.useRef)(t);return e.n(()=>{n.current=t}),n}function b({spec:e,onIssues:t,...n}){let[i]=(0,r.useState)(()=>new Map),{element:a,issues:o}=v(e,{...n,memory:i,resetKey:e,onError:e=>t?.([e])}),s=y(t),c=y(o),l=o.map(e=>`${e.code} ${e.path} ${e.message}`).join(`
|
|
2
|
+
`);return(0,r.useEffect)(()=>{s.current?.(c.current)},[l,c,s]),a}function x(e){return typeof e==`object`&&!!e&&`component`in e}function S(e,t,n){let r=x(t)?t:{component:t},i=n?.components[e];return{component:r.component,props:r.props??i?.props,slots:r.slots??i?.slots??[`default`],events:r.events??i?.events??[],description:r.description??i?.description}}function C(e){let t=Object.keys(e.components),n=new Map(t.map(t=>[t,S(t,e.components[t],e.catalog)]));return{names:t,components:Object.fromEntries([...n].map(([e,{component:t,...n}])=>[e,n])),get:e=>n.get(e)}}var w=o.matches;exports.SpecRenderer=b,exports.default=b,exports.createSpecRegistry=C,exports.matchesSchema=w,exports.renderSpec=v,exports.specSchema=t.t;
|
package/spec.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { default as SpecValidate } from './utils/spec/specValidate';
|
|
2
|
+
export { default, default as SpecRenderer } from './react/spec/specRenderer';
|
|
3
|
+
export type { SpecRendererProps } from './react/spec/specRenderer';
|
|
4
|
+
export { renderSpec } from './react/spec/renderSpec';
|
|
5
|
+
export type { SpecActionDetails, SpecActionHandler, SpecRenderOptions, SpecRenderResult } from './react/spec/renderSpec';
|
|
6
|
+
export { default as createSpecRegistry } from './react/spec/specRegistry';
|
|
7
|
+
export type { SpecComponent, SpecRegistry, SpecRegistryEntry, SpecRegistryOptions } from './react/spec/specRegistry';
|
|
8
|
+
export { default as specSchema } from './utils/spec/specSchema';
|
|
9
|
+
export type { SpecSchemaComponent, SpecSchemaOptions, SpecSchemaSource } from './utils/spec/specSchema';
|
|
10
|
+
export type { SpecAction, SpecChild, SpecDataRef, SpecIndexRef, SpecIssue, SpecIssueCode, SpecItemRef, SpecNode, SpecRef, SpecRules, } from './utils/spec/specTypes';
|
|
11
|
+
/** Whether a value is one a catalog schema allows: the check the renderer makes, for a host wanting it first. */
|
|
12
|
+
export declare const matchesSchema: typeof SpecValidate.matches;
|