hyperapp-is 0.1.24 → 0.1.26
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 +71 -60
- package/dist/hyperapp-is/core/navigator.d.ts +6 -0
- package/dist/hyperapp-is/core/navigator.js +80 -38
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -614,26 +614,29 @@ export const getParentItems = (
|
|
|
614
614
|
```ts
|
|
615
615
|
export const NavigatorFinder = function <S> (
|
|
616
616
|
props: {
|
|
617
|
-
state
|
|
618
|
-
id
|
|
619
|
-
currentKeys
|
|
620
|
-
columns
|
|
621
|
-
plugIn
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
afterRender
|
|
617
|
+
state : S
|
|
618
|
+
id : string
|
|
619
|
+
currentKeys : Keys_NavigatorItem
|
|
620
|
+
columns ?: (directory: NavigatorItem | undefined) => NavigatorColumn[]
|
|
621
|
+
plugIn ?: (state: S, localState: Record<string, any>) => VNode<S>[]
|
|
622
|
+
toolBarNode ?: (state: S, localState: Record<string, any>, vnode: VNode<S>) => VNode<S>
|
|
623
|
+
parentItemsNode ?: (state: S, localState: Record<string, any>, vnode: VNode<S>) => VNode<S>
|
|
624
|
+
statusBarNode ?: (state: S, localState: Record<string, any>, vnode: VNode<S>) => VNode<S>
|
|
625
|
+
afterRender ?: (state: S, localState: Record<string, any>, vnode: VNode<S>) => VNode<S>
|
|
626
626
|
[key: string]: any
|
|
627
627
|
}
|
|
628
628
|
): VNode<S>
|
|
629
629
|
```
|
|
630
630
|
|
|
631
|
-
- state
|
|
632
|
-
- id
|
|
633
|
-
- currentKeys
|
|
634
|
-
- columns
|
|
635
|
-
- plugIn
|
|
636
|
-
-
|
|
631
|
+
- state : ステート
|
|
632
|
+
- id : ユニークID (DOM ID)
|
|
633
|
+
- currentKeys : カレント NavigatorItem までのパス
|
|
634
|
+
- columns : NavigatorColumn の配列を返す関数
|
|
635
|
+
- plugIn : プラグインの挿入
|
|
636
|
+
- toolBarNode : `toolBar` レンダーフック
|
|
637
|
+
- parentItemsNode: `parentItems` レンダーフック
|
|
638
|
+
- statusBarNode : `statusBar` レンダーフック
|
|
639
|
+
- afterRender : 全体のレンダーフック
|
|
637
640
|
|
|
638
641
|
localState
|
|
639
642
|
- searchText: "" as string // 検索テキスト
|
|
@@ -645,39 +648,40 @@ localState
|
|
|
645
648
|
vnode
|
|
646
649
|
```html
|
|
647
650
|
<div id={id}>
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
651
|
+
<div class="rapper">
|
|
652
|
+
<div class="toolBar">
|
|
653
|
+
<input type="text" />
|
|
654
|
+
<button type="button">FILTER</button>
|
|
655
|
+
</div>
|
|
656
|
+
|
|
657
|
+
<div class="parentItems">
|
|
658
|
+
<ol>
|
|
659
|
+
<li>parent</li>
|
|
660
|
+
</ol>
|
|
661
|
+
<button type="button">COPY</button>
|
|
662
|
+
</div>
|
|
663
|
+
|
|
664
|
+
<div class="items">
|
|
665
|
+
<table>
|
|
666
|
+
<thead>
|
|
667
|
+
<tr>
|
|
668
|
+
<th>ヘッダー</th>
|
|
669
|
+
<th class="sort">ソート付きヘッダー</th>
|
|
670
|
+
</tr>
|
|
671
|
+
</thead>
|
|
672
|
+
<tbody>
|
|
673
|
+
<tr>
|
|
674
|
+
<td class="file"><span>value</span></td>
|
|
675
|
+
<td class="directory"><span>value</span></td>
|
|
676
|
+
</tr>
|
|
677
|
+
</tbody>
|
|
678
|
+
</table>
|
|
679
|
+
</div>
|
|
680
|
+
|
|
681
|
+
<div class="statusBar">message</div>
|
|
652
682
|
</div>
|
|
653
683
|
|
|
654
|
-
|
|
655
|
-
<ol>
|
|
656
|
-
<li>parent</li>
|
|
657
|
-
</ol>
|
|
658
|
-
<button type="button">COPY</button>
|
|
659
|
-
</div>
|
|
660
|
-
|
|
661
|
-
<div class="items">
|
|
662
|
-
<table>
|
|
663
|
-
<thead>
|
|
664
|
-
<tr>
|
|
665
|
-
<th>ヘッダー</th>
|
|
666
|
-
<th class="sort">ソート付きヘッダー</th>
|
|
667
|
-
</tr>
|
|
668
|
-
</thead>
|
|
669
|
-
<tbody>
|
|
670
|
-
<tr>
|
|
671
|
-
<td class="file"><span>value</span></td>
|
|
672
|
-
<td class="directory"><span>value</span></td>
|
|
673
|
-
</tr>
|
|
674
|
-
</tbody>
|
|
675
|
-
</table>
|
|
676
|
-
</div>
|
|
677
|
-
|
|
678
|
-
<div class="statusBar">message</div>
|
|
679
|
-
|
|
680
|
-
<!-- plugIn 必要な文だけ追加 -->
|
|
684
|
+
<!-- plugIn 必要な分だけ追加 -->
|
|
681
685
|
<div id={plugInID}>
|
|
682
686
|
</div>
|
|
683
687
|
</div>
|
|
@@ -703,24 +707,31 @@ export interface SearchResult {
|
|
|
703
707
|
```ts
|
|
704
708
|
export const NavigatorSearch = function <S> (
|
|
705
709
|
props: {
|
|
706
|
-
state
|
|
707
|
-
id
|
|
708
|
-
currentKeys
|
|
709
|
-
searchResult
|
|
710
|
-
hitTest
|
|
711
|
-
maxItemsCount
|
|
712
|
-
|
|
713
|
-
|
|
710
|
+
state : S
|
|
711
|
+
id : string
|
|
712
|
+
currentKeys : Keys_NavigatorItem
|
|
713
|
+
searchResult : (item: NavigatorItem, depth: number) => VNode<S> | VNode<S>[]
|
|
714
|
+
hitTest : (item: NavigatorItem) => boolean
|
|
715
|
+
maxItemsCount : number
|
|
716
|
+
toolBarNode ?: (state: S, localState: Record<string, any>, vnode: VNode<S>) => VNode<S>
|
|
717
|
+
parentItemsNode?: (state: S, localState: Record<string, any>, vnode: VNode<S>) => VNode<S>
|
|
718
|
+
statusBarNode ?: (state: S, localState: Record<string, any>, vnode: VNode<S>) => VNode<S>
|
|
719
|
+
afterRender ?: (state: S, localState: Record<string, any>, vnode: VNode<S>) => VNode<S>
|
|
720
|
+
[key: string] : any
|
|
714
721
|
}
|
|
715
722
|
): VNode<S>
|
|
716
723
|
```
|
|
717
724
|
|
|
718
|
-
- state
|
|
719
|
-
- id
|
|
720
|
-
-
|
|
721
|
-
-
|
|
722
|
-
-
|
|
723
|
-
-
|
|
725
|
+
- state : ステート
|
|
726
|
+
- id : ユニークID (DOM ID)
|
|
727
|
+
- currentKeys : カレント NavigatorItem までのパス
|
|
728
|
+
- searchResult : カードとして表示する VNode
|
|
729
|
+
- hitTest : 抽出条件
|
|
730
|
+
- maxItemsCount : 最初に表示するカードの最大数
|
|
731
|
+
- toolBarNode : `toolBar` レンダーフック
|
|
732
|
+
- parentItemsNode: `parentItems` レンダーフック
|
|
733
|
+
- statusBarNode : `statusBar` レンダーフック
|
|
734
|
+
- afterRender : 全体のレンダーフック
|
|
724
735
|
|
|
725
736
|
localState
|
|
726
737
|
- maxItemsCount: props.maxItemsCount as number // カードの最大表示数
|
|
@@ -53,6 +53,9 @@ export declare const NavigatorFinder: <S>(props: {
|
|
|
53
53
|
currentKeys: Keys_NavigatorItem;
|
|
54
54
|
columns?: (directory: NavigatorItem | undefined) => NavigatorColumn[];
|
|
55
55
|
plugIn?: (state: S, localState: Record<string, any>) => VNode<S>[];
|
|
56
|
+
toolBarNode?: (state: S, localState: Record<string, any>, vnode: VNode<S>) => VNode<S>;
|
|
57
|
+
parentItemsNode?: (state: S, localState: Record<string, any>, vnode: VNode<S>) => VNode<S>;
|
|
58
|
+
statusBarNode?: (state: S, localState: Record<string, any>, vnode: VNode<S>) => VNode<S>;
|
|
56
59
|
afterRender?: (state: S, localState: Record<string, any>, vnode: VNode<S>) => VNode<S>;
|
|
57
60
|
[key: string]: any;
|
|
58
61
|
}) => VNode<S>;
|
|
@@ -97,6 +100,9 @@ export declare const NavigatorSearch: <S>(props: {
|
|
|
97
100
|
searchResult: (item: NavigatorItem, depth: number) => VNode<S> | VNode<S>[];
|
|
98
101
|
hitTest: (item: NavigatorItem) => boolean;
|
|
99
102
|
maxItemsCount: number;
|
|
103
|
+
toolBarNode?: (state: S, localState: Record<string, any>, vnode: VNode<S>) => VNode<S>;
|
|
104
|
+
parentItemsNode?: (state: S, localState: Record<string, any>, vnode: VNode<S>) => VNode<S>;
|
|
105
|
+
statusBarNode?: (state: S, localState: Record<string, any>, vnode: VNode<S>) => VNode<S>;
|
|
100
106
|
afterRender?: (state: S, localState: Record<string, any>, vnode: VNode<S>) => VNode<S>;
|
|
101
107
|
[key: string]: any;
|
|
102
108
|
}) => VNode<S>;
|
|
@@ -238,15 +238,6 @@ export const NavigatorFinder = function (props) {
|
|
|
238
238
|
});
|
|
239
239
|
}; // end action_inputSearchText
|
|
240
240
|
// ---------- ---------- ----------
|
|
241
|
-
// action_copyFolderPath
|
|
242
|
-
// ---------- ---------- ----------
|
|
243
|
-
const action_copyFolderPath = (state) => {
|
|
244
|
-
if (!current)
|
|
245
|
-
return state;
|
|
246
|
-
navigator.clipboard.writeText(current.path);
|
|
247
|
-
return state;
|
|
248
|
-
}; // end action_copyFolderPath
|
|
249
|
-
// ---------- ---------- ----------
|
|
250
241
|
// action_sort
|
|
251
242
|
// ---------- ---------- ----------
|
|
252
243
|
const action_sort = (state, column) => {
|
|
@@ -261,29 +252,37 @@ export const NavigatorFinder = function (props) {
|
|
|
261
252
|
// ---------- ---------- ----------
|
|
262
253
|
// VNode
|
|
263
254
|
// ---------- ---------- ----------
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}, div({
|
|
255
|
+
// toolBarNode
|
|
256
|
+
const toolBarNode = div({
|
|
267
257
|
class: "toolBar"
|
|
268
258
|
}, input({
|
|
269
259
|
type: "text",
|
|
270
260
|
placeholder: "search keys",
|
|
271
261
|
value: localState.searchText,
|
|
272
262
|
oninput: action_inputSearchText
|
|
273
|
-
}),
|
|
263
|
+
}), button({
|
|
264
|
+
type: "button",
|
|
265
|
+
title: "delete keys",
|
|
266
|
+
onclick: (state) => {
|
|
267
|
+
return setLocalState(state, id, {
|
|
268
|
+
searchText: ""
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
}, icon_trashBox), SelectButton({
|
|
274
272
|
state: state,
|
|
275
273
|
id: `${createLocalKey(id)}_filter`,
|
|
276
|
-
keyNames: [createLocalKey(id), "selected"]
|
|
277
|
-
|
|
274
|
+
keyNames: [createLocalKey(id), "selected"],
|
|
275
|
+
title: "filter"
|
|
276
|
+
}, icon_filter));
|
|
277
|
+
// parentItemsNode
|
|
278
|
+
const parentItemsNode = div({
|
|
278
279
|
class: "parentItems"
|
|
279
280
|
}, ol({}, parentItems.map(parent => li({
|
|
280
281
|
key: parent.path,
|
|
281
282
|
onclick: [action_parentClick, parent]
|
|
282
|
-
}, parent.name)))
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
onclick: action_copyFolderPath
|
|
286
|
-
}, "COPY")), div({
|
|
283
|
+
}, parent.name))));
|
|
284
|
+
// itemsNode
|
|
285
|
+
const itemsNode = div({
|
|
287
286
|
class: "items"
|
|
288
287
|
}, table({}, thead({}, tr({}, columns.map(col => th({
|
|
289
288
|
class: col.compare ? "sort" : "",
|
|
@@ -306,9 +305,15 @@ export const NavigatorFinder = function (props) {
|
|
|
306
305
|
}, span({
|
|
307
306
|
class: hitTest(t) ? "hit" : ""
|
|
308
307
|
}, v));
|
|
309
|
-
}))))))
|
|
310
|
-
//
|
|
311
|
-
div({ class: "statusBar" }, message)
|
|
308
|
+
}))))));
|
|
309
|
+
// statusBarNode
|
|
310
|
+
const statusBarNode = div({ class: "statusBar" }, message);
|
|
311
|
+
// vnode
|
|
312
|
+
const vnode = div({
|
|
313
|
+
...deleteKeys(props, "state", "currentKeys", "columns", "plugIn", "toolBarNode", "parentItemsNode", "statusBarNode", "afterRender")
|
|
314
|
+
}, div({
|
|
315
|
+
class: "rapper"
|
|
316
|
+
}, props.toolBarNode ? props.toolBarNode(state, localState, toolBarNode) : toolBarNode, props.parentItemsNode ? props.parentItemsNode(state, localState, parentItemsNode) : parentItemsNode, itemsNode, props.statusBarNode ? props.statuBarNode(state, localState, statusBarNode) : statusBarNode),
|
|
312
317
|
// plugIn
|
|
313
318
|
plugIn
|
|
314
319
|
? plugIn(state, localState)
|
|
@@ -387,6 +392,39 @@ const icon_file = svg({
|
|
|
387
392
|
strokeLinecap: "round",
|
|
388
393
|
strokeLinejoin: "round"
|
|
389
394
|
}, path({ d: "M6 2h9l5 5v15a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2z" }), path({ d: "M14 2v6h6" }));
|
|
395
|
+
// icon_trashBox
|
|
396
|
+
const icon_trashBox = svg({
|
|
397
|
+
viewBox: "0 0 24 24",
|
|
398
|
+
width: 24,
|
|
399
|
+
height: 24,
|
|
400
|
+
fill: "none",
|
|
401
|
+
stroke: "currentColor",
|
|
402
|
+
strokeWidth: 2,
|
|
403
|
+
strokeLinecap: "round",
|
|
404
|
+
strokeLinejoin: "round"
|
|
405
|
+
}, path({ d: "M3 6h18" }), path({ d: "M8 6V4h8v2" }), path({ d: "M6 6l1 14h10l1-14" }), path({ d: "M10 11v6" }), path({ d: "M14 11v6" }));
|
|
406
|
+
// icon_filter
|
|
407
|
+
const icon_filter = svg({
|
|
408
|
+
viewBox: "0 0 24 24",
|
|
409
|
+
width: 24,
|
|
410
|
+
height: 24,
|
|
411
|
+
fill: "none",
|
|
412
|
+
stroke: "currentColor",
|
|
413
|
+
strokeWidth: 2,
|
|
414
|
+
strokeLinecap: "round",
|
|
415
|
+
strokeLinejoin: "round"
|
|
416
|
+
}, path({ d: "M3 5h18" }), path({ d: "M6 12h12" }), path({ d: "M10 19h4" }));
|
|
417
|
+
// icon_copy
|
|
418
|
+
const icon_copy = svg({
|
|
419
|
+
viewBox: "0 0 24 24",
|
|
420
|
+
width: 24,
|
|
421
|
+
height: 24,
|
|
422
|
+
fill: "none",
|
|
423
|
+
stroke: "currentColor",
|
|
424
|
+
strokeWidth: 2,
|
|
425
|
+
strokeLinecap: "round",
|
|
426
|
+
strokeLinejoin: "round"
|
|
427
|
+
}, path({ d: "M9 9h11v11H9z" }), path({ d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" }));
|
|
390
428
|
// ---------- ---------- ---------- ---------- ----------
|
|
391
429
|
// NavigatorSearch Component (NavigatorFinder plugIn)
|
|
392
430
|
// ---------- ---------- ---------- ---------- ----------
|
|
@@ -516,54 +554,58 @@ export const NavigatorSearch = function (props) {
|
|
|
516
554
|
// ---------- ---------- ----------
|
|
517
555
|
// vnode
|
|
518
556
|
// ---------- ---------- ----------
|
|
519
|
-
const
|
|
520
|
-
...deleteKeys(props, "state", "currentKeys", "searchResult", "hitTest", "maxItemsCount", "afterRender")
|
|
521
|
-
},
|
|
522
|
-
// toolBar
|
|
523
|
-
div({
|
|
557
|
+
const toolBarNode = div({
|
|
524
558
|
class: "toolBar"
|
|
525
559
|
},
|
|
526
560
|
// sort
|
|
527
561
|
button({
|
|
528
562
|
type: "button",
|
|
563
|
+
title: "sort depth",
|
|
529
564
|
onclick: [action_setSort, "depth"]
|
|
530
565
|
}, icon_depth), button({
|
|
531
566
|
type: "button",
|
|
567
|
+
title: "sort name",
|
|
532
568
|
onclick: [action_setSort, "name"]
|
|
533
569
|
}, icon_name),
|
|
534
570
|
// filter
|
|
535
571
|
button({
|
|
536
572
|
type: "button",
|
|
537
573
|
class: localState.isDirectory ? "" : "ignore",
|
|
574
|
+
title: "directory",
|
|
538
575
|
onclick: (state) => setLocalState(state, id, {
|
|
539
576
|
isDirectory: !localState.isDirectory
|
|
540
577
|
})
|
|
541
578
|
}, icon_directory), button({
|
|
542
579
|
type: "button",
|
|
543
580
|
class: localState.isFile ? "" : "ignore",
|
|
581
|
+
title: "file",
|
|
544
582
|
onclick: (state) => setLocalState(state, id, {
|
|
545
583
|
isFile: !localState.isFile
|
|
546
584
|
})
|
|
547
|
-
}, icon_file))
|
|
548
|
-
//
|
|
549
|
-
div({
|
|
585
|
+
}, icon_file));
|
|
586
|
+
// parentItemsNode
|
|
587
|
+
const parentItemsNode = div({
|
|
550
588
|
class: "parentItems"
|
|
551
589
|
}, ol({}, parentItems.map(item => li({
|
|
552
590
|
onclick: (state) => setValue(state, currentKeys, item)
|
|
553
|
-
}, item.name))))
|
|
554
|
-
//
|
|
555
|
-
div({
|
|
591
|
+
}, item.name))));
|
|
592
|
+
// itemsNode
|
|
593
|
+
const itemsNode = div({
|
|
556
594
|
class: "items",
|
|
557
595
|
onscroll: action_itemsScroll
|
|
558
596
|
}, ul({}, drawItems.map(item => li({
|
|
559
597
|
class: "item",
|
|
560
598
|
key: item.item.path,
|
|
561
599
|
title: item.item.path
|
|
562
|
-
}, searchResult(item.item, item.depth)))))
|
|
563
|
-
//
|
|
564
|
-
div({
|
|
600
|
+
}, searchResult(item.item, item.depth)))));
|
|
601
|
+
// statusBarNode
|
|
602
|
+
const statusBarNode = div({
|
|
565
603
|
class: "statusBar"
|
|
566
|
-
}, message)
|
|
604
|
+
}, message);
|
|
605
|
+
// vnode
|
|
606
|
+
const vnode = div({
|
|
607
|
+
...deleteKeys(props, "state", "currentKeys", "searchResult", "hitTest", "maxItemsCount", "toolBarNode", "parentItemsNode", "statusBarNode", "afterRender")
|
|
608
|
+
}, props.toolBarNode ? props.toolBarNode(state, localState, toolBarNode) : toolBarNode, props.parentItemsNode ? props.parentItemsNode(state, localState, parentItemsNode) : parentItemsNode, itemsNode, props.statusBarNode ? props.statusBarNode(state, localState, statusBarNode) : statusBarNode);
|
|
567
609
|
// ---------- ---------- ----------
|
|
568
610
|
// afterRender
|
|
569
611
|
// ---------- ---------- ----------
|