@studiometa/ui 0.2.10 → 0.2.11
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/Figure/Figure.cjs +19 -5
- package/atoms/Figure/Figure.d.ts +40 -17
- package/atoms/Figure/Figure.js +1 -1
- package/atoms/Figure/FigureTwicPics.cjs +1 -1
- package/atoms/Figure/FigureTwicPics.d.ts +5 -0
- package/atoms/Figure/FigureTwicPics.js +1 -1
- package/atoms/ScrollReveal/ScrollReveal.cjs +72 -0
- package/atoms/ScrollReveal/ScrollReveal.d.ts +77 -0
- package/atoms/ScrollReveal/ScrollReveal.js +1 -0
- package/atoms/ScrollReveal/index.cjs +29 -0
- package/atoms/ScrollReveal/index.d.ts +1 -0
- package/atoms/ScrollReveal/index.js +1 -0
- package/atoms/index.cjs +1 -0
- package/atoms/index.d.ts +1 -0
- package/atoms/index.js +1 -1
- package/decorators/index.cjs +29 -0
- package/decorators/index.d.ts +1 -0
- package/decorators/index.js +1 -0
- package/decorators/withTransition.cjs +66 -0
- package/decorators/withTransition.d.ts +43 -0
- package/decorators/withTransition.js +1 -0
- package/index.cjs +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -1
- package/molecules/Menu/MenuList.d.ts +11 -12
- package/molecules/Slider/Slider.cjs +68 -22
- package/molecules/Slider/Slider.d.ts +25 -2
- package/molecules/Slider/Slider.js +1 -1
- package/molecules/Slider/SliderDots.cjs +9 -4
- package/molecules/Slider/SliderDots.d.ts +18 -1
- package/molecules/Slider/SliderDots.js +1 -1
- package/molecules/Slider/SliderDrag.cjs +14 -3
- package/molecules/Slider/SliderDrag.d.ts +31 -3
- package/molecules/Slider/SliderDrag.js +1 -1
- package/molecules/Slider/SliderItem.cjs +1 -1
- package/molecules/Slider/SliderItem.js +1 -1
- package/molecules/Slider/SliderProgress.cjs +3 -4
- package/molecules/Slider/SliderProgress.js +1 -1
- package/organisms/Frame/FrameTarget.d.ts +16 -10
- package/package.json +1 -1
- package/primitives/Transition/Transition.cjs +3 -41
- package/primitives/Transition/Transition.d.ts +6 -66
- package/primitives/Transition/Transition.js +1 -1
package/atoms/Figure/Figure.cjs
CHANGED
|
@@ -28,7 +28,11 @@ __export(Figure_exports, {
|
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(Figure_exports);
|
|
30
30
|
var import_js_toolkit = require("@studiometa/js-toolkit");
|
|
31
|
-
var
|
|
31
|
+
var import_primitives = require("../../primitives/index.cjs");
|
|
32
|
+
var Figure = class extends (0, import_js_toolkit.withMountWhenInView)(import_primitives.Transition, { threshold: [0, 1] }) {
|
|
33
|
+
get target() {
|
|
34
|
+
return this.$refs.img;
|
|
35
|
+
}
|
|
32
36
|
get src() {
|
|
33
37
|
return this.$refs.img.src;
|
|
34
38
|
}
|
|
@@ -36,21 +40,31 @@ var Figure = class extends (0, import_js_toolkit.withMountWhenInView)(import_js_
|
|
|
36
40
|
this.$refs.img.src = value;
|
|
37
41
|
}
|
|
38
42
|
mounted() {
|
|
39
|
-
|
|
43
|
+
const { img } = this.$refs;
|
|
44
|
+
if (!img) {
|
|
40
45
|
throw new Error("[Figure] The `img` ref is required.");
|
|
41
46
|
}
|
|
42
|
-
if (!(
|
|
47
|
+
if (!(img instanceof HTMLImageElement)) {
|
|
43
48
|
throw new Error("[Figure] The `img` ref must be an `<img>` element.");
|
|
44
49
|
}
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
const src = img.getAttribute("data-src");
|
|
51
|
+
if (this.$options.lazy && src && src !== this.src) {
|
|
52
|
+
let tempImg = new Image();
|
|
53
|
+
tempImg.onload = () => {
|
|
54
|
+
this.enter();
|
|
55
|
+
this.src = src;
|
|
56
|
+
tempImg = null;
|
|
57
|
+
};
|
|
58
|
+
tempImg.src = src;
|
|
47
59
|
}
|
|
48
60
|
}
|
|
49
61
|
};
|
|
50
62
|
__publicField(Figure, "config", {
|
|
63
|
+
...import_primitives.Transition.config,
|
|
51
64
|
name: "Figure",
|
|
52
65
|
refs: ["img"],
|
|
53
66
|
options: {
|
|
67
|
+
...import_primitives.Transition.config.options,
|
|
54
68
|
lazy: Boolean
|
|
55
69
|
}
|
|
56
70
|
});
|
package/atoms/Figure/Figure.d.ts
CHANGED
|
@@ -1,28 +1,49 @@
|
|
|
1
|
+
declare const Figure_base: typeof import("@studiometa/js-toolkit").Base & (new (...a: any[]) => {
|
|
2
|
+
readonly target: HTMLElement | HTMLElement[];
|
|
3
|
+
enter(target?: HTMLElement | HTMLElement[]): Promise<void | void[]>;
|
|
4
|
+
leave(target?: HTMLElement | HTMLElement[]): Promise<void | void[]>;
|
|
5
|
+
});
|
|
1
6
|
/**
|
|
2
|
-
* @typedef {
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*
|
|
7
|
-
*
|
|
7
|
+
* @typedef {Figure & {
|
|
8
|
+
* $refs: {
|
|
9
|
+
* img: HTMLImageElement
|
|
10
|
+
* },
|
|
11
|
+
* $options: {
|
|
12
|
+
* lazy: boolean
|
|
13
|
+
* }
|
|
14
|
+
* }} FigureInterface
|
|
8
15
|
*/
|
|
9
16
|
/**
|
|
10
17
|
* Figure class.
|
|
11
18
|
*
|
|
12
19
|
* Manager lazyloading image sources.
|
|
13
20
|
*/
|
|
14
|
-
export default class Figure extends
|
|
21
|
+
export default class Figure extends Figure_base {
|
|
22
|
+
/**
|
|
23
|
+
* Config.
|
|
24
|
+
*/
|
|
15
25
|
static config: {
|
|
16
26
|
name: string;
|
|
17
27
|
refs: string[];
|
|
18
28
|
options: {
|
|
19
29
|
lazy: BooleanConstructor;
|
|
20
30
|
};
|
|
31
|
+
debug?: boolean;
|
|
32
|
+
log?: boolean;
|
|
33
|
+
emits?: string[];
|
|
34
|
+
components?: import("@studiometa/js-toolkit/Base/index.js").BaseConfigComponents;
|
|
21
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* Get the transition target.
|
|
38
|
+
*
|
|
39
|
+
* @this {FigureInterface}
|
|
40
|
+
* @returns {HTMLImageElement}
|
|
41
|
+
*/
|
|
42
|
+
get target(): HTMLImageElement;
|
|
22
43
|
/**
|
|
23
44
|
* Set the image source.
|
|
24
45
|
*
|
|
25
|
-
* @this {
|
|
46
|
+
* @this {FigureInterface}
|
|
26
47
|
* @param {string} value
|
|
27
48
|
* @returns {void}
|
|
28
49
|
*/
|
|
@@ -30,20 +51,22 @@ export default class Figure extends Base {
|
|
|
30
51
|
/**
|
|
31
52
|
* Get the image source.
|
|
32
53
|
*
|
|
33
|
-
* @this {
|
|
54
|
+
* @this {FigureInterface}
|
|
34
55
|
* @returns {string}
|
|
35
56
|
*/
|
|
36
57
|
get src(): string;
|
|
37
58
|
/**
|
|
38
59
|
* Load on mount.
|
|
39
|
-
* @this {
|
|
60
|
+
* @this {FigureInterface}
|
|
40
61
|
*/
|
|
41
|
-
mounted(this:
|
|
62
|
+
mounted(this: FigureInterface): void;
|
|
42
63
|
}
|
|
43
|
-
export type
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
$
|
|
64
|
+
export type FigureInterface = Figure & {
|
|
65
|
+
$refs: {
|
|
66
|
+
img: HTMLImageElement;
|
|
67
|
+
};
|
|
68
|
+
$options: {
|
|
69
|
+
lazy: boolean;
|
|
70
|
+
};
|
|
48
71
|
};
|
|
49
|
-
|
|
72
|
+
export {};
|
package/atoms/Figure/Figure.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{withMountWhenInView as s}from"@studiometa/js-toolkit";import{Transition as i}from"../../primitives/index.js";class n extends s(i,{threshold:[0,1]}){static config={...i.config,name:"Figure",refs:["img"],options:{...i.config.options,lazy:Boolean}};get target(){return this.$refs.img}get src(){return this.$refs.img.src}set src(e){this.$refs.img.src=e}mounted(){const{img:e}=this.$refs;if(!e)throw new Error("[Figure] The `img` ref is required.");if(!(e instanceof HTMLImageElement))throw new Error("[Figure] The `img` ref must be an `<img>` element.");const t=e.getAttribute("data-src");if(this.$options.lazy&&t&&t!==this.src){let r=new Image;r.onload=()=>{this.enter(),this.src=t,r=null},r.src=t}}}export{n as default};
|
|
@@ -41,7 +41,7 @@ var FigureTwicPics = class extends import_Figure.default {
|
|
|
41
41
|
return url.host;
|
|
42
42
|
}
|
|
43
43
|
set src(value) {
|
|
44
|
-
const url = new URL(value);
|
|
44
|
+
const url = new URL(value, window.location.origin);
|
|
45
45
|
url.host = this.domain;
|
|
46
46
|
const width = normalizeSize(this, "offsetWidth");
|
|
47
47
|
const height = normalizeSize(this, "offsetHeight");
|
|
@@ -22,6 +22,10 @@ export default class FigureTwicPics extends Figure {
|
|
|
22
22
|
lazy: BooleanConstructor;
|
|
23
23
|
};
|
|
24
24
|
refs: string[];
|
|
25
|
+
debug?: boolean;
|
|
26
|
+
log?: boolean;
|
|
27
|
+
emits?: string[];
|
|
28
|
+
components?: import("@studiometa/js-toolkit/Base/index.js").BaseConfigComponents;
|
|
25
29
|
};
|
|
26
30
|
/**
|
|
27
31
|
* Get the TwicPics domain.
|
|
@@ -43,6 +47,7 @@ export type FigureTwicPicsInterface = FigureTwicPics & FigureInterface & {
|
|
|
43
47
|
$options: {
|
|
44
48
|
transform: string;
|
|
45
49
|
step: number;
|
|
50
|
+
mode: string;
|
|
46
51
|
};
|
|
47
52
|
};
|
|
48
53
|
import Figure from "./Figure.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import e from"./Figure.js";function o(i,s){const{step:t}=i.$options;return Math.ceil(i.$refs.img[s]/t)*t}class c extends e{static config={...e.config,name:"FigureTwicPics",options:{...e.config.options,transform:String,step:{type:Number,default:50},mode:{type:String,default:"cover"}}};get domain(){return new URL(this.$refs.img.dataset.src).host}set src(s){const t=new URL(s,window.location.origin);t.host=this.domain;const r=o(this,"offsetWidth"),n=o(this,"offsetHeight");t.searchParams.set("twic",["v1",this.$options.transform,`${this.$options.mode}=${r}x${n}`].filter(Boolean).join("/")),t.search=decodeURIComponent(t.search),super.src=t.toString()}resized(){this.src=this.$refs.img.dataset.src}}export{c as default};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var __publicField = (obj, key, value) => {
|
|
20
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// packages/ui/atoms/ScrollReveal/ScrollReveal.js
|
|
25
|
+
var ScrollReveal_exports = {};
|
|
26
|
+
__export(ScrollReveal_exports, {
|
|
27
|
+
default: () => ScrollReveal
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(ScrollReveal_exports);
|
|
30
|
+
var import_js_toolkit = require("@studiometa/js-toolkit");
|
|
31
|
+
var import_primitives = require("../../primitives/index.cjs");
|
|
32
|
+
var _ScrollReveal = class extends (0, import_js_toolkit.withMountWhenInView)(import_primitives.Transition) {
|
|
33
|
+
get target() {
|
|
34
|
+
return this.$refs.target ?? this.$el;
|
|
35
|
+
}
|
|
36
|
+
mounted() {
|
|
37
|
+
if (!this.$options.repeat) {
|
|
38
|
+
this.enter();
|
|
39
|
+
this.$terminate();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const scroll = (0, import_js_toolkit.useScroll)();
|
|
43
|
+
if (!scroll.has("ScrollRevealRepeat")) {
|
|
44
|
+
scroll.add("ScrollRevealRepeat", (props) => {
|
|
45
|
+
_ScrollReveal.scrollDirectionY = props.direction.y;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (_ScrollReveal.scrollDirectionY !== "UP") {
|
|
49
|
+
this.enter();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var ScrollReveal = _ScrollReveal;
|
|
54
|
+
__publicField(ScrollReveal, "config", {
|
|
55
|
+
...import_primitives.Transition.config,
|
|
56
|
+
name: "ScrollReveal",
|
|
57
|
+
refs: ["target"],
|
|
58
|
+
options: {
|
|
59
|
+
...import_primitives.Transition.config.options,
|
|
60
|
+
enterKeep: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
default: true
|
|
63
|
+
},
|
|
64
|
+
repeat: Boolean,
|
|
65
|
+
intersectionObserver: {
|
|
66
|
+
type: Object,
|
|
67
|
+
default: () => ({ threshold: [0, 1] })
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
__publicField(ScrollReveal, "scrollDirectionY", "NONE");
|
|
72
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
declare const ScrollReveal_base: typeof import("@studiometa/js-toolkit").Base & (new (...a: any[]) => {
|
|
2
|
+
readonly target: HTMLElement | HTMLElement[];
|
|
3
|
+
enter(target?: HTMLElement | HTMLElement[]): Promise<void | void[]>; /**
|
|
4
|
+
* Trigger the `enter` transition on mount.
|
|
5
|
+
*
|
|
6
|
+
* @this {ScrollRevealInterface}
|
|
7
|
+
* @returns {void}
|
|
8
|
+
*/
|
|
9
|
+
leave(target?: HTMLElement | HTMLElement[]): Promise<void | void[]>;
|
|
10
|
+
});
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {ScrollReveal & {
|
|
13
|
+
* $refs: {
|
|
14
|
+
* target?: HTMLElement,
|
|
15
|
+
* },
|
|
16
|
+
* $options: {
|
|
17
|
+
* repeat: boolean;
|
|
18
|
+
* }
|
|
19
|
+
* }} ScrollRevealInterface
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* ScrollReveal class.
|
|
23
|
+
*/
|
|
24
|
+
export default class ScrollReveal extends ScrollReveal_base {
|
|
25
|
+
/**
|
|
26
|
+
* Config.
|
|
27
|
+
*/
|
|
28
|
+
static config: {
|
|
29
|
+
name: string;
|
|
30
|
+
refs: string[];
|
|
31
|
+
options: {
|
|
32
|
+
enterKeep: {
|
|
33
|
+
type: BooleanConstructor;
|
|
34
|
+
default: boolean;
|
|
35
|
+
};
|
|
36
|
+
repeat: BooleanConstructor;
|
|
37
|
+
intersectionObserver: {
|
|
38
|
+
type: ObjectConstructor;
|
|
39
|
+
default: () => {
|
|
40
|
+
threshold: number[];
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
debug?: boolean;
|
|
45
|
+
log?: boolean;
|
|
46
|
+
emits?: string[];
|
|
47
|
+
components?: import("@studiometa/js-toolkit/Base/index.js").BaseConfigComponents;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Vertical scroll direction.
|
|
51
|
+
* @type {'UP'|'DOWN'|'NONE'}
|
|
52
|
+
*/
|
|
53
|
+
static scrollDirectionY: 'UP' | 'DOWN' | 'NONE';
|
|
54
|
+
/**
|
|
55
|
+
* Get the transition target.
|
|
56
|
+
*
|
|
57
|
+
* @this {ScrollRevealInterface}
|
|
58
|
+
* @returns {HTMLElement}
|
|
59
|
+
*/
|
|
60
|
+
get target(): HTMLElement;
|
|
61
|
+
/**
|
|
62
|
+
* Trigger the `enter` transition on mount.
|
|
63
|
+
*
|
|
64
|
+
* @this {ScrollRevealInterface}
|
|
65
|
+
* @returns {void}
|
|
66
|
+
*/
|
|
67
|
+
mounted(this: ScrollRevealInterface): void;
|
|
68
|
+
}
|
|
69
|
+
export type ScrollRevealInterface = ScrollReveal & {
|
|
70
|
+
$refs: {
|
|
71
|
+
target?: HTMLElement;
|
|
72
|
+
};
|
|
73
|
+
$options: {
|
|
74
|
+
repeat: boolean;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{withMountWhenInView as i,useScroll as n}from"@studiometa/js-toolkit";import{Transition as t}from"../../primitives/index.js";class e extends i(t){static config={...t.config,name:"ScrollReveal",refs:["target"],options:{...t.config.options,enterKeep:{type:Boolean,default:!0},repeat:Boolean,intersectionObserver:{type:Object,default:()=>({threshold:[0,1]})}}};static scrollDirectionY="NONE";get target(){return this.$refs.target??this.$el}mounted(){if(!this.$options.repeat){this.enter(),this.$terminate();return}const r=n();r.has("ScrollRevealRepeat")||r.add("ScrollRevealRepeat",o=>{e.scrollDirectionY=o.direction.y}),e.scrollDirectionY!=="UP"&&this.enter()}}export{e as default};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
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));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// packages/ui/atoms/ScrollReveal/index.js
|
|
23
|
+
var ScrollReveal_exports = {};
|
|
24
|
+
__export(ScrollReveal_exports, {
|
|
25
|
+
ScrollReveal: () => import_ScrollReveal.default
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(ScrollReveal_exports);
|
|
28
|
+
var import_ScrollReveal = __toESM(require("./ScrollReveal.cjs"), 1);
|
|
29
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ScrollReveal } from "./ScrollReveal.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as a}from"./ScrollReveal.js";export{a as ScrollReveal};
|
package/atoms/index.cjs
CHANGED
|
@@ -32,6 +32,7 @@ module.exports = __toCommonJS(atoms_exports);
|
|
|
32
32
|
__reExport(atoms_exports, require("./Figure/index.cjs"), module.exports);
|
|
33
33
|
__reExport(atoms_exports, require("./Prefetch/index.cjs"), module.exports);
|
|
34
34
|
__reExport(atoms_exports, require("./ScrollAnimation/index.cjs"), module.exports);
|
|
35
|
+
__reExport(atoms_exports, require("./ScrollReveal/index.cjs"), module.exports);
|
|
35
36
|
var import_AnchorScrollTo = __toESM(require("./AnchorScrollTo/AnchorScrollTo.cjs"), 1);
|
|
36
37
|
var import_Cursor = __toESM(require("./Cursor/Cursor.cjs"), 1);
|
|
37
38
|
var import_LargeText = __toESM(require("./LargeText/LargeText.cjs"), 1);
|
package/atoms/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./Figure/index.js";
|
|
2
2
|
export * from "./Prefetch/index.js";
|
|
3
3
|
export * from "./ScrollAnimation/index.js";
|
|
4
|
+
export * from "./ScrollReveal/index.js";
|
|
4
5
|
export { default as AnchorScrollTo } from "./AnchorScrollTo/AnchorScrollTo.js";
|
|
5
6
|
export { default as Cursor } from "./Cursor/Cursor.js";
|
|
6
7
|
export { default as LargeText } from "./LargeText/LargeText.js";
|
package/atoms/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./Figure/index.js";export*from"./Prefetch/index.js";export*from"./ScrollAnimation/index.js";import{default as
|
|
1
|
+
export*from"./Figure/index.js";export*from"./Prefetch/index.js";export*from"./ScrollAnimation/index.js";export*from"./ScrollReveal/index.js";import{default as x}from"./AnchorScrollTo/AnchorScrollTo.js";import{default as p}from"./Cursor/Cursor.js";import{default as u}from"./LargeText/LargeText.js";import{default as s}from"./LazyInclude/LazyInclude.js";export{x as AnchorScrollTo,p as Cursor,u as LargeText,s as LazyInclude};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
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));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// packages/ui/decorators/index.js
|
|
23
|
+
var decorators_exports = {};
|
|
24
|
+
__export(decorators_exports, {
|
|
25
|
+
withTransition: () => import_withTransition.default
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(decorators_exports);
|
|
28
|
+
var import_withTransition = __toESM(require("./withTransition.cjs"), 1);
|
|
29
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as withTransition } from "./withTransition.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as i}from"./withTransition.js";export{i as withTransition};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/ui/decorators/withTransition.js
|
|
20
|
+
var withTransition_exports = {};
|
|
21
|
+
__export(withTransition_exports, {
|
|
22
|
+
default: () => withTransition
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(withTransition_exports);
|
|
25
|
+
var import_utils = require("@studiometa/js-toolkit/utils");
|
|
26
|
+
function delegateTransition(element, name, endMode) {
|
|
27
|
+
return (0, import_utils.isArray)(element) ? Promise.all(element.map((el) => (0, import_utils.transition)(el, name, endMode))) : (0, import_utils.transition)(element, name, endMode);
|
|
28
|
+
}
|
|
29
|
+
function withTransition(BaseClass) {
|
|
30
|
+
class Transition extends BaseClass {
|
|
31
|
+
static config = {
|
|
32
|
+
name: "Transition",
|
|
33
|
+
options: {
|
|
34
|
+
enterFrom: String,
|
|
35
|
+
enterActive: String,
|
|
36
|
+
enterTo: String,
|
|
37
|
+
enterKeep: Boolean,
|
|
38
|
+
leaveFrom: String,
|
|
39
|
+
leaveActive: String,
|
|
40
|
+
leaveTo: String,
|
|
41
|
+
leaveKeep: Boolean
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
get target() {
|
|
45
|
+
return this.$el;
|
|
46
|
+
}
|
|
47
|
+
enter(target) {
|
|
48
|
+
const { enterFrom, enterActive, enterTo, enterKeep, leaveTo } = this.$options;
|
|
49
|
+
return delegateTransition(target ?? this.target, {
|
|
50
|
+
from: (leaveTo + " " + enterFrom).trim(),
|
|
51
|
+
active: enterActive,
|
|
52
|
+
to: enterTo
|
|
53
|
+
}, enterKeep && "keep");
|
|
54
|
+
}
|
|
55
|
+
leave(target) {
|
|
56
|
+
const { leaveFrom, leaveActive, leaveTo, leaveKeep, enterTo } = this.$options;
|
|
57
|
+
return delegateTransition(target ?? this.target, {
|
|
58
|
+
from: (enterTo + " " + leaveFrom).trim(),
|
|
59
|
+
active: leaveActive,
|
|
60
|
+
to: leaveTo
|
|
61
|
+
}, leaveKeep && "keep");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return Transition;
|
|
65
|
+
}
|
|
66
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {{
|
|
3
|
+
* $options: {
|
|
4
|
+
* enterFrom: string,
|
|
5
|
+
* enterActive: string,
|
|
6
|
+
* enterTo: string,
|
|
7
|
+
* enterKeep: boolean,
|
|
8
|
+
* leaveFrom: string,
|
|
9
|
+
* leaveActive: string,
|
|
10
|
+
* leaveTo: string,
|
|
11
|
+
* leaveKeep: boolean,
|
|
12
|
+
* }
|
|
13
|
+
* }} TransitionInterface
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Extend a class to add transition capabilities.
|
|
17
|
+
* @template {typeof import('@studiometa/js-toolkit').Base} T
|
|
18
|
+
* @param {T} BaseClass
|
|
19
|
+
* @returns {T & {
|
|
20
|
+
* new(...a: any[]): {
|
|
21
|
+
* get target(): HTMLElement|HTMLElement[];
|
|
22
|
+
* enter(target?: HTMLElement|HTMLElement[]): Promise<void|void[]>;
|
|
23
|
+
* leave(target?: HTMLElement|HTMLElement[]): Promise<void|void[]>;
|
|
24
|
+
* }
|
|
25
|
+
* }}
|
|
26
|
+
*/
|
|
27
|
+
export default function withTransition<T extends typeof import("@studiometa/js-toolkit").Base>(BaseClass: T): T & (new (...a: any[]) => {
|
|
28
|
+
readonly target: HTMLElement | HTMLElement[];
|
|
29
|
+
enter(target?: HTMLElement | HTMLElement[]): Promise<void | void[]>;
|
|
30
|
+
leave(target?: HTMLElement | HTMLElement[]): Promise<void | void[]>;
|
|
31
|
+
});
|
|
32
|
+
export type TransitionInterface = {
|
|
33
|
+
$options: {
|
|
34
|
+
enterFrom: string;
|
|
35
|
+
enterActive: string;
|
|
36
|
+
enterTo: string;
|
|
37
|
+
enterKeep: boolean;
|
|
38
|
+
leaveFrom: string;
|
|
39
|
+
leaveActive: string;
|
|
40
|
+
leaveTo: string;
|
|
41
|
+
leaveKeep: boolean;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{transition as v,isArray as g}from"@studiometa/js-toolkit/utils";function c(e,r,n){return g(e)?Promise.all(e.map(t=>v(t,r,n))):v(e,r,n)}function p(e){class r extends e{static config={name:"Transition",options:{enterFrom:String,enterActive:String,enterTo:String,enterKeep:Boolean,leaveFrom:String,leaveActive:String,leaveTo:String,leaveKeep:Boolean}};get target(){return this.$el}enter(t){const{enterFrom:i,enterActive:o,enterTo:a,enterKeep:s,leaveTo:l}=this.$options;return c(t??this.target,{from:(l+" "+i).trim(),active:o,to:a},s&&"keep")}leave(t){const{leaveFrom:i,leaveActive:o,leaveTo:a,leaveKeep:s,enterTo:l}=this.$options;return c(t??this.target,{from:(l+" "+i).trim(),active:o,to:a},s&&"keep")}}return r}export{p as default};
|
package/index.cjs
CHANGED
|
@@ -20,4 +20,5 @@ __reExport(ui_exports, require("./primitives/index.cjs"), module.exports);
|
|
|
20
20
|
__reExport(ui_exports, require("./atoms/index.cjs"), module.exports);
|
|
21
21
|
__reExport(ui_exports, require("./molecules/index.cjs"), module.exports);
|
|
22
22
|
__reExport(ui_exports, require("./organisms/index.cjs"), module.exports);
|
|
23
|
+
__reExport(ui_exports, require("./decorators/index.cjs"), module.exports);
|
|
23
24
|
if (module.exports.default) module.exports = module.exports.default;
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./primitives/index.js";export*from"./atoms/index.js";export*from"./molecules/index.js";export*from"./organisms/index.js";
|
|
1
|
+
export*from"./primitives/index.js";export*from"./atoms/index.js";export*from"./molecules/index.js";export*from"./organisms/index.js";export*from"./decorators/index.js";
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
declare const MenuList_base: typeof import("@studiometa/js-toolkit").Base & (new (...a: any[]) => {
|
|
2
|
+
readonly target: HTMLElement | HTMLElement[];
|
|
3
|
+
enter(target?: HTMLElement | HTMLElement[]): Promise<void | void[]>;
|
|
4
|
+
leave(target?: HTMLElement | HTMLElement[]): Promise<void | void[]>;
|
|
5
|
+
});
|
|
1
6
|
/**
|
|
2
7
|
* @typedef {MenuList & {
|
|
3
8
|
* $children: {
|
|
@@ -8,7 +13,7 @@
|
|
|
8
13
|
/**
|
|
9
14
|
* MenuList class.
|
|
10
15
|
*/
|
|
11
|
-
export default class MenuList extends
|
|
16
|
+
export default class MenuList extends MenuList_base {
|
|
12
17
|
/**
|
|
13
18
|
* Config.
|
|
14
19
|
*/
|
|
@@ -18,16 +23,10 @@ export default class MenuList extends Transition {
|
|
|
18
23
|
components: {
|
|
19
24
|
MenuList: typeof MenuList;
|
|
20
25
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
enterKeep: BooleanConstructor;
|
|
26
|
-
leaveFrom: StringConstructor;
|
|
27
|
-
leaveActive: StringConstructor;
|
|
28
|
-
leaveTo: StringConstructor;
|
|
29
|
-
leaveKeep: BooleanConstructor;
|
|
30
|
-
};
|
|
26
|
+
debug?: boolean;
|
|
27
|
+
log?: boolean;
|
|
28
|
+
refs?: string[];
|
|
29
|
+
options?: import("@studiometa/js-toolkit/Base/managers/OptionsManager.js").OptionsSchema;
|
|
31
30
|
};
|
|
32
31
|
/**
|
|
33
32
|
* Are the menu items visible?
|
|
@@ -97,4 +96,4 @@ export type MenuListInterface = MenuList & {
|
|
|
97
96
|
MenuList: MenuList[];
|
|
98
97
|
};
|
|
99
98
|
};
|
|
100
|
-
|
|
99
|
+
export {};
|
|
@@ -53,6 +53,7 @@ var Slider = class extends import_js_toolkit.Base {
|
|
|
53
53
|
center: 0,
|
|
54
54
|
right: 0
|
|
55
55
|
};
|
|
56
|
+
hasFocus = false;
|
|
56
57
|
get currentState() {
|
|
57
58
|
return this.states[this.currentIndex];
|
|
58
59
|
}
|
|
@@ -82,15 +83,46 @@ var Slider = class extends import_js_toolkit.Base {
|
|
|
82
83
|
center: originRect.x + originRect.width / 2,
|
|
83
84
|
right: originRect.x + originRect.width
|
|
84
85
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
const states = this.$children.SliderItem.map((item) => ({
|
|
87
|
+
x: {
|
|
88
|
+
left: (item.rect.x - this.origins.left) * -1,
|
|
89
|
+
center: (item.rect.x + item.rect.width / 2 - this.origins.center) * -1,
|
|
90
|
+
right: (item.rect.x + item.rect.width - this.origins.right) * -1
|
|
91
|
+
}
|
|
92
|
+
}));
|
|
93
|
+
if (this.$options.contain) {
|
|
94
|
+
const { mode } = this.$options;
|
|
95
|
+
if (mode === "left") {
|
|
96
|
+
const lastChild = this.$children.SliderItem.at(-1);
|
|
97
|
+
const maxState = states.find((state) => {
|
|
98
|
+
const lastChildPosition = lastChild.rect.x - this.origins.left + lastChild.rect.width + state.x.left;
|
|
99
|
+
const diffWithWrapperBound = originRect.width - lastChildPosition;
|
|
100
|
+
if (diffWithWrapperBound > 0) {
|
|
101
|
+
state.x.left = Math.min(state.x.left + diffWithWrapperBound, 0);
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
return false;
|
|
105
|
+
});
|
|
106
|
+
if (maxState) {
|
|
107
|
+
return states.map((state) => {
|
|
108
|
+
state.x.left = Math.max(state.x.left, maxState.x.left);
|
|
109
|
+
return state;
|
|
110
|
+
});
|
|
91
111
|
}
|
|
92
|
-
}
|
|
93
|
-
|
|
112
|
+
}
|
|
113
|
+
if (mode === "right") {
|
|
114
|
+
const maxStateIndex = states.findIndex((state) => state.x.right <= 0);
|
|
115
|
+
const maxState = maxStateIndex < 0 ? states.at(-1) : states[maxStateIndex - 1];
|
|
116
|
+
return states.map((state) => {
|
|
117
|
+
state.x.right = maxStateIndex < 0 ? maxState.x.right : Math.min(state.x.right, 0);
|
|
118
|
+
return state;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
if (mode === "center" && import_utils.isDev) {
|
|
122
|
+
console.warn(`[${this.$id}]`, "The `center` mode is not yet compatible with the `contain` mode.");
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return states;
|
|
94
126
|
}
|
|
95
127
|
getOriginByMode(mode) {
|
|
96
128
|
return this.origins[mode ?? this.$options.mode];
|
|
@@ -128,21 +160,19 @@ var Slider = class extends import_js_toolkit.Base {
|
|
|
128
160
|
if (index < 0 || index > this.indexMax) {
|
|
129
161
|
throw new Error("Index out of bound.");
|
|
130
162
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (this.$children.SliderItem[this.indexMax].willBeFullyVisible(state)) {
|
|
134
|
-
state = this.getStateValueByMode(this.lastState.x, "right");
|
|
135
|
-
} else if (this.$children.SliderItem[0].willBeFullyVisible(state)) {
|
|
136
|
-
state = this.getStateValueByMode(this.firstState.x, "left");
|
|
137
|
-
}
|
|
138
|
-
}
|
|
163
|
+
const currentState = this.getStateValueByMode(this.currentState.x);
|
|
164
|
+
const state = this.getStateValueByMode(this.states[index].x);
|
|
139
165
|
const itemsToMove = this.getVisibleItems(state);
|
|
140
|
-
|
|
141
|
-
itemsToMove.reverse();
|
|
142
|
-
}
|
|
166
|
+
const invisibleItemsToMoveInstantly = this.getInvisibleItems(state);
|
|
143
167
|
itemsToMove.forEach((item) => {
|
|
168
|
+
if (currentState !== state) {
|
|
169
|
+
item.moveInstantly(currentState);
|
|
170
|
+
}
|
|
144
171
|
(0, import_utils.nextFrame)(() => item.move(state));
|
|
145
172
|
});
|
|
173
|
+
invisibleItemsToMoveInstantly.forEach((item) => {
|
|
174
|
+
item.moveInstantly(state);
|
|
175
|
+
});
|
|
146
176
|
this.currentIndex = index;
|
|
147
177
|
this.$emit("goto", index);
|
|
148
178
|
}
|
|
@@ -162,7 +192,7 @@ var Slider = class extends import_js_toolkit.Base {
|
|
|
162
192
|
if (Math.abs(props.delta.y) > Math.abs(props.delta.x)) {
|
|
163
193
|
return;
|
|
164
194
|
}
|
|
165
|
-
let finalX = (0, import_utils.clamp)((0, import_utils.inertiaFinalValue)(this.__distanceX, props.delta.x * this.$options.
|
|
195
|
+
let finalX = (0, import_utils.clamp)((0, import_utils.inertiaFinalValue)(this.__distanceX, props.delta.x * this.$options.dropSensitivity), 0, this.getStateValueByMode(this.lastState.x));
|
|
166
196
|
const absoluteDifferencesBetweenDistanceAndState = this.states.map((state) => Math.abs(finalX - this.getStateValueByMode(state.x)));
|
|
167
197
|
const minimumDifference = Math.min(...absoluteDifferencesBetweenDistanceAndState);
|
|
168
198
|
const closestIndex = absoluteDifferencesBetweenDistanceAndState.findIndex((number) => number === minimumDifference);
|
|
@@ -179,6 +209,21 @@ var Slider = class extends import_js_toolkit.Base {
|
|
|
179
209
|
this.currentIndex = closestIndex;
|
|
180
210
|
}
|
|
181
211
|
}
|
|
212
|
+
onWrapperFocus() {
|
|
213
|
+
this.hasFocus = true;
|
|
214
|
+
}
|
|
215
|
+
onWrapperBlur() {
|
|
216
|
+
this.hasFocus = false;
|
|
217
|
+
}
|
|
218
|
+
keyed({ LEFT, RIGHT, isDown }) {
|
|
219
|
+
if (this.hasFocus && isDown) {
|
|
220
|
+
if (LEFT) {
|
|
221
|
+
this.goPrev();
|
|
222
|
+
} else if (RIGHT) {
|
|
223
|
+
this.goNext();
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
182
227
|
prepareInvisibleItems() {
|
|
183
228
|
const state = this.states[this.currentIndex];
|
|
184
229
|
const nextItemsToPrepare = [];
|
|
@@ -222,7 +267,7 @@ var Slider = class extends import_js_toolkit.Base {
|
|
|
222
267
|
};
|
|
223
268
|
__publicField(Slider, "config", {
|
|
224
269
|
name: "Slider",
|
|
225
|
-
refs: ["wrapper"],
|
|
270
|
+
refs: ["wrapper", "debug"],
|
|
226
271
|
emits: ["goto", "index"],
|
|
227
272
|
components: {
|
|
228
273
|
SliderItem: import_SliderItem.default,
|
|
@@ -232,7 +277,8 @@ __publicField(Slider, "config", {
|
|
|
232
277
|
mode: { type: String, default: "left" },
|
|
233
278
|
fitBounds: Boolean,
|
|
234
279
|
contain: Boolean,
|
|
235
|
-
sensitivity: { type: Number, default: 1 }
|
|
280
|
+
sensitivity: { type: Number, default: 1 },
|
|
281
|
+
dropSensitivity: { type: Number, default: 2 }
|
|
236
282
|
}
|
|
237
283
|
});
|
|
238
284
|
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
/**
|
|
26
26
|
* Orchestrate the slider items state transition.
|
|
27
27
|
* @todo a11y
|
|
28
|
-
* @todo better state management with `mode` option
|
|
29
28
|
*/
|
|
30
29
|
export default class Slider extends Base {
|
|
31
30
|
/**
|
|
@@ -50,6 +49,10 @@ export default class Slider extends Base {
|
|
|
50
49
|
type: NumberConstructor;
|
|
51
50
|
default: number;
|
|
52
51
|
};
|
|
52
|
+
dropSensitivity: {
|
|
53
|
+
type: NumberConstructor;
|
|
54
|
+
default: number;
|
|
55
|
+
};
|
|
53
56
|
};
|
|
54
57
|
};
|
|
55
58
|
__distanceX: number;
|
|
@@ -80,6 +83,11 @@ export default class Slider extends Base {
|
|
|
80
83
|
* @type {Record<SliderModes, number>}
|
|
81
84
|
*/
|
|
82
85
|
origins: Record<SliderModes, number>;
|
|
86
|
+
/**
|
|
87
|
+
* Wether or not the wrapper is focused.
|
|
88
|
+
* @type {boolean}
|
|
89
|
+
*/
|
|
90
|
+
hasFocus: boolean;
|
|
83
91
|
/**
|
|
84
92
|
* Get the current state.
|
|
85
93
|
* @returns {SliderState}
|
|
@@ -122,7 +130,6 @@ export default class Slider extends Base {
|
|
|
122
130
|
/**
|
|
123
131
|
* Get the states for each SliderItem.
|
|
124
132
|
*
|
|
125
|
-
* @todo save value for every available modes to avoid recalculation when switching
|
|
126
133
|
* @this {SliderInterface}
|
|
127
134
|
*/
|
|
128
135
|
getStates(this: SliderInterface): {
|
|
@@ -199,6 +206,22 @@ export default class Slider extends Base {
|
|
|
199
206
|
* @returns {void}
|
|
200
207
|
*/
|
|
201
208
|
onSliderDragDrop(this: SliderInterface, props: import('@studiometa/js-toolkit/services/drag').DragServiceProps): void;
|
|
209
|
+
/**
|
|
210
|
+
* Enable focus.
|
|
211
|
+
* @returns {void}
|
|
212
|
+
*/
|
|
213
|
+
onWrapperFocus(): void;
|
|
214
|
+
/**
|
|
215
|
+
* Disable focus.
|
|
216
|
+
* @returns {void}
|
|
217
|
+
*/
|
|
218
|
+
onWrapperBlur(): void;
|
|
219
|
+
/**
|
|
220
|
+
* Go prev or next when focus is on the wrapper and pressing arrow keys.
|
|
221
|
+
* @param {import('@studiometa/js-toolkit/services/key').KeyServiceProps} props
|
|
222
|
+
* @returns {void}
|
|
223
|
+
*/
|
|
224
|
+
keyed({ LEFT, RIGHT, isDown }: import('@studiometa/js-toolkit/services/key').KeyServiceProps): void;
|
|
202
225
|
/**
|
|
203
226
|
* Prepare invisible items.
|
|
204
227
|
* @returns {void}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Base as
|
|
1
|
+
import{Base as d}from"@studiometa/js-toolkit";import{clamp as c,inertiaFinalValue as u,nextFrame as h,isDev as f}from"@studiometa/js-toolkit/utils";import x from"./SliderDrag.js";import g from"./SliderItem.js";class I extends d{static config={name:"Slider",refs:["wrapper","debug"],emits:["goto","index"],components:{SliderItem:g,SliderDrag:x},options:{mode:{type:String,default:"left"},fitBounds:Boolean,contain:Boolean,sensitivity:{type:Number,default:1},dropSensitivity:{type:Number,default:2}}};__distanceX=0;__initialX=0;__currentIndex=0;get currentIndex(){return this.__currentIndex}set currentIndex(e){this.currentSliderItem.disactivate(),this.$emit("index",e),this.__currentIndex=e,this.currentSliderItem.activate()}states=[];origins={left:0,center:0,right:0};hasFocus=!1;get currentState(){return this.states[this.currentIndex]}get firstState(){return this.states[0]}get lastState(){return this.states[this.states.length-1]}get containMinState(){return this.getStateValueByMode(this.firstState.x,"left")}get containMaxState(){return this.getStateValueByMode(this.lastState.x,"right")}get indexMax(){return this.$children.SliderItem.length-1}get currentSliderItem(){return this.$children.SliderItem[this.currentIndex]}getStates(){const{wrapper:e}=this.$refs,t=e.getBoundingClientRect();this.origins={left:t.left,center:t.x+t.width/2,right:t.x+t.width};const i=this.$children.SliderItem.map(s=>({x:{left:(s.rect.x-this.origins.left)*-1,center:(s.rect.x+s.rect.width/2-this.origins.center)*-1,right:(s.rect.x+s.rect.width-this.origins.right)*-1}}));if(this.$options.contain){const{mode:s}=this.$options;if(s==="left"){const n=this.$children.SliderItem.at(-1),r=i.find(a=>{const o=n.rect.x-this.origins.left+n.rect.width+a.x.left,l=t.width-o;return l>0?(a.x.left=Math.min(a.x.left+l,0),!0):!1});if(r)return i.map(a=>(a.x.left=Math.max(a.x.left,r.x.left),a))}if(s==="right"){const n=i.findIndex(a=>a.x.right<=0),r=n<0?i.at(-1):i[n-1];return i.map(a=>(a.x.right=n<0?r.x.right:Math.min(a.x.right,0),a))}s==="center"&&f&&console.warn(`[${this.$id}]`,"The `center` mode is not yet compatible with the `contain` mode.")}return i}getOriginByMode(e){return this.origins[e??this.$options.mode]}getStateValueByMode(e,t){return e[t??this.$options.mode]}mounted(){this.states=this.getStates(),this.prepareInvisibleItems(),this.goTo(this.currentIndex)}resized(){h(()=>{this.states=this.getStates(),h(()=>{this.prepareInvisibleItems(),this.goTo(this.currentIndex)})})}goNext(){this.currentIndex+1>this.indexMax||this.goTo(this.currentIndex+1)}goPrev(){this.currentIndex-1<0||this.goTo(this.currentIndex-1)}goTo(e){if(e<0||e>this.indexMax)throw new Error("Index out of bound.");const t=this.getStateValueByMode(this.currentState.x),i=this.getStateValueByMode(this.states[e].x),s=this.getVisibleItems(i),n=this.getInvisibleItems(i);s.forEach(r=>{t!==i&&r.moveInstantly(t),h(()=>r.move(i))}),n.forEach(r=>{r.moveInstantly(i)}),this.currentIndex=e,this.$emit("goto",e)}onSliderDragStart(){this.__initialX=this.currentSliderItem?this.currentSliderItem.x:0}onSliderDragDrag(e){Math.abs(e.delta.y)>Math.abs(e.delta.x)||(this.__distanceX=this.__initialX+e.distance.x*this.$options.sensitivity,this.getVisibleItems(this.__distanceX).forEach(t=>{t.moveInstantly(this.__distanceX)}))}onSliderDragDrop(e){if(Math.abs(e.delta.y)>Math.abs(e.delta.x))return;let t=c(u(this.__distanceX,e.delta.x*this.$options.dropSensitivity),0,this.getStateValueByMode(this.lastState.x));const i=this.states.map(r=>Math.abs(t-this.getStateValueByMode(r.x))),s=Math.min(...i),n=i.findIndex(r=>r===s);this.$options.fitBounds?this.goTo(n):(this.$options.contain&&(t=Math.min(this.containMinState,t),t=Math.max(this.containMaxState,t)),this.$children.SliderItem.forEach(r=>{r.move(t)}),this.currentIndex=n)}onWrapperFocus(){this.hasFocus=!0}onWrapperBlur(){this.hasFocus=!1}keyed({LEFT:e,RIGHT:t,isDown:i}){this.hasFocus&&i&&(e?this.goPrev():t&&this.goNext())}prepareInvisibleItems(){const e=this.states[this.currentIndex],t=[],i=[];this.getInvisibleItems(this.getStateValueByMode(e.x)).forEach((s,n)=>{if(n>this.currentIndex){t.push(s);return}n<this.currentIndex&&i.push(s)}),t.forEach(s=>{const n=this.getStateWhereItemWillBeInvisible(s);n&&s.moveInstantly(this.getStateValueByMode(n.x))}),i.forEach(s=>{const n=this.getStateWhereItemWillBeInvisible(s,{reversed:!0});n&&s.moveInstantly(this.getStateValueByMode(n.x))})}getStateWhereItemWillBeInvisible(e,{reversed:t=!1}={}){const i=this.states.filter(o=>e.willBeVisible(this.getStateValueByMode(o.x))),s=i[0],n=i[i.length-1],r=this.states.findIndex(o=>this.getStateValueByMode(o.x)===this.getStateValueByMode(s.x)),a=this.states.findIndex(o=>o.x===n.x);return t?this.states[a+1]:this.states[r-1]}getVisibleItems(e){return this.$children.SliderItem.filter(t=>t.isVisible||t.willBeVisible(e))}getInvisibleItems(e){return this.$children.SliderItem.filter(t=>!t.isVisible&&!t.willBeVisible(e))}}export{I as default};
|
|
@@ -30,12 +30,17 @@ __export(SliderDots_exports, {
|
|
|
30
30
|
default: () => SliderDots
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(SliderDots_exports);
|
|
33
|
+
var import_decorators = require("../../decorators/index.cjs");
|
|
33
34
|
var import_AbstractSliderChild = __toESM(require("./AbstractSliderChild.cjs"), 1);
|
|
34
|
-
var SliderDots = class extends import_AbstractSliderChild.default {
|
|
35
|
+
var SliderDots = class extends (0, import_decorators.withTransition)(import_AbstractSliderChild.default) {
|
|
36
|
+
get target() {
|
|
37
|
+
return this.$refs.dots;
|
|
38
|
+
}
|
|
39
|
+
currentIndex = 0;
|
|
35
40
|
update(index) {
|
|
36
|
-
this.$refs.dots.
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
this.leave(this.$refs.dots[this.currentIndex]);
|
|
42
|
+
this.enter(this.$refs.dots[index]);
|
|
43
|
+
this.currentIndex = index;
|
|
39
44
|
}
|
|
40
45
|
onDotsClick(event, index) {
|
|
41
46
|
this.$parent.goTo(index);
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
declare const SliderDots_base: typeof AbstractSliderChild & (new (...a: any[]) => {
|
|
2
|
+
readonly target: HTMLElement | HTMLElement[];
|
|
3
|
+
enter(target?: HTMLElement | HTMLElement[]): Promise<void | void[]>;
|
|
4
|
+
leave(target?: HTMLElement | HTMLElement[]): Promise<void | void[]>;
|
|
5
|
+
});
|
|
1
6
|
/**
|
|
2
7
|
* @typedef {SliderDots & {
|
|
3
8
|
* $refs: {
|
|
@@ -8,7 +13,7 @@
|
|
|
8
13
|
/**
|
|
9
14
|
* SliderDots class.
|
|
10
15
|
*/
|
|
11
|
-
export default class SliderDots extends
|
|
16
|
+
export default class SliderDots extends SliderDots_base {
|
|
12
17
|
/**
|
|
13
18
|
* Config.
|
|
14
19
|
*/
|
|
@@ -16,6 +21,17 @@ export default class SliderDots extends AbstractSliderChild {
|
|
|
16
21
|
name: string;
|
|
17
22
|
refs: string[];
|
|
18
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Get target.
|
|
26
|
+
* @this {SliderDotsInterface}
|
|
27
|
+
* @returns {HTMLButtonElement[]}
|
|
28
|
+
*/
|
|
29
|
+
get target(): HTMLButtonElement[];
|
|
30
|
+
/**
|
|
31
|
+
* The current active index.
|
|
32
|
+
* @type {number}
|
|
33
|
+
*/
|
|
34
|
+
currentIndex: number;
|
|
19
35
|
/**
|
|
20
36
|
* Update dots classes according to the new index.
|
|
21
37
|
*
|
|
@@ -39,3 +55,4 @@ export type SliderDotsInterface = SliderDots & {
|
|
|
39
55
|
};
|
|
40
56
|
};
|
|
41
57
|
import AbstractSliderChild from "./AbstractSliderChild.js";
|
|
58
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{withTransition as r}from"../../decorators/index.js";import s from"./AbstractSliderChild.js";class i extends r(s){static config={name:"SliderDots",refs:["dots[]"]};get target(){return this.$refs.dots}currentIndex=0;update(t){this.leave(this.$refs.dots[this.currentIndex]),this.enter(this.$refs.dots[t]),this.currentIndex=t}onDotsClick(t,e){this.$parent.goTo(e)}}export{i as default};
|
|
@@ -29,6 +29,15 @@ __export(SliderDrag_exports, {
|
|
|
29
29
|
module.exports = __toCommonJS(SliderDrag_exports);
|
|
30
30
|
var import_js_toolkit = require("@studiometa/js-toolkit");
|
|
31
31
|
var SliderDrag = class extends (0, import_js_toolkit.withDrag)(import_js_toolkit.Base) {
|
|
32
|
+
get shouldPreventScroll() {
|
|
33
|
+
const { distance } = this.$services.get("dragged");
|
|
34
|
+
return Math.abs(distance.x) > this.$options.scrollLockThreshold && Math.abs(distance.x) > Math.abs(distance.y);
|
|
35
|
+
}
|
|
36
|
+
onTouchmove(event) {
|
|
37
|
+
if (this.shouldPreventScroll) {
|
|
38
|
+
event.preventDefault();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
32
41
|
dragged(props) {
|
|
33
42
|
this.$emit(props.mode, props);
|
|
34
43
|
}
|
|
@@ -36,9 +45,11 @@ var SliderDrag = class extends (0, import_js_toolkit.withDrag)(import_js_toolkit
|
|
|
36
45
|
__publicField(SliderDrag, "config", {
|
|
37
46
|
name: "SliderDrag",
|
|
38
47
|
emits: ["start", "drag", "drop", "inertia", "stop"],
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
48
|
+
options: {
|
|
49
|
+
scrollLockThreshold: {
|
|
50
|
+
type: Number,
|
|
51
|
+
default: 10
|
|
52
|
+
}
|
|
42
53
|
}
|
|
43
54
|
});
|
|
44
55
|
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {SliderDrag & {
|
|
3
|
+
* $options: {
|
|
4
|
+
* scrollLockThreshold: number;
|
|
5
|
+
* }
|
|
6
|
+
* }} SliderDragInterface
|
|
7
|
+
*/
|
|
1
8
|
/**
|
|
2
9
|
* SliderDrag class.
|
|
3
10
|
*/
|
|
@@ -8,11 +15,27 @@ export default class SliderDrag extends Base {
|
|
|
8
15
|
static config: {
|
|
9
16
|
name: string;
|
|
10
17
|
emits: string[];
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
18
|
+
options: {
|
|
19
|
+
scrollLockThreshold: {
|
|
20
|
+
type: NumberConstructor;
|
|
21
|
+
default: number;
|
|
22
|
+
};
|
|
14
23
|
};
|
|
15
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Test if the scroll should be blocked. Used with the touchmove event to prevent
|
|
27
|
+
* scrolling vertically when trying to drag the slider.
|
|
28
|
+
*
|
|
29
|
+
* @this {SliderDragInterface}
|
|
30
|
+
* @returns {boolean}
|
|
31
|
+
*/
|
|
32
|
+
get shouldPreventScroll(): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Touchmove handler.
|
|
35
|
+
* @param {TouchEvent} event
|
|
36
|
+
* @returns {void}
|
|
37
|
+
*/
|
|
38
|
+
onTouchmove(event: TouchEvent): void;
|
|
16
39
|
/**
|
|
17
40
|
* Emit drag events.
|
|
18
41
|
* @param {import('@studiometa/js-toolkit/services/drag').DragServiceProps} props
|
|
@@ -20,4 +43,9 @@ export default class SliderDrag extends Base {
|
|
|
20
43
|
*/
|
|
21
44
|
dragged(props: import('@studiometa/js-toolkit/services/drag').DragServiceProps): void;
|
|
22
45
|
}
|
|
46
|
+
export type SliderDragInterface = SliderDrag & {
|
|
47
|
+
$options: {
|
|
48
|
+
scrollLockThreshold: number;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
23
51
|
import { Base } from "@studiometa/js-toolkit";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Base as
|
|
1
|
+
import{Base as t,withDrag as r}from"@studiometa/js-toolkit";class s extends r(t){static config={name:"SliderDrag",emits:["start","drag","drop","inertia","stop"],options:{scrollLockThreshold:{type:Number,default:10}}};get shouldPreventScroll(){const{distance:e}=this.$services.get("dragged");return Math.abs(e.x)>this.$options.scrollLockThreshold&&Math.abs(e.x)>Math.abs(e.y)}onTouchmove(e){this.shouldPreventScroll&&e.preventDefault()}dragged(e){this.$emit(e.mode,e)}}export{s as default};
|
|
@@ -56,7 +56,7 @@ var SliderItem = class extends (0, import_js_toolkit.withIntersectionObserver)(i
|
|
|
56
56
|
this.isVisible = isIntersecting;
|
|
57
57
|
}
|
|
58
58
|
ticked() {
|
|
59
|
-
this.dampedX = (0, import_utils.damp)(this.x, this.dampedX, 0.
|
|
59
|
+
this.dampedX = (0, import_utils.damp)(this.x, this.dampedX, 0.1, 1e-5);
|
|
60
60
|
this.render();
|
|
61
61
|
if (this.dampedX === this.x) {
|
|
62
62
|
this.$services.disable("ticked");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Base as t,withIntersectionObserver as s}from"@studiometa/js-toolkit";import{damp as d,domScheduler as h,transform as r}from"@studiometa/js-toolkit/utils";class l extends s(t,{threshold:[0,1]}){static config={name:"SliderItem",emits:["is-fully-visible","is-partially-visible","is-hidden"]};isVisible=!1;x=0;dampedX=0;mounted(){this.updateRectAdjustedWithX()}resized(){this.updateRectAdjustedWithX()}destroyed(){this.moveInstantly(0)}intersected([{intersectionRatio:e,isIntersecting:i}]){e>=1?(this.$emit("is-fully-visible"),this.$el.setAttribute("aria-hidden","false")):e>0?(this.$emit("is-partially-visible"),this.$el.setAttribute("aria-hidden","true")):(this.$emit("is-hidden"),this.$el.setAttribute("aria-hidden","true")),this.isVisible=i}ticked(){this.dampedX=d(this.x,this.dampedX,.
|
|
1
|
+
import{Base as t,withIntersectionObserver as s}from"@studiometa/js-toolkit";import{damp as d,domScheduler as h,transform as r}from"@studiometa/js-toolkit/utils";class l extends s(t,{threshold:[0,1]}){static config={name:"SliderItem",emits:["is-fully-visible","is-partially-visible","is-hidden"]};isVisible=!1;x=0;dampedX=0;mounted(){this.updateRectAdjustedWithX()}resized(){this.updateRectAdjustedWithX()}destroyed(){this.moveInstantly(0)}intersected([{intersectionRatio:e,isIntersecting:i}]){e>=1?(this.$emit("is-fully-visible"),this.$el.setAttribute("aria-hidden","false")):e>0?(this.$emit("is-partially-visible"),this.$el.setAttribute("aria-hidden","true")):(this.$emit("is-hidden"),this.$el.setAttribute("aria-hidden","true")),this.isVisible=i}ticked(){this.dampedX=d(this.x,this.dampedX,.1,1e-5),this.render(),this.dampedX===this.x&&this.$services.disable("ticked")}activate(){this.$el.classList.add("is-active")}disactivate(){this.$el.classList.remove("is-active")}move(e){this.x=e,this.$services.has("ticked")||this.$services.enable("ticked")}moveInstantly(e){this.x=e,this.dampedX=e,this.render()}render(){h.write(()=>{r(this.$el,{x:this.dampedX})})}willBeVisible(e){return this.rect.x+e<window.innerWidth*1.5&&this.rect.x+e+this.rect.width>window.innerWidth*-.5}willBeFullyVisible(e){return this.rect.x+e<window.innerWidth&&this.rect.x+e>0&&this.rect.x+e+this.rect.width<window.innerWidth&&this.rect.x+e+this.rect.width>0}updateRectAdjustedWithX(){const e=this.x*-1,i=this.$el.getBoundingClientRect().toJSON();this.rect={...i,left:i.left+e,right:i.left+e+i.width,x:i.left+e}}}export{l as default};
|
|
@@ -35,11 +35,10 @@ var import_AbstractSliderChild = __toESM(require("./AbstractSliderChild.cjs"), 1
|
|
|
35
35
|
var SliderProgress = class extends import_AbstractSliderChild.default {
|
|
36
36
|
update(index) {
|
|
37
37
|
import_utils.domScheduler.read(() => {
|
|
38
|
-
const
|
|
38
|
+
const { progress } = this.$refs;
|
|
39
|
+
const x = (0, import_utils.map)(index, 0, this.$parent.indexMax, progress.clientWidth * -1, 0);
|
|
39
40
|
import_utils.domScheduler.write(() => {
|
|
40
|
-
|
|
41
|
-
translateX: (0, import_utils.map)(index, 0, this.$parent.indexMax, (this.$refs.progress.clientWidth - unit) * -1, 0)
|
|
42
|
-
});
|
|
41
|
+
(0, import_utils.transform)(progress, { x });
|
|
43
42
|
});
|
|
44
43
|
});
|
|
45
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{transform as i,map as o,domScheduler as e}from"@studiometa/js-toolkit/utils";import d from"./AbstractSliderChild.js";class a extends d{static config={name:"SliderProgress",refs:["progress"]};update(s){e.read(()=>{const{progress:r}=this.$refs,t=o(s,0,this.$parent.indexMax,r.clientWidth*-1,0);e.write(()=>{i(r,{x:t})})})}}export{a as default};
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
declare const FrameTarget_base: typeof import("@studiometa/js-toolkit").Base & (new (...a: any[]) => {
|
|
2
|
+
readonly target: HTMLElement | HTMLElement[];
|
|
3
|
+
enter(target?: HTMLElement | HTMLElement[]): Promise<void | void[]>;
|
|
4
|
+
leave(target?: HTMLElement | HTMLElement[]): Promise<void | void[]>;
|
|
5
|
+
});
|
|
1
6
|
/**
|
|
2
7
|
* FrameTarget class.
|
|
3
8
|
*/
|
|
4
|
-
export default class FrameTarget extends
|
|
9
|
+
export default class FrameTarget extends FrameTarget_base {
|
|
5
10
|
/**
|
|
6
11
|
* Config.
|
|
7
12
|
*/
|
|
@@ -14,15 +19,11 @@ export default class FrameTarget extends Transition {
|
|
|
14
19
|
default: string;
|
|
15
20
|
};
|
|
16
21
|
id: StringConstructor;
|
|
17
|
-
enterFrom: StringConstructor;
|
|
18
|
-
enterActive: StringConstructor;
|
|
19
|
-
enterTo: StringConstructor;
|
|
20
|
-
enterKeep: BooleanConstructor;
|
|
21
|
-
leaveFrom: StringConstructor;
|
|
22
|
-
leaveActive: StringConstructor;
|
|
23
|
-
leaveTo: StringConstructor;
|
|
24
|
-
leaveKeep: BooleanConstructor;
|
|
25
22
|
};
|
|
23
|
+
debug?: boolean;
|
|
24
|
+
refs?: string[];
|
|
25
|
+
emits?: string[];
|
|
26
|
+
components?: import("@studiometa/js-toolkit/Base/index.js").BaseConfigComponents;
|
|
26
27
|
};
|
|
27
28
|
/**
|
|
28
29
|
* Insert modes.
|
|
@@ -36,6 +37,11 @@ export default class FrameTarget extends Transition {
|
|
|
36
37
|
* @returns {string}
|
|
37
38
|
*/
|
|
38
39
|
get id(): string;
|
|
40
|
+
/**
|
|
41
|
+
* Enter transition.
|
|
42
|
+
* @returns {Promise<void>}
|
|
43
|
+
*/
|
|
44
|
+
enter(): Promise<void>;
|
|
39
45
|
/**
|
|
40
46
|
* Update the content from the new target.
|
|
41
47
|
*
|
|
@@ -44,4 +50,4 @@ export default class FrameTarget extends Transition {
|
|
|
44
50
|
*/
|
|
45
51
|
updateContent(newTarget: FrameTarget): void;
|
|
46
52
|
}
|
|
47
|
-
|
|
53
|
+
export {};
|
package/package.json
CHANGED
|
@@ -2,7 +2,6 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
5
|
var __export = (target, all) => {
|
|
7
6
|
for (var name in all)
|
|
8
7
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -16,51 +15,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
15
|
return to;
|
|
17
16
|
};
|
|
18
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var __publicField = (obj, key, value) => {
|
|
20
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
|
-
return value;
|
|
22
|
-
};
|
|
23
18
|
|
|
24
19
|
// packages/ui/primitives/Transition/Transition.js
|
|
25
20
|
var Transition_exports = {};
|
|
26
21
|
__export(Transition_exports, {
|
|
27
|
-
default: () =>
|
|
22
|
+
default: () => Transition_default
|
|
28
23
|
});
|
|
29
24
|
module.exports = __toCommonJS(Transition_exports);
|
|
30
25
|
var import_js_toolkit = require("@studiometa/js-toolkit");
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
get target() {
|
|
34
|
-
return this.$el;
|
|
35
|
-
}
|
|
36
|
-
enter() {
|
|
37
|
-
const { enterFrom, enterActive, enterTo, enterKeep, leaveTo } = this.$options;
|
|
38
|
-
return (0, import_utils.transition)(this.target, {
|
|
39
|
-
from: (leaveTo + " " + enterFrom).trim(),
|
|
40
|
-
active: enterActive,
|
|
41
|
-
to: enterTo
|
|
42
|
-
}, enterKeep && "keep");
|
|
43
|
-
}
|
|
44
|
-
leave() {
|
|
45
|
-
const { leaveFrom, leaveActive, leaveTo, leaveKeep, enterTo } = this.$options;
|
|
46
|
-
return (0, import_utils.transition)(this.target, {
|
|
47
|
-
from: (enterTo + " " + leaveFrom).trim(),
|
|
48
|
-
active: leaveActive,
|
|
49
|
-
to: leaveTo
|
|
50
|
-
}, leaveKeep && "keep");
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
__publicField(Transition, "config", {
|
|
54
|
-
name: "Transition",
|
|
55
|
-
options: {
|
|
56
|
-
enterFrom: String,
|
|
57
|
-
enterActive: String,
|
|
58
|
-
enterTo: String,
|
|
59
|
-
enterKeep: Boolean,
|
|
60
|
-
leaveFrom: String,
|
|
61
|
-
leaveActive: String,
|
|
62
|
-
leaveTo: String,
|
|
63
|
-
leaveKeep: Boolean
|
|
64
|
-
}
|
|
65
|
-
});
|
|
26
|
+
var import_decorators = require("../../decorators/index.cjs");
|
|
27
|
+
var Transition_default = (0, import_decorators.withTransition)(import_js_toolkit.Base);
|
|
66
28
|
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1,67 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* @property {string} leaveFrom
|
|
8
|
-
* @property {string} leaveActive
|
|
9
|
-
* @property {string} leaveTo
|
|
10
|
-
* @property {boolean} leaveKeep
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* Transition class.
|
|
14
|
-
* @typedef {Transition & { $options: TransitionOptions }} TransitionInterface
|
|
15
|
-
*/
|
|
16
|
-
export default class Transition extends Base {
|
|
17
|
-
static config: {
|
|
18
|
-
name: string;
|
|
19
|
-
options: {
|
|
20
|
-
enterFrom: StringConstructor;
|
|
21
|
-
enterActive: StringConstructor;
|
|
22
|
-
enterTo: StringConstructor;
|
|
23
|
-
enterKeep: BooleanConstructor;
|
|
24
|
-
leaveFrom: StringConstructor;
|
|
25
|
-
leaveActive: StringConstructor;
|
|
26
|
-
leaveTo: StringConstructor;
|
|
27
|
-
leaveKeep: BooleanConstructor;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Get the transition target.
|
|
32
|
-
*
|
|
33
|
-
* @returns {HTMLElement}
|
|
34
|
-
*/
|
|
35
|
-
get target(): HTMLElement;
|
|
36
|
-
/**
|
|
37
|
-
* Trigger the enter transition.
|
|
38
|
-
*
|
|
39
|
-
* @this {TransitionInterface}
|
|
40
|
-
* @returns {Promise<void>}
|
|
41
|
-
*/
|
|
42
|
-
enter(this: TransitionInterface): Promise<void>;
|
|
43
|
-
/**
|
|
44
|
-
* Trigger the leave transition.
|
|
45
|
-
*
|
|
46
|
-
* @this {TransitionInterface}
|
|
47
|
-
* @returns {Promise<void>}
|
|
48
|
-
*/
|
|
49
|
-
leave(this: TransitionInterface): Promise<void>;
|
|
50
|
-
}
|
|
51
|
-
export type TransitionOptions = {
|
|
52
|
-
enterFrom: string;
|
|
53
|
-
enterActive: string;
|
|
54
|
-
enterTo: string;
|
|
55
|
-
enterKeep: boolean;
|
|
56
|
-
leaveFrom: string;
|
|
57
|
-
leaveActive: string;
|
|
58
|
-
leaveTo: string;
|
|
59
|
-
leaveKeep: boolean;
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* Transition class.
|
|
63
|
-
*/
|
|
64
|
-
export type TransitionInterface = Transition & {
|
|
65
|
-
$options: TransitionOptions;
|
|
66
|
-
};
|
|
1
|
+
declare const _default: typeof Base & (new (...a: any[]) => {
|
|
2
|
+
readonly target: HTMLElement | HTMLElement[];
|
|
3
|
+
enter(target?: HTMLElement | HTMLElement[]): Promise<void | void[]>;
|
|
4
|
+
leave(target?: HTMLElement | HTMLElement[]): Promise<void | void[]>;
|
|
5
|
+
});
|
|
6
|
+
export default _default;
|
|
67
7
|
import { Base } from "@studiometa/js-toolkit";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Base as
|
|
1
|
+
import{Base as o}from"@studiometa/js-toolkit";import{withTransition as r}from"../../decorators/index.js";var m=r(o);export{m as default};
|