sit-onyx 1.0.0-beta.154 → 1.0.0-beta.155

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,7 @@
1
- import { type DataGridFeature, type TypeRenderMap } from "./features";
1
+ import { type ColumnGroupConfig, type DataGridFeature, type TypeRenderMap } from "./features";
2
2
  import type { DataGridEntry, OnyxDataGridProps } from "./types";
3
- declare const _default: <TEntry extends DataGridEntry, TTypeRenderer extends TypeRenderMap<TEntry>, TFeatureName extends symbol, TFeatures extends DataGridFeature<TEntry, TTypeRenderer, TFeatureName>[] | []>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
4
- props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, never> & OnyxDataGridProps<TEntry, TTypeRenderer, TFeatureName, TFeatures> & Partial<{}>> & import("vue").PublicProps;
3
+ declare const _default: <TEntry extends DataGridEntry, TTypeRenderer extends TypeRenderMap<TEntry>, TColumnGroup extends ColumnGroupConfig, TFeatureName extends symbol, TFeatures extends DataGridFeature<TEntry, TTypeRenderer, TFeatureName>[] | []>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
4
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, never> & OnyxDataGridProps<TEntry, TColumnGroup, TTypeRenderer, TFeatureName, TFeatures> & Partial<{}>> & import("vue").PublicProps;
5
5
  expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
6
6
  attrs: any;
7
7
  slots: {
@@ -1,13 +1,14 @@
1
1
  import { type Component, type MaybeRefOrGetter, type WatchSource } from "vue";
2
2
  import { type OnyxI18n } from "../../../i18n";
3
3
  import type { OnyxMenuItem } from "../../OnyxNavBar/modules";
4
+ import type { TableColumnGroup } from "../../OnyxTable/types";
4
5
  import type { DataGridRendererCell, DataGridRendererColumn, DataGridRendererRow } from "../OnyxDataGridRenderer/types";
5
6
  import type { DataGridEntry, DataGridMetadata } from "../types";
6
7
  /**
7
8
  * Function type for modifying the normalized column configuration.
8
9
  */
9
10
  export type ModifyColumns<TEntry extends DataGridEntry> = {
10
- func: (columns: Readonly<NormalizedColumnConfig<TEntry, PropertyKey>[]>) => NormalizedColumnConfig<TEntry, PropertyKey>[];
11
+ func: (columns: Readonly<NormalizedColumnConfig<TEntry>[]>) => NormalizedColumnConfig<TEntry>[];
11
12
  };
12
13
  /**
13
14
  * Defines how a specific column type should be rendered.
@@ -24,14 +25,20 @@ export type TypeRenderMap<TEntry extends DataGridEntry> = Record<PropertyKey, Ty
24
25
  /**
25
26
  * ColumnConfig as it can be defined by the user.
26
27
  */
27
- export type ColumnConfig<TEntry extends DataGridEntry, TTypes> = keyof TEntry | NormalizedColumnConfig<TEntry, TTypes>;
28
+ export type ColumnConfig<TEntry extends DataGridEntry, TColumnGroup extends ColumnGroupConfig, TTypes> = keyof TEntry | NormalizedColumnConfig<TEntry, TColumnGroup, TTypes>;
28
29
  export type DefaultSupportedTypes = "string" | "number";
30
+ /**
31
+ * Configuration for the column groupings.
32
+ */
33
+ export type ColumnGroupConfig = Record<string, {
34
+ label: string;
35
+ }>;
29
36
  /**
30
37
  * Normalized column config for internal usage.
31
38
  */
32
- export type NormalizedColumnConfig<TEntry extends DataGridEntry, TTypes = PropertyKey> = {
39
+ export type NormalizedColumnConfig<TEntry extends DataGridEntry, TColumnGroup extends ColumnGroupConfig = any, TTypes = PropertyKey> = {
33
40
  /**
34
- * The `key` identifies which property of an `data` entry is used as a value.
41
+ * The `key` identifies which property of an `data` entry is used as `modelValue` for a cell.
35
42
  */
36
43
  key: keyof TEntry;
37
44
  /**
@@ -44,6 +51,14 @@ export type NormalizedColumnConfig<TEntry extends DataGridEntry, TTypes = Proper
44
51
  * If not defined the values are displayed as plain strings.
45
52
  */
46
53
  type?: TTypes | DefaultSupportedTypes;
54
+ /**
55
+ * Key of the ColumnGroup that this column should be visually grouped in.
56
+ * The columns have to be defined in the correct order.
57
+ * So columns that should be grouped together have to actually be defined after eachother.
58
+ *
59
+ * The label for the column group can be configured via the `columnGroups` prop.
60
+ */
61
+ columnGroupKey?: keyof TColumnGroup;
47
62
  };
48
63
  /**
49
64
  * Complete Type for a single data grid feature.
@@ -89,7 +104,7 @@ export type DataGridFeature<TEntry extends DataGridEntry, TTypeRenderer extends
89
104
  * `iconComponent` of an action is shown after the header label.
90
105
  * The components must be ARIA-conform buttons.
91
106
  */
92
- actions?: (column: NormalizedColumnConfig<TEntry, keyof TTypeRenderer>) => {
107
+ actions?: (column: NormalizedColumnConfig<TEntry>) => {
93
108
  iconComponent: Component;
94
109
  menuItems: Component<typeof OnyxMenuItem>[];
95
110
  }[];
@@ -117,10 +132,12 @@ export type DataGridFeature<TEntry extends DataGridEntry, TTypeRenderer extends
117
132
  */
118
133
  export declare function createFeature<TArgs extends any[], TFeature extends DataGridFeature<any, any, any>, T extends (...args: TArgs) => CheckDataGridFeature<TFeature>>(featureDefinition: T): T;
119
134
  type CheckDataGridFeature<T> = T extends DataGridFeature<infer A, TypeRenderMap<infer A>, infer C> ? DataGridFeature<A, TypeRenderMap<A>, C> : never;
120
- export type UseDataGridFeaturesOptions<TEntry extends DataGridEntry> = {
121
- columnConfig: MaybeRefOrGetter<ColumnConfig<TEntry, PropertyKey>[]>;
135
+ export type UseDataGridFeaturesOptions<TEntry extends DataGridEntry, TColumnGroup extends ColumnGroupConfig> = {
136
+ columnConfig: MaybeRefOrGetter<ColumnConfig<TEntry, TColumnGroup, PropertyKey>[]>;
122
137
  i18n: OnyxI18n;
138
+ columnGroups: MaybeRefOrGetter<TColumnGroup>;
123
139
  };
140
+ export declare const createTableColumnGroups: <TEntry extends DataGridEntry>(columns?: NormalizedColumnConfig<TEntry>[], columnGroups?: ColumnGroupConfig) => TableColumnGroup[] | undefined;
124
141
  /**
125
142
  * Uses the defined datagrid features to provide factory functions.
126
143
  * These factories are to be used to map data and configuration to `OnyxDataGridRenderer` properties.
@@ -155,7 +172,9 @@ export type UseDataGridFeaturesOptions<TEntry extends DataGridEntry> = {
155
172
  * </template>
156
173
  * ```
157
174
  */
158
- export declare const useDataGridFeatures: <TEntry extends DataGridEntry, TFeatureName extends symbol, TTypeRenderer extends TypeRenderMap<TEntry>, T extends DataGridFeature<TEntry, TTypeRenderer, TFeatureName>[] | []>(features: T, { i18n, columnConfig }: UseDataGridFeaturesOptions<TEntry>) => {
175
+ export declare const useDataGridFeatures: <TEntry extends DataGridEntry, TFeatureName extends symbol, TTypeRenderer extends TypeRenderMap<TEntry>, TColumnGroup extends ColumnGroupConfig, T extends DataGridFeature<TEntry, TTypeRenderer, TFeatureName>[] | []>(features: T, { i18n, columnConfig, columnGroups }: UseDataGridFeaturesOptions<TEntry, TColumnGroup>) => {
176
+ /** Uses the column definition and available column group config to generate the column groups for the underlying OnyxTable */
177
+ createRendererColumnGroups: () => TableColumnGroup[] | undefined;
159
178
  /** Takes the column definition and maps all, calls mutation func and maps at the end to RendererCell */
160
179
  createRendererRows: (entries: TEntry[]) => DataGridRendererRow<TEntry, DataGridMetadata>[];
161
180
  /** Takes the column definition and creates a RenderHeader for each, adds actions from features */
@@ -7,7 +7,7 @@ type __VLS_Props = {
7
7
  /**
8
8
  * props passed through to DataGrid
9
9
  */
10
- dataGrid: Pick<OnyxDataGridProps<any, any, any, any>, "columns" | "data">;
10
+ dataGrid: Pick<OnyxDataGridProps<any, any, any, any, any>, "columns" | "data">;
11
11
  /**
12
12
  * props passed through to the feature
13
13
  */
@@ -8,7 +8,7 @@ export declare const useSelection: <TEntry extends DataGridEntry>(options?: Sele
8
8
  name: symbol;
9
9
  watch: (Readonly<Ref<boolean, boolean>> | Ref<SelectionState, SelectionState>)[];
10
10
  modifyColumns: {
11
- func: (columnConfig: readonly import("..").NormalizedColumnConfig<TEntry, PropertyKey>[]) => import("..").NormalizedColumnConfig<TEntry, PropertyKey>[];
11
+ func: (columnConfig: readonly import("..").NormalizedColumnConfig<TEntry, any, PropertyKey>[]) => import("..").NormalizedColumnConfig<TEntry, any, PropertyKey>[];
12
12
  };
13
13
  typeRenderer: {
14
14
  [SELECTION_COLUMN]: {
@@ -1,6 +1,6 @@
1
1
  import type { DataGridEntry, OnyxDataGridProps } from "../../../..";
2
2
  import { DataGridFeatures } from "../../../..";
3
- type __VLS_Props = Pick<OnyxDataGridProps<any, any, any, any>, "columns" | "data">;
3
+ type __VLS_Props = Pick<OnyxDataGridProps<any, any, any, any, any>, "columns" | "data">;
4
4
  declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
5
5
  sortChange: (sortState: DataGridFeatures.SortState<DataGridEntry>) => any;
6
6
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
@@ -10,7 +10,7 @@ export declare const useSorting: <TEntry extends DataGridEntry>(options?: SortOp
10
10
  func: (data: Readonly<TEntry>[]) => void;
11
11
  };
12
12
  header: {
13
- actions: ({ key: column }: import("..").NormalizedColumnConfig<any, PropertyKey>) => {
13
+ actions: ({ key: column }: import("..").NormalizedColumnConfig<any, any, PropertyKey>) => {
14
14
  iconComponent: import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
15
15
  [key: string]: any;
16
16
  }>;
@@ -1,5 +1,5 @@
1
1
  import type { KeysOfUnion, MaybePick, UnionByKey } from "../../types";
2
- import type { ColumnConfig, DataGridFeature, TypeRenderMap } from "./features";
2
+ import type { ColumnConfig, ColumnGroupConfig, DataGridFeature, TypeRenderMap } from "./features";
3
3
  export type DataGridMetadata = Record<string, unknown>;
4
4
  /**
5
5
  * Unwraps the defined typeRenderers
@@ -8,7 +8,7 @@ export type RenderTypesFromFeature<TFeatures extends DataGridFeature<any, any, a
8
8
  /**
9
9
  * @experimental The DataGrid is still working in progress and the props will change in the future.
10
10
  */
11
- export type OnyxDataGridProps<TEntry extends DataGridEntry, TTypeRenderer extends TypeRenderMap<TEntry>, TFeatureName extends symbol, TFeatures extends DataGridFeature<TEntry, TTypeRenderer, TFeatureName>[] = DataGridFeature<TEntry, TTypeRenderer, TFeatureName>[], TTypes = RenderTypesFromFeature<TFeatures>> = {
11
+ export type OnyxDataGridProps<TEntry extends DataGridEntry, TColumnGroup extends ColumnGroupConfig, TTypeRenderer extends TypeRenderMap<TEntry>, TFeatureName extends symbol, TFeatures extends DataGridFeature<TEntry, TTypeRenderer, TFeatureName>[] = DataGridFeature<TEntry, TTypeRenderer, TFeatureName>[], TTypes = RenderTypesFromFeature<TFeatures>> = {
12
12
  /**
13
13
  * Features that should be applied.
14
14
  * They allow the modification of the behavior and rendering.
@@ -19,7 +19,11 @@ export type OnyxDataGridProps<TEntry extends DataGridEntry, TTypeRenderer extend
19
19
  /**
20
20
  * The order of and which columns should be rendered.
21
21
  */
22
- columns: ColumnConfig<TEntry, TTypes>[];
22
+ columns: ColumnConfig<TEntry, TColumnGroup, TTypes>[];
23
+ /**
24
+ * Configuration for the column groups defined via the `columns` configuration.
25
+ */
26
+ columnGroups?: TColumnGroup;
23
27
  /**
24
28
  * The data that should be used to fill the datagrid.
25
29
  */