hyperapp-is 0.1.49 → 0.2.0
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 +220 -1557
- package/dist/{hyperapp-is/animation → animation}/easing.d.ts +4 -0
- package/dist/{hyperapp-is/animation → animation}/easing.js +4 -4
- package/dist/{hyperapp-is/animation → animation}/properties.d.ts +9 -16
- package/dist/{hyperapp-is/animation → animation}/properties.js +13 -12
- package/dist/{hyperapp-is/animation → animation}/raf.d.ts +11 -12
- package/dist/animation/raf.js +192 -0
- package/dist/core/component.d.ts +23 -0
- package/dist/core/component.js +52 -0
- package/dist/core/effects.d.ts +10 -0
- package/dist/core/effects.js +34 -0
- package/dist/core/state.d.ts +21 -0
- package/dist/{hyperapp-is/core → core}/state.js +15 -20
- package/dist/dom/dialog.d.ts +6 -0
- package/dist/dom/dialog.js +85 -0
- package/dist/dom/utils.d.ts +15 -0
- package/dist/dom/utils.js +19 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/services/google.d.ts +69 -0
- package/dist/services/google.js +170 -0
- package/package.json +14 -40
- package/dist/hyperapp-is/animation/index.d.ts +0 -5
- package/dist/hyperapp-is/animation/index.js +0 -4
- package/dist/hyperapp-is/animation/raf.js +0 -209
- package/dist/hyperapp-is/animationView/carousel.d.ts +0 -48
- package/dist/hyperapp-is/animationView/carousel.js +0 -461
- package/dist/hyperapp-is/animationView/index.d.ts +0 -2
- package/dist/hyperapp-is/animationView/index.js +0 -2
- package/dist/hyperapp-is/core/component.d.ts +0 -65
- package/dist/hyperapp-is/core/component.js +0 -242
- package/dist/hyperapp-is/core/index.d.ts +0 -6
- package/dist/hyperapp-is/core/index.js +0 -4
- package/dist/hyperapp-is/core/navigator.d.ts +0 -115
- package/dist/hyperapp-is/core/navigator.js +0 -615
- package/dist/hyperapp-is/core/state.d.ts +0 -27
- package/dist/hyperapp-is/dom/index.d.ts +0 -2
- package/dist/hyperapp-is/dom/index.js +0 -2
- package/dist/hyperapp-is/dom/utils.d.ts +0 -37
- package/dist/hyperapp-is/dom/utils.js +0 -69
- package/dist/hyperapp-is/index.d.ts +0 -16
- package/dist/hyperapp-is/index.js +0 -10
- package/dist/hyperapp-is/services/google.d.ts +0 -89
- package/dist/hyperapp-is/services/google.js +0 -178
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
// hyperapp-is / core / component.ts
|
|
2
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
3
|
-
// import
|
|
4
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
5
|
-
import { h, text } from "hyperapp";
|
|
6
|
-
import { getValue, setValue, getLocalState, setLocalState } from "./state";
|
|
7
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
8
|
-
// el
|
|
9
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
10
|
-
/**
|
|
11
|
-
* h 関数のラッパー
|
|
12
|
-
* hが競合する可能性があるので作成した
|
|
13
|
-
*/
|
|
14
|
-
export const el = (tag) => (props, ...children) => h(tag, props !== null && props !== void 0 ? props : {}, children
|
|
15
|
-
.flat()
|
|
16
|
-
.filter(child => child !== null &&
|
|
17
|
-
child !== undefined)
|
|
18
|
-
.map((child) => typeof child === "object" ? child : text(`${child}`)));
|
|
19
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
20
|
-
// concatAction
|
|
21
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
22
|
-
/**
|
|
23
|
-
* アクションを結合して結果を返す
|
|
24
|
-
*/
|
|
25
|
-
export const concatAction = function (action, newState, e) {
|
|
26
|
-
if (!action)
|
|
27
|
-
return newState;
|
|
28
|
-
const effect = (dispatch) => {
|
|
29
|
-
requestAnimationFrame(() => {
|
|
30
|
-
dispatch((state) => action(state, e));
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
return [newState, effect];
|
|
34
|
-
};
|
|
35
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
36
|
-
// getClassList
|
|
37
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
38
|
-
/**
|
|
39
|
-
* props から classList を取得
|
|
40
|
-
*/
|
|
41
|
-
export const getClassList = (props) => {
|
|
42
|
-
return props.class
|
|
43
|
-
? props.class.trim().split(" ").filter(Boolean)
|
|
44
|
-
: [];
|
|
45
|
-
};
|
|
46
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
47
|
-
// deleteKeys
|
|
48
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
49
|
-
/**
|
|
50
|
-
* props から不要なキーを削除する
|
|
51
|
-
*/
|
|
52
|
-
export const deleteKeys = (props, ...keys) => {
|
|
53
|
-
const result = { ...props };
|
|
54
|
-
keys.forEach(key => delete result[key]);
|
|
55
|
-
return result;
|
|
56
|
-
};
|
|
57
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
58
|
-
// Route Component
|
|
59
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
60
|
-
/**
|
|
61
|
-
* ステート内の文字とmatchした時、VNodeを返す
|
|
62
|
-
*/
|
|
63
|
-
export const Route = function (props, children) {
|
|
64
|
-
const { state, keyNames, match } = props;
|
|
65
|
-
const selectedName = getValue(state, keyNames, "");
|
|
66
|
-
// nullの場合、VNodeは生成されない
|
|
67
|
-
return selectedName === match ? children : null;
|
|
68
|
-
};
|
|
69
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
70
|
-
// vnodes
|
|
71
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
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");
|
|
77
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
78
|
-
// SelectButton Component
|
|
79
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
80
|
-
const REVERSE_PREFIX = "r_";
|
|
81
|
-
/**
|
|
82
|
-
* クリックで、クラス名 select をトグルするボタン
|
|
83
|
-
*/
|
|
84
|
-
export const SelectButton = function (props, children) {
|
|
85
|
-
const { state, keyNames, id, reverse = false } = props;
|
|
86
|
-
// classList
|
|
87
|
-
const classList = getClassList(props).filter(item => {
|
|
88
|
-
const name = item.toLowerCase();
|
|
89
|
-
return name !== "select" && name !== "reverse";
|
|
90
|
-
});
|
|
91
|
-
const selectedNames = getValue(state, keyNames, []);
|
|
92
|
-
if (selectedNames.includes(id))
|
|
93
|
-
classList.push("select");
|
|
94
|
-
if (selectedNames.includes(`${REVERSE_PREFIX}${id}`))
|
|
95
|
-
classList.push("reverse");
|
|
96
|
-
// ---------- ---------- ----------
|
|
97
|
-
// action
|
|
98
|
-
// ---------- ---------- ----------
|
|
99
|
-
const action = (state, e) => {
|
|
100
|
-
const selectedNames = getValue(state, keyNames, []);
|
|
101
|
-
const newList = selectedNames.includes(id)
|
|
102
|
-
? reverse
|
|
103
|
-
? selectedNames.filter(item => item !== id).concat(`${REVERSE_PREFIX}${id}`)
|
|
104
|
-
: selectedNames.filter(item => item !== id)
|
|
105
|
-
: selectedNames.includes(`${REVERSE_PREFIX}${id}`)
|
|
106
|
-
? selectedNames.filter(item => item !== `${REVERSE_PREFIX}${id}`)
|
|
107
|
-
: selectedNames.concat(id);
|
|
108
|
-
const newState = setValue(state, keyNames, newList);
|
|
109
|
-
return concatAction(props.onclick, newState, e);
|
|
110
|
-
};
|
|
111
|
-
// ---------- ---------- ----------
|
|
112
|
-
// VNode
|
|
113
|
-
// ---------- ---------- ----------
|
|
114
|
-
return button({
|
|
115
|
-
type: "button",
|
|
116
|
-
...deleteKeys(props, "state", "keyNames", "reverse"),
|
|
117
|
-
class: classList.join(" "),
|
|
118
|
-
onclick: action
|
|
119
|
-
}, children);
|
|
120
|
-
};
|
|
121
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
122
|
-
// OptionButton Component
|
|
123
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
124
|
-
/**
|
|
125
|
-
* クリックで、クラス名 select を排他的に選択するボタン
|
|
126
|
-
*/
|
|
127
|
-
export const OptionButton = function (props, children) {
|
|
128
|
-
const { state, keyNames, id, reverse = false } = props;
|
|
129
|
-
// classList
|
|
130
|
-
const classList = getClassList(props).filter(item => {
|
|
131
|
-
const name = item.toLowerCase();
|
|
132
|
-
return name !== "select" && name !== "reverse";
|
|
133
|
-
});
|
|
134
|
-
const selectedName = getValue(state, keyNames, "");
|
|
135
|
-
if (selectedName === id)
|
|
136
|
-
classList.push("select");
|
|
137
|
-
if (selectedName === `${REVERSE_PREFIX}${id}`)
|
|
138
|
-
classList.push("reverse");
|
|
139
|
-
// ---------- ---------- ----------
|
|
140
|
-
// action
|
|
141
|
-
// ---------- ---------- ----------
|
|
142
|
-
const action = (state, e) => {
|
|
143
|
-
const selectedName = getValue(state, keyNames, "");
|
|
144
|
-
const newValue = selectedName === id && reverse
|
|
145
|
-
? `${REVERSE_PREFIX}${id}`
|
|
146
|
-
: id;
|
|
147
|
-
const newState = setValue(state, keyNames, newValue);
|
|
148
|
-
return concatAction(props.onclick, newState, e);
|
|
149
|
-
};
|
|
150
|
-
// ---------- ---------- ----------
|
|
151
|
-
// VNode
|
|
152
|
-
// ---------- ---------- ----------
|
|
153
|
-
return button({
|
|
154
|
-
type: "button",
|
|
155
|
-
...deleteKeys(props, "state", "keyNames", "reverse"),
|
|
156
|
-
class: classList.join(" "),
|
|
157
|
-
onclick: action
|
|
158
|
-
}, children);
|
|
159
|
-
};
|
|
160
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
161
|
-
// HistoryInput
|
|
162
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
163
|
-
/**
|
|
164
|
-
* 履歴付きインプット
|
|
165
|
-
* localState: { histories: string[] }
|
|
166
|
-
*
|
|
167
|
-
* @returns {VNode<S>[]} - [HTMLInputElement, HTMLDataListElement]
|
|
168
|
-
*/
|
|
169
|
-
export const HistoryInput = function (props) {
|
|
170
|
-
const { state, id, keyNames, historyLimit = 10, afterRender } = props;
|
|
171
|
-
const value = getValue(state, keyNames, "");
|
|
172
|
-
const localState = getLocalState(state, id, {
|
|
173
|
-
histories: []
|
|
174
|
-
});
|
|
175
|
-
const histories = localState.histories
|
|
176
|
-
.filter(item => item.toLowerCase().includes(value.toLowerCase()));
|
|
177
|
-
// ---------- ---------- ----------
|
|
178
|
-
// oninput
|
|
179
|
-
// ---------- ---------- ----------
|
|
180
|
-
const oninput = (state, e) => {
|
|
181
|
-
const element = e.target;
|
|
182
|
-
if (!element)
|
|
183
|
-
return state;
|
|
184
|
-
return concatAction(props.oninput, setValue(state, keyNames, element.value), e);
|
|
185
|
-
};
|
|
186
|
-
// ---------- ---------- ----------
|
|
187
|
-
// onkeydown
|
|
188
|
-
// ---------- ---------- ----------
|
|
189
|
-
const onkeydown = (state, e) => {
|
|
190
|
-
if (e.key !== "Enter")
|
|
191
|
-
return state;
|
|
192
|
-
const element = e.target;
|
|
193
|
-
if (!element)
|
|
194
|
-
return state;
|
|
195
|
-
const val = element.value.trim();
|
|
196
|
-
if (!val)
|
|
197
|
-
return state;
|
|
198
|
-
const items = getLocalState(state, id, {
|
|
199
|
-
histories: []
|
|
200
|
-
}).histories;
|
|
201
|
-
const newHistories = items
|
|
202
|
-
.filter(item => item !== val)
|
|
203
|
-
.concat(val)
|
|
204
|
-
.slice(-historyLimit);
|
|
205
|
-
return concatAction(props.onkeydown, setLocalState(state, id, {
|
|
206
|
-
histories: newHistories
|
|
207
|
-
}), e);
|
|
208
|
-
};
|
|
209
|
-
// ---------- ---------- ----------
|
|
210
|
-
// action_clear
|
|
211
|
-
// ---------- ---------- ----------
|
|
212
|
-
const action_clear = (state) => {
|
|
213
|
-
return setValue(setLocalState(state, id, {
|
|
214
|
-
histories: []
|
|
215
|
-
}), keyNames, "");
|
|
216
|
-
};
|
|
217
|
-
// ---------- ---------- ----------
|
|
218
|
-
// VNode
|
|
219
|
-
// ---------- ---------- ----------
|
|
220
|
-
const vnode = [
|
|
221
|
-
input({
|
|
222
|
-
type: "text",
|
|
223
|
-
...deleteKeys(props, "state", "keyNames", "historyLimit", "afterRender"),
|
|
224
|
-
list: `${id}-history`,
|
|
225
|
-
value,
|
|
226
|
-
oninput,
|
|
227
|
-
onkeydown,
|
|
228
|
-
}),
|
|
229
|
-
datalist({
|
|
230
|
-
id: `${id}-history`
|
|
231
|
-
}, histories.map(item => option({
|
|
232
|
-
value: item
|
|
233
|
-
}))),
|
|
234
|
-
button({
|
|
235
|
-
type: "button",
|
|
236
|
-
onclick: action_clear
|
|
237
|
-
}, "クリア")
|
|
238
|
-
];
|
|
239
|
-
return afterRender
|
|
240
|
-
? afterRender(state, localState, vnode)
|
|
241
|
-
: vnode;
|
|
242
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export type { Keys } from "./state";
|
|
2
|
-
export { getValue, setValue, getLocalState, setLocalState, createLocalKey } from "./state";
|
|
3
|
-
export type { Keys_String, Keys_ArrayString } from "./component";
|
|
4
|
-
export { el, concatAction, getClassList, deleteKeys, Route, SelectButton, OptionButton } from "./component";
|
|
5
|
-
export type { Keys_NavigatorItem, NavigatorItem, JsonEntry, NavigatorColumn } from "./navigator";
|
|
6
|
-
export { convertJsonToNavigatorItem, getParentItems, NavigatorFinder } from "./navigator";
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
// hyperapp-is / core / index.ts
|
|
2
|
-
export { getValue, setValue, getLocalState, setLocalState, createLocalKey } from "./state";
|
|
3
|
-
export { el, concatAction, getClassList, deleteKeys, Route, SelectButton, OptionButton } from "./component";
|
|
4
|
-
export { convertJsonToNavigatorItem, getParentItems, NavigatorFinder } from "./navigator";
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { VNode } from "hyperapp";
|
|
2
|
-
import { Keys_NavigatorItem } from "./state";
|
|
3
|
-
export interface NavigatorItem {
|
|
4
|
-
parent: NavigatorItem | null;
|
|
5
|
-
name: string;
|
|
6
|
-
path: string;
|
|
7
|
-
properties?: Record<string, any>;
|
|
8
|
-
children?: NavigatorItem[];
|
|
9
|
-
extension?: Record<string, any>;
|
|
10
|
-
}
|
|
11
|
-
export interface JsonEntry<D> {
|
|
12
|
-
name: string;
|
|
13
|
-
data: D;
|
|
14
|
-
isNode: boolean;
|
|
15
|
-
}
|
|
16
|
-
export interface NavigatorColumn {
|
|
17
|
-
name: string;
|
|
18
|
-
val: (item: NavigatorItem) => any;
|
|
19
|
-
text?: (item: NavigatorItem) => string;
|
|
20
|
-
compare?: (a: NavigatorItem, b: NavigatorItem) => number;
|
|
21
|
-
}
|
|
22
|
-
export declare const convertJsonToNavigatorItem: <D>(props: {
|
|
23
|
-
parent: NavigatorItem | null;
|
|
24
|
-
name: string;
|
|
25
|
-
data: D;
|
|
26
|
-
getEntries: (data: D, depth: number) => JsonEntry<D>[];
|
|
27
|
-
isNode: boolean;
|
|
28
|
-
depth?: number;
|
|
29
|
-
extension?: (item: NavigatorItem, data: D, depth: number) => Record<string, any> | undefined;
|
|
30
|
-
}) => NavigatorItem;
|
|
31
|
-
export declare const getParentItems: (item: NavigatorItem | undefined) => NavigatorItem[];
|
|
32
|
-
/**
|
|
33
|
-
* ファインダー
|
|
34
|
-
*
|
|
35
|
-
* - 必須項目
|
|
36
|
-
* state, id, currentKeys
|
|
37
|
-
*
|
|
38
|
-
* - 拡張項目
|
|
39
|
-
* columns, plugIn, afterRender
|
|
40
|
-
*
|
|
41
|
-
* - columns
|
|
42
|
-
* カラムの表示設定
|
|
43
|
-
*
|
|
44
|
-
* - plugIn
|
|
45
|
-
* プラグインの追加
|
|
46
|
-
*
|
|
47
|
-
* - afterRender
|
|
48
|
-
* レンダーフック
|
|
49
|
-
*/
|
|
50
|
-
export declare const NavigatorFinder: <S>(props: {
|
|
51
|
-
state: S;
|
|
52
|
-
id: string;
|
|
53
|
-
currentKeys: Keys_NavigatorItem;
|
|
54
|
-
columns?: (directory: NavigatorItem | undefined) => NavigatorColumn[];
|
|
55
|
-
plugIn?: (state: S, localState: Record<string, any>) => VNode<S>[];
|
|
56
|
-
toolBarNode?: (state: S, localState: Record<string, any>, vnode: VNode<S>) => VNode<S>;
|
|
57
|
-
parentItemsNode?: (state: S, localState: Record<string, any>, vnode: VNode<S>) => VNode<S>;
|
|
58
|
-
statusBarNode?: (state: S, localState: Record<string, any>, vnode: VNode<S>) => VNode<S>;
|
|
59
|
-
afterRender?: (state: S, localState: Record<string, any>, vnode: VNode<S>) => VNode<S>;
|
|
60
|
-
[key: string]: any;
|
|
61
|
-
}) => VNode<S>;
|
|
62
|
-
export declare const icon_depth: VNode<any>;
|
|
63
|
-
export declare const icon_name: VNode<any>;
|
|
64
|
-
export declare const icon_directory: VNode<any>;
|
|
65
|
-
export declare const icon_file: VNode<any>;
|
|
66
|
-
export declare const icon_trashBox: VNode<any>;
|
|
67
|
-
export declare const icon_filter: VNode<any>;
|
|
68
|
-
export declare const icon_copy: VNode<any>;
|
|
69
|
-
/**
|
|
70
|
-
* 検索結果
|
|
71
|
-
*
|
|
72
|
-
* - item
|
|
73
|
-
* ヒットしたアイテム
|
|
74
|
-
*
|
|
75
|
-
* - depth
|
|
76
|
-
* current からの深度
|
|
77
|
-
*/
|
|
78
|
-
export interface SearchResult {
|
|
79
|
-
item: NavigatorItem;
|
|
80
|
-
depth: number;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* ファイルサーチ - NavigatorFinder プラグイン
|
|
84
|
-
*
|
|
85
|
-
* - 必須項目
|
|
86
|
-
* state, id, currentKeys, searchResult, hitTest, maxItemsCount
|
|
87
|
-
*
|
|
88
|
-
* - searchResult
|
|
89
|
-
* カードとして表示するVNode
|
|
90
|
-
*
|
|
91
|
-
* - hitTest
|
|
92
|
-
* 抽出条件
|
|
93
|
-
*
|
|
94
|
-
* - maxItemsCount
|
|
95
|
-
* 最初に表示させるカードの最大数
|
|
96
|
-
*
|
|
97
|
-
* - 拡張項目
|
|
98
|
-
* afterRender
|
|
99
|
-
*
|
|
100
|
-
* - afterRender
|
|
101
|
-
* レンダーフック
|
|
102
|
-
*/
|
|
103
|
-
export declare const NavigatorSearch: <S>(props: {
|
|
104
|
-
state: S;
|
|
105
|
-
id: string;
|
|
106
|
-
currentKeys: Keys_NavigatorItem;
|
|
107
|
-
searchResult: (item: NavigatorItem, depth: number) => VNode<S> | VNode<S>[];
|
|
108
|
-
hitTest: (item: NavigatorItem) => boolean;
|
|
109
|
-
maxItemsCount: number;
|
|
110
|
-
toolBarNode?: (state: S, localState: Record<string, any>, vnode: VNode<S>) => VNode<S>;
|
|
111
|
-
parentItemsNode?: (state: S, localState: Record<string, any>, vnode: VNode<S>) => VNode<S>;
|
|
112
|
-
statusBarNode?: (state: S, localState: Record<string, any>, vnode: VNode<S>) => VNode<S>;
|
|
113
|
-
afterRender?: (state: S, localState: Record<string, any>, vnode: VNode<S>) => VNode<S>;
|
|
114
|
-
[key: string]: any;
|
|
115
|
-
}) => VNode<S>;
|