hyperapp-is 0.1.12 → 0.1.14

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 : string
536
- data : D
537
- isNode : boolean
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
 
@@ -553,12 +551,14 @@ NavigatorFinder に渡すヘッダーと値
553
551
  export interface NavigatorColumn {
554
552
  name : string
555
553
  val : (item: NavigatorItem) => any
554
+ text ?: (item: NavigatorItem) => string
556
555
  compare?: (a: NavigatorItem, b: NavigatorItem) => number
557
556
  }
558
557
  ```
559
558
 
560
- - name: 名前
561
- - val : 値を返す関数
559
+ - name : 名前
560
+ - val : 値を返す関数 (VNode等も可)
561
+ - text : val が string ではない時に設定するテキスト
562
562
  - compare: 比較関数
563
563
 
564
564
  `compare` を設置したカラムだけ、ソート対象となります
@@ -578,6 +578,7 @@ export const convertJsonToNavigatorItem = function <D> (
578
578
  getEntries : (data: D, depth: number) => JsonEntry<D>[]
579
579
  isNode : boolean
580
580
  depth ?: number
581
+ extension ?: (item: NavigatorItem, data: D, depth: number) => Record<string, any> | undefined
581
582
  }
582
583
  ): NavigatorItem
583
584
  ```
@@ -588,6 +589,7 @@ export const convertJsonToNavigatorItem = function <D> (
588
589
  - getEntries: JsonEntry配列を返す関数
589
590
  - isNode : ディレクトリか
590
591
  - depth : 階層の深さ
592
+ - extension : NavigatorItem.extensionに格納する拡張データ
591
593
 
592
594
  ---
593
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
- let extension;
15
- let properties;
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 (extension)
39
- result.extension = extension;
40
- if (properties)
39
+ if (hasProperties)
41
40
  result.properties = properties;
42
41
  if (isNode)
43
42
  result.children = children;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperapp-is",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "UI foundation library for Hyperapp by is4416",
5
5
  "license": "MIT",
6
6
  "type": "module",