@streamline-pulse/formkrafter-wc 0.2.0 → 0.4.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/README.md +10 -8
- package/dist/components/fk-brick-actions.js +1 -1
- package/dist/components/fk-brick-list.js +1 -1
- package/dist/components/fk-brick-mold-item.js +1 -1
- package/dist/components/fk-brick-not-found.js +1 -1
- package/dist/components/fk-brick-render.js +1 -1
- package/dist/components/fk-code-editor.js +1 -1
- package/dist/components/fk-data-grid.js +1 -1
- package/dist/components/fk-drop-area.js +1 -1
- package/dist/components/fk-empty-form.js +1 -1
- package/dist/components/fk-file-input.js +1 -1
- package/dist/components/fk-form-builder.js +1 -1
- package/dist/components/fk-form-render.js +1 -1
- package/dist/components/fk-property-panel.js +1 -1
- package/dist/components/fk-rules-editor.js +1 -1
- package/dist/components/fk-select-input.js +1 -1
- package/dist/components/fk-signature-input.js +1 -1
- package/dist/components/fk-stepper.js +1 -1
- package/dist/components/fk-tabs.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/{p-LXnm2ogM.js → p-28GBFlUX.js} +4 -4
- package/dist/components/p-BB4Llg42.js +1 -0
- package/dist/components/p-BGxmFcpL.js +1 -0
- package/dist/components/{p-BVBfbMl_.js → p-BInUBjyw.js} +1 -1
- package/dist/components/p-BietHxaT.js +1 -0
- package/dist/components/{p-C85zhhpr.js → p-BnzSarwW.js} +1 -1
- package/dist/components/p-BpkKcCCr.js +1 -0
- package/dist/components/p-C0Y8qh8R.js +1 -0
- package/dist/components/p-C5OWoRhO.js +1 -0
- package/dist/components/p-CKs1CWVz.js +1 -0
- package/dist/components/{p-BSPTuA1p.js → p-CZHykCYD.js} +1 -1
- package/dist/components/p-CehxuHtl.js +1 -0
- package/dist/components/p-CqVSd56Z.js +1 -0
- package/dist/components/p-CyZA17qf.js +1 -0
- package/dist/components/p-D4HhZxQ-.js +1 -0
- package/dist/components/p-DC6Wxbnz.js +1 -0
- package/dist/components/p-DRNycSdI.js +1 -0
- package/dist/components/{p-B0YjIsVn.js → p-Dh5Z49YD.js} +1 -1
- package/dist/components/p-DiOstAi9.js +1 -0
- package/dist/components/p-DlqnIm46.js +1 -0
- package/dist/components/{p-BDvqHJih.js → p-DshUS8Zm.js} +1 -1
- package/dist/components/p-DtcM1yw5.js +1 -0
- package/dist/components/p-NDbmiiYk.js +1 -0
- package/dist/components/p-RzeBwfwG.js +1 -0
- package/dist/components/p-ajy8ZcBX.js +1 -0
- package/dist/components/p-kYG3E0GQ.js +1 -0
- package/dist/components/p-tTJg_I4V.js +1 -0
- package/dist/formkrafter-wc/formkrafter-wc.css +1 -1
- package/dist/formkrafter-wc/formkrafter-wc.esm.js +1 -1
- package/dist/formkrafter-wc/index.esm.js +1 -1
- package/dist/formkrafter-wc/p-3579150a.entry.js +1 -0
- package/dist/formkrafter-wc/p-8b0ff66e.entry.js +1 -0
- package/dist/formkrafter-wc/p-BHZMDq2e.js +1 -0
- package/dist/formkrafter-wc/p-BietHxaT.js +1 -0
- package/dist/formkrafter-wc/p-C0Y8qh8R.js +1 -0
- package/dist/formkrafter-wc/p-CehxuHtl.js +1 -0
- package/dist/formkrafter-wc/p-DlqnIm46.js +1 -0
- package/dist/formkrafter-wc/p-DtcM1yw5.js +1 -0
- package/dist/formkrafter-wc/p-RzeBwfwG.js +1 -0
- package/dist/formkrafter-wc/p-WWmY5Z05.js +1 -0
- package/dist/formkrafter-wc/p-hcT25XX4.js +12 -0
- package/dist/formkrafter-wc/p-qLZlXROB.js +2 -0
- package/dist/types/components/fk-code-editor/fk-code-editor.d.ts +3 -1
- package/dist/types/components/fk-data-grid/fk-data-grid.d.ts +1 -0
- package/dist/types/components/fk-drop-area/fk-drop-area.d.ts +1 -0
- package/dist/types/components/fk-file-input/fk-file-input.d.ts +7 -3
- package/dist/types/components/fk-form-render/fk-form-render.d.ts +7 -1
- package/dist/types/components/fk-select-input/fk-select-input.d.ts +9 -0
- package/dist/types/components.d.ts +39 -4
- package/dist/types/index.d.ts +1 -1
- package/dist/types/registry/default-bricks.d.ts +36 -0
- package/dist/types/utils/mask.d.ts +1 -0
- package/package.json +10 -15
- package/dist/cjs/app-globals-V2Kpy_OQ.js +0 -5
- package/dist/cjs/fk-brick-actions_18.cjs.entry.js +0 -26443
- package/dist/cjs/formkrafter-wc.cjs.js +0 -25
- package/dist/cjs/index-Can2MpG5.js +0 -17538
- package/dist/cjs/index-CbyFxLc_.js +0 -2114
- package/dist/cjs/index.cjs.js +0 -48
- package/dist/cjs/loader.cjs.js +0 -13
- package/dist/collection/collection-manifest.json +0 -30
- package/dist/collection/components/fk-brick-actions/fk-brick-actions.css +0 -78
- package/dist/collection/components/fk-brick-actions/fk-brick-actions.js +0 -215
- package/dist/collection/components/fk-brick-list/fk-brick-list.css +0 -71
- package/dist/collection/components/fk-brick-list/fk-brick-list.js +0 -55
- package/dist/collection/components/fk-brick-mold-item/fk-brick-mold-item.css +0 -33
- package/dist/collection/components/fk-brick-mold-item/fk-brick-mold-item.js +0 -73
- package/dist/collection/components/fk-brick-not-found/fk-brick-not-found.css +0 -8
- package/dist/collection/components/fk-brick-not-found/fk-brick-not-found.js +0 -18
- package/dist/collection/components/fk-brick-render/fk-brick-render.js +0 -447
- package/dist/collection/components/fk-code-editor/fk-code-editor.css +0 -26
- package/dist/collection/components/fk-code-editor/fk-code-editor.js +0 -136
- package/dist/collection/components/fk-data-grid/fk-data-grid.css +0 -75
- package/dist/collection/components/fk-data-grid/fk-data-grid.js +0 -300
- package/dist/collection/components/fk-drop-area/fk-drop-area.css +0 -18
- package/dist/collection/components/fk-drop-area/fk-drop-area.js +0 -98
- package/dist/collection/components/fk-empty-form/fk-empty-form.css +0 -22
- package/dist/collection/components/fk-empty-form/fk-empty-form.js +0 -19
- package/dist/collection/components/fk-file-input/fk-file-input.css +0 -95
- package/dist/collection/components/fk-file-input/fk-file-input.js +0 -196
- package/dist/collection/components/fk-form-builder/fk-form-builder.css +0 -112
- package/dist/collection/components/fk-form-builder/fk-form-builder.js +0 -431
- package/dist/collection/components/fk-form-render/fk-form-render.css +0 -7
- package/dist/collection/components/fk-form-render/fk-form-render.js +0 -352
- package/dist/collection/components/fk-property-panel/fk-property-panel.css +0 -153
- package/dist/collection/components/fk-property-panel/fk-property-panel.js +0 -384
- package/dist/collection/components/fk-rules-editor/fk-rules-editor.css +0 -166
- package/dist/collection/components/fk-rules-editor/fk-rules-editor.js +0 -250
- package/dist/collection/components/fk-select-input/fk-select-input.css +0 -144
- package/dist/collection/components/fk-select-input/fk-select-input.js +0 -356
- package/dist/collection/components/fk-signature-input/fk-signature-input.css +0 -42
- package/dist/collection/components/fk-signature-input/fk-signature-input.js +0 -158
- package/dist/collection/components/fk-stepper/fk-stepper.css +0 -85
- package/dist/collection/components/fk-stepper/fk-stepper.js +0 -282
- package/dist/collection/components/fk-tabs/fk-tabs.css +0 -38
- package/dist/collection/components/fk-tabs/fk-tabs.js +0 -236
- package/dist/collection/i18n/i18n.js +0 -257
- package/dist/collection/index.js +0 -5
- package/dist/collection/registry/create-brick.js +0 -34
- package/dist/collection/registry/default-bricks.js +0 -562
- package/dist/collection/registry/registry.js +0 -44
- package/dist/collection/utils/brick-data.js +0 -16
- package/dist/collection/utils/drop.js +0 -14
- package/dist/collection/utils/events.js +0 -1
- package/dist/collection/utils/options.js +0 -21
- package/dist/collection/utils/remote.js +0 -27
- package/dist/collection/utils/rule-condition.js +0 -72
- package/dist/collection/utils/style.js +0 -11
- package/dist/components/p-B1t0M_hN.js +0 -1
- package/dist/components/p-B21cOFRx.js +0 -1
- package/dist/components/p-B7ED8qMb.js +0 -1
- package/dist/components/p-BrOXMyOG.js +0 -1
- package/dist/components/p-CMQ_4Zfv.js +0 -1
- package/dist/components/p-CWQX0sXS.js +0 -1
- package/dist/components/p-CXEvsomA.js +0 -1
- package/dist/components/p-Cq9HSEn8.js +0 -1
- package/dist/components/p-D7bf2ztq.js +0 -1
- package/dist/components/p-DIPoAaGe.js +0 -1
- package/dist/components/p-DYBirEew.js +0 -1
- package/dist/components/p-DluDp8V5.js +0 -1
- package/dist/components/p-Do6-yRva.js +0 -1
- package/dist/components/p-GjmAhT2E.js +0 -1
- package/dist/components/p-y0xDvzJR.js +0 -1
- package/dist/esm/app-globals-DQuL1Twl.js +0 -3
- package/dist/esm/fk-brick-actions_18.entry.js +0 -26424
- package/dist/esm/formkrafter-wc.js +0 -21
- package/dist/esm/index-BB2OOj__.js +0 -17478
- package/dist/esm/index-DMDO6w5-.js +0 -2105
- package/dist/esm/index.js +0 -2
- package/dist/esm/loader.js +0 -11
- package/dist/formkrafter-wc/p-0de7cbe1.entry.js +0 -1
- package/dist/formkrafter-wc/p-Bp_A8oL5.js +0 -12
- package/dist/formkrafter-wc/p-DMDO6w5-.js +0 -2
- package/dist/index.cjs.js +0 -1
- package/dist/index.js +0 -1
- package/dist/stencil.config.js +0 -34
- package/loader/cdn.js +0 -1
- package/loader/index.cjs.js +0 -1
- package/loader/index.d.ts +0 -24
- package/loader/index.es2017.js +0 -1
- package/loader/index.js +0 -2
|
@@ -1,562 +0,0 @@
|
|
|
1
|
-
import { h } from "@stencil/core";
|
|
2
|
-
import { createBrick } from "./create-brick";
|
|
3
|
-
import { registerBricks } from "./registry";
|
|
4
|
-
import { asInlineStyle } from "../utils/style";
|
|
5
|
-
import { normalizeOptions } from "../utils/options";
|
|
6
|
-
import { fkT, fkTOr } from "../i18n/i18n";
|
|
7
|
-
import { getAffectedProperties, resolveLocalizedText, } from "@streamline-pulse/formkrafter-core";
|
|
8
|
-
const labelOf = (props, fallback) => { var _a, _b, _c, _d; return (_d = (_b = (_a = props.configs) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : (_c = props.configs) === null || _c === void 0 ? void 0 : _c.key) !== null && _d !== void 0 ? _d : fallback; };
|
|
9
|
-
const adorned = (props, control) => {
|
|
10
|
-
var _a, _b;
|
|
11
|
-
const prefix = (_a = props.configs) === null || _a === void 0 ? void 0 : _a.prefix;
|
|
12
|
-
const suffix = (_b = props.configs) === null || _b === void 0 ? void 0 : _b.suffix;
|
|
13
|
-
if (!prefix && !suffix)
|
|
14
|
-
return control;
|
|
15
|
-
return (h("div", { class: "fk-adorned" }, prefix ? h("span", { class: "fk-adorned__affix" }, prefix) : null, control, suffix ? h("span", { class: "fk-adorned__affix" }, suffix) : null));
|
|
16
|
-
};
|
|
17
|
-
const fieldBlock = (props, fallback, control) => (h("div", { class: "fk-field", style: asInlineStyle(props.styles) }, h("span", { class: "fk-field__label" }, labelOf(props, fallback)), control, props.error ? h("span", { class: "fk-field__error" }, props.error) : null));
|
|
18
|
-
const field = (props, fallback, control) => (h("label", { class: "fk-field", style: asInlineStyle(props.styles) }, h("span", { class: "fk-field__label" }, labelOf(props, fallback)), control, props.error ? h("span", { class: "fk-field__error" }, props.error) : null));
|
|
19
|
-
const createTextVariant = (params) => createBrick({
|
|
20
|
-
type: 'input',
|
|
21
|
-
dataType: 'string',
|
|
22
|
-
id: params.id,
|
|
23
|
-
name: params.name,
|
|
24
|
-
category: 'Inputs',
|
|
25
|
-
defaultConfigs: { label: params.name },
|
|
26
|
-
render: (props) => {
|
|
27
|
-
var _a, _b;
|
|
28
|
-
return field(props, params.name, adorned(props, h("input", { class: "fk-field__input fk-adorned__input", type: params.inputType, value: (_a = props.data) !== null && _a !== void 0 ? _a : '', placeholder: (_b = props.configs) === null || _b === void 0 ? void 0 : _b.placeholder, disabled: props.editable || props.disabled, onInput: (event) => { var _a; return (_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, event.target.value); } })));
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
export const textInputBrick = createTextVariant({
|
|
32
|
-
id: 'text',
|
|
33
|
-
name: 'Text',
|
|
34
|
-
inputType: 'text',
|
|
35
|
-
});
|
|
36
|
-
export const emailBrick = createTextVariant({
|
|
37
|
-
id: 'email',
|
|
38
|
-
name: 'Email',
|
|
39
|
-
inputType: 'email',
|
|
40
|
-
});
|
|
41
|
-
export const passwordBrick = createTextVariant({
|
|
42
|
-
id: 'password',
|
|
43
|
-
name: 'Password',
|
|
44
|
-
inputType: 'password',
|
|
45
|
-
});
|
|
46
|
-
export const urlBrick = createTextVariant({
|
|
47
|
-
id: 'url',
|
|
48
|
-
name: 'URL',
|
|
49
|
-
inputType: 'url',
|
|
50
|
-
});
|
|
51
|
-
export const phoneBrick = createTextVariant({
|
|
52
|
-
id: 'phone',
|
|
53
|
-
name: 'Phone',
|
|
54
|
-
inputType: 'tel',
|
|
55
|
-
});
|
|
56
|
-
export const textareaBrick = createBrick({
|
|
57
|
-
type: 'input',
|
|
58
|
-
dataType: 'string',
|
|
59
|
-
id: 'textarea',
|
|
60
|
-
name: 'Text area',
|
|
61
|
-
category: 'Inputs',
|
|
62
|
-
defaultConfigs: { label: 'Text area' },
|
|
63
|
-
render: (props) => {
|
|
64
|
-
var _a, _b;
|
|
65
|
-
return field(props, 'Text area', h("textarea", { class: "fk-field__input fk-field__input--textarea", value: (_a = props.data) !== null && _a !== void 0 ? _a : '', placeholder: (_b = props.configs) === null || _b === void 0 ? void 0 : _b.placeholder, disabled: props.editable || props.disabled, onInput: (event) => { var _a; return (_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, event.target.value); } }));
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
export const numberBrick = createBrick({
|
|
69
|
-
type: 'input',
|
|
70
|
-
dataType: 'number',
|
|
71
|
-
id: 'number',
|
|
72
|
-
name: 'Number',
|
|
73
|
-
category: 'Inputs',
|
|
74
|
-
defaultConfigs: { label: 'Number' },
|
|
75
|
-
render: (props) => {
|
|
76
|
-
var _a;
|
|
77
|
-
return field(props, 'Number', adorned(props, h("input", { class: "fk-field__input fk-adorned__input", type: "number", value: props.data == null ? '' : String(props.data), placeholder: (_a = props.configs) === null || _a === void 0 ? void 0 : _a.placeholder, disabled: props.editable || props.disabled, onInput: (event) => {
|
|
78
|
-
var _a;
|
|
79
|
-
const raw = event.target.value;
|
|
80
|
-
(_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, raw === '' ? undefined : Number(raw));
|
|
81
|
-
} })));
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
export const dateBrick = createBrick({
|
|
85
|
-
type: 'input',
|
|
86
|
-
dataType: 'string',
|
|
87
|
-
id: 'date',
|
|
88
|
-
name: 'Date',
|
|
89
|
-
category: 'Inputs',
|
|
90
|
-
defaultConfigs: { label: 'Date' },
|
|
91
|
-
render: (props) => {
|
|
92
|
-
var _a;
|
|
93
|
-
return field(props, 'Date', h("input", { class: "fk-field__input", type: "date", value: (_a = props.data) !== null && _a !== void 0 ? _a : '', disabled: props.editable || props.disabled, onInput: (event) => {
|
|
94
|
-
var _a;
|
|
95
|
-
const raw = event.target.value;
|
|
96
|
-
(_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, raw === '' ? undefined : raw);
|
|
97
|
-
} }));
|
|
98
|
-
},
|
|
99
|
-
});
|
|
100
|
-
export const selectBrick = createBrick({
|
|
101
|
-
type: 'input',
|
|
102
|
-
dataType: 'string',
|
|
103
|
-
id: 'select',
|
|
104
|
-
name: 'Select',
|
|
105
|
-
category: 'Inputs',
|
|
106
|
-
defaultConfigs: {
|
|
107
|
-
label: 'Select',
|
|
108
|
-
optionsSource: 'static',
|
|
109
|
-
options: 'Option 1\nOption 2',
|
|
110
|
-
},
|
|
111
|
-
render: (props) => {
|
|
112
|
-
var _a;
|
|
113
|
-
return fieldBlock(props, 'Select', h("fk-select-input", { configs: props.configs, value: (_a = props.data) !== null && _a !== void 0 ? _a : '', disabled: props.editable || props.disabled, dataMap: props.dataMap, onSelectValueChange: (event) => {
|
|
114
|
-
var _a;
|
|
115
|
-
event.stopPropagation();
|
|
116
|
-
(_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, event.detail);
|
|
117
|
-
} }));
|
|
118
|
-
},
|
|
119
|
-
});
|
|
120
|
-
export const multiSelectBrick = createBrick({
|
|
121
|
-
type: 'input',
|
|
122
|
-
dataType: 'array',
|
|
123
|
-
id: 'multi-select',
|
|
124
|
-
name: 'Multi select',
|
|
125
|
-
category: 'Inputs',
|
|
126
|
-
defaultConfigs: {
|
|
127
|
-
label: 'Multi select',
|
|
128
|
-
optionsSource: 'static',
|
|
129
|
-
options: 'Option 1\nOption 2\nOption 3',
|
|
130
|
-
},
|
|
131
|
-
render: (props) => fieldBlock(props, 'Multi select', h("fk-select-input", { configs: props.configs, value: Array.isArray(props.data) ? props.data : [], multiple: true, disabled: props.editable || props.disabled, dataMap: props.dataMap, onSelectValueChange: (event) => {
|
|
132
|
-
var _a;
|
|
133
|
-
event.stopPropagation();
|
|
134
|
-
(_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, event.detail);
|
|
135
|
-
} })),
|
|
136
|
-
});
|
|
137
|
-
export const timeBrick = createTextVariant({
|
|
138
|
-
id: 'time',
|
|
139
|
-
name: 'Time',
|
|
140
|
-
inputType: 'time',
|
|
141
|
-
});
|
|
142
|
-
export const datetimeBrick = createTextVariant({
|
|
143
|
-
id: 'datetime',
|
|
144
|
-
name: 'Date / Time',
|
|
145
|
-
inputType: 'datetime-local',
|
|
146
|
-
});
|
|
147
|
-
const staticOptions = (props) => {
|
|
148
|
-
var _a, _b, _c;
|
|
149
|
-
return normalizeOptions((_a = props.configs) === null || _a === void 0 ? void 0 : _a.options, typeof ((_b = props.configs) === null || _b === void 0 ? void 0 : _b.labelKey) === 'string' ? props.configs.labelKey : 'label', typeof ((_c = props.configs) === null || _c === void 0 ? void 0 : _c.valueKey) === 'string' ? props.configs.valueKey : 'value');
|
|
150
|
-
};
|
|
151
|
-
export const selectBoxesBrick = createBrick({
|
|
152
|
-
type: 'input',
|
|
153
|
-
dataType: 'array',
|
|
154
|
-
id: 'select-boxes',
|
|
155
|
-
name: 'Select boxes',
|
|
156
|
-
category: 'Inputs',
|
|
157
|
-
defaultConfigs: { label: 'Select boxes', options: 'Option 1\nOption 2\nOption 3' },
|
|
158
|
-
render: (props) => {
|
|
159
|
-
const selected = Array.isArray(props.data) ? props.data : [];
|
|
160
|
-
return (h("div", { class: "fk-field", style: asInlineStyle(props.styles) }, h("span", { class: "fk-field__label" }, labelOf(props, 'Select boxes')), h("div", { class: "fk-radio-group" }, staticOptions(props).map((option) => (h("label", { class: "fk-radio", key: option.value }, h("input", { type: "checkbox", checked: selected.includes(option.value), disabled: props.editable || props.disabled, onChange: (event) => {
|
|
161
|
-
var _a;
|
|
162
|
-
const checked = event.target.checked;
|
|
163
|
-
const next = checked
|
|
164
|
-
? [...selected, option.value]
|
|
165
|
-
: selected.filter((value) => value !== option.value);
|
|
166
|
-
(_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, next.length ? next : undefined);
|
|
167
|
-
} }), h("span", null, option.label))))), props.error ? h("span", { class: "fk-field__error" }, props.error) : null));
|
|
168
|
-
},
|
|
169
|
-
});
|
|
170
|
-
export const tagsBrick = createBrick({
|
|
171
|
-
type: 'input',
|
|
172
|
-
dataType: 'array',
|
|
173
|
-
id: 'tags',
|
|
174
|
-
name: 'Tags',
|
|
175
|
-
category: 'Inputs',
|
|
176
|
-
defaultConfigs: { label: 'Tags' },
|
|
177
|
-
render: (props) => {
|
|
178
|
-
const tags = Array.isArray(props.data) ? props.data : [];
|
|
179
|
-
return field(props, 'Tags', h("div", { class: "fk-tags" }, tags.map((tag) => (h("span", { class: "fk-tags__chip", key: tag }, tag, h("button", { type: "button", class: "fk-tags__remove", disabled: props.editable || props.disabled, onClick: () => {
|
|
180
|
-
var _a;
|
|
181
|
-
const next = tags.filter((value) => value !== tag);
|
|
182
|
-
(_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, next.length ? next : undefined);
|
|
183
|
-
} }, "\u2715")))), h("input", { class: "fk-tags__input", type: "text", placeholder: "Add a tag\u2026", disabled: props.editable || props.disabled, onKeyDown: (event) => {
|
|
184
|
-
var _a;
|
|
185
|
-
if (event.key !== 'Enter')
|
|
186
|
-
return;
|
|
187
|
-
event.preventDefault();
|
|
188
|
-
const input = event.target;
|
|
189
|
-
const value = input.value.trim();
|
|
190
|
-
if (!value || tags.includes(value))
|
|
191
|
-
return;
|
|
192
|
-
(_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, [...tags, value]);
|
|
193
|
-
input.value = '';
|
|
194
|
-
} })));
|
|
195
|
-
},
|
|
196
|
-
});
|
|
197
|
-
export const signatureBrick = createBrick({
|
|
198
|
-
type: 'input',
|
|
199
|
-
dataType: 'string',
|
|
200
|
-
id: 'signature',
|
|
201
|
-
name: 'Signature',
|
|
202
|
-
category: 'Inputs',
|
|
203
|
-
defaultConfigs: { label: 'Signature' },
|
|
204
|
-
render: (props) => {
|
|
205
|
-
var _a;
|
|
206
|
-
return field(props, 'Signature', h("fk-signature-input", { value: (_a = props.data) !== null && _a !== void 0 ? _a : undefined, disabled: props.editable || props.disabled, onSignatureChange: (event) => {
|
|
207
|
-
var _a;
|
|
208
|
-
event.stopPropagation();
|
|
209
|
-
(_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, event.detail);
|
|
210
|
-
} }));
|
|
211
|
-
},
|
|
212
|
-
});
|
|
213
|
-
export const tabsBrick = createBrick({
|
|
214
|
-
type: 'panel',
|
|
215
|
-
dataType: 'void',
|
|
216
|
-
id: 'tabs',
|
|
217
|
-
name: 'Tabs',
|
|
218
|
-
category: 'Layout',
|
|
219
|
-
defaultConfigs: { validateTabs: false },
|
|
220
|
-
render: (props) => {
|
|
221
|
-
var _a, _b;
|
|
222
|
-
const labels = ((_b = (_a = props.brickSpec) === null || _a === void 0 ? void 0 : _a.children) !== null && _b !== void 0 ? _b : []).map((child, index) => {
|
|
223
|
-
var _a, _b;
|
|
224
|
-
const resolved = resolveLocalizedText((_a = child.configs) === null || _a === void 0 ? void 0 : _a.label, props.locale);
|
|
225
|
-
return typeof resolved === 'string'
|
|
226
|
-
? resolved
|
|
227
|
-
: ((_b = child.name) !== null && _b !== void 0 ? _b : `Tab ${index + 1}`);
|
|
228
|
-
});
|
|
229
|
-
return (h("fk-tabs", { tabLabels: labels, editable: props.editable, spec: props.brickSpec, dataMap: props.dataMap, locale: props.locale, style: asInlineStyle(props.styles) }, props.children));
|
|
230
|
-
},
|
|
231
|
-
});
|
|
232
|
-
export const radioBrick = createBrick({
|
|
233
|
-
type: 'input',
|
|
234
|
-
dataType: 'string',
|
|
235
|
-
id: 'radio',
|
|
236
|
-
name: 'Radio',
|
|
237
|
-
category: 'Inputs',
|
|
238
|
-
defaultConfigs: { label: 'Radio', options: 'Option 1\nOption 2' },
|
|
239
|
-
render: (props) => (h("div", { class: "fk-field", style: asInlineStyle(props.styles) }, h("span", { class: "fk-field__label" }, labelOf(props, 'Radio')), h("div", { class: "fk-radio-group", role: "radiogroup" }, staticOptions(props).map((option) => {
|
|
240
|
-
var _a, _b;
|
|
241
|
-
return (h("label", { class: "fk-radio", key: option.value }, h("input", { type: "radio", name: (_b = (_a = props.configs) === null || _a === void 0 ? void 0 : _a.key) !== null && _b !== void 0 ? _b : props.path, checked: props.data === option.value, disabled: props.editable || props.disabled, onChange: () => { var _a; return (_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, option.value); } }), h("span", null, option.label)));
|
|
242
|
-
})), props.error ? h("span", { class: "fk-field__error" }, props.error) : null)),
|
|
243
|
-
});
|
|
244
|
-
const ADDRESS_PARTS = [
|
|
245
|
-
{ key: 'street', label: () => fkT('address.street'), full: true },
|
|
246
|
-
{ key: 'city', label: () => fkT('address.city'), full: false },
|
|
247
|
-
{ key: 'zip', label: () => fkT('address.zip'), full: false },
|
|
248
|
-
{ key: 'country', label: () => fkT('address.country'), full: false },
|
|
249
|
-
];
|
|
250
|
-
export const addressBrick = createBrick({
|
|
251
|
-
type: 'input',
|
|
252
|
-
dataType: 'object',
|
|
253
|
-
id: 'address',
|
|
254
|
-
name: 'Address',
|
|
255
|
-
category: 'Inputs',
|
|
256
|
-
defaultConfigs: { label: 'Address' },
|
|
257
|
-
render: (props) => {
|
|
258
|
-
var _a;
|
|
259
|
-
const value = ((_a = props.data) !== null && _a !== void 0 ? _a : {});
|
|
260
|
-
return fieldBlock(props, 'Address', h("div", { class: "fk-address" }, ADDRESS_PARTS.map((part) => {
|
|
261
|
-
var _a;
|
|
262
|
-
return (h("label", { class: { 'fk-address__part': true, 'fk-address__part--full': part.full }, key: part.key }, h("span", { class: "fk-address__label" }, part.label()), h("input", { class: "fk-field__input", type: "text", value: (_a = value[part.key]) !== null && _a !== void 0 ? _a : '', disabled: props.editable || props.disabled, onInput: (event) => {
|
|
263
|
-
var _a;
|
|
264
|
-
const raw = event.target.value;
|
|
265
|
-
const next = Object.assign(Object.assign({}, value), { [part.key]: raw || undefined });
|
|
266
|
-
const cleaned = Object.fromEntries(Object.entries(next).filter(([, entry]) => entry !== undefined));
|
|
267
|
-
(_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, Object.keys(cleaned).length ? cleaned : undefined);
|
|
268
|
-
} })));
|
|
269
|
-
})));
|
|
270
|
-
},
|
|
271
|
-
});
|
|
272
|
-
export const fileBrick = createBrick({
|
|
273
|
-
type: 'input',
|
|
274
|
-
dataType: 'object',
|
|
275
|
-
id: 'file',
|
|
276
|
-
name: 'File',
|
|
277
|
-
category: 'Data',
|
|
278
|
-
defaultConfigs: { label: 'File' },
|
|
279
|
-
render: (props) => {
|
|
280
|
-
var _a, _b;
|
|
281
|
-
return fieldBlock(props, 'File', h("fk-file-input", { value: props.data, accept: (_a = props.configs) === null || _a === void 0 ? void 0 : _a.accept, uploadUrl: (_b = props.configs) === null || _b === void 0 ? void 0 : _b.uploadUrl, disabled: props.editable || props.disabled, onFileValueChange: (event) => {
|
|
282
|
-
var _a;
|
|
283
|
-
event.stopPropagation();
|
|
284
|
-
(_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, event.detail);
|
|
285
|
-
} }));
|
|
286
|
-
},
|
|
287
|
-
});
|
|
288
|
-
export const dataGridBrick = createBrick({
|
|
289
|
-
type: 'collection',
|
|
290
|
-
dataType: 'array',
|
|
291
|
-
id: 'data-grid',
|
|
292
|
-
name: 'Data grid',
|
|
293
|
-
category: 'Data',
|
|
294
|
-
defaultConfigs: { label: 'Data grid' },
|
|
295
|
-
render: (props) => props.editable || !props.brickSpec ? (fieldBlock(props, 'Data grid', h("div", { class: "fk-grid-template" }, h("span", { class: "fk-grid-template__hint" }, fkT('grid.columns')), props.children))) : (fieldBlock(props, 'Data grid', h("fk-data-grid", { spec: props.brickSpec, value: props.data, disabled: props.disabled, locale: props.locale, utils: props.utils, onGridValueChange: (event) => {
|
|
296
|
-
var _a;
|
|
297
|
-
event.stopPropagation();
|
|
298
|
-
(_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, event.detail);
|
|
299
|
-
} }))),
|
|
300
|
-
});
|
|
301
|
-
export const hiddenBrick = createBrick({
|
|
302
|
-
type: 'input',
|
|
303
|
-
dataType: 'string',
|
|
304
|
-
id: 'hidden',
|
|
305
|
-
name: 'Hidden',
|
|
306
|
-
category: 'Data',
|
|
307
|
-
defaultConfigs: {},
|
|
308
|
-
render: (props) => {
|
|
309
|
-
var _a, _b;
|
|
310
|
-
return props.editable ? (h("div", { class: "fk-hidden-chip" }, "hidden: ", (_a = props.configs) === null || _a === void 0 ? void 0 :
|
|
311
|
-
_a.key)) : (h("input", { type: "hidden", value: (_b = props.data) !== null && _b !== void 0 ? _b : '' }));
|
|
312
|
-
},
|
|
313
|
-
});
|
|
314
|
-
export const contentBrick = createBrick({
|
|
315
|
-
type: 'output',
|
|
316
|
-
dataType: 'void',
|
|
317
|
-
id: 'content',
|
|
318
|
-
name: 'Content',
|
|
319
|
-
category: 'Layout',
|
|
320
|
-
defaultConfigs: { content: 'Some text…' },
|
|
321
|
-
render: (props) => {
|
|
322
|
-
var _a, _b;
|
|
323
|
-
return (h("div", { class: "fk-content", style: asInlineStyle(props.styles) }, String((_b = (_a = props.configs) === null || _a === void 0 ? void 0 : _a.content) !== null && _b !== void 0 ? _b : '')
|
|
324
|
-
.split('\n')
|
|
325
|
-
.map((line) => (h("p", { class: "fk-content__line" }, line)))));
|
|
326
|
-
},
|
|
327
|
-
});
|
|
328
|
-
export const stepperBrick = createBrick({
|
|
329
|
-
type: 'panel',
|
|
330
|
-
dataType: 'void',
|
|
331
|
-
id: 'stepper',
|
|
332
|
-
name: 'Stepper',
|
|
333
|
-
category: 'Layout',
|
|
334
|
-
defaultConfigs: {
|
|
335
|
-
validateSteps: false,
|
|
336
|
-
allowStepClick: true,
|
|
337
|
-
showSubmit: false,
|
|
338
|
-
},
|
|
339
|
-
render: (props) => {
|
|
340
|
-
var _a, _b;
|
|
341
|
-
const labels = ((_b = (_a = props.brickSpec) === null || _a === void 0 ? void 0 : _a.children) !== null && _b !== void 0 ? _b : []).map((child, index) => {
|
|
342
|
-
var _a, _b;
|
|
343
|
-
const resolved = resolveLocalizedText((_a = child.configs) === null || _a === void 0 ? void 0 : _a.label, props.locale);
|
|
344
|
-
return typeof resolved === 'string'
|
|
345
|
-
? resolved
|
|
346
|
-
: ((_b = child.name) !== null && _b !== void 0 ? _b : `Step ${index + 1}`);
|
|
347
|
-
});
|
|
348
|
-
return (h("fk-stepper", { stepLabels: labels, editable: props.editable, spec: props.brickSpec, dataMap: props.dataMap, locale: props.locale, style: asInlineStyle(props.styles) }, props.children));
|
|
349
|
-
},
|
|
350
|
-
});
|
|
351
|
-
export const checkboxBrick = createBrick({
|
|
352
|
-
type: 'input',
|
|
353
|
-
dataType: 'boolean',
|
|
354
|
-
id: 'checkbox',
|
|
355
|
-
name: 'Checkbox',
|
|
356
|
-
category: 'Inputs',
|
|
357
|
-
defaultConfigs: { label: 'Checkbox' },
|
|
358
|
-
render: (props) => (h("label", { class: "fk-field fk-field--inline", style: asInlineStyle(props.styles) }, h("input", { class: "fk-field__checkbox", type: "checkbox", checked: props.data === true, disabled: props.editable || props.disabled, onChange: (event) => { var _a; return (_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, event.target.checked); } }), h("span", { class: "fk-field__label" }, labelOf(props, 'Checkbox')), props.error ? h("span", { class: "fk-field__error" }, props.error) : null)),
|
|
359
|
-
});
|
|
360
|
-
export const groupBrick = createBrick({
|
|
361
|
-
type: 'panel',
|
|
362
|
-
dataType: 'void',
|
|
363
|
-
id: 'group',
|
|
364
|
-
name: 'Group',
|
|
365
|
-
category: 'Layout',
|
|
366
|
-
render: (props) => {
|
|
367
|
-
var _a;
|
|
368
|
-
return (h("fieldset", { class: "fk-group", style: asInlineStyle(props.styles) }, ((_a = props.configs) === null || _a === void 0 ? void 0 : _a.label) ? (h("legend", { class: "fk-group__legend" }, props.configs.label)) : null, props.children));
|
|
369
|
-
},
|
|
370
|
-
});
|
|
371
|
-
export const rowBrick = createBrick({
|
|
372
|
-
type: 'panel',
|
|
373
|
-
dataType: 'void',
|
|
374
|
-
id: 'row',
|
|
375
|
-
name: 'Row',
|
|
376
|
-
category: 'Layout',
|
|
377
|
-
render: (props) => (h("div", { class: "fk-row", style: asInlineStyle(props.styles) }, props.children)),
|
|
378
|
-
});
|
|
379
|
-
export const columnBrick = createBrick({
|
|
380
|
-
type: 'panel',
|
|
381
|
-
dataType: 'void',
|
|
382
|
-
id: 'column',
|
|
383
|
-
name: 'Column',
|
|
384
|
-
category: 'Layout',
|
|
385
|
-
render: (props) => (h("div", { class: "fk-column", style: asInlineStyle(props.styles) }, props.children)),
|
|
386
|
-
});
|
|
387
|
-
const formatRecapValue = (brick, value) => {
|
|
388
|
-
var _a;
|
|
389
|
-
if (Array.isArray(value)) {
|
|
390
|
-
return value
|
|
391
|
-
.map((item) => formatRecapValue(brick, item))
|
|
392
|
-
.filter(Boolean)
|
|
393
|
-
.join(', ');
|
|
394
|
-
}
|
|
395
|
-
if (value === true)
|
|
396
|
-
return fkTOr('recap.yes', 'Yes');
|
|
397
|
-
if (value === false)
|
|
398
|
-
return fkTOr('recap.no', 'No');
|
|
399
|
-
if (value && typeof value === 'object') {
|
|
400
|
-
const record = value;
|
|
401
|
-
if (typeof record.name === 'string' && 'url' in record)
|
|
402
|
-
return record.name;
|
|
403
|
-
return Object.values(record)
|
|
404
|
-
.filter((part) => typeof part === 'string' && part)
|
|
405
|
-
.join(' ');
|
|
406
|
-
}
|
|
407
|
-
const raw = String(value !== null && value !== void 0 ? value : '');
|
|
408
|
-
if (((_a = brick.configs) === null || _a === void 0 ? void 0 : _a.options) != null) {
|
|
409
|
-
const labelKey = typeof brick.configs.labelKey === 'string' ? brick.configs.labelKey : 'label';
|
|
410
|
-
const valueKey = typeof brick.configs.valueKey === 'string' ? brick.configs.valueKey : 'value';
|
|
411
|
-
const match = normalizeOptions(brick.configs.options, labelKey, valueKey).find((option) => option.value === raw);
|
|
412
|
-
if (match)
|
|
413
|
-
return match.label;
|
|
414
|
-
}
|
|
415
|
-
return raw;
|
|
416
|
-
};
|
|
417
|
-
const isEmptyRecapValue = (raw) => raw === undefined ||
|
|
418
|
-
raw === null ||
|
|
419
|
-
raw === '' ||
|
|
420
|
-
(Array.isArray(raw) && raw.length === 0);
|
|
421
|
-
const brickLabel = (brick, locale) => {
|
|
422
|
-
var _a, _b, _c, _d, _e;
|
|
423
|
-
return String((_e = (_c = (_b = resolveLocalizedText((_a = brick.configs) === null || _a === void 0 ? void 0 : _a.label, locale)) !== null && _b !== void 0 ? _b : brick.name) !== null && _c !== void 0 ? _c : (_d = brick.configs) === null || _d === void 0 ? void 0 : _d.key) !== null && _e !== void 0 ? _e : '');
|
|
424
|
-
};
|
|
425
|
-
const collectionInputs = (spec) => {
|
|
426
|
-
var _a, _b;
|
|
427
|
-
const inputs = [];
|
|
428
|
-
for (const child of (_a = spec.children) !== null && _a !== void 0 ? _a : []) {
|
|
429
|
-
const key = (_b = child.configs) === null || _b === void 0 ? void 0 : _b.key;
|
|
430
|
-
if (child.type === 'input' && key && !key.startsWith('_')) {
|
|
431
|
-
inputs.push(child);
|
|
432
|
-
}
|
|
433
|
-
else if (child.type === 'panel') {
|
|
434
|
-
inputs.push(...collectionInputs(child));
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
return inputs;
|
|
438
|
-
};
|
|
439
|
-
const collectRecapItems = (spec, dataMap, locale, showEmpty, groupBySections = false) => {
|
|
440
|
-
var _a, _b, _c;
|
|
441
|
-
if (!spec)
|
|
442
|
-
return [];
|
|
443
|
-
const items = [];
|
|
444
|
-
for (const child of (_a = spec.children) !== null && _a !== void 0 ? _a : []) {
|
|
445
|
-
if (child.id === 'recap' || child.type === 'action')
|
|
446
|
-
continue;
|
|
447
|
-
if (getAffectedProperties(child.rules, dataMap).hidden === true)
|
|
448
|
-
continue;
|
|
449
|
-
const key = (_b = child.configs) === null || _b === void 0 ? void 0 : _b.key;
|
|
450
|
-
const label = brickLabel(child, locale);
|
|
451
|
-
if (child.type === 'collection') {
|
|
452
|
-
const rows = key && Array.isArray(dataMap === null || dataMap === void 0 ? void 0 : dataMap[key])
|
|
453
|
-
? dataMap[key]
|
|
454
|
-
: [];
|
|
455
|
-
if (!rows.length && !showEmpty)
|
|
456
|
-
continue;
|
|
457
|
-
const inputs = collectionInputs(child);
|
|
458
|
-
items.push({
|
|
459
|
-
kind: 'collection',
|
|
460
|
-
label,
|
|
461
|
-
columns: inputs.map((input) => brickLabel(input, locale)),
|
|
462
|
-
rows: rows.map((row) => inputs.map((input) => {
|
|
463
|
-
const raw = row === null || row === void 0 ? void 0 : row[input.configs.key];
|
|
464
|
-
return isEmptyRecapValue(raw) ? '—' : formatRecapValue(input, raw);
|
|
465
|
-
})),
|
|
466
|
-
});
|
|
467
|
-
continue;
|
|
468
|
-
}
|
|
469
|
-
if (child.type === 'panel') {
|
|
470
|
-
const sectionLabel = resolveLocalizedText((_c = child.configs) === null || _c === void 0 ? void 0 : _c.label, locale);
|
|
471
|
-
if (groupBySections &&
|
|
472
|
-
typeof sectionLabel === 'string' &&
|
|
473
|
-
sectionLabel.trim()) {
|
|
474
|
-
const sectionItems = collectRecapItems(child, dataMap, locale, showEmpty);
|
|
475
|
-
if (sectionItems.length) {
|
|
476
|
-
items.push({ kind: 'section', label: sectionLabel });
|
|
477
|
-
items.push(...sectionItems);
|
|
478
|
-
}
|
|
479
|
-
continue;
|
|
480
|
-
}
|
|
481
|
-
items.push(...collectRecapItems(child, dataMap, locale, showEmpty, groupBySections));
|
|
482
|
-
continue;
|
|
483
|
-
}
|
|
484
|
-
if (child.type !== 'input' || !key || key.startsWith('_'))
|
|
485
|
-
continue;
|
|
486
|
-
const raw = dataMap === null || dataMap === void 0 ? void 0 : dataMap[key];
|
|
487
|
-
if (isEmptyRecapValue(raw) && !showEmpty)
|
|
488
|
-
continue;
|
|
489
|
-
items.push({
|
|
490
|
-
kind: 'field',
|
|
491
|
-
label,
|
|
492
|
-
value: isEmptyRecapValue(raw) ? '—' : formatRecapValue(child, raw),
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
return items;
|
|
496
|
-
};
|
|
497
|
-
export const recapBrick = createBrick({
|
|
498
|
-
type: 'output',
|
|
499
|
-
dataType: 'void',
|
|
500
|
-
id: 'recap',
|
|
501
|
-
name: 'Recap',
|
|
502
|
-
category: 'Layout',
|
|
503
|
-
defaultConfigs: { label: 'Recap', showEmpty: false, groupBySections: false },
|
|
504
|
-
render: (props) => {
|
|
505
|
-
var _a, _b;
|
|
506
|
-
const items = collectRecapItems(props.rootSpec, props.dataMap, props.locale, ((_a = props.configs) === null || _a === void 0 ? void 0 : _a.showEmpty) === true, ((_b = props.configs) === null || _b === void 0 ? void 0 : _b.groupBySections) === true);
|
|
507
|
-
const blocks = [];
|
|
508
|
-
let fields = [];
|
|
509
|
-
const flushFields = () => {
|
|
510
|
-
if (!fields.length)
|
|
511
|
-
return;
|
|
512
|
-
blocks.push(h("dl", { class: "fk-recap__list" }, fields.map((field) => (h("div", { class: "fk-recap__row", key: field.label }, h("dt", { class: "fk-recap__term" }, field.label), h("dd", { class: "fk-recap__value" }, field.value))))));
|
|
513
|
-
fields = [];
|
|
514
|
-
};
|
|
515
|
-
for (const item of items) {
|
|
516
|
-
if (item.kind === 'field') {
|
|
517
|
-
fields.push(item);
|
|
518
|
-
continue;
|
|
519
|
-
}
|
|
520
|
-
flushFields();
|
|
521
|
-
if (item.kind === 'section') {
|
|
522
|
-
blocks.push(h("span", { class: "fk-recap__group-title", key: `section:${item.label}` }, item.label));
|
|
523
|
-
continue;
|
|
524
|
-
}
|
|
525
|
-
blocks.push(h("section", { class: "fk-recap__section", key: item.label }, h("span", { class: "fk-recap__section-title" }, item.label), item.rows.length ? (h("div", { class: "fk-recap__table-wrap" }, h("table", { class: "fk-recap__table" }, h("thead", null, h("tr", null, h("th", { class: "fk-recap__index-cell" }, "#"), item.columns.map((column) => (h("th", { key: column }, column))))), h("tbody", null, item.rows.map((row, index) => (h("tr", { key: index }, h("td", { class: "fk-recap__index-cell" }, index + 1), row.map((cell, cellIndex) => (h("td", { key: cellIndex }, cell)))))))))) : (h("p", { class: "fk-recap__empty" }, fkTOr('recap.empty', 'Nothing to summarize yet.')))));
|
|
526
|
-
}
|
|
527
|
-
flushFields();
|
|
528
|
-
return (h("div", { class: "fk-field fk-recap", style: asInlineStyle(props.styles) }, h("span", { class: "fk-field__label" }, labelOf(props, 'Recap')), blocks.length ? (blocks) : (h("p", { class: "fk-recap__empty" }, fkTOr('recap.empty', 'Nothing to summarize yet.')))));
|
|
529
|
-
},
|
|
530
|
-
});
|
|
531
|
-
export function registerDefaultBricks() {
|
|
532
|
-
registerBricks([
|
|
533
|
-
textInputBrick,
|
|
534
|
-
emailBrick,
|
|
535
|
-
passwordBrick,
|
|
536
|
-
urlBrick,
|
|
537
|
-
phoneBrick,
|
|
538
|
-
textareaBrick,
|
|
539
|
-
numberBrick,
|
|
540
|
-
dateBrick,
|
|
541
|
-
timeBrick,
|
|
542
|
-
datetimeBrick,
|
|
543
|
-
selectBrick,
|
|
544
|
-
multiSelectBrick,
|
|
545
|
-
radioBrick,
|
|
546
|
-
selectBoxesBrick,
|
|
547
|
-
checkboxBrick,
|
|
548
|
-
tagsBrick,
|
|
549
|
-
signatureBrick,
|
|
550
|
-
addressBrick,
|
|
551
|
-
fileBrick,
|
|
552
|
-
dataGridBrick,
|
|
553
|
-
hiddenBrick,
|
|
554
|
-
contentBrick,
|
|
555
|
-
recapBrick,
|
|
556
|
-
groupBrick,
|
|
557
|
-
rowBrick,
|
|
558
|
-
columnBrick,
|
|
559
|
-
stepperBrick,
|
|
560
|
-
tabsBrick,
|
|
561
|
-
]);
|
|
562
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
var _a;
|
|
2
|
-
const GLOBAL_KEY = Symbol.for('formkrafter.wc.bricks');
|
|
3
|
-
const globalStore = globalThis;
|
|
4
|
-
const bricks = ((_a = globalStore[GLOBAL_KEY]) !== null && _a !== void 0 ? _a : (globalStore[GLOBAL_KEY] = new Map()));
|
|
5
|
-
const keyOf = (type, id) => `${type}:${id}`;
|
|
6
|
-
export function registerBrick(brick) {
|
|
7
|
-
bricks.set(keyOf(brick.type, brick.id), brick);
|
|
8
|
-
}
|
|
9
|
-
export function registerBricks(list) {
|
|
10
|
-
list.forEach(registerBrick);
|
|
11
|
-
}
|
|
12
|
-
export function getBrick(type, id) {
|
|
13
|
-
return bricks.get(keyOf(type, id));
|
|
14
|
-
}
|
|
15
|
-
export function getBrickMolds() {
|
|
16
|
-
return [...bricks.values()]
|
|
17
|
-
.filter((brick) => !brick.isPrivate)
|
|
18
|
-
.map((brick) => ({
|
|
19
|
-
type: brick.type,
|
|
20
|
-
id: brick.id,
|
|
21
|
-
name: brick.name,
|
|
22
|
-
configsForm: brick.configsForm,
|
|
23
|
-
category: brick.category,
|
|
24
|
-
isPrivate: brick.isPrivate,
|
|
25
|
-
}));
|
|
26
|
-
}
|
|
27
|
-
export function getBrickMoldsGroupedByCategory() {
|
|
28
|
-
var _a, _b;
|
|
29
|
-
const grouped = {};
|
|
30
|
-
for (const mold of getBrickMolds()) {
|
|
31
|
-
const category = (_a = mold.category) !== null && _a !== void 0 ? _a : 'Uncategorized';
|
|
32
|
-
((_b = grouped[category]) !== null && _b !== void 0 ? _b : (grouped[category] = [])).push(mold);
|
|
33
|
-
}
|
|
34
|
-
return grouped;
|
|
35
|
-
}
|
|
36
|
-
export function newBrickSpec(type, id) {
|
|
37
|
-
var _a, _b;
|
|
38
|
-
const brick = getBrick(type, id);
|
|
39
|
-
if (!brick)
|
|
40
|
-
return undefined;
|
|
41
|
-
const empty = brick.getBrickEmptySpec();
|
|
42
|
-
const uid = crypto.randomUUID();
|
|
43
|
-
return Object.assign(Object.assign({}, empty), { configs: Object.assign(Object.assign({}, empty.configs), { uid, key: (_b = (_a = empty.configs) === null || _a === void 0 ? void 0 : _a.key) !== null && _b !== void 0 ? _b : `${id}_${uid.slice(0, 6)}` }) });
|
|
44
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export function getBrickData(brickSpec, data) {
|
|
2
|
-
var _a;
|
|
3
|
-
if (!((_a = brickSpec.configs) === null || _a === void 0 ? void 0 : _a.key) || !data)
|
|
4
|
-
return undefined;
|
|
5
|
-
if (brickSpec.unWrapData)
|
|
6
|
-
return data;
|
|
7
|
-
return data[brickSpec.configs.key];
|
|
8
|
-
}
|
|
9
|
-
export function wrapBrickData(brickSpec, value) {
|
|
10
|
-
var _a;
|
|
11
|
-
if (!((_a = brickSpec.configs) === null || _a === void 0 ? void 0 : _a.key))
|
|
12
|
-
return undefined;
|
|
13
|
-
if (brickSpec.unWrapData)
|
|
14
|
-
return value;
|
|
15
|
-
return { [brickSpec.configs.key]: value };
|
|
16
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { getBrickMolds } from "../registry/registry";
|
|
2
|
-
export function toBrickDropDetail(data, parentPath, index) {
|
|
3
|
-
if (data.kind === 'new-brick') {
|
|
4
|
-
const mold = getBrickMolds().find((candidate) => candidate.type === data.moldType &&
|
|
5
|
-
candidate.id === data.moldId);
|
|
6
|
-
if (!mold)
|
|
7
|
-
return undefined;
|
|
8
|
-
return { source: 'new', mold, parentPath, index };
|
|
9
|
-
}
|
|
10
|
-
if (data.kind === 'move-brick') {
|
|
11
|
-
return { source: 'move', from: data.path, parentPath, index };
|
|
12
|
-
}
|
|
13
|
-
return undefined;
|
|
14
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export function normalizeOptions(raw, labelKey = 'label', valueKey = 'value') {
|
|
2
|
-
if (Array.isArray(raw)) {
|
|
3
|
-
return raw
|
|
4
|
-
.map((item) => {
|
|
5
|
-
var _a, _b;
|
|
6
|
-
if (typeof item === 'object' && item !== null) {
|
|
7
|
-
const record = item;
|
|
8
|
-
const label = (_a = record[labelKey]) !== null && _a !== void 0 ? _a : record[valueKey];
|
|
9
|
-
const value = (_b = record[valueKey]) !== null && _b !== void 0 ? _b : record[labelKey];
|
|
10
|
-
return { label: String(label !== null && label !== void 0 ? label : ''), value: String(value !== null && value !== void 0 ? value : '') };
|
|
11
|
-
}
|
|
12
|
-
return { label: String(item), value: String(item) };
|
|
13
|
-
})
|
|
14
|
-
.filter((option) => option.label !== '');
|
|
15
|
-
}
|
|
16
|
-
return String(raw !== null && raw !== void 0 ? raw : '')
|
|
17
|
-
.split('\n')
|
|
18
|
-
.map((line) => line.trim())
|
|
19
|
-
.filter(Boolean)
|
|
20
|
-
.map((line) => ({ label: line, value: line }));
|
|
21
|
-
}
|