hyperapp-is 0.1.45 → 0.1.47

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
@@ -516,18 +516,20 @@ export const OptionButton = function <S> (
516
516
  ---
517
517
 
518
518
  ### HistoryInput
519
- 履歴付きインプットボックス
519
+ 履歴付きインプットボックス
520
+ localState: { histories: string[] }
520
521
 
521
522
  ```ts
522
523
  export const HistoryInput = function <S> (
523
524
  props: {
524
- state : S
525
- id : string
526
- keyNames : Keys_String
527
- historyLimit?: number
528
- [key: string]: any
525
+ state : S
526
+ id : string
527
+ keyNames : Keys_String
528
+ historyLimit ?: number
529
+ afterRender ?: (state: S, localState: Record<string, any>, vnode: VNode<S>[]) => VNode<S>[]
530
+ [key: string] : any
529
531
  }
530
- ): VNode<S>
532
+ ): VNode<S>[]
531
533
  ```
532
534
 
533
535
  - props : props
@@ -535,6 +537,8 @@ export const HistoryInput = function <S> (
535
537
  - props.id : ユニークID
536
538
  - props.keyNames: ステート内の文字までのパス
537
539
  - props.historyLimit: 保持する履歴の最大数 (default = 10)
540
+ - props.afterRender : 全体のレンダーフック
541
+ - returns : [HTMLInputElement, HTMLDataListElement]
538
542
 
539
543
  履歴は `[props.id].histories` に保存されます
540
544
  履歴を動的にクリアしたい場合 `setLocalState(state, id, { histories: [] })` などとして下さい
@@ -51,15 +51,15 @@ export declare const OptionButton: <S>(props: {
51
51
  }, children: any) => VNode<S>;
52
52
  /**
53
53
  * 履歴付きインプット
54
+ * localState: { histories: string[] }
54
55
  *
55
- * div
56
- * ├ input
57
- * └ datalist
56
+ * @returns {VNode<S>[]} - [HTMLInputElement, HTMLDataListElement]
58
57
  */
59
58
  export declare const HistoryInput: <S>(props: {
60
59
  state: S;
61
60
  id: string;
62
61
  keyNames: Keys_String;
63
62
  historyLimit?: number;
63
+ afterRender?: (state: S, localState: Record<string, any>, vnode: VNode<S>[]) => VNode<S>[];
64
64
  [key: string]: any;
65
- }) => VNode<S>;
65
+ }) => VNode<S>[];
@@ -162,13 +162,12 @@ export const OptionButton = function (props, children) {
162
162
  // ---------- ---------- ---------- ---------- ----------
163
163
  /**
164
164
  * 履歴付きインプット
165
+ * localState: { histories: string[] }
165
166
  *
166
- * div
167
- * ├ input
168
- * └ datalist
167
+ * @returns {VNode<S>[]} - [HTMLInputElement, HTMLDataListElement]
169
168
  */
170
169
  export const HistoryInput = function (props) {
171
- const { state, id, keyNames, historyLimit = 10 } = props;
170
+ const { state, id, keyNames, historyLimit = 10, afterRender } = props;
172
171
  const value = getValue(state, keyNames, "");
173
172
  const localState = getLocalState(state, id, {
174
173
  histories: []
@@ -210,16 +209,22 @@ export const HistoryInput = function (props) {
210
209
  // ---------- ---------- ----------
211
210
  // VNode
212
211
  // ---------- ---------- ----------
213
- return div({}, input({
214
- type: "text",
215
- ...deleteKeys(props, "state", "keyNames", "historyLimit"),
216
- list: `${id}-history`,
217
- value,
218
- oninput,
219
- onkeydown,
220
- }), datalist({
221
- id: `${id}-history`
222
- }, histories.map(item => option({
223
- value: item
224
- }))));
212
+ const vnode = [
213
+ input({
214
+ type: "text",
215
+ ...deleteKeys(props, "state", "keyNames", "historyLimit", "afterRender"),
216
+ list: `${id}-history`,
217
+ value,
218
+ oninput,
219
+ onkeydown,
220
+ }),
221
+ datalist({
222
+ id: `${id}-history`
223
+ }, histories.map(item => option({
224
+ value: item
225
+ })))
226
+ ];
227
+ return afterRender
228
+ ? afterRender(state, localState, vnode)
229
+ : vnode;
225
230
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperapp-is",
3
- "version": "0.1.45",
3
+ "version": "0.1.47",
4
4
  "description": "UI foundation library for Hyperapp by is4416",
5
5
  "license": "MIT",
6
6
  "type": "module",