hyperapp-is 0.1.15 → 0.1.18

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
@@ -364,7 +364,7 @@ Hyperapp の h 関数ラッパー。JSX と競合する場合に使用
364
364
  children の処理も同時に行っているため、本ライブラリでは VNode を作成する際に使用しています
365
365
 
366
366
  ```ts
367
- export const el = (tag: string) => <S> (
367
+ export const el = <S = any> (tag: string) => (
368
368
  props ?: { [key: string]: any },
369
369
  children?: Array
370
370
  ): VNode<S>
@@ -615,14 +615,10 @@ export const NavigatorFinder = function <S> (
615
615
  id : string
616
616
  currentKeys : Keys_NavigatorItem
617
617
  columns ?: (directory: NavigatorItem | undefined) => NavigatorColumn[]
618
- maxItemsCount?: number
619
- itemClick ?: (state: S, item: NavigatorItem) => S | [S, Effect<S>]
620
618
  afterRender ?: (props: {
621
619
  state : S
622
- current ?: NavigatorItem
623
- extension?: Record<string, any>
620
+ localState: Recrod<string, any>
624
621
  }, vnode: VNode<S>) => VNode<S>
625
- extension ?: Record<string, any>
626
622
  [key: string]: any
627
623
  }
628
624
  ): VNode<S>
@@ -632,12 +628,48 @@ export const NavigatorFinder = function <S> (
632
628
  - id : ユニークID (DOM ID)
633
629
  - currentKeys : カレント NavigatorItem までのパス
634
630
  - columns : NavigatorColumn の配列を返す関数
635
- - maxItemsCount: 最大表示するアイテム数
636
- - itemClick : アイテムをクリックした時のアクション
637
631
  - afterRender : レンダーフック
638
- - extension : レンダーフックに渡す拡張情報
639
632
 
640
- `maxItemsCount` は、そのうち表示数コントロールを作成するかも
633
+ vnode
634
+ ```html
635
+ <div>
636
+ <div class="main">
637
+ <section>
638
+ <div class="toolBar">
639
+ <input type="text" />
640
+ <button type="button">FILTER</button>
641
+ </div>
642
+
643
+ <div class="parentItems">
644
+ <ol>
645
+ <li>parent</li>
646
+ </ol>
647
+ <button type="button">COPY</button>
648
+ </div>
649
+
650
+ <div class="items">
651
+ <table>
652
+ <thead>
653
+ <tr>
654
+ <th>ヘッダー</th>
655
+ <th class="sort">ソート付きヘッダー</th>
656
+ </tr>
657
+ </thead>
658
+ <tbody>
659
+ <tr>
660
+ <td class="file"><span>value</span></td>
661
+ <td class="directory"><span>value</span></td>
662
+ </tr>
663
+ </tbody>
664
+ </table>
665
+ </div>
666
+ </section>
667
+ </div>
668
+
669
+ <!-- statusBar -->
670
+ <div class="statusBar">message</div>
671
+ </div>
672
+ ```
641
673
 
642
674
  ---
643
675
 
@@ -1,4 +1,4 @@
1
- import { VNode, Effect } from "hyperapp";
1
+ import { VNode } from "hyperapp";
2
2
  import { Keys_NavigatorItem } from "./state";
3
3
  export interface NavigatorItem {
4
4
  parent: NavigatorItem | null;
@@ -55,12 +55,9 @@ export declare const NavigatorFinder: <S>(props: {
55
55
  id: string;
56
56
  currentKeys: Keys_NavigatorItem;
57
57
  columns?: (directory: NavigatorItem | undefined) => NavigatorColumn[];
58
- maxItemsCount?: number;
59
- itemClick?: (state: S, item: NavigatorItem) => S | [S, Effect<S>];
60
58
  afterRender?: (props: {
61
59
  state: S;
62
- current?: NavigatorItem;
63
- extension?: Record<string, any>;
60
+ localState: Record<string, any>;
64
61
  }, vnode: VNode<S>) => VNode<S>;
65
62
  extension?: Record<string, any>;
66
63
  [key: string]: any;
@@ -32,7 +32,8 @@ export const convertJsonToNavigatorItem = function (props) {
32
32
  data: entry.data,
33
33
  getEntries,
34
34
  isNode: entry.isNode,
35
- depth: depth + 1
35
+ depth: depth + 1,
36
+ extension
36
37
  }));
37
38
  }
38
39
  });
@@ -60,6 +61,7 @@ export const getParentItems = (item) => {
60
61
  // vnodes
61
62
  // ---------- ---------- ---------- ---------- ----------
62
63
  const div = el("div");
64
+ const section = el("section");
63
65
  const table = el("table");
64
66
  const thead = el("thead");
65
67
  const tbody = el("tbody");
@@ -67,6 +69,7 @@ const tr = el("tr");
67
69
  const th = el("th");
68
70
  const td = el("td");
69
71
  const ol = el("ol");
72
+ const ul = el("ul");
70
73
  const li = el("li");
71
74
  const button = el("button");
72
75
  const input = el("input");
@@ -97,7 +100,7 @@ const span = el("span");
97
100
  */
98
101
  export const NavigatorFinder = function (props) {
99
102
  var _a, _b;
100
- const { state, id, currentKeys, maxItemsCount = 0, itemClick, afterRender, extension } = props;
103
+ const { state, id, currentKeys, afterRender } = props;
101
104
  const current = getValue(state, currentKeys, undefined);
102
105
  // localState
103
106
  const { searchText, selected, sortType, reverse, sortKey } = getLocalState(state, id, {
@@ -181,11 +184,7 @@ export const NavigatorFinder = function (props) {
181
184
  return columns.some(col => hitTest(col.text ? col.text(child) : col.val(child)));
182
185
  })
183
186
  : item.children;
184
- // maxCount
185
- const count = maxItemsCount === 0
186
- ? result.length
187
- : Math.min(maxItemsCount, result.length);
188
- return result.slice(0, count);
187
+ return result;
189
188
  }; // end getItems
190
189
  // items
191
190
  const items = getItems(current);
@@ -203,6 +202,8 @@ export const NavigatorFinder = function (props) {
203
202
  const hitCount = isFilter
204
203
  ? items.length
205
204
  : items.filter(item => columns.some(col => hitTest(col.text ? col.text(item) : col.val(item)))).length;
205
+ // message
206
+ const message = `hit items = ${hitCount} / ${count}`;
206
207
  // ---------- ---------- ----------
207
208
  // action_parentClick
208
209
  // ---------- ---------- ----------
@@ -260,10 +261,10 @@ export const NavigatorFinder = function (props) {
260
261
  // VNode
261
262
  // ---------- ---------- ----------
262
263
  const vnode = div({
263
- ...deleteKeys(props, "state", "currentKeys", "columns", "itemClick", "afterRender", "extension")
264
- },
265
- // toolBar
266
- div({
264
+ ...deleteKeys(props, "state", "currentKeys", "columns", "afterRender")
265
+ }, div({
266
+ class: "main"
267
+ }, section({}, div({
267
268
  class: "toolBar"
268
269
  }, input({
269
270
  type: "text",
@@ -274,25 +275,29 @@ export const NavigatorFinder = function (props) {
274
275
  state: state,
275
276
  id: `${createLocalKey(id)}_filter`,
276
277
  keyNames: [createLocalKey(id), "selected"]
277
- }, "FILTER"), button({
278
+ }, "FILTER")), div({
279
+ class: "parentItems"
280
+ }, ol({}, parentItems.map(parent => li({
281
+ key: parent.path,
282
+ onclick: [action_parentClick, parent]
283
+ }, parent.name))), button({
278
284
  type: "button",
279
285
  title: "現在のフォルダパスを、クリップボードにコピー",
280
286
  onclick: action_copyFolderPath
281
- }, "COPY")),
282
- // parentItems
283
- ol({}, parentItems.map(parent => li({
284
- key: parent.path,
285
- onclick: [action_parentClick, parent]
286
- }, parent.name))),
287
- // items
288
- table({}, thead({}, tr({}, columns.map(col => th({
287
+ }, "COPY")), div({
288
+ class: "items"
289
+ }, table({}, thead({}, tr({}, columns.map(col => th({
290
+ class: col.compare ? "sort" : "",
289
291
  onclick: [action_sort, col]
290
292
  }, col.name + (sortKey === col.name
291
293
  ? (reverse ? " ▼" : " ▲")
292
294
  : ""))))), tbody({}, items.map(item => tr({
293
295
  key: item.path,
296
+ class: item.children === undefined
297
+ ? "file"
298
+ : "directory",
294
299
  onclick: item.children === undefined
295
- ? itemClick ? [itemClick, item] : undefined
300
+ ? undefined
296
301
  : [action_itemClick, item]
297
302
  }, columns.map(col => {
298
303
  const v = col.val(item);
@@ -302,13 +307,20 @@ export const NavigatorFinder = function (props) {
302
307
  }, span({
303
308
  class: hitTest(t) ? "hit" : ""
304
309
  }, v));
305
- }))))),
310
+ })))))))),
306
311
  // statusBar
307
- div({
308
- class: "statusBar"
309
- }, `items ${items.length} / ${count}` + (searchText !== "" ? ` (${hitCount} hit)` : "")));
312
+ div({ class: "statusBar" }, message));
310
313
  // ---------- ---------- ----------
311
314
  // afterRender
312
315
  // ---------- ---------- ----------
313
- return afterRender ? afterRender({ state, current, extension }, vnode) : vnode;
316
+ return afterRender ? afterRender({
317
+ state,
318
+ localState: {
319
+ searchText,
320
+ selected,
321
+ sortType,
322
+ reverse,
323
+ sortKey
324
+ }
325
+ }, vnode) : vnode;
314
326
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperapp-is",
3
- "version": "0.1.15",
3
+ "version": "0.1.18",
4
4
  "description": "UI foundation library for Hyperapp by is4416",
5
5
  "license": "MIT",
6
6
  "type": "module",