@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,356 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
import { evalBrickCode, services } from "@streamline-pulse/formkrafter-core";
|
|
3
|
+
import { normalizeOptions } from "../../utils/options";
|
|
4
|
+
import { appendSearchParam, interpolateTemplate, parseHeaderLines, } from "../../utils/remote";
|
|
5
|
+
import { fkT } from "../../i18n/i18n";
|
|
6
|
+
export class FkSelectInput {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.disabled = false;
|
|
9
|
+
this.multiple = false;
|
|
10
|
+
this.open = false;
|
|
11
|
+
this.query = '';
|
|
12
|
+
this.remoteOptions = [];
|
|
13
|
+
this.outsideClick = (event) => {
|
|
14
|
+
if (!this.host.contains(event.target))
|
|
15
|
+
this.close();
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
componentWillLoad() {
|
|
19
|
+
return this.resolveRemote();
|
|
20
|
+
}
|
|
21
|
+
disconnectedCallback() {
|
|
22
|
+
this.unbindOutsideClick();
|
|
23
|
+
}
|
|
24
|
+
onConfigsChange() {
|
|
25
|
+
this.resolveRemote();
|
|
26
|
+
}
|
|
27
|
+
onDataMapChange() {
|
|
28
|
+
this.resolveRemote();
|
|
29
|
+
}
|
|
30
|
+
searchParam() {
|
|
31
|
+
var _a;
|
|
32
|
+
return ((_a = this.configs) === null || _a === void 0 ? void 0 : _a.searchParam) || undefined;
|
|
33
|
+
}
|
|
34
|
+
remoteUrl() {
|
|
35
|
+
var _a;
|
|
36
|
+
const raw = (_a = this.configs) === null || _a === void 0 ? void 0 : _a.optionsUrl;
|
|
37
|
+
if (!raw)
|
|
38
|
+
return undefined;
|
|
39
|
+
let url = interpolateTemplate(raw, this.dataMap);
|
|
40
|
+
const param = this.searchParam();
|
|
41
|
+
if (param)
|
|
42
|
+
url = appendSearchParam(url, param, this.query.trim());
|
|
43
|
+
return url;
|
|
44
|
+
}
|
|
45
|
+
bindOutsideClick() {
|
|
46
|
+
document.addEventListener('mousedown', this.outsideClick);
|
|
47
|
+
}
|
|
48
|
+
unbindOutsideClick() {
|
|
49
|
+
document.removeEventListener('mousedown', this.outsideClick);
|
|
50
|
+
}
|
|
51
|
+
toggleOpen() {
|
|
52
|
+
if (this.disabled)
|
|
53
|
+
return;
|
|
54
|
+
if (this.open)
|
|
55
|
+
this.close();
|
|
56
|
+
else {
|
|
57
|
+
this.open = true;
|
|
58
|
+
this.query = '';
|
|
59
|
+
this.bindOutsideClick();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
close() {
|
|
63
|
+
this.open = false;
|
|
64
|
+
this.unbindOutsideClick();
|
|
65
|
+
}
|
|
66
|
+
source() {
|
|
67
|
+
var _a, _b;
|
|
68
|
+
return (_b = (_a = this.configs) === null || _a === void 0 ? void 0 : _a.optionsSource) !== null && _b !== void 0 ? _b : 'static';
|
|
69
|
+
}
|
|
70
|
+
async resolveRemote(force = false) {
|
|
71
|
+
var _a;
|
|
72
|
+
if (this.source() !== 'remote')
|
|
73
|
+
return;
|
|
74
|
+
const url = this.remoteUrl();
|
|
75
|
+
if (!url) {
|
|
76
|
+
this.remoteOptions = [];
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const headers = parseHeaderLines((_a = this.configs) === null || _a === void 0 ? void 0 : _a.optionsHeaders, this.dataMap);
|
|
80
|
+
const signature = `${url}|${JSON.stringify(headers !== null && headers !== void 0 ? headers : {})}`;
|
|
81
|
+
if (!force && signature === this.lastRemoteSignature)
|
|
82
|
+
return;
|
|
83
|
+
this.lastRemoteSignature = signature;
|
|
84
|
+
try {
|
|
85
|
+
this.remoteError = undefined;
|
|
86
|
+
this.remoteOptions = await services.dataSourceService.fetchOptions(url, headers ? { headers } : undefined);
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
this.remoteOptions = [];
|
|
90
|
+
this.remoteError = error instanceof Error ? error.message : String(error);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
onSearchInput(value) {
|
|
94
|
+
this.query = value;
|
|
95
|
+
if (this.source() !== 'remote' || !this.searchParam())
|
|
96
|
+
return;
|
|
97
|
+
if (this.searchTimer)
|
|
98
|
+
clearTimeout(this.searchTimer);
|
|
99
|
+
this.searchTimer = setTimeout(() => this.resolveRemote(), 250);
|
|
100
|
+
}
|
|
101
|
+
resolve() {
|
|
102
|
+
var _a, _b, _c, _d, _e, _f;
|
|
103
|
+
const labelKey = ((_a = this.configs) === null || _a === void 0 ? void 0 : _a.labelKey) || undefined;
|
|
104
|
+
const valueKey = ((_b = this.configs) === null || _b === void 0 ? void 0 : _b.valueKey) || undefined;
|
|
105
|
+
switch (this.source()) {
|
|
106
|
+
case 'remote':
|
|
107
|
+
return {
|
|
108
|
+
options: normalizeOptions(this.remoteOptions, labelKey, valueKey),
|
|
109
|
+
error: this.remoteError,
|
|
110
|
+
};
|
|
111
|
+
case 'dataMap': {
|
|
112
|
+
const path = (_c = this.configs) === null || _c === void 0 ? void 0 : _c.optionsPath;
|
|
113
|
+
return {
|
|
114
|
+
options: normalizeOptions(path ? (_d = this.dataMap) === null || _d === void 0 ? void 0 : _d[path] : [], labelKey, valueKey),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
case 'js': {
|
|
118
|
+
const code = (_e = this.configs) === null || _e === void 0 ? void 0 : _e.optionsCode;
|
|
119
|
+
if (!code)
|
|
120
|
+
return { options: [] };
|
|
121
|
+
const result = evalBrickCode(code, this.dataMap);
|
|
122
|
+
if (result instanceof Error) {
|
|
123
|
+
return { options: [], error: result.message };
|
|
124
|
+
}
|
|
125
|
+
return { options: normalizeOptions(result, labelKey, valueKey) };
|
|
126
|
+
}
|
|
127
|
+
default:
|
|
128
|
+
return {
|
|
129
|
+
options: normalizeOptions((_f = this.configs) === null || _f === void 0 ? void 0 : _f.options, labelKey, valueKey),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
selectedValues() {
|
|
134
|
+
if (this.multiple) {
|
|
135
|
+
return Array.isArray(this.value) ? this.value : [];
|
|
136
|
+
}
|
|
137
|
+
return typeof this.value === 'string' && this.value !== '' ? [this.value] : [];
|
|
138
|
+
}
|
|
139
|
+
labelOf(value, options) {
|
|
140
|
+
var _a, _b;
|
|
141
|
+
return (_b = (_a = options.find((option) => option.value === value)) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : value;
|
|
142
|
+
}
|
|
143
|
+
pick(option) {
|
|
144
|
+
if (this.multiple) {
|
|
145
|
+
const selected = this.selectedValues();
|
|
146
|
+
const next = selected.includes(option.value)
|
|
147
|
+
? selected.filter((value) => value !== option.value)
|
|
148
|
+
: [...selected, option.value];
|
|
149
|
+
this.selectValueChange.emit(next.length ? next : undefined);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
this.selectValueChange.emit(option.value);
|
|
153
|
+
this.close();
|
|
154
|
+
}
|
|
155
|
+
unpick(value) {
|
|
156
|
+
const next = this.selectedValues().filter((entry) => entry !== value);
|
|
157
|
+
this.selectValueChange.emit(next.length ? next : undefined);
|
|
158
|
+
}
|
|
159
|
+
filteredOptions(options) {
|
|
160
|
+
if (this.source() === 'remote' && this.searchParam())
|
|
161
|
+
return options;
|
|
162
|
+
const query = this.query.trim().toLowerCase();
|
|
163
|
+
if (!query)
|
|
164
|
+
return options;
|
|
165
|
+
return options.filter((option) => option.label.toLowerCase().includes(query));
|
|
166
|
+
}
|
|
167
|
+
render() {
|
|
168
|
+
var _a, _b;
|
|
169
|
+
const { options, error } = this.resolve();
|
|
170
|
+
const selected = this.selectedValues();
|
|
171
|
+
const filtered = this.filteredOptions(options);
|
|
172
|
+
return (h("div", { key: '85d53f13df0d06af139fd666e2c81c1cae51080a', class: { 'fk-select': true, 'fk-select--disabled': this.disabled } }, h("div", { key: '2b91528a8584a4437b4a4d873276feb8a5126b1e', class: { 'fk-select__trigger': true, 'fk-select__trigger--open': this.open }, onClick: (event) => {
|
|
173
|
+
event.preventDefault();
|
|
174
|
+
this.toggleOpen();
|
|
175
|
+
} }, h("div", { key: 'bc0dafdb3b3aec4ad2f90fc57a59cae953dc5f16', class: "fk-select__values" }, selected.length === 0 ? (h("span", { class: "fk-select__placeholder" }, String((_b = (_a = this.configs) === null || _a === void 0 ? void 0 : _a.placeholder) !== null && _b !== void 0 ? _b : ''))) : this.multiple ? (selected.map((value) => (h("span", { class: "fk-select__chip", key: value }, this.labelOf(value, options), h("button", { type: "button", class: "fk-select__chip-remove", disabled: this.disabled, onClick: (event) => {
|
|
176
|
+
event.preventDefault();
|
|
177
|
+
event.stopPropagation();
|
|
178
|
+
this.unpick(value);
|
|
179
|
+
} }, "\u2715"))))) : (h("span", { class: "fk-select__value" }, this.labelOf(selected[0], options)))), !this.multiple && selected.length > 0 && !this.disabled ? (h("button", { type: "button", class: "fk-select__clear", title: fkT('select.clear'), onClick: (event) => {
|
|
180
|
+
event.preventDefault();
|
|
181
|
+
event.stopPropagation();
|
|
182
|
+
this.selectValueChange.emit(undefined);
|
|
183
|
+
} }, "\u2715")) : null, h("span", { key: '4b254a05b0a0f92171fc4ead179f407f5dbe0fd1', class: "fk-select__caret" }, "\u25BE")), this.open ? (h("div", { class: "fk-select__dropdown" }, h("input", { class: "fk-select__search", type: "text", placeholder: fkT('select.search'), value: this.query, ref: (element) => setTimeout(() => element === null || element === void 0 ? void 0 : element.focus(), 0), onInput: (event) => this.onSearchInput(event.target.value), onKeyDown: (event) => {
|
|
184
|
+
if (event.key === 'Escape')
|
|
185
|
+
this.close();
|
|
186
|
+
if (event.key === 'Enter' && filtered.length > 0) {
|
|
187
|
+
event.preventDefault();
|
|
188
|
+
this.pick(filtered[0]);
|
|
189
|
+
}
|
|
190
|
+
} }), h("div", { class: "fk-select__options", role: "listbox" }, filtered.map((option) => {
|
|
191
|
+
const isSelected = selected.includes(option.value);
|
|
192
|
+
return (h("div", { key: option.value, role: "option", "aria-selected": isSelected ? 'true' : 'false', class: {
|
|
193
|
+
'fk-select__option': true,
|
|
194
|
+
'fk-select__option--selected': isSelected,
|
|
195
|
+
}, onClick: (event) => {
|
|
196
|
+
event.preventDefault();
|
|
197
|
+
this.pick(option);
|
|
198
|
+
} }, h("span", { class: "fk-select__option-label" }, option.label), isSelected ? h("span", { class: "fk-select__check" }, "\u2713") : null));
|
|
199
|
+
}), filtered.length === 0 ? (h("p", { class: "fk-select__empty" }, fkT('select.empty'))) : null))) : null, error ? h("span", { class: "fk-field__error" }, error) : null));
|
|
200
|
+
}
|
|
201
|
+
static get is() { return "fk-select-input"; }
|
|
202
|
+
static get encapsulation() { return "scoped"; }
|
|
203
|
+
static get originalStyleUrls() {
|
|
204
|
+
return {
|
|
205
|
+
"$": ["fk-select-input.css"]
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
static get styleUrls() {
|
|
209
|
+
return {
|
|
210
|
+
"$": ["fk-select-input.css"]
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
static get properties() {
|
|
214
|
+
return {
|
|
215
|
+
"configs": {
|
|
216
|
+
"type": "unknown",
|
|
217
|
+
"mutable": false,
|
|
218
|
+
"complexType": {
|
|
219
|
+
"original": "Record<string, unknown>",
|
|
220
|
+
"resolved": "string | unknown",
|
|
221
|
+
"references": {
|
|
222
|
+
"Record": {
|
|
223
|
+
"location": "global",
|
|
224
|
+
"id": "global::Record"
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
"required": false,
|
|
229
|
+
"optional": true,
|
|
230
|
+
"docs": {
|
|
231
|
+
"tags": [],
|
|
232
|
+
"text": ""
|
|
233
|
+
},
|
|
234
|
+
"getter": false,
|
|
235
|
+
"setter": false
|
|
236
|
+
},
|
|
237
|
+
"value": {
|
|
238
|
+
"type": "string",
|
|
239
|
+
"mutable": false,
|
|
240
|
+
"complexType": {
|
|
241
|
+
"original": "string | string[]",
|
|
242
|
+
"resolved": "string | string[]",
|
|
243
|
+
"references": {}
|
|
244
|
+
},
|
|
245
|
+
"required": false,
|
|
246
|
+
"optional": true,
|
|
247
|
+
"docs": {
|
|
248
|
+
"tags": [],
|
|
249
|
+
"text": ""
|
|
250
|
+
},
|
|
251
|
+
"getter": false,
|
|
252
|
+
"setter": false,
|
|
253
|
+
"reflect": false,
|
|
254
|
+
"attribute": "value"
|
|
255
|
+
},
|
|
256
|
+
"disabled": {
|
|
257
|
+
"type": "boolean",
|
|
258
|
+
"mutable": false,
|
|
259
|
+
"complexType": {
|
|
260
|
+
"original": "boolean",
|
|
261
|
+
"resolved": "boolean",
|
|
262
|
+
"references": {}
|
|
263
|
+
},
|
|
264
|
+
"required": false,
|
|
265
|
+
"optional": false,
|
|
266
|
+
"docs": {
|
|
267
|
+
"tags": [],
|
|
268
|
+
"text": ""
|
|
269
|
+
},
|
|
270
|
+
"getter": false,
|
|
271
|
+
"setter": false,
|
|
272
|
+
"reflect": false,
|
|
273
|
+
"attribute": "disabled",
|
|
274
|
+
"defaultValue": "false"
|
|
275
|
+
},
|
|
276
|
+
"multiple": {
|
|
277
|
+
"type": "boolean",
|
|
278
|
+
"mutable": false,
|
|
279
|
+
"complexType": {
|
|
280
|
+
"original": "boolean",
|
|
281
|
+
"resolved": "boolean",
|
|
282
|
+
"references": {}
|
|
283
|
+
},
|
|
284
|
+
"required": false,
|
|
285
|
+
"optional": false,
|
|
286
|
+
"docs": {
|
|
287
|
+
"tags": [],
|
|
288
|
+
"text": ""
|
|
289
|
+
},
|
|
290
|
+
"getter": false,
|
|
291
|
+
"setter": false,
|
|
292
|
+
"reflect": false,
|
|
293
|
+
"attribute": "multiple",
|
|
294
|
+
"defaultValue": "false"
|
|
295
|
+
},
|
|
296
|
+
"dataMap": {
|
|
297
|
+
"type": "unknown",
|
|
298
|
+
"mutable": false,
|
|
299
|
+
"complexType": {
|
|
300
|
+
"original": "Record<string, unknown>",
|
|
301
|
+
"resolved": "string | unknown",
|
|
302
|
+
"references": {
|
|
303
|
+
"Record": {
|
|
304
|
+
"location": "global",
|
|
305
|
+
"id": "global::Record"
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
"required": false,
|
|
310
|
+
"optional": true,
|
|
311
|
+
"docs": {
|
|
312
|
+
"tags": [],
|
|
313
|
+
"text": ""
|
|
314
|
+
},
|
|
315
|
+
"getter": false,
|
|
316
|
+
"setter": false
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
static get states() {
|
|
321
|
+
return {
|
|
322
|
+
"open": {},
|
|
323
|
+
"query": {},
|
|
324
|
+
"remoteOptions": {},
|
|
325
|
+
"remoteError": {}
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
static get events() {
|
|
329
|
+
return [{
|
|
330
|
+
"method": "selectValueChange",
|
|
331
|
+
"name": "selectValueChange",
|
|
332
|
+
"bubbles": true,
|
|
333
|
+
"cancelable": true,
|
|
334
|
+
"composed": true,
|
|
335
|
+
"docs": {
|
|
336
|
+
"tags": [],
|
|
337
|
+
"text": ""
|
|
338
|
+
},
|
|
339
|
+
"complexType": {
|
|
340
|
+
"original": "string | string[] | undefined",
|
|
341
|
+
"resolved": "string | string[]",
|
|
342
|
+
"references": {}
|
|
343
|
+
}
|
|
344
|
+
}];
|
|
345
|
+
}
|
|
346
|
+
static get elementRef() { return "host"; }
|
|
347
|
+
static get watchers() {
|
|
348
|
+
return [{
|
|
349
|
+
"propName": "configs",
|
|
350
|
+
"methodName": "onConfigsChange"
|
|
351
|
+
}, {
|
|
352
|
+
"propName": "dataMap",
|
|
353
|
+
"methodName": "onDataMapChange"
|
|
354
|
+
}];
|
|
355
|
+
}
|
|
356
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.fk-signature {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
gap: calc(var(--fk-spacing) / 2);
|
|
9
|
+
align-items: flex-start;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.fk-signature__canvas {
|
|
13
|
+
width: 100%;
|
|
14
|
+
max-width: 480px;
|
|
15
|
+
border: 1px dashed var(--fk-color-border);
|
|
16
|
+
border-radius: var(--fk-radius);
|
|
17
|
+
background: var(--fk-color-surface);
|
|
18
|
+
color: var(--fk-color-text);
|
|
19
|
+
touch-action: none;
|
|
20
|
+
cursor: crosshair;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.fk-signature--disabled .fk-signature__canvas {
|
|
24
|
+
cursor: not-allowed;
|
|
25
|
+
opacity: 0.6;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.fk-signature__clear {
|
|
29
|
+
font: inherit;
|
|
30
|
+
font-size: 0.75rem;
|
|
31
|
+
padding: 3px 10px;
|
|
32
|
+
border: 1px solid var(--fk-color-border);
|
|
33
|
+
border-radius: calc(var(--fk-radius) / 2);
|
|
34
|
+
background: transparent;
|
|
35
|
+
color: var(--fk-color-muted);
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.fk-signature__clear:hover:not(:disabled) {
|
|
40
|
+
color: var(--fk-color-danger);
|
|
41
|
+
border-color: var(--fk-color-danger);
|
|
42
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
import { fkT } from "../../i18n/i18n";
|
|
3
|
+
export class FkSignatureInput {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.disabled = false;
|
|
6
|
+
this.drawing = false;
|
|
7
|
+
this.start = (event) => {
|
|
8
|
+
if (this.disabled || !this.canvas)
|
|
9
|
+
return;
|
|
10
|
+
this.drawing = true;
|
|
11
|
+
this.canvas.setPointerCapture(event.pointerId);
|
|
12
|
+
const ctx = this.context();
|
|
13
|
+
if (!ctx)
|
|
14
|
+
return;
|
|
15
|
+
ctx.lineWidth = 2;
|
|
16
|
+
ctx.lineCap = 'round';
|
|
17
|
+
ctx.strokeStyle = getComputedStyle(this.canvas).color;
|
|
18
|
+
ctx.beginPath();
|
|
19
|
+
ctx.moveTo(...this.position(event));
|
|
20
|
+
};
|
|
21
|
+
this.move = (event) => {
|
|
22
|
+
if (!this.drawing)
|
|
23
|
+
return;
|
|
24
|
+
const ctx = this.context();
|
|
25
|
+
if (!ctx)
|
|
26
|
+
return;
|
|
27
|
+
ctx.lineTo(...this.position(event));
|
|
28
|
+
ctx.stroke();
|
|
29
|
+
};
|
|
30
|
+
this.end = () => {
|
|
31
|
+
if (!this.drawing || !this.canvas)
|
|
32
|
+
return;
|
|
33
|
+
this.drawing = false;
|
|
34
|
+
this.lastEmitted = this.canvas.toDataURL('image/png');
|
|
35
|
+
this.signatureChange.emit(this.lastEmitted);
|
|
36
|
+
};
|
|
37
|
+
this.clear = () => {
|
|
38
|
+
const ctx = this.context();
|
|
39
|
+
if (!ctx || !this.canvas)
|
|
40
|
+
return;
|
|
41
|
+
ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
42
|
+
this.lastEmitted = undefined;
|
|
43
|
+
this.signatureChange.emit(undefined);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
componentDidLoad() {
|
|
47
|
+
this.restore();
|
|
48
|
+
}
|
|
49
|
+
onValueChange(next) {
|
|
50
|
+
if (next === this.lastEmitted)
|
|
51
|
+
return;
|
|
52
|
+
this.restore();
|
|
53
|
+
}
|
|
54
|
+
context() {
|
|
55
|
+
var _a, _b;
|
|
56
|
+
return (_b = (_a = this.canvas) === null || _a === void 0 ? void 0 : _a.getContext('2d')) !== null && _b !== void 0 ? _b : undefined;
|
|
57
|
+
}
|
|
58
|
+
restore() {
|
|
59
|
+
const ctx = this.context();
|
|
60
|
+
if (!ctx || !this.canvas)
|
|
61
|
+
return;
|
|
62
|
+
ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
63
|
+
if (!this.value)
|
|
64
|
+
return;
|
|
65
|
+
const image = new Image();
|
|
66
|
+
image.onload = () => ctx.drawImage(image, 0, 0);
|
|
67
|
+
image.src = this.value;
|
|
68
|
+
}
|
|
69
|
+
position(event) {
|
|
70
|
+
const rect = this.canvas.getBoundingClientRect();
|
|
71
|
+
return [
|
|
72
|
+
((event.clientX - rect.left) * this.canvas.width) / rect.width,
|
|
73
|
+
((event.clientY - rect.top) * this.canvas.height) / rect.height,
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
render() {
|
|
77
|
+
return (h("div", { key: 'e81687b01b30d71794b09cae1eb2215cc10a894f', class: { 'fk-signature': true, 'fk-signature--disabled': this.disabled } }, h("canvas", { key: '9a1031b1c89ee5c9d3ab465b06433125eaa7ee8c', class: "fk-signature__canvas", width: 480, height: 140, ref: (element) => (this.canvas = element), onPointerDown: this.start, onPointerMove: this.move, onPointerUp: this.end, onPointerLeave: this.end }), h("button", { key: '09e36234ffbd7367b65596a1eadf3cb019aeedad', type: "button", class: "fk-signature__clear", disabled: this.disabled, onClick: this.clear }, fkT('signature.clear'))));
|
|
78
|
+
}
|
|
79
|
+
static get is() { return "fk-signature-input"; }
|
|
80
|
+
static get encapsulation() { return "scoped"; }
|
|
81
|
+
static get originalStyleUrls() {
|
|
82
|
+
return {
|
|
83
|
+
"$": ["fk-signature-input.css"]
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
static get styleUrls() {
|
|
87
|
+
return {
|
|
88
|
+
"$": ["fk-signature-input.css"]
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
static get properties() {
|
|
92
|
+
return {
|
|
93
|
+
"value": {
|
|
94
|
+
"type": "string",
|
|
95
|
+
"mutable": false,
|
|
96
|
+
"complexType": {
|
|
97
|
+
"original": "string",
|
|
98
|
+
"resolved": "string",
|
|
99
|
+
"references": {}
|
|
100
|
+
},
|
|
101
|
+
"required": false,
|
|
102
|
+
"optional": true,
|
|
103
|
+
"docs": {
|
|
104
|
+
"tags": [],
|
|
105
|
+
"text": ""
|
|
106
|
+
},
|
|
107
|
+
"getter": false,
|
|
108
|
+
"setter": false,
|
|
109
|
+
"reflect": false,
|
|
110
|
+
"attribute": "value"
|
|
111
|
+
},
|
|
112
|
+
"disabled": {
|
|
113
|
+
"type": "boolean",
|
|
114
|
+
"mutable": false,
|
|
115
|
+
"complexType": {
|
|
116
|
+
"original": "boolean",
|
|
117
|
+
"resolved": "boolean",
|
|
118
|
+
"references": {}
|
|
119
|
+
},
|
|
120
|
+
"required": false,
|
|
121
|
+
"optional": false,
|
|
122
|
+
"docs": {
|
|
123
|
+
"tags": [],
|
|
124
|
+
"text": ""
|
|
125
|
+
},
|
|
126
|
+
"getter": false,
|
|
127
|
+
"setter": false,
|
|
128
|
+
"reflect": false,
|
|
129
|
+
"attribute": "disabled",
|
|
130
|
+
"defaultValue": "false"
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
static get events() {
|
|
135
|
+
return [{
|
|
136
|
+
"method": "signatureChange",
|
|
137
|
+
"name": "signatureChange",
|
|
138
|
+
"bubbles": true,
|
|
139
|
+
"cancelable": true,
|
|
140
|
+
"composed": true,
|
|
141
|
+
"docs": {
|
|
142
|
+
"tags": [],
|
|
143
|
+
"text": ""
|
|
144
|
+
},
|
|
145
|
+
"complexType": {
|
|
146
|
+
"original": "string | undefined",
|
|
147
|
+
"resolved": "string",
|
|
148
|
+
"references": {}
|
|
149
|
+
}
|
|
150
|
+
}];
|
|
151
|
+
}
|
|
152
|
+
static get watchers() {
|
|
153
|
+
return [{
|
|
154
|
+
"propName": "value",
|
|
155
|
+
"methodName": "onValueChange"
|
|
156
|
+
}];
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.fk-stepper {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
gap: var(--fk-spacing);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.fk-stepper__nav {
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-wrap: wrap;
|
|
14
|
+
gap: calc(var(--fk-spacing) * 1.5);
|
|
15
|
+
margin: 0;
|
|
16
|
+
padding: 0 0 var(--fk-spacing);
|
|
17
|
+
list-style: none;
|
|
18
|
+
border-bottom: 1px solid var(--fk-color-border);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.fk-stepper__step {
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
gap: calc(var(--fk-spacing) / 2);
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
color: var(--fk-color-muted);
|
|
27
|
+
font-size: 0.85rem;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.fk-stepper__index {
|
|
31
|
+
display: inline-flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
width: 22px;
|
|
35
|
+
height: 22px;
|
|
36
|
+
border-radius: 50%;
|
|
37
|
+
border: 1px solid var(--fk-color-border);
|
|
38
|
+
font-size: 0.72rem;
|
|
39
|
+
font-weight: 700;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.fk-stepper__step--active {
|
|
43
|
+
color: var(--fk-color-text);
|
|
44
|
+
font-weight: 600;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.fk-stepper__step--active .fk-stepper__index {
|
|
48
|
+
border-color: var(--fk-color-primary);
|
|
49
|
+
background: var(--fk-color-primary);
|
|
50
|
+
color: #ffffff;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.fk-stepper__step--done .fk-stepper__index {
|
|
54
|
+
border-color: var(--fk-color-primary);
|
|
55
|
+
color: var(--fk-color-primary);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.fk-stepper__actions {
|
|
59
|
+
display: flex;
|
|
60
|
+
justify-content: space-between;
|
|
61
|
+
padding-top: var(--fk-spacing);
|
|
62
|
+
border-top: 1px solid var(--fk-color-border);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.fk-stepper__button {
|
|
66
|
+
font: inherit;
|
|
67
|
+
font-size: 0.85rem;
|
|
68
|
+
padding: calc(var(--fk-spacing) / 1.5) calc(var(--fk-spacing) * 1.5);
|
|
69
|
+
border: 1px solid var(--fk-color-border);
|
|
70
|
+
border-radius: var(--fk-radius);
|
|
71
|
+
background: var(--fk-color-surface);
|
|
72
|
+
color: var(--fk-color-text);
|
|
73
|
+
cursor: pointer;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.fk-stepper__button--primary {
|
|
77
|
+
border-color: var(--fk-color-primary);
|
|
78
|
+
background: var(--fk-color-primary);
|
|
79
|
+
color: #ffffff;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.fk-stepper__button:disabled {
|
|
83
|
+
opacity: 0.45;
|
|
84
|
+
cursor: not-allowed;
|
|
85
|
+
}
|