@revisium/schema-toolkit-ui 0.6.6 → 0.6.8

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
@@ -6681,11 +6681,25 @@ const FileRendererComponent = (0, mobx_react_lite.observer)(({ node }) => {
6681
6681
  });
6682
6682
  });
6683
6683
 
6684
+ //#endregion
6685
+ //#region src/hooks/useAutoResize.ts
6686
+ const MIN_HEIGHT = 120;
6687
+ function useAutoResize(value) {
6688
+ const ref = (0, react.useRef)(null);
6689
+ (0, react.useEffect)(() => {
6690
+ const el = ref.current;
6691
+ if (!el) return;
6692
+ el.style.height = "auto";
6693
+ el.style.height = `${Math.max(el.scrollHeight, MIN_HEIGHT)}px`;
6694
+ }, [value]);
6695
+ return ref;
6696
+ }
6697
+
6684
6698
  //#endregion
6685
6699
  //#region src/row-editor/ui/editors/MarkdownEditor.tsx
6686
6700
  const MarkdownEditor = ({ value, setValue, readonly, dataTestId }) => {
6687
6701
  const [internalValue, setInternalValue] = (0, react.useState)(value);
6688
- const textareaRef = (0, react.useRef)(null);
6702
+ const textareaRef = useAutoResize(internalValue);
6689
6703
  (0, react.useEffect)(() => {
6690
6704
  setInternalValue(value);
6691
6705
  }, [value]);
@@ -6710,6 +6724,7 @@ const MarkdownEditor = ({ value, setValue, readonly, dataTestId }) => {
6710
6724
  lineHeight: "1.5",
6711
6725
  minHeight: "120px",
6712
6726
  resize: "vertical",
6727
+ overflow: "hidden",
6713
6728
  borderColor: "gray.200",
6714
6729
  _focus: {
6715
6730
  borderColor: "blue.400",
@@ -7063,7 +7078,7 @@ function resolveRefColumn(child, fieldPath) {
7063
7078
  systemFieldId: systemDef.id,
7064
7079
  isDeprecated,
7065
7080
  hasFormula,
7066
- isSortable: !isDeprecated && !hasFormula
7081
+ isSortable: !isDeprecated
7067
7082
  };
7068
7083
  }
7069
7084
  if (refValue === _revisium_schema_toolkit.SystemSchemaIds.File) return resolveFileRefColumns(child, fieldPath);
@@ -7089,7 +7104,8 @@ function stripDataPrefix(fieldPath) {
7089
7104
  }
7090
7105
  function createColumn(fieldPath, child, fieldType) {
7091
7106
  const isDeprecated = child.metadata().deprecated ?? false;
7092
- const hasFormula = child.hasFormula();
7107
+ const formula = child.formula();
7108
+ const hasFormula = formula !== void 0;
7093
7109
  return {
7094
7110
  field: fieldPath,
7095
7111
  label: stripDataPrefix(fieldPath),
@@ -7097,7 +7113,8 @@ function createColumn(fieldPath, child, fieldType) {
7097
7113
  isSystem: false,
7098
7114
  isDeprecated,
7099
7115
  hasFormula,
7100
- isSortable: !isDeprecated && !hasFormula && fieldType !== FilterFieldType.File
7116
+ formulaExpression: formula?.expression(),
7117
+ isSortable: !isDeprecated && fieldType !== FilterFieldType.File
7101
7118
  };
7102
7119
  }
7103
7120
 
@@ -13658,6 +13675,35 @@ const RowActionsMenu = ({ rowId, onSelect, onDuplicate, onDelete }) => {
13658
13675
  });
13659
13676
  };
13660
13677
 
13678
+ //#endregion
13679
+ //#region src/table-editor/Status/model/CellInfoModel.ts
13680
+ var CellInfoModel = class {
13681
+ _cellFSM;
13682
+ _columnsModel;
13683
+ constructor(cellFSM, columnsModel) {
13684
+ this._cellFSM = cellFSM;
13685
+ this._columnsModel = columnsModel;
13686
+ (0, mobx.makeAutoObservable)(this, {}, { autoBind: true });
13687
+ }
13688
+ get _focusedColumn() {
13689
+ const focused = this._cellFSM.focusedCell;
13690
+ if (!focused) return null;
13691
+ return this._columnsModel.allColumns.find((c) => c.field === focused.field) ?? null;
13692
+ }
13693
+ get isVisible() {
13694
+ return this._focusedColumn !== null && !this._cellFSM.hasSelection;
13695
+ }
13696
+ get fieldLabel() {
13697
+ return this._focusedColumn?.label ?? "";
13698
+ }
13699
+ get formulaExpression() {
13700
+ return this._focusedColumn?.formulaExpression;
13701
+ }
13702
+ get foreignKeyTableId() {
13703
+ return this._focusedColumn?.foreignKeyTableId;
13704
+ }
13705
+ };
13706
+
13661
13707
  //#endregion
13662
13708
  //#region src/table-editor/Status/model/RowCountModel.ts
13663
13709
  var RowCountModel = class {
@@ -13771,6 +13817,7 @@ var TableEditorCore = class {
13771
13817
  cellFSM;
13772
13818
  selection;
13773
13819
  rowCount;
13820
+ cellInfo;
13774
13821
  _dataSource;
13775
13822
  _pageSize;
13776
13823
  _breadcrumbs;
@@ -13799,6 +13846,7 @@ var TableEditorCore = class {
13799
13846
  this.cellFSM = new CellFSM();
13800
13847
  this.selection = new SelectionModel();
13801
13848
  this.rowCount = new RowCountModel();
13849
+ this.cellInfo = new CellInfoModel(this.cellFSM, this.columns);
13802
13850
  this.columns.setOnChange(() => this._handleColumnsChange());
13803
13851
  this.filters.setOnChange(() => this._handleFilterChange());
13804
13852
  this.filters.setOnApply((_where) => this._handleFilterApply());
@@ -14143,6 +14191,50 @@ var MockDataSource = class {
14143
14191
  }
14144
14192
  };
14145
14193
 
14194
+ //#endregion
14195
+ //#region src/table-editor/Status/ui/CellInfoWidget.tsx
14196
+ const CellInfoWidget = (0, mobx_react_lite.observer)(({ model }) => {
14197
+ if (!model.isVisible) return null;
14198
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_chakra_ui_react.Flex, {
14199
+ alignItems: "center",
14200
+ gap: 2,
14201
+ overflow: "hidden",
14202
+ flexShrink: 1,
14203
+ minW: 0,
14204
+ children: [
14205
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Text, {
14206
+ fontSize: "sm",
14207
+ color: "gray.500",
14208
+ overflow: "hidden",
14209
+ textOverflow: "ellipsis",
14210
+ whiteSpace: "nowrap",
14211
+ "data-testid": "cell-info-field",
14212
+ children: model.fieldLabel
14213
+ }),
14214
+ model.formulaExpression && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_chakra_ui_react.Text, {
14215
+ fontSize: "sm",
14216
+ color: "purple.400",
14217
+ fontFamily: "mono",
14218
+ overflow: "hidden",
14219
+ textOverflow: "ellipsis",
14220
+ whiteSpace: "nowrap",
14221
+ "data-testid": "cell-info-formula",
14222
+ children: ["= ", model.formulaExpression]
14223
+ }),
14224
+ model.foreignKeyTableId && !model.formulaExpression && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_chakra_ui_react.Text, {
14225
+ fontSize: "sm",
14226
+ color: "blue.400",
14227
+ fontFamily: "mono",
14228
+ overflow: "hidden",
14229
+ textOverflow: "ellipsis",
14230
+ whiteSpace: "nowrap",
14231
+ "data-testid": "cell-info-fk",
14232
+ children: ["→ ", model.foreignKeyTableId]
14233
+ })
14234
+ ]
14235
+ });
14236
+ });
14237
+
14146
14238
  //#endregion
14147
14239
  //#region src/table-editor/Status/ui/RowCountWidget.tsx
14148
14240
  const RowCountWidget = (0, mobx_react_lite.observer)(({ model }) => {
@@ -14325,14 +14417,24 @@ const TableEditor = (0, mobx_react_lite.observer)(({ viewModel, useWindowScroll
14325
14417
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_chakra_ui_react.Flex, {
14326
14418
  px: 3,
14327
14419
  py: 2,
14328
- justifyContent: "space-between",
14420
+ alignItems: "center",
14421
+ overflow: "hidden",
14329
14422
  ...useWindowScroll && {
14330
14423
  position: "sticky",
14331
14424
  bottom: 0,
14332
14425
  bg: "white",
14333
14426
  zIndex: 3
14334
14427
  },
14335
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RowCountWidget, { model: viewModel.rowCount }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ViewSettingsBadge, { model: viewModel.viewBadge })]
14428
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RowCountWidget, { model: viewModel.rowCount }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_chakra_ui_react.Flex, {
14429
+ alignItems: "center",
14430
+ gap: 3,
14431
+ overflow: "hidden",
14432
+ flexShrink: 1,
14433
+ minW: 0,
14434
+ flex: 1,
14435
+ justifyContent: "flex-end",
14436
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CellInfoWidget, { model: viewModel.cellInfo }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ViewSettingsBadge, { model: viewModel.viewBadge })]
14437
+ })]
14336
14438
  })
14337
14439
  ]
14338
14440
  });