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