sit-onyx 1.0.0-beta.151 → 1.0.0-beta.152
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,5 +1,5 @@
|
|
|
1
1
|
import { type Component, type MaybeRefOrGetter, type WatchSource } from "vue";
|
|
2
|
-
import {
|
|
2
|
+
import { type OnyxI18n } from "../../../i18n";
|
|
3
3
|
import type { OnyxMenuItem } from "../../OnyxNavBar/modules";
|
|
4
4
|
import type { DataGridRendererCell, DataGridRendererColumn, DataGridRendererRow } from "../OnyxDataGridRenderer/types";
|
|
5
5
|
import type { DataGridEntry, DataGridMetadata } from "../types";
|
|
@@ -25,6 +25,7 @@ export type TypeRenderMap<TEntry extends DataGridEntry> = Record<PropertyKey, Ty
|
|
|
25
25
|
* ColumnConfig as it can be defined by the user.
|
|
26
26
|
*/
|
|
27
27
|
export type ColumnConfig<TEntry extends DataGridEntry, TTypes> = keyof TEntry | NormalizedColumnConfig<TEntry, TTypes>;
|
|
28
|
+
export type DefaultSupportedTypes = "string" | "number";
|
|
28
29
|
/**
|
|
29
30
|
* Normalized column config for internal usage.
|
|
30
31
|
*/
|
|
@@ -42,7 +43,7 @@ export type NormalizedColumnConfig<TEntry extends DataGridEntry, TTypes = Proper
|
|
|
42
43
|
* The `type` of the column. It defines how the header and cells of a column is rendered.
|
|
43
44
|
* If not defined the values are displayed as plain strings.
|
|
44
45
|
*/
|
|
45
|
-
type?: TTypes;
|
|
46
|
+
type?: TTypes | DefaultSupportedTypes;
|
|
46
47
|
};
|
|
47
48
|
/**
|
|
48
49
|
* Complete Type for a single data grid feature.
|
|
@@ -118,7 +119,7 @@ export declare function createFeature<TArgs extends any[], TFeature extends Data
|
|
|
118
119
|
type CheckDataGridFeature<T> = T extends DataGridFeature<infer A, TypeRenderMap<infer A>, infer C> ? DataGridFeature<A, TypeRenderMap<A>, C> : never;
|
|
119
120
|
export type UseDataGridFeaturesOptions<TEntry extends DataGridEntry> = {
|
|
120
121
|
columnConfig: MaybeRefOrGetter<ColumnConfig<TEntry, PropertyKey>[]>;
|
|
121
|
-
|
|
122
|
+
i18n: OnyxI18n;
|
|
122
123
|
};
|
|
123
124
|
/**
|
|
124
125
|
* Uses the defined datagrid features to provide factory functions.
|
|
@@ -154,7 +155,7 @@ export type UseDataGridFeaturesOptions<TEntry extends DataGridEntry> = {
|
|
|
154
155
|
* </template>
|
|
155
156
|
* ```
|
|
156
157
|
*/
|
|
157
|
-
export declare const useDataGridFeatures: <TEntry extends DataGridEntry, TFeatureName extends symbol, TTypeRenderer extends TypeRenderMap<TEntry>, T extends DataGridFeature<TEntry, TTypeRenderer, TFeatureName>[] | []>(features: T, {
|
|
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>) => {
|
|
158
159
|
/** Takes the column definition and maps all, calls mutation func and maps at the end to RendererCell */
|
|
159
160
|
createRendererRows: (entries: TEntry[]) => DataGridRendererRow<TEntry, DataGridMetadata>[];
|
|
160
161
|
/** Takes the column definition and creates a RenderHeader for each, adds actions from features */
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DataGridEntry } from "../types";
|
|
2
|
+
import type { DataGridFeature, TypeRenderer, TypeRenderMap } from "./index";
|
|
3
|
+
import "./renderer.scss";
|
|
4
|
+
export type DefaultSupportedTypes = "string" | "number";
|
|
5
|
+
export declare const createRenderer: <TEntry extends DataGridEntry>(features: DataGridFeature<TEntry, TypeRenderMap<TEntry>, symbol>[]) => {
|
|
6
|
+
/**
|
|
7
|
+
* Returns a renderer for any given component and type.
|
|
8
|
+
* Uses the fallbackRenderer if necessary.
|
|
9
|
+
*/
|
|
10
|
+
getFor: <TComponent extends "cell" | "header">(component: TComponent, type?: PropertyKey) => NonNullable<TypeRenderer<TEntry>[TComponent]>;
|
|
11
|
+
};
|
package/dist/i18n/index.d.ts
CHANGED
|
@@ -63,7 +63,8 @@ export type TranslationFunction = (key: OnyxTranslationKey,
|
|
|
63
63
|
placeholders?: Record<string, string | number | undefined> & {
|
|
64
64
|
n?: number;
|
|
65
65
|
}) => string;
|
|
66
|
-
export declare const I18N_INJECTION_KEY: InjectionKey<
|
|
66
|
+
export declare const I18N_INJECTION_KEY: InjectionKey<OnyxI18n>;
|
|
67
|
+
export type OnyxI18n = ReturnType<typeof createI18n>;
|
|
67
68
|
/**
|
|
68
69
|
* Creates a new i18n instance.
|
|
69
70
|
*/
|