@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.
- package/dist/cjs/forms/CommandFormLayoutDiagnosticCode.js +20 -0
- package/dist/cjs/forms/CommandFormLayoutDiagnosticCode.js.map +1 -0
- package/dist/cjs/forms/commitCommandFormLayoutDraft.js +12 -0
- package/dist/cjs/forms/commitCommandFormLayoutDraft.js.map +1 -0
- package/dist/cjs/forms/defaultCommandFormLayout.js +23 -0
- package/dist/cjs/forms/defaultCommandFormLayout.js.map +1 -0
- package/dist/cjs/forms/formWidthToCss.js +24 -0
- package/dist/cjs/forms/formWidthToCss.js.map +1 -0
- package/dist/cjs/forms/normalizeCommandFormLayout.js +42 -0
- package/dist/cjs/forms/normalizeCommandFormLayout.js.map +1 -0
- package/dist/cjs/forms/parseFormWidth.js +34 -0
- package/dist/cjs/forms/parseFormWidth.js.map +1 -0
- package/dist/cjs/forms/preserveDirtyCommandValues.js +15 -0
- package/dist/cjs/forms/preserveDirtyCommandValues.js.map +1 -0
- package/dist/cjs/forms/resizeCommandFormColumn.js +27 -0
- package/dist/cjs/forms/resizeCommandFormColumn.js.map +1 -0
- package/dist/cjs/forms/updateCommandFormFieldPlacement.js +27 -0
- package/dist/cjs/forms/updateCommandFormFieldPlacement.js.map +1 -0
- package/dist/cjs/forms/validateCommandFormLayout.js +72 -0
- package/dist/cjs/forms/validateCommandFormLayout.js.map +1 -0
- package/dist/cjs/index.js +20 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/forms/CommandFormLayoutDiagnostic.d.ts +7 -0
- package/dist/esm/forms/CommandFormLayoutDiagnostic.d.ts.map +1 -0
- package/dist/esm/forms/CommandFormLayoutDiagnostic.js +2 -0
- package/dist/esm/forms/CommandFormLayoutDiagnostic.js.map +1 -0
- package/dist/esm/forms/CommandFormLayoutDiagnosticCode.d.ts +11 -0
- package/dist/esm/forms/CommandFormLayoutDiagnosticCode.d.ts.map +1 -0
- package/dist/esm/forms/CommandFormLayoutDiagnosticCode.js +18 -0
- package/dist/esm/forms/CommandFormLayoutDiagnosticCode.js.map +1 -0
- package/dist/esm/forms/CommandFormLayoutDraft.d.ts +9 -0
- package/dist/esm/forms/CommandFormLayoutDraft.d.ts.map +1 -0
- package/dist/esm/forms/CommandFormLayoutDraft.js +2 -0
- package/dist/esm/forms/CommandFormLayoutDraft.js.map +1 -0
- package/dist/esm/forms/commitCommandFormLayoutDraft.d.ts +4 -0
- package/dist/esm/forms/commitCommandFormLayoutDraft.d.ts.map +1 -0
- package/dist/esm/forms/commitCommandFormLayoutDraft.js +10 -0
- package/dist/esm/forms/commitCommandFormLayoutDraft.js.map +1 -0
- package/dist/esm/forms/defaultCommandFormLayout.d.ts +3 -0
- package/dist/esm/forms/defaultCommandFormLayout.d.ts.map +1 -0
- package/dist/esm/forms/defaultCommandFormLayout.js +21 -0
- package/dist/esm/forms/defaultCommandFormLayout.js.map +1 -0
- package/dist/esm/forms/formWidthToCss.d.ts +3 -0
- package/dist/esm/forms/formWidthToCss.d.ts.map +1 -0
- package/dist/esm/forms/formWidthToCss.js +22 -0
- package/dist/esm/forms/formWidthToCss.js.map +1 -0
- package/dist/esm/forms/index.d.ts +13 -0
- package/dist/esm/forms/index.d.ts.map +1 -0
- package/dist/esm/forms/index.js +13 -0
- package/dist/esm/forms/index.js.map +1 -0
- package/dist/esm/forms/normalizeCommandFormLayout.d.ts +8 -0
- package/dist/esm/forms/normalizeCommandFormLayout.d.ts.map +1 -0
- package/dist/esm/forms/normalizeCommandFormLayout.js +40 -0
- package/dist/esm/forms/normalizeCommandFormLayout.js.map +1 -0
- package/dist/esm/forms/parseFormWidth.d.ts +3 -0
- package/dist/esm/forms/parseFormWidth.d.ts.map +1 -0
- package/dist/esm/forms/parseFormWidth.js +32 -0
- package/dist/esm/forms/parseFormWidth.js.map +1 -0
- package/dist/esm/forms/preserveDirtyCommandValues.d.ts +2 -0
- package/dist/esm/forms/preserveDirtyCommandValues.d.ts.map +1 -0
- package/dist/esm/forms/preserveDirtyCommandValues.js +13 -0
- package/dist/esm/forms/preserveDirtyCommandValues.js.map +1 -0
- package/dist/esm/forms/resizeCommandFormColumn.d.ts +4 -0
- package/dist/esm/forms/resizeCommandFormColumn.d.ts.map +1 -0
- package/dist/esm/forms/resizeCommandFormColumn.js +25 -0
- package/dist/esm/forms/resizeCommandFormColumn.js.map +1 -0
- package/dist/esm/forms/updateCommandFormFieldPlacement.d.ts +4 -0
- package/dist/esm/forms/updateCommandFormFieldPlacement.d.ts.map +1 -0
- package/dist/esm/forms/updateCommandFormFieldPlacement.js +25 -0
- package/dist/esm/forms/updateCommandFormFieldPlacement.js.map +1 -0
- package/dist/esm/forms/validateCommandFormLayout.d.ts +4 -0
- package/dist/esm/forms/validateCommandFormLayout.d.ts.map +1 -0
- package/dist/esm/forms/validateCommandFormLayout.js +70 -0
- package/dist/esm/forms/validateCommandFormLayout.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +10 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/forms/CommandFormLayoutDiagnostic.ts +13 -0
- package/forms/CommandFormLayoutDiagnosticCode.ts +16 -0
- package/forms/CommandFormLayoutDraft.ts +15 -0
- package/forms/commitCommandFormLayoutDraft.ts +12 -0
- package/forms/defaultCommandFormLayout.ts +12 -0
- package/forms/formWidthToCss.ts +21 -0
- package/forms/index.ts +15 -0
- package/forms/normalizeCommandFormLayout.ts +39 -0
- package/forms/parseFormWidth.ts +20 -0
- package/forms/preserveDirtyCommandValues.ts +13 -0
- package/forms/resizeCommandFormColumn.ts +23 -0
- package/forms/updateCommandFormFieldPlacement.ts +22 -0
- package/forms/validateCommandFormLayout.ts +74 -0
- package/index.ts +1 -0
- package/package.json +3 -3
|
@@ -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,cAAcC,IAAI;YACnB,OAAO,MAAA;AACX,QAAA,KAAKD,cAAcE,QAAQ;AACvB,YAAA,OAAO,GAAGL,KAAAA,CAAMM,KAAK,IAAI,CAAA,CAAE,EAAE,CAAC;AAClC,QAAA,KAAKH,cAAcI,MAAM;AACrB,YAAA,OAAO,GAAGP,KAAAA,CAAMM,KAAK,IAAI,CAAA,CAAE,EAAE,CAAC;AAClC,QAAA,KAAKH,cAAcK,OAAO;AACtB,YAAA,OAAO,GAAGR,KAAAA,CAAMM,KAAK,IAAI,CAAA,CAAE,CAAC,CAAC;AACrC;AACJ;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './CommandFormLayoutDiagnostic';
|
|
2
|
+
export * from './CommandFormLayoutDiagnosticCode';
|
|
3
|
+
export * from './CommandFormLayoutDraft';
|
|
4
|
+
export * from './commitCommandFormLayoutDraft';
|
|
5
|
+
export * from './defaultCommandFormLayout';
|
|
6
|
+
export * from './formWidthToCss';
|
|
7
|
+
export * from './normalizeCommandFormLayout';
|
|
8
|
+
export * from './parseFormWidth';
|
|
9
|
+
export * from './preserveDirtyCommandValues';
|
|
10
|
+
export * from './resizeCommandFormColumn';
|
|
11
|
+
export * from './updateCommandFormFieldPlacement';
|
|
12
|
+
export * from './validateCommandFormLayout';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../forms/index.ts"],"names":[],"mappings":"AAGA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './CommandFormLayoutDiagnostic';
|
|
2
|
+
export * from './CommandFormLayoutDiagnosticCode';
|
|
3
|
+
export * from './CommandFormLayoutDraft';
|
|
4
|
+
export * from './commitCommandFormLayoutDraft';
|
|
5
|
+
export * from './defaultCommandFormLayout';
|
|
6
|
+
export * from './formWidthToCss';
|
|
7
|
+
export * from './normalizeCommandFormLayout';
|
|
8
|
+
export * from './parseFormWidth';
|
|
9
|
+
export * from './preserveDirtyCommandValues';
|
|
10
|
+
export * from './resizeCommandFormColumn';
|
|
11
|
+
export * from './updateCommandFormFieldPlacement';
|
|
12
|
+
export * from './validateCommandFormLayout';
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../forms/index.ts"],"names":[],"mappings":"AAGA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CommandFormLayout } from '@cratis/scene.model';
|
|
2
|
+
export interface LegacyCommandFormInputGeometry {
|
|
3
|
+
property: string;
|
|
4
|
+
column?: number;
|
|
5
|
+
width?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function normalizeCommandFormLayout(layout: CommandFormLayout | undefined, inputs?: readonly LegacyCommandFormInputGeometry[]): CommandFormLayout;
|
|
8
|
+
//# sourceMappingURL=normalizeCommandFormLayout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeCommandFormLayout.d.ts","sourceRoot":"","sources":["../../../forms/normalizeCommandFormLayout.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAA4D,MAAM,qBAAqB,CAAC;AAIlH,MAAM,WAAW,8BAA8B;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAKD,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,iBAAiB,GAAG,SAAS,EAAE,MAAM,GAAE,SAAS,8BAA8B,EAAO,GAAG,iBAAiB,CAc3J"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { FormWidthUnit } from '@cratis/scene.model';
|
|
2
|
+
import { defaultCommandFormLayout } from './defaultCommandFormLayout.js';
|
|
3
|
+
import { parseFormWidth } from './parseFormWidth.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
|
+
* Normalizes authored command form layout, including legacy per-input column/width metadata.
|
|
9
|
+
*/ function normalizeCommandFormLayout(layout, inputs = []) {
|
|
10
|
+
if (layout) return layout;
|
|
11
|
+
if (!inputs.length) return defaultCommandFormLayout;
|
|
12
|
+
const placements = inputs.map((input, index)=>({
|
|
13
|
+
field: input.property,
|
|
14
|
+
row: index + 1,
|
|
15
|
+
column: positiveInteger(input.column) ?? 1,
|
|
16
|
+
width: parseFormWidth(input.width)
|
|
17
|
+
}));
|
|
18
|
+
const columnCount = Math.max(1, ...placements.map((placement)=>placement.column));
|
|
19
|
+
return {
|
|
20
|
+
columns: Array.from({
|
|
21
|
+
length: columnCount
|
|
22
|
+
}, (_, index)=>({
|
|
23
|
+
index: index + 1,
|
|
24
|
+
width: fraction(1)
|
|
25
|
+
})),
|
|
26
|
+
placements
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function fraction(value) {
|
|
30
|
+
return {
|
|
31
|
+
unit: FormWidthUnit.Fraction,
|
|
32
|
+
value
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function positiveInteger(value) {
|
|
36
|
+
return value !== undefined && Number.isInteger(value) && value > 0 ? value : undefined;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { normalizeCommandFormLayout };
|
|
40
|
+
//# 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,wBAAAA;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,cAAAA,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,cAAcC,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 @@
|
|
|
1
|
+
{"version":3,"file":"parseFormWidth.d.ts","sourceRoot":"","sources":["../../../forms/parseFormWidth.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAiB,MAAM,qBAAqB,CAAC;AAK/D,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,CAWpE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
* Parses a legacy width token into typed form geometry. Arbitrary strings are intentionally rejected.
|
|
7
|
+
*/ function parseFormWidth(value) {
|
|
8
|
+
if (!value || typeof value !== 'string') return undefined;
|
|
9
|
+
const trimmed = value.trim();
|
|
10
|
+
if (trimmed === 'auto') return {
|
|
11
|
+
unit: FormWidthUnit.Auto
|
|
12
|
+
};
|
|
13
|
+
const match = /^([0-9]+(?:\.[0-9]+)?)(fr|px|%)$/.exec(trimmed);
|
|
14
|
+
if (!match) return undefined;
|
|
15
|
+
const widthValue = Number(match[1]);
|
|
16
|
+
if (!Number.isFinite(widthValue) || widthValue < 0) return undefined;
|
|
17
|
+
if (match[2] === 'fr') return {
|
|
18
|
+
unit: FormWidthUnit.Fraction,
|
|
19
|
+
value: widthValue
|
|
20
|
+
};
|
|
21
|
+
if (match[2] === 'px') return {
|
|
22
|
+
unit: FormWidthUnit.Pixels,
|
|
23
|
+
value: widthValue
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
unit: FormWidthUnit.Percent,
|
|
27
|
+
value: widthValue
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { parseFormWidth };
|
|
32
|
+
//# 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,cAAcC;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,cAAcO,QAAQ;QAAEZ,KAAAA,EAAOS;AAAW,KAAA;AAChF,IAAA,IAAIF,KAAK,CAAC,CAAA,CAAE,KAAK,MAAM,OAAO;AAAEH,QAAAA,IAAAA,EAAMC,cAAcQ,MAAM;QAAEb,KAAAA,EAAOS;AAAW,KAAA;IAC9E,OAAO;AAAEL,QAAAA,IAAAA,EAAMC,cAAcS,OAAO;QAAEd,KAAAA,EAAOS;AAAW,KAAA;AAC5D;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preserveDirtyCommandValues.d.ts","sourceRoot":"","sources":["../../../forms/preserveDirtyCommandValues.ts"],"names":[],"mappings":"AAMA,wBAAgB,0BAA0B,CACtC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,GACjC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
* Merges refreshed command values without overwriting dirty fields a user is editing.
|
|
5
|
+
*/ function preserveDirtyCommandValues(current, refreshed, dirtyFields) {
|
|
6
|
+
return Object.fromEntries(Object.entries(refreshed).map(([field, value])=>[
|
|
7
|
+
field,
|
|
8
|
+
dirtyFields.has(field) ? current[field] : value
|
|
9
|
+
]));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { preserveDirtyCommandValues };
|
|
13
|
+
//# 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,4 @@
|
|
|
1
|
+
import { CommandFormLayout, FormWidth } from '@cratis/scene.model';
|
|
2
|
+
import { CommandFormLayoutDraft } from './CommandFormLayoutDraft';
|
|
3
|
+
export declare function resizeCommandFormColumn(committed: CommandFormLayout, columnIndex: number, width: FormWidth, fields?: readonly string[]): CommandFormLayoutDraft;
|
|
4
|
+
//# sourceMappingURL=resizeCommandFormColumn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resizeCommandFormColumn.d.ts","sourceRoot":"","sources":["../../../forms/resizeCommandFormColumn.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAMlE,wBAAgB,uBAAuB,CACnC,SAAS,EAAE,iBAAiB,EAC5B,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,SAAS,EAChB,MAAM,GAAE,SAAS,MAAM,EAAO,GAC/B,sBAAsB,CAOxB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { validateCommandFormLayout } from './validateCommandFormLayout.js';
|
|
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
|
+
* Resizes a column as draft geometry, keeping the last committed layout separate when invalid.
|
|
7
|
+
*/ function resizeCommandFormColumn(committed, columnIndex, width, fields = []) {
|
|
8
|
+
const draft = {
|
|
9
|
+
...committed,
|
|
10
|
+
columns: committed.columns.map((column)=>column.index === columnIndex ? {
|
|
11
|
+
...column,
|
|
12
|
+
width
|
|
13
|
+
} : column)
|
|
14
|
+
};
|
|
15
|
+
const diagnostics = validateCommandFormLayout(draft, fields);
|
|
16
|
+
return {
|
|
17
|
+
committed,
|
|
18
|
+
draft,
|
|
19
|
+
diagnostics,
|
|
20
|
+
isValid: diagnostics.length === 0
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { resizeCommandFormColumn };
|
|
25
|
+
//# 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,0BAA0BN,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,4 @@
|
|
|
1
|
+
import { CommandFormLayout, FormFieldPlacement } from '@cratis/scene.model';
|
|
2
|
+
import { CommandFormLayoutDraft } from './CommandFormLayoutDraft';
|
|
3
|
+
export declare function updateCommandFormFieldPlacement(committed: CommandFormLayout, placement: FormFieldPlacement, fields?: readonly string[]): CommandFormLayoutDraft;
|
|
4
|
+
//# sourceMappingURL=updateCommandFormFieldPlacement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateCommandFormFieldPlacement.d.ts","sourceRoot":"","sources":["../../../forms/updateCommandFormFieldPlacement.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAMlE,wBAAgB,+BAA+B,CAC3C,SAAS,EAAE,iBAAiB,EAC5B,SAAS,EAAE,kBAAkB,EAC7B,MAAM,GAAE,SAAS,MAAM,EAAO,GAC/B,sBAAsB,CAOxB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { validateCommandFormLayout } from './validateCommandFormLayout.js';
|
|
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
|
+
* Updates a field placement as draft geometry, keeping the committed layout separate when invalid.
|
|
7
|
+
*/ function updateCommandFormFieldPlacement(committed, placement, fields = []) {
|
|
8
|
+
const draft = {
|
|
9
|
+
...committed,
|
|
10
|
+
placements: [
|
|
11
|
+
...committed.placements.filter((existing)=>existing.field !== placement.field),
|
|
12
|
+
placement
|
|
13
|
+
]
|
|
14
|
+
};
|
|
15
|
+
const diagnostics = validateCommandFormLayout(draft, fields);
|
|
16
|
+
return {
|
|
17
|
+
committed,
|
|
18
|
+
draft,
|
|
19
|
+
diagnostics,
|
|
20
|
+
isValid: diagnostics.length === 0
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { updateCommandFormFieldPlacement };
|
|
25
|
+
//# 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,0BAA0BN,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,4 @@
|
|
|
1
|
+
import { CommandFormLayout } from '@cratis/scene.model';
|
|
2
|
+
import { CommandFormLayoutDiagnostic } from './CommandFormLayoutDiagnostic';
|
|
3
|
+
export declare function validateCommandFormLayout(layout: CommandFormLayout, fields?: readonly string[]): CommandFormLayoutDiagnostic[];
|
|
4
|
+
//# sourceMappingURL=validateCommandFormLayout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateCommandFormLayout.d.ts","sourceRoot":"","sources":["../../../forms/validateCommandFormLayout.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAA4B,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAM5E,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAE,SAAS,MAAM,EAAO,GAAG,2BAA2B,EAAE,CA6ClI"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { FormWidthUnit } from '@cratis/scene.model';
|
|
2
|
+
import { CommandFormLayoutDiagnosticCode } from './CommandFormLayoutDiagnosticCode.js';
|
|
3
|
+
|
|
4
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
5
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
6
|
+
/**
|
|
7
|
+
* Validates authored command-form geometry without rewriting invalid drafts.
|
|
8
|
+
*/ function validateCommandFormLayout(layout, fields = []) {
|
|
9
|
+
const diagnostics = [];
|
|
10
|
+
const columnIndexes = new Set();
|
|
11
|
+
const knownFields = new Set(fields);
|
|
12
|
+
if (!layout.columns.length) diagnostics.push(problem(CommandFormLayoutDiagnosticCode.EmptyColumns, 'At least one column is required.', 'columns'));
|
|
13
|
+
layout.columns.forEach((column, index)=>{
|
|
14
|
+
if (!Number.isInteger(column.index) || column.index < 1) {
|
|
15
|
+
diagnostics.push(problem(CommandFormLayoutDiagnosticCode.InvalidColumnIndex, `Column ${index + 1} must have a one-based integer index.`, `columns.${index}.index`));
|
|
16
|
+
}
|
|
17
|
+
if (columnIndexes.has(column.index)) {
|
|
18
|
+
diagnostics.push(problem(CommandFormLayoutDiagnosticCode.DuplicateColumn, `Column ${column.index} is declared more than once.`, `columns.${index}.index`));
|
|
19
|
+
}
|
|
20
|
+
columnIndexes.add(column.index);
|
|
21
|
+
validateWidth(column.width, `columns.${index}.width`, diagnostics);
|
|
22
|
+
validateWidth(column.minWidth, `columns.${index}.minWidth`, diagnostics);
|
|
23
|
+
validateWidth(column.maxWidth, `columns.${index}.maxWidth`, diagnostics);
|
|
24
|
+
});
|
|
25
|
+
validateWidth(layout.columnGap, 'columnGap', diagnostics);
|
|
26
|
+
validateWidth(layout.rowGap, 'rowGap', diagnostics);
|
|
27
|
+
const placements = new Set();
|
|
28
|
+
layout.placements.forEach((placement, index)=>{
|
|
29
|
+
if (!placement.field.trim()) diagnostics.push(problem(CommandFormLayoutDiagnosticCode.MissingField, 'A placement must name its field.', `placements.${index}.field`));
|
|
30
|
+
if (knownFields.size && !knownFields.has(placement.field)) {
|
|
31
|
+
diagnostics.push(problem(CommandFormLayoutDiagnosticCode.MissingField, `Placement targets unknown field '${placement.field}'.`, `placements.${index}.field`));
|
|
32
|
+
}
|
|
33
|
+
if (placements.has(placement.field)) {
|
|
34
|
+
diagnostics.push(problem(CommandFormLayoutDiagnosticCode.DuplicatePlacement, `Field '${placement.field}' is placed more than once.`, `placements.${index}.field`));
|
|
35
|
+
}
|
|
36
|
+
placements.add(placement.field);
|
|
37
|
+
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)) {
|
|
38
|
+
diagnostics.push(problem(CommandFormLayoutDiagnosticCode.InvalidPlacement, `Placement for '${placement.field}' must use positive integer row, column and span values.`, `placements.${index}`));
|
|
39
|
+
}
|
|
40
|
+
const span = placement.columnSpan ?? 1;
|
|
41
|
+
if (layout.columns.length && placement.column + span - 1 > layout.columns.length) {
|
|
42
|
+
diagnostics.push(problem(CommandFormLayoutDiagnosticCode.OutOfBoundsPlacement, `Placement for '${placement.field}' extends beyond the declared columns.`, `placements.${index}.columnSpan`));
|
|
43
|
+
}
|
|
44
|
+
validateWidth(placement.width, `placements.${index}.width`, diagnostics);
|
|
45
|
+
});
|
|
46
|
+
return diagnostics;
|
|
47
|
+
}
|
|
48
|
+
function validateWidth(width, path, diagnostics) {
|
|
49
|
+
if (!width) return;
|
|
50
|
+
if (!Object.values(FormWidthUnit).includes(width.unit)) {
|
|
51
|
+
diagnostics.push(problem(CommandFormLayoutDiagnosticCode.InvalidWidth, `Width at '${path}' uses an unsupported unit.`, path));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (width.unit === FormWidthUnit.Auto && width.value !== undefined) {
|
|
55
|
+
diagnostics.push(problem(CommandFormLayoutDiagnosticCode.InvalidWidth, `Automatic width at '${path}' must not carry a numeric value.`, path));
|
|
56
|
+
}
|
|
57
|
+
if (width.unit !== FormWidthUnit.Auto && (width.value === undefined || width.value < 0 || !Number.isFinite(width.value))) {
|
|
58
|
+
diagnostics.push(problem(CommandFormLayoutDiagnosticCode.InvalidWidth, `Width at '${path}' must carry a non-negative numeric value.`, path));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function problem(code, message, path) {
|
|
62
|
+
return {
|
|
63
|
+
code,
|
|
64
|
+
message,
|
|
65
|
+
path
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { validateCommandFormLayout };
|
|
70
|
+
//# 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","Auto","value","isFinite","code","message"],"mappings":";;;AAAA;AACA;AAMA;;AAEC,IACM,SAASA,yBAAAA,CAA0BC,MAAyB,EAAEC,SAA4B,EAAE,EAAA;AAC/F,IAAA,MAAMC,cAA6C,EAAE;AACrD,IAAA,MAAMC,gBAAgB,IAAIC,GAAAA,EAAAA;IAC1B,MAAMC,WAAAA,GAAc,IAAID,GAAAA,CAAIH,MAAAA,CAAAA;AAE5B,IAAA,IAAI,CAACD,MAAAA,CAAOM,OAAO,CAACC,MAAM,EAAEL,WAAAA,CAAYM,IAAI,CAACC,OAAAA,CAAQC,+BAAAA,CAAgCC,YAAY,EAAE,kCAAA,EAAoC,SAAA,CAAA,CAAA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7 @@ export * from './BindingDiagnostic';
|
|
|
5
5
|
export * from './resolveBindingExpression';
|
|
6
6
|
export * from './validateBindingExpression';
|
|
7
7
|
export * from './renderElement';
|
|
8
|
+
export * from './forms';
|
|
8
9
|
export * from './elementKind';
|
|
9
10
|
export * from './panelKind';
|
|
10
11
|
export * from './flowNodeKind';
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAGA,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,SAAS,CAAC;AACxB,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kCAAkC,CAAC;AACjD,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAGA,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,SAAS,CAAC;AACxB,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kCAAkC,CAAC;AACjD,cAAc,WAAW,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
export { createBindingResolver, resolveBindingExpression } from './resolveBindingExpression.js';
|
|
2
2
|
export { validateBindingExpression } from './validateBindingExpression.js';
|
|
3
3
|
export { renderElement } from './renderElement.js';
|
|
4
|
+
export { CommandFormLayoutDiagnosticCode } from './forms/CommandFormLayoutDiagnosticCode.js';
|
|
5
|
+
export { commitCommandFormLayoutDraft } from './forms/commitCommandFormLayoutDraft.js';
|
|
6
|
+
export { defaultCommandFormLayout } from './forms/defaultCommandFormLayout.js';
|
|
7
|
+
export { formWidthToCss } from './forms/formWidthToCss.js';
|
|
8
|
+
export { normalizeCommandFormLayout } from './forms/normalizeCommandFormLayout.js';
|
|
9
|
+
export { parseFormWidth } from './forms/parseFormWidth.js';
|
|
10
|
+
export { preserveDirtyCommandValues } from './forms/preserveDirtyCommandValues.js';
|
|
11
|
+
export { resizeCommandFormColumn } from './forms/resizeCommandFormColumn.js';
|
|
12
|
+
export { updateCommandFormFieldPlacement } from './forms/updateCommandFormFieldPlacement.js';
|
|
13
|
+
export { validateCommandFormLayout } from './forms/validateCommandFormLayout.js';
|
|
4
14
|
export { isContentControl, isExternalComponent, isItemsControl, isPanel } from './elementKind.js';
|
|
5
15
|
export { isCanvas, isDockPanel, isGrid, isStackPanel, isWrapPanel } from './panelKind.js';
|
|
6
16
|
export { isFlowColumn, isFlowContainer, isFlowGrid, isFlowLeaf, isFlowRow, isFlowSlotLeaf } from './flowNodeKind.js';
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|