@plitzi/sdk-elements 0.32.24 → 0.33.0
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 +31 -0
- package/dist/Element/ElementContext.d.ts +7 -0
- package/dist/Element/helpers/isVisible.d.ts +1 -0
- package/dist/Element/helpers/isVisible.mjs +4 -0
- package/dist/Element/hocs/withElement.mjs +86 -78
- package/dist/Element/hooks/useInternalClassName.mjs +21 -20
- package/dist/Element/hooks/useInternalItems.mjs +1 -1
- package/dist/Element/hooks/useRscData.d.ts +4 -3
- package/dist/Element/hooks/useRscData.mjs +15 -10
- package/dist/dataSource/GlobalSources.d.ts +1 -2
- package/dist/dataSource/GlobalSources.mjs +46 -62
- package/dist/elements/advanced/BlockJsx/BlockJsx.mjs +1 -1
- package/dist/elements/basic/Link/Link.mjs +47 -41
- package/dist/elements/basic/RichText/RichText.d.ts +20 -0
- package/dist/elements/basic/RichText/RichText.mjs +30 -0
- package/dist/elements/basic/RichText/Settings.d.ts +7 -0
- package/dist/elements/basic/RichText/Settings.mjs +51 -0
- package/dist/elements/{provider/CollectionContainer → basic/RichText}/index.d.ts +6 -7
- package/dist/elements/{provider/CollectionContainer → basic/RichText}/index.mjs +12 -13
- package/dist/elements/basic/RichText/sanitizeHtml.d.ts +21 -0
- package/dist/elements/basic/RichText/sanitizeHtml.mjs +8 -0
- package/dist/elements/form/FormControl/index.mjs +1 -1
- package/dist/elements/index.d.ts +5 -3
- package/dist/elements/index.mjs +30 -28
- package/dist/elements/internal/Page/Page.mjs +28 -26
- package/dist/elements/provider/ApiContainer/ApiContainer.d.ts +28 -1
- package/dist/elements/provider/ApiContainer/ApiContainer.mjs +201 -86
- package/dist/elements/provider/ApiContainer/Settings.d.ts +15 -3
- package/dist/elements/provider/ApiContainer/Settings.mjs +209 -92
- package/dist/elements/provider/ApiContainer/components/FiltersInput/FiltersInput.d.ts +22 -0
- package/dist/elements/provider/ApiContainer/components/FiltersInput/FiltersInput.mjs +75 -0
- package/dist/elements/provider/ApiContainer/components/FiltersInput/index.d.ts +3 -0
- package/dist/elements/provider/ApiContainer/components/FiltersInput/index.mjs +5 -0
- package/dist/elements/provider/ApiContainer/hooks/useProviderPagination.d.ts +31 -0
- package/dist/elements/provider/ApiContainer/hooks/useProviderPagination.mjs +51 -0
- package/dist/elements/provider/ApiContainer/hooks/useProviderWrite.d.ts +26 -0
- package/dist/elements/provider/ApiContainer/hooks/useProviderWrite.mjs +27 -0
- package/dist/elements/provider/ApiContainer/index.d.ts +8 -0
- package/dist/elements/provider/ApiContainer/index.mjs +9 -1
- package/dist/elements/settings.mjs +32 -30
- package/dist/elements/structure/Pagination/Pagination.d.ts +41 -0
- package/dist/elements/structure/Pagination/Pagination.mjs +83 -0
- package/dist/elements/structure/Pagination/Settings.d.ts +12 -0
- package/dist/elements/structure/Pagination/Settings.mjs +85 -0
- package/dist/elements/structure/Pagination/buildPageWindow.d.ts +9 -0
- package/dist/elements/structure/Pagination/buildPageWindow.mjs +8 -0
- package/dist/elements/structure/Pagination/index.d.ts +67 -0
- package/dist/elements/structure/Pagination/index.mjs +59 -0
- package/dist/index.d.ts +130 -57
- package/dist/index.mjs +32 -30
- package/package.json +76 -32
- package/dist/elements/internal/Page/helpers/UserHelper.d.ts +0 -4
- package/dist/elements/provider/CollectionContainer/CollectionContainer.d.ts +0 -18
- package/dist/elements/provider/CollectionContainer/CollectionContainer.mjs +0 -69
- package/dist/elements/provider/CollectionContainer/CollectionContainer.stories-pending.d.ts +0 -1
- package/dist/elements/provider/CollectionContainer/Settings.d.ts +0 -10
- package/dist/elements/provider/CollectionContainer/Settings.mjs +0 -74
- package/dist/elements/provider/CollectionContainer/hooks/useCollectionContext.d.ts +0 -19
- package/dist/elements/provider/CollectionContainer/hooks/useCollectionContext.mjs +0 -71
|
@@ -1,84 +1,145 @@
|
|
|
1
1
|
import e from "../../../Element/hooks/useElement.mjs";
|
|
2
|
-
import
|
|
3
|
-
import n from "
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
2
|
+
import t from "../../../Element/hooks/useRscData.mjs";
|
|
3
|
+
import { RootElement as n } from "../../../Element/RootElement.mjs";
|
|
4
|
+
import ee from "./hooks/useApi.mjs";
|
|
5
|
+
import te from "./hooks/useProviderPagination.mjs";
|
|
6
|
+
import r from "./hooks/useProviderWrite.mjs";
|
|
7
|
+
import i from "../../../Element/hocs/withElement.mjs";
|
|
8
|
+
import { use as ne, useCallback as a, useEffect as re, useMemo as o } from "react";
|
|
9
|
+
import s from "@plitzi/sdk-shared/hooks/usePlitziServiceContext";
|
|
10
|
+
import { useSdkStore as ie } from "@plitzi/sdk-shared/store";
|
|
11
|
+
import { get as ae } from "@plitzi/plitzi-ui/helpers";
|
|
12
|
+
import { processTwig as oe } from "@plitzi/sdk-shared/helpers/twigWrapper";
|
|
13
|
+
import { StoreProvider as se } from "@plitzi/nexus/react";
|
|
14
|
+
import { emptyObject as c, getPathsFromObeject as ce } from "@plitzi/sdk-shared/helpers/utils";
|
|
15
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
16
|
+
import le from "clsx";
|
|
17
|
+
import ue from "@plitzi/sdk-shared/dataSource/helpers/getSourceName";
|
|
18
|
+
import u from "@plitzi/sdk-shared/dataSource/hooks/useRegisterSource";
|
|
19
|
+
import { QueryBuilderEvaluator as d } from "@plitzi/plitzi-ui/QueryBuilder";
|
|
16
20
|
//#region src/elements/provider/ApiContainer/ApiContainer.tsx
|
|
17
|
-
var
|
|
18
|
-
let { id:
|
|
19
|
-
|
|
21
|
+
var f = ({ ref: i, className: f = "", children: p, query: m = "", method: h = "get", accessToken: g = "", when: _ = c, headers: v = c, mockData: y = "{}", subType: de = "div", credentials: fe = "same-origin", singleRecord: b = !1, pagination: x = "none", pageParam: pe = "page", renderWhileLoading: me = !1 }) => {
|
|
22
|
+
let { id: S, idRef: C, visible: w, definition: { label: T = "Api Container", runtime: he } } = e(), E = he === "server", { loaded: D, elementData: O, refresh: k } = t(), A = ue("apiContainer", { idRef: C }), { settings: { previewMode: j, debugMode: M }, contexts: { InteractionsContext: N } } = s(), { interactionsManager: P } = ne(N), [[F, I, L]] = ie([
|
|
23
|
+
"navigation.routeParams",
|
|
24
|
+
"navigation.queryParams",
|
|
25
|
+
"navigation.navigate"
|
|
26
|
+
]), R = o(() => {
|
|
27
|
+
if (!m) return "";
|
|
20
28
|
try {
|
|
21
29
|
let e = {
|
|
22
|
-
...
|
|
23
|
-
...
|
|
30
|
+
...I,
|
|
31
|
+
...F
|
|
24
32
|
};
|
|
25
|
-
|
|
33
|
+
M && [...m.matchAll(/{{([ ]+|)(?<token>[a-zA-Z0-9-_:*/]+)([ ]+|)}}/gim)].forEach(({ groups: t }) => {
|
|
26
34
|
let n = t?.token.trim();
|
|
27
|
-
(!n || !
|
|
35
|
+
(!n || !ae(e, n)) && console.log(`Token ${n} is required`);
|
|
28
36
|
});
|
|
29
|
-
let t =
|
|
30
|
-
return typeof t == "string" ? t :
|
|
37
|
+
let t = oe(m, e, !0);
|
|
38
|
+
return typeof t == "string" ? t : m;
|
|
31
39
|
} catch (e) {
|
|
32
40
|
console.error(e.message);
|
|
33
41
|
}
|
|
34
42
|
return "";
|
|
35
43
|
}, [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
]),
|
|
41
|
-
...
|
|
42
|
-
Authorization: `Bearer ${
|
|
43
|
-
} :
|
|
44
|
-
...
|
|
45
|
-
...
|
|
46
|
-
})) || !
|
|
47
|
-
|
|
48
|
-
B,
|
|
44
|
+
m,
|
|
45
|
+
I,
|
|
46
|
+
F,
|
|
47
|
+
M
|
|
48
|
+
]), ge = o(() => g ? {
|
|
49
|
+
...v,
|
|
50
|
+
Authorization: `Bearer ${g}`
|
|
51
|
+
} : v, [v, g]), _e = o(() => E || !w ? !1 : !!(j && R && (_ === c || d(_, {
|
|
52
|
+
...F,
|
|
53
|
+
...I
|
|
54
|
+
})) || !j && (R || y && y !== "{}" && y !== c)), [
|
|
55
|
+
E,
|
|
49
56
|
w,
|
|
57
|
+
j,
|
|
50
58
|
R,
|
|
59
|
+
_,
|
|
60
|
+
F,
|
|
61
|
+
I,
|
|
62
|
+
y
|
|
63
|
+
]), { isLoading: ve, data: z, refetch: B, isSuccess: V, isError: H } = ee({
|
|
64
|
+
url: R,
|
|
65
|
+
method: h,
|
|
66
|
+
credentials: fe,
|
|
67
|
+
mock: j ? void 0 : y,
|
|
68
|
+
customHeaders: ge,
|
|
69
|
+
enabled: _e
|
|
70
|
+
}), U = E && D && O === null, W = o(() => {
|
|
71
|
+
if (!E) return z ?? c;
|
|
72
|
+
if (O) return O;
|
|
73
|
+
if (D) return c;
|
|
74
|
+
if (typeof y != "string") return y;
|
|
75
|
+
try {
|
|
76
|
+
return JSON.parse(y || "{}");
|
|
77
|
+
} catch {
|
|
78
|
+
return c;
|
|
79
|
+
}
|
|
80
|
+
}, [
|
|
81
|
+
E,
|
|
51
82
|
z,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
83
|
+
O,
|
|
84
|
+
D,
|
|
85
|
+
y
|
|
86
|
+
]), G = !E && ve, K = a(async () => {
|
|
87
|
+
if (!E) {
|
|
88
|
+
B();
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
await k([S]);
|
|
92
|
+
}, [
|
|
93
|
+
E,
|
|
94
|
+
B,
|
|
95
|
+
k,
|
|
96
|
+
S
|
|
97
|
+
]), q = W, ye = o(() => Array.isArray(q.records) ? q.records : [], [q.records]), { records: J, isLoadingMore: Y, goToPage: X, loadMore: Z } = te({
|
|
98
|
+
elementId: S,
|
|
99
|
+
mode: x,
|
|
100
|
+
pageParam: pe,
|
|
101
|
+
records: ye,
|
|
102
|
+
page: q.pageInfo?.page ?? 1,
|
|
103
|
+
refresh: k,
|
|
104
|
+
navigate: L
|
|
60
105
|
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
url:
|
|
64
|
-
method:
|
|
106
|
+
re(() => {
|
|
107
|
+
G || !C || (V ? P.interactionTrigger(C, "onApiSuccess", {
|
|
108
|
+
url: R,
|
|
109
|
+
method: h,
|
|
65
110
|
...W
|
|
66
|
-
}) :
|
|
67
|
-
url:
|
|
68
|
-
method:
|
|
111
|
+
}) : H && P.interactionTrigger(C, "onApiError", {
|
|
112
|
+
url: R,
|
|
113
|
+
method: h,
|
|
69
114
|
...W
|
|
70
115
|
}));
|
|
71
116
|
}, [
|
|
72
117
|
W,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
118
|
+
C,
|
|
119
|
+
P,
|
|
120
|
+
H,
|
|
121
|
+
G,
|
|
122
|
+
V,
|
|
123
|
+
h,
|
|
124
|
+
R
|
|
80
125
|
]);
|
|
81
|
-
let
|
|
126
|
+
let Q = o(() => ({
|
|
127
|
+
...W,
|
|
128
|
+
...Array.isArray(q.records) ? { records: J } : c,
|
|
129
|
+
isLoading: G || Y,
|
|
130
|
+
isEmpty: b ? q.record === void 0 : J.length === 0,
|
|
131
|
+
hasError: U,
|
|
132
|
+
errorMessage: U ? "The data provider could not be reached" : ""
|
|
133
|
+
}), [
|
|
134
|
+
W,
|
|
135
|
+
q.records,
|
|
136
|
+
q.record,
|
|
137
|
+
J,
|
|
138
|
+
G,
|
|
139
|
+
Y,
|
|
140
|
+
b,
|
|
141
|
+
U
|
|
142
|
+
]), be = a(() => ce(Q).reduce((e, t) => {
|
|
82
143
|
let n = t.split(".");
|
|
83
144
|
return n.length > 1 ? [...e, {
|
|
84
145
|
path: t,
|
|
@@ -87,21 +148,75 @@ var y = ({ ref: r, className: y = "", children: b, query: x = "", method: S = "g
|
|
|
87
148
|
path: t,
|
|
88
149
|
name: n[n.length - 1]
|
|
89
150
|
}];
|
|
90
|
-
}, []), [
|
|
91
|
-
|
|
92
|
-
id:
|
|
93
|
-
source:
|
|
94
|
-
name:
|
|
95
|
-
fields:
|
|
151
|
+
}, []), [Q]);
|
|
152
|
+
u({
|
|
153
|
+
id: S,
|
|
154
|
+
source: A,
|
|
155
|
+
name: T || `API - ${S}`,
|
|
156
|
+
fields: be
|
|
96
157
|
});
|
|
97
|
-
let
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
158
|
+
let { writeRecord: $ } = r({
|
|
159
|
+
elementId: S,
|
|
160
|
+
enabled: E,
|
|
161
|
+
onDone: K
|
|
162
|
+
}), xe = o(() => {
|
|
163
|
+
let e = {
|
|
164
|
+
performQuery: {
|
|
165
|
+
action: "performQuery",
|
|
166
|
+
title: `Perform Query ${T}`,
|
|
167
|
+
type: "callback",
|
|
168
|
+
callback: K,
|
|
169
|
+
preview: {},
|
|
170
|
+
params: {}
|
|
171
|
+
},
|
|
172
|
+
loadMore: {
|
|
173
|
+
action: "loadMore",
|
|
174
|
+
title: `Load More ${T}`,
|
|
175
|
+
type: "callback",
|
|
176
|
+
callback: Z,
|
|
177
|
+
preview: {},
|
|
178
|
+
params: {}
|
|
179
|
+
},
|
|
180
|
+
goToPage: {
|
|
181
|
+
action: "goToPage",
|
|
182
|
+
title: `Go To Page ${T}`,
|
|
183
|
+
type: "callback",
|
|
184
|
+
callback: ({ page: e }) => X(Number(e) || 1),
|
|
185
|
+
preview: {},
|
|
186
|
+
params: { page: {
|
|
187
|
+
label: "Page",
|
|
188
|
+
defaultValue: "1",
|
|
189
|
+
type: "text"
|
|
190
|
+
} }
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
return E && (e.writeRecord = {
|
|
194
|
+
action: "writeRecord",
|
|
195
|
+
title: `Write Record ${T}`,
|
|
196
|
+
type: "callback",
|
|
197
|
+
callback: $,
|
|
198
|
+
preview: { action: "create" },
|
|
199
|
+
params: {
|
|
200
|
+
action: {
|
|
201
|
+
label: "Endpoint",
|
|
202
|
+
defaultValue: "create",
|
|
203
|
+
type: "text"
|
|
204
|
+
},
|
|
205
|
+
recordId: {
|
|
206
|
+
label: "Record Id",
|
|
207
|
+
defaultValue: "",
|
|
208
|
+
type: "text"
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}), e;
|
|
212
|
+
}, [
|
|
213
|
+
T,
|
|
214
|
+
K,
|
|
215
|
+
Z,
|
|
216
|
+
X,
|
|
217
|
+
E,
|
|
218
|
+
$
|
|
219
|
+
]), Se = o(() => ({
|
|
105
220
|
onApiError: {
|
|
106
221
|
action: "onApiError",
|
|
107
222
|
title: "On Api Error",
|
|
@@ -126,20 +241,20 @@ var y = ({ ref: r, className: y = "", children: b, query: x = "", method: S = "g
|
|
|
126
241
|
data: ""
|
|
127
242
|
}
|
|
128
243
|
}
|
|
129
|
-
}), []),
|
|
130
|
-
return /* @__PURE__ */
|
|
131
|
-
ref:
|
|
132
|
-
tag:
|
|
133
|
-
className:
|
|
134
|
-
interactionTriggers:
|
|
135
|
-
interactionCallbacks:
|
|
136
|
-
children: /* @__PURE__ */
|
|
244
|
+
}), []), Ce = o(() => A ? { runtime: { sources: { [A]: Q } } } : c, [Q, A]);
|
|
245
|
+
return /* @__PURE__ */ l(n, {
|
|
246
|
+
ref: i,
|
|
247
|
+
tag: de,
|
|
248
|
+
className: le("plitzi-component__api-container", f),
|
|
249
|
+
interactionTriggers: Se,
|
|
250
|
+
interactionCallbacks: xe,
|
|
251
|
+
children: /* @__PURE__ */ l(se, {
|
|
137
252
|
inherit: "live",
|
|
138
|
-
name: `Api:${
|
|
139
|
-
value:
|
|
140
|
-
children: !
|
|
253
|
+
name: `Api:${S}`,
|
|
254
|
+
value: Ce,
|
|
255
|
+
children: (!G || me) && p
|
|
141
256
|
})
|
|
142
257
|
});
|
|
143
|
-
},
|
|
258
|
+
}, p = i(f);
|
|
144
259
|
//#endregion
|
|
145
|
-
export {
|
|
260
|
+
export { f as ApiContainer, p as default };
|
|
@@ -1,14 +1,26 @@
|
|
|
1
|
+
import { ConnectorFilterValue } from './components/FiltersInput';
|
|
1
2
|
import { RuleGroup } from '@plitzi/plitzi-ui/QueryBuilder';
|
|
3
|
+
import { ElementRuntime } from '@plitzi/sdk-shared';
|
|
2
4
|
type SettingsProps = {
|
|
3
5
|
query?: string;
|
|
4
6
|
method?: 'get' | 'post';
|
|
5
7
|
accessToken?: string;
|
|
6
|
-
when?: RuleGroup;
|
|
7
8
|
headers?: object;
|
|
9
|
+
when?: RuleGroup;
|
|
8
10
|
subType?: 'div' | 'header' | 'footer' | 'nav' | 'main' | 'section' | 'article' | 'aside' | 'address' | 'figure';
|
|
9
11
|
mockData?: string;
|
|
10
12
|
credentials?: RequestCredentials;
|
|
11
|
-
|
|
13
|
+
runtime?: ElementRuntime;
|
|
14
|
+
connector?: string;
|
|
15
|
+
endpoint?: string;
|
|
16
|
+
resource?: string;
|
|
17
|
+
limit?: string;
|
|
18
|
+
singleRecord?: boolean;
|
|
19
|
+
filters?: ConnectorFilterValue[];
|
|
20
|
+
pagination?: 'none' | 'url' | 'append';
|
|
21
|
+
pageParam?: string;
|
|
22
|
+
renderWhileLoading?: boolean;
|
|
23
|
+
onUpdate?: (key: string, value: string | boolean | number | object, isDefinition?: boolean) => void;
|
|
12
24
|
};
|
|
13
|
-
declare const Settings: ({ query, method, accessToken,
|
|
25
|
+
declare const Settings: ({ query, method, accessToken, headers, when, subType, mockData, credentials, runtime, connector, endpoint, resource, limit, singleRecord, filters, pagination, pageParam, renderWhileLoading, onUpdate }: SettingsProps) => import("react").JSX.Element;
|
|
14
26
|
export default Settings;
|