@neovici/cosmoz-queue 1.0.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.
Files changed (143) hide show
  1. package/README.md +3 -0
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +1 -0
  5. package/dist/queue/actions/index.d.ts +22 -0
  6. package/dist/queue/actions/index.d.ts.map +1 -0
  7. package/dist/queue/actions/index.js +20 -0
  8. package/dist/queue/icon.d.ts +2 -0
  9. package/dist/queue/icon.d.ts.map +1 -0
  10. package/dist/queue/icon.js +12 -0
  11. package/dist/queue/icons.d.ts +4 -0
  12. package/dist/queue/icons.d.ts.map +1 -0
  13. package/dist/queue/icons.js +61 -0
  14. package/dist/queue/index.d.ts +8 -0
  15. package/dist/queue/index.d.ts.map +1 -0
  16. package/dist/queue/index.js +5 -0
  17. package/dist/queue/item-click.d.ts +5 -0
  18. package/dist/queue/item-click.d.ts.map +1 -0
  19. package/dist/queue/item-click.js +15 -0
  20. package/dist/queue/list-core/column.d.ts +34 -0
  21. package/dist/queue/list-core/column.d.ts.map +1 -0
  22. package/dist/queue/list-core/column.js +10 -0
  23. package/dist/queue/list-core/index.d.ts +7 -0
  24. package/dist/queue/list-core/index.d.ts.map +1 -0
  25. package/dist/queue/list-core/index.js +6 -0
  26. package/dist/queue/list-core/list-core.d.ts +6 -0
  27. package/dist/queue/list-core/list-core.d.ts.map +1 -0
  28. package/dist/queue/list-core/list-core.js +6 -0
  29. package/dist/queue/list-core/render-generic-actions.d.ts +4 -0
  30. package/dist/queue/list-core/render-generic-actions.d.ts.map +1 -0
  31. package/dist/queue/list-core/render-generic-actions.js +14 -0
  32. package/dist/queue/list-core/render-list-core.d.ts +18 -0
  33. package/dist/queue/list-core/render-list-core.d.ts.map +1 -0
  34. package/dist/queue/list-core/render-list-core.js +42 -0
  35. package/dist/queue/list-core/style.css.d.ts +2 -0
  36. package/dist/queue/list-core/style.css.d.ts.map +1 -0
  37. package/dist/queue/list-core/style.css.js +20 -0
  38. package/dist/queue/list-core/use-inline-actions.d.ts +4 -0
  39. package/dist/queue/list-core/use-inline-actions.d.ts.map +1 -0
  40. package/dist/queue/list-core/use-inline-actions.js +10 -0
  41. package/dist/queue/list-core/use-list-core.d.ts +34 -0
  42. package/dist/queue/list-core/use-list-core.d.ts.map +1 -0
  43. package/dist/queue/list-core/use-list-core.js +36 -0
  44. package/dist/queue/list-core/use-list-state.d.ts +24 -0
  45. package/dist/queue/list-core/use-list-state.d.ts.map +1 -0
  46. package/dist/queue/list-core/use-list-state.js +25 -0
  47. package/dist/queue/list-core/use-more.d.ts +23 -0
  48. package/dist/queue/list-core/use-more.d.ts.map +1 -0
  49. package/dist/queue/list-core/use-more.js +41 -0
  50. package/dist/queue/omnitable.d.ts +19 -0
  51. package/dist/queue/omnitable.d.ts.map +1 -0
  52. package/dist/queue/omnitable.js +31 -0
  53. package/dist/queue/pagination.d.ts +5 -0
  54. package/dist/queue/pagination.d.ts.map +1 -0
  55. package/dist/queue/pagination.js +10 -0
  56. package/dist/queue/queue.d.ts +24 -0
  57. package/dist/queue/queue.d.ts.map +1 -0
  58. package/dist/queue/queue.js +58 -0
  59. package/dist/queue/render.d.ts +74 -0
  60. package/dist/queue/render.d.ts.map +1 -0
  61. package/dist/queue/render.js +134 -0
  62. package/dist/queue/style.d.ts +7 -0
  63. package/dist/queue/style.d.ts.map +1 -0
  64. package/dist/queue/style.js +182 -0
  65. package/dist/queue/test/__snapshots__/render.test.snap.d.ts +2 -0
  66. package/dist/queue/test/__snapshots__/render.test.snap.d.ts.map +1 -0
  67. package/dist/queue/test/__snapshots__/render.test.snap.js +64 -0
  68. package/dist/queue/test/item-click.test.d.ts +2 -0
  69. package/dist/queue/test/item-click.test.d.ts.map +1 -0
  70. package/dist/queue/test/item-click.test.js +28 -0
  71. package/dist/queue/test/render.test.d.ts +2 -0
  72. package/dist/queue/test/render.test.d.ts.map +1 -0
  73. package/dist/queue/test/render.test.js +27 -0
  74. package/dist/queue/test/use-pref.test.d.ts +2 -0
  75. package/dist/queue/test/use-pref.test.d.ts.map +1 -0
  76. package/dist/queue/test/use-pref.test.js +16 -0
  77. package/dist/queue/types.d.ts +10 -0
  78. package/dist/queue/types.d.ts.map +1 -0
  79. package/dist/queue/types.js +1 -0
  80. package/dist/queue/use-async-action.d.ts +15 -0
  81. package/dist/queue/use-async-action.d.ts.map +1 -0
  82. package/dist/queue/use-async-action.js +17 -0
  83. package/dist/queue/use-data-nav.d.ts +20 -0
  84. package/dist/queue/use-data-nav.d.ts.map +1 -0
  85. package/dist/queue/use-data-nav.js +59 -0
  86. package/dist/queue/use-data-service.d.ts +31 -0
  87. package/dist/queue/use-data-service.d.ts.map +1 -0
  88. package/dist/queue/use-data-service.js +26 -0
  89. package/dist/queue/use-fetch-actions.d.ts +42 -0
  90. package/dist/queue/use-fetch-actions.d.ts.map +1 -0
  91. package/dist/queue/use-fetch-actions.js +38 -0
  92. package/dist/queue/use-key-nav.d.ts +8 -0
  93. package/dist/queue/use-key-nav.d.ts.map +1 -0
  94. package/dist/queue/use-key-nav.js +49 -0
  95. package/dist/queue/use-list-sse.d.ts +42 -0
  96. package/dist/queue/use-list-sse.d.ts.map +1 -0
  97. package/dist/queue/use-list-sse.js +82 -0
  98. package/dist/queue/use-list.d.ts +33 -0
  99. package/dist/queue/use-list.d.ts.map +1 -0
  100. package/dist/queue/use-list.js +42 -0
  101. package/dist/queue/use-pref.d.ts +5 -0
  102. package/dist/queue/use-pref.d.ts.map +1 -0
  103. package/dist/queue/use-pref.js +11 -0
  104. package/dist/queue/use-queue.d.ts +132 -0
  105. package/dist/queue/use-queue.d.ts.map +1 -0
  106. package/dist/queue/use-queue.js +69 -0
  107. package/dist/queue/use-split.d.ts +8 -0
  108. package/dist/queue/use-split.d.ts.map +1 -0
  109. package/dist/queue/use-split.js +30 -0
  110. package/dist/queue/use-tabs.d.ts +54 -0
  111. package/dist/queue/use-tabs.d.ts.map +1 -0
  112. package/dist/queue/use-tabs.js +31 -0
  113. package/dist/queue/use-updates.d.ts +9 -0
  114. package/dist/queue/use-updates.d.ts.map +1 -0
  115. package/dist/queue/use-updates.js +17 -0
  116. package/dist/queue/util.d.ts +4 -0
  117. package/dist/queue/util.d.ts.map +1 -0
  118. package/dist/queue/util.js +16 -0
  119. package/dist/types/dialogable.d.ts +39 -0
  120. package/dist/types/dialogable.d.ts.map +1 -0
  121. package/dist/types/dialogable.js +5 -0
  122. package/dist/types/performable.d.ts +5 -0
  123. package/dist/types/performable.d.ts.map +1 -0
  124. package/dist/types/performable.js +1 -0
  125. package/dist/util/dom/active-element.d.ts +3 -0
  126. package/dist/util/dom/active-element.d.ts.map +1 -0
  127. package/dist/util/dom/active-element.js +11 -0
  128. package/dist/util/fetch/fetch.d.ts +41 -0
  129. package/dist/util/fetch/fetch.d.ts.map +1 -0
  130. package/dist/util/fetch/fetch.js +74 -0
  131. package/dist/util/fetch/url.d.ts +30 -0
  132. package/dist/util/fetch/url.d.ts.map +1 -0
  133. package/dist/util/fetch/url.js +29 -0
  134. package/dist/util/path.d.ts +42 -0
  135. package/dist/util/path.d.ts.map +1 -0
  136. package/dist/util/path.js +68 -0
  137. package/dist/util/polymer-property-changed-event.d.ts +6 -0
  138. package/dist/util/polymer-property-changed-event.d.ts.map +1 -0
  139. package/dist/util/polymer-property-changed-event.js +27 -0
  140. package/dist/util/test/path.test.d.ts +2 -0
  141. package/dist/util/test/path.test.d.ts.map +1 -0
  142. package/dist/util/test/path.test.js +99 -0
  143. package/package.json +113 -0
@@ -0,0 +1,74 @@
1
+ export class RequestError extends Error {
2
+ response;
3
+ data;
4
+ constructor(message, response, data) {
5
+ super(message);
6
+ this.name = 'RequestError';
7
+ this.response = response;
8
+ this.data = data;
9
+ }
10
+ }
11
+ export const notice = (data) => {
12
+ if (data && typeof data === 'object') {
13
+ const obj = data, message = obj.message ??
14
+ obj.Message ??
15
+ obj.friendlyMessage ??
16
+ obj.error?.httpMessage ??
17
+ obj.errors?.map((err) => err.message).join(' ');
18
+ if (message)
19
+ return message;
20
+ }
21
+ return 'Unknown error';
22
+ };
23
+ const baseInit = {};
24
+ export const setBaseInit = (init) => {
25
+ const mergedObject = {
26
+ ...baseInit,
27
+ ...init,
28
+ headers: { ...baseInit.headers, ...init.headers },
29
+ };
30
+ return Object.assign(baseInit, mergedObject);
31
+ };
32
+ export const fetch = (url, opts) => window.fetch(url, {
33
+ ...baseInit,
34
+ mode: 'cors',
35
+ credentials: 'include',
36
+ ...opts,
37
+ headers: {
38
+ ...baseInit?.headers,
39
+ ...opts?.headers,
40
+ },
41
+ });
42
+ export const handleJSON = (res) => {
43
+ if (res.status === 204) {
44
+ return '';
45
+ }
46
+ const json = res.json();
47
+ return res.ok
48
+ ? json.catch(() => '')
49
+ : json.then((data) => Promise.reject(new RequestError(notice(data), res, data)), (error) => {
50
+ if (res.status === 404) {
51
+ return Promise.reject(new RequestError('URL not found: ' + res.url, res));
52
+ }
53
+ return Promise.reject(error);
54
+ });
55
+ };
56
+ /**
57
+ * @deprecated
58
+ */
59
+ export const json = (url, { fetch: _fetch = fetch, handleJSON: _handleJSON = handleJSON, ...opts } = {}) => _fetch(url, opts).then(_handleJSON);
60
+ /**
61
+ * @deprecated
62
+ */
63
+ export const jsonPost = (url, body, opts) => json(url, {
64
+ method: 'POST',
65
+ ...(body ? { body: JSON.stringify(body) } : {}),
66
+ ...opts,
67
+ headers: {
68
+ 'Content-Type': 'application/json',
69
+ ...opts?.headers,
70
+ },
71
+ });
72
+ export const jsonPut = (url, body, opts) => jsonPost(url, body, { method: 'PUT', ...opts });
73
+ export const jsonPatch = (url, body, opts) => jsonPost(url, body, { method: 'PATCH', ...opts });
74
+ export const jsonDelete = (url, body, opts) => jsonPost(url, body, { method: 'DELETE', ...opts });
@@ -0,0 +1,30 @@
1
+ export type ParamValue = string | string[] | boolean | number | null | undefined;
2
+ export declare const toURLSearchParams: <T extends Record<string, ParamValue>>(obj: T) => URLSearchParams;
3
+ declare global {
4
+ interface Cz {
5
+ options: {
6
+ backendBaseUri: string;
7
+ googleClientId?: string;
8
+ idp?: string;
9
+ };
10
+ state: {
11
+ currentLocationPath: string;
12
+ };
13
+ }
14
+ interface Window {
15
+ cz: Cz;
16
+ }
17
+ }
18
+ /**
19
+ * @deprecated
20
+ */
21
+ export declare function apiUrl(api: string): string;
22
+ /**
23
+ * @deprecated
24
+ */
25
+ export declare function apiUrl(api: string, params?: Record<string, ParamValue>): string;
26
+ /**
27
+ * @deprecated This is a bad pattern to use and it's present only for legacy purposes.
28
+ */
29
+ export declare function guardUrl(url: string, deps?: unknown[]): string | undefined;
30
+ //# sourceMappingURL=url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../../src/util/fetch/url.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GACnB,MAAM,GACN,MAAM,EAAE,GACR,OAAO,GACP,MAAM,GACN,IAAI,GACJ,SAAS,CAAC;AAEb,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EACrE,KAAK,CAAC,oBAkBN,CAAC;AAEF,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,EAAE;QACX,OAAO,EAAE;YACR,cAAc,EAAE,MAAM,CAAC;YACvB,cAAc,CAAC,EAAE,MAAM,CAAC;YACxB,GAAG,CAAC,EAAE,MAAM,CAAC;SACb,CAAC;QACF,KAAK,EAAE;YACN,mBAAmB,EAAE,MAAM,CAAC;SAC5B,CAAC;KACF;IACD,UAAU,MAAM;QACf,EAAE,EAAE,EAAE,CAAC;KACP;CACD;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;AAC5C;;GAEG;AACH,wBAAgB,MAAM,CACrB,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GACjC,MAAM,CAAC;AAmBV;;GAEG;AACH,wBAAgB,QAAQ,CACvB,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,OAAO,EAAO,GAClB,MAAM,GAAG,SAAS,CAMpB"}
@@ -0,0 +1,29 @@
1
+ export const toURLSearchParams = (obj) => {
2
+ const entries = Object.entries(obj), simpleParams = Object.fromEntries(entries.filter(([, value]) => !Array.isArray(value) && value !== undefined)), allParams = new URLSearchParams(simpleParams);
3
+ // handle arrays
4
+ entries
5
+ .filter((entry) => Array.isArray(entry[1]))
6
+ .forEach(([key, values]) => values.forEach((value) => allParams.append(key, value)));
7
+ return allParams;
8
+ };
9
+ /**
10
+ * @deprecated
11
+ */
12
+ export function apiUrl(api, params = {}) {
13
+ const baseUrl = window.cz.options.backendBaseUri, url = new URL(api, baseUrl);
14
+ url.search = toURLSearchParams({
15
+ ...Object.fromEntries(url.searchParams),
16
+ ...params,
17
+ });
18
+ return `${url}`;
19
+ }
20
+ /**
21
+ * @deprecated This is a bad pattern to use and it's present only for legacy purposes.
22
+ */
23
+ export function guardUrl(url, deps = []) {
24
+ // bail if any required dependencies are undefined
25
+ if (deps.some((dep) => dep == null)) {
26
+ return;
27
+ }
28
+ return url;
29
+ }
@@ -0,0 +1,42 @@
1
+ type PathMember = string | number;
2
+ type Path = string | PathMember[];
3
+ /**
4
+ * Converts array-based paths to flattened path. String-based paths
5
+ * are returned as-is.
6
+ *
7
+ * Example:
8
+ *
9
+ * ```
10
+ * normalize(['foo.bar', 0, 'baz']) // 'foo.bar.0.baz'
11
+ * normalize('foo.bar.0.baz') // 'foo.bar.0.baz'
12
+ * ```
13
+ * @param {Path} path Input path
14
+ * @return {string} Flattened path
15
+ */
16
+ export declare const normalize: (path: Path) => string;
17
+ /**
18
+ * Splits a path into an array of property names. Accepts either arrays
19
+ * of path parts or strings.
20
+ *
21
+ * Example:
22
+ *
23
+ * ```
24
+ * split(['foo.bar', 0, 'baz']) // ['foo', 'bar', '0', 'baz']
25
+ * split('foo.bar.0.baz') // ['foo', 'bar', '0', 'baz']
26
+ * ```
27
+ * @param {Path} path Input path
28
+ * @return {string[]} Array of path parts
29
+ */
30
+ export declare const split: (path: Path) => string[];
31
+ /**
32
+ * Reads a value from a path. If any sub-property in the path is `undefined`,
33
+ * this method returns `undefined` (will never throw.
34
+ *
35
+ * @param {Object} root Object from which to dereference path from
36
+ * @param {Path} path Path to read
37
+ * @return {*} Value at path, or `undefined` if the path could not be
38
+ * fully dereferenced.
39
+ */
40
+ export declare const get: (root: unknown, path: Path) => unknown;
41
+ export {};
42
+ //# sourceMappingURL=path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/util/path.ts"],"names":[],"mappings":"AAEA,KAAK,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;AAClC,KAAK,IAAI,GAAG,MAAM,GAAG,UAAU,EAAE,CAAC;AAElC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,IAAI,KAAG,MAatC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,KAAK,GAAI,MAAM,IAAI,KAAG,MAAM,EAKxC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,GAAG,GAAI,MAAM,OAAO,EAAE,MAAM,IAAI,YAY5C,CAAC"}
@@ -0,0 +1,68 @@
1
+ // copied from @polymer/polymer/lib/utils/path.js
2
+ /**
3
+ * Converts array-based paths to flattened path. String-based paths
4
+ * are returned as-is.
5
+ *
6
+ * Example:
7
+ *
8
+ * ```
9
+ * normalize(['foo.bar', 0, 'baz']) // 'foo.bar.0.baz'
10
+ * normalize('foo.bar.0.baz') // 'foo.bar.0.baz'
11
+ * ```
12
+ * @param {Path} path Input path
13
+ * @return {string} Flattened path
14
+ */
15
+ export const normalize = (path) => {
16
+ if (Array.isArray(path)) {
17
+ const parts = [];
18
+ for (let i = 0; i < path.length; i++) {
19
+ const args = path[i].toString().split('.');
20
+ for (let j = 0; j < args.length; j++) {
21
+ parts.push(args[j]);
22
+ }
23
+ }
24
+ return parts.join('.');
25
+ }
26
+ return path;
27
+ };
28
+ /**
29
+ * Splits a path into an array of property names. Accepts either arrays
30
+ * of path parts or strings.
31
+ *
32
+ * Example:
33
+ *
34
+ * ```
35
+ * split(['foo.bar', 0, 'baz']) // ['foo', 'bar', '0', 'baz']
36
+ * split('foo.bar.0.baz') // ['foo', 'bar', '0', 'baz']
37
+ * ```
38
+ * @param {Path} path Input path
39
+ * @return {string[]} Array of path parts
40
+ */
41
+ export const split = (path) => {
42
+ if (Array.isArray(path)) {
43
+ return normalize(path).split('.');
44
+ }
45
+ return path.toString().split('.');
46
+ };
47
+ /**
48
+ * Reads a value from a path. If any sub-property in the path is `undefined`,
49
+ * this method returns `undefined` (will never throw.
50
+ *
51
+ * @param {Object} root Object from which to dereference path from
52
+ * @param {Path} path Path to read
53
+ * @return {*} Value at path, or `undefined` if the path could not be
54
+ * fully dereferenced.
55
+ */
56
+ export const get = (root, path) => {
57
+ let prop = root;
58
+ const parts = split(path);
59
+ // Loop over path parts[0..n-1] and dereference
60
+ for (let i = 0; i < parts.length; i++) {
61
+ if (!prop) {
62
+ return;
63
+ }
64
+ const part = parts[i];
65
+ prop = prop[part];
66
+ }
67
+ return prop;
68
+ };
@@ -0,0 +1,6 @@
1
+ type Setter<T> = (v: T) => void;
2
+ type Handler<T> = (e: CustomEvent<T>) => void;
3
+ export declare function updateWith<T>(setter: Setter<T>): Handler<T>;
4
+ export declare function updateWith<T>(setter?: Setter<T>): Handler<T> | void;
5
+ export {};
6
+ //# sourceMappingURL=polymer-property-changed-event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polymer-property-changed-event.d.ts","sourceRoot":"","sources":["../../src/util/polymer-property-changed-event.ts"],"names":[],"mappings":"AAAA,KAAK,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC;AAChC,KAAK,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AAmB9C,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAC7D,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC"}
@@ -0,0 +1,27 @@
1
+ const getPolymerPropertyValueFromUpdateEventDetail = (detail) => {
2
+ if (detail == null) {
3
+ return;
4
+ }
5
+ const subPath = detail?.path?.split('.')[1];
6
+ switch (subPath) {
7
+ case 'length':
8
+ return;
9
+ case 'splices':
10
+ return detail?.value?.indexSplices?.reduce((agg, splice) => {
11
+ return [...splice.object]; // shallow copy
12
+ }, []);
13
+ default:
14
+ return detail.value;
15
+ }
16
+ };
17
+ export function updateWith(setter) {
18
+ if (!setter)
19
+ return;
20
+ return (event) => {
21
+ const newValue = getPolymerPropertyValueFromUpdateEventDetail(event?.detail);
22
+ if (newValue === undefined) {
23
+ return;
24
+ }
25
+ setter(newValue);
26
+ };
27
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=path.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path.test.d.ts","sourceRoot":"","sources":["../../../src/util/test/path.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,99 @@
1
+ import { assert } from '@open-wc/testing';
2
+ import { get, normalize, split } from '../path';
3
+ suite('path', () => {
4
+ suite('normalize', () => {
5
+ test('returns string path as-is', () => {
6
+ assert.equal(normalize('foo.bar.0.baz'), 'foo.bar.0.baz');
7
+ });
8
+ test('returns empty string as-is', () => {
9
+ assert.equal(normalize(''), '');
10
+ });
11
+ test('converts array path to flattened string', () => {
12
+ assert.equal(normalize(['foo.bar', 0, 'baz']), 'foo.bar.0.baz');
13
+ });
14
+ test('handles array with single element', () => {
15
+ assert.equal(normalize(['foo']), 'foo');
16
+ });
17
+ test('handles array with dotted strings and numbers', () => {
18
+ assert.equal(normalize(['a.b', 1, 'c.d', 2]), 'a.b.1.c.d.2');
19
+ });
20
+ test('handles empty array', () => {
21
+ assert.equal(normalize([]), '');
22
+ });
23
+ });
24
+ suite('split', () => {
25
+ test('splits string path into array', () => {
26
+ assert.deepEqual(split('foo.bar.0.baz'), ['foo', 'bar', '0', 'baz']);
27
+ });
28
+ test('splits array path into flat array', () => {
29
+ assert.deepEqual(split(['foo.bar', 0, 'baz']), [
30
+ 'foo',
31
+ 'bar',
32
+ '0',
33
+ 'baz',
34
+ ]);
35
+ });
36
+ test('handles single segment string', () => {
37
+ assert.deepEqual(split('foo'), ['foo']);
38
+ });
39
+ test('handles array with single element', () => {
40
+ assert.deepEqual(split(['foo']), ['foo']);
41
+ });
42
+ test('handles empty string', () => {
43
+ assert.deepEqual(split(''), ['']);
44
+ });
45
+ });
46
+ suite('get', () => {
47
+ test('retrieves nested value with string path', () => {
48
+ const obj = { foo: { bar: { baz: 'value' } } };
49
+ assert.equal(get(obj, 'foo.bar.baz'), 'value');
50
+ });
51
+ test('retrieves nested value with array path', () => {
52
+ const obj = { foo: { bar: { baz: 'value' } } };
53
+ assert.equal(get(obj, ['foo', 'bar', 'baz']), 'value');
54
+ });
55
+ test('retrieves nested value with dotted string in array path', () => {
56
+ const obj = { foo: { bar: { baz: 'value' } } };
57
+ assert.equal(get(obj, ['foo.bar', 'baz']), 'value');
58
+ });
59
+ test('retrieves array element by index', () => {
60
+ const obj = { items: ['a', 'b', 'c'] };
61
+ assert.equal(get(obj, 'items.1'), 'b');
62
+ });
63
+ test('retrieves array element with array path', () => {
64
+ const obj = { items: ['a', 'b', 'c'] };
65
+ assert.equal(get(obj, ['items', 0]), 'a');
66
+ });
67
+ test('returns undefined for non-existent path', () => {
68
+ const obj = { foo: { bar: 'value' } };
69
+ assert.equal(get(obj, 'foo.baz.qux'), undefined);
70
+ });
71
+ test('returns undefined when intermediate property is undefined', () => {
72
+ const obj = { foo: undefined };
73
+ assert.equal(get(obj, 'foo.bar'), undefined);
74
+ });
75
+ test('returns undefined when intermediate property is null', () => {
76
+ const obj = { foo: null };
77
+ assert.equal(get(obj, 'foo.bar'), undefined);
78
+ });
79
+ test('returns undefined with empty string path', () => {
80
+ const obj = { foo: 'bar' };
81
+ assert.equal(get(obj, ''), undefined);
82
+ });
83
+ test('handles complex nested structure', () => {
84
+ const obj = {
85
+ users: [
86
+ { name: 'Alice', address: { city: 'NYC' } },
87
+ { name: 'Bob', address: { city: 'LA' } },
88
+ ],
89
+ };
90
+ assert.equal(get(obj, 'users.1.address.city'), 'LA');
91
+ });
92
+ test('returns undefined for null root', () => {
93
+ assert.equal(get(null, 'foo'), undefined);
94
+ });
95
+ test('returns undefined for undefined root', () => {
96
+ assert.equal(get(undefined, 'foo'), undefined);
97
+ });
98
+ });
99
+ });
package/package.json ADDED
@@ -0,0 +1,113 @@
1
+ {
2
+ "name": "@neovici/cosmoz-queue",
3
+ "version": "1.0.0",
4
+ "description": "A reusable queue component for master-detail views with list, split, and queue modes",
5
+ "keywords": [
6
+ "web-components",
7
+ "queue",
8
+ "master-detail",
9
+ "split-view",
10
+ "pion",
11
+ "lit-html"
12
+ ],
13
+ "homepage": "https://github.com/neovici/cosmoz-queue#readme",
14
+ "bugs": {
15
+ "url": "https://github.com/neovici/cosmoz-queue/issues"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/neovici/cosmoz-queue.git"
20
+ },
21
+ "license": "Apache-2.0",
22
+ "author": "",
23
+ "main": "dist/index.js",
24
+ "type": "module",
25
+ "directories": {
26
+ "test": "test"
27
+ },
28
+ "scripts": {
29
+ "lint": "tsc && eslint --cache .",
30
+ "build": "tsc -p tsconfig.build.json",
31
+ "start": "wds",
32
+ "test": "wtr --coverage",
33
+ "test:watch": "wtr --watch",
34
+ "dev": "npm run storybook:start",
35
+ "storybook:start": "storybook dev -p 8000",
36
+ "storybook:build": "storybook build",
37
+ "storybook:deploy": "storybook-to-ghpages",
38
+ "storybook:preview": "npm run storybook:build && http-server -d ./storybook-static/",
39
+ "prepare": "husky"
40
+ },
41
+ "release": {
42
+ "plugins": [
43
+ "@semantic-release/commit-analyzer",
44
+ "@semantic-release/release-notes-generator",
45
+ "@semantic-release/changelog",
46
+ "@semantic-release/github",
47
+ "@semantic-release/npm",
48
+ "@semantic-release/git"
49
+ ],
50
+ "branch": "master",
51
+ "preset": "conventionalcommits"
52
+ },
53
+ "publishConfig": {
54
+ "access": "public"
55
+ },
56
+ "files": [
57
+ "dist/",
58
+ "types"
59
+ ],
60
+ "exports": {
61
+ ".": "./dist/index.js",
62
+ "./use-queue": "./dist/queue/use-queue.js",
63
+ "./use-tabs": "./dist/queue/use-tabs.js",
64
+ "./use-split": "./dist/queue/use-split.js",
65
+ "./use-data-nav": "./dist/queue/use-data-nav.js",
66
+ "./use-list": "./dist/queue/use-list.js"
67
+ },
68
+ "dependencies": {
69
+ "@neovici/cosmoz-dialog-next": "^1.1.1",
70
+ "@neovici/cosmoz-form": "^1.0.1",
71
+ "@neovici/cosmoz-i18next": "^3.5.1",
72
+ "@neovici/cosmoz-omnitable": "^16.0.3",
73
+ "@neovici/cosmoz-router": "^11.2.8",
74
+ "@neovici/cosmoz-slider": "^5.2.1",
75
+ "@neovici/cosmoz-tabs": "^9.3.2",
76
+ "@neovici/cosmoz-utils": "^6.14.2",
77
+ "@neovici/cosmoz-viewinfo": "^4.1.1",
78
+ "@pionjs/pion": "^2.10.0",
79
+ "i18next": "^25.7.4",
80
+ "lit-html": "^3.3.1",
81
+ "split.js": "^1.6.5"
82
+ },
83
+ "devDependencies": {
84
+ "@commitlint/cli": "^19.2.1",
85
+ "@commitlint/config-conventional": "^19.1.0",
86
+ "@eslint/eslintrc": "^2.0.0",
87
+ "@neovici/cfg": "^2.0.0",
88
+ "@neovici/testing": "^2.0.0",
89
+ "@open-wc/testing": "^4.0.0",
90
+ "@open-wc/testing-helpers": "^3.0.1",
91
+ "@semantic-release/changelog": "^6.0.0",
92
+ "@semantic-release/git": "^10.0.0",
93
+ "@storybook/addon-links": "^10.0.0",
94
+ "@storybook/web-components": "^10.0.0",
95
+ "@storybook/web-components-vite": "^10.0.0",
96
+ "@types/mocha": "^10.0.6",
97
+ "@types/node": "^22.10.2",
98
+ "@types/split.js": "^1.6.0",
99
+ "@web/dev-server-esbuild": "^1.0.4",
100
+ "@web/test-runner-playwright": "^0.11.1",
101
+ "esbuild": "^0.27.0",
102
+ "http-server": "^14.1.1",
103
+ "husky": "^9.0.11",
104
+ "semantic-release": "^24.0.0",
105
+ "sinon": "^19.0.0",
106
+ "storybook": "^10.0.0",
107
+ "typescript": "^5.4.3"
108
+ },
109
+ "overrides": {
110
+ "conventional-changelog-conventionalcommits": ">= 8.0.0",
111
+ "@polymer/polymer": "^3.5.2"
112
+ }
113
+ }