@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.
- package/CHANGELOG.md +14 -0
- package/dist/elements/declarations/index.d.ts +78 -2
- package/dist/elements/declarations/index.mjs +24 -22
- package/dist/elements/form/Form/Form.d.ts +2 -1
- package/dist/elements/form/FormControl/FormControl.d.ts +7 -9
- package/dist/elements/form/FormControl/FormControl.mjs +110 -105
- package/dist/elements/form/FormControl/Settings.d.ts +4 -2
- package/dist/elements/form/FormControl/Settings.mjs +113 -172
- package/dist/elements/form/FormControl/declaration.d.ts +45 -1
- package/dist/elements/form/FormControl/declaration.mjs +7 -20
- package/dist/elements/form/FormControl/hocs/withFieldValue.d.ts +2 -1
- package/dist/elements/form/FormControl/hocs/withFieldValue.mjs +4 -1
- package/dist/elements/form/FormControl/index.d.ts +45 -1
- package/dist/elements/form/FormControl/inputs/FileInput.d.ts +21 -0
- package/dist/elements/form/FormControl/inputs/FileInput.mjs +29 -0
- package/dist/elements/form/FormControl/subTypes.d.ts +17 -0
- package/dist/elements/form/FormControl/subTypes.mjs +58 -0
- package/dist/elements/index.d.ts +3 -1
- package/dist/elements/index.mjs +12 -10
- package/dist/elements/settings.mjs +20 -18
- package/dist/elements/structure/FocusGroup/FocusGroup.d.ts +24 -0
- package/dist/elements/structure/FocusGroup/FocusGroup.mjs +27 -0
- package/dist/elements/structure/FocusGroup/Settings.d.ts +8 -0
- package/dist/elements/structure/FocusGroup/Settings.mjs +39 -0
- package/dist/elements/structure/FocusGroup/arrowFocus.d.ts +12 -0
- package/dist/elements/structure/FocusGroup/arrowFocus.mjs +30 -0
- package/dist/elements/structure/FocusGroup/declaration.d.ts +36 -0
- package/dist/elements/structure/FocusGroup/declaration.mjs +28 -0
- package/dist/elements/structure/FocusGroup/index.d.ts +37 -0
- package/dist/elements/structure/FocusGroup/index.mjs +6 -0
- package/dist/index.d.ts +81 -1
- package/dist/index.mjs +19 -17
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @plitzi/sdk-elements
|
|
2
2
|
|
|
3
|
+
## 0.39.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f174a61: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
|
|
8
|
+
`@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
|
|
9
|
+
- Updated dependencies [f174a61]
|
|
10
|
+
- @plitzi/sdk-auth@0.39.1
|
|
11
|
+
- @plitzi/sdk-event-bridge@0.39.1
|
|
12
|
+
- @plitzi/sdk-interactions@0.39.1
|
|
13
|
+
- @plitzi/sdk-navigation@0.39.1
|
|
14
|
+
- @plitzi/sdk-schema@0.39.1
|
|
15
|
+
- @plitzi/sdk-shared@0.39.1
|
|
16
|
+
|
|
3
17
|
## 0.39.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
|
@@ -32,6 +32,7 @@ import { default as CarouselTrackDeclaration } from '../structure/Carousel/Carou
|
|
|
32
32
|
import { default as CarouselDeclaration } from '../structure/Carousel/declaration';
|
|
33
33
|
import { default as ContainerDeclaration } from '../structure/Container/declaration';
|
|
34
34
|
import { default as DialogContainerDeclaration } from '../structure/DialogContainer/declaration';
|
|
35
|
+
import { default as FocusGroupDeclaration } from '../structure/FocusGroup/declaration';
|
|
35
36
|
import { default as ListDeclaration } from '../structure/List/declaration';
|
|
36
37
|
import { default as ListItemDeclaration } from '../structure/List/ListItem/declaration';
|
|
37
38
|
import { default as ModalContainerDeclaration } from '../structure/ModalContainer/declaration';
|
|
@@ -1038,6 +1039,37 @@ export declare const elementDeclarations: {
|
|
|
1038
1039
|
acceptButtonLabelLoading?: string | undefined;
|
|
1039
1040
|
rejectButtonLabel?: string | undefined;
|
|
1040
1041
|
}>>;
|
|
1042
|
+
readonly FocusGroup: import('@plitzi/sdk-shared/authoring').DeclaredElement<{
|
|
1043
|
+
readonly type: "focusGroup";
|
|
1044
|
+
readonly attributeValues: {
|
|
1045
|
+
readonly subType: readonly string[];
|
|
1046
|
+
};
|
|
1047
|
+
readonly content: {
|
|
1048
|
+
readonly attributes: {
|
|
1049
|
+
readonly subType: "div";
|
|
1050
|
+
};
|
|
1051
|
+
readonly definition: {
|
|
1052
|
+
readonly label: "Focus Group";
|
|
1053
|
+
readonly description: string;
|
|
1054
|
+
readonly items: [];
|
|
1055
|
+
};
|
|
1056
|
+
readonly market: {
|
|
1057
|
+
readonly category: "structure";
|
|
1058
|
+
readonly icon: "fa-solid fa-arrows-up-down";
|
|
1059
|
+
};
|
|
1060
|
+
readonly defaultStyle: {
|
|
1061
|
+
readonly style: {
|
|
1062
|
+
readonly base: {
|
|
1063
|
+
readonly default: {};
|
|
1064
|
+
};
|
|
1065
|
+
};
|
|
1066
|
+
readonly subTypes: {};
|
|
1067
|
+
};
|
|
1068
|
+
};
|
|
1069
|
+
}, Partial<{
|
|
1070
|
+
label?: string | undefined;
|
|
1071
|
+
subType?: "div" | "nav" | "section" | undefined;
|
|
1072
|
+
}>>;
|
|
1041
1073
|
readonly Dropdown: import('@plitzi/sdk-shared/authoring').DeclaredElement<{
|
|
1042
1074
|
readonly type: "dropdown";
|
|
1043
1075
|
readonly attributeValues: {
|
|
@@ -1369,7 +1401,7 @@ export declare const elementDeclarations: {
|
|
|
1369
1401
|
readonly type: "formControl";
|
|
1370
1402
|
readonly contentAttributes: readonly ["label", "placeholder", "options", "requiredMessage", "minLengthMessage", "maxLengthMessage", "minMessage", "maxMessage", "formatMessage", "patternMessage", "matchesMessage"];
|
|
1371
1403
|
readonly attributeValues: {
|
|
1372
|
-
readonly subType: readonly
|
|
1404
|
+
readonly subType: readonly ["text", "number", "email", "password", "search", "url", "tel", "date", "time", "checkbox", "switch", "select", "textarea", "hidden", "color", "file"];
|
|
1373
1405
|
};
|
|
1374
1406
|
readonly triggers: {
|
|
1375
1407
|
readonly onChange: {
|
|
@@ -1391,6 +1423,7 @@ export declare const elementDeclarations: {
|
|
|
1391
1423
|
readonly label: "Label";
|
|
1392
1424
|
readonly hideLabel: false;
|
|
1393
1425
|
readonly placeholder: "";
|
|
1426
|
+
readonly accept: "";
|
|
1394
1427
|
readonly defaultValue: "";
|
|
1395
1428
|
readonly autoComplete: true;
|
|
1396
1429
|
readonly autoFocus: false;
|
|
@@ -1913,6 +1946,49 @@ export declare const elementDeclarations: {
|
|
|
1913
1946
|
};
|
|
1914
1947
|
};
|
|
1915
1948
|
};
|
|
1949
|
+
readonly file: {
|
|
1950
|
+
name: string;
|
|
1951
|
+
displayMode: "desktop";
|
|
1952
|
+
style: {
|
|
1953
|
+
label: {
|
|
1954
|
+
default: {
|
|
1955
|
+
'margin-bottom': string;
|
|
1956
|
+
display: string;
|
|
1957
|
+
cursor: string;
|
|
1958
|
+
'font-weight': string;
|
|
1959
|
+
'font-size': string;
|
|
1960
|
+
'line-height': string;
|
|
1961
|
+
color: string;
|
|
1962
|
+
'user-select': string;
|
|
1963
|
+
};
|
|
1964
|
+
};
|
|
1965
|
+
requiredMark: {
|
|
1966
|
+
default: {
|
|
1967
|
+
color: string;
|
|
1968
|
+
'margin-left': string;
|
|
1969
|
+
};
|
|
1970
|
+
};
|
|
1971
|
+
error: {
|
|
1972
|
+
default: {
|
|
1973
|
+
display: string;
|
|
1974
|
+
color: string;
|
|
1975
|
+
'margin-top': string;
|
|
1976
|
+
};
|
|
1977
|
+
};
|
|
1978
|
+
icon?: {
|
|
1979
|
+
default: Record<string, string>;
|
|
1980
|
+
} | undefined;
|
|
1981
|
+
field?: {
|
|
1982
|
+
default: Record<string, string>;
|
|
1983
|
+
} | undefined;
|
|
1984
|
+
base: {
|
|
1985
|
+
default: {};
|
|
1986
|
+
};
|
|
1987
|
+
input: {
|
|
1988
|
+
default: Record<string, string>;
|
|
1989
|
+
};
|
|
1990
|
+
};
|
|
1991
|
+
};
|
|
1916
1992
|
readonly textarea: {
|
|
1917
1993
|
name: string;
|
|
1918
1994
|
displayMode: "desktop";
|
|
@@ -3861,7 +3937,7 @@ export declare const elementDeclarations: {
|
|
|
3861
3937
|
}>>;
|
|
3862
3938
|
};
|
|
3863
3939
|
export type ElementDeclarationName = keyof typeof elementDeclarations;
|
|
3864
|
-
export { ApiContainerDeclaration, BlockHtmlDeclaration, BlockJsxDeclaration, ButtonDeclaration, CarouselDeclaration, CarouselTrackDeclaration, ChannelDeclaration, ContainerDeclaration, CustomDeclaration, DialogContainerDeclaration, DropdownDeclaration, DropdownPopupDeclaration, EmbedDeclaration, FontAwesomeDeclaration, FormControlDeclaration, FormDeclaration, HeadingDeclaration, ImageDeclaration, LayoutContainerDeclaration, LinkDeclaration, ListDeclaration, ListItemDeclaration, LoadingDeclaration, MarkdownDeclaration, ModalContainerDeclaration, NodeHtmlDeclaration, NotFoundDeclaration, PageDeclaration, PaginationDeclaration, ParagraphDeclaration, PlitziSdkDeclaration, ReferenceDeclaration, RichTextDeclaration, ChartDeclaration, SvgDeclaration, TabContainerBodyDeclaration, TabContainerDeclaration, TabContainerHeaderDeclaration, TabContainerItemDeclaration, TextDeclaration, ThemeToggleDeclaration, VideoDeclaration };
|
|
3940
|
+
export { ApiContainerDeclaration, BlockHtmlDeclaration, BlockJsxDeclaration, ButtonDeclaration, CarouselDeclaration, CarouselTrackDeclaration, ChannelDeclaration, ContainerDeclaration, CustomDeclaration, DialogContainerDeclaration, FocusGroupDeclaration, DropdownDeclaration, DropdownPopupDeclaration, EmbedDeclaration, FontAwesomeDeclaration, FormControlDeclaration, FormDeclaration, HeadingDeclaration, ImageDeclaration, LayoutContainerDeclaration, LinkDeclaration, ListDeclaration, ListItemDeclaration, LoadingDeclaration, MarkdownDeclaration, ModalContainerDeclaration, NodeHtmlDeclaration, NotFoundDeclaration, PageDeclaration, PaginationDeclaration, ParagraphDeclaration, PlitziSdkDeclaration, ReferenceDeclaration, RichTextDeclaration, ChartDeclaration, SvgDeclaration, TabContainerBodyDeclaration, TabContainerDeclaration, TabContainerHeaderDeclaration, TabContainerItemDeclaration, TextDeclaration, ThemeToggleDeclaration, VideoDeclaration };
|
|
3865
3941
|
/**
|
|
3866
3942
|
* Each type's `serverTemplates`, by the type a document names: the attributes the page server evaluates against a
|
|
3867
3943
|
* context of its own, which the element runtime leaves as written and the authoring lint holds to that context.
|
|
@@ -32,19 +32,20 @@ import M from "../structure/Carousel/CarouselTrack/declaration.mjs";
|
|
|
32
32
|
import N from "../structure/Carousel/declaration.mjs";
|
|
33
33
|
import P, { NAMEABLE_CONTAINER_TAGS as F } from "../structure/Container/declaration.mjs";
|
|
34
34
|
import I from "../structure/DialogContainer/declaration.mjs";
|
|
35
|
-
import L from "../structure/
|
|
36
|
-
import R from "../structure/List/
|
|
37
|
-
import z from "../structure/
|
|
38
|
-
import B from "../structure/
|
|
39
|
-
import V from "../structure/
|
|
40
|
-
import H from "../structure/TabContainer/
|
|
41
|
-
import U from "../structure/TabContainer/
|
|
42
|
-
import W from "../structure/TabContainer/
|
|
43
|
-
import
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
35
|
+
import L from "../structure/FocusGroup/declaration.mjs";
|
|
36
|
+
import R from "../structure/List/declaration.mjs";
|
|
37
|
+
import z from "../structure/List/ListItem/declaration.mjs";
|
|
38
|
+
import B from "../structure/ModalContainer/declaration.mjs";
|
|
39
|
+
import V from "../structure/Pagination/declaration.mjs";
|
|
40
|
+
import H from "../structure/TabContainer/declaration.mjs";
|
|
41
|
+
import U from "../structure/TabContainer/TabContainerBody/declaration.mjs";
|
|
42
|
+
import W from "../structure/TabContainer/TabContainerHeader/declaration.mjs";
|
|
43
|
+
import G from "../structure/TabContainer/TabContainerItem/declaration.mjs";
|
|
44
|
+
import { interactionBasicTriggers as K } from "../../Element/helpers/elementConstants.mjs";
|
|
45
|
+
import { HTML_TAG_PARTS as q } from "../basic/RichText/classHtmlParts.mjs";
|
|
46
|
+
import { isSvgMarkup as J } from "../media/Svg/sanitizeSvg.mjs";
|
|
46
47
|
//#region src/elements/declarations/index.ts
|
|
47
|
-
var
|
|
48
|
+
var Y = {
|
|
48
49
|
ApiContainer: A,
|
|
49
50
|
BlockHtml: e,
|
|
50
51
|
BlockJsx: t,
|
|
@@ -55,6 +56,7 @@ var J = {
|
|
|
55
56
|
Container: P,
|
|
56
57
|
Custom: n,
|
|
57
58
|
DialogContainer: I,
|
|
59
|
+
FocusGroup: L,
|
|
58
60
|
Dropdown: s,
|
|
59
61
|
DropdownPopup: c,
|
|
60
62
|
Embed: T,
|
|
@@ -65,28 +67,28 @@ var J = {
|
|
|
65
67
|
Image: D,
|
|
66
68
|
LayoutContainer: v,
|
|
67
69
|
Link: u,
|
|
68
|
-
List:
|
|
69
|
-
ListItem:
|
|
70
|
+
List: R,
|
|
71
|
+
ListItem: z,
|
|
70
72
|
Loading: y,
|
|
71
73
|
Markdown: d,
|
|
72
|
-
ModalContainer:
|
|
74
|
+
ModalContainer: B,
|
|
73
75
|
NodeHtml: r,
|
|
74
76
|
NotFound: b,
|
|
75
77
|
Page: x,
|
|
76
|
-
Pagination:
|
|
78
|
+
Pagination: V,
|
|
77
79
|
Paragraph: f,
|
|
78
80
|
PlitziSdk: i,
|
|
79
81
|
Reference: a,
|
|
80
82
|
RichText: p,
|
|
81
83
|
Chart: w,
|
|
82
84
|
Svg: O,
|
|
83
|
-
TabContainer:
|
|
84
|
-
TabContainerBody:
|
|
85
|
-
TabContainerHeader:
|
|
86
|
-
TabContainerItem:
|
|
85
|
+
TabContainer: H,
|
|
86
|
+
TabContainerBody: U,
|
|
87
|
+
TabContainerHeader: W,
|
|
88
|
+
TabContainerItem: G,
|
|
87
89
|
Text: m,
|
|
88
90
|
ThemeToggle: h,
|
|
89
91
|
Video: k
|
|
90
|
-
},
|
|
92
|
+
}, X = Object.fromEntries(Object.values(Y).flatMap((e) => "serverTemplates" in e ? [[e.type, e.serverTemplates]] : [])), Z = Object.fromEntries(Object.values(Y).flatMap((e) => "contentAttributes" in e ? [[e.type, e.contentAttributes]] : [])), Q = (e) => Z[e] ?? [];
|
|
91
93
|
//#endregion
|
|
92
|
-
export { A as ApiContainerDeclaration, e as BlockHtmlDeclaration, t as BlockJsxDeclaration, o as ButtonDeclaration, N as CarouselDeclaration, M as CarouselTrackDeclaration, j as ChannelDeclaration, w as ChartDeclaration, P as ContainerDeclaration, n as CustomDeclaration, S as DOCUMENT_SCROLLS, I as DialogContainerDeclaration, s as DropdownDeclaration, c as DropdownPopupDeclaration, T as EmbedDeclaration, E as FontAwesomeDeclaration, _ as FormControlDeclaration, g as FormDeclaration,
|
|
94
|
+
export { A as ApiContainerDeclaration, e as BlockHtmlDeclaration, t as BlockJsxDeclaration, o as ButtonDeclaration, N as CarouselDeclaration, M as CarouselTrackDeclaration, j as ChannelDeclaration, w as ChartDeclaration, P as ContainerDeclaration, n as CustomDeclaration, S as DOCUMENT_SCROLLS, I as DialogContainerDeclaration, s as DropdownDeclaration, c as DropdownPopupDeclaration, T as EmbedDeclaration, L as FocusGroupDeclaration, E as FontAwesomeDeclaration, _ as FormControlDeclaration, g as FormDeclaration, q as HTML_TAG_PARTS, l as HeadingDeclaration, D as ImageDeclaration, v as LayoutContainerDeclaration, u as LinkDeclaration, R as ListDeclaration, z as ListItemDeclaration, y as LoadingDeclaration, d as MarkdownDeclaration, B as ModalContainerDeclaration, F as NAMEABLE_CONTAINER_TAGS, r as NodeHtmlDeclaration, b as NotFoundDeclaration, x as PageDeclaration, V as PaginationDeclaration, f as ParagraphDeclaration, i as PlitziSdkDeclaration, a as ReferenceDeclaration, p as RichTextDeclaration, O as SvgDeclaration, U as TabContainerBodyDeclaration, H as TabContainerDeclaration, W as TabContainerHeaderDeclaration, G as TabContainerItemDeclaration, m as TextDeclaration, h as ThemeToggleDeclaration, k as VideoDeclaration, Z as contentAttributesByType, Q as contentAttributesOf, Y as elementDeclarations, K as interactionBasicTriggers, C as isDocumentScroll, J as isSvgMarkup, X as serverTemplatesByType };
|
|
@@ -28,7 +28,8 @@ export type Field = {
|
|
|
28
28
|
id: string;
|
|
29
29
|
name: string;
|
|
30
30
|
};
|
|
31
|
-
|
|
31
|
+
/** A `file` control holds the `File` picked; every other control text, a number or a checkbox's state. */
|
|
32
|
+
export type FieldValue = string | boolean | number | File;
|
|
32
33
|
/** What a control says about the form's values as they stand: the sentence to show under it, or `''`. */
|
|
33
34
|
export type FieldValidator = (values: Record<string, unknown>) => string;
|
|
34
35
|
export type FormContextValue = {
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
+
import { FormControlSubType } from './subTypes';
|
|
1
2
|
import { ChangeEvent, RefObject } from 'react';
|
|
2
3
|
export type FormControlProps = {
|
|
3
4
|
ref: RefObject<HTMLElement>;
|
|
4
5
|
className: string;
|
|
5
|
-
subType:
|
|
6
|
-
/** A search box: the browser draws its clear button, and a phone shows its search key. */
|
|
7
|
-
| 'search' | 'url'
|
|
8
|
-
/** A phone number: a phone shows its dial pad. */
|
|
9
|
-
| 'tel' | 'date' | 'time' | 'checkbox' | 'switch' | 'select' | 'textarea' | 'hidden'
|
|
10
|
-
/** The browser's own colour picker: its value is `#rrggbb`. */
|
|
11
|
-
| 'color';
|
|
6
|
+
subType: FormControlSubType;
|
|
12
7
|
name: string;
|
|
13
8
|
label: string;
|
|
14
9
|
/**
|
|
@@ -18,6 +13,8 @@ export type FormControlProps = {
|
|
|
18
13
|
*/
|
|
19
14
|
hideLabel: boolean;
|
|
20
15
|
placeholder: string;
|
|
16
|
+
/** A `file` field's offer, as the browser reads `accept`: `image/png,image/jpeg`, `.pdf`. `''` for any file. */
|
|
17
|
+
accept: string;
|
|
21
18
|
autoComplete: boolean;
|
|
22
19
|
/**
|
|
23
20
|
* Takes the focus as it appears — a search box opened by a shortcut is typed into at once. With the control's
|
|
@@ -57,7 +54,8 @@ export type FormControlProps = {
|
|
|
57
54
|
matches: string;
|
|
58
55
|
matchesMessage: string;
|
|
59
56
|
readOnly: boolean;
|
|
60
|
-
value
|
|
57
|
+
/** Text for every type but `file`, whose value is the `File` picked. */
|
|
58
|
+
value: string | File;
|
|
61
59
|
error: string;
|
|
62
60
|
/**
|
|
63
61
|
* Supplied by `withFieldValue`, with or without a form around the control.
|
|
@@ -68,7 +66,7 @@ export type FormControlProps = {
|
|
|
68
66
|
handleChange?: (e: ChangeEvent<HTMLInputElement> | ChangeEvent<HTMLSelectElement> | ChangeEvent<HTMLTextAreaElement>) => void;
|
|
69
67
|
handleValidate?: () => void;
|
|
70
68
|
};
|
|
71
|
-
declare const FormControl: ({ ref, className, subType, name, label, hideLabel, placeholder, autoComplete, autoFocus, disabled, options, required, maxLength, min, max, step, readOnly, value, error, handleChange, handleValidate }: FormControlProps) => import('react').JSX.Element;
|
|
69
|
+
declare const FormControl: ({ ref, className, subType, name, label, hideLabel, placeholder, accept, autoComplete, autoFocus, disabled, options, required, maxLength, min, max, step, readOnly, value, error, handleChange, handleValidate }: FormControlProps) => import('react').JSX.Element;
|
|
72
70
|
declare const _default: {
|
|
73
71
|
(props: import('../../..').WithElementProps<import('./hocs/withFieldValue').WithFieldValueProps<FormControlProps>>): string | number | bigint | boolean | Iterable<import('react').ReactNode> | Promise<string | number | bigint | boolean | import('react').ReactPortal | import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>> | Iterable<import('react').ReactNode> | null | undefined> | import('react').JSX.Element | null | undefined;
|
|
74
72
|
displayName: string;
|
|
@@ -1,172 +1,177 @@
|
|
|
1
|
-
import e from "./
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import a from "./components/
|
|
7
|
-
import
|
|
1
|
+
import { CHECK_SUBTYPES as e, INPUT_SUBTYPES as t } from "./subTypes.mjs";
|
|
2
|
+
import n from "./declaration.mjs";
|
|
3
|
+
import r from "../../../Element/hocs/withElement.mjs";
|
|
4
|
+
import i from "../../../Element/hooks/useElement.mjs";
|
|
5
|
+
import { RootElement as ee } from "../../../Element/RootElement.mjs";
|
|
6
|
+
import { VISUALLY_HIDDEN as a } from "./components/visuallyHidden.mjs";
|
|
7
|
+
import o from "./components/Label.mjs";
|
|
8
|
+
import { isChecked as te } from "./helpers/isChecked.mjs";
|
|
8
9
|
import s from "./hocs/withFieldValue.mjs";
|
|
9
10
|
import c from "./inputs/Checkbox.mjs";
|
|
10
|
-
import l from "./inputs/
|
|
11
|
-
import u from "./inputs/
|
|
12
|
-
import d from "./inputs/
|
|
13
|
-
import f from "./inputs/
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import
|
|
19
|
-
import
|
|
11
|
+
import l from "./inputs/FileInput.mjs";
|
|
12
|
+
import u from "./inputs/Hidden.mjs";
|
|
13
|
+
import d from "./inputs/Input.mjs";
|
|
14
|
+
import f from "./inputs/Select.mjs";
|
|
15
|
+
import p from "./inputs/Textarea.mjs";
|
|
16
|
+
import { use as m, useCallback as ne, useEffect as re } from "react";
|
|
17
|
+
import { usePlitzi as ie } from "@plitzi/sdk-shared/hooks";
|
|
18
|
+
import { createStoreHook as h } from "@plitzi/nexus/react";
|
|
19
|
+
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
20
|
+
import v from "clsx";
|
|
21
|
+
import { InteractionsContext as ae } from "@plitzi/sdk-interactions";
|
|
20
22
|
//#region src/elements/form/FormControl/FormControl.tsx
|
|
21
|
-
var
|
|
22
|
-
let { id: L, rootId: R, visible: z, definition: { styleSelectors: B } } =
|
|
23
|
+
var y = ({ ref: r, className: s = "", subType: y = "text", name: b = "", label: x = "", hideLabel: S = !1, placeholder: C = "", accept: oe = "", autoComplete: w = !0, autoFocus: T = !1, disabled: E = !1, options: D = [], required: O = !1, maxLength: k = 0, min: se = "", max: A = "", step: j = "", readOnly: M = !1, value: N = "", error: P = "", handleChange: F, handleValidate: I }) => {
|
|
24
|
+
let { id: L, rootId: R, visible: z, definition: { styleSelectors: B } } = i(), { settings: { previewMode: V } } = ie(), { interactionsManager: H } = m(ae), { useStore: U } = h(), [W] = U("runtime.sources.form"), G = ne((e) => {
|
|
23
25
|
if (F?.(e), !V) return;
|
|
24
|
-
let { target: t } = e, n = t instanceof HTMLInputElement && t.type === "checkbox" ? t.checked : t.value;
|
|
26
|
+
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;
|
|
25
27
|
H.interactionTrigger(L, "onChange", {
|
|
26
|
-
value:
|
|
27
|
-
name:
|
|
28
|
+
value: i,
|
|
29
|
+
name: b
|
|
28
30
|
});
|
|
29
31
|
}, [
|
|
30
32
|
F,
|
|
31
33
|
V,
|
|
32
34
|
H,
|
|
33
35
|
L,
|
|
34
|
-
|
|
35
|
-
]), K = W?.registerField, q = W?.unregisterField, J =
|
|
36
|
-
variant:
|
|
36
|
+
b
|
|
37
|
+
]), K = W?.registerField, q = W?.unregisterField, J = e.includes(y), ce = y === "hidden", Y = T && V && z, X = S && V, Z = P && V ? `${R}_${L}_error` : void 0, Q = typeof N == "string" ? N : "", $ = J && /* @__PURE__ */ g(c, {
|
|
38
|
+
variant: y === "switch" ? "switch" : "checkbox",
|
|
37
39
|
id: `${R}_${L}`,
|
|
38
|
-
name:
|
|
39
|
-
checked:
|
|
40
|
+
name: b,
|
|
41
|
+
checked: te(N),
|
|
40
42
|
className: B.input,
|
|
41
|
-
required:
|
|
42
|
-
disabled:
|
|
43
|
+
required: O,
|
|
44
|
+
disabled: E,
|
|
43
45
|
onChange: G,
|
|
44
46
|
onValidate: I,
|
|
45
|
-
errorId:
|
|
47
|
+
errorId: Z
|
|
46
48
|
});
|
|
47
|
-
return
|
|
49
|
+
return re(() => {
|
|
48
50
|
if (K && q) return K({
|
|
49
|
-
name:
|
|
50
|
-
path:
|
|
51
|
-
}), () => q(
|
|
51
|
+
name: b,
|
|
52
|
+
path: b
|
|
53
|
+
}), () => q(b);
|
|
52
54
|
}, [
|
|
53
|
-
|
|
55
|
+
b,
|
|
54
56
|
K,
|
|
55
57
|
q
|
|
56
|
-
]), /* @__PURE__ */
|
|
57
|
-
ref:
|
|
58
|
-
interactionTriggers:
|
|
59
|
-
className:
|
|
58
|
+
]), /* @__PURE__ */ _(ee, {
|
|
59
|
+
ref: r,
|
|
60
|
+
interactionTriggers: n.triggers,
|
|
61
|
+
className: v("plitzi-component__form-control", {
|
|
60
62
|
"form-control--invalid": P && V,
|
|
61
|
-
[`plitzi-component__form-control-${
|
|
63
|
+
[`plitzi-component__form-control-${y}`]: y
|
|
62
64
|
}, s),
|
|
63
65
|
children: [
|
|
64
|
-
!J && !
|
|
66
|
+
!J && !ce && x && /* @__PURE__ */ g(o, {
|
|
65
67
|
targetInput: `${R}_${L}`,
|
|
66
68
|
previewMode: V,
|
|
67
69
|
className: B.label,
|
|
68
70
|
requiredClassName: B.requiredMark,
|
|
69
|
-
type:
|
|
70
|
-
required:
|
|
71
|
-
hidden:
|
|
72
|
-
children:
|
|
71
|
+
type: y,
|
|
72
|
+
required: O,
|
|
73
|
+
hidden: X,
|
|
74
|
+
children: x
|
|
73
75
|
}),
|
|
74
|
-
J &&
|
|
76
|
+
J && x && /* @__PURE__ */ _(o, {
|
|
75
77
|
targetInput: `${R}_${L}`,
|
|
76
78
|
previewMode: V,
|
|
77
79
|
className: B.label,
|
|
78
80
|
requiredClassName: B.requiredMark,
|
|
79
|
-
type:
|
|
80
|
-
required:
|
|
81
|
+
type: y,
|
|
82
|
+
required: O,
|
|
81
83
|
children: [
|
|
82
84
|
$,
|
|
83
|
-
|
|
84
|
-
style:
|
|
85
|
-
children:
|
|
85
|
+
X && /* @__PURE__ */ g("span", {
|
|
86
|
+
style: a,
|
|
87
|
+
children: x
|
|
86
88
|
}),
|
|
87
|
-
!
|
|
89
|
+
!X && x
|
|
88
90
|
]
|
|
89
91
|
}),
|
|
90
|
-
J && !
|
|
91
|
-
|
|
92
|
-
"text",
|
|
93
|
-
"number",
|
|
94
|
-
"email",
|
|
95
|
-
"password",
|
|
96
|
-
"search",
|
|
97
|
-
"url",
|
|
98
|
-
"tel",
|
|
99
|
-
"date",
|
|
100
|
-
"time",
|
|
101
|
-
"color"
|
|
102
|
-
].includes(b) && /* @__PURE__ */ _(u, {
|
|
92
|
+
J && !x && $,
|
|
93
|
+
t.includes(y) && /* @__PURE__ */ g(d, {
|
|
103
94
|
id: `${R}_${L}`,
|
|
104
|
-
name:
|
|
105
|
-
value:
|
|
106
|
-
type:
|
|
95
|
+
name: b,
|
|
96
|
+
value: Q,
|
|
97
|
+
type: y,
|
|
107
98
|
className: B.input,
|
|
108
99
|
fieldClassName: B.field,
|
|
109
100
|
iconClassName: B.icon,
|
|
110
|
-
placeholder:
|
|
111
|
-
autoComplete:
|
|
112
|
-
autoFocus:
|
|
113
|
-
required:
|
|
114
|
-
maxLength:
|
|
115
|
-
min:
|
|
116
|
-
max:
|
|
101
|
+
placeholder: C,
|
|
102
|
+
autoComplete: y !== "password" && w,
|
|
103
|
+
autoFocus: Y,
|
|
104
|
+
required: O,
|
|
105
|
+
maxLength: k,
|
|
106
|
+
min: se,
|
|
107
|
+
max: A,
|
|
117
108
|
step: j,
|
|
118
|
-
disabled:
|
|
109
|
+
disabled: E,
|
|
119
110
|
readOnly: M || !V,
|
|
120
111
|
onChange: G,
|
|
121
112
|
onValidate: I,
|
|
122
|
-
errorId:
|
|
113
|
+
errorId: Z
|
|
123
114
|
}),
|
|
124
|
-
|
|
115
|
+
y === "hidden" && /* @__PURE__ */ g(u, {
|
|
125
116
|
id: `${R}_${L}`,
|
|
126
|
-
name:
|
|
127
|
-
value:
|
|
128
|
-
required:
|
|
129
|
-
disabled:
|
|
117
|
+
name: b,
|
|
118
|
+
value: Q,
|
|
119
|
+
required: O,
|
|
120
|
+
disabled: E,
|
|
130
121
|
previewMode: V
|
|
131
122
|
}),
|
|
132
|
-
|
|
123
|
+
y === "select" && /* @__PURE__ */ g(f, {
|
|
133
124
|
id: `${R}_${L}`,
|
|
134
|
-
name:
|
|
125
|
+
name: b,
|
|
135
126
|
onChange: G,
|
|
136
127
|
onValidate: I,
|
|
137
|
-
errorId:
|
|
138
|
-
value:
|
|
128
|
+
errorId: Z,
|
|
129
|
+
value: Q,
|
|
139
130
|
className: B.input,
|
|
140
131
|
fieldClassName: B.field,
|
|
141
|
-
placeholder:
|
|
142
|
-
autoFocus:
|
|
143
|
-
required:
|
|
144
|
-
disabled:
|
|
145
|
-
options:
|
|
132
|
+
placeholder: C,
|
|
133
|
+
autoFocus: Y,
|
|
134
|
+
required: O,
|
|
135
|
+
disabled: E,
|
|
136
|
+
options: D
|
|
146
137
|
}),
|
|
147
|
-
|
|
138
|
+
y === "textarea" && /* @__PURE__ */ g(p, {
|
|
148
139
|
id: `${R}_${L}`,
|
|
149
|
-
name:
|
|
150
|
-
value:
|
|
140
|
+
name: b,
|
|
141
|
+
value: Q,
|
|
151
142
|
className: B.input,
|
|
152
|
-
placeholder:
|
|
153
|
-
autoFocus:
|
|
154
|
-
required:
|
|
155
|
-
maxLength:
|
|
156
|
-
disabled:
|
|
143
|
+
placeholder: C,
|
|
144
|
+
autoFocus: Y,
|
|
145
|
+
required: O,
|
|
146
|
+
maxLength: k,
|
|
147
|
+
disabled: E,
|
|
157
148
|
readOnly: M,
|
|
158
149
|
onChange: G,
|
|
159
150
|
onValidate: I,
|
|
160
|
-
errorId:
|
|
151
|
+
errorId: Z
|
|
161
152
|
}),
|
|
162
|
-
|
|
163
|
-
id:
|
|
153
|
+
y === "file" && /* @__PURE__ */ g(l, {
|
|
154
|
+
id: `${R}_${L}`,
|
|
155
|
+
name: b,
|
|
156
|
+
accept: oe,
|
|
157
|
+
chosen: N instanceof File ? N : void 0,
|
|
158
|
+
className: B.input,
|
|
159
|
+
fieldClassName: B.field,
|
|
160
|
+
required: O,
|
|
161
|
+
disabled: E,
|
|
162
|
+
previewMode: V,
|
|
163
|
+
onChange: G,
|
|
164
|
+
onValidate: I,
|
|
165
|
+
errorId: Z
|
|
166
|
+
}),
|
|
167
|
+
P && /* @__PURE__ */ g("div", {
|
|
168
|
+
id: Z,
|
|
164
169
|
role: "alert",
|
|
165
|
-
className:
|
|
170
|
+
className: v("form-control__error-message", B.error),
|
|
166
171
|
children: P
|
|
167
172
|
})
|
|
168
173
|
]
|
|
169
174
|
});
|
|
170
|
-
},
|
|
175
|
+
}, b = r(s(y));
|
|
171
176
|
//#endregion
|
|
172
|
-
export {
|
|
177
|
+
export { y as FormControl, b as default };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { FormControlSubType } from './subTypes';
|
|
1
2
|
type SettingsProps = {
|
|
2
|
-
subType?:
|
|
3
|
+
subType?: FormControlSubType;
|
|
3
4
|
name?: string;
|
|
4
5
|
label?: string;
|
|
5
6
|
hideLabel?: boolean;
|
|
6
7
|
placeholder?: string;
|
|
8
|
+
accept?: string;
|
|
7
9
|
autoComplete?: boolean;
|
|
8
10
|
autoFocus?: boolean;
|
|
9
11
|
defaultValue?: string;
|
|
@@ -29,5 +31,5 @@ type SettingsProps = {
|
|
|
29
31
|
previewError?: boolean;
|
|
30
32
|
onUpdate?: (key: string, value: string | boolean | number | string[]) => void;
|
|
31
33
|
};
|
|
32
|
-
declare const Settings: ({ subType, name, label, hideLabel, defaultValue, placeholder, autoComplete, autoFocus, options, required, requiredMessage, minLength, minLengthMessage, maxLength, maxLengthMessage, min, minMessage, max, maxMessage, step, formatMessage, pattern, patternMessage, matches, matchesMessage, readOnly, disabled, previewError, onUpdate }: SettingsProps) => import('react').JSX.Element;
|
|
34
|
+
declare const Settings: ({ subType, name, label, hideLabel, defaultValue, placeholder, accept, autoComplete, autoFocus, options, required, requiredMessage, minLength, minLengthMessage, maxLength, maxLengthMessage, min, minMessage, max, maxMessage, step, formatMessage, pattern, patternMessage, matches, matchesMessage, readOnly, disabled, previewError, onUpdate }: SettingsProps) => import('react').JSX.Element;
|
|
33
35
|
export default Settings;
|