@plitzi/sdk-elements 0.39.3 → 0.39.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/Element/PluginRemote.mjs +7 -3
- package/dist/Element/hooks/useElementState.d.ts +1 -1
- package/dist/Element/hooks/useRootElementInteractions.mjs +21 -18
- package/dist/components/MarkdownDocument/MarkdownDocument.mjs +37 -36
- package/dist/components/MarkdownDocument/helpers/rehypeTableLabels.d.ts +7 -0
- package/dist/components/MarkdownDocument/helpers/rehypeTableLabels.mjs +19 -0
- package/dist/elements/basic/Link/Link.mjs +68 -63
- package/dist/elements/basic/Link/usePrefetchInView.d.ts +3 -0
- package/dist/elements/basic/Link/usePrefetchInView.mjs +29 -0
- package/dist/elements/declarations/index.d.ts +1 -0
- package/dist/elements/form/Form/Form.mjs +1 -1
- package/dist/elements/form/FormControl/FormControl.d.ts +7 -1
- package/dist/elements/form/FormControl/FormControl.mjs +78 -77
- package/dist/elements/form/FormControl/Settings.d.ts +2 -1
- package/dist/elements/form/FormControl/Settings.mjs +1 -1
- package/dist/elements/form/FormControl/declaration.d.ts +1 -0
- package/dist/elements/form/FormControl/declaration.mjs +55 -51
- package/dist/elements/form/FormControl/helpers/autofill.d.ts +13 -0
- package/dist/elements/form/FormControl/helpers/autofill.mjs +18 -0
- package/dist/elements/form/FormControl/index.d.ts +2 -0
- package/dist/elements/form/FormControl/inputs/Input.d.ts +2 -1
- package/dist/elements/form/FormControl/inputs/Input.mjs +2 -2
- package/dist/elements/media/Chart/Chart.mjs +1 -1
- package/dist/elements/provider/ApiContainer/hooks/useApi.mjs +20 -19
- package/dist/elements/provider/ApiContainer/hooks/useProviderWrite.mjs +20 -19
- package/dist/index.d.ts +1 -0
- package/package.json +8 -8
|
@@ -1,165 +1,166 @@
|
|
|
1
1
|
import e from "./components/Label.mjs";
|
|
2
2
|
import { VISUALLY_HIDDEN as t } from "./components/visuallyHidden.mjs";
|
|
3
3
|
import n from "./declaration.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import a from "./
|
|
7
|
-
import o from "./
|
|
8
|
-
import
|
|
9
|
-
import
|
|
4
|
+
import { autocompleteOf as r } from "./helpers/autofill.mjs";
|
|
5
|
+
import { fieldText as i } from "./helpers/fieldText.mjs";
|
|
6
|
+
import { isChecked as a } from "./helpers/isChecked.mjs";
|
|
7
|
+
import o from "./hocs/withFieldValue.mjs";
|
|
8
|
+
import s from "./inputs/Checkbox.mjs";
|
|
9
|
+
import c from "./inputs/FileInput.mjs";
|
|
10
|
+
import ee from "./inputs/Hidden.mjs";
|
|
10
11
|
import te from "./inputs/Input.mjs";
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import { CHECK_SUBTYPES as
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import { RootElement as
|
|
17
|
-
import { use as
|
|
18
|
-
import { createStoreHook as
|
|
19
|
-
import { usePlitzi as
|
|
12
|
+
import l from "./inputs/Select.mjs";
|
|
13
|
+
import u from "./inputs/Textarea.mjs";
|
|
14
|
+
import { CHECK_SUBTYPES as d, INPUT_SUBTYPES as f } from "./subTypes.mjs";
|
|
15
|
+
import p from "../../../Element/hocs/withElement.mjs";
|
|
16
|
+
import m from "../../../Element/hooks/useElement.mjs";
|
|
17
|
+
import { RootElement as h } from "../../../Element/RootElement.mjs";
|
|
18
|
+
import { use as ne, useCallback as re, useEffect as ie } from "react";
|
|
19
|
+
import { createStoreHook as ae } from "@plitzi/nexus/react";
|
|
20
|
+
import { usePlitzi as oe } from "@plitzi/sdk-shared/hooks";
|
|
20
21
|
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
21
22
|
import v from "clsx";
|
|
22
|
-
import { InteractionsContext as
|
|
23
|
+
import { InteractionsContext as y } from "@plitzi/sdk-interactions";
|
|
23
24
|
// src/elements/form/FormControl/FormControl.tsx
|
|
24
|
-
var
|
|
25
|
-
let { id: L, rootId: R, visible: z, definition: { styleSelectors: B } } =
|
|
25
|
+
var b = ({ ref: o, className: p = "", subType: b = "text", name: x = "", label: S = "", hideLabel: C = !1, placeholder: w = "", accept: T = "", autoComplete: se = !0, autoFocus: ce = !1, disabled: E = !1, options: le = [], required: D = !1, maxLength: O = 0, min: k = "", max: A = "", step: j = "", readOnly: M = !1, value: N = "", error: P = "", handleChange: F, handleValidate: I }) => {
|
|
26
|
+
let { id: L, rootId: R, visible: z, definition: { styleSelectors: B } } = m(), { settings: { previewMode: V } } = oe(), { interactionsManager: H } = ne(y), { useStore: U } = ae(), [W] = U("runtime.sources.form"), G = re((e) => {
|
|
26
27
|
if (F?.(e), !V) return;
|
|
27
28
|
let { target: t } = e, n = t instanceof HTMLInputElement && t.type === "checkbox", r = t instanceof HTMLInputElement && t.type === "file" ? t.files?.[0] ?? null : void 0, i = r === void 0 ? n ? t.checked : t.value : r;
|
|
28
29
|
H.interactionTrigger(L, "onChange", {
|
|
29
30
|
value: i,
|
|
30
|
-
name:
|
|
31
|
+
name: x
|
|
31
32
|
});
|
|
32
33
|
}, [
|
|
33
34
|
F,
|
|
34
35
|
V,
|
|
35
36
|
H,
|
|
36
37
|
L,
|
|
37
|
-
|
|
38
|
-
]), K = W?.registerField, q = W?.unregisterField, J =
|
|
39
|
-
variant:
|
|
38
|
+
x
|
|
39
|
+
]), K = W?.registerField, q = W?.unregisterField, J = d.includes(b), ue = b === "hidden", Y = ce && V && z, X = C && V, Z = P && V ? `${R}_${L}_error` : void 0, Q = i(N), $ = J && /* @__PURE__ */ g(s, {
|
|
40
|
+
variant: b === "switch" ? "switch" : "checkbox",
|
|
40
41
|
id: `${R}_${L}`,
|
|
41
|
-
name:
|
|
42
|
-
checked:
|
|
42
|
+
name: x,
|
|
43
|
+
checked: a(N),
|
|
43
44
|
className: B.input,
|
|
44
|
-
required:
|
|
45
|
-
disabled:
|
|
45
|
+
required: D,
|
|
46
|
+
disabled: E,
|
|
46
47
|
onChange: G,
|
|
47
48
|
onValidate: I,
|
|
48
49
|
errorId: Z
|
|
49
50
|
});
|
|
50
|
-
return
|
|
51
|
+
return ie(() => {
|
|
51
52
|
if (K && q) return K({
|
|
52
|
-
name:
|
|
53
|
-
path:
|
|
54
|
-
}), () => q(
|
|
53
|
+
name: x,
|
|
54
|
+
path: x
|
|
55
|
+
}), () => q(x);
|
|
55
56
|
}, [
|
|
56
|
-
|
|
57
|
+
x,
|
|
57
58
|
K,
|
|
58
59
|
q
|
|
59
|
-
]), /* @__PURE__ */ _(
|
|
60
|
-
ref:
|
|
60
|
+
]), /* @__PURE__ */ _(h, {
|
|
61
|
+
ref: o,
|
|
61
62
|
interactionTriggers: n.triggers,
|
|
62
63
|
className: v("plitzi-component__form-control", {
|
|
63
64
|
"form-control--invalid": P && V,
|
|
64
|
-
[`plitzi-component__form-control-${
|
|
65
|
-
},
|
|
65
|
+
[`plitzi-component__form-control-${b}`]: b
|
|
66
|
+
}, p),
|
|
66
67
|
children: [
|
|
67
|
-
!J && !
|
|
68
|
+
!J && !ue && S && /* @__PURE__ */ g(e, {
|
|
68
69
|
targetInput: `${R}_${L}`,
|
|
69
70
|
previewMode: V,
|
|
70
71
|
className: B.label,
|
|
71
72
|
requiredClassName: B.requiredMark,
|
|
72
|
-
type:
|
|
73
|
-
required:
|
|
73
|
+
type: b,
|
|
74
|
+
required: D,
|
|
74
75
|
hidden: X,
|
|
75
|
-
children:
|
|
76
|
+
children: S
|
|
76
77
|
}),
|
|
77
|
-
J &&
|
|
78
|
+
J && S && /* @__PURE__ */ _(e, {
|
|
78
79
|
targetInput: `${R}_${L}`,
|
|
79
80
|
previewMode: V,
|
|
80
81
|
className: B.label,
|
|
81
82
|
requiredClassName: B.requiredMark,
|
|
82
|
-
type:
|
|
83
|
-
required:
|
|
83
|
+
type: b,
|
|
84
|
+
required: D,
|
|
84
85
|
children: [
|
|
85
86
|
$,
|
|
86
87
|
X && /* @__PURE__ */ g("span", {
|
|
87
88
|
style: t,
|
|
88
|
-
children:
|
|
89
|
+
children: S
|
|
89
90
|
}),
|
|
90
|
-
!X &&
|
|
91
|
+
!X && S
|
|
91
92
|
]
|
|
92
93
|
}),
|
|
93
|
-
J && !
|
|
94
|
-
|
|
94
|
+
J && !S && $,
|
|
95
|
+
f.includes(b) && /* @__PURE__ */ g(te, {
|
|
95
96
|
id: `${R}_${L}`,
|
|
96
|
-
name:
|
|
97
|
+
name: x,
|
|
97
98
|
value: Q,
|
|
98
|
-
type:
|
|
99
|
+
type: b,
|
|
99
100
|
className: B.input,
|
|
100
101
|
fieldClassName: B.field,
|
|
101
102
|
iconClassName: B.icon,
|
|
102
|
-
placeholder:
|
|
103
|
-
autoComplete:
|
|
103
|
+
placeholder: w,
|
|
104
|
+
autoComplete: r(se, b, V !== !1),
|
|
104
105
|
autoFocus: Y,
|
|
105
|
-
required:
|
|
106
|
-
maxLength:
|
|
107
|
-
min:
|
|
106
|
+
required: D,
|
|
107
|
+
maxLength: O,
|
|
108
|
+
min: k,
|
|
108
109
|
max: A,
|
|
109
110
|
step: j,
|
|
110
|
-
disabled:
|
|
111
|
+
disabled: E,
|
|
111
112
|
readOnly: M || !V,
|
|
112
113
|
onChange: G,
|
|
113
114
|
onValidate: I,
|
|
114
115
|
errorId: Z
|
|
115
116
|
}),
|
|
116
|
-
|
|
117
|
+
b === "hidden" && /* @__PURE__ */ g(ee, {
|
|
117
118
|
id: `${R}_${L}`,
|
|
118
|
-
name:
|
|
119
|
+
name: x,
|
|
119
120
|
value: Q,
|
|
120
|
-
required:
|
|
121
|
-
disabled:
|
|
121
|
+
required: D,
|
|
122
|
+
disabled: E,
|
|
122
123
|
previewMode: V
|
|
123
124
|
}),
|
|
124
|
-
|
|
125
|
+
b === "select" && /* @__PURE__ */ g(l, {
|
|
125
126
|
id: `${R}_${L}`,
|
|
126
|
-
name:
|
|
127
|
+
name: x,
|
|
127
128
|
onChange: G,
|
|
128
129
|
onValidate: I,
|
|
129
130
|
errorId: Z,
|
|
130
131
|
value: Q,
|
|
131
132
|
className: B.input,
|
|
132
133
|
fieldClassName: B.field,
|
|
133
|
-
placeholder:
|
|
134
|
+
placeholder: w,
|
|
134
135
|
autoFocus: Y,
|
|
135
|
-
required:
|
|
136
|
-
disabled:
|
|
137
|
-
options:
|
|
136
|
+
required: D,
|
|
137
|
+
disabled: E,
|
|
138
|
+
options: le
|
|
138
139
|
}),
|
|
139
|
-
|
|
140
|
+
b === "textarea" && /* @__PURE__ */ g(u, {
|
|
140
141
|
id: `${R}_${L}`,
|
|
141
|
-
name:
|
|
142
|
+
name: x,
|
|
142
143
|
value: Q,
|
|
143
144
|
className: B.input,
|
|
144
|
-
placeholder:
|
|
145
|
+
placeholder: w,
|
|
145
146
|
autoFocus: Y,
|
|
146
|
-
required:
|
|
147
|
-
maxLength:
|
|
148
|
-
disabled:
|
|
147
|
+
required: D,
|
|
148
|
+
maxLength: O,
|
|
149
|
+
disabled: E,
|
|
149
150
|
readOnly: M,
|
|
150
151
|
onChange: G,
|
|
151
152
|
onValidate: I,
|
|
152
153
|
errorId: Z
|
|
153
154
|
}),
|
|
154
|
-
|
|
155
|
+
b === "file" && /* @__PURE__ */ g(c, {
|
|
155
156
|
id: `${R}_${L}`,
|
|
156
|
-
name:
|
|
157
|
-
accept:
|
|
157
|
+
name: x,
|
|
158
|
+
accept: T,
|
|
158
159
|
chosen: N instanceof File ? N : void 0,
|
|
159
160
|
className: B.input,
|
|
160
161
|
fieldClassName: B.field,
|
|
161
|
-
required:
|
|
162
|
-
disabled:
|
|
162
|
+
required: D,
|
|
163
|
+
disabled: E,
|
|
163
164
|
previewMode: V,
|
|
164
165
|
onChange: G,
|
|
165
166
|
onValidate: I,
|
|
@@ -173,5 +174,5 @@ var y = ({ ref: a, className: d = "", subType: y = "text", name: b = "", label:
|
|
|
173
174
|
})
|
|
174
175
|
]
|
|
175
176
|
});
|
|
176
|
-
},
|
|
177
|
-
export {
|
|
177
|
+
}, x = p(o(b));
|
|
178
|
+
export { b as FormControl, x as default };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AutofillField } from './helpers/autofill';
|
|
1
2
|
import { FormControlSubType } from './subTypes';
|
|
2
3
|
type SettingsProps = {
|
|
3
4
|
subType?: FormControlSubType;
|
|
@@ -6,7 +7,7 @@ type SettingsProps = {
|
|
|
6
7
|
hideLabel?: boolean;
|
|
7
8
|
placeholder?: string;
|
|
8
9
|
accept?: string;
|
|
9
|
-
autoComplete?: boolean;
|
|
10
|
+
autoComplete?: boolean | AutofillField;
|
|
10
11
|
autoFocus?: boolean;
|
|
11
12
|
defaultValue?: string | number;
|
|
12
13
|
options?: string[];
|
|
@@ -12,6 +12,7 @@ declare const declaration: import('@plitzi/sdk-shared/authoring').DeclaredElemen
|
|
|
12
12
|
readonly contentAttributes: readonly ["label", "placeholder", "options", "requiredMessage", "minLengthMessage", "maxLengthMessage", "minMessage", "maxMessage", "formatMessage", "patternMessage", "matchesMessage"];
|
|
13
13
|
readonly attributeValues: {
|
|
14
14
|
readonly subType: readonly ["text", "number", "email", "password", "search", "url", "tel", "date", "time", "checkbox", "switch", "select", "textarea", "hidden", "color", "file"];
|
|
15
|
+
readonly autoComplete: readonly ["username", "current-password", "new-password", "one-time-code", "email", "name", "given-name", "family-name", "organization", "tel", "street-address", "postal-code", "country", "url"];
|
|
15
16
|
};
|
|
16
17
|
readonly triggers: {
|
|
17
18
|
readonly onChange: {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { AUTOFILL_FIELDS as e } from "./helpers/autofill.mjs";
|
|
2
|
+
import { FORM_CONTROL_SUBTYPES as t } from "./subTypes.mjs";
|
|
3
|
+
import { elementDeclaration as n } from "@plitzi/sdk-shared/authoring";
|
|
3
4
|
// src/elements/form/FormControl/declaration.ts
|
|
4
|
-
var
|
|
5
|
+
var r = {
|
|
5
6
|
width: "100%",
|
|
6
7
|
display: "flex",
|
|
7
8
|
"align-items": "center",
|
|
@@ -29,10 +30,10 @@ var n = {
|
|
|
29
30
|
"padding-bottom": "8px",
|
|
30
31
|
outline: "none",
|
|
31
32
|
position: "relative"
|
|
32
|
-
}, r = {
|
|
33
|
-
...n,
|
|
34
|
-
"line-height": "20px"
|
|
35
33
|
}, i = {
|
|
34
|
+
...r,
|
|
35
|
+
"line-height": "20px"
|
|
36
|
+
}, a = {
|
|
36
37
|
display: "flex",
|
|
37
38
|
cursor: "pointer",
|
|
38
39
|
"font-weight": "600",
|
|
@@ -40,22 +41,22 @@ var n = {
|
|
|
40
41
|
"line-height": "18px",
|
|
41
42
|
color: "#6b7280",
|
|
42
43
|
"user-select": "none"
|
|
43
|
-
}, a = {
|
|
44
|
-
...i,
|
|
45
|
-
"margin-bottom": "4px"
|
|
46
44
|
}, o = {
|
|
45
|
+
...a,
|
|
46
|
+
"margin-bottom": "4px"
|
|
47
|
+
}, s = {
|
|
47
48
|
display: "block",
|
|
48
49
|
color: "red",
|
|
49
50
|
"margin-top": "4px"
|
|
50
|
-
},
|
|
51
|
+
}, c = {
|
|
51
52
|
color: "red",
|
|
52
53
|
"margin-left": "4px"
|
|
53
|
-
},
|
|
54
|
+
}, l = {
|
|
54
55
|
"border-top-style": "none",
|
|
55
56
|
"border-right-style": "none",
|
|
56
57
|
"border-bottom-style": "none",
|
|
57
58
|
"border-left-style": "none"
|
|
58
|
-
},
|
|
59
|
+
}, u = {
|
|
59
60
|
height: "100%",
|
|
60
61
|
width: "100%",
|
|
61
62
|
"padding-top": "0px",
|
|
@@ -63,19 +64,19 @@ var n = {
|
|
|
63
64
|
"padding-bottom": "0px",
|
|
64
65
|
"padding-left": "0px",
|
|
65
66
|
display: "block",
|
|
66
|
-
...
|
|
67
|
+
...l,
|
|
67
68
|
"background-color": "transparent",
|
|
68
69
|
color: "inherit",
|
|
69
70
|
"line-height": "inherit",
|
|
70
71
|
"font-family": "inherit",
|
|
71
72
|
"font-size": "inherit",
|
|
72
73
|
"box-shadow": "none"
|
|
73
|
-
},
|
|
74
|
+
}, d = {
|
|
74
75
|
height: "100%",
|
|
75
76
|
width: "100%",
|
|
76
77
|
"padding-right": "calc(1.15em + 8px)",
|
|
77
78
|
display: "block",
|
|
78
|
-
...
|
|
79
|
+
...l,
|
|
79
80
|
"background-color": "transparent",
|
|
80
81
|
color: "inherit",
|
|
81
82
|
"line-height": "inherit",
|
|
@@ -84,7 +85,7 @@ var n = {
|
|
|
84
85
|
appearance: "none",
|
|
85
86
|
cursor: "inherit",
|
|
86
87
|
"box-shadow": "none"
|
|
87
|
-
},
|
|
88
|
+
}, f = {
|
|
88
89
|
height: "100%",
|
|
89
90
|
"margin-top": "0px",
|
|
90
91
|
"margin-right": "0px",
|
|
@@ -95,7 +96,7 @@ var n = {
|
|
|
95
96
|
display: "flex",
|
|
96
97
|
"justify-content": "center",
|
|
97
98
|
"align-items": "center",
|
|
98
|
-
...
|
|
99
|
+
...l,
|
|
99
100
|
"background-color": "transparent",
|
|
100
101
|
color: "inherit",
|
|
101
102
|
"line-height": "inherit",
|
|
@@ -103,10 +104,10 @@ var n = {
|
|
|
103
104
|
"font-size": "inherit",
|
|
104
105
|
"font-weight": "inherit",
|
|
105
106
|
cursor: "pointer"
|
|
106
|
-
}, f = {
|
|
107
|
-
...n,
|
|
108
|
-
cursor: "pointer"
|
|
109
107
|
}, p = {
|
|
108
|
+
...r,
|
|
109
|
+
cursor: "pointer"
|
|
110
|
+
}, m = {
|
|
110
111
|
height: "20px",
|
|
111
112
|
width: "36px",
|
|
112
113
|
"margin-top": "0px",
|
|
@@ -135,7 +136,7 @@ var n = {
|
|
|
135
136
|
transition: "background-color 150ms ease",
|
|
136
137
|
appearance: "none",
|
|
137
138
|
cursor: "pointer"
|
|
138
|
-
},
|
|
139
|
+
}, h = (e, t, { field: n, icon: r } = {}) => ({
|
|
139
140
|
name: e,
|
|
140
141
|
displayMode: "desktop",
|
|
141
142
|
style: {
|
|
@@ -143,11 +144,11 @@ var n = {
|
|
|
143
144
|
input: { default: t },
|
|
144
145
|
...n ? { field: { default: n } } : {},
|
|
145
146
|
...r ? { icon: { default: r } } : {},
|
|
146
|
-
label: { default:
|
|
147
|
-
requiredMark: { default:
|
|
148
|
-
error: { default:
|
|
147
|
+
label: { default: o },
|
|
148
|
+
requiredMark: { default: c },
|
|
149
|
+
error: { default: s }
|
|
149
150
|
}
|
|
150
|
-
}),
|
|
151
|
+
}), g = { field: u }, _ = n()({
|
|
151
152
|
type: "formControl",
|
|
152
153
|
contentAttributes: [
|
|
153
154
|
"label",
|
|
@@ -162,7 +163,10 @@ var n = {
|
|
|
162
163
|
"patternMessage",
|
|
163
164
|
"matchesMessage"
|
|
164
165
|
],
|
|
165
|
-
attributeValues: {
|
|
166
|
+
attributeValues: {
|
|
167
|
+
subType: t,
|
|
168
|
+
autoComplete: e
|
|
169
|
+
},
|
|
166
170
|
triggers: { onChange: {
|
|
167
171
|
action: "onChange",
|
|
168
172
|
title: "On Change",
|
|
@@ -225,28 +229,28 @@ var n = {
|
|
|
225
229
|
defaultStyle: {
|
|
226
230
|
style: { base: { default: {} } },
|
|
227
231
|
subTypes: {
|
|
228
|
-
hidden:
|
|
229
|
-
text:
|
|
230
|
-
number:
|
|
231
|
-
email:
|
|
232
|
-
password:
|
|
233
|
-
...
|
|
234
|
-
icon:
|
|
232
|
+
hidden: h("Form Control Hidden", {}),
|
|
233
|
+
text: h("Form Control Text", i, g),
|
|
234
|
+
number: h("Form Control Number", i, g),
|
|
235
|
+
email: h("Form Control Email", i, g),
|
|
236
|
+
password: h("Form Control Password", i, {
|
|
237
|
+
...g,
|
|
238
|
+
icon: f
|
|
235
239
|
}),
|
|
236
|
-
search:
|
|
237
|
-
url:
|
|
238
|
-
tel:
|
|
239
|
-
date:
|
|
240
|
-
time:
|
|
241
|
-
color:
|
|
242
|
-
file:
|
|
243
|
-
textarea:
|
|
244
|
-
...
|
|
240
|
+
search: h("Form Control Search", i, g),
|
|
241
|
+
url: h("Form Control URL", i, g),
|
|
242
|
+
tel: h("Form Control Phone", i, g),
|
|
243
|
+
date: h("Form Control Date", i, g),
|
|
244
|
+
time: h("Form Control Time", i, g),
|
|
245
|
+
color: h("Form Control Color", i, g),
|
|
246
|
+
file: h("Form Control File", i, g),
|
|
247
|
+
textarea: h("Form Control Textarea", {
|
|
248
|
+
...i,
|
|
245
249
|
color: "inherit",
|
|
246
250
|
"font-family": "inherit",
|
|
247
251
|
resize: "vertical"
|
|
248
252
|
}),
|
|
249
|
-
select:
|
|
253
|
+
select: h("Form Control Select", p, { field: d }),
|
|
250
254
|
checkbox: {
|
|
251
255
|
name: "Form Control Checkbox",
|
|
252
256
|
displayMode: "desktop",
|
|
@@ -258,9 +262,9 @@ var n = {
|
|
|
258
262
|
"margin-left": "0px",
|
|
259
263
|
"margin-right": "4px"
|
|
260
264
|
} },
|
|
261
|
-
label: { default:
|
|
262
|
-
requiredMark: { default:
|
|
263
|
-
error: { default:
|
|
265
|
+
label: { default: a },
|
|
266
|
+
requiredMark: { default: c },
|
|
267
|
+
error: { default: s }
|
|
264
268
|
}
|
|
265
269
|
},
|
|
266
270
|
switch: {
|
|
@@ -268,17 +272,17 @@ var n = {
|
|
|
268
272
|
displayMode: "desktop",
|
|
269
273
|
style: {
|
|
270
274
|
base: { default: {} },
|
|
271
|
-
input: { default:
|
|
275
|
+
input: { default: m },
|
|
272
276
|
label: { default: {
|
|
273
|
-
...
|
|
277
|
+
...a,
|
|
274
278
|
"align-items": "center"
|
|
275
279
|
} },
|
|
276
|
-
requiredMark: { default:
|
|
277
|
-
error: { default:
|
|
280
|
+
requiredMark: { default: c },
|
|
281
|
+
error: { default: s }
|
|
278
282
|
}
|
|
279
283
|
}
|
|
280
284
|
}
|
|
281
285
|
}
|
|
282
286
|
}
|
|
283
287
|
});
|
|
284
|
-
export {
|
|
288
|
+
export { _ as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a field holds, as a browser and a password manager read `autocomplete` (WHATWG autofill tokens) — the ones a
|
|
3
|
+
* sign-in, a sign-up and a contact form use. A password field said `off` for every space, so no password manager
|
|
4
|
+
* filled a sign-in or offered to save a new password.
|
|
5
|
+
*/
|
|
6
|
+
export declare const AUTOFILL_FIELDS: readonly ["username", "current-password", "new-password", "one-time-code", "email", "name", "given-name", "family-name", "organization", "tel", "street-address", "postal-code", "country", "url"];
|
|
7
|
+
export type AutofillField = (typeof AUTOFILL_FIELDS)[number];
|
|
8
|
+
/**
|
|
9
|
+
* The `autocomplete` an input is drawn with: `true` leaves it to the browser — the account's current password, on a
|
|
10
|
+
* password field — `false` asks it not to fill, and a token names what the field holds. In the builder's canvas a field
|
|
11
|
+
* is never filled: what is being designed is not a sign-in.
|
|
12
|
+
*/
|
|
13
|
+
export declare const autocompleteOf: (autoComplete: boolean | AutofillField, subType: string, live: boolean) => string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/elements/form/FormControl/helpers/autofill.ts
|
|
2
|
+
var e = [
|
|
3
|
+
"username",
|
|
4
|
+
"current-password",
|
|
5
|
+
"new-password",
|
|
6
|
+
"one-time-code",
|
|
7
|
+
"email",
|
|
8
|
+
"name",
|
|
9
|
+
"given-name",
|
|
10
|
+
"family-name",
|
|
11
|
+
"organization",
|
|
12
|
+
"tel",
|
|
13
|
+
"street-address",
|
|
14
|
+
"postal-code",
|
|
15
|
+
"country",
|
|
16
|
+
"url"
|
|
17
|
+
], t = (e, t, n) => !n || e === !1 ? "off" : e === !0 ? t === "password" ? "current-password" : "on" : e;
|
|
18
|
+
export { e as AUTOFILL_FIELDS, t as autocompleteOf };
|
|
@@ -789,6 +789,7 @@ declare const FormControl: import('react').FC<import('../../..').WithElementProp
|
|
|
789
789
|
contentAttributes: readonly ["label", "placeholder", "options", "requiredMessage", "minLengthMessage", "maxLengthMessage", "minMessage", "maxMessage", "formatMessage", "patternMessage", "matchesMessage"];
|
|
790
790
|
attributeValues: {
|
|
791
791
|
readonly subType: readonly ["text", "number", "email", "password", "search", "url", "tel", "date", "time", "checkbox", "switch", "select", "textarea", "hidden", "color", "file"];
|
|
792
|
+
readonly autoComplete: readonly ["username", "current-password", "new-password", "one-time-code", "email", "name", "given-name", "family-name", "organization", "tel", "street-address", "postal-code", "country", "url"];
|
|
792
793
|
};
|
|
793
794
|
triggers: {
|
|
794
795
|
readonly onChange: {
|
|
@@ -805,3 +806,4 @@ declare const FormControl: import('react').FC<import('../../..').WithElementProp
|
|
|
805
806
|
__attributes: import('./declaration').FormControlAttributes;
|
|
806
807
|
};
|
|
807
808
|
export default FormControl;
|
|
809
|
+
export type { AutofillField } from './helpers/autofill';
|
|
@@ -10,7 +10,8 @@ export type InputProps = {
|
|
|
10
10
|
placeholder?: string;
|
|
11
11
|
value?: string;
|
|
12
12
|
type?: string;
|
|
13
|
-
|
|
13
|
+
/** The `autocomplete` attribute as it is written: `off`, `on` or a token (`autocompleteOf`). */
|
|
14
|
+
autoComplete?: string;
|
|
14
15
|
/** Takes the focus while true: as it becomes true, whether on mount or as the field is shown again. */
|
|
15
16
|
autoFocus?: boolean;
|
|
16
17
|
required?: boolean;
|
|
@@ -4,7 +4,7 @@ import { useCallback as n, useRef as r, useState as i } from "react";
|
|
|
4
4
|
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
5
5
|
import s from "clsx";
|
|
6
6
|
// src/elements/form/FormControl/inputs/Input.tsx
|
|
7
|
-
var c = ({ className: c = "", fieldClassName: l, iconClassName: u, id: d = "", name: f = "", placeholder: p = "", value: m = "", type: h = "text", autoComplete: g =
|
|
7
|
+
var c = ({ className: c = "", fieldClassName: l, iconClassName: u, id: d = "", name: f = "", placeholder: p = "", value: m = "", type: h = "text", autoComplete: g = "off", autoFocus: _ = !1, required: v = !0, maxLength: y = 0, min: b = "", max: x = "", step: S = "", disabled: C = !1, readOnly: w = !1, onChange: T, onValidate: E, errorId: D }) => {
|
|
8
8
|
let [O, k] = i(!1), A = r(null);
|
|
9
9
|
e(A, _);
|
|
10
10
|
let j = n(() => k((e) => !e), [k]), M = n((e) => {
|
|
@@ -31,7 +31,7 @@ var c = ({ className: c = "", fieldClassName: l, iconClassName: u, id: d = "", n
|
|
|
31
31
|
min: h === "number" && b !== "" ? b : void 0,
|
|
32
32
|
max: h === "number" && x !== "" ? x : void 0,
|
|
33
33
|
step: h === "number" && S !== "" ? S : void 0,
|
|
34
|
-
autoComplete: g
|
|
34
|
+
autoComplete: g,
|
|
35
35
|
disabled: C,
|
|
36
36
|
readOnly: w,
|
|
37
37
|
onChange: T,
|