xmlui 0.7.22 → 0.7.23
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/dist/{apiInterceptorWorker-D8M55a0M.mjs → apiInterceptorWorker-BZ3Gd4mb.mjs} +1 -1
- package/dist/{index-BLoqesEB.mjs → index-C9zkAour.mjs} +16370 -16431
- package/dist/index.css +1 -1
- package/dist/scripts/src/components/Badge/Badge.js +2 -2
- package/dist/scripts/src/components/Badge/BadgeNative.js +3 -3
- package/dist/scripts/src/components/Bookmark/Bookmark.js +5 -1
- package/dist/scripts/src/components/Bookmark/BookmarkNative.js +5 -4
- package/dist/scripts/src/components/ColorPicker/ColorPicker.js +5 -2
- package/dist/scripts/src/components/ComponentProvider.js +0 -4
- package/dist/scripts/src/components/Heading/Heading.js +14 -1
- package/dist/scripts/src/components/Heading/HeadingNative.js +15 -3
- package/dist/scripts/src/components/HtmlTags/HtmlTags.js +32 -50
- package/dist/scripts/src/components/List/ListNative.js +143 -52
- package/dist/scripts/src/components/Slider/Slider.js +1 -1
- package/dist/scripts/src/components/TableOfContents/TableOfContents.js +4 -2
- package/dist/scripts/src/components/TableOfContents/TableOfContentsNative.js +26 -21
- package/dist/scripts/src/components/Text/Text.js +1 -0
- package/dist/scripts/src/components-core/LoaderComponent.js +3 -0
- package/dist/scripts/src/components-core/TableOfContentsContext.js +11 -1
- package/dist/scripts/src/components-core/action/APICall.js +6 -6
- package/dist/scripts/src/components-core/loader/PageableLoader.js +4 -1
- package/dist/scripts/src/components-core/utils/extractParam.js +44 -0
- package/dist/style.css +1 -1
- package/dist/xmlui-metadata.mjs +3638 -3532
- package/dist/xmlui-metadata.umd.js +17 -17
- package/dist/xmlui-standalone.umd.js +139 -129
- package/dist/xmlui.mjs +1 -1
- package/package.json +1 -1
- package/dist/scripts/src/components/Chart/Chart.js +0 -24
- package/dist/scripts/src/components/Chart/ChartNative.js +0 -164
|
@@ -32,6 +32,15 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
35
44
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
45
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
46
|
};
|
|
@@ -40,12 +49,12 @@ exports.ListNative = exports.ListContext = void 0;
|
|
|
40
49
|
exports.useListData = useListData;
|
|
41
50
|
exports.MemoizedSection = MemoizedSection;
|
|
42
51
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
43
|
-
const react_1 =
|
|
52
|
+
const react_1 = require("react");
|
|
53
|
+
const react_2 = __importStar(require("react"));
|
|
44
54
|
const lodash_es_1 = require("lodash-es");
|
|
45
55
|
const constants_1 = require("../../components-core/constants");
|
|
46
56
|
const CardNative_1 = require("../Card/CardNative");
|
|
47
57
|
const virtua_1 = require("virtua");
|
|
48
|
-
const hooks_1 = require("../../components-core/utils/hooks");
|
|
49
58
|
const ScrollContext_1 = require("../../components-core/ScrollContext");
|
|
50
59
|
const react_compose_refs_1 = require("@radix-ui/react-compose-refs");
|
|
51
60
|
const List_module_scss_1 = __importDefault(require("./List.module.scss"));
|
|
@@ -54,7 +63,7 @@ const misc_1 = require("../../components-core/utils/misc");
|
|
|
54
63
|
const SpinnerNative_1 = require("../Spinner/SpinnerNative");
|
|
55
64
|
const TextNative_1 = require("../Text/TextNative");
|
|
56
65
|
const container_helpers_1 = require("../container-helpers");
|
|
57
|
-
exports.ListContext =
|
|
66
|
+
exports.ListContext = react_2.default.createContext({
|
|
58
67
|
isExpanded: (id) => false,
|
|
59
68
|
toggleExpanded: (id, isExpanded) => { },
|
|
60
69
|
});
|
|
@@ -65,7 +74,7 @@ var RowType;
|
|
|
65
74
|
RowType["ITEM"] = "ITEM";
|
|
66
75
|
})(RowType || (RowType = {}));
|
|
67
76
|
function useListData({ groupsInitiallyExpanded = true, expanded = constants_1.EMPTY_OBJECT, items, limit, groupBy, orderBy, availableGroups, defaultGroups = constants_1.EMPTY_ARRAY, }) {
|
|
68
|
-
const sortedItems = (0,
|
|
77
|
+
const sortedItems = (0, react_2.useMemo)(() => {
|
|
69
78
|
if (!orderBy) {
|
|
70
79
|
return items;
|
|
71
80
|
}
|
|
@@ -81,19 +90,19 @@ function useListData({ groupsInitiallyExpanded = true, expanded = constants_1.EM
|
|
|
81
90
|
const fieldDirectionsToOrderBy = arrayOrderBy.map((ob) => ob.direction);
|
|
82
91
|
return (0, lodash_es_1.orderBy)(items, fieldSelectorsToOrderBy, fieldDirectionsToOrderBy);
|
|
83
92
|
}, [items, orderBy]);
|
|
84
|
-
const cappedItems = (0,
|
|
93
|
+
const cappedItems = (0, react_2.useMemo)(() => {
|
|
85
94
|
if (!limit) {
|
|
86
95
|
return sortedItems;
|
|
87
96
|
}
|
|
88
97
|
return sortedItems.slice(0, limit - 1);
|
|
89
98
|
}, [sortedItems, limit]);
|
|
90
|
-
const sectionedItems = (0,
|
|
99
|
+
const sectionedItems = (0, react_2.useMemo)(() => {
|
|
91
100
|
if (groupBy === undefined) {
|
|
92
101
|
return constants_1.EMPTY_OBJECT;
|
|
93
102
|
}
|
|
94
103
|
return (0, lodash_es_1.groupBy)(cappedItems, (item) => item[groupBy]);
|
|
95
104
|
}, [cappedItems, groupBy]);
|
|
96
|
-
const sections = (0,
|
|
105
|
+
const sections = (0, react_2.useMemo)(() => {
|
|
97
106
|
if (groupBy === undefined) {
|
|
98
107
|
return constants_1.EMPTY_ARRAY;
|
|
99
108
|
}
|
|
@@ -105,7 +114,7 @@ function useListData({ groupsInitiallyExpanded = true, expanded = constants_1.EM
|
|
|
105
114
|
}
|
|
106
115
|
return foundSectionKeys;
|
|
107
116
|
}, [groupBy, sectionedItems, defaultGroups, availableGroups]);
|
|
108
|
-
const rows = (0,
|
|
117
|
+
const rows = (0, react_2.useMemo)(() => {
|
|
109
118
|
if (groupBy === undefined) {
|
|
110
119
|
return cappedItems;
|
|
111
120
|
}
|
|
@@ -162,8 +171,8 @@ const defaultItemRenderer = (item, id) => {
|
|
|
162
171
|
return (0, jsx_runtime_1.jsx)(CardNative_1.Card, { title: title, subtitle: subtitle });
|
|
163
172
|
};
|
|
164
173
|
// eslint-disable-next-line react/display-name
|
|
165
|
-
const Item = (0,
|
|
166
|
-
const getItemType = (0,
|
|
174
|
+
const Item = (0, react_2.forwardRef)(({ children, style, index }, forwardedRef) => {
|
|
175
|
+
const getItemType = (0, react_2.useContext)(ListItemTypeContext);
|
|
167
176
|
const itemType = getItemType(index) || RowType.ITEM;
|
|
168
177
|
return ((0, jsx_runtime_1.jsx)("div", { style: style, ref: forwardedRef, className: (0, classnames_1.default)({
|
|
169
178
|
[List_module_scss_1.default.row]: itemType === RowType.ITEM,
|
|
@@ -171,23 +180,51 @@ const Item = (0, react_1.forwardRef)(({ children, style, index }, forwardedRef)
|
|
|
171
180
|
[List_module_scss_1.default.sectionFooter]: itemType === RowType.SECTION_FOOTER,
|
|
172
181
|
}), "data-list-item-type": itemType, "data-index": index, children: children }));
|
|
173
182
|
});
|
|
174
|
-
const ListItemTypeContext = (0,
|
|
175
|
-
|
|
183
|
+
const ListItemTypeContext = (0, react_2.createContext)((index) => RowType.ITEM);
|
|
184
|
+
/**
|
|
185
|
+
* Virtua's `shift` prop helps maintain scroll position when prepending items (like message history).
|
|
186
|
+
* Unfortunately it's finicky and must only be `true` when the beginning of the list changes, otherwise
|
|
187
|
+
* rendering gets broken (see: https://github.com/inokawa/virtua/issues/284).
|
|
188
|
+
*
|
|
189
|
+
* Virtua also requires `shift` to be correct on the same render pass when items are updated — so we can't
|
|
190
|
+
* just use `useEffect` and `useState` to monitor items and update `shift` since those will update _after_ the
|
|
191
|
+
* render pass. Instead, we use refs to check if the underlying data has changed on each render pass, and
|
|
192
|
+
* update a `shift` ref in the same pass.
|
|
193
|
+
*
|
|
194
|
+
* That's all encapsulated in this handy hook, to keep the logic out of the component.
|
|
195
|
+
*/
|
|
196
|
+
const useShift = (listData, idKey) => {
|
|
197
|
+
var _a, _b, _c;
|
|
198
|
+
const previousListData = (0, react_2.useRef)();
|
|
199
|
+
const shouldShift = (0, react_2.useRef)();
|
|
200
|
+
if (listData !== previousListData.current) {
|
|
201
|
+
if (((_a = listData === null || listData === void 0 ? void 0 : listData[0]) === null || _a === void 0 ? void 0 : _a[idKey]) !== ((_c = (_b = previousListData.current) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c[idKey])) {
|
|
202
|
+
shouldShift.current = true;
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
shouldShift.current = false;
|
|
206
|
+
}
|
|
207
|
+
previousListData.current = listData;
|
|
208
|
+
}
|
|
209
|
+
return shouldShift.current;
|
|
210
|
+
};
|
|
211
|
+
exports.ListNative = (0, react_2.forwardRef)(function DynamicHeightList({ items = constants_1.EMPTY_ARRAY, itemRenderer = defaultItemRenderer, sectionRenderer, sectionFooterRenderer, loading, limit, groupBy, orderBy, availableGroups, scrollAnchor = "top", requestFetchPrevPage = lodash_es_1.noop, requestFetchNextPage = lodash_es_1.noop, pageInfo, idKey = "id", style, emptyListPlaceholder, groupsInitiallyExpanded = true, defaultGroups = constants_1.EMPTY_ARRAY, registerComponentApi, borderCollapse = true, }, ref) {
|
|
176
212
|
var _a;
|
|
177
|
-
const virtualizerRef = (0,
|
|
178
|
-
const scrollRef = (0,
|
|
179
|
-
const parentRef = (0,
|
|
213
|
+
const virtualizerRef = (0, react_2.useRef)(null);
|
|
214
|
+
const scrollRef = (0, react_2.useContext)(ScrollContext_1.ScrollContext);
|
|
215
|
+
const parentRef = (0, react_2.useRef)(null);
|
|
180
216
|
const rootRef = ref ? (0, react_compose_refs_1.composeRefs)(parentRef, ref) : parentRef;
|
|
181
217
|
const hasOutsideScroll = scrollRef &&
|
|
182
218
|
(style === null || style === void 0 ? void 0 : style.maxHeight) === undefined &&
|
|
183
219
|
(style === null || style === void 0 ? void 0 : style.height) === undefined &&
|
|
184
220
|
(style === null || style === void 0 ? void 0 : style.flex) === undefined;
|
|
185
221
|
const scrollElementRef = hasOutsideScroll ? scrollRef : parentRef;
|
|
186
|
-
const
|
|
187
|
-
const
|
|
222
|
+
const shouldStickToBottom = (0, react_2.useRef)(scrollAnchor === "bottom");
|
|
223
|
+
const [expanded, setExpanded] = (0, react_2.useState)(constants_1.EMPTY_OBJECT);
|
|
224
|
+
const toggleExpanded = (0, react_2.useCallback)((id, isExpanded) => {
|
|
188
225
|
setExpanded((prev) => (Object.assign(Object.assign({}, prev), { [id]: isExpanded })));
|
|
189
226
|
}, []);
|
|
190
|
-
const expandContextValue = (0,
|
|
227
|
+
const expandContextValue = (0, react_2.useMemo)(() => {
|
|
191
228
|
return {
|
|
192
229
|
isExpanded: (id) => expanded[id] || (expanded[id] === undefined && groupsInitiallyExpanded),
|
|
193
230
|
toggleExpanded,
|
|
@@ -203,96 +240,150 @@ exports.ListNative = (0, react_1.forwardRef)(function DynamicHeightList({ items
|
|
|
203
240
|
orderBy,
|
|
204
241
|
availableGroups,
|
|
205
242
|
});
|
|
206
|
-
const
|
|
207
|
-
const
|
|
208
|
-
(0,
|
|
209
|
-
if ((prevRows === null || prevRows === void 0 ? void 0 : prevRows.length) < rows.length) {
|
|
210
|
-
isPrepend.current = false;
|
|
211
|
-
}
|
|
212
|
-
}, [rows.length, prevRows === null || prevRows === void 0 ? void 0 : prevRows.length]);
|
|
213
|
-
const initiallyScrolledToBottom = (0, react_1.useRef)(false);
|
|
214
|
-
(0, react_1.useEffect)(() => {
|
|
215
|
-
var _a;
|
|
243
|
+
const shift = useShift(rows, idKey);
|
|
244
|
+
const initiallyScrolledToBottom = (0, react_2.useRef)(false);
|
|
245
|
+
(0, react_2.useEffect)(() => {
|
|
216
246
|
if (rows.length && scrollAnchor === "bottom" && !initiallyScrolledToBottom.current) {
|
|
217
247
|
initiallyScrolledToBottom.current = true;
|
|
218
|
-
(
|
|
248
|
+
requestAnimationFrame(() => {
|
|
249
|
+
var _a;
|
|
250
|
+
(_a = virtualizerRef.current) === null || _a === void 0 ? void 0 : _a.scrollToIndex(rows.length - 1, {
|
|
251
|
+
align: "end",
|
|
252
|
+
});
|
|
253
|
+
});
|
|
219
254
|
}
|
|
220
255
|
}, [rows.length, scrollAnchor]);
|
|
221
|
-
|
|
256
|
+
(0, react_2.useEffect)(() => {
|
|
257
|
+
if (!virtualizerRef.current)
|
|
258
|
+
return;
|
|
259
|
+
if (!shouldStickToBottom.current)
|
|
260
|
+
return;
|
|
261
|
+
requestAnimationFrame(() => {
|
|
262
|
+
var _a;
|
|
263
|
+
(_a = virtualizerRef.current) === null || _a === void 0 ? void 0 : _a.scrollToIndex(rows.length - 1, {
|
|
264
|
+
align: "end",
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
}, [rows]);
|
|
268
|
+
const isFetchingPrevPage = (0, react_2.useRef)(false);
|
|
269
|
+
const tryToFetchPrevPage = (0, react_2.useCallback)(() => {
|
|
222
270
|
if (virtualizerRef.current &&
|
|
223
271
|
virtualizerRef.current.findStartIndex() < 10 &&
|
|
224
272
|
pageInfo &&
|
|
225
273
|
pageInfo.hasPrevPage &&
|
|
226
|
-
!pageInfo.isFetchingPrevPage
|
|
227
|
-
|
|
228
|
-
|
|
274
|
+
!pageInfo.isFetchingPrevPage &&
|
|
275
|
+
!isFetchingPrevPage.current) {
|
|
276
|
+
isFetchingPrevPage.current = true;
|
|
277
|
+
(function doFetch() {
|
|
278
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
279
|
+
try {
|
|
280
|
+
yield requestFetchPrevPage();
|
|
281
|
+
}
|
|
282
|
+
finally {
|
|
283
|
+
isFetchingPrevPage.current = false;
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
})();
|
|
229
287
|
}
|
|
230
288
|
}, [pageInfo, requestFetchPrevPage]);
|
|
231
|
-
const
|
|
289
|
+
const isFetchingNextPage = (0, react_2.useRef)(false);
|
|
290
|
+
const tryToFetchNextPage = (0, react_2.useCallback)(() => {
|
|
232
291
|
if (virtualizerRef.current &&
|
|
233
292
|
virtualizerRef.current.findEndIndex() + 10 > rows.length &&
|
|
234
293
|
pageInfo &&
|
|
235
294
|
pageInfo.hasNextPage &&
|
|
236
|
-
!pageInfo.isFetchingNextPage
|
|
237
|
-
|
|
295
|
+
!pageInfo.isFetchingNextPage &&
|
|
296
|
+
!isFetchingNextPage.current) {
|
|
297
|
+
isFetchingNextPage.current = true;
|
|
298
|
+
(function doFetch() {
|
|
299
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
300
|
+
try {
|
|
301
|
+
yield requestFetchNextPage();
|
|
302
|
+
}
|
|
303
|
+
finally {
|
|
304
|
+
isFetchingNextPage.current = false;
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
})();
|
|
238
308
|
}
|
|
239
309
|
}, [rows.length, pageInfo, requestFetchNextPage]);
|
|
240
|
-
const initiallyFetchedExtraPages = (0,
|
|
241
|
-
(0,
|
|
310
|
+
const initiallyFetchedExtraPages = (0, react_2.useRef)(false);
|
|
311
|
+
(0, react_2.useEffect)(() => {
|
|
242
312
|
if (rows.length && !initiallyFetchedExtraPages.current) {
|
|
243
313
|
initiallyFetchedExtraPages.current = true;
|
|
244
314
|
tryToFetchPrevPage();
|
|
245
315
|
}
|
|
246
316
|
}, [rows.length, tryToFetchNextPage, tryToFetchPrevPage]);
|
|
247
|
-
const onScroll = (0,
|
|
317
|
+
const onScroll = (0, react_2.useCallback)((offset) => {
|
|
248
318
|
if (!virtualizerRef.current)
|
|
249
319
|
return;
|
|
320
|
+
if (scrollAnchor === "bottom") {
|
|
321
|
+
// The sum may not be 0 because of sub-pixel value when browser's window.devicePixelRatio has decimal value
|
|
322
|
+
shouldStickToBottom.current =
|
|
323
|
+
offset - virtualizerRef.current.scrollSize + virtualizerRef.current.viewportSize >= -1.5;
|
|
324
|
+
}
|
|
250
325
|
tryToFetchPrevPage();
|
|
251
326
|
tryToFetchNextPage();
|
|
252
|
-
}, [tryToFetchNextPage, tryToFetchPrevPage]);
|
|
327
|
+
}, [scrollAnchor, tryToFetchNextPage, tryToFetchPrevPage]);
|
|
253
328
|
const scrollToBottom = (0, misc_1.useEvent)(() => {
|
|
329
|
+
var _a;
|
|
254
330
|
if (rows.length) {
|
|
255
|
-
virtualizerRef.current.scrollToIndex(rows.length - 1
|
|
331
|
+
(_a = virtualizerRef.current) === null || _a === void 0 ? void 0 : _a.scrollToIndex(rows.length - 1, {
|
|
332
|
+
align: "end",
|
|
333
|
+
});
|
|
256
334
|
}
|
|
257
335
|
});
|
|
258
336
|
const scrollToTop = (0, misc_1.useEvent)(() => {
|
|
337
|
+
var _a;
|
|
259
338
|
if (rows.length) {
|
|
260
|
-
virtualizerRef.current.scrollToIndex(0);
|
|
339
|
+
(_a = virtualizerRef.current) === null || _a === void 0 ? void 0 : _a.scrollToIndex(0);
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
const scrollToIndex = (0, misc_1.useEvent)((index) => {
|
|
343
|
+
var _a;
|
|
344
|
+
(_a = virtualizerRef.current) === null || _a === void 0 ? void 0 : _a.scrollToIndex(index);
|
|
345
|
+
});
|
|
346
|
+
const scrollToId = (0, misc_1.useEvent)((id) => {
|
|
347
|
+
const index = rows === null || rows === void 0 ? void 0 : rows.findIndex((row) => row[idKey] === id);
|
|
348
|
+
if (index >= 0) {
|
|
349
|
+
scrollToIndex(index);
|
|
261
350
|
}
|
|
262
351
|
});
|
|
263
|
-
(0,
|
|
352
|
+
(0, react_2.useLayoutEffect)(() => {
|
|
264
353
|
registerComponentApi === null || registerComponentApi === void 0 ? void 0 : registerComponentApi({
|
|
265
354
|
scrollToBottom,
|
|
266
355
|
scrollToTop,
|
|
356
|
+
scrollToIndex,
|
|
357
|
+
scrollToId
|
|
267
358
|
});
|
|
268
|
-
}, [registerComponentApi, scrollToBottom, scrollToTop]);
|
|
269
|
-
const rowTypeContextValue = (0,
|
|
359
|
+
}, [registerComponentApi, scrollToBottom, scrollToId, scrollToIndex, scrollToTop]);
|
|
360
|
+
const rowTypeContextValue = (0, react_2.useCallback)((index) => rows[index]._row_type, [rows]);
|
|
270
361
|
return ((0, jsx_runtime_1.jsx)(ListItemTypeContext.Provider, { value: rowTypeContextValue, children: (0, jsx_runtime_1.jsx)(exports.ListContext.Provider, { value: expandContextValue, children: (0, jsx_runtime_1.jsxs)("div", { ref: rootRef, style: style, className: (0, classnames_1.default)(List_module_scss_1.default.outerWrapper, {
|
|
271
362
|
[List_module_scss_1.default.hasOutsideScroll]: hasOutsideScroll,
|
|
272
363
|
}), children: [loading && rows.length === 0 && ((0, jsx_runtime_1.jsx)("div", { className: List_module_scss_1.default.loadingWrapper, children: (0, jsx_runtime_1.jsx)(SpinnerNative_1.Spinner, {}) })), !loading &&
|
|
273
364
|
rows.length === 0 &&
|
|
274
|
-
(emptyListPlaceholder !== null && emptyListPlaceholder !== void 0 ? emptyListPlaceholder : ((0, jsx_runtime_1.jsx)("div", { className: List_module_scss_1.default.noRows, children: (0, jsx_runtime_1.jsx)(TextNative_1.Text, { children: "No data available" }) }))),
|
|
365
|
+
(emptyListPlaceholder !== null && emptyListPlaceholder !== void 0 ? emptyListPlaceholder : ((0, jsx_runtime_1.jsx)("div", { className: List_module_scss_1.default.noRows, children: (0, jsx_runtime_1.jsx)(TextNative_1.Text, { children: "No data available" }) }))), rows.length > 0 && ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(List_module_scss_1.default.innerWrapper, {
|
|
275
366
|
[List_module_scss_1.default.reverse]: scrollAnchor === "bottom",
|
|
276
367
|
[List_module_scss_1.default.borderCollapse]: borderCollapse,
|
|
277
368
|
[List_module_scss_1.default.sectioned]: groupBy !== undefined,
|
|
278
|
-
}), "data-list-container": true, children: (0, jsx_runtime_1.jsx)(virtua_1.Virtualizer, { ref: virtualizerRef, scrollRef: scrollElementRef, shift:
|
|
369
|
+
}), "data-list-container": true, children: (0, jsx_runtime_1.jsx)(virtua_1.Virtualizer, { ref: virtualizerRef, scrollRef: scrollElementRef, shift: shift, onScroll: onScroll, startMargin: !hasOutsideScroll ? 0 : ((_a = parentRef.current) === null || _a === void 0 ? void 0 : _a.offsetTop) || 0, item: Item, children: rows.map((row) => {
|
|
279
370
|
const key = row[idKey];
|
|
280
371
|
switch (row._row_type) {
|
|
281
372
|
case RowType.SECTION:
|
|
282
|
-
return (sectionRenderer === null || sectionRenderer === void 0 ? void 0 : sectionRenderer(row, key)) || (0, jsx_runtime_1.jsx)("div", {}, key);
|
|
373
|
+
return (0, jsx_runtime_1.jsx)(react_1.Fragment, { children: (sectionRenderer === null || sectionRenderer === void 0 ? void 0 : sectionRenderer(row, key)) || (0, jsx_runtime_1.jsx)("div", {}) }, key);
|
|
283
374
|
case RowType.SECTION_FOOTER:
|
|
284
|
-
return (sectionFooterRenderer === null || sectionFooterRenderer === void 0 ? void 0 : sectionFooterRenderer(row, key)) || (0, jsx_runtime_1.jsx)("div", {}, key);
|
|
375
|
+
return (0, jsx_runtime_1.jsx)(react_1.Fragment, { children: (sectionFooterRenderer === null || sectionFooterRenderer === void 0 ? void 0 : sectionFooterRenderer(row, key)) || (0, jsx_runtime_1.jsx)("div", {}) }, key);
|
|
285
376
|
default:
|
|
286
|
-
return itemRenderer(row, key) || (0, jsx_runtime_1.jsx)("div", {}, key);
|
|
377
|
+
return (0, jsx_runtime_1.jsx)(react_1.Fragment, { children: itemRenderer(row, key) || (0, jsx_runtime_1.jsx)("div", {}) }, key);
|
|
287
378
|
}
|
|
288
379
|
}) }) }))] }) }) }));
|
|
289
380
|
});
|
|
290
381
|
// --- Helper function for List item rendering
|
|
291
382
|
function MemoizedSection({ node, renderChild, item, }) {
|
|
292
|
-
const { isExpanded, toggleExpanded } = (0,
|
|
383
|
+
const { isExpanded, toggleExpanded } = (0, react_2.useContext)(exports.ListContext);
|
|
293
384
|
const id = item.id;
|
|
294
385
|
const expanded = isExpanded(id);
|
|
295
|
-
const sectionContext = (0,
|
|
386
|
+
const sectionContext = (0, react_2.useMemo)(() => {
|
|
296
387
|
return {
|
|
297
388
|
isExpanded: expanded,
|
|
298
389
|
toggle: () => {
|
|
@@ -13,7 +13,7 @@ const metadata_helpers_1 = require("../metadata-helpers");
|
|
|
13
13
|
const SliderNative_1 = require("./SliderNative");
|
|
14
14
|
const COMP = "Slider";
|
|
15
15
|
exports.SliderMd = (0, ComponentDefs_1.createMetadata)({
|
|
16
|
-
status: "
|
|
16
|
+
status: "experimental",
|
|
17
17
|
description: `The \`${COMP}\` component allows you to select a numeric value ` +
|
|
18
18
|
`between a range specified by minimum and maximum values.`,
|
|
19
19
|
props: {
|
|
@@ -19,6 +19,8 @@ exports.TableOfContentsMd = (0, ComponentDefs_1.createMetadata)({
|
|
|
19
19
|
props: {
|
|
20
20
|
smoothScrolling: (0, ComponentDefs_1.d)(`This property indicates that smooth scrolling is used while scrolling the selected table ` +
|
|
21
21
|
`of contents items into view.`),
|
|
22
|
+
maxHeadingLevel: (0, ComponentDefs_1.d)("Defines the maximum heading level to include in the table of contents. Headings " +
|
|
23
|
+
"with a level greater than this value will be excluded."),
|
|
22
24
|
},
|
|
23
25
|
themeVars: (0, themeVars_1.parseScssVar)(TableOfContents_module_scss_1.default.themeVars),
|
|
24
26
|
defaultThemeVars: {
|
|
@@ -69,6 +71,6 @@ exports.TableOfContentsMd = (0, ComponentDefs_1.createMetadata)({
|
|
|
69
71
|
},
|
|
70
72
|
});
|
|
71
73
|
exports.tableOfContentsRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.TableOfContentsMd, ({ layoutCss, node, extractValue }) => {
|
|
72
|
-
var _a;
|
|
73
|
-
return ((0, jsx_runtime_1.jsx)(TableOfContentsNative_1.TableOfContents, { style: layoutCss, smoothScrolling: extractValue.asOptionalBoolean((_a = node.props) === null || _a === void 0 ? void 0 : _a.smoothScrolling) }));
|
|
74
|
+
var _a, _b;
|
|
75
|
+
return ((0, jsx_runtime_1.jsx)(TableOfContentsNative_1.TableOfContents, { style: layoutCss, smoothScrolling: extractValue.asOptionalBoolean((_a = node.props) === null || _a === void 0 ? void 0 : _a.smoothScrolling), maxHeadingLevel: extractValue.asOptionalNumber((_b = node.props) === null || _b === void 0 ? void 0 : _b.maxHeadingLevel) }));
|
|
74
76
|
});
|
|
@@ -12,7 +12,7 @@ const react_compose_refs_1 = require("@radix-ui/react-compose-refs");
|
|
|
12
12
|
const classnames_1 = __importDefault(require("classnames"));
|
|
13
13
|
const TableOfContents_module_scss_1 = __importDefault(require("./TableOfContents.module.scss"));
|
|
14
14
|
const TableOfContentsContext_1 = require("../../components-core/TableOfContentsContext");
|
|
15
|
-
exports.TableOfContents = (0, react_1.forwardRef)(function TableOfContents({ style, smoothScrolling }, forwardedRef) {
|
|
15
|
+
exports.TableOfContents = (0, react_1.forwardRef)(function TableOfContents({ style, smoothScrolling, maxHeadingLevel = 6 }, forwardedRef) {
|
|
16
16
|
const tocRef = (0, react_1.useRef)(null);
|
|
17
17
|
const { headings, setObserveIntersection, activeAnchorId, setActiveAnchorId } = (0, TableOfContentsContext_1.useTableOfContents)();
|
|
18
18
|
const ref = forwardedRef ? (0, react_compose_refs_1.composeRefs)(tocRef, forwardedRef) : tocRef;
|
|
@@ -33,24 +33,29 @@ exports.TableOfContents = (0, react_1.forwardRef)(function TableOfContents({ sty
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}, [activeAnchorId, headings]);
|
|
36
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: TableOfContents_module_scss_1.default.nav, ref: ref, style: style, children: (0, jsx_runtime_1.jsx)("ul", { className: TableOfContents_module_scss_1.default.list, children: headings.map((value) =>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
36
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: TableOfContents_module_scss_1.default.nav, ref: ref, style: style, children: (0, jsx_runtime_1.jsx)("ul", { className: TableOfContents_module_scss_1.default.list, children: headings.map((value) => {
|
|
37
|
+
if (value.level <= maxHeadingLevel) {
|
|
38
|
+
return ((0, jsx_runtime_1.jsx)("li", { className: (0, classnames_1.default)(TableOfContents_module_scss_1.default.listItem, {
|
|
39
|
+
[TableOfContents_module_scss_1.default.active]: value.id === activeAnchorId,
|
|
40
|
+
}), children: (0, jsx_runtime_1.jsx)(react_2.NavLink, { className: (0, classnames_1.default)(TableOfContents_module_scss_1.default.link, {
|
|
41
|
+
[TableOfContents_module_scss_1.default.head_1]: value.level === 1,
|
|
42
|
+
[TableOfContents_module_scss_1.default.head_2]: value.level === 2,
|
|
43
|
+
[TableOfContents_module_scss_1.default.head_3]: value.level === 3,
|
|
44
|
+
[TableOfContents_module_scss_1.default.head_4]: value.level === 4,
|
|
45
|
+
[TableOfContents_module_scss_1.default.head_5]: value.level === 5,
|
|
46
|
+
[TableOfContents_module_scss_1.default.head_6]: value.level === 6,
|
|
47
|
+
}), to: `#${value.id}`, onClick: () => {
|
|
48
|
+
if (smoothScrolling) {
|
|
49
|
+
(0, scroll_into_view_if_needed_1.default)(value.anchor, {
|
|
50
|
+
block: "start",
|
|
51
|
+
inline: "start",
|
|
52
|
+
behavior: "smooth",
|
|
53
|
+
scrollMode: "if-needed",
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
setActiveAnchorId(value.id);
|
|
57
|
+
}, id: value.id, children: value.text }) }, value.id));
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}) }) }));
|
|
56
61
|
});
|
|
@@ -115,6 +115,7 @@ exports.TextMd = (0, ComponentDefs_1.createMetadata)({
|
|
|
115
115
|
},
|
|
116
116
|
});
|
|
117
117
|
exports.textComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.TextMd, ({ node, extractValue, layoutCss, renderChild }) => {
|
|
118
|
+
// TEMP: Need to use the resolveAndCleanProps function here and handle VariantTypes correctly
|
|
118
119
|
const _a = node.props, { variant, maxLines, preserveLinebreaks, ellipses, value } = _a, variantSpecific = __rest(_a, ["variant", "maxLines", "preserveLinebreaks", "ellipses", "value"]);
|
|
119
120
|
const variantSpecificProps = Object.fromEntries(Object.entries(variantSpecific)
|
|
120
121
|
.filter(([key, _]) => abstractions_1.VariantPropsKeys.includes(key))
|
|
@@ -30,6 +30,9 @@ function LoaderComponent({ node, state, dispatch, lookupAction, lookupSyncCallba
|
|
|
30
30
|
}, [appContext, memoedVarsRef, referenceTrackedApi, state]);
|
|
31
31
|
// --- Memoizes the action resolution by action definition value
|
|
32
32
|
const memoedLookupSyncCallback = (0, react_1.useCallback)((action) => {
|
|
33
|
+
if (!action) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
33
36
|
return lookupSyncCallback(valueExtractor(action), uid);
|
|
34
37
|
}, [lookupSyncCallback, uid, valueExtractor]);
|
|
35
38
|
const memoedLoaderInProgressChanged = (0, react_1.useCallback)((isInProgress) => {
|
|
@@ -104,7 +104,17 @@ function TableOfContentsProvider({ children }) {
|
|
|
104
104
|
function useTableOfContents() {
|
|
105
105
|
const context = (0, react_1.useContext)(exports.TableOfContentsContext);
|
|
106
106
|
if (!context) {
|
|
107
|
-
throw new Error(
|
|
107
|
+
throw new Error(`The TableOfContents component can only be used inside a Page component.
|
|
108
|
+
<App>
|
|
109
|
+
<Pages>
|
|
110
|
+
<Page url="/">
|
|
111
|
+
<Heading>Harry Potter and the Sorcerer's Stone</Heading>
|
|
112
|
+
<TableOfContents />
|
|
113
|
+
</Page>
|
|
114
|
+
</Pages>
|
|
115
|
+
</App>
|
|
116
|
+
|
|
117
|
+
`);
|
|
108
118
|
}
|
|
109
119
|
return context;
|
|
110
120
|
}
|
|
@@ -124,20 +124,20 @@ function updateQueriesWithResult(queryKeysToUpdate, optimisticValuesByQueryKeys,
|
|
|
124
124
|
//pageable loader
|
|
125
125
|
if (optimisticValue) {
|
|
126
126
|
draft.pages[draft.pages.length - 1] = draft.pages[draft.pages.length - 1].map((item) => item.id === optimisticValue.id && item._initiatorClientTxId === clientTxId
|
|
127
|
-
? result
|
|
127
|
+
? result || Object.assign(Object.assign({}, item), { _optimisticValue: undefined, _initiatorClientTxId: undefined })
|
|
128
128
|
: item);
|
|
129
129
|
}
|
|
130
130
|
else {
|
|
131
131
|
let updated = false;
|
|
132
132
|
draft.pages.forEach((page) => {
|
|
133
133
|
page === null || page === void 0 ? void 0 : page.forEach((item) => {
|
|
134
|
-
if (item.id === result.id) {
|
|
134
|
+
if (item.id === (result === null || result === void 0 ? void 0 : result.id)) {
|
|
135
135
|
Object.assign(item, result);
|
|
136
136
|
updated = true;
|
|
137
137
|
}
|
|
138
138
|
});
|
|
139
139
|
});
|
|
140
|
-
if (!updated) {
|
|
140
|
+
if (!updated && result) {
|
|
141
141
|
draft.pages[draft.pages.length - 1].push(result);
|
|
142
142
|
}
|
|
143
143
|
}
|
|
@@ -146,7 +146,7 @@ function updateQueriesWithResult(queryKeysToUpdate, optimisticValuesByQueryKeys,
|
|
|
146
146
|
if (optimisticValue) {
|
|
147
147
|
draft.forEach((item, index) => {
|
|
148
148
|
if (item.id === optimisticValue.id && item._initiatorClientTxId === clientTxId) {
|
|
149
|
-
draft[index] = result;
|
|
149
|
+
draft[index] = result || Object.assign(Object.assign({}, item), { _optimisticValue: undefined, _initiatorClientTxId: undefined });
|
|
150
150
|
}
|
|
151
151
|
});
|
|
152
152
|
}
|
|
@@ -154,11 +154,11 @@ function updateQueriesWithResult(queryKeysToUpdate, optimisticValuesByQueryKeys,
|
|
|
154
154
|
let updated = false;
|
|
155
155
|
draft.forEach((item, index) => {
|
|
156
156
|
if (item.id === result.id) {
|
|
157
|
-
draft[index] = result;
|
|
157
|
+
draft[index] = result || Object.assign(Object.assign({}, item), { _optimisticValue: undefined, _initiatorClientTxId: undefined });
|
|
158
158
|
updated = true;
|
|
159
159
|
}
|
|
160
160
|
});
|
|
161
|
-
if (!updated) {
|
|
161
|
+
if (!updated && result) {
|
|
162
162
|
draft.push(result);
|
|
163
163
|
}
|
|
164
164
|
}
|
|
@@ -58,7 +58,7 @@ function PageableLoader({ state, loader, loaderFn, queryId, registerComponentApi
|
|
|
58
58
|
let prevPageParam = undefined;
|
|
59
59
|
const prevPageSelector = loader.props.prevPageSelector;
|
|
60
60
|
if (prevPageSelector) {
|
|
61
|
-
prevPageParam = (0, extractParam_1.extractParam)({ $response: firstPage }, prevPageSelector.startsWith("{") ? prevPageSelector : `{$response.${prevPageSelector}}`);
|
|
61
|
+
prevPageParam = (0, extractParam_1.extractParam)({ $response: firstPage.filter(item => !item._optimisticValue) }, prevPageSelector.startsWith("{") ? prevPageSelector : `{$response.${prevPageSelector}}`);
|
|
62
62
|
}
|
|
63
63
|
if (!prevPageParam) {
|
|
64
64
|
return undefined;
|
|
@@ -80,6 +80,9 @@ function PageableLoader({ state, loader, loaderFn, queryId, registerComponentApi
|
|
|
80
80
|
nextPageParam: nextPageParam,
|
|
81
81
|
};
|
|
82
82
|
}, [loader.props.nextPageSelector]);
|
|
83
|
+
// useEffect(()=>{
|
|
84
|
+
// console.log("TRANSFORM RESULT CHANGED", transformResult);
|
|
85
|
+
// }, [transformResult]);
|
|
83
86
|
const { data, status, error, hasNextPage, isFetchingNextPage, hasPreviousPage, isFetchingPreviousPage, isFetching, refetch, fetchPreviousPage, fetchNextPage, } = (0, react_query_1.useInfiniteQuery)({
|
|
84
87
|
queryKey,
|
|
85
88
|
queryFn: (0, react_1.useCallback)((_a) => __awaiter(this, [_a], void 0, function* ({ signal, pageParam }) {
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.extractParam = extractParam;
|
|
7
7
|
exports.withStableObjectReference = withStableObjectReference;
|
|
8
8
|
exports.shouldKeep = shouldKeep;
|
|
9
|
+
exports.resolveAndCleanProps = resolveAndCleanProps;
|
|
9
10
|
const react_1 = __importDefault(require("react"));
|
|
10
11
|
const lodash_es_1 = require("lodash-es");
|
|
11
12
|
const ParameterParser_1 = require("../script-runner/ParameterParser");
|
|
@@ -146,3 +147,46 @@ function shouldKeep(when, componentState, appContext) {
|
|
|
146
147
|
}
|
|
147
148
|
return extractParam(componentState, when, appContext, true);
|
|
148
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Resolves props that can either be regular properties or URL resources.
|
|
152
|
+
* It also removes layoutCss props from regular properties.
|
|
153
|
+
* @param props Component (rest) props
|
|
154
|
+
* @param extractValue Value extractor function
|
|
155
|
+
* @param layoutCss Component styles
|
|
156
|
+
* @param resourceExtraction URL resource extractor function and array that specifies which props are URL resources
|
|
157
|
+
* @returns properties that are resolved and cleaned of CSS styles
|
|
158
|
+
*/
|
|
159
|
+
function resolveAndCleanProps(props, extractValue, layoutCss = {}, resourceExtraction) {
|
|
160
|
+
const { extractResourceUrl, resourceProps } = resourceExtraction !== null && resourceExtraction !== void 0 ? resourceExtraction : {};
|
|
161
|
+
const cleanedProps = cleanStyles(props, layoutCss);
|
|
162
|
+
const resultProps = {};
|
|
163
|
+
const result = Object.keys(cleanedProps).reduce((acc, propName) => {
|
|
164
|
+
if (resourceProps && extractResourceUrl && resourceProps.includes(propName)) {
|
|
165
|
+
acc[propName] = extractResourceUrl(cleanedProps[propName]);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
acc[propName] = extractValue(cleanedProps[propName]);
|
|
169
|
+
}
|
|
170
|
+
return acc;
|
|
171
|
+
}, resultProps);
|
|
172
|
+
return result;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Removes unnecessary style related properties so only layoutCss contains them.
|
|
176
|
+
* @param nodeProps properties to clean
|
|
177
|
+
* @param layoutCss which style properties to remove
|
|
178
|
+
* @returns only component-specific properties
|
|
179
|
+
*/
|
|
180
|
+
function cleanStyles(nodeProps, layoutCss = {}) {
|
|
181
|
+
if (nodeProps.hasOwnProperty("style")) {
|
|
182
|
+
delete nodeProps["style"];
|
|
183
|
+
}
|
|
184
|
+
if (nodeProps.hasOwnProperty("class")) {
|
|
185
|
+
delete nodeProps["class"];
|
|
186
|
+
}
|
|
187
|
+
return removeEntries(nodeProps, layoutCss);
|
|
188
|
+
function removeEntries(sourceObj, filterObj) {
|
|
189
|
+
const filterKeys = Object.keys(filterObj);
|
|
190
|
+
return Object.fromEntries(Object.entries(sourceObj).filter(([key]) => !filterKeys.includes(key)));
|
|
191
|
+
}
|
|
192
|
+
}
|