@camstack/ui-library 1.2.53 → 1.2.55
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/composites/device-list/group.d.ts +11 -0
- package/dist/index.cjs +40 -3
- package/dist/index.js +40 -3
- package/package.json +1 -1
|
@@ -31,4 +31,15 @@ export interface GroupDevicesOptions {
|
|
|
31
31
|
* `display.hidden` flag. A future "show hidden" toggle flips this one prop. */
|
|
32
32
|
readonly includeHidden?: boolean;
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Re-order top-level rows so an ADOPTED device sits immediately after its
|
|
36
|
+
* parent row (a camera adopted by a `Home hub` is a primary row by design,
|
|
37
|
+
* but a primary row whose family is scattered across the table reads as a
|
|
38
|
+
* bug — the operator saw a standalone camera WEDGED between a hub and its
|
|
39
|
+
* two children). Pure and stable: parents/standalone keep their incoming
|
|
40
|
+
* relative order, siblings keep theirs, and a child whose parent is not a
|
|
41
|
+
* top-level row keeps its own position (emitted in the leftover pass —
|
|
42
|
+
* never dropped).
|
|
43
|
+
*/
|
|
44
|
+
export declare function orderAdoptedAfterParent(rows: readonly DeviceItemDevice[]): readonly DeviceItemDevice[];
|
|
34
45
|
export declare function groupTopLevelAndAccessories(devices: readonly DeviceItemDevice[], options?: GroupDevicesOptions): GroupedDevices;
|
package/dist/index.cjs
CHANGED
|
@@ -42026,6 +42026,43 @@ function countableDevices(devices) {
|
|
|
42026
42026
|
});
|
|
42027
42027
|
}
|
|
42028
42028
|
var PARENT_AS_OWNER_TYPES = new Set(["hub", "nvr"]);
|
|
42029
|
+
/**
|
|
42030
|
+
* Re-order top-level rows so an ADOPTED device sits immediately after its
|
|
42031
|
+
* parent row (a camera adopted by a `Home hub` is a primary row by design,
|
|
42032
|
+
* but a primary row whose family is scattered across the table reads as a
|
|
42033
|
+
* bug — the operator saw a standalone camera WEDGED between a hub and its
|
|
42034
|
+
* two children). Pure and stable: parents/standalone keep their incoming
|
|
42035
|
+
* relative order, siblings keep theirs, and a child whose parent is not a
|
|
42036
|
+
* top-level row keeps its own position (emitted in the leftover pass —
|
|
42037
|
+
* never dropped).
|
|
42038
|
+
*/
|
|
42039
|
+
function orderAdoptedAfterParent(rows) {
|
|
42040
|
+
const topIds = new Set(rows.map((d) => d.id));
|
|
42041
|
+
const childrenOf = /* @__PURE__ */ new Map();
|
|
42042
|
+
const roots = [];
|
|
42043
|
+
for (const d of rows) {
|
|
42044
|
+
const parentId = d.parentDeviceId;
|
|
42045
|
+
if (parentId !== null && parentId !== void 0 && parentId !== d.id && topIds.has(parentId)) {
|
|
42046
|
+
const list = childrenOf.get(parentId);
|
|
42047
|
+
if (list) list.push(d);
|
|
42048
|
+
else childrenOf.set(parentId, [d]);
|
|
42049
|
+
continue;
|
|
42050
|
+
}
|
|
42051
|
+
roots.push(d);
|
|
42052
|
+
}
|
|
42053
|
+
const ordered = [];
|
|
42054
|
+
const emitted = /* @__PURE__ */ new Set();
|
|
42055
|
+
const emit = (device) => {
|
|
42056
|
+
if (emitted.has(device.id)) return;
|
|
42057
|
+
emitted.add(device.id);
|
|
42058
|
+
ordered.push(device);
|
|
42059
|
+
const kids = childrenOf.get(device.id);
|
|
42060
|
+
if (kids) for (const kid of kids) emit(kid);
|
|
42061
|
+
};
|
|
42062
|
+
for (const root of roots) emit(root);
|
|
42063
|
+
for (const d of rows) emit(d);
|
|
42064
|
+
return ordered;
|
|
42065
|
+
}
|
|
42029
42066
|
function groupTopLevelAndAccessories(devices, options) {
|
|
42030
42067
|
const includeHidden = options?.includeHidden ?? false;
|
|
42031
42068
|
const byId = /* @__PURE__ */ new Map();
|
|
@@ -42054,7 +42091,7 @@ function groupTopLevelAndAccessories(devices, options) {
|
|
|
42054
42091
|
else accessoriesByParent.set(parentId, [d]);
|
|
42055
42092
|
}
|
|
42056
42093
|
return {
|
|
42057
|
-
topLevel,
|
|
42094
|
+
topLevel: orderAdoptedAfterParent(topLevel),
|
|
42058
42095
|
accessoriesByParent
|
|
42059
42096
|
};
|
|
42060
42097
|
}
|
|
@@ -42959,13 +42996,13 @@ function sortRows(rows, sort) {
|
|
|
42959
42996
|
if (sort === null) return [...rows];
|
|
42960
42997
|
const compare = ascComparator(sort.columnId);
|
|
42961
42998
|
const factor = sort.dir === "asc" ? 1 : -1;
|
|
42962
|
-
return [...rows].toSorted((a, b) => {
|
|
42999
|
+
return orderAdoptedAfterParent([...rows].toSorted((a, b) => {
|
|
42963
43000
|
if (sort.columnId === "manufacturer") {
|
|
42964
43001
|
const aHas = hasManufacturer(a);
|
|
42965
43002
|
if (aHas !== hasManufacturer(b)) return aHas ? -1 : 1;
|
|
42966
43003
|
}
|
|
42967
43004
|
return factor * compare(a, b);
|
|
42968
|
-
});
|
|
43005
|
+
}));
|
|
42969
43006
|
}
|
|
42970
43007
|
//#endregion
|
|
42971
43008
|
//#region src/composites/device-list/device-mode.tsx
|
package/dist/index.js
CHANGED
|
@@ -42002,6 +42002,43 @@ function countableDevices(devices) {
|
|
|
42002
42002
|
});
|
|
42003
42003
|
}
|
|
42004
42004
|
var PARENT_AS_OWNER_TYPES = new Set(["hub", "nvr"]);
|
|
42005
|
+
/**
|
|
42006
|
+
* Re-order top-level rows so an ADOPTED device sits immediately after its
|
|
42007
|
+
* parent row (a camera adopted by a `Home hub` is a primary row by design,
|
|
42008
|
+
* but a primary row whose family is scattered across the table reads as a
|
|
42009
|
+
* bug — the operator saw a standalone camera WEDGED between a hub and its
|
|
42010
|
+
* two children). Pure and stable: parents/standalone keep their incoming
|
|
42011
|
+
* relative order, siblings keep theirs, and a child whose parent is not a
|
|
42012
|
+
* top-level row keeps its own position (emitted in the leftover pass —
|
|
42013
|
+
* never dropped).
|
|
42014
|
+
*/
|
|
42015
|
+
function orderAdoptedAfterParent(rows) {
|
|
42016
|
+
const topIds = new Set(rows.map((d) => d.id));
|
|
42017
|
+
const childrenOf = /* @__PURE__ */ new Map();
|
|
42018
|
+
const roots = [];
|
|
42019
|
+
for (const d of rows) {
|
|
42020
|
+
const parentId = d.parentDeviceId;
|
|
42021
|
+
if (parentId !== null && parentId !== void 0 && parentId !== d.id && topIds.has(parentId)) {
|
|
42022
|
+
const list = childrenOf.get(parentId);
|
|
42023
|
+
if (list) list.push(d);
|
|
42024
|
+
else childrenOf.set(parentId, [d]);
|
|
42025
|
+
continue;
|
|
42026
|
+
}
|
|
42027
|
+
roots.push(d);
|
|
42028
|
+
}
|
|
42029
|
+
const ordered = [];
|
|
42030
|
+
const emitted = /* @__PURE__ */ new Set();
|
|
42031
|
+
const emit = (device) => {
|
|
42032
|
+
if (emitted.has(device.id)) return;
|
|
42033
|
+
emitted.add(device.id);
|
|
42034
|
+
ordered.push(device);
|
|
42035
|
+
const kids = childrenOf.get(device.id);
|
|
42036
|
+
if (kids) for (const kid of kids) emit(kid);
|
|
42037
|
+
};
|
|
42038
|
+
for (const root of roots) emit(root);
|
|
42039
|
+
for (const d of rows) emit(d);
|
|
42040
|
+
return ordered;
|
|
42041
|
+
}
|
|
42005
42042
|
function groupTopLevelAndAccessories(devices, options) {
|
|
42006
42043
|
const includeHidden = options?.includeHidden ?? false;
|
|
42007
42044
|
const byId = /* @__PURE__ */ new Map();
|
|
@@ -42030,7 +42067,7 @@ function groupTopLevelAndAccessories(devices, options) {
|
|
|
42030
42067
|
else accessoriesByParent.set(parentId, [d]);
|
|
42031
42068
|
}
|
|
42032
42069
|
return {
|
|
42033
|
-
topLevel,
|
|
42070
|
+
topLevel: orderAdoptedAfterParent(topLevel),
|
|
42034
42071
|
accessoriesByParent
|
|
42035
42072
|
};
|
|
42036
42073
|
}
|
|
@@ -42935,13 +42972,13 @@ function sortRows(rows, sort) {
|
|
|
42935
42972
|
if (sort === null) return [...rows];
|
|
42936
42973
|
const compare = ascComparator(sort.columnId);
|
|
42937
42974
|
const factor = sort.dir === "asc" ? 1 : -1;
|
|
42938
|
-
return [...rows].toSorted((a, b) => {
|
|
42975
|
+
return orderAdoptedAfterParent([...rows].toSorted((a, b) => {
|
|
42939
42976
|
if (sort.columnId === "manufacturer") {
|
|
42940
42977
|
const aHas = hasManufacturer(a);
|
|
42941
42978
|
if (aHas !== hasManufacturer(b)) return aHas ? -1 : 1;
|
|
42942
42979
|
}
|
|
42943
42980
|
return factor * compare(a, b);
|
|
42944
|
-
});
|
|
42981
|
+
}));
|
|
42945
42982
|
}
|
|
42946
42983
|
//#endregion
|
|
42947
42984
|
//#region src/composites/device-list/device-mode.tsx
|