@polyxd/react 0.2.2 → 0.3.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/NOTICE +13 -0
- package/README.md +15 -2
- package/dist/components/avatar.js +5 -36
- package/dist/components/avatar.js.map +1 -1
- package/dist/components/chart.js +4 -87
- package/dist/components/chart.js.map +1 -1
- package/dist/components/content.d.ts +0 -8
- package/dist/components/content.js +27 -349
- package/dist/components/content.js.map +1 -1
- package/dist/components/filter.js +1 -1
- package/dist/components/filter.js.map +1 -1
- package/dist/components/flow.js +11 -85
- package/dist/components/flow.js.map +1 -1
- package/dist/components/index.js +6 -1
- package/dist/components/index.js.map +1 -1
- package/dist/components/inputs.d.ts +2 -12
- package/dist/components/inputs.js +5 -47
- package/dist/components/inputs.js.map +1 -1
- package/dist/components/marks.js +5 -20
- package/dist/components/marks.js.map +1 -1
- package/dist/components/navigation.d.ts +2 -0
- package/dist/components/navigation.js +31 -19
- package/dist/components/navigation.js.map +1 -1
- package/dist/components/pickers.js +12 -160
- package/dist/components/pickers.js.map +1 -1
- package/dist/components/shell.d.ts +41 -0
- package/dist/components/shell.js +190 -0
- package/dist/components/shell.js.map +1 -0
- package/dist/components/split.d.ts +11 -0
- package/dist/components/split.js +85 -0
- package/dist/components/split.js.map +1 -0
- package/dist/components/structure.d.ts +8 -0
- package/dist/components/structure.js +12 -1
- package/dist/components/structure.js.map +1 -1
- package/dist/components/table.js +10 -17
- package/dist/components/table.js.map +1 -1
- package/dist/components/tree.js +6 -57
- package/dist/components/tree.js.map +1 -1
- package/dist/context.d.ts +34 -46
- package/dist/context.js +10 -7
- package/dist/context.js.map +1 -1
- package/dist/data.d.ts +2 -26
- package/dist/data.js +2 -51
- package/dist/data.js.map +1 -1
- package/dist/format.d.ts +2 -14
- package/dist/format.js +2 -69
- package/dist/format.js.map +1 -1
- package/dist/frame.d.ts +19 -0
- package/dist/frame.js +21 -0
- package/dist/frame.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/skeleton.d.ts +2 -1
- package/dist/skeleton.js +9 -25
- package/dist/skeleton.js.map +1 -1
- package/dist/surface.d.ts +7 -3
- package/dist/surface.js +15 -13
- package/dist/surface.js.map +1 -1
- package/package.json +11 -6
- package/preview/polyxd.css +2 -0
- package/preview/polyxd.js +63 -0
- package/src/styles.css +611 -8
- package/themes/brutalist.css +300 -0
- package/themes/civic.css +300 -0
- package/themes/editorial.css +300 -0
- package/themes/finance.css +300 -0
- package/themes/glass.css +300 -0
- package/themes/health.css +300 -0
- package/themes/mono.css +300 -0
- package/themes/neon.css +300 -0
- package/themes/pastel.css +300 -0
- package/themes/sketch.css +356 -0
- package/themes/terminal.css +300 -0
- package/themes/wireframe.css +328 -0
package/dist/context.js
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { createContext, useContext } from "react";
|
|
2
2
|
import { resolve, resolveContext, set, absolute } from "./data.js";
|
|
3
|
-
import { formatValue } from "./format.js";
|
|
3
|
+
import { formatValue, resolveFormat } from "./format.js";
|
|
4
4
|
export const SurfaceContext = createContext(null);
|
|
5
5
|
export const ScopeContext = createContext({ pointer: "" });
|
|
6
6
|
/** Heading level for the next Section (the surface title is h1). */
|
|
7
7
|
export const HeadingContext = createContext(2);
|
|
8
8
|
/** Handles ui.back / ui.next inside Steps. */
|
|
9
9
|
export const StepsContext = createContext(null);
|
|
10
|
+
export const FrameHostContext = createContext(null);
|
|
11
|
+
export const FrameContext = createContext(null);
|
|
12
|
+
const NO_FRAME = { navigation: "side", compact: false };
|
|
13
|
+
/** The layout the enclosing Frame chose; outside one, a wide layout with a side navigation. */
|
|
14
|
+
export function useFrame() {
|
|
15
|
+
const f = useContext(FrameContext);
|
|
16
|
+
return f ? { navigation: f.navigation, compact: f.compact } : NO_FRAME;
|
|
17
|
+
}
|
|
10
18
|
export function useSurface() {
|
|
11
19
|
const ctx = useContext(SurfaceContext);
|
|
12
20
|
if (!ctx)
|
|
@@ -32,11 +40,6 @@ export function useBindings() {
|
|
|
32
40
|
context: (c) => resolveContext(c, s.data, scope),
|
|
33
41
|
};
|
|
34
42
|
}
|
|
35
|
-
|
|
36
|
-
export function resolveFormat(format, data, scope) {
|
|
37
|
-
if (!format?.currency || typeof format.currency === "string")
|
|
38
|
-
return format;
|
|
39
|
-
return { ...format, currency: resolve(format.currency, data, scope) };
|
|
40
|
-
}
|
|
43
|
+
export { resolveFormat };
|
|
41
44
|
export { set };
|
|
42
45
|
//# sourceMappingURL=context.js.map
|
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAkB,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,EAAE,QAAQ,EAAyB,MAAM,WAAW,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAe,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAkB,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,EAAE,QAAQ,EAAyB,MAAM,WAAW,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAE,aAAa,EAAe,MAAM,aAAa,CAAC;AAuBtE,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAA6B,IAAI,CAAC,CAAC;AAC9E,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;AAClE,oEAAoE;AACpE,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AAC/C,8CAA8C;AAC9C,MAAM,CAAC,MAAM,YAAY,GAA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C,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAClI,CAAC;QACD,kEAAkE;QAClE,OAAO,EAAE,CAAC,CAAmB,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC;QACzD,KAAK,EAAE,CAAC,CAAmB,EAAE,KAAc,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC;QAC1F,OAAO,EAAE,CAAC,CAAsC,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC;KACtF,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,aAAa,EAAE,CAAC;AACzB,OAAO,EAAE,GAAG,EAAyC,CAAC"}
|
package/dist/data.d.ts
CHANGED
|
@@ -1,26 +1,2 @@
|
|
|
1
|
-
/** JSON Pointer helpers and binding resolution
|
|
2
|
-
export type Data
|
|
3
|
-
/** Where relative paths resolve: the pointer of the current repeated item, or "" at top level. */
|
|
4
|
-
export interface Scope {
|
|
5
|
-
pointer: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const ROOT_SCOPE: Scope;
|
|
8
|
-
export declare const isBinding: (v: unknown) => v is {
|
|
9
|
-
path: string;
|
|
10
|
-
};
|
|
11
|
-
/** Absolute pointer for a path: absolute paths stay; relative ones join the item scope. */
|
|
12
|
-
export declare function absolute(path: string, scope: Scope): string;
|
|
13
|
-
export declare function childPointer(pointer: string, key: string | number): string;
|
|
14
|
-
export declare function get(data: unknown, pointer: string): unknown;
|
|
15
|
-
/** Immutable set; creates intermediate objects (or arrays for numeric keys). */
|
|
16
|
-
export declare function set(data: Data, pointer: string, value: unknown): Data;
|
|
17
|
-
/**
|
|
18
|
-
* Host data as a list. A binding that a component repeats over should point at an array; when the
|
|
19
|
-
* host (or a generated document) points it somewhere else, the component shows nothing instead of
|
|
20
|
-
* throwing. The validator reports the mismatch.
|
|
21
|
-
*/
|
|
22
|
-
export declare const asList: (value: unknown) => unknown[];
|
|
23
|
-
/** Resolves a literal-or-binding value. */
|
|
24
|
-
export declare function resolve<T = unknown>(value: unknown, data: unknown, scope: Scope): T;
|
|
25
|
-
/** Resolves every value in an action context. */
|
|
26
|
-
export declare function resolveContext(context: Record<string, unknown> | undefined, data: unknown, scope: Scope): Record<string, unknown>;
|
|
1
|
+
/** JSON Pointer helpers and binding resolution live in @polyxd/core; the renderer's modules import them from here. */
|
|
2
|
+
export { type Data, type Scope, ROOT_SCOPE, isBinding, absolute, childPointer, get, set, asList, resolve, resolveContext, resolveDeep } from "@polyxd/core";
|
package/dist/data.js
CHANGED
|
@@ -1,52 +1,3 @@
|
|
|
1
|
-
/** JSON Pointer helpers and binding resolution
|
|
2
|
-
export
|
|
3
|
-
const decode = (s) => s.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
4
|
-
const encode = (s) => s.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
5
|
-
export const isBinding = (v) => !!v && typeof v === "object" && !Array.isArray(v) && typeof v.path === "string";
|
|
6
|
-
/** Absolute pointer for a path: absolute paths stay; relative ones join the item scope. */
|
|
7
|
-
export function absolute(path, scope) {
|
|
8
|
-
return path.startsWith("/") ? path : `${scope.pointer}/${path}`;
|
|
9
|
-
}
|
|
10
|
-
export function childPointer(pointer, key) {
|
|
11
|
-
return `${pointer}/${encode(String(key))}`;
|
|
12
|
-
}
|
|
13
|
-
export function get(data, pointer) {
|
|
14
|
-
if (pointer === "")
|
|
15
|
-
return data;
|
|
16
|
-
let cur = data;
|
|
17
|
-
for (const part of pointer.slice(1).split("/").map(decode)) {
|
|
18
|
-
if (cur === null || typeof cur !== "object")
|
|
19
|
-
return undefined;
|
|
20
|
-
cur = cur[part];
|
|
21
|
-
}
|
|
22
|
-
return cur;
|
|
23
|
-
}
|
|
24
|
-
/** Immutable set; creates intermediate objects (or arrays for numeric keys). */
|
|
25
|
-
export function set(data, pointer, value) {
|
|
26
|
-
const parts = pointer.slice(1).split("/").map(decode);
|
|
27
|
-
const write = (node, i) => {
|
|
28
|
-
const key = parts[i];
|
|
29
|
-
const copy = Array.isArray(node) ? [...node] : { ...(node ?? {}) };
|
|
30
|
-
if (i === parts.length - 1)
|
|
31
|
-
copy[key] = value;
|
|
32
|
-
else
|
|
33
|
-
copy[key] = write(node?.[key] ?? (/^\d+$/.test(parts[i + 1]) ? [] : {}), i + 1);
|
|
34
|
-
return copy;
|
|
35
|
-
};
|
|
36
|
-
return write(data, 0);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Host data as a list. A binding that a component repeats over should point at an array; when the
|
|
40
|
-
* host (or a generated document) points it somewhere else, the component shows nothing instead of
|
|
41
|
-
* throwing. The validator reports the mismatch.
|
|
42
|
-
*/
|
|
43
|
-
export const asList = (value) => (Array.isArray(value) ? value : []);
|
|
44
|
-
/** Resolves a literal-or-binding value. */
|
|
45
|
-
export function resolve(value, data, scope) {
|
|
46
|
-
return (isBinding(value) ? get(data, absolute(value.path, scope)) : value);
|
|
47
|
-
}
|
|
48
|
-
/** Resolves every value in an action context. */
|
|
49
|
-
export function resolveContext(context, data, scope) {
|
|
50
|
-
return Object.fromEntries(Object.entries(context ?? {}).map(([k, v]) => [k, resolve(v, data, scope)]));
|
|
51
|
-
}
|
|
1
|
+
/** JSON Pointer helpers and binding resolution live in @polyxd/core; the renderer's modules import them from here. */
|
|
2
|
+
export { ROOT_SCOPE, isBinding, absolute, childPointer, get, set, asList, resolve, resolveContext, resolveDeep } from "@polyxd/core";
|
|
52
3
|
//# sourceMappingURL=data.js.map
|
package/dist/data.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.js","sourceRoot":"","sources":["../src/data.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"data.js","sourceRoot":"","sources":["../src/data.ts"],"names":[],"mappings":"AAAA,sHAAsH;AACtH,OAAO,EAAyB,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/format.d.ts
CHANGED
|
@@ -1,14 +1,2 @@
|
|
|
1
|
-
/** Localised presentation of values
|
|
2
|
-
export
|
|
3
|
-
type: "text" | "number" | "currency" | "percent" | "date" | "time" | "datetime" | "relativeTime" | "duration" | "color" | "bytes";
|
|
4
|
-
/** ISO 4217 code, or a binding to one (resolved by the renderer before formatting) */
|
|
5
|
-
currency?: string | {
|
|
6
|
-
path: string;
|
|
7
|
-
};
|
|
8
|
-
precision?: number;
|
|
9
|
-
}
|
|
10
|
-
export declare function formatValue(value: unknown, format: Format | undefined, locale: string, now?: number): string;
|
|
11
|
-
/** A CSS colour a swatch can safely take as its background: named, hex, rgb()/hsl()/oklch() etc. Anything else is not painted. */
|
|
12
|
-
export declare function safeColor(value: unknown): string | undefined;
|
|
13
|
-
/** Currency symbol for input adornments, e.g. "£". */
|
|
14
|
-
export declare function currencySymbol(currency: string, locale: string): string;
|
|
1
|
+
/** Localised presentation of values lives in @polyxd/core; the renderer's modules import it from here. */
|
|
2
|
+
export { type Format, formatValue, safeColor, currencySymbol, resolveFormat } from "@polyxd/core";
|
package/dist/format.js
CHANGED
|
@@ -1,70 +1,3 @@
|
|
|
1
|
-
/** Localised presentation of values
|
|
2
|
-
export
|
|
3
|
-
if (value === null || value === undefined || value === "")
|
|
4
|
-
return "—";
|
|
5
|
-
if (!format || format.type === "text")
|
|
6
|
-
return Array.isArray(value) ? value.join(", ") : String(value);
|
|
7
|
-
const n = typeof value === "number" ? value : Number(value);
|
|
8
|
-
const digits = format.precision === undefined ? {} : { minimumFractionDigits: format.precision, maximumFractionDigits: format.precision };
|
|
9
|
-
try {
|
|
10
|
-
switch (format.type) {
|
|
11
|
-
case "number":
|
|
12
|
-
return new Intl.NumberFormat(locale, digits).format(n);
|
|
13
|
-
case "currency":
|
|
14
|
-
return new Intl.NumberFormat(locale, { style: "currency", currency: typeof format.currency === "string" ? format.currency : "USD", ...digits }).format(n);
|
|
15
|
-
case "percent":
|
|
16
|
-
return new Intl.NumberFormat(locale, { style: "percent", maximumFractionDigits: format.precision ?? 1 }).format(n);
|
|
17
|
-
case "date":
|
|
18
|
-
return new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeZone: "UTC" }).format(new Date(String(value)));
|
|
19
|
-
case "time":
|
|
20
|
-
return new Intl.DateTimeFormat(locale, { timeStyle: "short", timeZone: "UTC" }).format(new Date(String(value)));
|
|
21
|
-
case "datetime":
|
|
22
|
-
return new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeStyle: "short", timeZone: "UTC" }).format(new Date(String(value)));
|
|
23
|
-
case "relativeTime": {
|
|
24
|
-
const diff = (new Date(String(value)).getTime() - now) / 1000;
|
|
25
|
-
const units = [["year", 31536000], ["month", 2592000], ["day", 86400], ["hour", 3600], ["minute", 60]];
|
|
26
|
-
const rtf = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
|
|
27
|
-
for (const [unit, secs] of units)
|
|
28
|
-
if (Math.abs(diff) >= secs)
|
|
29
|
-
return rtf.format(Math.round(diff / secs), unit);
|
|
30
|
-
return rtf.format(Math.round(diff), "second");
|
|
31
|
-
}
|
|
32
|
-
case "duration": {
|
|
33
|
-
const mins = Math.round(n / 60);
|
|
34
|
-
return mins >= 60 ? `${Math.floor(mins / 60)} h ${mins % 60} min` : `${mins} min`;
|
|
35
|
-
}
|
|
36
|
-
case "color":
|
|
37
|
-
// The value is the colour itself; renderers show a swatch of it beside this text.
|
|
38
|
-
return String(value).trim();
|
|
39
|
-
case "bytes": {
|
|
40
|
-
// 1.2 MB: decimal units, one decimal past kilobytes.
|
|
41
|
-
const units = ["byte", "kilobyte", "megabyte", "gigabyte", "terabyte"];
|
|
42
|
-
let i = 0;
|
|
43
|
-
let v = Math.abs(n);
|
|
44
|
-
while (v >= 1000 && i < units.length - 1)
|
|
45
|
-
(v /= 1000), i++;
|
|
46
|
-
if (i === 0)
|
|
47
|
-
return `${new Intl.NumberFormat(locale, { maximumFractionDigits: 0 }).format(n)} B`;
|
|
48
|
-
return new Intl.NumberFormat(locale, { style: "unit", unit: units[i], unitDisplay: "short", maximumFractionDigits: format.precision ?? 1 }).format(n < 0 ? -v : v);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
return String(value);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
/** A CSS colour a swatch can safely take as its background: named, hex, rgb()/hsl()/oklch() etc. Anything else is not painted. */
|
|
57
|
-
export function safeColor(value) {
|
|
58
|
-
const v = String(value ?? "").trim();
|
|
59
|
-
return /^(#[0-9a-f]{3,8}|[a-z]{3,20}|(rgb|rgba|hsl|hsla|oklch|oklab|lab|lch|hwb)\([\d.,%\s\/-]+\))$/i.test(v) ? v : undefined;
|
|
60
|
-
}
|
|
61
|
-
/** Currency symbol for input adornments, e.g. "£". */
|
|
62
|
-
export function currencySymbol(currency, locale) {
|
|
63
|
-
try {
|
|
64
|
-
return new Intl.NumberFormat(locale, { style: "currency", currency }).formatToParts(0).find((p) => p.type === "currency")?.value ?? currency;
|
|
65
|
-
}
|
|
66
|
-
catch {
|
|
67
|
-
return currency;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
1
|
+
/** Localised presentation of values lives in @polyxd/core; the renderer's modules import it from here. */
|
|
2
|
+
export { formatValue, safeColor, currencySymbol, resolveFormat } from "@polyxd/core";
|
|
70
3
|
//# sourceMappingURL=format.js.map
|
package/dist/format.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAC1G,OAAO,EAAe,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/frame.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type PolyxdSurfaceProps } from "./surface.tsx";
|
|
3
|
+
export interface PolyxdFrameProps extends Omit<PolyxdSurfaceProps, "onDismiss" | "derive"> {
|
|
4
|
+
/** The current screen: a PolyxdSurface, a React screen, anything. It renders in the shell's Outlet. */
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
/** Which navigation item is current, and the screen's title (shown in the AppBar on compact layouts; the document title follows it). */
|
|
7
|
+
current?: {
|
|
8
|
+
key?: string;
|
|
9
|
+
title?: string;
|
|
10
|
+
};
|
|
11
|
+
/** A screen is on its way: the Outlet shows its skeleton instead of `children`. */
|
|
12
|
+
loading?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Renders a shell document (surface.kind "shell": a Frame with an Outlet) around the host's
|
|
16
|
+
* current screen. Navigation and AppBar actions dispatch through `onAction` like any action;
|
|
17
|
+
* the host routes and re-renders with the new `children` and `current`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function PolyxdFrame({ children, current, loading, ...surface }: PolyxdFrameProps): import("react").JSX.Element;
|
package/dist/frame.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo } from "react";
|
|
3
|
+
import { FrameHostContext } from "./context.js";
|
|
4
|
+
import { PolyxdSurface } from "./surface.js";
|
|
5
|
+
/**
|
|
6
|
+
* Renders a shell document (surface.kind "shell": a Frame with an Outlet) around the host's
|
|
7
|
+
* current screen. Navigation and AppBar actions dispatch through `onAction` like any action;
|
|
8
|
+
* the host routes and re-renders with the new `children` and `current`.
|
|
9
|
+
*/
|
|
10
|
+
export function PolyxdFrame({ children, current, loading, ...surface }) {
|
|
11
|
+
const host = useMemo(() => ({ outlet: children, current, loading }), [children, current?.key, current?.title, loading]);
|
|
12
|
+
// The document title follows the current screen, as the Frame's accessibility requires.
|
|
13
|
+
const product = surface.document.surface.title;
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (typeof document === "undefined" || !current || !product)
|
|
16
|
+
return;
|
|
17
|
+
document.title = current.title ? `${current.title} · ${product}` : product;
|
|
18
|
+
}, [current?.title, product, Boolean(current)]);
|
|
19
|
+
return (_jsx(FrameHostContext.Provider, { value: host, children: _jsx(PolyxdSurface, { ...surface }) }));
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=frame.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame.js","sourceRoot":"","sources":["../src/frame.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAkB,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAkB,MAAM,cAAe,CAAC;AACjE,OAAO,EAAE,aAAa,EAA2B,MAAM,cAAe,CAAC;AAWvE;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,EAAoB;IACtF,MAAM,IAAI,GAAG,OAAO,CAAY,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;IACnI,wFAAwF;IACxF,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC;IAC/C,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,OAAO,QAAQ,KAAK,WAAW,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO;YAAE,OAAO;QACpE,QAAQ,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,MAAM,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;IAC7E,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAChD,OAAO,CACL,KAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,IAAI,YACpC,KAAC,aAAa,OAAK,OAAO,GAAI,GACJ,CAC7B,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { PolyxdSurface, Render, type PolyxdSurfaceProps } from "./surface.tsx";
|
|
2
|
+
export { PolyxdFrame, type PolyxdFrameProps } from "./frame.tsx";
|
|
2
3
|
export { PolyxdSkeleton, type PolyxdSkeletonProps, type SkeletonShape } from "./skeleton.tsx";
|
|
3
|
-
export { useBindings, useSurface, type UIDocument, type ActionEvent, type Node } from "./context.tsx";
|
|
4
|
+
export { useBindings, useSurface, useFrame, type UIDocument, type ActionEvent, type Node, type FrameLayout, type NavigationPlacement } from "./context.tsx";
|
|
4
5
|
export { registry, type ComponentRenderer } from "./components/index.ts";
|
|
5
6
|
export { formatValue, type Format } from "./format.ts";
|
|
6
7
|
export { get as getPointer, set as setPointer, type Data } from "./data.ts";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { PolyxdSurface, Render } from "./surface.js";
|
|
2
|
+
export { PolyxdFrame } from "./frame.js";
|
|
2
3
|
export { PolyxdSkeleton } from "./skeleton.js";
|
|
3
|
-
export { useBindings, useSurface } from "./context.js";
|
|
4
|
+
export { useBindings, useSurface, useFrame } from "./context.js";
|
|
4
5
|
export { registry } from "./components/index.js";
|
|
5
6
|
export { formatValue } from "./format.js";
|
|
6
7
|
export { get as getPointer, set as setPointer } from "./data.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAA2B,MAAM,cAAe,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAgD,MAAM,eAAgB,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAA2B,MAAM,cAAe,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAyB,MAAM,YAAa,CAAC;AACjE,OAAO,EAAE,cAAc,EAAgD,MAAM,eAAgB,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAA4F,MAAM,cAAe,CAAC;AAC5J,OAAO,EAAE,QAAQ,EAA0B,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAE,WAAW,EAAe,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,GAAG,IAAI,UAAU,EAAE,GAAG,IAAI,UAAU,EAAa,MAAM,WAAW,CAAC"}
|
package/dist/skeleton.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { type SkeletonShape } from "@polyxd/core";
|
|
2
|
+
export type { SkeletonShape };
|
|
2
3
|
export interface PolyxdSkeletonProps {
|
|
3
4
|
/** Surface title if the host already knows it: the status reads "Preparing {title}". */
|
|
4
5
|
title?: string;
|
package/dist/skeleton.js
CHANGED
|
@@ -1,30 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
"confirm-destructive": "dialog",
|
|
9
|
-
"review-and-submit": "detail",
|
|
10
|
-
};
|
|
11
|
-
/** One placeholder block. `kind` sets its height and radius; `size` its width as a share of the row. */
|
|
12
|
-
function Block({ kind, size }) {
|
|
13
|
-
return _jsx("span", { className: `pxd-skeleton-block pxd-skeleton-${kind}${size ? ` pxd-skeleton-${size}` : ""}` });
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { SKELETON_GROUP_CLASS, SKELETON_SHAPES, skeletonShape, skeletonStatus } from "@polyxd/core";
|
|
3
|
+
/** One placeholder block, or a group of them, from the silhouette core describes. */
|
|
4
|
+
function Part({ part }) {
|
|
5
|
+
if ("block" in part)
|
|
6
|
+
return _jsx("span", { className: `pxd-skeleton-block pxd-skeleton-${part.block}${part.size ? ` pxd-skeleton-${part.size}` : ""}` });
|
|
7
|
+
return (_jsx("div", { className: SKELETON_GROUP_CLASS[part.group], children: part.parts.map((p, i) => (_jsx(Part, { part: p }, i))) }));
|
|
14
8
|
}
|
|
15
|
-
const Row = ({ children }) => _jsx("div", { className: "pxd-skeleton-row", children: children });
|
|
16
|
-
const times = (n, render) => Array.from({ length: n }, (_, i) => render(i));
|
|
17
|
-
const SHAPES = {
|
|
18
|
-
list: () => (_jsxs(_Fragment, { children: [_jsx(Block, { kind: "field", size: "full" }), times(5, (i) => (_jsxs(Row, { children: [_jsx(Block, { kind: "square" }), _jsxs("div", { className: "pxd-skeleton-lines", children: [_jsx(Block, { kind: "line", size: i % 2 ? "medium" : "long" }), _jsx(Block, { kind: "small", size: "short" })] })] }, i)))] })),
|
|
19
|
-
form: () => (_jsxs(_Fragment, { children: [times(4, (i) => (_jsxs("div", { className: "pxd-skeleton-lines", children: [_jsx(Block, { kind: "small", size: "short" }), _jsx(Block, { kind: "field", size: i === 1 ? "medium" : "long" })] }, i))), _jsxs("div", { className: "pxd-skeleton-actions", children: [_jsx(Block, { kind: "button" }), _jsx(Block, { kind: "button" })] })] })),
|
|
20
|
-
detail: () => (_jsxs(_Fragment, { children: [_jsxs(Row, { children: [_jsx(Block, { kind: "circle" }), _jsxs("div", { className: "pxd-skeleton-lines", children: [_jsxs(Row, { children: [_jsx(Block, { kind: "line", size: "medium" }), _jsx(Block, { kind: "badge" })] }), _jsx(Block, { kind: "small", size: "short" })] })] }), _jsx("div", { className: "pxd-skeleton-dl", children: times(6, (i) => (_jsxs(Row, { children: [_jsx(Block, { kind: "small", size: "short" }), _jsx(Block, { kind: "line", size: i % 3 === 2 ? "medium" : "long" })] }, i))) })] })),
|
|
21
|
-
dashboard: () => (_jsxs(_Fragment, { children: [_jsx("div", { className: "pxd-skeleton-cards", children: times(3, (i) => (_jsxs("div", { className: "pxd-skeleton-card", children: [_jsx(Block, { kind: "small", size: "short" }), _jsx(Block, { kind: "value", size: "medium" })] }, i))) }), _jsx(Block, { kind: "chart", size: "full" })] })),
|
|
22
|
-
dialog: () => (_jsxs(_Fragment, { children: [_jsx(Block, { kind: "line", size: "long" }), _jsx(Block, { kind: "line", size: "medium" }), _jsxs("div", { className: "pxd-skeleton-actions", children: [_jsx(Block, { kind: "button" }), _jsx(Block, { kind: "button" })] })] })),
|
|
23
|
-
compare: () => (_jsx("div", { className: "pxd-skeleton-cards", children: times(3, (c) => (_jsxs("div", { className: "pxd-skeleton-card", children: [_jsx(Block, { kind: "line", size: "medium" }), times(5, (i) => (_jsx(Block, { kind: "small", size: i % 2 ? "short" : "long" }, i)))] }, c))) })),
|
|
24
|
-
};
|
|
25
9
|
/** The loading state for a surface that has not arrived yet: the shape it will take, shimmering. */
|
|
26
10
|
export function PolyxdSkeleton({ title, pattern, shape, theme, mode, density, locale = "en-GB", className }) {
|
|
27
|
-
const chosen =
|
|
28
|
-
return (_jsxs("div", { className: ["pxd-surface", "pxd-skeleton", `pxd-skeleton-${chosen}`, className].filter(Boolean).join(" "), "data-pxd-theme": theme, "data-pxd-mode": mode, "data-pxd-density": density, lang: locale, role: "status", "aria-busy": "true", children: [_jsx("span", { className: "pxd-sr-only", children: title
|
|
11
|
+
const chosen = skeletonShape(pattern, shape);
|
|
12
|
+
return (_jsxs("div", { className: ["pxd-surface", "pxd-skeleton", `pxd-skeleton-${chosen}`, className].filter(Boolean).join(" "), "data-pxd-theme": theme, "data-pxd-mode": mode, "data-pxd-density": density, lang: locale, role: "status", "aria-busy": "true", children: [_jsx("span", { className: "pxd-sr-only", children: skeletonStatus(title) }), _jsxs("div", { className: "pxd-skeleton-body", "aria-hidden": "true", children: [_jsx(Part, { part: { block: "title", size: chosen === "dialog" ? "short" : "medium" } }), SKELETON_SHAPES[chosen].map((p, i) => (_jsx(Part, { part: p }, i)))] })] }));
|
|
29
13
|
}
|
|
30
14
|
//# sourceMappingURL=skeleton.js.map
|
package/dist/skeleton.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skeleton.js","sourceRoot":"","sources":["../src/skeleton.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"skeleton.js","sourceRoot":"","sources":["../src/skeleton.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAyC,MAAM,cAAc,CAAC;AAkB3I,qFAAqF;AACrF,SAAS,IAAI,CAAC,EAAE,IAAI,EAA0B;IAC5C,IAAI,OAAO,IAAI,IAAI;QAAE,OAAO,eAAM,SAAS,EAAE,mCAAmC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,GAAI,CAAC;IACjJ,OAAO,CACL,cAAK,SAAS,EAAE,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC,YAC7C,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CACxB,KAAC,IAAI,IAAS,IAAI,EAAE,CAAC,IAAV,CAAC,CAAa,CAC1B,CAAC,GACE,CACP,CAAC;AACJ,CAAC;AAED,oGAAoG;AACpG,MAAM,UAAU,cAAc,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,EAAE,SAAS,EAAuB;IAC9H,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC7C,OAAO,CACL,eACE,SAAS,EAAE,CAAC,aAAa,EAAE,cAAc,EAAE,gBAAgB,MAAM,EAAE,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,oBACzF,KAAK,mBACN,IAAI,sBACD,OAAO,EACzB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAC,QAAQ,eACH,MAAM,aAEhB,eAAM,SAAS,EAAC,aAAa,YAAE,cAAc,CAAC,KAAK,CAAC,GAAQ,EAC5D,eAAK,SAAS,EAAC,mBAAmB,iBAAa,MAAM,aACnD,KAAC,IAAI,IAAC,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAI,EACjF,eAAe,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CACrC,KAAC,IAAI,IAAS,IAAI,EAAE,CAAC,IAAV,CAAC,CAAa,CAC1B,CAAC,IACE,IACF,CACP,CAAC;AACJ,CAAC"}
|
package/dist/surface.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { type ComponentType } from "react";
|
|
1
2
|
import { StepsContext, type ActionEvent, type Node, type UIDocument } from "./context.tsx";
|
|
2
3
|
import { type Data, type Scope } from "./data.ts";
|
|
3
4
|
import { type ComponentRenderer } from "./components/index.ts";
|
|
4
5
|
export interface PolyxdSurfaceProps {
|
|
5
6
|
document: UIDocument;
|
|
6
|
-
/** Host data. Defaults to document.data. The surface keeps its own copy as inputs change. */
|
|
7
|
+
/** Host data. Defaults to document.data. The surface keeps its own copy as inputs change; a shell adopts each new copy the host passes. */
|
|
7
8
|
data?: Data;
|
|
8
9
|
/** Called for every capability action the user triggers. */
|
|
9
10
|
onAction?: (event: ActionEvent) => void;
|
|
@@ -27,8 +28,11 @@ export interface PolyxdSurfaceProps {
|
|
|
27
28
|
locale?: string;
|
|
28
29
|
/** Turns a host media reference into a URL. Generated UIs never contain URLs. */
|
|
29
30
|
resolveMedia?: (ref: string) => string | undefined;
|
|
30
|
-
/**
|
|
31
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Renderer adapter overrides: replace any component's renderer (e.g. with Astryx or your own).
|
|
33
|
+
* Namespaced keys ("brand.logo") are the host's own components, which a Custom renders by name.
|
|
34
|
+
*/
|
|
35
|
+
components?: Partial<Record<string, ComponentRenderer | ComponentType<any>>>;
|
|
32
36
|
className?: string;
|
|
33
37
|
}
|
|
34
38
|
/** Renders one Polyxd UI document. */
|
package/dist/surface.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useContext, useMemo, useState } from "react";
|
|
2
|
+
import { useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
3
3
|
import { SurfaceContext, ScopeContext, StepsContext, useSurface } from "./context.js";
|
|
4
|
-
import {
|
|
4
|
+
import { dispatchAction } from "@polyxd/core";
|
|
5
|
+
import { ROOT_SCOPE, resolve, set } from "./data.js";
|
|
5
6
|
import { registry } from "./components/index.js";
|
|
6
7
|
import { Avatar } from "./components/avatar.js";
|
|
7
8
|
/** Renders one Polyxd UI document. */
|
|
@@ -17,18 +18,19 @@ export function PolyxdSurface({ document: doc, data: initial, onAction, onDataCh
|
|
|
17
18
|
onDataChange?.(next);
|
|
18
19
|
return next;
|
|
19
20
|
}), [onDataChange, derive]);
|
|
20
|
-
const dispatch = useCallback((action, scope, source) => {
|
|
21
|
-
if (!action)
|
|
22
|
-
return;
|
|
23
|
-
const { name, context } = action.event;
|
|
24
|
-
if (name === "ui.dismiss")
|
|
25
|
-
return onDismiss?.();
|
|
26
|
-
onAction?.({ name, context: resolveContext(context, data, scope), source });
|
|
27
|
-
}, [data, onAction, onDismiss]);
|
|
21
|
+
const dispatch = useCallback((action, scope, source) => dispatchAction(action, scope, source, data, { onAction, onDismiss }), [data, onAction, onDismiss]);
|
|
28
22
|
const value = { doc, byId, data, setValue, dispatch, locale, resolveMedia, portal, root, components, disclosure };
|
|
29
23
|
const rootIsDialog = byId.get(doc.root)?.component === "Confirm";
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
// A shell has no surface header and places its own navigation: the Frame draws the regions.
|
|
25
|
+
const shell = doc.surface.kind === "shell";
|
|
26
|
+
// A shell lives as long as the product does, and its host data moves under it (a badge count,
|
|
27
|
+
// the signed-in person), so each new copy the host passes is adopted rather than remounted.
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (shell && initial)
|
|
30
|
+
setData(initial);
|
|
31
|
+
}, [shell, initial]);
|
|
32
|
+
const nav = shell ? undefined : doc.components.find((c) => c.component === "Navigation" && (!c.kind || c.kind === "main"));
|
|
33
|
+
return (_jsx(SurfaceContext.Provider, { value: value, children: _jsxs("div", { ref: setRoot, className: ["pxd-surface", shell ? "pxd-surface-shell" : null, doc.surface.presentation === "panel" ? "pxd-surface-panel" : null, nav ? "pxd-surface-with-nav" : null, className].filter(Boolean).join(" "), "data-pxd-theme": theme, "data-pxd-mode": mode, "data-pxd-density": density, "data-pxd-surface": doc.surface.id, lang: locale, children: [nav && _jsx(Render, { id: nav.id }), shell ? (_jsx(Render, { id: doc.root })) : (_jsxs("div", { className: "pxd-surface-main", children: [!rootIsDialog && _jsx(SurfaceHeader, {}), _jsx(Render, { id: doc.root })] })), _jsx("div", { ref: setPortal, className: "pxd-portal" })] }) }));
|
|
32
34
|
}
|
|
33
35
|
/** Title, and on a record page: where it sits, what state it's in, and what you can do to it. */
|
|
34
36
|
function SurfaceHeader() {
|
|
@@ -38,7 +40,7 @@ function SurfaceHeader() {
|
|
|
38
40
|
const plain = !subtitle && !breadcrumbs && !badge && !avatar && !actions;
|
|
39
41
|
if (plain)
|
|
40
42
|
return _jsx("h1", { className: "pxd-surface-title", children: title });
|
|
41
|
-
return (_jsxs("header", { className: "pxd-page-header", children: [breadcrumbs && (_jsx("nav", { className: "pxd-breadcrumbs", "aria-label": "Breadcrumb", children: _jsx("ol", { children: breadcrumbs.map((c, i) => (_jsx("li", { children: c.action ? (_jsx("button", { type: "button", className: "pxd-link", onClick: () => s.dispatch(c.action, ROOT_SCOPE, s.doc.surface.id), children: text(c.label) })) : (text(c.label)) }, i))) }) })), _jsxs("div", { className: "pxd-page-header-main", children: [avatar !== undefined && _jsx(Avatar, { value: text(avatar), name: title, size: 48 }), _jsxs("div", { className: "pxd-page-header-text", children: [_jsxs("h1", { className: "pxd-surface-title", children: [title, badge && _jsx("span", { className: `pxd-badge pxd-tone-${badge.tone ?? "neutral"}`, children: text(badge.text) })] }), subtitle && _jsx("p", { className: "pxd-surface-subtitle", children: subtitle })] }), actions && (_jsx("div", { className: "pxd-page-header-actions", children: _jsx(Render, { id: actions }) }))] })] }));
|
|
43
|
+
return (_jsxs("header", { className: "pxd-page-header", children: [breadcrumbs && (_jsx("nav", { className: "pxd-breadcrumbs", "aria-label": "Breadcrumb", children: _jsx("ol", { children: breadcrumbs.map((c, i) => (_jsx("li", { children: c.action ? (_jsx("button", { type: "button", className: "pxd-link", onClick: () => s.dispatch(c.action, ROOT_SCOPE, s.doc.surface.id), children: text(c.label) })) : (text(c.label)) }, i))) }) })), _jsxs("div", { className: "pxd-page-header-main", children: [avatar !== undefined && _jsx(Avatar, { value: text(avatar), name: title, size: 48 }), _jsxs("div", { className: "pxd-page-header-text", children: [_jsxs("h1", { className: "pxd-surface-title", children: [title, badge && _jsx("span", { className: `pxd-badge pxd-tone-${badge.tone ?? "neutral"}`, children: text(badge.text) })] }), subtitle !== undefined && _jsx("p", { className: "pxd-surface-subtitle", children: text(subtitle) })] }), actions && (_jsx("div", { className: "pxd-page-header-actions", children: _jsx(Render, { id: actions }) }))] })] }));
|
|
42
44
|
}
|
|
43
45
|
/** Renders a component by id in the current scope. */
|
|
44
46
|
export function Render({ id, scope }) {
|
package/dist/surface.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surface.js","sourceRoot":"","sources":["../src/surface.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAsB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"surface.js","sourceRoot":"","sources":["../src/surface.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAsB,MAAM,OAAO,CAAC;AAClG,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAA0E,MAAM,cAAe,CAAC;AAC/J,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,EAAyB,MAAM,WAAW,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAA0B,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAyB,CAAC;AAoCjD,sCAAsC;AACtC,MAAM,UAAU,aAAa,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,GAAG,aAAa,EAAE,MAAM,GAAG,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAsB;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AAE,aAAa,EAAE,IAAI,CAAC,EAAE,EAAE,oBAAoB,EAAE,IAAI,CAAC,SAAS,EAA6B,CAAC;IACxG,IAAI,CAAC,CAAC;QAAE,OAAO,GAAG,CAAC;IACnB,MAAM,IAAI,GAAG,CAAC,CAAU,EAAE,EAAE;QAC1B,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACpC,OAAO,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC,CAAC;IACF,OAAO;QACL,GAAG,GAAG;QACN,YAAY,EAAE,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS;QAC/D,kBAAkB,EAAE,CAAC,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;QACjF,WAAW,EAAE,CAAC,CAAC,IAAI;QACnB,aAAa,EAAE,CAAC,CAAC,MAAM,IAAI,SAAS;KACV,CAAC;AAC/B,CAAC;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polyxd/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "React renderer for Polyxd UI documents: Radix primitives styled by design-system tokens",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -12,19 +12,22 @@
|
|
|
12
12
|
"default": "./dist/index.js"
|
|
13
13
|
},
|
|
14
14
|
"./styles.css": "./src/styles.css",
|
|
15
|
-
"./themes/*": "./themes/*"
|
|
15
|
+
"./themes/*": "./themes/*",
|
|
16
|
+
"./preview/*": "./preview/*"
|
|
16
17
|
},
|
|
17
18
|
"files": [
|
|
18
19
|
"dist",
|
|
19
20
|
"src/styles.css",
|
|
20
21
|
"themes",
|
|
22
|
+
"preview",
|
|
21
23
|
"LICENSE",
|
|
22
24
|
"NOTICE"
|
|
23
25
|
],
|
|
24
26
|
"scripts": {
|
|
25
|
-
"build": "tsc -b",
|
|
27
|
+
"build": "tsc -b && node scripts/build-preview.ts",
|
|
26
28
|
"build:themes": "node scripts/build-themes.ts",
|
|
27
|
-
"test": "tsc -b && node --test \"test/**/*.test.ts\""
|
|
29
|
+
"test": "tsc -b && node --test \"test/**/*.test.ts\"",
|
|
30
|
+
"build:preview": "node scripts/build-preview.ts"
|
|
28
31
|
},
|
|
29
32
|
"peerDependencies": {
|
|
30
33
|
"react": ">=19",
|
|
@@ -34,10 +37,12 @@
|
|
|
34
37
|
"@types/react": "^19.3.0",
|
|
35
38
|
"@types/react-dom": "^19.3.0",
|
|
36
39
|
"react": "^19.3.0",
|
|
37
|
-
"react-dom": "^19.3.0"
|
|
40
|
+
"react-dom": "^19.3.0",
|
|
41
|
+
"esbuild": "^0.28.1"
|
|
38
42
|
},
|
|
39
43
|
"dependencies": {
|
|
40
|
-
"@polyxd/
|
|
44
|
+
"@polyxd/core": "^0.3.0",
|
|
45
|
+
"@polyxd/spec": "^0.3.0",
|
|
41
46
|
"radix-ui": "^1.6.7"
|
|
42
47
|
},
|
|
43
48
|
"repository": {
|