@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.
Files changed (74) hide show
  1. package/CHANGELOG.md +539 -0
  2. package/dist/Element/helpers/elementChildren.d.ts +29 -0
  3. package/dist/Element/helpers/elementChildren.mjs +16 -0
  4. package/dist/Element/hooks/useElementVisible.d.ts +11 -0
  5. package/dist/Element/hooks/useElementVisible.mjs +25 -0
  6. package/dist/Element/hooks/useRscData.d.ts +4 -0
  7. package/dist/Element/hooks/useRscData.mjs +23 -19
  8. package/dist/dataSource/GlobalSources.mjs +68 -57
  9. package/dist/elements/basic/Button/Button.d.ts +6 -1
  10. package/dist/elements/basic/Button/Button.mjs +9 -8
  11. package/dist/elements/basic/Button/declaration.d.ts +2 -1
  12. package/dist/elements/basic/Button/declaration.mjs +1 -1
  13. package/dist/elements/basic/Button/index.d.ts +2 -1
  14. package/dist/elements/basic/Dropdown/DropdownPopup/declaration.d.ts +1 -1
  15. package/dist/elements/basic/Dropdown/DropdownPopup/declaration.mjs +1 -1
  16. package/dist/elements/basic/Dropdown/DropdownPopup/index.d.ts +1 -1
  17. package/dist/elements/basic/Dropdown/index.d.ts +1 -1
  18. package/dist/elements/basic/Markdown/Markdown.d.ts +3 -3
  19. package/dist/elements/basic/Markdown/Markdown.mjs +10 -6
  20. package/dist/elements/basic/Markdown/declaration.d.ts +1 -1
  21. package/dist/elements/basic/Markdown/index.d.ts +1 -1
  22. package/dist/elements/basic/RichText/declaration.d.ts +1 -1
  23. package/dist/elements/basic/RichText/declaration.mjs +1 -1
  24. package/dist/elements/basic/RichText/index.d.ts +1 -1
  25. package/dist/elements/basic/Text/Text.d.ts +6 -1
  26. package/dist/elements/basic/Text/Text.mjs +6 -5
  27. package/dist/elements/basic/Text/declaration.d.ts +1 -0
  28. package/dist/elements/basic/Text/index.d.ts +1 -0
  29. package/dist/elements/declarations/index.d.ts +55 -11
  30. package/dist/elements/form/Form/declaration.d.ts +1 -0
  31. package/dist/elements/form/Form/declaration.mjs +2 -1
  32. package/dist/elements/form/FormControl/FormControl.d.ts +5 -1
  33. package/dist/elements/form/FormControl/FormControl.mjs +3 -0
  34. package/dist/elements/form/FormControl/Settings.d.ts +1 -1
  35. package/dist/elements/form/FormControl/Settings.mjs +16 -1
  36. package/dist/elements/form/FormControl/declaration.d.ts +1 -0
  37. package/dist/elements/form/FormControl/declaration.mjs +6 -2
  38. package/dist/elements/internal/LayoutContainer/LayoutContainer.mjs +37 -29
  39. package/dist/elements/internal/LayoutContainer/mask.d.ts +11 -0
  40. package/dist/elements/internal/LayoutContainer/mask.mjs +14 -0
  41. package/dist/elements/media/Image/Image.d.ts +7 -1
  42. package/dist/elements/media/Image/Image.mjs +10 -10
  43. package/dist/elements/media/Image/declaration.d.ts +2 -1
  44. package/dist/elements/media/Image/declaration.mjs +1 -1
  45. package/dist/elements/media/Image/index.d.ts +2 -1
  46. package/dist/elements/provider/ApiContainer/ApiContainer.d.ts +9 -1
  47. package/dist/elements/provider/ApiContainer/ApiContainer.mjs +172 -155
  48. package/dist/elements/provider/ApiContainer/declaration.d.ts +38 -10
  49. package/dist/elements/provider/ApiContainer/declaration.mjs +7 -0
  50. package/dist/elements/provider/ApiContainer/helpers/serverMock.d.ts +10 -0
  51. package/dist/elements/provider/ApiContainer/helpers/serverMock.mjs +17 -0
  52. package/dist/elements/provider/ApiContainer/hooks/useApi.d.ts +2 -0
  53. package/dist/elements/provider/ApiContainer/hooks/useApi.mjs +1 -0
  54. package/dist/elements/provider/ApiContainer/hooks/useInputRefresh.d.ts +20 -0
  55. package/dist/elements/provider/ApiContainer/hooks/useInputRefresh.mjs +16 -0
  56. package/dist/elements/provider/ApiContainer/index.d.ts +37 -1
  57. package/dist/elements/structure/Container/Container.d.ts +13 -2
  58. package/dist/elements/structure/Container/Container.mjs +8 -6
  59. package/dist/elements/structure/Container/declaration.d.ts +5 -2
  60. package/dist/elements/structure/Container/declaration.mjs +32 -24
  61. package/dist/elements/structure/Container/index.d.ts +5 -2
  62. package/dist/elements/structure/DialogContainer/declaration.d.ts +1 -1
  63. package/dist/elements/structure/DialogContainer/declaration.mjs +1 -1
  64. package/dist/elements/structure/DialogContainer/index.d.ts +1 -1
  65. package/dist/elements/structure/List/ListItem/declaration.d.ts +1 -1
  66. package/dist/elements/structure/List/ListItem/declaration.mjs +1 -1
  67. package/dist/elements/structure/List/ListItem/index.d.ts +1 -1
  68. package/dist/elements/structure/List/index.d.ts +1 -1
  69. package/dist/elements/structure/TabContainer/TabContainerItem/declaration.d.ts +1 -1
  70. package/dist/elements/structure/TabContainer/TabContainerItem/declaration.mjs +1 -1
  71. package/dist/elements/structure/TabContainer/TabContainerItem/index.d.ts +1 -1
  72. package/dist/elements/structure/TabContainer/index.d.ts +1 -1
  73. package/dist/index.d.ts +53 -11
  74. 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 r from "./hooks/useApi.mjs";
11
- import i from "./hooks/useAutoRefresh.mjs";
12
- import oe from "./hooks/useProviderPagination.mjs";
13
- import se from "./hooks/useProviderWrite.mjs";
14
- import ce from "../../../dataSource/pathFields.mjs";
15
- import { use as le, useCallback as a, useEffect as ue, useMemo as o, useRef as de } from "react";
16
- import fe from "@plitzi/sdk-shared/hooks/usePlitziServiceContext";
17
- import { useSdkStore as pe } from "@plitzi/sdk-shared/store";
18
- import { StoreProvider as s } from "@plitzi/nexus/react";
19
- import { emptyObject as c } from "@plitzi/sdk-shared/helpers/utils";
20
- import { jsx as l } from "react/jsx-runtime";
21
- import { currentRscLocation as me } from "@plitzi/sdk-shared/server/rsc/refreshRsc";
22
- import he from "clsx";
23
- import ge from "@plitzi/sdk-shared/dataSource/helpers/getSourceName";
24
- import _e from "@plitzi/sdk-shared/dataSource/hooks/useRegisterSource";
25
- import { QueryBuilderEvaluator as ve } from "@plitzi/plitzi-ui/QueryBuilder";
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 u = ({ ref: e, className: u = "", children: d, query: f = "", method: p = "get", accessToken: m = "", when: h = c, headers: g = c, mockData: _ = "{}", subType: ye = "", credentials: be = "same-origin", singleRecord: v = !1, pagination: xe = "none", pageParam: Se = "page", renderWhileLoading: Ce = !1, loadingSlot: y = "", cache: we = !1, staleTime: Te = 30, gcTime: Ee = 300, refreshSeconds: De = 0 }) => {
28
- let { id: b, visible: x, definition: { label: S = "Api Container", runtime: Oe, items: ke } } = t(), C = Oe === "server", { loaded: w, stale: T, location: E, elementData: D, refresh: O } = ee(), k = ge(n.sourceType, b), { settings: { previewMode: A }, contexts: { InteractionsContext: Ae } } = fe(), { interactionsManager: j } = le(Ae), [[M, N, je]] = pe([
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
- ]), Me = o(() => m ? {
33
- ...g,
34
- Authorization: `Bearer ${m}`
35
- } : g, [g, m]), P = o(() => C || !x ? !1 : !!(A && f && (h === c || ve(h, {
36
- ...M,
37
- ...N
38
- })) || !A && (f || _ && _ !== "{}" && _ !== c)), [
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
- A,
42
- f,
43
- h,
42
+ y,
43
+ k,
44
+ u,
45
+ p,
46
+ j,
44
47
  M,
45
- N,
46
- _
47
- ]), Ne = o(() => [b], [b]), { isLoading: Pe, isFetching: Fe, data: F, refetch: I, isSuccess: Ie, isError: Le } = r({
48
- url: f,
49
- method: p,
50
- credentials: be,
51
- mock: A ? void 0 : _,
52
- customHeaders: Me,
53
- enabled: P,
54
- cache: we,
55
- staleTime: Te,
56
- gcTime: Ee,
57
- tags: Ne
58
- }), L = C && !!E && E !== me(), R = C && w && !L && D === null, z = o(() => {
59
- if (!C) return F ?? c;
60
- if (D) return D;
61
- if (w) return c;
62
- if (typeof _ != "string") return _;
63
- try {
64
- return JSON.parse(_ || "{}");
65
- } catch {
66
- return c;
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
- C,
77
+ x,
70
78
  F,
71
- D,
72
- w,
73
- _
74
- ]), B = C ? L : Fe, V = C ? L : Pe, H = de({}), U = a((e, t) => O(e, {
75
- ...H.current,
76
- ...t
77
- }), [O]), W = a(async () => {
78
- if (!C) {
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
- await U([b]);
89
+ I();
83
90
  }, [
84
- C,
85
- I,
86
- U,
87
- b
88
- ]), G = a(async ({ input: e } = {}) => {
89
- let t = ae(e);
90
- t && (H.current = t), await W();
91
- }, [W]);
92
- i({
93
- seconds: De,
94
- enabled: x && (C ? w && !L : P),
95
- refresh: W
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 K = z, Re = o(() => Array.isArray(K.records) ? K.records : [], [K.records]), { records: q, isLoadingMore: J, goToPage: Y, loadMore: X } = oe({
98
- elementId: b,
99
- mode: xe,
100
- pageParam: Se,
101
- records: Re,
102
- page: K.pageInfo?.page ?? 1,
103
- refresh: U,
104
- navigate: je
105
- }), Z = ie({
106
- serverMode: C,
107
- isSuccess: Ie,
108
- isError: Le,
109
- rscResolved: w,
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: D
112
- });
113
- ue(() => {
114
- !B && b && Z && j.interactionTrigger(b, Z === "success" ? "onApiSuccess" : "onApiError", {
115
- url: f,
116
- method: p,
117
- ...z
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
- p,
125
- Z,
126
- f
132
+ v,
133
+ A,
134
+ V,
135
+ d,
136
+ X,
137
+ u
127
138
  ]);
128
- let Q = o(() => ({
129
- ...z,
130
- ...Array.isArray(K.records) ? { records: q } : c,
131
- isLoading: B || J,
132
- isEmpty: ne(K, q, v),
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: C && T
146
+ isStale: x && C
136
147
  }), [
137
- z,
138
- K.records,
139
- K.record,
140
- q,
141
148
  B,
142
- J,
143
- v,
149
+ J.records,
150
+ J.record,
151
+ Y,
152
+ V,
153
+ Ye,
154
+ g,
144
155
  R,
145
- C,
146
- T
147
- ]), ze = a(() => ce(Q), [Q]);
148
- _e({
149
- id: b,
150
- source: k,
151
- name: S || `API - ${b}`,
152
- fields: ze
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: $ } = se({
155
- elementId: b,
156
- enabled: C,
157
- onDone: W
158
- }), Be = o(() => {
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 ${S}`,
163
- callback: G
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 ${S}`,
168
- callback: X
183
+ title: `Load More ${b}`,
184
+ callback: Ze
169
185
  },
170
186
  goToPage: {
171
187
  ...n.callbacks.goToPage,
172
- title: `Go To Page ${S}`,
173
- callback: ({ page: e }) => Y(Number(e) || 1)
188
+ title: `Go To Page ${b}`,
189
+ callback: ({ page: e }) => Xe(Number(e) || 1)
174
190
  }
175
191
  };
176
- return C && (e.writeRecord = {
192
+ return x && (e.writeRecord = {
177
193
  ...n.callbacks.writeRecord,
178
- title: `Write Record ${S}`,
194
+ title: `Write Record ${b}`,
179
195
  callback: $
180
196
  }), e;
181
197
  }, [
182
- S,
183
- G,
184
- X,
185
- Y,
186
- C,
198
+ b,
199
+ K,
200
+ q,
201
+ Ze,
202
+ Xe,
203
+ x,
187
204
  $
188
- ]), Ve = o(() => y && A ? re(d, y, V) : d, [
189
- d,
190
- V,
191
- y,
192
- A
193
- ]), He = o(() => k ? { runtime: { sources: { [k]: Q } } } : c, [Q, k]);
194
- return /* @__PURE__ */ l(te, {
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: !A && !ke?.length ? "div" : ye,
197
- className: he("plitzi-component__api-container", u),
213
+ tag: !k && !Le?.length ? "div" : we,
214
+ className: be("plitzi-component__api-container", c),
198
215
  interactionTriggers: n.triggers,
199
- interactionCallbacks: Be,
200
- children: (!V || Ce || y) && /* @__PURE__ */ l(s, {
216
+ interactionCallbacks: $e,
217
+ children: (!H || Oe || _) && /* @__PURE__ */ s(ve, {
201
218
  inherit: "live",
202
- name: `Api:${b}`,
203
- value: He,
204
- children: Ve
219
+ name: `Api:${v}`,
220
+ value: tt,
221
+ children: et
205
222
  })
206
223
  });
207
- }, d = e(u);
224
+ }, l = e(c);
208
225
  //#endregion
209
- export { u as ApiContainer, d as default };
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<ApiContainerAttributes>;
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
  *
@@ -94,6 +94,7 @@ var l = 30, u = 300, d = (e) => !!e && e !== "{}" && e !== i, f = (e) => {
94
94
  isFetching: A,
95
95
  data: k,
96
96
  refetch: D.refetch,
97
+ cancel: D.cancel,
97
98
  isSuccess: !w && !A && !!k && k.status < 400,
98
99
  isError: !w && !A && !!k && k.status >= 400
99
100
  };
@@ -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<import('./declaration').ApiContainerAttributes>;
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;