@plitzi/sdk-elements 0.39.3 → 0.39.6
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 +39 -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/ElementAdvancedEditor.mjs +4 -4
- 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/components/SettingsSection/SettingsSection.d.ts +19 -0
- package/dist/components/SettingsSection/SettingsSection.mjs +37 -0
- package/dist/components/SettingsSection/index.d.ts +2 -0
- package/dist/components/SettingsSection/index.mjs +1 -0
- package/dist/elements/advanced/BlockJsx/declaration.d.ts +1 -1
- package/dist/elements/advanced/BlockJsx/declaration.mjs +1 -1
- package/dist/elements/advanced/BlockJsx/index.d.ts +1 -1
- package/dist/elements/basic/Link/Link.mjs +68 -63
- package/dist/elements/basic/Link/Settings.mjs +1 -1
- package/dist/elements/basic/Link/usePrefetchInView.d.ts +3 -0
- package/dist/elements/basic/Link/usePrefetchInView.mjs +29 -0
- package/dist/elements/basic/RichText/Settings.mjs +1 -1
- package/dist/elements/declarations/index.d.ts +8 -3
- 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/internal/LayoutContainer/Settings.mjs +1 -1
- package/dist/elements/internal/Page/Settings.mjs +323 -285
- package/dist/elements/internal/Page/settingsSummary.d.ts +26 -0
- package/dist/elements/internal/Page/settingsSummary.mjs +22 -0
- package/dist/elements/media/Chart/Chart.mjs +1 -1
- package/dist/elements/media/Image/Settings.mjs +2 -2
- package/dist/elements/media/Video/Settings.mjs +2 -2
- package/dist/elements/provider/ApiContainer/Settings.mjs +6 -6
- package/dist/elements/provider/ApiContainer/components/FiltersInput/FiltersInput.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/elements/structure/Pagination/Settings.mjs +1 -1
- package/dist/elements/structure/TabContainer/TabContainer.mjs +15 -11
- package/dist/elements/structure/TabContainer/TabContainerItem/Settings.d.ts +6 -1
- package/dist/elements/structure/TabContainer/TabContainerItem/Settings.mjs +24 -3
- package/dist/elements/structure/TabContainer/TabContainerItem/TabContainerItem.d.ts +7 -1
- package/dist/elements/structure/TabContainer/TabContainerItem/TabContainerItem.mjs +66 -38
- package/dist/elements/structure/TabContainer/TabContainerItem/declaration.d.ts +6 -2
- package/dist/elements/structure/TabContainer/TabContainerItem/declaration.mjs +1 -1
- package/dist/elements/structure/TabContainer/TabContainerItem/index.d.ts +6 -2
- package/dist/elements/structure/TabContainer/TabContainerItem/openTabFromHash.d.ts +10 -0
- package/dist/elements/structure/TabContainer/TabContainerItem/openTabFromHash.mjs +18 -0
- package/dist/elements/structure/TabContainer/index.d.ts +6 -2
- package/dist/index.d.ts +8 -3
- package/package.json +12 -12
|
@@ -1,90 +1,95 @@
|
|
|
1
1
|
import { ariaCurrent as e } from "./ariaCurrent.mjs";
|
|
2
|
-
import t from "
|
|
3
|
-
import n from "../../../Element/
|
|
4
|
-
import r from "../../../Element/
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import u from "
|
|
12
|
-
import
|
|
2
|
+
import t from "./usePrefetchInView.mjs";
|
|
3
|
+
import n from "../../../Element/ElementWords.mjs";
|
|
4
|
+
import r from "../../../Element/hocs/withElement.mjs";
|
|
5
|
+
import i from "../../../Element/hooks/useElement.mjs";
|
|
6
|
+
import { RootElement as a } from "../../../Element/RootElement.mjs";
|
|
7
|
+
import { useMemo as o } from "react";
|
|
8
|
+
import { usePlitzi as s } from "@plitzi/sdk-shared/hooks";
|
|
9
|
+
import { useSdkStore as c } from "@plitzi/sdk-shared/store";
|
|
10
|
+
import { processTwig as l } from "@plitzi/sdk-shared/helpers/twigWrapper";
|
|
11
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
12
|
+
import d from "clsx";
|
|
13
|
+
import { getPageFullPath as f } from "@plitzi/sdk-navigation";
|
|
13
14
|
// src/elements/basic/Link/Link.tsx
|
|
14
|
-
var
|
|
15
|
-
let { style:
|
|
15
|
+
var p = /^[a-z][a-z0-9+.-]*:/i, m = ({ ref: r, children: m, className: h = "", href: g = "#", target: _ = "self", mode: v = "page", hash: y = "", label: b = "", content: x = "", contentPlacement: S = "after", icon: C = "", iconPlacement: w = "before", current: T = "page" }) => {
|
|
16
|
+
let { style: E, definition: { styleSelectors: D } } = i(), { settings: { previewMode: O } } = s(), [[k, A, j, M, N, P, F]] = c([
|
|
16
17
|
"pageDefinitions",
|
|
17
18
|
"schema.pageFolders",
|
|
18
19
|
"navigation.routeParams",
|
|
19
20
|
"navigation.queryParams",
|
|
20
21
|
"navigation.navigate",
|
|
21
|
-
"navigation.href"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (
|
|
25
|
-
|
|
22
|
+
"navigation.href",
|
|
23
|
+
"navigation.prefetch"
|
|
24
|
+
]), I = v === "external" || p.test(g), L = !I && g.length > 1 && g.startsWith("#"), R = o(() => {
|
|
25
|
+
if (I || L) return g;
|
|
26
|
+
if (v === "internal") {
|
|
27
|
+
let e = `/${g}`.replaceAll(/[/]+/gim, "/");
|
|
26
28
|
try {
|
|
27
|
-
let t =
|
|
28
|
-
...
|
|
29
|
-
...
|
|
29
|
+
let t = l(e, {
|
|
30
|
+
...M,
|
|
31
|
+
...j
|
|
30
32
|
}, !0);
|
|
31
33
|
return typeof t == "string" ? t : e;
|
|
32
34
|
} catch {}
|
|
33
35
|
return e;
|
|
34
36
|
}
|
|
35
|
-
return
|
|
37
|
+
return f(k, A, g, !0);
|
|
36
38
|
}, [
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
I,
|
|
40
|
+
L,
|
|
41
|
+
v,
|
|
42
|
+
g,
|
|
41
43
|
k,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
A,
|
|
45
|
+
M,
|
|
46
|
+
j
|
|
47
|
+
]), z = !I && !L && y ? `${R}#${y}` : R, B = I || L ? void 0 : e(R, P, T);
|
|
48
|
+
t(r, z, F, O === !0 && !I && !L && _ === "self");
|
|
49
|
+
let V = (e) => {
|
|
50
|
+
if (!O) return;
|
|
46
51
|
e.stopPropagation();
|
|
47
|
-
let t =
|
|
48
|
-
|
|
49
|
-
},
|
|
52
|
+
let t = _ !== "self" || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button !== 0;
|
|
53
|
+
I || L || t || (e.preventDefault(), N(z));
|
|
54
|
+
}, H = o(() => {
|
|
50
55
|
let e = {
|
|
51
|
-
ref:
|
|
52
|
-
style:
|
|
53
|
-
target: `_${
|
|
54
|
-
...
|
|
55
|
-
"aria-label":
|
|
56
|
-
"aria-current":
|
|
57
|
-
className:
|
|
56
|
+
ref: r,
|
|
57
|
+
style: E,
|
|
58
|
+
target: `_${_}`,
|
|
59
|
+
..._ === "blank" ? { rel: "noopener noreferrer" } : {},
|
|
60
|
+
"aria-label": b || void 0,
|
|
61
|
+
"aria-current": B,
|
|
62
|
+
className: d("plitzi-component__link", h)
|
|
58
63
|
};
|
|
59
|
-
return
|
|
64
|
+
return O ? {
|
|
60
65
|
...e,
|
|
61
|
-
href:
|
|
66
|
+
href: z
|
|
62
67
|
} : {
|
|
63
68
|
...e,
|
|
64
|
-
"href-disabled":
|
|
69
|
+
"href-disabled": z
|
|
65
70
|
};
|
|
66
71
|
}, [
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
r,
|
|
73
|
+
E,
|
|
74
|
+
_,
|
|
75
|
+
b,
|
|
76
|
+
B,
|
|
77
|
+
h,
|
|
78
|
+
O,
|
|
79
|
+
z
|
|
75
80
|
]);
|
|
76
|
-
return /* @__PURE__ */
|
|
81
|
+
return /* @__PURE__ */ u(a, {
|
|
77
82
|
tag: "a",
|
|
78
|
-
...
|
|
79
|
-
onClick:
|
|
80
|
-
children: /* @__PURE__ */
|
|
81
|
-
content:
|
|
82
|
-
icon:
|
|
83
|
-
iconPlacement:
|
|
84
|
-
iconClassName:
|
|
85
|
-
contentPlacement:
|
|
86
|
-
children:
|
|
83
|
+
...H,
|
|
84
|
+
onClick: V,
|
|
85
|
+
children: /* @__PURE__ */ u(n, {
|
|
86
|
+
content: x,
|
|
87
|
+
icon: C,
|
|
88
|
+
iconPlacement: w,
|
|
89
|
+
iconClassName: D.icon,
|
|
90
|
+
contentPlacement: S,
|
|
91
|
+
children: m
|
|
87
92
|
})
|
|
88
93
|
});
|
|
89
|
-
},
|
|
90
|
-
export {
|
|
94
|
+
}, h = r(m);
|
|
95
|
+
export { m as Link, h as default };
|
|
@@ -140,7 +140,7 @@ var h = ({ mode: h = "page", href: g = "#", hash: _ = "", target: v = "self", la
|
|
|
140
140
|
children: e.label
|
|
141
141
|
}, e.key))]
|
|
142
142
|
}), /* @__PURE__ */ l("div", {
|
|
143
|
-
className: "truncate rounded-b border-r border-b border-l
|
|
143
|
+
className: "border-ui-line truncate rounded-b border-r border-b border-l p-1 text-xs",
|
|
144
144
|
children: F
|
|
145
145
|
})]
|
|
146
146
|
}),
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useEffect as e } from "react";
|
|
2
|
+
// src/elements/basic/Link/usePrefetchInView.ts
|
|
3
|
+
var t = /* @__PURE__ */ new WeakMap(), n, r = (e) => {
|
|
4
|
+
typeof requestIdleCallback == "function" ? requestIdleCallback(e, { timeout: 2e3 }) : setTimeout(e, 200);
|
|
5
|
+
}, i = () => (n ??= new IntersectionObserver((e) => {
|
|
6
|
+
for (let i of e) {
|
|
7
|
+
let e = t.get(i.target);
|
|
8
|
+
i.isIntersecting && e && (n?.unobserve(i.target), t.delete(i.target), r(() => e.prefetch(e.url)));
|
|
9
|
+
}
|
|
10
|
+
}), n), a = (n, r, a, o) => {
|
|
11
|
+
e(() => {
|
|
12
|
+
let e = n?.current;
|
|
13
|
+
if (!o || !a || !e || typeof IntersectionObserver > "u") return;
|
|
14
|
+
t.set(e, {
|
|
15
|
+
url: r,
|
|
16
|
+
prefetch: a
|
|
17
|
+
});
|
|
18
|
+
let s = i();
|
|
19
|
+
return s.observe(e), () => {
|
|
20
|
+
s.unobserve(e), t.delete(e);
|
|
21
|
+
};
|
|
22
|
+
}, [
|
|
23
|
+
n,
|
|
24
|
+
r,
|
|
25
|
+
a,
|
|
26
|
+
o
|
|
27
|
+
]);
|
|
28
|
+
};
|
|
29
|
+
export { a as default };
|
|
@@ -37,7 +37,7 @@ var a = ({ format: a = "html", mediaBaseUrl: o = "", onUpdate: s }) => {
|
|
|
37
37
|
size: "xs"
|
|
38
38
|
}),
|
|
39
39
|
/* @__PURE__ */ n("span", {
|
|
40
|
-
className: "text-
|
|
40
|
+
className: "text-ui-fg-subtle text-xs",
|
|
41
41
|
children: [
|
|
42
42
|
"Bind ",
|
|
43
43
|
/* @__PURE__ */ t("strong", { children: "content" }),
|
|
@@ -248,7 +248,7 @@ export declare const elementDeclarations: {
|
|
|
248
248
|
readonly type: "blockJsx";
|
|
249
249
|
readonly content: {
|
|
250
250
|
readonly attributes: {
|
|
251
|
-
readonly content: "import { useCallback } from \"react\";\nimport { JsxManager } from \"@plitzi/plitzi-sdk\";\n\nconst BlockJsx = ({ internalProps, content, content2 }) => {\n
|
|
251
|
+
readonly content: "import { useCallback } from \"react\";\nimport { JsxManager } from \"@plitzi/plitzi-sdk\";\n\nconst BlockJsx = ({ internalProps, content, content2 }) => {\n const handleClick = useCallback(() => {\n alert(\"Hello World\");\n }, []);\n\n return (\n <div style={{ display: \"flex\", gap: \"4px\" }}>\n <JsxManager\n as=\"Heading\"\n internalProps={internalProps}\n content={`${content} ${content2}`}\n />\n <button onClick={handleClick} style={{ border: \"1px gray solid\", cursor: \"pointer\" }}>\n Click Me\n </button>\n </div>\n );\n};\n\nexport default BlockJsx;";
|
|
252
252
|
readonly props: "{\"content\": \"Hello\", \"content2\": \"World\"}";
|
|
253
253
|
readonly contentCache: "aW1wb3J0ICogYXMgUmVhY3QgZnJvbSAncmVhY3QnOwppbXBvcnQgeyB1c2VDYWxsYmFjayB9IGZyb20gInJlYWN0IjsKaW1wb3J0IHsgSnN4TWFuYWdlciB9IGZyb20gIkBwbGl0emkvcGxpdHppLXNkayI7CnZhciBCbG9ja0pzeCA9IGZ1bmN0aW9uIEJsb2NrSnN4KF9yZWYpIHsKICB2YXIgaW50ZXJuYWxQcm9wcyA9IF9yZWYuaW50ZXJuYWxQcm9wcywKICAgIGNvbnRlbnQgPSBfcmVmLmNvbnRlbnQsCiAgICBjb250ZW50MiA9IF9yZWYuY29udGVudDI7CiAgdmFyIGhhbmRsZUNsaWNrID0gdXNlQ2FsbGJhY2soZnVuY3Rpb24gKCkgewogICAgYWxlcnQoIkhlbGxvIFdvcmxkIik7CiAgfSwgW10pOwogIHJldHVybiAvKiNfX1BVUkVfXyovUmVhY3QuY3JlYXRlRWxlbWVudCgiZGl2IiwgewogICAgc3R5bGU6IHsKICAgICAgZGlzcGxheTogImZsZXgiLAogICAgICBnYXA6ICI0cHgiCiAgICB9CiAgfSwgLyojX19QVVJFX18qL1JlYWN0LmNyZWF0ZUVsZW1lbnQoSnN4TWFuYWdlciwgewogICAgYXM6ICJIZWFkaW5nIiwKICAgIGludGVybmFsUHJvcHM6IGludGVybmFsUHJvcHMsCiAgICBjb250ZW50OiAiIi5jb25jYXQoY29udGVudCwgIiAiKS5jb25jYXQoY29udGVudDIpCiAgfSksIC8qI19fUFVSRV9fKi9SZWFjdC5jcmVhdGVFbGVtZW50KCJidXR0b24iLCB7CiAgICBvbkNsaWNrOiBoYW5kbGVDbGljaywKICAgIHN0eWxlOiB7CiAgICAgIGJvcmRlcjogIjFweCBncmF5IHNvbGlkIiwKICAgICAgY3Vyc29yOiAncG9pbnRlcicKICAgIH0KICB9LCAiQ2xpY2sgTWUiKSk7Cn07CmV4cG9ydCBkZWZhdWx0IEJsb2NrSnN4Ow==";
|
|
254
254
|
readonly allowEmptyRender: false;
|
|
@@ -1402,6 +1402,7 @@ export declare const elementDeclarations: {
|
|
|
1402
1402
|
readonly contentAttributes: readonly ["label", "placeholder", "options", "requiredMessage", "minLengthMessage", "maxLengthMessage", "minMessage", "maxMessage", "formatMessage", "patternMessage", "matchesMessage"];
|
|
1403
1403
|
readonly attributeValues: {
|
|
1404
1404
|
readonly subType: readonly ["text", "number", "email", "password", "search", "url", "tel", "date", "time", "checkbox", "switch", "select", "textarea", "hidden", "color", "file"];
|
|
1405
|
+
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"];
|
|
1405
1406
|
};
|
|
1406
1407
|
readonly triggers: {
|
|
1407
1408
|
readonly onChange: {
|
|
@@ -3748,7 +3749,9 @@ export declare const elementDeclarations: {
|
|
|
3748
3749
|
readonly tabindex: "roving: 0 on the open tab, -1 on the rest — the arrow keys move between them";
|
|
3749
3750
|
};
|
|
3750
3751
|
readonly content: {
|
|
3751
|
-
readonly attributes: {
|
|
3752
|
+
readonly attributes: {
|
|
3753
|
+
readonly hash: "";
|
|
3754
|
+
};
|
|
3752
3755
|
readonly definition: {
|
|
3753
3756
|
readonly label: "Tab Container Item";
|
|
3754
3757
|
readonly description: "One selectable tab (trigger + panel) inside a tabContainer.";
|
|
@@ -3770,7 +3773,9 @@ export declare const elementDeclarations: {
|
|
|
3770
3773
|
readonly subTypes: {};
|
|
3771
3774
|
};
|
|
3772
3775
|
};
|
|
3773
|
-
},
|
|
3776
|
+
}, Partial<{
|
|
3777
|
+
hash?: string | undefined;
|
|
3778
|
+
}>>;
|
|
3774
3779
|
readonly Text: import('@plitzi/sdk-shared/authoring').DeclaredElement<{
|
|
3775
3780
|
readonly type: "text";
|
|
3776
3781
|
readonly contentAttributes: readonly ["content"];
|
|
@@ -24,7 +24,7 @@ var x = ({ ref: n, className: x = "", children: S, method: C = "get", actionUrl:
|
|
|
24
24
|
}), []);
|
|
25
25
|
let V = o((e) => {
|
|
26
26
|
N.current || (j((t) => y(t, (t) => {
|
|
27
|
-
t[e] &&
|
|
27
|
+
t[e] && Reflect.deleteProperty(t, e);
|
|
28
28
|
})), e && I((t) => ({
|
|
29
29
|
...t,
|
|
30
30
|
values: h(t, `values.${e}`),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AutofillField } from './helpers/autofill';
|
|
1
2
|
import { FormControlSubType } from './subTypes';
|
|
2
3
|
import { ChangeEvent, RefObject } from 'react';
|
|
3
4
|
export type FormControlProps = {
|
|
@@ -15,7 +16,12 @@ export type FormControlProps = {
|
|
|
15
16
|
placeholder: string;
|
|
16
17
|
/** A `file` field's offer, as the browser reads `accept`: `image/png,image/jpeg`, `.pdf`. `''` for any file. */
|
|
17
18
|
accept: string;
|
|
18
|
-
|
|
19
|
+
/**
|
|
20
|
+
* What the browser may fill in: `true` lets it decide (on a password field, the account's current password), `false`
|
|
21
|
+
* asks it not to, and a token names what the field holds — `username`, `new-password`, `one-time-code`, `email`…
|
|
22
|
+
* (`AUTOFILL_FIELDS`), which is what a password manager reads to fill a sign-in and to save a new password.
|
|
23
|
+
*/
|
|
24
|
+
autoComplete: boolean | AutofillField;
|
|
19
25
|
/**
|
|
20
26
|
* Takes the focus as it appears — a search box opened by a shortcut is typed into at once. With the control's
|
|
21
27
|
* container shown only while wanted (`loadStrategy: 'visible'`), it appears each time it is opened.
|
|
@@ -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: {
|