@streamline-pulse/formkrafter-wc 0.1.1 → 0.3.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 +3 -3
- package/dist/cjs/fk-brick-actions_18.cjs.entry.js +258 -22476
- package/dist/cjs/formkrafter-wc.cjs.js +2 -2
- package/dist/cjs/index-Bhy1RJMV.js +3042 -0
- package/dist/cjs/{index-D_7eGIJ0.js → index-CImTe9BG.js} +40 -4
- package/dist/cjs/index-CdaT3-qx.js +5444 -0
- package/dist/cjs/{index-By4GGW_q.js → index-CkPPRg03.js} +237 -35
- package/dist/cjs/index-DHgK3reD.js +12233 -0
- package/dist/cjs/index-Ds0sDbXV.js +4019 -0
- package/dist/cjs/index-c9BL7y3N.js +1922 -0
- package/dist/cjs/index.cjs.js +3 -2
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/components/fk-brick-render/fk-brick-render.js +31 -3
- package/dist/collection/components/fk-code-editor/fk-code-editor.js +17 -8
- package/dist/collection/components/fk-file-input/fk-file-input.css +26 -5
- package/dist/collection/components/fk-file-input/fk-file-input.js +96 -14
- package/dist/collection/components/fk-form-builder/fk-form-builder.css +30 -0
- package/dist/collection/components/fk-form-render/fk-form-render.js +1 -1
- package/dist/collection/components/fk-property-panel/fk-property-panel.js +5 -1
- package/dist/collection/components/fk-select-input/fk-select-input.css +9 -0
- package/dist/collection/components/fk-select-input/fk-select-input.js +118 -20
- package/dist/collection/components/fk-stepper/fk-stepper.css +14 -0
- package/dist/collection/components/fk-stepper/fk-stepper.js +4 -1
- package/dist/collection/components/fk-tabs/fk-tabs.js +15 -2
- package/dist/collection/i18n/i18n.js +20 -0
- package/dist/collection/index.js +1 -1
- package/dist/collection/registry/default-bricks.js +174 -34
- 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-B4vAN-UA.js → p--vL6GR31.js} +1 -1
- package/dist/components/p-4COASNrZ.js +1 -0
- package/dist/components/p-BB4Llg42.js +1 -0
- package/dist/components/p-BGkZP87K.js +1 -0
- package/dist/components/p-BOmBVgfJ.js +1 -0
- package/dist/components/p-BWdm2a6q.js +1 -0
- package/dist/components/{p-D318uFl-.js → p-B_-x-GlA.js} +1 -1
- package/dist/components/p-Br1s4Ujx.js +1 -0
- package/dist/components/p-C-wnqV3i.js +1 -0
- package/dist/components/{p-ZEW2q-4b.js → p-CIfjRTky.js} +1 -1
- package/dist/components/{p-dX7Lo8Fe.js → p-CKMHMpID.js} +1 -1
- package/dist/components/p-CUF31e-P.js +1 -0
- package/dist/components/p-CWQX0sXS.js +1 -0
- package/dist/components/p-D6n74M9d.js +1 -0
- package/dist/components/{p-DJDrDvoC.js → p-DFe3zZCI.js} +1 -1
- package/dist/components/p-DMCkrZqi.js +1 -0
- package/dist/components/p-DOInQkG6.js +1 -0
- package/dist/components/{p-BNREw7TY.js → p-DYchD23x.js} +1 -1
- package/dist/components/p-DtcM1yw5.js +1 -0
- package/dist/components/{p-BB3BQPr8.js → p-NDbmiiYk.js} +1 -1
- package/dist/components/p-PAr7WoWG.js +1 -0
- package/dist/components/{p-Ctt--jpe.js → p-YyGnQmX-.js} +1 -1
- package/dist/components/{p-DtzMNM4i.js → p-fDJP6whN.js} +1 -1
- package/dist/components/p-swxZqinH.js +1 -0
- package/dist/components/{p-BXFug2Ql.js → p-v7LxwCAc.js} +1 -1
- package/dist/components/p-wuC5rVU7.js +1 -0
- package/dist/esm/fk-brick-actions_18.entry.js +254 -22472
- package/dist/esm/formkrafter-wc.js +3 -3
- package/dist/esm/index-BAcz7b5u.js +5416 -0
- package/dist/esm/index-BkRMoLXK.js +3029 -0
- package/dist/esm/index-CGMDfZ5m.js +1808 -0
- package/dist/esm/{index-BTmZ8XET.js → index-D7Cta1UB.js} +236 -36
- package/dist/esm/index-DtcM1yw5.js +3991 -0
- package/dist/esm/index-DuVf3NlP.js +12222 -0
- package/dist/esm/{index-BQqrzKxo.js → index-qLZlXROB.js} +40 -4
- package/dist/esm/index.js +2 -2
- package/dist/esm/loader.js +3 -3
- 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-4COASNrZ.js +1 -0
- package/dist/formkrafter-wc/p-6d29555b.entry.js +1 -0
- package/dist/formkrafter-wc/p-C-wnqV3i.js +1 -0
- package/dist/formkrafter-wc/p-DMCkrZqi.js +1 -0
- package/dist/formkrafter-wc/p-DOInQkG6.js +1 -0
- package/dist/formkrafter-wc/{p-BXIsVlA6.js → p-Ddu6BquK.js} +4 -4
- package/dist/formkrafter-wc/p-DtcM1yw5.js +1 -0
- package/dist/formkrafter-wc/p-qLZlXROB.js +2 -0
- package/dist/types/components/fk-brick-render/fk-brick-render.d.ts +1 -0
- package/dist/types/components/fk-code-editor/fk-code-editor.d.ts +2 -1
- package/dist/types/components/fk-file-input/fk-file-input.d.ts +9 -2
- package/dist/types/components/fk-select-input/fk-select-input.d.ts +9 -0
- package/dist/types/components.d.ts +27 -4
- package/dist/types/home/runner/work/formkrafter/formkrafter/packages/wc/.stencil/stencil.config.d.ts +2 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/registry/default-bricks.d.ts +73 -54
- package/package.json +11 -2
- package/dist/components/p-BCQ-hj6j.js +0 -1
- package/dist/components/p-BIEpAM4V.js +0 -1
- package/dist/components/p-BLKRn62s.js +0 -1
- package/dist/components/p-BOvjVIvo.js +0 -1
- package/dist/components/p-BQP1WryV.js +0 -1
- package/dist/components/p-DKGyje7v.js +0 -1
- package/dist/components/p-DKoJovNt.js +0 -1
- package/dist/components/p-DWgjI3TW.js +0 -1
- package/dist/components/p-QC41Uj05.js +0 -1
- package/dist/components/p-TvmRksgg.js +0 -1
- package/dist/formkrafter-wc/p-BQqrzKxo.js +0 -2
- package/dist/formkrafter-wc/p-f6bc0be0.entry.js +0 -1
- package/dist/types/Users/datagnikan/Desktop/WorkSpace/streamline-pulse/formkrafter-js/formkrafter/packages/wc/.stencil/stencil.config.d.ts +0 -2
|
@@ -2,8 +2,9 @@ import { h } from "@stencil/core";
|
|
|
2
2
|
import { createBrick } from "./create-brick";
|
|
3
3
|
import { registerBricks } from "./registry";
|
|
4
4
|
import { asInlineStyle } from "../utils/style";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { normalizeOptions } from "../utils/options";
|
|
6
|
+
import { fkT, fkTOr } from "../i18n/i18n";
|
|
7
|
+
import { getAffectedProperties, resolveLocalizedText, } from "@streamline-pulse/formkrafter-core";
|
|
7
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; };
|
|
8
9
|
const adorned = (props, control) => {
|
|
9
10
|
var _a, _b;
|
|
@@ -13,8 +14,10 @@ const adorned = (props, control) => {
|
|
|
13
14
|
return control;
|
|
14
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));
|
|
15
16
|
};
|
|
16
|
-
const
|
|
17
|
-
const
|
|
17
|
+
const fieldError = (props) => props.error ? (h("span", { class: "fk-field__error", role: "alert" }, props.error)) : null;
|
|
18
|
+
const invalidAttr = (props) => props.error ? { 'aria-invalid': 'true' } : {};
|
|
19
|
+
const fieldBlock = (props, fallback, control) => (h("div", { class: "fk-field", style: asInlineStyle(props.styles) }, h("span", { class: "fk-field__label" }, labelOf(props, fallback)), control, fieldError(props)));
|
|
20
|
+
const field = (props, fallback, control) => (h("label", { class: "fk-field", style: asInlineStyle(props.styles) }, h("span", { class: "fk-field__label" }, labelOf(props, fallback)), control, fieldError(props)));
|
|
18
21
|
const createTextVariant = (params) => createBrick({
|
|
19
22
|
type: 'input',
|
|
20
23
|
dataType: 'string',
|
|
@@ -24,7 +27,7 @@ const createTextVariant = (params) => createBrick({
|
|
|
24
27
|
defaultConfigs: { label: params.name },
|
|
25
28
|
render: (props) => {
|
|
26
29
|
var _a, _b;
|
|
27
|
-
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); } })));
|
|
30
|
+
return field(props, params.name, adorned(props, h("input", Object.assign({}, invalidAttr(props), { 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); } }))));
|
|
28
31
|
},
|
|
29
32
|
});
|
|
30
33
|
export const textInputBrick = createTextVariant({
|
|
@@ -61,7 +64,7 @@ export const textareaBrick = createBrick({
|
|
|
61
64
|
defaultConfigs: { label: 'Text area' },
|
|
62
65
|
render: (props) => {
|
|
63
66
|
var _a, _b;
|
|
64
|
-
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); } }));
|
|
67
|
+
return field(props, 'Text area', h("textarea", Object.assign({}, invalidAttr(props), { 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); } })));
|
|
65
68
|
},
|
|
66
69
|
});
|
|
67
70
|
export const numberBrick = createBrick({
|
|
@@ -73,11 +76,11 @@ export const numberBrick = createBrick({
|
|
|
73
76
|
defaultConfigs: { label: 'Number' },
|
|
74
77
|
render: (props) => {
|
|
75
78
|
var _a;
|
|
76
|
-
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) => {
|
|
79
|
+
return field(props, 'Number', adorned(props, h("input", Object.assign({}, invalidAttr(props), { 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) => {
|
|
77
80
|
var _a;
|
|
78
81
|
const raw = event.target.value;
|
|
79
82
|
(_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, raw === '' ? undefined : Number(raw));
|
|
80
|
-
} })));
|
|
83
|
+
} }))));
|
|
81
84
|
},
|
|
82
85
|
});
|
|
83
86
|
export const dateBrick = createBrick({
|
|
@@ -89,11 +92,11 @@ export const dateBrick = createBrick({
|
|
|
89
92
|
defaultConfigs: { label: 'Date' },
|
|
90
93
|
render: (props) => {
|
|
91
94
|
var _a;
|
|
92
|
-
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) => {
|
|
95
|
+
return field(props, 'Date', h("input", Object.assign({}, invalidAttr(props), { class: "fk-field__input", type: "date", value: (_a = props.data) !== null && _a !== void 0 ? _a : '', disabled: props.editable || props.disabled, onInput: (event) => {
|
|
93
96
|
var _a;
|
|
94
97
|
const raw = event.target.value;
|
|
95
98
|
(_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, raw === '' ? undefined : raw);
|
|
96
|
-
} }));
|
|
99
|
+
} })));
|
|
97
100
|
},
|
|
98
101
|
});
|
|
99
102
|
export const selectBrick = createBrick({
|
|
@@ -109,7 +112,7 @@ export const selectBrick = createBrick({
|
|
|
109
112
|
},
|
|
110
113
|
render: (props) => {
|
|
111
114
|
var _a;
|
|
112
|
-
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) => {
|
|
115
|
+
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, invalid: !!props.error, dataMap: props.dataMap, onSelectValueChange: (event) => {
|
|
113
116
|
var _a;
|
|
114
117
|
event.stopPropagation();
|
|
115
118
|
(_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, event.detail);
|
|
@@ -127,7 +130,7 @@ export const multiSelectBrick = createBrick({
|
|
|
127
130
|
optionsSource: 'static',
|
|
128
131
|
options: 'Option 1\nOption 2\nOption 3',
|
|
129
132
|
},
|
|
130
|
-
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) => {
|
|
133
|
+
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, invalid: !!props.error, dataMap: props.dataMap, onSelectValueChange: (event) => {
|
|
131
134
|
var _a;
|
|
132
135
|
event.stopPropagation();
|
|
133
136
|
(_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, event.detail);
|
|
@@ -143,10 +146,10 @@ export const datetimeBrick = createTextVariant({
|
|
|
143
146
|
name: 'Date / Time',
|
|
144
147
|
inputType: 'datetime-local',
|
|
145
148
|
});
|
|
146
|
-
const staticOptions = (
|
|
147
|
-
|
|
148
|
-
.
|
|
149
|
-
|
|
149
|
+
const staticOptions = (props) => {
|
|
150
|
+
var _a, _b, _c;
|
|
151
|
+
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');
|
|
152
|
+
};
|
|
150
153
|
export const selectBoxesBrick = createBrick({
|
|
151
154
|
type: 'input',
|
|
152
155
|
dataType: 'array',
|
|
@@ -155,16 +158,15 @@ export const selectBoxesBrick = createBrick({
|
|
|
155
158
|
category: 'Inputs',
|
|
156
159
|
defaultConfigs: { label: 'Select boxes', options: 'Option 1\nOption 2\nOption 3' },
|
|
157
160
|
render: (props) => {
|
|
158
|
-
var _a;
|
|
159
161
|
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(
|
|
162
|
+
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
163
|
var _a;
|
|
162
164
|
const checked = event.target.checked;
|
|
163
165
|
const next = checked
|
|
164
|
-
? [...selected, option]
|
|
165
|
-
: selected.filter((value) => value !== option);
|
|
166
|
+
? [...selected, option.value]
|
|
167
|
+
: selected.filter((value) => value !== option.value);
|
|
166
168
|
(_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, next.length ? next : undefined);
|
|
167
|
-
} }), h("span", null, option))))), props.error ? h("span", { class: "fk-field__error" }, props.error) : null));
|
|
169
|
+
} }), h("span", null, option.label))))), props.error ? h("span", { class: "fk-field__error" }, props.error) : null));
|
|
168
170
|
},
|
|
169
171
|
});
|
|
170
172
|
export const tagsBrick = createBrick({
|
|
@@ -236,17 +238,10 @@ export const radioBrick = createBrick({
|
|
|
236
238
|
name: 'Radio',
|
|
237
239
|
category: 'Inputs',
|
|
238
240
|
defaultConfigs: { label: 'Radio', options: 'Option 1\nOption 2' },
|
|
239
|
-
render: (props) => {
|
|
241
|
+
render: (props) => (h("div", { class: "fk-field", style: asInlineStyle(props.styles) }, h("span", { class: "fk-field__label" }, labelOf(props, 'Radio')), h("div", Object.assign({ class: "fk-radio-group", role: "radiogroup" }, invalidAttr(props)), staticOptions(props).map((option) => {
|
|
240
242
|
var _a, _b;
|
|
241
|
-
return (h("
|
|
242
|
-
|
|
243
|
-
.map((option) => option.trim())
|
|
244
|
-
.filter(Boolean)
|
|
245
|
-
.map((option) => {
|
|
246
|
-
var _a, _b;
|
|
247
|
-
return (h("label", { class: "fk-radio", key: option }, 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, disabled: props.editable || props.disabled, onChange: () => { var _a; return (_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, option); } }), h("span", null, option)));
|
|
248
|
-
})), props.error ? h("span", { class: "fk-field__error" }, props.error) : null));
|
|
249
|
-
},
|
|
243
|
+
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)));
|
|
244
|
+
})), props.error ? h("span", { class: "fk-field__error" }, props.error) : null)),
|
|
250
245
|
});
|
|
251
246
|
const ADDRESS_PARTS = [
|
|
252
247
|
{ key: 'street', label: () => fkT('address.street'), full: true },
|
|
@@ -282,10 +277,10 @@ export const fileBrick = createBrick({
|
|
|
282
277
|
id: 'file',
|
|
283
278
|
name: 'File',
|
|
284
279
|
category: 'Data',
|
|
285
|
-
defaultConfigs: { label: 'File' },
|
|
280
|
+
defaultConfigs: { label: 'File', accept: '', uploadUrl: '', multiple: false },
|
|
286
281
|
render: (props) => {
|
|
287
|
-
var _a;
|
|
288
|
-
return fieldBlock(props, 'File', h("fk-file-input", { value: props.data, accept: (_a = props.configs) === null || _a === void 0 ? void 0 : _a.accept, disabled: props.editable || props.disabled, onFileValueChange: (event) => {
|
|
282
|
+
var _a, _b, _c;
|
|
283
|
+
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, multiple: ((_c = props.configs) === null || _c === void 0 ? void 0 : _c.multiple) === true, disabled: props.editable || props.disabled, onFileValueChange: (event) => {
|
|
289
284
|
var _a;
|
|
290
285
|
event.stopPropagation();
|
|
291
286
|
(_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, event.detail);
|
|
@@ -391,6 +386,150 @@ export const columnBrick = createBrick({
|
|
|
391
386
|
category: 'Layout',
|
|
392
387
|
render: (props) => (h("div", { class: "fk-column", style: asInlineStyle(props.styles) }, props.children)),
|
|
393
388
|
});
|
|
389
|
+
const formatRecapValue = (brick, value) => {
|
|
390
|
+
var _a;
|
|
391
|
+
if (Array.isArray(value)) {
|
|
392
|
+
return value
|
|
393
|
+
.map((item) => formatRecapValue(brick, item))
|
|
394
|
+
.filter(Boolean)
|
|
395
|
+
.join(', ');
|
|
396
|
+
}
|
|
397
|
+
if (value === true)
|
|
398
|
+
return fkTOr('recap.yes', 'Yes');
|
|
399
|
+
if (value === false)
|
|
400
|
+
return fkTOr('recap.no', 'No');
|
|
401
|
+
if (value && typeof value === 'object') {
|
|
402
|
+
const record = value;
|
|
403
|
+
if (typeof record.name === 'string' && 'url' in record)
|
|
404
|
+
return record.name;
|
|
405
|
+
return Object.values(record)
|
|
406
|
+
.filter((part) => typeof part === 'string' && part)
|
|
407
|
+
.join(' ');
|
|
408
|
+
}
|
|
409
|
+
const raw = String(value !== null && value !== void 0 ? value : '');
|
|
410
|
+
if (((_a = brick.configs) === null || _a === void 0 ? void 0 : _a.options) != null) {
|
|
411
|
+
const labelKey = typeof brick.configs.labelKey === 'string' ? brick.configs.labelKey : 'label';
|
|
412
|
+
const valueKey = typeof brick.configs.valueKey === 'string' ? brick.configs.valueKey : 'value';
|
|
413
|
+
const match = normalizeOptions(brick.configs.options, labelKey, valueKey).find((option) => option.value === raw);
|
|
414
|
+
if (match)
|
|
415
|
+
return match.label;
|
|
416
|
+
}
|
|
417
|
+
return raw;
|
|
418
|
+
};
|
|
419
|
+
const isEmptyRecapValue = (raw) => raw === undefined ||
|
|
420
|
+
raw === null ||
|
|
421
|
+
raw === '' ||
|
|
422
|
+
(Array.isArray(raw) && raw.length === 0);
|
|
423
|
+
const brickLabel = (brick, locale) => {
|
|
424
|
+
var _a, _b, _c, _d, _e;
|
|
425
|
+
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 : '');
|
|
426
|
+
};
|
|
427
|
+
const collectionInputs = (spec) => {
|
|
428
|
+
var _a, _b;
|
|
429
|
+
const inputs = [];
|
|
430
|
+
for (const child of (_a = spec.children) !== null && _a !== void 0 ? _a : []) {
|
|
431
|
+
const key = (_b = child.configs) === null || _b === void 0 ? void 0 : _b.key;
|
|
432
|
+
if (child.type === 'input' && key && !key.startsWith('_')) {
|
|
433
|
+
inputs.push(child);
|
|
434
|
+
}
|
|
435
|
+
else if (child.type === 'panel') {
|
|
436
|
+
inputs.push(...collectionInputs(child));
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
return inputs;
|
|
440
|
+
};
|
|
441
|
+
const collectRecapItems = (spec, dataMap, locale, showEmpty, groupBySections = false) => {
|
|
442
|
+
var _a, _b, _c;
|
|
443
|
+
if (!spec)
|
|
444
|
+
return [];
|
|
445
|
+
const items = [];
|
|
446
|
+
for (const child of (_a = spec.children) !== null && _a !== void 0 ? _a : []) {
|
|
447
|
+
if (child.id === 'recap' || child.type === 'action')
|
|
448
|
+
continue;
|
|
449
|
+
if (getAffectedProperties(child.rules, dataMap).hidden === true)
|
|
450
|
+
continue;
|
|
451
|
+
const key = (_b = child.configs) === null || _b === void 0 ? void 0 : _b.key;
|
|
452
|
+
const label = brickLabel(child, locale);
|
|
453
|
+
if (child.type === 'collection') {
|
|
454
|
+
const rows = key && Array.isArray(dataMap === null || dataMap === void 0 ? void 0 : dataMap[key])
|
|
455
|
+
? dataMap[key]
|
|
456
|
+
: [];
|
|
457
|
+
if (!rows.length && !showEmpty)
|
|
458
|
+
continue;
|
|
459
|
+
const inputs = collectionInputs(child);
|
|
460
|
+
items.push({
|
|
461
|
+
kind: 'collection',
|
|
462
|
+
label,
|
|
463
|
+
columns: inputs.map((input) => brickLabel(input, locale)),
|
|
464
|
+
rows: rows.map((row) => inputs.map((input) => {
|
|
465
|
+
const raw = row === null || row === void 0 ? void 0 : row[input.configs.key];
|
|
466
|
+
return isEmptyRecapValue(raw) ? '—' : formatRecapValue(input, raw);
|
|
467
|
+
})),
|
|
468
|
+
});
|
|
469
|
+
continue;
|
|
470
|
+
}
|
|
471
|
+
if (child.type === 'panel') {
|
|
472
|
+
const sectionLabel = resolveLocalizedText((_c = child.configs) === null || _c === void 0 ? void 0 : _c.label, locale);
|
|
473
|
+
if (groupBySections &&
|
|
474
|
+
typeof sectionLabel === 'string' &&
|
|
475
|
+
sectionLabel.trim()) {
|
|
476
|
+
const sectionItems = collectRecapItems(child, dataMap, locale, showEmpty);
|
|
477
|
+
if (sectionItems.length) {
|
|
478
|
+
items.push({ kind: 'section', label: sectionLabel });
|
|
479
|
+
items.push(...sectionItems);
|
|
480
|
+
}
|
|
481
|
+
continue;
|
|
482
|
+
}
|
|
483
|
+
items.push(...collectRecapItems(child, dataMap, locale, showEmpty, groupBySections));
|
|
484
|
+
continue;
|
|
485
|
+
}
|
|
486
|
+
if (child.type !== 'input' || !key || key.startsWith('_'))
|
|
487
|
+
continue;
|
|
488
|
+
const raw = dataMap === null || dataMap === void 0 ? void 0 : dataMap[key];
|
|
489
|
+
if (isEmptyRecapValue(raw) && !showEmpty)
|
|
490
|
+
continue;
|
|
491
|
+
items.push({
|
|
492
|
+
kind: 'field',
|
|
493
|
+
label,
|
|
494
|
+
value: isEmptyRecapValue(raw) ? '—' : formatRecapValue(child, raw),
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
return items;
|
|
498
|
+
};
|
|
499
|
+
export const recapBrick = createBrick({
|
|
500
|
+
type: 'output',
|
|
501
|
+
dataType: 'void',
|
|
502
|
+
id: 'recap',
|
|
503
|
+
name: 'Recap',
|
|
504
|
+
category: 'Layout',
|
|
505
|
+
defaultConfigs: { label: 'Recap', showEmpty: false, groupBySections: false },
|
|
506
|
+
render: (props) => {
|
|
507
|
+
var _a, _b;
|
|
508
|
+
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);
|
|
509
|
+
const blocks = [];
|
|
510
|
+
let fields = [];
|
|
511
|
+
const flushFields = () => {
|
|
512
|
+
if (!fields.length)
|
|
513
|
+
return;
|
|
514
|
+
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))))));
|
|
515
|
+
fields = [];
|
|
516
|
+
};
|
|
517
|
+
for (const item of items) {
|
|
518
|
+
if (item.kind === 'field') {
|
|
519
|
+
fields.push(item);
|
|
520
|
+
continue;
|
|
521
|
+
}
|
|
522
|
+
flushFields();
|
|
523
|
+
if (item.kind === 'section') {
|
|
524
|
+
blocks.push(h("span", { class: "fk-recap__group-title", key: `section:${item.label}` }, item.label));
|
|
525
|
+
continue;
|
|
526
|
+
}
|
|
527
|
+
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.')))));
|
|
528
|
+
}
|
|
529
|
+
flushFields();
|
|
530
|
+
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.')))));
|
|
531
|
+
},
|
|
532
|
+
});
|
|
394
533
|
export function registerDefaultBricks() {
|
|
395
534
|
registerBricks([
|
|
396
535
|
textInputBrick,
|
|
@@ -415,6 +554,7 @@ export function registerDefaultBricks() {
|
|
|
415
554
|
dataGridBrick,
|
|
416
555
|
hiddenBrick,
|
|
417
556
|
contentBrick,
|
|
557
|
+
recapBrick,
|
|
418
558
|
groupBrick,
|
|
419
559
|
rowBrick,
|
|
420
560
|
columnBrick,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as o,d as s}from"./p-
|
|
1
|
+
import{F as o,d as s}from"./p-DYchD23x.js";const p=o,r=s;export{p as FkBrickActions,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as o,d as s}from"./p-
|
|
1
|
+
import{F as o,d as s}from"./p-CIfjRTky.js";const p=o,r=s;export{p as FkBrickList,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as o,d as s}from"./p
|
|
1
|
+
import{F as o,d as s}from"./p--vL6GR31.js";const p=o,r=s;export{p as FkBrickMoldItem,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as o,d as
|
|
1
|
+
import{F as o,d as s}from"./p-NDbmiiYk.js";const i=o,m=s;export{i as FkBrickNotFound,m as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as o,d as s}from"./p-
|
|
1
|
+
import{F as o,d as s}from"./p-BWdm2a6q.js";const a=o,m=s;export{a as FkBrickRender,m as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as
|
|
1
|
+
import{F as s,d as o}from"./p-Br1s4Ujx.js";const r=s,p=o;export{r as FkCodeEditor,p as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as o,d as s}from"./p-
|
|
1
|
+
import{F as o,d as s}from"./p-CUF31e-P.js";const p=o,r=s;export{p as FkDataGrid,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as
|
|
1
|
+
import{F as o,d as s}from"./p-YyGnQmX-.js";const m=o,p=s;export{m as FkDropArea,p as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as o,d as
|
|
1
|
+
import{F as o,d as s}from"./p-DFe3zZCI.js";const p=o,r=s;export{p as FkEmptyForm,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as o,d as s}from"./p-
|
|
1
|
+
import{F as o,d as s}from"./p-D6n74M9d.js";const p=o,r=s;export{p as FkFileInput,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e,p as s,H as t,c as r,h as i}from"./p-QC41Uj05.js";import{S as o,c as a,d as c,m as l,e as d,f as n,u as f,h as k,j as p,k as h,i as u}from"./p-dX7Lo8Fe.js";import{g as b,n as m}from"./p-gPc0o8Jb.js";import{registerDefaultBricks as v}from"./index.js";import{a as g}from"./p-BQP1WryV.js";import{d as y}from"./p-BNREw7TY.js";import{d as _}from"./p-ZEW2q-4b.js";import{d as j}from"./p-B4vAN-UA.js";import{d as C}from"./p-BB3BQPr8.js";import{d as E}from"./p-DKoJovNt.js";import{d as x}from"./p-BIEpAM4V.js";import{d as B}from"./p-BCQ-hj6j.js";import{d as D}from"./p-Ctt--jpe.js";import{d as S}from"./p-DJDrDvoC.js";import{d as w}from"./p-BOvjVIvo.js";import{d as R}from"./p-D318uFl-.js";import{d as J}from"./p-DWgjI3TW.js";import{d as O}from"./p-BXFug2Ql.js";import{d as U}from"./p-TvmRksgg.js";import{d as I}from"./p-DtzMNM4i.js";import{d as L}from"./p-BLKRn62s.js";import{d as N}from"./p-DKGyje7v.js";const P=s(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.specChange=r(this,"specChange"),this.locales=[],this.currentData={},this.copied=!1,this.history=new o,this.importFromClipboard=async()=>{try{const e=await navigator.clipboard.readText();this.importSpec(e,!1)}catch(e){this.flashImportError(g("builder.pasteHint"))}},this.copySpec=async()=>{this.currentSpec&&(await navigator.clipboard.writeText(this.specJson()),this.copied=!0,setTimeout((()=>this.copied=!1),1500))},this.downloadSpec=()=>{if(!this.currentSpec)return;const e=new Blob([this.specJson()],{type:"application/json"}),s=URL.createObjectURL(e),t=document.createElement("a");t.href=s,t.download="form-spec.json",t.click(),URL.revokeObjectURL(s)},this.undo=()=>{if(!this.currentSpec)return;const e=this.history.undo(this.currentSpec);void 0!==e&&(this.currentSpec=e,this.specChange.emit({spec:e,patches:[],inverse:[]}))},this.redo=()=>{if(!this.currentSpec)return;const e=this.history.redo(this.currentSpec);void 0!==e&&(this.currentSpec=e,this.specChange.emit({spec:e,patches:[],inverse:[]}))}}componentWillLoad(){0===b().length&&v(),this.editLocale=this.locales[0],this.currentSpec=this.spec,this.currentData=Object.assign({},this.data)}syncSpec(e){this.currentSpec=e,this.history.clear()}handleBrickDrop(e){var s,t;e.stopPropagation();const{source:r,mold:i,from:o,parentPath:d,index:n}=e.detail;if("new"===r&&i){const e=m(i.type,i.id);if(!e)return;return this.currentSpec?void this.applyUpdate(a(this.currentSpec,e,d,n)):void this.setRootSpec("panel"===e.type?e:this.wrapInRootGroup(e))}if("move"===r&&o&&this.currentSpec){if(d===o||d.startsWith(o+"."))return;const e=c(this.currentSpec,d);if(!e)return;const r=null!==(t=null===(s=e.children)||void 0===s?void 0:s.length)&&void 0!==t?t:0,i=o.split("."),a=i.slice(0,-1).join("."),f=Number(i[i.length-1]),k=null!=n?n:r;if(a===d&&(k===f||k===f+1))return;this.applyUpdate(l(this.currentSpec,o,`${d}.${k}`))}}handleBrickRemove(e){e.stopPropagation(),this.currentSpec&&("0"!==e.detail.path?this.applyUpdate(d(this.currentSpec,e.detail.path)):this.setRootSpec(void 0))}handleBrickDuplicate(e){e.stopPropagation(),this.currentSpec&&this.applyUpdate(n(this.currentSpec,e.detail.path))}handleConfigsChange(e){e.stopPropagation(),this.currentSpec&&e.detail.uid&&this.applyUpdate(f(this.currentSpec,e.detail.uid,e.detail.configs))}handleStylesChange(e){e.stopPropagation(),this.currentSpec&&e.detail.uid&&this.applyUpdate(k(this.currentSpec,e.detail.uid,e.detail.styles))}handleValidationsChange(e){e.stopPropagation(),this.currentSpec&&e.detail.uid&&this.applyUpdate(p(this.currentSpec,e.detail.uid,e.detail.validations))}handleRulesChange(e){e.stopPropagation(),this.currentSpec&&e.detail.uid&&this.applyUpdate(h(this.currentSpec,e.detail.uid,e.detail.rules))}handleDataChange(e){this.currentData=e.detail.data}handlePaste(e){var s;const t=e.target;(null==t?void 0:t.closest("input, textarea, select, [contenteditable]"))||this.importSpec(null===(s=e.clipboardData)||void 0===s?void 0:s.getData("text/plain"),!0)}importSpec(e,s){if(e)try{const s=JSON.parse(e);if("object"!=typeof s||null===s||"string"!=typeof s.type||"string"!=typeof s.id)throw Error("not a brick spec");this.selectedUid=void 0,this.importError=void 0,this.setRootSpec(this.ensureUids(s))}catch(e){s||this.flashImportError(g("builder.importInvalid"))}else s||this.flashImportError(g("builder.importInvalid"))}ensureUids(e){var s;const t=structuredClone(e);for(const{brick:e}of u(t))(null===(s=e.configs)||void 0===s?void 0:s.uid)||(e.configs=Object.assign(Object.assign({},e.configs),{uid:crypto.randomUUID()}));return t}flashImportError(e){this.importError=e,setTimeout((()=>this.importError=void 0),4e3)}handleBrickSelect(e){var s,t;e.stopPropagation(),this.currentSpec&&(this.selectedUid=null===(t=null===(s=c(this.currentSpec,e.detail.path))||void 0===s?void 0:s.configs)||void 0===t?void 0:t.uid)}findSelected(){var e;if(this.currentSpec&&this.selectedUid)for(const{brick:s,path:t}of u(this.currentSpec))if((null===(e=s.configs)||void 0===e?void 0:e.uid)===this.selectedUid)return{brick:s,path:t}}inputFieldKeys(){var e;const s=[];for(const{brick:t}of u(this.currentSpec)){const r=null===(e=t.configs)||void 0===e?void 0:e.key;"input"===t.type&&r&&s.push(r)}return s}wrapInRootGroup(e){const s=m("panel","column");return s?Object.assign(Object.assign({},s),{name:"Form",children:[e]}):e}setRootSpec(e){this.currentSpec=e,this.history.clear(),this.specChange.emit({spec:e,patches:[],inverse:[]})}applyUpdate(e){this.history.record(e),this.currentSpec=e.spec,this.specChange.emit({spec:e.spec,patches:e.patches,inverse:e.inverse})}specJson(){return JSON.stringify(this.currentSpec,null,2)}render(){return i("div",{key:"f23b549325059ff00dc9b4dcce05f82e7905f646",class:"fk-builder"},i("aside",{key:"76d630af39352b324fa1160945953bcc92f7e678",class:"fk-builder__palette"},i("fk-brick-list",{key:"a2fbf6fb78febd993e1972a3077e07cd952501f9"})),i("main",{key:"e65836c299ef0b102bf99da9263823cb8506aa87",class:"fk-builder__main"},i("div",{key:"cf6681fdc4f36720919f3e52852eeaf247b4cd3f",class:"fk-builder__toolbar"},i("button",{key:"8669e0c0bff778cee7b5a0f8dc85d762cd923309",type:"button",class:"fk-builder__tool",disabled:!this.history.canUndo,onClick:this.undo},"↩ ",g("builder.undo")),i("button",{key:"e8f1b9e73a97ce7fc134628ec9dd80c43ef27f16",type:"button",class:"fk-builder__tool",disabled:!this.history.canRedo,onClick:this.redo},"↪ ",g("builder.redo")),i("span",{key:"e0af911cdb8686c8276ef3b48f75cf65b3f300ea",class:"fk-builder__spacer"}),this.locales.length>1?i("select",{class:"fk-builder__tool",onChange:e=>this.editLocale=e.target.value},this.locales.map((e=>i("option",{value:e,selected:e===this.editLocale},e.toUpperCase())))):null,this.importError?i("span",{class:"fk-builder__import-error"},this.importError):null,i("button",{key:"5eb508486721587353400365ca3826bed2037620",type:"button",class:"fk-builder__tool",onClick:this.importFromClipboard},"⤓ ",g("builder.importJson")),i("button",{key:"4e60dd9edeef51da8871c34ea042cb828c6a547b",type:"button",class:"fk-builder__tool",disabled:!this.currentSpec,onClick:this.copySpec},"⧉ ",g(this.copied?"builder.copied":"builder.copyJson")),i("button",{key:"40fc0afc683894136b6be5f73fd7f9803e0cc34c",type:"button",class:"fk-builder__tool",disabled:!this.currentSpec,onClick:this.downloadSpec},"⬇ ",g("builder.downloadJson"))),i("div",{key:"317a25b31e4fa22204b923457a507f94bcbe5fbe",class:"fk-builder__canvas"},this.currentSpec?i("fk-form-render",{spec:this.currentSpec,data:this.currentData,editable:!0,selectedUid:this.selectedUid,locale:this.editLocale}):[i("fk-empty-form",null),i("fk-drop-area",{path:"0"})])),i("aside",{key:"7d6491acc432ed158eec6727db75f152fa8398d4",class:"fk-builder__inspector"},(()=>{const e=this.findSelected();return e?i("fk-property-panel",{brick:e.brick,fields:this.inputFieldKeys(),locales:this.locales,editLocale:this.editLocale}):i("p",{class:"fk-builder__hint"},g("builder.hint"))})()))}static get watchers(){return{spec:[{syncSpec:0}]}}static get style(){return".fk-builder.sc-fk-form-builder{display:flex;gap:calc(var(--fk-spacing) * 2);align-items:flex-start;font-family:var(--fk-font);color:var(--fk-color-text)}.fk-builder__palette.sc-fk-form-builder{width:220px;flex-shrink:0;padding:calc(var(--fk-spacing) * 1.5);border:1px solid var(--fk-color-border);border-radius:var(--fk-radius);background:var(--fk-color-surface)}.fk-builder__main.sc-fk-form-builder{flex:1;min-width:0;display:flex;flex-direction:column;gap:var(--fk-spacing)}.fk-builder__toolbar.sc-fk-form-builder{display:flex;align-items:center;gap:calc(var(--fk-spacing) / 2)}.fk-builder__spacer.sc-fk-form-builder{flex:1}.fk-builder__import-error.sc-fk-form-builder{font-size:0.75rem;color:var(--fk-color-danger)}.fk-builder__tool.sc-fk-form-builder{padding:calc(var(--fk-spacing) / 2) var(--fk-spacing);border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 2);background:var(--fk-color-surface);color:var(--fk-color-text);font-size:0.8rem;cursor:pointer}.fk-builder__tool.sc-fk-form-builder:hover:not(:disabled){border-color:var(--fk-color-primary);color:var(--fk-color-primary)}.fk-builder__tool.sc-fk-form-builder:disabled{opacity:0.4;cursor:default}.fk-builder__canvas.sc-fk-form-builder{min-height:320px;padding:calc(var(--fk-spacing) * 2);border:1px solid var(--fk-color-border);border-radius:var(--fk-radius);background:var(--fk-color-surface)}.fk-builder__inspector.sc-fk-form-builder{width:260px;flex-shrink:0;padding:calc(var(--fk-spacing) * 1.5);border:1px solid var(--fk-color-border);border-radius:var(--fk-radius);background:var(--fk-color-surface)}.fk-builder__hint.sc-fk-form-builder{margin:0;font-size:0.8rem;color:var(--fk-color-muted)}"}},[2,"fk-form-builder",{spec:[16],data:[16],locales:[16],currentSpec:[32],currentData:[32],selectedUid:[32],copied:[32],importError:[32],editLocale:[32]},[[0,"brickDrop","handleBrickDrop"],[0,"brickRemove","handleBrickRemove"],[0,"brickDuplicate","handleBrickDuplicate"],[0,"brickConfigsChange","handleConfigsChange"],[0,"brickStylesChange","handleStylesChange"],[0,"brickValidationsChange","handleValidationsChange"],[0,"brickRulesChange","handleRulesChange"],[0,"formDataChange","handleDataChange"],[4,"paste","handlePaste"],[0,"brickSelect","handleBrickSelect"]],{spec:[{syncSpec:0}]}]);function V(){"undefined"!=typeof customElements&&["fk-form-builder","fk-brick-actions","fk-brick-list","fk-brick-mold-item","fk-brick-not-found","fk-brick-render","fk-code-editor","fk-data-grid","fk-drop-area","fk-empty-form","fk-file-input","fk-form-render","fk-property-panel","fk-rules-editor","fk-select-input","fk-signature-input","fk-stepper","fk-tabs"].forEach((s=>{switch(s){case"fk-form-builder":customElements.get(e(s))||customElements.define(e(s),P);break;case"fk-brick-actions":customElements.get(e(s))||y();break;case"fk-brick-list":customElements.get(e(s))||_();break;case"fk-brick-mold-item":customElements.get(e(s))||j();break;case"fk-brick-not-found":customElements.get(e(s))||C();break;case"fk-brick-render":customElements.get(e(s))||E();break;case"fk-code-editor":customElements.get(e(s))||x();break;case"fk-data-grid":customElements.get(e(s))||B();break;case"fk-drop-area":customElements.get(e(s))||D();break;case"fk-empty-form":customElements.get(e(s))||S();break;case"fk-file-input":customElements.get(e(s))||w();break;case"fk-form-render":customElements.get(e(s))||R();break;case"fk-property-panel":customElements.get(e(s))||J();break;case"fk-rules-editor":customElements.get(e(s))||O();break;case"fk-select-input":customElements.get(e(s))||U();break;case"fk-signature-input":customElements.get(e(s))||I();break;case"fk-stepper":customElements.get(e(s))||L();break;case"fk-tabs":customElements.get(e(s))||N()}}))}V();const F=P,Q=V;export{F as FkFormBuilder,Q as defineCustomElement}
|
|
1
|
+
import{t as e,p as r,H as s,c as t,h as i}from"./p-BB4Llg42.js";import{S as o,c as a,d as c,m as l,e as d,f as n,u as f,h as k,j as p,k as h,i as u}from"./p-CKMHMpID.js";import{g as b,n as m}from"./p-gPc0o8Jb.js";import{registerDefaultBricks as v}from"./index.js";import{a as _}from"./p-BOmBVgfJ.js";import{d as g}from"./p-DYchD23x.js";import{d as y}from"./p-CIfjRTky.js";import{d as x}from"./p--vL6GR31.js";import{d as j}from"./p-NDbmiiYk.js";import{d as C}from"./p-BWdm2a6q.js";import{d as E}from"./p-Br1s4Ujx.js";import{d as w}from"./p-CUF31e-P.js";import{d as B}from"./p-YyGnQmX-.js";import{d as D}from"./p-DFe3zZCI.js";import{d as S}from"./p-D6n74M9d.js";import{d as R}from"./p-B_-x-GlA.js";import{d as J}from"./p-PAr7WoWG.js";import{d as U}from"./p-v7LxwCAc.js";import{d as L}from"./p-swxZqinH.js";import{d as O}from"./p-fDJP6whN.js";import{d as P}from"./p-BGkZP87K.js";import{d as I}from"./p-wuC5rVU7.js";const G=r(class extends s{constructor(e){super(),!1!==e&&this.__registerHost(),this.specChange=t(this,"specChange"),this.locales=[],this.currentData={},this.copied=!1,this.history=new o,this.importFromClipboard=async()=>{try{const e=await navigator.clipboard.readText();this.importSpec(e,!1)}catch(e){this.flashImportError(_("builder.pasteHint"))}},this.copySpec=async()=>{this.currentSpec&&(await navigator.clipboard.writeText(this.specJson()),this.copied=!0,setTimeout((()=>this.copied=!1),1500))},this.downloadSpec=()=>{if(!this.currentSpec)return;const e=new Blob([this.specJson()],{type:"application/json"}),r=URL.createObjectURL(e),s=document.createElement("a");s.href=r,s.download="form-spec.json",s.click(),URL.revokeObjectURL(r)},this.undo=()=>{if(!this.currentSpec)return;const e=this.history.undo(this.currentSpec);void 0!==e&&(this.currentSpec=e,this.specChange.emit({spec:e,patches:[],inverse:[]}))},this.redo=()=>{if(!this.currentSpec)return;const e=this.history.redo(this.currentSpec);void 0!==e&&(this.currentSpec=e,this.specChange.emit({spec:e,patches:[],inverse:[]}))}}componentWillLoad(){0===b().length&&v(),this.editLocale=this.locales[0],this.currentSpec=this.spec,this.currentData=Object.assign({},this.data)}syncSpec(e){this.currentSpec=e,this.history.clear()}handleBrickDrop(e){var r,s;e.stopPropagation();const{source:t,mold:i,from:o,parentPath:d,index:n}=e.detail;if("new"===t&&i){const e=m(i.type,i.id);if(!e)return;return this.currentSpec?void this.applyUpdate(a(this.currentSpec,e,d,n)):void this.setRootSpec("panel"===e.type?e:this.wrapInRootGroup(e))}if("move"===t&&o&&this.currentSpec){if(d===o||d.startsWith(o+"."))return;const e=c(this.currentSpec,d);if(!e)return;const t=null!==(s=null===(r=e.children)||void 0===r?void 0:r.length)&&void 0!==s?s:0,i=o.split("."),a=i.slice(0,-1).join("."),f=Number(i[i.length-1]),k=null!=n?n:t;if(a===d&&(k===f||k===f+1))return;this.applyUpdate(l(this.currentSpec,o,`${d}.${k}`))}}handleBrickRemove(e){e.stopPropagation(),this.currentSpec&&("0"!==e.detail.path?this.applyUpdate(d(this.currentSpec,e.detail.path)):this.setRootSpec(void 0))}handleBrickDuplicate(e){e.stopPropagation(),this.currentSpec&&this.applyUpdate(n(this.currentSpec,e.detail.path))}handleConfigsChange(e){e.stopPropagation(),this.currentSpec&&e.detail.uid&&this.applyUpdate(f(this.currentSpec,e.detail.uid,e.detail.configs))}handleStylesChange(e){e.stopPropagation(),this.currentSpec&&e.detail.uid&&this.applyUpdate(k(this.currentSpec,e.detail.uid,e.detail.styles))}handleValidationsChange(e){e.stopPropagation(),this.currentSpec&&e.detail.uid&&this.applyUpdate(p(this.currentSpec,e.detail.uid,e.detail.validations))}handleRulesChange(e){e.stopPropagation(),this.currentSpec&&e.detail.uid&&this.applyUpdate(h(this.currentSpec,e.detail.uid,e.detail.rules))}handleDataChange(e){this.currentData=e.detail.data}handlePaste(e){var r;const s=e.target;(null==s?void 0:s.closest("input, textarea, select, [contenteditable]"))||this.importSpec(null===(r=e.clipboardData)||void 0===r?void 0:r.getData("text/plain"),!0)}importSpec(e,r){if(e)try{const r=JSON.parse(e);if("object"!=typeof r||null===r||"string"!=typeof r.type||"string"!=typeof r.id)throw Error("not a brick spec");this.selectedUid=void 0,this.importError=void 0,this.setRootSpec(this.ensureUids(r))}catch(e){r||this.flashImportError(_("builder.importInvalid"))}else r||this.flashImportError(_("builder.importInvalid"))}ensureUids(e){var r;const s=structuredClone(e);for(const{brick:e}of u(s))(null===(r=e.configs)||void 0===r?void 0:r.uid)||(e.configs=Object.assign(Object.assign({},e.configs),{uid:crypto.randomUUID()}));return s}flashImportError(e){this.importError=e,setTimeout((()=>this.importError=void 0),4e3)}handleBrickSelect(e){var r,s;e.stopPropagation(),this.currentSpec&&(this.selectedUid=null===(s=null===(r=c(this.currentSpec,e.detail.path))||void 0===r?void 0:r.configs)||void 0===s?void 0:s.uid)}findSelected(){var e;if(this.currentSpec&&this.selectedUid)for(const{brick:r,path:s}of u(this.currentSpec))if((null===(e=r.configs)||void 0===e?void 0:e.uid)===this.selectedUid)return{brick:r,path:s}}inputFieldKeys(){var e;const r=[];for(const{brick:s}of u(this.currentSpec)){const t=null===(e=s.configs)||void 0===e?void 0:e.key;"input"===s.type&&t&&r.push(t)}return r}wrapInRootGroup(e){const r=m("panel","column");return r?Object.assign(Object.assign({},r),{name:"Form",children:[e]}):e}setRootSpec(e){this.currentSpec=e,this.history.clear(),this.specChange.emit({spec:e,patches:[],inverse:[]})}applyUpdate(e){this.history.record(e),this.currentSpec=e.spec,this.specChange.emit({spec:e.spec,patches:e.patches,inverse:e.inverse})}specJson(){return JSON.stringify(this.currentSpec,null,2)}render(){return i("div",{key:"f23b549325059ff00dc9b4dcce05f82e7905f646",class:"fk-builder"},i("aside",{key:"76d630af39352b324fa1160945953bcc92f7e678",class:"fk-builder__palette"},i("fk-brick-list",{key:"a2fbf6fb78febd993e1972a3077e07cd952501f9"})),i("main",{key:"e65836c299ef0b102bf99da9263823cb8506aa87",class:"fk-builder__main"},i("div",{key:"cf6681fdc4f36720919f3e52852eeaf247b4cd3f",class:"fk-builder__toolbar"},i("button",{key:"8669e0c0bff778cee7b5a0f8dc85d762cd923309",type:"button",class:"fk-builder__tool",disabled:!this.history.canUndo,onClick:this.undo},"↩ ",_("builder.undo")),i("button",{key:"e8f1b9e73a97ce7fc134628ec9dd80c43ef27f16",type:"button",class:"fk-builder__tool",disabled:!this.history.canRedo,onClick:this.redo},"↪ ",_("builder.redo")),i("span",{key:"e0af911cdb8686c8276ef3b48f75cf65b3f300ea",class:"fk-builder__spacer"}),this.locales.length>1?i("select",{class:"fk-builder__tool",onChange:e=>this.editLocale=e.target.value},this.locales.map((e=>i("option",{value:e,selected:e===this.editLocale},e.toUpperCase())))):null,this.importError?i("span",{class:"fk-builder__import-error"},this.importError):null,i("button",{key:"5eb508486721587353400365ca3826bed2037620",type:"button",class:"fk-builder__tool",onClick:this.importFromClipboard},"⤓ ",_("builder.importJson")),i("button",{key:"4e60dd9edeef51da8871c34ea042cb828c6a547b",type:"button",class:"fk-builder__tool",disabled:!this.currentSpec,onClick:this.copySpec},"⧉ ",_(this.copied?"builder.copied":"builder.copyJson")),i("button",{key:"40fc0afc683894136b6be5f73fd7f9803e0cc34c",type:"button",class:"fk-builder__tool",disabled:!this.currentSpec,onClick:this.downloadSpec},"⬇ ",_("builder.downloadJson"))),i("div",{key:"317a25b31e4fa22204b923457a507f94bcbe5fbe",class:"fk-builder__canvas"},this.currentSpec?i("fk-form-render",{spec:this.currentSpec,data:this.currentData,editable:!0,selectedUid:this.selectedUid,locale:this.editLocale}):[i("fk-empty-form",null),i("fk-drop-area",{path:"0"})])),i("aside",{key:"7d6491acc432ed158eec6727db75f152fa8398d4",class:"fk-builder__inspector"},(()=>{const e=this.findSelected();return e?i("fk-property-panel",{brick:e.brick,fields:this.inputFieldKeys(),locales:this.locales,editLocale:this.editLocale}):i("p",{class:"fk-builder__hint"},_("builder.hint"))})()))}static get watchers(){return{spec:[{syncSpec:0}]}}static get style(){return".sc-fk-form-builder-h{display:block;container-type:inline-size}.fk-builder.sc-fk-form-builder{display:flex;gap:calc(var(--fk-spacing) * 2);align-items:flex-start;font-family:var(--fk-font);color:var(--fk-color-text)}@container (max-width: 820px){.fk-builder{flex-wrap:wrap}.fk-builder__palette,.fk-builder__inspector{width:100%}.fk-builder__main{order:2;flex-basis:100%}.fk-builder__palette{order:1}.fk-builder__inspector{order:3}}.fk-builder__palette.sc-fk-form-builder{width:220px;flex-shrink:0;padding:calc(var(--fk-spacing) * 1.5);border:1px solid var(--fk-color-border);border-radius:var(--fk-radius);background:var(--fk-color-surface)}.fk-builder__main.sc-fk-form-builder{flex:1;min-width:0;display:flex;flex-direction:column;gap:var(--fk-spacing)}.fk-builder__toolbar.sc-fk-form-builder{display:flex;align-items:center;gap:calc(var(--fk-spacing) / 2)}.fk-builder__spacer.sc-fk-form-builder{flex:1}.fk-builder__import-error.sc-fk-form-builder{font-size:0.75rem;color:var(--fk-color-danger)}.fk-builder__tool.sc-fk-form-builder{padding:calc(var(--fk-spacing) / 2) var(--fk-spacing);border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 2);background:var(--fk-color-surface);color:var(--fk-color-text);font-size:0.8rem;cursor:pointer}.fk-builder__tool.sc-fk-form-builder:hover:not(:disabled){border-color:var(--fk-color-primary);color:var(--fk-color-primary)}.fk-builder__tool.sc-fk-form-builder:disabled{opacity:0.4;cursor:default}.fk-builder__canvas.sc-fk-form-builder{min-height:320px;padding:calc(var(--fk-spacing) * 2);border:1px solid var(--fk-color-border);border-radius:var(--fk-radius);background:var(--fk-color-surface);overflow-x:auto}.fk-builder__inspector.sc-fk-form-builder{width:260px;flex-shrink:0;padding:calc(var(--fk-spacing) * 1.5);border:1px solid var(--fk-color-border);border-radius:var(--fk-radius);background:var(--fk-color-surface)}.fk-builder__hint.sc-fk-form-builder{margin:0;font-size:0.8rem;color:var(--fk-color-muted)}"}},[2,"fk-form-builder",{spec:[16],data:[16],locales:[16],currentSpec:[32],currentData:[32],selectedUid:[32],copied:[32],importError:[32],editLocale:[32]},[[0,"brickDrop","handleBrickDrop"],[0,"brickRemove","handleBrickRemove"],[0,"brickDuplicate","handleBrickDuplicate"],[0,"brickConfigsChange","handleConfigsChange"],[0,"brickStylesChange","handleStylesChange"],[0,"brickValidationsChange","handleValidationsChange"],[0,"brickRulesChange","handleRulesChange"],[0,"formDataChange","handleDataChange"],[4,"paste","handlePaste"],[0,"brickSelect","handleBrickSelect"]],{spec:[{syncSpec:0}]}]);function z(){"undefined"!=typeof customElements&&["fk-form-builder","fk-brick-actions","fk-brick-list","fk-brick-mold-item","fk-brick-not-found","fk-brick-render","fk-code-editor","fk-data-grid","fk-drop-area","fk-empty-form","fk-file-input","fk-form-render","fk-property-panel","fk-rules-editor","fk-select-input","fk-signature-input","fk-stepper","fk-tabs"].forEach((r=>{switch(r){case"fk-form-builder":customElements.get(e(r))||customElements.define(e(r),G);break;case"fk-brick-actions":customElements.get(e(r))||g();break;case"fk-brick-list":customElements.get(e(r))||y();break;case"fk-brick-mold-item":customElements.get(e(r))||x();break;case"fk-brick-not-found":customElements.get(e(r))||j();break;case"fk-brick-render":customElements.get(e(r))||C();break;case"fk-code-editor":customElements.get(e(r))||E();break;case"fk-data-grid":customElements.get(e(r))||w();break;case"fk-drop-area":customElements.get(e(r))||B();break;case"fk-empty-form":customElements.get(e(r))||D();break;case"fk-file-input":customElements.get(e(r))||S();break;case"fk-form-render":customElements.get(e(r))||R();break;case"fk-property-panel":customElements.get(e(r))||J();break;case"fk-rules-editor":customElements.get(e(r))||U();break;case"fk-select-input":customElements.get(e(r))||L();break;case"fk-signature-input":customElements.get(e(r))||O();break;case"fk-stepper":customElements.get(e(r))||P();break;case"fk-tabs":customElements.get(e(r))||I()}}))}z();const N=G,V=z;export{N as FkFormBuilder,V as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as o,d as s}from"./p-
|
|
1
|
+
import{F as o,d as s}from"./p-B_-x-GlA.js";const p=o,r=s;export{p as FkFormRender,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as o,d as
|
|
1
|
+
import{F as o,d as r}from"./p-PAr7WoWG.js";const s=o,p=r;export{s as FkPropertyPanel,p as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as o,d as s}from"./p-
|
|
1
|
+
import{F as o,d as s}from"./p-v7LxwCAc.js";const p=o,r=s;export{p as FkRulesEditor,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as s,d as o}from"./p-
|
|
1
|
+
import{F as s,d as o}from"./p-swxZqinH.js";const p=s,r=o;export{p as FkSelectInput,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as o,d as s}from"./p-
|
|
1
|
+
import{F as o,d as s}from"./p-fDJP6whN.js";const p=o,r=s;export{p as FkSignatureInput,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as
|
|
1
|
+
import{F as o,d as s}from"./p-BGkZP87K.js";const p=o,r=s;export{p as FkStepper,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as o,d as
|
|
1
|
+
import{F as o,d as r}from"./p-wuC5rVU7.js";const s=o,p=r;export{s as FkTabs,p as defineCustomElement}
|
package/dist/components/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as e}from"./p-QC41Uj05.js";export{g as getAssetPath,r as render,s as setAssetPath,b as setNonce,d as setPlatformOptions}from"./p-QC41Uj05.js";import{r as t}from"./p-gPc0o8Jb.js";export{b as getBrick,g as getBrickMolds,a as getBrickMoldsGroupedByCategory,n as newBrickSpec,c as registerBrick}from"./p-gPc0o8Jb.js";import{B as l,n as i}from"./p-dX7Lo8Fe.js";import{a as o}from"./p-BQP1WryV.js";export{f as fkTOr,b as frFkTranslations,s as setFkTranslations}from"./p-BQP1WryV.js";function u(e){return new class extends l{constructor(){var a;super({type:e.type,dataType:e.dataType,id:e.id,name:e.name,category:e.category,configsForm:e.configsForm,styles:null!==(a=e.styles)&&void 0!==a?a:{},validators:e.validators,unWrapData:e.unWrapData,isPrivate:e.isPrivate,defaultConfigs:e.defaultConfigs})}render(a){return e.render(a)}renderBuilder(a){var t;return(null!==(t=e.renderBuilder)&&void 0!==t?t:e.render)(a)}getComponent(e){return this.render(e)}getComponentWithActions(e){return this.renderBuilder(e)}}}const p=e=>e.replace(/-([a-z])/g,((e,a)=>a.toUpperCase()));function v(e){const a=Object.entries(null!=e?e:{}).filter((([,e])=>null!=e&&""!==e));if(0===a.length)return;const t={};for(const[e,l]of a)t[p(e)]=l+"";return t}const y=(e,a)=>{var t,l,n,i;return null!==(i=null!==(l=null===(t=e.configs)||void 0===t?void 0:t.label)&&void 0!==l?l:null===(n=e.configs)||void 0===n?void 0:n.key)&&void 0!==i?i:a},k=(a,t)=>{var l,n;const i=null===(l=a.configs)||void 0===l?void 0:l.prefix,d=null===(n=a.configs)||void 0===n?void 0:n.suffix;return i||d?e("div",{class:"fk-adorned"},i?e("span",{class:"fk-adorned__affix"},i):null,t,d?e("span",{class:"fk-adorned__affix"},d):null):t},m=(a,t,l)=>e("div",{class:"fk-field",style:v(a.styles)},e("span",{class:"fk-field__label"},y(a,t)),l,a.error?e("span",{class:"fk-field__error"},a.error):null),_=(a,t,l)=>e("label",{class:"fk-field",style:v(a.styles)},e("span",{class:"fk-field__label"},y(a,t)),l,a.error?e("span",{class:"fk-field__error"},a.error):null),T=a=>u({type:"input",dataType:"string",id:a.id,name:a.name,category:"Inputs",defaultConfigs:{label:a.name},render:t=>{var l,n;return _(t,a.name,k(t,e("input",{class:"fk-field__input fk-adorned__input",type:a.inputType,value:null!==(l=t.data)&&void 0!==l?l:"",placeholder:null===(n=t.configs)||void 0===n?void 0:n.placeholder,disabled:t.editable||t.disabled,onInput:e=>{var a;return null===(a=t.onDataChange)||void 0===a?void 0:a.call(t,e.target.value)}})))}}),C=T({id:"text",name:"Text",inputType:"text"}),h=T({id:"email",name:"Email",inputType:"email"}),x=T({id:"password",name:"Password",inputType:"password"}),S=T({id:"url",name:"URL",inputType:"url"}),O=T({id:"phone",name:"Phone",inputType:"tel"}),j=u({type:"input",dataType:"string",id:"textarea",name:"Text area",category:"Inputs",defaultConfigs:{label:"Text area"},render:a=>{var t,l;return _(a,"Text area",e("textarea",{class:"fk-field__input fk-field__input--textarea",value:null!==(t=a.data)&&void 0!==t?t:"",placeholder:null===(l=a.configs)||void 0===l?void 0:l.placeholder,disabled:a.editable||a.disabled,onInput:e=>{var t;return null===(t=a.onDataChange)||void 0===t?void 0:t.call(a,e.target.value)}}))}}),I=u({type:"input",dataType:"number",id:"number",name:"Number",category:"Inputs",defaultConfigs:{label:"Number"},render:a=>{var t;return _(a,"Number",k(a,e("input",{class:"fk-field__input fk-adorned__input",type:"number",value:null==a.data?"":a.data+"",placeholder:null===(t=a.configs)||void 0===t?void 0:t.placeholder,disabled:a.editable||a.disabled,onInput:e=>{var t;const l=e.target.value;null===(t=a.onDataChange)||void 0===t||t.call(a,""===l?void 0:Number(l))}})))}}),B=u({type:"input",dataType:"string",id:"date",name:"Date",category:"Inputs",defaultConfigs:{label:"Date"},render:a=>{var t;return _(a,"Date",e("input",{class:"fk-field__input",type:"date",value:null!==(t=a.data)&&void 0!==t?t:"",disabled:a.editable||a.disabled,onInput:e=>{var t;const l=e.target.value;null===(t=a.onDataChange)||void 0===t||t.call(a,""===l?void 0:l)}}))}}),D=u({type:"input",dataType:"string",id:"select",name:"Select",category:"Inputs",defaultConfigs:{label:"Select",optionsSource:"static",options:"Option 1\nOption 2"},render:a=>{var t;return m(a,"Select",e("fk-select-input",{configs:a.configs,value:null!==(t=a.data)&&void 0!==t?t:"",disabled:a.editable||a.disabled,dataMap:a.dataMap,onSelectValueChange:e=>{var t;e.stopPropagation(),null===(t=a.onDataChange)||void 0===t||t.call(a,e.detail)}}))}}),w=u({type:"input",dataType:"array",id:"multi-select",name:"Multi select",category:"Inputs",defaultConfigs:{label:"Multi select",optionsSource:"static",options:"Option 1\nOption 2\nOption 3"},render:a=>m(a,"Multi select",e("fk-select-input",{configs:a.configs,value:Array.isArray(a.data)?a.data:[],multiple:!0,disabled:a.editable||a.disabled,dataMap:a.dataMap,onSelectValueChange:e=>{var t;e.stopPropagation(),null===(t=a.onDataChange)||void 0===t||t.call(a,e.detail)}}))}),A=T({id:"time",name:"Time",inputType:"time"}),L=T({id:"datetime",name:"Date / Time",inputType:"datetime-local"}),P=u({type:"input",dataType:"array",id:"select-boxes",name:"Select boxes",category:"Inputs",defaultConfigs:{label:"Select boxes",options:"Option 1\nOption 2\nOption 3"},render:a=>{var t;const l=Array.isArray(a.data)?a.data:[];return e("div",{class:"fk-field",style:v(a.styles)},e("span",{class:"fk-field__label"},y(a,"Select boxes")),e("div",{class:"fk-radio-group"},(e=>((null!=e?e:"")+"").split("\n").map((e=>e.trim())).filter(Boolean))(null===(t=a.configs)||void 0===t?void 0:t.options).map((t=>e("label",{class:"fk-radio",key:t},e("input",{type:"checkbox",checked:l.includes(t),disabled:a.editable||a.disabled,onChange:e=>{var n;const i=e.target.checked?[...l,t]:l.filter((e=>e!==t));null===(n=a.onDataChange)||void 0===n||n.call(a,i.length?i:void 0)}}),e("span",null,t))))),a.error?e("span",{class:"fk-field__error"},a.error):null)}}),M=u({type:"input",dataType:"array",id:"tags",name:"Tags",category:"Inputs",defaultConfigs:{label:"Tags"},render:a=>{const t=Array.isArray(a.data)?a.data:[];return _(a,"Tags",e("div",{class:"fk-tags"},t.map((l=>e("span",{class:"fk-tags__chip",key:l},l,e("button",{type:"button",class:"fk-tags__remove",disabled:a.editable||a.disabled,onClick:()=>{var e;const n=t.filter((e=>e!==l));null===(e=a.onDataChange)||void 0===e||e.call(a,n.length?n:void 0)}},"✕")))),e("input",{class:"fk-tags__input",type:"text",placeholder:"Add a tag…",disabled:a.editable||a.disabled,onKeyDown:e=>{var l;if("Enter"!==e.key)return;e.preventDefault();const n=e.target,i=n.value.trim();i&&!t.includes(i)&&(null===(l=a.onDataChange)||void 0===l||l.call(a,[...t,i]),n.value="")}})))}}),F=u({type:"input",dataType:"string",id:"signature",name:"Signature",category:"Inputs",defaultConfigs:{label:"Signature"},render:a=>{var t;return _(a,"Signature",e("fk-signature-input",{value:null!==(t=a.data)&&void 0!==t?t:void 0,disabled:a.editable||a.disabled,onSignatureChange:e=>{var t;e.stopPropagation(),null===(t=a.onDataChange)||void 0===t||t.call(a,e.detail)}}))}}),V=u({type:"panel",dataType:"void",id:"tabs",name:"Tabs",category:"Layout",defaultConfigs:{validateTabs:!1},render:a=>{var t,l;const n=(null!==(l=null===(t=a.brickSpec)||void 0===t?void 0:t.children)&&void 0!==l?l:[]).map(((e,t)=>{var l,n;const d=i(null===(l=e.configs)||void 0===l?void 0:l.label,a.locale);return"string"==typeof d?d:null!==(n=e.name)&&void 0!==n?n:"Tab "+(t+1)}));return e("fk-tabs",{tabLabels:n,editable:a.editable,spec:a.brickSpec,dataMap:a.dataMap,locale:a.locale,style:v(a.styles)},a.children)}}),N=u({type:"input",dataType:"string",id:"radio",name:"Radio",category:"Inputs",defaultConfigs:{label:"Radio",options:"Option 1\nOption 2"},render:a=>{var t,l;return e("div",{class:"fk-field",style:v(a.styles)},e("span",{class:"fk-field__label"},y(a,"Radio")),e("div",{class:"fk-radio-group",role:"radiogroup"},((null!==(l=null===(t=a.configs)||void 0===t?void 0:t.options)&&void 0!==l?l:"")+"").split("\n").map((e=>e.trim())).filter(Boolean).map((t=>{var l,n;return e("label",{class:"fk-radio",key:t},e("input",{type:"radio",name:null!==(n=null===(l=a.configs)||void 0===l?void 0:l.key)&&void 0!==n?n:a.path,checked:a.data===t,disabled:a.editable||a.disabled,onChange:()=>{var e;return null===(e=a.onDataChange)||void 0===e?void 0:e.call(a,t)}}),e("span",null,t))}))),a.error?e("span",{class:"fk-field__error"},a.error):null)}}),R=[{key:"street",label:()=>o("address.street"),full:!0},{key:"city",label:()=>o("address.city"),full:!1},{key:"zip",label:()=>o("address.zip"),full:!1},{key:"country",label:()=>o("address.country"),full:!1}],Q=u({type:"input",dataType:"object",id:"address",name:"Address",category:"Inputs",defaultConfigs:{label:"Address"},render:a=>{var t;const l=null!==(t=a.data)&&void 0!==t?t:{};return m(a,"Address",e("div",{class:"fk-address"},R.map((t=>{var n;return e("label",{class:{"fk-address__part":!0,"fk-address__part--full":t.full},key:t.key},e("span",{class:"fk-address__label"},t.label()),e("input",{class:"fk-field__input",type:"text",value:null!==(n=l[t.key])&&void 0!==n?n:"",disabled:a.editable||a.disabled,onInput:e=>{var n;const i=e.target.value,d=Object.assign(Object.assign({},l),{[t.key]:i||void 0}),r=Object.fromEntries(Object.entries(d).filter((([,e])=>void 0!==e)));null===(n=a.onDataChange)||void 0===n||n.call(a,Object.keys(r).length?r:void 0)}}))}))))}}),W=u({type:"input",dataType:"object",id:"file",name:"File",category:"Data",defaultConfigs:{label:"File"},render:a=>{var t;return m(a,"File",e("fk-file-input",{value:a.data,accept:null===(t=a.configs)||void 0===t?void 0:t.accept,disabled:a.editable||a.disabled,onFileValueChange:e=>{var t;e.stopPropagation(),null===(t=a.onDataChange)||void 0===t||t.call(a,e.detail)}}))}}),z=u({type:"collection",dataType:"array",id:"data-grid",name:"Data grid",category:"Data",defaultConfigs:{label:"Data grid"},render:a=>m(a,"Data grid",a.editable||!a.brickSpec?e("div",{class:"fk-grid-template"},e("span",{class:"fk-grid-template__hint"},o("grid.columns")),a.children):e("fk-data-grid",{spec:a.brickSpec,value:a.data,disabled:a.disabled,locale:a.locale,utils:a.utils,onGridValueChange:e=>{var t;e.stopPropagation(),null===(t=a.onDataChange)||void 0===t||t.call(a,e.detail)}}))}),G=u({type:"input",dataType:"string",id:"hidden",name:"Hidden",category:"Data",defaultConfigs:{},render:a=>{var t,l;return a.editable?e("div",{class:"fk-hidden-chip"},"hidden: ",null===(t=a.configs)||void 0===t?void 0:t.key):e("input",{type:"hidden",value:null!==(l=a.data)&&void 0!==l?l:""})}}),U=u({type:"output",dataType:"void",id:"content",name:"Content",category:"Layout",defaultConfigs:{content:"Some text…"},render:a=>{var t,l;return e("div",{class:"fk-content",style:v(a.styles)},((null!==(l=null===(t=a.configs)||void 0===t?void 0:t.content)&&void 0!==l?l:"")+"").split("\n").map((a=>e("p",{class:"fk-content__line"},a))))}}),E=u({type:"panel",dataType:"void",id:"stepper",name:"Stepper",category:"Layout",defaultConfigs:{validateSteps:!1,allowStepClick:!0,showSubmit:!1},render:a=>{var t,l;const n=(null!==(l=null===(t=a.brickSpec)||void 0===t?void 0:t.children)&&void 0!==l?l:[]).map(((e,t)=>{var l,n;const d=i(null===(l=e.configs)||void 0===l?void 0:l.label,a.locale);return"string"==typeof d?d:null!==(n=e.name)&&void 0!==n?n:"Step "+(t+1)}));return e("fk-stepper",{stepLabels:n,editable:a.editable,spec:a.brickSpec,dataMap:a.dataMap,locale:a.locale,style:v(a.styles)},a.children)}}),J=u({type:"input",dataType:"boolean",id:"checkbox",name:"Checkbox",category:"Inputs",defaultConfigs:{label:"Checkbox"},render:a=>e("label",{class:"fk-field fk-field--inline",style:v(a.styles)},e("input",{class:"fk-field__checkbox",type:"checkbox",checked:!0===a.data,disabled:a.editable||a.disabled,onChange:e=>{var t;return null===(t=a.onDataChange)||void 0===t?void 0:t.call(a,e.target.checked)}}),e("span",{class:"fk-field__label"},y(a,"Checkbox")),a.error?e("span",{class:"fk-field__error"},a.error):null)}),H=u({type:"panel",dataType:"void",id:"group",name:"Group",category:"Layout",render:a=>{var t;return e("fieldset",{class:"fk-group",style:v(a.styles)},(null===(t=a.configs)||void 0===t?void 0:t.label)?e("legend",{class:"fk-group__legend"},a.configs.label):null,a.children)}}),K=u({type:"panel",dataType:"void",id:"row",name:"Row",category:"Layout",render:a=>e("div",{class:"fk-row",style:v(a.styles)},a.children)}),X=u({type:"panel",dataType:"void",id:"column",name:"Column",category:"Layout",render:a=>e("div",{class:"fk-column",style:v(a.styles)},a.children)});function q(){t([C,h,x,S,O,j,I,B,A,L,D,w,N,P,J,M,F,Q,W,z,G,U,H,K,X,E,V])}export{Q as addressBrick,J as checkboxBrick,X as columnBrick,U as contentBrick,u as createBrick,z as dataGridBrick,B as dateBrick,L as datetimeBrick,h as emailBrick,W as fileBrick,o as fkT,H as groupBrick,e as h,G as hiddenBrick,w as multiSelectBrick,I as numberBrick,x as passwordBrick,O as phoneBrick,N as radioBrick,t as registerBricks,q as registerDefaultBricks,K as rowBrick,P as selectBoxesBrick,D as selectBrick,F as signatureBrick,E as stepperBrick,V as tabsBrick,M as tagsBrick,C as textInputBrick,j as textareaBrick,A as timeBrick,S as urlBrick}
|
|
1
|
+
import{h as e}from"./p-BB4Llg42.js";export{g as getAssetPath,r as render,s as setAssetPath,b as setNonce,d as setPlatformOptions}from"./p-BB4Llg42.js";import{r as t}from"./p-gPc0o8Jb.js";export{b as getBrick,g as getBrickMolds,a as getBrickMoldsGroupedByCategory,n as newBrickSpec,c as registerBrick}from"./p-gPc0o8Jb.js";import{B as l,n as i,g as o}from"./p-CKMHMpID.js";import{n as u}from"./p-CWQX0sXS.js";import{a as p,f}from"./p-BOmBVgfJ.js";export{b as frFkTranslations,s as setFkTranslations}from"./p-BOmBVgfJ.js";function v(e){return new class extends l{constructor(){var t;super({type:e.type,dataType:e.dataType,id:e.id,name:e.name,category:e.category,configsForm:e.configsForm,styles:null!==(t=e.styles)&&void 0!==t?t:{},validators:e.validators,unWrapData:e.unWrapData,isPrivate:e.isPrivate,defaultConfigs:e.defaultConfigs})}render(t){return e.render(t)}renderBuilder(t){var a;return(null!==(a=e.renderBuilder)&&void 0!==a?a:e.render)(t)}getComponent(e){return this.render(e)}getComponentWithActions(e){return this.renderBuilder(e)}}}const y=e=>e.replace(/-([a-z])/g,((e,t)=>t.toUpperCase()));function k(e){const t=Object.entries(null!=e?e:{}).filter((([,e])=>null!=e&&""!==e));if(0===t.length)return;const a={};for(const[e,l]of t)a[y(e)]=l+"";return a}const m=(e,t)=>{var a,l,n,i;return null!==(i=null!==(l=null===(a=e.configs)||void 0===a?void 0:a.label)&&void 0!==l?l:null===(n=e.configs)||void 0===n?void 0:n.key)&&void 0!==i?i:t},_=(t,a)=>{var l,n;const i=null===(l=t.configs)||void 0===l?void 0:l.prefix,o=null===(n=t.configs)||void 0===n?void 0:n.suffix;return i||o?e("div",{class:"fk-adorned"},i?e("span",{class:"fk-adorned__affix"},i):null,a,o?e("span",{class:"fk-adorned__affix"},o):null):a},T=t=>t.error?e("span",{class:"fk-field__error",role:"alert"},t.error):null,h=e=>e.error?{"aria-invalid":"true"}:{},C=(t,a,l)=>e("div",{class:"fk-field",style:k(t.styles)},e("span",{class:"fk-field__label"},m(t,a)),l,T(t)),x=(t,a,l)=>e("label",{class:"fk-field",style:k(t.styles)},e("span",{class:"fk-field__label"},m(t,a)),l,T(t)),O=t=>v({type:"input",dataType:"string",id:t.id,name:t.name,category:"Inputs",defaultConfigs:{label:t.name},render:a=>{var l,n;return x(a,t.name,_(a,e("input",Object.assign({},h(a),{class:"fk-field__input fk-adorned__input",type:t.inputType,value:null!==(l=a.data)&&void 0!==l?l:"",placeholder:null===(n=a.configs)||void 0===n?void 0:n.placeholder,disabled:a.editable||a.disabled,onInput:e=>{var t;return null===(t=a.onDataChange)||void 0===t?void 0:t.call(a,e.target.value)}}))))}}),j=O({id:"text",name:"Text",inputType:"text"}),S=O({id:"email",name:"Email",inputType:"email"}),B=O({id:"password",name:"Password",inputType:"password"}),I=O({id:"url",name:"URL",inputType:"url"}),w=O({id:"phone",name:"Phone",inputType:"tel"}),A=v({type:"input",dataType:"string",id:"textarea",name:"Text area",category:"Inputs",defaultConfigs:{label:"Text area"},render:t=>{var a,l;return x(t,"Text area",e("textarea",Object.assign({},h(t),{class:"fk-field__input fk-field__input--textarea",value:null!==(a=t.data)&&void 0!==a?a:"",placeholder:null===(l=t.configs)||void 0===l?void 0:l.placeholder,disabled:t.editable||t.disabled,onInput:e=>{var a;return null===(a=t.onDataChange)||void 0===a?void 0:a.call(t,e.target.value)}})))}}),D=v({type:"input",dataType:"number",id:"number",name:"Number",category:"Inputs",defaultConfigs:{label:"Number"},render:t=>{var a;return x(t,"Number",_(t,e("input",Object.assign({},h(t),{class:"fk-field__input fk-adorned__input",type:"number",value:null==t.data?"":t.data+"",placeholder:null===(a=t.configs)||void 0===a?void 0:a.placeholder,disabled:t.editable||t.disabled,onInput:e=>{var a;const l=e.target.value;null===(a=t.onDataChange)||void 0===a||a.call(t,""===l?void 0:Number(l))}}))))}}),L=v({type:"input",dataType:"string",id:"date",name:"Date",category:"Inputs",defaultConfigs:{label:"Date"},render:t=>{var a;return x(t,"Date",e("input",Object.assign({},h(t),{class:"fk-field__input",type:"date",value:null!==(a=t.data)&&void 0!==a?a:"",disabled:t.editable||t.disabled,onInput:e=>{var a;const l=e.target.value;null===(a=t.onDataChange)||void 0===a||a.call(t,""===l?void 0:l)}})))}}),M=v({type:"input",dataType:"string",id:"select",name:"Select",category:"Inputs",defaultConfigs:{label:"Select",optionsSource:"static",options:"Option 1\nOption 2"},render:t=>{var a;return C(t,"Select",e("fk-select-input",{configs:t.configs,value:null!==(a=t.data)&&void 0!==a?a:"",disabled:t.editable||t.disabled,invalid:!!t.error,dataMap:t.dataMap,onSelectValueChange:e=>{var a;e.stopPropagation(),null===(a=t.onDataChange)||void 0===a||a.call(t,e.detail)}}))}}),N=v({type:"input",dataType:"array",id:"multi-select",name:"Multi select",category:"Inputs",defaultConfigs:{label:"Multi select",optionsSource:"static",options:"Option 1\nOption 2\nOption 3"},render:t=>C(t,"Multi select",e("fk-select-input",{configs:t.configs,value:Array.isArray(t.data)?t.data:[],multiple:!0,disabled:t.editable||t.disabled,invalid:!!t.error,dataMap:t.dataMap,onSelectValueChange:e=>{var a;e.stopPropagation(),null===(a=t.onDataChange)||void 0===a||a.call(t,e.detail)}}))}),P=O({id:"time",name:"Time",inputType:"time"}),R=O({id:"datetime",name:"Date / Time",inputType:"datetime-local"}),F=e=>{var t,a,l;return u(null===(t=e.configs)||void 0===t?void 0:t.options,"string"==typeof(null===(a=e.configs)||void 0===a?void 0:a.labelKey)?e.configs.labelKey:"label","string"==typeof(null===(l=e.configs)||void 0===l?void 0:l.valueKey)?e.configs.valueKey:"value")},V=v({type:"input",dataType:"array",id:"select-boxes",name:"Select boxes",category:"Inputs",defaultConfigs:{label:"Select boxes",options:"Option 1\nOption 2\nOption 3"},render:t=>{const a=Array.isArray(t.data)?t.data:[];return e("div",{class:"fk-field",style:k(t.styles)},e("span",{class:"fk-field__label"},m(t,"Select boxes")),e("div",{class:"fk-radio-group"},F(t).map((l=>e("label",{class:"fk-radio",key:l.value},e("input",{type:"checkbox",checked:a.includes(l.value),disabled:t.editable||t.disabled,onChange:e=>{var n;const i=e.target.checked?[...a,l.value]:a.filter((e=>e!==l.value));null===(n=t.onDataChange)||void 0===n||n.call(t,i.length?i:void 0)}}),e("span",null,l.label))))),t.error?e("span",{class:"fk-field__error"},t.error):null)}}),z=v({type:"input",dataType:"array",id:"tags",name:"Tags",category:"Inputs",defaultConfigs:{label:"Tags"},render:t=>{const a=Array.isArray(t.data)?t.data:[];return x(t,"Tags",e("div",{class:"fk-tags"},a.map((l=>e("span",{class:"fk-tags__chip",key:l},l,e("button",{type:"button",class:"fk-tags__remove",disabled:t.editable||t.disabled,onClick:()=>{var e;const n=a.filter((e=>e!==l));null===(e=t.onDataChange)||void 0===e||e.call(t,n.length?n:void 0)}},"✕")))),e("input",{class:"fk-tags__input",type:"text",placeholder:"Add a tag…",disabled:t.editable||t.disabled,onKeyDown:e=>{var l;if("Enter"!==e.key)return;e.preventDefault();const n=e.target,i=n.value.trim();i&&!a.includes(i)&&(null===(l=t.onDataChange)||void 0===l||l.call(t,[...a,i]),n.value="")}})))}}),J=v({type:"input",dataType:"string",id:"signature",name:"Signature",category:"Inputs",defaultConfigs:{label:"Signature"},render:t=>{var a;return x(t,"Signature",e("fk-signature-input",{value:null!==(a=t.data)&&void 0!==a?a:void 0,disabled:t.editable||t.disabled,onSignatureChange:e=>{var a;e.stopPropagation(),null===(a=t.onDataChange)||void 0===a||a.call(t,e.detail)}}))}}),E=v({type:"panel",dataType:"void",id:"tabs",name:"Tabs",category:"Layout",defaultConfigs:{validateTabs:!1},render:t=>{var a,l;const n=(null!==(l=null===(a=t.brickSpec)||void 0===a?void 0:a.children)&&void 0!==l?l:[]).map(((e,a)=>{var l,n;const o=i(null===(l=e.configs)||void 0===l?void 0:l.label,t.locale);return"string"==typeof o?o:null!==(n=e.name)&&void 0!==n?n:"Tab "+(a+1)}));return e("fk-tabs",{tabLabels:n,editable:t.editable,spec:t.brickSpec,dataMap:t.dataMap,locale:t.locale,style:k(t.styles)},t.children)}}),G=v({type:"input",dataType:"string",id:"radio",name:"Radio",category:"Inputs",defaultConfigs:{label:"Radio",options:"Option 1\nOption 2"},render:t=>e("div",{class:"fk-field",style:k(t.styles)},e("span",{class:"fk-field__label"},m(t,"Radio")),e("div",Object.assign({class:"fk-radio-group",role:"radiogroup"},h(t)),F(t).map((a=>{var l,n;return e("label",{class:"fk-radio",key:a.value},e("input",{type:"radio",name:null!==(n=null===(l=t.configs)||void 0===l?void 0:l.key)&&void 0!==n?n:t.path,checked:t.data===a.value,disabled:t.editable||t.disabled,onChange:()=>{var e;return null===(e=t.onDataChange)||void 0===e?void 0:e.call(t,a.value)}}),e("span",null,a.label))}))),t.error?e("span",{class:"fk-field__error"},t.error):null)}),U=[{key:"street",label:()=>p("address.street"),full:!0},{key:"city",label:()=>p("address.city"),full:!1},{key:"zip",label:()=>p("address.zip"),full:!1},{key:"country",label:()=>p("address.country"),full:!1}],W=v({type:"input",dataType:"object",id:"address",name:"Address",category:"Inputs",defaultConfigs:{label:"Address"},render:t=>{var a;const l=null!==(a=t.data)&&void 0!==a?a:{};return C(t,"Address",e("div",{class:"fk-address"},U.map((a=>{var n;return e("label",{class:{"fk-address__part":!0,"fk-address__part--full":a.full},key:a.key},e("span",{class:"fk-address__label"},a.label()),e("input",{class:"fk-field__input",type:"text",value:null!==(n=l[a.key])&&void 0!==n?n:"",disabled:t.editable||t.disabled,onInput:e=>{var n;const i=e.target.value,o=Object.assign(Object.assign({},l),{[a.key]:i||void 0}),r=Object.fromEntries(Object.entries(o).filter((([,e])=>void 0!==e)));null===(n=t.onDataChange)||void 0===n||n.call(t,Object.keys(r).length?r:void 0)}}))}))))}}),H=v({type:"input",dataType:"object",id:"file",name:"File",category:"Data",defaultConfigs:{label:"File",accept:"",uploadUrl:"",multiple:!1},render:t=>{var a,l,n;return C(t,"File",e("fk-file-input",{value:t.data,accept:null===(a=t.configs)||void 0===a?void 0:a.accept,uploadUrl:null===(l=t.configs)||void 0===l?void 0:l.uploadUrl,multiple:!0===(null===(n=t.configs)||void 0===n?void 0:n.multiple),disabled:t.editable||t.disabled,onFileValueChange:e=>{var a;e.stopPropagation(),null===(a=t.onDataChange)||void 0===a||a.call(t,e.detail)}}))}}),K=v({type:"collection",dataType:"array",id:"data-grid",name:"Data grid",category:"Data",defaultConfigs:{label:"Data grid"},render:t=>C(t,"Data grid",t.editable||!t.brickSpec?e("div",{class:"fk-grid-template"},e("span",{class:"fk-grid-template__hint"},p("grid.columns")),t.children):e("fk-data-grid",{spec:t.brickSpec,value:t.data,disabled:t.disabled,locale:t.locale,utils:t.utils,onGridValueChange:e=>{var a;e.stopPropagation(),null===(a=t.onDataChange)||void 0===a||a.call(t,e.detail)}}))}),X=v({type:"input",dataType:"string",id:"hidden",name:"Hidden",category:"Data",defaultConfigs:{},render:t=>{var a,l;return t.editable?e("div",{class:"fk-hidden-chip"},"hidden: ",null===(a=t.configs)||void 0===a?void 0:a.key):e("input",{type:"hidden",value:null!==(l=t.data)&&void 0!==l?l:""})}}),Q=v({type:"output",dataType:"void",id:"content",name:"Content",category:"Layout",defaultConfigs:{content:"Some text…"},render:t=>{var a,l;return e("div",{class:"fk-content",style:k(t.styles)},((null!==(l=null===(a=t.configs)||void 0===a?void 0:a.content)&&void 0!==l?l:"")+"").split("\n").map((t=>e("p",{class:"fk-content__line"},t))))}}),Y=v({type:"panel",dataType:"void",id:"stepper",name:"Stepper",category:"Layout",defaultConfigs:{validateSteps:!1,allowStepClick:!0,showSubmit:!1},render:t=>{var a,l;const n=(null!==(l=null===(a=t.brickSpec)||void 0===a?void 0:a.children)&&void 0!==l?l:[]).map(((e,a)=>{var l,n;const o=i(null===(l=e.configs)||void 0===l?void 0:l.label,t.locale);return"string"==typeof o?o:null!==(n=e.name)&&void 0!==n?n:"Step "+(a+1)}));return e("fk-stepper",{stepLabels:n,editable:t.editable,spec:t.brickSpec,dataMap:t.dataMap,locale:t.locale,style:k(t.styles)},t.children)}}),q=v({type:"input",dataType:"boolean",id:"checkbox",name:"Checkbox",category:"Inputs",defaultConfigs:{label:"Checkbox"},render:t=>e("label",{class:"fk-field fk-field--inline",style:k(t.styles)},e("input",{class:"fk-field__checkbox",type:"checkbox",checked:!0===t.data,disabled:t.editable||t.disabled,onChange:e=>{var a;return null===(a=t.onDataChange)||void 0===a?void 0:a.call(t,e.target.checked)}}),e("span",{class:"fk-field__label"},m(t,"Checkbox")),t.error?e("span",{class:"fk-field__error"},t.error):null)}),Z=v({type:"panel",dataType:"void",id:"group",name:"Group",category:"Layout",render:t=>{var a;return e("fieldset",{class:"fk-group",style:k(t.styles)},(null===(a=t.configs)||void 0===a?void 0:a.label)?e("legend",{class:"fk-group__legend"},t.configs.label):null,t.children)}}),$=v({type:"panel",dataType:"void",id:"row",name:"Row",category:"Layout",render:t=>e("div",{class:"fk-row",style:k(t.styles)},t.children)}),ee=v({type:"panel",dataType:"void",id:"column",name:"Column",category:"Layout",render:t=>e("div",{class:"fk-column",style:k(t.styles)},t.children)}),te=(e,t)=>{var a;if(Array.isArray(t))return t.map((t=>te(e,t))).filter(Boolean).join(", ");if(!0===t)return f("recap.yes","Yes");if(!1===t)return f("recap.no","No");if(t&&"object"==typeof t)return"string"==typeof t.name&&"url"in t?t.name:Object.values(t).filter((e=>"string"==typeof e&&e)).join(" ");const l=(null!=t?t:"")+"";if(null!=(null===(a=e.configs)||void 0===a?void 0:a.options)){const t=u(e.configs.options,"string"==typeof e.configs.labelKey?e.configs.labelKey:"label","string"==typeof e.configs.valueKey?e.configs.valueKey:"value").find((e=>e.value===l));if(t)return t.label}return l},ae=e=>null==e||""===e||Array.isArray(e)&&0===e.length,le=(e,t)=>{var a,l,n,o,r;return(null!==(r=null!==(n=null!==(l=i(null===(a=e.configs)||void 0===a?void 0:a.label,t))&&void 0!==l?l:e.name)&&void 0!==n?n:null===(o=e.configs)||void 0===o?void 0:o.key)&&void 0!==r?r:"")+""},ne=e=>{var t,a;const l=[];for(const n of null!==(t=e.children)&&void 0!==t?t:[]){const e=null===(a=n.configs)||void 0===a?void 0:a.key;"input"===n.type&&e&&!e.startsWith("_")?l.push(n):"panel"===n.type&&l.push(...ne(n))}return l},ie=(e,t,a,l,n=!1)=>{var r,d,s;if(!e)return[];const u=[];for(const p of null!==(r=e.children)&&void 0!==r?r:[]){if("recap"===p.id||"action"===p.type)continue;if(!0===o(p.rules,t).hidden)continue;const e=null===(d=p.configs)||void 0===d?void 0:d.key,r=le(p,a);if("collection"===p.type){const n=e&&Array.isArray(null==t?void 0:t[e])?t[e]:[];if(!n.length&&!l)continue;const i=ne(p);u.push({kind:"collection",label:r,columns:i.map((e=>le(e,a))),rows:n.map((e=>i.map((t=>{const a=null==e?void 0:e[t.configs.key];return ae(a)?"—":te(t,a)}))))});continue}if("panel"===p.type){const e=i(null===(s=p.configs)||void 0===s?void 0:s.label,a);if(n&&"string"==typeof e&&e.trim()){const n=ie(p,t,a,l);n.length&&(u.push({kind:"section",label:e}),u.push(...n));continue}u.push(...ie(p,t,a,l,n));continue}if("input"!==p.type||!e||e.startsWith("_"))continue;const c=null==t?void 0:t[e];ae(c)&&!l||u.push({kind:"field",label:r,value:ae(c)?"—":te(p,c)})}return u},oe=v({type:"output",dataType:"void",id:"recap",name:"Recap",category:"Layout",defaultConfigs:{label:"Recap",showEmpty:!1,groupBySections:!1},render:t=>{var a,l;const n=ie(t.rootSpec,t.dataMap,t.locale,!0===(null===(a=t.configs)||void 0===a?void 0:a.showEmpty),!0===(null===(l=t.configs)||void 0===l?void 0:l.groupBySections)),i=[];let o=[];const r=()=>{o.length&&(i.push(e("dl",{class:"fk-recap__list"},o.map((t=>e("div",{class:"fk-recap__row",key:t.label},e("dt",{class:"fk-recap__term"},t.label),e("dd",{class:"fk-recap__value"},t.value)))))),o=[])};for(const t of n)"field"!==t.kind?(r(),i.push("section"!==t.kind?e("section",{class:"fk-recap__section",key:t.label},e("span",{class:"fk-recap__section-title"},t.label),t.rows.length?e("div",{class:"fk-recap__table-wrap"},e("table",{class:"fk-recap__table"},e("thead",null,e("tr",null,e("th",{class:"fk-recap__index-cell"},"#"),t.columns.map((t=>e("th",{key:t},t))))),e("tbody",null,t.rows.map(((t,a)=>e("tr",{key:a},e("td",{class:"fk-recap__index-cell"},a+1),t.map(((t,a)=>e("td",{key:a},t))))))))):e("p",{class:"fk-recap__empty"},f("recap.empty","Nothing to summarize yet."))):e("span",{class:"fk-recap__group-title",key:"section:"+t.label},t.label))):o.push(t);return r(),e("div",{class:"fk-field fk-recap",style:k(t.styles)},e("span",{class:"fk-field__label"},m(t,"Recap")),i.length?i:e("p",{class:"fk-recap__empty"},f("recap.empty","Nothing to summarize yet.")))}});function re(){t([j,S,B,I,w,A,D,L,P,R,M,N,G,V,q,z,J,W,H,K,X,Q,oe,Z,$,ee,Y,E])}export{W as addressBrick,q as checkboxBrick,ee as columnBrick,Q as contentBrick,v as createBrick,K as dataGridBrick,L as dateBrick,R as datetimeBrick,S as emailBrick,H as fileBrick,p as fkT,f as fkTOr,Z as groupBrick,e as h,X as hiddenBrick,N as multiSelectBrick,D as numberBrick,B as passwordBrick,w as phoneBrick,G as radioBrick,oe as recapBrick,t as registerBricks,re as registerDefaultBricks,$ as rowBrick,V as selectBoxesBrick,M as selectBrick,J as signatureBrick,Y as stepperBrick,E as tabsBrick,z as tagsBrick,j as textInputBrick,A as textareaBrick,P as timeBrick,I as urlBrick}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as o,p as r,H as i,h as e}from"./p-
|
|
1
|
+
import{t as o,p as r,H as i,h as e}from"./p-BB4Llg42.js";import{d as s}from"./p-92BozD8S.js";import{f as t}from"./p-BOmBVgfJ.js";const a=r(class extends i{constructor(o){super(),!1!==o&&this.__registerHost(),this.isDragging=!1}componentDidLoad(){this.cleanup=s({element:this.host,getInitialData:()=>({kind:"new-brick",moldType:this.brickMold.type,moldId:this.brickMold.id}),onDragStart:()=>this.isDragging=!0,onDrop:()=>this.isDragging=!1})}disconnectedCallback(){var o;null===(o=this.cleanup)||void 0===o||o.call(this)}render(){return e("div",{key:"0570015fb47b6be613f900a333b061537006edec",class:{"fk-mold":!0,"fk-mold--dragging":this.isDragging},title:t(`brick.${this.brickMold.id}.name`,this.brickMold.name)},e("span",{key:"bf3ab329f7a4b054c56e042dd83822706546c93b",class:"fk-mold__name"},t(`brick.${this.brickMold.id}.name`,this.brickMold.name)))}get host(){return this}static get style(){return".sc-fk-brick-mold-item-h{display:block;cursor:grab;min-width:0}.fk-mold.sc-fk-brick-mold-item{display:flex;align-items:center;padding:calc(var(--fk-spacing) / 1.5) var(--fk-spacing);border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 1.5);background:var(--fk-color-surface);font-size:0.8rem;transition:border-color 120ms ease, box-shadow 120ms ease}.fk-mold.sc-fk-brick-mold-item:hover{border-color:var(--fk-color-primary);box-shadow:0 1px 4px var(--fk-color-shadow)}.fk-mold--dragging.sc-fk-brick-mold-item{opacity:0.5}.fk-mold__name.sc-fk-brick-mold-item{font-weight:500;color:var(--fk-color-text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}"}},[2,"fk-brick-mold-item",{brickMold:[16],isDragging:[32]}]);function c(){"undefined"!=typeof customElements&&["fk-brick-mold-item"].forEach((r=>{"fk-brick-mold-item"===r&&(customElements.get(o(r))||customElements.define(o(r),a))}))}c();export{a as F,c as d}
|