@rippling/pebble-sdui-web 0.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/dist/catalogs/custom-apps/action-params.d.ts +33 -0
- package/dist/catalogs/custom-apps/actions.d.ts +9 -0
- package/dist/catalogs/custom-apps/catalog.d.ts +25 -0
- package/dist/catalogs/custom-apps/component-events.d.ts +173 -0
- package/dist/catalogs/custom-apps/component-props.d.ts +3479 -0
- package/dist/catalogs/custom-apps/components.d.ts +174 -0
- package/dist/catalogs/custom-apps/index.cjs +12 -0
- package/dist/catalogs/custom-apps/index.cjs.map +1 -0
- package/dist/catalogs/custom-apps/index.d.ts +13 -0
- package/dist/catalogs/custom-apps/index.js +25236 -0
- package/dist/catalogs/custom-apps/index.js.map +1 -0
- package/dist/catalogs/custom-apps/render.d.ts +20 -0
- package/dist/core/action-utils.cjs +2 -0
- package/dist/core/action-utils.cjs.map +1 -0
- package/dist/core/action-utils.d.ts +48 -0
- package/dist/core/action-utils.js +8 -0
- package/dist/core/action-utils.js.map +1 -0
- package/dist/core/component-utils.cjs +2 -0
- package/dist/core/component-utils.cjs.map +1 -0
- package/dist/core/component-utils.d.ts +77 -0
- package/dist/core/component-utils.js +11 -0
- package/dist/core/component-utils.js.map +1 -0
- package/dist/core/conditions.cjs +2 -0
- package/dist/core/conditions.cjs.map +1 -0
- package/dist/core/conditions.d.ts +70 -0
- package/dist/core/conditions.js +69 -0
- package/dist/core/conditions.js.map +1 -0
- package/dist/core/elements.cjs +2 -0
- package/dist/core/elements.cjs.map +1 -0
- package/dist/core/elements.d.ts +24 -0
- package/dist/core/elements.js +2 -0
- package/dist/core/elements.js.map +1 -0
- package/dist/core/expressions.cjs +2 -0
- package/dist/core/expressions.cjs.map +1 -0
- package/dist/core/expressions.d.ts +81 -0
- package/dist/core/expressions.js +2 -0
- package/dist/core/expressions.js.map +1 -0
- package/dist/core/index.cjs +2 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.ts +14 -0
- package/dist/core/index.js +25 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/paths.cjs +2 -0
- package/dist/core/paths.cjs.map +1 -0
- package/dist/core/paths.d.ts +27 -0
- package/dist/core/paths.js +2 -0
- package/dist/core/paths.js.map +1 -0
- package/dist/core/spec.cjs +2 -0
- package/dist/core/spec.cjs.map +1 -0
- package/dist/core/spec.d.ts +56 -0
- package/dist/core/spec.js +105 -0
- package/dist/core/spec.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ElementNode } from '../../core/elements';
|
|
2
|
+
import { FlatSpec } from '../../core/spec';
|
|
3
|
+
export interface CatalogSpec extends FlatSpec {
|
|
4
|
+
platform: 'web';
|
|
5
|
+
catalog: string;
|
|
6
|
+
catalogVersion: string;
|
|
7
|
+
}
|
|
8
|
+
type CatalogElementNode = ElementNode<'web', 'custom-apps'>;
|
|
9
|
+
/**
|
|
10
|
+
* Render an element tree into a flat json-render spec tagged with
|
|
11
|
+
* the custom-apps catalog name and version.
|
|
12
|
+
*
|
|
13
|
+
* This is the catalog-level render — consumers import this instead
|
|
14
|
+
* of using createSpec().render() directly.
|
|
15
|
+
*/
|
|
16
|
+
export declare function render<TState extends object = Record<string, unknown>>(opts: {
|
|
17
|
+
root: CatalogElementNode;
|
|
18
|
+
state?: TState;
|
|
19
|
+
}): CatalogSpec;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function n(f,c,r){const e={action:f};return c&&(e.params=c),r&&(r.confirm&&(e.confirm=r.confirm),r.onSuccess&&(e.onSuccess=r.onSuccess),r.onError&&(e.onError=r.onError),r.preventDefault&&(e.preventDefault=r.preventDefault)),e}exports.buildAction=n;
|
|
2
|
+
//# sourceMappingURL=action-utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-utils.cjs","sources":["../../../sdui-core/src/action-utils.ts"],"sourcesContent":["/**\n * Action Binding Types\n *\n * Generic types and helpers used by generated action creators.\n * Mirrors Python SDK's actions.py.\n */\n\ndeclare const __actionBrand: unique symbol;\n\n/**\n * Opaque branded type returned by action creators.\n * Cannot be constructed manually — must go through a generated action creator.\n */\nexport interface ActionBinding {\n readonly [__actionBrand]: true;\n}\n\n/** Confirmation dialog before executing an action. */\nexport interface ActionConfirm {\n title: string;\n message: string;\n confirmLabel?: string;\n cancelLabel?: string;\n variant?: 'default' | 'danger';\n}\n\n/** Success handler after action execution. */\nexport type ActionOnSuccess =\n | { navigate: string }\n | { set: Record<string, unknown> }\n | { action: string };\n\n/** Error handler after action execution. */\nexport type ActionOnError =\n | { set: Record<string, unknown> }\n | { action: string };\n\n/** Options shared by all action bindings. */\nexport interface ActionOptions {\n confirm?: ActionConfirm;\n onSuccess?: ActionOnSuccess;\n onError?: ActionOnError;\n preventDefault?: boolean;\n}\n\n/**\n * Creates an action binding object. Used by generated action creators.\n */\nexport function buildAction(\n action: string,\n params?: Record<string, unknown>,\n options?: ActionOptions\n): ActionBinding {\n const binding: Record<string, unknown> = { action };\n if (params) binding.params = params;\n if (options) {\n if (options.confirm) binding.confirm = options.confirm;\n if (options.onSuccess) binding.onSuccess = options.onSuccess;\n if (options.onError) binding.onError = options.onError;\n if (options.preventDefault) binding.preventDefault = options.preventDefault;\n }\n return binding as unknown as ActionBinding;\n}\n"],"names":["buildAction","action","params","options","binding"],"mappings":"gFAgDO,SAASA,EACdC,EACAC,EACAC,EACe,CACf,MAAMC,EAAmC,CAAE,OAAAH,CAAA,EAC3C,OAAIC,MAAgB,OAASA,GACzBC,IACEA,EAAQ,UAASC,EAAQ,QAAUD,EAAQ,SAC3CA,EAAQ,YAAWC,EAAQ,UAAYD,EAAQ,WAC/CA,EAAQ,UAASC,EAAQ,QAAUD,EAAQ,SAC3CA,EAAQ,iBAAgBC,EAAQ,eAAiBD,EAAQ,iBAExDC,CACT"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Action Binding Types
|
|
3
|
+
*
|
|
4
|
+
* Generic types and helpers used by generated action creators.
|
|
5
|
+
* Mirrors Python SDK's actions.py.
|
|
6
|
+
*/
|
|
7
|
+
declare const __actionBrand: unique symbol;
|
|
8
|
+
/**
|
|
9
|
+
* Opaque branded type returned by action creators.
|
|
10
|
+
* Cannot be constructed manually — must go through a generated action creator.
|
|
11
|
+
*/
|
|
12
|
+
export interface ActionBinding {
|
|
13
|
+
readonly [__actionBrand]: true;
|
|
14
|
+
}
|
|
15
|
+
/** Confirmation dialog before executing an action. */
|
|
16
|
+
export interface ActionConfirm {
|
|
17
|
+
title: string;
|
|
18
|
+
message: string;
|
|
19
|
+
confirmLabel?: string;
|
|
20
|
+
cancelLabel?: string;
|
|
21
|
+
variant?: 'default' | 'danger';
|
|
22
|
+
}
|
|
23
|
+
/** Success handler after action execution. */
|
|
24
|
+
export type ActionOnSuccess = {
|
|
25
|
+
navigate: string;
|
|
26
|
+
} | {
|
|
27
|
+
set: Record<string, unknown>;
|
|
28
|
+
} | {
|
|
29
|
+
action: string;
|
|
30
|
+
};
|
|
31
|
+
/** Error handler after action execution. */
|
|
32
|
+
export type ActionOnError = {
|
|
33
|
+
set: Record<string, unknown>;
|
|
34
|
+
} | {
|
|
35
|
+
action: string;
|
|
36
|
+
};
|
|
37
|
+
/** Options shared by all action bindings. */
|
|
38
|
+
export interface ActionOptions {
|
|
39
|
+
confirm?: ActionConfirm;
|
|
40
|
+
onSuccess?: ActionOnSuccess;
|
|
41
|
+
onError?: ActionOnError;
|
|
42
|
+
preventDefault?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Creates an action binding object. Used by generated action creators.
|
|
46
|
+
*/
|
|
47
|
+
export declare function buildAction(action: string, params?: Record<string, unknown>, options?: ActionOptions): ActionBinding;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
function n(c, f, r) {
|
|
2
|
+
const e = { action: c };
|
|
3
|
+
return f && (e.params = f), r && (r.confirm && (e.confirm = r.confirm), r.onSuccess && (e.onSuccess = r.onSuccess), r.onError && (e.onError = r.onError), r.preventDefault && (e.preventDefault = r.preventDefault)), e;
|
|
4
|
+
}
|
|
5
|
+
export {
|
|
6
|
+
n as buildAction
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=action-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-utils.js","sources":["../../../sdui-core/src/action-utils.ts"],"sourcesContent":["/**\n * Action Binding Types\n *\n * Generic types and helpers used by generated action creators.\n * Mirrors Python SDK's actions.py.\n */\n\ndeclare const __actionBrand: unique symbol;\n\n/**\n * Opaque branded type returned by action creators.\n * Cannot be constructed manually — must go through a generated action creator.\n */\nexport interface ActionBinding {\n readonly [__actionBrand]: true;\n}\n\n/** Confirmation dialog before executing an action. */\nexport interface ActionConfirm {\n title: string;\n message: string;\n confirmLabel?: string;\n cancelLabel?: string;\n variant?: 'default' | 'danger';\n}\n\n/** Success handler after action execution. */\nexport type ActionOnSuccess =\n | { navigate: string }\n | { set: Record<string, unknown> }\n | { action: string };\n\n/** Error handler after action execution. */\nexport type ActionOnError =\n | { set: Record<string, unknown> }\n | { action: string };\n\n/** Options shared by all action bindings. */\nexport interface ActionOptions {\n confirm?: ActionConfirm;\n onSuccess?: ActionOnSuccess;\n onError?: ActionOnError;\n preventDefault?: boolean;\n}\n\n/**\n * Creates an action binding object. Used by generated action creators.\n */\nexport function buildAction(\n action: string,\n params?: Record<string, unknown>,\n options?: ActionOptions\n): ActionBinding {\n const binding: Record<string, unknown> = { action };\n if (params) binding.params = params;\n if (options) {\n if (options.confirm) binding.confirm = options.confirm;\n if (options.onSuccess) binding.onSuccess = options.onSuccess;\n if (options.onError) binding.onError = options.onError;\n if (options.preventDefault) binding.preventDefault = options.preventDefault;\n }\n return binding as unknown as ActionBinding;\n}\n"],"names":["buildAction","action","params","options","binding"],"mappings":"AAgDO,SAASA,EACdC,GACAC,GACAC,GACe;AACf,QAAMC,IAAmC,EAAE,QAAAH,EAAA;AAC3C,SAAIC,QAAgB,SAASA,IACzBC,MACEA,EAAQ,YAASC,EAAQ,UAAUD,EAAQ,UAC3CA,EAAQ,cAAWC,EAAQ,YAAYD,EAAQ,YAC/CA,EAAQ,YAASC,EAAQ,UAAUD,EAAQ,UAC3CA,EAAQ,mBAAgBC,EAAQ,iBAAiBD,EAAQ,kBAExDC;AACT;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function i(d,e){const o={type:d,props:e.props??{}};return e.id!==void 0&&(o.id=e.id),e.visible!==void 0&&(o.visible=e.visible),e.on&&(o.on=e.on),e.children&&(o.children=e.children),e.repeat&&(o.repeat=e.repeat),o}exports.buildNode=i;
|
|
2
|
+
//# sourceMappingURL=component-utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-utils.cjs","sources":["../../../sdui-core/src/component-utils.ts"],"sourcesContent":["/**\n * Component Utilities\n *\n * Generic types and helpers used by generated component builders.\n * Mirrors Python SDK's elements.py Element base class.\n */\n\nimport type { WrapWithPropValue } from './expressions';\nimport type { ActionBinding } from './action-utils';\nimport type { VisibilityBinding } from './conditions';\nimport type { ElementNode, RepeatBinding } from './elements';\n\n/**\n * The actual runtime shape behind the branded ElementNode.\n * Only used internally by buildNode() and render().\n */\nexport interface InternalElementNode {\n id?: string;\n type: string;\n props: Record<string, unknown>;\n children?: ElementNode[];\n visible?: unknown;\n on?: Record<string, unknown>;\n watch?: Record<string, unknown>;\n repeat?: { statePath: string; key?: string };\n}\n\n/**\n * Standard input shape for a component builder.\n *\n * - `Props`: plain prop types — automatically wrapped with PropValue\n * - `Events`: string union of supported event names (use `never` for none)\n * - `HasChildren`: whether this component accepts children\n *\n * The conditional types ensure `on` is only available when events exist,\n * and `children` is only available when HasChildren is true.\n */\nexport type ComponentInputs<\n Props,\n Events extends string = never,\n HasChildren extends boolean = false,\n> = {\n id?: string;\n props: WrapWithPropValue<Props>;\n visible?: VisibilityBinding | boolean;\n repeat?: RepeatBinding;\n} & ([Events] extends [never]\n ? { on?: never }\n : { on?: { [K in Events]?: ActionBinding } }) &\n (HasChildren extends true\n ? { children?: ElementNode[] }\n : { children?: never });\n\n/**\n * Variant where props is optional (for components with all-optional props).\n */\nexport type ComponentInputsOptionalProps<\n Props,\n Events extends string = never,\n HasChildren extends boolean = false,\n> = {\n id?: string;\n props?: WrapWithPropValue<Props>;\n visible?: VisibilityBinding | boolean;\n repeat?: RepeatBinding;\n} & ([Events] extends [never]\n ? { on?: never }\n : { on?: { [K in Events]?: ActionBinding } }) &\n (HasChildren extends true\n ? { children?: ElementNode[] }\n : { children?: never });\n\n/**\n * Creates an ElementNode from builder input. Used by generated component builders.\n */\nexport function buildNode<\n TPlatform extends string = string,\n TCatalog extends string = string,\n>(\n type: string,\n input: {\n id?: string;\n props?: unknown;\n visible?: unknown;\n on?: unknown;\n children?: unknown;\n repeat?: unknown;\n }\n): ElementNode<TPlatform, TCatalog> {\n const node: InternalElementNode = {\n type,\n props: (input.props ?? {}) as Record<string, unknown>,\n };\n if (input.id !== undefined) node.id = input.id;\n if (input.visible !== undefined) node.visible = input.visible;\n if (input.on) node.on = input.on as Record<string, unknown>;\n if (input.children) node.children = input.children as ElementNode[];\n if (input.repeat)\n node.repeat = input.repeat as unknown as {\n statePath: string;\n key?: string;\n };\n return node as unknown as ElementNode<TPlatform, TCatalog>;\n}\n"],"names":["buildNode","type","input","node"],"mappings":"gFA2EO,SAASA,EAIdC,EACAC,EAQkC,CAClC,MAAMC,EAA4B,CAChC,KAAAF,EACA,MAAQC,EAAM,OAAS,CAAA,CAAC,EAE1B,OAAIA,EAAM,KAAO,SAAWC,EAAK,GAAKD,EAAM,IACxCA,EAAM,UAAY,SAAWC,EAAK,QAAUD,EAAM,SAClDA,EAAM,KAAIC,EAAK,GAAKD,EAAM,IAC1BA,EAAM,WAAUC,EAAK,SAAWD,EAAM,UACtCA,EAAM,SACRC,EAAK,OAASD,EAAM,QAIfC,CACT"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { WrapWithPropValue } from './expressions';
|
|
2
|
+
import { ActionBinding } from './action-utils';
|
|
3
|
+
import { VisibilityBinding } from './conditions';
|
|
4
|
+
import { ElementNode, RepeatBinding } from './elements';
|
|
5
|
+
/**
|
|
6
|
+
* The actual runtime shape behind the branded ElementNode.
|
|
7
|
+
* Only used internally by buildNode() and render().
|
|
8
|
+
*/
|
|
9
|
+
export interface InternalElementNode {
|
|
10
|
+
id?: string;
|
|
11
|
+
type: string;
|
|
12
|
+
props: Record<string, unknown>;
|
|
13
|
+
children?: ElementNode[];
|
|
14
|
+
visible?: unknown;
|
|
15
|
+
on?: Record<string, unknown>;
|
|
16
|
+
watch?: Record<string, unknown>;
|
|
17
|
+
repeat?: {
|
|
18
|
+
statePath: string;
|
|
19
|
+
key?: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Standard input shape for a component builder.
|
|
24
|
+
*
|
|
25
|
+
* - `Props`: plain prop types — automatically wrapped with PropValue
|
|
26
|
+
* - `Events`: string union of supported event names (use `never` for none)
|
|
27
|
+
* - `HasChildren`: whether this component accepts children
|
|
28
|
+
*
|
|
29
|
+
* The conditional types ensure `on` is only available when events exist,
|
|
30
|
+
* and `children` is only available when HasChildren is true.
|
|
31
|
+
*/
|
|
32
|
+
export type ComponentInputs<Props, Events extends string = never, HasChildren extends boolean = false> = {
|
|
33
|
+
id?: string;
|
|
34
|
+
props: WrapWithPropValue<Props>;
|
|
35
|
+
visible?: VisibilityBinding | boolean;
|
|
36
|
+
repeat?: RepeatBinding;
|
|
37
|
+
} & ([Events] extends [never] ? {
|
|
38
|
+
on?: never;
|
|
39
|
+
} : {
|
|
40
|
+
on?: {
|
|
41
|
+
[K in Events]?: ActionBinding;
|
|
42
|
+
};
|
|
43
|
+
}) & (HasChildren extends true ? {
|
|
44
|
+
children?: ElementNode[];
|
|
45
|
+
} : {
|
|
46
|
+
children?: never;
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* Variant where props is optional (for components with all-optional props).
|
|
50
|
+
*/
|
|
51
|
+
export type ComponentInputsOptionalProps<Props, Events extends string = never, HasChildren extends boolean = false> = {
|
|
52
|
+
id?: string;
|
|
53
|
+
props?: WrapWithPropValue<Props>;
|
|
54
|
+
visible?: VisibilityBinding | boolean;
|
|
55
|
+
repeat?: RepeatBinding;
|
|
56
|
+
} & ([Events] extends [never] ? {
|
|
57
|
+
on?: never;
|
|
58
|
+
} : {
|
|
59
|
+
on?: {
|
|
60
|
+
[K in Events]?: ActionBinding;
|
|
61
|
+
};
|
|
62
|
+
}) & (HasChildren extends true ? {
|
|
63
|
+
children?: ElementNode[];
|
|
64
|
+
} : {
|
|
65
|
+
children?: never;
|
|
66
|
+
});
|
|
67
|
+
/**
|
|
68
|
+
* Creates an ElementNode from builder input. Used by generated component builders.
|
|
69
|
+
*/
|
|
70
|
+
export declare function buildNode<TPlatform extends string = string, TCatalog extends string = string>(type: string, input: {
|
|
71
|
+
id?: string;
|
|
72
|
+
props?: unknown;
|
|
73
|
+
visible?: unknown;
|
|
74
|
+
on?: unknown;
|
|
75
|
+
children?: unknown;
|
|
76
|
+
repeat?: unknown;
|
|
77
|
+
}): ElementNode<TPlatform, TCatalog>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function i(d, e) {
|
|
2
|
+
const o = {
|
|
3
|
+
type: d,
|
|
4
|
+
props: e.props ?? {}
|
|
5
|
+
};
|
|
6
|
+
return e.id !== void 0 && (o.id = e.id), e.visible !== void 0 && (o.visible = e.visible), e.on && (o.on = e.on), e.children && (o.children = e.children), e.repeat && (o.repeat = e.repeat), o;
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
i as buildNode
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=component-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-utils.js","sources":["../../../sdui-core/src/component-utils.ts"],"sourcesContent":["/**\n * Component Utilities\n *\n * Generic types and helpers used by generated component builders.\n * Mirrors Python SDK's elements.py Element base class.\n */\n\nimport type { WrapWithPropValue } from './expressions';\nimport type { ActionBinding } from './action-utils';\nimport type { VisibilityBinding } from './conditions';\nimport type { ElementNode, RepeatBinding } from './elements';\n\n/**\n * The actual runtime shape behind the branded ElementNode.\n * Only used internally by buildNode() and render().\n */\nexport interface InternalElementNode {\n id?: string;\n type: string;\n props: Record<string, unknown>;\n children?: ElementNode[];\n visible?: unknown;\n on?: Record<string, unknown>;\n watch?: Record<string, unknown>;\n repeat?: { statePath: string; key?: string };\n}\n\n/**\n * Standard input shape for a component builder.\n *\n * - `Props`: plain prop types — automatically wrapped with PropValue\n * - `Events`: string union of supported event names (use `never` for none)\n * - `HasChildren`: whether this component accepts children\n *\n * The conditional types ensure `on` is only available when events exist,\n * and `children` is only available when HasChildren is true.\n */\nexport type ComponentInputs<\n Props,\n Events extends string = never,\n HasChildren extends boolean = false,\n> = {\n id?: string;\n props: WrapWithPropValue<Props>;\n visible?: VisibilityBinding | boolean;\n repeat?: RepeatBinding;\n} & ([Events] extends [never]\n ? { on?: never }\n : { on?: { [K in Events]?: ActionBinding } }) &\n (HasChildren extends true\n ? { children?: ElementNode[] }\n : { children?: never });\n\n/**\n * Variant where props is optional (for components with all-optional props).\n */\nexport type ComponentInputsOptionalProps<\n Props,\n Events extends string = never,\n HasChildren extends boolean = false,\n> = {\n id?: string;\n props?: WrapWithPropValue<Props>;\n visible?: VisibilityBinding | boolean;\n repeat?: RepeatBinding;\n} & ([Events] extends [never]\n ? { on?: never }\n : { on?: { [K in Events]?: ActionBinding } }) &\n (HasChildren extends true\n ? { children?: ElementNode[] }\n : { children?: never });\n\n/**\n * Creates an ElementNode from builder input. Used by generated component builders.\n */\nexport function buildNode<\n TPlatform extends string = string,\n TCatalog extends string = string,\n>(\n type: string,\n input: {\n id?: string;\n props?: unknown;\n visible?: unknown;\n on?: unknown;\n children?: unknown;\n repeat?: unknown;\n }\n): ElementNode<TPlatform, TCatalog> {\n const node: InternalElementNode = {\n type,\n props: (input.props ?? {}) as Record<string, unknown>,\n };\n if (input.id !== undefined) node.id = input.id;\n if (input.visible !== undefined) node.visible = input.visible;\n if (input.on) node.on = input.on as Record<string, unknown>;\n if (input.children) node.children = input.children as ElementNode[];\n if (input.repeat)\n node.repeat = input.repeat as unknown as {\n statePath: string;\n key?: string;\n };\n return node as unknown as ElementNode<TPlatform, TCatalog>;\n}\n"],"names":["buildNode","type","input","node"],"mappings":"AA2EO,SAASA,EAIdC,GACAC,GAQkC;AAClC,QAAMC,IAA4B;AAAA,IAChC,MAAAF;AAAA,IACA,OAAQC,EAAM,SAAS,CAAA;AAAA,EAAC;AAE1B,SAAIA,EAAM,OAAO,WAAWC,EAAK,KAAKD,EAAM,KACxCA,EAAM,YAAY,WAAWC,EAAK,UAAUD,EAAM,UAClDA,EAAM,OAAIC,EAAK,KAAKD,EAAM,KAC1BA,EAAM,aAAUC,EAAK,WAAWD,EAAM,WACtCA,EAAM,WACRC,EAAK,SAASD,EAAM,SAIfC;AACT;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=Symbol("visibilityBrand");function r(t,n){return{...t,...n,[e]:!0}}function i(t,n){return r(t,{eq:n})}function a(t,n){return r(t,{neq:n})}function c(t,n){return r(t,{gt:n})}function l(t,n){return r(t,{gte:n})}function f(t,n){return r(t,{lt:n})}function s(t,n){return r(t,{lte:n})}function y(t){return r(t)}function d(t){return r(t,{not:!0})}function g(t){return{...t,not:!0,[e]:!0}}function u(...t){return{$and:t,[e]:!0}}function o(...t){return{$or:t,[e]:!0}}exports.$and=u;exports.$or=o;exports.$when=r;exports.__visibilityBrand=e;exports.and_=u;exports.equals=i;exports.falsy=d;exports.gt=c;exports.gte=l;exports.lt=f;exports.lte=s;exports.neq=a;exports.not_=g;exports.or_=o;exports.truthy=y;
|
|
2
|
+
//# sourceMappingURL=conditions.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditions.cjs","sources":["../../../sdui-core/src/conditions.ts"],"sourcesContent":["/**\n * Visibility Condition Types\n *\n * Matches the Python SDK's condition system (equals, neq, gt, gte, lt, lte,\n * truthy, falsy, not_, or_, and_) while using the prototype's opaque branded\n * approach for type safety.\n */\n\nimport type { StateRef, ItemRef, IndexRef } from './expressions';\n\n/** Brand symbol for VisibilityBinding. */\nexport const __visibilityBrand: unique symbol = Symbol('visibilityBrand');\n\n/** A number value — literal or a StateRef resolving to number. */\ntype NumberValue = number | StateRef<number>;\n\n/** Comparison operators shared by all condition sources. */\nexport interface ComparisonOps {\n eq?: unknown;\n neq?: unknown;\n gt?: NumberValue;\n gte?: NumberValue;\n lt?: NumberValue;\n lte?: NumberValue;\n not?: true;\n}\n\n/**\n * Opaque branded type for visibility conditions.\n *\n * External code cannot construct these manually because they cannot assign\n * to the unique symbol property — must use condition builder functions.\n */\nexport type VisibilityBinding = { readonly [__visibilityBrand]: true } & (\n | ({ readonly $state: string } & ComparisonOps)\n | ({ readonly $item: string } & ComparisonOps)\n | ({ readonly $index: true } & ComparisonOps)\n | { readonly $and: (VisibilityBinding | boolean)[] }\n | { readonly $or: (VisibilityBinding | boolean)[] }\n);\n\n/** Source ref types accepted by condition builders. */\ntype ConditionSource = StateRef<unknown> | ItemRef<unknown> | IndexRef;\n\n/**\n * Create a visibility condition from a typed ref.\n *\n * This is the prototype's $when() — kept for backwards compatibility.\n * Matches the Python SDK's condition builder API pattern.\n *\n * Usage:\n * $when($state('/isAdmin'))\n * $when($state('/count'), { gt: 0 })\n */\nexport function $when(\n ref: ConditionSource,\n ops?: ComparisonOps\n): VisibilityBinding {\n const raw = ref as unknown as Record<string, unknown>;\n return {\n ...raw,\n ...ops,\n [__visibilityBrand]: true as const,\n } as VisibilityBinding;\n}\n\n// ---------------------------------------------------------------------------\n// Builder functions matching the Python SDK's API\n// ---------------------------------------------------------------------------\n\n/** Equality condition: visible when ref value == rhs. */\nexport function equals(\n ref: ConditionSource,\n value: unknown\n): VisibilityBinding {\n return $when(ref, { eq: value });\n}\n\n/** Not-equal condition: visible when ref value != rhs. */\nexport function neq(ref: ConditionSource, value: unknown): VisibilityBinding {\n return $when(ref, { neq: value });\n}\n\n/** Greater-than condition: visible when ref value > rhs. */\nexport function gt(\n ref: ConditionSource,\n value: NumberValue\n): VisibilityBinding {\n return $when(ref, { gt: value });\n}\n\n/** Greater-than-or-equal condition: visible when ref value >= rhs. */\nexport function gte(\n ref: ConditionSource,\n value: NumberValue\n): VisibilityBinding {\n return $when(ref, { gte: value });\n}\n\n/** Less-than condition: visible when ref value < rhs. */\nexport function lt(\n ref: ConditionSource,\n value: NumberValue\n): VisibilityBinding {\n return $when(ref, { lt: value });\n}\n\n/** Less-than-or-equal condition: visible when ref value <= rhs. */\nexport function lte(\n ref: ConditionSource,\n value: NumberValue\n): VisibilityBinding {\n return $when(ref, { lte: value });\n}\n\n/** Truthy condition: visible when ref value is truthy. */\nexport function truthy(ref: ConditionSource): VisibilityBinding {\n return $when(ref);\n}\n\n/** Falsy condition: visible when ref value is falsy. */\nexport function falsy(ref: ConditionSource): VisibilityBinding {\n return $when(ref, { not: true });\n}\n\n/** Negate a condition. */\nexport function not_(condition: VisibilityBinding): VisibilityBinding {\n const raw = condition as unknown as Record<string, unknown>;\n return {\n ...raw,\n not: true,\n [__visibilityBrand]: true as const,\n } as VisibilityBinding;\n}\n\n/** Logical AND — all conditions must be true. */\nexport function $and(\n ...conditions: (VisibilityBinding | boolean)[]\n): VisibilityBinding {\n return {\n $and: conditions,\n [__visibilityBrand]: true as const,\n } as unknown as VisibilityBinding;\n}\n\n/** Logical OR — at least one condition must be true. */\nexport function $or(\n ...conditions: (VisibilityBinding | boolean)[]\n): VisibilityBinding {\n return {\n $or: conditions,\n [__visibilityBrand]: true as const,\n } as unknown as VisibilityBinding;\n}\n\n// Aliases matching Python SDK naming\nexport { $and as and_, $or as or_ };\n"],"names":["__visibilityBrand","$when","ref","ops","equals","value","neq","gt","gte","lt","lte","truthy","falsy","not_","condition","$and","conditions","$or"],"mappings":"gFAWO,MAAMA,EAAmC,OAAO,iBAAiB,EA2CjE,SAASC,EACdC,EACAC,EACmB,CAEnB,MAAO,CACL,GAFUD,EAGV,GAAGC,EACH,CAACH,CAAiB,EAAG,EAAA,CAEzB,CAOO,SAASI,EACdF,EACAG,EACmB,CACnB,OAAOJ,EAAMC,EAAK,CAAE,GAAIG,EAAO,CACjC,CAGO,SAASC,EAAIJ,EAAsBG,EAAmC,CAC3E,OAAOJ,EAAMC,EAAK,CAAE,IAAKG,EAAO,CAClC,CAGO,SAASE,EACdL,EACAG,EACmB,CACnB,OAAOJ,EAAMC,EAAK,CAAE,GAAIG,EAAO,CACjC,CAGO,SAASG,EACdN,EACAG,EACmB,CACnB,OAAOJ,EAAMC,EAAK,CAAE,IAAKG,EAAO,CAClC,CAGO,SAASI,EACdP,EACAG,EACmB,CACnB,OAAOJ,EAAMC,EAAK,CAAE,GAAIG,EAAO,CACjC,CAGO,SAASK,EACdR,EACAG,EACmB,CACnB,OAAOJ,EAAMC,EAAK,CAAE,IAAKG,EAAO,CAClC,CAGO,SAASM,EAAOT,EAAyC,CAC9D,OAAOD,EAAMC,CAAG,CAClB,CAGO,SAASU,EAAMV,EAAyC,CAC7D,OAAOD,EAAMC,EAAK,CAAE,IAAK,GAAM,CACjC,CAGO,SAASW,EAAKC,EAAiD,CAEpE,MAAO,CACL,GAFUA,EAGV,IAAK,GACL,CAACd,CAAiB,EAAG,EAAA,CAEzB,CAGO,SAASe,KACXC,EACgB,CACnB,MAAO,CACL,KAAMA,EACN,CAAChB,CAAiB,EAAG,EAAA,CAEzB,CAGO,SAASiB,KACXD,EACgB,CACnB,MAAO,CACL,IAAKA,EACL,CAAChB,CAAiB,EAAG,EAAA,CAEzB"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { StateRef, ItemRef, IndexRef } from './expressions';
|
|
2
|
+
/** Brand symbol for VisibilityBinding. */
|
|
3
|
+
export declare const __visibilityBrand: unique symbol;
|
|
4
|
+
/** A number value — literal or a StateRef resolving to number. */
|
|
5
|
+
type NumberValue = number | StateRef<number>;
|
|
6
|
+
/** Comparison operators shared by all condition sources. */
|
|
7
|
+
export interface ComparisonOps {
|
|
8
|
+
eq?: unknown;
|
|
9
|
+
neq?: unknown;
|
|
10
|
+
gt?: NumberValue;
|
|
11
|
+
gte?: NumberValue;
|
|
12
|
+
lt?: NumberValue;
|
|
13
|
+
lte?: NumberValue;
|
|
14
|
+
not?: true;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Opaque branded type for visibility conditions.
|
|
18
|
+
*
|
|
19
|
+
* External code cannot construct these manually because they cannot assign
|
|
20
|
+
* to the unique symbol property — must use condition builder functions.
|
|
21
|
+
*/
|
|
22
|
+
export type VisibilityBinding = {
|
|
23
|
+
readonly [__visibilityBrand]: true;
|
|
24
|
+
} & (({
|
|
25
|
+
readonly $state: string;
|
|
26
|
+
} & ComparisonOps) | ({
|
|
27
|
+
readonly $item: string;
|
|
28
|
+
} & ComparisonOps) | ({
|
|
29
|
+
readonly $index: true;
|
|
30
|
+
} & ComparisonOps) | {
|
|
31
|
+
readonly $and: (VisibilityBinding | boolean)[];
|
|
32
|
+
} | {
|
|
33
|
+
readonly $or: (VisibilityBinding | boolean)[];
|
|
34
|
+
});
|
|
35
|
+
/** Source ref types accepted by condition builders. */
|
|
36
|
+
type ConditionSource = StateRef<unknown> | ItemRef<unknown> | IndexRef;
|
|
37
|
+
/**
|
|
38
|
+
* Create a visibility condition from a typed ref.
|
|
39
|
+
*
|
|
40
|
+
* This is the prototype's $when() — kept for backwards compatibility.
|
|
41
|
+
* Matches the Python SDK's condition builder API pattern.
|
|
42
|
+
*
|
|
43
|
+
* Usage:
|
|
44
|
+
* $when($state('/isAdmin'))
|
|
45
|
+
* $when($state('/count'), { gt: 0 })
|
|
46
|
+
*/
|
|
47
|
+
export declare function $when(ref: ConditionSource, ops?: ComparisonOps): VisibilityBinding;
|
|
48
|
+
/** Equality condition: visible when ref value == rhs. */
|
|
49
|
+
export declare function equals(ref: ConditionSource, value: unknown): VisibilityBinding;
|
|
50
|
+
/** Not-equal condition: visible when ref value != rhs. */
|
|
51
|
+
export declare function neq(ref: ConditionSource, value: unknown): VisibilityBinding;
|
|
52
|
+
/** Greater-than condition: visible when ref value > rhs. */
|
|
53
|
+
export declare function gt(ref: ConditionSource, value: NumberValue): VisibilityBinding;
|
|
54
|
+
/** Greater-than-or-equal condition: visible when ref value >= rhs. */
|
|
55
|
+
export declare function gte(ref: ConditionSource, value: NumberValue): VisibilityBinding;
|
|
56
|
+
/** Less-than condition: visible when ref value < rhs. */
|
|
57
|
+
export declare function lt(ref: ConditionSource, value: NumberValue): VisibilityBinding;
|
|
58
|
+
/** Less-than-or-equal condition: visible when ref value <= rhs. */
|
|
59
|
+
export declare function lte(ref: ConditionSource, value: NumberValue): VisibilityBinding;
|
|
60
|
+
/** Truthy condition: visible when ref value is truthy. */
|
|
61
|
+
export declare function truthy(ref: ConditionSource): VisibilityBinding;
|
|
62
|
+
/** Falsy condition: visible when ref value is falsy. */
|
|
63
|
+
export declare function falsy(ref: ConditionSource): VisibilityBinding;
|
|
64
|
+
/** Negate a condition. */
|
|
65
|
+
export declare function not_(condition: VisibilityBinding): VisibilityBinding;
|
|
66
|
+
/** Logical AND — all conditions must be true. */
|
|
67
|
+
export declare function $and(...conditions: (VisibilityBinding | boolean)[]): VisibilityBinding;
|
|
68
|
+
/** Logical OR — at least one condition must be true. */
|
|
69
|
+
export declare function $or(...conditions: (VisibilityBinding | boolean)[]): VisibilityBinding;
|
|
70
|
+
export { $and as and_, $or as or_ };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const u = Symbol("visibilityBrand");
|
|
2
|
+
function r(n, t) {
|
|
3
|
+
return {
|
|
4
|
+
...n,
|
|
5
|
+
...t,
|
|
6
|
+
[u]: !0
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function o(n, t) {
|
|
10
|
+
return r(n, { eq: t });
|
|
11
|
+
}
|
|
12
|
+
function i(n, t) {
|
|
13
|
+
return r(n, { neq: t });
|
|
14
|
+
}
|
|
15
|
+
function c(n, t) {
|
|
16
|
+
return r(n, { gt: t });
|
|
17
|
+
}
|
|
18
|
+
function a(n, t) {
|
|
19
|
+
return r(n, { gte: t });
|
|
20
|
+
}
|
|
21
|
+
function f(n, t) {
|
|
22
|
+
return r(n, { lt: t });
|
|
23
|
+
}
|
|
24
|
+
function l(n, t) {
|
|
25
|
+
return r(n, { lte: t });
|
|
26
|
+
}
|
|
27
|
+
function s(n) {
|
|
28
|
+
return r(n);
|
|
29
|
+
}
|
|
30
|
+
function d(n) {
|
|
31
|
+
return r(n, { not: !0 });
|
|
32
|
+
}
|
|
33
|
+
function w(n) {
|
|
34
|
+
return {
|
|
35
|
+
...n,
|
|
36
|
+
not: !0,
|
|
37
|
+
[u]: !0
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function y(...n) {
|
|
41
|
+
return {
|
|
42
|
+
$and: n,
|
|
43
|
+
[u]: !0
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function _(...n) {
|
|
47
|
+
return {
|
|
48
|
+
$or: n,
|
|
49
|
+
[u]: !0
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
y as $and,
|
|
54
|
+
_ as $or,
|
|
55
|
+
r as $when,
|
|
56
|
+
u as __visibilityBrand,
|
|
57
|
+
y as and_,
|
|
58
|
+
o as equals,
|
|
59
|
+
d as falsy,
|
|
60
|
+
c as gt,
|
|
61
|
+
a as gte,
|
|
62
|
+
f as lt,
|
|
63
|
+
l as lte,
|
|
64
|
+
i as neq,
|
|
65
|
+
w as not_,
|
|
66
|
+
_ as or_,
|
|
67
|
+
s as truthy
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=conditions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditions.js","sources":["../../../sdui-core/src/conditions.ts"],"sourcesContent":["/**\n * Visibility Condition Types\n *\n * Matches the Python SDK's condition system (equals, neq, gt, gte, lt, lte,\n * truthy, falsy, not_, or_, and_) while using the prototype's opaque branded\n * approach for type safety.\n */\n\nimport type { StateRef, ItemRef, IndexRef } from './expressions';\n\n/** Brand symbol for VisibilityBinding. */\nexport const __visibilityBrand: unique symbol = Symbol('visibilityBrand');\n\n/** A number value — literal or a StateRef resolving to number. */\ntype NumberValue = number | StateRef<number>;\n\n/** Comparison operators shared by all condition sources. */\nexport interface ComparisonOps {\n eq?: unknown;\n neq?: unknown;\n gt?: NumberValue;\n gte?: NumberValue;\n lt?: NumberValue;\n lte?: NumberValue;\n not?: true;\n}\n\n/**\n * Opaque branded type for visibility conditions.\n *\n * External code cannot construct these manually because they cannot assign\n * to the unique symbol property — must use condition builder functions.\n */\nexport type VisibilityBinding = { readonly [__visibilityBrand]: true } & (\n | ({ readonly $state: string } & ComparisonOps)\n | ({ readonly $item: string } & ComparisonOps)\n | ({ readonly $index: true } & ComparisonOps)\n | { readonly $and: (VisibilityBinding | boolean)[] }\n | { readonly $or: (VisibilityBinding | boolean)[] }\n);\n\n/** Source ref types accepted by condition builders. */\ntype ConditionSource = StateRef<unknown> | ItemRef<unknown> | IndexRef;\n\n/**\n * Create a visibility condition from a typed ref.\n *\n * This is the prototype's $when() — kept for backwards compatibility.\n * Matches the Python SDK's condition builder API pattern.\n *\n * Usage:\n * $when($state('/isAdmin'))\n * $when($state('/count'), { gt: 0 })\n */\nexport function $when(\n ref: ConditionSource,\n ops?: ComparisonOps\n): VisibilityBinding {\n const raw = ref as unknown as Record<string, unknown>;\n return {\n ...raw,\n ...ops,\n [__visibilityBrand]: true as const,\n } as VisibilityBinding;\n}\n\n// ---------------------------------------------------------------------------\n// Builder functions matching the Python SDK's API\n// ---------------------------------------------------------------------------\n\n/** Equality condition: visible when ref value == rhs. */\nexport function equals(\n ref: ConditionSource,\n value: unknown\n): VisibilityBinding {\n return $when(ref, { eq: value });\n}\n\n/** Not-equal condition: visible when ref value != rhs. */\nexport function neq(ref: ConditionSource, value: unknown): VisibilityBinding {\n return $when(ref, { neq: value });\n}\n\n/** Greater-than condition: visible when ref value > rhs. */\nexport function gt(\n ref: ConditionSource,\n value: NumberValue\n): VisibilityBinding {\n return $when(ref, { gt: value });\n}\n\n/** Greater-than-or-equal condition: visible when ref value >= rhs. */\nexport function gte(\n ref: ConditionSource,\n value: NumberValue\n): VisibilityBinding {\n return $when(ref, { gte: value });\n}\n\n/** Less-than condition: visible when ref value < rhs. */\nexport function lt(\n ref: ConditionSource,\n value: NumberValue\n): VisibilityBinding {\n return $when(ref, { lt: value });\n}\n\n/** Less-than-or-equal condition: visible when ref value <= rhs. */\nexport function lte(\n ref: ConditionSource,\n value: NumberValue\n): VisibilityBinding {\n return $when(ref, { lte: value });\n}\n\n/** Truthy condition: visible when ref value is truthy. */\nexport function truthy(ref: ConditionSource): VisibilityBinding {\n return $when(ref);\n}\n\n/** Falsy condition: visible when ref value is falsy. */\nexport function falsy(ref: ConditionSource): VisibilityBinding {\n return $when(ref, { not: true });\n}\n\n/** Negate a condition. */\nexport function not_(condition: VisibilityBinding): VisibilityBinding {\n const raw = condition as unknown as Record<string, unknown>;\n return {\n ...raw,\n not: true,\n [__visibilityBrand]: true as const,\n } as VisibilityBinding;\n}\n\n/** Logical AND — all conditions must be true. */\nexport function $and(\n ...conditions: (VisibilityBinding | boolean)[]\n): VisibilityBinding {\n return {\n $and: conditions,\n [__visibilityBrand]: true as const,\n } as unknown as VisibilityBinding;\n}\n\n/** Logical OR — at least one condition must be true. */\nexport function $or(\n ...conditions: (VisibilityBinding | boolean)[]\n): VisibilityBinding {\n return {\n $or: conditions,\n [__visibilityBrand]: true as const,\n } as unknown as VisibilityBinding;\n}\n\n// Aliases matching Python SDK naming\nexport { $and as and_, $or as or_ };\n"],"names":["__visibilityBrand","$when","ref","ops","equals","value","neq","gt","gte","lt","lte","truthy","falsy","not_","condition","$and","conditions","$or"],"mappings":"AAWO,MAAMA,IAAmC,OAAO,iBAAiB;AA2CjE,SAASC,EACdC,GACAC,GACmB;AAEnB,SAAO;AAAA,IACL,GAFUD;AAAA,IAGV,GAAGC;AAAA,IACH,CAACH,CAAiB,GAAG;AAAA,EAAA;AAEzB;AAOO,SAASI,EACdF,GACAG,GACmB;AACnB,SAAOJ,EAAMC,GAAK,EAAE,IAAIG,GAAO;AACjC;AAGO,SAASC,EAAIJ,GAAsBG,GAAmC;AAC3E,SAAOJ,EAAMC,GAAK,EAAE,KAAKG,GAAO;AAClC;AAGO,SAASE,EACdL,GACAG,GACmB;AACnB,SAAOJ,EAAMC,GAAK,EAAE,IAAIG,GAAO;AACjC;AAGO,SAASG,EACdN,GACAG,GACmB;AACnB,SAAOJ,EAAMC,GAAK,EAAE,KAAKG,GAAO;AAClC;AAGO,SAASI,EACdP,GACAG,GACmB;AACnB,SAAOJ,EAAMC,GAAK,EAAE,IAAIG,GAAO;AACjC;AAGO,SAASK,EACdR,GACAG,GACmB;AACnB,SAAOJ,EAAMC,GAAK,EAAE,KAAKG,GAAO;AAClC;AAGO,SAASM,EAAOT,GAAyC;AAC9D,SAAOD,EAAMC,CAAG;AAClB;AAGO,SAASU,EAAMV,GAAyC;AAC7D,SAAOD,EAAMC,GAAK,EAAE,KAAK,IAAM;AACjC;AAGO,SAASW,EAAKC,GAAiD;AAEpE,SAAO;AAAA,IACL,GAFUA;AAAA,IAGV,KAAK;AAAA,IACL,CAACd,CAAiB,GAAG;AAAA,EAAA;AAEzB;AAGO,SAASe,KACXC,GACgB;AACnB,SAAO;AAAA,IACL,MAAMA;AAAA,IACN,CAAChB,CAAiB,GAAG;AAAA,EAAA;AAEzB;AAGO,SAASiB,KACXD,GACgB;AACnB,SAAO;AAAA,IACL,KAAKA;AAAA,IACL,CAAChB,CAAiB,GAAG;AAAA,EAAA;AAEzB;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elements.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Element Node - Internal tree representation
|
|
3
|
+
*
|
|
4
|
+
* Opaque branded types for element nodes and repeat bindings.
|
|
5
|
+
*/
|
|
6
|
+
declare const __elementBrand: unique symbol;
|
|
7
|
+
/**
|
|
8
|
+
* Opaque branded type returned by component builders.
|
|
9
|
+
* Cannot be constructed manually — must go through a generated component builder.
|
|
10
|
+
*/
|
|
11
|
+
export interface ElementNode<TPlatform extends string = string, TCatalog extends string = string> {
|
|
12
|
+
readonly [__elementBrand]: true;
|
|
13
|
+
readonly __platform?: TPlatform;
|
|
14
|
+
readonly __catalog?: TCatalog;
|
|
15
|
+
}
|
|
16
|
+
declare const __repeatBrand: unique symbol;
|
|
17
|
+
/**
|
|
18
|
+
* Opaque branded type returned by repeat().
|
|
19
|
+
* Cannot be constructed manually — must go through the typed repeat() helper.
|
|
20
|
+
*/
|
|
21
|
+
export interface RepeatBinding {
|
|
22
|
+
readonly [__repeatBrand]: true;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elements.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expressions.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phantom-Typed Expression Markers
|
|
3
|
+
*
|
|
4
|
+
* Each expression helper returns a marker object that carries the resolved
|
|
5
|
+
* value type as a phantom type. Builders accept PropValue<T> which
|
|
6
|
+
* structurally matches only when the phantom type aligns with the prop type.
|
|
7
|
+
*
|
|
8
|
+
* The __phantom symbol is used to embed type information in runtime objects
|
|
9
|
+
* without affecting JSON serialization. This enables compile-time type safety
|
|
10
|
+
* while keeping the runtime representation clean.
|
|
11
|
+
*/
|
|
12
|
+
declare const __phantom: unique symbol;
|
|
13
|
+
/** Read-only reference to a state path. Carries resolved value type T. */
|
|
14
|
+
export interface StateRef<T> {
|
|
15
|
+
readonly $state: string;
|
|
16
|
+
readonly [__phantom]: T;
|
|
17
|
+
}
|
|
18
|
+
/** Two-way binding to a state path. Carries resolved value type T. */
|
|
19
|
+
export interface BindStateRef<T> {
|
|
20
|
+
readonly $bindState: string;
|
|
21
|
+
readonly [__phantom]: T;
|
|
22
|
+
}
|
|
23
|
+
/** Read-only reference to a repeat item path. Carries resolved value type T. */
|
|
24
|
+
export interface ItemRef<T> {
|
|
25
|
+
readonly $item: string;
|
|
26
|
+
readonly [__phantom]: T;
|
|
27
|
+
}
|
|
28
|
+
/** Two-way binding to a repeat item path. Carries resolved value type T. */
|
|
29
|
+
export interface BindItemRef<T> {
|
|
30
|
+
readonly $bindItem: string;
|
|
31
|
+
readonly [__phantom]: T;
|
|
32
|
+
}
|
|
33
|
+
/** Current repeat index. Always resolves to number. */
|
|
34
|
+
export interface IndexRef {
|
|
35
|
+
readonly $index: true;
|
|
36
|
+
readonly [__phantom]: number;
|
|
37
|
+
}
|
|
38
|
+
/** String template expression. Always resolves to string. */
|
|
39
|
+
export interface TemplateRef {
|
|
40
|
+
readonly $template: string;
|
|
41
|
+
readonly [__phantom]: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Valid interpolation value inside a $template tagged template.
|
|
45
|
+
* Accepts any expression ref that can be stringified at runtime.
|
|
46
|
+
*/
|
|
47
|
+
export type TemplateInterpolation = StateRef<unknown> | ItemRef<unknown> | IndexRef | null | undefined;
|
|
48
|
+
/** Conditional expression with typed branches. Uses T directly to avoid circular PropValue recursion. */
|
|
49
|
+
export interface CondRef<T> {
|
|
50
|
+
readonly $cond: unknown;
|
|
51
|
+
readonly $then: T | StateRef<T> | BindStateRef<T> | ItemRef<T> | BindItemRef<T>;
|
|
52
|
+
readonly $else: T | StateRef<T> | BindStateRef<T> | ItemRef<T> | BindItemRef<T>;
|
|
53
|
+
readonly [__phantom]: T;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* A prop value that is either a literal T or a phantom-typed expression
|
|
57
|
+
* that resolves to T at runtime.
|
|
58
|
+
*/
|
|
59
|
+
export type PropValue<T> = T | StateRef<T> | BindStateRef<T> | ItemRef<T> | BindItemRef<T> | (T extends number ? IndexRef : never) | (T extends string ? TemplateRef : never) | CondRef<T>;
|
|
60
|
+
/**
|
|
61
|
+
* A value in an action param: literal T or a read-only expression.
|
|
62
|
+
* Narrower than PropValue — no bind refs, templates, or cond.
|
|
63
|
+
*/
|
|
64
|
+
export type ActionParamValue<T> = T | StateRef<T> | ItemRef<T> | (T extends number ? IndexRef : never);
|
|
65
|
+
/**
|
|
66
|
+
* Takes a plain props type and wraps each field with PropValue<T>.
|
|
67
|
+
* Preserves optionality: required fields stay required, optional stay optional.
|
|
68
|
+
*
|
|
69
|
+
* Uses Extract<TProps[K], undefined> to preserve undefined in the union,
|
|
70
|
+
* which maintains the optional field semantics from the original type.
|
|
71
|
+
*/
|
|
72
|
+
export type WrapWithPropValue<TProps> = {
|
|
73
|
+
[K in keyof TProps]: PropValue<NonNullable<TProps[K]>> | Extract<TProps[K], undefined>;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Takes a plain params type and wraps each field with ActionParamValue<T>.
|
|
77
|
+
*/
|
|
78
|
+
export type WrapWithActionParamValue<TParams> = {
|
|
79
|
+
[K in keyof TParams]: ActionParamValue<NonNullable<TParams[K]>> | Extract<TParams[K], undefined>;
|
|
80
|
+
};
|
|
81
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expressions.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./spec.cjs"),r=require("./component-utils.cjs"),n=require("./action-utils.cjs"),e=require("./conditions.cjs");exports.createSpec=t.createSpec;exports.renderElementTree=t.renderElementTree;exports.buildNode=r.buildNode;exports.buildAction=n.buildAction;exports.$and=e.$and;exports.$or=e.$or;exports.$when=e.$when;exports.and_=e.$and;exports.equals=e.equals;exports.falsy=e.falsy;exports.gt=e.gt;exports.gte=e.gte;exports.lt=e.lt;exports.lte=e.lte;exports.neq=e.neq;exports.not_=e.not_;exports.or_=e.$or;exports.truthy=e.truthy;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared SDK implementation used by platform packages and generated catalog code.
|
|
3
|
+
*/
|
|
4
|
+
export { createSpec, renderElementTree } from './spec';
|
|
5
|
+
export type { SpecContext, FlatSpec, FlatUIElement, ItemAccessor, } from './spec';
|
|
6
|
+
export { buildNode } from './component-utils';
|
|
7
|
+
export type { ComponentInputs, ComponentInputsOptionalProps, InternalElementNode, } from './component-utils';
|
|
8
|
+
export { buildAction } from './action-utils';
|
|
9
|
+
export type { ActionBinding, ActionConfirm, ActionOptions, ActionOnSuccess, ActionOnError, } from './action-utils';
|
|
10
|
+
export type { PropValue, WrapWithPropValue, StateRef, BindStateRef, ItemRef, BindItemRef, IndexRef, TemplateRef, CondRef, TemplateInterpolation, ActionParamValue, WrapWithActionParamValue, } from './expressions';
|
|
11
|
+
export { $when, equals, neq, gt, gte, lt, lte, truthy, falsy, not_, $and, $or, and_, or_, } from './conditions';
|
|
12
|
+
export type { VisibilityBinding, ComparisonOps } from './conditions';
|
|
13
|
+
export type { StatePaths, ValueAt, ArrayPaths, ArrayItemAt, ItemPaths, ItemValueAt, } from './paths';
|
|
14
|
+
export type { ElementNode, RepeatBinding } from './elements';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createSpec as o, renderElementTree as t } from "./spec.js";
|
|
2
|
+
import { buildNode as a } from "./component-utils.js";
|
|
3
|
+
import { buildAction as l } from "./action-utils.js";
|
|
4
|
+
import { $and as m, $or as p, $when as $, $and as s, equals as u, falsy as x, gt as c, gte as i, lt as _, lte as b, neq as g, not_ as h, $or as q, truthy as y } from "./conditions.js";
|
|
5
|
+
export {
|
|
6
|
+
m as $and,
|
|
7
|
+
p as $or,
|
|
8
|
+
$ as $when,
|
|
9
|
+
s as and_,
|
|
10
|
+
l as buildAction,
|
|
11
|
+
a as buildNode,
|
|
12
|
+
o as createSpec,
|
|
13
|
+
u as equals,
|
|
14
|
+
x as falsy,
|
|
15
|
+
c as gt,
|
|
16
|
+
i as gte,
|
|
17
|
+
_ as lt,
|
|
18
|
+
b as lte,
|
|
19
|
+
g as neq,
|
|
20
|
+
h as not_,
|
|
21
|
+
q as or_,
|
|
22
|
+
t as renderElementTree,
|
|
23
|
+
y as truthy
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type-level JSON pointer path helpers for state and repeat items.
|
|
3
|
+
*/
|
|
4
|
+
type Primitive = string | number | boolean | bigint | symbol | null | undefined;
|
|
5
|
+
type StringKeyOf<T> = Extract<keyof T, string>;
|
|
6
|
+
type NestedStatePaths<T> = T extends Primitive ? never : T extends readonly unknown[] ? never : {
|
|
7
|
+
[K in StringKeyOf<T>]: T[K] extends Primitive | readonly unknown[] ? `/${K}` : `/${K}` | `/${K}${NestedStatePaths<T[K]>}`;
|
|
8
|
+
}[StringKeyOf<T>];
|
|
9
|
+
type NestedItemPaths<T> = T extends Primitive ? never : T extends readonly unknown[] ? never : {
|
|
10
|
+
[K in StringKeyOf<T>]: T[K] extends Primitive | readonly unknown[] ? K : K | `${K}/${NestedItemPaths<T[K]>}`;
|
|
11
|
+
}[StringKeyOf<T>];
|
|
12
|
+
type ValueAtSegments<T, P extends string> = P extends `${infer K}/${infer Rest}` ? K extends StringKeyOf<T> ? T[K] extends readonly (infer Item)[] ? Rest extends `${number}/${infer ArrayRest}` ? ValueAtSegments<Item, ArrayRest> : never : ValueAtSegments<T[K], Rest> : never : P extends StringKeyOf<T> ? T[P] : never;
|
|
13
|
+
/** JSON pointer paths into a state object, such as "/user/name". */
|
|
14
|
+
export type StatePaths<T> = NestedStatePaths<T>;
|
|
15
|
+
/** Resolved value type for a state JSON pointer path. */
|
|
16
|
+
export type ValueAt<T, P extends string> = P extends `/${infer Rest}` ? ValueAtSegments<T, Rest> : ValueAtSegments<T, P>;
|
|
17
|
+
/** State paths whose resolved value is an array. */
|
|
18
|
+
export type ArrayPaths<T> = {
|
|
19
|
+
[P in StatePaths<T>]: ValueAt<T, P> extends readonly unknown[] ? P : never;
|
|
20
|
+
}[StatePaths<T>];
|
|
21
|
+
/** Array item type at an array-valued state path. */
|
|
22
|
+
export type ArrayItemAt<T, P extends string> = ValueAt<T, P> extends readonly (infer Item)[] ? Item : never;
|
|
23
|
+
/** Slash-separated paths into a repeat item, such as "title" or "owner/name". */
|
|
24
|
+
export type ItemPaths<T> = NestedItemPaths<T>;
|
|
25
|
+
/** Resolved value type for a repeat item path. */
|
|
26
|
+
export type ItemValueAt<T, P extends string> = ValueAtSegments<T, P>;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function w(f,S){const $={},p=new Map,m=new WeakMap,h=new WeakSet,u=new Set;let b=0;function t(n,d=new WeakSet){var s;const c=n;if(d.has(c))return;d.add(c);const e=n;if(e.id!==void 0){const o=p.get(e.id);if(o&&o!==c)throw new Error(`Duplicate element id: ${e.id}`);p.set(e.id,c),u.add(e.id)}(s=e.children)==null||s.forEach(o=>t(o,d))}function a(){let n;do n=`element-${b}`,b+=1;while(u.has(n));return u.add(n),n}function r(n){const d=n,c=m.get(d);if(c)return c;const s=n.id??a();return m.set(d,s),s}function l(n){const d=n,c=r(n);if(h.has(d))return c;h.add(d);const e=n,s=e.children?e.children.map(g=>l(g)):void 0,o={type:e.type,props:e.props};return s&&s.length>0&&(o.children=s),e.visible!==void 0&&(o.visible=e.visible),e.on&&(o.on=e.on),e.watch&&(o.watch=e.watch),e.repeat&&(o.repeat=e.repeat),$[c]=o,c}t(f);const i=l(f);return JSON.parse(JSON.stringify({root:i,elements:$,state:S}))}function I(f){const S=f.state;function $(t){return{$state:t}}function p(t){return{$bindState:t}}function m(t,...a){let r=t[0];for(let l=0;l<a.length;l+=1){const i=a[l];!i||typeof i!="object"?r+="":"$state"in i?r+=`\${${i.$state}}`:"$item"in i?r+=`\${$item.${i.$item}}`:"$index"in i&&(r+="${$index}"),r+=t[l+1]}return{$template:r}}function h(t,a,r){return{$cond:t,$then:a,$else:r}}function u(t,a){return[{statePath:t,key:a},{$(i){return{$item:i}},$bind(i){return{$bindItem:i}},$index(){return{$index:!0}}}]}function b(t){return w(t,S)}return{$state:$,$bindState:p,$template:m,$cond:h,repeat:u,render:b}}exports.createSpec=I;exports.renderElementTree=w;
|
|
2
|
+
//# sourceMappingURL=spec.cjs.map
|