@streamline-pulse/formkrafter-core 0.21.0 → 0.23.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/brick/brick.d.ts +10 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +108 -40
- package/dist/index.js.map +7 -5
- package/dist/review.d.ts +10 -0
- package/dist/utils/fields.d.ts +34 -0
- package/package.json +1 -1
package/dist/brick/brick.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { BrickSpec } from "../utils/brick-spec";
|
|
|
7
7
|
import type { BrickType } from "../utils/brick-type";
|
|
8
8
|
import type { BrickBaseConfigs, CommonBrickProps } from "../utils/common-brick-props";
|
|
9
9
|
import type { BrickMoldDropType } from "../utils/drop-type";
|
|
10
|
+
import type { FieldAnnotation } from "../review";
|
|
10
11
|
export interface BrickProps<DataType, Configs extends BrickBaseConfigs, Styles> extends CommonBrickProps<Configs, Styles> {
|
|
11
12
|
onConfigsChange?: (configs: BrickBaseConfigs & Record<string, unknown>, path?: string) => void;
|
|
12
13
|
onStylesChange?: (styles: Record<string, unknown>, path?: string) => void;
|
|
@@ -22,6 +23,15 @@ export interface BrickProps<DataType, Configs extends BrickBaseConfigs, Styles>
|
|
|
22
23
|
error?: string;
|
|
23
24
|
disabled?: boolean;
|
|
24
25
|
readOnly?: boolean;
|
|
26
|
+
/** A reviewer's note on this field, shown under the control. */
|
|
27
|
+
annotation?: FieldAnnotation;
|
|
28
|
+
/** An earlier review's verdict on this field, shown as a reminder in any mode. */
|
|
29
|
+
note?: FieldAnnotation;
|
|
30
|
+
/** Present in review mode: the controls to flag the field and comment it. */
|
|
31
|
+
review?: {
|
|
32
|
+
value: FieldAnnotation;
|
|
33
|
+
onChange: (next: FieldAnnotation) => void;
|
|
34
|
+
};
|
|
25
35
|
locale?: string;
|
|
26
36
|
children?: unknown;
|
|
27
37
|
brickSpec?: BrickSpec;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export { BrickSpec, buildValidationSchema, iterateBricks, iterateSchemaBricks, d
|
|
|
7
7
|
export { getBrickData, wrapBrickData } from "./utils/brick-data";
|
|
8
8
|
export { SelectOption, normalizeOptions } from "./utils/options";
|
|
9
9
|
export { RecapItem, collectRecapItems } from "./utils/recap";
|
|
10
|
+
export { FieldDescriptor, CollectFieldsOptions, collectFields } from "./utils/fields";
|
|
11
|
+
export { FieldAnnotation, FieldAnnotations, flaggedKeys } from "./review";
|
|
10
12
|
export { SpecIssue, SpecIssueCode, lintSpec } from "./utils/lint-spec";
|
|
11
13
|
export { ensureBrickUids, stripBrickUids, stripUidsFromPatches } from "./ops/uids";
|
|
12
14
|
export { interpolateTemplate, parseHeaderLines, appendSearchParam } from "./utils/remote";
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
17
17
|
return cached;
|
|
18
18
|
}
|
|
19
19
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
20
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
20
|
+
const to = isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
21
21
|
if (mod && typeof mod === "object" || typeof mod === "function") {
|
|
22
22
|
for (let key of __getOwnPropNames(mod))
|
|
23
23
|
if (!__hasOwnProp.call(to, key))
|
|
@@ -199,9 +199,9 @@ var require_scope = __commonJS(function(exports) {
|
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
var UsedValueState;
|
|
202
|
-
(function(
|
|
203
|
-
|
|
204
|
-
|
|
202
|
+
(function(UsedValueState) {
|
|
203
|
+
UsedValueState[UsedValueState["Started"] = 0] = "Started";
|
|
204
|
+
UsedValueState[UsedValueState["Completed"] = 1] = "Completed";
|
|
205
205
|
})(UsedValueState || (exports.UsedValueState = UsedValueState = {}));
|
|
206
206
|
exports.varKinds = {
|
|
207
207
|
const: new code_1.Name("const"),
|
|
@@ -1183,9 +1183,9 @@ var require_util = __commonJS(function(exports) {
|
|
|
1183
1183
|
}
|
|
1184
1184
|
exports.useFunc = useFunc;
|
|
1185
1185
|
var Type;
|
|
1186
|
-
(function(
|
|
1187
|
-
|
|
1188
|
-
|
|
1186
|
+
(function(Type) {
|
|
1187
|
+
Type[Type["Num"] = 0] = "Num";
|
|
1188
|
+
Type[Type["Str"] = 1] = "Str";
|
|
1189
1189
|
})(Type || (exports.Type = Type = {}));
|
|
1190
1190
|
function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
|
|
1191
1191
|
if (dataProp instanceof codegen_1.Name) {
|
|
@@ -1455,9 +1455,9 @@ var require_dataType = __commonJS(function(exports) {
|
|
|
1455
1455
|
var codegen_1 = require_codegen();
|
|
1456
1456
|
var util_1 = require_util();
|
|
1457
1457
|
var DataType;
|
|
1458
|
-
(function(
|
|
1459
|
-
|
|
1460
|
-
|
|
1458
|
+
(function(DataType) {
|
|
1459
|
+
DataType[DataType["Correct"] = 0] = "Correct";
|
|
1460
|
+
DataType[DataType["Wrong"] = 1] = "Wrong";
|
|
1461
1461
|
})(DataType || (exports.DataType = DataType = {}));
|
|
1462
1462
|
function getSchemaTypes(schema) {
|
|
1463
1463
|
const types = getJSONTypes(schema.type);
|
|
@@ -1853,8 +1853,8 @@ var require_keyword = __commonJS(function(exports) {
|
|
|
1853
1853
|
gen.assign(valid, (0, codegen_1._)`${_await}${(0, code_1.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def.modifying);
|
|
1854
1854
|
}
|
|
1855
1855
|
function reportErrs(errors) {
|
|
1856
|
-
var
|
|
1857
|
-
gen.if((0, codegen_1.not)((
|
|
1856
|
+
var _a;
|
|
1857
|
+
gen.if((0, codegen_1.not)((_a = def.valid) !== null && _a !== undefined ? _a : valid), errors);
|
|
1858
1858
|
}
|
|
1859
1859
|
}
|
|
1860
1860
|
exports.funcKeywordCode = funcKeywordCode;
|
|
@@ -2635,8 +2635,8 @@ var require_validate = __commonJS(function(exports) {
|
|
|
2635
2635
|
if (!this.allErrors)
|
|
2636
2636
|
this.gen.if(cond);
|
|
2637
2637
|
}
|
|
2638
|
-
setParams(obj,
|
|
2639
|
-
if (
|
|
2638
|
+
setParams(obj, assign) {
|
|
2639
|
+
if (assign)
|
|
2640
2640
|
Object.assign(this.params, obj);
|
|
2641
2641
|
else
|
|
2642
2642
|
this.params = obj;
|
|
@@ -3527,7 +3527,7 @@ var require_fast_uri = __commonJS(function(exports, module) {
|
|
|
3527
3527
|
if (typeof uri === "string") {
|
|
3528
3528
|
uri = normalizeString(uri, options);
|
|
3529
3529
|
} else if (typeof uri === "object") {
|
|
3530
|
-
uri =
|
|
3530
|
+
uri = parse(serialize(uri, options), options);
|
|
3531
3531
|
}
|
|
3532
3532
|
return uri;
|
|
3533
3533
|
}
|
|
@@ -3545,8 +3545,8 @@ var require_fast_uri = __commonJS(function(exports, module) {
|
|
|
3545
3545
|
function resolveComponent(base, relative, options, skipNormalization) {
|
|
3546
3546
|
const target = {};
|
|
3547
3547
|
if (!skipNormalization) {
|
|
3548
|
-
base =
|
|
3549
|
-
relative =
|
|
3548
|
+
base = parse(serialize(base, options), options);
|
|
3549
|
+
relative = parse(serialize(relative, options), options);
|
|
3550
3550
|
}
|
|
3551
3551
|
options = options || {};
|
|
3552
3552
|
if (!options.tolerant && relative.scheme) {
|
|
@@ -3791,7 +3791,7 @@ var require_fast_uri = __commonJS(function(exports, module) {
|
|
|
3791
3791
|
}
|
|
3792
3792
|
return { parsed, malformedAuthorityOrPort };
|
|
3793
3793
|
}
|
|
3794
|
-
function
|
|
3794
|
+
function parse(uri, opts) {
|
|
3795
3795
|
return parseWithStatus(uri, opts).parsed;
|
|
3796
3796
|
}
|
|
3797
3797
|
function normalizeString(uri, opts) {
|
|
@@ -3820,7 +3820,7 @@ var require_fast_uri = __commonJS(function(exports, module) {
|
|
|
3820
3820
|
resolveComponent,
|
|
3821
3821
|
equal,
|
|
3822
3822
|
serialize,
|
|
3823
|
-
parse
|
|
3823
|
+
parse
|
|
3824
3824
|
};
|
|
3825
3825
|
module.exports = fastUri;
|
|
3826
3826
|
module.exports.default = fastUri;
|
|
@@ -6001,9 +6001,9 @@ var require_types = __commonJS(function(exports) {
|
|
|
6001
6001
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6002
6002
|
exports.DiscrError = undefined;
|
|
6003
6003
|
var DiscrError;
|
|
6004
|
-
(function(
|
|
6005
|
-
|
|
6006
|
-
|
|
6004
|
+
(function(DiscrError) {
|
|
6005
|
+
DiscrError["Tag"] = "tag";
|
|
6006
|
+
DiscrError["Mapping"] = "mapping";
|
|
6007
6007
|
})(DiscrError || (exports.DiscrError = DiscrError = {}));
|
|
6008
6008
|
});
|
|
6009
6009
|
|
|
@@ -7229,7 +7229,11 @@ var en = {
|
|
|
7229
7229
|
"brick.row.name": "Row",
|
|
7230
7230
|
"brick.column.name": "Column",
|
|
7231
7231
|
"brick.stepper.name": "Stepper",
|
|
7232
|
-
"brick.tabs.name": "Tabs"
|
|
7232
|
+
"brick.tabs.name": "Tabs",
|
|
7233
|
+
"review.incorrect": "Incorrect",
|
|
7234
|
+
"review.comment": "Comment for the person who corrects it",
|
|
7235
|
+
"review.flagged": "To correct",
|
|
7236
|
+
"review.previous": "Flagged in the previous review"
|
|
7233
7237
|
};
|
|
7234
7238
|
var frFkTranslations = {
|
|
7235
7239
|
"palette.search": "Rechercher une brique…",
|
|
@@ -7367,7 +7371,11 @@ var frFkTranslations = {
|
|
|
7367
7371
|
"brick.row.name": "Ligne",
|
|
7368
7372
|
"brick.column.name": "Colonne",
|
|
7369
7373
|
"brick.stepper.name": "Étapes",
|
|
7370
|
-
"brick.tabs.name": "Onglets"
|
|
7374
|
+
"brick.tabs.name": "Onglets",
|
|
7375
|
+
"review.incorrect": "Incorrect",
|
|
7376
|
+
"review.comment": "Commentaire pour la personne qui corrige",
|
|
7377
|
+
"review.flagged": "À corriger",
|
|
7378
|
+
"review.previous": "Signalé lors de la revue précédente"
|
|
7371
7379
|
};
|
|
7372
7380
|
var GLOBAL_KEY = Symbol.for("formkrafter.i18n");
|
|
7373
7381
|
var globalStore = globalThis;
|
|
@@ -7523,16 +7531,16 @@ var evalNode = (ctx, node) => {
|
|
|
7523
7531
|
return;
|
|
7524
7532
|
throw new Error(`Cannot call "${String(prop)}" of ${String(object)}`);
|
|
7525
7533
|
}
|
|
7526
|
-
const
|
|
7527
|
-
if (typeof
|
|
7528
|
-
if (node.optional === true &&
|
|
7534
|
+
const fn2 = object[prop];
|
|
7535
|
+
if (typeof fn2 !== "function") {
|
|
7536
|
+
if (node.optional === true && fn2 == null)
|
|
7529
7537
|
return;
|
|
7530
7538
|
throw new Error(`"${String(prop)}" is not a function`);
|
|
7531
7539
|
}
|
|
7532
|
-
if (
|
|
7540
|
+
if (fn2 === Function || fn2 === eval) {
|
|
7533
7541
|
throw new Error("This function is not allowed");
|
|
7534
7542
|
}
|
|
7535
|
-
return
|
|
7543
|
+
return fn2.apply(object, args);
|
|
7536
7544
|
}
|
|
7537
7545
|
const fn2 = evalNode(ctx, callee);
|
|
7538
7546
|
if (typeof fn2 !== "function") {
|
|
@@ -7664,8 +7672,8 @@ var evalNode = (ctx, node) => {
|
|
|
7664
7672
|
if (property.type === "SpreadElement") {
|
|
7665
7673
|
const spread = evalNode(ctx, property.argument);
|
|
7666
7674
|
if (spread && typeof spread === "object") {
|
|
7667
|
-
for (const [
|
|
7668
|
-
result[String(guardProp(
|
|
7675
|
+
for (const [key, value] of Object.entries(spread)) {
|
|
7676
|
+
result[String(guardProp(key))] = value;
|
|
7669
7677
|
}
|
|
7670
7678
|
}
|
|
7671
7679
|
continue;
|
|
@@ -8083,8 +8091,8 @@ var collectRecapItems = (spec, dataMap, locale, showEmpty, groupBySections = fal
|
|
|
8083
8091
|
label,
|
|
8084
8092
|
columns: inputs.map((input) => brickLabel(input, locale)),
|
|
8085
8093
|
rows: rows.map((row) => inputs.map((input) => {
|
|
8086
|
-
const
|
|
8087
|
-
return isEmptyRecapValue(
|
|
8094
|
+
const raw = row?.[input.configs.key];
|
|
8095
|
+
return isEmptyRecapValue(raw) ? "—" : formatRecapValue(input, raw);
|
|
8088
8096
|
}))
|
|
8089
8097
|
});
|
|
8090
8098
|
continue;
|
|
@@ -8115,6 +8123,64 @@ var collectRecapItems = (spec, dataMap, locale, showEmpty, groupBySections = fal
|
|
|
8115
8123
|
}
|
|
8116
8124
|
return items;
|
|
8117
8125
|
};
|
|
8126
|
+
// lib/utils/fields.ts
|
|
8127
|
+
var staticOptions = (brick) => {
|
|
8128
|
+
const configs = brick.configs ?? {};
|
|
8129
|
+
const source = typeof configs.optionsSource === "string" ? configs.optionsSource : "static";
|
|
8130
|
+
if (source !== "static" || configs.options == null)
|
|
8131
|
+
return;
|
|
8132
|
+
const labelKey = typeof configs.labelKey === "string" ? configs.labelKey : "label";
|
|
8133
|
+
const valueKey = typeof configs.valueKey === "string" ? configs.valueKey : "value";
|
|
8134
|
+
const options = normalizeOptions(configs.options, labelKey, valueKey);
|
|
8135
|
+
return options.length ? options : undefined;
|
|
8136
|
+
};
|
|
8137
|
+
var describe = (brick, path, locale) => {
|
|
8138
|
+
const key = brick.configs?.key;
|
|
8139
|
+
const label = resolveLocalizedText(brick.configs?.label, locale);
|
|
8140
|
+
return {
|
|
8141
|
+
key,
|
|
8142
|
+
path,
|
|
8143
|
+
label: typeof label === "string" && label ? label : key,
|
|
8144
|
+
brick: brick.id,
|
|
8145
|
+
type: brick.type,
|
|
8146
|
+
dataType: brick.dataType,
|
|
8147
|
+
multiple: brick.type === "input" && brick.dataType === "array",
|
|
8148
|
+
required: (brick.validations ?? []).some((validation2) => validation2.validator === "required"),
|
|
8149
|
+
options: staticOptions(brick)
|
|
8150
|
+
};
|
|
8151
|
+
};
|
|
8152
|
+
var collectFields = (spec, locale, options = {}) => {
|
|
8153
|
+
const out = [];
|
|
8154
|
+
const walk = (brick, path, into) => {
|
|
8155
|
+
if (!brick)
|
|
8156
|
+
return;
|
|
8157
|
+
const key = brick.configs?.key;
|
|
8158
|
+
const named = typeof key === "string" && key !== "" && (options.includePrivate || !key.startsWith("_"));
|
|
8159
|
+
if (brick.type === "collection") {
|
|
8160
|
+
if (named) {
|
|
8161
|
+
const field = describe(brick, path, locale);
|
|
8162
|
+
field.columns = [];
|
|
8163
|
+
for (const [index, child] of (brick.children ?? []).entries())
|
|
8164
|
+
walk(child, `${path}.${index}`, field.columns);
|
|
8165
|
+
into.push(field);
|
|
8166
|
+
}
|
|
8167
|
+
return;
|
|
8168
|
+
}
|
|
8169
|
+
if (brick.type === "input") {
|
|
8170
|
+
if (named && brick.dataType && brick.dataType !== "void")
|
|
8171
|
+
into.push(describe(brick, path, locale));
|
|
8172
|
+
return;
|
|
8173
|
+
}
|
|
8174
|
+
if (brick.type === "panel") {
|
|
8175
|
+
for (const [index, child] of (brick.children ?? []).entries())
|
|
8176
|
+
walk(child, `${path}.${index}`, into);
|
|
8177
|
+
}
|
|
8178
|
+
};
|
|
8179
|
+
walk(spec, "0", out);
|
|
8180
|
+
return out;
|
|
8181
|
+
};
|
|
8182
|
+
// lib/review.ts
|
|
8183
|
+
var flaggedKeys = (annotations) => Object.entries(annotations ?? {}).filter(([, annotation]) => annotation?.incorrect === true).map(([key]) => key);
|
|
8118
8184
|
// lib/utils/lint-spec.ts
|
|
8119
8185
|
var isDataCarrying = (brick) => brick.type === "input" || brick.type === "collection";
|
|
8120
8186
|
function lintSpec(spec) {
|
|
@@ -8502,8 +8568,8 @@ function addBrick(spec, brick, parentPath, index) {
|
|
|
8502
8568
|
const parentPointer = pointerFromPath(parentPath);
|
|
8503
8569
|
const value = toJsonValue(brick);
|
|
8504
8570
|
if (!parent.children) {
|
|
8505
|
-
const
|
|
8506
|
-
return apply(spec, [{ op: "add", path:
|
|
8571
|
+
const pointer = `${parentPointer}/children`;
|
|
8572
|
+
return apply(spec, [{ op: "add", path: pointer, value: [value] }], [{ op: "remove", path: pointer }]);
|
|
8507
8573
|
}
|
|
8508
8574
|
const position = Math.min(index ?? parent.children.length, parent.children.length);
|
|
8509
8575
|
const pointer = `${parentPointer}/children/${position}`;
|
|
@@ -8818,7 +8884,7 @@ function convertComponent(component, ctx) {
|
|
|
8818
8884
|
configs: {
|
|
8819
8885
|
...baseConfigs(component, ctx),
|
|
8820
8886
|
optionsSource: "static",
|
|
8821
|
-
options: emitOptions(
|
|
8887
|
+
options: emitOptions(staticOptions2(component.values), component, ctx)
|
|
8822
8888
|
}
|
|
8823
8889
|
})
|
|
8824
8890
|
];
|
|
@@ -8833,7 +8899,7 @@ function convertComponent(component, ctx) {
|
|
|
8833
8899
|
configs: {
|
|
8834
8900
|
...baseConfigs(component, ctx),
|
|
8835
8901
|
optionsSource: "static",
|
|
8836
|
-
options: emitOptions(
|
|
8902
|
+
options: emitOptions(staticOptions2(component.values), component, ctx)
|
|
8837
8903
|
}
|
|
8838
8904
|
})
|
|
8839
8905
|
];
|
|
@@ -8921,7 +8987,7 @@ function convertSelect(component, ctx) {
|
|
|
8921
8987
|
ctx.warn(`select "${component.key ?? "?"}" uses dataSrc "${component.dataSrc}" — converted to static options`);
|
|
8922
8988
|
}
|
|
8923
8989
|
configs.optionsSource = "static";
|
|
8924
|
-
configs.options = emitOptions(
|
|
8990
|
+
configs.options = emitOptions(staticOptions2(component.data?.values ?? component.values), component, ctx);
|
|
8925
8991
|
}
|
|
8926
8992
|
return withCommon(component, ctx, {
|
|
8927
8993
|
type: "input",
|
|
@@ -8968,7 +9034,7 @@ function labelKeyFromTemplate(template) {
|
|
|
8968
9034
|
const match = /item\.([a-zA-Z0-9_.]+)/.exec(template);
|
|
8969
9035
|
return match?.[1];
|
|
8970
9036
|
}
|
|
8971
|
-
function
|
|
9037
|
+
function staticOptions2(values) {
|
|
8972
9038
|
return (values ?? []).map((option) => {
|
|
8973
9039
|
if (!isPlainOptionObject(option))
|
|
8974
9040
|
return scalarOption(option);
|
|
@@ -9214,6 +9280,7 @@ export {
|
|
|
9214
9280
|
addBrick,
|
|
9215
9281
|
appendSearchParam,
|
|
9216
9282
|
buildValidationSchema,
|
|
9283
|
+
collectFields,
|
|
9217
9284
|
collectRecapItems,
|
|
9218
9285
|
convertFormioForm,
|
|
9219
9286
|
defaultFormData,
|
|
@@ -9224,6 +9291,7 @@ export {
|
|
|
9224
9291
|
expandSpec,
|
|
9225
9292
|
fkT,
|
|
9226
9293
|
fkTOr,
|
|
9294
|
+
flaggedKeys,
|
|
9227
9295
|
frFkTranslations,
|
|
9228
9296
|
getAffectedProperties,
|
|
9229
9297
|
getBrickAt,
|
|
@@ -9257,5 +9325,5 @@ export {
|
|
|
9257
9325
|
wrapBrickData
|
|
9258
9326
|
};
|
|
9259
9327
|
|
|
9260
|
-
//# debugId=
|
|
9328
|
+
//# debugId=35DCE1488AEE05C464756E2164756E21
|
|
9261
9329
|
//# sourceMappingURL=index.js.map
|