@ostack.tech/ui 0.12.0 → 0.12.2

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/ostack-ui.js CHANGED
@@ -1049,7 +1049,7 @@ function numberOfRows$1(columns) {
1049
1049
  }
1050
1050
  function numberOfColumns(columns) {
1051
1051
  return columns.reduce(
1052
- (n, column) => n + (column.subColumns.length === 0 ? 1 : numberOfColumns(column.subColumns)),
1052
+ (n, column) => n + (column.subColumns.length === 0 ? column.colSpan ?? 1 : numberOfColumns(column.subColumns)),
1053
1053
  0
1054
1054
  );
1055
1055
  }
@@ -1159,6 +1159,10 @@ function useCreateTableContext({
1159
1159
  scrollPosition: void 0,
1160
1160
  leafColumns: void 0,
1161
1161
  defaultColumnWidth,
1162
+ numberOfColumns: computed(
1163
+ () => [get().leafColumns],
1164
+ (leaves) => leaves && numberOfColumns(leaves)
1165
+ ),
1162
1166
  stickyColumnOffsets: computed(
1163
1167
  () => [get().leafColumns, get().defaultColumnWidth],
1164
1168
  (leaves, defaultColumnWidth2) => leaves && stickyColumnOffsets(leaves, defaultColumnWidth2)
@@ -1187,7 +1191,7 @@ function useTableContext() {
1187
1191
  }
1188
1192
  function useTableNumberOfColumns() {
1189
1193
  const { store } = useTableContext();
1190
- return useStore$1(store, (state) => state.leafColumns?.length);
1194
+ return useStore$1(store, ({ numberOfColumns: numberOfColumns2 }) => numberOfColumns2());
1191
1195
  }
1192
1196
  const TableHeadContext = createContext(false);
1193
1197
  function useIsInTableHead() {
@@ -4245,7 +4249,7 @@ const TableCell = forwardRef(
4245
4249
  { fireImmediately: true }
4246
4250
  );
4247
4251
  }
4248
- }, [_stickyColumnIndex, colSpan, otherProps.colSpan, sticky, store]);
4252
+ }, [_stickyColumnIndex, colSpan, sticky, store]);
4249
4253
  useEffect(() => {
4250
4254
  if (_stickyColumnIndex != null && sticky) {
4251
4255
  return store.subscribe(
@@ -4449,16 +4453,18 @@ const TableRow = forwardRef(
4449
4453
  return child;
4450
4454
  }
4451
4455
  const tableCellProps = child.props;
4452
- const { columnIndex, colSpan, ...otherTableCellProps } = tableCellProps;
4456
+ const { columnIndex, colSpan } = tableCellProps;
4453
4457
  if (columnIndex !== void 0) {
4454
- nextIdx = (columnIndex ?? nextIdx) + (colSpan ?? 1);
4458
+ if (columnIndex !== null) {
4459
+ nextIdx = columnIndex + (colSpan ?? 1);
4460
+ }
4455
4461
  return child;
4456
4462
  }
4457
4463
  const cellIdx = nextIdx;
4458
4464
  nextIdx += colSpan ?? 1;
4459
4465
  return cloneElement(
4460
4466
  child,
4461
- { columnIndex: cellIdx, colSpan, ...otherTableCellProps }
4467
+ { ...tableCellProps, columnIndex: cellIdx }
4462
4468
  );
4463
4469
  });
4464
4470
  return /* @__PURE__ */ jsx(
@@ -5464,19 +5470,26 @@ function useDataTableSelectionColumn() {
5464
5470
  }
5465
5471
  const [selectedRows2] = state.selectedRows;
5466
5472
  const window2 = selectionWindow(displayMode, state);
5467
- let enabledCount = 0;
5468
5473
  let selectedCount = 0;
5474
+ let disabledCount = 0;
5475
+ let allEnabledChecked = true;
5469
5476
  for (const row of window2) {
5470
5477
  if (row === void 0) {
5471
5478
  return "loading";
5472
5479
  }
5473
5480
  const key = getRowKey(row, rowKey);
5474
- enabledCount += +!disabledSelections?.has(key);
5475
- selectedCount += +selectedRows2.has(key);
5481
+ const isSelected = selectedRows2.has(key);
5482
+ const isDisabled = disabledSelections?.has(key) ?? false;
5483
+ selectedCount += +isSelected;
5484
+ disabledCount += +isDisabled;
5485
+ if (!isDisabled) {
5486
+ allEnabledChecked = allEnabledChecked && isSelected;
5487
+ }
5476
5488
  }
5477
5489
  return {
5478
- allChecked: selectedCount === window2.length ? true : selectedCount === 0 ? false : "indeterminate",
5479
- allEnabledChecked: selectedCount >= enabledCount
5490
+ allDisabled: disabledCount === window2.length,
5491
+ allChecked: window2.length > 0 && selectedCount === window2.length ? true : selectedCount === 0 ? false : "indeterminate",
5492
+ allEnabledChecked
5480
5493
  };
5481
5494
  })
5482
5495
  );
@@ -5496,6 +5509,7 @@ function useDataTableSelectionColumn() {
5496
5509
  selectRows(keys);
5497
5510
  }
5498
5511
  },
5512
+ disabled: allCheckedStatus.allDisabled,
5499
5513
  labelProps: {
5500
5514
  containerProps: { className: prefix("visually-hidden") }
5501
5515
  },
@@ -5657,10 +5671,10 @@ function DataTableEmptyOrLoadingRows({
5657
5671
  emptyMessageProps
5658
5672
  }) {
5659
5673
  const prefix = usePrefix();
5660
- const { showSelectionColumn, renderRow, store, apiRef } = useDataTableContext();
5674
+ const { renderRow, store, apiRef } = useDataTableContext();
5661
5675
  const loading = useStore$1(store, (state) => state.loading);
5662
5676
  const loadingCount = useStore$1(store, (state) => state.loadingCount);
5663
- const numberOfColumns2 = (useTableNumberOfColumns() ?? 1) + (showSelectionColumn ? 1 : 0);
5677
+ const numberOfColumns2 = useTableNumberOfColumns() ?? 1;
5664
5678
  const headCount = useStore$1(store, (state) => state.headCount);
5665
5679
  useImperativeHandle(
5666
5680
  apiRef,
@@ -5681,11 +5695,12 @@ function DataTableEmptyOrLoadingRows({
5681
5695
  }) : /* @__PURE__ */ jsx(TableRow, { "aria-rowindex": headCount + 1, children: /* @__PURE__ */ jsx(
5682
5696
  TableCell,
5683
5697
  {
5698
+ columnIndex: null,
5684
5699
  header: true,
5685
5700
  variant: "data",
5686
5701
  paddingless: false,
5687
5702
  colSpan: numberOfColumns2 === 1 ? void 0 : numberOfColumns2,
5688
- children: !loading && /* @__PURE__ */ jsx(
5703
+ children: /* @__PURE__ */ jsx(
5689
5704
  "div",
5690
5705
  {
5691
5706
  className: cx(
@@ -8550,7 +8565,7 @@ function SelectNative({
8550
8565
  [hasEmptyOption, optionStates]
8551
8566
  );
8552
8567
  const options = useMemo(
8553
- () => optionStates.map(({ value, content, disabled }) => /* @__PURE__ */ jsx("option", { value, disabled, children: content }, value)),
8568
+ () => optionStates.map(({ value, disabled }) => /* @__PURE__ */ jsx("option", { value, disabled }, value)),
8554
8569
  [optionStates]
8555
8570
  );
8556
8571
  return /* @__PURE__ */ jsxs(