@revisium/schema-toolkit-ui 0.6.3 → 0.6.4
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/README.md +1 -0
- package/dist/index.cjs +59 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -26
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +31 -26
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +60 -31
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -236,6 +236,7 @@ All callbacks are optional and passed via `TableEditorOptions.callbacks`:
|
|
|
236
236
|
| `onBreadcrumbClick` | `(segment, index) => void` | Navigate on breadcrumb click |
|
|
237
237
|
| `onCreateRow` | `() => void` | Create a new row (shows "+" button) |
|
|
238
238
|
| `onOpenRow` | `(rowId: string) => void` | Navigate to row detail view |
|
|
239
|
+
| `onPickRow` | `(rowId: string) => void` | Pick a row (e.g. foreign key selection). When set, the primary row action becomes "Pick" and the table behaves as read-only |
|
|
239
240
|
| `onDuplicateRow` | `(rowId: string) => void` | Duplicate a row |
|
|
240
241
|
| `onSearchForeignKey` | `SearchForeignKeySearchFn` | Foreign key search handler |
|
|
241
242
|
| `onUploadFile` | `(params: { rowId: string; fileId: string; file: File }) => Promise<Record<string, unknown> \| null>` | Upload a file for a file field |
|
package/dist/index.cjs
CHANGED
|
@@ -5757,21 +5757,25 @@ const Row = ({ node, name, guides, isCollapsible = false, isExpanded = true, onT
|
|
|
5757
5757
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_chakra_ui_react.Flex, {
|
|
5758
5758
|
width: "100%",
|
|
5759
5759
|
alignItems: "center",
|
|
5760
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_chakra_ui_react.Flex, {
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5760
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_chakra_ui_react.Flex, {
|
|
5761
|
+
flex: skipDot && skipField ? 1 : void 0,
|
|
5762
|
+
minWidth: 0,
|
|
5763
|
+
children: [
|
|
5764
|
+
!skipDot && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Dot, {
|
|
5765
|
+
isCollapsed,
|
|
5766
|
+
isCollapsible,
|
|
5767
|
+
toggleCollapsed: onToggle,
|
|
5768
|
+
testId
|
|
5769
|
+
}),
|
|
5770
|
+
!skipField && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
5771
|
+
name,
|
|
5772
|
+
formula,
|
|
5773
|
+
description,
|
|
5774
|
+
isDeprecated
|
|
5775
|
+
}),
|
|
5776
|
+
children
|
|
5777
|
+
]
|
|
5778
|
+
}), !skipMore && isCollapsed && collapsedLabel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(More, {
|
|
5775
5779
|
onClick: onToggle,
|
|
5776
5780
|
label: collapsedLabel
|
|
5777
5781
|
})]
|
|
@@ -6997,7 +7001,10 @@ var SchemaContext = class {
|
|
|
6997
7001
|
const wrapped = wrapDataSchema(dataSchema);
|
|
6998
7002
|
this._wrappedDataSchema = wrapped;
|
|
6999
7003
|
const rowSchema = buildRowSchema(wrapped);
|
|
7000
|
-
|
|
7004
|
+
const parser = new _revisium_schema_toolkit.SchemaParser();
|
|
7005
|
+
this._rootNode = parser.parse(rowSchema, this._fullRefSchemas);
|
|
7006
|
+
const tree = (0, _revisium_schema_toolkit.createSchemaTree)(this._rootNode);
|
|
7007
|
+
parser.parseFormulas(tree);
|
|
7001
7008
|
this._allColumns = extractColumns(this._rootNode);
|
|
7002
7009
|
}
|
|
7003
7010
|
};
|
|
@@ -12179,6 +12186,19 @@ const FilterIndicator = (0, mobx_react_lite.observer)(({ field, filterModel }) =
|
|
|
12179
12186
|
});
|
|
12180
12187
|
});
|
|
12181
12188
|
|
|
12189
|
+
//#endregion
|
|
12190
|
+
//#region src/table-editor/Table/ui/Header/FormulaIndicator.tsx
|
|
12191
|
+
const FormulaIndicator = ({ column }) => {
|
|
12192
|
+
if (!column.hasFormula) return null;
|
|
12193
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Flex, {
|
|
12194
|
+
alignItems: "center",
|
|
12195
|
+
color: "gray.400",
|
|
12196
|
+
flexShrink: 0,
|
|
12197
|
+
"data-testid": `formula-indicator-${column.field}`,
|
|
12198
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_icons_pi.PiFunction, { size: 12 })
|
|
12199
|
+
});
|
|
12200
|
+
};
|
|
12201
|
+
|
|
12182
12202
|
//#endregion
|
|
12183
12203
|
//#region src/table-editor/Table/ui/Header/SortSubmenu.tsx
|
|
12184
12204
|
const SortSubmenu = (0, mobx_react_lite.observer)(({ field, sortModel }) => {
|
|
@@ -12447,10 +12467,6 @@ const ColumnHeaderMenu = (0, mobx_react_lite.observer)(({ column, columnsModel,
|
|
|
12447
12467
|
onClick: handleAddFilter,
|
|
12448
12468
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_icons_lu.LuFilter, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Text, { children: "Add filter" })]
|
|
12449
12469
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Menu.Separator, {})] }),
|
|
12450
|
-
canMove && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MoveColumnSubmenu, {
|
|
12451
|
-
field: column.field,
|
|
12452
|
-
columnsModel
|
|
12453
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Menu.Separator, {})] }),
|
|
12454
12470
|
isPinned ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_chakra_ui_react.Menu.Item, {
|
|
12455
12471
|
value: "unpin",
|
|
12456
12472
|
onClick: handleUnpin,
|
|
@@ -12468,6 +12484,10 @@ const ColumnHeaderMenu = (0, mobx_react_lite.observer)(({ column, columnsModel,
|
|
|
12468
12484
|
}),
|
|
12469
12485
|
(canPinLeft || canPinRight) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Menu.Separator, {})
|
|
12470
12486
|
] }),
|
|
12487
|
+
canMove && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MoveColumnSubmenu, {
|
|
12488
|
+
field: column.field,
|
|
12489
|
+
columnsModel
|
|
12490
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Menu.Separator, {})] }),
|
|
12471
12491
|
hasInsertableFields && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
12472
12492
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(InsertColumnSubmenu, {
|
|
12473
12493
|
label: "Insert before",
|
|
@@ -12594,6 +12614,7 @@ const ColumnHeader = (0, mobx_react_lite.observer)(({ column, columnsModel, sort
|
|
|
12594
12614
|
textDecoration: column.isDeprecated ? "line-through" : void 0,
|
|
12595
12615
|
children: column.label
|
|
12596
12616
|
}),
|
|
12617
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormulaIndicator, { column }),
|
|
12597
12618
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(PinIndicator, {
|
|
12598
12619
|
field: column.field,
|
|
12599
12620
|
columnsModel
|
|
@@ -12795,8 +12816,12 @@ const RowActionMenuItems = ({ rowId, testIdPrefix, onSelect, onDuplicate, onDele
|
|
|
12795
12816
|
|
|
12796
12817
|
//#endregion
|
|
12797
12818
|
//#region src/table-editor/Table/ui/RowActionOverlay.tsx
|
|
12798
|
-
const RowActionOverlay = ({ rowId, onOpen, onSelect, onDuplicate, onDelete }) => {
|
|
12819
|
+
const RowActionOverlay = ({ rowId, onOpen, onPick, onSelect, onDuplicate, onDelete }) => {
|
|
12799
12820
|
const [isMenuOpen, setIsMenuOpen] = (0, react.useState)(false);
|
|
12821
|
+
const primaryAction = onPick ?? onOpen;
|
|
12822
|
+
const primaryIcon = onPick ? react_icons_pi.PiCheckSquare : react_icons_pi.PiArrowSquareRightLight;
|
|
12823
|
+
const primaryTestId = onPick ? `row-action-pick-${rowId}` : `row-action-open-${rowId}`;
|
|
12824
|
+
const hasMenuItems = Boolean(onOpen || onSelect || onDuplicate || onDelete);
|
|
12800
12825
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Flex, {
|
|
12801
12826
|
position: "absolute",
|
|
12802
12827
|
right: "8px",
|
|
@@ -12814,7 +12839,7 @@ const RowActionOverlay = ({ rowId, onOpen, onSelect, onDuplicate, onDelete }) =>
|
|
|
12814
12839
|
boxShadow: "0px 2px 8px rgba(0,0,0,0.16)",
|
|
12815
12840
|
overflow: "hidden",
|
|
12816
12841
|
"data-testid": `row-action-split-${rowId}`,
|
|
12817
|
-
children: [
|
|
12842
|
+
children: [primaryAction && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Flex, {
|
|
12818
12843
|
alignItems: "center",
|
|
12819
12844
|
justifyContent: "center",
|
|
12820
12845
|
height: "100%",
|
|
@@ -12824,15 +12849,15 @@ const RowActionOverlay = ({ rowId, onOpen, onSelect, onDuplicate, onDelete }) =>
|
|
|
12824
12849
|
_hover: { bg: "gray.100" },
|
|
12825
12850
|
onClick: (e) => {
|
|
12826
12851
|
e.stopPropagation();
|
|
12827
|
-
|
|
12852
|
+
primaryAction(rowId);
|
|
12828
12853
|
},
|
|
12829
|
-
"data-testid":
|
|
12854
|
+
"data-testid": primaryTestId,
|
|
12830
12855
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Icon, {
|
|
12831
12856
|
boxSize: "20px",
|
|
12832
12857
|
color: "gray.400",
|
|
12833
|
-
as:
|
|
12858
|
+
as: primaryIcon
|
|
12834
12859
|
})
|
|
12835
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_chakra_ui_react.Menu.Root, {
|
|
12860
|
+
}), hasMenuItems && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_chakra_ui_react.Menu.Root, {
|
|
12836
12861
|
lazyMount: true,
|
|
12837
12862
|
unmountOnExit: true,
|
|
12838
12863
|
onOpenChange: ({ open }) => setIsMenuOpen(open),
|
|
@@ -12846,7 +12871,7 @@ const RowActionOverlay = ({ rowId, onOpen, onSelect, onDuplicate, onDelete }) =>
|
|
|
12846
12871
|
width: "18px",
|
|
12847
12872
|
minWidth: "18px",
|
|
12848
12873
|
cursor: "pointer",
|
|
12849
|
-
borderLeft:
|
|
12874
|
+
borderLeft: primaryAction ? "1px solid" : void 0,
|
|
12850
12875
|
borderColor: "gray.100",
|
|
12851
12876
|
_hover: { bg: "gray.100" },
|
|
12852
12877
|
onClick: (e) => e.stopPropagation(),
|
|
@@ -12972,8 +12997,8 @@ function getCellBoxShadow(isSticky, side) {
|
|
|
12972
12997
|
if (!isSticky) return BOTTOM_BORDER_SHADOW;
|
|
12973
12998
|
return `${BOTTOM_BORDER_SHADOW}, ${side === "left" ? `inset -1px 0 0 0 ${CELL_BORDER_COLOR}` : `inset 1px 0 0 0 ${CELL_BORDER_COLOR}`}`;
|
|
12974
12999
|
}
|
|
12975
|
-
const DataRow = (0, mobx_react_lite.observer)(({ row, columnsModel, showSelection, onSearchForeignKey, onUploadFile, onOpenFile, onOpenRow, onSelectRow, onDuplicateRow, onDeleteRow }) => {
|
|
12976
|
-
const hasRowActions = Boolean(onOpenRow || onSelectRow || onDuplicateRow || onDeleteRow);
|
|
13000
|
+
const DataRow = (0, mobx_react_lite.observer)(({ row, columnsModel, showSelection, onSearchForeignKey, onUploadFile, onOpenFile, onOpenRow, onPickRow, onSelectRow, onDuplicateRow, onDeleteRow }) => {
|
|
13001
|
+
const hasRowActions = Boolean(onOpenRow || onPickRow || onSelectRow || onDuplicateRow || onDeleteRow);
|
|
12977
13002
|
const selectionWidth = showSelection ? SELECTION_COLUMN_WIDTH : 0;
|
|
12978
13003
|
const addColumnStickyRight = columnsModel.hasHiddenColumns;
|
|
12979
13004
|
const addColOffset = addColumnStickyRight ? ADD_COLUMN_BUTTON_WIDTH : 0;
|
|
@@ -13020,6 +13045,7 @@ const DataRow = (0, mobx_react_lite.observer)(({ row, columnsModel, showSelectio
|
|
|
13020
13045
|
}), showOverlay && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RowActionOverlay, {
|
|
13021
13046
|
rowId: row.rowId,
|
|
13022
13047
|
onOpen: onOpenRow,
|
|
13048
|
+
onPick: onPickRow,
|
|
13023
13049
|
onSelect: onSelectRow,
|
|
13024
13050
|
onDuplicate: onDuplicateRow,
|
|
13025
13051
|
onDelete: onDeleteRow
|
|
@@ -13310,7 +13336,7 @@ const baseComponents = {
|
|
|
13310
13336
|
Table: TableComponent,
|
|
13311
13337
|
TableRow: TableRowComponent
|
|
13312
13338
|
};
|
|
13313
|
-
const TableWidget = (0, mobx_react_lite.observer)(({ rows, columnsModel, cellFSM, selection, sortModel, filterModel, onSearchForeignKey, onUploadFile, onOpenFile, onOpenRow, onDeleteSelected, onDuplicateSelected, onDeleteRow, onDuplicateRow, onCopyPath, onEndReached, isLoadingMore, useWindowScroll: useWindowScrollProp }) => {
|
|
13339
|
+
const TableWidget = (0, mobx_react_lite.observer)(({ rows, columnsModel, cellFSM, selection, sortModel, filterModel, onSearchForeignKey, onUploadFile, onOpenFile, onOpenRow, onPickRow, onDeleteSelected, onDuplicateSelected, onDeleteRow, onDuplicateRow, onCopyPath, onEndReached, isLoadingMore, useWindowScroll: useWindowScrollProp }) => {
|
|
13314
13340
|
const showSelection = selection.isSelectionMode;
|
|
13315
13341
|
const allRowIds = rows.map((r) => r.rowId);
|
|
13316
13342
|
const [deleteConfirm, setDeleteConfirm] = (0, react.useState)(null);
|
|
@@ -13437,6 +13463,7 @@ const TableWidget = (0, mobx_react_lite.observer)(({ rows, columnsModel, cellFSM
|
|
|
13437
13463
|
onUploadFile,
|
|
13438
13464
|
onOpenFile,
|
|
13439
13465
|
onOpenRow,
|
|
13466
|
+
onPickRow,
|
|
13440
13467
|
onSelectRow: canSelect ? handleSelectRow : void 0,
|
|
13441
13468
|
onDuplicateRow: canDuplicateRow ? onDuplicateRow : void 0,
|
|
13442
13469
|
onDeleteRow: canDeleteRow ? handleDeleteRowRequest : void 0
|
|
@@ -13447,6 +13474,7 @@ const TableWidget = (0, mobx_react_lite.observer)(({ rows, columnsModel, cellFSM
|
|
|
13447
13474
|
onUploadFile,
|
|
13448
13475
|
onOpenFile,
|
|
13449
13476
|
onOpenRow,
|
|
13477
|
+
onPickRow,
|
|
13450
13478
|
canSelect,
|
|
13451
13479
|
canDeleteRow,
|
|
13452
13480
|
canDuplicateRow,
|
|
@@ -14277,6 +14305,7 @@ const TableEditor = (0, mobx_react_lite.observer)(({ viewModel, useWindowScroll
|
|
|
14277
14305
|
isLoadingMore: viewModel.isLoadingMore,
|
|
14278
14306
|
onEndReached: viewModel.loadMore,
|
|
14279
14307
|
onOpenRow: callbacks.onOpenRow,
|
|
14308
|
+
onPickRow: callbacks.onPickRow,
|
|
14280
14309
|
onDeleteRow: isReadonly ? void 0 : (id) => viewModel.deleteRows([id]),
|
|
14281
14310
|
onDuplicateRow: isReadonly ? void 0 : callbacks.onDuplicateRow,
|
|
14282
14311
|
onDeleteSelected: isReadonly ? void 0 : (ids) => viewModel.deleteRows(ids),
|