@henryx/onedot-ui 0.3.0 → 0.4.0
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/README.md +7 -3
- package/dist/components/OdTable.types.d.ts +29 -9
- package/dist/components/OdTable.vue.d.ts +6 -4
- package/dist/index.d.ts +1 -1
- package/dist/onedot-ui.cjs +19 -19
- package/dist/onedot-ui.cjs.map +1 -1
- package/dist/onedot-ui.js +1851 -1776
- package/dist/onedot-ui.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,10 +47,14 @@ const rows = [{ id: 1, name: 'Ada' }]
|
|
|
47
47
|
</template>
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
Remote tables
|
|
50
|
+
Remote tables default to frontend columns and one POST query endpoint
|
|
51
51
|
returning paginated data plus `meta.fields` for query capabilities and enum
|
|
52
52
|
options. Use `query-url` or `load-data`, with the same `columns` and `row-key`
|
|
53
|
-
props.
|
|
53
|
+
props. When the server determines columns, use `schema-url + query-url` or
|
|
54
|
+
`load-schema + load-data`; omit frontend columns and row-key. Both column modes
|
|
55
|
+
are supported starting in 0.4.0 (0.3.0 uses frontend columns).
|
|
56
|
+
Both modes share query metadata. Field slots such as `#cell-name` match existing
|
|
57
|
+
columns by field and let the page render links or dialog
|
|
54
58
|
buttons. See the [OdTable guide](./用户使用手册/OdTable.md) for complete examples,
|
|
55
59
|
and the [capability list](./用户使用手册/能力清单.md) for implementation status.
|
|
56
60
|
|
|
@@ -115,7 +119,7 @@ The full Tabler Vue catalog and raw SVG assets are shipped inside this package,
|
|
|
115
119
|
so moving the component library to another application does not require a
|
|
116
120
|
second icon dependency or a network request.
|
|
117
121
|
|
|
118
|
-
The current package version is `0.
|
|
122
|
+
The current package version is `0.4.0`. Maintainers should run
|
|
119
123
|
`corepack pnpm release:check` before publishing subsequent versions.
|
|
120
124
|
|
|
121
125
|
## License
|
|
@@ -77,12 +77,26 @@ export type OdTablePaginationConfig = {
|
|
|
77
77
|
defaultPageSize?: number;
|
|
78
78
|
pageSizeOptions?: number[];
|
|
79
79
|
};
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
/** Structure only: query capabilities and enum options belong to Result.meta. */
|
|
81
|
+
export type OdTableSchemaColumn = Omit<OdTableColumn, 'sortable' | 'searchable' | 'filterable' | 'options'>;
|
|
82
|
+
export type OdTableSchema = {
|
|
83
|
+
rowKey: string;
|
|
84
|
+
columns: OdTableSchemaColumn[];
|
|
85
|
+
};
|
|
86
|
+
export type OdTableLoadSchema = (context: {
|
|
87
|
+
signal: AbortSignal;
|
|
88
|
+
}) => Promise<OdTableSchema>;
|
|
89
|
+
export type OdTableRequestOptions = {
|
|
82
90
|
headers?: Record<string, string>;
|
|
83
|
-
body: OdTableQuery;
|
|
84
91
|
signal: AbortSignal;
|
|
85
|
-
}
|
|
92
|
+
} & ({
|
|
93
|
+
method: 'GET';
|
|
94
|
+
body?: never;
|
|
95
|
+
} | {
|
|
96
|
+
method: 'POST';
|
|
97
|
+
body: OdTableQuery;
|
|
98
|
+
});
|
|
99
|
+
export type OdTableRequest = (url: string, options: OdTableRequestOptions) => Promise<unknown>;
|
|
86
100
|
export type OdTableLoadData<T> = (query: OdTableQuery, context: {
|
|
87
101
|
signal: AbortSignal;
|
|
88
102
|
}) => Promise<OdTableResult<T>>;
|
|
@@ -123,10 +137,12 @@ export type OdTableLocale = Partial<{
|
|
|
123
137
|
/** Built-in Chinese copy. Consumers override entries through the `locale` prop. */
|
|
124
138
|
export declare const OD_TABLE_DEFAULT_LOCALE: Required<OdTableLocale>;
|
|
125
139
|
export type OdTableProps<T extends object> = {
|
|
126
|
-
columns
|
|
140
|
+
columns?: OdTableColumn[];
|
|
127
141
|
rows?: T[];
|
|
128
|
-
rowKey
|
|
142
|
+
rowKey?: string;
|
|
129
143
|
pagination?: OdTablePaginationConfig;
|
|
144
|
+
loadSchema?: OdTableLoadSchema;
|
|
145
|
+
schemaUrl?: string;
|
|
130
146
|
loadData?: OdTableLoadData<T>;
|
|
131
147
|
queryUrl?: string;
|
|
132
148
|
request?: OdTableRequest;
|
|
@@ -142,6 +158,7 @@ export type OdTableProps<T extends object> = {
|
|
|
142
158
|
};
|
|
143
159
|
export type OdTableExpose = {
|
|
144
160
|
refresh: () => Promise<void>;
|
|
161
|
+
refreshSchema: () => Promise<void>;
|
|
145
162
|
};
|
|
146
163
|
export type OdTableEvents<T> = {
|
|
147
164
|
'selection-change': (keys: OdTableRowKey[], rows: T[]) => void;
|
|
@@ -156,12 +173,13 @@ export type OdTableEvents<T> = {
|
|
|
156
173
|
error: unknown;
|
|
157
174
|
query: OdTableQuery;
|
|
158
175
|
}) => void;
|
|
176
|
+
'schema-error': (error: unknown) => void;
|
|
159
177
|
retry: (payload: {
|
|
160
|
-
stage: 'data';
|
|
178
|
+
stage: 'schema' | 'data';
|
|
161
179
|
}) => void;
|
|
162
180
|
'config-error': (error: OdTableConfigError) => void;
|
|
163
181
|
};
|
|
164
|
-
export type OdTableConfigErrorCode = 'MODE_MISSING' | 'MODE_PARTIAL' | 'MODE_CONFLICT' | 'REQUEST_WITHOUT_URL_MODE' | 'INVALID_COLUMNS' | 'DUPLICATE_COLUMN_FIELD' | 'INVALID_COLUMN_FIELD' | 'INVALID_COLUMN_WIDTH' | 'INVALID_NUMBER_FORMAT' | 'SEARCHABLE_NON_TEXT' | 'FILTERABLE_NON_ENUM' | 'ENUM_OPTIONS_REQUIRED' | 'DUPLICATE_ENUM_OPTION' | 'INVALID_PAGINATION' | 'MISSING_ROW_KEY' | 'DUPLICATE_ROW_KEY' | 'INVALID_INITIAL_QUERY' | 'INVALID_ROWS' | 'INVALID_RESULT' | 'RESULT_TOTAL_INVALID' | 'RESULT_PAGE_INVALID' | 'RESULT_PAGE_SIZE_INVALID' | 'RESULT_ITEMS_OVERFLOW' | 'RESULT_EMPTY_CONFLICT' | 'INVALID_META' | 'META_QUERY_CONFLICT';
|
|
182
|
+
export type OdTableConfigErrorCode = 'MODE_MISSING' | 'MODE_PARTIAL' | 'MODE_CONFLICT' | 'REQUEST_WITHOUT_URL_MODE' | 'INVALID_COLUMNS' | 'INVALID_SCHEMA' | 'INVALID_ROW_KEY_FIELD' | 'DUPLICATE_COLUMN_FIELD' | 'INVALID_COLUMN_FIELD' | 'INVALID_COLUMN_WIDTH' | 'INVALID_NUMBER_FORMAT' | 'SEARCHABLE_NON_TEXT' | 'FILTERABLE_NON_ENUM' | 'ENUM_OPTIONS_REQUIRED' | 'DUPLICATE_ENUM_OPTION' | 'INVALID_PAGINATION' | 'MISSING_ROW_KEY' | 'DUPLICATE_ROW_KEY' | 'INVALID_INITIAL_QUERY' | 'INVALID_ROWS' | 'INVALID_RESULT' | 'RESULT_TOTAL_INVALID' | 'RESULT_PAGE_INVALID' | 'RESULT_PAGE_SIZE_INVALID' | 'RESULT_ITEMS_OVERFLOW' | 'RESULT_EMPTY_CONFLICT' | 'INVALID_META' | 'META_QUERY_CONFLICT';
|
|
165
183
|
export declare class OdTableConfigError extends Error {
|
|
166
184
|
readonly name = "OdTableConfigError";
|
|
167
185
|
readonly code: OdTableConfigErrorCode;
|
|
@@ -169,7 +187,7 @@ export declare class OdTableConfigError extends Error {
|
|
|
169
187
|
constructor(code: OdTableConfigErrorCode, message: string, details?: unknown);
|
|
170
188
|
}
|
|
171
189
|
export type OdTableSourceMode = 'local' | 'function' | 'url';
|
|
172
|
-
type OdTableSourceInput<T extends object> = Partial<Pick<OdTableProps<T>, 'columns' | 'rows' | 'rowKey' | 'pagination' | 'loadData' | 'queryUrl' | 'request'>>;
|
|
190
|
+
type OdTableSourceInput<T extends object> = Partial<Pick<OdTableProps<T>, 'columns' | 'rows' | 'rowKey' | 'pagination' | 'loadSchema' | 'schemaUrl' | 'loadData' | 'queryUrl' | 'request'>>;
|
|
173
191
|
export declare function validateOdTableColumns(columns: unknown, remote?: boolean): OdTableColumn[];
|
|
174
192
|
export declare function validateOdTablePagination(pagination: unknown): OdTablePaginationConfig;
|
|
175
193
|
export declare function validateOdTableInitialQuery(query: unknown): OdTableInitialQuery | undefined;
|
|
@@ -187,6 +205,8 @@ export declare function validateOdTableSourceMode<T extends object>(input: OdTab
|
|
|
187
205
|
* so callers can route them to `data-error` without string matching.
|
|
188
206
|
*/
|
|
189
207
|
export declare function validateOdTableResult<T>(payload: unknown): OdTableResult<T>;
|
|
208
|
+
/** Restored from the 0.2 Schema contract, restricted to the current structural role. */
|
|
209
|
+
export declare function validateOdTableSchema(payload: unknown): OdTableSchema;
|
|
190
210
|
/** Copy only supported metadata so extra response properties cannot define UI. */
|
|
191
211
|
export declare function validateOdTableMeta(payload: unknown): OdTableMeta;
|
|
192
212
|
/** A null snapshot means the first response has not arrived: all query UI is closed. */
|
|
@@ -2,7 +2,7 @@ import { OdTableConfigError, OdTableProps, OdTableQuery, OdTableRowKey, OdTableS
|
|
|
2
2
|
declare const _default: <T extends object>(__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
3
|
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
|
|
4
4
|
readonly onRetry?: ((payload: {
|
|
5
|
-
stage: "data";
|
|
5
|
+
stage: "schema" | "data";
|
|
6
6
|
}) => any) | undefined;
|
|
7
7
|
readonly "onSelection-change"?: ((keys: OdTableRowKey[], rows: T[]) => any) | undefined;
|
|
8
8
|
readonly "onUpdate:selected-row-keys"?: ((keys: OdTableRowKey[]) => any) | undefined;
|
|
@@ -16,22 +16,24 @@ declare const _default: <T extends object>(__VLS_props: NonNullable<Awaited<type
|
|
|
16
16
|
error: unknown;
|
|
17
17
|
query: OdTableQuery;
|
|
18
18
|
}) => any) | undefined;
|
|
19
|
+
readonly "onSchema-error"?: ((error: unknown) => any) | undefined;
|
|
19
20
|
readonly "onConfig-error"?: ((error: OdTableConfigError) => any) | undefined;
|
|
20
|
-
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onRetry" | "onSelection-change" | "onUpdate:selected-row-keys" | "onQuery-change" | "onColumn-visibility-change" | "onColumn-width-change" | "onData-error" | "onConfig-error"> & OdTableProps<T> & Partial<{}>> & import('vue').PublicProps;
|
|
21
|
+
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onRetry" | "onSelection-change" | "onUpdate:selected-row-keys" | "onQuery-change" | "onColumn-visibility-change" | "onColumn-width-change" | "onData-error" | "onSchema-error" | "onConfig-error"> & OdTableProps<T> & Partial<{}>> & import('vue').PublicProps;
|
|
21
22
|
expose(exposed: import('vue').ShallowUnwrapRef<{
|
|
22
23
|
refresh: () => Promise<void>;
|
|
24
|
+
refreshSchema: () => Promise<void>;
|
|
23
25
|
}>): void;
|
|
24
26
|
attrs: any;
|
|
25
27
|
slots: Readonly<OdTableSlots<T>> & OdTableSlots<T>;
|
|
26
28
|
emit: ((evt: "retry", payload: {
|
|
27
|
-
stage: "data";
|
|
29
|
+
stage: "schema" | "data";
|
|
28
30
|
}) => void) & ((evt: "selection-change", keys: OdTableRowKey[], rows: T[]) => void) & ((evt: "update:selected-row-keys", keys: OdTableRowKey[]) => void) & ((evt: "query-change", query: OdTableQuery) => void) & ((evt: "column-visibility-change", visibility: Record<string, boolean>) => void) & ((evt: "column-width-change", payload: {
|
|
29
31
|
field: string;
|
|
30
32
|
width: number;
|
|
31
33
|
}) => void) & ((evt: "data-error", payload: {
|
|
32
34
|
error: unknown;
|
|
33
35
|
query: OdTableQuery;
|
|
34
|
-
}) => void) & ((evt: "config-error", error: OdTableConfigError) => void);
|
|
36
|
+
}) => void) & ((evt: "schema-error", error: unknown) => void) & ((evt: "config-error", error: OdTableConfigError) => void);
|
|
35
37
|
}>) => import('vue').VNode & {
|
|
36
38
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
37
39
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { default as OdTable } from './components/OdTable.vue';
|
|
|
5
5
|
export { OdButton, OdIcon, OdTable };
|
|
6
6
|
export { OdTableConfigError } from './components/OdTable.types';
|
|
7
7
|
export type { OdButtonVariant, OdSize } from './components/OdButton.vue';
|
|
8
|
-
export type { OdTableCellContext, OdTableColumn, OdTableConfigErrorCode, OdTableDataType, OdTableEvents, OdTableExpose, OdTableFilter, OdTableFieldMeta, OdTableInitialQuery, OdTableLocale, OdTableMeta, OdTableOption, OdTablePaginationConfig, OdTableProps, OdTableQuery, OdTableRequest, OdTableResult, OdTableRowKey, OdTableSearch, OdTableSorting, OdTableSlots, OdTableLoadData, } from './components/OdTable.types';
|
|
8
|
+
export type { OdTableCellContext, OdTableColumn, OdTableConfigErrorCode, OdTableDataType, OdTableEvents, OdTableExpose, OdTableFilter, OdTableFieldMeta, OdTableInitialQuery, OdTableLocale, OdTableMeta, OdTableOption, OdTablePaginationConfig, OdTableProps, OdTableQuery, OdTableRequest, OdTableResult, OdTableRowKey, OdTableSearch, OdTableSorting, OdTableSlots, OdTableLoadData, OdTableSchemaColumn, OdTableSchema, OdTableLoadSchema, OdTableRequestOptions, } from './components/OdTable.types';
|
|
9
9
|
export declare const OnedotUI: {
|
|
10
10
|
install(app: App): void;
|
|
11
11
|
};
|