@plitzi/sdk-elements 0.39.0 → 0.39.1

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 (33) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/elements/declarations/index.d.ts +78 -2
  3. package/dist/elements/declarations/index.mjs +24 -22
  4. package/dist/elements/form/Form/Form.d.ts +2 -1
  5. package/dist/elements/form/FormControl/FormControl.d.ts +7 -9
  6. package/dist/elements/form/FormControl/FormControl.mjs +110 -105
  7. package/dist/elements/form/FormControl/Settings.d.ts +4 -2
  8. package/dist/elements/form/FormControl/Settings.mjs +113 -172
  9. package/dist/elements/form/FormControl/declaration.d.ts +45 -1
  10. package/dist/elements/form/FormControl/declaration.mjs +7 -20
  11. package/dist/elements/form/FormControl/hocs/withFieldValue.d.ts +2 -1
  12. package/dist/elements/form/FormControl/hocs/withFieldValue.mjs +4 -1
  13. package/dist/elements/form/FormControl/index.d.ts +45 -1
  14. package/dist/elements/form/FormControl/inputs/FileInput.d.ts +21 -0
  15. package/dist/elements/form/FormControl/inputs/FileInput.mjs +29 -0
  16. package/dist/elements/form/FormControl/subTypes.d.ts +17 -0
  17. package/dist/elements/form/FormControl/subTypes.mjs +58 -0
  18. package/dist/elements/index.d.ts +3 -1
  19. package/dist/elements/index.mjs +12 -10
  20. package/dist/elements/settings.mjs +20 -18
  21. package/dist/elements/structure/FocusGroup/FocusGroup.d.ts +24 -0
  22. package/dist/elements/structure/FocusGroup/FocusGroup.mjs +27 -0
  23. package/dist/elements/structure/FocusGroup/Settings.d.ts +8 -0
  24. package/dist/elements/structure/FocusGroup/Settings.mjs +39 -0
  25. package/dist/elements/structure/FocusGroup/arrowFocus.d.ts +12 -0
  26. package/dist/elements/structure/FocusGroup/arrowFocus.mjs +30 -0
  27. package/dist/elements/structure/FocusGroup/declaration.d.ts +36 -0
  28. package/dist/elements/structure/FocusGroup/declaration.mjs +28 -0
  29. package/dist/elements/structure/FocusGroup/index.d.ts +37 -0
  30. package/dist/elements/structure/FocusGroup/index.mjs +6 -0
  31. package/dist/index.d.ts +81 -1
  32. package/dist/index.mjs +19 -17
  33. package/package.json +7 -7
@@ -1,266 +1,207 @@
1
- import { hasFormat as e } from "./helpers/validateField.mjs";
2
- import { useCallback as t, useMemo as n } from "react";
3
- import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
4
- import o from "@plitzi/plitzi-ui/Checkbox";
5
- import s from "@plitzi/plitzi-ui/Input";
6
- import c from "@plitzi/plitzi-ui/TextArea";
7
- import l from "@plitzi/plitzi-ui/Select";
1
+ import { SUBTYPE_LABELS as e, TYPED_SUBTYPES as t } from "./subTypes.mjs";
2
+ import { hasFormat as n } from "./helpers/validateField.mjs";
3
+ import { useCallback as r, useMemo as i } from "react";
4
+ import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
5
+ import c from "@plitzi/plitzi-ui/Checkbox";
6
+ import l from "@plitzi/plitzi-ui/Input";
7
+ import u from "@plitzi/plitzi-ui/TextArea";
8
+ import d from "@plitzi/plitzi-ui/Select";
8
9
  //#region src/elements/form/FormControl/Settings.tsx
9
- var u = (e) => {
10
+ var f = (e) => {
10
11
  let t = parseInt(e, 10);
11
12
  return Number.isNaN(t) || t < 0 ? 0 : t;
12
- }, d = ({ subType: d = "text", name: f = "", label: p = "", hideLabel: m = !1, defaultValue: h = "", placeholder: g = "", autoComplete: _ = !0, autoFocus: v = !1, options: y, required: b = !1, requiredMessage: x = "", minLength: S = 0, minLengthMessage: C = "", maxLength: w = 0, maxLengthMessage: T = "", min: E = "", minMessage: D = "", max: O = "", maxMessage: k = "", step: A = "", formatMessage: j = "", pattern: M = "", patternMessage: N = "", matches: P = "", matchesMessage: F = "", readOnly: I = !1, disabled: L = !1, previewError: R = !1, onUpdate: z }) => {
13
- let B = [
14
- "text",
15
- "textarea",
16
- "number",
17
- "email",
18
- "password",
19
- "search",
20
- "url",
21
- "tel"
22
- ].includes(d), V = t((e) => z?.("name", e), [z]), H = t((e) => z?.("label", e), [z]), U = t((e) => z?.("hideLabel", e.target.checked), [z]), ee = t((e) => z?.("placeholder", e), [z]), W = t((e) => {
23
- z?.("subType", e), z?.("defaultValue", "");
24
- }, [z]), G = t((e) => z?.("defaultValue", e), [z]), K = t((e) => z?.("autoFocus", e.target.checked), [z]), q = t((e) => z?.("autoComplete", e.target.checked), [z]), J = t((e) => z?.("required", e.target.checked), [z]), Y = t((e) => z?.("requiredMessage", e), [z]), X = t((e) => z?.("minLength", u(e)), [z]), Z = t((e) => z?.("minLengthMessage", e), [z]), Q = t((e) => z?.("maxLength", u(e)), [z]), $ = t((e) => z?.("maxLengthMessage", e), [z]), te = t((e) => z?.("min", e.trim()), [z]), ne = t((e) => z?.("minMessage", e), [z]), re = t((e) => z?.("max", e.trim()), [z]), ie = t((e) => z?.("maxMessage", e), [z]), ae = t((e) => z?.("step", e.trim()), [z]), oe = t((e) => z?.("formatMessage", e), [z]), se = t((e) => z?.("pattern", e), [z]), ce = t((e) => z?.("patternMessage", e), [z]), le = t((e) => z?.("matches", e), [z]), ue = t((e) => z?.("matchesMessage", e), [z]), de = t((e) => z?.("readOnly", e.target.checked), [z]), fe = t((e) => z?.("disabled", e.target.checked), [z]), pe = t((e) => z?.("previewError", e.target.checked), [z]), me = t((e) => {
25
- e ? z?.("options", e.split("\n")) : z?.("options", []);
26
- }, [z]), he = n(() => Array.isArray(y) ? y.join("\n") : "", [y]);
27
- return /* @__PURE__ */ a("div", {
13
+ }, p = ({ subType: p = "text", name: m = "", label: h = "", hideLabel: g = !1, defaultValue: _ = "", placeholder: v = "", accept: y = "", autoComplete: ee = !0, autoFocus: b = !1, options: x, required: S = !1, requiredMessage: C = "", minLength: w = 0, minLengthMessage: T = "", maxLength: E = 0, maxLengthMessage: D = "", min: O = "", minMessage: k = "", max: A = "", maxMessage: j = "", step: M = "", formatMessage: N = "", pattern: P = "", patternMessage: F = "", matches: I = "", matchesMessage: L = "", readOnly: R = !1, disabled: z = !1, previewError: B = !1, onUpdate: V }) => {
14
+ let H = t.includes(p), U = r((e) => V?.("name", e), [V]), te = r((e) => V?.("label", e), [V]), W = r((e) => V?.("hideLabel", e.target.checked), [V]), G = r((e) => V?.("placeholder", e), [V]), K = r((e) => V?.("accept", e), [V]), q = r((e) => {
15
+ V?.("subType", e), V?.("defaultValue", "");
16
+ }, [V]), J = r((e) => V?.("defaultValue", e), [V]), Y = r((e) => V?.("autoFocus", e.target.checked), [V]), X = r((e) => V?.("autoComplete", e.target.checked), [V]), Z = r((e) => V?.("required", e.target.checked), [V]), Q = r((e) => V?.("requiredMessage", e), [V]), ne = r((e) => V?.("minLength", f(e)), [V]), re = r((e) => V?.("minLengthMessage", e), [V]), ie = r((e) => V?.("maxLength", f(e)), [V]), ae = r((e) => V?.("maxLengthMessage", e), [V]), oe = r((e) => V?.("min", e.trim()), [V]), se = r((e) => V?.("minMessage", e), [V]), ce = r((e) => V?.("max", e.trim()), [V]), le = r((e) => V?.("maxMessage", e), [V]), ue = r((e) => V?.("step", e.trim()), [V]), de = r((e) => V?.("formatMessage", e), [V]), fe = r((e) => V?.("pattern", e), [V]), pe = r((e) => V?.("patternMessage", e), [V]), $ = r((e) => V?.("matches", e), [V]), me = r((e) => V?.("matchesMessage", e), [V]), he = r((e) => V?.("readOnly", e.target.checked), [V]), ge = r((e) => V?.("disabled", e.target.checked), [V]), _e = r((e) => V?.("previewError", e.target.checked), [V]), ve = r((e) => {
17
+ e ? V?.("options", e.split("\n")) : V?.("options", []);
18
+ }, [V]), ye = i(() => Array.isArray(x) ? x.join("\n") : "", [x]);
19
+ return /* @__PURE__ */ s("div", {
28
20
  className: "flex h-full flex-col gap-4 py-2",
29
21
  children: [
30
- /* @__PURE__ */ i(s, {
31
- value: f,
22
+ /* @__PURE__ */ o(l, {
23
+ value: m,
32
24
  label: "Input Name",
33
- onChange: V,
25
+ onChange: U,
34
26
  size: "xs"
35
27
  }),
36
- /* @__PURE__ */ i(s, {
37
- value: p,
28
+ /* @__PURE__ */ o(l, {
29
+ value: h,
38
30
  label: "Label",
39
- onChange: H,
31
+ onChange: te,
40
32
  size: "xs"
41
33
  }),
42
- /* @__PURE__ */ i(o, {
43
- checked: m,
34
+ /* @__PURE__ */ o(c, {
35
+ checked: g,
44
36
  label: "Hide Label (still read by screen readers)",
45
- onChange: U,
37
+ onChange: W,
46
38
  size: "xs"
47
39
  }),
48
- /* @__PURE__ */ i(s, {
49
- value: g,
40
+ /* @__PURE__ */ o(l, {
41
+ value: v,
50
42
  label: "Placeholder",
51
- onChange: ee,
43
+ onChange: G,
52
44
  size: "xs"
53
45
  }),
54
- /* @__PURE__ */ a(l, {
55
- value: d,
56
- onChange: W,
46
+ /* @__PURE__ */ o(d, {
47
+ value: p,
48
+ onChange: q,
57
49
  label: "Input Type",
58
50
  size: "xs",
59
- children: [
60
- /* @__PURE__ */ i("option", {
61
- value: "text",
62
- children: "Text"
63
- }),
64
- /* @__PURE__ */ i("option", {
65
- value: "number",
66
- children: "Number"
67
- }),
68
- /* @__PURE__ */ i("option", {
69
- value: "date",
70
- children: "Date"
71
- }),
72
- /* @__PURE__ */ i("option", {
73
- value: "time",
74
- children: "Time"
75
- }),
76
- /* @__PURE__ */ i("option", {
77
- value: "email",
78
- children: "Email"
79
- }),
80
- /* @__PURE__ */ i("option", {
81
- value: "search",
82
- children: "Search"
83
- }),
84
- /* @__PURE__ */ i("option", {
85
- value: "url",
86
- children: "URL"
87
- }),
88
- /* @__PURE__ */ i("option", {
89
- value: "tel",
90
- children: "Phone"
91
- }),
92
- /* @__PURE__ */ i("option", {
93
- value: "password",
94
- children: "Password"
95
- }),
96
- /* @__PURE__ */ i("option", {
97
- value: "select",
98
- children: "Select"
99
- }),
100
- /* @__PURE__ */ i("option", {
101
- value: "checkbox",
102
- children: "Checkbox"
103
- }),
104
- /* @__PURE__ */ i("option", {
105
- value: "switch",
106
- children: "Switch"
107
- }),
108
- /* @__PURE__ */ i("option", {
109
- value: "textarea",
110
- children: "Long Text"
111
- }),
112
- /* @__PURE__ */ i("option", {
113
- value: "hidden",
114
- children: "Hidden"
115
- }),
116
- /* @__PURE__ */ i("option", {
117
- value: "color",
118
- children: "Color"
119
- })
120
- ]
51
+ children: Object.entries(e).map(([e, t]) => /* @__PURE__ */ o("option", {
52
+ value: e,
53
+ children: t
54
+ }, e))
55
+ }),
56
+ p === "file" && /* @__PURE__ */ o(l, {
57
+ value: y,
58
+ label: "Accepted Files",
59
+ placeholder: "image/png, image/jpeg, .pdf",
60
+ onChange: K,
61
+ size: "xs"
121
62
  }),
122
- /* @__PURE__ */ i(c, {
123
- value: h,
63
+ p !== "file" && /* @__PURE__ */ o(u, {
64
+ value: _,
124
65
  label: "Default Value",
125
- onChange: G,
66
+ onChange: J,
126
67
  size: "xs"
127
68
  }),
128
- d === "text" && /* @__PURE__ */ i(o, {
129
- checked: _,
69
+ p === "text" && /* @__PURE__ */ o(c, {
70
+ checked: ee,
130
71
  label: "Auto Complete",
131
- onChange: q,
72
+ onChange: X,
132
73
  size: "xs"
133
74
  }),
134
- B && /* @__PURE__ */ i(o, {
135
- checked: I,
75
+ H && /* @__PURE__ */ o(c, {
76
+ checked: R,
136
77
  label: "Read Only",
137
- onChange: de,
78
+ onChange: he,
138
79
  size: "xs"
139
80
  }),
140
- /* @__PURE__ */ i(o, {
141
- checked: v,
81
+ /* @__PURE__ */ o(c, {
82
+ checked: b,
142
83
  label: "Focus When Shown",
143
- onChange: K,
84
+ onChange: Y,
144
85
  size: "xs"
145
86
  }),
146
- d === "select" && /* @__PURE__ */ i(c, {
147
- value: he,
87
+ p === "select" && /* @__PURE__ */ o(u, {
88
+ value: ye,
148
89
  label: "Options",
149
- onChange: me,
90
+ onChange: ve,
150
91
  size: "xs"
151
92
  }),
152
- /* @__PURE__ */ i(o, {
153
- checked: b,
93
+ /* @__PURE__ */ o(c, {
94
+ checked: S,
154
95
  label: "Required",
155
- onChange: J,
96
+ onChange: Z,
156
97
  size: "xs"
157
98
  }),
158
- b && /* @__PURE__ */ i(s, {
159
- value: x,
99
+ S && /* @__PURE__ */ o(l, {
100
+ value: C,
160
101
  label: "Required Message",
161
- onChange: Y,
102
+ onChange: Q,
162
103
  size: "xs"
163
104
  }),
164
- B && /* @__PURE__ */ i(s, {
165
- value: S ? String(S) : "",
105
+ H && /* @__PURE__ */ o(l, {
106
+ value: w ? String(w) : "",
166
107
  label: "Min Length",
167
- onChange: X,
108
+ onChange: ne,
168
109
  size: "xs"
169
110
  }),
170
- B && S > 0 && /* @__PURE__ */ i(s, {
171
- value: C,
111
+ H && w > 0 && /* @__PURE__ */ o(l, {
112
+ value: T,
172
113
  label: "Min Length Message",
173
- onChange: Z,
114
+ onChange: re,
174
115
  size: "xs"
175
116
  }),
176
- B && /* @__PURE__ */ i(s, {
177
- value: w ? String(w) : "",
117
+ H && /* @__PURE__ */ o(l, {
118
+ value: E ? String(E) : "",
178
119
  label: "Max Length",
179
- onChange: Q,
120
+ onChange: ie,
180
121
  size: "xs"
181
122
  }),
182
- B && w > 0 && /* @__PURE__ */ i(s, {
183
- value: T,
123
+ H && E > 0 && /* @__PURE__ */ o(l, {
124
+ value: D,
184
125
  label: "Max Length Message",
185
- onChange: $,
126
+ onChange: ae,
186
127
  size: "xs"
187
128
  }),
188
- d === "number" && /* @__PURE__ */ a(r, { children: [
189
- /* @__PURE__ */ i(s, {
190
- value: E,
129
+ p === "number" && /* @__PURE__ */ s(a, { children: [
130
+ /* @__PURE__ */ o(l, {
131
+ value: O,
191
132
  label: "Least Number",
192
- onChange: te,
133
+ onChange: oe,
193
134
  size: "xs"
194
135
  }),
195
- E !== "" && /* @__PURE__ */ i(s, {
196
- value: D,
136
+ O !== "" && /* @__PURE__ */ o(l, {
137
+ value: k,
197
138
  label: "Too Small Message",
198
- onChange: ne,
139
+ onChange: se,
199
140
  size: "xs"
200
141
  }),
201
- /* @__PURE__ */ i(s, {
202
- value: O,
142
+ /* @__PURE__ */ o(l, {
143
+ value: A,
203
144
  label: "Greatest Number",
204
- onChange: re,
145
+ onChange: ce,
205
146
  size: "xs"
206
147
  }),
207
- O !== "" && /* @__PURE__ */ i(s, {
208
- value: k,
148
+ A !== "" && /* @__PURE__ */ o(l, {
149
+ value: j,
209
150
  label: "Too Large Message",
210
- onChange: ie,
151
+ onChange: le,
211
152
  size: "xs"
212
153
  }),
213
- /* @__PURE__ */ i(s, {
214
- value: A,
154
+ /* @__PURE__ */ o(l, {
155
+ value: M,
215
156
  label: "Step",
216
- onChange: ae,
157
+ onChange: ue,
217
158
  size: "xs"
218
159
  })
219
160
  ] }),
220
- e(d) && /* @__PURE__ */ i(s, {
221
- value: j,
161
+ n(p) && /* @__PURE__ */ o(l, {
162
+ value: N,
222
163
  label: "Invalid Format Message",
223
- onChange: oe,
164
+ onChange: de,
224
165
  size: "xs"
225
166
  }),
226
- B && /* @__PURE__ */ i(s, {
227
- value: M,
167
+ H && /* @__PURE__ */ o(l, {
168
+ value: P,
228
169
  label: "Pattern (regular expression)",
229
- onChange: se,
170
+ onChange: fe,
230
171
  size: "xs"
231
172
  }),
232
- B && M && /* @__PURE__ */ i(s, {
233
- value: N,
173
+ H && P && /* @__PURE__ */ o(l, {
174
+ value: F,
234
175
  label: "Pattern Message",
235
- onChange: ce,
176
+ onChange: pe,
236
177
  size: "xs"
237
178
  }),
238
- B && /* @__PURE__ */ i(s, {
239
- value: P,
179
+ H && /* @__PURE__ */ o(l, {
180
+ value: I,
240
181
  label: "Must Match Field",
241
- onChange: le,
182
+ onChange: $,
242
183
  size: "xs"
243
184
  }),
244
- B && P && /* @__PURE__ */ i(s, {
245
- value: F,
185
+ H && I && /* @__PURE__ */ o(l, {
186
+ value: L,
246
187
  label: "Mismatch Message",
247
- onChange: ue,
188
+ onChange: me,
248
189
  size: "xs"
249
190
  }),
250
- /* @__PURE__ */ i(o, {
251
- checked: L,
191
+ /* @__PURE__ */ o(c, {
192
+ checked: z,
252
193
  label: "Disabled",
253
- onChange: fe,
194
+ onChange: ge,
254
195
  size: "xs"
255
196
  }),
256
- /* @__PURE__ */ i(o, {
257
- checked: R,
197
+ /* @__PURE__ */ o(c, {
198
+ checked: B,
258
199
  label: "Preview Error Message",
259
- onChange: pe,
200
+ onChange: _e,
260
201
  size: "xs"
261
202
  })
262
203
  ]
263
204
  });
264
205
  };
265
206
  //#endregion
266
- export { d as default };
207
+ export { p as default };
@@ -10,7 +10,7 @@ declare const declaration: import('@plitzi/sdk-shared/authoring').DeclaredElemen
10
10
  readonly type: "formControl";
11
11
  readonly contentAttributes: readonly ["label", "placeholder", "options", "requiredMessage", "minLengthMessage", "maxLengthMessage", "minMessage", "maxMessage", "formatMessage", "patternMessage", "matchesMessage"];
12
12
  readonly attributeValues: {
13
- readonly subType: readonly string[];
13
+ readonly subType: readonly ["text", "number", "email", "password", "search", "url", "tel", "date", "time", "checkbox", "switch", "select", "textarea", "hidden", "color", "file"];
14
14
  };
15
15
  readonly triggers: {
16
16
  readonly onChange: {
@@ -32,6 +32,7 @@ declare const declaration: import('@plitzi/sdk-shared/authoring').DeclaredElemen
32
32
  readonly label: "Label";
33
33
  readonly hideLabel: false;
34
34
  readonly placeholder: "";
35
+ readonly accept: "";
35
36
  readonly defaultValue: "";
36
37
  readonly autoComplete: true;
37
38
  readonly autoFocus: false;
@@ -554,6 +555,49 @@ declare const declaration: import('@plitzi/sdk-shared/authoring').DeclaredElemen
554
555
  };
555
556
  };
556
557
  };
558
+ readonly file: {
559
+ name: string;
560
+ displayMode: "desktop";
561
+ style: {
562
+ label: {
563
+ default: {
564
+ 'margin-bottom': string;
565
+ display: string;
566
+ cursor: string;
567
+ 'font-weight': string;
568
+ 'font-size': string;
569
+ 'line-height': string;
570
+ color: string;
571
+ 'user-select': string;
572
+ };
573
+ };
574
+ requiredMark: {
575
+ default: {
576
+ color: string;
577
+ 'margin-left': string;
578
+ };
579
+ };
580
+ error: {
581
+ default: {
582
+ display: string;
583
+ color: string;
584
+ 'margin-top': string;
585
+ };
586
+ };
587
+ icon?: {
588
+ default: Record<string, string>;
589
+ } | undefined;
590
+ field?: {
591
+ default: Record<string, string>;
592
+ } | undefined;
593
+ base: {
594
+ default: {};
595
+ };
596
+ input: {
597
+ default: Record<string, string>;
598
+ };
599
+ };
600
+ };
557
601
  readonly textarea: {
558
602
  name: string;
559
603
  displayMode: "desktop";
@@ -1,4 +1,5 @@
1
- import { elementDeclaration as e, valuesOf as t } from "@plitzi/sdk-shared/authoring";
1
+ import { FORM_CONTROL_SUBTYPES as e } from "./subTypes.mjs";
2
+ import { elementDeclaration as t } from "@plitzi/sdk-shared/authoring";
2
3
  //#region src/elements/form/FormControl/declaration.ts
3
4
  var n = {
4
5
  width: "100%",
@@ -146,7 +147,7 @@ var n = {
146
147
  requiredMark: { default: s },
147
148
  error: { default: o }
148
149
  }
149
- }), h = { field: l }, g = e()({
150
+ }), h = { field: l }, g = t()({
150
151
  type: "formControl",
151
152
  contentAttributes: [
152
153
  "label",
@@ -161,23 +162,7 @@ var n = {
161
162
  "patternMessage",
162
163
  "matchesMessage"
163
164
  ],
164
- attributeValues: { subType: t()([
165
- "text",
166
- "number",
167
- "email",
168
- "password",
169
- "search",
170
- "url",
171
- "tel",
172
- "date",
173
- "time",
174
- "checkbox",
175
- "switch",
176
- "select",
177
- "textarea",
178
- "hidden",
179
- "color"
180
- ]) },
165
+ attributeValues: { subType: e },
181
166
  triggers: { onChange: {
182
167
  action: "onChange",
183
168
  title: "On Change",
@@ -196,6 +181,7 @@ var n = {
196
181
  label: "Label",
197
182
  hideLabel: !1,
198
183
  placeholder: "",
184
+ accept: "",
199
185
  defaultValue: "",
200
186
  autoComplete: !0,
201
187
  autoFocus: !1,
@@ -221,7 +207,7 @@ var n = {
221
207
  },
222
208
  definition: {
223
209
  label: "Form Control",
224
- description: "A single labelled input (text/select/checkbox/… per its subType) inside a form; captures one field of user input. Optional unless `required: true`, as an HTML field is: a `requiredMessage` alone requires nothing. A `number` field takes `min` and `max` (each said by its `minMessage`/`maxMessage` when broken) and `step`, written as numbers are — `'2'`; `''` for none. A select offers its `options`: `[{ label, value }, …]` — the text shown, and what the field takes. A `switch` is a checkbox announced and drawn as an on/off switch (`role=\"switch\"`), for a setting that applies at once; both hold `true`/`false`, and a `defaultValue` of `\"true\"` starts them on. Its slots: `label`, `requiredMark` (the `*` that ends the label of a required field), `input` (the box a typed field or a select is drawn in — a textarea, checkbox or switch is its own box), `field` (the `<input>` or `<select>` inside that box), `icon` (the show/hide button of a password) and `error`. The box is ringed (`2px solid currentColor`) while the field inside has keyboard focus: restyle it with a `focus-within` state on the `input` slot — the box never takes `focus` itself. The thumb of a switch is no element a class reaches: the class on its `input` slot sets `--plitzi-switch-thumb` (off), `--plitzi-switch-thumb-checked` (on, white by default) and `--plitzi-switch-thumb-shadow`.",
210
+ description: "A single labelled input (text/select/checkbox/… per its subType) inside a form; captures one field of user input. Optional unless `required: true`, as an HTML field is: a `requiredMessage` alone requires nothing. A `number` field takes `min` and `max` (each said by its `minMessage`/`maxMessage` when broken) and `step`, written as numbers are — `'2'`; `''` for none. A `file` field holds the `File` picked; a `webHook` whose body holds it sends it as multipart, under its `name`, and `accept` says what the picker offers — `'image/png,image/jpeg'`. A select offers its `options`: `[{ label, value }, …]` — the text shown, and what the field takes. A `switch` is a checkbox announced and drawn as an on/off switch (`role=\"switch\"`), for a setting that applies at once; both hold `true`/`false`, and a `defaultValue` of `\"true\"` starts them on. Its slots: `label`, `requiredMark` (the `*` that ends the label of a required field), `input` (the box a typed field or a select is drawn in — a textarea, checkbox or switch is its own box), `field` (the `<input>` or `<select>` inside that box), `icon` (the show/hide button of a password) and `error`. The box is ringed (`2px solid currentColor`) while the field inside has keyboard focus: restyle it with a `focus-within` state on the `input` slot — the box never takes `focus` itself. The thumb of a switch is no element a class reaches: the class on its `input` slot sets `--plitzi-switch-thumb` (off), `--plitzi-switch-thumb-checked` (on, white by default) and `--plitzi-switch-thumb-shadow`.",
225
211
  styleSelectors: {
226
212
  label: "",
227
213
  requiredMark: "",
@@ -253,6 +239,7 @@ var n = {
253
239
  date: m("Form Control Date", r, h),
254
240
  time: m("Form Control Time", r, h),
255
241
  color: m("Form Control Color", r, h),
242
+ file: m("Form Control File", r, h),
256
243
  textarea: m("Form Control Textarea", {
257
244
  ...r,
258
245
  color: "inherit",
@@ -1,9 +1,10 @@
1
+ import { FormControlSubType } from '../subTypes';
1
2
  import { FC, RefObject } from 'react';
2
3
  export type WithFieldValueProps<T> = {
3
4
  ref: RefObject<HTMLElement>;
4
5
  name: string;
5
6
  defaultValue?: string;
6
- subType: 'hidden' | 'text' | 'number' | 'email' | 'password' | 'date' | 'time' | 'select' | 'checkbox' | 'textarea' | 'color' | 'switch';
7
+ subType: FormControlSubType;
7
8
  required: boolean;
8
9
  requiredMessage?: string;
9
10
  minLength?: number;
@@ -74,7 +74,10 @@ var u = (u) => {
74
74
  ]);
75
75
  let K = t((e) => {
76
76
  let t = e.target.type === "radio" || e.target.type === "checkbox";
77
- W ? W(f, t ? e.target.checked : e.target.value) : F(t ? String(e.target.checked) : e.target.value);
77
+ if (e.target.type === "file") {
78
+ let t = e.target.files?.[0] ?? null;
79
+ W && W(f, t);
80
+ } else W ? W(f, t ? e.target.checked : e.target.value) : F(t ? String(e.target.checked) : e.target.value);
78
81
  }, [W, f]), q = t(() => G?.(f, e(z, V, R ?? {})), [
79
82
  z,
80
83
  V,
@@ -19,6 +19,7 @@ declare const FormControl: {
19
19
  readonly label: "Label";
20
20
  readonly hideLabel: false;
21
21
  readonly placeholder: "";
22
+ readonly accept: "";
22
23
  readonly defaultValue: "";
23
24
  readonly autoComplete: true;
24
25
  readonly autoFocus: false;
@@ -544,6 +545,49 @@ declare const FormControl: {
544
545
  };
545
546
  };
546
547
  };
548
+ readonly file: {
549
+ name: string;
550
+ displayMode: "desktop";
551
+ style: {
552
+ label: {
553
+ default: {
554
+ 'margin-bottom': string;
555
+ display: string;
556
+ cursor: string;
557
+ 'font-weight': string;
558
+ 'font-size': string;
559
+ 'line-height': string;
560
+ color: string;
561
+ 'user-select': string;
562
+ };
563
+ };
564
+ requiredMark: {
565
+ default: {
566
+ color: string;
567
+ 'margin-left': string;
568
+ };
569
+ };
570
+ error: {
571
+ default: {
572
+ display: string;
573
+ color: string;
574
+ 'margin-top': string;
575
+ };
576
+ };
577
+ icon?: {
578
+ default: Record<string, string>;
579
+ } | undefined;
580
+ field?: {
581
+ default: Record<string, string>;
582
+ } | undefined;
583
+ base: {
584
+ default: {};
585
+ };
586
+ input: {
587
+ default: Record<string, string>;
588
+ };
589
+ };
590
+ };
547
591
  readonly textarea: {
548
592
  name: string;
549
593
  displayMode: "desktop";
@@ -747,7 +791,7 @@ declare const FormControl: {
747
791
  type: "formControl";
748
792
  contentAttributes: readonly ["label", "placeholder", "options", "requiredMessage", "minLengthMessage", "maxLengthMessage", "minMessage", "maxMessage", "formatMessage", "patternMessage", "matchesMessage"];
749
793
  attributeValues: {
750
- readonly subType: readonly string[];
794
+ readonly subType: readonly ["text", "number", "email", "password", "search", "url", "tel", "date", "time", "checkbox", "switch", "select", "textarea", "hidden", "color", "file"];
751
795
  };
752
796
  triggers: {
753
797
  readonly onChange: {
@@ -0,0 +1,21 @@
1
+ export type FileInputProps = {
2
+ /** The box the field is drawn in — the `input` slot. */
3
+ className?: string;
4
+ /** The `<input type="file">` inside the box — the `field` slot. */
5
+ fieldClassName?: string;
6
+ id?: string;
7
+ name?: string;
8
+ /** What the picker offers, as the browser reads `accept`: `image/png,image/jpeg`, `.pdf`. `''` for anything. */
9
+ accept?: string;
10
+ /** The file the form holds for this control, when it holds one. */
11
+ chosen?: File;
12
+ required?: boolean;
13
+ disabled?: boolean;
14
+ /** In the builder the field is drawn, never opened: a picker there would choose a file for nobody. */
15
+ previewMode?: boolean;
16
+ onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
17
+ onValidate?: () => void;
18
+ errorId?: string;
19
+ };
20
+ declare const FileInput: ({ className, fieldClassName, id, name, accept, chosen, required, disabled, previewMode, onChange, onValidate, errorId }: FileInputProps) => import('react').JSX.Element;
21
+ export default FileInput;