hyperapp-is 0.1.20 → 0.1.22
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 +42 -33
- package/dist/hyperapp-is/core/navigator.d.ts +7 -4
- package/dist/hyperapp-is/core/navigator.js +32 -30
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -615,6 +615,10 @@ export const NavigatorFinder = function <S> (
|
|
|
615
615
|
id : string
|
|
616
616
|
currentKeys : Keys_NavigatorItem
|
|
617
617
|
columns ?: (directory: NavigatorItem | undefined) => NavigatorColumn[]
|
|
618
|
+
plugIn ?: (props: {
|
|
619
|
+
state : S
|
|
620
|
+
localState: Record<string, any>
|
|
621
|
+
}) => VNode<S>[]
|
|
618
622
|
afterRender ?: (props: {
|
|
619
623
|
state : S
|
|
620
624
|
localState: Recrod<string, any>
|
|
@@ -628,49 +632,54 @@ export const NavigatorFinder = function <S> (
|
|
|
628
632
|
- id : ユニークID (DOM ID)
|
|
629
633
|
- currentKeys : カレント NavigatorItem までのパス
|
|
630
634
|
- columns : NavigatorColumn の配列を返す関数
|
|
635
|
+
- plugIn : プラグインの挿入
|
|
631
636
|
- afterRender : レンダーフック
|
|
632
637
|
|
|
633
638
|
vnode
|
|
634
639
|
```html
|
|
635
|
-
<div>
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
</table>
|
|
665
|
-
</div>
|
|
666
|
-
</section>
|
|
640
|
+
<div id={id}>
|
|
641
|
+
|
|
642
|
+
<div class="toolBar">
|
|
643
|
+
<input type="text" />
|
|
644
|
+
<button type="button">FILTER</button>
|
|
645
|
+
</div>
|
|
646
|
+
|
|
647
|
+
<div class="parentItems">
|
|
648
|
+
<ol>
|
|
649
|
+
<li>parent</li>
|
|
650
|
+
</ol>
|
|
651
|
+
<button type="button">COPY</button>
|
|
652
|
+
</div>
|
|
653
|
+
|
|
654
|
+
<div class="items">
|
|
655
|
+
<table>
|
|
656
|
+
<thead>
|
|
657
|
+
<tr>
|
|
658
|
+
<th>ヘッダー</th>
|
|
659
|
+
<th class="sort">ソート付きヘッダー</th>
|
|
660
|
+
</tr>
|
|
661
|
+
</thead>
|
|
662
|
+
<tbody>
|
|
663
|
+
<tr>
|
|
664
|
+
<td class="file"><span>value</span></td>
|
|
665
|
+
<td class="directory"><span>value</span></td>
|
|
666
|
+
</tr>
|
|
667
|
+
</tbody>
|
|
668
|
+
</table>
|
|
667
669
|
</div>
|
|
668
670
|
|
|
669
|
-
<!-- statusBar -->
|
|
670
671
|
<div class="statusBar">message</div>
|
|
672
|
+
|
|
673
|
+
<!-- plugIn 必要な文だけ追加 -->
|
|
674
|
+
<div id={plugInID}>
|
|
675
|
+
</div>
|
|
671
676
|
</div>
|
|
672
677
|
```
|
|
673
678
|
|
|
679
|
+
**CSS設計**
|
|
680
|
+
- plugInを追加する場合は `grid` で整える前提
|
|
681
|
+
- `flex` で整える場合は `afterRender` を併用し VNode を調整する
|
|
682
|
+
|
|
674
683
|
---
|
|
675
684
|
|
|
676
685
|
## hyperapp-is/animation
|
|
@@ -44,21 +44,24 @@ export declare const getParentItems: (item: NavigatorItem | undefined) => Naviga
|
|
|
44
44
|
* - itemClick
|
|
45
45
|
* 非ノードをクリックした際のアクション
|
|
46
46
|
*
|
|
47
|
+
* - plugIn
|
|
48
|
+
* プラグインの追加
|
|
49
|
+
*
|
|
47
50
|
* - afterRender
|
|
48
51
|
* レンダーフック
|
|
49
|
-
*
|
|
50
|
-
* - extension
|
|
51
|
-
* レンダーフックで参照できる拡張情報
|
|
52
52
|
*/
|
|
53
53
|
export declare const NavigatorFinder: <S>(props: {
|
|
54
54
|
state: S;
|
|
55
55
|
id: string;
|
|
56
56
|
currentKeys: Keys_NavigatorItem;
|
|
57
57
|
columns?: (directory: NavigatorItem | undefined) => NavigatorColumn[];
|
|
58
|
+
plugIn?: (props: {
|
|
59
|
+
state: S;
|
|
60
|
+
localState: Record<string, any>;
|
|
61
|
+
}) => VNode<S>[];
|
|
58
62
|
afterRender?: (props: {
|
|
59
63
|
state: S;
|
|
60
64
|
localState: Record<string, any>;
|
|
61
65
|
}, vnode: VNode<S>) => VNode<S>;
|
|
62
|
-
extension?: Record<string, any>;
|
|
63
66
|
[key: string]: any;
|
|
64
67
|
}) => VNode<S>;
|
|
@@ -92,26 +92,35 @@ const span = el("span");
|
|
|
92
92
|
* - itemClick
|
|
93
93
|
* 非ノードをクリックした際のアクション
|
|
94
94
|
*
|
|
95
|
+
* - plugIn
|
|
96
|
+
* プラグインの追加
|
|
97
|
+
*
|
|
95
98
|
* - afterRender
|
|
96
99
|
* レンダーフック
|
|
97
|
-
*
|
|
98
|
-
* - extension
|
|
99
|
-
* レンダーフックで参照できる拡張情報
|
|
100
100
|
*/
|
|
101
101
|
export const NavigatorFinder = function (props) {
|
|
102
102
|
var _a, _b;
|
|
103
|
-
const { state, id, currentKeys, afterRender } = props;
|
|
103
|
+
const { state, id, currentKeys, plugIn, afterRender } = props;
|
|
104
104
|
const current = getValue(state, currentKeys, undefined);
|
|
105
105
|
// localState
|
|
106
|
-
const
|
|
106
|
+
const localState = getLocalState(state, id, {
|
|
107
107
|
searchText: "", // 検索テキスト
|
|
108
108
|
selected: [], // 選択されているボタン名
|
|
109
109
|
sortType: undefined, // ソート用比較関数
|
|
110
110
|
reverse: false, // ソートを逆順にするか
|
|
111
111
|
sortKey: undefined // 使用されているソート名 (column.name)
|
|
112
112
|
});
|
|
113
|
+
/*
|
|
114
|
+
const { searchText, selected, sortType, reverse, sortKey } = getLocalState(state, id, {
|
|
115
|
+
searchText: "", // 検索テキスト
|
|
116
|
+
selected : [], // 選択されているボタン名
|
|
117
|
+
sortType : undefined, // ソート用比較関数
|
|
118
|
+
reverse : false, // ソートを逆順にするか
|
|
119
|
+
sortKey : undefined // 使用されているソート名 (column.name)
|
|
120
|
+
})
|
|
121
|
+
*/
|
|
113
122
|
// selected filter
|
|
114
|
-
const isFilter = selected.includes(`${createLocalKey(id)}_filter`);
|
|
123
|
+
const isFilter = localState.selected.includes(`${createLocalKey(id)}_filter`);
|
|
115
124
|
// ---------- ---------- ----------
|
|
116
125
|
// createColumns
|
|
117
126
|
// ---------- ---------- ----------
|
|
@@ -163,7 +172,7 @@ export const NavigatorFinder = function (props) {
|
|
|
163
172
|
const hitTest = (text) => {
|
|
164
173
|
if (typeof text !== "string")
|
|
165
174
|
return false;
|
|
166
|
-
const S = searchText.trim().toLowerCase();
|
|
175
|
+
const S = localState.searchText.trim().toLowerCase();
|
|
167
176
|
if (S === "")
|
|
168
177
|
return false;
|
|
169
178
|
const keys = S.replace(/[ ]+/g, " ").split(" ").filter(Boolean);
|
|
@@ -179,7 +188,7 @@ export const NavigatorFinder = function (props) {
|
|
|
179
188
|
if (!item || item.children === undefined)
|
|
180
189
|
return [];
|
|
181
190
|
// filter
|
|
182
|
-
const result = isFilter && searchText !== ""
|
|
191
|
+
const result = isFilter && localState.searchText !== ""
|
|
183
192
|
? item.children.filter(child => {
|
|
184
193
|
return columns.some(col => hitTest(col.text ? col.text(child) : col.val(child)));
|
|
185
194
|
})
|
|
@@ -189,9 +198,9 @@ export const NavigatorFinder = function (props) {
|
|
|
189
198
|
// items
|
|
190
199
|
const items = getItems(current);
|
|
191
200
|
// sort
|
|
192
|
-
if (sortType) {
|
|
193
|
-
items.sort(sortType);
|
|
194
|
-
if (reverse)
|
|
201
|
+
if (localState.sortType) {
|
|
202
|
+
items.sort(localState.sortType);
|
|
203
|
+
if (localState.reverse)
|
|
195
204
|
items.reverse();
|
|
196
205
|
}
|
|
197
206
|
// items count
|
|
@@ -253,7 +262,7 @@ export const NavigatorFinder = function (props) {
|
|
|
253
262
|
return state;
|
|
254
263
|
return setLocalState(state, id, {
|
|
255
264
|
sortType: column.compare,
|
|
256
|
-
reverse: sortKey === column.name ? !reverse : false,
|
|
265
|
+
reverse: localState.sortKey === column.name ? !localState.reverse : false,
|
|
257
266
|
sortKey: column.name
|
|
258
267
|
});
|
|
259
268
|
}; // end action_sort
|
|
@@ -261,15 +270,13 @@ export const NavigatorFinder = function (props) {
|
|
|
261
270
|
// VNode
|
|
262
271
|
// ---------- ---------- ----------
|
|
263
272
|
const vnode = div({
|
|
264
|
-
...deleteKeys(props, "state", "currentKeys", "columns", "afterRender")
|
|
273
|
+
...deleteKeys(props, "state", "currentKeys", "columns", "plugIn", "afterRender")
|
|
265
274
|
}, div({
|
|
266
|
-
class: "main"
|
|
267
|
-
}, section({}, div({
|
|
268
275
|
class: "toolBar"
|
|
269
276
|
}, input({
|
|
270
277
|
type: "text",
|
|
271
278
|
placeholder: "search keys",
|
|
272
|
-
value: searchText,
|
|
279
|
+
value: localState.searchText,
|
|
273
280
|
oninput: action_inputSearchText
|
|
274
281
|
}), SelectButton({
|
|
275
282
|
state: state,
|
|
@@ -289,8 +296,8 @@ export const NavigatorFinder = function (props) {
|
|
|
289
296
|
}, table({}, thead({}, tr({}, columns.map(col => th({
|
|
290
297
|
class: col.compare ? "sort" : "",
|
|
291
298
|
onclick: [action_sort, col]
|
|
292
|
-
}, col.name + (sortKey === col.name
|
|
293
|
-
? (reverse ? " ▼" : " ▲")
|
|
299
|
+
}, col.name + (localState.sortKey === col.name
|
|
300
|
+
? (localState.reverse ? " ▼" : " ▲")
|
|
294
301
|
: ""))))), tbody({}, items.map(item => tr({
|
|
295
302
|
key: item.path,
|
|
296
303
|
class: item.children === undefined
|
|
@@ -307,20 +314,15 @@ export const NavigatorFinder = function (props) {
|
|
|
307
314
|
}, span({
|
|
308
315
|
class: hitTest(t) ? "hit" : ""
|
|
309
316
|
}, v));
|
|
310
|
-
}))))))
|
|
317
|
+
})))))),
|
|
311
318
|
// statusBar
|
|
312
|
-
div({ class: "statusBar" }, message)
|
|
319
|
+
div({ class: "statusBar" }, message),
|
|
320
|
+
// plugIn
|
|
321
|
+
plugIn
|
|
322
|
+
? plugIn({ state, localState })
|
|
323
|
+
: []);
|
|
313
324
|
// ---------- ---------- ----------
|
|
314
325
|
// afterRender
|
|
315
326
|
// ---------- ---------- ----------
|
|
316
|
-
return afterRender ? afterRender({
|
|
317
|
-
state,
|
|
318
|
-
localState: {
|
|
319
|
-
searchText,
|
|
320
|
-
selected,
|
|
321
|
-
sortType,
|
|
322
|
-
reverse,
|
|
323
|
-
sortKey
|
|
324
|
-
}
|
|
325
|
-
}, vnode) : vnode;
|
|
327
|
+
return afterRender ? afterRender({ state, localState }, vnode) : vnode;
|
|
326
328
|
};
|