hyperapp-is 0.1.13 → 0.1.15
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
CHANGED
|
@@ -532,17 +532,15 @@ getEntriesの返す値
|
|
|
532
532
|
|
|
533
533
|
```ts
|
|
534
534
|
export interface JsonEntry <D> {
|
|
535
|
-
name
|
|
536
|
-
data
|
|
537
|
-
isNode
|
|
538
|
-
extension?: Record<string, any>
|
|
535
|
+
name : string
|
|
536
|
+
data : D
|
|
537
|
+
isNode: boolean
|
|
539
538
|
}
|
|
540
539
|
```
|
|
541
540
|
|
|
542
|
-
- name
|
|
543
|
-
- data
|
|
544
|
-
- isNode
|
|
545
|
-
- extension?: `NavigatorItem.extension` に追加する値
|
|
541
|
+
- name : 名前
|
|
542
|
+
- data : データ
|
|
543
|
+
- isNode: ディレクトリか
|
|
546
544
|
|
|
547
545
|
---
|
|
548
546
|
|
|
@@ -580,6 +578,7 @@ export const convertJsonToNavigatorItem = function <D> (
|
|
|
580
578
|
getEntries : (data: D, depth: number) => JsonEntry<D>[]
|
|
581
579
|
isNode : boolean
|
|
582
580
|
depth ?: number
|
|
581
|
+
extension ?: (item: NavigatorItem, data: D, depth: number) => Record<string, any> | undefined
|
|
583
582
|
}
|
|
584
583
|
): NavigatorItem
|
|
585
584
|
```
|
|
@@ -590,6 +589,7 @@ export const convertJsonToNavigatorItem = function <D> (
|
|
|
590
589
|
- getEntries: JsonEntry配列を返す関数
|
|
591
590
|
- isNode : ディレクトリか
|
|
592
591
|
- depth : 階層の深さ
|
|
592
|
+
- extension : NavigatorItem.extensionに格納する拡張データ
|
|
593
593
|
|
|
594
594
|
---
|
|
595
595
|
|
|
@@ -12,7 +12,6 @@ export interface JsonEntry<D> {
|
|
|
12
12
|
name: string;
|
|
13
13
|
data: D;
|
|
14
14
|
isNode: boolean;
|
|
15
|
-
extension?: Record<string, any>;
|
|
16
15
|
}
|
|
17
16
|
export interface NavigatorColumn {
|
|
18
17
|
name: string;
|
|
@@ -27,6 +26,7 @@ export declare const convertJsonToNavigatorItem: <D>(props: {
|
|
|
27
26
|
getEntries: (data: D, depth: number) => JsonEntry<D>[];
|
|
28
27
|
isNode: boolean;
|
|
29
28
|
depth?: number;
|
|
29
|
+
extension?: (item: NavigatorItem, data: D, depth: number) => Record<string, any> | undefined;
|
|
30
30
|
}) => NavigatorItem;
|
|
31
31
|
export declare const getParentItems: (item: NavigatorItem | undefined) => NavigatorItem[];
|
|
32
32
|
/**
|
|
@@ -5,24 +5,25 @@ import { el, deleteKeys, SelectButton } from "./component";
|
|
|
5
5
|
// convertJsonToNavigatorItem
|
|
6
6
|
// ---------- ---------- ---------- ---------- ----------
|
|
7
7
|
export const convertJsonToNavigatorItem = function (props) {
|
|
8
|
-
const { parent, name, data, getEntries, isNode, depth = 0 } = props;
|
|
8
|
+
const { parent, name, data, getEntries, isNode, depth = 0, extension } = props;
|
|
9
9
|
const result = {
|
|
10
10
|
parent,
|
|
11
11
|
name,
|
|
12
12
|
path: parent ? parent.path + "/" + name : "/" + name
|
|
13
13
|
};
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
if (extension) {
|
|
15
|
+
const ext = extension(result, data, depth);
|
|
16
|
+
if (ext)
|
|
17
|
+
result.extension = ext;
|
|
18
|
+
}
|
|
19
|
+
let properties = {};
|
|
20
|
+
let hasProperties = false;
|
|
16
21
|
const children = [];
|
|
17
22
|
getEntries(data, depth).forEach(entry => {
|
|
18
|
-
if (entry.extension) {
|
|
19
|
-
extension !== null && extension !== void 0 ? extension : (extension = {});
|
|
20
|
-
Object.assign(extension, entry.extension);
|
|
21
|
-
}
|
|
22
23
|
const isProperty = typeof entry.data !== "object" || Array.isArray(entry.data);
|
|
23
24
|
if (isProperty) {
|
|
24
|
-
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
25
25
|
properties[entry.name] = entry.data;
|
|
26
|
+
hasProperties = true;
|
|
26
27
|
}
|
|
27
28
|
else {
|
|
28
29
|
children.push(convertJsonToNavigatorItem({
|
|
@@ -35,9 +36,7 @@ export const convertJsonToNavigatorItem = function (props) {
|
|
|
35
36
|
}));
|
|
36
37
|
}
|
|
37
38
|
});
|
|
38
|
-
if (
|
|
39
|
-
result.extension = extension;
|
|
40
|
-
if (properties)
|
|
39
|
+
if (hasProperties)
|
|
41
40
|
result.properties = properties;
|
|
42
41
|
if (isNode)
|
|
43
42
|
result.children = children;
|