@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,564 +0,0 @@
1
- import { h } from "@stencil/core";
2
- import { createBrick } from "./create-brick";
3
- import { registerBricks } from "./registry";
4
- import { asInlineStyle } from "../utils/style";
5
- import { normalizeOptions } from "../utils/options";
6
- import { fkT, fkTOr } from "../i18n/i18n";
7
- import { getAffectedProperties, resolveLocalizedText, } from "@streamline-pulse/formkrafter-core";
8
- const labelOf = (props, fallback) => { var _a, _b, _c, _d; return (_d = (_b = (_a = props.configs) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : (_c = props.configs) === null || _c === void 0 ? void 0 : _c.key) !== null && _d !== void 0 ? _d : fallback; };
9
- const adorned = (props, control) => {
10
- var _a, _b;
11
- const prefix = (_a = props.configs) === null || _a === void 0 ? void 0 : _a.prefix;
12
- const suffix = (_b = props.configs) === null || _b === void 0 ? void 0 : _b.suffix;
13
- if (!prefix && !suffix)
14
- return control;
15
- return (h("div", { class: "fk-adorned" }, prefix ? h("span", { class: "fk-adorned__affix" }, prefix) : null, control, suffix ? h("span", { class: "fk-adorned__affix" }, suffix) : null));
16
- };
17
- const fieldError = (props) => props.error ? (h("span", { class: "fk-field__error", role: "alert" }, props.error)) : null;
18
- const invalidAttr = (props) => props.error ? { 'aria-invalid': 'true' } : {};
19
- const fieldBlock = (props, fallback, control) => (h("div", { class: "fk-field", style: asInlineStyle(props.styles) }, h("span", { class: "fk-field__label" }, labelOf(props, fallback)), control, fieldError(props)));
20
- const field = (props, fallback, control) => (h("label", { class: "fk-field", style: asInlineStyle(props.styles) }, h("span", { class: "fk-field__label" }, labelOf(props, fallback)), control, fieldError(props)));
21
- const createTextVariant = (params) => createBrick({
22
- type: 'input',
23
- dataType: 'string',
24
- id: params.id,
25
- name: params.name,
26
- category: 'Inputs',
27
- defaultConfigs: { label: params.name },
28
- render: (props) => {
29
- var _a, _b;
30
- return field(props, params.name, adorned(props, h("input", Object.assign({}, invalidAttr(props), { class: "fk-field__input fk-adorned__input", type: params.inputType, value: (_a = props.data) !== null && _a !== void 0 ? _a : '', placeholder: (_b = props.configs) === null || _b === void 0 ? void 0 : _b.placeholder, disabled: props.editable || props.disabled, onInput: (event) => { var _a; return (_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, event.target.value); } }))));
31
- },
32
- });
33
- export const textInputBrick = createTextVariant({
34
- id: 'text',
35
- name: 'Text',
36
- inputType: 'text',
37
- });
38
- export const emailBrick = createTextVariant({
39
- id: 'email',
40
- name: 'Email',
41
- inputType: 'email',
42
- });
43
- export const passwordBrick = createTextVariant({
44
- id: 'password',
45
- name: 'Password',
46
- inputType: 'password',
47
- });
48
- export const urlBrick = createTextVariant({
49
- id: 'url',
50
- name: 'URL',
51
- inputType: 'url',
52
- });
53
- export const phoneBrick = createTextVariant({
54
- id: 'phone',
55
- name: 'Phone',
56
- inputType: 'tel',
57
- });
58
- export const textareaBrick = createBrick({
59
- type: 'input',
60
- dataType: 'string',
61
- id: 'textarea',
62
- name: 'Text area',
63
- category: 'Inputs',
64
- defaultConfigs: { label: 'Text area' },
65
- render: (props) => {
66
- var _a, _b;
67
- return field(props, 'Text area', h("textarea", Object.assign({}, invalidAttr(props), { class: "fk-field__input fk-field__input--textarea", value: (_a = props.data) !== null && _a !== void 0 ? _a : '', placeholder: (_b = props.configs) === null || _b === void 0 ? void 0 : _b.placeholder, disabled: props.editable || props.disabled, onInput: (event) => { var _a; return (_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, event.target.value); } })));
68
- },
69
- });
70
- export const numberBrick = createBrick({
71
- type: 'input',
72
- dataType: 'number',
73
- id: 'number',
74
- name: 'Number',
75
- category: 'Inputs',
76
- defaultConfigs: { label: 'Number' },
77
- render: (props) => {
78
- var _a;
79
- return field(props, 'Number', adorned(props, h("input", Object.assign({}, invalidAttr(props), { class: "fk-field__input fk-adorned__input", type: "number", value: props.data == null ? '' : String(props.data), placeholder: (_a = props.configs) === null || _a === void 0 ? void 0 : _a.placeholder, disabled: props.editable || props.disabled, onInput: (event) => {
80
- var _a;
81
- const raw = event.target.value;
82
- (_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, raw === '' ? undefined : Number(raw));
83
- } }))));
84
- },
85
- });
86
- export const dateBrick = createBrick({
87
- type: 'input',
88
- dataType: 'string',
89
- id: 'date',
90
- name: 'Date',
91
- category: 'Inputs',
92
- defaultConfigs: { label: 'Date' },
93
- render: (props) => {
94
- var _a;
95
- return field(props, 'Date', h("input", Object.assign({}, invalidAttr(props), { class: "fk-field__input", type: "date", value: (_a = props.data) !== null && _a !== void 0 ? _a : '', disabled: props.editable || props.disabled, onInput: (event) => {
96
- var _a;
97
- const raw = event.target.value;
98
- (_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, raw === '' ? undefined : raw);
99
- } })));
100
- },
101
- });
102
- export const selectBrick = createBrick({
103
- type: 'input',
104
- dataType: 'string',
105
- id: 'select',
106
- name: 'Select',
107
- category: 'Inputs',
108
- defaultConfigs: {
109
- label: 'Select',
110
- optionsSource: 'static',
111
- options: 'Option 1\nOption 2',
112
- },
113
- render: (props) => {
114
- var _a;
115
- return fieldBlock(props, 'Select', h("fk-select-input", { configs: props.configs, value: (_a = props.data) !== null && _a !== void 0 ? _a : '', disabled: props.editable || props.disabled, invalid: !!props.error, dataMap: props.dataMap, onSelectValueChange: (event) => {
116
- var _a;
117
- event.stopPropagation();
118
- (_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, event.detail);
119
- } }));
120
- },
121
- });
122
- export const multiSelectBrick = createBrick({
123
- type: 'input',
124
- dataType: 'array',
125
- id: 'multi-select',
126
- name: 'Multi select',
127
- category: 'Inputs',
128
- defaultConfigs: {
129
- label: 'Multi select',
130
- optionsSource: 'static',
131
- options: 'Option 1\nOption 2\nOption 3',
132
- },
133
- render: (props) => fieldBlock(props, 'Multi select', h("fk-select-input", { configs: props.configs, value: Array.isArray(props.data) ? props.data : [], multiple: true, disabled: props.editable || props.disabled, invalid: !!props.error, dataMap: props.dataMap, onSelectValueChange: (event) => {
134
- var _a;
135
- event.stopPropagation();
136
- (_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, event.detail);
137
- } })),
138
- });
139
- export const timeBrick = createTextVariant({
140
- id: 'time',
141
- name: 'Time',
142
- inputType: 'time',
143
- });
144
- export const datetimeBrick = createTextVariant({
145
- id: 'datetime',
146
- name: 'Date / Time',
147
- inputType: 'datetime-local',
148
- });
149
- const staticOptions = (props) => {
150
- var _a, _b, _c;
151
- return normalizeOptions((_a = props.configs) === null || _a === void 0 ? void 0 : _a.options, typeof ((_b = props.configs) === null || _b === void 0 ? void 0 : _b.labelKey) === 'string' ? props.configs.labelKey : 'label', typeof ((_c = props.configs) === null || _c === void 0 ? void 0 : _c.valueKey) === 'string' ? props.configs.valueKey : 'value');
152
- };
153
- export const selectBoxesBrick = createBrick({
154
- type: 'input',
155
- dataType: 'array',
156
- id: 'select-boxes',
157
- name: 'Select boxes',
158
- category: 'Inputs',
159
- defaultConfigs: { label: 'Select boxes', options: 'Option 1\nOption 2\nOption 3' },
160
- render: (props) => {
161
- const selected = Array.isArray(props.data) ? props.data : [];
162
- return (h("div", { class: "fk-field", style: asInlineStyle(props.styles) }, h("span", { class: "fk-field__label" }, labelOf(props, 'Select boxes')), h("div", { class: "fk-radio-group" }, staticOptions(props).map((option) => (h("label", { class: "fk-radio", key: option.value }, h("input", { type: "checkbox", checked: selected.includes(option.value), disabled: props.editable || props.disabled, onChange: (event) => {
163
- var _a;
164
- const checked = event.target.checked;
165
- const next = checked
166
- ? [...selected, option.value]
167
- : selected.filter((value) => value !== option.value);
168
- (_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, next.length ? next : undefined);
169
- } }), h("span", null, option.label))))), props.error ? h("span", { class: "fk-field__error" }, props.error) : null));
170
- },
171
- });
172
- export const tagsBrick = createBrick({
173
- type: 'input',
174
- dataType: 'array',
175
- id: 'tags',
176
- name: 'Tags',
177
- category: 'Inputs',
178
- defaultConfigs: { label: 'Tags' },
179
- render: (props) => {
180
- const tags = Array.isArray(props.data) ? props.data : [];
181
- return field(props, 'Tags', h("div", { class: "fk-tags" }, tags.map((tag) => (h("span", { class: "fk-tags__chip", key: tag }, tag, h("button", { type: "button", class: "fk-tags__remove", disabled: props.editable || props.disabled, onClick: () => {
182
- var _a;
183
- const next = tags.filter((value) => value !== tag);
184
- (_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, next.length ? next : undefined);
185
- } }, "\u2715")))), h("input", { class: "fk-tags__input", type: "text", placeholder: "Add a tag\u2026", disabled: props.editable || props.disabled, onKeyDown: (event) => {
186
- var _a;
187
- if (event.key !== 'Enter')
188
- return;
189
- event.preventDefault();
190
- const input = event.target;
191
- const value = input.value.trim();
192
- if (!value || tags.includes(value))
193
- return;
194
- (_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, [...tags, value]);
195
- input.value = '';
196
- } })));
197
- },
198
- });
199
- export const signatureBrick = createBrick({
200
- type: 'input',
201
- dataType: 'string',
202
- id: 'signature',
203
- name: 'Signature',
204
- category: 'Inputs',
205
- defaultConfigs: { label: 'Signature' },
206
- render: (props) => {
207
- var _a;
208
- return field(props, 'Signature', h("fk-signature-input", { value: (_a = props.data) !== null && _a !== void 0 ? _a : undefined, disabled: props.editable || props.disabled, onSignatureChange: (event) => {
209
- var _a;
210
- event.stopPropagation();
211
- (_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, event.detail);
212
- } }));
213
- },
214
- });
215
- export const tabsBrick = createBrick({
216
- type: 'panel',
217
- dataType: 'void',
218
- id: 'tabs',
219
- name: 'Tabs',
220
- category: 'Layout',
221
- defaultConfigs: { validateTabs: false },
222
- render: (props) => {
223
- var _a, _b;
224
- const labels = ((_b = (_a = props.brickSpec) === null || _a === void 0 ? void 0 : _a.children) !== null && _b !== void 0 ? _b : []).map((child, index) => {
225
- var _a, _b;
226
- const resolved = resolveLocalizedText((_a = child.configs) === null || _a === void 0 ? void 0 : _a.label, props.locale);
227
- return typeof resolved === 'string'
228
- ? resolved
229
- : ((_b = child.name) !== null && _b !== void 0 ? _b : `Tab ${index + 1}`);
230
- });
231
- return (h("fk-tabs", { tabLabels: labels, editable: props.editable, spec: props.brickSpec, dataMap: props.dataMap, locale: props.locale, style: asInlineStyle(props.styles) }, props.children));
232
- },
233
- });
234
- export const radioBrick = createBrick({
235
- type: 'input',
236
- dataType: 'string',
237
- id: 'radio',
238
- name: 'Radio',
239
- category: 'Inputs',
240
- defaultConfigs: { label: 'Radio', options: 'Option 1\nOption 2' },
241
- render: (props) => (h("div", { class: "fk-field", style: asInlineStyle(props.styles) }, h("span", { class: "fk-field__label" }, labelOf(props, 'Radio')), h("div", Object.assign({ class: "fk-radio-group", role: "radiogroup" }, invalidAttr(props)), staticOptions(props).map((option) => {
242
- var _a, _b;
243
- return (h("label", { class: "fk-radio", key: option.value }, h("input", { type: "radio", name: (_b = (_a = props.configs) === null || _a === void 0 ? void 0 : _a.key) !== null && _b !== void 0 ? _b : props.path, checked: props.data === option.value, disabled: props.editable || props.disabled, onChange: () => { var _a; return (_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, option.value); } }), h("span", null, option.label)));
244
- })), props.error ? h("span", { class: "fk-field__error" }, props.error) : null)),
245
- });
246
- const ADDRESS_PARTS = [
247
- { key: 'street', label: () => fkT('address.street'), full: true },
248
- { key: 'city', label: () => fkT('address.city'), full: false },
249
- { key: 'zip', label: () => fkT('address.zip'), full: false },
250
- { key: 'country', label: () => fkT('address.country'), full: false },
251
- ];
252
- export const addressBrick = createBrick({
253
- type: 'input',
254
- dataType: 'object',
255
- id: 'address',
256
- name: 'Address',
257
- category: 'Inputs',
258
- defaultConfigs: { label: 'Address' },
259
- render: (props) => {
260
- var _a;
261
- const value = ((_a = props.data) !== null && _a !== void 0 ? _a : {});
262
- return fieldBlock(props, 'Address', h("div", { class: "fk-address" }, ADDRESS_PARTS.map((part) => {
263
- var _a;
264
- return (h("label", { class: { 'fk-address__part': true, 'fk-address__part--full': part.full }, key: part.key }, h("span", { class: "fk-address__label" }, part.label()), h("input", { class: "fk-field__input", type: "text", value: (_a = value[part.key]) !== null && _a !== void 0 ? _a : '', disabled: props.editable || props.disabled, onInput: (event) => {
265
- var _a;
266
- const raw = event.target.value;
267
- const next = Object.assign(Object.assign({}, value), { [part.key]: raw || undefined });
268
- const cleaned = Object.fromEntries(Object.entries(next).filter(([, entry]) => entry !== undefined));
269
- (_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, Object.keys(cleaned).length ? cleaned : undefined);
270
- } })));
271
- })));
272
- },
273
- });
274
- export const fileBrick = createBrick({
275
- type: 'input',
276
- dataType: 'object',
277
- id: 'file',
278
- name: 'File',
279
- category: 'Data',
280
- defaultConfigs: { label: 'File', accept: '', uploadUrl: '', multiple: false },
281
- render: (props) => {
282
- var _a, _b, _c;
283
- return fieldBlock(props, 'File', h("fk-file-input", { value: props.data, accept: (_a = props.configs) === null || _a === void 0 ? void 0 : _a.accept, uploadUrl: (_b = props.configs) === null || _b === void 0 ? void 0 : _b.uploadUrl, multiple: ((_c = props.configs) === null || _c === void 0 ? void 0 : _c.multiple) === true, disabled: props.editable || props.disabled, onFileValueChange: (event) => {
284
- var _a;
285
- event.stopPropagation();
286
- (_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, event.detail);
287
- } }));
288
- },
289
- });
290
- export const dataGridBrick = createBrick({
291
- type: 'collection',
292
- dataType: 'array',
293
- id: 'data-grid',
294
- name: 'Data grid',
295
- category: 'Data',
296
- defaultConfigs: { label: 'Data grid' },
297
- render: (props) => props.editable || !props.brickSpec ? (fieldBlock(props, 'Data grid', h("div", { class: "fk-grid-template" }, h("span", { class: "fk-grid-template__hint" }, fkT('grid.columns')), props.children))) : (fieldBlock(props, 'Data grid', h("fk-data-grid", { spec: props.brickSpec, value: props.data, disabled: props.disabled, locale: props.locale, utils: props.utils, onGridValueChange: (event) => {
298
- var _a;
299
- event.stopPropagation();
300
- (_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, event.detail);
301
- } }))),
302
- });
303
- export const hiddenBrick = createBrick({
304
- type: 'input',
305
- dataType: 'string',
306
- id: 'hidden',
307
- name: 'Hidden',
308
- category: 'Data',
309
- defaultConfigs: {},
310
- render: (props) => {
311
- var _a, _b;
312
- return props.editable ? (h("div", { class: "fk-hidden-chip" }, "hidden: ", (_a = props.configs) === null || _a === void 0 ? void 0 :
313
- _a.key)) : (h("input", { type: "hidden", value: (_b = props.data) !== null && _b !== void 0 ? _b : '' }));
314
- },
315
- });
316
- export const contentBrick = createBrick({
317
- type: 'output',
318
- dataType: 'void',
319
- id: 'content',
320
- name: 'Content',
321
- category: 'Layout',
322
- defaultConfigs: { content: 'Some text…' },
323
- render: (props) => {
324
- var _a, _b;
325
- return (h("div", { class: "fk-content", style: asInlineStyle(props.styles) }, String((_b = (_a = props.configs) === null || _a === void 0 ? void 0 : _a.content) !== null && _b !== void 0 ? _b : '')
326
- .split('\n')
327
- .map((line) => (h("p", { class: "fk-content__line" }, line)))));
328
- },
329
- });
330
- export const stepperBrick = createBrick({
331
- type: 'panel',
332
- dataType: 'void',
333
- id: 'stepper',
334
- name: 'Stepper',
335
- category: 'Layout',
336
- defaultConfigs: {
337
- validateSteps: false,
338
- allowStepClick: true,
339
- showSubmit: false,
340
- },
341
- render: (props) => {
342
- var _a, _b;
343
- const labels = ((_b = (_a = props.brickSpec) === null || _a === void 0 ? void 0 : _a.children) !== null && _b !== void 0 ? _b : []).map((child, index) => {
344
- var _a, _b;
345
- const resolved = resolveLocalizedText((_a = child.configs) === null || _a === void 0 ? void 0 : _a.label, props.locale);
346
- return typeof resolved === 'string'
347
- ? resolved
348
- : ((_b = child.name) !== null && _b !== void 0 ? _b : `Step ${index + 1}`);
349
- });
350
- return (h("fk-stepper", { stepLabels: labels, editable: props.editable, spec: props.brickSpec, dataMap: props.dataMap, locale: props.locale, style: asInlineStyle(props.styles) }, props.children));
351
- },
352
- });
353
- export const checkboxBrick = createBrick({
354
- type: 'input',
355
- dataType: 'boolean',
356
- id: 'checkbox',
357
- name: 'Checkbox',
358
- category: 'Inputs',
359
- defaultConfigs: { label: 'Checkbox' },
360
- render: (props) => (h("label", { class: "fk-field fk-field--inline", style: asInlineStyle(props.styles) }, h("input", { class: "fk-field__checkbox", type: "checkbox", checked: props.data === true, disabled: props.editable || props.disabled, onChange: (event) => { var _a; return (_a = props.onDataChange) === null || _a === void 0 ? void 0 : _a.call(props, event.target.checked); } }), h("span", { class: "fk-field__label" }, labelOf(props, 'Checkbox')), props.error ? h("span", { class: "fk-field__error" }, props.error) : null)),
361
- });
362
- export const groupBrick = createBrick({
363
- type: 'panel',
364
- dataType: 'void',
365
- id: 'group',
366
- name: 'Group',
367
- category: 'Layout',
368
- render: (props) => {
369
- var _a;
370
- return (h("fieldset", { class: "fk-group", style: asInlineStyle(props.styles) }, ((_a = props.configs) === null || _a === void 0 ? void 0 : _a.label) ? (h("legend", { class: "fk-group__legend" }, props.configs.label)) : null, props.children));
371
- },
372
- });
373
- export const rowBrick = createBrick({
374
- type: 'panel',
375
- dataType: 'void',
376
- id: 'row',
377
- name: 'Row',
378
- category: 'Layout',
379
- render: (props) => (h("div", { class: "fk-row", style: asInlineStyle(props.styles) }, props.children)),
380
- });
381
- export const columnBrick = createBrick({
382
- type: 'panel',
383
- dataType: 'void',
384
- id: 'column',
385
- name: 'Column',
386
- category: 'Layout',
387
- render: (props) => (h("div", { class: "fk-column", style: asInlineStyle(props.styles) }, props.children)),
388
- });
389
- const formatRecapValue = (brick, value) => {
390
- var _a;
391
- if (Array.isArray(value)) {
392
- return value
393
- .map((item) => formatRecapValue(brick, item))
394
- .filter(Boolean)
395
- .join(', ');
396
- }
397
- if (value === true)
398
- return fkTOr('recap.yes', 'Yes');
399
- if (value === false)
400
- return fkTOr('recap.no', 'No');
401
- if (value && typeof value === 'object') {
402
- const record = value;
403
- if (typeof record.name === 'string' && 'url' in record)
404
- return record.name;
405
- return Object.values(record)
406
- .filter((part) => typeof part === 'string' && part)
407
- .join(' ');
408
- }
409
- const raw = String(value !== null && value !== void 0 ? value : '');
410
- if (((_a = brick.configs) === null || _a === void 0 ? void 0 : _a.options) != null) {
411
- const labelKey = typeof brick.configs.labelKey === 'string' ? brick.configs.labelKey : 'label';
412
- const valueKey = typeof brick.configs.valueKey === 'string' ? brick.configs.valueKey : 'value';
413
- const match = normalizeOptions(brick.configs.options, labelKey, valueKey).find((option) => option.value === raw);
414
- if (match)
415
- return match.label;
416
- }
417
- return raw;
418
- };
419
- const isEmptyRecapValue = (raw) => raw === undefined ||
420
- raw === null ||
421
- raw === '' ||
422
- (Array.isArray(raw) && raw.length === 0);
423
- const brickLabel = (brick, locale) => {
424
- var _a, _b, _c, _d, _e;
425
- return String((_e = (_c = (_b = resolveLocalizedText((_a = brick.configs) === null || _a === void 0 ? void 0 : _a.label, locale)) !== null && _b !== void 0 ? _b : brick.name) !== null && _c !== void 0 ? _c : (_d = brick.configs) === null || _d === void 0 ? void 0 : _d.key) !== null && _e !== void 0 ? _e : '');
426
- };
427
- const collectionInputs = (spec) => {
428
- var _a, _b;
429
- const inputs = [];
430
- for (const child of (_a = spec.children) !== null && _a !== void 0 ? _a : []) {
431
- const key = (_b = child.configs) === null || _b === void 0 ? void 0 : _b.key;
432
- if (child.type === 'input' && key && !key.startsWith('_')) {
433
- inputs.push(child);
434
- }
435
- else if (child.type === 'panel') {
436
- inputs.push(...collectionInputs(child));
437
- }
438
- }
439
- return inputs;
440
- };
441
- const collectRecapItems = (spec, dataMap, locale, showEmpty, groupBySections = false) => {
442
- var _a, _b, _c;
443
- if (!spec)
444
- return [];
445
- const items = [];
446
- for (const child of (_a = spec.children) !== null && _a !== void 0 ? _a : []) {
447
- if (child.id === 'recap' || child.type === 'action')
448
- continue;
449
- if (getAffectedProperties(child.rules, dataMap).hidden === true)
450
- continue;
451
- const key = (_b = child.configs) === null || _b === void 0 ? void 0 : _b.key;
452
- const label = brickLabel(child, locale);
453
- if (child.type === 'collection') {
454
- const rows = key && Array.isArray(dataMap === null || dataMap === void 0 ? void 0 : dataMap[key])
455
- ? dataMap[key]
456
- : [];
457
- if (!rows.length && !showEmpty)
458
- continue;
459
- const inputs = collectionInputs(child);
460
- items.push({
461
- kind: 'collection',
462
- label,
463
- columns: inputs.map((input) => brickLabel(input, locale)),
464
- rows: rows.map((row) => inputs.map((input) => {
465
- const raw = row === null || row === void 0 ? void 0 : row[input.configs.key];
466
- return isEmptyRecapValue(raw) ? '—' : formatRecapValue(input, raw);
467
- })),
468
- });
469
- continue;
470
- }
471
- if (child.type === 'panel') {
472
- const sectionLabel = resolveLocalizedText((_c = child.configs) === null || _c === void 0 ? void 0 : _c.label, locale);
473
- if (groupBySections &&
474
- typeof sectionLabel === 'string' &&
475
- sectionLabel.trim()) {
476
- const sectionItems = collectRecapItems(child, dataMap, locale, showEmpty);
477
- if (sectionItems.length) {
478
- items.push({ kind: 'section', label: sectionLabel });
479
- items.push(...sectionItems);
480
- }
481
- continue;
482
- }
483
- items.push(...collectRecapItems(child, dataMap, locale, showEmpty, groupBySections));
484
- continue;
485
- }
486
- if (child.type !== 'input' || !key || key.startsWith('_'))
487
- continue;
488
- const raw = dataMap === null || dataMap === void 0 ? void 0 : dataMap[key];
489
- if (isEmptyRecapValue(raw) && !showEmpty)
490
- continue;
491
- items.push({
492
- kind: 'field',
493
- label,
494
- value: isEmptyRecapValue(raw) ? '—' : formatRecapValue(child, raw),
495
- });
496
- }
497
- return items;
498
- };
499
- export const recapBrick = createBrick({
500
- type: 'output',
501
- dataType: 'void',
502
- id: 'recap',
503
- name: 'Recap',
504
- category: 'Layout',
505
- defaultConfigs: { label: 'Recap', showEmpty: false, groupBySections: false },
506
- render: (props) => {
507
- var _a, _b;
508
- const items = collectRecapItems(props.rootSpec, props.dataMap, props.locale, ((_a = props.configs) === null || _a === void 0 ? void 0 : _a.showEmpty) === true, ((_b = props.configs) === null || _b === void 0 ? void 0 : _b.groupBySections) === true);
509
- const blocks = [];
510
- let fields = [];
511
- const flushFields = () => {
512
- if (!fields.length)
513
- return;
514
- blocks.push(h("dl", { class: "fk-recap__list" }, fields.map((field) => (h("div", { class: "fk-recap__row", key: field.label }, h("dt", { class: "fk-recap__term" }, field.label), h("dd", { class: "fk-recap__value" }, field.value))))));
515
- fields = [];
516
- };
517
- for (const item of items) {
518
- if (item.kind === 'field') {
519
- fields.push(item);
520
- continue;
521
- }
522
- flushFields();
523
- if (item.kind === 'section') {
524
- blocks.push(h("span", { class: "fk-recap__group-title", key: `section:${item.label}` }, item.label));
525
- continue;
526
- }
527
- blocks.push(h("section", { class: "fk-recap__section", key: item.label }, h("span", { class: "fk-recap__section-title" }, item.label), item.rows.length ? (h("div", { class: "fk-recap__table-wrap" }, h("table", { class: "fk-recap__table" }, h("thead", null, h("tr", null, h("th", { class: "fk-recap__index-cell" }, "#"), item.columns.map((column) => (h("th", { key: column }, column))))), h("tbody", null, item.rows.map((row, index) => (h("tr", { key: index }, h("td", { class: "fk-recap__index-cell" }, index + 1), row.map((cell, cellIndex) => (h("td", { key: cellIndex }, cell)))))))))) : (h("p", { class: "fk-recap__empty" }, fkTOr('recap.empty', 'Nothing to summarize yet.')))));
528
- }
529
- flushFields();
530
- return (h("div", { class: "fk-field fk-recap", style: asInlineStyle(props.styles) }, h("span", { class: "fk-field__label" }, labelOf(props, 'Recap')), blocks.length ? (blocks) : (h("p", { class: "fk-recap__empty" }, fkTOr('recap.empty', 'Nothing to summarize yet.')))));
531
- },
532
- });
533
- export function registerDefaultBricks() {
534
- registerBricks([
535
- textInputBrick,
536
- emailBrick,
537
- passwordBrick,
538
- urlBrick,
539
- phoneBrick,
540
- textareaBrick,
541
- numberBrick,
542
- dateBrick,
543
- timeBrick,
544
- datetimeBrick,
545
- selectBrick,
546
- multiSelectBrick,
547
- radioBrick,
548
- selectBoxesBrick,
549
- checkboxBrick,
550
- tagsBrick,
551
- signatureBrick,
552
- addressBrick,
553
- fileBrick,
554
- dataGridBrick,
555
- hiddenBrick,
556
- contentBrick,
557
- recapBrick,
558
- groupBrick,
559
- rowBrick,
560
- columnBrick,
561
- stepperBrick,
562
- tabsBrick,
563
- ]);
564
- }
@@ -1,44 +0,0 @@
1
- var _a;
2
- const GLOBAL_KEY = Symbol.for('formkrafter.wc.bricks');
3
- const globalStore = globalThis;
4
- const bricks = ((_a = globalStore[GLOBAL_KEY]) !== null && _a !== void 0 ? _a : (globalStore[GLOBAL_KEY] = new Map()));
5
- const keyOf = (type, id) => `${type}:${id}`;
6
- export function registerBrick(brick) {
7
- bricks.set(keyOf(brick.type, brick.id), brick);
8
- }
9
- export function registerBricks(list) {
10
- list.forEach(registerBrick);
11
- }
12
- export function getBrick(type, id) {
13
- return bricks.get(keyOf(type, id));
14
- }
15
- export function getBrickMolds() {
16
- return [...bricks.values()]
17
- .filter((brick) => !brick.isPrivate)
18
- .map((brick) => ({
19
- type: brick.type,
20
- id: brick.id,
21
- name: brick.name,
22
- configsForm: brick.configsForm,
23
- category: brick.category,
24
- isPrivate: brick.isPrivate,
25
- }));
26
- }
27
- export function getBrickMoldsGroupedByCategory() {
28
- var _a, _b;
29
- const grouped = {};
30
- for (const mold of getBrickMolds()) {
31
- const category = (_a = mold.category) !== null && _a !== void 0 ? _a : 'Uncategorized';
32
- ((_b = grouped[category]) !== null && _b !== void 0 ? _b : (grouped[category] = [])).push(mold);
33
- }
34
- return grouped;
35
- }
36
- export function newBrickSpec(type, id) {
37
- var _a, _b;
38
- const brick = getBrick(type, id);
39
- if (!brick)
40
- return undefined;
41
- const empty = brick.getBrickEmptySpec();
42
- const uid = crypto.randomUUID();
43
- return Object.assign(Object.assign({}, empty), { configs: Object.assign(Object.assign({}, empty.configs), { uid, key: (_b = (_a = empty.configs) === null || _a === void 0 ? void 0 : _a.key) !== null && _b !== void 0 ? _b : `${id}_${uid.slice(0, 6)}` }) });
44
- }
@@ -1,16 +0,0 @@
1
- export function getBrickData(brickSpec, data) {
2
- var _a;
3
- if (!((_a = brickSpec.configs) === null || _a === void 0 ? void 0 : _a.key) || !data)
4
- return undefined;
5
- if (brickSpec.unWrapData)
6
- return data;
7
- return data[brickSpec.configs.key];
8
- }
9
- export function wrapBrickData(brickSpec, value) {
10
- var _a;
11
- if (!((_a = brickSpec.configs) === null || _a === void 0 ? void 0 : _a.key))
12
- return undefined;
13
- if (brickSpec.unWrapData)
14
- return value;
15
- return { [brickSpec.configs.key]: value };
16
- }
@@ -1,14 +0,0 @@
1
- import { getBrickMolds } from "../registry/registry";
2
- export function toBrickDropDetail(data, parentPath, index) {
3
- if (data.kind === 'new-brick') {
4
- const mold = getBrickMolds().find((candidate) => candidate.type === data.moldType &&
5
- candidate.id === data.moldId);
6
- if (!mold)
7
- return undefined;
8
- return { source: 'new', mold, parentPath, index };
9
- }
10
- if (data.kind === 'move-brick') {
11
- return { source: 'move', from: data.path, parentPath, index };
12
- }
13
- return undefined;
14
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,21 +0,0 @@
1
- export function normalizeOptions(raw, labelKey = 'label', valueKey = 'value') {
2
- if (Array.isArray(raw)) {
3
- return raw
4
- .map((item) => {
5
- var _a, _b;
6
- if (typeof item === 'object' && item !== null) {
7
- const record = item;
8
- const label = (_a = record[labelKey]) !== null && _a !== void 0 ? _a : record[valueKey];
9
- const value = (_b = record[valueKey]) !== null && _b !== void 0 ? _b : record[labelKey];
10
- return { label: String(label !== null && label !== void 0 ? label : ''), value: String(value !== null && value !== void 0 ? value : '') };
11
- }
12
- return { label: String(item), value: String(item) };
13
- })
14
- .filter((option) => option.label !== '');
15
- }
16
- return String(raw !== null && raw !== void 0 ? raw : '')
17
- .split('\n')
18
- .map((line) => line.trim())
19
- .filter(Boolean)
20
- .map((line) => ({ label: line, value: line }));
21
- }