hyperapp-is 0.1.11 → 0.1.13

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
@@ -553,12 +553,14 @@ NavigatorFinder に渡すヘッダーと値
553
553
  export interface NavigatorColumn {
554
554
  name : string
555
555
  val : (item: NavigatorItem) => any
556
+ text ?: (item: NavigatorItem) => string
556
557
  compare?: (a: NavigatorItem, b: NavigatorItem) => number
557
558
  }
558
559
  ```
559
560
 
560
- - name: 名前
561
- - val : 値を返す関数
561
+ - name : 名前
562
+ - val : 値を返す関数 (VNode等も可)
563
+ - text : val が string ではない時に設定するテキスト
562
564
  - compare: 比較関数
563
565
 
564
566
  `compare` を設置したカラムだけ、ソート対象となります
@@ -17,6 +17,7 @@ export interface JsonEntry<D> {
17
17
  export interface NavigatorColumn {
18
18
  name: string;
19
19
  val: (item: NavigatorItem) => any;
20
+ text?: (item: NavigatorItem) => string;
20
21
  compare?: (a: NavigatorItem, b: NavigatorItem) => number;
21
22
  }
22
23
  export declare const convertJsonToNavigatorItem: <D>(props: {
@@ -179,7 +179,7 @@ export const NavigatorFinder = function (props) {
179
179
  // filter
180
180
  const result = isFilter && searchText !== ""
181
181
  ? item.children.filter(child => {
182
- return columns.some(col => hitTest(col.val(child)));
182
+ return columns.some(col => hitTest(col.text ? col.text(child) : col.val(child)));
183
183
  })
184
184
  : item.children;
185
185
  // maxCount
@@ -203,7 +203,7 @@ export const NavigatorFinder = function (props) {
203
203
  // items hitCount
204
204
  const hitCount = isFilter
205
205
  ? items.length
206
- : items.filter(item => columns.some(col => hitTest(col.val(item)))).length;
206
+ : items.filter(item => columns.some(col => hitTest(col.text ? col.text(item) : col.val(item)))).length;
207
207
  // ---------- ---------- ----------
208
208
  // action_parentClick
209
209
  // ---------- ---------- ----------
@@ -297,10 +297,11 @@ export const NavigatorFinder = function (props) {
297
297
  : [action_itemClick, item]
298
298
  }, columns.map(col => {
299
299
  const v = col.val(item);
300
+ const t = col.text ? col.text(item) : typeof v === "string" ? v : "";
300
301
  return td({
301
- title: String(v)
302
+ title: t
302
303
  }, span({
303
- class: typeof v === "string" && hitTest(v) ? "hit" : ""
304
+ class: hitTest(t) ? "hit" : ""
304
305
  }, v));
305
306
  }))))),
306
307
  // statusBar
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperapp-is",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "UI foundation library for Hyperapp by is4416",
5
5
  "license": "MIT",
6
6
  "type": "module",