@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
|
@@ -3,193 +3,201 @@ import t from "../../../Element/hooks/useElement.mjs";
|
|
|
3
3
|
import ee from "../../../Element/hooks/useRscData.mjs";
|
|
4
4
|
import { RootElement as te } from "../../../Element/RootElement.mjs";
|
|
5
5
|
import n from "./declaration.mjs";
|
|
6
|
-
import r from "./helpers/
|
|
7
|
-
import ne from "./
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
6
|
+
import { isEmptyAnswer as r } from "./helpers/isEmptyAnswer.mjs";
|
|
7
|
+
import ne from "./helpers/providerOutcome.mjs";
|
|
8
|
+
import { queryInputOf as i } from "./helpers/queryInput.mjs";
|
|
9
|
+
import re from "./hooks/useApi.mjs";
|
|
10
|
+
import ie from "./hooks/useAutoRefresh.mjs";
|
|
11
|
+
import ae from "./hooks/useProviderPagination.mjs";
|
|
12
|
+
import oe from "./hooks/useProviderWrite.mjs";
|
|
13
|
+
import se from "../../../dataSource/pathFields.mjs";
|
|
14
|
+
import { use as ce, useCallback as a, useEffect as le, useMemo as o, useRef as ue } from "react";
|
|
15
|
+
import de from "@plitzi/sdk-shared/hooks/usePlitziServiceContext";
|
|
16
|
+
import { useSdkStore as s } from "@plitzi/sdk-shared/store";
|
|
17
|
+
import { StoreProvider as fe } from "@plitzi/nexus/react";
|
|
18
|
+
import { emptyObject as c } from "@plitzi/sdk-shared/helpers/utils";
|
|
19
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
20
|
+
import { currentRscLocation as pe } from "@plitzi/sdk-shared/server/rsc/refreshRsc";
|
|
21
|
+
import me from "clsx";
|
|
22
|
+
import he from "@plitzi/sdk-shared/dataSource/helpers/getSourceName";
|
|
23
|
+
import ge from "@plitzi/sdk-shared/dataSource/hooks/useRegisterSource";
|
|
24
|
+
import { QueryBuilderEvaluator as _e } from "@plitzi/plitzi-ui/QueryBuilder";
|
|
23
25
|
//#region src/elements/provider/ApiContainer/ApiContainer.tsx
|
|
24
|
-
var
|
|
25
|
-
let { id:
|
|
26
|
+
var u = ({ ref: e, className: u = "", children: d, query: f = "", method: p = "get", accessToken: m = "", when: h = c, headers: g = c, mockData: _ = "{}", subType: v = "", credentials: ve = "same-origin", singleRecord: y = !1, pagination: ye = "none", pageParam: be = "page", renderWhileLoading: xe = !1, cache: b = !1, staleTime: Se = 30, gcTime: Ce = 300, refreshSeconds: we = 0 }) => {
|
|
27
|
+
let { id: x, visible: S, definition: { label: C = "Api Container", runtime: Te, items: Ee } } = t(), w = Te === "server", { loaded: T, stale: E, location: D, elementData: O, refresh: k } = ee(), A = he(n.sourceType, x), { settings: { previewMode: j }, contexts: { InteractionsContext: De } } = de(), { interactionsManager: M } = ce(De), [[N, P, Oe]] = s([
|
|
26
28
|
"navigation.routeParams",
|
|
27
29
|
"navigation.queryParams",
|
|
28
30
|
"navigation.navigate"
|
|
29
|
-
]),
|
|
30
|
-
...
|
|
31
|
-
Authorization: `Bearer ${
|
|
32
|
-
} :
|
|
33
|
-
...
|
|
34
|
-
...
|
|
35
|
-
})) || !
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
]), ke = o(() => m ? {
|
|
32
|
+
...g,
|
|
33
|
+
Authorization: `Bearer ${m}`
|
|
34
|
+
} : g, [g, m]), F = o(() => w || !S ? !1 : !!(j && f && (h === c || _e(h, {
|
|
35
|
+
...N,
|
|
36
|
+
...P
|
|
37
|
+
})) || !j && (f || _ && _ !== "{}" && _ !== c)), [
|
|
38
|
+
w,
|
|
39
|
+
S,
|
|
40
|
+
j,
|
|
41
|
+
f,
|
|
42
|
+
h,
|
|
38
43
|
N,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (
|
|
57
|
-
if (A) return A;
|
|
58
|
-
if (D) return l;
|
|
59
|
-
if (typeof v != "string") return v;
|
|
44
|
+
P,
|
|
45
|
+
_
|
|
46
|
+
]), Ae = o(() => [x], [x]), { isLoading: je, isFetching: Me, data: I, refetch: L, isSuccess: Ne, isError: Pe } = re({
|
|
47
|
+
url: f,
|
|
48
|
+
method: p,
|
|
49
|
+
credentials: ve,
|
|
50
|
+
mock: j ? void 0 : _,
|
|
51
|
+
customHeaders: ke,
|
|
52
|
+
enabled: F,
|
|
53
|
+
cache: b,
|
|
54
|
+
staleTime: Se,
|
|
55
|
+
gcTime: Ce,
|
|
56
|
+
tags: Ae
|
|
57
|
+
}), R = w && !!D && D !== pe(), z = w && T && !R && O === null, B = o(() => {
|
|
58
|
+
if (!w) return I ?? c;
|
|
59
|
+
if (O) return O;
|
|
60
|
+
if (T) return c;
|
|
61
|
+
if (typeof _ != "string") return _;
|
|
60
62
|
try {
|
|
61
|
-
return JSON.parse(
|
|
63
|
+
return JSON.parse(_ || "{}");
|
|
62
64
|
} catch {
|
|
63
|
-
return
|
|
65
|
+
return c;
|
|
64
66
|
}
|
|
65
67
|
}, [
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
]),
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
w,
|
|
69
|
+
I,
|
|
70
|
+
O,
|
|
71
|
+
T,
|
|
72
|
+
_
|
|
73
|
+
]), V = w ? R : Me, Fe = w ? R : je, H = ue({}), U = a((e, t) => k(e, {
|
|
74
|
+
...H.current,
|
|
75
|
+
...t
|
|
76
|
+
}), [k]), W = a(async () => {
|
|
77
|
+
if (!w) {
|
|
78
|
+
L();
|
|
74
79
|
return;
|
|
75
80
|
}
|
|
76
|
-
await
|
|
81
|
+
await U([x]);
|
|
77
82
|
}, [
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
])
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
w,
|
|
84
|
+
L,
|
|
85
|
+
U,
|
|
86
|
+
x
|
|
87
|
+
]), G = a(async ({ input: e } = {}) => {
|
|
88
|
+
let t = i(e);
|
|
89
|
+
t && (H.current = t), await W();
|
|
90
|
+
}, [W]);
|
|
91
|
+
ie({
|
|
92
|
+
seconds: we,
|
|
93
|
+
enabled: S && (w ? T && !R : F),
|
|
94
|
+
refresh: W
|
|
87
95
|
});
|
|
88
|
-
let K =
|
|
89
|
-
elementId:
|
|
90
|
-
mode:
|
|
91
|
-
pageParam:
|
|
92
|
-
records:
|
|
96
|
+
let K = B, Ie = o(() => Array.isArray(K.records) ? K.records : [], [K.records]), { records: q, isLoadingMore: J, goToPage: Y, loadMore: X } = ae({
|
|
97
|
+
elementId: x,
|
|
98
|
+
mode: ye,
|
|
99
|
+
pageParam: be,
|
|
100
|
+
records: Ie,
|
|
93
101
|
page: K.pageInfo?.page ?? 1,
|
|
94
|
-
refresh:
|
|
95
|
-
navigate:
|
|
96
|
-
}), Z =
|
|
97
|
-
serverMode:
|
|
98
|
-
isSuccess:
|
|
99
|
-
isError:
|
|
100
|
-
rscResolved:
|
|
101
|
-
rscPending:
|
|
102
|
-
elementData:
|
|
102
|
+
refresh: U,
|
|
103
|
+
navigate: Oe
|
|
104
|
+
}), Z = ne({
|
|
105
|
+
serverMode: w,
|
|
106
|
+
isSuccess: Ne,
|
|
107
|
+
isError: Pe,
|
|
108
|
+
rscResolved: T,
|
|
109
|
+
rscPending: R,
|
|
110
|
+
elementData: O
|
|
103
111
|
});
|
|
104
|
-
|
|
105
|
-
!
|
|
106
|
-
url:
|
|
107
|
-
method:
|
|
108
|
-
...
|
|
112
|
+
le(() => {
|
|
113
|
+
!V && x && Z && M.interactionTrigger(x, Z === "success" ? "onApiSuccess" : "onApiError", {
|
|
114
|
+
url: f,
|
|
115
|
+
method: p,
|
|
116
|
+
...B
|
|
109
117
|
});
|
|
110
118
|
}, [
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
119
|
+
B,
|
|
120
|
+
x,
|
|
121
|
+
M,
|
|
122
|
+
V,
|
|
123
|
+
p,
|
|
116
124
|
Z,
|
|
117
|
-
|
|
125
|
+
f
|
|
118
126
|
]);
|
|
119
|
-
let Q =
|
|
120
|
-
...
|
|
121
|
-
...Array.isArray(K.records) ? { records: q } :
|
|
122
|
-
isLoading:
|
|
123
|
-
isEmpty:
|
|
124
|
-
hasError:
|
|
125
|
-
errorMessage:
|
|
126
|
-
isStale:
|
|
127
|
+
let Q = o(() => ({
|
|
128
|
+
...B,
|
|
129
|
+
...Array.isArray(K.records) ? { records: q } : c,
|
|
130
|
+
isLoading: V || J,
|
|
131
|
+
isEmpty: r(K, q, y),
|
|
132
|
+
hasError: z,
|
|
133
|
+
errorMessage: z ? "The data provider could not be reached" : "",
|
|
134
|
+
isStale: w && E
|
|
127
135
|
}), [
|
|
128
|
-
|
|
136
|
+
B,
|
|
129
137
|
K.records,
|
|
130
138
|
K.record,
|
|
131
139
|
q,
|
|
132
|
-
|
|
140
|
+
V,
|
|
133
141
|
J,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
]),
|
|
139
|
-
|
|
140
|
-
id:
|
|
141
|
-
source:
|
|
142
|
-
name:
|
|
143
|
-
fields:
|
|
142
|
+
y,
|
|
143
|
+
z,
|
|
144
|
+
w,
|
|
145
|
+
E
|
|
146
|
+
]), Le = a(() => se(Q), [Q]);
|
|
147
|
+
ge({
|
|
148
|
+
id: x,
|
|
149
|
+
source: A,
|
|
150
|
+
name: C || `API - ${x}`,
|
|
151
|
+
fields: Le
|
|
144
152
|
});
|
|
145
|
-
let { writeRecord: $ } =
|
|
146
|
-
elementId:
|
|
147
|
-
enabled:
|
|
148
|
-
onDone:
|
|
149
|
-
}),
|
|
153
|
+
let { writeRecord: $ } = oe({
|
|
154
|
+
elementId: x,
|
|
155
|
+
enabled: w,
|
|
156
|
+
onDone: W
|
|
157
|
+
}), Re = o(() => {
|
|
150
158
|
let e = {
|
|
151
159
|
performQuery: {
|
|
152
160
|
...n.callbacks.performQuery,
|
|
153
|
-
title: `Perform Query ${
|
|
161
|
+
title: `Perform Query ${C}`,
|
|
154
162
|
callback: G
|
|
155
163
|
},
|
|
156
164
|
loadMore: {
|
|
157
165
|
...n.callbacks.loadMore,
|
|
158
|
-
title: `Load More ${
|
|
166
|
+
title: `Load More ${C}`,
|
|
159
167
|
callback: X
|
|
160
168
|
},
|
|
161
169
|
goToPage: {
|
|
162
170
|
...n.callbacks.goToPage,
|
|
163
|
-
title: `Go To Page ${
|
|
171
|
+
title: `Go To Page ${C}`,
|
|
164
172
|
callback: ({ page: e }) => Y(Number(e) || 1)
|
|
165
173
|
}
|
|
166
174
|
};
|
|
167
|
-
return
|
|
175
|
+
return w && (e.writeRecord = {
|
|
168
176
|
...n.callbacks.writeRecord,
|
|
169
|
-
title: `Write Record ${
|
|
177
|
+
title: `Write Record ${C}`,
|
|
170
178
|
callback: $
|
|
171
179
|
}), e;
|
|
172
180
|
}, [
|
|
173
|
-
|
|
181
|
+
C,
|
|
174
182
|
G,
|
|
175
183
|
X,
|
|
176
184
|
Y,
|
|
177
|
-
|
|
185
|
+
w,
|
|
178
186
|
$
|
|
179
|
-
]),
|
|
180
|
-
return /* @__PURE__ */
|
|
187
|
+
]), ze = o(() => A ? { runtime: { sources: { [A]: Q } } } : c, [Q, A]);
|
|
188
|
+
return /* @__PURE__ */ l(te, {
|
|
181
189
|
ref: e,
|
|
182
|
-
tag: !
|
|
183
|
-
className:
|
|
190
|
+
tag: !j && !Ee?.length ? "div" : v,
|
|
191
|
+
className: me("plitzi-component__api-container", u),
|
|
184
192
|
interactionTriggers: n.triggers,
|
|
185
|
-
interactionCallbacks:
|
|
186
|
-
children: (!
|
|
193
|
+
interactionCallbacks: Re,
|
|
194
|
+
children: (!Fe || xe) && /* @__PURE__ */ l(fe, {
|
|
187
195
|
inherit: "live",
|
|
188
|
-
name: `Api:${
|
|
189
|
-
value:
|
|
190
|
-
children:
|
|
196
|
+
name: `Api:${x}`,
|
|
197
|
+
value: ze,
|
|
198
|
+
children: d
|
|
191
199
|
})
|
|
192
200
|
});
|
|
193
|
-
},
|
|
201
|
+
}, d = e(u);
|
|
194
202
|
//#endregion
|
|
195
|
-
export {
|
|
203
|
+
export { u as ApiContainer, d as default };
|
|
@@ -12,6 +12,12 @@ export type ApiContainerAttributes = AuthorableAttributes<ApiContainerProps> & {
|
|
|
12
12
|
};
|
|
13
13
|
declare const declaration: {
|
|
14
14
|
readonly type: "apiContainer";
|
|
15
|
+
readonly attributeValues: {
|
|
16
|
+
readonly subType: readonly string[];
|
|
17
|
+
readonly method: readonly string[];
|
|
18
|
+
readonly credentials: readonly string[];
|
|
19
|
+
readonly pagination: readonly string[];
|
|
20
|
+
};
|
|
15
21
|
readonly sourceType: "apiContainer";
|
|
16
22
|
readonly triggers: {
|
|
17
23
|
readonly onApiError: {
|
|
@@ -45,7 +51,14 @@ declare const declaration: {
|
|
|
45
51
|
readonly title: "Perform Query";
|
|
46
52
|
readonly type: "callback";
|
|
47
53
|
readonly preview: {};
|
|
48
|
-
readonly params: {
|
|
54
|
+
readonly params: {
|
|
55
|
+
readonly input: {
|
|
56
|
+
readonly label: "Input (server providers)";
|
|
57
|
+
readonly type: "codemirror-json";
|
|
58
|
+
readonly defaultValue: "{}";
|
|
59
|
+
readonly description: string;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
49
62
|
};
|
|
50
63
|
readonly loadMore: {
|
|
51
64
|
readonly action: "loadMore";
|
|
@@ -1,7 +1,39 @@
|
|
|
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/provider/ApiContainer/declaration.ts
|
|
3
|
-
var
|
|
3
|
+
var n = e()({
|
|
4
4
|
type: "apiContainer",
|
|
5
|
+
attributeValues: {
|
|
6
|
+
subType: t()([
|
|
7
|
+
"",
|
|
8
|
+
"div",
|
|
9
|
+
"header",
|
|
10
|
+
"footer",
|
|
11
|
+
"nav",
|
|
12
|
+
"main",
|
|
13
|
+
"section",
|
|
14
|
+
"article",
|
|
15
|
+
"aside",
|
|
16
|
+
"address",
|
|
17
|
+
"figure"
|
|
18
|
+
]),
|
|
19
|
+
method: t()([
|
|
20
|
+
"get",
|
|
21
|
+
"post",
|
|
22
|
+
"put",
|
|
23
|
+
"delete",
|
|
24
|
+
"patch"
|
|
25
|
+
]),
|
|
26
|
+
credentials: t()([
|
|
27
|
+
"include",
|
|
28
|
+
"omit",
|
|
29
|
+
"same-origin"
|
|
30
|
+
]),
|
|
31
|
+
pagination: t()([
|
|
32
|
+
"none",
|
|
33
|
+
"url",
|
|
34
|
+
"append"
|
|
35
|
+
])
|
|
36
|
+
},
|
|
5
37
|
sourceType: "apiContainer",
|
|
6
38
|
triggers: {
|
|
7
39
|
onApiError: {
|
|
@@ -35,7 +67,12 @@ var t = e()({
|
|
|
35
67
|
title: "Perform Query",
|
|
36
68
|
type: "callback",
|
|
37
69
|
preview: {},
|
|
38
|
-
params: {
|
|
70
|
+
params: { input: {
|
|
71
|
+
label: "Input (server providers)",
|
|
72
|
+
type: "codemirror-json",
|
|
73
|
+
defaultValue: "{}",
|
|
74
|
+
description: "Values handed to a server-driven provider with its request, beside the page’s own route and query params — a search, a filter. Kept for the pages it loads after (`loadMore`, `goToPage`) until the next query."
|
|
75
|
+
} }
|
|
39
76
|
},
|
|
40
77
|
loadMore: {
|
|
41
78
|
action: "loadMore",
|
|
@@ -131,4 +168,4 @@ var t = e()({
|
|
|
131
168
|
}
|
|
132
169
|
});
|
|
133
170
|
//#endregion
|
|
134
|
-
export {
|
|
171
|
+
export { n as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
type ProviderSlice = {
|
|
2
|
+
records?: unknown[];
|
|
3
|
+
record?: unknown;
|
|
4
|
+
data?: unknown;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Whether a provider has nothing to show, for each shape of answer it can hold.
|
|
8
|
+
*
|
|
9
|
+
* A connector list publishes `records`, a detail provider `record`, and a plain `query` the body it received under
|
|
10
|
+
* `data`. Only the first two used to be asked, so a `query` — whose slice has no `records` at all — reported empty
|
|
11
|
+
* whatever it held, and an empty state bound to `isEmpty` showed over a full page.
|
|
12
|
+
*
|
|
13
|
+
* `records` is the list after pagination has accumulated it, which is why it is passed in rather than read here.
|
|
14
|
+
*/
|
|
15
|
+
export declare const isEmptyAnswer: (slice: ProviderSlice, records: unknown[], singleRecord: boolean) => boolean;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region src/elements/provider/ApiContainer/helpers/isEmptyAnswer.ts
|
|
2
|
+
var e = (e) => e == null || e === "" || Array.isArray(e) && e.length === 0 || typeof e == "object" && !Array.isArray(e) && Object.keys(e).length === 0, t = (t, n, r) => r ? t.record === void 0 : Array.isArray(t.records) ? n.length === 0 : e(t.data);
|
|
3
|
+
//#endregion
|
|
4
|
+
export { t as isEmptyAnswer };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A query's `input`, as the server reads a page's query params: flat, each value a string. An object as authored, or
|
|
3
|
+
* its JSON text as the editor keeps it; anything else is no input at all.
|
|
4
|
+
*/
|
|
5
|
+
export declare const queryInputOf: (input: unknown) => Record<string, string> | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/elements/provider/ApiContainer/helpers/queryInput.ts
|
|
2
|
+
var e = (e) => {
|
|
3
|
+
let t = e;
|
|
4
|
+
if (typeof t == "string") try {
|
|
5
|
+
t = JSON.parse(t || "{}");
|
|
6
|
+
} catch {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (typeof t == "object" && t && !Array.isArray(t)) return Object.fromEntries(Object.entries(t).flatMap(([e, t]) => typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? [[e, String(t)]] : []));
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { e as queryInputOf };
|
|
@@ -3,6 +3,12 @@ declare const ApiContainer: {
|
|
|
3
3
|
displayName: string;
|
|
4
4
|
} & {
|
|
5
5
|
readonly type: "apiContainer";
|
|
6
|
+
readonly attributeValues: {
|
|
7
|
+
readonly subType: readonly string[];
|
|
8
|
+
readonly method: readonly string[];
|
|
9
|
+
readonly credentials: readonly string[];
|
|
10
|
+
readonly pagination: readonly string[];
|
|
11
|
+
};
|
|
6
12
|
readonly sourceType: "apiContainer";
|
|
7
13
|
readonly triggers: {
|
|
8
14
|
readonly onApiError: {
|
|
@@ -36,7 +42,14 @@ declare const ApiContainer: {
|
|
|
36
42
|
readonly title: "Perform Query";
|
|
37
43
|
readonly type: "callback";
|
|
38
44
|
readonly preview: {};
|
|
39
|
-
readonly params: {
|
|
45
|
+
readonly params: {
|
|
46
|
+
readonly input: {
|
|
47
|
+
readonly label: "Input (server providers)";
|
|
48
|
+
readonly type: "codemirror-json";
|
|
49
|
+
readonly defaultValue: "{}";
|
|
50
|
+
readonly description: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
40
53
|
};
|
|
41
54
|
readonly loadMore: {
|
|
42
55
|
readonly action: "loadMore";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ReactNode, RefObject } from 'react';
|
|
2
|
+
export type ChannelProps = {
|
|
3
|
+
ref?: RefObject<HTMLElement | null>;
|
|
4
|
+
className?: string;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
/** The topic, usually a template: `board:{{ id }}`. A channel the space declares must cover it. */
|
|
7
|
+
topic?: string;
|
|
8
|
+
/**
|
|
9
|
+
* What opens a topic of a private (`grant: true`) channel: bound to the `grant` the action that let this visitor in
|
|
10
|
+
* returned — `{{ data.grant }}`. Empty for any other channel.
|
|
11
|
+
*/
|
|
12
|
+
grant?: string;
|
|
13
|
+
/** What this page announces to the members — an object from a binding, or JSON text typed in the builder. */
|
|
14
|
+
presence?: unknown;
|
|
15
|
+
/** How many of the latest messages its source holds. */
|
|
16
|
+
keep?: number | string;
|
|
17
|
+
/** Empty renders no element of its own, as a provider does; a tag gives it one to style. */
|
|
18
|
+
subType?: '' | 'div' | 'section' | 'aside' | 'main';
|
|
19
|
+
};
|
|
20
|
+
declare const Channel: ({ ref, className, children, topic, grant, presence, keep, subType }: ChannelProps) => import('react').JSX.Element;
|
|
21
|
+
declare const _default: {
|
|
22
|
+
(props: import('../../../Element/hocs/withElement').WithElementProps<ChannelProps>): import('react').JSX.Element;
|
|
23
|
+
displayName: string;
|
|
24
|
+
};
|
|
25
|
+
export default _default;
|
|
26
|
+
export { Channel };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import e from "../../../Element/hocs/withElement.mjs";
|
|
2
|
+
import t from "../../../Element/hooks/useElement.mjs";
|
|
3
|
+
import { RootElement as n } from "../../../Element/RootElement.mjs";
|
|
4
|
+
import r from "../../../dataSource/pathFields.mjs";
|
|
5
|
+
import i from "./declaration.mjs";
|
|
6
|
+
import a from "../../../realtime/useChannel.mjs";
|
|
7
|
+
import { use as o, useCallback as s, useMemo as c, useState as l } from "react";
|
|
8
|
+
import u from "@plitzi/sdk-shared/hooks/usePlitziServiceContext";
|
|
9
|
+
import { StoreProvider as d } from "@plitzi/nexus/react";
|
|
10
|
+
import { emptyObject as f } from "@plitzi/sdk-shared/helpers/utils";
|
|
11
|
+
import { jsx as p } from "react/jsx-runtime";
|
|
12
|
+
import m from "clsx";
|
|
13
|
+
import h from "@plitzi/sdk-shared/dataSource/helpers/getSourceName";
|
|
14
|
+
import g from "@plitzi/sdk-shared/dataSource/hooks/useRegisterSource";
|
|
15
|
+
import { JOIN_TYPE as _, LEAVE_TYPE as v, PRESENCE_TYPE as y } from "@plitzi/sdk-shared/realtime";
|
|
16
|
+
//#region src/elements/provider/Channel/Channel.tsx
|
|
17
|
+
var b = (e) => {
|
|
18
|
+
if (typeof e != "string") return e;
|
|
19
|
+
try {
|
|
20
|
+
return JSON.parse(e);
|
|
21
|
+
} catch {
|
|
22
|
+
return e;
|
|
23
|
+
}
|
|
24
|
+
}, x = /* @__PURE__ */ new Set([
|
|
25
|
+
y,
|
|
26
|
+
_,
|
|
27
|
+
v
|
|
28
|
+
]), S = ({ ref: e, className: _, children: v, topic: y = "", grant: S = "", presence: C, keep: w = 20, subType: T = "" }) => {
|
|
29
|
+
let { id: E, definition: { label: D = "Channel" } } = t(), { settings: { previewMode: O }, contexts: { InteractionsContext: k } } = u(), { interactionsManager: A } = o(k), j = Math.max(0, Number(w) || 0), [M, N] = l([]), P = s((e) => {
|
|
30
|
+
x.has(e.type) || (j > 0 && N((t) => [...t, e].slice(-j)), A.interactionTrigger(E, "onMessage", { ...e }));
|
|
31
|
+
}, [
|
|
32
|
+
E,
|
|
33
|
+
A,
|
|
34
|
+
j
|
|
35
|
+
]), F = s(({ from: e, user: t, state: n }) => void A.interactionTrigger(E, "onJoin", {
|
|
36
|
+
from: e,
|
|
37
|
+
user: t ?? "",
|
|
38
|
+
state: n
|
|
39
|
+
}), [E, A]), I = s(({ from: e, user: t, state: n }) => void A.interactionTrigger(E, "onLeave", {
|
|
40
|
+
from: e,
|
|
41
|
+
user: t ?? "",
|
|
42
|
+
state: n
|
|
43
|
+
}), [E, A]), L = a(O && y ? y : void 0, {
|
|
44
|
+
grant: S || void 0,
|
|
45
|
+
presence: C === void 0 || C === "" ? void 0 : b(C),
|
|
46
|
+
onMessage: P,
|
|
47
|
+
onJoin: F,
|
|
48
|
+
onLeave: I
|
|
49
|
+
}), R = c(() => ({
|
|
50
|
+
publish: {
|
|
51
|
+
...i.callbacks.publish,
|
|
52
|
+
callback: ({ type: e, data: t }) => typeof e == "string" && e ? L.publish(e, b(t)) : Promise.resolve(!1)
|
|
53
|
+
},
|
|
54
|
+
setPresence: {
|
|
55
|
+
...i.callbacks.setPresence,
|
|
56
|
+
callback: ({ data: e }) => L.setPresence(b(e))
|
|
57
|
+
}
|
|
58
|
+
}), [L]), z = h(i.sourceType, E), B = c(() => ({
|
|
59
|
+
connected: L.connected,
|
|
60
|
+
me: L.me ?? "",
|
|
61
|
+
members: L.members,
|
|
62
|
+
messages: M,
|
|
63
|
+
last: M.at(-1) ?? null
|
|
64
|
+
}), [
|
|
65
|
+
L.connected,
|
|
66
|
+
L.me,
|
|
67
|
+
L.members,
|
|
68
|
+
M
|
|
69
|
+
]), V = s(() => r(B), [B]);
|
|
70
|
+
g({
|
|
71
|
+
id: E,
|
|
72
|
+
source: z,
|
|
73
|
+
name: D || `Channel - ${E}`,
|
|
74
|
+
fields: V
|
|
75
|
+
});
|
|
76
|
+
let H = c(() => z ? { runtime: { sources: { [z]: B } } } : f, [B, z]);
|
|
77
|
+
return /* @__PURE__ */ p(n, {
|
|
78
|
+
ref: e,
|
|
79
|
+
tag: T,
|
|
80
|
+
className: m("plitzi-component__channel", _),
|
|
81
|
+
interactionTriggers: i.triggers,
|
|
82
|
+
interactionCallbacks: R,
|
|
83
|
+
children: /* @__PURE__ */ p(d, {
|
|
84
|
+
inherit: "live",
|
|
85
|
+
name: `Channel:${E}`,
|
|
86
|
+
value: H,
|
|
87
|
+
children: v
|
|
88
|
+
})
|
|
89
|
+
});
|
|
90
|
+
}, C = e(S);
|
|
91
|
+
//#endregion
|
|
92
|
+
export { S as Channel, C as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type SettingsProps = {
|
|
2
|
+
topic?: string;
|
|
3
|
+
grant?: string;
|
|
4
|
+
keep?: number | string;
|
|
5
|
+
presence?: unknown;
|
|
6
|
+
onUpdate?: (key: string, value: string | boolean | number) => void;
|
|
7
|
+
};
|
|
8
|
+
declare const Settings: ({ topic, grant, keep, presence, onUpdate }: SettingsProps) => import('react').JSX.Element;
|
|
9
|
+
export default Settings;
|