sit-onyx 1.0.0-beta.61 → 1.0.0-beta.62

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.
@@ -0,0 +1,16 @@
1
+ import { type DataGridEntry, type OnyxDataGridProps } from "../..";
2
+ declare const _default: <TEntry extends DataGridEntry>(__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<{
3
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, never> & OnyxDataGridProps<TEntry>> & import("vue").PublicProps;
4
+ expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
5
+ attrs: any;
6
+ slots: {};
7
+ emit: {};
8
+ }>) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
9
+ [key: string]: any;
10
+ }> & {
11
+ __ctx?: Awaited<typeof __VLS_setup>;
12
+ };
13
+ export default _default;
14
+ type __VLS_PrettifyLocal<T> = {
15
+ [K in keyof T]: T[K];
16
+ } & {};
@@ -74,7 +74,7 @@ export type DataGridRendererCellComponentProps<TEntry extends DataGridEntry, TMe
74
74
  /**
75
75
  * Complete row data.
76
76
  */
77
- row: TEntry;
77
+ row: Readonly<TEntry>;
78
78
  /**
79
79
  * Cell data that is provided to the component via the `metadata` prop.
80
80
  */
@@ -0,0 +1,28 @@
1
+ declare function __VLS_template(): {
2
+ slots: Readonly<{
3
+ actions?(): unknown;
4
+ }> & {
5
+ actions?(): unknown;
6
+ };
7
+ refs: {};
8
+ attrs: Partial<{}>;
9
+ };
10
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
11
+ declare const __VLS_component: import("vue").DefineComponent<{
12
+ /**
13
+ * label of the column
14
+ */
15
+ label: string;
16
+ }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
17
+ /**
18
+ * label of the column
19
+ */
20
+ label: string;
21
+ }> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
22
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
23
+ export default _default;
24
+ type __VLS_WithTemplateSlots<T, S> = T & {
25
+ new (): {
26
+ $slots: S;
27
+ };
28
+ };
@@ -0,0 +1,97 @@
1
+ import { type Component, type WatchSource } from "vue";
2
+ import type { DataGridRendererColumn, DataGridRendererRow } from "../../..";
3
+ import type { DataGridEntry, DataGridMetadata } from "../types";
4
+ export type DataGridFeature<TEntry extends DataGridEntry, TFeatureName extends symbol> = {
5
+ /**
6
+ * Unique name and identifier of the datagrid feature
7
+ */
8
+ name: TFeatureName;
9
+ /**
10
+ * An array of reactive states that should trigger a datagrid re-generation
11
+ */
12
+ watch: WatchSource[];
13
+ /**
14
+ * Allows modifying the datagrid state as a whole.
15
+ */
16
+ mutation?: {
17
+ func: (state: Readonly<TEntry>[]) => void;
18
+ };
19
+ /**
20
+ * Allows the modification of the headers.
21
+ */
22
+ header?: {
23
+ /**
24
+ * Adds header icon button(s).
25
+ * `iconComponent` of an action is shown after the header label.
26
+ * The components must be ARIA-conform buttons.
27
+ */
28
+ actions?: (column: keyof TEntry) => {
29
+ iconComponent: Component;
30
+ listComponent?: never;
31
+ }[];
32
+ };
33
+ };
34
+ /**
35
+ * Helper function that infers the generics of the DataGridFeature type.
36
+ * @example
37
+ * ```ts
38
+ *
39
+ * const MY_FEATURE = Symbol("TABLE_HEADER_BUTTON");
40
+ * export const useDataGridHeaderButton = createFeature(<TEntry extends DataGridEntry>() => {
41
+ * return {
42
+ * name: MY_FEATURE,
43
+ * header: {
44
+ * actions: (column) => [
45
+ * {
46
+ * iconComponent: h('button', { onClick: (column) => console.log(`Clicked on ${column}`) },),
47
+ * },
48
+ * ],
49
+ * },
50
+ * };
51
+ * });
52
+ * ```
53
+ */
54
+ export declare const createFeature: <TFeatureName extends symbol, TArgs extends unknown[]>(featureDefinition: <TEntry extends DataGridEntry>(...args: TArgs) => DataGridFeature<TEntry, TFeatureName>) => <TEntry extends DataGridEntry>(...args: TArgs) => DataGridFeature<TEntry, TFeatureName>;
55
+ type ExtractTEntry<T> = T extends DataGridFeature<infer I, symbol>[] ? I : never;
56
+ /**
57
+ * Uses the defined datagrid features to provide factory functions.
58
+ * These factories are to be used to map data and configuration to `OnyxDataGridRenderer` properties.
59
+ * The properties are then used to render the data grid.
60
+ *
61
+ * Make use of the `watchSources` to trigger re-rendering when state changes occur.
62
+ * @example
63
+ * ```vue
64
+ * <script setup lang="ts">
65
+ * // ...
66
+ * // imports, props, emits, etc.
67
+ * const withHeaderButton = useDataGridHeaderButton<TEntry>();
68
+ *
69
+ * const { watchSources, createRendererRows, createRendererColumns } = useDataGridFeatures([withHeaderButton]);
70
+ *
71
+ * const renderCols: Ref<DataGridRendererColumn<TEntry, object>[]> = ref([]);
72
+ * const renderRows: Ref<DataGridRendererRow<TEntry, DataGridMetadata>[]> = ref([]);
73
+ *
74
+ * const { columns, data } = toRefs(props);
75
+ *
76
+ * watch(
77
+ * [columns, data, ...watchSources],
78
+ * ([newColumns, newData]) => {
79
+ * renderCols.value = createRendererColumns(newColumns);
80
+ * renderRows.value = createRendererRows(newData, newColumns);
81
+ * },
82
+ * { immediate: true },
83
+ * );
84
+ * </script>
85
+ * <template>
86
+ * <OnyxDataGridRenderer :columns="renderCols" :rows="renderRows" />
87
+ * </template>
88
+ * ```
89
+ */
90
+ export declare const useDataGridFeatures: <T extends DataGridFeature<TEntry, symbol>[] | [], TEntry extends DataGridEntry = ExtractTEntry<T>>(features: T) => {
91
+ /** Takes the column definition and maps all, calls mutation func and maps at the end to RendererCell */
92
+ createRendererRows: (entries: TEntry[], columns: (keyof TEntry)[]) => DataGridRendererRow<TEntry, DataGridMetadata>[];
93
+ /** Takes the column definition and creates a RenderHeader for each, adds actions from features */
94
+ createRendererColumns: (columns: (keyof TEntry)[]) => DataGridRendererColumn<TEntry, object>[];
95
+ watchSources: WatchSource[];
96
+ };
97
+ export {};
@@ -0,0 +1,21 @@
1
+ import type { SortDirection } from "./sorting";
2
+ declare const _default: import("vue").DefineComponent<{
3
+ /**
4
+ * Label of this Column.
5
+ */
6
+ columnLabel: string;
7
+ /**
8
+ * The current sorting direction, that should be indicated.
9
+ */
10
+ sortDirection?: SortDirection;
11
+ }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
12
+ /**
13
+ * Label of this Column.
14
+ */
15
+ columnLabel: string;
16
+ /**
17
+ * The current sorting direction, that should be indicated.
18
+ */
19
+ sortDirection?: SortDirection;
20
+ }> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
21
+ export default _default;
@@ -0,0 +1,6 @@
1
+ import type { DataGridEntry } from "../../types";
2
+ export type SortDirection = "asc" | "desc" | "none";
3
+ export declare const nextSortDirection: (current?: SortDirection) => SortDirection;
4
+ declare const SORTING_FEATURE: unique symbol;
5
+ export declare const useDataGridSorting: <TEntry extends DataGridEntry>() => import("..").DataGridFeature<TEntry, typeof SORTING_FEATURE>;
6
+ export {};
@@ -1,4 +1,17 @@
1
1
  export type DataGridMetadata = Record<string, unknown>;
2
+ /**
3
+ * @experimental The DataGrid is still working in progress and the props will change in the future.
4
+ */
5
+ export type OnyxDataGridProps<TEntry extends DataGridEntry> = {
6
+ /**
7
+ * The order of and which columns should be rendered.
8
+ */
9
+ columns: (keyof TEntry)[];
10
+ /**
11
+ * The data that should be used to fill the datagrid.
12
+ */
13
+ data: TEntry[];
14
+ };
2
15
  /**
3
16
  * "Raw" user data for a data grid entry/row, e.g. fetched from a backend service.
4
17
  */