@cratis/scene.engine 4.11.0 → 4.12.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 (94) hide show
  1. package/dist/cjs/forms/CommandFormLayoutDiagnosticCode.js +20 -0
  2. package/dist/cjs/forms/CommandFormLayoutDiagnosticCode.js.map +1 -0
  3. package/dist/cjs/forms/commitCommandFormLayoutDraft.js +12 -0
  4. package/dist/cjs/forms/commitCommandFormLayoutDraft.js.map +1 -0
  5. package/dist/cjs/forms/defaultCommandFormLayout.js +23 -0
  6. package/dist/cjs/forms/defaultCommandFormLayout.js.map +1 -0
  7. package/dist/cjs/forms/formWidthToCss.js +24 -0
  8. package/dist/cjs/forms/formWidthToCss.js.map +1 -0
  9. package/dist/cjs/forms/normalizeCommandFormLayout.js +42 -0
  10. package/dist/cjs/forms/normalizeCommandFormLayout.js.map +1 -0
  11. package/dist/cjs/forms/parseFormWidth.js +34 -0
  12. package/dist/cjs/forms/parseFormWidth.js.map +1 -0
  13. package/dist/cjs/forms/preserveDirtyCommandValues.js +15 -0
  14. package/dist/cjs/forms/preserveDirtyCommandValues.js.map +1 -0
  15. package/dist/cjs/forms/resizeCommandFormColumn.js +27 -0
  16. package/dist/cjs/forms/resizeCommandFormColumn.js.map +1 -0
  17. package/dist/cjs/forms/updateCommandFormFieldPlacement.js +27 -0
  18. package/dist/cjs/forms/updateCommandFormFieldPlacement.js.map +1 -0
  19. package/dist/cjs/forms/validateCommandFormLayout.js +72 -0
  20. package/dist/cjs/forms/validateCommandFormLayout.js.map +1 -0
  21. package/dist/cjs/index.js +20 -0
  22. package/dist/cjs/index.js.map +1 -1
  23. package/dist/esm/forms/CommandFormLayoutDiagnostic.d.ts +7 -0
  24. package/dist/esm/forms/CommandFormLayoutDiagnostic.d.ts.map +1 -0
  25. package/dist/esm/forms/CommandFormLayoutDiagnostic.js +2 -0
  26. package/dist/esm/forms/CommandFormLayoutDiagnostic.js.map +1 -0
  27. package/dist/esm/forms/CommandFormLayoutDiagnosticCode.d.ts +11 -0
  28. package/dist/esm/forms/CommandFormLayoutDiagnosticCode.d.ts.map +1 -0
  29. package/dist/esm/forms/CommandFormLayoutDiagnosticCode.js +18 -0
  30. package/dist/esm/forms/CommandFormLayoutDiagnosticCode.js.map +1 -0
  31. package/dist/esm/forms/CommandFormLayoutDraft.d.ts +9 -0
  32. package/dist/esm/forms/CommandFormLayoutDraft.d.ts.map +1 -0
  33. package/dist/esm/forms/CommandFormLayoutDraft.js +2 -0
  34. package/dist/esm/forms/CommandFormLayoutDraft.js.map +1 -0
  35. package/dist/esm/forms/commitCommandFormLayoutDraft.d.ts +4 -0
  36. package/dist/esm/forms/commitCommandFormLayoutDraft.d.ts.map +1 -0
  37. package/dist/esm/forms/commitCommandFormLayoutDraft.js +10 -0
  38. package/dist/esm/forms/commitCommandFormLayoutDraft.js.map +1 -0
  39. package/dist/esm/forms/defaultCommandFormLayout.d.ts +3 -0
  40. package/dist/esm/forms/defaultCommandFormLayout.d.ts.map +1 -0
  41. package/dist/esm/forms/defaultCommandFormLayout.js +21 -0
  42. package/dist/esm/forms/defaultCommandFormLayout.js.map +1 -0
  43. package/dist/esm/forms/formWidthToCss.d.ts +3 -0
  44. package/dist/esm/forms/formWidthToCss.d.ts.map +1 -0
  45. package/dist/esm/forms/formWidthToCss.js +22 -0
  46. package/dist/esm/forms/formWidthToCss.js.map +1 -0
  47. package/dist/esm/forms/index.d.ts +13 -0
  48. package/dist/esm/forms/index.d.ts.map +1 -0
  49. package/dist/esm/forms/index.js +13 -0
  50. package/dist/esm/forms/index.js.map +1 -0
  51. package/dist/esm/forms/normalizeCommandFormLayout.d.ts +8 -0
  52. package/dist/esm/forms/normalizeCommandFormLayout.d.ts.map +1 -0
  53. package/dist/esm/forms/normalizeCommandFormLayout.js +40 -0
  54. package/dist/esm/forms/normalizeCommandFormLayout.js.map +1 -0
  55. package/dist/esm/forms/parseFormWidth.d.ts +3 -0
  56. package/dist/esm/forms/parseFormWidth.d.ts.map +1 -0
  57. package/dist/esm/forms/parseFormWidth.js +32 -0
  58. package/dist/esm/forms/parseFormWidth.js.map +1 -0
  59. package/dist/esm/forms/preserveDirtyCommandValues.d.ts +2 -0
  60. package/dist/esm/forms/preserveDirtyCommandValues.d.ts.map +1 -0
  61. package/dist/esm/forms/preserveDirtyCommandValues.js +13 -0
  62. package/dist/esm/forms/preserveDirtyCommandValues.js.map +1 -0
  63. package/dist/esm/forms/resizeCommandFormColumn.d.ts +4 -0
  64. package/dist/esm/forms/resizeCommandFormColumn.d.ts.map +1 -0
  65. package/dist/esm/forms/resizeCommandFormColumn.js +25 -0
  66. package/dist/esm/forms/resizeCommandFormColumn.js.map +1 -0
  67. package/dist/esm/forms/updateCommandFormFieldPlacement.d.ts +4 -0
  68. package/dist/esm/forms/updateCommandFormFieldPlacement.d.ts.map +1 -0
  69. package/dist/esm/forms/updateCommandFormFieldPlacement.js +25 -0
  70. package/dist/esm/forms/updateCommandFormFieldPlacement.js.map +1 -0
  71. package/dist/esm/forms/validateCommandFormLayout.d.ts +4 -0
  72. package/dist/esm/forms/validateCommandFormLayout.d.ts.map +1 -0
  73. package/dist/esm/forms/validateCommandFormLayout.js +70 -0
  74. package/dist/esm/forms/validateCommandFormLayout.js.map +1 -0
  75. package/dist/esm/index.d.ts +1 -0
  76. package/dist/esm/index.d.ts.map +1 -1
  77. package/dist/esm/index.js +10 -0
  78. package/dist/esm/index.js.map +1 -1
  79. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  80. package/forms/CommandFormLayoutDiagnostic.ts +13 -0
  81. package/forms/CommandFormLayoutDiagnosticCode.ts +16 -0
  82. package/forms/CommandFormLayoutDraft.ts +15 -0
  83. package/forms/commitCommandFormLayoutDraft.ts +12 -0
  84. package/forms/defaultCommandFormLayout.ts +12 -0
  85. package/forms/formWidthToCss.ts +21 -0
  86. package/forms/index.ts +15 -0
  87. package/forms/normalizeCommandFormLayout.ts +39 -0
  88. package/forms/parseFormWidth.ts +20 -0
  89. package/forms/preserveDirtyCommandValues.ts +13 -0
  90. package/forms/resizeCommandFormColumn.ts +23 -0
  91. package/forms/updateCommandFormFieldPlacement.ts +22 -0
  92. package/forms/validateCommandFormLayout.ts +74 -0
  93. package/index.ts +1 -0
  94. package/package.json +3 -3
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ // Copyright (c) Cratis. All rights reserved.
4
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
5
+ /**
6
+ * Diagnostic codes for command-form geometry validation.
7
+ */ var CommandFormLayoutDiagnosticCode = /*#__PURE__*/ function(CommandFormLayoutDiagnosticCode) {
8
+ CommandFormLayoutDiagnosticCode["EmptyColumns"] = "emptyColumns";
9
+ CommandFormLayoutDiagnosticCode["DuplicateColumn"] = "duplicateColumn";
10
+ CommandFormLayoutDiagnosticCode["InvalidColumnIndex"] = "invalidColumnIndex";
11
+ CommandFormLayoutDiagnosticCode["InvalidWidth"] = "invalidWidth";
12
+ CommandFormLayoutDiagnosticCode["DuplicatePlacement"] = "duplicatePlacement";
13
+ CommandFormLayoutDiagnosticCode["InvalidPlacement"] = "invalidPlacement";
14
+ CommandFormLayoutDiagnosticCode["MissingField"] = "missingField";
15
+ CommandFormLayoutDiagnosticCode["OutOfBoundsPlacement"] = "outOfBoundsPlacement";
16
+ return CommandFormLayoutDiagnosticCode;
17
+ }({});
18
+
19
+ exports.CommandFormLayoutDiagnosticCode = CommandFormLayoutDiagnosticCode;
20
+ //# sourceMappingURL=CommandFormLayoutDiagnosticCode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandFormLayoutDiagnosticCode.js","sources":["../../../forms/CommandFormLayoutDiagnosticCode.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * Diagnostic codes for command-form geometry validation.\n */\nexport enum CommandFormLayoutDiagnosticCode {\n EmptyColumns = 'emptyColumns',\n DuplicateColumn = 'duplicateColumn',\n InvalidColumnIndex = 'invalidColumnIndex',\n InvalidWidth = 'invalidWidth',\n DuplicatePlacement = 'duplicatePlacement',\n InvalidPlacement = 'invalidPlacement',\n MissingField = 'missingField',\n OutOfBoundsPlacement = 'outOfBoundsPlacement',\n}\n"],"names":["CommandFormLayoutDiagnosticCode"],"mappings":";;AAAA;AACA;AAEA;;IAGO,IAAKA,+BAAAA,iBAAAA,SAAAA,+BAAAA,EAAAA;;;;;;;;;AAAAA,IAAAA,OAAAA,+BAAAA;AASX,CAAA,CAAA,EAAA;;"}
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ // Copyright (c) Cratis. All rights reserved.
4
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
5
+ /**
6
+ * Commits a draft layout only when it is valid; otherwise returns the previous committed metadata.
7
+ */ function commitCommandFormLayoutDraft(draft) {
8
+ return draft.isValid ? draft.draft : draft.committed;
9
+ }
10
+
11
+ exports.commitCommandFormLayoutDraft = commitCommandFormLayoutDraft;
12
+ //# sourceMappingURL=commitCommandFormLayoutDraft.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commitCommandFormLayoutDraft.js","sources":["../../../forms/commitCommandFormLayoutDraft.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { CommandFormLayout } from '@cratis/scene.model';\nimport { CommandFormLayoutDraft } from './CommandFormLayoutDraft';\n\n/**\n * Commits a draft layout only when it is valid; otherwise returns the previous committed metadata.\n */\nexport function commitCommandFormLayoutDraft(draft: CommandFormLayoutDraft): CommandFormLayout {\n return draft.isValid ? draft.draft : draft.committed;\n}\n"],"names":["commitCommandFormLayoutDraft","draft","isValid","committed"],"mappings":";;AAAA;AACA;AAKA;;IAGO,SAASA,4BAAAA,CAA6BC,KAA6B,EAAA;AACtE,IAAA,OAAOA,MAAMC,OAAO,GAAGD,MAAMA,KAAK,GAAGA,MAAME,SAAS;AACxD;;"}
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ var scene_model = require('@cratis/scene.model');
4
+
5
+ // Copyright (c) Cratis. All rights reserved.
6
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
7
+ /**
8
+ * Backward-compatible command form geometry: one flexible column and no authored placements.
9
+ */ const defaultCommandFormLayout = {
10
+ columns: [
11
+ {
12
+ index: 1,
13
+ width: {
14
+ unit: scene_model.FormWidthUnit.Fraction,
15
+ value: 1
16
+ }
17
+ }
18
+ ],
19
+ placements: []
20
+ };
21
+
22
+ exports.defaultCommandFormLayout = defaultCommandFormLayout;
23
+ //# sourceMappingURL=defaultCommandFormLayout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultCommandFormLayout.js","sources":["../../../forms/defaultCommandFormLayout.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { CommandFormLayout, FormWidthUnit } from '@cratis/scene.model';\n\n/**\n * Backward-compatible command form geometry: one flexible column and no authored placements.\n */\nexport const defaultCommandFormLayout: CommandFormLayout = {\n columns: [{ index: 1, width: { unit: FormWidthUnit.Fraction, value: 1 } }],\n placements: [],\n};\n"],"names":["defaultCommandFormLayout","columns","index","width","unit","FormWidthUnit","Fraction","value","placements"],"mappings":";;;;AAAA;AACA;AAIA;;UAGaA,wBAAAA,GAA8C;IACvDC,OAAAA,EAAS;AAAC,QAAA;YAAEC,KAAAA,EAAO,CAAA;YAAGC,KAAAA,EAAO;AAAEC,gBAAAA,IAAAA,EAAMC,0BAAcC,QAAQ;gBAAEC,KAAAA,EAAO;AAAE;AAAE;AAAE,KAAA;AAC1EC,IAAAA,UAAAA,EAAY;AAChB;;"}
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ var scene_model = require('@cratis/scene.model');
4
+
5
+ // Copyright (c) Cratis. All rights reserved.
6
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
7
+ /**
8
+ * Converts a platform-neutral form width to a browser CSS width token.
9
+ */ function formWidthToCss(width) {
10
+ if (!width) return undefined;
11
+ switch(width.unit){
12
+ case scene_model.FormWidthUnit.Auto:
13
+ return 'auto';
14
+ case scene_model.FormWidthUnit.Fraction:
15
+ return `${width.value ?? 1}fr`;
16
+ case scene_model.FormWidthUnit.Pixels:
17
+ return `${width.value ?? 0}px`;
18
+ case scene_model.FormWidthUnit.Percent:
19
+ return `${width.value ?? 0}%`;
20
+ }
21
+ }
22
+
23
+ exports.formWidthToCss = formWidthToCss;
24
+ //# sourceMappingURL=formWidthToCss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formWidthToCss.js","sources":["../../../forms/formWidthToCss.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { FormWidth, FormWidthUnit } from '@cratis/scene.model';\n\n/**\n * Converts a platform-neutral form width to a browser CSS width token.\n */\nexport function formWidthToCss(width: FormWidth | undefined): string | undefined {\n if (!width) return undefined;\n switch (width.unit) {\n case FormWidthUnit.Auto:\n return 'auto';\n case FormWidthUnit.Fraction:\n return `${width.value ?? 1}fr`;\n case FormWidthUnit.Pixels:\n return `${width.value ?? 0}px`;\n case FormWidthUnit.Percent:\n return `${width.value ?? 0}%`;\n }\n}\n"],"names":["formWidthToCss","width","undefined","unit","FormWidthUnit","Auto","Fraction","value","Pixels","Percent"],"mappings":";;;;AAAA;AACA;AAIA;;IAGO,SAASA,cAAAA,CAAeC,KAA4B,EAAA;IACvD,IAAI,CAACA,OAAO,OAAOC,SAAAA;AACnB,IAAA,OAAQD,MAAME,IAAI;AACd,QAAA,KAAKC,0BAAcC,IAAI;YACnB,OAAO,MAAA;AACX,QAAA,KAAKD,0BAAcE,QAAQ;AACvB,YAAA,OAAO,GAAGL,KAAAA,CAAMM,KAAK,IAAI,CAAA,CAAE,EAAE,CAAC;AAClC,QAAA,KAAKH,0BAAcI,MAAM;AACrB,YAAA,OAAO,GAAGP,KAAAA,CAAMM,KAAK,IAAI,CAAA,CAAE,EAAE,CAAC;AAClC,QAAA,KAAKH,0BAAcK,OAAO;AACtB,YAAA,OAAO,GAAGR,KAAAA,CAAMM,KAAK,IAAI,CAAA,CAAE,CAAC,CAAC;AACrC;AACJ;;"}
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+
3
+ var scene_model = require('@cratis/scene.model');
4
+ var defaultCommandFormLayout = require('./defaultCommandFormLayout.js');
5
+ var parseFormWidth = require('./parseFormWidth.js');
6
+
7
+ // Copyright (c) Cratis. All rights reserved.
8
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
9
+ /**
10
+ * Normalizes authored command form layout, including legacy per-input column/width metadata.
11
+ */ function normalizeCommandFormLayout(layout, inputs = []) {
12
+ if (layout) return layout;
13
+ if (!inputs.length) return defaultCommandFormLayout.defaultCommandFormLayout;
14
+ const placements = inputs.map((input, index)=>({
15
+ field: input.property,
16
+ row: index + 1,
17
+ column: positiveInteger(input.column) ?? 1,
18
+ width: parseFormWidth.parseFormWidth(input.width)
19
+ }));
20
+ const columnCount = Math.max(1, ...placements.map((placement)=>placement.column));
21
+ return {
22
+ columns: Array.from({
23
+ length: columnCount
24
+ }, (_, index)=>({
25
+ index: index + 1,
26
+ width: fraction(1)
27
+ })),
28
+ placements
29
+ };
30
+ }
31
+ function fraction(value) {
32
+ return {
33
+ unit: scene_model.FormWidthUnit.Fraction,
34
+ value
35
+ };
36
+ }
37
+ function positiveInteger(value) {
38
+ return value !== undefined && Number.isInteger(value) && value > 0 ? value : undefined;
39
+ }
40
+
41
+ exports.normalizeCommandFormLayout = normalizeCommandFormLayout;
42
+ //# sourceMappingURL=normalizeCommandFormLayout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeCommandFormLayout.js","sources":["../../../forms/normalizeCommandFormLayout.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { CommandFormLayout, FormColumn, FormFieldPlacement, FormWidth, FormWidthUnit } from '@cratis/scene.model';\nimport { defaultCommandFormLayout } from './defaultCommandFormLayout';\nimport { parseFormWidth } from './parseFormWidth';\n\nexport interface LegacyCommandFormInputGeometry {\n property: string;\n column?: number;\n width?: string;\n}\n\n/**\n * Normalizes authored command form layout, including legacy per-input column/width metadata.\n */\nexport function normalizeCommandFormLayout(layout: CommandFormLayout | undefined, inputs: readonly LegacyCommandFormInputGeometry[] = []): CommandFormLayout {\n if (layout) return layout;\n if (!inputs.length) return defaultCommandFormLayout;\n const placements = inputs.map((input, index): FormFieldPlacement => ({\n field: input.property,\n row: index + 1,\n column: positiveInteger(input.column) ?? 1,\n width: parseFormWidth(input.width),\n }));\n const columnCount = Math.max(1, ...placements.map(placement => placement.column));\n return {\n columns: Array.from({ length: columnCount }, (_, index): FormColumn => ({ index: index + 1, width: fraction(1) })),\n placements,\n };\n}\n\nfunction fraction(value: number): FormWidth {\n return { unit: FormWidthUnit.Fraction, value };\n}\n\nfunction positiveInteger(value: number | undefined): number | undefined {\n return value !== undefined && Number.isInteger(value) && value > 0 ? value : undefined;\n}\n"],"names":["normalizeCommandFormLayout","layout","inputs","length","defaultCommandFormLayout","placements","map","input","index","field","property","row","column","positiveInteger","width","parseFormWidth","columnCount","Math","max","placement","columns","Array","from","_","fraction","value","unit","FormWidthUnit","Fraction","undefined","Number","isInteger"],"mappings":";;;;;;AAAA;AACA;AAYA;;AAEC,IACM,SAASA,0BAAAA,CAA2BC,MAAqC,EAAEC,SAAoD,EAAE,EAAA;AACpI,IAAA,IAAID,QAAQ,OAAOA,MAAAA;AACnB,IAAA,IAAI,CAACC,MAAAA,CAAOC,MAAM,EAAE,OAAOC,iDAAAA;AAC3B,IAAA,MAAMC,aAAaH,MAAAA,CAAOI,GAAG,CAAC,CAACC,KAAAA,EAAOC,SAA+B;AACjEC,YAAAA,KAAAA,EAAOF,MAAMG,QAAQ;AACrBC,YAAAA,GAAAA,EAAKH,KAAAA,GAAQ,CAAA;YACbI,MAAAA,EAAQC,eAAAA,CAAgBN,KAAAA,CAAMK,MAAM,CAAA,IAAK,CAAA;YACzCE,KAAAA,EAAOC,6BAAAA,CAAeR,MAAMO,KAAK;SACrC,CAAA,CAAA;IACA,MAAME,WAAAA,GAAcC,IAAAA,CAAKC,GAAG,CAAC,CAAA,EAAA,GAAMb,UAAAA,CAAWC,GAAG,CAACa,CAAAA,SAAAA,GAAaA,SAAAA,CAAUP,MAAM,CAAA,CAAA;IAC/E,OAAO;QACHQ,OAAAA,EAASC,KAAAA,CAAMC,IAAI,CAAC;YAAEnB,MAAAA,EAAQa;SAAY,EAAG,CAACO,CAAAA,EAAGf,KAAAA,IAAuB;AAAEA,gBAAAA,KAAAA,EAAOA,KAAAA,GAAQ,CAAA;AAAGM,gBAAAA,KAAAA,EAAOU,QAAAA,CAAS,CAAA;aAAG,CAAA,CAAA;AAC/GnB,QAAAA;AACJ,KAAA;AACJ;AAEA,SAASmB,SAASC,KAAa,EAAA;IAC3B,OAAO;AAAEC,QAAAA,IAAAA,EAAMC,0BAAcC,QAAQ;AAAEH,QAAAA;AAAM,KAAA;AACjD;AAEA,SAASZ,gBAAgBY,KAAyB,EAAA;IAC9C,OAAOA,KAAAA,KAAUI,aAAaC,MAAAA,CAAOC,SAAS,CAACN,KAAAA,CAAAA,IAAUA,KAAAA,GAAQ,IAAIA,KAAAA,GAAQI,SAAAA;AACjF;;"}
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ var scene_model = require('@cratis/scene.model');
4
+
5
+ // Copyright (c) Cratis. All rights reserved.
6
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
7
+ /**
8
+ * Parses a legacy width token into typed form geometry. Arbitrary strings are intentionally rejected.
9
+ */ function parseFormWidth(value) {
10
+ if (!value || typeof value !== 'string') return undefined;
11
+ const trimmed = value.trim();
12
+ if (trimmed === 'auto') return {
13
+ unit: scene_model.FormWidthUnit.Auto
14
+ };
15
+ const match = /^([0-9]+(?:\.[0-9]+)?)(fr|px|%)$/.exec(trimmed);
16
+ if (!match) return undefined;
17
+ const widthValue = Number(match[1]);
18
+ if (!Number.isFinite(widthValue) || widthValue < 0) return undefined;
19
+ if (match[2] === 'fr') return {
20
+ unit: scene_model.FormWidthUnit.Fraction,
21
+ value: widthValue
22
+ };
23
+ if (match[2] === 'px') return {
24
+ unit: scene_model.FormWidthUnit.Pixels,
25
+ value: widthValue
26
+ };
27
+ return {
28
+ unit: scene_model.FormWidthUnit.Percent,
29
+ value: widthValue
30
+ };
31
+ }
32
+
33
+ exports.parseFormWidth = parseFormWidth;
34
+ //# sourceMappingURL=parseFormWidth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseFormWidth.js","sources":["../../../forms/parseFormWidth.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { FormWidth, FormWidthUnit } from '@cratis/scene.model';\n\n/**\n * Parses a legacy width token into typed form geometry. Arbitrary strings are intentionally rejected.\n */\nexport function parseFormWidth(value: unknown): FormWidth | undefined {\n if (!value || typeof value !== 'string') return undefined;\n const trimmed = value.trim();\n if (trimmed === 'auto') return { unit: FormWidthUnit.Auto };\n const match = /^([0-9]+(?:\\.[0-9]+)?)(fr|px|%)$/.exec(trimmed);\n if (!match) return undefined;\n const widthValue = Number(match[1]);\n if (!Number.isFinite(widthValue) || widthValue < 0) return undefined;\n if (match[2] === 'fr') return { unit: FormWidthUnit.Fraction, value: widthValue };\n if (match[2] === 'px') return { unit: FormWidthUnit.Pixels, value: widthValue };\n return { unit: FormWidthUnit.Percent, value: widthValue };\n}\n"],"names":["parseFormWidth","value","undefined","trimmed","trim","unit","FormWidthUnit","Auto","match","exec","widthValue","Number","isFinite","Fraction","Pixels","Percent"],"mappings":";;;;AAAA;AACA;AAIA;;IAGO,SAASA,cAAAA,CAAeC,KAAc,EAAA;AACzC,IAAA,IAAI,CAACA,KAAAA,IAAS,OAAOA,KAAAA,KAAU,UAAU,OAAOC,SAAAA;IAChD,MAAMC,OAAAA,GAAUF,MAAMG,IAAI,EAAA;IAC1B,IAAID,OAAAA,KAAY,QAAQ,OAAO;AAAEE,QAAAA,IAAAA,EAAMC,0BAAcC;AAAK,KAAA;IAC1D,MAAMC,KAAAA,GAAQ,kCAAA,CAAmCC,IAAI,CAACN,OAAAA,CAAAA;IACtD,IAAI,CAACK,OAAO,OAAON,SAAAA;AACnB,IAAA,MAAMQ,UAAAA,GAAaC,MAAAA,CAAOH,KAAK,CAAC,CAAA,CAAE,CAAA;AAClC,IAAA,IAAI,CAACG,MAAAA,CAAOC,QAAQ,CAACF,UAAAA,CAAAA,IAAeA,UAAAA,GAAa,GAAG,OAAOR,SAAAA;AAC3D,IAAA,IAAIM,KAAK,CAAC,CAAA,CAAE,KAAK,MAAM,OAAO;AAAEH,QAAAA,IAAAA,EAAMC,0BAAcO,QAAQ;QAAEZ,KAAAA,EAAOS;AAAW,KAAA;AAChF,IAAA,IAAIF,KAAK,CAAC,CAAA,CAAE,KAAK,MAAM,OAAO;AAAEH,QAAAA,IAAAA,EAAMC,0BAAcQ,MAAM;QAAEb,KAAAA,EAAOS;AAAW,KAAA;IAC9E,OAAO;AAAEL,QAAAA,IAAAA,EAAMC,0BAAcS,OAAO;QAAEd,KAAAA,EAAOS;AAAW,KAAA;AAC5D;;"}
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ // Copyright (c) Cratis. All rights reserved.
4
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
5
+ /**
6
+ * Merges refreshed command values without overwriting dirty fields a user is editing.
7
+ */ function preserveDirtyCommandValues(current, refreshed, dirtyFields) {
8
+ return Object.fromEntries(Object.entries(refreshed).map(([field, value])=>[
9
+ field,
10
+ dirtyFields.has(field) ? current[field] : value
11
+ ]));
12
+ }
13
+
14
+ exports.preserveDirtyCommandValues = preserveDirtyCommandValues;
15
+ //# sourceMappingURL=preserveDirtyCommandValues.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preserveDirtyCommandValues.js","sources":["../../../forms/preserveDirtyCommandValues.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * Merges refreshed command values without overwriting dirty fields a user is editing.\n */\nexport function preserveDirtyCommandValues(\n current: Record<string, unknown>,\n refreshed: Record<string, unknown>,\n dirtyFields: ReadonlySet<string>,\n): Record<string, unknown> {\n return Object.fromEntries(Object.entries(refreshed).map(([field, value]) => [field, dirtyFields.has(field) ? current[field] : value]));\n}\n"],"names":["preserveDirtyCommandValues","current","refreshed","dirtyFields","Object","fromEntries","entries","map","field","value","has"],"mappings":";;AAAA;AACA;AAEA;;AAEC,IACM,SAASA,0BAAAA,CACZC,OAAgC,EAChCC,SAAkC,EAClCC,WAAgC,EAAA;AAEhC,IAAA,OAAOC,MAAAA,CAAOC,WAAW,CAACD,MAAAA,CAAOE,OAAO,CAACJ,SAAAA,CAAAA,CAAWK,GAAG,CAAC,CAAC,CAACC,KAAAA,EAAOC,MAAM,GAAK;AAACD,YAAAA,KAAAA;AAAOL,YAAAA,WAAAA,CAAYO,GAAG,CAACF,KAAAA,CAAAA,GAASP,OAAO,CAACO,MAAM,GAAGC;AAAM,SAAA,CAAA,CAAA;AACxI;;"}
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ var validateCommandFormLayout = require('./validateCommandFormLayout.js');
4
+
5
+ // Copyright (c) Cratis. All rights reserved.
6
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
7
+ /**
8
+ * Resizes a column as draft geometry, keeping the last committed layout separate when invalid.
9
+ */ function resizeCommandFormColumn(committed, columnIndex, width, fields = []) {
10
+ const draft = {
11
+ ...committed,
12
+ columns: committed.columns.map((column)=>column.index === columnIndex ? {
13
+ ...column,
14
+ width
15
+ } : column)
16
+ };
17
+ const diagnostics = validateCommandFormLayout.validateCommandFormLayout(draft, fields);
18
+ return {
19
+ committed,
20
+ draft,
21
+ diagnostics,
22
+ isValid: diagnostics.length === 0
23
+ };
24
+ }
25
+
26
+ exports.resizeCommandFormColumn = resizeCommandFormColumn;
27
+ //# sourceMappingURL=resizeCommandFormColumn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resizeCommandFormColumn.js","sources":["../../../forms/resizeCommandFormColumn.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { CommandFormLayout, FormWidth } from '@cratis/scene.model';\nimport { CommandFormLayoutDraft } from './CommandFormLayoutDraft';\nimport { validateCommandFormLayout } from './validateCommandFormLayout';\n\n/**\n * Resizes a column as draft geometry, keeping the last committed layout separate when invalid.\n */\nexport function resizeCommandFormColumn(\n committed: CommandFormLayout,\n columnIndex: number,\n width: FormWidth,\n fields: readonly string[] = [],\n): CommandFormLayoutDraft {\n const draft: CommandFormLayout = {\n ...committed,\n columns: committed.columns.map(column => column.index === columnIndex ? { ...column, width } : column),\n };\n const diagnostics = validateCommandFormLayout(draft, fields);\n return { committed, draft, diagnostics, isValid: diagnostics.length === 0 };\n}\n"],"names":["resizeCommandFormColumn","committed","columnIndex","width","fields","draft","columns","map","column","index","diagnostics","validateCommandFormLayout","isValid","length"],"mappings":";;;;AAAA;AACA;AAMA;;IAGO,SAASA,uBAAAA,CACZC,SAA4B,EAC5BC,WAAmB,EACnBC,KAAgB,EAChBC,MAAAA,GAA4B,EAAE,EAAA;AAE9B,IAAA,MAAMC,KAAAA,GAA2B;AAC7B,QAAA,GAAGJ,SAAS;QACZK,OAAAA,EAASL,SAAAA,CAAUK,OAAO,CAACC,GAAG,CAACC,CAAAA,MAAAA,GAAUA,MAAAA,CAAOC,KAAK,KAAKP,WAAAA,GAAc;AAAE,gBAAA,GAAGM,MAAM;AAAEL,gBAAAA;aAAM,GAAIK,MAAAA;AACnG,KAAA;IACA,MAAME,WAAAA,GAAcC,oDAA0BN,KAAAA,EAAOD,MAAAA,CAAAA;IACrD,OAAO;AAAEH,QAAAA,SAAAA;AAAWI,QAAAA,KAAAA;AAAOK,QAAAA,WAAAA;QAAaE,OAAAA,EAASF,WAAAA,CAAYG,MAAM,KAAK;AAAE,KAAA;AAC9E;;"}
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ var validateCommandFormLayout = require('./validateCommandFormLayout.js');
4
+
5
+ // Copyright (c) Cratis. All rights reserved.
6
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
7
+ /**
8
+ * Updates a field placement as draft geometry, keeping the committed layout separate when invalid.
9
+ */ function updateCommandFormFieldPlacement(committed, placement, fields = []) {
10
+ const draft = {
11
+ ...committed,
12
+ placements: [
13
+ ...committed.placements.filter((existing)=>existing.field !== placement.field),
14
+ placement
15
+ ]
16
+ };
17
+ const diagnostics = validateCommandFormLayout.validateCommandFormLayout(draft, fields);
18
+ return {
19
+ committed,
20
+ draft,
21
+ diagnostics,
22
+ isValid: diagnostics.length === 0
23
+ };
24
+ }
25
+
26
+ exports.updateCommandFormFieldPlacement = updateCommandFormFieldPlacement;
27
+ //# sourceMappingURL=updateCommandFormFieldPlacement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateCommandFormFieldPlacement.js","sources":["../../../forms/updateCommandFormFieldPlacement.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { CommandFormLayout, FormFieldPlacement } from '@cratis/scene.model';\nimport { CommandFormLayoutDraft } from './CommandFormLayoutDraft';\nimport { validateCommandFormLayout } from './validateCommandFormLayout';\n\n/**\n * Updates a field placement as draft geometry, keeping the committed layout separate when invalid.\n */\nexport function updateCommandFormFieldPlacement(\n committed: CommandFormLayout,\n placement: FormFieldPlacement,\n fields: readonly string[] = [],\n): CommandFormLayoutDraft {\n const draft: CommandFormLayout = {\n ...committed,\n placements: [...committed.placements.filter(existing => existing.field !== placement.field), placement],\n };\n const diagnostics = validateCommandFormLayout(draft, fields);\n return { committed, draft, diagnostics, isValid: diagnostics.length === 0 };\n}\n"],"names":["updateCommandFormFieldPlacement","committed","placement","fields","draft","placements","filter","existing","field","diagnostics","validateCommandFormLayout","isValid","length"],"mappings":";;;;AAAA;AACA;AAMA;;IAGO,SAASA,+BAAAA,CACZC,SAA4B,EAC5BC,SAA6B,EAC7BC,SAA4B,EAAE,EAAA;AAE9B,IAAA,MAAMC,KAAAA,GAA2B;AAC7B,QAAA,GAAGH,SAAS;QACZI,UAAAA,EAAY;eAAIJ,SAAAA,CAAUI,UAAU,CAACC,MAAM,CAACC,CAAAA,WAAYA,QAAAA,CAASC,KAAK,KAAKN,SAAAA,CAAUM,KAAK,CAAA;AAAGN,YAAAA;AAAU;AAC3G,KAAA;IACA,MAAMO,WAAAA,GAAcC,oDAA0BN,KAAAA,EAAOD,MAAAA,CAAAA;IACrD,OAAO;AAAEF,QAAAA,SAAAA;AAAWG,QAAAA,KAAAA;AAAOK,QAAAA,WAAAA;QAAaE,OAAAA,EAASF,WAAAA,CAAYG,MAAM,KAAK;AAAE,KAAA;AAC9E;;"}
@@ -0,0 +1,72 @@
1
+ 'use strict';
2
+
3
+ var scene_model = require('@cratis/scene.model');
4
+ var CommandFormLayoutDiagnosticCode = require('./CommandFormLayoutDiagnosticCode.js');
5
+
6
+ // Copyright (c) Cratis. All rights reserved.
7
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
8
+ /**
9
+ * Validates authored command-form geometry without rewriting invalid drafts.
10
+ */ function validateCommandFormLayout(layout, fields = []) {
11
+ const diagnostics = [];
12
+ const columnIndexes = new Set();
13
+ const knownFields = new Set(fields);
14
+ if (!layout.columns.length) diagnostics.push(problem(CommandFormLayoutDiagnosticCode.CommandFormLayoutDiagnosticCode.EmptyColumns, 'At least one column is required.', 'columns'));
15
+ layout.columns.forEach((column, index)=>{
16
+ if (!Number.isInteger(column.index) || column.index < 1) {
17
+ diagnostics.push(problem(CommandFormLayoutDiagnosticCode.CommandFormLayoutDiagnosticCode.InvalidColumnIndex, `Column ${index + 1} must have a one-based integer index.`, `columns.${index}.index`));
18
+ }
19
+ if (columnIndexes.has(column.index)) {
20
+ diagnostics.push(problem(CommandFormLayoutDiagnosticCode.CommandFormLayoutDiagnosticCode.DuplicateColumn, `Column ${column.index} is declared more than once.`, `columns.${index}.index`));
21
+ }
22
+ columnIndexes.add(column.index);
23
+ validateWidth(column.width, `columns.${index}.width`, diagnostics);
24
+ validateWidth(column.minWidth, `columns.${index}.minWidth`, diagnostics);
25
+ validateWidth(column.maxWidth, `columns.${index}.maxWidth`, diagnostics);
26
+ });
27
+ validateWidth(layout.columnGap, 'columnGap', diagnostics);
28
+ validateWidth(layout.rowGap, 'rowGap', diagnostics);
29
+ const placements = new Set();
30
+ layout.placements.forEach((placement, index)=>{
31
+ if (!placement.field.trim()) diagnostics.push(problem(CommandFormLayoutDiagnosticCode.CommandFormLayoutDiagnosticCode.MissingField, 'A placement must name its field.', `placements.${index}.field`));
32
+ if (knownFields.size && !knownFields.has(placement.field)) {
33
+ diagnostics.push(problem(CommandFormLayoutDiagnosticCode.CommandFormLayoutDiagnosticCode.MissingField, `Placement targets unknown field '${placement.field}'.`, `placements.${index}.field`));
34
+ }
35
+ if (placements.has(placement.field)) {
36
+ diagnostics.push(problem(CommandFormLayoutDiagnosticCode.CommandFormLayoutDiagnosticCode.DuplicatePlacement, `Field '${placement.field}' is placed more than once.`, `placements.${index}.field`));
37
+ }
38
+ placements.add(placement.field);
39
+ if (!Number.isInteger(placement.row) || placement.row < 1 || !Number.isInteger(placement.column) || placement.column < 1 || placement.rowSpan !== undefined && (!Number.isInteger(placement.rowSpan) || placement.rowSpan < 1) || placement.columnSpan !== undefined && (!Number.isInteger(placement.columnSpan) || placement.columnSpan < 1)) {
40
+ diagnostics.push(problem(CommandFormLayoutDiagnosticCode.CommandFormLayoutDiagnosticCode.InvalidPlacement, `Placement for '${placement.field}' must use positive integer row, column and span values.`, `placements.${index}`));
41
+ }
42
+ const span = placement.columnSpan ?? 1;
43
+ if (layout.columns.length && placement.column + span - 1 > layout.columns.length) {
44
+ diagnostics.push(problem(CommandFormLayoutDiagnosticCode.CommandFormLayoutDiagnosticCode.OutOfBoundsPlacement, `Placement for '${placement.field}' extends beyond the declared columns.`, `placements.${index}.columnSpan`));
45
+ }
46
+ validateWidth(placement.width, `placements.${index}.width`, diagnostics);
47
+ });
48
+ return diagnostics;
49
+ }
50
+ function validateWidth(width, path, diagnostics) {
51
+ if (!width) return;
52
+ if (!Object.values(scene_model.FormWidthUnit).includes(width.unit)) {
53
+ diagnostics.push(problem(CommandFormLayoutDiagnosticCode.CommandFormLayoutDiagnosticCode.InvalidWidth, `Width at '${path}' uses an unsupported unit.`, path));
54
+ return;
55
+ }
56
+ if (width.unit === scene_model.FormWidthUnit.Auto && width.value !== undefined) {
57
+ diagnostics.push(problem(CommandFormLayoutDiagnosticCode.CommandFormLayoutDiagnosticCode.InvalidWidth, `Automatic width at '${path}' must not carry a numeric value.`, path));
58
+ }
59
+ if (width.unit !== scene_model.FormWidthUnit.Auto && (width.value === undefined || width.value < 0 || !Number.isFinite(width.value))) {
60
+ diagnostics.push(problem(CommandFormLayoutDiagnosticCode.CommandFormLayoutDiagnosticCode.InvalidWidth, `Width at '${path}' must carry a non-negative numeric value.`, path));
61
+ }
62
+ }
63
+ function problem(code, message, path) {
64
+ return {
65
+ code,
66
+ message,
67
+ path
68
+ };
69
+ }
70
+
71
+ exports.validateCommandFormLayout = validateCommandFormLayout;
72
+ //# sourceMappingURL=validateCommandFormLayout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateCommandFormLayout.js","sources":["../../../forms/validateCommandFormLayout.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { CommandFormLayout, FormWidth, FormWidthUnit } from '@cratis/scene.model';\nimport { CommandFormLayoutDiagnostic } from './CommandFormLayoutDiagnostic';\nimport { CommandFormLayoutDiagnosticCode } from './CommandFormLayoutDiagnosticCode';\n\n/**\n * Validates authored command-form geometry without rewriting invalid drafts.\n */\nexport function validateCommandFormLayout(layout: CommandFormLayout, fields: readonly string[] = []): CommandFormLayoutDiagnostic[] {\n const diagnostics: CommandFormLayoutDiagnostic[] = [];\n const columnIndexes = new Set<number>();\n const knownFields = new Set(fields);\n\n if (!layout.columns.length) diagnostics.push(problem(CommandFormLayoutDiagnosticCode.EmptyColumns, 'At least one column is required.', 'columns'));\n layout.columns.forEach((column, index) => {\n if (!Number.isInteger(column.index) || column.index < 1) {\n diagnostics.push(problem(CommandFormLayoutDiagnosticCode.InvalidColumnIndex, `Column ${index + 1} must have a one-based integer index.`, `columns.${index}.index`));\n }\n if (columnIndexes.has(column.index)) {\n diagnostics.push(problem(CommandFormLayoutDiagnosticCode.DuplicateColumn, `Column ${column.index} is declared more than once.`, `columns.${index}.index`));\n }\n columnIndexes.add(column.index);\n validateWidth(column.width, `columns.${index}.width`, diagnostics);\n validateWidth(column.minWidth, `columns.${index}.minWidth`, diagnostics);\n validateWidth(column.maxWidth, `columns.${index}.maxWidth`, diagnostics);\n });\n\n validateWidth(layout.columnGap, 'columnGap', diagnostics);\n validateWidth(layout.rowGap, 'rowGap', diagnostics);\n\n const placements = new Set<string>();\n layout.placements.forEach((placement, index) => {\n if (!placement.field.trim()) diagnostics.push(problem(CommandFormLayoutDiagnosticCode.MissingField, 'A placement must name its field.', `placements.${index}.field`));\n if (knownFields.size && !knownFields.has(placement.field)) {\n diagnostics.push(problem(CommandFormLayoutDiagnosticCode.MissingField, `Placement targets unknown field '${placement.field}'.`, `placements.${index}.field`));\n }\n if (placements.has(placement.field)) {\n diagnostics.push(problem(CommandFormLayoutDiagnosticCode.DuplicatePlacement, `Field '${placement.field}' is placed more than once.`, `placements.${index}.field`));\n }\n placements.add(placement.field);\n if (!Number.isInteger(placement.row) || placement.row < 1 || !Number.isInteger(placement.column) || placement.column < 1 ||\n (placement.rowSpan !== undefined && (!Number.isInteger(placement.rowSpan) || placement.rowSpan < 1)) ||\n (placement.columnSpan !== undefined && (!Number.isInteger(placement.columnSpan) || placement.columnSpan < 1))) {\n diagnostics.push(problem(CommandFormLayoutDiagnosticCode.InvalidPlacement, `Placement for '${placement.field}' must use positive integer row, column and span values.`, `placements.${index}`));\n }\n const span = placement.columnSpan ?? 1;\n if (layout.columns.length && placement.column + span - 1 > layout.columns.length) {\n diagnostics.push(problem(CommandFormLayoutDiagnosticCode.OutOfBoundsPlacement, `Placement for '${placement.field}' extends beyond the declared columns.`, `placements.${index}.columnSpan`));\n }\n validateWidth(placement.width, `placements.${index}.width`, diagnostics);\n });\n\n return diagnostics;\n}\n\nfunction validateWidth(width: FormWidth | undefined, path: string, diagnostics: CommandFormLayoutDiagnostic[]): void {\n if (!width) return;\n if (!Object.values(FormWidthUnit).includes(width.unit)) {\n diagnostics.push(problem(CommandFormLayoutDiagnosticCode.InvalidWidth, `Width at '${path}' uses an unsupported unit.`, path));\n return;\n }\n if (width.unit === FormWidthUnit.Auto && width.value !== undefined) {\n diagnostics.push(problem(CommandFormLayoutDiagnosticCode.InvalidWidth, `Automatic width at '${path}' must not carry a numeric value.`, path));\n }\n if (width.unit !== FormWidthUnit.Auto && (width.value === undefined || width.value < 0 || !Number.isFinite(width.value))) {\n diagnostics.push(problem(CommandFormLayoutDiagnosticCode.InvalidWidth, `Width at '${path}' must carry a non-negative numeric value.`, path));\n }\n}\n\nfunction problem(code: CommandFormLayoutDiagnosticCode, message: string, path: string): CommandFormLayoutDiagnostic {\n return { code, message, path };\n}\n"],"names":["validateCommandFormLayout","layout","fields","diagnostics","columnIndexes","Set","knownFields","columns","length","push","problem","CommandFormLayoutDiagnosticCode","EmptyColumns","forEach","column","index","Number","isInteger","InvalidColumnIndex","has","DuplicateColumn","add","validateWidth","width","minWidth","maxWidth","columnGap","rowGap","placements","placement","field","trim","MissingField","size","DuplicatePlacement","row","rowSpan","undefined","columnSpan","InvalidPlacement","span","OutOfBoundsPlacement","path","Object","values","FormWidthUnit","includes","unit","InvalidWidth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AAC5B,KAAAA,CAAM2B,KAAK,CAAA,CAAA,EAAI;AACtH/C,QAAAA,WAAAA,CAAYM,IAAI,CAACC,OAAAA,CAAQC,+DAAAA,CAAgCqC,YAAY,EAAE,CAAC,UAAU,EAAEN,IAAAA,CAAK,0CAA0C,CAAC,EAAEA,IAAAA,CAAAA,CAAAA;AAC1I,IAAA;AACJ;AAEA,SAAShC,OAAAA,CAAQ0C,IAAqC,EAAEC,OAAe,EAAEX,IAAY,EAAA;IACjF,OAAO;AAAEU,QAAAA,IAAAA;AAAMC,QAAAA,OAAAA;AAASX,QAAAA;AAAK,KAAA;AACjC;;"}
package/dist/cjs/index.js CHANGED
@@ -3,6 +3,16 @@
3
3
  var resolveBindingExpression = require('./resolveBindingExpression.js');
4
4
  var validateBindingExpression = require('./validateBindingExpression.js');
5
5
  var renderElement = require('./renderElement.js');
6
+ var CommandFormLayoutDiagnosticCode = require('./forms/CommandFormLayoutDiagnosticCode.js');
7
+ var commitCommandFormLayoutDraft = require('./forms/commitCommandFormLayoutDraft.js');
8
+ var defaultCommandFormLayout = require('./forms/defaultCommandFormLayout.js');
9
+ var formWidthToCss = require('./forms/formWidthToCss.js');
10
+ var normalizeCommandFormLayout = require('./forms/normalizeCommandFormLayout.js');
11
+ var parseFormWidth = require('./forms/parseFormWidth.js');
12
+ var preserveDirtyCommandValues = require('./forms/preserveDirtyCommandValues.js');
13
+ var resizeCommandFormColumn = require('./forms/resizeCommandFormColumn.js');
14
+ var updateCommandFormFieldPlacement = require('./forms/updateCommandFormFieldPlacement.js');
15
+ var validateCommandFormLayout = require('./forms/validateCommandFormLayout.js');
6
16
  var elementKind = require('./elementKind.js');
7
17
  var panelKind = require('./panelKind.js');
8
18
  var flowNodeKind = require('./flowNodeKind.js');
@@ -53,6 +63,16 @@ exports.createBindingResolver = resolveBindingExpression.createBindingResolver;
53
63
  exports.resolveBindingExpression = resolveBindingExpression.resolveBindingExpression;
54
64
  exports.validateBindingExpression = validateBindingExpression.validateBindingExpression;
55
65
  exports.renderElement = renderElement.renderElement;
66
+ exports.CommandFormLayoutDiagnosticCode = CommandFormLayoutDiagnosticCode.CommandFormLayoutDiagnosticCode;
67
+ exports.commitCommandFormLayoutDraft = commitCommandFormLayoutDraft.commitCommandFormLayoutDraft;
68
+ exports.defaultCommandFormLayout = defaultCommandFormLayout.defaultCommandFormLayout;
69
+ exports.formWidthToCss = formWidthToCss.formWidthToCss;
70
+ exports.normalizeCommandFormLayout = normalizeCommandFormLayout.normalizeCommandFormLayout;
71
+ exports.parseFormWidth = parseFormWidth.parseFormWidth;
72
+ exports.preserveDirtyCommandValues = preserveDirtyCommandValues.preserveDirtyCommandValues;
73
+ exports.resizeCommandFormColumn = resizeCommandFormColumn.resizeCommandFormColumn;
74
+ exports.updateCommandFormFieldPlacement = updateCommandFormFieldPlacement.updateCommandFormFieldPlacement;
75
+ exports.validateCommandFormLayout = validateCommandFormLayout.validateCommandFormLayout;
56
76
  exports.isContentControl = elementKind.isContentControl;
57
77
  exports.isExternalComponent = elementKind.isExternalComponent;
58
78
  exports.isItemsControl = elementKind.isItemsControl;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,7 @@
1
+ import { CommandFormLayoutDiagnosticCode } from './CommandFormLayoutDiagnosticCode';
2
+ export interface CommandFormLayoutDiagnostic {
3
+ code: CommandFormLayoutDiagnosticCode;
4
+ message: string;
5
+ path: string;
6
+ }
7
+ //# sourceMappingURL=CommandFormLayoutDiagnostic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandFormLayoutDiagnostic.d.ts","sourceRoot":"","sources":["../../../forms/CommandFormLayoutDiagnostic.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AAKpF,MAAM,WAAW,2BAA2B;IACxC,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=CommandFormLayoutDiagnostic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandFormLayoutDiagnostic.js","sourceRoot":"","sources":["../../../forms/CommandFormLayoutDiagnostic.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ export declare enum CommandFormLayoutDiagnosticCode {
2
+ EmptyColumns = "emptyColumns",
3
+ DuplicateColumn = "duplicateColumn",
4
+ InvalidColumnIndex = "invalidColumnIndex",
5
+ InvalidWidth = "invalidWidth",
6
+ DuplicatePlacement = "duplicatePlacement",
7
+ InvalidPlacement = "invalidPlacement",
8
+ MissingField = "missingField",
9
+ OutOfBoundsPlacement = "outOfBoundsPlacement"
10
+ }
11
+ //# sourceMappingURL=CommandFormLayoutDiagnosticCode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandFormLayoutDiagnosticCode.d.ts","sourceRoot":"","sources":["../../../forms/CommandFormLayoutDiagnosticCode.ts"],"names":[],"mappings":"AAMA,oBAAY,+BAA+B;IACvC,YAAY,iBAAiB;IAC7B,eAAe,oBAAoB;IACnC,kBAAkB,uBAAuB;IACzC,YAAY,iBAAiB;IAC7B,kBAAkB,uBAAuB;IACzC,gBAAgB,qBAAqB;IACrC,YAAY,iBAAiB;IAC7B,oBAAoB,yBAAyB;CAChD"}
@@ -0,0 +1,18 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+ /**
4
+ * Diagnostic codes for command-form geometry validation.
5
+ */ var CommandFormLayoutDiagnosticCode = /*#__PURE__*/ function(CommandFormLayoutDiagnosticCode) {
6
+ CommandFormLayoutDiagnosticCode["EmptyColumns"] = "emptyColumns";
7
+ CommandFormLayoutDiagnosticCode["DuplicateColumn"] = "duplicateColumn";
8
+ CommandFormLayoutDiagnosticCode["InvalidColumnIndex"] = "invalidColumnIndex";
9
+ CommandFormLayoutDiagnosticCode["InvalidWidth"] = "invalidWidth";
10
+ CommandFormLayoutDiagnosticCode["DuplicatePlacement"] = "duplicatePlacement";
11
+ CommandFormLayoutDiagnosticCode["InvalidPlacement"] = "invalidPlacement";
12
+ CommandFormLayoutDiagnosticCode["MissingField"] = "missingField";
13
+ CommandFormLayoutDiagnosticCode["OutOfBoundsPlacement"] = "outOfBoundsPlacement";
14
+ return CommandFormLayoutDiagnosticCode;
15
+ }({});
16
+
17
+ export { CommandFormLayoutDiagnosticCode };
18
+ //# sourceMappingURL=CommandFormLayoutDiagnosticCode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandFormLayoutDiagnosticCode.js","sources":["../../../forms/CommandFormLayoutDiagnosticCode.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * Diagnostic codes for command-form geometry validation.\n */\nexport enum CommandFormLayoutDiagnosticCode {\n EmptyColumns = 'emptyColumns',\n DuplicateColumn = 'duplicateColumn',\n InvalidColumnIndex = 'invalidColumnIndex',\n InvalidWidth = 'invalidWidth',\n DuplicatePlacement = 'duplicatePlacement',\n InvalidPlacement = 'invalidPlacement',\n MissingField = 'missingField',\n OutOfBoundsPlacement = 'outOfBoundsPlacement',\n}\n"],"names":["CommandFormLayoutDiagnosticCode"],"mappings":"AAAA;AACA;AAEA;;IAGO,IAAKA,+BAAAA,iBAAAA,SAAAA,+BAAAA,EAAAA;;;;;;;;;AAAAA,IAAAA,OAAAA,+BAAAA;AASX,CAAA,CAAA,EAAA;;"}
@@ -0,0 +1,9 @@
1
+ import { CommandFormLayout } from '@cratis/scene.model';
2
+ import { CommandFormLayoutDiagnostic } from './CommandFormLayoutDiagnostic';
3
+ export interface CommandFormLayoutDraft {
4
+ committed: CommandFormLayout;
5
+ draft: CommandFormLayout;
6
+ diagnostics: CommandFormLayoutDiagnostic[];
7
+ isValid: boolean;
8
+ }
9
+ //# sourceMappingURL=CommandFormLayoutDraft.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandFormLayoutDraft.d.ts","sourceRoot":"","sources":["../../../forms/CommandFormLayoutDraft.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAK5E,MAAM,WAAW,sBAAsB;IACnC,SAAS,EAAE,iBAAiB,CAAC;IAC7B,KAAK,EAAE,iBAAiB,CAAC;IACzB,WAAW,EAAE,2BAA2B,EAAE,CAAC;IAC3C,OAAO,EAAE,OAAO,CAAC;CACpB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=CommandFormLayoutDraft.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandFormLayoutDraft.js","sourceRoot":"","sources":["../../../forms/CommandFormLayoutDraft.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import { CommandFormLayout } from '@cratis/scene.model';
2
+ import { CommandFormLayoutDraft } from './CommandFormLayoutDraft';
3
+ export declare function commitCommandFormLayoutDraft(draft: CommandFormLayoutDraft): CommandFormLayout;
4
+ //# sourceMappingURL=commitCommandFormLayoutDraft.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commitCommandFormLayoutDraft.d.ts","sourceRoot":"","sources":["../../../forms/commitCommandFormLayoutDraft.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAKlE,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,sBAAsB,GAAG,iBAAiB,CAE7F"}
@@ -0,0 +1,10 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+ /**
4
+ * Commits a draft layout only when it is valid; otherwise returns the previous committed metadata.
5
+ */ function commitCommandFormLayoutDraft(draft) {
6
+ return draft.isValid ? draft.draft : draft.committed;
7
+ }
8
+
9
+ export { commitCommandFormLayoutDraft };
10
+ //# sourceMappingURL=commitCommandFormLayoutDraft.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commitCommandFormLayoutDraft.js","sources":["../../../forms/commitCommandFormLayoutDraft.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { CommandFormLayout } from '@cratis/scene.model';\nimport { CommandFormLayoutDraft } from './CommandFormLayoutDraft';\n\n/**\n * Commits a draft layout only when it is valid; otherwise returns the previous committed metadata.\n */\nexport function commitCommandFormLayoutDraft(draft: CommandFormLayoutDraft): CommandFormLayout {\n return draft.isValid ? draft.draft : draft.committed;\n}\n"],"names":["commitCommandFormLayoutDraft","draft","isValid","committed"],"mappings":"AAAA;AACA;AAKA;;IAGO,SAASA,4BAAAA,CAA6BC,KAA6B,EAAA;AACtE,IAAA,OAAOA,MAAMC,OAAO,GAAGD,MAAMA,KAAK,GAAGA,MAAME,SAAS;AACxD;;"}
@@ -0,0 +1,3 @@
1
+ import { CommandFormLayout } from '@cratis/scene.model';
2
+ export declare const defaultCommandFormLayout: CommandFormLayout;
3
+ //# sourceMappingURL=defaultCommandFormLayout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultCommandFormLayout.d.ts","sourceRoot":"","sources":["../../../forms/defaultCommandFormLayout.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAiB,MAAM,qBAAqB,CAAC;AAKvE,eAAO,MAAM,wBAAwB,EAAE,iBAGtC,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { FormWidthUnit } from '@cratis/scene.model';
2
+
3
+ // Copyright (c) Cratis. All rights reserved.
4
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
5
+ /**
6
+ * Backward-compatible command form geometry: one flexible column and no authored placements.
7
+ */ const defaultCommandFormLayout = {
8
+ columns: [
9
+ {
10
+ index: 1,
11
+ width: {
12
+ unit: FormWidthUnit.Fraction,
13
+ value: 1
14
+ }
15
+ }
16
+ ],
17
+ placements: []
18
+ };
19
+
20
+ export { defaultCommandFormLayout };
21
+ //# sourceMappingURL=defaultCommandFormLayout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultCommandFormLayout.js","sources":["../../../forms/defaultCommandFormLayout.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { CommandFormLayout, FormWidthUnit } from '@cratis/scene.model';\n\n/**\n * Backward-compatible command form geometry: one flexible column and no authored placements.\n */\nexport const defaultCommandFormLayout: CommandFormLayout = {\n columns: [{ index: 1, width: { unit: FormWidthUnit.Fraction, value: 1 } }],\n placements: [],\n};\n"],"names":["defaultCommandFormLayout","columns","index","width","unit","FormWidthUnit","Fraction","value","placements"],"mappings":";;AAAA;AACA;AAIA;;UAGaA,wBAAAA,GAA8C;IACvDC,OAAAA,EAAS;AAAC,QAAA;YAAEC,KAAAA,EAAO,CAAA;YAAGC,KAAAA,EAAO;AAAEC,gBAAAA,IAAAA,EAAMC,cAAcC,QAAQ;gBAAEC,KAAAA,EAAO;AAAE;AAAE;AAAE,KAAA;AAC1EC,IAAAA,UAAAA,EAAY;AAChB;;"}
@@ -0,0 +1,3 @@
1
+ import { FormWidth } from '@cratis/scene.model';
2
+ export declare function formWidthToCss(width: FormWidth | undefined): string | undefined;
3
+ //# sourceMappingURL=formWidthToCss.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formWidthToCss.d.ts","sourceRoot":"","sources":["../../../forms/formWidthToCss.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAiB,MAAM,qBAAqB,CAAC;AAK/D,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAY/E"}
@@ -0,0 +1,22 @@
1
+ import { FormWidthUnit } from '@cratis/scene.model';
2
+
3
+ // Copyright (c) Cratis. All rights reserved.
4
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
5
+ /**
6
+ * Converts a platform-neutral form width to a browser CSS width token.
7
+ */ function formWidthToCss(width) {
8
+ if (!width) return undefined;
9
+ switch(width.unit){
10
+ case FormWidthUnit.Auto:
11
+ return 'auto';
12
+ case FormWidthUnit.Fraction:
13
+ return `${width.value ?? 1}fr`;
14
+ case FormWidthUnit.Pixels:
15
+ return `${width.value ?? 0}px`;
16
+ case FormWidthUnit.Percent:
17
+ return `${width.value ?? 0}%`;
18
+ }
19
+ }
20
+
21
+ export { formWidthToCss };
22
+ //# sourceMappingURL=formWidthToCss.js.map