@revisium/schema-toolkit-ui 0.6.12 → 0.6.13

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 CHANGED
@@ -14233,6 +14233,45 @@ var MockDataSource = class {
14233
14233
  }
14234
14234
  };
14235
14235
 
14236
+ //#endregion
14237
+ //#region src/hooks/useDelayedVisibility.ts
14238
+ /**
14239
+ * Controls visibility with a show delay and minimum display time.
14240
+ *
14241
+ * - If `active` becomes false before `delayMs` elapses → never shown.
14242
+ * - If shown, stays visible for at least `minShowMs` after `active` becomes false.
14243
+ */
14244
+ function useDelayedVisibility(active, { delayMs = 150, minShowMs = 300 } = {}) {
14245
+ const [visible, setVisible] = (0, react.useState)(false);
14246
+ const shownAt = (0, react.useRef)(null);
14247
+ (0, react.useEffect)(() => {
14248
+ if (active) {
14249
+ const timer = setTimeout(() => {
14250
+ shownAt.current = Date.now();
14251
+ setVisible(true);
14252
+ }, delayMs);
14253
+ return () => clearTimeout(timer);
14254
+ }
14255
+ if (shownAt.current !== null) {
14256
+ const remaining = minShowMs - (Date.now() - shownAt.current);
14257
+ if (remaining > 0) {
14258
+ const timer = setTimeout(() => {
14259
+ shownAt.current = null;
14260
+ setVisible(false);
14261
+ }, remaining);
14262
+ return () => clearTimeout(timer);
14263
+ }
14264
+ shownAt.current = null;
14265
+ }
14266
+ setVisible(false);
14267
+ }, [
14268
+ active,
14269
+ delayMs,
14270
+ minShowMs
14271
+ ]);
14272
+ return visible;
14273
+ }
14274
+
14236
14275
  //#endregion
14237
14276
  //#region src/table-editor/Status/ui/CellInfoWidget.tsx
14238
14277
  const CellInfoWidget = (0, mobx_react_lite.observer)(({ model }) => {
@@ -14375,17 +14414,178 @@ const ViewSettingsBadge = (0, mobx_react_lite.observer)(({ model }) => {
14375
14414
  });
14376
14415
  });
14377
14416
 
14417
+ //#endregion
14418
+ //#region src/table-editor/TableEditor/ui/TableEditorSkeleton.tsx
14419
+ const HEADER_ROW_HEIGHT = 40;
14420
+ const DATA_ROW_HEIGHT = 40;
14421
+ const SKELETON_ROW_COUNT = 8;
14422
+ const COLUMN_WIDTHS = [
14423
+ 120,
14424
+ 150,
14425
+ 120,
14426
+ 100,
14427
+ 130
14428
+ ];
14429
+ const CONTENT_WIDTHS = [
14430
+ [
14431
+ 80,
14432
+ 110,
14433
+ 70,
14434
+ 60,
14435
+ 90
14436
+ ],
14437
+ [
14438
+ 100,
14439
+ 90,
14440
+ 100,
14441
+ 80,
14442
+ 110
14443
+ ],
14444
+ [
14445
+ 60,
14446
+ 130,
14447
+ 80,
14448
+ 70,
14449
+ 80
14450
+ ],
14451
+ [
14452
+ 90,
14453
+ 100,
14454
+ 60,
14455
+ 90,
14456
+ 100
14457
+ ],
14458
+ [
14459
+ 75,
14460
+ 120,
14461
+ 90,
14462
+ 55,
14463
+ 70
14464
+ ],
14465
+ [
14466
+ 110,
14467
+ 80,
14468
+ 75,
14469
+ 80,
14470
+ 120
14471
+ ],
14472
+ [
14473
+ 85,
14474
+ 140,
14475
+ 95,
14476
+ 65,
14477
+ 95
14478
+ ],
14479
+ [
14480
+ 95,
14481
+ 70,
14482
+ 110,
14483
+ 85,
14484
+ 80
14485
+ ]
14486
+ ];
14487
+ const TableEditorSkeleton = ({ breadcrumbs, onBreadcrumbClick, showCreateButton, useWindowScroll }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_chakra_ui_react.Box, {
14488
+ display: "flex",
14489
+ flexDirection: "column",
14490
+ height: useWindowScroll ? void 0 : "100%",
14491
+ flex: useWindowScroll ? 1 : void 0,
14492
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_chakra_ui_react.Flex, {
14493
+ px: 3,
14494
+ pt: "32px",
14495
+ pb: "48px",
14496
+ alignItems: "flex-start",
14497
+ justifyContent: "space-between",
14498
+ ...useWindowScroll && {
14499
+ position: "sticky",
14500
+ top: 0,
14501
+ zIndex: 3,
14502
+ bg: "white"
14503
+ },
14504
+ children: [breadcrumbs.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Breadcrumbs, {
14505
+ segments: breadcrumbs,
14506
+ highlightLast: false,
14507
+ onSegmentClick: onBreadcrumbClick,
14508
+ action: showCreateButton ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Skeleton, {
14509
+ height: "32px",
14510
+ width: "32px",
14511
+ borderRadius: "6px"
14512
+ }) : void 0
14513
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Box, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_chakra_ui_react.Flex, {
14514
+ alignItems: "center",
14515
+ gap: "8px",
14516
+ children: [
14517
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Skeleton, {
14518
+ height: "32px",
14519
+ width: "32px",
14520
+ borderRadius: "6px"
14521
+ }),
14522
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Skeleton, {
14523
+ height: "32px",
14524
+ width: "32px",
14525
+ borderRadius: "6px"
14526
+ }),
14527
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Skeleton, {
14528
+ height: "32px",
14529
+ width: "32px",
14530
+ borderRadius: "6px"
14531
+ })
14532
+ ]
14533
+ })]
14534
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_chakra_ui_react.Box, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Flex, {
14535
+ height: `${HEADER_ROW_HEIGHT}px`,
14536
+ alignItems: "center",
14537
+ px: 3,
14538
+ borderBottom: "1px solid",
14539
+ borderColor: "gray.100",
14540
+ children: COLUMN_WIDTHS.map((colWidth, j) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Box, {
14541
+ width: `${colWidth}px`,
14542
+ flexShrink: 0,
14543
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Skeleton, {
14544
+ height: "12px",
14545
+ width: "60px",
14546
+ borderRadius: "4px"
14547
+ })
14548
+ }, `h-${j}`))
14549
+ }), CONTENT_WIDTHS.slice(0, SKELETON_ROW_COUNT).map((contentWidths, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Flex, {
14550
+ height: `${DATA_ROW_HEIGHT}px`,
14551
+ alignItems: "center",
14552
+ px: 3,
14553
+ borderBottom: "1px solid",
14554
+ borderColor: "gray.100",
14555
+ children: COLUMN_WIDTHS.map((colWidth, j) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Box, {
14556
+ width: `${colWidth}px`,
14557
+ flexShrink: 0,
14558
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Skeleton, {
14559
+ height: "14px",
14560
+ width: `${contentWidths[j]}px`,
14561
+ borderRadius: "4px"
14562
+ })
14563
+ }, `r-${i}-c-${j}`))
14564
+ }, `r-${i}`))] })]
14565
+ });
14566
+
14378
14567
  //#endregion
14379
14568
  //#region src/table-editor/TableEditor/ui/TableEditor.tsx
14380
14569
  const noop = () => {};
14570
+ function getWriteCallbacks(isReadonly, viewModel, callbacks) {
14571
+ return {
14572
+ onDeleteRow: isReadonly ? void 0 : (id) => viewModel.deleteRows([id]),
14573
+ onDuplicateRow: isReadonly ? void 0 : callbacks.onDuplicateRow,
14574
+ onDeleteSelected: isReadonly ? void 0 : (ids) => viewModel.deleteRows(ids),
14575
+ onUploadFile: isReadonly ? void 0 : callbacks.onUploadFile
14576
+ };
14577
+ }
14381
14578
  const TableEditor = (0, mobx_react_lite.observer)(({ viewModel, useWindowScroll }) => {
14382
- if (viewModel.isBootstrapping) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Box, {
14383
- display: "flex",
14384
- alignItems: "center",
14385
- justifyContent: "center",
14386
- height: "100%",
14387
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Spinner, {})
14388
- });
14579
+ const showSkeleton = useDelayedVisibility(viewModel.isBootstrapping);
14580
+ if (viewModel.isBootstrapping) {
14581
+ if (!showSkeleton) return null;
14582
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableEditorSkeleton, {
14583
+ breadcrumbs: viewModel.breadcrumbs,
14584
+ onBreadcrumbClick: viewModel.callbacks.onBreadcrumbClick,
14585
+ showCreateButton: !viewModel.readonly && !!viewModel.callbacks.onCreateRow,
14586
+ useWindowScroll
14587
+ });
14588
+ }
14389
14589
  const isReadonly = viewModel.readonly;
14390
14590
  const { breadcrumbs, callbacks } = viewModel;
14391
14591
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_chakra_ui_react.Box, {
@@ -14446,11 +14646,8 @@ const TableEditor = (0, mobx_react_lite.observer)(({ viewModel, useWindowScroll
14446
14646
  onEndReached: viewModel.loadMore,
14447
14647
  onOpenRow: callbacks.onOpenRow,
14448
14648
  onPickRow: callbacks.onPickRow,
14449
- onDeleteRow: isReadonly ? void 0 : (id) => viewModel.deleteRows([id]),
14450
- onDuplicateRow: isReadonly ? void 0 : callbacks.onDuplicateRow,
14451
- onDeleteSelected: isReadonly ? void 0 : (ids) => viewModel.deleteRows(ids),
14649
+ ...getWriteCallbacks(isReadonly, viewModel, callbacks),
14452
14650
  onSearchForeignKey: callbacks.onSearchForeignKey,
14453
- onUploadFile: isReadonly ? void 0 : callbacks.onUploadFile,
14454
14651
  onOpenFile: callbacks.onOpenFile,
14455
14652
  onCopyPath: callbacks.onCopyPath,
14456
14653
  useWindowScroll
@@ -14577,6 +14774,7 @@ exports.operatorRequiresValue = operatorRequiresValue;
14577
14774
  exports.selectDefaultColumns = selectDefaultColumns;
14578
14775
  exports.typeMenuGroups = typeMenuGroups;
14579
14776
  exports.useContentEditable = useContentEditable;
14777
+ exports.useDelayedVisibility = useDelayedVisibility;
14580
14778
  Object.keys(_revisium_schema_toolkit).forEach(function (k) {
14581
14779
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
14582
14780
  enumerable: true,