@plitzi/sdk-elements 0.37.2 → 0.37.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 +1180 -0
- package/dist/Component/ComponentProvider.mjs +10 -5
- package/dist/Element/JsxManager.mjs +1 -0
- package/dist/Element/PluginRemote.d.ts +3 -1
- package/dist/Element/PluginRemote.mjs +9 -9
- package/dist/Element/helpers/elementConstants.mjs +28 -0
- package/dist/Element/helpers/elementUtils.mjs +1 -1
- package/dist/Element/helpers/loadComponent.d.ts +6 -1
- package/dist/Element/helpers/loadComponent.mjs +7 -7
- package/dist/Element/helpers/pluginSelector.mjs +1 -0
- package/dist/Element/hooks/useElementDataSource.mjs +23 -16
- package/dist/Element/hooks/useElementInternal.mjs +60 -52
- package/dist/Element/hooks/useInternalClassName.mjs +19 -18
- package/dist/Element/hooks/useKeyTriggers.d.ts +18 -0
- package/dist/Element/hooks/useKeyTriggers.mjs +36 -0
- package/dist/Element/hooks/useRootElementInteractions.mjs +65 -56
- package/dist/Element/hooks/useRscData.mjs +20 -15
- package/dist/dataSource/GlobalSources.mjs +114 -80
- package/dist/dataSource/getSourcesByElementId.mjs +2 -2
- package/dist/elements/advanced/BlockJsx/BlockJsx.mjs +1 -1
- package/dist/elements/advanced/NodeHtml/declaration.d.ts +1 -1
- package/dist/elements/advanced/NodeHtml/index.d.ts +1 -1
- package/dist/elements/basic/Button/Button.d.ts +10 -3
- package/dist/elements/basic/Button/Button.mjs +5 -5
- package/dist/elements/basic/Button/Settings.d.ts +2 -1
- package/dist/elements/basic/Button/Settings.mjs +14 -7
- package/dist/elements/basic/Button/declaration.d.ts +8 -3
- package/dist/elements/basic/Button/declaration.mjs +14 -6
- package/dist/elements/basic/Button/index.d.ts +8 -3
- package/dist/elements/basic/Dropdown/Dropdown.mjs +48 -39
- package/dist/elements/basic/Dropdown/declaration.d.ts +3 -0
- package/dist/elements/basic/Dropdown/declaration.mjs +9 -3
- package/dist/elements/basic/Dropdown/index.d.ts +3 -0
- package/dist/elements/basic/Dropdown/useDropdown.d.ts +6 -1
- package/dist/elements/basic/Dropdown/useDropdown.mjs +58 -41
- package/dist/elements/basic/Dropdown/useDropdownTrigger.d.ts +26 -0
- package/dist/elements/basic/Dropdown/useDropdownTrigger.mjs +30 -0
- package/dist/elements/basic/Heading/declaration.d.ts +9 -6
- package/dist/elements/basic/Heading/declaration.mjs +17 -9
- package/dist/elements/basic/Heading/index.d.ts +9 -6
- package/dist/elements/basic/Link/Link.mjs +4 -1
- package/dist/elements/basic/Link/Settings.d.ts +2 -1
- package/dist/elements/basic/Link/Settings.mjs +31 -24
- package/dist/elements/basic/Link/declaration.d.ts +5 -1
- package/dist/elements/basic/Link/declaration.mjs +16 -3
- package/dist/elements/basic/Link/index.d.ts +5 -1
- package/dist/elements/basic/Markdown/declaration.d.ts +1 -1
- package/dist/elements/basic/Markdown/declaration.mjs +1 -1
- package/dist/elements/basic/Markdown/index.d.ts +1 -1
- package/dist/elements/basic/RichText/declaration.d.ts +3 -0
- package/dist/elements/basic/RichText/declaration.mjs +8 -3
- package/dist/elements/basic/RichText/index.d.ts +3 -0
- package/dist/elements/basic/Text/declaration.d.ts +1 -1
- package/dist/elements/basic/Text/declaration.mjs +1 -1
- package/dist/elements/basic/Text/index.d.ts +1 -1
- package/dist/elements/basic/ThemeToggle/ThemeToggle.mjs +3 -0
- package/dist/elements/basic/ThemeToggle/declaration.d.ts +3 -0
- package/dist/elements/basic/ThemeToggle/declaration.mjs +4 -3
- package/dist/elements/basic/ThemeToggle/index.d.ts +3 -0
- package/dist/elements/declarations/index.d.ts +217 -17
- package/dist/elements/declarations/index.mjs +24 -22
- package/dist/elements/form/Form/declaration.d.ts +3 -0
- package/dist/elements/form/Form/declaration.mjs +4 -3
- package/dist/elements/form/Form/index.d.ts +3 -0
- package/dist/elements/form/FormControl/FormControl.d.ts +18 -6
- package/dist/elements/form/FormControl/FormControl.mjs +135 -127
- package/dist/elements/form/FormControl/Settings.d.ts +3 -1
- package/dist/elements/form/FormControl/Settings.mjs +73 -57
- package/dist/elements/form/FormControl/components/Label.d.ts +3 -1
- package/dist/elements/form/FormControl/components/Label.mjs +20 -18
- package/dist/elements/form/FormControl/components/visuallyHidden.d.ts +6 -0
- package/dist/elements/form/FormControl/components/visuallyHidden.mjs +14 -0
- package/dist/elements/form/FormControl/declaration.d.ts +5 -0
- package/dist/elements/form/FormControl/declaration.mjs +46 -30
- package/dist/elements/form/FormControl/hocs/withFieldValue.mjs +68 -61
- package/dist/elements/form/FormControl/index.d.ts +5 -0
- package/dist/elements/form/FormControl/inputs/Checkbox.d.ts +6 -1
- package/dist/elements/form/FormControl/inputs/Checkbox.mjs +5 -3
- package/dist/elements/form/FormControl/inputs/Input.d.ts +8 -1
- package/dist/elements/form/FormControl/inputs/Input.mjs +44 -38
- package/dist/elements/form/FormControl/inputs/Select.d.ts +6 -1
- package/dist/elements/form/FormControl/inputs/Select.mjs +12 -10
- package/dist/elements/form/FormControl/inputs/Textarea.d.ts +8 -1
- package/dist/elements/form/FormControl/inputs/Textarea.mjs +26 -21
- package/dist/elements/form/FormControl/inputs/useFocusWhenShown.d.ts +7 -0
- package/dist/elements/form/FormControl/inputs/useFocusWhenShown.mjs +9 -0
- package/dist/elements/index.d.ts +3 -1
- package/dist/elements/index.mjs +16 -14
- package/dist/elements/internal/LayoutContainer/declaration.d.ts +3 -0
- package/dist/elements/internal/LayoutContainer/declaration.mjs +15 -3
- package/dist/elements/internal/LayoutContainer/index.d.ts +3 -0
- package/dist/elements/media/FontAwesome/FontAwesome.d.ts +8 -1
- package/dist/elements/media/FontAwesome/FontAwesome.mjs +12 -5
- package/dist/elements/media/FontAwesome/Settings.d.ts +2 -1
- package/dist/elements/media/FontAwesome/Settings.mjs +29 -22
- package/dist/elements/media/FontAwesome/declaration.d.ts +1 -0
- package/dist/elements/media/FontAwesome/index.d.ts +1 -0
- package/dist/elements/media/Image/Image.d.ts +13 -2
- package/dist/elements/media/Image/Image.mjs +25 -25
- package/dist/elements/media/Image/Settings.d.ts +3 -1
- package/dist/elements/media/Image/Settings.mjs +29 -15
- package/dist/elements/media/Image/declaration.d.ts +7 -1
- package/dist/elements/media/Image/declaration.mjs +16 -3
- package/dist/elements/media/Image/index.d.ts +7 -1
- package/dist/elements/provider/ApiContainer/ApiContainer.mjs +145 -137
- package/dist/elements/provider/ApiContainer/declaration.d.ts +14 -1
- package/dist/elements/provider/ApiContainer/declaration.mjs +41 -4
- package/dist/elements/provider/ApiContainer/helpers/isEmptyAnswer.d.ts +16 -0
- package/dist/elements/provider/ApiContainer/helpers/isEmptyAnswer.mjs +4 -0
- package/dist/elements/provider/ApiContainer/helpers/queryInput.d.ts +5 -0
- package/dist/elements/provider/ApiContainer/helpers/queryInput.mjs +12 -0
- package/dist/elements/provider/ApiContainer/index.d.ts +14 -1
- package/dist/elements/provider/Channel/Channel.d.ts +26 -0
- package/dist/elements/provider/Channel/Channel.mjs +92 -0
- package/dist/elements/provider/Channel/Settings.d.ts +9 -0
- package/dist/elements/provider/Channel/Settings.mjs +38 -0
- package/dist/elements/provider/Channel/declaration.d.ts +138 -0
- package/dist/elements/provider/Channel/declaration.mjs +125 -0
- package/dist/elements/provider/Channel/index.d.ts +137 -0
- package/dist/elements/provider/Channel/index.mjs +6 -0
- package/dist/elements/settings.mjs +25 -23
- package/dist/elements/structure/Container/Container.d.ts +16 -2
- package/dist/elements/structure/Container/Container.mjs +18 -9
- package/dist/elements/structure/Container/Settings.d.ts +4 -2
- package/dist/elements/structure/Container/Settings.mjs +110 -69
- package/dist/elements/structure/Container/declaration.d.ts +12 -1
- package/dist/elements/structure/Container/declaration.mjs +35 -3
- package/dist/elements/structure/Container/index.d.ts +6 -1
- package/dist/elements/structure/Container/index.mjs +3 -3
- package/dist/elements/structure/DialogContainer/DialogContainer.mjs +123 -100
- package/dist/elements/structure/List/declaration.d.ts +4 -0
- package/dist/elements/structure/List/declaration.mjs +7 -3
- package/dist/elements/structure/List/index.d.ts +4 -0
- package/dist/elements/structure/ModalContainer/ModalContainer.mjs +92 -80
- package/dist/elements/structure/ModalContainer/metadataFromText.d.ts +1 -0
- package/dist/elements/structure/ModalContainer/metadataFromText.mjs +10 -0
- package/dist/elements/structure/ModalContainer/useModalDialog.d.ts +20 -0
- package/dist/elements/structure/ModalContainer/useModalDialog.mjs +31 -0
- package/dist/elements/structure/Pagination/Pagination.d.ts +6 -1
- package/dist/elements/structure/Pagination/Pagination.mjs +23 -21
- package/dist/elements/structure/Pagination/Settings.d.ts +2 -1
- package/dist/elements/structure/Pagination/Settings.mjs +16 -9
- package/dist/elements/structure/Pagination/declaration.d.ts +5 -0
- package/dist/elements/structure/Pagination/declaration.mjs +7 -3
- package/dist/elements/structure/Pagination/index.d.ts +5 -0
- package/dist/elements/structure/TabContainer/TabContainer.mjs +19 -17
- package/dist/elements/structure/TabContainer/TabContainerBody/TabContainerBody.mjs +8 -6
- package/dist/elements/structure/TabContainer/TabContainerContext.d.ts +2 -0
- package/dist/elements/structure/TabContainer/TabContainerHeader/TabContainerHeader.mjs +18 -14
- package/dist/elements/structure/TabContainer/TabContainerItem/TabContainerItem.d.ts +5 -1
- package/dist/elements/structure/TabContainer/TabContainerItem/TabContainerItem.mjs +48 -13
- package/dist/elements/structure/TabContainer/TabContainerItem/declaration.d.ts +1 -1
- package/dist/index.d.ts +220 -16
- package/dist/index.mjs +20 -17
- package/dist/realtime/useChannel.d.ts +35 -0
- package/dist/realtime/useChannel.mjs +57 -0
- package/package.json +67 -11
- package/dist/elements/media/FontAwesome/FontAwesome.stories-paused.d.ts +0 -1
|
@@ -4,6 +4,10 @@ import { AuthorableAttributes } from '@plitzi/sdk-shared/authoring/declare';
|
|
|
4
4
|
export type ButtonAttributes = AuthorableAttributes<ButtonProps>;
|
|
5
5
|
declare const declaration: {
|
|
6
6
|
readonly type: "button";
|
|
7
|
+
readonly attributeValues: {
|
|
8
|
+
readonly subType: readonly string[];
|
|
9
|
+
readonly contentPlacement: readonly string[];
|
|
10
|
+
};
|
|
7
11
|
readonly content: {
|
|
8
12
|
readonly attributes: {
|
|
9
13
|
readonly contentPlacement: "after";
|
|
@@ -63,7 +67,7 @@ declare const declaration: {
|
|
|
63
67
|
readonly 'padding-bottom': "6px";
|
|
64
68
|
readonly cursor: "pointer";
|
|
65
69
|
readonly 'font-size': "16px";
|
|
66
|
-
readonly 'line-height': "
|
|
70
|
+
readonly 'line-height': "1.5";
|
|
67
71
|
readonly 'border-top-left-radius': "4px";
|
|
68
72
|
readonly 'border-top-right-radius': "4px";
|
|
69
73
|
readonly 'border-bottom-left-radius': "4px";
|
|
@@ -84,7 +88,7 @@ declare const declaration: {
|
|
|
84
88
|
readonly 'padding-bottom': "6px";
|
|
85
89
|
readonly cursor: "pointer";
|
|
86
90
|
readonly 'font-size': "16px";
|
|
87
|
-
readonly 'line-height': "
|
|
91
|
+
readonly 'line-height': "1.5";
|
|
88
92
|
readonly 'border-top-left-radius': "4px";
|
|
89
93
|
readonly 'border-top-right-radius': "4px";
|
|
90
94
|
readonly 'border-bottom-left-radius': "4px";
|
|
@@ -105,7 +109,7 @@ declare const declaration: {
|
|
|
105
109
|
readonly 'padding-bottom': "6px";
|
|
106
110
|
readonly cursor: "pointer";
|
|
107
111
|
readonly 'font-size': "16px";
|
|
108
|
-
readonly 'line-height': "
|
|
112
|
+
readonly 'line-height': "1.5";
|
|
109
113
|
readonly 'border-top-left-radius': "4px";
|
|
110
114
|
readonly 'border-top-right-radius': "4px";
|
|
111
115
|
readonly 'border-bottom-left-radius': "4px";
|
|
@@ -119,6 +123,7 @@ declare const declaration: {
|
|
|
119
123
|
readonly settings: {};
|
|
120
124
|
};
|
|
121
125
|
} & import('@plitzi/sdk-shared/authoring/declare').ElementAttributesBrand<Partial<{
|
|
126
|
+
label?: string | undefined;
|
|
122
127
|
title?: string | undefined;
|
|
123
128
|
content?: string | undefined;
|
|
124
129
|
disabled?: boolean | undefined;
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import { elementDeclaration as e } from "@plitzi/sdk-shared/authoring/declare";
|
|
1
|
+
import { elementDeclaration as e, valuesOf as t } from "@plitzi/sdk-shared/authoring/declare";
|
|
2
2
|
//#region src/elements/basic/Button/declaration.ts
|
|
3
|
-
var
|
|
3
|
+
var n = e()({
|
|
4
4
|
type: "button",
|
|
5
|
+
attributeValues: {
|
|
6
|
+
subType: t()([
|
|
7
|
+
"button",
|
|
8
|
+
"submit",
|
|
9
|
+
"reset"
|
|
10
|
+
]),
|
|
11
|
+
contentPlacement: t()(["before", "after"])
|
|
12
|
+
},
|
|
5
13
|
content: {
|
|
6
14
|
attributes: {
|
|
7
15
|
contentPlacement: "after",
|
|
@@ -51,7 +59,7 @@ var t = e()({
|
|
|
51
59
|
"padding-bottom": "6px",
|
|
52
60
|
cursor: "pointer",
|
|
53
61
|
"font-size": "16px",
|
|
54
|
-
"line-height": "
|
|
62
|
+
"line-height": "1.5",
|
|
55
63
|
"border-top-left-radius": "4px",
|
|
56
64
|
"border-top-right-radius": "4px",
|
|
57
65
|
"border-bottom-left-radius": "4px",
|
|
@@ -68,7 +76,7 @@ var t = e()({
|
|
|
68
76
|
"padding-bottom": "6px",
|
|
69
77
|
cursor: "pointer",
|
|
70
78
|
"font-size": "16px",
|
|
71
|
-
"line-height": "
|
|
79
|
+
"line-height": "1.5",
|
|
72
80
|
"border-top-left-radius": "4px",
|
|
73
81
|
"border-top-right-radius": "4px",
|
|
74
82
|
"border-bottom-left-radius": "4px",
|
|
@@ -85,7 +93,7 @@ var t = e()({
|
|
|
85
93
|
"padding-bottom": "6px",
|
|
86
94
|
cursor: "pointer",
|
|
87
95
|
"font-size": "16px",
|
|
88
|
-
"line-height": "
|
|
96
|
+
"line-height": "1.5",
|
|
89
97
|
"border-top-left-radius": "4px",
|
|
90
98
|
"border-top-right-radius": "4px",
|
|
91
99
|
"border-bottom-left-radius": "4px",
|
|
@@ -98,4 +106,4 @@ var t = e()({
|
|
|
98
106
|
}
|
|
99
107
|
});
|
|
100
108
|
//#endregion
|
|
101
|
-
export {
|
|
109
|
+
export { n as default };
|
|
@@ -3,6 +3,10 @@ declare const Button: {
|
|
|
3
3
|
displayName: string;
|
|
4
4
|
} & {
|
|
5
5
|
readonly type: "button";
|
|
6
|
+
readonly attributeValues: {
|
|
7
|
+
readonly subType: readonly string[];
|
|
8
|
+
readonly contentPlacement: readonly string[];
|
|
9
|
+
};
|
|
6
10
|
readonly content: {
|
|
7
11
|
readonly attributes: {
|
|
8
12
|
readonly contentPlacement: "after";
|
|
@@ -62,7 +66,7 @@ declare const Button: {
|
|
|
62
66
|
readonly 'padding-bottom': "6px";
|
|
63
67
|
readonly cursor: "pointer";
|
|
64
68
|
readonly 'font-size': "16px";
|
|
65
|
-
readonly 'line-height': "
|
|
69
|
+
readonly 'line-height': "1.5";
|
|
66
70
|
readonly 'border-top-left-radius': "4px";
|
|
67
71
|
readonly 'border-top-right-radius': "4px";
|
|
68
72
|
readonly 'border-bottom-left-radius': "4px";
|
|
@@ -83,7 +87,7 @@ declare const Button: {
|
|
|
83
87
|
readonly 'padding-bottom': "6px";
|
|
84
88
|
readonly cursor: "pointer";
|
|
85
89
|
readonly 'font-size': "16px";
|
|
86
|
-
readonly 'line-height': "
|
|
90
|
+
readonly 'line-height': "1.5";
|
|
87
91
|
readonly 'border-top-left-radius': "4px";
|
|
88
92
|
readonly 'border-top-right-radius': "4px";
|
|
89
93
|
readonly 'border-bottom-left-radius': "4px";
|
|
@@ -104,7 +108,7 @@ declare const Button: {
|
|
|
104
108
|
readonly 'padding-bottom': "6px";
|
|
105
109
|
readonly cursor: "pointer";
|
|
106
110
|
readonly 'font-size': "16px";
|
|
107
|
-
readonly 'line-height': "
|
|
111
|
+
readonly 'line-height': "1.5";
|
|
108
112
|
readonly 'border-top-left-radius': "4px";
|
|
109
113
|
readonly 'border-top-right-radius': "4px";
|
|
110
114
|
readonly 'border-bottom-left-radius': "4px";
|
|
@@ -118,6 +122,7 @@ declare const Button: {
|
|
|
118
122
|
readonly settings: {};
|
|
119
123
|
};
|
|
120
124
|
} & import('@plitzi/sdk-shared/authoring/declare').ElementAttributesBrand<Partial<{
|
|
125
|
+
label?: string | undefined;
|
|
121
126
|
title?: string | undefined;
|
|
122
127
|
content?: string | undefined;
|
|
123
128
|
disabled?: boolean | undefined;
|
|
@@ -3,56 +3,65 @@ import t from "../../../Element/hooks/useElement.mjs";
|
|
|
3
3
|
import { RootElement as n } from "../../../Element/RootElement.mjs";
|
|
4
4
|
import r from "./DropdownContext.mjs";
|
|
5
5
|
import i from "./useDropdown.mjs";
|
|
6
|
-
import
|
|
7
|
-
import c from "
|
|
8
|
-
import
|
|
9
|
-
import d from "
|
|
6
|
+
import a from "./useDropdownTrigger.mjs";
|
|
7
|
+
import { useCallback as o, useMemo as s, useRef as c } from "react";
|
|
8
|
+
import l from "@plitzi/sdk-shared/hooks/usePlitziServiceContext";
|
|
9
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
10
|
+
import f from "clsx";
|
|
10
11
|
//#region src/elements/basic/Dropdown/Dropdown.tsx
|
|
11
|
-
var
|
|
12
|
-
let { setElementState:
|
|
13
|
-
|
|
12
|
+
var p = ({ ref: e, children: p, className: m = "", popupPlacement: h = "bottom", openPopup: g = !1, backgroundDisabled: _ = !1, closeOnClickBackground: v = !0, closeOnClickPopup: y = !0, containerTopOffset: b = 5, containerLeftOffset: x = 5, disabled: S = !1 }) => {
|
|
13
|
+
let { setElementState: C, definition: { styleSelectors: w } } = t(), { settings: { previewMode: T }, utils: { getWindow: E } } = l(), D = c(null), O = c(null), k = s(() => E(), [E]), A = o((e) => {
|
|
14
|
+
v && (e.stopPropagation(), e.preventDefault(), C((e) => ({
|
|
14
15
|
...e,
|
|
15
16
|
openPopup: !1
|
|
16
17
|
})));
|
|
17
|
-
}, [
|
|
18
|
-
|
|
18
|
+
}, [v, C]), j = o((e) => {
|
|
19
|
+
C((t) => ({
|
|
19
20
|
...t,
|
|
20
21
|
openPopup: e
|
|
21
22
|
}));
|
|
22
|
-
}, [
|
|
23
|
+
}, [C]), [, , M, N, , P] = i({
|
|
23
24
|
ref: e,
|
|
24
|
-
popupRef:
|
|
25
|
-
open:
|
|
26
|
-
disabled: !
|
|
27
|
-
closeOnClickPopup:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
25
|
+
popupRef: D,
|
|
26
|
+
open: g,
|
|
27
|
+
disabled: !T || S,
|
|
28
|
+
closeOnClickPopup: y,
|
|
29
|
+
closeOnClickOutside: v && !_,
|
|
30
|
+
placement: h,
|
|
31
|
+
offsetX: x,
|
|
32
|
+
offsetY: b,
|
|
33
|
+
myWindow: k,
|
|
34
|
+
onChange: j
|
|
35
|
+
}), F = a({
|
|
36
|
+
popupRef: D,
|
|
37
|
+
open: g,
|
|
38
|
+
positioned: !!P,
|
|
39
|
+
enabled: !!T && !S
|
|
40
|
+
}), I = o((e) => {
|
|
41
|
+
F(e), M(e);
|
|
42
|
+
}, [F, M]), L = s(() => ({
|
|
43
|
+
popupRef: D,
|
|
44
|
+
openPopup: g,
|
|
45
|
+
parameters: P,
|
|
46
|
+
onClick: N
|
|
38
47
|
}), [
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
48
|
+
N,
|
|
49
|
+
g,
|
|
50
|
+
P
|
|
42
51
|
]);
|
|
43
|
-
return /* @__PURE__ */
|
|
52
|
+
return /* @__PURE__ */ d(n, {
|
|
44
53
|
ref: e,
|
|
45
|
-
className:
|
|
46
|
-
onClick:
|
|
47
|
-
children: [/* @__PURE__ */
|
|
48
|
-
value:
|
|
49
|
-
children:
|
|
50
|
-
}),
|
|
51
|
-
ref:
|
|
52
|
-
className:
|
|
53
|
-
onClick:
|
|
54
|
+
className: f("plitzi-component__dropdown", m, { "container--empty--skip": !T && !p }),
|
|
55
|
+
onClick: I,
|
|
56
|
+
children: [/* @__PURE__ */ u(r, {
|
|
57
|
+
value: L,
|
|
58
|
+
children: p
|
|
59
|
+
}), g && _ && T && /* @__PURE__ */ u("div", {
|
|
60
|
+
ref: O,
|
|
61
|
+
className: f("plitzi-component__dropdown__background-container", w.backgroundContainer),
|
|
62
|
+
onClick: A
|
|
54
63
|
})]
|
|
55
64
|
});
|
|
56
|
-
},
|
|
65
|
+
}, m = e(p);
|
|
57
66
|
//#endregion
|
|
58
|
-
export {
|
|
67
|
+
export { p as Dropdown, m as default };
|
|
@@ -4,6 +4,9 @@ import { AuthorableAttributes } from '@plitzi/sdk-shared/authoring/declare';
|
|
|
4
4
|
export type DropdownAttributes = AuthorableAttributes<DropdownProps>;
|
|
5
5
|
declare const declaration: {
|
|
6
6
|
readonly type: "dropdown";
|
|
7
|
+
readonly attributeValues: {
|
|
8
|
+
readonly popupPlacement: readonly string[];
|
|
9
|
+
};
|
|
7
10
|
readonly content: {
|
|
8
11
|
readonly attributes: {
|
|
9
12
|
readonly popupPlacement: "bottom";
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import { elementDeclaration as e } from "@plitzi/sdk-shared/authoring/declare";
|
|
1
|
+
import { elementDeclaration as e, valuesOf as t } from "@plitzi/sdk-shared/authoring/declare";
|
|
2
2
|
//#region src/elements/basic/Dropdown/declaration.ts
|
|
3
|
-
var
|
|
3
|
+
var n = e()({
|
|
4
4
|
type: "dropdown",
|
|
5
|
+
attributeValues: { popupPlacement: t()([
|
|
6
|
+
"left",
|
|
7
|
+
"right",
|
|
8
|
+
"top",
|
|
9
|
+
"bottom"
|
|
10
|
+
]) },
|
|
5
11
|
content: {
|
|
6
12
|
attributes: {
|
|
7
13
|
popupPlacement: "bottom",
|
|
@@ -67,4 +73,4 @@ var t = e()({
|
|
|
67
73
|
initialItems: ["dropdownPopup"]
|
|
68
74
|
});
|
|
69
75
|
//#endregion
|
|
70
|
-
export {
|
|
76
|
+
export { n as default };
|
|
@@ -71,6 +71,9 @@ declare const Dropdown: {
|
|
|
71
71
|
} & import('@plitzi/sdk-shared/authoring/declare').ElementAttributesBrand<unknown>;
|
|
72
72
|
};
|
|
73
73
|
type: "dropdown";
|
|
74
|
+
attributeValues: {
|
|
75
|
+
readonly popupPlacement: readonly string[];
|
|
76
|
+
};
|
|
74
77
|
content: {
|
|
75
78
|
readonly attributes: {
|
|
76
79
|
readonly popupPlacement: "bottom";
|
|
@@ -10,6 +10,11 @@ export type UseDropdownProps = {
|
|
|
10
10
|
disabled?: boolean;
|
|
11
11
|
loading?: boolean;
|
|
12
12
|
closeOnClickPopup?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Close when the pointer goes down anywhere outside the trigger and the popup. What a menu is expected to do; off by
|
|
15
|
+
* default here because a caller that renders its own backdrop closes from that instead.
|
|
16
|
+
*/
|
|
17
|
+
closeOnClickOutside?: boolean;
|
|
13
18
|
placement?: 'left' | 'right' | 'top' | 'bottom';
|
|
14
19
|
myWindow?: Window | null;
|
|
15
20
|
offsetX?: number;
|
|
@@ -24,5 +29,5 @@ export type UseDropdownReturn = [
|
|
|
24
29
|
DOMRect | undefined,
|
|
25
30
|
FloatingPosition | undefined
|
|
26
31
|
];
|
|
27
|
-
declare const useDropdown: ({ ref, popupRef, open: openProp, placement, disabled, loading, closeOnClickPopup, offsetX, offsetY, myWindow, onChange }: UseDropdownProps) => UseDropdownReturn;
|
|
32
|
+
declare const useDropdown: ({ ref, popupRef, open: openProp, placement, disabled, loading, closeOnClickPopup, closeOnClickOutside, offsetX, offsetY, myWindow, onChange }: UseDropdownProps) => UseDropdownReturn;
|
|
28
33
|
export default useDropdown;
|
|
@@ -1,107 +1,124 @@
|
|
|
1
1
|
import { useCallback as e, useEffect as t, useMemo as n, useState as r } from "react";
|
|
2
2
|
import i from "@plitzi/plitzi-ui/hooks/useDidUpdateEffect";
|
|
3
3
|
//#region src/elements/basic/Dropdown/useDropdown.ts
|
|
4
|
-
var a = ({ ref: a, popupRef: o, open: s, placement: c = "bottom", disabled: l = !1, loading: u = !1, closeOnClickPopup: d = !0,
|
|
5
|
-
let [
|
|
6
|
-
if (!(l || u)) {
|
|
4
|
+
var a = ({ ref: a, popupRef: o, open: s, placement: c = "bottom", disabled: l = !1, loading: u = !1, closeOnClickPopup: d = !0, closeOnClickOutside: f = !1, offsetX: p = 0, offsetY: m = 0, myWindow: h, onChange: g }) => {
|
|
5
|
+
let [_, v] = r(s ?? !1), [y, b] = r(() => a?.current?.getBoundingClientRect()), x = n(() => h || (typeof window < "u" ? window : null), [h]), S = e((e) => {
|
|
6
|
+
if (!(l || u || e.target instanceof Node && o?.current?.contains(e.target))) {
|
|
7
7
|
if (e.stopPropagation(), e.preventDefault(), s !== void 0) {
|
|
8
|
-
|
|
8
|
+
g?.(!_, !1);
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
g?.(!_, !0), v((e) => !e);
|
|
12
12
|
}
|
|
13
13
|
}, [
|
|
14
14
|
l,
|
|
15
15
|
u,
|
|
16
|
-
h,
|
|
17
16
|
g,
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
_,
|
|
18
|
+
s,
|
|
19
|
+
o
|
|
20
|
+
]), C = e((e) => {
|
|
20
21
|
if (!(l || u || !d)) {
|
|
21
22
|
if (e.stopPropagation(), e.preventDefault(), s !== void 0) {
|
|
22
|
-
|
|
23
|
+
g?.(!_, !1);
|
|
23
24
|
return;
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
+
g?.(!_, !0), v((e) => !e);
|
|
26
27
|
}
|
|
27
28
|
}, [
|
|
28
29
|
d,
|
|
29
30
|
l,
|
|
30
31
|
u,
|
|
31
|
-
h,
|
|
32
32
|
g,
|
|
33
|
+
_,
|
|
33
34
|
s
|
|
34
35
|
]);
|
|
35
36
|
t(() => {
|
|
36
37
|
let e = a?.current;
|
|
37
|
-
if (!e || typeof window > "u" || !
|
|
38
|
-
let t = () =>
|
|
38
|
+
if (!e || typeof window > "u" || !_) return;
|
|
39
|
+
let t = () => b(a.current?.getBoundingClientRect()), n;
|
|
39
40
|
return typeof ResizeObserver < "u" && (n = new ResizeObserver(t), n.observe(e)), window.addEventListener("scroll", t, !0), window.addEventListener("resize", t), () => {
|
|
40
41
|
n?.disconnect(), window.removeEventListener("scroll", t, !0), window.removeEventListener("resize", t);
|
|
41
42
|
};
|
|
42
|
-
}, [
|
|
43
|
-
let
|
|
44
|
-
e.key === "Escape" && (
|
|
43
|
+
}, [_, a]);
|
|
44
|
+
let w = e((e) => {
|
|
45
|
+
e.key === "Escape" && (g?.(!_, s !== void 0), v((e) => !e));
|
|
45
46
|
}, [
|
|
46
|
-
h,
|
|
47
47
|
g,
|
|
48
|
+
_,
|
|
48
49
|
s
|
|
49
50
|
]);
|
|
50
51
|
t(() => {
|
|
51
|
-
if (
|
|
52
|
-
|
|
52
|
+
if (!_ || l || !f || !x) return;
|
|
53
|
+
let e = (e) => {
|
|
54
|
+
let t = e.target instanceof Node ? e.target : null;
|
|
55
|
+
!t || a?.current?.contains(t) || o?.current?.contains(t) || (g?.(!1, s === void 0), s === void 0 && v(!1));
|
|
53
56
|
};
|
|
57
|
+
return x.addEventListener("pointerdown", e, !0), () => x.removeEventListener("pointerdown", e, !0);
|
|
54
58
|
}, [
|
|
59
|
+
_,
|
|
60
|
+
l,
|
|
61
|
+
f,
|
|
62
|
+
x,
|
|
63
|
+
a,
|
|
64
|
+
o,
|
|
55
65
|
g,
|
|
56
|
-
|
|
66
|
+
s
|
|
67
|
+
]), t(() => {
|
|
68
|
+
if (_ && !l) return window.addEventListener("keydown", w), () => {
|
|
69
|
+
window.removeEventListener("keydown", w);
|
|
70
|
+
};
|
|
71
|
+
}, [
|
|
72
|
+
_,
|
|
73
|
+
w,
|
|
57
74
|
l
|
|
58
75
|
]);
|
|
59
|
-
let
|
|
60
|
-
if (!
|
|
61
|
-
let t =
|
|
76
|
+
let T = e((e) => {
|
|
77
|
+
if (!y || !x) return;
|
|
78
|
+
let t = x.innerWidth, n = x.innerHeight, r = 0, i = 0;
|
|
62
79
|
switch (c) {
|
|
63
80
|
case "top":
|
|
64
|
-
r =
|
|
81
|
+
r = y.top - e.height, i = y.left;
|
|
65
82
|
break;
|
|
66
83
|
case "bottom":
|
|
67
|
-
r =
|
|
84
|
+
r = y.bottom, i = y.left;
|
|
68
85
|
break;
|
|
69
86
|
case "left":
|
|
70
|
-
r =
|
|
87
|
+
r = y.top, i = y.left - e.width;
|
|
71
88
|
break;
|
|
72
89
|
case "right":
|
|
73
|
-
r =
|
|
90
|
+
r = y.top, i = y.right;
|
|
74
91
|
break;
|
|
75
|
-
default: r =
|
|
92
|
+
default: r = y.bottom, i = y.left;
|
|
76
93
|
}
|
|
77
|
-
return c === "bottom" ? (r +=
|
|
94
|
+
return c === "bottom" ? (r += m, i += p) : c === "top" ? (r -= m, i += p) : c === "left" ? (r += m, i -= p) : c === "right" && (r += m, i += p), c === "bottom" || c === "top" ? (i + e.width > t ? i = y.right - e.width : i < 0 && (i = y.left), r = Math.max(0, Math.min(n - e.height, r))) : c === "left" || c === "right" ? (r + e.height > n ? r = y.bottom - e.height : r < 0 && (r = y.top), i = Math.max(0, Math.min(t - e.width, i))) : (r = Math.max(0, Math.min(n - e.height, r)), i = Math.max(0, Math.min(t - e.width, i))), {
|
|
78
95
|
top: r,
|
|
79
96
|
left: i
|
|
80
97
|
};
|
|
81
98
|
}, [
|
|
82
|
-
|
|
83
|
-
|
|
99
|
+
y,
|
|
100
|
+
x,
|
|
84
101
|
c,
|
|
85
|
-
|
|
86
|
-
|
|
102
|
+
m,
|
|
103
|
+
p
|
|
87
104
|
]);
|
|
88
105
|
return i(() => {
|
|
89
|
-
|
|
106
|
+
v(s ?? !1);
|
|
90
107
|
}, [s]), [
|
|
91
|
-
g,
|
|
92
108
|
_,
|
|
93
|
-
x,
|
|
94
|
-
S,
|
|
95
109
|
v,
|
|
110
|
+
S,
|
|
111
|
+
C,
|
|
112
|
+
y,
|
|
96
113
|
n(() => {
|
|
97
|
-
if (!
|
|
114
|
+
if (!_ || !a?.current || !o?.current) return;
|
|
98
115
|
let e = o.current.getBoundingClientRect();
|
|
99
|
-
return
|
|
116
|
+
return T(e);
|
|
100
117
|
}, [
|
|
101
|
-
|
|
118
|
+
_,
|
|
102
119
|
a,
|
|
103
120
|
o,
|
|
104
|
-
|
|
121
|
+
T
|
|
105
122
|
])
|
|
106
123
|
];
|
|
107
124
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { MouseEvent, RefObject } from 'react';
|
|
2
|
+
export type UseDropdownTriggerProps = {
|
|
3
|
+
popupRef: RefObject<HTMLElement | null>;
|
|
4
|
+
open: boolean;
|
|
5
|
+
/** Where the popup is drawn; until it is known the popup is hidden, and nothing in it can take the focus. */
|
|
6
|
+
positioned: boolean;
|
|
7
|
+
/** Off in the builder, where a dropdown is something being edited. */
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* What a dropdown tells assistive technology about the control that opens it, and where the keyboard goes.
|
|
12
|
+
*
|
|
13
|
+
* - **The trigger says it opens something** (`aria-haspopup`) **and whether it is open** (`aria-expanded`). The trigger
|
|
14
|
+
* is the author's own button, so the attributes are written on it rather than rendered.
|
|
15
|
+
* - **Opened from the keyboard, the focus moves to the popup's first control** — the popup can come before the trigger
|
|
16
|
+
* in the page, where Tab would never reach it. Opened with a pointer, the focus stays: nobody asked for it to move.
|
|
17
|
+
* - **Closed while the focus is inside, the focus goes back to the trigger**, so Escape leaves a person where they were
|
|
18
|
+
* instead of on a control that has just been hidden.
|
|
19
|
+
*
|
|
20
|
+
* A dropdown with no control outside its popup has none of this: nothing a keyboard can reach opens it
|
|
21
|
+
* (`dropdown-without-control`, in the linter).
|
|
22
|
+
*
|
|
23
|
+
* @returns what the dropdown's own click handler calls first, to learn whether a keyboard pressed the trigger.
|
|
24
|
+
*/
|
|
25
|
+
declare const useDropdownTrigger: ({ popupRef, open, positioned, enabled }: UseDropdownTriggerProps) => ((event: MouseEvent) => void);
|
|
26
|
+
export default useDropdownTrigger;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useCallback as e, useEffect as t, useRef as n } from "react";
|
|
2
|
+
//#region src/elements/basic/Dropdown/useDropdownTrigger.ts
|
|
3
|
+
var r = "button, a[href], input, select, textarea, [role=\"button\"]", i = (e) => {
|
|
4
|
+
let t = e?.closest(".plitzi-component__dropdown");
|
|
5
|
+
return t ? [...t.querySelectorAll(r)].find((t) => !e?.contains(t)) : void 0;
|
|
6
|
+
}, a = ({ popupRef: a, open: o, positioned: s, enabled: c }) => {
|
|
7
|
+
let l = n(!1), u = n(o), d = e((e) => {
|
|
8
|
+
l.current = e.detail === 0;
|
|
9
|
+
}, []);
|
|
10
|
+
return t(() => {
|
|
11
|
+
let e = c ? i(a.current) : void 0;
|
|
12
|
+
e && (e.setAttribute("aria-haspopup", "true"), e.setAttribute("aria-expanded", String(o)));
|
|
13
|
+
}), t(() => {
|
|
14
|
+
let e = a.current, t = u.current && !o;
|
|
15
|
+
if (u.current = o, c && e) {
|
|
16
|
+
if (t && e.contains(e.ownerDocument.activeElement)) {
|
|
17
|
+
i(e)?.focus({ preventScroll: !0 });
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
o && s && l.current && !e.contains(e.ownerDocument.activeElement) && (l.current = !1, e.querySelector(r)?.focus({ preventScroll: !0 }));
|
|
21
|
+
}
|
|
22
|
+
}, [
|
|
23
|
+
c,
|
|
24
|
+
o,
|
|
25
|
+
s,
|
|
26
|
+
a
|
|
27
|
+
]), d;
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
export { a as default };
|
|
@@ -4,6 +4,9 @@ import { AuthorableAttributes } from '@plitzi/sdk-shared/authoring/declare';
|
|
|
4
4
|
export type HeadingAttributes = AuthorableAttributes<HeadingProps>;
|
|
5
5
|
declare const declaration: {
|
|
6
6
|
readonly type: "heading";
|
|
7
|
+
readonly attributeValues: {
|
|
8
|
+
readonly subType: readonly string[];
|
|
9
|
+
};
|
|
7
10
|
readonly content: {
|
|
8
11
|
readonly attributes: {
|
|
9
12
|
readonly content: "Heading";
|
|
@@ -58,7 +61,7 @@ declare const declaration: {
|
|
|
58
61
|
readonly 'margin-bottom': "25px";
|
|
59
62
|
readonly 'font-size': "38px";
|
|
60
63
|
readonly 'font-weight': 700;
|
|
61
|
-
readonly 'line-height': "
|
|
64
|
+
readonly 'line-height': "1.158";
|
|
62
65
|
};
|
|
63
66
|
};
|
|
64
67
|
};
|
|
@@ -73,7 +76,7 @@ declare const declaration: {
|
|
|
73
76
|
readonly 'margin-bottom': "25px";
|
|
74
77
|
readonly 'font-size': "32px";
|
|
75
78
|
readonly 'font-weight': 700;
|
|
76
|
-
readonly 'line-height': "
|
|
79
|
+
readonly 'line-height': "1.125";
|
|
77
80
|
};
|
|
78
81
|
};
|
|
79
82
|
};
|
|
@@ -88,7 +91,7 @@ declare const declaration: {
|
|
|
88
91
|
readonly 'margin-bottom': "25px";
|
|
89
92
|
readonly 'font-size': "24px";
|
|
90
93
|
readonly 'font-weight': 700;
|
|
91
|
-
readonly 'line-height': "
|
|
94
|
+
readonly 'line-height': "1.25";
|
|
92
95
|
};
|
|
93
96
|
};
|
|
94
97
|
};
|
|
@@ -103,7 +106,7 @@ declare const declaration: {
|
|
|
103
106
|
readonly 'margin-bottom': "25px";
|
|
104
107
|
readonly 'font-size': "18px";
|
|
105
108
|
readonly 'font-weight': 700;
|
|
106
|
-
readonly 'line-height': "
|
|
109
|
+
readonly 'line-height': "1.333";
|
|
107
110
|
};
|
|
108
111
|
};
|
|
109
112
|
};
|
|
@@ -118,7 +121,7 @@ declare const declaration: {
|
|
|
118
121
|
readonly 'margin-bottom': "25px";
|
|
119
122
|
readonly 'font-size': "14px";
|
|
120
123
|
readonly 'font-weight': 700;
|
|
121
|
-
readonly 'line-height': "
|
|
124
|
+
readonly 'line-height': "1.429";
|
|
122
125
|
};
|
|
123
126
|
};
|
|
124
127
|
};
|
|
@@ -133,7 +136,7 @@ declare const declaration: {
|
|
|
133
136
|
readonly 'margin-bottom': "25px";
|
|
134
137
|
readonly 'font-size': "12px";
|
|
135
138
|
readonly 'font-weight': 700;
|
|
136
|
-
readonly 'line-height': "
|
|
139
|
+
readonly 'line-height': "1.5";
|
|
137
140
|
};
|
|
138
141
|
};
|
|
139
142
|
};
|