@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,384 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
import { isLocalizedObject } from "@streamline-pulse/formkrafter-core";
|
|
3
|
+
import { fkT, fkTOr } from "../../i18n/i18n";
|
|
4
|
+
export class FkPropertyPanel {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.fields = [];
|
|
7
|
+
this.locales = [];
|
|
8
|
+
this.activeTab = 'config';
|
|
9
|
+
this.newStyleKey = '';
|
|
10
|
+
}
|
|
11
|
+
onBrickChange() {
|
|
12
|
+
if (!this.availableTabs().some((tab) => tab.id === this.activeTab)) {
|
|
13
|
+
this.activeTab = 'config';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
availableTabs() {
|
|
17
|
+
const tabs = [
|
|
18
|
+
{ id: 'config', label: fkT('panel.tab.config') },
|
|
19
|
+
];
|
|
20
|
+
if (this.brick.type === 'input') {
|
|
21
|
+
tabs.push({ id: 'validation', label: fkT('panel.tab.validation') });
|
|
22
|
+
}
|
|
23
|
+
tabs.push({ id: 'styles', label: fkT('panel.tab.styles') }, { id: 'rules', label: fkT('panel.tab.rules') });
|
|
24
|
+
return tabs;
|
|
25
|
+
}
|
|
26
|
+
localized(current, value) {
|
|
27
|
+
var _a;
|
|
28
|
+
if (this.locales.length <= 1)
|
|
29
|
+
return value || undefined;
|
|
30
|
+
const map = isLocalizedObject(current)
|
|
31
|
+
? Object.assign({}, current) : {};
|
|
32
|
+
if (typeof current === 'string' && current && !isLocalizedObject(current)) {
|
|
33
|
+
map[this.locales[0]] = current;
|
|
34
|
+
}
|
|
35
|
+
map[(_a = this.editLocale) !== null && _a !== void 0 ? _a : this.locales[0]] = value;
|
|
36
|
+
return map;
|
|
37
|
+
}
|
|
38
|
+
readLocalized(current) {
|
|
39
|
+
var _a, _b, _c;
|
|
40
|
+
if (isLocalizedObject(current)) {
|
|
41
|
+
return (_b = current[(_a = this.editLocale) !== null && _a !== void 0 ? _a : this.locales[0]]) !== null && _b !== void 0 ? _b : '';
|
|
42
|
+
}
|
|
43
|
+
return (_c = current) !== null && _c !== void 0 ? _c : '';
|
|
44
|
+
}
|
|
45
|
+
writeTextConfig(key, value) {
|
|
46
|
+
var _a;
|
|
47
|
+
this.emitConfigs({ [key]: this.localized((_a = this.brick.configs) === null || _a === void 0 ? void 0 : _a[key], value) });
|
|
48
|
+
}
|
|
49
|
+
emitConfigs(patch) {
|
|
50
|
+
var _a;
|
|
51
|
+
const uid = (_a = this.brick.configs) === null || _a === void 0 ? void 0 : _a.uid;
|
|
52
|
+
if (!uid)
|
|
53
|
+
return;
|
|
54
|
+
this.brickConfigsChange.emit({ configs: patch, uid });
|
|
55
|
+
}
|
|
56
|
+
emitValidations(validations) {
|
|
57
|
+
var _a;
|
|
58
|
+
const uid = (_a = this.brick.configs) === null || _a === void 0 ? void 0 : _a.uid;
|
|
59
|
+
if (!uid)
|
|
60
|
+
return;
|
|
61
|
+
this.brickValidationsChange.emit({ validations, uid });
|
|
62
|
+
}
|
|
63
|
+
emitStyles(patch) {
|
|
64
|
+
var _a;
|
|
65
|
+
const uid = (_a = this.brick.configs) === null || _a === void 0 ? void 0 : _a.uid;
|
|
66
|
+
if (!uid)
|
|
67
|
+
return;
|
|
68
|
+
this.brickStylesChange.emit({ styles: patch, uid });
|
|
69
|
+
}
|
|
70
|
+
validationOf(validator) {
|
|
71
|
+
var _a;
|
|
72
|
+
return (_a = this.brick.validations) === null || _a === void 0 ? void 0 : _a.find((validation) => validation.validator === validator);
|
|
73
|
+
}
|
|
74
|
+
setValidation(validator, active, patch = {}) {
|
|
75
|
+
var _a;
|
|
76
|
+
const current = this.validationOf(validator);
|
|
77
|
+
const others = ((_a = this.brick.validations) !== null && _a !== void 0 ? _a : []).filter((validation) => validation.validator !== validator);
|
|
78
|
+
this.emitValidations(active ? [...others, Object.assign(Object.assign(Object.assign({}, current), { validator }), patch)] : others);
|
|
79
|
+
}
|
|
80
|
+
addStyle(value) {
|
|
81
|
+
const key = this.newStyleKey.trim();
|
|
82
|
+
if (!key)
|
|
83
|
+
return;
|
|
84
|
+
this.emitStyles({ [key]: value });
|
|
85
|
+
this.newStyleKey = '';
|
|
86
|
+
}
|
|
87
|
+
textField(label, value, onCommit) {
|
|
88
|
+
var _a;
|
|
89
|
+
return (h("label", { class: "fk-props__field" }, h("span", { class: "fk-props__label" }, label), h("input", { class: "fk-props__input", type: "text", value: (_a = value) !== null && _a !== void 0 ? _a : '', onChange: (event) => onCommit(event.target.value) })));
|
|
90
|
+
}
|
|
91
|
+
optionsFields() {
|
|
92
|
+
var _a, _b, _c;
|
|
93
|
+
const configs = this.brick.configs;
|
|
94
|
+
if (!configs || !('options' in configs || 'optionsSource' in configs)) {
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
const supportsSources = 'optionsSource' in configs;
|
|
98
|
+
const source = supportsSources
|
|
99
|
+
? ((_a = configs.optionsSource) !== null && _a !== void 0 ? _a : 'static')
|
|
100
|
+
: 'static';
|
|
101
|
+
const nodes = supportsSources
|
|
102
|
+
? [
|
|
103
|
+
h("label", { class: "fk-props__field" }, h("span", { class: "fk-props__label" }, fkT('panel.optionsSource')), h("select", { class: "fk-props__input", onChange: (event) => this.emitConfigs({
|
|
104
|
+
optionsSource: event.target.value,
|
|
105
|
+
}) }, ['static', 'dataMap', 'remote', 'js'].map((candidate) => (h("option", { value: candidate, selected: candidate === source }, candidate))))),
|
|
106
|
+
]
|
|
107
|
+
: [];
|
|
108
|
+
if (source === 'static') {
|
|
109
|
+
nodes.push(h("label", { class: "fk-props__field" }, h("span", { class: "fk-props__label" }, fkT('panel.options')), h("textarea", { class: "fk-props__input fk-props__input--textarea", onChange: (event) => this.writeTextConfig('options', event.target.value) }, this.readLocalized(configs.options))));
|
|
110
|
+
}
|
|
111
|
+
if (source === 'dataMap') {
|
|
112
|
+
nodes.push(this.textField(fkT('panel.dataKey'), configs.optionsPath, (value) => this.emitConfigs({ optionsPath: value })));
|
|
113
|
+
}
|
|
114
|
+
if (source === 'remote') {
|
|
115
|
+
nodes.push(this.textField(fkT('panel.url'), configs.optionsUrl, (value) => this.emitConfigs({ optionsUrl: value })), h("label", { class: "fk-props__field" }, h("span", { class: "fk-props__label" }, fkT('panel.headers')), h("textarea", { class: "fk-props__input fk-props__input--textarea", placeholder: 'Authorization: Bearer {token}', onChange: (event) => this.emitConfigs({
|
|
116
|
+
optionsHeaders: event.target.value || undefined,
|
|
117
|
+
}) }, (_b = configs.optionsHeaders) !== null && _b !== void 0 ? _b : '')), this.textField(fkT('panel.searchParam'), configs.searchParam, (value) => this.emitConfigs({ searchParam: value || undefined })));
|
|
118
|
+
}
|
|
119
|
+
if (source === 'js') {
|
|
120
|
+
nodes.push(h("label", { class: "fk-props__field" }, h("span", { class: "fk-props__label" }, "Code"), h("fk-code-editor", { value: (_c = configs.optionsCode) !== null && _c !== void 0 ? _c : '', placeholder: "return dataMap.country === 'BJ' ? ['Cotonou'] : ['Paris'];", onCodeChange: (event) => this.emitConfigs({ optionsCode: event.detail }) })));
|
|
121
|
+
}
|
|
122
|
+
if (source === 'remote' || source === 'js') {
|
|
123
|
+
nodes.push(this.textField(fkT('panel.labelKey'), configs.labelKey, (value) => this.emitConfigs({ labelKey: value })), this.textField(fkT('panel.valueKey'), configs.valueKey, (value) => this.emitConfigs({ valueKey: value })));
|
|
124
|
+
}
|
|
125
|
+
return nodes;
|
|
126
|
+
}
|
|
127
|
+
renderConfigTab() {
|
|
128
|
+
const configs = this.brick.configs;
|
|
129
|
+
const isInput = this.brick.type === 'input';
|
|
130
|
+
return (h("section", { class: "fk-props__section" }, this.textField(fkT('panel.key'), configs === null || configs === void 0 ? void 0 : configs.key, (value) => this.emitConfigs({ key: value })), this.textField(fkT('panel.label'), this.readLocalized(configs === null || configs === void 0 ? void 0 : configs.label), (value) => this.writeTextConfig('label', value)), isInput
|
|
131
|
+
? [
|
|
132
|
+
this.textField(fkT('panel.placeholder'), this.readLocalized(configs === null || configs === void 0 ? void 0 : configs.placeholder), (value) => this.writeTextConfig('placeholder', value)),
|
|
133
|
+
this.textField(fkT('panel.prefix'), configs === null || configs === void 0 ? void 0 : configs.prefix, (value) => this.emitConfigs({ prefix: value || undefined })),
|
|
134
|
+
this.textField(fkT('panel.suffix'), configs === null || configs === void 0 ? void 0 : configs.suffix, (value) => this.emitConfigs({ suffix: value || undefined })),
|
|
135
|
+
]
|
|
136
|
+
: null, this.optionsFields(), Object.entries(configs !== null && configs !== void 0 ? configs : {})
|
|
137
|
+
.filter(([, value]) => typeof value === 'boolean')
|
|
138
|
+
.map(([key, value]) => (h("label", { class: "fk-props__field fk-props__field--inline", key: key }, h("input", { type: "checkbox", checked: value === true, onChange: (event) => this.emitConfigs({
|
|
139
|
+
[key]: event.target.checked,
|
|
140
|
+
}) }), h("span", { class: "fk-props__label" }, fkTOr(`panel.cfg.${key}`, key))))), configs && 'content' in configs ? (h("label", { class: "fk-props__field" }, h("span", { class: "fk-props__label" }, fkT('panel.content')), h("textarea", { class: "fk-props__input fk-props__input--textarea", onChange: (event) => this.writeTextConfig('content', event.target.value) }, this.readLocalized(configs.content)))) : null));
|
|
141
|
+
}
|
|
142
|
+
validationRow(validator, label, valueType) {
|
|
143
|
+
const rule = this.validationOf(validator);
|
|
144
|
+
return (h("div", { class: "fk-props__vrule" }, h("label", { class: "fk-props__field fk-props__field--inline" }, h("input", { type: "checkbox", checked: !!rule, onChange: (event) => this.setValidation(validator, event.target.checked) }), h("span", { class: "fk-props__label" }, label)), rule && valueType ? (h("input", { class: "fk-props__input", type: valueType, placeholder: valueType === 'number' ? 'value' : 'regex', value: rule.value == null ? '' : String(rule.value), onChange: (event) => {
|
|
145
|
+
const raw = event.target.value;
|
|
146
|
+
this.setValidation(validator, true, {
|
|
147
|
+
value: valueType === 'number'
|
|
148
|
+
? raw === ''
|
|
149
|
+
? undefined
|
|
150
|
+
: Number(raw)
|
|
151
|
+
: raw || undefined,
|
|
152
|
+
});
|
|
153
|
+
} })) : null, rule
|
|
154
|
+
? this.textField(fkT('panel.errorMessage'), this.readLocalized(rule.message), (value) => this.setValidation(validator, true, {
|
|
155
|
+
message: this.localized(rule.message, value),
|
|
156
|
+
}))
|
|
157
|
+
: null));
|
|
158
|
+
}
|
|
159
|
+
renderValidationTab() {
|
|
160
|
+
var _a;
|
|
161
|
+
const dataType = this.brick.dataType;
|
|
162
|
+
const custom = this.validationOf('custom');
|
|
163
|
+
return (h("section", { class: "fk-props__section" }, this.validationRow('required', fkT('panel.required')), dataType === 'string'
|
|
164
|
+
? [
|
|
165
|
+
this.validationRow('minLength', fkT('panel.minLength'), 'number'),
|
|
166
|
+
this.validationRow('maxLength', fkT('panel.maxLength'), 'number'),
|
|
167
|
+
this.validationRow('pattern', fkT('panel.pattern'), 'text'),
|
|
168
|
+
this.validationRow('email', fkT('panel.emailFormat')),
|
|
169
|
+
this.validationRow('url', fkT('panel.urlFormat')),
|
|
170
|
+
]
|
|
171
|
+
: null, dataType === 'number'
|
|
172
|
+
? [
|
|
173
|
+
this.validationRow('min', fkT('panel.min'), 'number'),
|
|
174
|
+
this.validationRow('max', fkT('panel.max'), 'number'),
|
|
175
|
+
]
|
|
176
|
+
: null, dataType === 'array'
|
|
177
|
+
? [
|
|
178
|
+
this.validationRow('minItems', fkT('panel.minItems'), 'number'),
|
|
179
|
+
this.validationRow('maxItems', fkT('panel.maxItems'), 'number'),
|
|
180
|
+
]
|
|
181
|
+
: null, h("div", { class: "fk-props__vrule" }, h("label", { class: "fk-props__field fk-props__field--inline" }, h("input", { type: "checkbox", checked: !!custom, onChange: (event) => {
|
|
182
|
+
var _a;
|
|
183
|
+
return this.setValidation('custom', event.target.checked, { customValidator: (_a = custom === null || custom === void 0 ? void 0 : custom.customValidator) !== null && _a !== void 0 ? _a : 'return true;' });
|
|
184
|
+
} }), h("span", { class: "fk-props__label" }, fkT('panel.custom'))), custom ? (h("fk-code-editor", { value: (_a = custom.customValidator) !== null && _a !== void 0 ? _a : '', placeholder: 'return value?.startsWith("BJ-") ? true : "Must start with BJ-";', onCodeChange: (event) => this.setValidation('custom', true, {
|
|
185
|
+
customValidator: event.detail,
|
|
186
|
+
}) })) : null, custom
|
|
187
|
+
? this.textField(fkT('panel.fallbackMessage'), this.readLocalized(custom.message), (value) => this.setValidation('custom', true, {
|
|
188
|
+
message: this.localized(custom.message, value),
|
|
189
|
+
}))
|
|
190
|
+
: null)));
|
|
191
|
+
}
|
|
192
|
+
renderStylesTab() {
|
|
193
|
+
var _a;
|
|
194
|
+
return (h("section", { class: "fk-props__section" }, Object.entries((_a = this.brick.styles) !== null && _a !== void 0 ? _a : {}).map(([key, value]) => (h("div", { class: "fk-props__style-row", key: key }, h("span", { class: "fk-props__style-key" }, key), h("input", { class: "fk-props__input fk-props__input--grow", type: "text", value: String(value !== null && value !== void 0 ? value : ''), onChange: (event) => this.emitStyles({
|
|
195
|
+
[key]: event.target.value,
|
|
196
|
+
}) }), h("button", { type: "button", class: "fk-props__remove", title: "Remove style", onClick: () => this.emitStyles({ [key]: undefined }) }, "\u2715")))), h("div", { class: "fk-props__style-row" }, h("input", { class: "fk-props__input", type: "text", placeholder: fkT('panel.styleProperty'), value: this.newStyleKey, onInput: (event) => (this.newStyleKey = event.target.value) }), h("input", { class: "fk-props__input fk-props__input--grow", type: "text", placeholder: fkT('panel.styleValue'), onChange: (event) => {
|
|
197
|
+
const target = event.target;
|
|
198
|
+
this.addStyle(target.value);
|
|
199
|
+
target.value = '';
|
|
200
|
+
} }))));
|
|
201
|
+
}
|
|
202
|
+
render() {
|
|
203
|
+
return (h("div", { key: 'a935dd3bf883d81cc16b9a14786b8a663dbb33be', class: "fk-props" }, h("header", { key: '021592872aed2d7c41644f492fb0b48847e0e12d', class: "fk-props__header" }, h("span", { key: '56b02e18fc6b87976aa45ab13bc643630220f3d3', class: "fk-props__type" }, this.brick.type), h("h4", { key: '78f0a39ee6db58a1d60b0587792424e6bb0efd20', class: "fk-props__title" }, fkTOr(`brick.${this.brick.id}.name`, this.brick.name))), h("div", { key: 'bce6485ecc449b0db6e3c7db1b5fde98196d1ae7', class: "fk-props__tabs" }, this.availableTabs().map((tab) => (h("button", { key: tab.id, type: "button", class: {
|
|
204
|
+
'fk-props__tab': true,
|
|
205
|
+
'fk-props__tab--active': this.activeTab === tab.id,
|
|
206
|
+
}, onClick: () => (this.activeTab = tab.id) }, tab.label)))), this.activeTab === 'config' ? this.renderConfigTab() : null, this.activeTab === 'validation' ? this.renderValidationTab() : null, this.activeTab === 'styles' ? this.renderStylesTab() : null, this.activeTab === 'rules' ? (h("section", { class: "fk-props__section" }, h("fk-rules-editor", { brick: this.brick, fields: this.fields }))) : null));
|
|
207
|
+
}
|
|
208
|
+
static get is() { return "fk-property-panel"; }
|
|
209
|
+
static get encapsulation() { return "scoped"; }
|
|
210
|
+
static get originalStyleUrls() {
|
|
211
|
+
return {
|
|
212
|
+
"$": ["fk-property-panel.css"]
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
static get styleUrls() {
|
|
216
|
+
return {
|
|
217
|
+
"$": ["fk-property-panel.css"]
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
static get properties() {
|
|
221
|
+
return {
|
|
222
|
+
"brick": {
|
|
223
|
+
"type": "unknown",
|
|
224
|
+
"mutable": false,
|
|
225
|
+
"complexType": {
|
|
226
|
+
"original": "BrickSpec",
|
|
227
|
+
"resolved": "BrickSpec",
|
|
228
|
+
"references": {
|
|
229
|
+
"BrickSpec": {
|
|
230
|
+
"location": "import",
|
|
231
|
+
"path": "@streamline-pulse/formkrafter-core",
|
|
232
|
+
"id": "../core/dist/index.d.ts::BrickSpec",
|
|
233
|
+
"referenceLocation": "BrickSpec"
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
"required": true,
|
|
238
|
+
"optional": false,
|
|
239
|
+
"docs": {
|
|
240
|
+
"tags": [],
|
|
241
|
+
"text": ""
|
|
242
|
+
},
|
|
243
|
+
"getter": false,
|
|
244
|
+
"setter": false
|
|
245
|
+
},
|
|
246
|
+
"fields": {
|
|
247
|
+
"type": "unknown",
|
|
248
|
+
"mutable": false,
|
|
249
|
+
"complexType": {
|
|
250
|
+
"original": "string[]",
|
|
251
|
+
"resolved": "string[]",
|
|
252
|
+
"references": {}
|
|
253
|
+
},
|
|
254
|
+
"required": false,
|
|
255
|
+
"optional": false,
|
|
256
|
+
"docs": {
|
|
257
|
+
"tags": [],
|
|
258
|
+
"text": ""
|
|
259
|
+
},
|
|
260
|
+
"getter": false,
|
|
261
|
+
"setter": false,
|
|
262
|
+
"defaultValue": "[]"
|
|
263
|
+
},
|
|
264
|
+
"locales": {
|
|
265
|
+
"type": "unknown",
|
|
266
|
+
"mutable": false,
|
|
267
|
+
"complexType": {
|
|
268
|
+
"original": "string[]",
|
|
269
|
+
"resolved": "string[]",
|
|
270
|
+
"references": {}
|
|
271
|
+
},
|
|
272
|
+
"required": false,
|
|
273
|
+
"optional": false,
|
|
274
|
+
"docs": {
|
|
275
|
+
"tags": [],
|
|
276
|
+
"text": ""
|
|
277
|
+
},
|
|
278
|
+
"getter": false,
|
|
279
|
+
"setter": false,
|
|
280
|
+
"defaultValue": "[]"
|
|
281
|
+
},
|
|
282
|
+
"editLocale": {
|
|
283
|
+
"type": "string",
|
|
284
|
+
"mutable": false,
|
|
285
|
+
"complexType": {
|
|
286
|
+
"original": "string",
|
|
287
|
+
"resolved": "string",
|
|
288
|
+
"references": {}
|
|
289
|
+
},
|
|
290
|
+
"required": false,
|
|
291
|
+
"optional": true,
|
|
292
|
+
"docs": {
|
|
293
|
+
"tags": [],
|
|
294
|
+
"text": ""
|
|
295
|
+
},
|
|
296
|
+
"getter": false,
|
|
297
|
+
"setter": false,
|
|
298
|
+
"reflect": false,
|
|
299
|
+
"attribute": "edit-locale"
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
static get states() {
|
|
304
|
+
return {
|
|
305
|
+
"activeTab": {},
|
|
306
|
+
"newStyleKey": {}
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
static get events() {
|
|
310
|
+
return [{
|
|
311
|
+
"method": "brickConfigsChange",
|
|
312
|
+
"name": "brickConfigsChange",
|
|
313
|
+
"bubbles": true,
|
|
314
|
+
"cancelable": true,
|
|
315
|
+
"composed": true,
|
|
316
|
+
"docs": {
|
|
317
|
+
"tags": [],
|
|
318
|
+
"text": ""
|
|
319
|
+
},
|
|
320
|
+
"complexType": {
|
|
321
|
+
"original": "BrickConfigsChangeDetail",
|
|
322
|
+
"resolved": "BrickConfigsChangeDetail",
|
|
323
|
+
"references": {
|
|
324
|
+
"BrickConfigsChangeDetail": {
|
|
325
|
+
"location": "import",
|
|
326
|
+
"path": "../../utils/events",
|
|
327
|
+
"id": "src/utils/events.ts::BrickConfigsChangeDetail",
|
|
328
|
+
"referenceLocation": "BrickConfigsChangeDetail"
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}, {
|
|
333
|
+
"method": "brickValidationsChange",
|
|
334
|
+
"name": "brickValidationsChange",
|
|
335
|
+
"bubbles": true,
|
|
336
|
+
"cancelable": true,
|
|
337
|
+
"composed": true,
|
|
338
|
+
"docs": {
|
|
339
|
+
"tags": [],
|
|
340
|
+
"text": ""
|
|
341
|
+
},
|
|
342
|
+
"complexType": {
|
|
343
|
+
"original": "BrickValidationsChangeDetail",
|
|
344
|
+
"resolved": "BrickValidationsChangeDetail",
|
|
345
|
+
"references": {
|
|
346
|
+
"BrickValidationsChangeDetail": {
|
|
347
|
+
"location": "import",
|
|
348
|
+
"path": "../../utils/events",
|
|
349
|
+
"id": "src/utils/events.ts::BrickValidationsChangeDetail",
|
|
350
|
+
"referenceLocation": "BrickValidationsChangeDetail"
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}, {
|
|
355
|
+
"method": "brickStylesChange",
|
|
356
|
+
"name": "brickStylesChange",
|
|
357
|
+
"bubbles": true,
|
|
358
|
+
"cancelable": true,
|
|
359
|
+
"composed": true,
|
|
360
|
+
"docs": {
|
|
361
|
+
"tags": [],
|
|
362
|
+
"text": ""
|
|
363
|
+
},
|
|
364
|
+
"complexType": {
|
|
365
|
+
"original": "BrickStylesChangeDetail",
|
|
366
|
+
"resolved": "BrickStylesChangeDetail",
|
|
367
|
+
"references": {
|
|
368
|
+
"BrickStylesChangeDetail": {
|
|
369
|
+
"location": "import",
|
|
370
|
+
"path": "../../utils/events",
|
|
371
|
+
"id": "src/utils/events.ts::BrickStylesChangeDetail",
|
|
372
|
+
"referenceLocation": "BrickStylesChangeDetail"
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}];
|
|
377
|
+
}
|
|
378
|
+
static get watchers() {
|
|
379
|
+
return [{
|
|
380
|
+
"propName": "brick",
|
|
381
|
+
"methodName": "onBrickChange"
|
|
382
|
+
}];
|
|
383
|
+
}
|
|
384
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.fk-rules {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
gap: var(--fk-spacing);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.fk-rule {
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
gap: calc(var(--fk-spacing) / 1.5);
|
|
15
|
+
padding: var(--fk-spacing);
|
|
16
|
+
border: 1px solid var(--fk-color-border);
|
|
17
|
+
border-radius: calc(var(--fk-radius) / 1.5);
|
|
18
|
+
background: color-mix(in srgb, var(--fk-color-surface) 60%, transparent);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.fk-rule__header {
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
gap: 6px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.fk-rule__name {
|
|
28
|
+
flex: 1;
|
|
29
|
+
min-width: 0;
|
|
30
|
+
font: inherit;
|
|
31
|
+
font-size: 0.8rem;
|
|
32
|
+
font-weight: 600;
|
|
33
|
+
padding: 4px 6px;
|
|
34
|
+
border: 1px solid transparent;
|
|
35
|
+
border-radius: calc(var(--fk-radius) / 2);
|
|
36
|
+
background: transparent;
|
|
37
|
+
color: var(--fk-color-text);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.fk-rule__name:hover,
|
|
41
|
+
.fk-rule__name:focus {
|
|
42
|
+
border-color: var(--fk-color-border);
|
|
43
|
+
background: var(--fk-color-surface);
|
|
44
|
+
outline: none;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.fk-rule__modes {
|
|
48
|
+
display: flex;
|
|
49
|
+
gap: 4px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.fk-rule__mode {
|
|
53
|
+
font: inherit;
|
|
54
|
+
font-size: 0.65rem;
|
|
55
|
+
font-weight: 600;
|
|
56
|
+
text-transform: uppercase;
|
|
57
|
+
letter-spacing: 0.05em;
|
|
58
|
+
padding: 3px 8px;
|
|
59
|
+
border: 1px solid var(--fk-color-border);
|
|
60
|
+
border-radius: 999px;
|
|
61
|
+
background: transparent;
|
|
62
|
+
color: var(--fk-color-muted);
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.fk-rule__mode--active {
|
|
67
|
+
border-color: var(--fk-color-primary);
|
|
68
|
+
background: color-mix(in srgb, var(--fk-color-primary) 12%, transparent);
|
|
69
|
+
color: var(--fk-color-primary);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.fk-rule__condition,
|
|
73
|
+
.fk-rule__effect {
|
|
74
|
+
display: flex;
|
|
75
|
+
flex-wrap: wrap;
|
|
76
|
+
align-items: center;
|
|
77
|
+
gap: 4px;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.fk-rule__keyword {
|
|
81
|
+
font-size: 0.65rem;
|
|
82
|
+
font-weight: 700;
|
|
83
|
+
text-transform: uppercase;
|
|
84
|
+
letter-spacing: 0.08em;
|
|
85
|
+
color: var(--fk-color-muted);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.fk-rule__control {
|
|
89
|
+
font: inherit;
|
|
90
|
+
font-size: 0.78rem;
|
|
91
|
+
padding: 4px 6px;
|
|
92
|
+
max-width: 100%;
|
|
93
|
+
min-width: 0;
|
|
94
|
+
border: 1px solid var(--fk-color-border);
|
|
95
|
+
border-radius: calc(var(--fk-radius) / 2);
|
|
96
|
+
background: var(--fk-color-surface);
|
|
97
|
+
color: var(--fk-color-text);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.fk-rule__control:focus {
|
|
101
|
+
outline: none;
|
|
102
|
+
border-color: var(--fk-color-primary);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.fk-rule__advanced {
|
|
106
|
+
display: flex;
|
|
107
|
+
flex-direction: column;
|
|
108
|
+
gap: 4px;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.fk-rule__code {
|
|
112
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
113
|
+
font-size: 0.75rem;
|
|
114
|
+
min-height: 72px;
|
|
115
|
+
padding: 6px 8px;
|
|
116
|
+
border: 1px solid var(--fk-color-border);
|
|
117
|
+
border-radius: calc(var(--fk-radius) / 2);
|
|
118
|
+
background: var(--fk-color-surface);
|
|
119
|
+
color: var(--fk-color-text);
|
|
120
|
+
resize: vertical;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.fk-rule__error {
|
|
124
|
+
margin: 0;
|
|
125
|
+
font-size: 0.72rem;
|
|
126
|
+
color: var(--fk-color-danger);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.fk-rule__effects {
|
|
130
|
+
display: flex;
|
|
131
|
+
flex-direction: column;
|
|
132
|
+
gap: 6px;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.fk-rule__remove {
|
|
136
|
+
border: none;
|
|
137
|
+
background: transparent;
|
|
138
|
+
color: var(--fk-color-muted);
|
|
139
|
+
font-size: 0.75rem;
|
|
140
|
+
cursor: pointer;
|
|
141
|
+
padding: 2px 4px;
|
|
142
|
+
border-radius: calc(var(--fk-radius) / 2);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.fk-rule__remove:hover {
|
|
146
|
+
color: var(--fk-color-danger);
|
|
147
|
+
background: color-mix(in srgb, var(--fk-color-danger) 10%, transparent);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.fk-rule__add {
|
|
151
|
+
align-self: flex-start;
|
|
152
|
+
font: inherit;
|
|
153
|
+
font-size: 0.75rem;
|
|
154
|
+
font-weight: 600;
|
|
155
|
+
padding: 4px 10px;
|
|
156
|
+
border: 1px dashed var(--fk-color-border);
|
|
157
|
+
border-radius: calc(var(--fk-radius) / 2);
|
|
158
|
+
background: transparent;
|
|
159
|
+
color: var(--fk-color-muted);
|
|
160
|
+
cursor: pointer;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.fk-rule__add:hover {
|
|
164
|
+
border-color: var(--fk-color-primary);
|
|
165
|
+
color: var(--fk-color-primary);
|
|
166
|
+
}
|