@streamline-pulse/formkrafter-wc 0.1.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/LICENSE +21 -0
- package/README.md +140 -0
- package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
- package/dist/cjs/fk-brick-actions_18.cjs.entry.js +26442 -0
- package/dist/cjs/formkrafter-wc.cjs.js +25 -0
- package/dist/cjs/index-By4GGW_q.js +17346 -0
- package/dist/cjs/index-D_7eGIJ0.js +2090 -0
- package/dist/cjs/index.cjs.js +47 -0
- package/dist/cjs/loader.cjs.js +13 -0
- package/dist/collection/collection-manifest.json +30 -0
- package/dist/collection/components/fk-brick-actions/fk-brick-actions.css +78 -0
- package/dist/collection/components/fk-brick-actions/fk-brick-actions.js +215 -0
- package/dist/collection/components/fk-brick-list/fk-brick-list.css +71 -0
- package/dist/collection/components/fk-brick-list/fk-brick-list.js +55 -0
- package/dist/collection/components/fk-brick-mold-item/fk-brick-mold-item.css +33 -0
- package/dist/collection/components/fk-brick-mold-item/fk-brick-mold-item.js +73 -0
- package/dist/collection/components/fk-brick-not-found/fk-brick-not-found.css +8 -0
- package/dist/collection/components/fk-brick-not-found/fk-brick-not-found.js +18 -0
- package/dist/collection/components/fk-brick-render/fk-brick-render.js +419 -0
- package/dist/collection/components/fk-code-editor/fk-code-editor.css +26 -0
- package/dist/collection/components/fk-code-editor/fk-code-editor.js +136 -0
- package/dist/collection/components/fk-data-grid/fk-data-grid.css +75 -0
- package/dist/collection/components/fk-data-grid/fk-data-grid.js +300 -0
- package/dist/collection/components/fk-drop-area/fk-drop-area.css +18 -0
- package/dist/collection/components/fk-drop-area/fk-drop-area.js +98 -0
- package/dist/collection/components/fk-empty-form/fk-empty-form.css +22 -0
- package/dist/collection/components/fk-empty-form/fk-empty-form.js +19 -0
- package/dist/collection/components/fk-file-input/fk-file-input.css +74 -0
- package/dist/collection/components/fk-file-input/fk-file-input.js +157 -0
- package/dist/collection/components/fk-form-builder/fk-form-builder.css +82 -0
- package/dist/collection/components/fk-form-builder/fk-form-builder.js +431 -0
- package/dist/collection/components/fk-form-render/fk-form-render.css +7 -0
- package/dist/collection/components/fk-form-render/fk-form-render.js +352 -0
- package/dist/collection/components/fk-property-panel/fk-property-panel.css +153 -0
- package/dist/collection/components/fk-property-panel/fk-property-panel.js +384 -0
- package/dist/collection/components/fk-rules-editor/fk-rules-editor.css +166 -0
- package/dist/collection/components/fk-rules-editor/fk-rules-editor.js +250 -0
- package/dist/collection/components/fk-select-input/fk-select-input.css +144 -0
- package/dist/collection/components/fk-select-input/fk-select-input.js +356 -0
- package/dist/collection/components/fk-signature-input/fk-signature-input.css +42 -0
- package/dist/collection/components/fk-signature-input/fk-signature-input.js +158 -0
- package/dist/collection/components/fk-stepper/fk-stepper.css +85 -0
- package/dist/collection/components/fk-stepper/fk-stepper.js +282 -0
- package/dist/collection/components/fk-tabs/fk-tabs.css +38 -0
- package/dist/collection/components/fk-tabs/fk-tabs.js +236 -0
- package/dist/collection/i18n/i18n.js +245 -0
- package/dist/collection/index.js +5 -0
- package/dist/collection/registry/create-brick.js +34 -0
- package/dist/collection/registry/default-bricks.js +424 -0
- package/dist/collection/registry/registry.js +44 -0
- package/dist/collection/utils/brick-data.js +16 -0
- package/dist/collection/utils/drop.js +14 -0
- package/dist/collection/utils/events.js +1 -0
- package/dist/collection/utils/options.js +21 -0
- package/dist/collection/utils/remote.js +27 -0
- package/dist/collection/utils/rule-condition.js +72 -0
- package/dist/collection/utils/style.js +11 -0
- package/dist/components/fk-brick-actions.d.ts +11 -0
- package/dist/components/fk-brick-actions.js +1 -0
- package/dist/components/fk-brick-list.d.ts +11 -0
- package/dist/components/fk-brick-list.js +1 -0
- package/dist/components/fk-brick-mold-item.d.ts +11 -0
- package/dist/components/fk-brick-mold-item.js +1 -0
- package/dist/components/fk-brick-not-found.d.ts +11 -0
- package/dist/components/fk-brick-not-found.js +1 -0
- package/dist/components/fk-brick-render.d.ts +11 -0
- package/dist/components/fk-brick-render.js +1 -0
- package/dist/components/fk-code-editor.d.ts +11 -0
- package/dist/components/fk-code-editor.js +1 -0
- package/dist/components/fk-data-grid.d.ts +11 -0
- package/dist/components/fk-data-grid.js +1 -0
- package/dist/components/fk-drop-area.d.ts +11 -0
- package/dist/components/fk-drop-area.js +1 -0
- package/dist/components/fk-empty-form.d.ts +11 -0
- package/dist/components/fk-empty-form.js +1 -0
- package/dist/components/fk-file-input.d.ts +11 -0
- package/dist/components/fk-file-input.js +1 -0
- package/dist/components/fk-form-builder.d.ts +11 -0
- package/dist/components/fk-form-builder.js +1 -0
- package/dist/components/fk-form-render.d.ts +11 -0
- package/dist/components/fk-form-render.js +1 -0
- package/dist/components/fk-property-panel.d.ts +11 -0
- package/dist/components/fk-property-panel.js +1 -0
- package/dist/components/fk-rules-editor.d.ts +11 -0
- package/dist/components/fk-rules-editor.js +1 -0
- package/dist/components/fk-select-input.d.ts +11 -0
- package/dist/components/fk-select-input.js +1 -0
- package/dist/components/fk-signature-input.d.ts +11 -0
- package/dist/components/fk-signature-input.js +1 -0
- package/dist/components/fk-stepper.d.ts +11 -0
- package/dist/components/fk-stepper.js +1 -0
- package/dist/components/fk-tabs.d.ts +11 -0
- package/dist/components/fk-tabs.js +1 -0
- package/dist/components/index.d.ts +35 -0
- package/dist/components/index.js +1 -0
- package/dist/components/p-92BozD8S.js +1 -0
- package/dist/components/p-B4vAN-UA.js +1 -0
- package/dist/components/p-BB3BQPr8.js +1 -0
- package/dist/components/p-BCQ-hj6j.js +1 -0
- package/dist/components/p-BIEpAM4V.js +1 -0
- package/dist/components/p-BLKRn62s.js +1 -0
- package/dist/components/p-BNREw7TY.js +1 -0
- package/dist/components/p-BOvjVIvo.js +1 -0
- package/dist/components/p-BQP1WryV.js +1 -0
- package/dist/components/p-BXFug2Ql.js +1 -0
- package/dist/components/p-Ctt--jpe.js +1 -0
- package/dist/components/p-D318uFl-.js +1 -0
- package/dist/components/p-DJDrDvoC.js +1 -0
- package/dist/components/p-DKGyje7v.js +1 -0
- package/dist/components/p-DKoJovNt.js +1 -0
- package/dist/components/p-DWgjI3TW.js +1 -0
- package/dist/components/p-Diknh4-7.js +1 -0
- package/dist/components/p-DtzMNM4i.js +1 -0
- package/dist/components/p-QC41Uj05.js +1 -0
- package/dist/components/p-TvmRksgg.js +1 -0
- package/dist/components/p-ZEW2q-4b.js +1 -0
- package/dist/components/p-dX7Lo8Fe.js +12 -0
- package/dist/components/p-gPc0o8Jb.js +1 -0
- package/dist/esm/app-globals-DQuL1Twl.js +3 -0
- package/dist/esm/fk-brick-actions_18.entry.js +26423 -0
- package/dist/esm/formkrafter-wc.js +21 -0
- package/dist/esm/index-BQqrzKxo.js +2081 -0
- package/dist/esm/index-BTmZ8XET.js +17288 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/loader.js +11 -0
- package/dist/formkrafter-wc/formkrafter-wc.css +1 -0
- package/dist/formkrafter-wc/formkrafter-wc.esm.js +1 -0
- package/dist/formkrafter-wc/index.esm.js +1 -0
- package/dist/formkrafter-wc/p-BQqrzKxo.js +2 -0
- package/dist/formkrafter-wc/p-BXIsVlA6.js +12 -0
- package/dist/formkrafter-wc/p-DQuL1Twl.js +1 -0
- package/dist/formkrafter-wc/p-f6bc0be0.entry.js +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/stencil.config.js +34 -0
- package/dist/types/Users/datagnikan/Desktop/WorkSpace/streamline-pulse/formkrafter-js/formkrafter/packages/wc/.stencil/stencil.config.d.ts +2 -0
- package/dist/types/components/fk-brick-actions/fk-brick-actions.d.ts +18 -0
- package/dist/types/components/fk-brick-list/fk-brick-list.d.ts +6 -0
- package/dist/types/components/fk-brick-mold-item/fk-brick-mold-item.d.ts +10 -0
- package/dist/types/components/fk-brick-not-found/fk-brick-not-found.d.ts +3 -0
- package/dist/types/components/fk-brick-render/fk-brick-render.d.ts +22 -0
- package/dist/types/components/fk-code-editor/fk-code-editor.d.ts +13 -0
- package/dist/types/components/fk-data-grid/fk-data-grid.d.ts +21 -0
- package/dist/types/components/fk-drop-area/fk-drop-area.d.ts +12 -0
- package/dist/types/components/fk-empty-form/fk-empty-form.d.ts +3 -0
- package/dist/types/components/fk-file-input/fk-file-input.d.ts +14 -0
- package/dist/types/components/fk-form-builder/fk-form-builder.d.ts +43 -0
- package/dist/types/components/fk-form-render/fk-form-render.d.ts +29 -0
- package/dist/types/components/fk-property-panel/fk-property-panel.d.ts +34 -0
- package/dist/types/components/fk-rules-editor/fk-rules-editor.d.ts +29 -0
- package/dist/types/components/fk-select-input/fk-select-input.d.ts +37 -0
- package/dist/types/components/fk-signature-input/fk-signature-input.d.ts +19 -0
- package/dist/types/components/fk-stepper/fk-stepper.d.ts +27 -0
- package/dist/types/components/fk-tabs/fk-tabs.d.ts +23 -0
- package/dist/types/components.d.ts +796 -0
- package/dist/types/i18n/i18n.d.ts +5 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/registry/create-brick.d.ts +37 -0
- package/dist/types/registry/default-bricks.d.ts +489 -0
- package/dist/types/registry/registry.d.ts +8 -0
- package/dist/types/stencil-public-runtime.d.ts +1861 -0
- package/dist/types/utils/brick-data.d.ts +3 -0
- package/dist/types/utils/drop.d.ts +2 -0
- package/dist/types/utils/events.d.ts +37 -0
- package/dist/types/utils/options.d.ts +5 -0
- package/dist/types/utils/remote.d.ts +3 -0
- package/dist/types/utils/rule-condition.d.ts +30 -0
- package/dist/types/utils/style.d.ts +1 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/package.json +80 -0
|
@@ -0,0 +1,424 @@
|
|
|
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 { fkT } from "../i18n/i18n";
|
|
6
|
+
import { resolveLocalizedText } from "@streamline-pulse/formkrafter-core";
|
|
7
|
+
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
|
+
const adorned = (props, control) => {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
const prefix = (_a = props.configs) === null || _a === void 0 ? void 0 : _a.prefix;
|
|
11
|
+
const suffix = (_b = props.configs) === null || _b === void 0 ? void 0 : _b.suffix;
|
|
12
|
+
if (!prefix && !suffix)
|
|
13
|
+
return control;
|
|
14
|
+
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
|
+
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));
|
|
17
|
+
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));
|
|
18
|
+
const createTextVariant = (params) => createBrick({
|
|
19
|
+
type: 'input',
|
|
20
|
+
dataType: 'string',
|
|
21
|
+
id: params.id,
|
|
22
|
+
name: params.name,
|
|
23
|
+
category: 'Inputs',
|
|
24
|
+
defaultConfigs: { label: params.name },
|
|
25
|
+
render: (props) => {
|
|
26
|
+
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); } })));
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
export const textInputBrick = createTextVariant({
|
|
31
|
+
id: 'text',
|
|
32
|
+
name: 'Text',
|
|
33
|
+
inputType: 'text',
|
|
34
|
+
});
|
|
35
|
+
export const emailBrick = createTextVariant({
|
|
36
|
+
id: 'email',
|
|
37
|
+
name: 'Email',
|
|
38
|
+
inputType: 'email',
|
|
39
|
+
});
|
|
40
|
+
export const passwordBrick = createTextVariant({
|
|
41
|
+
id: 'password',
|
|
42
|
+
name: 'Password',
|
|
43
|
+
inputType: 'password',
|
|
44
|
+
});
|
|
45
|
+
export const urlBrick = createTextVariant({
|
|
46
|
+
id: 'url',
|
|
47
|
+
name: 'URL',
|
|
48
|
+
inputType: 'url',
|
|
49
|
+
});
|
|
50
|
+
export const phoneBrick = createTextVariant({
|
|
51
|
+
id: 'phone',
|
|
52
|
+
name: 'Phone',
|
|
53
|
+
inputType: 'tel',
|
|
54
|
+
});
|
|
55
|
+
export const textareaBrick = createBrick({
|
|
56
|
+
type: 'input',
|
|
57
|
+
dataType: 'string',
|
|
58
|
+
id: 'textarea',
|
|
59
|
+
name: 'Text area',
|
|
60
|
+
category: 'Inputs',
|
|
61
|
+
defaultConfigs: { label: 'Text area' },
|
|
62
|
+
render: (props) => {
|
|
63
|
+
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); } }));
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
export const numberBrick = createBrick({
|
|
68
|
+
type: 'input',
|
|
69
|
+
dataType: 'number',
|
|
70
|
+
id: 'number',
|
|
71
|
+
name: 'Number',
|
|
72
|
+
category: 'Inputs',
|
|
73
|
+
defaultConfigs: { label: 'Number' },
|
|
74
|
+
render: (props) => {
|
|
75
|
+
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) => {
|
|
77
|
+
var _a;
|
|
78
|
+
const raw = event.target.value;
|
|
79
|
+
(_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, raw === '' ? undefined : Number(raw));
|
|
80
|
+
} })));
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
export const dateBrick = createBrick({
|
|
84
|
+
type: 'input',
|
|
85
|
+
dataType: 'string',
|
|
86
|
+
id: 'date',
|
|
87
|
+
name: 'Date',
|
|
88
|
+
category: 'Inputs',
|
|
89
|
+
defaultConfigs: { label: 'Date' },
|
|
90
|
+
render: (props) => {
|
|
91
|
+
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) => {
|
|
93
|
+
var _a;
|
|
94
|
+
const raw = event.target.value;
|
|
95
|
+
(_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, raw === '' ? undefined : raw);
|
|
96
|
+
} }));
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
export const selectBrick = createBrick({
|
|
100
|
+
type: 'input',
|
|
101
|
+
dataType: 'string',
|
|
102
|
+
id: 'select',
|
|
103
|
+
name: 'Select',
|
|
104
|
+
category: 'Inputs',
|
|
105
|
+
defaultConfigs: {
|
|
106
|
+
label: 'Select',
|
|
107
|
+
optionsSource: 'static',
|
|
108
|
+
options: 'Option 1\nOption 2',
|
|
109
|
+
},
|
|
110
|
+
render: (props) => {
|
|
111
|
+
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) => {
|
|
113
|
+
var _a;
|
|
114
|
+
event.stopPropagation();
|
|
115
|
+
(_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, event.detail);
|
|
116
|
+
} }));
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
export const multiSelectBrick = createBrick({
|
|
120
|
+
type: 'input',
|
|
121
|
+
dataType: 'array',
|
|
122
|
+
id: 'multi-select',
|
|
123
|
+
name: 'Multi select',
|
|
124
|
+
category: 'Inputs',
|
|
125
|
+
defaultConfigs: {
|
|
126
|
+
label: 'Multi select',
|
|
127
|
+
optionsSource: 'static',
|
|
128
|
+
options: 'Option 1\nOption 2\nOption 3',
|
|
129
|
+
},
|
|
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) => {
|
|
131
|
+
var _a;
|
|
132
|
+
event.stopPropagation();
|
|
133
|
+
(_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, event.detail);
|
|
134
|
+
} })),
|
|
135
|
+
});
|
|
136
|
+
export const timeBrick = createTextVariant({
|
|
137
|
+
id: 'time',
|
|
138
|
+
name: 'Time',
|
|
139
|
+
inputType: 'time',
|
|
140
|
+
});
|
|
141
|
+
export const datetimeBrick = createTextVariant({
|
|
142
|
+
id: 'datetime',
|
|
143
|
+
name: 'Date / Time',
|
|
144
|
+
inputType: 'datetime-local',
|
|
145
|
+
});
|
|
146
|
+
const staticOptions = (raw) => String(raw !== null && raw !== void 0 ? raw : '')
|
|
147
|
+
.split('\n')
|
|
148
|
+
.map((option) => option.trim())
|
|
149
|
+
.filter(Boolean);
|
|
150
|
+
export const selectBoxesBrick = createBrick({
|
|
151
|
+
type: 'input',
|
|
152
|
+
dataType: 'array',
|
|
153
|
+
id: 'select-boxes',
|
|
154
|
+
name: 'Select boxes',
|
|
155
|
+
category: 'Inputs',
|
|
156
|
+
defaultConfigs: { label: 'Select boxes', options: 'Option 1\nOption 2\nOption 3' },
|
|
157
|
+
render: (props) => {
|
|
158
|
+
var _a;
|
|
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((_a = props.configs) === null || _a === void 0 ? void 0 : _a.options).map((option) => (h("label", { class: "fk-radio", key: option }, h("input", { type: "checkbox", checked: selected.includes(option), disabled: props.editable || props.disabled, onChange: (event) => {
|
|
161
|
+
var _a;
|
|
162
|
+
const checked = event.target.checked;
|
|
163
|
+
const next = checked
|
|
164
|
+
? [...selected, option]
|
|
165
|
+
: selected.filter((value) => value !== option);
|
|
166
|
+
(_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));
|
|
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) => {
|
|
240
|
+
var _a, _b;
|
|
241
|
+
return (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" }, String((_b = (_a = props.configs) === null || _a === void 0 ? void 0 : _a.options) !== null && _b !== void 0 ? _b : '')
|
|
242
|
+
.split('\n')
|
|
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
|
+
},
|
|
250
|
+
});
|
|
251
|
+
const ADDRESS_PARTS = [
|
|
252
|
+
{ key: 'street', label: () => fkT('address.street'), full: true },
|
|
253
|
+
{ key: 'city', label: () => fkT('address.city'), full: false },
|
|
254
|
+
{ key: 'zip', label: () => fkT('address.zip'), full: false },
|
|
255
|
+
{ key: 'country', label: () => fkT('address.country'), full: false },
|
|
256
|
+
];
|
|
257
|
+
export const addressBrick = createBrick({
|
|
258
|
+
type: 'input',
|
|
259
|
+
dataType: 'object',
|
|
260
|
+
id: 'address',
|
|
261
|
+
name: 'Address',
|
|
262
|
+
category: 'Inputs',
|
|
263
|
+
defaultConfigs: { label: 'Address' },
|
|
264
|
+
render: (props) => {
|
|
265
|
+
var _a;
|
|
266
|
+
const value = ((_a = props.data) !== null && _a !== void 0 ? _a : {});
|
|
267
|
+
return fieldBlock(props, 'Address', h("div", { class: "fk-address" }, ADDRESS_PARTS.map((part) => {
|
|
268
|
+
var _a;
|
|
269
|
+
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) => {
|
|
270
|
+
var _a;
|
|
271
|
+
const raw = event.target.value;
|
|
272
|
+
const next = Object.assign(Object.assign({}, value), { [part.key]: raw || undefined });
|
|
273
|
+
const cleaned = Object.fromEntries(Object.entries(next).filter(([, entry]) => entry !== undefined));
|
|
274
|
+
(_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, Object.keys(cleaned).length ? cleaned : undefined);
|
|
275
|
+
} })));
|
|
276
|
+
})));
|
|
277
|
+
},
|
|
278
|
+
});
|
|
279
|
+
export const fileBrick = createBrick({
|
|
280
|
+
type: 'input',
|
|
281
|
+
dataType: 'object',
|
|
282
|
+
id: 'file',
|
|
283
|
+
name: 'File',
|
|
284
|
+
category: 'Data',
|
|
285
|
+
defaultConfigs: { label: 'File' },
|
|
286
|
+
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) => {
|
|
289
|
+
var _a;
|
|
290
|
+
event.stopPropagation();
|
|
291
|
+
(_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, event.detail);
|
|
292
|
+
} }));
|
|
293
|
+
},
|
|
294
|
+
});
|
|
295
|
+
export const dataGridBrick = createBrick({
|
|
296
|
+
type: 'collection',
|
|
297
|
+
dataType: 'array',
|
|
298
|
+
id: 'data-grid',
|
|
299
|
+
name: 'Data grid',
|
|
300
|
+
category: 'Data',
|
|
301
|
+
defaultConfigs: { label: 'Data grid' },
|
|
302
|
+
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) => {
|
|
303
|
+
var _a;
|
|
304
|
+
event.stopPropagation();
|
|
305
|
+
(_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, event.detail);
|
|
306
|
+
} }))),
|
|
307
|
+
});
|
|
308
|
+
export const hiddenBrick = createBrick({
|
|
309
|
+
type: 'input',
|
|
310
|
+
dataType: 'string',
|
|
311
|
+
id: 'hidden',
|
|
312
|
+
name: 'Hidden',
|
|
313
|
+
category: 'Data',
|
|
314
|
+
defaultConfigs: {},
|
|
315
|
+
render: (props) => {
|
|
316
|
+
var _a, _b;
|
|
317
|
+
return props.editable ? (h("div", { class: "fk-hidden-chip" }, "hidden: ", (_a = props.configs) === null || _a === void 0 ? void 0 :
|
|
318
|
+
_a.key)) : (h("input", { type: "hidden", value: (_b = props.data) !== null && _b !== void 0 ? _b : '' }));
|
|
319
|
+
},
|
|
320
|
+
});
|
|
321
|
+
export const contentBrick = createBrick({
|
|
322
|
+
type: 'output',
|
|
323
|
+
dataType: 'void',
|
|
324
|
+
id: 'content',
|
|
325
|
+
name: 'Content',
|
|
326
|
+
category: 'Layout',
|
|
327
|
+
defaultConfigs: { content: 'Some text…' },
|
|
328
|
+
render: (props) => {
|
|
329
|
+
var _a, _b;
|
|
330
|
+
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 : '')
|
|
331
|
+
.split('\n')
|
|
332
|
+
.map((line) => (h("p", { class: "fk-content__line" }, line)))));
|
|
333
|
+
},
|
|
334
|
+
});
|
|
335
|
+
export const stepperBrick = createBrick({
|
|
336
|
+
type: 'panel',
|
|
337
|
+
dataType: 'void',
|
|
338
|
+
id: 'stepper',
|
|
339
|
+
name: 'Stepper',
|
|
340
|
+
category: 'Layout',
|
|
341
|
+
defaultConfigs: {
|
|
342
|
+
validateSteps: false,
|
|
343
|
+
allowStepClick: true,
|
|
344
|
+
showSubmit: false,
|
|
345
|
+
},
|
|
346
|
+
render: (props) => {
|
|
347
|
+
var _a, _b;
|
|
348
|
+
const labels = ((_b = (_a = props.brickSpec) === null || _a === void 0 ? void 0 : _a.children) !== null && _b !== void 0 ? _b : []).map((child, index) => {
|
|
349
|
+
var _a, _b;
|
|
350
|
+
const resolved = resolveLocalizedText((_a = child.configs) === null || _a === void 0 ? void 0 : _a.label, props.locale);
|
|
351
|
+
return typeof resolved === 'string'
|
|
352
|
+
? resolved
|
|
353
|
+
: ((_b = child.name) !== null && _b !== void 0 ? _b : `Step ${index + 1}`);
|
|
354
|
+
});
|
|
355
|
+
return (h("fk-stepper", { stepLabels: labels, editable: props.editable, spec: props.brickSpec, dataMap: props.dataMap, locale: props.locale, style: asInlineStyle(props.styles) }, props.children));
|
|
356
|
+
},
|
|
357
|
+
});
|
|
358
|
+
export const checkboxBrick = createBrick({
|
|
359
|
+
type: 'input',
|
|
360
|
+
dataType: 'boolean',
|
|
361
|
+
id: 'checkbox',
|
|
362
|
+
name: 'Checkbox',
|
|
363
|
+
category: 'Inputs',
|
|
364
|
+
defaultConfigs: { label: 'Checkbox' },
|
|
365
|
+
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)),
|
|
366
|
+
});
|
|
367
|
+
export const groupBrick = createBrick({
|
|
368
|
+
type: 'panel',
|
|
369
|
+
dataType: 'void',
|
|
370
|
+
id: 'group',
|
|
371
|
+
name: 'Group',
|
|
372
|
+
category: 'Layout',
|
|
373
|
+
render: (props) => {
|
|
374
|
+
var _a;
|
|
375
|
+
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));
|
|
376
|
+
},
|
|
377
|
+
});
|
|
378
|
+
export const rowBrick = createBrick({
|
|
379
|
+
type: 'panel',
|
|
380
|
+
dataType: 'void',
|
|
381
|
+
id: 'row',
|
|
382
|
+
name: 'Row',
|
|
383
|
+
category: 'Layout',
|
|
384
|
+
render: (props) => (h("div", { class: "fk-row", style: asInlineStyle(props.styles) }, props.children)),
|
|
385
|
+
});
|
|
386
|
+
export const columnBrick = createBrick({
|
|
387
|
+
type: 'panel',
|
|
388
|
+
dataType: 'void',
|
|
389
|
+
id: 'column',
|
|
390
|
+
name: 'Column',
|
|
391
|
+
category: 'Layout',
|
|
392
|
+
render: (props) => (h("div", { class: "fk-column", style: asInlineStyle(props.styles) }, props.children)),
|
|
393
|
+
});
|
|
394
|
+
export function registerDefaultBricks() {
|
|
395
|
+
registerBricks([
|
|
396
|
+
textInputBrick,
|
|
397
|
+
emailBrick,
|
|
398
|
+
passwordBrick,
|
|
399
|
+
urlBrick,
|
|
400
|
+
phoneBrick,
|
|
401
|
+
textareaBrick,
|
|
402
|
+
numberBrick,
|
|
403
|
+
dateBrick,
|
|
404
|
+
timeBrick,
|
|
405
|
+
datetimeBrick,
|
|
406
|
+
selectBrick,
|
|
407
|
+
multiSelectBrick,
|
|
408
|
+
radioBrick,
|
|
409
|
+
selectBoxesBrick,
|
|
410
|
+
checkboxBrick,
|
|
411
|
+
tagsBrick,
|
|
412
|
+
signatureBrick,
|
|
413
|
+
addressBrick,
|
|
414
|
+
fileBrick,
|
|
415
|
+
dataGridBrick,
|
|
416
|
+
hiddenBrick,
|
|
417
|
+
contentBrick,
|
|
418
|
+
groupBrick,
|
|
419
|
+
rowBrick,
|
|
420
|
+
columnBrick,
|
|
421
|
+
stepperBrick,
|
|
422
|
+
tabsBrick,
|
|
423
|
+
]);
|
|
424
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function interpolateTemplate(template, dataMap) {
|
|
2
|
+
return template.replace(/\{(\w+)\}/g, (_, token) => {
|
|
3
|
+
const value = dataMap === null || dataMap === void 0 ? void 0 : dataMap[token];
|
|
4
|
+
return value === undefined || value === null ? '' : String(value);
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
export function parseHeaderLines(raw, dataMap) {
|
|
8
|
+
if (typeof raw !== 'string' || !raw.trim())
|
|
9
|
+
return undefined;
|
|
10
|
+
const headers = {};
|
|
11
|
+
for (const line of raw.split('\n')) {
|
|
12
|
+
const separator = line.indexOf(':');
|
|
13
|
+
if (separator <= 0)
|
|
14
|
+
continue;
|
|
15
|
+
const name = line.slice(0, separator).trim();
|
|
16
|
+
const value = interpolateTemplate(line.slice(separator + 1).trim(), dataMap);
|
|
17
|
+
if (name)
|
|
18
|
+
headers[name] = value;
|
|
19
|
+
}
|
|
20
|
+
return Object.keys(headers).length ? headers : undefined;
|
|
21
|
+
}
|
|
22
|
+
export function appendSearchParam(url, param, term) {
|
|
23
|
+
if (!term)
|
|
24
|
+
return url;
|
|
25
|
+
const separator = url.includes('?') ? '&' : '?';
|
|
26
|
+
return `${url}${separator}${encodeURIComponent(param)}=${encodeURIComponent(term)}`;
|
|
27
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export const OPERATORS = [
|
|
2
|
+
{ id: 'equals', label: 'equals' },
|
|
3
|
+
{ id: 'notEquals', label: 'does not equal' },
|
|
4
|
+
{ id: 'greaterThan', label: 'is greater than' },
|
|
5
|
+
{ id: 'lessThan', label: 'is less than' },
|
|
6
|
+
{ id: 'isEmpty', label: 'is empty' },
|
|
7
|
+
{ id: 'isNotEmpty', label: 'is not empty' },
|
|
8
|
+
];
|
|
9
|
+
export function buildLogic(condition) {
|
|
10
|
+
const variable = { var: condition.field };
|
|
11
|
+
switch (condition.operator) {
|
|
12
|
+
case 'equals':
|
|
13
|
+
return { '==': [variable, condition.value] };
|
|
14
|
+
case 'notEquals':
|
|
15
|
+
return { '!=': [variable, condition.value] };
|
|
16
|
+
case 'greaterThan':
|
|
17
|
+
return { '>': [variable, condition.value] };
|
|
18
|
+
case 'lessThan':
|
|
19
|
+
return { '<': [variable, condition.value] };
|
|
20
|
+
case 'isEmpty':
|
|
21
|
+
return { '!': variable };
|
|
22
|
+
case 'isNotEmpty':
|
|
23
|
+
return { '!!': variable };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const varName = (value) => value !== null &&
|
|
27
|
+
typeof value === 'object' &&
|
|
28
|
+
typeof value.var === 'string'
|
|
29
|
+
? value.var
|
|
30
|
+
: undefined;
|
|
31
|
+
const BINARY_OPERATORS = {
|
|
32
|
+
'==': 'equals',
|
|
33
|
+
'!=': 'notEquals',
|
|
34
|
+
'>': 'greaterThan',
|
|
35
|
+
'<': 'lessThan',
|
|
36
|
+
};
|
|
37
|
+
export function parseLogic(logic) {
|
|
38
|
+
if (!logic || typeof logic !== 'object')
|
|
39
|
+
return undefined;
|
|
40
|
+
const entries = Object.entries(logic);
|
|
41
|
+
if (entries.length !== 1)
|
|
42
|
+
return undefined;
|
|
43
|
+
const [operator, args] = entries[0];
|
|
44
|
+
if (operator === '!' || operator === '!!') {
|
|
45
|
+
const field = varName(Array.isArray(args) ? args[0] : args);
|
|
46
|
+
if (!field)
|
|
47
|
+
return undefined;
|
|
48
|
+
return { field, operator: operator === '!' ? 'isEmpty' : 'isNotEmpty' };
|
|
49
|
+
}
|
|
50
|
+
const mapped = BINARY_OPERATORS[operator];
|
|
51
|
+
if (!mapped || !Array.isArray(args) || args.length !== 2)
|
|
52
|
+
return undefined;
|
|
53
|
+
const field = varName(args[0]);
|
|
54
|
+
if (!field)
|
|
55
|
+
return undefined;
|
|
56
|
+
return { field, operator: mapped, value: args[1] };
|
|
57
|
+
}
|
|
58
|
+
export function parseValueInput(raw) {
|
|
59
|
+
if (raw === '')
|
|
60
|
+
return '';
|
|
61
|
+
try {
|
|
62
|
+
return JSON.parse(raw);
|
|
63
|
+
}
|
|
64
|
+
catch (_a) {
|
|
65
|
+
return raw;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export function formatValue(value) {
|
|
69
|
+
if (value === undefined)
|
|
70
|
+
return '';
|
|
71
|
+
return typeof value === 'string' ? value : JSON.stringify(value);
|
|
72
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const toCamel = (key) => key.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
2
|
+
export function asInlineStyle(styles) {
|
|
3
|
+
const entries = Object.entries(styles !== null && styles !== void 0 ? styles : {}).filter(([, value]) => value !== undefined && value !== null && value !== '');
|
|
4
|
+
if (entries.length === 0)
|
|
5
|
+
return undefined;
|
|
6
|
+
const result = {};
|
|
7
|
+
for (const [key, value] of entries) {
|
|
8
|
+
result[toCamel(key)] = String(value);
|
|
9
|
+
}
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface FkBrickActions extends Components.FkBrickActions, HTMLElement {}
|
|
4
|
+
export const FkBrickActions: {
|
|
5
|
+
prototype: FkBrickActions;
|
|
6
|
+
new (): FkBrickActions;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{F as o,d as s}from"./p-BNREw7TY.js";const p=o,r=s;export{p as FkBrickActions,r as defineCustomElement}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface FkBrickList extends Components.FkBrickList, HTMLElement {}
|
|
4
|
+
export const FkBrickList: {
|
|
5
|
+
prototype: FkBrickList;
|
|
6
|
+
new (): FkBrickList;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{F as o,d as s}from"./p-ZEW2q-4b.js";const p=o,r=s;export{p as FkBrickList,r as defineCustomElement}
|