@dataverse-kit/form-runtime 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +93 -0
  3. package/dist/businessRules-U1_MBgyG.d.cts +372 -0
  4. package/dist/businessRules-U1_MBgyG.d.ts +372 -0
  5. package/dist/context.cjs +151 -0
  6. package/dist/context.cjs.map +1 -0
  7. package/dist/context.d.cts +132 -0
  8. package/dist/context.d.ts +132 -0
  9. package/dist/context.mjs +113 -0
  10. package/dist/context.mjs.map +1 -0
  11. package/dist/control-DFOg_pc_.d.cts +1027 -0
  12. package/dist/control-DaXBm-52.d.ts +1027 -0
  13. package/dist/gridCustomizer-C0V9FAE_.d.ts +569 -0
  14. package/dist/gridCustomizer-mJO-kmQ4.d.cts +569 -0
  15. package/dist/hooks.cjs +85 -0
  16. package/dist/hooks.cjs.map +1 -0
  17. package/dist/hooks.d.cts +24 -0
  18. package/dist/hooks.d.ts +24 -0
  19. package/dist/hooks.mjs +60 -0
  20. package/dist/hooks.mjs.map +1 -0
  21. package/dist/icons.cjs +202 -0
  22. package/dist/icons.cjs.map +1 -0
  23. package/dist/icons.d.cts +130 -0
  24. package/dist/icons.d.ts +130 -0
  25. package/dist/icons.mjs +165 -0
  26. package/dist/icons.mjs.map +1 -0
  27. package/dist/index.cjs +6509 -0
  28. package/dist/index.cjs.map +1 -0
  29. package/dist/index.d.cts +410 -0
  30. package/dist/index.d.ts +410 -0
  31. package/dist/index.mjs +6490 -0
  32. package/dist/index.mjs.map +1 -0
  33. package/dist/runtime-capabilities-BdGDdu0d.d.cts +119 -0
  34. package/dist/runtime-capabilities-Brfc7loJ.d.ts +119 -0
  35. package/dist/theme-BfeZIxmZ.d.cts +74 -0
  36. package/dist/theme-BfeZIxmZ.d.ts +74 -0
  37. package/dist/theme.cjs +215 -0
  38. package/dist/theme.cjs.map +1 -0
  39. package/dist/theme.d.cts +32 -0
  40. package/dist/theme.d.ts +32 -0
  41. package/dist/theme.mjs +186 -0
  42. package/dist/theme.mjs.map +1 -0
  43. package/dist/types.cjs +976 -0
  44. package/dist/types.cjs.map +1 -0
  45. package/dist/types.d.cts +813 -0
  46. package/dist/types.d.ts +813 -0
  47. package/dist/types.mjs +902 -0
  48. package/dist/types.mjs.map +1 -0
  49. package/dist/utils.cjs +250 -0
  50. package/dist/utils.cjs.map +1 -0
  51. package/dist/utils.d.cts +99 -0
  52. package/dist/utils.d.ts +99 -0
  53. package/dist/utils.mjs +220 -0
  54. package/dist/utils.mjs.map +1 -0
  55. package/dist/v8.cjs +4622 -0
  56. package/dist/v8.cjs.map +1 -0
  57. package/dist/v8.d.cts +730 -0
  58. package/dist/v8.d.ts +730 -0
  59. package/dist/v8.mjs +4622 -0
  60. package/dist/v8.mjs.map +1 -0
  61. package/dist/v9.cjs +19 -0
  62. package/dist/v9.cjs.map +1 -0
  63. package/dist/v9.d.cts +2 -0
  64. package/dist/v9.d.ts +2 -0
  65. package/dist/v9.mjs +1 -0
  66. package/dist/v9.mjs.map +1 -0
  67. package/package.json +113 -0
package/dist/types.cjs ADDED
@@ -0,0 +1,976 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/types/index.ts
21
+ var types_exports = {};
22
+ __export(types_exports, {
23
+ BPF_CONDITION_NODE_DISPLAY: () => BPF_CONDITION_NODE_DISPLAY,
24
+ BPF_EDGE_DISPLAY: () => BPF_EDGE_DISPLAY,
25
+ BPF_STAGE_STATUSES: () => BPF_STAGE_STATUSES,
26
+ BPF_STEP_TYPES: () => BPF_STEP_TYPES,
27
+ DEFAULT_FORM_GRID_LAYOUT: () => DEFAULT_FORM_GRID_LAYOUT,
28
+ DEFAULT_THEME: () => DEFAULT_THEME,
29
+ FOCUSED_VIEW_ICON_OPTIONS: () => FOCUSED_VIEW_ICON_OPTIONS,
30
+ MAX_FOCUSED_VIEW_ROWS: () => MAX_FOCUSED_VIEW_ROWS,
31
+ PRIMARY_CAPABLE_VARIANTS: () => PRIMARY_CAPABLE_VARIANTS,
32
+ STANDARD_COLORS: () => STANDARD_COLORS,
33
+ THEME_PRESETS: () => THEME_PRESETS,
34
+ convertDataverseBPFToDefinition: () => convertDataverseBPFToDefinition,
35
+ createBPFInstance: () => createBPFInstance,
36
+ createConfigFromColumns: () => createConfigFromColumns,
37
+ createDefaultBPF: () => createDefaultBPF,
38
+ createDefaultBPFConditionNode: () => createDefaultBPFConditionNode,
39
+ createDefaultBPFEdge: () => createDefaultBPFEdge,
40
+ createDefaultBPFStage: () => createDefaultBPFStage,
41
+ createDefaultBPFStep: () => createDefaultBPFStep,
42
+ createDefaultBusinessRule: () => createDefaultBusinessRule,
43
+ createDefaultCardViewConfig: () => createDefaultCardViewConfig,
44
+ createDefaultCompositeRendererConfig: () => createDefaultCompositeRendererConfig,
45
+ createDefaultCompositeSlot: () => createDefaultCompositeSlot,
46
+ createDefaultFieldState: () => createDefaultFieldState,
47
+ createDefaultFocusedViewConfig: () => createDefaultFocusedViewConfig,
48
+ createDefaultGridColumn: () => createDefaultGridColumn,
49
+ createDefaultGridCustomizer: () => createDefaultGridCustomizer,
50
+ createDefaultToolbarConfig: () => createDefaultToolbarConfig,
51
+ createFormSelectorRule: () => createFormSelectorRule,
52
+ entityIconMap: () => entityIconMap,
53
+ generateGridId: () => generateGridId,
54
+ getActionTargets: () => getActionTargets,
55
+ getConditionNodeById: () => getConditionNodeById,
56
+ getDefaultEdge: () => getDefaultEdge,
57
+ getEntityIcon: () => getEntityIcon,
58
+ getIncomingEdges: () => getIncomingEdges,
59
+ getOutgoingEdges: () => getOutgoingEdges,
60
+ getResolvedThemeColors: () => getResolvedThemeColors,
61
+ getThemeById: () => getThemeById,
62
+ hasBranching: () => hasBranching,
63
+ isAuditTab: () => isAuditTab,
64
+ isConditionGroup: () => isConditionGroup,
65
+ isConditionNode: () => isConditionNode,
66
+ isMainTab: () => isMainTab,
67
+ isRelatedTab: () => isRelatedTab,
68
+ isValidFocusedViewConfig: () => isValidFocusedViewConfig,
69
+ migrateLegacyConfig: () => migrateLegacyConfig,
70
+ toFormSummary: () => toFormSummary
71
+ });
72
+ module.exports = __toCommonJS(types_exports);
73
+
74
+ // src/types/control.ts
75
+ var PRIMARY_CAPABLE_VARIANTS = ["default", "compound", "split", "toggle"];
76
+
77
+ // src/types/form.ts
78
+ var DEFAULT_FORM_GRID_LAYOUT = {
79
+ columns: 12,
80
+ rowHeight: 80,
81
+ gap: 12
82
+ };
83
+ function isMainTab(tab) {
84
+ return tab.tabType === "main" || !("tabType" in tab) || tab.tabType === void 0;
85
+ }
86
+ function isRelatedTab(tab) {
87
+ return tab.tabType === "related";
88
+ }
89
+ function isAuditTab(tab) {
90
+ return tab.tabType === "audit";
91
+ }
92
+
93
+ // src/types/theme.ts
94
+ var THEME_PRESETS = [
95
+ {
96
+ id: "soft-blue",
97
+ name: "Soft blue",
98
+ colors: {
99
+ primary: "#0078d4",
100
+ primaryDark: "#005a9e",
101
+ headerBackground: "#ffffff",
102
+ sectionBackground: "#ffffff",
103
+ canvasBackground: "#f3f2f1",
104
+ textPrimary: "#323130",
105
+ textSecondary: "#605e5c",
106
+ border: "#edebe9",
107
+ inputBackground: "#ffffff",
108
+ inputBorder: "#8a8886"
109
+ }
110
+ },
111
+ {
112
+ id: "blue",
113
+ name: "Blue",
114
+ colors: {
115
+ primary: "#0078d4",
116
+ primaryDark: "#005a9e",
117
+ headerBackground: "#0078d4",
118
+ sectionBackground: "#e6f2ff",
119
+ canvasBackground: "#e6f2ff",
120
+ textPrimary: "#323130",
121
+ textSecondary: "#605e5c",
122
+ border: "#c7e0f4",
123
+ inputBackground: "#ffffff",
124
+ inputBorder: "#0078d4"
125
+ }
126
+ },
127
+ {
128
+ id: "light",
129
+ name: "Light",
130
+ colors: {
131
+ primary: "#605e5c",
132
+ primaryDark: "#3b3a39",
133
+ headerBackground: "#f5f5f5",
134
+ sectionBackground: "#ffffff",
135
+ canvasBackground: "#fafafa",
136
+ textPrimary: "#323130",
137
+ textSecondary: "#605e5c",
138
+ border: "#e1dfdd",
139
+ inputBackground: "#ffffff",
140
+ inputBorder: "#8a8886"
141
+ }
142
+ },
143
+ {
144
+ id: "coral",
145
+ name: "Coral",
146
+ colors: {
147
+ primary: "#d83b01",
148
+ primaryDark: "#a52a00",
149
+ headerBackground: "#d83b01",
150
+ sectionBackground: "#fff4f0",
151
+ canvasBackground: "#fff4f0",
152
+ textPrimary: "#323130",
153
+ textSecondary: "#605e5c",
154
+ border: "#f3d6cd",
155
+ inputBackground: "#ffffff",
156
+ inputBorder: "#d83b01"
157
+ }
158
+ },
159
+ {
160
+ id: "red",
161
+ name: "Red",
162
+ colors: {
163
+ primary: "#a4262c",
164
+ primaryDark: "#7e1e23",
165
+ headerBackground: "#a4262c",
166
+ sectionBackground: "#fdf3f4",
167
+ canvasBackground: "#fdf3f4",
168
+ textPrimary: "#323130",
169
+ textSecondary: "#605e5c",
170
+ border: "#f1d3d5",
171
+ inputBackground: "#ffffff",
172
+ inputBorder: "#a4262c"
173
+ }
174
+ },
175
+ {
176
+ id: "steel",
177
+ name: "Steel",
178
+ colors: {
179
+ primary: "#004578",
180
+ primaryDark: "#002d4e",
181
+ headerBackground: "#004578",
182
+ sectionBackground: "#f0f4f7",
183
+ canvasBackground: "#e8eef2",
184
+ textPrimary: "#323130",
185
+ textSecondary: "#605e5c",
186
+ border: "#c8d4dc",
187
+ inputBackground: "#ffffff",
188
+ inputBorder: "#004578"
189
+ }
190
+ },
191
+ {
192
+ id: "dune",
193
+ name: "Dune",
194
+ colors: {
195
+ primary: "#7a6855",
196
+ primaryDark: "#5c4f3f",
197
+ headerBackground: "#7a6855",
198
+ sectionBackground: "#f5f3f0",
199
+ canvasBackground: "#e8e4df",
200
+ textPrimary: "#323130",
201
+ textSecondary: "#605e5c",
202
+ border: "#d6d0c8",
203
+ inputBackground: "#ffffff",
204
+ inputBorder: "#7a6855"
205
+ }
206
+ },
207
+ {
208
+ id: "lavender",
209
+ name: "Lavender",
210
+ colors: {
211
+ primary: "#5c2d91",
212
+ primaryDark: "#472270",
213
+ headerBackground: "#5c2d91",
214
+ sectionBackground: "#f9f5ff",
215
+ canvasBackground: "#f5f0fa",
216
+ textPrimary: "#323130",
217
+ textSecondary: "#605e5c",
218
+ border: "#e1d4f0",
219
+ inputBackground: "#ffffff",
220
+ inputBorder: "#5c2d91"
221
+ }
222
+ },
223
+ {
224
+ id: "brown",
225
+ name: "Brown",
226
+ colors: {
227
+ primary: "#6d4c41",
228
+ primaryDark: "#4e362e",
229
+ headerBackground: "#6d4c41",
230
+ sectionBackground: "#f5f0ed",
231
+ canvasBackground: "#ebe5e1",
232
+ textPrimary: "#323130",
233
+ textSecondary: "#605e5c",
234
+ border: "#d4ccc7",
235
+ inputBackground: "#ffffff",
236
+ inputBorder: "#6d4c41"
237
+ }
238
+ }
239
+ ];
240
+ var DEFAULT_THEME = THEME_PRESETS[0];
241
+ var STANDARD_COLORS = [
242
+ "#ffffff",
243
+ "#000000",
244
+ "#1a1a1a",
245
+ "#333333",
246
+ "#4d4d4d",
247
+ "#666666",
248
+ "#808080",
249
+ "#999999",
250
+ "#b3b3b3",
251
+ "#cccccc",
252
+ "#a4262c",
253
+ "#d83b01",
254
+ "#ff8c00",
255
+ "#ffb900",
256
+ "#fff100",
257
+ "#bad80a",
258
+ "#107c10",
259
+ "#00b294",
260
+ "#0078d4",
261
+ "#5c2d91"
262
+ ];
263
+ function getThemeById(id) {
264
+ return THEME_PRESETS.find((t) => t.id === id) ?? DEFAULT_THEME;
265
+ }
266
+ function getResolvedThemeColors(themeSettings) {
267
+ const theme = getThemeById(themeSettings?.presetId ?? "soft-blue");
268
+ if (themeSettings?.customBackgroundColor) {
269
+ return {
270
+ ...theme.colors,
271
+ canvasBackground: themeSettings.customBackgroundColor
272
+ };
273
+ }
274
+ return theme.colors;
275
+ }
276
+
277
+ // src/types/focusedView.ts
278
+ var FOCUSED_VIEW_ICON_OPTIONS = [
279
+ { iconName: "", label: "None" },
280
+ { iconName: "FavoriteStarFill", label: "Star" },
281
+ { iconName: "NumberSymbol", label: "Number" },
282
+ { iconName: "Clock", label: "Time" },
283
+ { iconName: "Phone", label: "Phone" },
284
+ { iconName: "Mail", label: "Email" },
285
+ { iconName: "Calendar", label: "Calendar" },
286
+ { iconName: "Contact", label: "Contact" },
287
+ { iconName: "Money", label: "Currency" },
288
+ { iconName: "StatusCircleCheckmark", label: "Status" }
289
+ ];
290
+ var MAX_FOCUSED_VIEW_ROWS = 4;
291
+ function migrateLegacyConfig(primaryNameField, summaryFields) {
292
+ const rows = [];
293
+ if (primaryNameField) {
294
+ rows.push({
295
+ id: "row-1",
296
+ primaryField: {
297
+ fieldName: primaryNameField,
298
+ label: toDisplayName(primaryNameField)
299
+ }
300
+ });
301
+ }
302
+ summaryFields.slice(0, MAX_FOCUSED_VIEW_ROWS - 1).forEach((sf, index) => {
303
+ rows.push({
304
+ id: `row-${index + 2}`,
305
+ primaryField: {
306
+ fieldName: sf.fieldName,
307
+ label: sf.label
308
+ }
309
+ });
310
+ });
311
+ return { rows };
312
+ }
313
+ function toDisplayName(fieldName) {
314
+ return fieldName.replace(/([A-Z])/g, " $1").replace(/_/g, " ").replace(/^\s+/, "").split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ").trim();
315
+ }
316
+ function createDefaultFocusedViewConfig(primaryNameField = "name") {
317
+ return {
318
+ rows: [
319
+ {
320
+ id: "row-1",
321
+ primaryField: {
322
+ fieldName: primaryNameField,
323
+ label: toDisplayName(primaryNameField)
324
+ }
325
+ }
326
+ ],
327
+ showUpNextActivity: false
328
+ };
329
+ }
330
+ function isValidFocusedViewConfig(config) {
331
+ if (!config || typeof config !== "object") return false;
332
+ const c = config;
333
+ if (!Array.isArray(c.rows)) return false;
334
+ if (c.rows.length === 0 || c.rows.length > MAX_FOCUSED_VIEW_ROWS) return false;
335
+ return c.rows.every(
336
+ (row) => row.id && row.primaryField && typeof row.primaryField.fieldName === "string" && typeof row.primaryField.label === "string"
337
+ );
338
+ }
339
+ function createConfigFromColumns(columns) {
340
+ if (!columns || columns.length === 0) {
341
+ return createDefaultFocusedViewConfig();
342
+ }
343
+ const rows = columns.slice(0, MAX_FOCUSED_VIEW_ROWS).map((col, index) => ({
344
+ id: `row-${index + 1}`,
345
+ primaryField: {
346
+ fieldName: col.fieldName,
347
+ label: col.name || toDisplayName(col.fieldName)
348
+ }
349
+ }));
350
+ return {
351
+ rows,
352
+ showUpNextActivity: false
353
+ };
354
+ }
355
+
356
+ // src/types/businessRules.ts
357
+ function isConditionGroup(c) {
358
+ return "logic" in c;
359
+ }
360
+ function getActionTargets(action) {
361
+ return action.targets?.length ? action.targets : [action.target];
362
+ }
363
+ function createDefaultBusinessRule(entityLogicalName, name = "New Rule") {
364
+ const id = `rule-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
365
+ const now = (/* @__PURE__ */ new Date()).toISOString();
366
+ return {
367
+ id,
368
+ name,
369
+ entityLogicalName,
370
+ scope: "entity",
371
+ trigger: { type: "onLoad" },
372
+ priority: 100,
373
+ enabled: true,
374
+ dataSources: [],
375
+ variables: [],
376
+ conditionTree: {
377
+ id: `grp-${Date.now()}`,
378
+ logic: "and",
379
+ conditions: []
380
+ },
381
+ thenActions: [],
382
+ elseActions: [],
383
+ createdAt: now,
384
+ updatedAt: now
385
+ };
386
+ }
387
+ function createDefaultFieldState() {
388
+ return {
389
+ visible: true,
390
+ locked: false,
391
+ required: "none"
392
+ };
393
+ }
394
+
395
+ // src/types/bpf.ts
396
+ function uid(prefix) {
397
+ return `${prefix}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
398
+ }
399
+ function createDefaultBPFStep(type = "data", order = 1) {
400
+ return {
401
+ id: uid("step"),
402
+ name: "New Step",
403
+ order,
404
+ type,
405
+ required: false
406
+ };
407
+ }
408
+ function createDefaultBPFStage(order = 1) {
409
+ return {
410
+ id: uid("stage"),
411
+ name: "New Stage",
412
+ order,
413
+ status: "pending",
414
+ steps: []
415
+ };
416
+ }
417
+ function createDefaultBPFEdge(fromStageId, toStageId, options) {
418
+ return {
419
+ id: uid("edge"),
420
+ fromStageId,
421
+ toStageId,
422
+ label: options?.label,
423
+ condition: options?.condition,
424
+ isDefault: options?.isDefault ?? false,
425
+ order: options?.order ?? 0
426
+ };
427
+ }
428
+ function createDefaultBPFConditionNode(name = "New Condition", condition) {
429
+ return {
430
+ id: uid("cond"),
431
+ name,
432
+ condition: condition ?? {
433
+ id: uid("grp"),
434
+ logic: "and",
435
+ conditions: []
436
+ }
437
+ };
438
+ }
439
+ function createDefaultBPF(entityLogicalName, name = "New Business Process Flow") {
440
+ const now = (/* @__PURE__ */ new Date()).toISOString();
441
+ return {
442
+ id: uid("bpf"),
443
+ name,
444
+ entityLogicalName,
445
+ source: "custom",
446
+ stages: [
447
+ {
448
+ ...createDefaultBPFStage(1),
449
+ name: "Stage 1",
450
+ status: "active"
451
+ },
452
+ {
453
+ ...createDefaultBPFStage(2),
454
+ name: "Stage 2"
455
+ },
456
+ {
457
+ ...createDefaultBPFStage(3),
458
+ name: "Stage 3"
459
+ }
460
+ ],
461
+ activeStageIndex: 0,
462
+ isActive: true,
463
+ allowBackNavigation: true,
464
+ showStageLabels: true,
465
+ progressVariant: "chevron",
466
+ createdAt: now,
467
+ updatedAt: now
468
+ };
469
+ }
470
+ function createBPFInstance(bpf, recordId) {
471
+ const firstStage = bpf.stages[0];
472
+ return {
473
+ id: uid("inst"),
474
+ bpfDefinitionId: bpf.id,
475
+ recordId,
476
+ entityLogicalName: bpf.entityLogicalName,
477
+ activeStageId: firstStage?.id ?? "",
478
+ completedStageIds: [],
479
+ skippedStageIds: [],
480
+ completedStepIds: [],
481
+ pathHistory: firstStage ? [firstStage.id] : [],
482
+ startedAt: (/* @__PURE__ */ new Date()).toISOString()
483
+ };
484
+ }
485
+ function mapAttributeTypeToFieldType(attributeType, format) {
486
+ switch (attributeType) {
487
+ case "String":
488
+ if (format === "Email" || format === "Url" || format === "Phone") {
489
+ return "text";
490
+ }
491
+ return "text";
492
+ case "Memo":
493
+ return "textarea";
494
+ case "Integer":
495
+ case "BigInt":
496
+ return "number";
497
+ case "Decimal":
498
+ case "Double":
499
+ return "decimal";
500
+ case "Money":
501
+ return "currency";
502
+ case "DateTime":
503
+ if (format === "DateOnly") {
504
+ return "date";
505
+ }
506
+ return "datetime";
507
+ case "Boolean":
508
+ return "boolean";
509
+ case "Lookup":
510
+ case "Customer":
511
+ case "PartyList":
512
+ return "lookup";
513
+ case "Owner":
514
+ return "owner";
515
+ case "Picklist":
516
+ case "State":
517
+ case "Status":
518
+ return "optionset";
519
+ case "MultiSelectPicklist":
520
+ return "multiselect";
521
+ default:
522
+ return "text";
523
+ }
524
+ }
525
+ function createStepFromStepInfo(stepInfo, stepIndex) {
526
+ const fieldType = mapAttributeTypeToFieldType(
527
+ stepInfo.attributeType,
528
+ stepInfo.format
529
+ );
530
+ const step = {
531
+ id: uid("step"),
532
+ name: stepInfo.displayName || stepInfo.controlId,
533
+ order: stepIndex + 1,
534
+ type: "data",
535
+ required: stepInfo.isRequired ?? false,
536
+ fieldLogicalName: stepInfo.controlId,
537
+ fieldDisplayName: stepInfo.displayName,
538
+ fieldType
539
+ };
540
+ if ((fieldType === "lookup" || fieldType === "owner") && stepInfo.lookupTargets && stepInfo.lookupTargets.length > 0) {
541
+ step.lookupTargetEntity = stepInfo.lookupTargets[0];
542
+ if (stepInfo.lookupTargets.length > 1) {
543
+ step.lookupTargetEntities = stepInfo.lookupTargets;
544
+ }
545
+ }
546
+ if ((fieldType === "optionset" || fieldType === "multiselect") && stepInfo.options && stepInfo.options.length > 0) {
547
+ step.options = stepInfo.options;
548
+ }
549
+ return step;
550
+ }
551
+ function convertDataverseBPFToDefinition(metadata) {
552
+ const now = (/* @__PURE__ */ new Date()).toISOString();
553
+ const sortedStages = [...metadata.stages].sort(
554
+ (a, b) => a.stageCategory - b.stageCategory
555
+ );
556
+ const stageIdMap = /* @__PURE__ */ new Map();
557
+ const stages = sortedStages.map((stageMeta, index) => {
558
+ const internalId = uid("stage");
559
+ stageIdMap.set(stageMeta.stageId.toLowerCase(), internalId);
560
+ let steps;
561
+ if (stageMeta.parsedSteps && stageMeta.parsedSteps.length > 0) {
562
+ steps = stageMeta.parsedSteps.map(
563
+ (stepInfo, stepIndex) => createStepFromStepInfo(stepInfo, stepIndex)
564
+ );
565
+ } else {
566
+ steps = stageMeta.requiredAttributes.map((attr, stepIndex) => ({
567
+ id: uid("step"),
568
+ name: attr,
569
+ order: stepIndex + 1,
570
+ type: "data",
571
+ required: false,
572
+ // Default to not required when we don't have parsed data
573
+ fieldLogicalName: attr,
574
+ fieldType: "text"
575
+ // Default to text when no metadata
576
+ }));
577
+ }
578
+ return {
579
+ id: internalId,
580
+ name: stageMeta.name,
581
+ order: index + 1,
582
+ status: index === 0 ? "active" : "pending",
583
+ dataverseStageId: stageMeta.stageId,
584
+ dataverseStageCategory: stageMeta.stageCategory,
585
+ steps
586
+ };
587
+ });
588
+ let edges;
589
+ let conditionNodes;
590
+ if (metadata.branchData?.hasBranching) {
591
+ const condNodeIdMap = /* @__PURE__ */ new Map();
592
+ conditionNodes = metadata.branchData.conditionNodes.map((condInfo) => {
593
+ const internalId = uid("cond");
594
+ condNodeIdMap.set(condInfo.nodeId.toLowerCase(), internalId);
595
+ const condition = buildConditionGroupFromBranch(condInfo);
596
+ return {
597
+ id: internalId,
598
+ name: condInfo.name,
599
+ description: condInfo.conditionExpression,
600
+ condition
601
+ };
602
+ });
603
+ edges = metadata.branchData.branches.map((branch) => {
604
+ let fromId = stageIdMap.get(branch.fromNodeId.toLowerCase()) || condNodeIdMap.get(branch.fromNodeId.toLowerCase());
605
+ let toId = stageIdMap.get(branch.toStageId.toLowerCase());
606
+ if (!fromId || !toId) {
607
+ return null;
608
+ }
609
+ let edgeCondition;
610
+ if (!branch.isDefault && branch.conditionField) {
611
+ edgeCondition = buildConditionGroupFromBranch({
612
+ nodeId: "",
613
+ name: "",
614
+ conditionField: branch.conditionField,
615
+ conditionOperator: branch.conditionOperator,
616
+ conditionValue: branch.conditionValue
617
+ });
618
+ }
619
+ return {
620
+ id: uid("edge"),
621
+ fromStageId: fromId,
622
+ toStageId: toId,
623
+ label: branch.label,
624
+ condition: edgeCondition,
625
+ isDefault: branch.isDefault,
626
+ order: branch.order ?? 0
627
+ };
628
+ }).filter((e) => e !== null);
629
+ }
630
+ const bpf = {
631
+ id: uid("bpf"),
632
+ name: metadata.name,
633
+ description: metadata.description,
634
+ entityLogicalName: metadata.primaryEntity,
635
+ source: "dataverse",
636
+ dataverseWorkflowId: metadata.workflowId,
637
+ dataverseUniqueName: metadata.uniqueName,
638
+ stages,
639
+ activeStageIndex: 0,
640
+ isActive: metadata.stateCode === 1,
641
+ allowBackNavigation: true,
642
+ showStageLabels: true,
643
+ progressVariant: "chevron",
644
+ createdAt: now,
645
+ updatedAt: now
646
+ };
647
+ if (edges && edges.length > 0) {
648
+ bpf.edges = edges;
649
+ }
650
+ if (conditionNodes && conditionNodes.length > 0) {
651
+ bpf.conditionNodes = conditionNodes;
652
+ }
653
+ return bpf;
654
+ }
655
+ function buildConditionGroupFromBranch(condInfo) {
656
+ const conditions = [];
657
+ if (condInfo.conditionField) {
658
+ const opMap = {
659
+ "eq": "eq",
660
+ "=": "eq",
661
+ "equals": "eq",
662
+ "ne": "ne",
663
+ "!=": "ne",
664
+ "notequals": "ne",
665
+ "gt": "gt",
666
+ ">": "gt",
667
+ "ge": "ge",
668
+ ">=": "ge",
669
+ "lt": "lt",
670
+ "<": "lt",
671
+ "le": "le",
672
+ "<=": "le",
673
+ "like": "like",
674
+ "null": "null",
675
+ "not-null": "not-null",
676
+ "notnull": "not-null"
677
+ };
678
+ const operator = opMap[condInfo.conditionOperator?.toLowerCase() ?? "eq"] ?? "eq";
679
+ conditions.push({
680
+ id: uid("cond"),
681
+ source: "field",
682
+ fieldName: condInfo.conditionField,
683
+ operator,
684
+ value: condInfo.conditionValue
685
+ });
686
+ }
687
+ return {
688
+ id: uid("grp"),
689
+ logic: "and",
690
+ conditions
691
+ };
692
+ }
693
+ var BPF_STEP_TYPES = {
694
+ data: {
695
+ label: "Data Entry",
696
+ icon: "TextField",
697
+ description: "Requires a field value to be entered"
698
+ },
699
+ workflow: {
700
+ label: "Workflow",
701
+ icon: "Flow",
702
+ description: "Runs a Dynamics 365 workflow"
703
+ },
704
+ action: {
705
+ label: "Custom Action",
706
+ icon: "LightningBolt",
707
+ description: "Executes a custom action"
708
+ },
709
+ flow: {
710
+ label: "Power Automate",
711
+ icon: "MicrosoftFlowLogo",
712
+ description: "Triggers a Power Automate flow"
713
+ }
714
+ };
715
+ var BPF_STAGE_STATUSES = {
716
+ pending: {
717
+ label: "Pending",
718
+ icon: "CircleRing",
719
+ color: "#605e5c"
720
+ },
721
+ active: {
722
+ label: "Active",
723
+ icon: "CircleFill",
724
+ color: "#0078d4"
725
+ },
726
+ completed: {
727
+ label: "Completed",
728
+ icon: "CheckMark",
729
+ color: "#107c10"
730
+ },
731
+ skipped: {
732
+ label: "Skipped",
733
+ icon: "SkipForward",
734
+ color: "#8a8886"
735
+ }
736
+ };
737
+ var BPF_CONDITION_NODE_DISPLAY = {
738
+ label: "Condition",
739
+ icon: "BranchFork2",
740
+ color: "#8764b8",
741
+ // Purple like Dynamics
742
+ shape: "diamond"
743
+ };
744
+ var BPF_EDGE_DISPLAY = {
745
+ defaultLabel: "Next",
746
+ yesLabel: "Yes",
747
+ noLabel: "No",
748
+ defaultColor: "#605e5c",
749
+ conditionalColor: "#0078d4"
750
+ };
751
+ function hasBranching(bpf) {
752
+ return Boolean(bpf.edges && bpf.edges.length > 0);
753
+ }
754
+ function getOutgoingEdges(bpf, nodeId) {
755
+ if (!bpf.edges) return [];
756
+ return bpf.edges.filter((e) => e.fromStageId === nodeId).sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
757
+ }
758
+ function getIncomingEdges(bpf, nodeId) {
759
+ if (!bpf.edges) return [];
760
+ return bpf.edges.filter((e) => e.toStageId === nodeId);
761
+ }
762
+ function getConditionNodeById(bpf, nodeId) {
763
+ return bpf.conditionNodes?.find((n) => n.id === nodeId);
764
+ }
765
+ function isConditionNode(bpf, nodeId) {
766
+ return Boolean(bpf.conditionNodes?.some((n) => n.id === nodeId));
767
+ }
768
+ function getDefaultEdge(bpf, nodeId) {
769
+ const edges = getOutgoingEdges(bpf, nodeId);
770
+ return edges.find((e) => e.isDefault) ?? edges.find((e) => !e.condition);
771
+ }
772
+
773
+ // src/types/formSelector.ts
774
+ function createFormSelectorRule(entityLogicalName, targetFormId, name = "New Rule") {
775
+ const now = (/* @__PURE__ */ new Date()).toISOString();
776
+ const id = `fsr-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
777
+ return {
778
+ id,
779
+ name,
780
+ entityLogicalName,
781
+ formType: "main",
782
+ targetFormId,
783
+ condition: {
784
+ id: `grp-${Date.now()}`,
785
+ logic: "and",
786
+ conditions: []
787
+ },
788
+ priority: 100,
789
+ enabled: true,
790
+ createdAt: now,
791
+ updatedAt: now
792
+ };
793
+ }
794
+ function toFormSummary(form) {
795
+ return {
796
+ id: form.id,
797
+ name: form.name,
798
+ type: form.type,
799
+ entityLogicalName: form.settings?.dataSources?.[0]?.entityName,
800
+ isDefault: form.settings?.isDefaultForEntity,
801
+ order: form.order,
802
+ description: form.description,
803
+ calloutCount: form.callouts?.length ?? 0
804
+ };
805
+ }
806
+ var entityIconMap = {
807
+ contact: "Contact",
808
+ account: "CityNext",
809
+ opportunity: "Money",
810
+ lead: "People",
811
+ case: "Inbox",
812
+ incident: "Inbox",
813
+ task: "TaskLogo",
814
+ appointment: "Calendar",
815
+ email: "Mail",
816
+ phonecall: "Phone",
817
+ quote: "Documentation",
818
+ order: "Package",
819
+ invoice: "Money",
820
+ product: "Product",
821
+ user: "Contact",
822
+ team: "Group",
823
+ businessunit: "Org",
824
+ systemuser: "Contact"
825
+ };
826
+ function getEntityIcon(entityLogicalName) {
827
+ const normalizedName = entityLogicalName.toLowerCase().replace(/^new_|^cr\d+_/, "");
828
+ return entityIconMap[normalizedName] || "TableGroup";
829
+ }
830
+
831
+ // src/types/gridCustomizer.ts
832
+ var _gridIdCounter = 0;
833
+ function generateGridId(prefix = "gc") {
834
+ _gridIdCounter++;
835
+ return `${prefix}_${Date.now()}_${_gridIdCounter}`;
836
+ }
837
+ function createDefaultGridColumn(overrides) {
838
+ return {
839
+ id: generateGridId("col"),
840
+ fieldName: "",
841
+ displayName: "New Column",
842
+ dataType: "text",
843
+ width: 150,
844
+ minWidth: 50,
845
+ isResizable: true,
846
+ isVisible: true,
847
+ order: 0,
848
+ rendererType: "text",
849
+ rendererConfig: {},
850
+ isSortable: true,
851
+ isFilterable: false,
852
+ ...overrides
853
+ };
854
+ }
855
+ function createDefaultToolbarConfig() {
856
+ return {
857
+ showSearch: true,
858
+ showFilters: false,
859
+ showViewToggle: false,
860
+ showExport: false,
861
+ showRefresh: true,
862
+ showColumnChooser: false,
863
+ customButtons: []
864
+ };
865
+ }
866
+ function createDefaultCardViewConfig() {
867
+ return {
868
+ enabled: false,
869
+ cardsPerRow: 3,
870
+ cardHeight: 200
871
+ };
872
+ }
873
+ function createDefaultGridCustomizer(overrides) {
874
+ const now = (/* @__PURE__ */ new Date()).toISOString();
875
+ return {
876
+ id: generateGridId("grid"),
877
+ name: "New Grid",
878
+ columns: [
879
+ createDefaultGridColumn({ fieldName: "name", displayName: "Name", order: 0 }),
880
+ createDefaultGridColumn({ fieldName: "status", displayName: "Status", dataType: "optionset", rendererType: "optionset", order: 1 }),
881
+ createDefaultGridColumn({ fieldName: "created", displayName: "Created On", dataType: "date", rendererType: "date", order: 2 })
882
+ ],
883
+ gridType: "standard",
884
+ maxVisibleRows: 5,
885
+ selectionMode: "multiple",
886
+ paginationMode: "pagination",
887
+ pageSize: 10,
888
+ showCommandBar: true,
889
+ showCommandBarLabels: true,
890
+ isEditable: false,
891
+ allowViewChange: true,
892
+ toolbar: createDefaultToolbarConfig(),
893
+ cardView: createDefaultCardViewConfig(),
894
+ showTitle: true,
895
+ compactMode: false,
896
+ alternateRowColor: true,
897
+ alternateRowColors: { even: "#ffffff", odd: "#faf9f8" },
898
+ nestedSelectionMode: "independent",
899
+ commandBarItems: [
900
+ { id: "cmd-new", text: "New", iconName: "Add", position: "primary", actionType: "new" },
901
+ { id: "cmd-delete", text: "Delete", iconName: "Delete", position: "primary", actionType: "delete" }
902
+ ],
903
+ lookupPreview: { enabled: true },
904
+ sampleDataMode: "auto",
905
+ createdAt: now,
906
+ updatedAt: now,
907
+ ...overrides
908
+ };
909
+ }
910
+ function createDefaultCompositeSlot(type = "text") {
911
+ return {
912
+ id: generateGridId("slot"),
913
+ type
914
+ };
915
+ }
916
+ function createDefaultCompositeRendererConfig() {
917
+ return {
918
+ layout: "horizontal",
919
+ gap: 4,
920
+ slots: [
921
+ createDefaultCompositeSlot("text")
922
+ ]
923
+ };
924
+ }
925
+ // Annotate the CommonJS export names for ESM import in node:
926
+ 0 && (module.exports = {
927
+ BPF_CONDITION_NODE_DISPLAY,
928
+ BPF_EDGE_DISPLAY,
929
+ BPF_STAGE_STATUSES,
930
+ BPF_STEP_TYPES,
931
+ DEFAULT_FORM_GRID_LAYOUT,
932
+ DEFAULT_THEME,
933
+ FOCUSED_VIEW_ICON_OPTIONS,
934
+ MAX_FOCUSED_VIEW_ROWS,
935
+ PRIMARY_CAPABLE_VARIANTS,
936
+ STANDARD_COLORS,
937
+ THEME_PRESETS,
938
+ convertDataverseBPFToDefinition,
939
+ createBPFInstance,
940
+ createConfigFromColumns,
941
+ createDefaultBPF,
942
+ createDefaultBPFConditionNode,
943
+ createDefaultBPFEdge,
944
+ createDefaultBPFStage,
945
+ createDefaultBPFStep,
946
+ createDefaultBusinessRule,
947
+ createDefaultCardViewConfig,
948
+ createDefaultCompositeRendererConfig,
949
+ createDefaultCompositeSlot,
950
+ createDefaultFieldState,
951
+ createDefaultFocusedViewConfig,
952
+ createDefaultGridColumn,
953
+ createDefaultGridCustomizer,
954
+ createDefaultToolbarConfig,
955
+ createFormSelectorRule,
956
+ entityIconMap,
957
+ generateGridId,
958
+ getActionTargets,
959
+ getConditionNodeById,
960
+ getDefaultEdge,
961
+ getEntityIcon,
962
+ getIncomingEdges,
963
+ getOutgoingEdges,
964
+ getResolvedThemeColors,
965
+ getThemeById,
966
+ hasBranching,
967
+ isAuditTab,
968
+ isConditionGroup,
969
+ isConditionNode,
970
+ isMainTab,
971
+ isRelatedTab,
972
+ isValidFocusedViewConfig,
973
+ migrateLegacyConfig,
974
+ toFormSummary
975
+ });
976
+ //# sourceMappingURL=types.cjs.map