@rippling/rippling-sdk 0.2.0-alpha.34 → 0.2.0-alpha.36
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/client.d.mts +6 -0
- package/client.d.mts.map +1 -1
- package/client.d.ts +6 -0
- package/client.d.ts.map +1 -1
- package/client.js +6 -0
- package/client.js.map +1 -1
- package/client.mjs +6 -0
- package/client.mjs.map +1 -1
- package/examples/.keep +4 -0
- package/examples/manifest/dental-practice-management/dental-practice-management.ts +651 -0
- package/examples/manifest/dental-practice-management/manifest.json +1870 -0
- package/examples/manifest/gym-membership-management/gym-membership-management.ts +757 -0
- package/examples/manifest/gym-membership-management/manifest.json +1975 -0
- package/examples/sdui/sdui-crud-todo/rippling-function.ts +367 -0
- package/examples/sdui/sdui-crud-todo/sdui-crud-todo.ts +282 -0
- package/examples/sdui/sdui-showcase/rippling-function.ts +381 -0
- package/examples/sdui/sdui-showcase/sdui-showcase.ts +351 -0
- package/examples/sdui/sdui-tab-multi-view/rippling-function.ts +1061 -0
- package/examples/sdui/sdui-tab-multi-view/sdui-tab-multi-view.ts +924 -0
- package/examples/sdui/vote/rippling-function.ts +330 -0
- package/examples/sdui/vote/vote.ts +298 -0
- package/lib/manifest/app.d.mts +81 -13
- package/lib/manifest/app.d.mts.map +1 -1
- package/lib/manifest/app.d.ts +81 -13
- package/lib/manifest/app.d.ts.map +1 -1
- package/lib/manifest/app.js +37 -16
- package/lib/manifest/app.js.map +1 -1
- package/lib/manifest/app.mjs +37 -16
- package/lib/manifest/app.mjs.map +1 -1
- package/lib/manifest/category.d.mts +63 -7
- package/lib/manifest/category.d.mts.map +1 -1
- package/lib/manifest/category.d.ts +63 -7
- package/lib/manifest/category.d.ts.map +1 -1
- package/lib/manifest/category.js +45 -10
- package/lib/manifest/category.js.map +1 -1
- package/lib/manifest/category.mjs +43 -8
- package/lib/manifest/category.mjs.map +1 -1
- package/lib/manifest/custom-object-field-section.d.mts +56 -6
- package/lib/manifest/custom-object-field-section.d.mts.map +1 -1
- package/lib/manifest/custom-object-field-section.d.ts +56 -6
- package/lib/manifest/custom-object-field-section.d.ts.map +1 -1
- package/lib/manifest/custom-object-field-section.js +41 -14
- package/lib/manifest/custom-object-field-section.js.map +1 -1
- package/lib/manifest/custom-object-field-section.mjs +39 -12
- package/lib/manifest/custom-object-field-section.mjs.map +1 -1
- package/lib/manifest/custom-object-page-layout.d.mts +201 -41
- package/lib/manifest/custom-object-page-layout.d.mts.map +1 -1
- package/lib/manifest/custom-object-page-layout.d.ts +201 -41
- package/lib/manifest/custom-object-page-layout.d.ts.map +1 -1
- package/lib/manifest/custom-object-page-layout.js +76 -30
- package/lib/manifest/custom-object-page-layout.js.map +1 -1
- package/lib/manifest/custom-object-page-layout.mjs +74 -28
- package/lib/manifest/custom-object-page-layout.mjs.map +1 -1
- package/lib/manifest/custom-object.d.mts +128 -15
- package/lib/manifest/custom-object.d.mts.map +1 -1
- package/lib/manifest/custom-object.d.ts +128 -15
- package/lib/manifest/custom-object.d.ts.map +1 -1
- package/lib/manifest/custom-object.js +61 -26
- package/lib/manifest/custom-object.js.map +1 -1
- package/lib/manifest/custom-object.mjs +61 -26
- package/lib/manifest/custom-object.mjs.map +1 -1
- package/lib/manifest/field.d.mts +265 -54
- package/lib/manifest/field.d.mts.map +1 -1
- package/lib/manifest/field.d.ts +265 -54
- package/lib/manifest/field.d.ts.map +1 -1
- package/lib/manifest/field.js +100 -57
- package/lib/manifest/field.js.map +1 -1
- package/lib/manifest/field.mjs +100 -57
- package/lib/manifest/field.mjs.map +1 -1
- package/lib/manifest/list-view.d.mts +105 -14
- package/lib/manifest/list-view.d.mts.map +1 -1
- package/lib/manifest/list-view.d.ts +105 -14
- package/lib/manifest/list-view.d.ts.map +1 -1
- package/lib/manifest/list-view.js +50 -14
- package/lib/manifest/list-view.js.map +1 -1
- package/lib/manifest/list-view.mjs +48 -12
- package/lib/manifest/list-view.mjs.map +1 -1
- package/lib/manifest/manifest-builder.d.mts +77 -11
- package/lib/manifest/manifest-builder.d.mts.map +1 -1
- package/lib/manifest/manifest-builder.d.ts +77 -11
- package/lib/manifest/manifest-builder.d.ts.map +1 -1
- package/lib/manifest/manifest-builder.js +46 -24
- package/lib/manifest/manifest-builder.js.map +1 -1
- package/lib/manifest/manifest-builder.mjs +44 -22
- package/lib/manifest/manifest-builder.mjs.map +1 -1
- package/lib/manifest/manifest-function.d.mts +92 -12
- package/lib/manifest/manifest-function.d.mts.map +1 -1
- package/lib/manifest/manifest-function.d.ts +92 -12
- package/lib/manifest/manifest-function.d.ts.map +1 -1
- package/lib/manifest/manifest-function.js +40 -11
- package/lib/manifest/manifest-function.js.map +1 -1
- package/lib/manifest/manifest-function.mjs +38 -9
- package/lib/manifest/manifest-function.mjs.map +1 -1
- package/lib/manifest/rule.d.mts +94 -16
- package/lib/manifest/rule.d.mts.map +1 -1
- package/lib/manifest/rule.d.ts +94 -16
- package/lib/manifest/rule.d.ts.map +1 -1
- package/lib/manifest/rule.js +36 -15
- package/lib/manifest/rule.js.map +1 -1
- package/lib/manifest/rule.mjs +36 -15
- package/lib/manifest/rule.mjs.map +1 -1
- package/lib/manifest/sdui-page.d.mts +67 -11
- package/lib/manifest/sdui-page.d.mts.map +1 -1
- package/lib/manifest/sdui-page.d.ts +67 -11
- package/lib/manifest/sdui-page.d.ts.map +1 -1
- package/lib/manifest/sdui-page.js +44 -13
- package/lib/manifest/sdui-page.js.map +1 -1
- package/lib/manifest/sdui-page.mjs +42 -11
- package/lib/manifest/sdui-page.mjs.map +1 -1
- package/lib/manifest/validation.d.mts +87 -12
- package/lib/manifest/validation.d.mts.map +1 -1
- package/lib/manifest/validation.d.ts +87 -12
- package/lib/manifest/validation.d.ts.map +1 -1
- package/lib/manifest/validation.js +41 -15
- package/lib/manifest/validation.js.map +1 -1
- package/lib/manifest/validation.mjs +39 -13
- package/lib/manifest/validation.mjs.map +1 -1
- package/lib/sdui/actions.d.mts +25 -0
- package/lib/sdui/actions.d.mts.map +1 -0
- package/lib/sdui/actions.d.ts +25 -0
- package/lib/sdui/actions.d.ts.map +1 -0
- package/lib/sdui/actions.js +53 -0
- package/lib/sdui/actions.js.map +1 -0
- package/lib/sdui/actions.mjs +42 -0
- package/lib/sdui/actions.mjs.map +1 -0
- package/lib/sdui/component.d.mts +41 -0
- package/lib/sdui/component.d.mts.map +1 -0
- package/lib/sdui/component.d.ts +41 -0
- package/lib/sdui/component.d.ts.map +1 -0
- package/lib/sdui/component.js +95 -0
- package/lib/sdui/component.js.map +1 -0
- package/lib/sdui/component.mjs +91 -0
- package/lib/sdui/component.mjs.map +1 -0
- package/lib/sdui/components.d.mts +149 -0
- package/lib/sdui/components.d.mts.map +1 -0
- package/lib/sdui/components.d.ts +149 -0
- package/lib/sdui/components.d.ts.map +1 -0
- package/lib/sdui/components.js +303 -0
- package/lib/sdui/components.js.map +1 -0
- package/lib/sdui/components.mjs +298 -0
- package/lib/sdui/components.mjs.map +1 -0
- package/lib/sdui/conditions.d.mts +25 -0
- package/lib/sdui/conditions.d.mts.map +1 -0
- package/lib/sdui/conditions.d.ts +25 -0
- package/lib/sdui/conditions.d.ts.map +1 -0
- package/lib/sdui/conditions.js +47 -0
- package/lib/sdui/conditions.js.map +1 -0
- package/lib/sdui/conditions.mjs +35 -0
- package/lib/sdui/conditions.mjs.map +1 -0
- package/lib/sdui/directives.d.mts +18 -0
- package/lib/sdui/directives.d.mts.map +1 -0
- package/lib/sdui/directives.d.ts +18 -0
- package/lib/sdui/directives.d.ts.map +1 -0
- package/lib/sdui/directives.js +28 -0
- package/lib/sdui/directives.js.map +1 -0
- package/lib/sdui/directives.mjs +21 -0
- package/lib/sdui/directives.mjs.map +1 -0
- package/lib/sdui/index.d.mts +362 -0
- package/lib/sdui/index.d.mts.map +1 -0
- package/lib/sdui/index.d.ts +362 -0
- package/lib/sdui/index.d.ts.map +1 -0
- package/lib/sdui/index.js +375 -0
- package/lib/sdui/index.js.map +1 -0
- package/lib/sdui/index.mjs +199 -0
- package/lib/sdui/index.mjs.map +1 -0
- package/lib/sdui/props.d.mts +12 -0
- package/lib/sdui/props.d.mts.map +1 -0
- package/lib/sdui/props.d.ts +12 -0
- package/lib/sdui/props.d.ts.map +1 -0
- package/lib/sdui/props.js +25 -0
- package/lib/sdui/props.js.map +1 -0
- package/lib/sdui/props.mjs +21 -0
- package/lib/sdui/props.mjs.map +1 -0
- package/lib/sdui/render.d.mts +23 -0
- package/lib/sdui/render.d.mts.map +1 -0
- package/lib/sdui/render.d.ts +23 -0
- package/lib/sdui/render.d.ts.map +1 -0
- package/lib/sdui/render.js +40 -0
- package/lib/sdui/render.js.map +1 -0
- package/lib/sdui/render.mjs +37 -0
- package/lib/sdui/render.mjs.map +1 -0
- package/lib/sdui/state.d.mts +22 -0
- package/lib/sdui/state.d.mts.map +1 -0
- package/lib/sdui/state.d.ts +22 -0
- package/lib/sdui/state.d.ts.map +1 -0
- package/lib/sdui/state.js +57 -0
- package/lib/sdui/state.js.map +1 -0
- package/lib/sdui/state.mjs +53 -0
- package/lib/sdui/state.mjs.map +1 -0
- package/package.json +11 -1
- package/resources/company-legal-entity-workers.d.mts +79 -0
- package/resources/company-legal-entity-workers.d.mts.map +1 -0
- package/resources/company-legal-entity-workers.d.ts +79 -0
- package/resources/company-legal-entity-workers.d.ts.map +1 -0
- package/resources/company-legal-entity-workers.js +30 -0
- package/resources/company-legal-entity-workers.js.map +1 -0
- package/resources/company-legal-entity-workers.mjs +26 -0
- package/resources/company-legal-entity-workers.mjs.map +1 -0
- package/resources/draft-hires.d.mts +4 -0
- package/resources/draft-hires.d.mts.map +1 -1
- package/resources/draft-hires.d.ts +4 -0
- package/resources/draft-hires.d.ts.map +1 -1
- package/resources/files.d.mts +16 -1
- package/resources/files.d.mts.map +1 -1
- package/resources/files.d.ts +16 -1
- package/resources/files.d.ts.map +1 -1
- package/resources/headcount-positions.d.mts +2 -2
- package/resources/headcount-positions.d.mts.map +1 -1
- package/resources/headcount-positions.d.ts +2 -2
- package/resources/headcount-positions.d.ts.map +1 -1
- package/resources/index.d.mts +1 -0
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -0
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +4 -2
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -0
- package/resources/index.mjs.map +1 -1
- package/resources/legal-entities.d.mts +1 -1
- package/resources/legal-entities.d.mts.map +1 -1
- package/resources/legal-entities.d.ts +1 -1
- package/resources/legal-entities.d.ts.map +1 -1
- package/resources/location-factors.d.mts +2 -2
- package/resources/location-factors.d.mts.map +1 -1
- package/resources/location-factors.d.ts +2 -2
- package/resources/location-factors.d.ts.map +1 -1
- package/resources/shared.d.mts +1 -1
- package/resources/shared.d.mts.map +1 -1
- package/resources/shared.d.ts +1 -1
- package/resources/shared.d.ts.map +1 -1
- package/resources/workers.d.mts +2 -2
- package/resources/workers.d.mts.map +1 -1
- package/resources/workers.d.ts +2 -2
- package/resources/workers.d.ts.map +1 -1
- package/src/client.ts +20 -0
- package/src/lib/manifest/app.ts +81 -26
- package/src/lib/manifest/category.ts +63 -14
- package/src/lib/manifest/custom-object-field-section.ts +56 -17
- package/src/lib/manifest/custom-object-page-layout.ts +201 -66
- package/src/lib/manifest/custom-object.ts +128 -37
- package/src/lib/manifest/field.ts +265 -75
- package/src/lib/manifest/list-view.ts +105 -25
- package/src/lib/manifest/manifest-builder.ts +75 -32
- package/src/lib/manifest/manifest-function.ts +92 -22
- package/src/lib/manifest/rule.ts +95 -29
- package/src/lib/manifest/sdui-page.ts +67 -21
- package/src/lib/manifest/validation.ts +87 -24
- package/src/lib/sdui/actions.ts +58 -0
- package/src/lib/sdui/component.ts +122 -0
- package/src/lib/sdui/components.ts +308 -0
- package/src/lib/sdui/conditions.ts +59 -0
- package/src/lib/sdui/directives.ts +42 -0
- package/src/lib/sdui/index.ts +365 -0
- package/src/lib/sdui/props.ts +32 -0
- package/src/lib/sdui/render.ts +58 -0
- package/src/lib/sdui/state.ts +60 -0
- package/src/resources/company-legal-entity-workers.ts +115 -0
- package/src/resources/draft-hires.ts +5 -0
- package/src/resources/files.ts +18 -1
- package/src/resources/headcount-positions.ts +2 -0
- package/src/resources/index.ts +7 -0
- package/src/resources/legal-entities.ts +1 -0
- package/src/resources/location-factors.ts +2 -0
- package/src/resources/shared.ts +1 -0
- package/src/resources/workers.ts +2 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -1,17 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { generateId } from "./_helpers.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Defines a validation rule and registers it with the manifest.
|
|
4
|
+
*
|
|
5
|
+
* A validation rule evaluates an RQL formula on save and blocks the operation
|
|
6
|
+
* when the formula returns `true`. You would normally define validations after
|
|
7
|
+
* the fields they reference.
|
|
3
8
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
9
|
+
* **Violation semantics:** the formula encodes the *invalid* condition, not the
|
|
10
|
+
* valid one. `'(end_time__c <= start_time__c)'` fires when end is before or equal
|
|
11
|
+
* to start — i.e., it is truthy when the record is wrong.
|
|
6
12
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* new Validation(sessionObj, {
|
|
16
|
+
* ruleId: 'gym_session_end_after_start',
|
|
17
|
+
* displayName: 'End time must be after start',
|
|
18
|
+
* rqlFormula: '(end_time__c <= start_time__c)',
|
|
19
|
+
* errorMessage: 'End time must be after the start time.',
|
|
20
|
+
* ruleDescription: 'Prevents zero-length or inverted intervals',
|
|
21
|
+
* state: 'ACTIVE',
|
|
22
|
+
* level: 'FIELD',
|
|
23
|
+
* fieldRef: sessionEndField,
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
11
26
|
*/
|
|
12
|
-
import { generateId } from "./_helpers.mjs";
|
|
13
27
|
export class Validation {
|
|
14
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* @param customObject - The custom object this rule applies to.
|
|
30
|
+
* @param props - Initialization properties.
|
|
31
|
+
*/
|
|
15
32
|
constructor(customObject, props) {
|
|
16
33
|
this._ruleId = props.ruleId ?? generateId('rule');
|
|
17
34
|
this._customObjectApiName = customObject.getApiName();
|
|
@@ -24,15 +41,24 @@ export class Validation {
|
|
|
24
41
|
this._fieldRef = props.fieldRef;
|
|
25
42
|
customObject._register(this);
|
|
26
43
|
}
|
|
27
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Returns the stable identifier for this validation rule (e.g. `'gym_session_end_after_start'`).
|
|
46
|
+
*/
|
|
28
47
|
getRuleId() {
|
|
29
48
|
return this._ruleId;
|
|
30
49
|
}
|
|
31
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* Returns the api_name of the custom object this validation rule applies to.
|
|
52
|
+
*/
|
|
32
53
|
getCustomObjectApiName() {
|
|
33
54
|
return this._customObjectApiName;
|
|
34
55
|
}
|
|
35
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* Serializes this validation rule to the wire format consumed by the manifest install endpoint.
|
|
58
|
+
*
|
|
59
|
+
* @returns A plain object with `type: 'CUSTOM_OBJECT_VALIDATION_RULE'`.
|
|
60
|
+
* `field_rql_name` is omitted when `fieldRef` was not provided.
|
|
61
|
+
*/
|
|
36
62
|
toDict() {
|
|
37
63
|
const component = {
|
|
38
64
|
type: 'CUSTOM_OBJECT_VALIDATION_RULE',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.mjs","sourceRoot":"","sources":["../../src/lib/manifest/validation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validation.mjs","sourceRoot":"","sources":["../../src/lib/manifest/validation.ts"],"names":[],"mappings":"OAAO,EAAE,UAAU,EAA8C;AA6DjE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,OAAO,UAAU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,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;QACtF,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface ActionBinding {
|
|
2
|
+
action: string;
|
|
3
|
+
params?: Record<string, unknown>;
|
|
4
|
+
onSuccess?: ActionBinding | {
|
|
5
|
+
set: Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
onError?: ActionBinding | {
|
|
8
|
+
set: Record<string, unknown>;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare function set(ref: unknown, value: unknown): ActionBinding;
|
|
12
|
+
export declare function push(ref: unknown, value: unknown, opts?: {
|
|
13
|
+
clear?: unknown;
|
|
14
|
+
}): ActionBinding;
|
|
15
|
+
export declare function remove(ref: unknown, index: unknown): ActionBinding;
|
|
16
|
+
export declare function callFunction(functionId: string, action: string, opts?: Record<string, unknown>): ActionBinding;
|
|
17
|
+
export declare function nav(config: {
|
|
18
|
+
path: string;
|
|
19
|
+
openInNewTab?: boolean;
|
|
20
|
+
}): ActionBinding;
|
|
21
|
+
export declare function notify(message: string, variant: string): ActionBinding;
|
|
22
|
+
export declare function validate(statePath?: string): ActionBinding;
|
|
23
|
+
export declare function openModal(modalId: string): ActionBinding;
|
|
24
|
+
export declare function closeModal(): ActionBinding;
|
|
25
|
+
//# sourceMappingURL=actions.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.mts","sourceRoot":"","sources":["../../src/lib/sdui/actions.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,aAAa,GAAG;QAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;IAC7D,OAAO,CAAC,EAAE,aAAa,GAAG;QAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;CAC5D;AAED,wBAAgB,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,aAAa,CAE/D;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,aAAa,CAM5F;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,aAAa,CAElE;AAED,wBAAgB,YAAY,CAC1B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,aAAa,CAQf;AAED,wBAAgB,GAAG,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,aAAa,CAEnF;AAED,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,aAAa,CAEtE;AAED,wBAAgB,QAAQ,CAAC,SAAS,SAAoB,GAAG,aAAa,CAErE;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CAExD;AAED,wBAAgB,UAAU,IAAI,aAAa,CAE1C"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface ActionBinding {
|
|
2
|
+
action: string;
|
|
3
|
+
params?: Record<string, unknown>;
|
|
4
|
+
onSuccess?: ActionBinding | {
|
|
5
|
+
set: Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
onError?: ActionBinding | {
|
|
8
|
+
set: Record<string, unknown>;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare function set(ref: unknown, value: unknown): ActionBinding;
|
|
12
|
+
export declare function push(ref: unknown, value: unknown, opts?: {
|
|
13
|
+
clear?: unknown;
|
|
14
|
+
}): ActionBinding;
|
|
15
|
+
export declare function remove(ref: unknown, index: unknown): ActionBinding;
|
|
16
|
+
export declare function callFunction(functionId: string, action: string, opts?: Record<string, unknown>): ActionBinding;
|
|
17
|
+
export declare function nav(config: {
|
|
18
|
+
path: string;
|
|
19
|
+
openInNewTab?: boolean;
|
|
20
|
+
}): ActionBinding;
|
|
21
|
+
export declare function notify(message: string, variant: string): ActionBinding;
|
|
22
|
+
export declare function validate(statePath?: string): ActionBinding;
|
|
23
|
+
export declare function openModal(modalId: string): ActionBinding;
|
|
24
|
+
export declare function closeModal(): ActionBinding;
|
|
25
|
+
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/lib/sdui/actions.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,aAAa,GAAG;QAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;IAC7D,OAAO,CAAC,EAAE,aAAa,GAAG;QAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;CAC5D;AAED,wBAAgB,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,aAAa,CAE/D;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,aAAa,CAM5F;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,aAAa,CAElE;AAED,wBAAgB,YAAY,CAC1B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,aAAa,CAQf;AAED,wBAAgB,GAAG,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,aAAa,CAEnF;AAED,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,aAAa,CAEtE;AAED,wBAAgB,QAAQ,CAAC,SAAS,SAAoB,GAAG,aAAa,CAErE;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CAExD;AAED,wBAAgB,UAAU,IAAI,aAAa,CAE1C"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.set = set;
|
|
4
|
+
exports.push = push;
|
|
5
|
+
exports.remove = remove;
|
|
6
|
+
exports.callFunction = callFunction;
|
|
7
|
+
exports.nav = nav;
|
|
8
|
+
exports.notify = notify;
|
|
9
|
+
exports.validate = validate;
|
|
10
|
+
exports.openModal = openModal;
|
|
11
|
+
exports.closeModal = closeModal;
|
|
12
|
+
const state_1 = require("./state.js");
|
|
13
|
+
function set(ref, value) {
|
|
14
|
+
return { action: 'setState', params: { statePath: (0, state_1.extractPath)(ref), value } };
|
|
15
|
+
}
|
|
16
|
+
function push(ref, value, opts) {
|
|
17
|
+
const params = { statePath: (0, state_1.extractPath)(ref), value };
|
|
18
|
+
if (opts?.clear) {
|
|
19
|
+
params['clearStatePath'] = (0, state_1.extractPath)(opts.clear);
|
|
20
|
+
}
|
|
21
|
+
return { action: 'pushState', params };
|
|
22
|
+
}
|
|
23
|
+
function remove(ref, index) {
|
|
24
|
+
return { action: 'removeState', params: { statePath: (0, state_1.extractPath)(ref), index } };
|
|
25
|
+
}
|
|
26
|
+
function callFunction(functionId, action, opts) {
|
|
27
|
+
const { responsePath, onSuccess, onError, ...rest } = opts || {};
|
|
28
|
+
const params = { functionId, action, ...rest };
|
|
29
|
+
if (responsePath !== undefined)
|
|
30
|
+
params['responsePath'] = responsePath;
|
|
31
|
+
const binding = { action: 'triggerFunction', params };
|
|
32
|
+
if (onSuccess)
|
|
33
|
+
binding.onSuccess = onSuccess;
|
|
34
|
+
if (onError)
|
|
35
|
+
binding.onError = onError;
|
|
36
|
+
return binding;
|
|
37
|
+
}
|
|
38
|
+
function nav(config) {
|
|
39
|
+
return { action: 'navigate', params: config };
|
|
40
|
+
}
|
|
41
|
+
function notify(message, variant) {
|
|
42
|
+
return { action: 'showNotification', params: { message, variant } };
|
|
43
|
+
}
|
|
44
|
+
function validate(statePath = '/formValidation') {
|
|
45
|
+
return { action: 'validateForm', params: { statePath } };
|
|
46
|
+
}
|
|
47
|
+
function openModal(modalId) {
|
|
48
|
+
return { action: 'openModal', params: { modalId } };
|
|
49
|
+
}
|
|
50
|
+
function closeModal() {
|
|
51
|
+
return { action: 'closeModal' };
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../src/lib/sdui/actions.ts"],"names":[],"mappings":";;AASA,kBAEC;AAED,oBAMC;AAED,wBAEC;AAED,oCAYC;AAED,kBAEC;AAED,wBAEC;AAED,4BAEC;AAED,8BAEC;AAED,gCAEC;AAzDD,sCAAsC;AAStC,SAAgB,GAAG,CAAC,GAAY,EAAE,KAAc;IAC9C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,IAAA,mBAAW,EAAC,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;AAChF,CAAC;A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AgB,MAAM,CAAC,OAAe,EAAE,OAAe;IACrD,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC;AACtE,CAAC;AAED,SAAgB,QAAQ,CAAC,SAAS,GAAG,iBAAiB;IACpD,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,EAAE,CAAC;AAC3D,CAAC;AAED,SAAgB,SAAS,CAAC,OAAe;IACvC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC;AACtD,CAAC;AAED,SAAgB,UAAU;IACxB,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { extractPath } from "./state.mjs";
|
|
2
|
+
export function set(ref, value) {
|
|
3
|
+
return { action: 'setState', params: { statePath: extractPath(ref), value } };
|
|
4
|
+
}
|
|
5
|
+
export function push(ref, value, opts) {
|
|
6
|
+
const params = { statePath: extractPath(ref), value };
|
|
7
|
+
if (opts?.clear) {
|
|
8
|
+
params['clearStatePath'] = extractPath(opts.clear);
|
|
9
|
+
}
|
|
10
|
+
return { action: 'pushState', params };
|
|
11
|
+
}
|
|
12
|
+
export function remove(ref, index) {
|
|
13
|
+
return { action: 'removeState', params: { statePath: extractPath(ref), index } };
|
|
14
|
+
}
|
|
15
|
+
export function callFunction(functionId, action, opts) {
|
|
16
|
+
const { responsePath, onSuccess, onError, ...rest } = opts || {};
|
|
17
|
+
const params = { functionId, action, ...rest };
|
|
18
|
+
if (responsePath !== undefined)
|
|
19
|
+
params['responsePath'] = responsePath;
|
|
20
|
+
const binding = { action: 'triggerFunction', params };
|
|
21
|
+
if (onSuccess)
|
|
22
|
+
binding.onSuccess = onSuccess;
|
|
23
|
+
if (onError)
|
|
24
|
+
binding.onError = onError;
|
|
25
|
+
return binding;
|
|
26
|
+
}
|
|
27
|
+
export function nav(config) {
|
|
28
|
+
return { action: 'navigate', params: config };
|
|
29
|
+
}
|
|
30
|
+
export function notify(message, variant) {
|
|
31
|
+
return { action: 'showNotification', params: { message, variant } };
|
|
32
|
+
}
|
|
33
|
+
export function validate(statePath = '/formValidation') {
|
|
34
|
+
return { action: 'validateForm', params: { statePath } };
|
|
35
|
+
}
|
|
36
|
+
export function openModal(modalId) {
|
|
37
|
+
return { action: 'openModal', params: { modalId } };
|
|
38
|
+
}
|
|
39
|
+
export function closeModal() {
|
|
40
|
+
return { action: 'closeModal' };
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=actions.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.mjs","sourceRoot":"","sources":["../../src/lib/sdui/actions.ts"],"names":[],"mappings":"OAAO,EAAE,WAAW,EAAE;AAStB,MAAM,UAAU,GAAG,CAAC,GAAY,EAAE,KAAc;IAC9C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,WAAW,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;AAChF,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,GAAY,EAAE,KAAc,EAAE,IAA0B;IAC3E,MAAM,MAAM,GAA4B,EAAE,SAAS,EAAE,WAAW,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC;IAC/E,IAAI,IAAI,EAAE,KAAK,EAAE,CAAC;QAChB,MAAM,CAAC,gBAAgB,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,GAAY,EAAE,KAAc;IACjD,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,WAAW,CAAC,G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,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* component() — creates a stateful component boundary.
|
|
3
|
+
*
|
|
4
|
+
* Provides ctx.useState (scoped local state) and ctx.useEffect (onMount actions).
|
|
5
|
+
* The returned element is automatically wrapped with _LocalStateProvider in the rendered spec.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* function MembersGrid(props) {
|
|
9
|
+
* return component((ctx) => {
|
|
10
|
+
* const local = ctx.useState({ data: [], loading: true })
|
|
11
|
+
* ctx.useEffect(fetchAction)
|
|
12
|
+
* return { element: DataGrid({ ... }), refresh: fetchAction }
|
|
13
|
+
* })
|
|
14
|
+
* }
|
|
15
|
+
*/
|
|
16
|
+
import type { SpecNode } from "./components.mjs";
|
|
17
|
+
import type { ActionBinding } from "./actions.mjs";
|
|
18
|
+
export declare function _resetIdCounter(): void;
|
|
19
|
+
export interface StateScope {
|
|
20
|
+
/** Read state value: { $state: "/auto_xxx/field" } */
|
|
21
|
+
readonly [key: string]: any;
|
|
22
|
+
/** Two-way bind: { $bindState: "/auto_xxx/field" } */
|
|
23
|
+
readonly $bind: {
|
|
24
|
+
$bindState: string;
|
|
25
|
+
};
|
|
26
|
+
/** Raw path string */
|
|
27
|
+
readonly $path: string;
|
|
28
|
+
}
|
|
29
|
+
interface ComponentContext {
|
|
30
|
+
/** Declare scoped local state. Returns a proxy for reading/binding. */
|
|
31
|
+
useState<T extends Record<string, unknown>>(initial: T): StateScope;
|
|
32
|
+
/** Register an action to fire on mount (when element becomes visible). */
|
|
33
|
+
useEffect(action: ActionBinding | ActionBinding[]): void;
|
|
34
|
+
}
|
|
35
|
+
interface ComponentResult {
|
|
36
|
+
element: SpecNode;
|
|
37
|
+
[key: string]: any;
|
|
38
|
+
}
|
|
39
|
+
export declare function component(factory: (ctx: ComponentContext) => ComponentResult): ComponentResult;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=component.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.d.mts","sourceRoot":"","sources":["../../src/lib/sdui/component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;OAEI,KAAK,EAAE,QAAQ,EAAE;OACjB,KAAK,EAAE,aAAa,EAAE;AAQ7B,wBAAgB,eAAe,IAAI,IAAI,CAEtC;AAED,MAAM,WAAW,UAAU;IACzB,sDAAsD;IACtD,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IAC5B,sDAAsD;IACtD,QAAQ,CAAC,KAAK,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IACvC,sBAAsB;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,gBAAgB;IACxB,uEAAuE;IACvE,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,UAAU,CAAC;IACpE,0EAA0E;IAC1E,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,EAAE,GAAG,IAAI,CAAC;CAC1D;AAED,UAAU,eAAe;IACvB,OAAO,EAAE,QAAQ,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAkBD,wBAAgB,SAAS,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,eAAe,GAAG,eAAe,CAuD9F"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* component() — creates a stateful component boundary.
|
|
3
|
+
*
|
|
4
|
+
* Provides ctx.useState (scoped local state) and ctx.useEffect (onMount actions).
|
|
5
|
+
* The returned element is automatically wrapped with _LocalStateProvider in the rendered spec.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* function MembersGrid(props) {
|
|
9
|
+
* return component((ctx) => {
|
|
10
|
+
* const local = ctx.useState({ data: [], loading: true })
|
|
11
|
+
* ctx.useEffect(fetchAction)
|
|
12
|
+
* return { element: DataGrid({ ... }), refresh: fetchAction }
|
|
13
|
+
* })
|
|
14
|
+
* }
|
|
15
|
+
*/
|
|
16
|
+
import type { SpecNode } from "./components.js";
|
|
17
|
+
import type { ActionBinding } from "./actions.js";
|
|
18
|
+
export declare function _resetIdCounter(): void;
|
|
19
|
+
export interface StateScope {
|
|
20
|
+
/** Read state value: { $state: "/auto_xxx/field" } */
|
|
21
|
+
readonly [key: string]: any;
|
|
22
|
+
/** Two-way bind: { $bindState: "/auto_xxx/field" } */
|
|
23
|
+
readonly $bind: {
|
|
24
|
+
$bindState: string;
|
|
25
|
+
};
|
|
26
|
+
/** Raw path string */
|
|
27
|
+
readonly $path: string;
|
|
28
|
+
}
|
|
29
|
+
interface ComponentContext {
|
|
30
|
+
/** Declare scoped local state. Returns a proxy for reading/binding. */
|
|
31
|
+
useState<T extends Record<string, unknown>>(initial: T): StateScope;
|
|
32
|
+
/** Register an action to fire on mount (when element becomes visible). */
|
|
33
|
+
useEffect(action: ActionBinding | ActionBinding[]): void;
|
|
34
|
+
}
|
|
35
|
+
interface ComponentResult {
|
|
36
|
+
element: SpecNode;
|
|
37
|
+
[key: string]: any;
|
|
38
|
+
}
|
|
39
|
+
export declare function component(factory: (ctx: ComponentContext) => ComponentResult): ComponentResult;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/lib/sdui/component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;OAEI,KAAK,EAAE,QAAQ,EAAE;OACjB,KAAK,EAAE,aAAa,EAAE;AAQ7B,wBAAgB,eAAe,IAAI,IAAI,CAEtC;AAED,MAAM,WAAW,UAAU;IACzB,sDAAsD;IACtD,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IAC5B,sDAAsD;IACtD,QAAQ,CAAC,KAAK,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IACvC,sBAAsB;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,gBAAgB;IACxB,uEAAuE;IACvE,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,UAAU,CAAC;IACpE,0EAA0E;IAC1E,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,EAAE,GAAG,IAAI,CAAC;CAC1D;AAED,UAAU,eAAe;IACvB,OAAO,EAAE,QAAQ,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAkBD,wBAAgB,SAAS,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,eAAe,GAAG,eAAe,CAuD9F"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* component() — creates a stateful component boundary.
|
|
4
|
+
*
|
|
5
|
+
* Provides ctx.useState (scoped local state) and ctx.useEffect (onMount actions).
|
|
6
|
+
* The returned element is automatically wrapped with _LocalStateProvider in the rendered spec.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* function MembersGrid(props) {
|
|
10
|
+
* return component((ctx) => {
|
|
11
|
+
* const local = ctx.useState({ data: [], loading: true })
|
|
12
|
+
* ctx.useEffect(fetchAction)
|
|
13
|
+
* return { element: DataGrid({ ... }), refresh: fetchAction }
|
|
14
|
+
* })
|
|
15
|
+
* }
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports._resetIdCounter = _resetIdCounter;
|
|
19
|
+
exports.component = component;
|
|
20
|
+
let _idCounter = 0;
|
|
21
|
+
function generateId() {
|
|
22
|
+
return `auto_${(++_idCounter).toString(36)}_${Date.now().toString(36)}`;
|
|
23
|
+
}
|
|
24
|
+
// Reset counter (for testing)
|
|
25
|
+
function _resetIdCounter() {
|
|
26
|
+
_idCounter = 0;
|
|
27
|
+
}
|
|
28
|
+
function createScopeProxy(basePath) {
|
|
29
|
+
const handler = {
|
|
30
|
+
get(_target, prop) {
|
|
31
|
+
if (prop === '$bind')
|
|
32
|
+
return { $bindState: basePath };
|
|
33
|
+
if (prop === '$path')
|
|
34
|
+
return basePath;
|
|
35
|
+
if (prop === '$state')
|
|
36
|
+
return basePath;
|
|
37
|
+
if (prop === 'toJSON')
|
|
38
|
+
return () => ({ $state: basePath });
|
|
39
|
+
if (prop === Symbol.toPrimitive)
|
|
40
|
+
return () => `$state:${basePath}`;
|
|
41
|
+
const childPath = `${basePath}/${String(prop)}`;
|
|
42
|
+
return createScopeProxy(childPath);
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
return new Proxy({}, handler);
|
|
46
|
+
}
|
|
47
|
+
function component(factory) {
|
|
48
|
+
let localState = null;
|
|
49
|
+
let mountAction = null;
|
|
50
|
+
const ctx = {
|
|
51
|
+
useState(initial) {
|
|
52
|
+
const path = `/${generateId()}`;
|
|
53
|
+
localState = { path, initial };
|
|
54
|
+
return createScopeProxy(path);
|
|
55
|
+
},
|
|
56
|
+
useEffect(action) {
|
|
57
|
+
mountAction = action;
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
const result = factory(ctx);
|
|
61
|
+
// Capture state after factory execution (TS can't track closure mutations)
|
|
62
|
+
const capturedState = localState;
|
|
63
|
+
const capturedMount = mountAction;
|
|
64
|
+
// If no local state and no effects, return as-is
|
|
65
|
+
if (!capturedState && !capturedMount) {
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
// Wrap element with _LocalStateProvider
|
|
69
|
+
const providerProps = {};
|
|
70
|
+
if (capturedState) {
|
|
71
|
+
providerProps['statePath'] = capturedState.path;
|
|
72
|
+
providerProps['initialValue'] = capturedState.initial;
|
|
73
|
+
}
|
|
74
|
+
if (capturedMount) {
|
|
75
|
+
providerProps['onMountAction'] = capturedMount;
|
|
76
|
+
}
|
|
77
|
+
const wrapper = {
|
|
78
|
+
type: '_LocalStateProvider',
|
|
79
|
+
props: providerProps,
|
|
80
|
+
children: [result.element],
|
|
81
|
+
};
|
|
82
|
+
// Attach the local state to the spec's state tree
|
|
83
|
+
// The render() function will collect this via a special marker
|
|
84
|
+
if (capturedState) {
|
|
85
|
+
wrapper._localStateRegistration = {
|
|
86
|
+
path: capturedState.path,
|
|
87
|
+
initial: capturedState.initial,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
...result,
|
|
92
|
+
element: wrapper,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../src/lib/sdui/component.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAWH,0CAEC;AAuCD,8BAuDC;AAtGD,IAAI,UAAU,GAAG,CAAC,CAAC;AACnB,SAAS,UAAU;IACjB,OAAO,QAAQ,CAAC,EAAE,UAAU,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;AAC1E,CAAC;AAED,8BAA8B;AAC9B,SAAgB,eAAe;IAC7B,UAAU,GAAG,CAAC,CAAC;AACjB,CAAC;AAuBD,SAAS,gBAAgB,CAAC,QAAgB;IACxC,MAAM,OAAO,GAAyB;QACpC,GAAG,CAAC,OAAO,EAAE,IAAI;YACf,IAAI,IAAI,KAAK,OAAO;gBAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC;YACtD,IAAI,IAAI,KAAK,OAAO;gBAAE,OAAO,QAAQ,CAAC;YACtC,IAAI,IAAI,KAAK,QAAQ;gBAAE,OAAO,QA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CAAC;QAChD,aAAa,CAAC,cAAc,CAAC,GAAG,aAAa,CAAC,OAAO,CAAC;IACxD,CAAC;IACD,IAAI,aAAa,EAAE,CAAC;QAClB,aAAa,CAAC,eAAe,CAAC,GAAG,aAAa,CAAC;IACjD,CAAC;IAED,MAAM,OAAO,GAAa;QACxB,IAAI,EAAE,qBAAqB;QAC3B,KAAK,EAAE,aAAa;QACpB,QAAQ,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC;KAC3B,CAAC;IAEF,kDAAkD;IAClD,+DAA+D;IAC/D,IAAI,aAAa,EAAE,CAAC;QACjB,OAAe,CAAC,uBAAuB,GAAG;YACzC,IAAI,EAAE,aAAa,CAAC,IAAI;YACxB,OAAO,EAAE,aAAa,CAAC,OAAO;SAC/B,CAAC;IACJ,CAAC;IAED,OAAO;QACL,GAAG,MAAM;QACT,OAAO,EAAE,OAAO;KACjB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* component() — creates a stateful component boundary.
|
|
3
|
+
*
|
|
4
|
+
* Provides ctx.useState (scoped local state) and ctx.useEffect (onMount actions).
|
|
5
|
+
* The returned element is automatically wrapped with _LocalStateProvider in the rendered spec.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* function MembersGrid(props) {
|
|
9
|
+
* return component((ctx) => {
|
|
10
|
+
* const local = ctx.useState({ data: [], loading: true })
|
|
11
|
+
* ctx.useEffect(fetchAction)
|
|
12
|
+
* return { element: DataGrid({ ... }), refresh: fetchAction }
|
|
13
|
+
* })
|
|
14
|
+
* }
|
|
15
|
+
*/
|
|
16
|
+
let _idCounter = 0;
|
|
17
|
+
function generateId() {
|
|
18
|
+
return `auto_${(++_idCounter).toString(36)}_${Date.now().toString(36)}`;
|
|
19
|
+
}
|
|
20
|
+
// Reset counter (for testing)
|
|
21
|
+
export function _resetIdCounter() {
|
|
22
|
+
_idCounter = 0;
|
|
23
|
+
}
|
|
24
|
+
function createScopeProxy(basePath) {
|
|
25
|
+
const handler = {
|
|
26
|
+
get(_target, prop) {
|
|
27
|
+
if (prop === '$bind')
|
|
28
|
+
return { $bindState: basePath };
|
|
29
|
+
if (prop === '$path')
|
|
30
|
+
return basePath;
|
|
31
|
+
if (prop === '$state')
|
|
32
|
+
return basePath;
|
|
33
|
+
if (prop === 'toJSON')
|
|
34
|
+
return () => ({ $state: basePath });
|
|
35
|
+
if (prop === Symbol.toPrimitive)
|
|
36
|
+
return () => `$state:${basePath}`;
|
|
37
|
+
const childPath = `${basePath}/${String(prop)}`;
|
|
38
|
+
return createScopeProxy(childPath);
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
return new Proxy({}, handler);
|
|
42
|
+
}
|
|
43
|
+
export function component(factory) {
|
|
44
|
+
let localState = null;
|
|
45
|
+
let mountAction = null;
|
|
46
|
+
const ctx = {
|
|
47
|
+
useState(initial) {
|
|
48
|
+
const path = `/${generateId()}`;
|
|
49
|
+
localState = { path, initial };
|
|
50
|
+
return createScopeProxy(path);
|
|
51
|
+
},
|
|
52
|
+
useEffect(action) {
|
|
53
|
+
mountAction = action;
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
const result = factory(ctx);
|
|
57
|
+
// Capture state after factory execution (TS can't track closure mutations)
|
|
58
|
+
const capturedState = localState;
|
|
59
|
+
const capturedMount = mountAction;
|
|
60
|
+
// If no local state and no effects, return as-is
|
|
61
|
+
if (!capturedState && !capturedMount) {
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
// Wrap element with _LocalStateProvider
|
|
65
|
+
const providerProps = {};
|
|
66
|
+
if (capturedState) {
|
|
67
|
+
providerProps['statePath'] = capturedState.path;
|
|
68
|
+
providerProps['initialValue'] = capturedState.initial;
|
|
69
|
+
}
|
|
70
|
+
if (capturedMount) {
|
|
71
|
+
providerProps['onMountAction'] = capturedMount;
|
|
72
|
+
}
|
|
73
|
+
const wrapper = {
|
|
74
|
+
type: '_LocalStateProvider',
|
|
75
|
+
props: providerProps,
|
|
76
|
+
children: [result.element],
|
|
77
|
+
};
|
|
78
|
+
// Attach the local state to the spec's state tree
|
|
79
|
+
// The render() function will collect this via a special marker
|
|
80
|
+
if (capturedState) {
|
|
81
|
+
wrapper._localStateRegistration = {
|
|
82
|
+
path: capturedState.path,
|
|
83
|
+
initial: capturedState.initial,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
...result,
|
|
88
|
+
element: wrapper,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=component.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.mjs","sourceRoot":"","sources":["../../src/lib/sdui/component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,IAAI,UAAU,GAAG,CAAC,CAAC;AACnB,SAAS,UAAU;IACjB,OAAO,QAAQ,CAAC,EAAE,UAAU,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;AAC1E,CAAC;AAED,8BAA8B;AAC9B,MAAM,UAAU,eAAe;IAC7B,UAAU,GAAG,CAAC,CAAC;AACjB,CAAC;AAuBD,SAAS,gBAAgB,CAAC,QAAgB;IACxC,MAAM,OAAO,GAAyB;QACpC,GAAG,CAAC,OAAO,EAAE,IAAI;YACf,IAAI,IAAI,KAAK,OAAO;gBAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC;YACtD,IAAI,IAAI,KAAK,OAAO;gBAAE,OAAO,QAAQ,CAAC;YACtC,IAAI,IAAI,KAAK,QAAQ;gBAAE,OAAO,QAAQ,CAAC;YACvC,IAAI,IAAI,KAAK,QAAQ;gBAAE,OAAO,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;YAC3D,IAAI,IAAI,KAAK,MAA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