@plitzi/sdk-elements 0.38.3 → 0.38.5
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 +539 -0
- package/dist/Element/helpers/elementChildren.d.ts +29 -0
- package/dist/Element/helpers/elementChildren.mjs +16 -0
- package/dist/Element/hooks/useElementVisible.d.ts +11 -0
- package/dist/Element/hooks/useElementVisible.mjs +25 -0
- package/dist/Element/hooks/useRscData.d.ts +4 -0
- package/dist/Element/hooks/useRscData.mjs +23 -19
- package/dist/dataSource/GlobalSources.mjs +68 -57
- package/dist/elements/basic/Button/Button.d.ts +6 -1
- package/dist/elements/basic/Button/Button.mjs +9 -8
- package/dist/elements/basic/Button/declaration.d.ts +2 -1
- package/dist/elements/basic/Button/declaration.mjs +1 -1
- package/dist/elements/basic/Button/index.d.ts +2 -1
- package/dist/elements/basic/Dropdown/DropdownPopup/declaration.d.ts +1 -1
- package/dist/elements/basic/Dropdown/DropdownPopup/declaration.mjs +1 -1
- package/dist/elements/basic/Dropdown/DropdownPopup/index.d.ts +1 -1
- package/dist/elements/basic/Dropdown/index.d.ts +1 -1
- package/dist/elements/basic/Markdown/Markdown.d.ts +3 -3
- package/dist/elements/basic/Markdown/Markdown.mjs +10 -6
- package/dist/elements/basic/Markdown/declaration.d.ts +1 -1
- package/dist/elements/basic/Markdown/index.d.ts +1 -1
- package/dist/elements/basic/RichText/declaration.d.ts +1 -1
- package/dist/elements/basic/RichText/declaration.mjs +1 -1
- package/dist/elements/basic/RichText/index.d.ts +1 -1
- package/dist/elements/basic/Text/Text.d.ts +6 -1
- package/dist/elements/basic/Text/Text.mjs +6 -5
- package/dist/elements/basic/Text/declaration.d.ts +1 -0
- package/dist/elements/basic/Text/index.d.ts +1 -0
- package/dist/elements/declarations/index.d.ts +55 -11
- package/dist/elements/form/Form/declaration.d.ts +1 -0
- package/dist/elements/form/Form/declaration.mjs +2 -1
- package/dist/elements/form/FormControl/FormControl.d.ts +5 -1
- package/dist/elements/form/FormControl/FormControl.mjs +3 -0
- package/dist/elements/form/FormControl/Settings.d.ts +1 -1
- package/dist/elements/form/FormControl/Settings.mjs +16 -1
- package/dist/elements/form/FormControl/declaration.d.ts +1 -0
- package/dist/elements/form/FormControl/declaration.mjs +6 -2
- package/dist/elements/internal/LayoutContainer/LayoutContainer.mjs +37 -29
- package/dist/elements/internal/LayoutContainer/mask.d.ts +11 -0
- package/dist/elements/internal/LayoutContainer/mask.mjs +14 -0
- package/dist/elements/media/Image/Image.d.ts +7 -1
- package/dist/elements/media/Image/Image.mjs +10 -10
- package/dist/elements/media/Image/declaration.d.ts +2 -1
- package/dist/elements/media/Image/declaration.mjs +1 -1
- package/dist/elements/media/Image/index.d.ts +2 -1
- package/dist/elements/provider/ApiContainer/ApiContainer.d.ts +9 -1
- package/dist/elements/provider/ApiContainer/ApiContainer.mjs +172 -155
- package/dist/elements/provider/ApiContainer/declaration.d.ts +38 -10
- package/dist/elements/provider/ApiContainer/declaration.mjs +7 -0
- package/dist/elements/provider/ApiContainer/helpers/serverMock.d.ts +10 -0
- package/dist/elements/provider/ApiContainer/helpers/serverMock.mjs +17 -0
- package/dist/elements/provider/ApiContainer/hooks/useApi.d.ts +2 -0
- package/dist/elements/provider/ApiContainer/hooks/useApi.mjs +1 -0
- package/dist/elements/provider/ApiContainer/hooks/useInputRefresh.d.ts +20 -0
- package/dist/elements/provider/ApiContainer/hooks/useInputRefresh.mjs +16 -0
- package/dist/elements/provider/ApiContainer/index.d.ts +37 -1
- package/dist/elements/structure/Container/Container.d.ts +13 -2
- package/dist/elements/structure/Container/Container.mjs +8 -6
- package/dist/elements/structure/Container/declaration.d.ts +5 -2
- package/dist/elements/structure/Container/declaration.mjs +32 -24
- package/dist/elements/structure/Container/index.d.ts +5 -2
- package/dist/elements/structure/DialogContainer/declaration.d.ts +1 -1
- package/dist/elements/structure/DialogContainer/declaration.mjs +1 -1
- package/dist/elements/structure/DialogContainer/index.d.ts +1 -1
- package/dist/elements/structure/List/ListItem/declaration.d.ts +1 -1
- package/dist/elements/structure/List/ListItem/declaration.mjs +1 -1
- package/dist/elements/structure/List/ListItem/index.d.ts +1 -1
- package/dist/elements/structure/List/index.d.ts +1 -1
- package/dist/elements/structure/TabContainer/TabContainerItem/declaration.d.ts +1 -1
- package/dist/elements/structure/TabContainer/TabContainerItem/declaration.mjs +1 -1
- package/dist/elements/structure/TabContainer/TabContainerItem/index.d.ts +1 -1
- package/dist/elements/structure/TabContainer/index.d.ts +1 -1
- package/dist/index.d.ts +53 -11
- package/package.json +25 -9
|
@@ -7,203 +7,220 @@ import { isEmptyAnswer as ne } from "./helpers/isEmptyAnswer.mjs";
|
|
|
7
7
|
import { childrenWhile as re } from "./helpers/loadingSlot.mjs";
|
|
8
8
|
import ie from "./helpers/providerOutcome.mjs";
|
|
9
9
|
import { queryInputOf as ae } from "./helpers/queryInput.mjs";
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import fe from "
|
|
17
|
-
import {
|
|
18
|
-
import
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
10
|
+
import { serverMock as oe } from "./helpers/serverMock.mjs";
|
|
11
|
+
import se from "./hooks/useApi.mjs";
|
|
12
|
+
import ce from "./hooks/useAutoRefresh.mjs";
|
|
13
|
+
import le from "./hooks/useInputRefresh.mjs";
|
|
14
|
+
import ue from "./hooks/useProviderPagination.mjs";
|
|
15
|
+
import de from "./hooks/useProviderWrite.mjs";
|
|
16
|
+
import fe from "../../../dataSource/pathFields.mjs";
|
|
17
|
+
import { use as pe, useCallback as r, useEffect as me, useMemo as i, useRef as a } from "react";
|
|
18
|
+
import he from "@plitzi/sdk-shared/hooks/usePlitziServiceContext";
|
|
19
|
+
import { useCommonStore as ge, useSdkStore as _e } from "@plitzi/sdk-shared/store";
|
|
20
|
+
import { StoreProvider as ve } from "@plitzi/nexus/react";
|
|
21
|
+
import { emptyObject as o } from "@plitzi/sdk-shared/helpers/utils";
|
|
22
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
23
|
+
import { currentRscLocation as ye } from "@plitzi/sdk-shared/server/rsc/refreshRsc";
|
|
24
|
+
import be from "clsx";
|
|
25
|
+
import xe from "@plitzi/sdk-shared/dataSource/helpers/getSourceName";
|
|
26
|
+
import Se from "@plitzi/sdk-shared/dataSource/hooks/useRegisterSource";
|
|
27
|
+
import { QueryBuilderEvaluator as Ce } from "@plitzi/plitzi-ui/QueryBuilder";
|
|
26
28
|
//#region src/elements/provider/ApiContainer/ApiContainer.tsx
|
|
27
|
-
var
|
|
28
|
-
let { id:
|
|
29
|
+
var c = ({ ref: e, className: c = "", children: l, query: u = "", method: d = "get", accessToken: f = "", when: p = o, headers: m = o, mockData: h = "{}", subType: we = "", credentials: Te = "same-origin", singleRecord: g = !1, pagination: Ee = "none", pageParam: De = "page", renderWhileLoading: Oe = !1, loadingSlot: _ = "", cache: ke = !1, staleTime: Ae = 30, gcTime: je = 300, refreshSeconds: Me = 0, connector: Ne = "", action: Pe = "", input: Fe }) => {
|
|
30
|
+
let { id: v, visible: y, definition: { label: b = "Api Container", runtime: Ie, items: Le } } = t(), x = Ie === "server", { loaded: S, stale: C, location: w, elementData: T, refreshing: Re, refresh: E, cancel: D } = ee(), O = xe(n.sourceType, v), { settings: { previewMode: k }, contexts: { InteractionsContext: ze } } = he(), { interactionsManager: A } = pe(ze), [[j, M, Be]] = _e([
|
|
29
31
|
"navigation.routeParams",
|
|
30
32
|
"navigation.queryParams",
|
|
31
33
|
"navigation.navigate"
|
|
32
|
-
]),
|
|
33
|
-
...
|
|
34
|
-
Authorization: `Bearer ${
|
|
35
|
-
} :
|
|
36
|
-
...
|
|
37
|
-
...
|
|
38
|
-
})) || !
|
|
39
|
-
C,
|
|
34
|
+
]), Ve = i(() => f ? {
|
|
35
|
+
...m,
|
|
36
|
+
Authorization: `Bearer ${f}`
|
|
37
|
+
} : m, [m, f]), N = i(() => x || !y ? !1 : !!(k && u && (p === o || Ce(p, {
|
|
38
|
+
...j,
|
|
39
|
+
...M
|
|
40
|
+
})) || !k && (u || h && h !== "{}" && h !== o)), [
|
|
40
41
|
x,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
y,
|
|
43
|
+
k,
|
|
44
|
+
u,
|
|
45
|
+
p,
|
|
46
|
+
j,
|
|
44
47
|
M,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
48
|
+
h
|
|
49
|
+
]), He = i(() => [v], [v]), { isLoading: Ue, isFetching: We, data: P, refetch: F, cancel: I, isSuccess: Ge, isError: Ke } = se({
|
|
50
|
+
url: u,
|
|
51
|
+
method: d,
|
|
52
|
+
credentials: Te,
|
|
53
|
+
mock: k ? void 0 : h,
|
|
54
|
+
customHeaders: Ve,
|
|
55
|
+
enabled: N,
|
|
56
|
+
cache: ke,
|
|
57
|
+
staleTime: Ae,
|
|
58
|
+
gcTime: je,
|
|
59
|
+
tags: He
|
|
60
|
+
}), L = x && !!w && w !== ye(), R = x && S && !L && T === null, z = x && !Ne && !Pe, B = i(() => x ? T || (S ? o : oe(h, z)) : P ?? o, [
|
|
61
|
+
x,
|
|
62
|
+
P,
|
|
63
|
+
T,
|
|
64
|
+
S,
|
|
65
|
+
h,
|
|
66
|
+
z
|
|
67
|
+
]), V = x ? L || Re : We, H = x ? L : Ue, U = a({}), W = r((e, t) => E(e, {
|
|
68
|
+
...U.current,
|
|
69
|
+
...t
|
|
70
|
+
}), [E]), G = r(async () => {
|
|
71
|
+
if (!x) {
|
|
72
|
+
F();
|
|
73
|
+
return;
|
|
67
74
|
}
|
|
75
|
+
await W([v]);
|
|
68
76
|
}, [
|
|
69
|
-
|
|
77
|
+
x,
|
|
70
78
|
F,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
I();
|
|
79
|
+
W,
|
|
80
|
+
v
|
|
81
|
+
]), K = r(async ({ input: e } = {}) => {
|
|
82
|
+
let t = ae(e);
|
|
83
|
+
t && (U.current = t), await G();
|
|
84
|
+
}, [G]), q = r(() => {
|
|
85
|
+
if (x) {
|
|
86
|
+
D();
|
|
80
87
|
return;
|
|
81
88
|
}
|
|
82
|
-
|
|
89
|
+
I();
|
|
83
90
|
}, [
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
x,
|
|
92
|
+
D,
|
|
93
|
+
I
|
|
94
|
+
]), [qe] = ge(`schema.flat.${v}.attributes.input`, { mode: "mount" });
|
|
95
|
+
le({
|
|
96
|
+
enabled: x && S,
|
|
97
|
+
input: Fe,
|
|
98
|
+
savedInput: qe,
|
|
99
|
+
performQuery: K
|
|
100
|
+
}), ce({
|
|
101
|
+
seconds: Me,
|
|
102
|
+
enabled: y && (x ? S && !L : N),
|
|
103
|
+
refresh: G
|
|
96
104
|
});
|
|
97
|
-
let
|
|
98
|
-
elementId:
|
|
99
|
-
mode:
|
|
100
|
-
pageParam:
|
|
101
|
-
records:
|
|
102
|
-
page:
|
|
103
|
-
refresh:
|
|
104
|
-
navigate:
|
|
105
|
-
}),
|
|
106
|
-
serverMode:
|
|
107
|
-
isSuccess:
|
|
108
|
-
isError:
|
|
109
|
-
rscResolved:
|
|
105
|
+
let J = B, Je = i(() => Array.isArray(J.records) ? J.records : [], [J.records]), { records: Y, isLoadingMore: Ye, goToPage: Xe, loadMore: Ze } = ue({
|
|
106
|
+
elementId: v,
|
|
107
|
+
mode: Ee,
|
|
108
|
+
pageParam: De,
|
|
109
|
+
records: Je,
|
|
110
|
+
page: J.pageInfo?.page ?? 1,
|
|
111
|
+
refresh: W,
|
|
112
|
+
navigate: Be
|
|
113
|
+
}), X = ie({
|
|
114
|
+
serverMode: x,
|
|
115
|
+
isSuccess: Ge,
|
|
116
|
+
isError: Ke,
|
|
117
|
+
rscResolved: S,
|
|
110
118
|
rscPending: L,
|
|
111
|
-
elementData:
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
!
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
+
elementData: T
|
|
120
|
+
}), Z = a(void 0);
|
|
121
|
+
me(() => {
|
|
122
|
+
!V && v && X && (Z.current?.data !== B || Z.current.outcome !== X) && (Z.current = {
|
|
123
|
+
data: B,
|
|
124
|
+
outcome: X
|
|
125
|
+
}, A.interactionTrigger(v, X === "success" ? "onApiSuccess" : "onApiError", {
|
|
126
|
+
url: u,
|
|
127
|
+
method: d,
|
|
128
|
+
...B
|
|
129
|
+
}));
|
|
119
130
|
}, [
|
|
120
|
-
z,
|
|
121
|
-
b,
|
|
122
|
-
j,
|
|
123
131
|
B,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
132
|
+
v,
|
|
133
|
+
A,
|
|
134
|
+
V,
|
|
135
|
+
d,
|
|
136
|
+
X,
|
|
137
|
+
u
|
|
127
138
|
]);
|
|
128
|
-
let Q =
|
|
129
|
-
...
|
|
130
|
-
...Array.isArray(
|
|
131
|
-
isLoading:
|
|
132
|
-
isEmpty: ne(
|
|
139
|
+
let Q = i(() => ({
|
|
140
|
+
...B,
|
|
141
|
+
...Array.isArray(J.records) ? { records: Y } : o,
|
|
142
|
+
isLoading: V || Ye,
|
|
143
|
+
isEmpty: ne(J, Y, g),
|
|
133
144
|
hasError: R,
|
|
134
145
|
errorMessage: R ? "The data provider could not be reached" : "",
|
|
135
|
-
isStale:
|
|
146
|
+
isStale: x && C
|
|
136
147
|
}), [
|
|
137
|
-
z,
|
|
138
|
-
K.records,
|
|
139
|
-
K.record,
|
|
140
|
-
q,
|
|
141
148
|
B,
|
|
142
|
-
J,
|
|
143
|
-
|
|
149
|
+
J.records,
|
|
150
|
+
J.record,
|
|
151
|
+
Y,
|
|
152
|
+
V,
|
|
153
|
+
Ye,
|
|
154
|
+
g,
|
|
144
155
|
R,
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
]),
|
|
148
|
-
|
|
149
|
-
id:
|
|
150
|
-
source:
|
|
151
|
-
name:
|
|
152
|
-
fields:
|
|
156
|
+
x,
|
|
157
|
+
C
|
|
158
|
+
]), Qe = r(() => fe(Q), [Q]);
|
|
159
|
+
Se({
|
|
160
|
+
id: v,
|
|
161
|
+
source: O,
|
|
162
|
+
name: b || `API - ${v}`,
|
|
163
|
+
fields: Qe
|
|
153
164
|
});
|
|
154
|
-
let { writeRecord: $ } =
|
|
155
|
-
elementId:
|
|
156
|
-
enabled:
|
|
157
|
-
onDone:
|
|
158
|
-
}),
|
|
165
|
+
let { writeRecord: $ } = de({
|
|
166
|
+
elementId: v,
|
|
167
|
+
enabled: x,
|
|
168
|
+
onDone: G
|
|
169
|
+
}), $e = i(() => {
|
|
159
170
|
let e = {
|
|
160
171
|
performQuery: {
|
|
161
172
|
...n.callbacks.performQuery,
|
|
162
|
-
title: `Perform Query ${
|
|
163
|
-
callback:
|
|
173
|
+
title: `Perform Query ${b}`,
|
|
174
|
+
callback: K
|
|
175
|
+
},
|
|
176
|
+
cancelQuery: {
|
|
177
|
+
...n.callbacks.cancelQuery,
|
|
178
|
+
title: `Cancel Query ${b}`,
|
|
179
|
+
callback: q
|
|
164
180
|
},
|
|
165
181
|
loadMore: {
|
|
166
182
|
...n.callbacks.loadMore,
|
|
167
|
-
title: `Load More ${
|
|
168
|
-
callback:
|
|
183
|
+
title: `Load More ${b}`,
|
|
184
|
+
callback: Ze
|
|
169
185
|
},
|
|
170
186
|
goToPage: {
|
|
171
187
|
...n.callbacks.goToPage,
|
|
172
|
-
title: `Go To Page ${
|
|
173
|
-
callback: ({ page: e }) =>
|
|
188
|
+
title: `Go To Page ${b}`,
|
|
189
|
+
callback: ({ page: e }) => Xe(Number(e) || 1)
|
|
174
190
|
}
|
|
175
191
|
};
|
|
176
|
-
return
|
|
192
|
+
return x && (e.writeRecord = {
|
|
177
193
|
...n.callbacks.writeRecord,
|
|
178
|
-
title: `Write Record ${
|
|
194
|
+
title: `Write Record ${b}`,
|
|
179
195
|
callback: $
|
|
180
196
|
}), e;
|
|
181
197
|
}, [
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
198
|
+
b,
|
|
199
|
+
K,
|
|
200
|
+
q,
|
|
201
|
+
Ze,
|
|
202
|
+
Xe,
|
|
203
|
+
x,
|
|
187
204
|
$
|
|
188
|
-
]),
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
]),
|
|
194
|
-
return /* @__PURE__ */
|
|
205
|
+
]), et = i(() => _ && k ? re(l, _, H) : l, [
|
|
206
|
+
l,
|
|
207
|
+
H,
|
|
208
|
+
_,
|
|
209
|
+
k
|
|
210
|
+
]), tt = i(() => O ? { runtime: { sources: { [O]: Q } } } : o, [Q, O]);
|
|
211
|
+
return /* @__PURE__ */ s(te, {
|
|
195
212
|
ref: e,
|
|
196
|
-
tag: !
|
|
197
|
-
className:
|
|
213
|
+
tag: !k && !Le?.length ? "div" : we,
|
|
214
|
+
className: be("plitzi-component__api-container", c),
|
|
198
215
|
interactionTriggers: n.triggers,
|
|
199
|
-
interactionCallbacks:
|
|
200
|
-
children: (!
|
|
216
|
+
interactionCallbacks: $e,
|
|
217
|
+
children: (!H || Oe || _) && /* @__PURE__ */ s(ve, {
|
|
201
218
|
inherit: "live",
|
|
202
|
-
name: `Api:${
|
|
203
|
-
value:
|
|
204
|
-
children:
|
|
219
|
+
name: `Api:${v}`,
|
|
220
|
+
value: tt,
|
|
221
|
+
children: et
|
|
205
222
|
})
|
|
206
223
|
});
|
|
207
|
-
},
|
|
224
|
+
}, l = e(c);
|
|
208
225
|
//#endregion
|
|
209
|
-
export {
|
|
226
|
+
export { c as ApiContainer, l as default };
|
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
import { ApiContainerProps } from './ApiContainer';
|
|
2
2
|
import { AuthorableAttributes } from '@plitzi/sdk-shared/authoring/declare';
|
|
3
3
|
/** What this element can be authored with — its component's own props, minus what the runtime supplies. */
|
|
4
|
-
export type ApiContainerAttributes = AuthorableAttributes<ApiContainerProps
|
|
5
|
-
/**
|
|
6
|
-
* What this element asks of the action it names, on top of the page's own route and query params.
|
|
7
|
-
*
|
|
8
|
-
* Not a component prop, and it never will be: the action runs on the server, so this is read there and the
|
|
9
|
-
* element only ever sees what came back.
|
|
10
|
-
*/
|
|
11
|
-
input?: Record<string, unknown>;
|
|
12
|
-
};
|
|
4
|
+
export type ApiContainerAttributes = AuthorableAttributes<ApiContainerProps>;
|
|
13
5
|
declare const declaration: {
|
|
14
6
|
readonly type: "apiContainer";
|
|
15
7
|
readonly attributeValues: {
|
|
@@ -60,6 +52,13 @@ declare const declaration: {
|
|
|
60
52
|
};
|
|
61
53
|
};
|
|
62
54
|
};
|
|
55
|
+
readonly cancelQuery: {
|
|
56
|
+
readonly action: "cancelQuery";
|
|
57
|
+
readonly title: "Cancel Query";
|
|
58
|
+
readonly type: "callback";
|
|
59
|
+
readonly preview: {};
|
|
60
|
+
readonly params: {};
|
|
61
|
+
};
|
|
63
62
|
readonly loadMore: {
|
|
64
63
|
readonly action: "loadMore";
|
|
65
64
|
readonly title: "Load More";
|
|
@@ -164,5 +163,34 @@ declare const declaration: {
|
|
|
164
163
|
};
|
|
165
164
|
readonly settings: {};
|
|
166
165
|
};
|
|
167
|
-
} & import('@plitzi/sdk-shared/authoring/declare').ElementAttributesBrand<
|
|
166
|
+
} & import('@plitzi/sdk-shared/authoring/declare').ElementAttributesBrand<Partial<{
|
|
167
|
+
when?: import('@plitzi/sdk-shared').RuleGroup | undefined;
|
|
168
|
+
action?: string | undefined;
|
|
169
|
+
cache?: boolean | undefined;
|
|
170
|
+
endpoint?: string | undefined;
|
|
171
|
+
input?: (Record<string, unknown> | string) | undefined;
|
|
172
|
+
method?: "get" | "post" | "put" | "delete" | "patch" | undefined;
|
|
173
|
+
resource?: string | undefined;
|
|
174
|
+
headers?: Record<string, string> | undefined;
|
|
175
|
+
subType?: "div" | "header" | "footer" | "nav" | "main" | "section" | "article" | "aside" | "address" | "figure" | "" | undefined;
|
|
176
|
+
query?: string | undefined;
|
|
177
|
+
accessToken?: string | undefined;
|
|
178
|
+
mockData?: (Record<string, unknown> | string) | undefined;
|
|
179
|
+
credentials?: RequestCredentials | undefined;
|
|
180
|
+
connector?: string | undefined;
|
|
181
|
+
limit?: string | undefined;
|
|
182
|
+
singleRecord?: boolean | undefined;
|
|
183
|
+
filters?: {
|
|
184
|
+
field: string;
|
|
185
|
+
operator: string;
|
|
186
|
+
value: string;
|
|
187
|
+
}[] | undefined;
|
|
188
|
+
pagination?: import('./hooks/useProviderPagination').ProviderPagination | undefined;
|
|
189
|
+
pageParam?: string | undefined;
|
|
190
|
+
renderWhileLoading?: boolean | undefined;
|
|
191
|
+
loadingSlot?: string | undefined;
|
|
192
|
+
staleTime?: number | string | undefined;
|
|
193
|
+
gcTime?: number | string | undefined;
|
|
194
|
+
refreshSeconds?: number | string | undefined;
|
|
195
|
+
}>>;
|
|
168
196
|
export default declaration;
|
|
@@ -74,6 +74,13 @@ var n = e()({
|
|
|
74
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
75
|
} }
|
|
76
76
|
},
|
|
77
|
+
cancelQuery: {
|
|
78
|
+
action: "cancelQuery",
|
|
79
|
+
title: "Cancel Query",
|
|
80
|
+
type: "callback",
|
|
81
|
+
preview: {},
|
|
82
|
+
params: {}
|
|
83
|
+
},
|
|
77
84
|
loadMore: {
|
|
78
85
|
action: "loadMore",
|
|
79
86
|
title: "Load More",
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a server provider renders from in the builder, which has no `/_rsc` to ask: its mock data, in the shape the
|
|
3
|
+
* server answers it with.
|
|
4
|
+
*
|
|
5
|
+
* A provider that only has a `query` is answered as a browser request publishes — `{ status, data }`, the body under
|
|
6
|
+
* `data` — so its mock is that body under `data` too: `<source>.data.<field>` in the browser, on the server and in the
|
|
7
|
+
* builder alike. A connector's or an action's answer is its own slice (`records`, an action's output), and so is its
|
|
8
|
+
* mock. Mock data that is not JSON renders nothing, as an empty answer would.
|
|
9
|
+
*/
|
|
10
|
+
export declare const serverMock: (mockData: Record<string, unknown> | string, queryShaped: boolean) => Record<string, unknown>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { emptyObject as e } from "@plitzi/sdk-shared/helpers/utils";
|
|
2
|
+
//#region src/elements/provider/ApiContainer/helpers/serverMock.ts
|
|
3
|
+
var t = (t, n) => {
|
|
4
|
+
let r;
|
|
5
|
+
if (typeof t != "string") r = t;
|
|
6
|
+
else try {
|
|
7
|
+
r = JSON.parse(t || "{}");
|
|
8
|
+
} catch {
|
|
9
|
+
return e;
|
|
10
|
+
}
|
|
11
|
+
return n ? {
|
|
12
|
+
status: 200,
|
|
13
|
+
data: r
|
|
14
|
+
} : r;
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { t as serverMock };
|
|
@@ -39,6 +39,8 @@ declare const useApi: ({ url, method, mock, customHeaders, enabled, credentials,
|
|
|
39
39
|
isFetching: boolean;
|
|
40
40
|
data: ApiResponse | undefined;
|
|
41
41
|
refetch: () => void;
|
|
42
|
+
/** Stops the request in flight; the last answer stays on screen. */
|
|
43
|
+
cancel: () => void;
|
|
42
44
|
/**
|
|
43
45
|
* Whether THIS question has been answered — not whether an answer is on screen.
|
|
44
46
|
*
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type UseInputRefreshProps = {
|
|
2
|
+
/** A server provider whose payload has arrived: there is a question to ask again. */
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
/** The input as it resolves now — bound to state, it changes as the visitor does. */
|
|
5
|
+
input: unknown;
|
|
6
|
+
/** The input the element was saved with: what the page server resolved the first paint with. */
|
|
7
|
+
savedInput: unknown;
|
|
8
|
+
performQuery: (options: {
|
|
9
|
+
input?: unknown;
|
|
10
|
+
}) => Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* A bound `input` asks again when what it says changes.
|
|
14
|
+
*
|
|
15
|
+
* The first paint was resolved by the page server with the input the element was SAVED with — bindings to the
|
|
16
|
+
* visitor's state are not the server's to read — so that is what the first value is compared against: a binding that
|
|
17
|
+
* already says something else (a state kept from the last visit) asks at once.
|
|
18
|
+
*/
|
|
19
|
+
declare const useInputRefresh: ({ enabled, input, savedInput, performQuery }: UseInputRefreshProps) => void;
|
|
20
|
+
export default useInputRefresh;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { queryInputOf as e } from "../helpers/queryInput.mjs";
|
|
2
|
+
import { useEffect as t, useRef as n } from "react";
|
|
3
|
+
//#region src/elements/provider/ApiContainer/hooks/useInputRefresh.ts
|
|
4
|
+
var r = ({ enabled: r, input: i, savedInput: a, performQuery: o }) => {
|
|
5
|
+
let s = JSON.stringify(e(i) ?? {}), c = n(JSON.stringify(e(a) ?? {}));
|
|
6
|
+
t(() => {
|
|
7
|
+
r && s !== c.current && (c.current = s, o({ input: i }));
|
|
8
|
+
}, [
|
|
9
|
+
r,
|
|
10
|
+
s,
|
|
11
|
+
i,
|
|
12
|
+
o
|
|
13
|
+
]);
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { r as default };
|
|
@@ -51,6 +51,13 @@ declare const ApiContainer: {
|
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
53
|
};
|
|
54
|
+
readonly cancelQuery: {
|
|
55
|
+
readonly action: "cancelQuery";
|
|
56
|
+
readonly title: "Cancel Query";
|
|
57
|
+
readonly type: "callback";
|
|
58
|
+
readonly preview: {};
|
|
59
|
+
readonly params: {};
|
|
60
|
+
};
|
|
54
61
|
readonly loadMore: {
|
|
55
62
|
readonly action: "loadMore";
|
|
56
63
|
readonly title: "Load More";
|
|
@@ -155,5 +162,34 @@ declare const ApiContainer: {
|
|
|
155
162
|
};
|
|
156
163
|
readonly settings: {};
|
|
157
164
|
};
|
|
158
|
-
} & import('@plitzi/sdk-shared/authoring/declare').ElementAttributesBrand<
|
|
165
|
+
} & import('@plitzi/sdk-shared/authoring/declare').ElementAttributesBrand<Partial<{
|
|
166
|
+
when?: import('@plitzi/sdk-shared').RuleGroup | undefined;
|
|
167
|
+
action?: string | undefined;
|
|
168
|
+
cache?: boolean | undefined;
|
|
169
|
+
endpoint?: string | undefined;
|
|
170
|
+
input?: (Record<string, unknown> | string) | undefined;
|
|
171
|
+
method?: "get" | "post" | "put" | "delete" | "patch" | undefined;
|
|
172
|
+
resource?: string | undefined;
|
|
173
|
+
headers?: Record<string, string> | undefined;
|
|
174
|
+
subType?: "div" | "header" | "footer" | "nav" | "main" | "section" | "article" | "aside" | "address" | "figure" | "" | undefined;
|
|
175
|
+
query?: string | undefined;
|
|
176
|
+
accessToken?: string | undefined;
|
|
177
|
+
mockData?: (Record<string, unknown> | string) | undefined;
|
|
178
|
+
credentials?: RequestCredentials | undefined;
|
|
179
|
+
connector?: string | undefined;
|
|
180
|
+
limit?: string | undefined;
|
|
181
|
+
singleRecord?: boolean | undefined;
|
|
182
|
+
filters?: {
|
|
183
|
+
field: string;
|
|
184
|
+
operator: string;
|
|
185
|
+
value: string;
|
|
186
|
+
}[] | undefined;
|
|
187
|
+
pagination?: import('./hooks/useProviderPagination').ProviderPagination | undefined;
|
|
188
|
+
pageParam?: string | undefined;
|
|
189
|
+
renderWhileLoading?: boolean | undefined;
|
|
190
|
+
loadingSlot?: string | undefined;
|
|
191
|
+
staleTime?: number | string | undefined;
|
|
192
|
+
gcTime?: number | string | undefined;
|
|
193
|
+
refreshSeconds?: number | string | undefined;
|
|
194
|
+
}>>;
|
|
159
195
|
export default ApiContainer;
|
|
@@ -2,7 +2,7 @@ import { ReactNode, RefObject } from 'react';
|
|
|
2
2
|
export type ContainerProps = {
|
|
3
3
|
ref?: RefObject<HTMLElement>;
|
|
4
4
|
className?: string;
|
|
5
|
-
subType?: 'div' | 'header' | 'footer' | 'nav' | 'main' | 'section' | 'article' | 'aside' | 'address' | 'figure' | 'dl' | 'dt' | 'dd' | 'li' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'span';
|
|
5
|
+
subType?: 'div' | 'header' | 'footer' | 'nav' | 'main' | 'section' | 'article' | 'aside' | 'address' | 'figure' | 'dl' | 'dt' | 'dd' | 'li' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span';
|
|
6
6
|
/**
|
|
7
7
|
* The name of the part of the page this is — "Main navigation", "Search results", "Your cart" — for screen readers
|
|
8
8
|
* and browser agents, which list the page by its landmarks and regions and jump between them.
|
|
@@ -17,9 +17,20 @@ export type ContainerProps = {
|
|
|
17
17
|
* control inside it can still be tabbed to, and is then announced as nothing.
|
|
18
18
|
*/
|
|
19
19
|
decorative?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* A part of the page whose words change while somebody is on it — a count, a total, a status — said aloud when they
|
|
22
|
+
* do (`aria-live`): `polite` once the reader is idle, `assertive` at once, for what cannot wait. Left out, a change is
|
|
23
|
+
* silent to a screen reader, which reads only what it is moved to.
|
|
24
|
+
*/
|
|
25
|
+
live?: 'polite' | 'assertive' | '';
|
|
26
|
+
/**
|
|
27
|
+
* What a pointer resting on it shows — the whole of a value cut short, what a symbol means. Not a name: a screen reader
|
|
28
|
+
* may not say it, so what matters to someone who cannot hover is in the content or in `label` too.
|
|
29
|
+
*/
|
|
30
|
+
title?: string;
|
|
20
31
|
children?: ReactNode;
|
|
21
32
|
};
|
|
22
|
-
declare const Container: ({ ref, className, subType, label, decorative, children }: ContainerProps) => import('react').JSX.Element;
|
|
33
|
+
declare const Container: ({ ref, className, subType, label, decorative, live, title, children }: ContainerProps) => import('react').JSX.Element;
|
|
23
34
|
declare const _default: {
|
|
24
35
|
(props: import('../../../Element/hocs/withElement').WithElementProps<ContainerProps>): import('react').JSX.Element;
|
|
25
36
|
displayName: string;
|