@studiometa/ui 0.2.13 → 0.2.14
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/atoms/AnchorScrollTo/AnchorScrollTo.cjs +3 -3
- package/atoms/AnchorScrollTo/AnchorScrollTo.d.ts +8 -15
- package/atoms/AnchorScrollTo/AnchorScrollTo.js +26 -1
- package/atoms/AnchorScrollTo/index.cjs +20 -0
- package/atoms/AnchorScrollTo/index.d.ts +1 -0
- package/atoms/AnchorScrollTo/index.js +1 -0
- package/atoms/Cursor/Cursor.cjs +16 -9
- package/atoms/Cursor/Cursor.d.ts +19 -117
- package/atoms/Cursor/Cursor.js +111 -1
- package/atoms/Cursor/index.cjs +20 -0
- package/atoms/Cursor/index.d.ts +1 -0
- package/atoms/Cursor/index.js +1 -0
- package/atoms/Figure/Figure.cjs +15 -9
- package/atoms/Figure/Figure.d.ts +18 -53
- package/atoms/Figure/Figure.js +56 -1
- package/atoms/Figure/FigureTwicPics.cjs +10 -10
- package/atoms/Figure/FigureTwicPics.d.ts +16 -37
- package/atoms/Figure/FigureTwicPics.js +51 -1
- package/atoms/Figure/index.cjs +4 -14
- package/atoms/Figure/index.d.ts +2 -2
- package/atoms/Figure/index.js +2 -1
- package/atoms/LargeText/LargeText.cjs +17 -10
- package/atoms/LargeText/LargeText.d.ts +19 -40
- package/atoms/LargeText/LargeText.js +68 -1
- package/atoms/LargeText/index.cjs +20 -0
- package/atoms/LargeText/index.d.ts +1 -0
- package/atoms/LargeText/index.js +1 -0
- package/atoms/LazyInclude/LazyInclude.cjs +2 -2
- package/atoms/LazyInclude/LazyInclude.d.ts +17 -36
- package/atoms/LazyInclude/LazyInclude.js +46 -1
- package/atoms/LazyInclude/index.cjs +20 -0
- package/atoms/LazyInclude/index.d.ts +1 -0
- package/atoms/LazyInclude/index.js +1 -0
- package/atoms/Prefetch/AbstractPrefetch.cjs +6 -6
- package/atoms/Prefetch/AbstractPrefetch.d.ts +12 -35
- package/atoms/Prefetch/AbstractPrefetch.js +58 -1
- package/atoms/Prefetch/PrefetchWhenOver.cjs +5 -8
- package/atoms/Prefetch/PrefetchWhenOver.d.ts +8 -14
- package/atoms/Prefetch/PrefetchWhenOver.js +19 -1
- package/atoms/Prefetch/PrefetchWhenVisible.cjs +5 -8
- package/atoms/Prefetch/PrefetchWhenVisible.d.ts +10 -14
- package/atoms/Prefetch/PrefetchWhenVisible.js +20 -1
- package/atoms/Prefetch/index.cjs +5 -16
- package/atoms/Prefetch/index.d.ts +3 -3
- package/atoms/Prefetch/index.js +3 -1
- package/atoms/ScrollAnimation/AbstractScrollAnimation.cjs +17 -14
- package/atoms/ScrollAnimation/AbstractScrollAnimation.d.ts +19 -89
- package/atoms/ScrollAnimation/AbstractScrollAnimation.js +67 -1
- package/atoms/ScrollAnimation/ScrollAnimation.cjs +5 -14
- package/atoms/ScrollAnimation/ScrollAnimation.d.ts +13 -51
- package/atoms/ScrollAnimation/ScrollAnimation.js +21 -1
- package/atoms/ScrollAnimation/ScrollAnimationChild.cjs +37 -14
- package/atoms/ScrollAnimation/ScrollAnimationChild.d.ts +19 -6
- package/atoms/ScrollAnimation/ScrollAnimationChild.js +53 -1
- package/atoms/ScrollAnimation/ScrollAnimationChildWithEase.cjs +6 -9
- package/atoms/ScrollAnimation/ScrollAnimationChildWithEase.d.ts +8 -2
- package/atoms/ScrollAnimation/ScrollAnimationChildWithEase.js +17 -1
- package/atoms/ScrollAnimation/ScrollAnimationParent.cjs +8 -8
- package/atoms/ScrollAnimation/ScrollAnimationParent.d.ts +14 -26
- package/atoms/ScrollAnimation/ScrollAnimationParent.js +27 -1
- package/atoms/ScrollAnimation/ScrollAnimationWithEase.cjs +6 -9
- package/atoms/ScrollAnimation/ScrollAnimationWithEase.d.ts +15 -2
- package/atoms/ScrollAnimation/ScrollAnimationWithEase.js +17 -1
- package/atoms/ScrollAnimation/animationScrollWithEase.cjs +24 -16
- package/atoms/ScrollAnimation/animationScrollWithEase.d.ts +10 -8
- package/atoms/ScrollAnimation/animationScrollWithEase.js +36 -1
- package/atoms/ScrollAnimation/index.cjs +9 -24
- package/atoms/ScrollAnimation/index.d.ts +7 -7
- package/atoms/ScrollAnimation/index.js +7 -1
- package/atoms/ScrollReveal/ScrollReveal.cjs +7 -4
- package/atoms/ScrollReveal/ScrollReveal.d.ts +16 -59
- package/atoms/ScrollReveal/ScrollReveal.js +54 -1
- package/atoms/ScrollReveal/index.cjs +3 -12
- package/atoms/ScrollReveal/index.d.ts +1 -1
- package/atoms/ScrollReveal/index.js +1 -1
- package/atoms/index.cjs +5 -18
- package/atoms/index.d.ts +8 -8
- package/atoms/index.js +8 -1
- package/decorators/index.cjs +3 -12
- package/decorators/index.d.ts +1 -1
- package/decorators/index.js +1 -1
- package/decorators/withTransition.cjs +44 -29
- package/decorators/withTransition.d.ts +21 -33
- package/decorators/withTransition.js +60 -1
- package/index.cjs +1 -1
- package/index.d.ts +5 -5
- package/index.js +5 -1
- package/molecules/Accordion/Accordion.cjs +7 -10
- package/molecules/Accordion/Accordion.d.ts +5 -23
- package/molecules/Accordion/Accordion.js +19 -1
- package/molecules/Accordion/AccordionCore.cjs +6 -8
- package/molecules/Accordion/AccordionCore.d.ts +22 -70
- package/molecules/Accordion/AccordionCore.js +32 -1
- package/molecules/Accordion/AccordionItem.cjs +39 -23
- package/molecules/Accordion/AccordionItem.d.ts +24 -94
- package/molecules/Accordion/AccordionItem.js +153 -1
- package/molecules/Accordion/index.cjs +21 -0
- package/molecules/Accordion/index.d.ts +2 -0
- package/molecules/Accordion/index.js +2 -0
- package/molecules/Menu/Menu.cjs +6 -10
- package/molecules/Menu/Menu.d.ts +24 -84
- package/molecules/Menu/Menu.js +114 -1
- package/molecules/Menu/MenuBtn.cjs +7 -5
- package/molecules/Menu/MenuBtn.d.ts +7 -9
- package/molecules/Menu/MenuBtn.js +30 -1
- package/molecules/Menu/MenuList.cjs +13 -11
- package/molecules/Menu/MenuList.d.ts +16 -53
- package/molecules/Menu/MenuList.js +113 -1
- package/molecules/Menu/index.cjs +5 -16
- package/molecules/Menu/index.d.ts +3 -3
- package/molecules/Menu/index.js +3 -1
- package/molecules/Modal/Modal.cjs +42 -13
- package/molecules/Modal/Modal.d.ts +69 -140
- package/molecules/Modal/Modal.js +163 -1
- package/molecules/Modal/ModalWithTransition.cjs +4 -7
- package/molecules/Modal/ModalWithTransition.d.ts +6 -22
- package/molecules/Modal/ModalWithTransition.js +46 -1
- package/molecules/Modal/index.cjs +21 -0
- package/molecules/Modal/index.d.ts +2 -0
- package/molecules/Modal/index.js +2 -0
- package/molecules/Panel/Panel.cjs +41 -26
- package/molecules/Panel/Panel.d.ts +22 -21
- package/molecules/Panel/Panel.js +108 -1
- package/molecules/Panel/index.cjs +20 -0
- package/molecules/Panel/index.d.ts +1 -0
- package/molecules/Panel/index.js +1 -0
- package/molecules/Slider/AbstractSliderChild.cjs +7 -9
- package/molecules/Slider/AbstractSliderChild.d.ts +11 -30
- package/molecules/Slider/AbstractSliderChild.js +48 -1
- package/molecules/Slider/Slider.cjs +45 -30
- package/molecules/Slider/Slider.d.ts +40 -157
- package/molecules/Slider/Slider.js +279 -1
- package/molecules/Slider/SliderBtn.cjs +4 -7
- package/molecules/Slider/SliderBtn.d.ts +12 -23
- package/molecules/Slider/SliderBtn.js +34 -1
- package/molecules/Slider/SliderCount.cjs +4 -7
- package/molecules/Slider/SliderCount.d.ts +10 -16
- package/molecules/Slider/SliderCount.js +19 -1
- package/molecules/Slider/SliderDots.cjs +8 -8
- package/molecules/Slider/SliderDots.d.ts +11 -31
- package/molecules/Slider/SliderDots.js +32 -1
- package/molecules/Slider/SliderDrag.cjs +2 -2
- package/molecules/Slider/SliderDrag.d.ts +12 -30
- package/molecules/Slider/SliderDrag.js +34 -1
- package/molecules/Slider/SliderItem.cjs +12 -6
- package/molecules/Slider/SliderItem.d.ts +21 -33
- package/molecules/Slider/SliderItem.js +93 -1
- package/molecules/Slider/SliderProgress.cjs +4 -7
- package/molecules/Slider/SliderProgress.d.ts +10 -25
- package/molecules/Slider/SliderProgress.js +26 -1
- package/molecules/Slider/index.cjs +10 -26
- package/molecules/Slider/index.d.ts +8 -8
- package/molecules/Slider/index.js +8 -1
- package/molecules/Sticky/Sticky.cjs +16 -10
- package/molecules/Sticky/Sticky.d.ts +30 -68
- package/molecules/Sticky/Sticky.js +110 -1
- package/molecules/Sticky/index.cjs +20 -0
- package/molecules/Sticky/index.d.ts +1 -0
- package/molecules/Sticky/index.js +1 -0
- package/molecules/TableOfContent/TableOfContent.cjs +5 -8
- package/molecules/TableOfContent/TableOfContent.d.ts +19 -41
- package/molecules/TableOfContent/TableOfContent.js +42 -1
- package/molecules/TableOfContent/TableOfContentAnchor.cjs +9 -5
- package/molecules/TableOfContent/TableOfContentAnchor.d.ts +14 -17
- package/molecules/TableOfContent/TableOfContentAnchor.js +43 -1
- package/molecules/TableOfContent/index.cjs +4 -14
- package/molecules/TableOfContent/index.d.ts +2 -2
- package/molecules/TableOfContent/index.js +2 -1
- package/molecules/Tabs/Tabs.cjs +42 -22
- package/molecules/Tabs/Tabs.d.ts +28 -90
- package/molecules/Tabs/Tabs.js +123 -1
- package/molecules/Tabs/index.cjs +20 -0
- package/molecules/Tabs/index.d.ts +1 -0
- package/molecules/Tabs/index.js +1 -0
- package/molecules/index.cjs +7 -24
- package/molecules/index.d.ts +9 -10
- package/molecules/index.js +9 -1
- package/organisms/Frame/Frame.cjs +20 -43
- package/organisms/Frame/Frame.d.ts +21 -98
- package/organisms/Frame/Frame.js +161 -1
- package/organisms/Frame/FrameAnchor.cjs +2 -2
- package/organisms/Frame/FrameAnchor.d.ts +7 -16
- package/organisms/Frame/FrameAnchor.js +18 -1
- package/organisms/Frame/FrameForm.cjs +2 -2
- package/organisms/Frame/FrameForm.d.ts +10 -16
- package/organisms/Frame/FrameForm.js +18 -1
- package/organisms/Frame/FrameTarget.cjs +15 -7
- package/organisms/Frame/FrameTarget.d.ts +17 -26
- package/organisms/Frame/FrameTarget.js +79 -1
- package/organisms/Frame/index.cjs +6 -18
- package/organisms/Frame/index.d.ts +4 -4
- package/organisms/Frame/index.js +4 -1
- package/organisms/index.cjs +1 -1
- package/organisms/index.d.ts +1 -1
- package/organisms/index.js +1 -1
- package/package.json +2 -2
- package/primitives/Draggable/Draggable.cjs +9 -6
- package/primitives/Draggable/Draggable.d.ts +10 -11
- package/primitives/Draggable/Draggable.js +33 -1
- package/primitives/Draggable/index.cjs +20 -0
- package/primitives/Draggable/index.d.ts +1 -0
- package/primitives/Draggable/index.js +1 -0
- package/primitives/Sentinel/Sentinel.cjs +2 -2
- package/primitives/Sentinel/Sentinel.d.ts +6 -5
- package/primitives/Sentinel/Sentinel.js +15 -1
- package/primitives/Sentinel/index.cjs +20 -0
- package/primitives/Sentinel/index.d.ts +1 -0
- package/primitives/Sentinel/index.js +1 -0
- package/primitives/Transition/Transition.cjs +12 -3
- package/primitives/Transition/Transition.d.ts +13 -7
- package/primitives/Transition/Transition.js +16 -1
- package/primitives/Transition/index.cjs +20 -0
- package/primitives/Transition/index.d.ts +1 -0
- package/primitives/Transition/index.js +1 -0
- package/primitives/index.cjs +5 -16
- package/primitives/index.d.ts +3 -3
- package/primitives/index.js +3 -1
|
@@ -1,86 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*/
|
|
1
|
+
import { Base } from '@studiometa/js-toolkit';
|
|
2
|
+
import type { BaseProps, BaseConfig, DragServiceProps, KeyServiceProps } from '@studiometa/js-toolkit';
|
|
3
|
+
import { SliderDrag } from './SliderDrag.js';
|
|
4
|
+
import { SliderItem } from './SliderItem.js';
|
|
5
|
+
export declare type SliderModes = 'left' | 'center' | 'right';
|
|
6
|
+
declare type SliderState = {
|
|
7
|
+
x: Record<SliderModes, number>;
|
|
8
|
+
};
|
|
9
|
+
export interface SliderProps extends BaseProps {
|
|
10
|
+
$refs: {
|
|
11
|
+
wrapper: HTMLElement;
|
|
12
|
+
};
|
|
13
|
+
$children: {
|
|
14
|
+
SliderItem: SliderItem[];
|
|
15
|
+
SliderDrag: SliderDrag[];
|
|
16
|
+
};
|
|
17
|
+
$options: {
|
|
18
|
+
mode: SliderModes;
|
|
19
|
+
fitBounds: boolean;
|
|
20
|
+
sensitivity: number;
|
|
21
|
+
dropSensitivity: number;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
25
24
|
/**
|
|
26
25
|
* Orchestrate the slider items state transition.
|
|
27
26
|
* @todo a11y
|
|
28
27
|
*/
|
|
29
|
-
export
|
|
28
|
+
export declare class Slider<T extends BaseProps = BaseProps> extends Base<T & SliderProps> {
|
|
30
29
|
/**
|
|
31
30
|
* Config.
|
|
32
31
|
*/
|
|
33
|
-
static config:
|
|
34
|
-
name: string;
|
|
35
|
-
refs: string[];
|
|
36
|
-
emits: string[];
|
|
37
|
-
components: {
|
|
38
|
-
SliderItem: typeof SliderItem;
|
|
39
|
-
SliderDrag: typeof SliderDrag;
|
|
40
|
-
};
|
|
41
|
-
options: {
|
|
42
|
-
mode: {
|
|
43
|
-
type: StringConstructor;
|
|
44
|
-
default: string;
|
|
45
|
-
};
|
|
46
|
-
fitBounds: BooleanConstructor;
|
|
47
|
-
contain: BooleanConstructor;
|
|
48
|
-
sensitivity: {
|
|
49
|
-
type: NumberConstructor;
|
|
50
|
-
default: number;
|
|
51
|
-
};
|
|
52
|
-
dropSensitivity: {
|
|
53
|
-
type: NumberConstructor;
|
|
54
|
-
default: number;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
};
|
|
32
|
+
static config: BaseConfig;
|
|
58
33
|
__distanceX: number;
|
|
59
34
|
__initialX: number;
|
|
60
35
|
/**
|
|
61
36
|
* Index of the current active slide.
|
|
62
|
-
* @type {number}
|
|
63
37
|
*/
|
|
64
38
|
__currentIndex: number;
|
|
65
|
-
/**
|
|
66
|
-
* Set the current index and emit the `index` event.
|
|
67
|
-
* @param {number} value
|
|
68
|
-
* @returns {void}
|
|
69
|
-
*/
|
|
70
|
-
set currentIndex(arg: number);
|
|
71
39
|
/**
|
|
72
40
|
* Get the current index.
|
|
73
|
-
* @returns {number}
|
|
74
41
|
*/
|
|
75
42
|
get currentIndex(): number;
|
|
43
|
+
/**
|
|
44
|
+
* Set the current index and emit the `index` event.
|
|
45
|
+
*/
|
|
46
|
+
set currentIndex(value: number);
|
|
76
47
|
/**
|
|
77
48
|
* Store all the states.
|
|
78
|
-
* @type {SliderState[]}
|
|
79
49
|
*/
|
|
80
50
|
states: SliderState[];
|
|
81
51
|
/**
|
|
82
52
|
* Origins for the different modes.
|
|
83
|
-
* @type {Record<SliderModes, number>}
|
|
84
53
|
*/
|
|
85
54
|
origins: Record<SliderModes, number>;
|
|
86
55
|
/**
|
|
@@ -90,193 +59,107 @@ export default class Slider extends Base {
|
|
|
90
59
|
hasFocus: boolean;
|
|
91
60
|
/**
|
|
92
61
|
* Get the current state.
|
|
93
|
-
* @returns {SliderState}
|
|
94
62
|
*/
|
|
95
63
|
get currentState(): SliderState;
|
|
96
64
|
/**
|
|
97
65
|
* Get the first state.
|
|
98
|
-
* @returns {SliderState}
|
|
99
66
|
*/
|
|
100
67
|
get firstState(): SliderState;
|
|
101
68
|
/**
|
|
102
69
|
* Get the last state.
|
|
103
|
-
* @returns {SliderState}
|
|
104
70
|
*/
|
|
105
71
|
get lastState(): SliderState;
|
|
106
72
|
/**
|
|
107
73
|
* Get the minimal contain state value.
|
|
108
|
-
* @returns {number} [description]
|
|
109
74
|
*/
|
|
110
75
|
get containMinState(): number;
|
|
111
76
|
/**
|
|
112
77
|
* Get the maximal contain state value.
|
|
113
|
-
* @returns {number} [description]
|
|
114
78
|
*/
|
|
115
79
|
get containMaxState(): number;
|
|
116
80
|
/**
|
|
117
81
|
* Get the last index.
|
|
118
|
-
*
|
|
119
|
-
* @this {SliderInterface}
|
|
120
|
-
* @returns {number}
|
|
121
82
|
*/
|
|
122
83
|
get indexMax(): number;
|
|
123
84
|
/**
|
|
124
85
|
* Get the current SliderItem
|
|
125
|
-
*
|
|
126
|
-
* @this {SliderInterface}
|
|
127
|
-
* @returns {SliderItem}
|
|
128
86
|
*/
|
|
129
|
-
get currentSliderItem(): SliderItem
|
|
87
|
+
get currentSliderItem(): SliderItem<BaseProps>;
|
|
130
88
|
/**
|
|
131
89
|
* Get the states for each SliderItem.
|
|
132
|
-
*
|
|
133
|
-
* @this {SliderInterface}
|
|
134
90
|
*/
|
|
135
|
-
getStates(
|
|
136
|
-
x: {
|
|
137
|
-
left: number;
|
|
138
|
-
center: number;
|
|
139
|
-
right: number;
|
|
140
|
-
};
|
|
141
|
-
}[];
|
|
91
|
+
getStates(): SliderState[];
|
|
142
92
|
/**
|
|
143
93
|
* Get an origin by mode.
|
|
144
|
-
* @param {SliderOptions['mode']} [mode]
|
|
145
|
-
* @returns {number}
|
|
146
94
|
*/
|
|
147
|
-
getOriginByMode(mode?:
|
|
95
|
+
getOriginByMode(mode?: SliderModes): number;
|
|
148
96
|
/**
|
|
149
97
|
* Get a state value according to the given mode.
|
|
150
|
-
*
|
|
151
|
-
* @this {SliderInterface}
|
|
152
|
-
* @param {SliderState['x']} state
|
|
153
|
-
* @param {SliderOptions['mode']} [mode]
|
|
154
|
-
* @returns {number}
|
|
155
98
|
*/
|
|
156
|
-
getStateValueByMode(
|
|
99
|
+
getStateValueByMode(state: SliderState['x'], mode?: SliderModes): number;
|
|
157
100
|
/**
|
|
158
101
|
* Mounted hook.
|
|
159
|
-
*
|
|
160
|
-
* @returns {void}
|
|
161
102
|
*/
|
|
162
103
|
mounted(): void;
|
|
163
104
|
/**
|
|
164
105
|
* Resized hook.
|
|
165
|
-
* @returns {void}
|
|
166
106
|
*/
|
|
167
107
|
resized(): void;
|
|
168
108
|
/**
|
|
169
109
|
* Go to the next slide.
|
|
170
|
-
*
|
|
171
|
-
* @returns {void}
|
|
172
110
|
*/
|
|
173
111
|
goNext(): void;
|
|
174
112
|
/**
|
|
175
113
|
* Go to the previous slide.
|
|
176
|
-
*
|
|
177
|
-
* @returns {void}
|
|
178
114
|
*/
|
|
179
115
|
goPrev(): void;
|
|
180
116
|
/**
|
|
181
117
|
* Go to the given index.
|
|
182
|
-
*
|
|
183
|
-
* @this {SliderInterface}
|
|
184
|
-
* @param {number} index
|
|
185
|
-
* @param {{ withInstantMove?: boolean }} [options]
|
|
186
|
-
* @returns {void}
|
|
187
118
|
*/
|
|
188
|
-
goTo(
|
|
119
|
+
goTo(index: number, { withInstantMove }?: {
|
|
189
120
|
withInstantMove?: boolean;
|
|
190
121
|
}): void;
|
|
191
122
|
/**
|
|
192
123
|
* Listen to the Draggable `start` event.
|
|
193
|
-
*
|
|
194
|
-
* @returns {void}
|
|
195
124
|
*/
|
|
196
125
|
onSliderDragStart(): void;
|
|
197
126
|
/**
|
|
198
127
|
* Listen to the Draggable `drag` event.
|
|
199
|
-
*
|
|
200
|
-
* @param {import('@studiometa/js-toolkit/services/drag').DragServiceProps} props
|
|
201
|
-
* @returns {void}
|
|
202
128
|
*/
|
|
203
|
-
onSliderDragDrag(props:
|
|
129
|
+
onSliderDragDrag(props: DragServiceProps): void;
|
|
204
130
|
/**
|
|
205
131
|
* Listen to the Draggable `drop` event and find the new active slide.
|
|
206
|
-
*
|
|
207
|
-
* @this {SliderInterface}
|
|
208
|
-
* @param {import('@studiometa/js-toolkit/services/drag').DragServiceProps} props
|
|
209
|
-
* @returns {void}
|
|
210
132
|
*/
|
|
211
|
-
onSliderDragDrop(
|
|
133
|
+
onSliderDragDrop(props: DragServiceProps): void;
|
|
212
134
|
/**
|
|
213
135
|
* Enable focus.
|
|
214
|
-
* @returns {void}
|
|
215
136
|
*/
|
|
216
137
|
onWrapperFocus(): void;
|
|
217
138
|
/**
|
|
218
139
|
* Disable focus.
|
|
219
|
-
* @returns {void}
|
|
220
140
|
*/
|
|
221
141
|
onWrapperBlur(): void;
|
|
222
142
|
/**
|
|
223
143
|
* Go prev or next when focus is on the wrapper and pressing arrow keys.
|
|
224
|
-
* @param {import('@studiometa/js-toolkit/services/key').KeyServiceProps} props
|
|
225
|
-
* @returns {void}
|
|
226
144
|
*/
|
|
227
|
-
keyed({ LEFT, RIGHT, isDown }:
|
|
145
|
+
keyed({ LEFT, RIGHT, isDown }: KeyServiceProps): void;
|
|
228
146
|
/**
|
|
229
147
|
* Prepare invisible items.
|
|
230
|
-
* @returns {void}
|
|
231
148
|
*/
|
|
232
149
|
prepareInvisibleItems(): void;
|
|
233
150
|
/**
|
|
234
151
|
* Get the state where the given item will be visible.
|
|
235
|
-
*
|
|
236
|
-
* @param {SliderItem} item
|
|
237
|
-
* @returns {SliderState}
|
|
238
152
|
*/
|
|
239
153
|
getStateWhereItemWillBeInvisible(item: SliderItem, { reversed }?: {
|
|
240
154
|
reversed?: boolean;
|
|
241
155
|
}): SliderState;
|
|
242
156
|
/**
|
|
243
157
|
* Get the visible slides for the given position.
|
|
244
|
-
*
|
|
245
|
-
* @this {SliderInterface}
|
|
246
|
-
* @param {number} target
|
|
247
|
-
* @returns {SliderItem[]}
|
|
248
158
|
*/
|
|
249
|
-
getVisibleItems(
|
|
159
|
+
getVisibleItems(target: number): SliderItem<BaseProps>[];
|
|
250
160
|
/**
|
|
251
161
|
* Get the invisible slides for the given position.
|
|
252
|
-
*
|
|
253
|
-
* @this {SliderInterface}
|
|
254
|
-
* @param {number} target
|
|
255
|
-
* @returns {SliderItem[]}
|
|
256
162
|
*/
|
|
257
|
-
getInvisibleItems(
|
|
163
|
+
getInvisibleItems(target: number): SliderItem<BaseProps>[];
|
|
258
164
|
}
|
|
259
|
-
export
|
|
260
|
-
export type SliderState = {
|
|
261
|
-
x: Record<SliderModes, number>;
|
|
262
|
-
};
|
|
263
|
-
export type SliderChildren = {
|
|
264
|
-
SliderItem: SliderItem[];
|
|
265
|
-
SliderDrag: SliderDrag[];
|
|
266
|
-
};
|
|
267
|
-
export type SliderOptions = {
|
|
268
|
-
mode: SliderModes;
|
|
269
|
-
fitBounds: boolean;
|
|
270
|
-
sensitivity: number;
|
|
271
|
-
};
|
|
272
|
-
export type SliderPrivateInterface = {
|
|
273
|
-
$refs: {
|
|
274
|
-
wrapper: HTMLElement;
|
|
275
|
-
};
|
|
276
|
-
$children: SliderChildren;
|
|
277
|
-
$options: SliderOptions;
|
|
278
|
-
};
|
|
279
|
-
export type SliderInterface = Slider & SliderPrivateInterface;
|
|
280
|
-
import { Base } from "@studiometa/js-toolkit";
|
|
281
|
-
import SliderItem from "./SliderItem.js";
|
|
282
|
-
import SliderDrag from "./SliderDrag.js";
|
|
165
|
+
export {};
|
|
@@ -1 +1,279 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
import { Base } from "@studiometa/js-toolkit";
|
|
8
|
+
import { clamp, inertiaFinalValue, nextFrame, isDev } from "@studiometa/js-toolkit/utils";
|
|
9
|
+
import { SliderDrag } from "./SliderDrag.js";
|
|
10
|
+
import { SliderItem } from "./SliderItem.js";
|
|
11
|
+
class Slider extends Base {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
__publicField(this, "__distanceX", 0);
|
|
15
|
+
__publicField(this, "__initialX", 0);
|
|
16
|
+
__publicField(this, "__currentIndex", 0);
|
|
17
|
+
__publicField(this, "states", []);
|
|
18
|
+
__publicField(this, "origins", {
|
|
19
|
+
left: 0,
|
|
20
|
+
center: 0,
|
|
21
|
+
right: 0
|
|
22
|
+
});
|
|
23
|
+
__publicField(this, "hasFocus", false);
|
|
24
|
+
}
|
|
25
|
+
get currentIndex() {
|
|
26
|
+
return this.__currentIndex;
|
|
27
|
+
}
|
|
28
|
+
set currentIndex(value) {
|
|
29
|
+
this.currentSliderItem.disactivate();
|
|
30
|
+
this.$emit("index", value);
|
|
31
|
+
this.__currentIndex = value;
|
|
32
|
+
this.currentSliderItem.activate();
|
|
33
|
+
}
|
|
34
|
+
get currentState() {
|
|
35
|
+
return this.states[this.currentIndex];
|
|
36
|
+
}
|
|
37
|
+
get firstState() {
|
|
38
|
+
return this.states[0];
|
|
39
|
+
}
|
|
40
|
+
get lastState() {
|
|
41
|
+
return this.states.at(-1);
|
|
42
|
+
}
|
|
43
|
+
get containMinState() {
|
|
44
|
+
return this.getStateValueByMode(this.firstState.x, "left");
|
|
45
|
+
}
|
|
46
|
+
get containMaxState() {
|
|
47
|
+
return this.getStateValueByMode(this.lastState.x, "right");
|
|
48
|
+
}
|
|
49
|
+
get indexMax() {
|
|
50
|
+
return this.$children.SliderItem.length - 1;
|
|
51
|
+
}
|
|
52
|
+
get currentSliderItem() {
|
|
53
|
+
return this.$children.SliderItem[this.currentIndex];
|
|
54
|
+
}
|
|
55
|
+
getStates() {
|
|
56
|
+
const { wrapper } = this.$refs;
|
|
57
|
+
const originRect = wrapper.getBoundingClientRect();
|
|
58
|
+
this.origins = {
|
|
59
|
+
left: originRect.left,
|
|
60
|
+
center: originRect.x + originRect.width / 2,
|
|
61
|
+
right: originRect.x + originRect.width
|
|
62
|
+
};
|
|
63
|
+
const states = this.$children.SliderItem.map((item) => ({
|
|
64
|
+
x: {
|
|
65
|
+
left: (item.rect.x - this.origins.left) * -1,
|
|
66
|
+
center: (item.rect.x + item.rect.width / 2 - this.origins.center) * -1,
|
|
67
|
+
right: (item.rect.x + item.rect.width - this.origins.right) * -1
|
|
68
|
+
}
|
|
69
|
+
}));
|
|
70
|
+
if (this.$options.contain) {
|
|
71
|
+
const { mode } = this.$options;
|
|
72
|
+
if (mode === "left") {
|
|
73
|
+
const lastChild = this.$children.SliderItem.at(-1);
|
|
74
|
+
const maxState = states.find((state) => {
|
|
75
|
+
const lastChildPosition = lastChild.rect.x - this.origins.left + lastChild.rect.width + state.x.left;
|
|
76
|
+
const diffWithWrapperBound = originRect.width - lastChildPosition;
|
|
77
|
+
if (diffWithWrapperBound > 0) {
|
|
78
|
+
state.x.left = Math.min(state.x.left + diffWithWrapperBound, 0);
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
});
|
|
83
|
+
if (maxState) {
|
|
84
|
+
return states.map((state) => {
|
|
85
|
+
state.x.left = Math.max(state.x.left, maxState.x.left);
|
|
86
|
+
return state;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (mode === "right") {
|
|
91
|
+
const maxStateIndex = states.findIndex((state) => state.x.right <= 0);
|
|
92
|
+
const maxState = maxStateIndex < 0 ? states.at(-1) : states[maxStateIndex - 1];
|
|
93
|
+
return states.map((state) => {
|
|
94
|
+
state.x.right = maxStateIndex < 0 ? maxState.x.right : Math.min(state.x.right, 0);
|
|
95
|
+
return state;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (mode === "center" && isDev) {
|
|
99
|
+
console.warn(
|
|
100
|
+
`[${this.$id}]`,
|
|
101
|
+
"The `center` mode is not yet compatible with the `contain` mode."
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return states;
|
|
106
|
+
}
|
|
107
|
+
getOriginByMode(mode) {
|
|
108
|
+
return this.origins[mode != null ? mode : this.$options.mode];
|
|
109
|
+
}
|
|
110
|
+
getStateValueByMode(state, mode) {
|
|
111
|
+
return state[mode != null ? mode : this.$options.mode];
|
|
112
|
+
}
|
|
113
|
+
mounted() {
|
|
114
|
+
this.states = this.getStates();
|
|
115
|
+
this.prepareInvisibleItems();
|
|
116
|
+
this.goTo(this.currentIndex);
|
|
117
|
+
}
|
|
118
|
+
resized() {
|
|
119
|
+
nextFrame(() => {
|
|
120
|
+
this.states = this.getStates();
|
|
121
|
+
nextFrame(() => {
|
|
122
|
+
this.prepareInvisibleItems();
|
|
123
|
+
this.goTo(this.currentIndex);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
goNext() {
|
|
128
|
+
if (this.currentIndex + 1 > this.indexMax) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
this.goTo(this.currentIndex + 1);
|
|
132
|
+
}
|
|
133
|
+
goPrev() {
|
|
134
|
+
if (this.currentIndex - 1 < 0) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
this.goTo(this.currentIndex - 1);
|
|
138
|
+
}
|
|
139
|
+
goTo(index, { withInstantMove = true } = {}) {
|
|
140
|
+
if (index < 0 || index > this.indexMax) {
|
|
141
|
+
throw new Error("Index out of bound.");
|
|
142
|
+
}
|
|
143
|
+
const currentState = this.getStateValueByMode(this.currentState.x);
|
|
144
|
+
const state = this.getStateValueByMode(this.states[index].x);
|
|
145
|
+
const itemsToMove = this.getVisibleItems(state);
|
|
146
|
+
const invisibleItemsToMoveInstantly = this.getInvisibleItems(state);
|
|
147
|
+
itemsToMove.forEach((item) => {
|
|
148
|
+
if (currentState !== state && withInstantMove) {
|
|
149
|
+
item.moveInstantly(currentState);
|
|
150
|
+
}
|
|
151
|
+
nextFrame(() => item.move(state));
|
|
152
|
+
});
|
|
153
|
+
invisibleItemsToMoveInstantly.forEach((item) => {
|
|
154
|
+
item.moveInstantly(state);
|
|
155
|
+
});
|
|
156
|
+
this.currentIndex = index;
|
|
157
|
+
this.$emit("goto", index);
|
|
158
|
+
}
|
|
159
|
+
onSliderDragStart() {
|
|
160
|
+
this.__initialX = this.currentSliderItem ? this.currentSliderItem.x : 0;
|
|
161
|
+
this.__distanceX = this.__initialX;
|
|
162
|
+
}
|
|
163
|
+
onSliderDragDrag(props) {
|
|
164
|
+
if (Math.abs(props.delta.y) > Math.abs(props.delta.x)) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
this.__distanceX = this.__initialX + props.distance.x * this.$options.sensitivity;
|
|
168
|
+
this.getVisibleItems(this.__distanceX).forEach((item) => {
|
|
169
|
+
item.moveInstantly(this.__distanceX);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
onSliderDragDrop(props) {
|
|
173
|
+
if (Math.abs(props.delta.y) > Math.abs(props.delta.x)) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
let finalX = clamp(
|
|
177
|
+
inertiaFinalValue(this.__distanceX, props.delta.x * this.$options.dropSensitivity),
|
|
178
|
+
0,
|
|
179
|
+
this.getStateValueByMode(this.lastState.x)
|
|
180
|
+
);
|
|
181
|
+
const absoluteDifferencesBetweenDistanceAndState = this.states.map(
|
|
182
|
+
(state) => Math.abs(finalX - this.getStateValueByMode(state.x))
|
|
183
|
+
);
|
|
184
|
+
const minimumDifference = Math.min(...absoluteDifferencesBetweenDistanceAndState);
|
|
185
|
+
const closestIndex = absoluteDifferencesBetweenDistanceAndState.indexOf(minimumDifference);
|
|
186
|
+
if (this.$options.fitBounds) {
|
|
187
|
+
this.goTo(closestIndex, { withInstantMove: false });
|
|
188
|
+
} else {
|
|
189
|
+
if (this.$options.contain) {
|
|
190
|
+
finalX = Math.min(this.containMinState, finalX);
|
|
191
|
+
finalX = Math.max(this.containMaxState, finalX);
|
|
192
|
+
}
|
|
193
|
+
this.$children.SliderItem.forEach((item) => {
|
|
194
|
+
item.move(finalX);
|
|
195
|
+
});
|
|
196
|
+
this.currentIndex = closestIndex;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
onWrapperFocus() {
|
|
200
|
+
this.hasFocus = true;
|
|
201
|
+
}
|
|
202
|
+
onWrapperBlur() {
|
|
203
|
+
this.hasFocus = false;
|
|
204
|
+
}
|
|
205
|
+
keyed({ LEFT, RIGHT, isDown }) {
|
|
206
|
+
if (this.hasFocus && isDown) {
|
|
207
|
+
if (LEFT) {
|
|
208
|
+
this.goPrev();
|
|
209
|
+
} else if (RIGHT) {
|
|
210
|
+
this.goNext();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
prepareInvisibleItems() {
|
|
215
|
+
const state = this.states[this.currentIndex];
|
|
216
|
+
const nextItemsToPrepare = [];
|
|
217
|
+
const previousItemsToPrepare = [];
|
|
218
|
+
this.getInvisibleItems(this.getStateValueByMode(state.x)).forEach((item, i) => {
|
|
219
|
+
if (i > this.currentIndex) {
|
|
220
|
+
nextItemsToPrepare.push(item);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
if (i < this.currentIndex) {
|
|
224
|
+
previousItemsToPrepare.push(item);
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
nextItemsToPrepare.forEach((item) => {
|
|
228
|
+
const invisibleState = this.getStateWhereItemWillBeInvisible(item);
|
|
229
|
+
if (invisibleState) {
|
|
230
|
+
item.moveInstantly(this.getStateValueByMode(invisibleState.x));
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
previousItemsToPrepare.forEach((item) => {
|
|
234
|
+
const invisibleState = this.getStateWhereItemWillBeInvisible(item, { reversed: true });
|
|
235
|
+
if (invisibleState) {
|
|
236
|
+
item.moveInstantly(this.getStateValueByMode(invisibleState.x));
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
getStateWhereItemWillBeInvisible(item, { reversed = false } = {}) {
|
|
241
|
+
const visibleStates = this.states.filter(
|
|
242
|
+
(state) => item.willBeVisible(this.getStateValueByMode(state.x))
|
|
243
|
+
);
|
|
244
|
+
const firstVisibleState = visibleStates[0];
|
|
245
|
+
const lastVisibleState = visibleStates.at(-1);
|
|
246
|
+
const firstVisibleStateIndex = this.states.findIndex(
|
|
247
|
+
(state) => this.getStateValueByMode(state.x) === this.getStateValueByMode(firstVisibleState.x)
|
|
248
|
+
);
|
|
249
|
+
const lastVisibleStateIndex = this.states.findIndex((state) => state.x === lastVisibleState.x);
|
|
250
|
+
return reversed ? this.states[lastVisibleStateIndex + 1] : this.states[firstVisibleStateIndex - 1];
|
|
251
|
+
}
|
|
252
|
+
getVisibleItems(target) {
|
|
253
|
+
return this.$children.SliderItem.filter((item) => item.isVisible || item.willBeVisible(target));
|
|
254
|
+
}
|
|
255
|
+
getInvisibleItems(target) {
|
|
256
|
+
return this.$children.SliderItem.filter(
|
|
257
|
+
(item) => !item.isVisible && !item.willBeVisible(target)
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
__publicField(Slider, "config", {
|
|
262
|
+
name: "Slider",
|
|
263
|
+
refs: ["wrapper", "debug"],
|
|
264
|
+
emits: ["goto", "index"],
|
|
265
|
+
components: {
|
|
266
|
+
SliderItem,
|
|
267
|
+
SliderDrag
|
|
268
|
+
},
|
|
269
|
+
options: {
|
|
270
|
+
mode: { type: String, default: "left" },
|
|
271
|
+
fitBounds: Boolean,
|
|
272
|
+
contain: Boolean,
|
|
273
|
+
sensitivity: { type: Number, default: 1 },
|
|
274
|
+
dropSensitivity: { type: Number, default: 2 }
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
export {
|
|
278
|
+
Slider
|
|
279
|
+
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
6
|
var __export = (target, all) => {
|
|
@@ -17,21 +15,20 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
21
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
19
|
var __publicField = (obj, key, value) => {
|
|
23
20
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
24
21
|
return value;
|
|
25
22
|
};
|
|
26
23
|
|
|
27
|
-
// packages/ui/molecules/Slider/SliderBtn.
|
|
24
|
+
// packages/ui/molecules/Slider/SliderBtn.ts
|
|
28
25
|
var SliderBtn_exports = {};
|
|
29
26
|
__export(SliderBtn_exports, {
|
|
30
|
-
|
|
27
|
+
SliderBtn: () => SliderBtn
|
|
31
28
|
});
|
|
32
29
|
module.exports = __toCommonJS(SliderBtn_exports);
|
|
33
|
-
var import_AbstractSliderChild =
|
|
34
|
-
var SliderBtn = class extends import_AbstractSliderChild.
|
|
30
|
+
var import_AbstractSliderChild = require("./AbstractSliderChild.cjs");
|
|
31
|
+
var SliderBtn = class extends import_AbstractSliderChild.AbstractSliderChild {
|
|
35
32
|
update(index) {
|
|
36
33
|
if (index === 0 && this.$options.prev || index === this.$parent.indexMax && this.$options.next) {
|
|
37
34
|
this.$el.setAttribute("disabled", "");
|
|
@@ -1,39 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type { BaseProps, BaseConfig } from '@studiometa/js-toolkit';
|
|
2
|
+
import { AbstractSliderChild } from './AbstractSliderChild.js';
|
|
3
|
+
export interface SliderBtnProps extends BaseProps {
|
|
4
|
+
$options: {
|
|
5
|
+
prev: boolean;
|
|
6
|
+
next: boolean;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
6
9
|
/**
|
|
7
10
|
* SliderBtn class.
|
|
8
11
|
*/
|
|
9
|
-
export
|
|
12
|
+
export declare class SliderBtn<T extends BaseProps = BaseProps> extends AbstractSliderChild<T & SliderBtnProps> {
|
|
10
13
|
/**
|
|
11
14
|
* Config.
|
|
12
15
|
*/
|
|
13
|
-
static config:
|
|
14
|
-
name: string;
|
|
15
|
-
options: {
|
|
16
|
-
prev: BooleanConstructor;
|
|
17
|
-
next: BooleanConstructor;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
16
|
+
static config: BaseConfig;
|
|
20
17
|
/**
|
|
21
18
|
* Update attributes.
|
|
22
|
-
*
|
|
23
|
-
* @this {SliderBtnInterface}
|
|
24
19
|
* @param {number} index
|
|
25
20
|
* @returns {void}
|
|
26
21
|
*/
|
|
27
|
-
update(
|
|
22
|
+
update(index: number): void;
|
|
28
23
|
/**
|
|
29
24
|
* Go prev or next on click.
|
|
30
|
-
*
|
|
31
|
-
* @this {SliderBtnInterface}
|
|
32
25
|
* @returns {void}
|
|
33
26
|
*/
|
|
34
|
-
onClick(
|
|
27
|
+
onClick(): void;
|
|
35
28
|
}
|
|
36
|
-
export type SliderBtnInterface = SliderBtn & {
|
|
37
|
-
$parent: import('./Slider.js').default;
|
|
38
|
-
};
|
|
39
|
-
import AbstractSliderChild from "./AbstractSliderChild.js";
|