@jskit-ai/users-web 0.1.36 → 0.1.38

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.
Files changed (79) hide show
  1. package/package.descriptor.mjs +8 -22
  2. package/package.json +16 -11
  3. package/src/client/components/MembersAdminClientElement.vue +5 -5
  4. package/src/client/components/UsersSurfaceAwareMenuLinkItem.vue +14 -25
  5. package/src/client/components/WorkspaceMembersClientElement.vue +19 -19
  6. package/src/client/components/WorkspaceProfileClientElement.vue +1 -1
  7. package/src/client/components/WorkspaceSettingsFieldsClientElement.vue +1 -1
  8. package/src/client/components/WorkspacesClientElement.vue +4 -4
  9. package/src/client/composables/account-settings/accountSettingsAvatarUploadRuntime.js +61 -0
  10. package/src/client/composables/{accountSettingsInvitesRuntime.js → account-settings/accountSettingsInvitesRuntime.js} +1 -1
  11. package/src/client/composables/{accountSettingsRuntimeConstants.js → account-settings/accountSettingsRuntimeConstants.js} +0 -4
  12. package/src/client/composables/{accountSettingsRuntimeHelpers.js → account-settings/accountSettingsRuntimeHelpers.js} +2 -2
  13. package/src/client/composables/crud/crudBindingSupport.js +75 -0
  14. package/src/client/composables/{crudLookupFieldLabelSupport.js → crud/crudLookupFieldLabelSupport.js} +37 -5
  15. package/src/client/composables/{crudLookupFieldRuntime.js → crud/crudLookupFieldRuntime.js} +11 -4
  16. package/src/client/composables/{crudSchemaFormHelpers.js → crud/crudSchemaFormHelpers.js} +178 -5
  17. package/src/client/composables/internal/crudListParentTitleSupport.js +168 -0
  18. package/src/client/composables/internal/useOperationScope.js +1 -1
  19. package/src/client/composables/{useAddEdit.js → records/useAddEdit.js} +18 -8
  20. package/src/client/composables/{useCrudSchemaForm.js → records/useCrudAddEdit.js} +32 -15
  21. package/src/client/composables/records/useCrudList.js +83 -0
  22. package/src/client/composables/records/useCrudView.js +35 -0
  23. package/src/client/composables/records/useList.js +482 -0
  24. package/src/client/composables/{useView.js → records/useView.js} +7 -7
  25. package/src/client/composables/{addEditUiRuntime.js → runtime/addEditUiRuntime.js} +13 -4
  26. package/src/client/composables/{listUiRuntime.js → runtime/listUiRuntime.js} +20 -8
  27. package/src/client/composables/{operationAdapters.js → runtime/operationAdapters.js} +1 -1
  28. package/src/client/composables/{useEndpointResource.js → runtime/useEndpointResource.js} +5 -5
  29. package/src/client/composables/{useListCore.js → runtime/useListCore.js} +4 -4
  30. package/src/client/composables/{useUiFeedback.js → runtime/useUiFeedback.js} +1 -1
  31. package/src/client/composables/{viewUiRuntime.js → runtime/viewUiRuntime.js} +13 -4
  32. package/src/client/composables/support/listQueryParamSupport.js +459 -0
  33. package/src/client/composables/{routeTemplateHelpers.js → support/routeTemplateHelpers.js} +122 -0
  34. package/src/client/composables/useAccess.js +2 -2
  35. package/src/client/composables/useAccountSettingsRuntime.js +6 -6
  36. package/src/client/composables/useBootstrapQuery.js +1 -1
  37. package/src/client/composables/useCommand.js +5 -5
  38. package/src/client/composables/useCrudListParentTitle.js +131 -0
  39. package/src/client/composables/usePagedCollection.js +58 -7
  40. package/src/client/composables/useScopeRuntime.js +1 -1
  41. package/src/client/lib/bootstrap.js +1 -1
  42. package/src/client/lib/menuIcons.js +27 -6
  43. package/src/client/support/menuLinkTarget.js +93 -0
  44. package/templates/src/components/WorkspaceNotFoundCard.vue +2 -1
  45. package/templates/src/components/account/settings/AccountSettingsInvitesSection.vue +1 -1
  46. package/test/addEditUiRuntime.test.js +19 -1
  47. package/test/crudBindingSupport.test.js +110 -0
  48. package/test/crudLookupFieldRuntime.test.js +52 -2
  49. package/test/errorMessageHelpers.test.js +1 -1
  50. package/test/exportsContract.test.js +10 -1
  51. package/test/listQueryParamSupport.test.js +190 -0
  52. package/test/listUiRuntime.test.js +22 -1
  53. package/test/menuIcons.test.js +2 -0
  54. package/test/menuLinkTarget.test.js +116 -0
  55. package/test/permissions.test.js +2 -2
  56. package/test/refValueHelpers.test.js +1 -1
  57. package/test/resourceLoadStateHelpers.test.js +1 -1
  58. package/test/routeTemplateHelpers.test.js +57 -1
  59. package/test/scopeHelpers.test.js +1 -1
  60. package/test/{useCrudSchemaForm.test.js → useCrudAddEdit.test.js} +81 -1
  61. package/test/useCrudListParentTitle.test.js +143 -0
  62. package/test/useListSearchSupport.test.js +1 -1
  63. package/test/usePagedCollection.test.js +53 -0
  64. package/test/viewCoreLoading.test.js +1 -1
  65. package/test/viewUiRuntime.test.js +36 -1
  66. package/src/client/composables/accountSettingsAvatarUploadRuntime.js +0 -241
  67. package/src/client/composables/useList.js +0 -268
  68. /package/src/client/composables/{modelStateHelpers.js → runtime/modelStateHelpers.js} +0 -0
  69. /package/src/client/composables/{operationUiHelpers.js → runtime/operationUiHelpers.js} +0 -0
  70. /package/src/client/composables/{operationValidationHelpers.js → runtime/operationValidationHelpers.js} +0 -0
  71. /package/src/client/composables/{useAddEditCore.js → runtime/useAddEditCore.js} +0 -0
  72. /package/src/client/composables/{useCommandCore.js → runtime/useCommandCore.js} +0 -0
  73. /package/src/client/composables/{useFieldErrorBag.js → runtime/useFieldErrorBag.js} +0 -0
  74. /package/src/client/composables/{useViewCore.js → runtime/useViewCore.js} +0 -0
  75. /package/src/client/composables/{errorMessageHelpers.js → support/errorMessageHelpers.js} +0 -0
  76. /package/src/client/composables/{listSearchSupport.js → support/listSearchSupport.js} +0 -0
  77. /package/src/client/composables/{refValueHelpers.js → support/refValueHelpers.js} +0 -0
  78. /package/src/client/composables/{resourceLoadStateHelpers.js → support/resourceLoadStateHelpers.js} +0 -0
  79. /package/src/client/composables/{scopeHelpers.js → support/scopeHelpers.js} +0 -0
@@ -1,12 +1,12 @@
1
1
  import { computed } from "vue";
2
- import { asPlainObject } from "./scopeHelpers.js";
2
+ import { asPlainObject } from "../support/scopeHelpers.js";
3
3
  import {
4
4
  normalizeRouteParamName,
5
5
  toRouteParamValue,
6
6
  resolveRouteParamsSource,
7
- resolveRoutePathnameSource,
7
+ resolveScopedRoutePathname,
8
8
  resolveRouteTemplateLocation
9
- } from "./routeTemplateHelpers.js";
9
+ } from "../support/routeTemplateHelpers.js";
10
10
 
11
11
  function resolveRecordId(record, recordIdSelector) {
12
12
  const item = asPlainObject(record);
@@ -23,6 +23,7 @@ function createListUiRuntime({
23
23
  recordIdParam = "recordId",
24
24
  recordIdSelector = null,
25
25
  routeParams = null,
26
+ routeParamNames = null,
26
27
  routePath = "",
27
28
  viewUrlTemplate = "",
28
29
  editUrlTemplate = ""
@@ -44,12 +45,23 @@ function createListUiRuntime({
44
45
  return "";
45
46
  }
46
47
 
48
+ const currentRouteParams = resolveRouteParamsSource(routeParams);
49
+ const sourceParams = {
50
+ ...currentRouteParams,
51
+ ...asPlainObject(extraParams)
52
+ };
53
+ const currentPathname = resolveScopedRoutePathname({
54
+ currentPathname: routePath,
55
+ params: currentRouteParams,
56
+ orderedParamNames: routeParamNames,
57
+ anchorParamName: normalizedRecordIdParam,
58
+ anchorParamValue: currentRouteParams[normalizedRecordIdParam],
59
+ anchorMode: "before"
60
+ });
61
+
47
62
  return resolveRouteTemplateLocation(normalizedTemplate, {
48
- params: {
49
- ...resolveRouteParamsSource(routeParams),
50
- ...asPlainObject(extraParams)
51
- },
52
- currentPathname: resolveRoutePathnameSource(routePath)
63
+ params: sourceParams,
64
+ currentPathname
53
65
  });
54
66
  }
55
67
 
@@ -1,4 +1,4 @@
1
- import { useOperationScope } from "./internal/useOperationScope.js";
1
+ import { useOperationScope } from "../internal/useOperationScope.js";
2
2
 
3
3
  const USERS_OPERATION_ADAPTER_ID = "users-default";
4
4
 
@@ -1,10 +1,10 @@
1
1
  import { computed } from "vue";
2
2
  import { useMutation, useQuery } from "@tanstack/vue-query";
3
- import { usersWebHttpClient } from "../lib/httpClient.js";
4
- import { asPlainObject } from "./scopeHelpers.js";
5
- import { resolveEnabledRef, resolveTextRef } from "./refValueHelpers.js";
6
- import { toQueryErrorMessage } from "./errorMessageHelpers.js";
7
- import { hasResolvedQueryData } from "./resourceLoadStateHelpers.js";
3
+ import { usersWebHttpClient } from "../../lib/httpClient.js";
4
+ import { asPlainObject } from "../support/scopeHelpers.js";
5
+ import { resolveEnabledRef, resolveTextRef } from "../support/refValueHelpers.js";
6
+ import { toQueryErrorMessage } from "../support/errorMessageHelpers.js";
7
+ import { hasResolvedQueryData } from "../support/resourceLoadStateHelpers.js";
8
8
 
9
9
  function useEndpointResource({
10
10
  queryKey,
@@ -1,9 +1,9 @@
1
1
  import { computed } from "vue";
2
2
  import { appendQueryString } from "@jskit-ai/kernel/shared/support";
3
- import { usersWebHttpClient } from "../lib/httpClient.js";
4
- import { asPlainObject } from "./scopeHelpers.js";
5
- import { resolveEnabledRef, resolveTextRef } from "./refValueHelpers.js";
6
- import { usePagedCollection } from "./usePagedCollection.js";
3
+ import { usersWebHttpClient } from "../../lib/httpClient.js";
4
+ import { asPlainObject } from "../support/scopeHelpers.js";
5
+ import { resolveEnabledRef, resolveTextRef } from "../support/refValueHelpers.js";
6
+ import { usePagedCollection } from "../usePagedCollection.js";
7
7
 
8
8
  function appendPageParam(path, pageParam) {
9
9
  const normalizedPath = String(path || "").trim();
@@ -1,6 +1,6 @@
1
1
  import { ref } from "vue";
2
2
  import { useShellWebErrorRuntime } from "@jskit-ai/shell-web/client/error";
3
- import { toUiErrorMessage } from "./errorMessageHelpers.js";
3
+ import { toUiErrorMessage } from "../support/errorMessageHelpers.js";
4
4
 
5
5
  function useUiFeedback({
6
6
  initialType = "success",
@@ -1,12 +1,12 @@
1
1
  import { computed, unref } from "vue";
2
- import { asPlainObject } from "./scopeHelpers.js";
2
+ import { asPlainObject } from "../support/scopeHelpers.js";
3
3
  import {
4
4
  normalizeRouteParamName,
5
5
  resolveRouteParamsSource,
6
- resolveRoutePathnameSource,
6
+ resolveScopedRoutePathname,
7
7
  resolveRouteTemplateLocation,
8
8
  toRouteParamValue
9
- } from "./routeTemplateHelpers.js";
9
+ } from "../support/routeTemplateHelpers.js";
10
10
 
11
11
  function resolveRecordId({ routeParams, recordIdParam, routeRecordId }) {
12
12
  const explicitRecordId = toRouteParamValue(
@@ -22,6 +22,7 @@ function resolveRecordId({ routeParams, recordIdParam, routeRecordId }) {
22
22
  function createViewUiRuntime({
23
23
  recordIdParam = "recordId",
24
24
  routeParams = null,
25
+ routeParamNames = null,
25
26
  routePath = "",
26
27
  routeRecordId = null,
27
28
  apiUrlTemplate = "",
@@ -53,10 +54,18 @@ function createViewUiRuntime({
53
54
  routeRecordId
54
55
  });
55
56
  sourceParams[normalizedRecordIdParam] = resolvedRecordId;
57
+ const currentPathname = resolveScopedRoutePathname({
58
+ currentPathname: routePath,
59
+ params: currentRouteParams,
60
+ orderedParamNames: routeParamNames,
61
+ anchorParamName: normalizedRecordIdParam,
62
+ anchorParamValue: resolvedRecordId,
63
+ anchorMode: "at"
64
+ });
56
65
 
57
66
  return resolveRouteTemplateLocation(normalizedTemplate, {
58
67
  params: sourceParams,
59
- currentPathname: resolveRoutePathnameSource(routePath)
68
+ currentPathname
60
69
  });
61
70
  }
62
71
 
@@ -0,0 +1,459 @@
1
+ import { isRef, unref } from "vue";
2
+ import {
3
+ normalizeBoolean,
4
+ normalizeText,
5
+ normalizeUniqueTextList
6
+ } from "@jskit-ai/kernel/shared/support/normalize";
7
+ import { asPlainObject } from "./scopeHelpers.js";
8
+
9
+ const QUERY_PARAM_BINDING_TYPE_TEXT = "text";
10
+ const QUERY_PARAM_BINDING_TYPE_BOOLEAN = "boolean";
11
+ const QUERY_PARAM_BINDING_TYPE_NUMBER = "number";
12
+ const QUERY_PARAM_BINDING_TYPE_ARRAY = "array";
13
+ const QUERY_PARAM_BINDING_TYPE_DATE = "date";
14
+
15
+ function normalizeListSyncToRouteConfig(syncToRoute = false, { defaultSearchParam = "q" } = {}) {
16
+ const source = syncToRoute === true ? {} : asPlainObject(syncToRoute);
17
+ const requested = syncToRoute === true || Object.keys(source).length > 0;
18
+ const queryParamBlacklist = Object.freeze(normalizeUniqueTextList(source.queryParamBlacklist));
19
+ if (!requested || source.enabled === false) {
20
+ return Object.freeze({
21
+ enabled: false,
22
+ mode: "replace",
23
+ syncSearch: false,
24
+ syncQueryParams: false,
25
+ hydrateFromRoute: false,
26
+ searchParam: normalizeText(defaultSearchParam) || "q",
27
+ queryParamBlacklist
28
+ });
29
+ }
30
+
31
+ const mode = normalizeText(source.mode).toLowerCase() === "push" ? "push" : "replace";
32
+ const searchParam = normalizeText(source.searchParam) || normalizeText(defaultSearchParam) || "q";
33
+
34
+ return Object.freeze({
35
+ enabled: true,
36
+ mode,
37
+ syncSearch: source.search !== false,
38
+ syncQueryParams: source.queryParams !== false,
39
+ hydrateFromRoute: source.hydrateFromRoute !== false,
40
+ searchParam,
41
+ queryParamBlacklist
42
+ });
43
+ }
44
+
45
+ function normalizeQueryParamKey(value) {
46
+ return normalizeText(value);
47
+ }
48
+
49
+ function normalizeQueryParamValues(value) {
50
+ const list = Array.isArray(value) ? value : [value];
51
+ const normalizedValues = [];
52
+
53
+ for (const entry of list) {
54
+ const resolvedEntry = unref(entry);
55
+ if (resolvedEntry == null) {
56
+ continue;
57
+ }
58
+
59
+ if (typeof resolvedEntry === "boolean") {
60
+ if (resolvedEntry) {
61
+ normalizedValues.push("1");
62
+ }
63
+ continue;
64
+ }
65
+
66
+ if (typeof resolvedEntry === "number") {
67
+ if (Number.isFinite(resolvedEntry)) {
68
+ normalizedValues.push(String(resolvedEntry));
69
+ }
70
+ continue;
71
+ }
72
+
73
+ if (resolvedEntry instanceof Date) {
74
+ if (!Number.isNaN(resolvedEntry.getTime())) {
75
+ normalizedValues.push(resolvedEntry.toISOString());
76
+ }
77
+ continue;
78
+ }
79
+
80
+ const normalizedText = normalizeText(resolvedEntry);
81
+ if (normalizedText) {
82
+ normalizedValues.push(normalizedText);
83
+ }
84
+ }
85
+
86
+ return normalizedValues;
87
+ }
88
+
89
+ function resolveQueryParamsInput(queryParams, context = {}) {
90
+ if (typeof queryParams === "function") {
91
+ return asPlainObject(queryParams(context));
92
+ }
93
+ return asPlainObject(unref(queryParams));
94
+ }
95
+
96
+ function resolveQueryParamBindingType(value) {
97
+ if (Array.isArray(value)) {
98
+ return QUERY_PARAM_BINDING_TYPE_ARRAY;
99
+ }
100
+ if (typeof value === "boolean") {
101
+ return QUERY_PARAM_BINDING_TYPE_BOOLEAN;
102
+ }
103
+ if (typeof value === "number") {
104
+ return QUERY_PARAM_BINDING_TYPE_NUMBER;
105
+ }
106
+ if (value instanceof Date) {
107
+ return QUERY_PARAM_BINDING_TYPE_DATE;
108
+ }
109
+
110
+ return QUERY_PARAM_BINDING_TYPE_TEXT;
111
+ }
112
+
113
+ function resolveArrayQueryParamItemType(values = []) {
114
+ const list = Array.isArray(values) ? values : [];
115
+ for (const entry of list) {
116
+ if (entry == null) {
117
+ continue;
118
+ }
119
+
120
+ if (typeof entry === "boolean") {
121
+ return QUERY_PARAM_BINDING_TYPE_BOOLEAN;
122
+ }
123
+ if (typeof entry === "number") {
124
+ return QUERY_PARAM_BINDING_TYPE_NUMBER;
125
+ }
126
+ if (entry instanceof Date) {
127
+ return QUERY_PARAM_BINDING_TYPE_DATE;
128
+ }
129
+
130
+ return QUERY_PARAM_BINDING_TYPE_TEXT;
131
+ }
132
+
133
+ return QUERY_PARAM_BINDING_TYPE_TEXT;
134
+ }
135
+
136
+ function createWritableQueryParamBinding({
137
+ source = {},
138
+ rawKey = "",
139
+ rawValue = null,
140
+ key = ""
141
+ } = {}) {
142
+ const valueSourceIsRef = isRef(rawValue);
143
+ const read = valueSourceIsRef
144
+ ? () => rawValue.value
145
+ : () => source[rawKey];
146
+ const write = valueSourceIsRef
147
+ ? (nextValue) => {
148
+ rawValue.value = nextValue;
149
+ }
150
+ : (nextValue) => {
151
+ source[rawKey] = nextValue;
152
+ };
153
+
154
+ const currentValue = read();
155
+ const valueType = resolveQueryParamBindingType(currentValue);
156
+ return {
157
+ key,
158
+ valueType,
159
+ arrayItemType: valueType === QUERY_PARAM_BINDING_TYPE_ARRAY
160
+ ? resolveArrayQueryParamItemType(currentValue)
161
+ : QUERY_PARAM_BINDING_TYPE_TEXT,
162
+ get: read,
163
+ set: write
164
+ };
165
+ }
166
+
167
+ function resolveQueryParamDescriptors(queryParams, context = {}) {
168
+ const source = resolveQueryParamsInput(queryParams, context);
169
+ const descriptorsByKey = new Map();
170
+ const canWriteToSource = typeof queryParams !== "function";
171
+
172
+ for (const [rawKey, rawValue] of Object.entries(source)) {
173
+ const key = normalizeQueryParamKey(rawKey);
174
+ if (!key) {
175
+ continue;
176
+ }
177
+
178
+ const values = normalizeQueryParamValues(rawValue);
179
+ const current = descriptorsByKey.get(key) || {
180
+ key,
181
+ values: [],
182
+ binding: null
183
+ };
184
+ if (values.length > 0) {
185
+ current.values.push(...values);
186
+ }
187
+ if (!current.binding && canWriteToSource) {
188
+ current.binding = createWritableQueryParamBinding({
189
+ source,
190
+ rawKey,
191
+ rawValue,
192
+ key
193
+ });
194
+ }
195
+
196
+ descriptorsByKey.set(key, current);
197
+ }
198
+
199
+ return [...descriptorsByKey.values()].sort((left, right) => left.key.localeCompare(right.key));
200
+ }
201
+
202
+ function resolveActiveQueryParamEntries(descriptors = []) {
203
+ const source = Array.isArray(descriptors) ? descriptors : [];
204
+ return source
205
+ .filter((descriptor) => Array.isArray(descriptor?.values) && descriptor.values.length > 0)
206
+ .map((descriptor) => ({
207
+ key: descriptor.key,
208
+ values: [...descriptor.values]
209
+ }));
210
+ }
211
+
212
+ function resolveWritableQueryParamBindings(descriptors = []) {
213
+ const source = Array.isArray(descriptors) ? descriptors : [];
214
+ return source
215
+ .map((descriptor) => descriptor?.binding || null)
216
+ .filter(Boolean);
217
+ }
218
+
219
+ function buildQueryParamEntriesToken(entries = []) {
220
+ const normalizedEntries = Array.isArray(entries) ? entries : [];
221
+ if (normalizedEntries.length < 1) {
222
+ return "";
223
+ }
224
+
225
+ return normalizedEntries
226
+ .map((entry) => {
227
+ const key = normalizeQueryParamKey(entry?.key);
228
+ const values = Array.isArray(entry?.values)
229
+ ? entry.values.map((value) => normalizeText(value)).filter(Boolean)
230
+ : [];
231
+ if (!key || values.length < 1) {
232
+ return "";
233
+ }
234
+ return `${key}=${values.join(",")}`;
235
+ })
236
+ .filter(Boolean)
237
+ .join("&");
238
+ }
239
+
240
+ function firstRouteQueryValue(value) {
241
+ if (Array.isArray(value)) {
242
+ return value[0];
243
+ }
244
+ return value;
245
+ }
246
+
247
+ function normalizeRouteQueryValues(value) {
248
+ const values = Array.isArray(value) ? value : [value];
249
+ return values
250
+ .map((entry) => normalizeText(entry))
251
+ .filter(Boolean);
252
+ }
253
+
254
+ function parseRouteBooleanValue(value, fallback = false) {
255
+ if (value === undefined) {
256
+ return fallback;
257
+ }
258
+ if (value === null || value === "") {
259
+ return true;
260
+ }
261
+
262
+ try {
263
+ return normalizeBoolean(firstRouteQueryValue(value));
264
+ } catch {
265
+ return fallback;
266
+ }
267
+ }
268
+
269
+ function parseRouteNumberValue(value, fallback = null) {
270
+ if (value === undefined) {
271
+ return null;
272
+ }
273
+
274
+ const normalized = normalizeText(firstRouteQueryValue(value));
275
+ if (!normalized) {
276
+ return null;
277
+ }
278
+
279
+ const parsed = Number(normalized);
280
+ if (!Number.isFinite(parsed)) {
281
+ return fallback;
282
+ }
283
+
284
+ return parsed;
285
+ }
286
+
287
+ function parseRouteDateValue(value, fallback = null) {
288
+ if (value === undefined) {
289
+ return null;
290
+ }
291
+
292
+ const normalized = normalizeText(firstRouteQueryValue(value));
293
+ if (!normalized) {
294
+ return null;
295
+ }
296
+
297
+ const parsed = new Date(normalized);
298
+ if (Number.isNaN(parsed.getTime())) {
299
+ return fallback;
300
+ }
301
+
302
+ return parsed;
303
+ }
304
+
305
+ function parseRouteQueryItemValue(value, itemType = QUERY_PARAM_BINDING_TYPE_TEXT, fallback = null) {
306
+ if (itemType === QUERY_PARAM_BINDING_TYPE_BOOLEAN) {
307
+ try {
308
+ return normalizeBoolean(value);
309
+ } catch {
310
+ return fallback;
311
+ }
312
+ }
313
+ if (itemType === QUERY_PARAM_BINDING_TYPE_NUMBER) {
314
+ const numeric = Number(value);
315
+ return Number.isFinite(numeric) ? numeric : fallback;
316
+ }
317
+ if (itemType === QUERY_PARAM_BINDING_TYPE_DATE) {
318
+ const date = new Date(value);
319
+ return Number.isNaN(date.getTime()) ? fallback : date;
320
+ }
321
+
322
+ const normalized = normalizeText(value);
323
+ return normalized || fallback;
324
+ }
325
+
326
+ function parseRouteBindingValue(binding, routeQueryValue) {
327
+ const valueType = normalizeText(binding?.valueType).toLowerCase();
328
+ if (valueType === QUERY_PARAM_BINDING_TYPE_BOOLEAN) {
329
+ return parseRouteBooleanValue(routeQueryValue, false);
330
+ }
331
+ if (valueType === QUERY_PARAM_BINDING_TYPE_NUMBER) {
332
+ const fallback = typeof binding?.get === "function" ? binding.get() : null;
333
+ return parseRouteNumberValue(routeQueryValue, fallback);
334
+ }
335
+ if (valueType === QUERY_PARAM_BINDING_TYPE_DATE) {
336
+ const fallback = typeof binding?.get === "function" ? binding.get() : null;
337
+ return parseRouteDateValue(routeQueryValue, fallback);
338
+ }
339
+ if (valueType === QUERY_PARAM_BINDING_TYPE_ARRAY) {
340
+ const itemType = normalizeText(binding?.arrayItemType).toLowerCase() || QUERY_PARAM_BINDING_TYPE_TEXT;
341
+ return normalizeRouteQueryValues(routeQueryValue)
342
+ .map((value) => parseRouteQueryItemValue(value, itemType, null))
343
+ .filter((value) => value != null && !(typeof value === "string" && !value));
344
+ }
345
+
346
+ return normalizeText(firstRouteQueryValue(routeQueryValue));
347
+ }
348
+
349
+ function areQueryParamBindingItemsEqual(left, right) {
350
+ if (left === right) {
351
+ return true;
352
+ }
353
+ if (left instanceof Date && right instanceof Date) {
354
+ return left.getTime() === right.getTime();
355
+ }
356
+
357
+ return Object.is(left, right);
358
+ }
359
+
360
+ function areQueryParamBindingValuesEqual(left, right) {
361
+ if (left === right) {
362
+ return true;
363
+ }
364
+ if (left instanceof Date && right instanceof Date) {
365
+ return left.getTime() === right.getTime();
366
+ }
367
+ if (!Array.isArray(left) || !Array.isArray(right)) {
368
+ return Object.is(left, right);
369
+ }
370
+ if (left.length !== right.length) {
371
+ return false;
372
+ }
373
+
374
+ for (let index = 0; index < left.length; index += 1) {
375
+ if (!areQueryParamBindingItemsEqual(left[index], right[index])) {
376
+ return false;
377
+ }
378
+ }
379
+
380
+ return true;
381
+ }
382
+
383
+ function buildRouteQueryCompareToken(query = {}) {
384
+ const source = asPlainObject(query);
385
+ const keys = Object.keys(source).sort();
386
+ const parts = [];
387
+ for (const key of keys) {
388
+ const normalizedKey = normalizeQueryParamKey(key);
389
+ if (!normalizedKey) {
390
+ continue;
391
+ }
392
+
393
+ const normalizedValues = normalizeRouteQueryValues(source[key]);
394
+ if (normalizedValues.length < 1) {
395
+ continue;
396
+ }
397
+
398
+ parts.push(`${normalizedKey}=${normalizedValues.join(",")}`);
399
+ }
400
+
401
+ return parts.join("&");
402
+ }
403
+
404
+ function mergeManagedQueryParamKeyHistory(history = [], keys = []) {
405
+ const merged = new Set();
406
+ for (const key of Array.isArray(history) ? history : []) {
407
+ const normalized = normalizeQueryParamKey(key);
408
+ if (normalized) {
409
+ merged.add(normalized);
410
+ }
411
+ }
412
+ for (const key of Array.isArray(keys) ? keys : []) {
413
+ const normalized = normalizeQueryParamKey(key);
414
+ if (normalized) {
415
+ merged.add(normalized);
416
+ }
417
+ }
418
+
419
+ return [...merged].sort((left, right) => left.localeCompare(right));
420
+ }
421
+
422
+ function resolveRouteSyncManagedKeys({
423
+ searchEnabled = false,
424
+ searchParam = "q",
425
+ syncSearch = false,
426
+ syncQueryParams = false,
427
+ declaredKeys = [],
428
+ keyHistory = []
429
+ } = {}) {
430
+ const managed = new Set();
431
+
432
+ if (syncSearch === true && searchEnabled === true) {
433
+ const normalizedSearchParam = normalizeQueryParamKey(searchParam);
434
+ if (normalizedSearchParam) {
435
+ managed.add(normalizedSearchParam);
436
+ }
437
+ }
438
+
439
+ if (syncQueryParams === true) {
440
+ for (const key of mergeManagedQueryParamKeyHistory(keyHistory, declaredKeys)) {
441
+ managed.add(key);
442
+ }
443
+ }
444
+
445
+ return [...managed].sort((left, right) => left.localeCompare(right));
446
+ }
447
+
448
+ export {
449
+ normalizeListSyncToRouteConfig,
450
+ resolveQueryParamDescriptors,
451
+ resolveActiveQueryParamEntries,
452
+ resolveWritableQueryParamBindings,
453
+ buildQueryParamEntriesToken,
454
+ parseRouteBindingValue,
455
+ areQueryParamBindingValuesEqual,
456
+ buildRouteQueryCompareToken,
457
+ mergeManagedQueryParamKeyHistory,
458
+ resolveRouteSyncManagedKeys
459
+ };