@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.
Files changed (174) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +140 -0
  3. package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
  4. package/dist/cjs/fk-brick-actions_18.cjs.entry.js +26442 -0
  5. package/dist/cjs/formkrafter-wc.cjs.js +25 -0
  6. package/dist/cjs/index-By4GGW_q.js +17346 -0
  7. package/dist/cjs/index-D_7eGIJ0.js +2090 -0
  8. package/dist/cjs/index.cjs.js +47 -0
  9. package/dist/cjs/loader.cjs.js +13 -0
  10. package/dist/collection/collection-manifest.json +30 -0
  11. package/dist/collection/components/fk-brick-actions/fk-brick-actions.css +78 -0
  12. package/dist/collection/components/fk-brick-actions/fk-brick-actions.js +215 -0
  13. package/dist/collection/components/fk-brick-list/fk-brick-list.css +71 -0
  14. package/dist/collection/components/fk-brick-list/fk-brick-list.js +55 -0
  15. package/dist/collection/components/fk-brick-mold-item/fk-brick-mold-item.css +33 -0
  16. package/dist/collection/components/fk-brick-mold-item/fk-brick-mold-item.js +73 -0
  17. package/dist/collection/components/fk-brick-not-found/fk-brick-not-found.css +8 -0
  18. package/dist/collection/components/fk-brick-not-found/fk-brick-not-found.js +18 -0
  19. package/dist/collection/components/fk-brick-render/fk-brick-render.js +419 -0
  20. package/dist/collection/components/fk-code-editor/fk-code-editor.css +26 -0
  21. package/dist/collection/components/fk-code-editor/fk-code-editor.js +136 -0
  22. package/dist/collection/components/fk-data-grid/fk-data-grid.css +75 -0
  23. package/dist/collection/components/fk-data-grid/fk-data-grid.js +300 -0
  24. package/dist/collection/components/fk-drop-area/fk-drop-area.css +18 -0
  25. package/dist/collection/components/fk-drop-area/fk-drop-area.js +98 -0
  26. package/dist/collection/components/fk-empty-form/fk-empty-form.css +22 -0
  27. package/dist/collection/components/fk-empty-form/fk-empty-form.js +19 -0
  28. package/dist/collection/components/fk-file-input/fk-file-input.css +74 -0
  29. package/dist/collection/components/fk-file-input/fk-file-input.js +157 -0
  30. package/dist/collection/components/fk-form-builder/fk-form-builder.css +82 -0
  31. package/dist/collection/components/fk-form-builder/fk-form-builder.js +431 -0
  32. package/dist/collection/components/fk-form-render/fk-form-render.css +7 -0
  33. package/dist/collection/components/fk-form-render/fk-form-render.js +352 -0
  34. package/dist/collection/components/fk-property-panel/fk-property-panel.css +153 -0
  35. package/dist/collection/components/fk-property-panel/fk-property-panel.js +384 -0
  36. package/dist/collection/components/fk-rules-editor/fk-rules-editor.css +166 -0
  37. package/dist/collection/components/fk-rules-editor/fk-rules-editor.js +250 -0
  38. package/dist/collection/components/fk-select-input/fk-select-input.css +144 -0
  39. package/dist/collection/components/fk-select-input/fk-select-input.js +356 -0
  40. package/dist/collection/components/fk-signature-input/fk-signature-input.css +42 -0
  41. package/dist/collection/components/fk-signature-input/fk-signature-input.js +158 -0
  42. package/dist/collection/components/fk-stepper/fk-stepper.css +85 -0
  43. package/dist/collection/components/fk-stepper/fk-stepper.js +282 -0
  44. package/dist/collection/components/fk-tabs/fk-tabs.css +38 -0
  45. package/dist/collection/components/fk-tabs/fk-tabs.js +236 -0
  46. package/dist/collection/i18n/i18n.js +245 -0
  47. package/dist/collection/index.js +5 -0
  48. package/dist/collection/registry/create-brick.js +34 -0
  49. package/dist/collection/registry/default-bricks.js +424 -0
  50. package/dist/collection/registry/registry.js +44 -0
  51. package/dist/collection/utils/brick-data.js +16 -0
  52. package/dist/collection/utils/drop.js +14 -0
  53. package/dist/collection/utils/events.js +1 -0
  54. package/dist/collection/utils/options.js +21 -0
  55. package/dist/collection/utils/remote.js +27 -0
  56. package/dist/collection/utils/rule-condition.js +72 -0
  57. package/dist/collection/utils/style.js +11 -0
  58. package/dist/components/fk-brick-actions.d.ts +11 -0
  59. package/dist/components/fk-brick-actions.js +1 -0
  60. package/dist/components/fk-brick-list.d.ts +11 -0
  61. package/dist/components/fk-brick-list.js +1 -0
  62. package/dist/components/fk-brick-mold-item.d.ts +11 -0
  63. package/dist/components/fk-brick-mold-item.js +1 -0
  64. package/dist/components/fk-brick-not-found.d.ts +11 -0
  65. package/dist/components/fk-brick-not-found.js +1 -0
  66. package/dist/components/fk-brick-render.d.ts +11 -0
  67. package/dist/components/fk-brick-render.js +1 -0
  68. package/dist/components/fk-code-editor.d.ts +11 -0
  69. package/dist/components/fk-code-editor.js +1 -0
  70. package/dist/components/fk-data-grid.d.ts +11 -0
  71. package/dist/components/fk-data-grid.js +1 -0
  72. package/dist/components/fk-drop-area.d.ts +11 -0
  73. package/dist/components/fk-drop-area.js +1 -0
  74. package/dist/components/fk-empty-form.d.ts +11 -0
  75. package/dist/components/fk-empty-form.js +1 -0
  76. package/dist/components/fk-file-input.d.ts +11 -0
  77. package/dist/components/fk-file-input.js +1 -0
  78. package/dist/components/fk-form-builder.d.ts +11 -0
  79. package/dist/components/fk-form-builder.js +1 -0
  80. package/dist/components/fk-form-render.d.ts +11 -0
  81. package/dist/components/fk-form-render.js +1 -0
  82. package/dist/components/fk-property-panel.d.ts +11 -0
  83. package/dist/components/fk-property-panel.js +1 -0
  84. package/dist/components/fk-rules-editor.d.ts +11 -0
  85. package/dist/components/fk-rules-editor.js +1 -0
  86. package/dist/components/fk-select-input.d.ts +11 -0
  87. package/dist/components/fk-select-input.js +1 -0
  88. package/dist/components/fk-signature-input.d.ts +11 -0
  89. package/dist/components/fk-signature-input.js +1 -0
  90. package/dist/components/fk-stepper.d.ts +11 -0
  91. package/dist/components/fk-stepper.js +1 -0
  92. package/dist/components/fk-tabs.d.ts +11 -0
  93. package/dist/components/fk-tabs.js +1 -0
  94. package/dist/components/index.d.ts +35 -0
  95. package/dist/components/index.js +1 -0
  96. package/dist/components/p-92BozD8S.js +1 -0
  97. package/dist/components/p-B4vAN-UA.js +1 -0
  98. package/dist/components/p-BB3BQPr8.js +1 -0
  99. package/dist/components/p-BCQ-hj6j.js +1 -0
  100. package/dist/components/p-BIEpAM4V.js +1 -0
  101. package/dist/components/p-BLKRn62s.js +1 -0
  102. package/dist/components/p-BNREw7TY.js +1 -0
  103. package/dist/components/p-BOvjVIvo.js +1 -0
  104. package/dist/components/p-BQP1WryV.js +1 -0
  105. package/dist/components/p-BXFug2Ql.js +1 -0
  106. package/dist/components/p-Ctt--jpe.js +1 -0
  107. package/dist/components/p-D318uFl-.js +1 -0
  108. package/dist/components/p-DJDrDvoC.js +1 -0
  109. package/dist/components/p-DKGyje7v.js +1 -0
  110. package/dist/components/p-DKoJovNt.js +1 -0
  111. package/dist/components/p-DWgjI3TW.js +1 -0
  112. package/dist/components/p-Diknh4-7.js +1 -0
  113. package/dist/components/p-DtzMNM4i.js +1 -0
  114. package/dist/components/p-QC41Uj05.js +1 -0
  115. package/dist/components/p-TvmRksgg.js +1 -0
  116. package/dist/components/p-ZEW2q-4b.js +1 -0
  117. package/dist/components/p-dX7Lo8Fe.js +12 -0
  118. package/dist/components/p-gPc0o8Jb.js +1 -0
  119. package/dist/esm/app-globals-DQuL1Twl.js +3 -0
  120. package/dist/esm/fk-brick-actions_18.entry.js +26423 -0
  121. package/dist/esm/formkrafter-wc.js +21 -0
  122. package/dist/esm/index-BQqrzKxo.js +2081 -0
  123. package/dist/esm/index-BTmZ8XET.js +17288 -0
  124. package/dist/esm/index.js +2 -0
  125. package/dist/esm/loader.js +11 -0
  126. package/dist/formkrafter-wc/formkrafter-wc.css +1 -0
  127. package/dist/formkrafter-wc/formkrafter-wc.esm.js +1 -0
  128. package/dist/formkrafter-wc/index.esm.js +1 -0
  129. package/dist/formkrafter-wc/p-BQqrzKxo.js +2 -0
  130. package/dist/formkrafter-wc/p-BXIsVlA6.js +12 -0
  131. package/dist/formkrafter-wc/p-DQuL1Twl.js +1 -0
  132. package/dist/formkrafter-wc/p-f6bc0be0.entry.js +1 -0
  133. package/dist/index.cjs.js +1 -0
  134. package/dist/index.js +1 -0
  135. package/dist/stencil.config.js +34 -0
  136. package/dist/types/Users/datagnikan/Desktop/WorkSpace/streamline-pulse/formkrafter-js/formkrafter/packages/wc/.stencil/stencil.config.d.ts +2 -0
  137. package/dist/types/components/fk-brick-actions/fk-brick-actions.d.ts +18 -0
  138. package/dist/types/components/fk-brick-list/fk-brick-list.d.ts +6 -0
  139. package/dist/types/components/fk-brick-mold-item/fk-brick-mold-item.d.ts +10 -0
  140. package/dist/types/components/fk-brick-not-found/fk-brick-not-found.d.ts +3 -0
  141. package/dist/types/components/fk-brick-render/fk-brick-render.d.ts +22 -0
  142. package/dist/types/components/fk-code-editor/fk-code-editor.d.ts +13 -0
  143. package/dist/types/components/fk-data-grid/fk-data-grid.d.ts +21 -0
  144. package/dist/types/components/fk-drop-area/fk-drop-area.d.ts +12 -0
  145. package/dist/types/components/fk-empty-form/fk-empty-form.d.ts +3 -0
  146. package/dist/types/components/fk-file-input/fk-file-input.d.ts +14 -0
  147. package/dist/types/components/fk-form-builder/fk-form-builder.d.ts +43 -0
  148. package/dist/types/components/fk-form-render/fk-form-render.d.ts +29 -0
  149. package/dist/types/components/fk-property-panel/fk-property-panel.d.ts +34 -0
  150. package/dist/types/components/fk-rules-editor/fk-rules-editor.d.ts +29 -0
  151. package/dist/types/components/fk-select-input/fk-select-input.d.ts +37 -0
  152. package/dist/types/components/fk-signature-input/fk-signature-input.d.ts +19 -0
  153. package/dist/types/components/fk-stepper/fk-stepper.d.ts +27 -0
  154. package/dist/types/components/fk-tabs/fk-tabs.d.ts +23 -0
  155. package/dist/types/components.d.ts +796 -0
  156. package/dist/types/i18n/i18n.d.ts +5 -0
  157. package/dist/types/index.d.ts +11 -0
  158. package/dist/types/registry/create-brick.d.ts +37 -0
  159. package/dist/types/registry/default-bricks.d.ts +489 -0
  160. package/dist/types/registry/registry.d.ts +8 -0
  161. package/dist/types/stencil-public-runtime.d.ts +1861 -0
  162. package/dist/types/utils/brick-data.d.ts +3 -0
  163. package/dist/types/utils/drop.d.ts +2 -0
  164. package/dist/types/utils/events.d.ts +37 -0
  165. package/dist/types/utils/options.d.ts +5 -0
  166. package/dist/types/utils/remote.d.ts +3 -0
  167. package/dist/types/utils/rule-condition.d.ts +30 -0
  168. package/dist/types/utils/style.d.ts +1 -0
  169. package/loader/cdn.js +1 -0
  170. package/loader/index.cjs.js +1 -0
  171. package/loader/index.d.ts +24 -0
  172. package/loader/index.es2017.js +1 -0
  173. package/loader/index.js +2 -0
  174. package/package.json +80 -0
@@ -0,0 +1,300 @@
1
+ import { h } from "@stencil/core";
2
+ import { validateBrickSpecDataDetailed } from "@streamline-pulse/formkrafter-core";
3
+ import { fkT } from "../../i18n/i18n";
4
+ export class FkDataGrid {
5
+ constructor() {
6
+ this.disabled = false;
7
+ this.touched = {};
8
+ this.addRow = (event) => {
9
+ event.preventDefault();
10
+ this.gridValueChange.emit([...this.rows(), {}]);
11
+ };
12
+ }
13
+ rows() {
14
+ return Array.isArray(this.value)
15
+ ? this.value
16
+ : [];
17
+ }
18
+ rowSpec() {
19
+ var _a, _b;
20
+ if (((_a = this.rowSpecCache) === null || _a === void 0 ? void 0 : _a.source) !== this.spec) {
21
+ this.rowSpecCache = {
22
+ source: this.spec,
23
+ rowSpec: {
24
+ type: 'panel',
25
+ id: 'grid-row',
26
+ name: 'Row',
27
+ configs: { key: 'row' },
28
+ children: (_b = this.spec.children) !== null && _b !== void 0 ? _b : [],
29
+ },
30
+ };
31
+ }
32
+ return this.rowSpecCache.rowSpec;
33
+ }
34
+ rowErrors(row) {
35
+ const present = Object.fromEntries(Object.entries(row).filter(([, value]) => value !== '' && value !== null && value !== undefined));
36
+ return validateBrickSpecDataDetailed(this.rowSpec(), present, this.locale)
37
+ .errors;
38
+ }
39
+ visibleRowErrors(index) {
40
+ var _a, _b;
41
+ const row = (_a = this.rows()[index]) !== null && _a !== void 0 ? _a : {};
42
+ const touched = (_b = this.touched[index]) !== null && _b !== void 0 ? _b : {};
43
+ const errors = {};
44
+ for (const [key, message] of Object.entries(this.rowErrors(row))) {
45
+ if (touched[key])
46
+ errors[key] = message;
47
+ }
48
+ return errors;
49
+ }
50
+ handleRowChange(event) {
51
+ var _a, _b;
52
+ event.stopPropagation();
53
+ const origin = event.target;
54
+ const rowEl = origin.closest('[data-grid-row]');
55
+ const index = Number((_a = rowEl === null || rowEl === void 0 ? void 0 : rowEl.getAttribute('data-grid-row')) !== null && _a !== void 0 ? _a : -1);
56
+ if (index < 0)
57
+ return;
58
+ const rowTouched = Object.assign({}, ((_b = this.touched[index]) !== null && _b !== void 0 ? _b : {}));
59
+ for (const key of Object.keys(event.detail))
60
+ rowTouched[key] = true;
61
+ this.touched = Object.assign(Object.assign({}, this.touched), { [index]: rowTouched });
62
+ const rows = this.rows().map((row, i) => i === index ? Object.assign(Object.assign({}, row), event.detail) : row);
63
+ this.gridValueChange.emit(rows);
64
+ }
65
+ async validateRows() {
66
+ var _a, _b;
67
+ const rows = this.rows();
68
+ const gridKey = (_b = (_a = this.spec.configs) === null || _a === void 0 ? void 0 : _a.key) !== null && _b !== void 0 ? _b : 'grid';
69
+ const allTouched = {};
70
+ const errors = {};
71
+ rows.forEach((row, index) => {
72
+ var _a, _b;
73
+ const rowTouched = {};
74
+ for (const child of (_a = this.spec.children) !== null && _a !== void 0 ? _a : []) {
75
+ if ((_b = child.configs) === null || _b === void 0 ? void 0 : _b.key)
76
+ rowTouched[child.configs.key] = true;
77
+ }
78
+ allTouched[index] = rowTouched;
79
+ for (const [key, message] of Object.entries(this.rowErrors(row))) {
80
+ errors[`${gridKey}[${index}].${key}`] = message;
81
+ }
82
+ });
83
+ this.touched = allTouched;
84
+ return { valid: Object.keys(errors).length === 0, errors };
85
+ }
86
+ removeRow(index) {
87
+ const rows = this.rows().filter((_, i) => i !== index);
88
+ const touched = {};
89
+ for (const [key, value] of Object.entries(this.touched)) {
90
+ const i = Number(key);
91
+ if (i < index)
92
+ touched[i] = value;
93
+ else if (i > index)
94
+ touched[i - 1] = value;
95
+ }
96
+ this.touched = touched;
97
+ this.gridValueChange.emit(rows.length ? rows : undefined);
98
+ }
99
+ render() {
100
+ var _a;
101
+ const children = (_a = this.spec.children) !== null && _a !== void 0 ? _a : [];
102
+ const rows = this.rows();
103
+ return (h("div", { key: '1c77d72cd1482d673ffdb5b7d67ca200e55919d7', class: "fk-grid" }, rows.length === 0 ? (h("p", { class: "fk-grid__empty" }, fkT('grid.empty'))) : null, rows.map((row, index) => (h("div", { class: "fk-grid__row", "data-grid-row": index, key: index }, h("div", { class: "fk-grid__cells" }, children.map((child, childIndex) => (h("fk-brick-render", { brickSpec: child, data: row, dataMap: row, errors: this.visibleRowErrors(index), locale: this.locale, path: `grid.${index}.${childIndex}`, utils: this.utils })))), h("button", { type: "button", class: "fk-grid__remove", title: fkT('grid.removeRow'), disabled: this.disabled, onClick: (event) => {
104
+ event.preventDefault();
105
+ this.removeRow(index);
106
+ } }, "\u2715")))), h("button", { key: '9bf04c364b3262c436ffb580daf802d15f29de57', type: "button", class: "fk-grid__add", disabled: this.disabled, onClick: this.addRow }, fkT('grid.addRow'))));
107
+ }
108
+ static get is() { return "fk-data-grid"; }
109
+ static get encapsulation() { return "scoped"; }
110
+ static get originalStyleUrls() {
111
+ return {
112
+ "$": ["fk-data-grid.css"]
113
+ };
114
+ }
115
+ static get styleUrls() {
116
+ return {
117
+ "$": ["fk-data-grid.css"]
118
+ };
119
+ }
120
+ static get properties() {
121
+ return {
122
+ "spec": {
123
+ "type": "unknown",
124
+ "mutable": false,
125
+ "complexType": {
126
+ "original": "BrickSpec",
127
+ "resolved": "BrickSpec",
128
+ "references": {
129
+ "BrickSpec": {
130
+ "location": "import",
131
+ "path": "@streamline-pulse/formkrafter-core",
132
+ "id": "../core/dist/index.d.ts::BrickSpec",
133
+ "referenceLocation": "BrickSpec"
134
+ }
135
+ }
136
+ },
137
+ "required": true,
138
+ "optional": false,
139
+ "docs": {
140
+ "tags": [],
141
+ "text": ""
142
+ },
143
+ "getter": false,
144
+ "setter": false
145
+ },
146
+ "value": {
147
+ "type": "unknown",
148
+ "mutable": false,
149
+ "complexType": {
150
+ "original": "unknown",
151
+ "resolved": "unknown",
152
+ "references": {}
153
+ },
154
+ "required": false,
155
+ "optional": true,
156
+ "docs": {
157
+ "tags": [],
158
+ "text": ""
159
+ },
160
+ "getter": false,
161
+ "setter": false
162
+ },
163
+ "disabled": {
164
+ "type": "boolean",
165
+ "mutable": false,
166
+ "complexType": {
167
+ "original": "boolean",
168
+ "resolved": "boolean",
169
+ "references": {}
170
+ },
171
+ "required": false,
172
+ "optional": false,
173
+ "docs": {
174
+ "tags": [],
175
+ "text": ""
176
+ },
177
+ "getter": false,
178
+ "setter": false,
179
+ "reflect": false,
180
+ "attribute": "disabled",
181
+ "defaultValue": "false"
182
+ },
183
+ "locale": {
184
+ "type": "string",
185
+ "mutable": false,
186
+ "complexType": {
187
+ "original": "string",
188
+ "resolved": "string",
189
+ "references": {}
190
+ },
191
+ "required": false,
192
+ "optional": true,
193
+ "docs": {
194
+ "tags": [],
195
+ "text": ""
196
+ },
197
+ "getter": false,
198
+ "setter": false,
199
+ "reflect": false,
200
+ "attribute": "locale"
201
+ },
202
+ "utils": {
203
+ "type": "unknown",
204
+ "mutable": false,
205
+ "complexType": {
206
+ "original": "Utils",
207
+ "resolved": "object & { validateForm: () => { isValid: boolean; }; }",
208
+ "references": {
209
+ "Utils": {
210
+ "location": "import",
211
+ "path": "@streamline-pulse/formkrafter-core",
212
+ "id": "../core/dist/index.d.ts::Utils",
213
+ "referenceLocation": "Utils"
214
+ }
215
+ }
216
+ },
217
+ "required": true,
218
+ "optional": false,
219
+ "docs": {
220
+ "tags": [],
221
+ "text": ""
222
+ },
223
+ "getter": false,
224
+ "setter": false
225
+ }
226
+ };
227
+ }
228
+ static get states() {
229
+ return {
230
+ "touched": {}
231
+ };
232
+ }
233
+ static get events() {
234
+ return [{
235
+ "method": "gridValueChange",
236
+ "name": "gridValueChange",
237
+ "bubbles": true,
238
+ "cancelable": true,
239
+ "composed": true,
240
+ "docs": {
241
+ "tags": [],
242
+ "text": ""
243
+ },
244
+ "complexType": {
245
+ "original": "Array<Record<string, unknown>> | undefined",
246
+ "resolved": "Record<string, unknown>[]",
247
+ "references": {
248
+ "Array": {
249
+ "location": "global",
250
+ "id": "global::Array"
251
+ },
252
+ "Record": {
253
+ "location": "global",
254
+ "id": "global::Record"
255
+ }
256
+ }
257
+ }
258
+ }];
259
+ }
260
+ static get methods() {
261
+ return {
262
+ "validateRows": {
263
+ "complexType": {
264
+ "signature": "() => Promise<ValidationResult>",
265
+ "parameters": [],
266
+ "references": {
267
+ "Promise": {
268
+ "location": "global",
269
+ "id": "global::Promise"
270
+ },
271
+ "ValidationResult": {
272
+ "location": "import",
273
+ "path": "@streamline-pulse/formkrafter-core",
274
+ "id": "../core/dist/index.d.ts::ValidationResult",
275
+ "referenceLocation": "ValidationResult"
276
+ },
277
+ "Record": {
278
+ "location": "global",
279
+ "id": "global::Record"
280
+ }
281
+ },
282
+ "return": "Promise<ValidationResult>"
283
+ },
284
+ "docs": {
285
+ "text": "",
286
+ "tags": []
287
+ }
288
+ }
289
+ };
290
+ }
291
+ static get listeners() {
292
+ return [{
293
+ "name": "brickDataChange",
294
+ "method": "handleRowChange",
295
+ "target": undefined,
296
+ "capture": false,
297
+ "passive": false
298
+ }];
299
+ }
300
+ }
@@ -0,0 +1,18 @@
1
+ .fk-drop {
2
+ display: flex;
3
+ align-items: center;
4
+ justify-content: center;
5
+ min-height: 40px;
6
+ margin-top: calc(var(--fk-spacing) / 2);
7
+ border: 1px dashed var(--fk-color-border);
8
+ border-radius: var(--fk-radius);
9
+ color: var(--fk-color-muted);
10
+ font-size: 0.75rem;
11
+ transition: border-color 120ms ease, background-color 120ms ease;
12
+ }
13
+
14
+ .fk-drop--over {
15
+ border-color: var(--fk-color-primary);
16
+ background: color-mix(in srgb, var(--fk-color-primary) 8%, transparent);
17
+ color: var(--fk-color-primary);
18
+ }
@@ -0,0 +1,98 @@
1
+ import { h } from "@stencil/core";
2
+ import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
3
+ import { toBrickDropDetail } from "../../utils/drop";
4
+ import { fkT } from "../../i18n/i18n";
5
+ export class FkDropArea {
6
+ constructor() {
7
+ this.isOver = false;
8
+ }
9
+ componentDidLoad() {
10
+ this.cleanup = dropTargetForElements({
11
+ element: this.host,
12
+ onDragEnter: () => (this.isOver = true),
13
+ onDragLeave: () => (this.isOver = false),
14
+ onDrop: ({ source, location }) => {
15
+ var _a;
16
+ this.isOver = false;
17
+ if (((_a = location.current.dropTargets[0]) === null || _a === void 0 ? void 0 : _a.element) !== this.host)
18
+ return;
19
+ const detail = toBrickDropDetail(source.data, this.path);
20
+ if (detail)
21
+ this.brickDrop.emit(detail);
22
+ },
23
+ });
24
+ }
25
+ disconnectedCallback() {
26
+ var _a;
27
+ (_a = this.cleanup) === null || _a === void 0 ? void 0 : _a.call(this);
28
+ }
29
+ render() {
30
+ return (h("div", { key: '727b7005fcc58e3b6b2f455b03312fd91e3b063b', class: { 'fk-drop': true, 'fk-drop--over': this.isOver } }, h("span", { key: '41d1158e101100ebb229b74aec2ddfaf1aa57202', class: "fk-drop__hint" }, fkT('drop.hint'))));
31
+ }
32
+ static get is() { return "fk-drop-area"; }
33
+ static get encapsulation() { return "scoped"; }
34
+ static get originalStyleUrls() {
35
+ return {
36
+ "$": ["fk-drop-area.css"]
37
+ };
38
+ }
39
+ static get styleUrls() {
40
+ return {
41
+ "$": ["fk-drop-area.css"]
42
+ };
43
+ }
44
+ static get properties() {
45
+ return {
46
+ "path": {
47
+ "type": "string",
48
+ "mutable": false,
49
+ "complexType": {
50
+ "original": "string",
51
+ "resolved": "string",
52
+ "references": {}
53
+ },
54
+ "required": true,
55
+ "optional": false,
56
+ "docs": {
57
+ "tags": [],
58
+ "text": ""
59
+ },
60
+ "getter": false,
61
+ "setter": false,
62
+ "reflect": false,
63
+ "attribute": "path"
64
+ }
65
+ };
66
+ }
67
+ static get states() {
68
+ return {
69
+ "isOver": {}
70
+ };
71
+ }
72
+ static get events() {
73
+ return [{
74
+ "method": "brickDrop",
75
+ "name": "brickDrop",
76
+ "bubbles": true,
77
+ "cancelable": true,
78
+ "composed": true,
79
+ "docs": {
80
+ "tags": [],
81
+ "text": ""
82
+ },
83
+ "complexType": {
84
+ "original": "BrickDropDetail",
85
+ "resolved": "BrickDropDetail",
86
+ "references": {
87
+ "BrickDropDetail": {
88
+ "location": "import",
89
+ "path": "../../utils/events",
90
+ "id": "src/utils/events.ts::BrickDropDetail",
91
+ "referenceLocation": "BrickDropDetail"
92
+ }
93
+ }
94
+ }
95
+ }];
96
+ }
97
+ static get elementRef() { return "host"; }
98
+ }
@@ -0,0 +1,22 @@
1
+ .fk-empty {
2
+ display: flex;
3
+ flex-direction: column;
4
+ align-items: center;
5
+ justify-content: center;
6
+ gap: calc(var(--fk-spacing) / 2);
7
+ min-height: 160px;
8
+ border: 2px dashed var(--fk-color-border);
9
+ border-radius: var(--fk-radius);
10
+ color: var(--fk-color-muted);
11
+ text-align: center;
12
+ }
13
+
14
+ .fk-empty__title {
15
+ margin: 0;
16
+ font-weight: 600;
17
+ }
18
+
19
+ .fk-empty__hint {
20
+ margin: 0;
21
+ font-size: 0.875rem;
22
+ }
@@ -0,0 +1,19 @@
1
+ import { Host, h } from "@stencil/core";
2
+ import { fkT } from "../../i18n/i18n";
3
+ export class FkEmptyForm {
4
+ render() {
5
+ return (h(Host, { key: '1b0ab4cd1d988a4800deeb6e3cfd8f5074520f6b' }, h("div", { key: '65b551e1cab6162514ad941b21e318c5f19b824a', class: "fk-empty" }, h("p", { key: 'c4eba1c6fecb4f2669f1c4dfb09cd816790a5ebf', class: "fk-empty__title" }, fkT('empty.title')), h("p", { key: '751bb3a2fc07982c90a214bd1e71592ec03d988d', class: "fk-empty__hint" }, fkT('empty.hint')))));
6
+ }
7
+ static get is() { return "fk-empty-form"; }
8
+ static get encapsulation() { return "scoped"; }
9
+ static get originalStyleUrls() {
10
+ return {
11
+ "$": ["fk-empty-form.css"]
12
+ };
13
+ }
14
+ static get styleUrls() {
15
+ return {
16
+ "$": ["fk-empty-form.css"]
17
+ };
18
+ }
19
+ }
@@ -0,0 +1,74 @@
1
+ :host {
2
+ display: block;
3
+ }
4
+
5
+ .fk-file {
6
+ display: flex;
7
+ flex-direction: column;
8
+ gap: calc(var(--fk-spacing) / 2);
9
+ align-items: flex-start;
10
+ }
11
+
12
+ .fk-file__native {
13
+ display: none;
14
+ }
15
+
16
+ .fk-file__choose {
17
+ font: inherit;
18
+ font-size: 0.85rem;
19
+ padding: calc(var(--fk-spacing) / 1.5) var(--fk-spacing);
20
+ border: 1px dashed var(--fk-color-border);
21
+ border-radius: var(--fk-radius);
22
+ background: transparent;
23
+ color: var(--fk-color-muted);
24
+ cursor: pointer;
25
+ }
26
+
27
+ .fk-file__choose:hover:not(:disabled) {
28
+ border-color: var(--fk-color-primary);
29
+ color: var(--fk-color-primary);
30
+ }
31
+
32
+ .fk-file__choose:disabled {
33
+ opacity: 0.55;
34
+ cursor: not-allowed;
35
+ }
36
+
37
+ .fk-file__selected {
38
+ display: flex;
39
+ align-items: center;
40
+ gap: calc(var(--fk-spacing) / 2);
41
+ max-width: 100%;
42
+ padding: calc(var(--fk-spacing) / 2) var(--fk-spacing);
43
+ border: 1px solid var(--fk-color-border);
44
+ border-radius: var(--fk-radius);
45
+ background: var(--fk-color-surface);
46
+ }
47
+
48
+ .fk-file__name {
49
+ font-size: 0.85rem;
50
+ font-weight: 600;
51
+ color: var(--fk-color-text);
52
+ overflow: hidden;
53
+ text-overflow: ellipsis;
54
+ white-space: nowrap;
55
+ }
56
+
57
+ .fk-file__size {
58
+ font-size: 0.72rem;
59
+ color: var(--fk-color-muted);
60
+ white-space: nowrap;
61
+ }
62
+
63
+ .fk-file__remove {
64
+ border: none;
65
+ background: transparent;
66
+ color: var(--fk-color-muted);
67
+ font-size: 0.75rem;
68
+ cursor: pointer;
69
+ padding: 2px 4px;
70
+ }
71
+
72
+ .fk-file__remove:hover:not(:disabled) {
73
+ color: var(--fk-color-danger);
74
+ }
@@ -0,0 +1,157 @@
1
+ import { h } from "@stencil/core";
2
+ import { services } from "@streamline-pulse/formkrafter-core";
3
+ import { fkT } from "../../i18n/i18n";
4
+ export class FkFileInput {
5
+ constructor() {
6
+ this.disabled = false;
7
+ this.uploading = false;
8
+ this.handleFile = async (event) => {
9
+ var _a;
10
+ const input = event.target;
11
+ const file = (_a = input.files) === null || _a === void 0 ? void 0 : _a[0];
12
+ if (!file)
13
+ return;
14
+ this.uploading = true;
15
+ this.uploadError = undefined;
16
+ try {
17
+ const uploaded = await services.fileUploadService.upload(file);
18
+ this.fileValueChange.emit(uploaded);
19
+ }
20
+ catch (error) {
21
+ this.uploadError =
22
+ error instanceof Error ? error.message : String(error);
23
+ }
24
+ finally {
25
+ this.uploading = false;
26
+ input.value = '';
27
+ }
28
+ };
29
+ }
30
+ formatSize(size) {
31
+ if (size < 1024)
32
+ return `${size} B`;
33
+ if (size < 1024 * 1024)
34
+ return `${(size / 1024).toFixed(1)} KB`;
35
+ return `${(size / (1024 * 1024)).toFixed(1)} MB`;
36
+ }
37
+ render() {
38
+ return (h("div", { key: '69749ee4f48878949fbda5a89478c14559bfba57', class: "fk-file" }, this.value ? (h("div", { class: "fk-file__selected" }, h("span", { class: "fk-file__name", title: this.value.name }, this.value.name), h("span", { class: "fk-file__size" }, this.formatSize(this.value.size)), h("button", { type: "button", class: "fk-file__remove", title: fkT('file.remove'), disabled: this.disabled, onClick: (event) => {
39
+ event.preventDefault();
40
+ this.fileValueChange.emit(undefined);
41
+ } }, "\u2715"))) : (h("button", { type: "button", class: "fk-file__choose", disabled: this.disabled || this.uploading, onClick: (event) => {
42
+ var _a;
43
+ event.preventDefault();
44
+ (_a = this.inputEl) === null || _a === void 0 ? void 0 : _a.click();
45
+ } }, this.uploading ? fkT('file.uploading') : fkT('file.choose'))), h("input", { key: 'fa8e03377d64380d98a1b9f571fd6dfa6a6aa58f', class: "fk-file__native", type: "file", accept: this.accept, disabled: this.disabled, ref: (element) => (this.inputEl = element), onChange: this.handleFile }), this.uploadError ? (h("span", { class: "fk-field__error" }, this.uploadError)) : null));
46
+ }
47
+ static get is() { return "fk-file-input"; }
48
+ static get encapsulation() { return "scoped"; }
49
+ static get originalStyleUrls() {
50
+ return {
51
+ "$": ["fk-file-input.css"]
52
+ };
53
+ }
54
+ static get styleUrls() {
55
+ return {
56
+ "$": ["fk-file-input.css"]
57
+ };
58
+ }
59
+ static get properties() {
60
+ return {
61
+ "value": {
62
+ "type": "unknown",
63
+ "mutable": false,
64
+ "complexType": {
65
+ "original": "UploadedFile",
66
+ "resolved": "UploadedFile",
67
+ "references": {
68
+ "UploadedFile": {
69
+ "location": "import",
70
+ "path": "@streamline-pulse/formkrafter-core",
71
+ "id": "../core/dist/index.d.ts::UploadedFile",
72
+ "referenceLocation": "UploadedFile"
73
+ }
74
+ }
75
+ },
76
+ "required": false,
77
+ "optional": true,
78
+ "docs": {
79
+ "tags": [],
80
+ "text": ""
81
+ },
82
+ "getter": false,
83
+ "setter": false
84
+ },
85
+ "disabled": {
86
+ "type": "boolean",
87
+ "mutable": false,
88
+ "complexType": {
89
+ "original": "boolean",
90
+ "resolved": "boolean",
91
+ "references": {}
92
+ },
93
+ "required": false,
94
+ "optional": false,
95
+ "docs": {
96
+ "tags": [],
97
+ "text": ""
98
+ },
99
+ "getter": false,
100
+ "setter": false,
101
+ "reflect": false,
102
+ "attribute": "disabled",
103
+ "defaultValue": "false"
104
+ },
105
+ "accept": {
106
+ "type": "string",
107
+ "mutable": false,
108
+ "complexType": {
109
+ "original": "string",
110
+ "resolved": "string",
111
+ "references": {}
112
+ },
113
+ "required": false,
114
+ "optional": true,
115
+ "docs": {
116
+ "tags": [],
117
+ "text": ""
118
+ },
119
+ "getter": false,
120
+ "setter": false,
121
+ "reflect": false,
122
+ "attribute": "accept"
123
+ }
124
+ };
125
+ }
126
+ static get states() {
127
+ return {
128
+ "uploading": {},
129
+ "uploadError": {}
130
+ };
131
+ }
132
+ static get events() {
133
+ return [{
134
+ "method": "fileValueChange",
135
+ "name": "fileValueChange",
136
+ "bubbles": true,
137
+ "cancelable": true,
138
+ "composed": true,
139
+ "docs": {
140
+ "tags": [],
141
+ "text": ""
142
+ },
143
+ "complexType": {
144
+ "original": "UploadedFile | undefined",
145
+ "resolved": "UploadedFile",
146
+ "references": {
147
+ "UploadedFile": {
148
+ "location": "import",
149
+ "path": "@streamline-pulse/formkrafter-core",
150
+ "id": "../core/dist/index.d.ts::UploadedFile",
151
+ "referenceLocation": "UploadedFile"
152
+ }
153
+ }
154
+ }
155
+ }];
156
+ }
157
+ }