@antelopejs/dms 0.23.0 → 0.23.1-next.1029.g63c44fb
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/dist/implementations/dms/page/payloads.js.map +1 -1
- package/dist/implementations/dms-builder/engine/analysis-relations.js +9 -6
- package/dist/implementations/dms-builder/engine/analysis-relations.js.map +1 -1
- package/dist/implementations/dms-builder/engine/analysis.js +11 -8
- package/dist/implementations/dms-builder/engine/analysis.js.map +1 -1
- package/dist/implementations/dms-builder/engine/block-tree.js +3 -4
- package/dist/implementations/dms-builder/engine/block-tree.js.map +1 -1
- package/dist/implementations/dms-builder/engine/chain.d.ts +5 -1
- package/dist/implementations/dms-builder/engine/chain.js +3 -2
- package/dist/implementations/dms-builder/engine/chain.js.map +1 -1
- package/dist/implementations/dms-builder/engine/map-resources-batch.js +4 -1
- package/dist/implementations/dms-builder/engine/map-resources-batch.js.map +1 -1
- package/dist/implementations/dms-builder/engine/mapped-choices.js +10 -5
- package/dist/implementations/dms-builder/engine/mapped-choices.js.map +1 -1
- package/dist/implementations/dms-builder/engine/page-draft.js +10 -10
- package/dist/implementations/dms-builder/engine/page-draft.js.map +1 -1
- package/dist/implementations/dms-builder/engine/relabel-columns.js +7 -2
- package/dist/implementations/dms-builder/engine/relabel-columns.js.map +1 -1
- package/dist/implementations/dms-builder/engine/source-options.d.ts +3 -3
- package/dist/implementations/dms-builder/engine/source-options.js +6 -2
- package/dist/implementations/dms-builder/engine/source-options.js.map +1 -1
- package/frontend-vue/layers/dms-core/app/build/composables/user/tablePreferences.ts +96 -107
- package/frontend-vue/layers/dms-core/app/composables/data-types/useDataType.ts +31 -11
- package/frontend-vue/layers/dms-core/app/composables/realtime/useSseStream.ts +1 -1
- package/frontend-vue/layers/dms-core/app/composables/realtime/useUserRealtime.ts +5 -3
- package/frontend-vue/layers/dms-core/app/composables/user/usePreferences.ts +1 -0
- package/frontend-vue/layers/dms-core/app/types/page.ts +2 -2
- package/frontend-vue/layers/dms-core/app/types/watch.ts +3 -2
- package/frontend-vue/layers/dms-core/app/utils/query-validation.ts +4 -3
- package/frontend-vue/layers/dms-ui/app/build/components/sortable/SortableList.vue +1 -0
- package/frontend-vue/layers/dms-ui/app/build/components/table/MenuImport.vue +1 -1
- package/frontend-vue/layers/dms-ui/app/build/components/table/MenuRoot.vue +1 -1
- package/frontend-vue/layers/dms-ui/app/build/composables/chart/apexRawOptions.ts +2 -1
- package/frontend-vue/layers/dms-ui/app/build/composables/form/repeaterTable.ts +2 -2
- package/frontend-vue/layers/dms-ui/app/build/composables/form/useFormModel.ts +38 -24
- package/frontend-vue/layers/dms-ui/app/build/composables/table/useTableConfigClipboard.ts +2 -2
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/tableViewArrival.ts +3 -6
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/tableViewDisplays.ts +1 -4
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/tableViewFilters.ts +2 -5
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/tableViewPersistence.ts +20 -20
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/tableViewSorting.ts +1 -1
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/tableViewTabs.ts +1 -1
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/tableViewTypes.ts +0 -3
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/tableViewViews.ts +1 -2
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/usePersistedPagination.ts +3 -6
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/useTablePreferences.ts +57 -25
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/useTableViews.ts +2 -9
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/utils/linkedArrival.ts +11 -6
- package/frontend-vue/layers/dms-ui/app/components/form/components/InputRepeater.vue +2 -1
- package/frontend-vue/layers/dms-ui/app/components/form/components/KeyValue.vue +2 -1
- package/frontend-vue/layers/dms-ui/app/composables/form/types/props.ts +3 -7
- package/frontend-vue/layers/dms-ui/app/composables/form/types/value.ts +1 -1
- package/frontend-vue/layers/dms-ui/app/composables/form/useForm.ts +3 -2
- package/frontend-vue/layers/dms-ui/app/entries/composables/form/useFormModel.ts +1 -0
- package/frontend-vue/package.json +0 -1
- package/package.json +5 -6
|
@@ -1,23 +1,41 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
|
+
PaginationState,
|
|
3
|
+
SortingState,
|
|
4
|
+
VisibilityState,
|
|
5
|
+
} from "@tanstack/vue-table";
|
|
2
6
|
import { isBranch, type PreferencesTree } from "./preferencesCookie";
|
|
3
7
|
import { isNumber, isString } from "../../../utils/type-check";
|
|
4
8
|
|
|
9
|
+
/** @internal A filter of a table view, as `TableFilter` shapes it. */
|
|
10
|
+
export interface FilterEntry {
|
|
11
|
+
accessorKey: string;
|
|
12
|
+
value?: unknown;
|
|
13
|
+
mode: string;
|
|
14
|
+
pinned?: boolean;
|
|
15
|
+
initialValue?: unknown;
|
|
16
|
+
}
|
|
17
|
+
|
|
5
18
|
/**
|
|
6
19
|
* @internal
|
|
7
20
|
* The state of a table view that the server render reads to list and draw
|
|
8
|
-
* the right rows: kept in the preferences cookie, compactly.
|
|
21
|
+
* the right rows: kept in the preferences cookie, compactly. Each field maps
|
|
22
|
+
* to the type of its value.
|
|
9
23
|
*/
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
export interface ServerTableValues {
|
|
25
|
+
sorting: SortingState;
|
|
26
|
+
columnFilters: FilterEntry[];
|
|
27
|
+
columnVisibility: VisibilityState;
|
|
28
|
+
pagination: PaginationState;
|
|
29
|
+
paginationScope: string;
|
|
30
|
+
activeTab: string;
|
|
31
|
+
viewMode: string;
|
|
32
|
+
activeView: string;
|
|
33
|
+
linkScope: string;
|
|
34
|
+
shownLink: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** @internal The fields kept in the preferences cookie. */
|
|
38
|
+
export type ServerTableField = keyof ServerTableValues;
|
|
21
39
|
|
|
22
40
|
/**
|
|
23
41
|
* @internal
|
|
@@ -92,53 +110,27 @@ export const tablePreferenceId = (
|
|
|
92
110
|
.padStart(TABLE_ID_LENGTH, "0")
|
|
93
111
|
.slice(0, TABLE_ID_LENGTH);
|
|
94
112
|
|
|
95
|
-
interface SortEntry {
|
|
96
|
-
id: string;
|
|
97
|
-
desc: boolean;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
interface FilterEntry {
|
|
101
|
-
accessorKey: string;
|
|
102
|
-
value?: unknown;
|
|
103
|
-
mode: string;
|
|
104
|
-
pinned?: boolean;
|
|
105
|
-
initialValue?: unknown;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
interface PaginationEntry {
|
|
109
|
-
pageIndex: number;
|
|
110
|
-
pageSize: number;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
113
|
/**
|
|
114
114
|
* @internal
|
|
115
|
-
* How a server field is kept: its key in the table's
|
|
116
|
-
* form. `encode` gets the field's default so that it
|
|
117
|
-
* differs from it; a value whose form equals the default's
|
|
115
|
+
* How a server field's value of type `V` is kept: its key in the table's
|
|
116
|
+
* entry, and its compact form. `encode` gets the field's default so that it
|
|
117
|
+
* can keep only what differs from it; a value whose form equals the default's
|
|
118
|
+
* is not written. `decode` throws on a stored value that is not a `V`'s form.
|
|
118
119
|
*/
|
|
119
|
-
export interface ServerFieldCodec {
|
|
120
|
+
export interface ServerFieldCodec<V> {
|
|
120
121
|
key: string;
|
|
121
|
-
encode: (
|
|
122
|
-
|
|
123
|
-
defaultValue: PreferencesTree[string],
|
|
124
|
-
) => PreferencesTree[string];
|
|
125
|
-
decode: (
|
|
126
|
-
stored: PreferencesTree[string],
|
|
127
|
-
defaultValue: PreferencesTree[string],
|
|
128
|
-
) => PreferencesTree[string];
|
|
122
|
+
encode: (value: V, defaultValue: V | undefined) => PreferencesTree[string];
|
|
123
|
+
decode: (stored: PreferencesTree[string], defaultValue: V | undefined) => V;
|
|
129
124
|
}
|
|
130
125
|
|
|
131
|
-
const encodeSorting: ServerFieldCodec["encode"] = (value) => {
|
|
132
|
-
const
|
|
133
|
-
const tokens = sorts.map(
|
|
126
|
+
const encodeSorting: ServerFieldCodec<SortingState>["encode"] = (value) => {
|
|
127
|
+
const tokens = value.map(
|
|
134
128
|
(sort) => `${sort.desc ? DESCENDING_PREFIX : ""}${sort.id}`,
|
|
135
129
|
);
|
|
136
130
|
return tokens.length === 1 ? tokens[0] : tokens;
|
|
137
131
|
};
|
|
138
132
|
|
|
139
|
-
const decodeSorting = (
|
|
140
|
-
stored: Parameters<ServerFieldCodec["decode"]>[0],
|
|
141
|
-
): SortEntry[] => {
|
|
133
|
+
const decodeSorting = (stored: PreferencesTree[string]): SortingState => {
|
|
142
134
|
const tokens = isString(stored) ? [stored] : stored;
|
|
143
135
|
if (!Array.isArray(tokens)) throw new TypeError("sorting");
|
|
144
136
|
return tokens.map((token: string) => ({
|
|
@@ -147,26 +139,22 @@ const decodeSorting = (
|
|
|
147
139
|
}));
|
|
148
140
|
};
|
|
149
141
|
|
|
150
|
-
const isSameValue = (
|
|
151
|
-
left
|
|
152
|
-
right: Parameters<ServerFieldCodec["encode"]>[0],
|
|
153
|
-
): boolean => JSON.stringify(left) === JSON.stringify(right);
|
|
142
|
+
const isSameValue = <V>(left: V, right: V): boolean =>
|
|
143
|
+
JSON.stringify(left) === JSON.stringify(right);
|
|
154
144
|
|
|
155
|
-
const encodeFilters: ServerFieldCodec["encode"] = (value) =>
|
|
156
|
-
|
|
145
|
+
const encodeFilters: ServerFieldCodec<FilterEntry[]>["encode"] = (value) =>
|
|
146
|
+
value
|
|
157
147
|
.filter(
|
|
158
|
-
(filter
|
|
148
|
+
(filter) =>
|
|
159
149
|
!filter.pinned || !isSameValue(filter.value, filter.initialValue),
|
|
160
150
|
)
|
|
161
|
-
.map((filter
|
|
151
|
+
.map((filter) =>
|
|
162
152
|
filter.mode === DEFAULT_FILTER_MODE
|
|
163
153
|
? [filter.accessorKey, filter.value ?? null]
|
|
164
154
|
: [filter.accessorKey, filter.value ?? null, filter.mode],
|
|
165
155
|
);
|
|
166
156
|
|
|
167
|
-
const decodeFilters = (
|
|
168
|
-
stored: Parameters<ServerFieldCodec["decode"]>[0],
|
|
169
|
-
): FilterEntry[] => {
|
|
157
|
+
const decodeFilters = (stored: PreferencesTree[string]): FilterEntry[] => {
|
|
170
158
|
if (!Array.isArray(stored)) throw new TypeError("columnFilters");
|
|
171
159
|
return stored.map(([accessorKey, value, mode]: unknown[]) => ({
|
|
172
160
|
accessorKey: String(accessorKey),
|
|
@@ -175,12 +163,12 @@ const decodeFilters = (
|
|
|
175
163
|
}));
|
|
176
164
|
};
|
|
177
165
|
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
const defaults =
|
|
183
|
-
return Object.entries(
|
|
166
|
+
const encodeVisibility: ServerFieldCodec<VisibilityState>["encode"] = (
|
|
167
|
+
value,
|
|
168
|
+
defaultValue,
|
|
169
|
+
) => {
|
|
170
|
+
const defaults = defaultValue ?? {};
|
|
171
|
+
return Object.entries(value)
|
|
184
172
|
.filter(([column, isShown]) => isShown !== (defaults[column] ?? true))
|
|
185
173
|
.map(
|
|
186
174
|
([column, isShown]) =>
|
|
@@ -188,27 +176,26 @@ const encodeVisibility: ServerFieldCodec["encode"] = (value, defaultValue) => {
|
|
|
188
176
|
);
|
|
189
177
|
};
|
|
190
178
|
|
|
191
|
-
const decodeVisibility: ServerFieldCodec["decode"] = (
|
|
179
|
+
const decodeVisibility: ServerFieldCodec<VisibilityState>["decode"] = (
|
|
180
|
+
stored,
|
|
181
|
+
defaultValue,
|
|
182
|
+
) => {
|
|
192
183
|
if (!Array.isArray(stored)) throw new TypeError("columnVisibility");
|
|
193
|
-
const changes = stored.map((token: string) => [
|
|
184
|
+
const changes = stored.map((token: string): [string, boolean] => [
|
|
194
185
|
token.slice(1),
|
|
195
186
|
token.startsWith(SHOWN_PREFIX),
|
|
196
187
|
]);
|
|
197
|
-
return { ...
|
|
188
|
+
return { ...defaultValue, ...Object.fromEntries(changes) };
|
|
198
189
|
};
|
|
199
190
|
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
const encodePagination: ServerFieldCodec["encode"] = (value) => {
|
|
204
|
-
if (!isPaginationEntry(value)) return undefined;
|
|
191
|
+
const encodePagination: ServerFieldCodec<PaginationState>["encode"] = (
|
|
192
|
+
value,
|
|
193
|
+
) => {
|
|
205
194
|
const { pageIndex, pageSize } = value;
|
|
206
195
|
return pageIndex === FIRST_PAGE_INDEX ? pageSize : [pageSize, pageIndex];
|
|
207
196
|
};
|
|
208
197
|
|
|
209
|
-
const decodePagination = (
|
|
210
|
-
stored: Parameters<ServerFieldCodec["decode"]>[0],
|
|
211
|
-
): PaginationEntry => {
|
|
198
|
+
const decodePagination = (stored: PreferencesTree[string]): PaginationState => {
|
|
212
199
|
const pair: unknown[] = Array.isArray(stored)
|
|
213
200
|
? stored
|
|
214
201
|
: [stored, FIRST_PAGE_INDEX];
|
|
@@ -219,10 +206,13 @@ const decodePagination = (
|
|
|
219
206
|
return { pageIndex, pageSize };
|
|
220
207
|
};
|
|
221
208
|
|
|
222
|
-
const
|
|
209
|
+
const stringField = (key: string): ServerFieldCodec<string> => ({
|
|
223
210
|
key,
|
|
224
211
|
encode: (value) => value,
|
|
225
|
-
decode: (stored) =>
|
|
212
|
+
decode: (stored) => {
|
|
213
|
+
if (!isString(stored)) throw new TypeError(key);
|
|
214
|
+
return stored;
|
|
215
|
+
},
|
|
226
216
|
});
|
|
227
217
|
|
|
228
218
|
/**
|
|
@@ -231,7 +221,7 @@ const plainField = (key: string): ServerFieldCodec => ({
|
|
|
231
221
|
* `"-name"`, a filter `["status", "open"]`, a hidden column `"-email"`, a
|
|
232
222
|
* page size `50`.
|
|
233
223
|
*/
|
|
234
|
-
export const SERVER_TABLE_FIELDS
|
|
224
|
+
export const SERVER_TABLE_FIELDS = {
|
|
235
225
|
sorting: { key: "s", encode: encodeSorting, decode: decodeSorting },
|
|
236
226
|
columnFilters: { key: "f", encode: encodeFilters, decode: decodeFilters },
|
|
237
227
|
columnVisibility: {
|
|
@@ -240,30 +230,26 @@ export const SERVER_TABLE_FIELDS: Record<ServerTableField, ServerFieldCodec> = {
|
|
|
240
230
|
decode: decodeVisibility,
|
|
241
231
|
},
|
|
242
232
|
pagination: { key: "p", encode: encodePagination, decode: decodePagination },
|
|
243
|
-
paginationScope:
|
|
244
|
-
activeTab:
|
|
245
|
-
viewMode:
|
|
246
|
-
activeView:
|
|
247
|
-
linkScope:
|
|
248
|
-
shownLink:
|
|
233
|
+
paginationScope: stringField("q"),
|
|
234
|
+
activeTab: stringField("t"),
|
|
235
|
+
viewMode: stringField("d"),
|
|
236
|
+
activeView: stringField("w"),
|
|
237
|
+
linkScope: stringField("l"),
|
|
238
|
+
shownLink: stringField("k"),
|
|
239
|
+
} satisfies {
|
|
240
|
+
[F in ServerTableField]: ServerFieldCodec<ServerTableValues[F]>;
|
|
249
241
|
};
|
|
250
242
|
|
|
251
|
-
/** @internal Whether `field` is kept in the cookie. */
|
|
252
|
-
export const isServerTableField = (
|
|
253
|
-
field: TableField,
|
|
254
|
-
): field is ServerTableField => Object.hasOwn(SERVER_TABLE_FIELDS, field);
|
|
255
|
-
|
|
256
243
|
/**
|
|
257
244
|
* @internal
|
|
258
245
|
* `value`'s form in the entry, or `undefined` when it equals the default's
|
|
259
246
|
* and is not to be written.
|
|
260
247
|
*/
|
|
261
|
-
export const encodeServerField = (
|
|
262
|
-
|
|
263
|
-
value:
|
|
264
|
-
defaultValue:
|
|
265
|
-
):
|
|
266
|
-
const codec = SERVER_TABLE_FIELDS[field];
|
|
248
|
+
export const encodeServerField = <V>(
|
|
249
|
+
codec: ServerFieldCodec<V>,
|
|
250
|
+
value: V | undefined,
|
|
251
|
+
defaultValue: V | undefined,
|
|
252
|
+
): PreferencesTree[string] => {
|
|
267
253
|
if (value === undefined) return undefined;
|
|
268
254
|
const encoded = codec.encode(value, defaultValue);
|
|
269
255
|
const encodedDefault =
|
|
@@ -273,26 +259,29 @@ export const encodeServerField = (
|
|
|
273
259
|
return isSameValue(encoded, encodedDefault) ? undefined : encoded;
|
|
274
260
|
};
|
|
275
261
|
|
|
276
|
-
/**
|
|
277
|
-
|
|
278
|
-
|
|
262
|
+
/**
|
|
263
|
+
* @internal
|
|
264
|
+
* The value `entry` keeps under `codec`, else `defaultValue`: also when
|
|
265
|
+
* what it keeps is not a form the codec reads.
|
|
266
|
+
*/
|
|
267
|
+
export const decodeServerField = <V, D extends V | undefined>(
|
|
268
|
+
codec: ServerFieldCodec<V>,
|
|
279
269
|
entry: CompactTableEntry | undefined,
|
|
280
|
-
defaultValue:
|
|
281
|
-
):
|
|
282
|
-
const codec = SERVER_TABLE_FIELDS[field];
|
|
270
|
+
defaultValue: D,
|
|
271
|
+
): V | D => {
|
|
283
272
|
const stored = entry?.[codec.key];
|
|
284
273
|
if (stored === undefined) return defaultValue;
|
|
285
274
|
try {
|
|
286
|
-
return codec.decode(stored, defaultValue)
|
|
275
|
+
return codec.decode(stored, defaultValue);
|
|
287
276
|
} catch {
|
|
288
277
|
return defaultValue;
|
|
289
278
|
}
|
|
290
279
|
};
|
|
291
280
|
|
|
292
281
|
/** @internal Whether `value` is the field's default, not to be written. */
|
|
293
|
-
export const isDefaultValue = (
|
|
294
|
-
value:
|
|
295
|
-
defaultValue:
|
|
282
|
+
export const isDefaultValue = <V>(
|
|
283
|
+
value: V | undefined,
|
|
284
|
+
defaultValue: V | undefined,
|
|
296
285
|
): boolean => value === undefined || isSameValue(value, defaultValue);
|
|
297
286
|
|
|
298
287
|
const localKey = (id: string): string => `${LOCAL_TABLE_KEY_PREFIX}${id}`;
|
|
@@ -10,30 +10,47 @@ export type RecordWithDefault<T> = Record<string, T> & { default: T };
|
|
|
10
10
|
* Keys of a data type's `formatter` record: `default` (required), `cell` (a
|
|
11
11
|
* shorter grid rendering), `empty` (drawn instead of the fallback for a
|
|
12
12
|
* null/undefined value), and one per compare mode for filter chips.
|
|
13
|
+
*
|
|
14
|
+
* @typeParam Value - What a field of the row holds, the formatted one included.
|
|
15
|
+
* @typeParam Options - The options of the field's control.
|
|
16
|
+
* @typeParam Display - What the formatter draws.
|
|
13
17
|
*/
|
|
14
|
-
export type DataTypeFormatter
|
|
15
|
-
|
|
18
|
+
export type DataTypeFormatter<
|
|
19
|
+
Value = unknown,
|
|
20
|
+
Options = unknown,
|
|
21
|
+
Display = unknown,
|
|
22
|
+
> = (
|
|
23
|
+
value: Value,
|
|
16
24
|
locale: string,
|
|
17
|
-
options?:
|
|
18
|
-
row?: Record<string,
|
|
19
|
-
) =>
|
|
25
|
+
options?: Options,
|
|
26
|
+
row?: Record<string, Value>,
|
|
27
|
+
) => Display;
|
|
20
28
|
|
|
21
29
|
/**
|
|
22
30
|
* Reshapes a server value into its form-state representation.
|
|
23
31
|
* Must be idempotent: form reset re-applies the mapper to values that
|
|
24
32
|
* may already be mapped (e.g. restored from a submit-success snapshot).
|
|
33
|
+
*
|
|
34
|
+
* @typeParam Value - The field's value, as served and as held.
|
|
35
|
+
* @typeParam Options - The options of the field's control.
|
|
25
36
|
*/
|
|
26
|
-
export type BeforeStateMapper =
|
|
37
|
+
export type BeforeStateMapper<Value = unknown, Options = unknown> = (
|
|
38
|
+
value: Value,
|
|
39
|
+
options?: Options,
|
|
40
|
+
) => Value;
|
|
27
41
|
|
|
28
42
|
/**
|
|
29
43
|
* Whether two values of a data type are the same value, whatever shape each
|
|
30
44
|
* comes in: a form compares the value it loaded from the server with the one
|
|
31
45
|
* its control holds through it, to tell an edited field from an untouched one.
|
|
46
|
+
*
|
|
47
|
+
* @typeParam Value - The field's value, as served and as held.
|
|
48
|
+
* @typeParam Options - The options of the field's control.
|
|
32
49
|
*/
|
|
33
|
-
export type DataTypeValueComparer = (
|
|
34
|
-
left:
|
|
35
|
-
right:
|
|
36
|
-
options?:
|
|
50
|
+
export type DataTypeValueComparer<Value = unknown, Options = unknown> = (
|
|
51
|
+
left: Value,
|
|
52
|
+
right: Value,
|
|
53
|
+
options?: Options,
|
|
37
54
|
) => boolean;
|
|
38
55
|
|
|
39
56
|
/**
|
|
@@ -42,7 +59,10 @@ export type DataTypeValueComparer = (
|
|
|
42
59
|
* input refuses `"0"`, a date range wants its two days. The filter itself
|
|
43
60
|
* keeps its text, so the query is unchanged.
|
|
44
61
|
*/
|
|
45
|
-
export type DataTypeFilterEditorValue =
|
|
62
|
+
export type DataTypeFilterEditorValue<Value = unknown> = (
|
|
63
|
+
text: string,
|
|
64
|
+
mode: string,
|
|
65
|
+
) => Value;
|
|
46
66
|
|
|
47
67
|
/**
|
|
48
68
|
* Where the rows a value names are read: the `select` route of the table a
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
isString,
|
|
14
14
|
isUndefined,
|
|
15
15
|
} from "../../utils/type-check";
|
|
16
|
-
import { isJsonObject } from "../../build/utils/json";
|
|
16
|
+
import { isJsonObject, type JsonObject } from "../../build/utils/json";
|
|
17
17
|
import { isRecord } from "../../build/utils/record";
|
|
18
18
|
import type { JsonValue } from "../../types/json";
|
|
19
19
|
|
|
@@ -161,14 +161,16 @@ const isSnapshotEntry = (
|
|
|
161
161
|
const isSnapshotEvent = (
|
|
162
162
|
eventName: string,
|
|
163
163
|
data: RealtimeFrameData,
|
|
164
|
-
): data is RealtimeSnapshotEvent =>
|
|
164
|
+
): data is RealtimeSnapshotEvent & JsonObject =>
|
|
165
165
|
eventName === SNAPSHOT_EVENT &&
|
|
166
166
|
isRecord(data) &&
|
|
167
167
|
isString(data.topic) &&
|
|
168
168
|
Array.isArray(data.entries) &&
|
|
169
169
|
data.entries.every(isSnapshotEntry);
|
|
170
170
|
|
|
171
|
-
const isRealtimeEvent = (
|
|
171
|
+
const isRealtimeEvent = (
|
|
172
|
+
data: RealtimeFrameData,
|
|
173
|
+
): data is RealtimeEvent & JsonObject =>
|
|
172
174
|
!!data &&
|
|
173
175
|
isObject(data) &&
|
|
174
176
|
isString(data.topic) &&
|
|
@@ -69,6 +69,7 @@ export const usePreferences = () => {
|
|
|
69
69
|
|
|
70
70
|
const getPreference = <T = unknown>(keyPath: string, defaultValue?: T): T => {
|
|
71
71
|
const value = readAt(tree.value, keyPath.split("."));
|
|
72
|
+
// SAFETY: Holds while the preferences cookie was written by this version and each caller names as T the type its setPreference writes under keyPath: the tree is that cookie decoded, so the value read back has that type or is undefined.
|
|
72
73
|
return (value === undefined ? defaultValue : value) as T;
|
|
73
74
|
};
|
|
74
75
|
|
|
@@ -190,11 +190,11 @@ export interface QuickActionsPayload {
|
|
|
190
190
|
actions: Record<string, QuickActionInfo>;
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
export interface ComponentChild<T = object> {
|
|
193
|
+
export interface ComponentChild<T = object, Extra = unknown> {
|
|
194
194
|
id: string;
|
|
195
195
|
component: ComponentInfo<T>;
|
|
196
196
|
slot?: string;
|
|
197
|
-
[key: string]:
|
|
197
|
+
[key: string]: string | ComponentInfo<T> | Extra | undefined;
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
export interface ComponentInfo<T = object> {
|
|
@@ -5,10 +5,11 @@ export const ComponentId = {
|
|
|
5
5
|
SELF: "$component:self",
|
|
6
6
|
} as const;
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
/** A watch action, run against the state of the component that watches: `Value` is what that state holds per key. */
|
|
9
|
+
export type WatchActionFunction<Value = unknown> = (
|
|
9
10
|
action: WatchAction,
|
|
10
11
|
eventData: ComponentEventData,
|
|
11
|
-
componentState: Ref<Record<string,
|
|
12
|
+
componentState: Ref<Record<string, Value>>,
|
|
12
13
|
) => void;
|
|
13
14
|
|
|
14
15
|
export interface WatchActionCondition {
|
|
@@ -12,9 +12,10 @@ export function validateRequiredQueryParams(
|
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
/** The route a validation reads: `Value` is what each query entry holds. */
|
|
16
|
+
export interface ValidationRouteContext<Value = unknown> {
|
|
17
|
+
query: Record<string, Value>;
|
|
18
|
+
params: Record<string, Value>;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export type ValidationFunction = (route: ValidationRouteContext) => boolean;
|
|
@@ -106,6 +106,7 @@ const { option } = useSortable(root, list, {
|
|
|
106
106
|
emit("change", { moved: { element, oldIndex, newIndex } });
|
|
107
107
|
},
|
|
108
108
|
onAdd: (event: SortableEvent) => {
|
|
109
|
+
// SAFETY: Holds while only onStart writes sharedDragged, under its list's group, with an element of that list, and lists of one group hold the same Item type: the group prop is the contract that makes them exchange items.
|
|
109
110
|
const element = sharedDragged.get(draggedKey()) as Item | undefined;
|
|
110
111
|
const { newIndex } = event;
|
|
111
112
|
if (element === undefined || newIndex === undefined) return;
|
|
@@ -34,7 +34,7 @@ const appConfig = useDmsAppConfig();
|
|
|
34
34
|
const tableSharedData =
|
|
35
35
|
injectLocal<ShallowRef<TableSharedData<T>>>("tableSharedData");
|
|
36
36
|
|
|
37
|
-
const { exportConfig } = useTableConfigClipboard
|
|
37
|
+
const { exportConfig } = useTableConfigClipboard();
|
|
38
38
|
|
|
39
39
|
const navItems = computed((): NavItem[] => {
|
|
40
40
|
const capabilities = tableSharedData?.value?.activeCapabilities.value;
|
|
@@ -6,7 +6,8 @@ import {
|
|
|
6
6
|
} from "../../../../../dms-core/app/utils/type-check";
|
|
7
7
|
import type { UseApexChartInput } from "../../../composables/chart/useApexChart.types";
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
/** An options tree for Apex, one entry per key: `Value` is what an entry holds. */
|
|
10
|
+
export type RawOptionSection<Value = unknown> = Record<string, Value>;
|
|
10
11
|
|
|
11
12
|
/** A value an override is written as: JSON, or the text itself when it is not JSON. */
|
|
12
13
|
type RawOptionJson =
|
|
@@ -11,7 +11,7 @@ export interface RepeaterTableColumn {
|
|
|
11
11
|
id: string;
|
|
12
12
|
label?: string;
|
|
13
13
|
type?: string;
|
|
14
|
-
component: ComponentInfo
|
|
14
|
+
component: ComponentInfo<ComponentOptionsData>;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
/** Where a relation column reads the rows its values name. */
|
|
@@ -31,7 +31,7 @@ export function renderableColumn(
|
|
|
31
31
|
compareModes: [],
|
|
32
32
|
filterComponents: {},
|
|
33
33
|
|
|
34
|
-
inputComponent: column.component
|
|
34
|
+
inputComponent: column.component,
|
|
35
35
|
};
|
|
36
36
|
return { id: column.id, type };
|
|
37
37
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { onMounted, unref } from "vue";
|
|
3
|
-
import { jsonSchemaToZod } from "json-schema-to-zod";
|
|
4
3
|
import type { FormProps } from "../../../composables/form/types";
|
|
5
4
|
import { FormEvents } from "../../../composables/form/types/events";
|
|
6
5
|
import type {
|
|
@@ -48,9 +47,14 @@ const INTERNAL_STATE_KEYS = new Set([
|
|
|
48
47
|
|
|
49
48
|
function isFormFieldValue(value: unknown): value is FormFieldValue {
|
|
50
49
|
if (value === null || isString(value) || isNumber(value)) return true;
|
|
51
|
-
if (isBoolean(value)) return true;
|
|
50
|
+
if (isBoolean(value) || value instanceof Date) return true;
|
|
52
51
|
if (Array.isArray(value)) return value.every(isFormFieldValue);
|
|
53
|
-
return
|
|
52
|
+
return (
|
|
53
|
+
isPlainObject(value) &&
|
|
54
|
+
Object.values(value).every(
|
|
55
|
+
(entry) => entry === undefined || isFormFieldValue(entry),
|
|
56
|
+
)
|
|
57
|
+
);
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
function parseClonedValue(json: string): FormFieldValue {
|
|
@@ -69,7 +73,12 @@ export function cloneFormValue(value: StateValue): FormFieldValue | undefined {
|
|
|
69
73
|
/** The record a form loaded, cloned by value; what is not a plain record clones to none. */
|
|
70
74
|
export function cloneRecordValues(record: FormData): FormData {
|
|
71
75
|
const cloned = parseClonedValue(JSON.stringify(record));
|
|
72
|
-
|
|
76
|
+
if (!isPlainObject(cloned)) return {};
|
|
77
|
+
const values: FormData = {};
|
|
78
|
+
for (const [key, value] of Object.entries(cloned)) {
|
|
79
|
+
if (value !== undefined) values[key] = value;
|
|
80
|
+
}
|
|
81
|
+
return values;
|
|
73
82
|
}
|
|
74
83
|
|
|
75
84
|
/**
|
|
@@ -142,13 +151,10 @@ export function createBaseValidationSchema(
|
|
|
142
151
|
): z.ZodObject<Record<string, z.ZodTypeAny>> {
|
|
143
152
|
if (!schema) return z.object({});
|
|
144
153
|
try {
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
return zodObjectSchema.parse(
|
|
150
|
-
new Function("z", `"use strict"; return (${zodCode})`)(z),
|
|
151
|
-
);
|
|
154
|
+
const built = zodObjectSchema.parse(z.fromJSONSchema(schema));
|
|
155
|
+
return schema.additionalProperties === false
|
|
156
|
+
? built.loose()
|
|
157
|
+
: z.object(built.shape);
|
|
152
158
|
} catch {
|
|
153
159
|
return z.object({});
|
|
154
160
|
}
|
|
@@ -167,23 +173,27 @@ export function resolveSubmitTarget(
|
|
|
167
173
|
return url === undefined ? { missing: "token" } : { url };
|
|
168
174
|
}
|
|
169
175
|
|
|
176
|
+
/** The values a form's state holds per field, as its inputs read them. */
|
|
177
|
+
export type FormStateValues = { [key: string]: StateValue };
|
|
178
|
+
|
|
179
|
+
/** `data` with each field's value reshaped by its data type's `beforeStateMapper`. */
|
|
170
180
|
export function processBeforeStateMappers(
|
|
171
181
|
data: FormData,
|
|
172
182
|
fields: FormFieldOrGroup[],
|
|
173
183
|
getDataType: (type: string) => DataType | undefined,
|
|
174
|
-
):
|
|
175
|
-
const
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
if (!field.type ||
|
|
184
|
+
): FormStateValues {
|
|
185
|
+
const values = new Map<string, StateValue>(Object.entries({ ...data }));
|
|
186
|
+
for (const field of flattenFields(fields)) {
|
|
187
|
+
const value = values.get(field.id);
|
|
188
|
+
if (!field.type || value === undefined) continue;
|
|
179
189
|
const dataType = getDataType(field.type);
|
|
180
190
|
if (!dataType?.beforeStateMapper) continue;
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
field.component.options,
|
|
184
|
-
)
|
|
191
|
+
values.set(
|
|
192
|
+
field.id,
|
|
193
|
+
dataType.beforeStateMapper(value, field.component.options),
|
|
194
|
+
);
|
|
185
195
|
}
|
|
186
|
-
return
|
|
196
|
+
return Object.fromEntries(values);
|
|
187
197
|
}
|
|
188
198
|
|
|
189
199
|
/** A cleared list submits an empty list; other cleared fields submit null. */
|
|
@@ -294,7 +304,11 @@ export function collectSubmitData(
|
|
|
294
304
|
const initial = context.initialValues?.[field.id];
|
|
295
305
|
if (context.onlyChanged && isSameValue(field, value, initial)) continue;
|
|
296
306
|
if (!isClearedField(field, value)) {
|
|
297
|
-
|
|
307
|
+
const submitted = submittedFieldValue(field, value);
|
|
308
|
+
const sent = isFormFieldValue(submitted)
|
|
309
|
+
? submitted
|
|
310
|
+
: cloneFormValue(submitted);
|
|
311
|
+
if (sent !== undefined) fieldData[field.id] = sent;
|
|
298
312
|
continue;
|
|
299
313
|
}
|
|
300
314
|
if (field.disabled || context.disabled?.has(field.id)) continue;
|
|
@@ -302,7 +316,7 @@ export function collectSubmitData(
|
|
|
302
316
|
fieldData[field.id] = clearedFieldValue(initial);
|
|
303
317
|
}
|
|
304
318
|
return {
|
|
305
|
-
...
|
|
319
|
+
...context.submitDefaults,
|
|
306
320
|
...fieldData,
|
|
307
321
|
};
|
|
308
322
|
}
|
|
@@ -332,7 +346,7 @@ export function fieldValuesOfSubmitDefaults(
|
|
|
332
346
|
if (!submitDefaults) return values;
|
|
333
347
|
for (const { id } of fields) {
|
|
334
348
|
if (id in submitDefaults) {
|
|
335
|
-
values[id] = submitDefaults[id]
|
|
349
|
+
values[id] = submitDefaults[id];
|
|
336
350
|
}
|
|
337
351
|
}
|
|
338
352
|
return values;
|