@sukramj/fabric-ui 0.1.2 → 0.2.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 +14 -1
- package/package.json +1 -1
- package/src/lib/api/client.ts +134 -1
- package/src/lib/api/schema.gen.ts +1838 -264
- package/src/lib/api/stream.ts +40 -1
- package/src/lib/context.ts +15 -2
- package/src/lib/controller-store.svelte.ts +175 -0
- package/src/lib/i18n/de.json +212 -1
- package/src/lib/i18n/en.json +212 -1
- package/src/lib/index.ts +1 -0
- package/src/lib/pages/controller/Commission.svelte +180 -0
- package/src/lib/pages/controller/Node.svelte +91 -0
- package/src/lib/pages/controller/Nodes.svelte +156 -0
- package/src/lib/pages/controller/Settings.svelte +160 -0
- package/src/lib/pages/controller/format.ts +49 -0
- package/src/lib/pages/controller/node/Acl.svelte +151 -0
- package/src/lib/pages/controller/node/Attributes.svelte +100 -0
- package/src/lib/pages/controller/node/Bindings.svelte +114 -0
- package/src/lib/pages/controller/node/Endpoints.svelte +49 -0
- package/src/lib/pages/controller/node/Fabrics.svelte +83 -0
- package/src/lib/pages/controller/node/Icd.svelte +92 -0
- package/src/lib/pages/controller/node/Overview.svelte +81 -0
- package/src/lib/pages/controller/node/Updates.svelte +75 -0
- package/src/lib/pages/controller/node/Window.svelte +80 -0
- package/src/lib/pages/index.ts +7 -1
- package/src/lib/pages/node/Selection.svelte +11 -6
- package/src/lib/pages/node/fields.ts +47 -12
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
// List-valued item fields (Column.multi, Filter.multi): the provider
|
|
2
|
-
// carries
|
|
2
|
+
// carries the values in `lists[key]`, one entry per value, so a value may
|
|
3
|
+
// contain a comma. The comma-separated `fields[key]` is the deprecated
|
|
4
|
+
// fallback (until v0.2.0), read only when `lists` has no such key.
|
|
3
5
|
|
|
4
|
-
/** The
|
|
6
|
+
/** The part of an item the list helpers read. */
|
|
7
|
+
export type ListSource = {
|
|
8
|
+
fields: Record<string, string>;
|
|
9
|
+
lists?: Record<string, string[]>;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The values of a comma-separated field, trimmed, without empty ones.
|
|
14
|
+
*
|
|
15
|
+
* @deprecated The comma form is accepted until v0.2.0; read
|
|
16
|
+
* {@link itemValues}, which prefers `lists`.
|
|
17
|
+
*/
|
|
5
18
|
export function listValues(field: string | undefined): string[] {
|
|
6
19
|
if (!field) return [];
|
|
7
20
|
return field
|
|
@@ -11,22 +24,44 @@ export function listValues(field: string | undefined): string[] {
|
|
|
11
24
|
}
|
|
12
25
|
|
|
13
26
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
27
|
+
* The values of an item's list-valued field: `lists[key]` when the key is
|
|
28
|
+
* present there (empty entries dropped, the rest as given), otherwise the
|
|
29
|
+
* comma split of `fields[key]`.
|
|
30
|
+
*/
|
|
31
|
+
export function itemValues(item: ListSource, key: string): string[] {
|
|
32
|
+
const list = item.lists?.[key];
|
|
33
|
+
if (list) return list.filter((v) => v !== "");
|
|
34
|
+
return listValues(item.fields[key]);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Whether an item matches a filter value on a field: by equality, or, for
|
|
39
|
+
* a list-valued field, by membership in its list. An empty value never
|
|
16
40
|
* matches a list.
|
|
17
41
|
*/
|
|
18
|
-
export function fieldMatches(
|
|
19
|
-
|
|
42
|
+
export function fieldMatches(
|
|
43
|
+
item: ListSource,
|
|
44
|
+
key: string,
|
|
45
|
+
value: string,
|
|
46
|
+
multi: boolean,
|
|
47
|
+
): boolean {
|
|
48
|
+
if (!multi) return item.fields[key] === value;
|
|
20
49
|
const v = value.trim();
|
|
21
|
-
return v !== "" &&
|
|
50
|
+
return v !== "" && itemValues(item, key).includes(v);
|
|
22
51
|
}
|
|
23
52
|
|
|
24
53
|
/** The distinct filter values of a field across items, sorted for display. */
|
|
25
|
-
export function distinctValues(
|
|
54
|
+
export function distinctValues(
|
|
55
|
+
items: ListSource[],
|
|
56
|
+
key: string,
|
|
57
|
+
multi: boolean,
|
|
58
|
+
): string[] {
|
|
26
59
|
const values = new Set<string>();
|
|
27
|
-
for (const
|
|
28
|
-
if (multi) for (const v of
|
|
29
|
-
else if (
|
|
60
|
+
for (const item of items) {
|
|
61
|
+
if (multi) for (const v of itemValues(item, key)) values.add(v);
|
|
62
|
+
else if (item.fields[key]) values.add(item.fields[key]);
|
|
30
63
|
}
|
|
31
|
-
return [...values].sort((a, b) =>
|
|
64
|
+
return [...values].sort((a, b) =>
|
|
65
|
+
a.localeCompare(b, undefined, { sensitivity: "base", numeric: true }),
|
|
66
|
+
);
|
|
32
67
|
}
|