hyperapp-is 0.1.6 → 0.1.8
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 +176 -10
- package/dist/hyperapp-is/animation/easing.js +1 -1
- package/dist/hyperapp-is/animation/index.js +1 -0
- package/dist/hyperapp-is/animation/properties.d.ts +2 -6
- package/dist/hyperapp-is/animation/properties.js +1 -1
- package/dist/hyperapp-is/animation/raf.d.ts +7 -12
- package/dist/hyperapp-is/animation/raf.js +3 -3
- package/dist/hyperapp-is/animationView/carousel.d.ts +17 -18
- package/dist/hyperapp-is/animationView/carousel.js +14 -16
- package/dist/hyperapp-is/animationView/index.js +1 -0
- package/dist/hyperapp-is/core/component.d.ts +7 -6
- package/dist/hyperapp-is/core/component.js +4 -4
- package/dist/hyperapp-is/core/index.d.ts +4 -0
- package/dist/hyperapp-is/core/index.js +2 -0
- package/dist/hyperapp-is/core/navigator.d.ts +74 -0
- package/dist/hyperapp-is/core/navigator.js +193 -0
- package/dist/hyperapp-is/core/state.d.ts +22 -17
- package/dist/hyperapp-is/core/state.js +8 -8
- package/dist/hyperapp-is/dom/index.d.ts +1 -1
- package/dist/hyperapp-is/dom/index.js +2 -1
- package/dist/hyperapp-is/dom/utils.d.ts +0 -19
- package/dist/hyperapp-is/dom/utils.js +1 -85
- package/dist/hyperapp-is/index.d.ts +14 -7
- package/dist/hyperapp-is/index.js +9 -5
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -127,6 +127,7 @@ JSX を使用する場合は `hyperapp-jsx-pragma` を前提としています
|
|
|
127
127
|
npm で非公開の関数 (実験用)は、解説に記載します
|
|
128
128
|
|
|
129
129
|
**core / state.ts**
|
|
130
|
+
- [Keys](#keys)
|
|
130
131
|
- [getValue](#getvalue)
|
|
131
132
|
- [setValue](#setvalue)
|
|
132
133
|
- [getLocalState](#getlocalstate)
|
|
@@ -134,6 +135,8 @@ npm で非公開の関数 (実験用)は、解説に記載します
|
|
|
134
135
|
- [createLocalKey](#createlocalkey)
|
|
135
136
|
|
|
136
137
|
**core / component.ts**
|
|
138
|
+
- [Keys_String](#keys_string-keys_arraystring)
|
|
139
|
+
- [Keys_ArrayString](#keys_string-keys_arraystring)
|
|
137
140
|
- [el](#el)
|
|
138
141
|
- [concatAction](#concataction)
|
|
139
142
|
- [getClassList](#getclasslist)
|
|
@@ -142,6 +145,15 @@ npm で非公開の関数 (実験用)は、解説に記載します
|
|
|
142
145
|
- [SelectButton](#selectbutton)
|
|
143
146
|
- [OptionButton](#optionbutton)
|
|
144
147
|
|
|
148
|
+
**core / navigator.ts**
|
|
149
|
+
- [Keys_NavigatorItem](#keys_navigatoritem)
|
|
150
|
+
- [NavigatorItem](#navigatoritem)
|
|
151
|
+
- [JsonEntry](#jsonentry)
|
|
152
|
+
- [NavigatorColumn](#navigatorcolumn)
|
|
153
|
+
- [convertJsonToNavigatorItem](#convertjsontonavigatoritem)
|
|
154
|
+
- [getParentItems](#getparentitems)
|
|
155
|
+
- [NavigatorFinder](#navigatorfinder)
|
|
156
|
+
|
|
145
157
|
**animation / step.ts**
|
|
146
158
|
- [effect_throwMessageStart](#effect_throwmessagestart)
|
|
147
159
|
- [effect_throwMessagePause](#effect_throwmessagepause--effect_throwmessageresume)
|
|
@@ -198,11 +210,17 @@ src
|
|
|
198
210
|
│
|
|
199
211
|
├ core
|
|
200
212
|
│ ├ state.ts
|
|
213
|
+
│ │ Keys
|
|
201
214
|
│ │ getValue, setValue, getLocalState, setLocalState, createLocalKey
|
|
202
215
|
│ │
|
|
203
|
-
│
|
|
204
|
-
│
|
|
205
|
-
│
|
|
216
|
+
│ ├ component.ts
|
|
217
|
+
│ │ Keys_String, Keys_ArrayString
|
|
218
|
+
│ │ el, concatAction, getClassList, deleteKeys
|
|
219
|
+
│ │ Route, SelectButton, OptionButton
|
|
220
|
+
│ │
|
|
221
|
+
│ └ navigator.ts
|
|
222
|
+
│ Keys_NavigatorItem, NavigatorItem, JsonEntry, NavigatorColumn
|
|
223
|
+
│ convertJsonToNavigatorItem, getParentItems, NavigatorFinder
|
|
206
224
|
│
|
|
207
225
|
├ animation
|
|
208
226
|
│ ├ step.ts
|
|
@@ -249,6 +267,15 @@ src
|
|
|
249
267
|
|
|
250
268
|
## hyperapp-is/core
|
|
251
269
|
|
|
270
|
+
### Keys
|
|
271
|
+
ステートの任意の値までのパスを表す、文字配列の型エイリアス
|
|
272
|
+
|
|
273
|
+
```ts
|
|
274
|
+
export type Keys = readonly string[]
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
252
279
|
### getValue
|
|
253
280
|
パスを辿ってステートから値を取得
|
|
254
281
|
安全にアクセス可能
|
|
@@ -327,6 +354,11 @@ export const createLocalKey = (id: string): string => `local_key_${ id }`
|
|
|
327
354
|
|
|
328
355
|
---
|
|
329
356
|
|
|
357
|
+
### Keys_String, Keys_ArrayString
|
|
358
|
+
ステートの任意の値までのパスを表す、文字配列の型エイリアス
|
|
359
|
+
|
|
360
|
+
---
|
|
361
|
+
|
|
330
362
|
### el
|
|
331
363
|
Hyperapp の h 関数ラッパー。JSX と競合する場合に使用
|
|
332
364
|
children の処理も同時に行っているため、本ライブラリでは VNode を作成する際に使用しています
|
|
@@ -465,6 +497,140 @@ export const OptionButton = function <S> (
|
|
|
465
497
|
- props.reverse?: 反転選択するか
|
|
466
498
|
- children : 子要素 (VNode / string / 配列など)
|
|
467
499
|
|
|
500
|
+
---
|
|
501
|
+
|
|
502
|
+
### Keys_NavigatorItem
|
|
503
|
+
ステートの任意の値までのパスを表す、文字配列の型エイリアス
|
|
504
|
+
|
|
505
|
+
---
|
|
506
|
+
|
|
507
|
+
### NavigatorItem
|
|
508
|
+
ツリー構造となるナビゲーションオブジェクト
|
|
509
|
+
|
|
510
|
+
```ts
|
|
511
|
+
export interface NavigatorItem {
|
|
512
|
+
parent : NavigatorItem | null
|
|
513
|
+
name : string
|
|
514
|
+
properties?: Record<string, any>
|
|
515
|
+
children ?: NavigatorItem[]
|
|
516
|
+
path : string
|
|
517
|
+
extension ?: Record<string, any>
|
|
518
|
+
}
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
- parent : 親アイテム
|
|
522
|
+
- name : 名前
|
|
523
|
+
- properties: プロパティ
|
|
524
|
+
- children : 子アイテム
|
|
525
|
+
- path : パス
|
|
526
|
+
- extension : 拡張オブジェクト
|
|
527
|
+
|
|
528
|
+
---
|
|
529
|
+
|
|
530
|
+
### JsonEntry
|
|
531
|
+
getEntriesの返す値
|
|
532
|
+
|
|
533
|
+
```ts
|
|
534
|
+
export interface JsonEntry <D> {
|
|
535
|
+
name : string
|
|
536
|
+
data : D
|
|
537
|
+
isNode: boolean
|
|
538
|
+
}
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
- name : 名前
|
|
542
|
+
- data : データ
|
|
543
|
+
- isNode : ディレクトリか
|
|
544
|
+
|
|
545
|
+
---
|
|
546
|
+
|
|
547
|
+
### NavigatorColumn
|
|
548
|
+
NavigatorFinder に渡すヘッダーと値
|
|
549
|
+
|
|
550
|
+
```ts
|
|
551
|
+
export interface NavigatorColumn {
|
|
552
|
+
name: string
|
|
553
|
+
val : (item: NavigatorItem) => any
|
|
554
|
+
}
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
- name: 名前
|
|
558
|
+
- val : 値を返す関数
|
|
559
|
+
|
|
560
|
+
---
|
|
561
|
+
|
|
562
|
+
### convertJsonToNavigatorItem
|
|
563
|
+
Json から NavigatorItem に変換
|
|
564
|
+
getEntries の採用により、JSON の形を問わない
|
|
565
|
+
|
|
566
|
+
```ts
|
|
567
|
+
export const convertJsonToNavigatorItem = function <D> (
|
|
568
|
+
props: {
|
|
569
|
+
parent : NavigatorItem | null
|
|
570
|
+
name : string
|
|
571
|
+
data : D
|
|
572
|
+
getEntries : (data: D, depth: number) => JsonEntry<D>[]
|
|
573
|
+
isNode : boolean
|
|
574
|
+
depth ?: number
|
|
575
|
+
extension ?: (item: NavigatorItem, data: D, depth: number) => Record<string, any> | undefined
|
|
576
|
+
}
|
|
577
|
+
): NavigatorItem
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
- parent : 親アイテム
|
|
581
|
+
- name : 名前
|
|
582
|
+
- data : データ
|
|
583
|
+
- getEntries: JsonEntry配列を返す関数
|
|
584
|
+
- isNode : ディレクトリか
|
|
585
|
+
- depth : 階層の深さ
|
|
586
|
+
- extension : 拡張オブジェクトを作成する関数
|
|
587
|
+
|
|
588
|
+
---
|
|
589
|
+
|
|
590
|
+
### getParentItems
|
|
591
|
+
NavigatorItem から 親アイテムのリストを取得する
|
|
592
|
+
自分自信はリストに含まない
|
|
593
|
+
|
|
594
|
+
```ts
|
|
595
|
+
export const getParentItems = (
|
|
596
|
+
item: NavigatorItem | undefined
|
|
597
|
+
): NavigatorItem[]
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
---
|
|
601
|
+
|
|
602
|
+
### NavigatorFinder
|
|
603
|
+
ナビゲーターファインダーコンポーネント
|
|
604
|
+
|
|
605
|
+
```ts
|
|
606
|
+
export const NavigatorFinder = function <S> (
|
|
607
|
+
props: {
|
|
608
|
+
state : S
|
|
609
|
+
currentKeys : Keys_NavigatorItem
|
|
610
|
+
columns ?: (directory: NavigatorItem | undefined) => NavigatorColumn[]
|
|
611
|
+
maxItemsCount?: number
|
|
612
|
+
itemClick ?: (state: S, item: NavigatorItem) => S | [S, Effect<S>]
|
|
613
|
+
afterRender ?: (props: {
|
|
614
|
+
state : S
|
|
615
|
+
current ?: NavigatorItem
|
|
616
|
+
extension?: Record<string, any>
|
|
617
|
+
}, vnode: VNode<S>) => VNode<S>
|
|
618
|
+
extension ?: Record<string, any>
|
|
619
|
+
[key: string]: any
|
|
620
|
+
}
|
|
621
|
+
): VNode<S>
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
- state : ステート
|
|
625
|
+
- currentKeys : カレント NavigatorItem までのパス
|
|
626
|
+
- columns : NavigatorColumn の配列を返す関数
|
|
627
|
+
- maxItemsCount: 最大表示するアイテム数
|
|
628
|
+
- itemClick : アイテムをクリックした時のアクション
|
|
629
|
+
- afterRender : レンダーフック
|
|
630
|
+
- extension : レンダーフックに渡す拡張情報
|
|
631
|
+
|
|
632
|
+
---
|
|
633
|
+
|
|
468
634
|
## hyperapp-is/animation
|
|
469
635
|
|
|
470
636
|
### effect_throwMessageStart
|
|
@@ -599,7 +765,7 @@ export class RAFTask <S> {
|
|
|
599
765
|
action : RAFEvent<S>
|
|
600
766
|
finish ?: RAFEvent<S>
|
|
601
767
|
priority ?: number
|
|
602
|
-
extension?:
|
|
768
|
+
extension?: Record<string, any>
|
|
603
769
|
})
|
|
604
770
|
|
|
605
771
|
// getter
|
|
@@ -614,7 +780,7 @@ export class RAFTask <S> {
|
|
|
614
780
|
// getter / setter
|
|
615
781
|
groupID : string | undefined
|
|
616
782
|
priority : number
|
|
617
|
-
extension:
|
|
783
|
+
extension: Record<string, any>
|
|
618
784
|
isDone : boolean
|
|
619
785
|
paused : boolean
|
|
620
786
|
|
|
@@ -729,7 +895,7 @@ export const createRAFProperties = function <S> (
|
|
|
729
895
|
finish?: (state: S, rafTask: RAFTask<S>) => S | [S, InternalEffect<S>]
|
|
730
896
|
|
|
731
897
|
priority ?: number
|
|
732
|
-
extension?:
|
|
898
|
+
extension?: Record<string, any>
|
|
733
899
|
|
|
734
900
|
properties: CSSProperty[]
|
|
735
901
|
}
|
|
@@ -756,7 +922,7 @@ export const effect_RAFProperties = function <S>(
|
|
|
756
922
|
finish?: (state: S, rafTask: RAFTask<S>) => S | [S, InternalEffect<S>]
|
|
757
923
|
|
|
758
924
|
priority ?: number
|
|
759
|
-
extension?:
|
|
925
|
+
extension?: Record<string, any>
|
|
760
926
|
|
|
761
927
|
properties: CSSProperty[]
|
|
762
928
|
keyNames : string[]
|
|
@@ -808,7 +974,7 @@ export const createRAFTranslate = function <S> (
|
|
|
808
974
|
finish?: (state: S, rafTask: RAFTask<S>) => S | [S, InternalEffect<S>]
|
|
809
975
|
|
|
810
976
|
priority ?: number
|
|
811
|
-
extension?:
|
|
977
|
+
extension?: Record<string, any>
|
|
812
978
|
|
|
813
979
|
translateState: TranslateState
|
|
814
980
|
}
|
|
@@ -836,7 +1002,7 @@ export const effect_translateStart = function <S> (
|
|
|
836
1002
|
finish?: (state: S, rafTask: RAFTask<S>) => S | [S, InternalEffect<S>]
|
|
837
1003
|
|
|
838
1004
|
priority ?: number
|
|
839
|
-
extension?:
|
|
1005
|
+
extension?: Record<string, any>
|
|
840
1006
|
|
|
841
1007
|
easing ?: (t: number) => number
|
|
842
1008
|
|
|
@@ -1023,7 +1189,7 @@ export interface CarouselState <S> {
|
|
|
1023
1189
|
duration ?: number
|
|
1024
1190
|
delay ?: number
|
|
1025
1191
|
priority ?: number
|
|
1026
|
-
extension?:
|
|
1192
|
+
extension?: Record<string, any>
|
|
1027
1193
|
|
|
1028
1194
|
// event
|
|
1029
1195
|
action?: RAFEvent<S>
|
|
@@ -37,9 +37,7 @@ export declare const createRAFProperties: <S>(props: {
|
|
|
37
37
|
delay?: number;
|
|
38
38
|
finish?: (state: S, rafTask: RAFTask<S>) => S | [S, InternalEffect<S>];
|
|
39
39
|
priority?: number;
|
|
40
|
-
extension?:
|
|
41
|
-
[key: string]: any;
|
|
42
|
-
};
|
|
40
|
+
extension?: Record<string, any>;
|
|
43
41
|
properties: CSSProperty[];
|
|
44
42
|
}) => RAFTask<S>;
|
|
45
43
|
/**
|
|
@@ -56,9 +54,7 @@ export declare const effect_RAFProperties: <S>(props: {
|
|
|
56
54
|
delay?: number;
|
|
57
55
|
finish?: (state: S, rafTask: RAFTask<S>) => S | [S, InternalEffect<S>];
|
|
58
56
|
priority?: number;
|
|
59
|
-
extension?:
|
|
60
|
-
[key: string]: any;
|
|
61
|
-
};
|
|
57
|
+
extension?: Record<string, any>;
|
|
62
58
|
properties: CSSProperty[];
|
|
63
59
|
keyNames: string[];
|
|
64
60
|
}) => (dispatch: Dispatch<S>) => void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Effect, Subscription } from "hyperapp";
|
|
2
|
+
import { Keys_ArrayRAFTask } from "../core/state";
|
|
2
3
|
/**
|
|
3
4
|
* 戻値としては返されないことを示したエフェクト
|
|
4
5
|
* Effect の型エイリアス
|
|
@@ -20,9 +21,7 @@ export declare class RAFTask<S> {
|
|
|
20
21
|
action: RAFEvent<S>;
|
|
21
22
|
finish?: RAFEvent<S>;
|
|
22
23
|
priority?: number;
|
|
23
|
-
extension?:
|
|
24
|
-
[key: string]: any;
|
|
25
|
-
};
|
|
24
|
+
extension?: Record<string, any>;
|
|
26
25
|
});
|
|
27
26
|
get id(): string;
|
|
28
27
|
get groupID(): string | undefined;
|
|
@@ -31,18 +30,14 @@ export declare class RAFTask<S> {
|
|
|
31
30
|
get action(): RAFEvent<S>;
|
|
32
31
|
get finish(): RAFEvent<S> | undefined;
|
|
33
32
|
get priority(): number;
|
|
34
|
-
get extension():
|
|
35
|
-
[key: string]: any;
|
|
36
|
-
};
|
|
33
|
+
get extension(): Record<string, any>;
|
|
37
34
|
get progress(): number;
|
|
38
35
|
get deltaTime(): number;
|
|
39
36
|
get isDone(): boolean;
|
|
40
37
|
get paused(): boolean;
|
|
41
38
|
set groupID(val: string | undefined);
|
|
42
39
|
set priority(val: number);
|
|
43
|
-
set extension(val:
|
|
44
|
-
[key: string]: any;
|
|
45
|
-
});
|
|
40
|
+
set extension(val: Record<string, any>);
|
|
46
41
|
set isDone(val: boolean);
|
|
47
42
|
set paused(val: boolean);
|
|
48
43
|
/**
|
|
@@ -63,9 +58,9 @@ export declare class RAFTask<S> {
|
|
|
63
58
|
* RAFTask 配列をフレームごとに実行するサブスクリプション
|
|
64
59
|
*
|
|
65
60
|
* @template S
|
|
66
|
-
* @param {S}
|
|
67
|
-
* @param {
|
|
61
|
+
* @param {S} state - ステート
|
|
62
|
+
* @param {Keys_ArrayRAFTask} keyNames - RAFTask 配列までのパス
|
|
68
63
|
* @returns {Subscription<S>}
|
|
69
64
|
*/
|
|
70
|
-
export declare const subscription_RAFManager: <S>(state: S, keyNames:
|
|
65
|
+
export declare const subscription_RAFManager: <S>(state: S, keyNames: Keys_ArrayRAFTask) => Subscription<S>;
|
|
71
66
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// hyperapp-
|
|
1
|
+
// hyperapp-is / animation / raf.ts
|
|
2
2
|
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
3
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
4
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
@@ -143,8 +143,8 @@ export class RAFTask {
|
|
|
143
143
|
* RAFTask 配列をフレームごとに実行するサブスクリプション
|
|
144
144
|
*
|
|
145
145
|
* @template S
|
|
146
|
-
* @param {S}
|
|
147
|
-
* @param {
|
|
146
|
+
* @param {S} state - ステート
|
|
147
|
+
* @param {Keys_ArrayRAFTask} keyNames - RAFTask 配列までのパス
|
|
148
148
|
* @returns {Subscription<S>}
|
|
149
149
|
*/
|
|
150
150
|
export const subscription_RAFManager = function (state, keyNames) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { VNode, Dispatch } from "hyperapp";
|
|
2
|
+
import { Keys_Number, Keys_ArrayRAFTask } from "../core/state";
|
|
2
3
|
import { RAFEvent, RAFTask } from "../animation/raf";
|
|
3
4
|
/**
|
|
4
5
|
* Carousel コンポーネント情報
|
|
@@ -19,7 +20,7 @@ import { RAFEvent, RAFTask } from "../animation/raf";
|
|
|
19
20
|
* @property {number} [duration] - 1回あたりの実行時間 (ms)
|
|
20
21
|
* @property {number} [delay] - 待機時間 (ms)
|
|
21
22
|
* @property {number} [priority] - 処理優先巡視 (未実装)
|
|
22
|
-
* @property {
|
|
23
|
+
* @property {Record<string, any>} [extension] - 拡張用プロパティ
|
|
23
24
|
*
|
|
24
25
|
* event
|
|
25
26
|
* @property {RAFEvent<S>} [action] - 毎フレーム発生するイベント
|
|
@@ -29,7 +30,7 @@ import { RAFEvent, RAFTask } from "../animation/raf";
|
|
|
29
30
|
* @property {(t: number) => number} easing - easing 関数
|
|
30
31
|
*
|
|
31
32
|
* report
|
|
32
|
-
* @property {
|
|
33
|
+
* @property {Keys_Number} [reportPageIndex] - 現在表示中インデックスの出力パス
|
|
33
34
|
*/
|
|
34
35
|
export interface CarouselState<S> {
|
|
35
36
|
id: string;
|
|
@@ -38,13 +39,11 @@ export interface CarouselState<S> {
|
|
|
38
39
|
duration?: number;
|
|
39
40
|
delay?: number;
|
|
40
41
|
priority?: number;
|
|
41
|
-
extension?:
|
|
42
|
-
[key: string]: any;
|
|
43
|
-
};
|
|
42
|
+
extension?: Record<string, any>;
|
|
44
43
|
action?: RAFEvent<S>;
|
|
45
44
|
finish?: RAFEvent<S>;
|
|
46
45
|
easing?: (t: number) => number;
|
|
47
|
-
reportPageIndex?:
|
|
46
|
+
reportPageIndex?: Keys_Number;
|
|
48
47
|
}
|
|
49
48
|
/**
|
|
50
49
|
* 外部から Carousel コンポーネントを操作するためのクラス
|
|
@@ -67,19 +66,19 @@ export interface CarouselController<S> {
|
|
|
67
66
|
* Carousel Component
|
|
68
67
|
*
|
|
69
68
|
* @template S
|
|
70
|
-
* @param {Object}
|
|
71
|
-
* @param {S}
|
|
72
|
-
* @param {string}
|
|
73
|
-
* @param {
|
|
74
|
-
* @param {boolean}
|
|
75
|
-
* @param {boolean}
|
|
76
|
-
* @param {number}
|
|
77
|
-
* @param {any}
|
|
69
|
+
* @param {Object} props - props
|
|
70
|
+
* @param {S} props.state - ステート
|
|
71
|
+
* @param {string} props.id - ユニークID (DOM id)
|
|
72
|
+
* @param {Keys_ArrayRAFTask} props.keyNames - RAFTask 配列までのパス
|
|
73
|
+
* @param {boolean} [props.controlButton] - ページ切り替えボタンを表示する (未実装)
|
|
74
|
+
* @param {boolean} [props.controlBar] - 現在位置を示すステータスバーを表示する
|
|
75
|
+
* @param {number} [skipSpeedRate] - skip 時に duration に乗じる値
|
|
76
|
+
* @param {any} children - 表示するページ (HTMLLIElement の子になる)
|
|
78
77
|
*/
|
|
79
78
|
export declare const Carousel: <S>(props: {
|
|
80
79
|
state: S;
|
|
81
80
|
id: string;
|
|
82
|
-
keyNames:
|
|
81
|
+
keyNames: Keys_ArrayRAFTask;
|
|
83
82
|
controlButton?: boolean;
|
|
84
83
|
controlBar?: boolean;
|
|
85
84
|
skipSpeedRate?: number;
|
|
@@ -88,8 +87,8 @@ export declare const Carousel: <S>(props: {
|
|
|
88
87
|
/**
|
|
89
88
|
* カルーセルを初期化し起動するエフェクト
|
|
90
89
|
*
|
|
91
|
-
* @param {
|
|
92
|
-
* @param {CarouselState}
|
|
90
|
+
* @param {Keys_ArrayRAFTask} keyNames - RAFTask 配列までのパス
|
|
91
|
+
* @param {CarouselState} carouselState - カルーセル情報
|
|
93
92
|
* @returns {(dispatch: Dispatch<S>) => void}
|
|
94
93
|
*/
|
|
95
|
-
export declare const effect_InitCarousel: <S>(keyNames:
|
|
94
|
+
export declare const effect_InitCarousel: <S>(keyNames: Keys_ArrayRAFTask, carouselState: CarouselState<S>) => (dispatch: Dispatch<S>) => void;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
//
|
|
2
|
-
// import
|
|
3
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
1
|
+
// hyperapp-is / animationView / carousel.ts
|
|
4
2
|
import { getValue, setValue, createLocalKey } from "../core/state";
|
|
5
3
|
import { el, deleteKeys } from "../core/component";
|
|
6
4
|
import { RAFTask } from "../animation/raf";
|
|
@@ -16,14 +14,14 @@ const button = el("button");
|
|
|
16
14
|
* Carousel Component
|
|
17
15
|
*
|
|
18
16
|
* @template S
|
|
19
|
-
* @param {Object}
|
|
20
|
-
* @param {S}
|
|
21
|
-
* @param {string}
|
|
22
|
-
* @param {
|
|
23
|
-
* @param {boolean}
|
|
24
|
-
* @param {boolean}
|
|
25
|
-
* @param {number}
|
|
26
|
-
* @param {any}
|
|
17
|
+
* @param {Object} props - props
|
|
18
|
+
* @param {S} props.state - ステート
|
|
19
|
+
* @param {string} props.id - ユニークID (DOM id)
|
|
20
|
+
* @param {Keys_ArrayRAFTask} props.keyNames - RAFTask 配列までのパス
|
|
21
|
+
* @param {boolean} [props.controlButton] - ページ切り替えボタンを表示する (未実装)
|
|
22
|
+
* @param {boolean} [props.controlBar] - 現在位置を示すステータスバーを表示する
|
|
23
|
+
* @param {number} [skipSpeedRate] - skip 時に duration に乗じる値
|
|
24
|
+
* @param {any} children - 表示するページ (HTMLLIElement の子になる)
|
|
27
25
|
*/
|
|
28
26
|
export const Carousel = function (props, children) {
|
|
29
27
|
var _a;
|
|
@@ -111,7 +109,7 @@ export const Carousel = function (props, children) {
|
|
|
111
109
|
onmouseleave: action_mouseleave
|
|
112
110
|
}, items.map(item => li({}, item))),
|
|
113
111
|
// controlButton, controlBar
|
|
114
|
-
(controlButton || controlBar)
|
|
112
|
+
(controlButton || controlBar) ? div({}, controlButton
|
|
115
113
|
? button({ onclick: action_prevPage }, "<")
|
|
116
114
|
: null, controlBar
|
|
117
115
|
? ul({}, items.map((_, i) => li({
|
|
@@ -122,15 +120,15 @@ export const Carousel = function (props, children) {
|
|
|
122
120
|
param
|
|
123
121
|
? i === index ? "◉" : "・"
|
|
124
122
|
: "・")))
|
|
125
|
-
:
|
|
123
|
+
: null, controlButton
|
|
126
124
|
? button({ onclick: action_nextPage }, ">")
|
|
127
|
-
: null));
|
|
125
|
+
: null) : null);
|
|
128
126
|
};
|
|
129
127
|
/**
|
|
130
128
|
* カルーセルを初期化し起動するエフェクト
|
|
131
129
|
*
|
|
132
|
-
* @param {
|
|
133
|
-
* @param {CarouselState}
|
|
130
|
+
* @param {Keys_ArrayRAFTask} keyNames - RAFTask 配列までのパス
|
|
131
|
+
* @param {CarouselState} carouselState - カルーセル情報
|
|
134
132
|
* @returns {(dispatch: Dispatch<S>) => void}
|
|
135
133
|
*/
|
|
136
134
|
export const effect_InitCarousel = function (keyNames, carouselState) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { VNode, Effect } from "hyperapp";
|
|
2
|
+
import { Keys_String, Keys_ArrayString } from "./state";
|
|
2
3
|
/**
|
|
3
4
|
* h 関数のラッパー
|
|
4
5
|
* 他でjsxを使用した場合、hが競合する可能性があるので作成した
|
|
@@ -45,14 +46,14 @@ export declare const deleteKeys: <T extends Record<string, any>>(props: T, ...ke
|
|
|
45
46
|
* @template S
|
|
46
47
|
* @param {Record<string, any>} props - props
|
|
47
48
|
* @param {S} props.state - ステート
|
|
48
|
-
* @param {
|
|
49
|
+
* @param {Keys_String} props.keyNames - ステート内の文字までのパス
|
|
49
50
|
* @param {string} props.match - 一致判定する文字
|
|
50
51
|
* @param {any} children - 出力する内容 (VNode / 配列 / 文字など)
|
|
51
52
|
* @returns {VNode<S> | null}
|
|
52
53
|
*/
|
|
53
54
|
export declare const Route: <S>(props: {
|
|
54
55
|
state: S;
|
|
55
|
-
keyNames:
|
|
56
|
+
keyNames: Keys_String;
|
|
56
57
|
match: string;
|
|
57
58
|
}, children: any) => VNode<S> | null;
|
|
58
59
|
/**
|
|
@@ -61,7 +62,7 @@ export declare const Route: <S>(props: {
|
|
|
61
62
|
* @template S
|
|
62
63
|
* @param {Record<string, any>} props - props
|
|
63
64
|
* @param {S} props.state - ステート
|
|
64
|
-
* @param {
|
|
65
|
+
* @param {Keys_ArrayString} props.keyNames - ステート内の文字配列までのパス
|
|
65
66
|
* @param {string} props.id - ユニークID
|
|
66
67
|
* @param {boolean} [props.reverse] - 反転選択するか
|
|
67
68
|
* @param {any} children - 子要素 (VNode / string / 配列など)
|
|
@@ -69,7 +70,7 @@ export declare const Route: <S>(props: {
|
|
|
69
70
|
*/
|
|
70
71
|
export declare const SelectButton: <S>(props: {
|
|
71
72
|
state: S;
|
|
72
|
-
keyNames:
|
|
73
|
+
keyNames: Keys_ArrayString;
|
|
73
74
|
id: string;
|
|
74
75
|
reverse?: boolean;
|
|
75
76
|
[key: string]: any;
|
|
@@ -80,7 +81,7 @@ export declare const SelectButton: <S>(props: {
|
|
|
80
81
|
* @template S
|
|
81
82
|
* @param {Record<string, any>} props - props
|
|
82
83
|
* @param {S} props.state - ステート
|
|
83
|
-
* @param {
|
|
84
|
+
* @param {Keys_String} props.keyNames - ステート内の文字までのパス
|
|
84
85
|
* @param {string} props.id - ユニークID
|
|
85
86
|
* @param {boolean} [props.reverse] - 反転選択するか
|
|
86
87
|
* @param {any} children - 子要素 (VNode / string / 配列など)
|
|
@@ -88,7 +89,7 @@ export declare const SelectButton: <S>(props: {
|
|
|
88
89
|
*/
|
|
89
90
|
export declare const OptionButton: <S>(props: {
|
|
90
91
|
state: S;
|
|
91
|
-
keyNames:
|
|
92
|
+
keyNames: Keys_String;
|
|
92
93
|
id: string;
|
|
93
94
|
reverse?: boolean;
|
|
94
95
|
[key: string]: any;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// hyperapp-
|
|
1
|
+
// hyperapp-is / core / component.ts
|
|
2
2
|
import { h, text } from "hyperapp";
|
|
3
3
|
import { getValue, setValue } from "./state";
|
|
4
4
|
// ========== ========== ========== ========== ==========
|
|
@@ -87,7 +87,7 @@ export const deleteKeys = (props, ...keys) => {
|
|
|
87
87
|
* @template S
|
|
88
88
|
* @param {Record<string, any>} props - props
|
|
89
89
|
* @param {S} props.state - ステート
|
|
90
|
-
* @param {
|
|
90
|
+
* @param {Keys_String} props.keyNames - ステート内の文字までのパス
|
|
91
91
|
* @param {string} props.match - 一致判定する文字
|
|
92
92
|
* @param {any} children - 出力する内容 (VNode / 配列 / 文字など)
|
|
93
93
|
* @returns {VNode<S> | null}
|
|
@@ -108,7 +108,7 @@ const REVERSE_PREFIX = "r_";
|
|
|
108
108
|
* @template S
|
|
109
109
|
* @param {Record<string, any>} props - props
|
|
110
110
|
* @param {S} props.state - ステート
|
|
111
|
-
* @param {
|
|
111
|
+
* @param {Keys_ArrayString} props.keyNames - ステート内の文字配列までのパス
|
|
112
112
|
* @param {string} props.id - ユニークID
|
|
113
113
|
* @param {boolean} [props.reverse] - 反転選択するか
|
|
114
114
|
* @param {any} children - 子要素 (VNode / string / 配列など)
|
|
@@ -156,7 +156,7 @@ export const SelectButton = function (props, children) {
|
|
|
156
156
|
* @template S
|
|
157
157
|
* @param {Record<string, any>} props - props
|
|
158
158
|
* @param {S} props.state - ステート
|
|
159
|
-
* @param {
|
|
159
|
+
* @param {Keys_String} props.keyNames - ステート内の文字までのパス
|
|
160
160
|
* @param {string} props.id - ユニークID
|
|
161
161
|
* @param {boolean} [props.reverse] - 反転選択するか
|
|
162
162
|
* @param {any} children - 子要素 (VNode / string / 配列など)
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
+
export type { Keys } from "./state";
|
|
1
2
|
export { getValue, setValue, getLocalState, setLocalState, createLocalKey } from "./state";
|
|
3
|
+
export type { Keys_String, Keys_ArrayString } from "./component";
|
|
2
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,2 +1,4 @@
|
|
|
1
|
+
// hyperapp-is / core / index.ts
|
|
1
2
|
export { getValue, setValue, getLocalState, setLocalState, createLocalKey } from "./state";
|
|
2
3
|
export { el, concatAction, getClassList, deleteKeys, Route, SelectButton, OptionButton } from "./component";
|
|
4
|
+
export { convertJsonToNavigatorItem, getParentItems, NavigatorFinder } from "./navigator";
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { VNode, Effect } from "hyperapp";
|
|
2
|
+
import { Keys_NavigatorItem } from "./state";
|
|
3
|
+
/**
|
|
4
|
+
* ツリー構造となるナビゲーションオブジェクト
|
|
5
|
+
*
|
|
6
|
+
* parent - 親アイテム
|
|
7
|
+
* name - 名前
|
|
8
|
+
* properties - プロパティオブジェクト
|
|
9
|
+
* children - 子アイテムリスト (undefinedのときはファイル)
|
|
10
|
+
* path - パス
|
|
11
|
+
* extension - 拡張情報
|
|
12
|
+
*/
|
|
13
|
+
export interface NavigatorItem {
|
|
14
|
+
parent: NavigatorItem | null;
|
|
15
|
+
name: string;
|
|
16
|
+
properties?: Record<string, any>;
|
|
17
|
+
children?: NavigatorItem[];
|
|
18
|
+
path: string;
|
|
19
|
+
extension?: Record<string, any>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* getEntriesで返すオブジェクト
|
|
23
|
+
*
|
|
24
|
+
* name - 名前
|
|
25
|
+
* data - データ
|
|
26
|
+
* isNode - ディレクトリか
|
|
27
|
+
*/
|
|
28
|
+
export interface JsonEntry<D> {
|
|
29
|
+
name: string;
|
|
30
|
+
data: D;
|
|
31
|
+
isNode: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* ヘッダー名と値
|
|
35
|
+
*/
|
|
36
|
+
export interface NavigatorColumn {
|
|
37
|
+
name: string;
|
|
38
|
+
val: (item: NavigatorItem) => any;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Json から NavigatorItem に変換
|
|
42
|
+
* getEntries の採用により、JSON の形を問わない
|
|
43
|
+
* extension により、任意情報を保存できる
|
|
44
|
+
*/
|
|
45
|
+
export declare const convertJsonToNavigatorItem: <D>(props: {
|
|
46
|
+
parent: NavigatorItem | null;
|
|
47
|
+
name: string;
|
|
48
|
+
data: D;
|
|
49
|
+
getEntries: (data: D, depth: number) => JsonEntry<D>[];
|
|
50
|
+
isNode: boolean;
|
|
51
|
+
depth?: number;
|
|
52
|
+
extension?: (item: NavigatorItem, data: D, depth: number) => Record<string, any> | undefined;
|
|
53
|
+
}) => NavigatorItem;
|
|
54
|
+
/**
|
|
55
|
+
* NavigatorItem の親をリストで取得する
|
|
56
|
+
*/
|
|
57
|
+
export declare const getParentItems: (item: NavigatorItem | undefined) => NavigatorItem[];
|
|
58
|
+
/**
|
|
59
|
+
* ナビゲーションファインダーコンポーネント
|
|
60
|
+
*/
|
|
61
|
+
export declare const NavigatorFinder: <S>(props: {
|
|
62
|
+
state: S;
|
|
63
|
+
currentKeys: Keys_NavigatorItem;
|
|
64
|
+
columns?: (directory: NavigatorItem | undefined) => NavigatorColumn[];
|
|
65
|
+
maxItemsCount?: number;
|
|
66
|
+
itemClick?: (state: S, item: NavigatorItem) => S | [S, Effect<S>];
|
|
67
|
+
afterRender?: (props: {
|
|
68
|
+
state: S;
|
|
69
|
+
current?: NavigatorItem;
|
|
70
|
+
extension?: Record<string, any>;
|
|
71
|
+
}, vnode: VNode<S>) => VNode<S>;
|
|
72
|
+
extension?: Record<string, any>;
|
|
73
|
+
[key: string]: any;
|
|
74
|
+
}) => VNode<S>;
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
// hyperapp-is / core / navigator.ts
|
|
2
|
+
import { getValue, setValue } from "./state";
|
|
3
|
+
import { el, deleteKeys } from "./component";
|
|
4
|
+
/* element */
|
|
5
|
+
const div = el("div");
|
|
6
|
+
const table = el("table");
|
|
7
|
+
const thead = el("thead");
|
|
8
|
+
const tbody = el("tbody");
|
|
9
|
+
const tr = el("tr");
|
|
10
|
+
const th = el("th");
|
|
11
|
+
const td = el("td");
|
|
12
|
+
const ul = el("ul");
|
|
13
|
+
const ol = el("ol");
|
|
14
|
+
const li = el("li");
|
|
15
|
+
const button = el("button");
|
|
16
|
+
const input = el("input");
|
|
17
|
+
const span = el("span");
|
|
18
|
+
// ---------- ---------- ---------- ---------- ----------
|
|
19
|
+
// convertJsonToNavigatorItem
|
|
20
|
+
// ---------- ---------- ---------- ---------- ----------
|
|
21
|
+
/**
|
|
22
|
+
* Json から NavigatorItem に変換
|
|
23
|
+
* getEntries の採用により、JSON の形を問わない
|
|
24
|
+
* extension により、任意情報を保存できる
|
|
25
|
+
*/
|
|
26
|
+
export const convertJsonToNavigatorItem = function (props) {
|
|
27
|
+
const { parent, name, data, getEntries, isNode, depth = 0, extension } = props;
|
|
28
|
+
const result = {
|
|
29
|
+
parent,
|
|
30
|
+
name,
|
|
31
|
+
path: parent ? parent.path + "/" + name : "/" + name
|
|
32
|
+
};
|
|
33
|
+
// 拡張情報
|
|
34
|
+
if (extension) {
|
|
35
|
+
const ext = extension(result, data, depth);
|
|
36
|
+
if (ext)
|
|
37
|
+
result.extension = ext;
|
|
38
|
+
}
|
|
39
|
+
const properties = {};
|
|
40
|
+
let hasProperty = false;
|
|
41
|
+
const children = [];
|
|
42
|
+
getEntries(data, depth).forEach(entry => {
|
|
43
|
+
const isProperty = typeof entry.data !== "object" || Array.isArray(entry.data);
|
|
44
|
+
// プロパティ
|
|
45
|
+
if (isProperty) {
|
|
46
|
+
properties[entry.name] = entry.data;
|
|
47
|
+
hasProperty = true;
|
|
48
|
+
// 子アイテム
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
children.push(convertJsonToNavigatorItem({
|
|
52
|
+
parent: result,
|
|
53
|
+
name: entry.name,
|
|
54
|
+
data: entry.data,
|
|
55
|
+
getEntries,
|
|
56
|
+
isNode: entry.isNode,
|
|
57
|
+
depth: depth + 1,
|
|
58
|
+
extension
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
if (hasProperty)
|
|
63
|
+
result.properties = properties;
|
|
64
|
+
if (isNode)
|
|
65
|
+
result.children = children; // ファイルのときは undefined
|
|
66
|
+
return result;
|
|
67
|
+
};
|
|
68
|
+
// ---------- ---------- ---------- ---------- ----------
|
|
69
|
+
// getParentItems
|
|
70
|
+
// ---------- ---------- ---------- ---------- ----------
|
|
71
|
+
/**
|
|
72
|
+
* NavigatorItem の親をリストで取得する
|
|
73
|
+
*/
|
|
74
|
+
export const getParentItems = (item) => {
|
|
75
|
+
if (!item)
|
|
76
|
+
return [];
|
|
77
|
+
const result = [];
|
|
78
|
+
let cd = item.parent;
|
|
79
|
+
while (cd) {
|
|
80
|
+
result.push(cd);
|
|
81
|
+
cd = cd.parent;
|
|
82
|
+
}
|
|
83
|
+
return result.reverse();
|
|
84
|
+
};
|
|
85
|
+
// ---------- ---------- ---------- ---------- ----------
|
|
86
|
+
// NavigatorFinder Component
|
|
87
|
+
// ---------- ---------- ---------- ---------- ----------
|
|
88
|
+
/**
|
|
89
|
+
* ナビゲーションファインダーコンポーネント
|
|
90
|
+
*/
|
|
91
|
+
export const NavigatorFinder = function (props) {
|
|
92
|
+
var _a, _b;
|
|
93
|
+
const { state, currentKeys, maxItemsCount = 0, itemClick, afterRender, extension } = props;
|
|
94
|
+
const current = getValue(state, currentKeys, undefined);
|
|
95
|
+
// createColumns
|
|
96
|
+
const createColumns = (_a = props.columns) !== null && _a !== void 0 ? _a : ((directory) => {
|
|
97
|
+
const result = [];
|
|
98
|
+
if (!directory)
|
|
99
|
+
return result;
|
|
100
|
+
result.push({
|
|
101
|
+
name: "name",
|
|
102
|
+
val: (item) => item.name
|
|
103
|
+
});
|
|
104
|
+
// get properties
|
|
105
|
+
const children = directory.children;
|
|
106
|
+
if (children) {
|
|
107
|
+
// get names
|
|
108
|
+
const names = [];
|
|
109
|
+
// get properties
|
|
110
|
+
// 子アイテムのプロパティをすべて確認して抽出しています
|
|
111
|
+
children.forEach(child => {
|
|
112
|
+
if (child.properties) {
|
|
113
|
+
Object.keys(child.properties).forEach(key => names.push(key));
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
// add NavigatorColumn
|
|
117
|
+
Array.from(new Set(names)).forEach(name => {
|
|
118
|
+
result.push({
|
|
119
|
+
name,
|
|
120
|
+
val: (item) => {
|
|
121
|
+
var _a;
|
|
122
|
+
const p = item.properties;
|
|
123
|
+
return p
|
|
124
|
+
? (_a = p[name]) !== null && _a !== void 0 ? _a : ""
|
|
125
|
+
: "";
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return result;
|
|
131
|
+
}); // end createColumns
|
|
132
|
+
const columns = createColumns(current);
|
|
133
|
+
// parentItems
|
|
134
|
+
const parentItems = getParentItems(current);
|
|
135
|
+
if (current)
|
|
136
|
+
parentItems.push(current);
|
|
137
|
+
// getItems
|
|
138
|
+
const getItems = (item) => {
|
|
139
|
+
if (!item || item.children === undefined)
|
|
140
|
+
return [];
|
|
141
|
+
const count = maxItemsCount === 0
|
|
142
|
+
? item.children.length
|
|
143
|
+
: Math.min(maxItemsCount, item.children.length);
|
|
144
|
+
return item.children.slice(0, count);
|
|
145
|
+
}; // end getItems
|
|
146
|
+
// items
|
|
147
|
+
const items = getItems(current);
|
|
148
|
+
const count = current
|
|
149
|
+
? (_b = current.children) === null || _b === void 0 ? void 0 : _b.length
|
|
150
|
+
: 0;
|
|
151
|
+
// action_parentClick
|
|
152
|
+
const action_parentClick = (state, item) => {
|
|
153
|
+
return setValue(state, currentKeys, item);
|
|
154
|
+
};
|
|
155
|
+
// action_itemClick
|
|
156
|
+
const action_itemClick = (state, item) => {
|
|
157
|
+
// 子アイテムがすべてプロパティのときは移動しない
|
|
158
|
+
const children = item.children;
|
|
159
|
+
if (!children)
|
|
160
|
+
return state;
|
|
161
|
+
if (!children.some(child => typeof child === "object" && !Array.isArray(child)))
|
|
162
|
+
return state;
|
|
163
|
+
return setValue(state, currentKeys, item);
|
|
164
|
+
};
|
|
165
|
+
// VNode
|
|
166
|
+
const vnode = div({
|
|
167
|
+
...deleteKeys(props, "state", "currentKeys", "columns", "itemClick", "afterRender", "extension")
|
|
168
|
+
},
|
|
169
|
+
// toolBar
|
|
170
|
+
div({
|
|
171
|
+
class: "toolBar"
|
|
172
|
+
}, "toolBar (未実装)"),
|
|
173
|
+
// parentItems
|
|
174
|
+
ol({}, parentItems.map(parent => li({
|
|
175
|
+
key: parent.path,
|
|
176
|
+
onclick: [action_parentClick, parent]
|
|
177
|
+
}, parent.name))),
|
|
178
|
+
// items
|
|
179
|
+
table({}, thead({}, tr({}, columns.map(col => th({}, col.name)))), tbody({}, items.map(item => tr({
|
|
180
|
+
key: item.path,
|
|
181
|
+
onclick: item.children === undefined
|
|
182
|
+
? itemClick ? [itemClick, item] : undefined
|
|
183
|
+
: [action_itemClick, item]
|
|
184
|
+
}, columns.map(col => td({
|
|
185
|
+
title: col.val(item)
|
|
186
|
+
}, col.val(item))))))),
|
|
187
|
+
// statusBar
|
|
188
|
+
div({
|
|
189
|
+
class: "statusBar"
|
|
190
|
+
}, `items ${items.length} / ${count}`));
|
|
191
|
+
// afterRender
|
|
192
|
+
return afterRender ? afterRender({ state, current, extension }, vnode) : vnode;
|
|
193
|
+
};
|
|
@@ -1,24 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ステートへのパス
|
|
3
|
+
* 参照する値の型がわかりやすいよう、複数パターンをここで集約
|
|
4
|
+
*/
|
|
5
|
+
export type Keys = readonly string[];
|
|
6
|
+
export type Keys_String = Keys;
|
|
7
|
+
export type Keys_ArrayString = Keys;
|
|
8
|
+
export type Keys_Number = Keys;
|
|
9
|
+
export type Keys_ArrayNumber = Keys;
|
|
10
|
+
export type Keys_ArrayRAFTask = Keys;
|
|
11
|
+
export type Keys_NavigatorItem = Keys;
|
|
1
12
|
/**
|
|
2
13
|
* パスを辿って、ステートから値を取得する
|
|
3
14
|
*
|
|
4
15
|
* @template S
|
|
5
16
|
* @template D
|
|
6
|
-
* @param {S}
|
|
7
|
-
* @param {
|
|
8
|
-
* @param {D}
|
|
9
|
-
* @returns {D}
|
|
17
|
+
* @param {S} state - ステート
|
|
18
|
+
* @param {Keys} keyNames - 値までのパス
|
|
19
|
+
* @param {D} def - デフォルト値
|
|
20
|
+
* @returns {D} - 型保証は呼び出し側の責任
|
|
10
21
|
*/
|
|
11
|
-
export declare const getValue: <S, D>(state: S, keyNames:
|
|
22
|
+
export declare const getValue: <S, D>(state: S, keyNames: Keys, def: D) => D;
|
|
12
23
|
/**
|
|
13
24
|
* パスを辿って、ステートに値を設定して返す
|
|
14
25
|
*
|
|
15
26
|
* @template S
|
|
16
|
-
* @param {S}
|
|
17
|
-
* @param {
|
|
18
|
-
* @param {any}
|
|
27
|
+
* @param {S} state - ステート
|
|
28
|
+
* @param {Keys} keyNames - 値までのパス
|
|
29
|
+
* @param {any} value - 設定する値
|
|
19
30
|
* @returns {S}
|
|
20
31
|
*/
|
|
21
|
-
export declare const setValue: <S>(state: S, keyNames:
|
|
32
|
+
export declare const setValue: <S>(state: S, keyNames: Keys, value: any) => S;
|
|
22
33
|
/**
|
|
23
34
|
* IDからユニーク文字列を作成する
|
|
24
35
|
*
|
|
@@ -35,11 +46,7 @@ export declare const createLocalKey: (id: string) => string;
|
|
|
35
46
|
* @param {Record<string, any>} def - 初期値
|
|
36
47
|
* @returns {Record<string, any>}
|
|
37
48
|
*/
|
|
38
|
-
export declare const getLocalState: <S>(state: S, id: string, def:
|
|
39
|
-
[key: string]: any;
|
|
40
|
-
}) => {
|
|
41
|
-
[key: string]: any;
|
|
42
|
-
};
|
|
49
|
+
export declare const getLocalState: <S>(state: S, id: string, def: Record<string, any>) => Record<string, any>;
|
|
43
50
|
/**
|
|
44
51
|
* ローカルステートを更新してステートを返す
|
|
45
52
|
*
|
|
@@ -49,6 +56,4 @@ export declare const getLocalState: <S>(state: S, id: string, def: {
|
|
|
49
56
|
* @param {Record<string, any>} value - 設定するローカルステート
|
|
50
57
|
* @returns {S}
|
|
51
58
|
*/
|
|
52
|
-
export declare const setLocalState: <S>(state: S, id: string, value:
|
|
53
|
-
[key: string]: any;
|
|
54
|
-
}) => S;
|
|
59
|
+
export declare const setLocalState: <S>(state: S, id: string, value: Record<string, any>) => S;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// hyperapp-
|
|
1
|
+
// hyperapp-is / core / state.ts
|
|
2
2
|
// ---------- ---------- ---------- ---------- ----------
|
|
3
3
|
// getValue
|
|
4
4
|
// ---------- ---------- ---------- ---------- ----------
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @template S
|
|
9
9
|
* @template D
|
|
10
|
-
* @param {S}
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {D}
|
|
13
|
-
* @returns {D}
|
|
10
|
+
* @param {S} state - ステート
|
|
11
|
+
* @param {Keys} keyNames - 値までのパス
|
|
12
|
+
* @param {D} def - デフォルト値
|
|
13
|
+
* @returns {D} - 型保証は呼び出し側の責任
|
|
14
14
|
*/
|
|
15
15
|
export const getValue = function (state, keyNames, def) {
|
|
16
16
|
let result = state;
|
|
@@ -34,9 +34,9 @@ export const getValue = function (state, keyNames, def) {
|
|
|
34
34
|
* パスを辿って、ステートに値を設定して返す
|
|
35
35
|
*
|
|
36
36
|
* @template S
|
|
37
|
-
* @param {S}
|
|
38
|
-
* @param {
|
|
39
|
-
* @param {any}
|
|
37
|
+
* @param {S} state - ステート
|
|
38
|
+
* @param {Keys} keyNames - 値までのパス
|
|
39
|
+
* @param {any} value - 設定する値
|
|
40
40
|
* @returns {S}
|
|
41
41
|
*/
|
|
42
42
|
export const setValue = function (state, keyNames, value) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export type { ScrollMargin, MatrixState } from "./utils";
|
|
2
|
-
export { getScrollMargin, getMatrixState
|
|
2
|
+
export { getScrollMargin, getMatrixState } from "./utils";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
// hyperapp-is / dom / index.ts
|
|
2
|
+
export { getScrollMargin, getMatrixState } from "./utils";
|
|
@@ -47,22 +47,3 @@ export interface MatrixState {
|
|
|
47
47
|
* @returns {MatrixState}
|
|
48
48
|
*/
|
|
49
49
|
export declare const getMatrixState: (dom: HTMLElement) => MatrixState | null;
|
|
50
|
-
/**
|
|
51
|
-
* Carousel 風に DOM が流れるアニメーションを実行する
|
|
52
|
-
*
|
|
53
|
-
* @param {Object} props - props
|
|
54
|
-
* @param {HTMLElement} props.element - DOM
|
|
55
|
-
* @param {number} props.duration - 実行時間 (ms)
|
|
56
|
-
* @param {number} props.interval - 待機時間 (ms)
|
|
57
|
-
* @param {(t: number) => number} [props.easing] - easing 関数
|
|
58
|
-
* @returns {{start: () => void, stop: () => void}}
|
|
59
|
-
*/
|
|
60
|
-
export declare const marquee: <S>(props: {
|
|
61
|
-
element: HTMLElement;
|
|
62
|
-
duration: number;
|
|
63
|
-
interval: number;
|
|
64
|
-
easing?: (t: number) => number;
|
|
65
|
-
}) => {
|
|
66
|
-
start: () => void;
|
|
67
|
-
stop: () => void;
|
|
68
|
-
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// hyperapp-
|
|
1
|
+
// hyperapp-is / dom / utils.ts
|
|
2
2
|
// ---------- ---------- ---------- ---------- ----------
|
|
3
3
|
// getScrollMargin
|
|
4
4
|
// ---------- ---------- ---------- ---------- ----------
|
|
@@ -73,87 +73,3 @@ export const getMatrixState = (dom) => {
|
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
75
|
};
|
|
76
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
77
|
-
// marquee
|
|
78
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
79
|
-
/**
|
|
80
|
-
* Carousel 風に DOM が流れるアニメーションを実行する
|
|
81
|
-
*
|
|
82
|
-
* @param {Object} props - props
|
|
83
|
-
* @param {HTMLElement} props.element - DOM
|
|
84
|
-
* @param {number} props.duration - 実行時間 (ms)
|
|
85
|
-
* @param {number} props.interval - 待機時間 (ms)
|
|
86
|
-
* @param {(t: number) => number} [props.easing] - easing 関数
|
|
87
|
-
* @returns {{start: () => void, stop: () => void}}
|
|
88
|
-
*/
|
|
89
|
-
export const marquee = function (props) {
|
|
90
|
-
const { element, duration, interval, easing = (t) => t } = props;
|
|
91
|
-
// function calcWidth
|
|
92
|
-
const calcWidth = () => {
|
|
93
|
-
const children = Array.from(element.children);
|
|
94
|
-
return !children || children.length < 2
|
|
95
|
-
? 0
|
|
96
|
-
: children[1].offsetLeft - children[0].offsetLeft;
|
|
97
|
-
};
|
|
98
|
-
// variable
|
|
99
|
-
let rID = 0;
|
|
100
|
-
let timerID = 0;
|
|
101
|
-
let startTime = 0;
|
|
102
|
-
let width = 0;
|
|
103
|
-
// requestAnimationFrame callback
|
|
104
|
-
const action = (now) => {
|
|
105
|
-
// set startTime
|
|
106
|
-
if (startTime === 0)
|
|
107
|
-
startTime = now;
|
|
108
|
-
// get progress
|
|
109
|
-
const progress = Math.min((now - startTime) / Math.max(1, duration));
|
|
110
|
-
// set property
|
|
111
|
-
element.style.transform = `translateX(${-easing(progress) * width}px)`;
|
|
112
|
-
// next
|
|
113
|
-
if (progress < 1) {
|
|
114
|
-
rID = requestAnimationFrame(action);
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
// reset property
|
|
118
|
-
element.style.transform = `translateX(0px)`;
|
|
119
|
-
// set children
|
|
120
|
-
const firstChild = element.children[0];
|
|
121
|
-
if (!firstChild)
|
|
122
|
-
return;
|
|
123
|
-
// loop
|
|
124
|
-
element.appendChild(firstChild);
|
|
125
|
-
// loop
|
|
126
|
-
timerID = window.setTimeout(() => {
|
|
127
|
-
startTime = 0;
|
|
128
|
-
rID = requestAnimationFrame(action);
|
|
129
|
-
}, interval);
|
|
130
|
-
};
|
|
131
|
-
// result
|
|
132
|
-
return {
|
|
133
|
-
start: () => {
|
|
134
|
-
// 二重起動防止
|
|
135
|
-
if (rID !== 0)
|
|
136
|
-
return;
|
|
137
|
-
// get width
|
|
138
|
-
width = calcWidth();
|
|
139
|
-
if (width === 0)
|
|
140
|
-
return;
|
|
141
|
-
// set gpu layer
|
|
142
|
-
element.style.willChange = "transform";
|
|
143
|
-
// start animation
|
|
144
|
-
rID = requestAnimationFrame(action);
|
|
145
|
-
},
|
|
146
|
-
stop: () => {
|
|
147
|
-
// cancel animation
|
|
148
|
-
cancelAnimationFrame(rID);
|
|
149
|
-
// stop timer
|
|
150
|
-
clearTimeout(timerID);
|
|
151
|
-
// clear gpy layer
|
|
152
|
-
element.style.willChange = "";
|
|
153
|
-
element.style.transform = "";
|
|
154
|
-
// clear ID
|
|
155
|
-
rID = 0;
|
|
156
|
-
timerID = 0;
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
};
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type {
|
|
3
|
-
export {
|
|
4
|
-
export
|
|
5
|
-
export {
|
|
6
|
-
export type {
|
|
7
|
-
export {
|
|
1
|
+
export type { Keys, Keys_String, Keys_ArrayString, Keys_Number, Keys_ArrayNumber, Keys_ArrayRAFTask, Keys_NavigatorItem, } from "./core/state";
|
|
2
|
+
export type { NavigatorItem, JsonEntry, NavigatorColumn } from "./core/navigator";
|
|
3
|
+
export { getValue, setValue, getLocalState, setLocalState, createLocalKey } from "./core/state";
|
|
4
|
+
export { el, concatAction, getClassList, deleteKeys, Route, SelectButton, OptionButton } from "./core/component";
|
|
5
|
+
export { convertJsonToNavigatorItem, getParentItems, NavigatorFinder } from "./core/navigator";
|
|
6
|
+
export type { InternalEffect, RAFEvent } from "./animation/raf";
|
|
7
|
+
export type { CSSProperty } from "./animation/properties";
|
|
8
|
+
export { RAFTask, subscription_RAFManager } from "./animation/raf";
|
|
9
|
+
export { progress_easing } from "./animation/easing";
|
|
10
|
+
export { createUnits, createRAFProperties, effect_RAFProperties } from "./animation/properties";
|
|
11
|
+
export type { CarouselState, CarouselController } from "./animationView/carousel";
|
|
12
|
+
export { Carousel, effect_InitCarousel } from "./animationView/carousel";
|
|
13
|
+
export type { ScrollMargin, MatrixState } from "./dom/utils";
|
|
14
|
+
export { getScrollMargin, getMatrixState } from "./dom/utils";
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
//
|
|
2
|
-
export { getValue, setValue, getLocalState, setLocalState, createLocalKey
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
1
|
+
// hyperapp-is / index.ts
|
|
2
|
+
export { getValue, setValue, getLocalState, setLocalState, createLocalKey } from "./core/state";
|
|
3
|
+
export { el, concatAction, getClassList, deleteKeys, Route, SelectButton, OptionButton } from "./core/component";
|
|
4
|
+
export { convertJsonToNavigatorItem, getParentItems, NavigatorFinder } from "./core/navigator";
|
|
5
|
+
export { RAFTask, subscription_RAFManager } from "./animation/raf";
|
|
6
|
+
export { progress_easing } from "./animation/easing";
|
|
7
|
+
export { createUnits, createRAFProperties, effect_RAFProperties } from "./animation/properties";
|
|
8
|
+
export { Carousel, effect_InitCarousel } from "./animationView/carousel";
|
|
9
|
+
export { getScrollMargin, getMatrixState } from "./dom/utils";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hyperapp-is",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "UI foundation library for Hyperapp by is4416",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -37,5 +37,8 @@
|
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"typescript": "^5.0.0",
|
|
39
39
|
"vite": "^7.3.0"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"marked": "^17.0.4"
|
|
40
43
|
}
|
|
41
44
|
}
|