sit-onyx 1.4.0-dev-20251118074438 → 1.4.0-dev-20251118092838

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.
@@ -1,7 +1,19 @@
1
+ import { Ref } from 'vue';
1
2
  import { DataGridEntry } from '../../types.js';
2
3
  import { DataGridFeatureOptions } from '../index.js';
3
4
  /**
4
5
  * The configuration options for the resizing feature in the OnyxDataGrid component.
5
6
  * Includes settings for the individual columns and general resizing behavior.
6
7
  */
7
- export type ResizingOptions<TEntry extends DataGridEntry> = DataGridFeatureOptions<TEntry, object>;
8
+ export type ResizingOptions<TEntry extends DataGridEntry> = DataGridFeatureOptions<TEntry, object> & {
9
+ /**
10
+ * The current column resizing state.
11
+ * Can be used to e.g. save the user resized columns and restore them on page load.
12
+ */
13
+ resizeState?: Ref<ResizeState<TEntry>>;
14
+ };
15
+ /**
16
+ * Defines the current column resizing state.
17
+ * Key = Column key, value = resized width.
18
+ */
19
+ export type ResizeState<TEntry> = Map<keyof TEntry, string>;
@@ -9581,15 +9581,15 @@ const useResizing = (options) => createFeature((ctx) => {
9581
9581
  const MIN_COLUMN_WIDTH = 3 * 16;
9582
9582
  const headers = ref(/* @__PURE__ */ new Map());
9583
9583
  const { isEnabled } = useFeatureContext(ctx, options);
9584
- const colWidths = ref(/* @__PURE__ */ new Map());
9584
+ const resizeState = toRef(options?.resizeState ?? /* @__PURE__ */ new Map());
9585
9585
  const scrollContainer = ref();
9586
9586
  watch(
9587
- [headers, colWidths],
9587
+ [headers, resizeState],
9588
9588
  () => {
9589
9589
  headers.value.forEach((th, columnKey) => {
9590
9590
  const property = `--onyx-data-grid-column-${escapeCSS(columnKey)}`;
9591
9591
  const container = th.closest(".onyx-table-wrapper__container");
9592
- const width = colWidths.value.get(columnKey);
9592
+ const width = resizeState.value.get(columnKey);
9593
9593
  if (width) {
9594
9594
  container?.style.setProperty(property, width);
9595
9595
  } else {
@@ -9612,7 +9612,7 @@ const useResizing = (options) => createFeature((ctx) => {
9612
9612
  }
9613
9613
  }
9614
9614
  };
9615
- const resizedWidth = colWidths.value.get(column.key);
9615
+ const resizedWidth = resizeState.value.get(column.key);
9616
9616
  return {
9617
9617
  ...column,
9618
9618
  width: resizedWidth || column.width,
@@ -9634,16 +9634,16 @@ const useResizing = (options) => createFeature((ctx) => {
9634
9634
  resizingCol.value = column;
9635
9635
  Array.from(headers.value.entries()).forEach(([col, el]) => {
9636
9636
  const { width } = el.getBoundingClientRect();
9637
- colWidths.value.set(col, `${Math.max(MIN_COLUMN_WIDTH, width)}px`);
9637
+ resizeState.value.set(col, `${Math.max(MIN_COLUMN_WIDTH, width)}px`);
9638
9638
  });
9639
9639
  },
9640
9640
  onEnd: () => {
9641
9641
  resizingCol.value = void 0;
9642
9642
  },
9643
9643
  onUpdateWidth: (width) => {
9644
- colWidths.value.set(column.key, `${width}px`);
9644
+ resizeState.value.set(column.key, `${width}px`);
9645
9645
  },
9646
- onAutoSize: () => colWidths.value.set(column.key, "max-content")
9646
+ onAutoSize: () => resizeState.value.set(column.key, "max-content")
9647
9647
  }),
9648
9648
  slotContent
9649
9649
  ];