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