hyperapp-is 0.1.28 → 0.1.31
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
|
@@ -144,6 +144,7 @@ npm で非公開の関数 (実験用)は、解説に記載します
|
|
|
144
144
|
- [Route](#route)
|
|
145
145
|
- [SelectButton](#selectbutton)
|
|
146
146
|
- [OptionButton](#optionbutton)
|
|
147
|
+
- [HistoryInput](#historyinput)
|
|
147
148
|
|
|
148
149
|
**core / navigator.ts**
|
|
149
150
|
- [Keys_NavigatorItem](#keys_navigatoritem)
|
|
@@ -502,6 +503,32 @@ export const OptionButton = function <S> (
|
|
|
502
503
|
|
|
503
504
|
---
|
|
504
505
|
|
|
506
|
+
### HistoryInput
|
|
507
|
+
履歴付きインプットボックス
|
|
508
|
+
|
|
509
|
+
```ts
|
|
510
|
+
export const HistoryInput = function <S> (
|
|
511
|
+
props: {
|
|
512
|
+
state : S
|
|
513
|
+
id : string
|
|
514
|
+
keyNames : Keys_String
|
|
515
|
+
historyLimit?: number
|
|
516
|
+
[key: string]: any
|
|
517
|
+
}
|
|
518
|
+
): VNode<S>
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
- props : props
|
|
522
|
+
- props.state : ステート
|
|
523
|
+
- props.id : ユニークID
|
|
524
|
+
- props.keyNames: ステート内の文字までのパス
|
|
525
|
+
- props.historyLimit: 保持する履歴の最大数 (default = 10)
|
|
526
|
+
|
|
527
|
+
履歴は `[props.id].histories` に保存されます
|
|
528
|
+
履歴を動的にクリアしたい場合 `setLocalState(state, id, { histories: [] })` などとして下さい
|
|
529
|
+
|
|
530
|
+
---
|
|
531
|
+
|
|
505
532
|
### Keys_NavigatorItem
|
|
506
533
|
ステートの任意の値までのパスを表す、文字配列の型エイリアス
|
|
507
534
|
|
|
@@ -650,6 +677,10 @@ vnode
|
|
|
650
677
|
<div id={id}>
|
|
651
678
|
<div class="rapper">
|
|
652
679
|
<div class="toolBar">
|
|
680
|
+
<div>
|
|
681
|
+
<input type="text" id={id}_searchText list={id}_searchText-history/>
|
|
682
|
+
<datalist id={id}_searchText-history />
|
|
683
|
+
</div>
|
|
653
684
|
<input type="text" />
|
|
654
685
|
<button type="button">FILTER</button>
|
|
655
686
|
</div>
|
|
@@ -49,3 +49,17 @@ export declare const OptionButton: <S>(props: {
|
|
|
49
49
|
reverse?: boolean;
|
|
50
50
|
[key: string]: any;
|
|
51
51
|
}, children: any) => VNode<S>;
|
|
52
|
+
/**
|
|
53
|
+
* 履歴付きインプット
|
|
54
|
+
*
|
|
55
|
+
* div
|
|
56
|
+
* ├ input
|
|
57
|
+
* └ datalist
|
|
58
|
+
*/
|
|
59
|
+
export declare const HistoryInput: <S>(props: {
|
|
60
|
+
state: S;
|
|
61
|
+
id: string;
|
|
62
|
+
keyNames: Keys_String;
|
|
63
|
+
historyLimit?: number;
|
|
64
|
+
[key: string]: any;
|
|
65
|
+
}) => VNode<S>;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// import
|
|
4
4
|
// ---------- ---------- ---------- ---------- ----------
|
|
5
5
|
import { h, text } from "hyperapp";
|
|
6
|
-
import { getValue, setValue } from "./state";
|
|
6
|
+
import { getValue, setValue, getLocalState, setLocalState } from "./state";
|
|
7
7
|
// ---------- ---------- ---------- ---------- ----------
|
|
8
8
|
// el
|
|
9
9
|
// ---------- ---------- ---------- ---------- ----------
|
|
@@ -13,7 +13,9 @@ import { getValue, setValue } from "./state";
|
|
|
13
13
|
*/
|
|
14
14
|
export const el = (tag) => (props, ...children) => h(tag, props !== null && props !== void 0 ? props : {}, children
|
|
15
15
|
.flat()
|
|
16
|
-
.
|
|
16
|
+
.filter(child => child !== null &&
|
|
17
|
+
child !== undefined)
|
|
18
|
+
.map((child) => typeof child === "object" ? child : text(`${child}`)));
|
|
17
19
|
// ---------- ---------- ---------- ---------- ----------
|
|
18
20
|
// concatAction
|
|
19
21
|
// ---------- ---------- ---------- ---------- ----------
|
|
@@ -68,6 +70,10 @@ export const Route = function (props, children) {
|
|
|
68
70
|
// vnodes
|
|
69
71
|
// ---------- ---------- ---------- ---------- ----------
|
|
70
72
|
const button = el("button");
|
|
73
|
+
const div = el("div");
|
|
74
|
+
const input = el("input");
|
|
75
|
+
const datalist = el("datalist");
|
|
76
|
+
const option = el("option");
|
|
71
77
|
// ---------- ---------- ---------- ---------- ----------
|
|
72
78
|
// SelectButton Component
|
|
73
79
|
// ---------- ---------- ---------- ---------- ----------
|
|
@@ -151,3 +157,69 @@ export const OptionButton = function (props, children) {
|
|
|
151
157
|
onclick: action
|
|
152
158
|
}, children);
|
|
153
159
|
};
|
|
160
|
+
// ---------- ---------- ---------- ---------- ----------
|
|
161
|
+
// HistoryInput
|
|
162
|
+
// ---------- ---------- ---------- ---------- ----------
|
|
163
|
+
/**
|
|
164
|
+
* 履歴付きインプット
|
|
165
|
+
*
|
|
166
|
+
* div
|
|
167
|
+
* ├ input
|
|
168
|
+
* └ datalist
|
|
169
|
+
*/
|
|
170
|
+
export const HistoryInput = function (props) {
|
|
171
|
+
const { state, id, keyNames, historyLimit = 10 } = props;
|
|
172
|
+
const value = getValue(state, keyNames, "");
|
|
173
|
+
const localState = getLocalState(state, id, {
|
|
174
|
+
histories: []
|
|
175
|
+
});
|
|
176
|
+
const histories = localState.histories
|
|
177
|
+
.filter(item => item.toLowerCase().includes(value.toLowerCase()));
|
|
178
|
+
// ---------- ---------- ----------
|
|
179
|
+
// oninput
|
|
180
|
+
// ---------- ---------- ----------
|
|
181
|
+
const oninput = (state, e) => {
|
|
182
|
+
const element = e.target;
|
|
183
|
+
if (!element)
|
|
184
|
+
return state;
|
|
185
|
+
return concatAction(props.oninput, setValue(state, keyNames, element.value), e);
|
|
186
|
+
};
|
|
187
|
+
// ---------- ---------- ----------
|
|
188
|
+
// onkeydown
|
|
189
|
+
// ---------- ---------- ----------
|
|
190
|
+
const onkeydown = (state, e) => {
|
|
191
|
+
if (e.key !== "Enter")
|
|
192
|
+
return state;
|
|
193
|
+
const element = e.target;
|
|
194
|
+
if (!element)
|
|
195
|
+
return state;
|
|
196
|
+
const val = element.value.trim();
|
|
197
|
+
if (!val)
|
|
198
|
+
return state;
|
|
199
|
+
const items = getLocalState(state, id, {
|
|
200
|
+
histories: []
|
|
201
|
+
}).histories;
|
|
202
|
+
const newHistories = items
|
|
203
|
+
.filter(item => item !== val)
|
|
204
|
+
.concat(val)
|
|
205
|
+
.slice(-historyLimit);
|
|
206
|
+
return concatAction(props.onkeydown, setLocalState(state, id, {
|
|
207
|
+
histories: newHistories
|
|
208
|
+
}), e);
|
|
209
|
+
};
|
|
210
|
+
// ---------- ---------- ----------
|
|
211
|
+
// VNode
|
|
212
|
+
// ---------- ---------- ----------
|
|
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
|
+
}))));
|
|
225
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type { Keys, Keys_String, Keys_ArrayString, Keys_Number, Keys_ArrayNumber, Keys_ArrayRAFTask, Keys_NavigatorItem, } from "./core/state";
|
|
2
2
|
export type { NavigatorItem, JsonEntry, NavigatorColumn, SearchResult } from "./core/navigator";
|
|
3
3
|
export { getValue, setValue, getLocalState, setLocalState, createLocalKey } from "./core/state";
|
|
4
|
-
export { el, concatAction, getClassList, deleteKeys, Route, SelectButton, OptionButton } from "./core/component";
|
|
4
|
+
export { el, concatAction, getClassList, deleteKeys, Route, SelectButton, OptionButton, HistoryInput } from "./core/component";
|
|
5
5
|
export { convertJsonToNavigatorItem, getParentItems, NavigatorFinder, NavigatorSearch, icon_depth, icon_name, icon_directory, icon_file, icon_trashBox, icon_filter, icon_copy } from "./core/navigator";
|
|
6
6
|
export type { InternalEffect, RAFEvent } from "./animation/raf";
|
|
7
7
|
export type { CSSProperty } from "./animation/properties";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// hyperapp-is / index.ts
|
|
2
2
|
export { getValue, setValue, getLocalState, setLocalState, createLocalKey } from "./core/state";
|
|
3
|
-
export { el, concatAction, getClassList, deleteKeys, Route, SelectButton, OptionButton } from "./core/component";
|
|
3
|
+
export { el, concatAction, getClassList, deleteKeys, Route, SelectButton, OptionButton, HistoryInput } from "./core/component";
|
|
4
4
|
export { convertJsonToNavigatorItem, getParentItems, NavigatorFinder, NavigatorSearch, icon_depth, icon_name, icon_directory, icon_file, icon_trashBox, icon_filter, icon_copy } from "./core/navigator";
|
|
5
5
|
export { RAFTask, subscription_RAFManager } from "./animation/raf";
|
|
6
6
|
export { progress_easing } from "./animation/easing";
|