@revisium/schema-toolkit-ui 0.6.12 → 0.6.14
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/index.cjs +222 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +49 -31
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +49 -31
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +223 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -9535,6 +9535,14 @@ var SortModel = class {
|
|
|
9535
9535
|
direction: sort.direction
|
|
9536
9536
|
}));
|
|
9537
9537
|
}
|
|
9538
|
+
serializeToQuerySorts() {
|
|
9539
|
+
const lookup = this._fieldLookup;
|
|
9540
|
+
return this.sorts.map((sort) => ({
|
|
9541
|
+
field: stripDataFieldPrefix(sort.field),
|
|
9542
|
+
direction: sort.direction,
|
|
9543
|
+
type: lookup.get(sort.field)?.fieldType ?? "String"
|
|
9544
|
+
}));
|
|
9545
|
+
}
|
|
9538
9546
|
applyViewSorts(viewSorts) {
|
|
9539
9547
|
const lookup = this._fieldLookup;
|
|
9540
9548
|
const sorts = [];
|
|
@@ -9864,7 +9872,7 @@ const SortingsWidget = (0, mobx_react_lite.observer)(({ model, availableFields,
|
|
|
9864
9872
|
children: "Clear all"
|
|
9865
9873
|
}),
|
|
9866
9874
|
model.hasSorts && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyJsonPopover, {
|
|
9867
|
-
data: model.
|
|
9875
|
+
data: model.serializeToQuerySorts(),
|
|
9868
9876
|
tooltipContent: "Copy sort JSON",
|
|
9869
9877
|
testId: "sort-copy-json"
|
|
9870
9878
|
}),
|
|
@@ -13996,10 +14004,7 @@ var TableEditorCore = class {
|
|
|
13996
14004
|
_buildQuery(after = null) {
|
|
13997
14005
|
return {
|
|
13998
14006
|
where: this.filters.hasActiveFilters ? this.filters.buildCurrentWhereClause() : null,
|
|
13999
|
-
orderBy: this.sorts.
|
|
14000
|
-
field: stripDataFieldPrefix(s.field),
|
|
14001
|
-
direction: s.direction
|
|
14002
|
-
})),
|
|
14007
|
+
orderBy: this.sorts.serializeToQuerySorts(),
|
|
14003
14008
|
search: this.search.debouncedQuery,
|
|
14004
14009
|
first: this._pageSize,
|
|
14005
14010
|
after
|
|
@@ -14012,9 +14017,10 @@ var TableEditorCore = class {
|
|
|
14012
14017
|
this._replaceRowVMs(result.rows);
|
|
14013
14018
|
this._endCursor = result.endCursor;
|
|
14014
14019
|
this._hasNextPage = result.hasNextPage;
|
|
14020
|
+
const isFiltering = this.filters.hasActiveFilters || this.search.hasActiveSearch;
|
|
14015
14021
|
this.rowCount.setTotalCount(result.totalCount);
|
|
14016
|
-
this.rowCount.setBaseTotalCount(result.totalCount);
|
|
14017
|
-
this.rowCount.setIsFiltering(
|
|
14022
|
+
if (!isFiltering) this.rowCount.setBaseTotalCount(result.totalCount);
|
|
14023
|
+
this.rowCount.setIsFiltering(isFiltering);
|
|
14018
14024
|
this._updateNavigationContext();
|
|
14019
14025
|
});
|
|
14020
14026
|
}
|
|
@@ -14233,6 +14239,45 @@ var MockDataSource = class {
|
|
|
14233
14239
|
}
|
|
14234
14240
|
};
|
|
14235
14241
|
|
|
14242
|
+
//#endregion
|
|
14243
|
+
//#region src/hooks/useDelayedVisibility.ts
|
|
14244
|
+
/**
|
|
14245
|
+
* Controls visibility with a show delay and minimum display time.
|
|
14246
|
+
*
|
|
14247
|
+
* - If `active` becomes false before `delayMs` elapses → never shown.
|
|
14248
|
+
* - If shown, stays visible for at least `minShowMs` after `active` becomes false.
|
|
14249
|
+
*/
|
|
14250
|
+
function useDelayedVisibility(active, { delayMs = 150, minShowMs = 300 } = {}) {
|
|
14251
|
+
const [visible, setVisible] = (0, react.useState)(false);
|
|
14252
|
+
const shownAt = (0, react.useRef)(null);
|
|
14253
|
+
(0, react.useEffect)(() => {
|
|
14254
|
+
if (active) {
|
|
14255
|
+
const timer = setTimeout(() => {
|
|
14256
|
+
shownAt.current = Date.now();
|
|
14257
|
+
setVisible(true);
|
|
14258
|
+
}, delayMs);
|
|
14259
|
+
return () => clearTimeout(timer);
|
|
14260
|
+
}
|
|
14261
|
+
if (shownAt.current !== null) {
|
|
14262
|
+
const remaining = minShowMs - (Date.now() - shownAt.current);
|
|
14263
|
+
if (remaining > 0) {
|
|
14264
|
+
const timer = setTimeout(() => {
|
|
14265
|
+
shownAt.current = null;
|
|
14266
|
+
setVisible(false);
|
|
14267
|
+
}, remaining);
|
|
14268
|
+
return () => clearTimeout(timer);
|
|
14269
|
+
}
|
|
14270
|
+
shownAt.current = null;
|
|
14271
|
+
}
|
|
14272
|
+
setVisible(false);
|
|
14273
|
+
}, [
|
|
14274
|
+
active,
|
|
14275
|
+
delayMs,
|
|
14276
|
+
minShowMs
|
|
14277
|
+
]);
|
|
14278
|
+
return visible;
|
|
14279
|
+
}
|
|
14280
|
+
|
|
14236
14281
|
//#endregion
|
|
14237
14282
|
//#region src/table-editor/Status/ui/CellInfoWidget.tsx
|
|
14238
14283
|
const CellInfoWidget = (0, mobx_react_lite.observer)(({ model }) => {
|
|
@@ -14375,17 +14420,178 @@ const ViewSettingsBadge = (0, mobx_react_lite.observer)(({ model }) => {
|
|
|
14375
14420
|
});
|
|
14376
14421
|
});
|
|
14377
14422
|
|
|
14423
|
+
//#endregion
|
|
14424
|
+
//#region src/table-editor/TableEditor/ui/TableEditorSkeleton.tsx
|
|
14425
|
+
const HEADER_ROW_HEIGHT = 40;
|
|
14426
|
+
const DATA_ROW_HEIGHT = 40;
|
|
14427
|
+
const SKELETON_ROW_COUNT = 8;
|
|
14428
|
+
const COLUMN_WIDTHS = [
|
|
14429
|
+
120,
|
|
14430
|
+
150,
|
|
14431
|
+
120,
|
|
14432
|
+
100,
|
|
14433
|
+
130
|
|
14434
|
+
];
|
|
14435
|
+
const CONTENT_WIDTHS = [
|
|
14436
|
+
[
|
|
14437
|
+
80,
|
|
14438
|
+
110,
|
|
14439
|
+
70,
|
|
14440
|
+
60,
|
|
14441
|
+
90
|
|
14442
|
+
],
|
|
14443
|
+
[
|
|
14444
|
+
100,
|
|
14445
|
+
90,
|
|
14446
|
+
100,
|
|
14447
|
+
80,
|
|
14448
|
+
110
|
|
14449
|
+
],
|
|
14450
|
+
[
|
|
14451
|
+
60,
|
|
14452
|
+
130,
|
|
14453
|
+
80,
|
|
14454
|
+
70,
|
|
14455
|
+
80
|
|
14456
|
+
],
|
|
14457
|
+
[
|
|
14458
|
+
90,
|
|
14459
|
+
100,
|
|
14460
|
+
60,
|
|
14461
|
+
90,
|
|
14462
|
+
100
|
|
14463
|
+
],
|
|
14464
|
+
[
|
|
14465
|
+
75,
|
|
14466
|
+
120,
|
|
14467
|
+
90,
|
|
14468
|
+
55,
|
|
14469
|
+
70
|
|
14470
|
+
],
|
|
14471
|
+
[
|
|
14472
|
+
110,
|
|
14473
|
+
80,
|
|
14474
|
+
75,
|
|
14475
|
+
80,
|
|
14476
|
+
120
|
|
14477
|
+
],
|
|
14478
|
+
[
|
|
14479
|
+
85,
|
|
14480
|
+
140,
|
|
14481
|
+
95,
|
|
14482
|
+
65,
|
|
14483
|
+
95
|
|
14484
|
+
],
|
|
14485
|
+
[
|
|
14486
|
+
95,
|
|
14487
|
+
70,
|
|
14488
|
+
110,
|
|
14489
|
+
85,
|
|
14490
|
+
80
|
|
14491
|
+
]
|
|
14492
|
+
];
|
|
14493
|
+
const TableEditorSkeleton = ({ breadcrumbs, onBreadcrumbClick, showCreateButton, useWindowScroll }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_chakra_ui_react.Box, {
|
|
14494
|
+
display: "flex",
|
|
14495
|
+
flexDirection: "column",
|
|
14496
|
+
height: useWindowScroll ? void 0 : "100%",
|
|
14497
|
+
flex: useWindowScroll ? 1 : void 0,
|
|
14498
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_chakra_ui_react.Flex, {
|
|
14499
|
+
px: 3,
|
|
14500
|
+
pt: "32px",
|
|
14501
|
+
pb: "48px",
|
|
14502
|
+
alignItems: "flex-start",
|
|
14503
|
+
justifyContent: "space-between",
|
|
14504
|
+
...useWindowScroll && {
|
|
14505
|
+
position: "sticky",
|
|
14506
|
+
top: 0,
|
|
14507
|
+
zIndex: 3,
|
|
14508
|
+
bg: "white"
|
|
14509
|
+
},
|
|
14510
|
+
children: [breadcrumbs.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Breadcrumbs, {
|
|
14511
|
+
segments: breadcrumbs,
|
|
14512
|
+
highlightLast: false,
|
|
14513
|
+
onSegmentClick: onBreadcrumbClick,
|
|
14514
|
+
action: showCreateButton ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Skeleton, {
|
|
14515
|
+
height: "32px",
|
|
14516
|
+
width: "32px",
|
|
14517
|
+
borderRadius: "6px"
|
|
14518
|
+
}) : void 0
|
|
14519
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Box, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_chakra_ui_react.Flex, {
|
|
14520
|
+
alignItems: "center",
|
|
14521
|
+
gap: "8px",
|
|
14522
|
+
children: [
|
|
14523
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Skeleton, {
|
|
14524
|
+
height: "32px",
|
|
14525
|
+
width: "32px",
|
|
14526
|
+
borderRadius: "6px"
|
|
14527
|
+
}),
|
|
14528
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Skeleton, {
|
|
14529
|
+
height: "32px",
|
|
14530
|
+
width: "32px",
|
|
14531
|
+
borderRadius: "6px"
|
|
14532
|
+
}),
|
|
14533
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Skeleton, {
|
|
14534
|
+
height: "32px",
|
|
14535
|
+
width: "32px",
|
|
14536
|
+
borderRadius: "6px"
|
|
14537
|
+
})
|
|
14538
|
+
]
|
|
14539
|
+
})]
|
|
14540
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_chakra_ui_react.Box, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Flex, {
|
|
14541
|
+
height: `${HEADER_ROW_HEIGHT}px`,
|
|
14542
|
+
alignItems: "center",
|
|
14543
|
+
px: 3,
|
|
14544
|
+
borderBottom: "1px solid",
|
|
14545
|
+
borderColor: "gray.100",
|
|
14546
|
+
children: COLUMN_WIDTHS.map((colWidth, j) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Box, {
|
|
14547
|
+
width: `${colWidth}px`,
|
|
14548
|
+
flexShrink: 0,
|
|
14549
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Skeleton, {
|
|
14550
|
+
height: "12px",
|
|
14551
|
+
width: "60px",
|
|
14552
|
+
borderRadius: "4px"
|
|
14553
|
+
})
|
|
14554
|
+
}, `h-${j}`))
|
|
14555
|
+
}), CONTENT_WIDTHS.slice(0, SKELETON_ROW_COUNT).map((contentWidths, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Flex, {
|
|
14556
|
+
height: `${DATA_ROW_HEIGHT}px`,
|
|
14557
|
+
alignItems: "center",
|
|
14558
|
+
px: 3,
|
|
14559
|
+
borderBottom: "1px solid",
|
|
14560
|
+
borderColor: "gray.100",
|
|
14561
|
+
children: COLUMN_WIDTHS.map((colWidth, j) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Box, {
|
|
14562
|
+
width: `${colWidth}px`,
|
|
14563
|
+
flexShrink: 0,
|
|
14564
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Skeleton, {
|
|
14565
|
+
height: "14px",
|
|
14566
|
+
width: `${contentWidths[j]}px`,
|
|
14567
|
+
borderRadius: "4px"
|
|
14568
|
+
})
|
|
14569
|
+
}, `r-${i}-c-${j}`))
|
|
14570
|
+
}, `r-${i}`))] })]
|
|
14571
|
+
});
|
|
14572
|
+
|
|
14378
14573
|
//#endregion
|
|
14379
14574
|
//#region src/table-editor/TableEditor/ui/TableEditor.tsx
|
|
14380
14575
|
const noop = () => {};
|
|
14576
|
+
function getWriteCallbacks(isReadonly, viewModel, callbacks) {
|
|
14577
|
+
return {
|
|
14578
|
+
onDeleteRow: isReadonly ? void 0 : (id) => viewModel.deleteRows([id]),
|
|
14579
|
+
onDuplicateRow: isReadonly ? void 0 : callbacks.onDuplicateRow,
|
|
14580
|
+
onDeleteSelected: isReadonly ? void 0 : (ids) => viewModel.deleteRows(ids),
|
|
14581
|
+
onUploadFile: isReadonly ? void 0 : callbacks.onUploadFile
|
|
14582
|
+
};
|
|
14583
|
+
}
|
|
14381
14584
|
const TableEditor = (0, mobx_react_lite.observer)(({ viewModel, useWindowScroll }) => {
|
|
14382
|
-
|
|
14383
|
-
|
|
14384
|
-
|
|
14385
|
-
|
|
14386
|
-
|
|
14387
|
-
|
|
14388
|
-
|
|
14585
|
+
const showSkeleton = useDelayedVisibility(viewModel.isBootstrapping);
|
|
14586
|
+
if (viewModel.isBootstrapping) {
|
|
14587
|
+
if (!showSkeleton) return null;
|
|
14588
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableEditorSkeleton, {
|
|
14589
|
+
breadcrumbs: viewModel.breadcrumbs,
|
|
14590
|
+
onBreadcrumbClick: viewModel.callbacks.onBreadcrumbClick,
|
|
14591
|
+
showCreateButton: !viewModel.readonly && !!viewModel.callbacks.onCreateRow,
|
|
14592
|
+
useWindowScroll
|
|
14593
|
+
});
|
|
14594
|
+
}
|
|
14389
14595
|
const isReadonly = viewModel.readonly;
|
|
14390
14596
|
const { breadcrumbs, callbacks } = viewModel;
|
|
14391
14597
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_chakra_ui_react.Box, {
|
|
@@ -14446,11 +14652,8 @@ const TableEditor = (0, mobx_react_lite.observer)(({ viewModel, useWindowScroll
|
|
|
14446
14652
|
onEndReached: viewModel.loadMore,
|
|
14447
14653
|
onOpenRow: callbacks.onOpenRow,
|
|
14448
14654
|
onPickRow: callbacks.onPickRow,
|
|
14449
|
-
|
|
14450
|
-
onDuplicateRow: isReadonly ? void 0 : callbacks.onDuplicateRow,
|
|
14451
|
-
onDeleteSelected: isReadonly ? void 0 : (ids) => viewModel.deleteRows(ids),
|
|
14655
|
+
...getWriteCallbacks(isReadonly, viewModel, callbacks),
|
|
14452
14656
|
onSearchForeignKey: callbacks.onSearchForeignKey,
|
|
14453
|
-
onUploadFile: isReadonly ? void 0 : callbacks.onUploadFile,
|
|
14454
14657
|
onOpenFile: callbacks.onOpenFile,
|
|
14455
14658
|
onCopyPath: callbacks.onCopyPath,
|
|
14456
14659
|
useWindowScroll
|
|
@@ -14577,6 +14780,7 @@ exports.operatorRequiresValue = operatorRequiresValue;
|
|
|
14577
14780
|
exports.selectDefaultColumns = selectDefaultColumns;
|
|
14578
14781
|
exports.typeMenuGroups = typeMenuGroups;
|
|
14579
14782
|
exports.useContentEditable = useContentEditable;
|
|
14783
|
+
exports.useDelayedVisibility = useDelayedVisibility;
|
|
14580
14784
|
Object.keys(_revisium_schema_toolkit).forEach(function (k) {
|
|
14581
14785
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
14582
14786
|
enumerable: true,
|