@streamline-pulse/formkrafter-wc 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/README.md +10 -8
  2. package/dist/components/fk-brick-actions.js +1 -1
  3. package/dist/components/fk-brick-list.js +1 -1
  4. package/dist/components/fk-brick-mold-item.js +1 -1
  5. package/dist/components/fk-brick-render.js +1 -1
  6. package/dist/components/fk-code-editor.js +1 -1
  7. package/dist/components/fk-data-grid.js +1 -1
  8. package/dist/components/fk-drop-area.js +1 -1
  9. package/dist/components/fk-empty-form.js +1 -1
  10. package/dist/components/fk-file-input.js +1 -1
  11. package/dist/components/fk-form-builder.js +1 -1
  12. package/dist/components/fk-form-render.js +1 -1
  13. package/dist/components/fk-property-panel.js +1 -1
  14. package/dist/components/fk-rules-editor.js +1 -1
  15. package/dist/components/fk-select-input.js +1 -1
  16. package/dist/components/fk-signature-input.js +1 -1
  17. package/dist/components/fk-stepper.js +1 -1
  18. package/dist/components/fk-tabs.js +1 -1
  19. package/dist/components/index.js +1 -1
  20. package/dist/components/{p-CKMHMpID.js → p-28GBFlUX.js} +4 -4
  21. package/dist/components/{p-D6n74M9d.js → p-BGxmFcpL.js} +1 -1
  22. package/dist/components/{p-DYchD23x.js → p-BInUBjyw.js} +1 -1
  23. package/dist/{formkrafter-wc/p-C-wnqV3i.js → components/p-BietHxaT.js} +1 -1
  24. package/dist/components/{p-fDJP6whN.js → p-BnzSarwW.js} +1 -1
  25. package/dist/components/p-BpkKcCCr.js +1 -0
  26. package/dist/components/p-C0Y8qh8R.js +1 -0
  27. package/dist/components/p-C5OWoRhO.js +1 -0
  28. package/dist/components/{p-wuC5rVU7.js → p-CKs1CWVz.js} +1 -1
  29. package/dist/components/{p-v7LxwCAc.js → p-CZHykCYD.js} +1 -1
  30. package/dist/components/{p-4COASNrZ.js → p-CehxuHtl.js} +1 -1
  31. package/dist/components/p-CqVSd56Z.js +1 -0
  32. package/dist/components/p-CyZA17qf.js +1 -0
  33. package/dist/components/{p-BGkZP87K.js → p-D4HhZxQ-.js} +1 -1
  34. package/dist/components/p-DC6Wxbnz.js +1 -0
  35. package/dist/components/p-DRNycSdI.js +1 -0
  36. package/dist/components/{p--vL6GR31.js → p-Dh5Z49YD.js} +1 -1
  37. package/dist/components/p-DiOstAi9.js +1 -0
  38. package/dist/components/p-DlqnIm46.js +1 -0
  39. package/dist/components/{p-CIfjRTky.js → p-DshUS8Zm.js} +1 -1
  40. package/dist/components/{p-DMCkrZqi.js → p-RzeBwfwG.js} +1 -1
  41. package/dist/components/{p-BWdm2a6q.js → p-ajy8ZcBX.js} +1 -1
  42. package/dist/components/p-kYG3E0GQ.js +1 -0
  43. package/dist/components/p-tTJg_I4V.js +1 -0
  44. package/dist/formkrafter-wc/formkrafter-wc.css +1 -1
  45. package/dist/formkrafter-wc/formkrafter-wc.esm.js +1 -1
  46. package/dist/formkrafter-wc/index.esm.js +1 -1
  47. package/dist/formkrafter-wc/p-3579150a.entry.js +1 -0
  48. package/dist/formkrafter-wc/p-8b0ff66e.entry.js +1 -0
  49. package/dist/formkrafter-wc/p-BHZMDq2e.js +1 -0
  50. package/dist/{components/p-C-wnqV3i.js → formkrafter-wc/p-BietHxaT.js} +1 -1
  51. package/dist/formkrafter-wc/p-C0Y8qh8R.js +1 -0
  52. package/dist/formkrafter-wc/{p-4COASNrZ.js → p-CehxuHtl.js} +1 -1
  53. package/dist/formkrafter-wc/p-DlqnIm46.js +1 -0
  54. package/dist/formkrafter-wc/{p-DMCkrZqi.js → p-RzeBwfwG.js} +1 -1
  55. package/dist/formkrafter-wc/p-WWmY5Z05.js +1 -0
  56. package/dist/formkrafter-wc/p-hcT25XX4.js +12 -0
  57. package/dist/types/components/fk-code-editor/fk-code-editor.d.ts +1 -0
  58. package/dist/types/components/fk-data-grid/fk-data-grid.d.ts +1 -0
  59. package/dist/types/components/fk-drop-area/fk-drop-area.d.ts +1 -0
  60. package/dist/types/components/fk-form-render/fk-form-render.d.ts +7 -1
  61. package/dist/types/components.d.ts +17 -0
  62. package/dist/types/index.d.ts +1 -1
  63. package/dist/types/registry/default-bricks.d.ts +36 -0
  64. package/dist/types/utils/mask.d.ts +1 -0
  65. package/package.json +10 -15
  66. package/dist/cjs/app-globals-V2Kpy_OQ.js +0 -5
  67. package/dist/cjs/fk-brick-actions_18.cjs.entry.js +0 -4224
  68. package/dist/cjs/formkrafter-wc.cjs.js +0 -25
  69. package/dist/cjs/index-Bhy1RJMV.js +0 -3042
  70. package/dist/cjs/index-CImTe9BG.js +0 -2126
  71. package/dist/cjs/index-CdaT3-qx.js +0 -5444
  72. package/dist/cjs/index-CkPPRg03.js +0 -17548
  73. package/dist/cjs/index-DHgK3reD.js +0 -12233
  74. package/dist/cjs/index-Ds0sDbXV.js +0 -4019
  75. package/dist/cjs/index-c9BL7y3N.js +0 -1922
  76. package/dist/cjs/index.cjs.js +0 -48
  77. package/dist/cjs/loader.cjs.js +0 -13
  78. package/dist/collection/collection-manifest.json +0 -30
  79. package/dist/collection/components/fk-brick-actions/fk-brick-actions.css +0 -78
  80. package/dist/collection/components/fk-brick-actions/fk-brick-actions.js +0 -215
  81. package/dist/collection/components/fk-brick-list/fk-brick-list.css +0 -71
  82. package/dist/collection/components/fk-brick-list/fk-brick-list.js +0 -55
  83. package/dist/collection/components/fk-brick-mold-item/fk-brick-mold-item.css +0 -33
  84. package/dist/collection/components/fk-brick-mold-item/fk-brick-mold-item.js +0 -73
  85. package/dist/collection/components/fk-brick-not-found/fk-brick-not-found.css +0 -8
  86. package/dist/collection/components/fk-brick-not-found/fk-brick-not-found.js +0 -18
  87. package/dist/collection/components/fk-brick-render/fk-brick-render.js +0 -447
  88. package/dist/collection/components/fk-code-editor/fk-code-editor.css +0 -26
  89. package/dist/collection/components/fk-code-editor/fk-code-editor.js +0 -145
  90. package/dist/collection/components/fk-data-grid/fk-data-grid.css +0 -75
  91. package/dist/collection/components/fk-data-grid/fk-data-grid.js +0 -300
  92. package/dist/collection/components/fk-drop-area/fk-drop-area.css +0 -18
  93. package/dist/collection/components/fk-drop-area/fk-drop-area.js +0 -98
  94. package/dist/collection/components/fk-empty-form/fk-empty-form.css +0 -22
  95. package/dist/collection/components/fk-empty-form/fk-empty-form.js +0 -19
  96. package/dist/collection/components/fk-file-input/fk-file-input.css +0 -95
  97. package/dist/collection/components/fk-file-input/fk-file-input.js +0 -239
  98. package/dist/collection/components/fk-form-builder/fk-form-builder.css +0 -112
  99. package/dist/collection/components/fk-form-builder/fk-form-builder.js +0 -431
  100. package/dist/collection/components/fk-form-render/fk-form-render.css +0 -7
  101. package/dist/collection/components/fk-form-render/fk-form-render.js +0 -352
  102. package/dist/collection/components/fk-property-panel/fk-property-panel.css +0 -153
  103. package/dist/collection/components/fk-property-panel/fk-property-panel.js +0 -388
  104. package/dist/collection/components/fk-rules-editor/fk-rules-editor.css +0 -166
  105. package/dist/collection/components/fk-rules-editor/fk-rules-editor.js +0 -250
  106. package/dist/collection/components/fk-select-input/fk-select-input.css +0 -153
  107. package/dist/collection/components/fk-select-input/fk-select-input.js +0 -454
  108. package/dist/collection/components/fk-signature-input/fk-signature-input.css +0 -42
  109. package/dist/collection/components/fk-signature-input/fk-signature-input.js +0 -158
  110. package/dist/collection/components/fk-stepper/fk-stepper.css +0 -99
  111. package/dist/collection/components/fk-stepper/fk-stepper.js +0 -285
  112. package/dist/collection/components/fk-tabs/fk-tabs.css +0 -38
  113. package/dist/collection/components/fk-tabs/fk-tabs.js +0 -249
  114. package/dist/collection/i18n/i18n.js +0 -265
  115. package/dist/collection/index.js +0 -5
  116. package/dist/collection/registry/create-brick.js +0 -34
  117. package/dist/collection/registry/default-bricks.js +0 -564
  118. package/dist/collection/registry/registry.js +0 -44
  119. package/dist/collection/utils/brick-data.js +0 -16
  120. package/dist/collection/utils/drop.js +0 -14
  121. package/dist/collection/utils/events.js +0 -1
  122. package/dist/collection/utils/options.js +0 -21
  123. package/dist/collection/utils/remote.js +0 -27
  124. package/dist/collection/utils/rule-condition.js +0 -72
  125. package/dist/collection/utils/style.js +0 -11
  126. package/dist/components/p-BOmBVgfJ.js +0 -1
  127. package/dist/components/p-B_-x-GlA.js +0 -1
  128. package/dist/components/p-Br1s4Ujx.js +0 -1
  129. package/dist/components/p-CUF31e-P.js +0 -1
  130. package/dist/components/p-CWQX0sXS.js +0 -1
  131. package/dist/components/p-DFe3zZCI.js +0 -1
  132. package/dist/components/p-DOInQkG6.js +0 -1
  133. package/dist/components/p-PAr7WoWG.js +0 -1
  134. package/dist/components/p-YyGnQmX-.js +0 -1
  135. package/dist/components/p-swxZqinH.js +0 -1
  136. package/dist/esm/app-globals-DQuL1Twl.js +0 -3
  137. package/dist/esm/fk-brick-actions_18.entry.js +0 -4205
  138. package/dist/esm/formkrafter-wc.js +0 -21
  139. package/dist/esm/index-BAcz7b5u.js +0 -5416
  140. package/dist/esm/index-BkRMoLXK.js +0 -3029
  141. package/dist/esm/index-CGMDfZ5m.js +0 -1808
  142. package/dist/esm/index-D7Cta1UB.js +0 -17488
  143. package/dist/esm/index-DtcM1yw5.js +0 -3991
  144. package/dist/esm/index-DuVf3NlP.js +0 -12222
  145. package/dist/esm/index-qLZlXROB.js +0 -2117
  146. package/dist/esm/index.js +0 -2
  147. package/dist/esm/loader.js +0 -11
  148. package/dist/formkrafter-wc/p-6d29555b.entry.js +0 -1
  149. package/dist/formkrafter-wc/p-DOInQkG6.js +0 -1
  150. package/dist/formkrafter-wc/p-Ddu6BquK.js +0 -12
  151. package/dist/index.cjs.js +0 -1
  152. package/dist/index.js +0 -1
  153. package/dist/stencil.config.js +0 -34
  154. package/loader/cdn.js +0 -1
  155. package/loader/index.cjs.js +0 -1
  156. package/loader/index.d.ts +0 -24
  157. package/loader/index.es2017.js +0 -1
  158. package/loader/index.js +0 -2
@@ -1,454 +0,0 @@
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
- let selectInstanceCounter = 0;
7
- export class FkSelectInput {
8
- constructor() {
9
- this.disabled = false;
10
- this.multiple = false;
11
- this.invalid = false;
12
- this.open = false;
13
- this.query = '';
14
- this.activeIndex = 0;
15
- this.instanceId = `fk-select-${++selectInstanceCounter}`;
16
- this.remoteOptions = [];
17
- this.outsideClick = (event) => {
18
- if (!this.host.contains(event.target))
19
- this.close();
20
- };
21
- this.onTriggerKeyDown = (event) => {
22
- if (this.disabled)
23
- return;
24
- if (['Enter', ' ', 'ArrowDown', 'ArrowUp'].includes(event.key)) {
25
- event.preventDefault();
26
- this.openDropdown();
27
- }
28
- else if (event.key === 'Escape' && this.open) {
29
- event.preventDefault();
30
- this.close();
31
- }
32
- };
33
- }
34
- componentWillLoad() {
35
- return this.resolveRemote();
36
- }
37
- disconnectedCallback() {
38
- this.unbindOutsideClick();
39
- }
40
- onConfigsChange() {
41
- this.resolveRemote();
42
- }
43
- onDataMapChange() {
44
- this.resolveRemote();
45
- }
46
- searchParam() {
47
- var _a;
48
- return ((_a = this.configs) === null || _a === void 0 ? void 0 : _a.searchParam) || undefined;
49
- }
50
- remoteUrl() {
51
- var _a;
52
- const raw = (_a = this.configs) === null || _a === void 0 ? void 0 : _a.optionsUrl;
53
- if (!raw)
54
- return undefined;
55
- let url = interpolateTemplate(raw, this.dataMap);
56
- const param = this.searchParam();
57
- if (param)
58
- url = appendSearchParam(url, param, this.query.trim());
59
- return url;
60
- }
61
- bindOutsideClick() {
62
- document.addEventListener('mousedown', this.outsideClick);
63
- }
64
- unbindOutsideClick() {
65
- document.removeEventListener('mousedown', this.outsideClick);
66
- }
67
- toggleOpen() {
68
- if (this.disabled)
69
- return;
70
- if (this.open)
71
- this.close();
72
- else
73
- this.openDropdown();
74
- }
75
- openDropdown() {
76
- if (this.disabled || this.open)
77
- return;
78
- this.open = true;
79
- this.query = '';
80
- const { options } = this.resolve();
81
- const selected = this.selectedValues();
82
- const selectedIndex = options.findIndex((option) => selected.includes(option.value));
83
- this.activeIndex = selectedIndex >= 0 ? selectedIndex : 0;
84
- this.bindOutsideClick();
85
- }
86
- close(refocusTrigger = false) {
87
- var _a;
88
- this.open = false;
89
- this.unbindOutsideClick();
90
- if (refocusTrigger)
91
- (_a = this.triggerEl) === null || _a === void 0 ? void 0 : _a.focus();
92
- }
93
- moveActive(delta, count) {
94
- if (!count)
95
- return;
96
- this.activeIndex = (this.activeIndex + delta + count) % count;
97
- this.scrollActiveIntoView();
98
- }
99
- scrollActiveIntoView() {
100
- requestAnimationFrame(() => {
101
- var _a;
102
- const active = this.host.querySelector(`#${this.instanceId}-opt-${this.activeIndex}`);
103
- (_a = active === null || active === void 0 ? void 0 : active.scrollIntoView) === null || _a === void 0 ? void 0 : _a.call(active, { block: 'nearest' });
104
- });
105
- }
106
- onSearchKeyDown(event, filtered) {
107
- var _a;
108
- switch (event.key) {
109
- case 'ArrowDown':
110
- event.preventDefault();
111
- this.moveActive(1, filtered.length);
112
- break;
113
- case 'ArrowUp':
114
- event.preventDefault();
115
- this.moveActive(-1, filtered.length);
116
- break;
117
- case 'Home':
118
- event.preventDefault();
119
- this.activeIndex = 0;
120
- this.scrollActiveIntoView();
121
- break;
122
- case 'End':
123
- event.preventDefault();
124
- this.activeIndex = Math.max(filtered.length - 1, 0);
125
- this.scrollActiveIntoView();
126
- break;
127
- case 'Enter': {
128
- event.preventDefault();
129
- const option = (_a = filtered[this.activeIndex]) !== null && _a !== void 0 ? _a : filtered[0];
130
- if (option)
131
- this.pick(option);
132
- break;
133
- }
134
- case 'Escape':
135
- event.preventDefault();
136
- this.close(true);
137
- break;
138
- case 'Tab':
139
- this.close();
140
- break;
141
- }
142
- }
143
- source() {
144
- var _a, _b;
145
- return (_b = (_a = this.configs) === null || _a === void 0 ? void 0 : _a.optionsSource) !== null && _b !== void 0 ? _b : 'static';
146
- }
147
- async resolveRemote(force = false) {
148
- var _a;
149
- if (this.source() !== 'remote')
150
- return;
151
- const url = this.remoteUrl();
152
- if (!url) {
153
- this.remoteOptions = [];
154
- return;
155
- }
156
- const headers = parseHeaderLines((_a = this.configs) === null || _a === void 0 ? void 0 : _a.optionsHeaders, this.dataMap);
157
- const signature = `${url}|${JSON.stringify(headers !== null && headers !== void 0 ? headers : {})}`;
158
- if (!force && signature === this.lastRemoteSignature)
159
- return;
160
- this.lastRemoteSignature = signature;
161
- try {
162
- this.remoteError = undefined;
163
- this.remoteOptions = await services.dataSourceService.fetchOptions(url, headers ? { headers } : undefined);
164
- }
165
- catch (error) {
166
- this.remoteOptions = [];
167
- this.remoteError = error instanceof Error ? error.message : String(error);
168
- }
169
- }
170
- onSearchInput(value) {
171
- this.query = value;
172
- if (this.source() !== 'remote' || !this.searchParam())
173
- return;
174
- if (this.searchTimer)
175
- clearTimeout(this.searchTimer);
176
- this.searchTimer = setTimeout(() => this.resolveRemote(), 250);
177
- }
178
- resolve() {
179
- var _a, _b, _c, _d, _e, _f;
180
- const labelKey = ((_a = this.configs) === null || _a === void 0 ? void 0 : _a.labelKey) || undefined;
181
- const valueKey = ((_b = this.configs) === null || _b === void 0 ? void 0 : _b.valueKey) || undefined;
182
- switch (this.source()) {
183
- case 'remote':
184
- return {
185
- options: normalizeOptions(this.remoteOptions, labelKey, valueKey),
186
- error: this.remoteError,
187
- };
188
- case 'dataMap': {
189
- const path = (_c = this.configs) === null || _c === void 0 ? void 0 : _c.optionsPath;
190
- return {
191
- options: normalizeOptions(path ? (_d = this.dataMap) === null || _d === void 0 ? void 0 : _d[path] : [], labelKey, valueKey),
192
- };
193
- }
194
- case 'js': {
195
- const code = (_e = this.configs) === null || _e === void 0 ? void 0 : _e.optionsCode;
196
- if (!code)
197
- return { options: [] };
198
- const result = evalBrickCode(code, this.dataMap);
199
- if (result instanceof Error) {
200
- return { options: [], error: result.message };
201
- }
202
- return { options: normalizeOptions(result, labelKey, valueKey) };
203
- }
204
- default:
205
- return {
206
- options: normalizeOptions((_f = this.configs) === null || _f === void 0 ? void 0 : _f.options, labelKey, valueKey),
207
- };
208
- }
209
- }
210
- selectedValues() {
211
- if (this.multiple) {
212
- return Array.isArray(this.value) ? this.value : [];
213
- }
214
- return typeof this.value === 'string' && this.value !== '' ? [this.value] : [];
215
- }
216
- labelOf(value, options) {
217
- var _a, _b;
218
- return (_b = (_a = options.find((option) => option.value === value)) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : value;
219
- }
220
- pick(option) {
221
- if (this.multiple) {
222
- const selected = this.selectedValues();
223
- const next = selected.includes(option.value)
224
- ? selected.filter((value) => value !== option.value)
225
- : [...selected, option.value];
226
- this.selectValueChange.emit(next.length ? next : undefined);
227
- return;
228
- }
229
- this.selectValueChange.emit(option.value);
230
- this.close(true);
231
- }
232
- unpick(value) {
233
- const next = this.selectedValues().filter((entry) => entry !== value);
234
- this.selectValueChange.emit(next.length ? next : undefined);
235
- }
236
- filteredOptions(options) {
237
- if (this.source() === 'remote' && this.searchParam())
238
- return options;
239
- const query = this.query.trim().toLowerCase();
240
- if (!query)
241
- return options;
242
- return options.filter((option) => option.label.toLowerCase().includes(query));
243
- }
244
- render() {
245
- var _a, _b;
246
- const { options, error } = this.resolve();
247
- const selected = this.selectedValues();
248
- const filtered = this.filteredOptions(options);
249
- return (h("div", { key: 'b891babd7bf125b1e388618ed12be7283136def1', class: { 'fk-select': true, 'fk-select--disabled': this.disabled } }, h("div", { key: 'ef9d0b05e422f78f92a74fcd7dd589c25bc2cbe0', class: { 'fk-select__trigger': true, 'fk-select__trigger--open': this.open }, role: "combobox", tabIndex: this.disabled ? undefined : 0, "aria-expanded": this.open ? 'true' : 'false', "aria-haspopup": "listbox", "aria-controls": `${this.instanceId}-listbox`, "aria-disabled": this.disabled ? 'true' : undefined, "aria-invalid": this.invalid ? 'true' : undefined, ref: (element) => (this.triggerEl = element), onKeyDown: this.onTriggerKeyDown, onClick: (event) => {
250
- event.preventDefault();
251
- this.toggleOpen();
252
- } }, h("div", { key: '9f803f11783a2730865685c34770171a8bf92850', 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", "aria-label": `${fkT('select.clear')} — ${this.labelOf(value, options)}`, disabled: this.disabled, onClick: (event) => {
253
- event.preventDefault();
254
- event.stopPropagation();
255
- this.unpick(value);
256
- } }, "\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'), "aria-label": fkT('select.clear'), onClick: (event) => {
257
- event.preventDefault();
258
- event.stopPropagation();
259
- this.selectValueChange.emit(undefined);
260
- } }, "\u2715")) : null, h("span", { key: '2fabef683d5007a58b1b2c34e7005cd4d3eaef04', 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, role: "combobox", "aria-expanded": "true", "aria-autocomplete": "list", "aria-controls": `${this.instanceId}-listbox`, "aria-activedescendant": filtered.length
261
- ? `${this.instanceId}-opt-${Math.min(this.activeIndex, filtered.length - 1)}`
262
- : undefined, ref: (element) => setTimeout(() => element === null || element === void 0 ? void 0 : element.focus(), 0), onInput: (event) => {
263
- this.activeIndex = 0;
264
- this.onSearchInput(event.target.value);
265
- }, onKeyDown: (event) => this.onSearchKeyDown(event, filtered) }), h("div", { class: "fk-select__options", role: "listbox", id: `${this.instanceId}-listbox`, "aria-multiselectable": this.multiple ? 'true' : undefined }, filtered.map((option, index) => {
266
- const isSelected = selected.includes(option.value);
267
- const isActive = index === Math.min(this.activeIndex, filtered.length - 1);
268
- return (h("div", { key: option.value, id: `${this.instanceId}-opt-${index}`, role: "option", "aria-selected": isSelected ? 'true' : 'false', class: {
269
- 'fk-select__option': true,
270
- 'fk-select__option--selected': isSelected,
271
- 'fk-select__option--active': isActive,
272
- }, onMouseEnter: () => (this.activeIndex = index), onClick: (event) => {
273
- event.preventDefault();
274
- this.pick(option);
275
- } }, h("span", { class: "fk-select__option-label" }, option.label), isSelected ? h("span", { class: "fk-select__check" }, "\u2713") : null));
276
- }), filtered.length === 0 ? (h("p", { class: "fk-select__empty" }, fkT('select.empty'))) : null))) : null, error ? h("span", { class: "fk-field__error" }, error) : null));
277
- }
278
- static get is() { return "fk-select-input"; }
279
- static get encapsulation() { return "scoped"; }
280
- static get originalStyleUrls() {
281
- return {
282
- "$": ["fk-select-input.css"]
283
- };
284
- }
285
- static get styleUrls() {
286
- return {
287
- "$": ["fk-select-input.css"]
288
- };
289
- }
290
- static get properties() {
291
- return {
292
- "configs": {
293
- "type": "unknown",
294
- "mutable": false,
295
- "complexType": {
296
- "original": "Record<string, unknown>",
297
- "resolved": "string | unknown",
298
- "references": {
299
- "Record": {
300
- "location": "global",
301
- "id": "global::Record"
302
- }
303
- }
304
- },
305
- "required": false,
306
- "optional": true,
307
- "docs": {
308
- "tags": [],
309
- "text": ""
310
- },
311
- "getter": false,
312
- "setter": false
313
- },
314
- "value": {
315
- "type": "string",
316
- "mutable": false,
317
- "complexType": {
318
- "original": "string | string[]",
319
- "resolved": "string | string[]",
320
- "references": {}
321
- },
322
- "required": false,
323
- "optional": true,
324
- "docs": {
325
- "tags": [],
326
- "text": ""
327
- },
328
- "getter": false,
329
- "setter": false,
330
- "reflect": false,
331
- "attribute": "value"
332
- },
333
- "disabled": {
334
- "type": "boolean",
335
- "mutable": false,
336
- "complexType": {
337
- "original": "boolean",
338
- "resolved": "boolean",
339
- "references": {}
340
- },
341
- "required": false,
342
- "optional": false,
343
- "docs": {
344
- "tags": [],
345
- "text": ""
346
- },
347
- "getter": false,
348
- "setter": false,
349
- "reflect": false,
350
- "attribute": "disabled",
351
- "defaultValue": "false"
352
- },
353
- "multiple": {
354
- "type": "boolean",
355
- "mutable": false,
356
- "complexType": {
357
- "original": "boolean",
358
- "resolved": "boolean",
359
- "references": {}
360
- },
361
- "required": false,
362
- "optional": false,
363
- "docs": {
364
- "tags": [],
365
- "text": ""
366
- },
367
- "getter": false,
368
- "setter": false,
369
- "reflect": false,
370
- "attribute": "multiple",
371
- "defaultValue": "false"
372
- },
373
- "invalid": {
374
- "type": "boolean",
375
- "mutable": false,
376
- "complexType": {
377
- "original": "boolean",
378
- "resolved": "boolean",
379
- "references": {}
380
- },
381
- "required": false,
382
- "optional": false,
383
- "docs": {
384
- "tags": [],
385
- "text": ""
386
- },
387
- "getter": false,
388
- "setter": false,
389
- "reflect": false,
390
- "attribute": "invalid",
391
- "defaultValue": "false"
392
- },
393
- "dataMap": {
394
- "type": "unknown",
395
- "mutable": false,
396
- "complexType": {
397
- "original": "Record<string, unknown>",
398
- "resolved": "string | unknown",
399
- "references": {
400
- "Record": {
401
- "location": "global",
402
- "id": "global::Record"
403
- }
404
- }
405
- },
406
- "required": false,
407
- "optional": true,
408
- "docs": {
409
- "tags": [],
410
- "text": ""
411
- },
412
- "getter": false,
413
- "setter": false
414
- }
415
- };
416
- }
417
- static get states() {
418
- return {
419
- "open": {},
420
- "query": {},
421
- "activeIndex": {},
422
- "remoteOptions": {},
423
- "remoteError": {}
424
- };
425
- }
426
- static get events() {
427
- return [{
428
- "method": "selectValueChange",
429
- "name": "selectValueChange",
430
- "bubbles": true,
431
- "cancelable": true,
432
- "composed": true,
433
- "docs": {
434
- "tags": [],
435
- "text": ""
436
- },
437
- "complexType": {
438
- "original": "string | string[] | undefined",
439
- "resolved": "string | string[]",
440
- "references": {}
441
- }
442
- }];
443
- }
444
- static get elementRef() { return "host"; }
445
- static get watchers() {
446
- return [{
447
- "propName": "configs",
448
- "methodName": "onConfigsChange"
449
- }, {
450
- "propName": "dataMap",
451
- "methodName": "onDataMapChange"
452
- }];
453
- }
454
- }
@@ -1,42 +0,0 @@
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
- }
@@ -1,158 +0,0 @@
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
- }