@ramesesinc/platform-core 0.1.9 → 0.1.11

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.
Files changed (76) hide show
  1. package/dist/components/action/DeleteData.d.ts +1 -0
  2. package/dist/components/action/DeleteData.js +16 -5
  3. package/dist/components/action/LookupPage.d.ts +2 -1
  4. package/dist/components/action/LookupPage.js +4 -3
  5. package/dist/components/action/Play.d.ts +6 -0
  6. package/dist/components/action/Play.js +40 -0
  7. package/dist/components/action/ProgressBar.d.ts +8 -0
  8. package/dist/components/action/ProgressBar.js +146 -0
  9. package/dist/components/action/ViewPage.d.ts +3 -1
  10. package/dist/components/action/ViewPage.js +22 -10
  11. package/dist/components/common/UIMenu.d.ts +1 -0
  12. package/dist/components/common/UIMenu.js +5 -3
  13. package/dist/components/index.d.ts +4 -1
  14. package/dist/components/index.js +4 -1
  15. package/dist/components/input/Combo.d.ts +21 -0
  16. package/dist/components/input/Combo.js +137 -0
  17. package/dist/components/input/DateField.js +7 -14
  18. package/dist/components/input/Text.d.ts +5 -0
  19. package/dist/components/input/Text.js +42 -7
  20. package/dist/components/input/YearPicker.js +3 -2
  21. package/dist/components/list/EditableMenu.d.ts +2 -0
  22. package/dist/components/list/EditableMenu.js +128 -0
  23. package/dist/components/list/TabMenu.js +2 -2
  24. package/dist/components/list/TreeMenu.js +35 -13
  25. package/dist/components/table/DataList.d.ts +1 -1
  26. package/dist/components/table/DataList.js +56 -29
  27. package/dist/components/table/DataTable.d.ts +2 -0
  28. package/dist/components/table/DataTable.js +31 -22
  29. package/dist/components/view/FilterView.js +1 -1
  30. package/dist/components/view/HtmlForm.js +12 -9
  31. package/dist/components/view/HtmlView.js +1 -1
  32. package/dist/components/view/PageView.d.ts +1 -0
  33. package/dist/components/view/PageView.js +38 -11
  34. package/dist/components/view/PopupView.d.ts +1 -0
  35. package/dist/components/view/PopupView.js +4 -4
  36. package/dist/components/view/RootView.d.ts +1 -0
  37. package/dist/components/view/RootView.js +18 -18
  38. package/dist/components/view/WizardView.d.ts +1 -1
  39. package/dist/components/view/WizardView.js +7 -25
  40. package/dist/core/AuthContext.js +1 -1
  41. package/dist/core/DynamicComponent.d.ts +2 -1
  42. package/dist/core/DynamicComponent.js +24 -2
  43. package/dist/core/Page.d.ts +1 -0
  44. package/dist/core/Page.js +6 -5
  45. package/dist/core/PageCache.d.ts +0 -2
  46. package/dist/core/PageCache.js +3 -8
  47. package/dist/core/PageContext.d.ts +1 -0
  48. package/dist/core/PageContext.js +16 -2
  49. package/dist/core/PageViewContext.d.ts +8 -2
  50. package/dist/core/PageViewContext.js +155 -86
  51. package/dist/core/Panel.js +34 -12
  52. package/dist/core/StepHandler.d.ts +1 -1
  53. package/dist/core/StepHandler.js +58 -21
  54. package/dist/index.css +98 -0
  55. package/dist/layouts/CardLayout.d.ts +2 -2
  56. package/dist/layouts/CardLayout.js +3 -4
  57. package/dist/layouts/HPanel.d.ts +2 -2
  58. package/dist/layouts/HPanel.js +1 -2
  59. package/dist/layouts/VPanel.d.ts +2 -2
  60. package/dist/layouts/VPanel.js +1 -2
  61. package/dist/layouts/index.d.ts +2 -3
  62. package/dist/layouts/index.js +2 -3
  63. package/dist/lib/utils/ExprUtil.js +18 -29
  64. package/dist/lib/utils/ResourceLoader.js +19 -7
  65. package/dist/lib/utils/SectionProvider.js +1 -1
  66. package/dist/lib/utils/initResourceLoader.d.ts +2 -0
  67. package/dist/lib/utils/initResourceLoader.js +64 -95
  68. package/dist/lib/utils/nunjucks.d.ts +2 -0
  69. package/dist/lib/utils/nunjucks.js +8 -0
  70. package/dist/templates/CrudFormTemplate.js +2 -3
  71. package/dist/templates/DataListTemplate.js +1 -1
  72. package/dist/templates/WizardTemplate.d.ts +3 -0
  73. package/dist/templates/WizardTemplate.js +17 -10
  74. package/package.json +1 -1
  75. package/dist/components/input/Select.d.ts +0 -14
  76. package/dist/components/input/Select.js +0 -40
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
3
+ import { createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, } from "react";
4
4
  /* ------------------ Global Stack ------------------ */
5
5
  const contextStack = [];
6
6
  /* ------------------ Context ------------------ */
@@ -17,13 +17,18 @@ const PageViewContext = createContext({
17
17
  getSelectedPage: () => null,
18
18
  pushPage: () => { },
19
19
  popPage: () => { },
20
- setSelectedPage: () => { },
21
20
  hasBackPage: () => false,
22
21
  isStandalone: () => false,
23
22
  hasSelectionHandling: () => false,
24
23
  setSelectionHandling: () => null,
25
24
  getOriginalLocationInfo: () => null,
26
25
  getEventHandler: () => null,
26
+ getUrl: () => "",
27
+ getPage: () => "",
28
+ getParams: () => ({}),
29
+ getSubPaths: () => [],
30
+ isRootView: () => false,
31
+ getPageChainInfo: () => ({ path: "", base: "", page: "", options: {}, params: {} }),
27
32
  });
28
33
  const usePageViewUI = () => {
29
34
  const propsRef = useRef({});
@@ -49,7 +54,7 @@ const usePageViewUI = () => {
49
54
  handler(e);
50
55
  }
51
56
  catch (err) {
52
- // do nothing: let the handler handle its own error
57
+ // do nothing: let the handler handle its own error
53
58
  }
54
59
  });
55
60
  };
@@ -57,13 +62,13 @@ const usePageViewUI = () => {
57
62
  if (name == null)
58
63
  return;
59
64
  propsRef.current[name] = value;
60
- if (String(autoPublish) === 'true') {
65
+ if (String(autoPublish) === "true") {
61
66
  notifyChange(name, value);
62
67
  }
63
68
  };
64
69
  const get = (name) => {
65
70
  var _a;
66
- const value = name == null ? null : (_a = propsRef.current[name]) !== null && _a !== void 0 ? _a : null;
71
+ const value = name == null ? null : ((_a = propsRef.current[name]) !== null && _a !== void 0 ? _a : null);
67
72
  return value;
68
73
  };
69
74
  const getTitle = () => {
@@ -114,40 +119,49 @@ export const PageViewProvider = ({ paths, handle, children, prefix = "page", eve
114
119
  paths.push(hash);
115
120
  }
116
121
  let [, ...anchors] = hash.split("#");
117
- anchors = anchors.slice(0, -1);
118
- if (anchors.length > 0) {
119
- finalBasePaths.push("#" + anchors.join("#"));
122
+ if (prefix === "root") {
123
+ // root level - no hash in base
124
+ // console.log("root finalBasePaths[0]", finalBasePaths[0]);
125
+ result.base = finalBasePaths[0]; // just pathname + query, no hash
126
+ result.path = finalBasePaths[0];
127
+ }
128
+ else {
129
+ // child levels - include anchors up to current paths level
130
+ anchors = anchors.slice(0, -1);
131
+ if (anchors.length > 0) {
132
+ finalBasePaths.push("#" + anchors.join("#"));
133
+ }
134
+ result.base = finalBasePaths.join("");
135
+ result.path = paths.join("");
120
136
  }
121
- result.base = finalBasePaths.join("");
122
- result.path = paths.join("");
123
137
  return result;
124
138
  }
125
139
  catch (err) {
126
140
  console.log("Error getting path location info:", err);
127
141
  return result;
128
142
  }
129
- }, []);
143
+ }, [prefix]);
130
144
  const originalLocInfo = useMemo(() => {
145
+ var _a;
131
146
  const [, selectedPath] = paths;
132
147
  const standalone = isStandalone();
133
- const chainInfo = { base: "", path: "", page: "" };
148
+ const chainInfo = { path: "", base: "", page: "", options: {}, params: {} };
134
149
  if (standalone) {
135
150
  chainInfo.path = selectedPath !== null && selectedPath !== void 0 ? selectedPath : "";
136
151
  chainInfo.page = chainInfo.path;
137
152
  }
138
153
  else {
139
- const loc = getLocationInfo();
154
+ const loc = (_a = getLocationInfo()) !== null && _a !== void 0 ? _a : { root: "", path: "", base: "" };
140
155
  chainInfo.base = loc.base;
141
156
  chainInfo.path = [loc.path, selectedPath].filter(Boolean).join("#");
142
157
  }
143
- // console.log("pageview original loc info ", chainInfo);
144
158
  return chainInfo;
145
159
  }, [paths, handle]);
146
160
  const [pageChain, setPageChain] = useState(() => {
147
161
  var _a;
148
162
  const [, selectedPath] = paths;
149
163
  const standalone = isStandalone();
150
- const chainInfo = { path: "", base: "", page: "", options: {} };
164
+ const chainInfo = { path: "", base: "", page: "", options: {}, params: {} };
151
165
  const result = { current: chainInfo, previous: null };
152
166
  if (standalone) {
153
167
  chainInfo.path = selectedPath !== null && selectedPath !== void 0 ? selectedPath : "";
@@ -168,67 +182,80 @@ export const PageViewProvider = ({ paths, handle, children, prefix = "page", eve
168
182
  useLayoutEffect(() => {
169
183
  handleRef.current = handle;
170
184
  }, [handle]);
171
- useEffect(() => {
172
- const standalone = isStandalone();
173
- // console.log("pageChain changed", uuid, standalone, pageChain);
174
- }, [pageChain]);
175
- const setSelectedPage = (page) => {
176
- const chainInfo = pageChain.current;
177
- const newChainInfo = Object.assign(Object.assign({}, chainInfo), { page });
178
- if (page == null || page === "") {
179
- // do nothing
180
- }
181
- else {
182
- newChainInfo.path = newChainInfo.base + "#" + page;
183
- newChainInfo.page = page;
184
- }
185
- pageChain.current = newChainInfo;
186
- };
185
+ // useEffect(() => {
186
+ // const standalone = isStandalone();
187
+ // console.log("pageChain changed", uuid, standalone, pageChain);
188
+ // }, [pageChain]);
187
189
  const setPage = (page, options = {}) => {
188
- var _a;
190
+ var _a, _b;
189
191
  if (page == null || page.trim() === "") {
190
192
  return;
191
193
  }
192
194
  const standalone = isStandalone();
193
195
  const pageOptions = options !== null && options !== void 0 ? options : {};
194
- const { mode = "default" } = pageOptions;
195
- const locInfo = getLocationInfo();
196
- const { current: currentChain, previous: previousChain } = pageChain;
197
- const newChainInfo = { path: "", base: "", page: "", options: pageOptions };
196
+ const { mode = "self" } = pageOptions;
197
+ const { previous: previousChain } = pageChain;
198
+ const newChainInfo = { path: "", base: "", page: "", options: pageOptions, params: {} };
198
199
  const newPageChain = { current: newChainInfo, previous: null };
199
- // console.log("setPage mode => ", { page, pageOptions });
200
200
  if (mode != null && mode === "window") {
201
+ if (!uuid.startsWith("root")) {
202
+ parentContext === null || parentContext === void 0 ? void 0 : parentContext.setPage(page, options);
203
+ return;
204
+ }
205
+ const locInfo = getLocationInfo();
201
206
  newChainInfo.page = page;
202
207
  newChainInfo.base = locInfo.root;
203
208
  newChainInfo.path = locInfo.root + "/" + page;
204
- newPageChain.previous = { current: currentChain, previous: previousChain };
209
+ const currentFullPath = window.location.pathname + window.location.search + window.location.hash;
210
+ const currentPageName = (_a = window.location.pathname.split("/").at(-1)) !== null && _a !== void 0 ? _a : "";
211
+ const previousChainInfo = {
212
+ path: currentFullPath,
213
+ base: locInfo.root,
214
+ page: currentPageName,
215
+ options: {},
216
+ params: {},
217
+ };
218
+ newPageChain.previous = { current: previousChainInfo, previous: previousChain };
205
219
  }
206
220
  else {
221
+ const currentUrl = getUrl();
207
222
  newChainInfo.page = page;
208
- newChainInfo.base = originalLocInfo.base;
209
- newChainInfo.path = [originalLocInfo.base, page].filter(Boolean).join("#");
223
+ newChainInfo.base = currentUrl;
224
+ newChainInfo.path = [currentUrl, page].filter(Boolean).join("#");
210
225
  }
211
226
  setPageChain((prev) => (Object.assign({}, newPageChain)));
212
- if (!standalone) {
213
- // console.log("setPage push state => ", { newChainInfo });
227
+ if (mode === "window") {
214
228
  history.pushState(null, "", newChainInfo.path);
215
229
  }
216
- (_a = handleRef.current) === null || _a === void 0 ? void 0 : _a.renderPage(page);
230
+ else if (!standalone) {
231
+ const currentPathname = window.location.pathname;
232
+ const expectedPathname = newChainInfo.path.split("#")[0].split("?")[0];
233
+ if (currentPathname === expectedPathname) {
234
+ history.pushState(null, "", newChainInfo.path);
235
+ }
236
+ }
237
+ (_b = handleRef.current) === null || _b === void 0 ? void 0 : _b.renderPage(page);
217
238
  };
218
239
  const pushPage = (page) => {
219
240
  var _a;
220
241
  if (page == null)
221
242
  return;
222
243
  const standalone = isStandalone();
223
- // console.log("pushPage (pageChain)", uuid, prefix, pageChain, standalone, parentContext);
224
244
  const { current: chainInfo, previous: prevChain } = pageChain;
225
- if (standalone && (chainInfo.path == null || chainInfo.path === "")) {
226
- Object.assign(chainInfo, { path: paths[0], base: "", page: paths[0] });
245
+ if (prefix === "root") {
246
+ setPage(page, { mode: "window" });
247
+ return;
227
248
  }
249
+ // if (standalone && (chainInfo.path == null || chainInfo.path === "")) {
250
+ // Object.assign(chainInfo, { path: paths[0], base: "", page: paths[0] });
251
+ // }
252
+ const loc = getLocationInfo();
228
253
  const newChainInfo = {
229
- path: [chainInfo.path, page].filter(Boolean).join("#"),
230
- base: chainInfo.path,
254
+ path: [loc.base, page].filter(Boolean).join("#"),
255
+ base: loc.base,
231
256
  page: page,
257
+ options: {},
258
+ params: {},
232
259
  };
233
260
  const newPageChain = {
234
261
  current: newChainInfo,
@@ -241,53 +268,57 @@ export const PageViewProvider = ({ paths, handle, children, prefix = "page", eve
241
268
  (_a = handleRef.current) === null || _a === void 0 ? void 0 : _a.renderPage(page);
242
269
  };
243
270
  const popPage = () => {
244
- var _a, _b, _c;
245
- // console.log("popPage (pageChain)", uuid, prefix, JSON.stringify(pageChain));
271
+ var _a, _b;
246
272
  const { previous: prevChain } = pageChain;
247
- if (prevChain == null) {
273
+ if (prevChain == null)
248
274
  return;
249
- }
250
275
  const standalone = isStandalone();
251
276
  const current = (_a = prevChain === null || prevChain === void 0 ? void 0 : prevChain.current) !== null && _a !== void 0 ? _a : {};
252
277
  const { path, options = {} } = current;
253
- if (path == null || path === "") {
278
+ if (path == null || path === "")
254
279
  return;
255
- }
256
- // extract page from path
257
- let page = "";
258
- if (prefix === "root") {
259
- let newPath = path.split("#")[0].split("?")[0];
260
- const idx = newPath.lastIndexOf("/");
261
- if (idx >= 0) {
262
- newPath = path.substring(idx + 1);
263
- // newPath = newPath.substring(idx + 1);
264
- }
265
- page = newPath;
266
- // console.log("popPage 1.3", uuid, page);
267
- }
268
- else {
269
- const [, ...anchors] = path.split("#");
270
- page = (_b = anchors.at(-1)) !== null && _b !== void 0 ? _b : "";
271
- // console.log("popPage 1.4", uuid, "page:", page, "path:", path);
272
- if (page === "") {
273
- // page = path;
274
- const withoutHash = path.split("#")[0];
275
- const idx = withoutHash.lastIndexOf("/");
276
- if (idx >= 0) {
277
- page = withoutHash.substring(idx + 1);
278
- }
279
- else {
280
- page = path;
281
- }
282
- }
283
- }
280
+ const loc = getLocationInfo();
284
281
  const newPageChain = Object.assign({}, prevChain);
285
282
  setPageChain(newPageChain);
286
283
  if (!standalone) {
287
- history.pushState(null, "", path);
284
+ history.pushState(null, "", newPageChain.current.path);
288
285
  }
289
- // console.log("popPage 2", uuid, page);
290
- (_c = handleRef.current) === null || _c === void 0 ? void 0 : _c.renderPage(page);
286
+ (_b = handleRef.current) === null || _b === void 0 ? void 0 : _b.renderPage(newPageChain.current.page);
287
+ // // extract page from path
288
+ // let page = "";
289
+ // if (prefix === "root") {
290
+ // let newPath = path.split("#")[0].split("?")[0];
291
+ // const idx = newPath.lastIndexOf("/");
292
+ // if (idx >= 0) {
293
+ // newPath = path.substring(idx + 1);
294
+ // }
295
+ // page = newPath;
296
+ // } else {
297
+ // const loc = getLocationInfo();
298
+ // // pop means go back to previous loc.base (one less anchor)
299
+ // const [, ...anchors] = loc.base.split("#");
300
+ // anchors.pop(); // remove last anchor
301
+ // page = anchors.at(-1) ?? "";
302
+ // if (page === "") {
303
+ // const withoutHash = path.split("#")[0];
304
+ // const idx = withoutHash.lastIndexOf("/");
305
+ // if (idx >= 0) {
306
+ // page = withoutHash.substring(idx + 1);
307
+ // } else {
308
+ // page = path;
309
+ // }
310
+ // }
311
+ // }
312
+ // const newPageChain = { ...prevChain } as PageChain;
313
+ // setPageChain(newPageChain);
314
+ // if (!standalone) {
315
+ // const loc = getLocationInfo();
316
+ // const [, ...anchors] = loc.base.split("#");
317
+ // anchors.pop();
318
+ // const newPath = [loc.base.split("#")[0], ...anchors].filter(Boolean).join("#");
319
+ // history.pushState(null, "", newPath);
320
+ // }
321
+ // handleRef.current?.renderPage(page);
291
322
  };
292
323
  const hasBackPage = () => {
293
324
  const { previous } = pageChain;
@@ -296,6 +327,35 @@ export const PageViewProvider = ({ paths, handle, children, prefix = "page", eve
296
327
  const { path } = previous.current;
297
328
  return path != null && path !== "";
298
329
  };
330
+ const getUrl = () => {
331
+ var _a, _b;
332
+ if (prefix === "root") {
333
+ const loc = getLocationInfo();
334
+ return loc.root + "/" + paths[0];
335
+ }
336
+ else {
337
+ const parentUrl = (_b = (_a = parentContext === null || parentContext === void 0 ? void 0 : parentContext.getUrl) === null || _a === void 0 ? void 0 : _a.call(parentContext)) !== null && _b !== void 0 ? _b : "";
338
+ const [currentPath] = paths;
339
+ return [parentUrl, currentPath].filter(Boolean).join("#");
340
+ }
341
+ };
342
+ const getSubPaths = () => {
343
+ const [, ...subPaths] = paths !== null && paths !== void 0 ? paths : [];
344
+ return subPaths;
345
+ };
346
+ const getPage = () => {
347
+ var _a, _b;
348
+ return (_b = (_a = pageChain.current) === null || _a === void 0 ? void 0 : _a.page) !== null && _b !== void 0 ? _b : "";
349
+ };
350
+ const getParams = () => {
351
+ const url = getUrl();
352
+ const urlParams = new URLSearchParams(url.split("?")[1]);
353
+ const params = {};
354
+ urlParams.forEach((value, key) => {
355
+ params[key] = value;
356
+ });
357
+ return params;
358
+ };
299
359
  const getInfo = () => {
300
360
  var _a;
301
361
  return {
@@ -307,6 +367,10 @@ export const PageViewProvider = ({ paths, handle, children, prefix = "page", eve
307
367
  previous: (_a = pageChain.previous) === null || _a === void 0 ? void 0 : _a.current,
308
368
  };
309
369
  };
370
+ const getPageChainInfo = () => {
371
+ var _a;
372
+ return (_a = pageChain.current) !== null && _a !== void 0 ? _a : { path: "", base: "", page: "", options: {}, params: {} };
373
+ };
310
374
  const ui = usePageViewUI();
311
375
  const values = {
312
376
  parentContext,
@@ -320,7 +384,6 @@ export const PageViewProvider = ({ paths, handle, children, prefix = "page", eve
320
384
  titleRef.current = title;
321
385
  },
322
386
  setPage,
323
- setSelectedPage,
324
387
  getSelectedPage: () => {
325
388
  const { current } = pageChain;
326
389
  return current === null || current === void 0 ? void 0 : current.path;
@@ -335,6 +398,12 @@ export const PageViewProvider = ({ paths, handle, children, prefix = "page", eve
335
398
  getEventHandler: () => {
336
399
  return eventHandler !== null && eventHandler !== void 0 ? eventHandler : {};
337
400
  },
401
+ isRootView: () => { var _a; return (_a = uuid === null || uuid === void 0 ? void 0 : uuid.startsWith("root")) !== null && _a !== void 0 ? _a : false; },
402
+ getUrl,
403
+ getPage,
404
+ getParams,
405
+ getSubPaths,
406
+ getPageChainInfo,
338
407
  };
339
408
  useEffect(() => {
340
409
  const idx = contextStack.length;
@@ -12,27 +12,49 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { DynamicComponent } from "./DynamicComponent";
14
14
  const Panel = ({ content, orientation = "vertical", styles = {}, className = "" }) => {
15
- if (content == undefined || content == null) {
15
+ if (content == null)
16
16
  return null;
17
- }
18
17
  return (_jsx("div", { className: className, style: styles, children: renderContent(content, orientation) }));
19
18
  };
20
19
  const renderContent = (content, orientation = "vertical") => {
21
- //console.log(content)
22
- // 1. Array → flex container, each item rendered recursively with flipped orientation for nested arrays
20
+ if (content == null)
21
+ return null;
22
+ // ── 1. Outer array: vertical column of rows / standalone items ──────────
23
23
  if (Array.isArray(content)) {
24
- const isHorizontal = orientation === "horizontal";
25
- return (_jsx("div", { style: { display: "flex", flexDirection: isHorizontal ? "row" : "column", gap: 12, flexWrap: "wrap" }, children: content.map((item, i) => Array.isArray(item) ? (_jsx("div", { children: renderContent(item, isHorizontal ? "vertical" : "horizontal") }, i)) : (_jsx("div", { children: renderContent(item, orientation) }, i))) }));
24
+ return (_jsx("div", { style: { display: "flex", flexDirection: "column", gap: 12, width: "100%" }, children: content.map((item, i) => {
25
+ // ── 2. Nested array = one horizontal row ────────────────────────
26
+ if (Array.isArray(item)) {
27
+ return (_jsx("div", { style: {
28
+ display: "flex",
29
+ flexDirection: "row",
30
+ gap: 12,
31
+ width: "100%",
32
+ flexWrap: "wrap",
33
+ alignItems: "flex-start",
34
+ justifyContent: "flex-start", // ← keeps items packed left
35
+ }, children: item.map((cell, j) => {
36
+ var _a, _b;
37
+ const isFullWidth = ((_a = cell === null || cell === void 0 ? void 0 : cell.attr) === null || _a === void 0 ? void 0 : _a.fullWidth) === true;
38
+ const isStretch = ((_b = cell === null || cell === void 0 ? void 0 : cell.attr) === null || _b === void 0 ? void 0 : _b.stretch) === true; // ← opt-in stretch
39
+ return (_jsx("div", { style: {
40
+ flex: isFullWidth ? "0 0 100%" : isStretch ? "1 1 0" : "0 0 auto",
41
+ minWidth: 0,
42
+ }, children: renderContent(cell, "vertical") }, j));
43
+ }) }, i));
44
+ }
45
+ // ── 3. Standalone object = full-width row ───────────────────────
46
+ return (_jsx("div", { style: { width: "100%" }, children: renderContent(item, "vertical") }, i));
47
+ }) }));
26
48
  }
27
- // 2. Object with `component` → DynamicComponent
28
- if (content && typeof content === "object" && content.component) {
29
- const { component, attr } = content;
30
- return _jsx(DynamicComponent, { config: { component, attr } });
49
+ // ── 4. Object with `component` or `componentid` → DynamicComponent ──────────────────────
50
+ if (content && typeof content === "object" && (content.component || content.componentid)) {
51
+ const { component, componentid, attr } = content;
52
+ return _jsx(DynamicComponent, { config: { component, componentid, attr } });
31
53
  }
32
- // 3. Object without `component` → Panel with nested elements
54
+ // ── 5. Object without `component` → nested Panel ───────────────────────
33
55
  if (content && typeof content === "object") {
34
56
  const { elements, styles, className, orientation: innerOrientation } = content, rest = __rest(content, ["elements", "styles", "className", "orientation"]);
35
- return (_jsx(Panel, { content: elements || null, orientation: innerOrientation || orientation, styles: Object.assign(Object.assign({}, styles), rest), className: className || "" }));
57
+ return (_jsx(Panel, { content: elements !== null && elements !== void 0 ? elements : null, orientation: innerOrientation !== null && innerOrientation !== void 0 ? innerOrientation : orientation, styles: Object.assign(Object.assign({}, styles), rest), className: className !== null && className !== void 0 ? className : "" }));
36
58
  }
37
59
  return null;
38
60
  };
@@ -6,4 +6,4 @@ export type StepActionHandler = {
6
6
  next: () => void;
7
7
  back: () => void;
8
8
  };
9
- export declare const StepHandler: (items: Record<string, any>[], callback: (item: Record<string, any>) => void) => StepActionHandler;
9
+ export declare const StepHandler: (items: Record<string, any>[], callback: (item: Record<string, any>) => void, getData?: () => Record<string, any>) => StepActionHandler;
@@ -1,32 +1,69 @@
1
- export const StepHandler = (items, callback) => {
1
+ const evaluateWhen = (expr, data) => {
2
+ try {
3
+ const filled = expr.replace(/\{\{([\s\S]+?)\}\}/g, (_, path) => {
4
+ const val = path.trim().split(".").reduce((obj, key) => obj === null || obj === void 0 ? void 0 : obj[key], data);
5
+ return JSON.stringify(val !== null && val !== void 0 ? val : null);
6
+ });
7
+ // eslint-disable-next-line no-new-func
8
+ return Boolean(new Function(`return (${filled})`)());
9
+ }
10
+ catch (_a) {
11
+ return false;
12
+ }
13
+ };
14
+ const resolveNext = (current, items, currentIndex, getData) => {
15
+ const { next } = current;
16
+ // no next defined — linear
17
+ if (next == null)
18
+ return currentIndex + 1;
19
+ // next is a string id — jump directly
20
+ if (typeof next === "string") {
21
+ const idx = items.findIndex((it) => it.id === next);
22
+ return idx >= 0 ? idx : currentIndex + 1;
23
+ }
24
+ // next is a conditions array
25
+ if (Array.isArray(next)) {
26
+ const data = getData();
27
+ for (const condition of next) {
28
+ const c = condition;
29
+ if (c.when != null && evaluateWhen(c.when, data)) {
30
+ const idx = items.findIndex((it) => it.id === c.goto);
31
+ return idx >= 0 ? idx : currentIndex + 1;
32
+ }
33
+ if (c.default != null) {
34
+ const idx = items.findIndex((it) => it.id === c.default);
35
+ return idx >= 0 ? idx : currentIndex + 1;
36
+ }
37
+ }
38
+ }
39
+ return currentIndex + 1;
40
+ };
41
+ export const StepHandler = (items, callback, getData = () => ({})) => {
2
42
  let currentIndex = 0;
3
- let lastIndex = 0; // max index visited
4
- const hasPrev = () => {
5
- if (items.length == 0)
6
- return false;
7
- if (currentIndex - 1 < 0)
8
- return false;
9
- return true;
10
- };
43
+ let lastIndex = 0;
44
+ const history = []; // track visited indices for back navigation
45
+ const hasPrev = () => history.length > 0;
11
46
  const hasNext = () => {
12
- if (items.length == 0)
47
+ if (items.length === 0)
13
48
  return false;
14
- if (currentIndex + 1 >= items.length)
15
- return false;
16
- return true;
49
+ const nextIndex = resolveNext(items[currentIndex], items, currentIndex, getData);
50
+ return nextIndex < items.length;
17
51
  };
18
52
  const next = () => {
19
- currentIndex++;
20
- if (currentIndex > lastIndex) {
53
+ const nextIndex = resolveNext(items[currentIndex], items, currentIndex, getData);
54
+ if (nextIndex >= items.length)
55
+ return;
56
+ history.push(currentIndex);
57
+ currentIndex = nextIndex;
58
+ if (currentIndex > lastIndex)
21
59
  lastIndex = currentIndex;
22
- }
23
- const selected = items[currentIndex];
24
- callback(selected);
60
+ callback(items[currentIndex]);
25
61
  };
26
62
  const back = () => {
27
- currentIndex--;
28
- const selected = items[currentIndex];
29
- callback(selected);
63
+ if (history.length === 0)
64
+ return;
65
+ currentIndex = history.pop();
66
+ callback(items[currentIndex]);
30
67
  };
31
68
  return {
32
69
  getCurrentIndex: () => currentIndex,