hyperapp-is 0.1.21 → 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 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,11 +632,13 @@ 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
640
  <div id={id}>
641
+
636
642
  <div class="toolBar">
637
643
  <input type="text" />
638
644
  <button type="button">FILTER</button>
@@ -662,11 +668,18 @@ vnode
662
668
  </table>
663
669
  </div>
664
670
 
665
- <!-- statusBar -->
666
671
  <div class="statusBar">message</div>
672
+
673
+ <!-- plugIn 必要な文だけ追加 -->
674
+ <div id={plugInID}>
675
+ </div>
667
676
  </div>
668
677
  ```
669
678
 
679
+ **CSS設計**
680
+ - plugInを追加する場合は `grid` で整える前提
681
+ - `flex` で整える場合は `afterRender` を併用し VNode を調整する
682
+
670
683
  ---
671
684
 
672
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 { searchText, selected, sortType, reverse, sortKey } = getLocalState(state, id, {
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,13 +270,13 @@ export const NavigatorFinder = function (props) {
261
270
  // VNode
262
271
  // ---------- ---------- ----------
263
272
  const vnode = div({
264
- ...deleteKeys(props, "state", "currentKeys", "columns", "afterRender", "extension")
273
+ ...deleteKeys(props, "state", "currentKeys", "columns", "plugIn", "afterRender")
265
274
  }, div({
266
275
  class: "toolBar"
267
276
  }, input({
268
277
  type: "text",
269
278
  placeholder: "search keys",
270
- value: searchText,
279
+ value: localState.searchText,
271
280
  oninput: action_inputSearchText
272
281
  }), SelectButton({
273
282
  state: state,
@@ -287,8 +296,8 @@ export const NavigatorFinder = function (props) {
287
296
  }, table({}, thead({}, tr({}, columns.map(col => th({
288
297
  class: col.compare ? "sort" : "",
289
298
  onclick: [action_sort, col]
290
- }, col.name + (sortKey === col.name
291
- ? (reverse ? " ▼" : " ▲")
299
+ }, col.name + (localState.sortKey === col.name
300
+ ? (localState.reverse ? " ▼" : " ▲")
292
301
  : ""))))), tbody({}, items.map(item => tr({
293
302
  key: item.path,
294
303
  class: item.children === undefined
@@ -307,18 +316,13 @@ export const NavigatorFinder = function (props) {
307
316
  }, v));
308
317
  })))))),
309
318
  // statusBar
310
- div({ class: "statusBar" }, message));
319
+ div({ class: "statusBar" }, message),
320
+ // plugIn
321
+ plugIn
322
+ ? plugIn({ state, localState })
323
+ : []);
311
324
  // ---------- ---------- ----------
312
325
  // afterRender
313
326
  // ---------- ---------- ----------
314
- return afterRender ? afterRender({
315
- state,
316
- localState: {
317
- searchText,
318
- selected,
319
- sortType,
320
- reverse,
321
- sortKey
322
- }
323
- }, vnode) : vnode;
327
+ return afterRender ? afterRender({ state, localState }, vnode) : vnode;
324
328
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperapp-is",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "description": "UI foundation library for Hyperapp by is4416",
5
5
  "license": "MIT",
6
6
  "type": "module",