@rippling/rippling-sdk 0.2.0-alpha.36 → 0.2.0-alpha.38
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 +7 -1
- package/client.d.mts.map +1 -1
- package/client.d.ts +7 -1
- package/client.d.ts.map +1 -1
- package/client.js +7 -1
- package/client.js.map +1 -1
- package/client.mjs +7 -1
- package/client.mjs.map +1 -1
- package/examples/manifest/dental-practice-management/dental-practice-management.ts +21 -34
- package/examples/manifest/gym-membership-management/gym-membership-management.ts +27 -38
- package/examples/manifest/gym-membership-management/manifest.json +1 -1
- package/examples/sdui/sdui-crud-todo/sdui-crud-todo.ts +3 -3
- package/examples/sdui/sdui-showcase/sdui-showcase.ts +6 -11
- package/examples/sdui/sdui-tab-multi-view/sdui-tab-multi-view.ts +14 -24
- package/examples/sdui/vote/vote.ts +7 -11
- package/internal/utils/log.d.mts.map +1 -1
- package/internal/utils/log.d.ts.map +1 -1
- package/internal/utils/log.js +2 -0
- package/internal/utils/log.js.map +1 -1
- package/internal/utils/log.mjs +2 -0
- package/internal/utils/log.mjs.map +1 -1
- package/lib/manifest/category.d.mts +4 -2
- package/lib/manifest/category.d.mts.map +1 -1
- package/lib/manifest/category.d.ts +4 -2
- package/lib/manifest/category.d.ts.map +1 -1
- package/lib/manifest/category.js +2 -2
- package/lib/manifest/category.js.map +1 -1
- package/lib/manifest/category.mjs +2 -2
- package/lib/manifest/category.mjs.map +1 -1
- package/lib/manifest/custom-object-field-section.d.mts +4 -0
- package/lib/manifest/custom-object-field-section.d.mts.map +1 -1
- package/lib/manifest/custom-object-field-section.d.ts +4 -0
- package/lib/manifest/custom-object-field-section.d.ts.map +1 -1
- package/lib/manifest/custom-object-field-section.js +6 -0
- package/lib/manifest/custom-object-field-section.js.map +1 -1
- package/lib/manifest/custom-object-field-section.mjs +6 -0
- package/lib/manifest/custom-object-field-section.mjs.map +1 -1
- package/lib/manifest/custom-object-page-layout.d.mts +23 -13
- package/lib/manifest/custom-object-page-layout.d.mts.map +1 -1
- package/lib/manifest/custom-object-page-layout.d.ts +23 -13
- package/lib/manifest/custom-object-page-layout.d.ts.map +1 -1
- package/lib/manifest/custom-object-page-layout.js +122 -9
- package/lib/manifest/custom-object-page-layout.js.map +1 -1
- package/lib/manifest/custom-object-page-layout.mjs +122 -9
- package/lib/manifest/custom-object-page-layout.mjs.map +1 -1
- package/lib/manifest/custom-object.d.mts +30 -1
- package/lib/manifest/custom-object.d.mts.map +1 -1
- package/lib/manifest/custom-object.d.ts +30 -1
- package/lib/manifest/custom-object.d.ts.map +1 -1
- package/lib/manifest/custom-object.js +15 -1
- package/lib/manifest/custom-object.js.map +1 -1
- package/lib/manifest/custom-object.mjs +15 -1
- package/lib/manifest/custom-object.mjs.map +1 -1
- package/lib/manifest/field.d.mts +25 -3
- package/lib/manifest/field.d.mts.map +1 -1
- package/lib/manifest/field.d.ts +25 -3
- package/lib/manifest/field.d.ts.map +1 -1
- package/lib/manifest/field.js +28 -2
- package/lib/manifest/field.js.map +1 -1
- package/lib/manifest/field.mjs +28 -2
- package/lib/manifest/field.mjs.map +1 -1
- package/lib/manifest/index.d.mts +1 -1
- package/lib/manifest/index.d.mts.map +1 -1
- package/lib/manifest/index.d.ts +1 -1
- package/lib/manifest/index.d.ts.map +1 -1
- package/lib/manifest/index.js.map +1 -1
- package/lib/manifest/index.mjs.map +1 -1
- package/lib/manifest/manifest-builder.d.mts +1 -1
- package/lib/manifest/manifest-builder.d.ts +1 -1
- package/lib/manifest/manifest-builder.js +1 -1
- package/lib/manifest/manifest-builder.mjs +1 -1
- package/lib/manifest/manifest-function.d.mts +8 -2
- package/lib/manifest/manifest-function.d.mts.map +1 -1
- package/lib/manifest/manifest-function.d.ts +8 -2
- package/lib/manifest/manifest-function.d.ts.map +1 -1
- package/lib/manifest/manifest-function.js +8 -2
- package/lib/manifest/manifest-function.js.map +1 -1
- package/lib/manifest/manifest-function.mjs +8 -2
- package/lib/manifest/manifest-function.mjs.map +1 -1
- package/lib/sdui/actions.d.mts.map +1 -1
- package/lib/sdui/actions.d.ts.map +1 -1
- package/lib/sdui/actions.js +23 -13
- package/lib/sdui/actions.js.map +1 -1
- package/lib/sdui/actions.mjs +23 -13
- package/lib/sdui/actions.mjs.map +1 -1
- package/lib/sdui/component.d.mts +28 -11
- package/lib/sdui/component.d.mts.map +1 -1
- package/lib/sdui/component.d.ts +28 -11
- package/lib/sdui/component.d.ts.map +1 -1
- package/lib/sdui/component.js +69 -36
- package/lib/sdui/component.js.map +1 -1
- package/lib/sdui/component.mjs +69 -36
- package/lib/sdui/component.mjs.map +1 -1
- package/lib/sdui/components.d.mts +1141 -132
- package/lib/sdui/components.d.mts.map +1 -1
- package/lib/sdui/components.d.ts +1141 -132
- package/lib/sdui/components.d.ts.map +1 -1
- package/lib/sdui/components.js +834 -206
- package/lib/sdui/components.js.map +1 -1
- package/lib/sdui/components.mjs +830 -203
- package/lib/sdui/components.mjs.map +1 -1
- package/lib/sdui/directives.d.mts.map +1 -1
- package/lib/sdui/directives.d.ts.map +1 -1
- package/lib/sdui/directives.js +4 -1
- package/lib/sdui/directives.js.map +1 -1
- package/lib/sdui/directives.mjs +4 -1
- package/lib/sdui/directives.mjs.map +1 -1
- package/lib/sdui/index.d.mts +314 -261
- package/lib/sdui/index.d.mts.map +1 -1
- package/lib/sdui/index.d.ts +314 -261
- package/lib/sdui/index.d.ts.map +1 -1
- package/lib/sdui/index.js +255 -204
- package/lib/sdui/index.js.map +1 -1
- package/lib/sdui/index.mjs +128 -103
- package/lib/sdui/index.mjs.map +1 -1
- package/lib/sdui/propTypes.d.mts +6330 -0
- package/lib/sdui/propTypes.d.mts.map +1 -0
- package/lib/sdui/propTypes.d.ts +6330 -0
- package/lib/sdui/propTypes.d.ts.map +1 -0
- package/lib/sdui/propTypes.js +14 -0
- package/lib/sdui/propTypes.js.map +1 -0
- package/lib/sdui/propTypes.mjs +13 -0
- package/lib/sdui/propTypes.mjs.map +1 -0
- package/lib/sdui/render.d.mts +1 -1
- package/lib/sdui/render.d.mts.map +1 -1
- package/lib/sdui/render.d.ts +1 -1
- package/lib/sdui/render.d.ts.map +1 -1
- package/lib/sdui/render.js +11 -3
- package/lib/sdui/render.js.map +1 -1
- package/lib/sdui/render.mjs +11 -3
- package/lib/sdui/render.mjs.map +1 -1
- package/lib/sdui/state.d.mts.map +1 -1
- package/lib/sdui/state.d.ts.map +1 -1
- package/lib/sdui/state.js +3 -1
- package/lib/sdui/state.js.map +1 -1
- package/lib/sdui/state.mjs +3 -1
- package/lib/sdui/state.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/company-legal-entities.d.mts +180 -0
- package/resources/company-legal-entities.d.mts.map +1 -0
- package/resources/company-legal-entities.d.ts +180 -0
- package/resources/company-legal-entities.d.ts.map +1 -0
- package/resources/company-legal-entities.js +30 -0
- package/resources/company-legal-entities.js.map +1 -0
- package/resources/company-legal-entities.mjs +26 -0
- package/resources/company-legal-entities.mjs.map +1 -0
- package/resources/earning-types.d.mts +1 -6
- package/resources/earning-types.d.mts.map +1 -1
- package/resources/earning-types.d.ts +1 -6
- package/resources/earning-types.d.ts.map +1 -1
- package/resources/earning-types.js +1 -1
- package/resources/earning-types.mjs +1 -1
- package/resources/earnings-inputs.d.mts +1 -1
- package/resources/earnings-inputs.d.ts +1 -1
- package/resources/earnings-inputs.js +1 -1
- package/resources/earnings-inputs.mjs +1 -1
- package/resources/index.d.mts +2 -1
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +2 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +5 -3
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +2 -1
- 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/payroll-runs/index.d.mts +3 -0
- package/resources/payroll-runs/index.d.mts.map +1 -0
- package/resources/payroll-runs/index.d.ts +3 -0
- package/resources/payroll-runs/index.d.ts.map +1 -0
- package/resources/payroll-runs/index.js +9 -0
- package/resources/payroll-runs/index.js.map +1 -0
- package/resources/payroll-runs/index.mjs +4 -0
- package/resources/payroll-runs/index.mjs.map +1 -0
- package/resources/payroll-runs/payroll-runs.d.mts +199 -0
- package/resources/payroll-runs/payroll-runs.d.mts.map +1 -0
- package/resources/payroll-runs/payroll-runs.d.ts +199 -0
- package/resources/payroll-runs/payroll-runs.d.ts.map +1 -0
- package/resources/payroll-runs/payroll-runs.js +40 -0
- package/resources/payroll-runs/payroll-runs.js.map +1 -0
- package/resources/payroll-runs/payroll-runs.mjs +35 -0
- package/resources/payroll-runs/payroll-runs.mjs.map +1 -0
- package/resources/payroll-runs/worker-payroll-records.d.mts +200 -0
- package/resources/payroll-runs/worker-payroll-records.d.mts.map +1 -0
- package/resources/payroll-runs/worker-payroll-records.d.ts +200 -0
- package/resources/payroll-runs/worker-payroll-records.d.ts.map +1 -0
- package/resources/payroll-runs/worker-payroll-records.js +23 -0
- package/resources/payroll-runs/worker-payroll-records.js.map +1 -0
- package/resources/payroll-runs/worker-payroll-records.mjs +19 -0
- package/resources/payroll-runs/worker-payroll-records.mjs.map +1 -0
- package/resources/payroll-runs.d.mts +1 -194
- package/resources/payroll-runs.d.mts.map +1 -1
- package/resources/payroll-runs.d.ts +1 -194
- package/resources/payroll-runs.d.ts.map +1 -1
- package/resources/payroll-runs.js +2 -28
- package/resources/payroll-runs.js.map +1 -1
- package/resources/payroll-runs.mjs +1 -26
- package/resources/payroll-runs.mjs.map +1 -1
- package/src/client.ts +27 -7
- package/src/internal/utils/log.ts +2 -0
- package/src/lib/manifest/category.ts +7 -5
- package/src/lib/manifest/custom-object-field-section.ts +7 -0
- package/src/lib/manifest/custom-object-page-layout.ts +225 -18
- package/src/lib/manifest/custom-object.ts +30 -1
- package/src/lib/manifest/field.ts +29 -3
- package/src/lib/manifest/index.ts +2 -0
- package/src/lib/manifest/manifest-builder.ts +1 -1
- package/src/lib/manifest/manifest-function.ts +8 -2
- package/src/lib/sdui/actions.ts +23 -10
- package/src/lib/sdui/component.ts +84 -44
- package/src/lib/sdui/components.ts +1627 -212
- package/src/lib/sdui/directives.ts +4 -1
- package/src/lib/sdui/index.ts +565 -200
- package/src/lib/sdui/propTypes.ts +8470 -0
- package/src/lib/sdui/render.ts +13 -5
- package/src/lib/sdui/state.ts +8 -2
- package/src/resources/company-legal-entities.ts +237 -0
- package/src/resources/earning-types.ts +1 -7
- package/src/resources/earnings-inputs.ts +1 -1
- package/src/resources/index.ts +8 -1
- package/src/resources/legal-entities.ts +1 -1
- package/src/resources/payroll-runs/index.ts +15 -0
- package/src/resources/payroll-runs/payroll-runs.ts +270 -0
- package/src/resources/payroll-runs/worker-payroll-records.ts +255 -0
- package/src/resources/payroll-runs.ts +1 -249
- 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
|
@@ -2,8 +2,14 @@
|
|
|
2
2
|
* Defines a serverless function and registers it with the manifest.
|
|
3
3
|
*
|
|
4
4
|
* A `ManifestFunction` packages TypeScript handler code that runs on Rippling's
|
|
5
|
-
* serverless infrastructure.
|
|
6
|
-
*
|
|
5
|
+
* serverless infrastructure. The handler must export `onRipplingEvent`.
|
|
6
|
+
*
|
|
7
|
+
* Functions have two primary uses:
|
|
8
|
+
* 1. **Authoring SDUI for Custom Apps** — the function returns an SDUI spec
|
|
9
|
+
* (built with `@rippling/sdui-builder`) that renders as a page tab. Wrap the
|
|
10
|
+
* function in an {@link SduiPage} and reference it from an {@link App}.
|
|
11
|
+
* 2. **Workflow / event handlers** — functions invoked from rules, automations,
|
|
12
|
+
* or callbacks that do not render UI.
|
|
7
13
|
*
|
|
8
14
|
* This class is named `ManifestFunction` to avoid collision with the JavaScript
|
|
9
15
|
* built-in `Function`. It is also re-exported as `Function` from the barrel for
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest-function.mjs","sourceRoot":"","sources":["../../src/lib/manifest/manifest-function.ts"],"names":[],"mappings":"AAkEA
|
|
1
|
+
{"version":3,"file":"manifest-function.mjs","sourceRoot":"","sources":["../../src/lib/manifest/manifest-function.ts"],"names":[],"mappings":"AAkEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,OAAO,gBAAgB;IAU3B;;;OAGG;IACH,YAAY,KAAoB,EAAE,KAA4B;QAC5D,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;QAC9B,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,WAAW,IAAI,EAAE,CAAC;QAC5C,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,YAAY,CAAC;QACxC,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC,iBAAiB,CAAC;QAClD,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;YAClB,IAAI,CAAC,kBAAkB,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,kBAAkB,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;QAC3F,CAAC;QACD,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC,cAAc,CAAC;QAC5C,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC;QACvC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACH,MAAM;QACJ,MAAM,SAAS,GAAwB;YACrC,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,IAAI,CAAC,KAAK;YAChB,QAAQ,EAAE,IAAI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QAAQ,CAAC,SAAS,SAAoB,GAAG,aAAa,CAErE;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CAExD;AAED,wBAAgB,UAAU,IAAI,aAAa,CAE1C"}
|
|
@@ -1 +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,
|
|
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,CAO5F;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,aAAa,CAKlE;AAED,wBAAgB,YAAY,CAC1B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,aAAa,CAiBf;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"}
|
package/lib/sdui/actions.js
CHANGED
|
@@ -14,25 +14,35 @@ function set(ref, value) {
|
|
|
14
14
|
return { action: 'setState', params: { statePath: (0, state_1.extractPath)(ref), value } };
|
|
15
15
|
}
|
|
16
16
|
function push(ref, value, opts) {
|
|
17
|
-
const params = {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const params = {
|
|
18
|
+
statePath: (0, state_1.extractPath)(ref),
|
|
19
|
+
value,
|
|
20
|
+
...(opts?.clear ? { clearStatePath: (0, state_1.extractPath)(opts.clear) } : {}),
|
|
21
|
+
};
|
|
21
22
|
return { action: 'pushState', params };
|
|
22
23
|
}
|
|
23
24
|
function remove(ref, index) {
|
|
24
|
-
return {
|
|
25
|
+
return {
|
|
26
|
+
action: 'removeState',
|
|
27
|
+
params: { statePath: (0, state_1.extractPath)(ref), index },
|
|
28
|
+
};
|
|
25
29
|
}
|
|
26
30
|
function callFunction(functionId, action, opts) {
|
|
27
31
|
const { responsePath, onSuccess, onError, ...rest } = opts || {};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
// Spread rest FIRST so explicit functionId/action always win if opts
|
|
33
|
+
// happens to carry colliding keys.
|
|
34
|
+
const params = {
|
|
35
|
+
...rest,
|
|
36
|
+
functionId,
|
|
37
|
+
action,
|
|
38
|
+
...(responsePath !== undefined ? { responsePath } : {}),
|
|
39
|
+
};
|
|
40
|
+
const binding = {
|
|
41
|
+
action: 'triggerFunction',
|
|
42
|
+
params,
|
|
43
|
+
...(onSuccess ? { onSuccess: onSuccess } : {}),
|
|
44
|
+
...(onError ? { onError: onError } : {}),
|
|
45
|
+
};
|
|
36
46
|
return binding;
|
|
37
47
|
}
|
|
38
48
|
function nav(config) {
|
package/lib/sdui/actions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../src/lib/sdui/actions.ts"],"names":[],"mappings":";;AASA,kBAEC;AAED,
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../src/lib/sdui/actions.ts"],"names":[],"mappings":";;AASA,kBAEC;AAED,oBAOC;AAED,wBAKC;AAED,oCAqBC;AAED,kBAEC;AAED,wBAEC;AAED,4BAEC;AAED,8BAEC;AAED,gCAEC;AAtED,sCAAsC;AAStC,SAAgB,GAAG,CAAC,GAAY,EAAE,KAAc;IAC9C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE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C,EAAE,OAAO,EAAE,OAAwB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC1D,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAgB,GAAG,CAAC,MAAgD;IAClE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAChD,CAAC;AAED,SAAgB,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"}
|
package/lib/sdui/actions.mjs
CHANGED
|
@@ -3,25 +3,35 @@ export function set(ref, value) {
|
|
|
3
3
|
return { action: 'setState', params: { statePath: extractPath(ref), value } };
|
|
4
4
|
}
|
|
5
5
|
export function push(ref, value, opts) {
|
|
6
|
-
const params = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const params = {
|
|
7
|
+
statePath: extractPath(ref),
|
|
8
|
+
value,
|
|
9
|
+
...(opts?.clear ? { clearStatePath: extractPath(opts.clear) } : {}),
|
|
10
|
+
};
|
|
10
11
|
return { action: 'pushState', params };
|
|
11
12
|
}
|
|
12
13
|
export function remove(ref, index) {
|
|
13
|
-
return {
|
|
14
|
+
return {
|
|
15
|
+
action: 'removeState',
|
|
16
|
+
params: { statePath: extractPath(ref), index },
|
|
17
|
+
};
|
|
14
18
|
}
|
|
15
19
|
export function callFunction(functionId, action, opts) {
|
|
16
20
|
const { responsePath, onSuccess, onError, ...rest } = opts || {};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
// Spread rest FIRST so explicit functionId/action always win if opts
|
|
22
|
+
// happens to carry colliding keys.
|
|
23
|
+
const params = {
|
|
24
|
+
...rest,
|
|
25
|
+
functionId,
|
|
26
|
+
action,
|
|
27
|
+
...(responsePath !== undefined ? { responsePath } : {}),
|
|
28
|
+
};
|
|
29
|
+
const binding = {
|
|
30
|
+
action: 'triggerFunction',
|
|
31
|
+
params,
|
|
32
|
+
...(onSuccess ? { onSuccess: onSuccess } : {}),
|
|
33
|
+
...(onError ? { onError: onError } : {}),
|
|
34
|
+
};
|
|
25
35
|
return binding;
|
|
26
36
|
}
|
|
27
37
|
export function nav(config) {
|
package/lib/sdui/actions.mjs.map
CHANGED
|
@@ -1 +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,
|
|
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,EAA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,EAAE,OAAO,EAAE,OAAwB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC1D,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,MAAgD;IAClE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,OAAe,EAAE,OAAe;IACrD,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,SAAS,GAAG,iBAAiB;IACpD,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,EAAE,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,OAAe;IACvC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;AAClC,CAAC"}
|
package/lib/sdui/component.d.mts
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* component() — creates a stateful component boundary.
|
|
3
3
|
*
|
|
4
|
-
* Provides ctx.
|
|
5
|
-
*
|
|
4
|
+
* Provides ctx.localState (scoped local state slot) and ctx.onMount (an
|
|
5
|
+
* action that fires once when the component mounts on the client). The
|
|
6
|
+
* runtime handles state setup and mount firing; consumers don't need to
|
|
7
|
+
* know how the wrapping is implemented.
|
|
8
|
+
*
|
|
9
|
+
* NOTE: these are NOT React hooks. The factory runs ONCE at spec-build
|
|
10
|
+
* time, producing a JSON description of the UI. `localState` returns a
|
|
11
|
+
* path-builder proxy (not a [value, setter] tuple); `onMount` registers
|
|
12
|
+
* a JSON action that fires on first client render (not an effect that
|
|
13
|
+
* re-runs).
|
|
6
14
|
*
|
|
7
15
|
* Usage:
|
|
8
16
|
* function MembersGrid(props) {
|
|
9
17
|
* return component((ctx) => {
|
|
10
|
-
* const local = ctx.
|
|
11
|
-
* ctx.
|
|
12
|
-
* return { element: DataGrid({ ... })
|
|
18
|
+
* const local = ctx.localState({ data: [], loading: true })
|
|
19
|
+
* ctx.onMount(fetchAction)
|
|
20
|
+
* return { element: DataGrid({ ... }) }
|
|
13
21
|
* })
|
|
14
22
|
* }
|
|
15
23
|
*/
|
|
16
|
-
import type { SpecNode } from "./components.mjs";
|
|
17
24
|
import type { ActionBinding } from "./actions.mjs";
|
|
25
|
+
import type { SpecNode } from "./components.mjs";
|
|
18
26
|
export declare function _resetIdCounter(): void;
|
|
19
27
|
export interface StateScope {
|
|
20
28
|
/** Read state value: { $state: "/auto_xxx/field" } */
|
|
@@ -27,14 +35,23 @@ export interface StateScope {
|
|
|
27
35
|
readonly $path: string;
|
|
28
36
|
}
|
|
29
37
|
interface ComponentContext {
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Declare a scoped local state slot. Returns a path-builder proxy whose
|
|
40
|
+
* property accesses produce `{ $state: '/path' }` references for reading
|
|
41
|
+
* and `.$bind` for two-way binding. Not a React hook — runs once when
|
|
42
|
+
* the factory is invoked, never returns `[value, setter]`.
|
|
43
|
+
*/
|
|
44
|
+
localState<T extends Record<string, unknown>>(initial: T): StateScope;
|
|
45
|
+
/**
|
|
46
|
+
* Register a JSON action to fire once when the component mounts on the
|
|
47
|
+
* client. Not a React effect — does not re-run, has no dependency
|
|
48
|
+
* tracking. Pass an `ActionBinding` (e.g. from `set(...)`, `callFunction(...)`)
|
|
49
|
+
* or an array of them.
|
|
50
|
+
*/
|
|
51
|
+
onMount(action: ActionBinding | ActionBinding[]): void;
|
|
34
52
|
}
|
|
35
53
|
interface ComponentResult {
|
|
36
54
|
element: SpecNode;
|
|
37
|
-
[key: string]: any;
|
|
38
55
|
}
|
|
39
56
|
export declare function component(factory: (ctx: ComponentContext) => ComponentResult): ComponentResult;
|
|
40
57
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.mts","sourceRoot":"","sources":["../../src/lib/sdui/component.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"component.d.mts","sourceRoot":"","sources":["../../src/lib/sdui/component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;OAEI,KAAK,EAAE,aAAa,EAAE;OACtB,KAAK,EAAE,QAAQ,EAAE;AAaxB,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;;;;;OAKG;IACH,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,UAAU,CAAC;IAEtE;;;;;OAKG;IACH,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,EAAE,GAAG,IAAI,CAAC;CACxD;AAED,UAAU,eAAe;IACvB,OAAO,EAAE,QAAQ,CAAC;CACnB;AAkBD,wBAAgB,SAAS,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,eAAe,GAAG,eAAe,CAwE9F"}
|
package/lib/sdui/component.d.ts
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* component() — creates a stateful component boundary.
|
|
3
3
|
*
|
|
4
|
-
* Provides ctx.
|
|
5
|
-
*
|
|
4
|
+
* Provides ctx.localState (scoped local state slot) and ctx.onMount (an
|
|
5
|
+
* action that fires once when the component mounts on the client). The
|
|
6
|
+
* runtime handles state setup and mount firing; consumers don't need to
|
|
7
|
+
* know how the wrapping is implemented.
|
|
8
|
+
*
|
|
9
|
+
* NOTE: these are NOT React hooks. The factory runs ONCE at spec-build
|
|
10
|
+
* time, producing a JSON description of the UI. `localState` returns a
|
|
11
|
+
* path-builder proxy (not a [value, setter] tuple); `onMount` registers
|
|
12
|
+
* a JSON action that fires on first client render (not an effect that
|
|
13
|
+
* re-runs).
|
|
6
14
|
*
|
|
7
15
|
* Usage:
|
|
8
16
|
* function MembersGrid(props) {
|
|
9
17
|
* return component((ctx) => {
|
|
10
|
-
* const local = ctx.
|
|
11
|
-
* ctx.
|
|
12
|
-
* return { element: DataGrid({ ... })
|
|
18
|
+
* const local = ctx.localState({ data: [], loading: true })
|
|
19
|
+
* ctx.onMount(fetchAction)
|
|
20
|
+
* return { element: DataGrid({ ... }) }
|
|
13
21
|
* })
|
|
14
22
|
* }
|
|
15
23
|
*/
|
|
16
|
-
import type { SpecNode } from "./components.js";
|
|
17
24
|
import type { ActionBinding } from "./actions.js";
|
|
25
|
+
import type { SpecNode } from "./components.js";
|
|
18
26
|
export declare function _resetIdCounter(): void;
|
|
19
27
|
export interface StateScope {
|
|
20
28
|
/** Read state value: { $state: "/auto_xxx/field" } */
|
|
@@ -27,14 +35,23 @@ export interface StateScope {
|
|
|
27
35
|
readonly $path: string;
|
|
28
36
|
}
|
|
29
37
|
interface ComponentContext {
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Declare a scoped local state slot. Returns a path-builder proxy whose
|
|
40
|
+
* property accesses produce `{ $state: '/path' }` references for reading
|
|
41
|
+
* and `.$bind` for two-way binding. Not a React hook — runs once when
|
|
42
|
+
* the factory is invoked, never returns `[value, setter]`.
|
|
43
|
+
*/
|
|
44
|
+
localState<T extends Record<string, unknown>>(initial: T): StateScope;
|
|
45
|
+
/**
|
|
46
|
+
* Register a JSON action to fire once when the component mounts on the
|
|
47
|
+
* client. Not a React effect — does not re-run, has no dependency
|
|
48
|
+
* tracking. Pass an `ActionBinding` (e.g. from `set(...)`, `callFunction(...)`)
|
|
49
|
+
* or an array of them.
|
|
50
|
+
*/
|
|
51
|
+
onMount(action: ActionBinding | ActionBinding[]): void;
|
|
34
52
|
}
|
|
35
53
|
interface ComponentResult {
|
|
36
54
|
element: SpecNode;
|
|
37
|
-
[key: string]: any;
|
|
38
55
|
}
|
|
39
56
|
export declare function component(factory: (ctx: ComponentContext) => ComponentResult): ComponentResult;
|
|
40
57
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/lib/sdui/component.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/lib/sdui/component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;OAEI,KAAK,EAAE,aAAa,EAAE;OACtB,KAAK,EAAE,QAAQ,EAAE;AAaxB,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;;;;;OAKG;IACH,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,UAAU,CAAC;IAEtE;;;;;OAKG;IACH,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,EAAE,GAAG,IAAI,CAAC;CACxD;AAED,UAAU,eAAe;IACvB,OAAO,EAAE,QAAQ,CAAC;CACnB;AAkBD,wBAAgB,SAAS,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,eAAe,GAAG,eAAe,CAwE9F"}
|
package/lib/sdui/component.js
CHANGED
|
@@ -2,15 +2,23 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* component() — creates a stateful component boundary.
|
|
4
4
|
*
|
|
5
|
-
* Provides ctx.
|
|
6
|
-
*
|
|
5
|
+
* Provides ctx.localState (scoped local state slot) and ctx.onMount (an
|
|
6
|
+
* action that fires once when the component mounts on the client). The
|
|
7
|
+
* runtime handles state setup and mount firing; consumers don't need to
|
|
8
|
+
* know how the wrapping is implemented.
|
|
9
|
+
*
|
|
10
|
+
* NOTE: these are NOT React hooks. The factory runs ONCE at spec-build
|
|
11
|
+
* time, producing a JSON description of the UI. `localState` returns a
|
|
12
|
+
* path-builder proxy (not a [value, setter] tuple); `onMount` registers
|
|
13
|
+
* a JSON action that fires on first client render (not an effect that
|
|
14
|
+
* re-runs).
|
|
7
15
|
*
|
|
8
16
|
* Usage:
|
|
9
17
|
* function MembersGrid(props) {
|
|
10
18
|
* return component((ctx) => {
|
|
11
|
-
* const local = ctx.
|
|
12
|
-
* ctx.
|
|
13
|
-
* return { element: DataGrid({ ... })
|
|
19
|
+
* const local = ctx.localState({ data: [], loading: true })
|
|
20
|
+
* ctx.onMount(fetchAction)
|
|
21
|
+
* return { element: DataGrid({ ... }) }
|
|
14
22
|
* })
|
|
15
23
|
* }
|
|
16
24
|
*/
|
|
@@ -18,8 +26,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
26
|
exports._resetIdCounter = _resetIdCounter;
|
|
19
27
|
exports.component = component;
|
|
20
28
|
let _idCounter = 0;
|
|
29
|
+
// Counter-only IDs (no Date.now()) so the same factory body produces the
|
|
30
|
+
// same paths across runs. The counter is monotonic per process; calling
|
|
31
|
+
// `_resetIdCounter()` (tests only) brings it back to 0 so snapshot tests
|
|
32
|
+
// stay stable.
|
|
21
33
|
function generateId() {
|
|
22
|
-
|
|
34
|
+
_idCounter += 1;
|
|
35
|
+
return `auto_${_idCounter.toString(36)}`;
|
|
23
36
|
}
|
|
24
37
|
// Reset counter (for testing)
|
|
25
38
|
function _resetIdCounter() {
|
|
@@ -45,51 +58,71 @@ function createScopeProxy(basePath) {
|
|
|
45
58
|
return new Proxy({}, handler);
|
|
46
59
|
}
|
|
47
60
|
function component(factory) {
|
|
48
|
-
|
|
49
|
-
|
|
61
|
+
const states = [];
|
|
62
|
+
const mountActions = [];
|
|
50
63
|
const ctx = {
|
|
51
|
-
|
|
64
|
+
localState(initial) {
|
|
52
65
|
const path = `/${generateId()}`;
|
|
53
|
-
|
|
66
|
+
states.push({ path, initial });
|
|
54
67
|
return createScopeProxy(path);
|
|
55
68
|
},
|
|
56
|
-
|
|
57
|
-
|
|
69
|
+
onMount(action) {
|
|
70
|
+
mountActions.push(action);
|
|
58
71
|
},
|
|
59
72
|
};
|
|
60
73
|
const result = factory(ctx);
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
const capturedMount = mountAction;
|
|
64
|
-
// If no local state and no effects, return as-is
|
|
65
|
-
if (!capturedState && !capturedMount) {
|
|
74
|
+
// No state, no effects → return as-is.
|
|
75
|
+
if (states.length === 0 && mountActions.length === 0) {
|
|
66
76
|
return result;
|
|
67
77
|
}
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
78
|
+
// Collapse zero/one/many mount actions for the single onMountAction slot
|
|
79
|
+
// on the innermost wrapper.
|
|
80
|
+
let combinedMount;
|
|
81
|
+
if (mountActions.length === 1) {
|
|
82
|
+
combinedMount = mountActions[0];
|
|
73
83
|
}
|
|
74
|
-
if (
|
|
75
|
-
|
|
84
|
+
else if (mountActions.length > 1) {
|
|
85
|
+
combinedMount = mountActions.flatMap((a) => (Array.isArray(a) ? a : [a]));
|
|
76
86
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (capturedState) {
|
|
85
|
-
wrapper._localStateRegistration = {
|
|
86
|
-
path: capturedState.path,
|
|
87
|
-
initial: capturedState.initial,
|
|
87
|
+
let wrapped = result.element;
|
|
88
|
+
if (states.length === 0) {
|
|
89
|
+
// Mount-only: a single state-provider wrapper carries onMountAction.
|
|
90
|
+
wrapped = {
|
|
91
|
+
type: '_LocalStateProvider',
|
|
92
|
+
props: combinedMount ? { onMountAction: combinedMount } : {},
|
|
93
|
+
children: [wrapped],
|
|
88
94
|
};
|
|
89
95
|
}
|
|
96
|
+
else {
|
|
97
|
+
// One state-provider wrapper per localState() call, nested
|
|
98
|
+
// innermost-first. Mount actions attach to the innermost wrapper so
|
|
99
|
+
// every state slot is initialized before any action fires.
|
|
100
|
+
for (let i = states.length - 1; i >= 0; i--) {
|
|
101
|
+
const state = states[i];
|
|
102
|
+
if (state) {
|
|
103
|
+
const isInnermost = i === states.length - 1;
|
|
104
|
+
const props = {
|
|
105
|
+
statePath: state.path,
|
|
106
|
+
initialValue: state.initial,
|
|
107
|
+
...(isInnermost && combinedMount ? { onMountAction: combinedMount } : {}),
|
|
108
|
+
};
|
|
109
|
+
const wrapper = {
|
|
110
|
+
type: '_LocalStateProvider',
|
|
111
|
+
props,
|
|
112
|
+
children: [wrapped],
|
|
113
|
+
};
|
|
114
|
+
// render() picks up this marker to populate spec.state.
|
|
115
|
+
wrapper._localStateRegistration = {
|
|
116
|
+
path: state.path,
|
|
117
|
+
initial: state.initial,
|
|
118
|
+
};
|
|
119
|
+
wrapped = wrapper;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
90
123
|
return {
|
|
91
124
|
...result,
|
|
92
|
-
element:
|
|
125
|
+
element: wrapped,
|
|
93
126
|
};
|
|
94
127
|
}
|
|
95
128
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../src/lib/sdui/component.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../src/lib/sdui/component.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;AAgBH,0CAEC;AAiDD,8BAwEC;AAtID,IAAI,UAAU,GAAG,CAAC,CAAC;AACnB,yEAAyE;AACzE,wEAAwE;AACxE,yEAAyE;AACzE,eAAe;AACf,SAAS,UAAU;IACjB,UAAU,IAAI,CAAC,CAAC;IAChB,OAAO,QAAQ,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;AAC3C,CAAC;AAED,8BAA8B;AAC9B,SAAgB,eAAe;IAC7B,UAAU,GAAG,CAAC,CAAC;AACjB,CAAC;AAiCD,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,MAAM,CAAC,WAAW;gBAAE,OAAO,GAAG,EAAE,CAAC,UAAU,QAAQ,EAAE,CAAC;YAEnE,MAAM,SAAS,GAAG,GAAG,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YAChD,OAAO,gBAAgB,CAAC,SAAS,CAAC,CAAC;QACrC,CAAC;KACF,CAAC;IACF,OAAO,IAAI,KAAK,CAAC,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
* component() — creates a stateful component boundary.
|
|
3
3
|
*
|
|
4
|
-
* Provides ctx.
|
|
5
|
-
*
|
|
4
|
+
* Provides ctx.localState (scoped local state slot) and ctx.onMount (an
|
|
5
|
+
* action that fires once when the component mounts on the client). The
|
|
6
|
+
* runtime handles state setup and mount firing; consumers don't need to
|
|
7
|
+
* know how the wrapping is implemented.
|
|
8
|
+
*
|
|
9
|
+
* NOTE: these are NOT React hooks. The factory runs ONCE at spec-build
|
|
10
|
+
* time, producing a JSON description of the UI. `localState` returns a
|
|
11
|
+
* path-builder proxy (not a [value, setter] tuple); `onMount` registers
|
|
12
|
+
* a JSON action that fires on first client render (not an effect that
|
|
13
|
+
* re-runs).
|
|
6
14
|
*
|
|
7
15
|
* Usage:
|
|
8
16
|
* function MembersGrid(props) {
|
|
9
17
|
* return component((ctx) => {
|
|
10
|
-
* const local = ctx.
|
|
11
|
-
* ctx.
|
|
12
|
-
* return { element: DataGrid({ ... })
|
|
18
|
+
* const local = ctx.localState({ data: [], loading: true })
|
|
19
|
+
* ctx.onMount(fetchAction)
|
|
20
|
+
* return { element: DataGrid({ ... }) }
|
|
13
21
|
* })
|
|
14
22
|
* }
|
|
15
23
|
*/
|
|
16
24
|
let _idCounter = 0;
|
|
25
|
+
// Counter-only IDs (no Date.now()) so the same factory body produces the
|
|
26
|
+
// same paths across runs. The counter is monotonic per process; calling
|
|
27
|
+
// `_resetIdCounter()` (tests only) brings it back to 0 so snapshot tests
|
|
28
|
+
// stay stable.
|
|
17
29
|
function generateId() {
|
|
18
|
-
|
|
30
|
+
_idCounter += 1;
|
|
31
|
+
return `auto_${_idCounter.toString(36)}`;
|
|
19
32
|
}
|
|
20
33
|
// Reset counter (for testing)
|
|
21
34
|
export function _resetIdCounter() {
|
|
@@ -41,51 +54,71 @@ function createScopeProxy(basePath) {
|
|
|
41
54
|
return new Proxy({}, handler);
|
|
42
55
|
}
|
|
43
56
|
export function component(factory) {
|
|
44
|
-
|
|
45
|
-
|
|
57
|
+
const states = [];
|
|
58
|
+
const mountActions = [];
|
|
46
59
|
const ctx = {
|
|
47
|
-
|
|
60
|
+
localState(initial) {
|
|
48
61
|
const path = `/${generateId()}`;
|
|
49
|
-
|
|
62
|
+
states.push({ path, initial });
|
|
50
63
|
return createScopeProxy(path);
|
|
51
64
|
},
|
|
52
|
-
|
|
53
|
-
|
|
65
|
+
onMount(action) {
|
|
66
|
+
mountActions.push(action);
|
|
54
67
|
},
|
|
55
68
|
};
|
|
56
69
|
const result = factory(ctx);
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
const capturedMount = mountAction;
|
|
60
|
-
// If no local state and no effects, return as-is
|
|
61
|
-
if (!capturedState && !capturedMount) {
|
|
70
|
+
// No state, no effects → return as-is.
|
|
71
|
+
if (states.length === 0 && mountActions.length === 0) {
|
|
62
72
|
return result;
|
|
63
73
|
}
|
|
64
|
-
//
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
74
|
+
// Collapse zero/one/many mount actions for the single onMountAction slot
|
|
75
|
+
// on the innermost wrapper.
|
|
76
|
+
let combinedMount;
|
|
77
|
+
if (mountActions.length === 1) {
|
|
78
|
+
combinedMount = mountActions[0];
|
|
69
79
|
}
|
|
70
|
-
if (
|
|
71
|
-
|
|
80
|
+
else if (mountActions.length > 1) {
|
|
81
|
+
combinedMount = mountActions.flatMap((a) => (Array.isArray(a) ? a : [a]));
|
|
72
82
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (capturedState) {
|
|
81
|
-
wrapper._localStateRegistration = {
|
|
82
|
-
path: capturedState.path,
|
|
83
|
-
initial: capturedState.initial,
|
|
83
|
+
let wrapped = result.element;
|
|
84
|
+
if (states.length === 0) {
|
|
85
|
+
// Mount-only: a single state-provider wrapper carries onMountAction.
|
|
86
|
+
wrapped = {
|
|
87
|
+
type: '_LocalStateProvider',
|
|
88
|
+
props: combinedMount ? { onMountAction: combinedMount } : {},
|
|
89
|
+
children: [wrapped],
|
|
84
90
|
};
|
|
85
91
|
}
|
|
92
|
+
else {
|
|
93
|
+
// One state-provider wrapper per localState() call, nested
|
|
94
|
+
// innermost-first. Mount actions attach to the innermost wrapper so
|
|
95
|
+
// every state slot is initialized before any action fires.
|
|
96
|
+
for (let i = states.length - 1; i >= 0; i--) {
|
|
97
|
+
const state = states[i];
|
|
98
|
+
if (state) {
|
|
99
|
+
const isInnermost = i === states.length - 1;
|
|
100
|
+
const props = {
|
|
101
|
+
statePath: state.path,
|
|
102
|
+
initialValue: state.initial,
|
|
103
|
+
...(isInnermost && combinedMount ? { onMountAction: combinedMount } : {}),
|
|
104
|
+
};
|
|
105
|
+
const wrapper = {
|
|
106
|
+
type: '_LocalStateProvider',
|
|
107
|
+
props,
|
|
108
|
+
children: [wrapped],
|
|
109
|
+
};
|
|
110
|
+
// render() picks up this marker to populate spec.state.
|
|
111
|
+
wrapper._localStateRegistration = {
|
|
112
|
+
path: state.path,
|
|
113
|
+
initial: state.initial,
|
|
114
|
+
};
|
|
115
|
+
wrapped = wrapper;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
86
119
|
return {
|
|
87
120
|
...result,
|
|
88
|
-
element:
|
|
121
|
+
element: wrapped,
|
|
89
122
|
};
|
|
90
123
|
}
|
|
91
124
|
//# sourceMappingURL=component.mjs.map
|