@studiometa/ui 1.0.0-alpha.1 → 1.0.0-alpha.12
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/Action/Action.d.ts +4 -6
- package/atoms/Action/Action.js +25 -60
- package/atoms/Action/Action.js.map +2 -2
- package/atoms/Action/ActionEvent.d.ts +55 -0
- package/atoms/Action/ActionEvent.js +130 -0
- package/atoms/Action/ActionEvent.js.map +7 -0
- package/atoms/AnchorScrollTo/AnchorScrollTo.d.ts +3 -3
- package/atoms/AnchorScrollTo/AnchorScrollTo.js +1 -3
- package/atoms/AnchorScrollTo/AnchorScrollTo.js.map +2 -2
- package/atoms/Data/DataBind.d.ts +2 -2
- package/atoms/Data/DataBind.js +19 -9
- package/atoms/Data/DataBind.js.map +2 -2
- package/atoms/Data/DataComputed.js +3 -3
- package/atoms/Data/DataComputed.js.map +2 -2
- package/atoms/Data/DataEffect.js +2 -2
- package/atoms/Data/DataEffect.js.map +2 -2
- package/atoms/Data/DataModel.js +1 -1
- package/atoms/Data/DataModel.js.map +2 -2
- package/atoms/Figure/AbstractFigure.d.ts +41 -0
- package/atoms/Figure/AbstractFigure.js +65 -0
- package/atoms/Figure/AbstractFigure.js.map +7 -0
- package/atoms/Figure/AbstractFigureDynamic.d.ts +29 -0
- package/atoms/Figure/AbstractFigureDynamic.js +48 -0
- package/atoms/Figure/AbstractFigureDynamic.js.map +7 -0
- package/atoms/Figure/Figure.d.ts +4 -35
- package/atoms/Figure/Figure.js +5 -68
- package/atoms/Figure/Figure.js.map +2 -2
- package/atoms/Figure/FigureShopify.d.ts +23 -0
- package/atoms/Figure/FigureShopify.js +38 -0
- package/atoms/Figure/FigureShopify.js.map +7 -0
- package/atoms/Figure/FigureTwicpics.d.ts +3 -19
- package/atoms/Figure/FigureTwicpics.js +10 -32
- package/atoms/Figure/FigureTwicpics.js.map +2 -2
- package/atoms/Figure/index.d.ts +1 -0
- package/atoms/Figure/index.js +1 -0
- package/atoms/Figure/index.js.map +2 -2
- package/atoms/Figure/utils.d.ts +8 -0
- package/atoms/Figure/utils.js +15 -0
- package/atoms/Figure/utils.js.map +7 -0
- package/atoms/FigureVideo/FigureVideo.js +1 -1
- package/atoms/FigureVideo/FigureVideo.js.map +1 -1
- package/atoms/FigureVideo/FigureVideoTwicpics.js +1 -1
- package/atoms/FigureVideo/FigureVideoTwicpics.js.map +1 -1
- package/atoms/LazyInclude/LazyInclude.d.ts +3 -1
- package/atoms/LazyInclude/LazyInclude.js +1 -1
- package/atoms/LazyInclude/LazyInclude.js.map +2 -2
- package/atoms/ScrollAnimation/ScrollAnimationChildWithEase.d.ts +1 -1
- package/atoms/ScrollAnimation/ScrollAnimationWithEase.d.ts +1 -1
- package/decorators/withTransition.d.ts +1 -0
- package/decorators/withTransition.js +47 -23
- package/decorators/withTransition.js.map +2 -2
- package/molecules/Accordion/AccordionCore.d.ts +6 -2
- package/molecules/Accordion/AccordionCore.js +2 -2
- package/molecules/Accordion/AccordionCore.js.map +2 -2
- package/molecules/AnchorNav/AnchorNav.d.ts +6 -2
- package/molecules/AnchorNav/AnchorNav.js +4 -4
- package/molecules/AnchorNav/AnchorNav.js.map +2 -2
- package/molecules/AnchorNav/AnchorNavLink.d.ts +1 -1
- package/molecules/Menu/Menu.d.ts +11 -4
- package/molecules/Menu/Menu.js +7 -9
- package/molecules/Menu/Menu.js.map +2 -2
- package/molecules/Menu/MenuBtn.d.ts +9 -3
- package/molecules/Menu/MenuBtn.js +3 -3
- package/molecules/Menu/MenuBtn.js.map +2 -2
- package/molecules/Menu/MenuList.d.ts +1 -1
- package/molecules/Slider/Slider.d.ts +6 -2
- package/molecules/Slider/Slider.js +2 -2
- package/molecules/Slider/Slider.js.map +2 -2
- package/molecules/Slider/SliderDots.d.ts +5 -2
- package/molecules/Slider/SliderDots.js +1 -1
- package/molecules/Slider/SliderDots.js.map +2 -2
- package/molecules/Slider/SliderDrag.d.ts +3 -1
- package/molecules/Slider/SliderDrag.js +1 -1
- package/molecules/Slider/SliderDrag.js.map +2 -2
- package/molecules/Sticky/Sticky.d.ts +3 -1
- package/molecules/Sticky/Sticky.js +1 -1
- package/molecules/Sticky/Sticky.js.map +2 -2
- package/molecules/Tabs/Tabs.d.ts +4 -1
- package/molecules/Tabs/Tabs.js +1 -1
- package/molecules/Tabs/Tabs.js.map +2 -2
- package/molecules/index.d.ts +2 -3
- package/molecules/index.js +2 -3
- package/molecules/index.js.map +2 -2
- package/organisms/Frame/Frame.d.ts +11 -3
- package/organisms/Frame/Frame.js +14 -16
- package/organisms/Frame/Frame.js.map +2 -2
- package/organisms/Frame/FrameTarget.d.ts +1 -1
- package/package.json +2 -2
- package/primitives/Transition/Transition.d.ts +1 -1
- package/atoms/Action/Action.cjs +0 -115
- package/atoms/Action/Action.cjs.map +0 -7
- package/atoms/Action/Target.cjs +0 -35
- package/atoms/Action/Target.cjs.map +0 -7
- package/atoms/Action/index.cjs +0 -22
- package/atoms/Action/index.cjs.map +0 -7
- package/atoms/AnchorScrollTo/AnchorScrollTo.cjs +0 -52
- package/atoms/AnchorScrollTo/AnchorScrollTo.cjs.map +0 -7
- package/atoms/AnchorScrollTo/index.cjs +0 -21
- package/atoms/AnchorScrollTo/index.cjs.map +0 -7
- package/atoms/CircularMarquee/CircularMarquee.cjs +0 -69
- package/atoms/CircularMarquee/CircularMarquee.cjs.map +0 -7
- package/atoms/CircularMarquee/index.cjs +0 -21
- package/atoms/CircularMarquee/index.cjs.map +0 -7
- package/atoms/Cursor/Cursor.cjs +0 -137
- package/atoms/Cursor/Cursor.cjs.map +0 -7
- package/atoms/Cursor/index.cjs +0 -21
- package/atoms/Cursor/index.cjs.map +0 -7
- package/atoms/Data/DataBind.cjs +0 -124
- package/atoms/Data/DataBind.cjs.map +0 -7
- package/atoms/Data/DataComputed.cjs +0 -49
- package/atoms/Data/DataComputed.cjs.map +0 -7
- package/atoms/Data/DataEffect.cjs +0 -47
- package/atoms/Data/DataEffect.cjs.map +0 -7
- package/atoms/Data/DataModel.cjs +0 -48
- package/atoms/Data/DataModel.cjs.map +0 -7
- package/atoms/Data/index.cjs +0 -24
- package/atoms/Data/index.cjs.map +0 -7
- package/atoms/Data/utils.cjs +0 -46
- package/atoms/Data/utils.cjs.map +0 -7
- package/atoms/Figure/Figure.cjs +0 -105
- package/atoms/Figure/Figure.cjs.map +0 -7
- package/atoms/Figure/FigureTwicpics.cjs +0 -123
- package/atoms/Figure/FigureTwicpics.cjs.map +0 -7
- package/atoms/Figure/index.cjs +0 -22
- package/atoms/Figure/index.cjs.map +0 -7
- package/atoms/FigureVideo/FigureVideo.cjs +0 -132
- package/atoms/FigureVideo/FigureVideo.cjs.map +0 -7
- package/atoms/FigureVideo/FigureVideoTwicpics.cjs +0 -153
- package/atoms/FigureVideo/FigureVideoTwicpics.cjs.map +0 -7
- package/atoms/FigureVideo/index.cjs +0 -22
- package/atoms/FigureVideo/index.cjs.map +0 -7
- package/atoms/LargeText/LargeText.cjs +0 -109
- package/atoms/LargeText/LargeText.cjs.map +0 -7
- package/atoms/LargeText/index.cjs +0 -21
- package/atoms/LargeText/index.cjs.map +0 -7
- package/atoms/LazyInclude/LazyInclude.cjs +0 -78
- package/atoms/LazyInclude/LazyInclude.cjs.map +0 -7
- package/atoms/LazyInclude/index.cjs +0 -21
- package/atoms/LazyInclude/index.cjs.map +0 -7
- package/atoms/Prefetch/AbstractPrefetch.cjs +0 -86
- package/atoms/Prefetch/AbstractPrefetch.cjs.map +0 -7
- package/atoms/Prefetch/PrefetchWhenOver.cjs +0 -42
- package/atoms/Prefetch/PrefetchWhenOver.cjs.map +0 -7
- package/atoms/Prefetch/PrefetchWhenVisible.cjs +0 -43
- package/atoms/Prefetch/PrefetchWhenVisible.cjs.map +0 -7
- package/atoms/Prefetch/index.cjs +0 -23
- package/atoms/Prefetch/index.cjs.map +0 -7
- package/atoms/ScrollAnimation/AbstractScrollAnimation.cjs +0 -95
- package/atoms/ScrollAnimation/AbstractScrollAnimation.cjs.map +0 -7
- package/atoms/ScrollAnimation/ScrollAnimation.cjs +0 -44
- package/atoms/ScrollAnimation/ScrollAnimation.cjs.map +0 -7
- package/atoms/ScrollAnimation/ScrollAnimationChild.cjs +0 -84
- package/atoms/ScrollAnimation/ScrollAnimationChild.cjs.map +0 -7
- package/atoms/ScrollAnimation/ScrollAnimationChildWithEase.cjs +0 -37
- package/atoms/ScrollAnimation/ScrollAnimationChildWithEase.cjs.map +0 -7
- package/atoms/ScrollAnimation/ScrollAnimationParent.cjs +0 -50
- package/atoms/ScrollAnimation/ScrollAnimationParent.cjs.map +0 -7
- package/atoms/ScrollAnimation/ScrollAnimationWithEase.cjs +0 -37
- package/atoms/ScrollAnimation/ScrollAnimationWithEase.cjs.map +0 -7
- package/atoms/ScrollAnimation/animationScrollWithEase.cjs +0 -59
- package/atoms/ScrollAnimation/animationScrollWithEase.cjs.map +0 -7
- package/atoms/ScrollAnimation/index.cjs +0 -27
- package/atoms/ScrollAnimation/index.cjs.map +0 -7
- package/atoms/ScrollReveal/ScrollReveal.cjs +0 -81
- package/atoms/ScrollReveal/ScrollReveal.cjs.map +0 -7
- package/atoms/ScrollReveal/index.cjs +0 -21
- package/atoms/ScrollReveal/index.cjs.map +0 -7
- package/atoms/index.cjs +0 -32
- package/atoms/index.cjs.map +0 -7
- package/decorators/index.cjs +0 -22
- package/decorators/index.cjs.map +0 -7
- package/decorators/withDeprecation.cjs +0 -47
- package/decorators/withDeprecation.cjs.map +0 -7
- package/decorators/withTransition.cjs +0 -86
- package/decorators/withTransition.cjs.map +0 -7
- package/index.cjs +0 -25
- package/index.cjs.map +0 -7
- package/molecules/Accordion/Accordion.cjs +0 -36
- package/molecules/Accordion/Accordion.cjs.map +0 -7
- package/molecules/Accordion/AccordionCore.cjs +0 -58
- package/molecules/Accordion/AccordionCore.cjs.map +0 -7
- package/molecules/Accordion/AccordionItem.cjs +0 -206
- package/molecules/Accordion/AccordionItem.cjs.map +0 -7
- package/molecules/Accordion/index.cjs +0 -22
- package/molecules/Accordion/index.cjs.map +0 -7
- package/molecules/AnchorNav/AnchorNav.cjs +0 -63
- package/molecules/AnchorNav/AnchorNav.cjs.map +0 -7
- package/molecules/AnchorNav/AnchorNavLink.cjs +0 -40
- package/molecules/AnchorNav/AnchorNavLink.cjs.map +0 -7
- package/molecules/AnchorNav/AnchorNavTarget.cjs +0 -35
- package/molecules/AnchorNav/AnchorNavTarget.cjs.map +0 -7
- package/molecules/AnchorNav/index.cjs +0 -23
- package/molecules/AnchorNav/index.cjs.map +0 -7
- package/molecules/Menu/Menu.cjs +0 -177
- package/molecules/Menu/Menu.cjs.map +0 -7
- package/molecules/Menu/MenuBtn.cjs +0 -66
- package/molecules/Menu/MenuBtn.cjs.map +0 -7
- package/molecules/Menu/MenuList.cjs +0 -165
- package/molecules/Menu/MenuList.cjs.map +0 -7
- package/molecules/Menu/index.cjs +0 -23
- package/molecules/Menu/index.cjs.map +0 -7
- package/molecules/Modal/Modal.cjs +0 -219
- package/molecules/Modal/Modal.cjs.map +0 -7
- package/molecules/Modal/ModalWithTransition.cjs +0 -69
- package/molecules/Modal/ModalWithTransition.cjs.map +0 -7
- package/molecules/Modal/index.cjs +0 -22
- package/molecules/Modal/index.cjs.map +0 -7
- package/molecules/Panel/Panel.cjs +0 -137
- package/molecules/Panel/Panel.cjs.map +0 -7
- package/molecules/Panel/index.cjs +0 -21
- package/molecules/Panel/index.cjs.map +0 -7
- package/molecules/Slider/AbstractSliderChild.cjs +0 -88
- package/molecules/Slider/AbstractSliderChild.cjs.map +0 -7
- package/molecules/Slider/Slider.cjs +0 -404
- package/molecules/Slider/Slider.cjs.map +0 -7
- package/molecules/Slider/SliderBtn.cjs +0 -71
- package/molecules/Slider/SliderBtn.cjs.map +0 -7
- package/molecules/Slider/SliderCount.cjs +0 -44
- package/molecules/Slider/SliderCount.cjs.map +0 -7
- package/molecules/Slider/SliderDots.cjs +0 -64
- package/molecules/Slider/SliderDots.cjs.map +0 -7
- package/molecules/Slider/SliderDrag.cjs +0 -66
- package/molecules/Slider/SliderDrag.cjs.map +0 -7
- package/molecules/Slider/SliderItem.cjs +0 -177
- package/molecules/Slider/SliderItem.cjs.map +0 -7
- package/molecules/Slider/SliderProgress.cjs +0 -49
- package/molecules/Slider/SliderProgress.cjs.map +0 -7
- package/molecules/Slider/index.cjs +0 -28
- package/molecules/Slider/index.cjs.map +0 -7
- package/molecules/Sticky/Sticky.cjs +0 -177
- package/molecules/Sticky/Sticky.cjs.map +0 -7
- package/molecules/Sticky/index.cjs +0 -21
- package/molecules/Sticky/index.cjs.map +0 -7
- package/molecules/TableOfContent/TableOfContent.cjs +0 -72
- package/molecules/TableOfContent/TableOfContent.cjs.map +0 -7
- package/molecules/TableOfContent/TableOfContentAnchor.cjs +0 -76
- package/molecules/TableOfContent/TableOfContentAnchor.cjs.map +0 -7
- package/molecules/TableOfContent/index.cjs +0 -22
- package/molecules/TableOfContent/index.cjs.map +0 -7
- package/molecules/Tabs/Tabs.cjs +0 -153
- package/molecules/Tabs/Tabs.cjs.map +0 -7
- package/molecules/Tabs/index.cjs +0 -21
- package/molecules/Tabs/index.cjs.map +0 -7
- package/molecules/index.cjs +0 -30
- package/molecules/index.cjs.map +0 -7
- package/organisms/Frame/Frame.cjs +0 -220
- package/organisms/Frame/Frame.cjs.map +0 -7
- package/organisms/Frame/FrameAnchor.cjs +0 -41
- package/organisms/Frame/FrameAnchor.cjs.map +0 -7
- package/organisms/Frame/FrameForm.cjs +0 -41
- package/organisms/Frame/FrameForm.cjs.map +0 -7
- package/organisms/Frame/FrameTarget.cjs +0 -114
- package/organisms/Frame/FrameTarget.cjs.map +0 -7
- package/organisms/Frame/index.cjs +0 -24
- package/organisms/Frame/index.cjs.map +0 -7
- package/organisms/index.cjs +0 -21
- package/organisms/index.cjs.map +0 -7
- package/primitives/Draggable/Draggable.cjs +0 -65
- package/primitives/Draggable/Draggable.cjs.map +0 -7
- package/primitives/Draggable/index.cjs +0 -21
- package/primitives/Draggable/index.cjs.map +0 -7
- package/primitives/Sentinel/Sentinel.cjs +0 -35
- package/primitives/Sentinel/Sentinel.cjs.map +0 -7
- package/primitives/Sentinel/index.cjs +0 -21
- package/primitives/Sentinel/index.cjs.map +0 -7
- package/primitives/Transition/Transition.cjs +0 -36
- package/primitives/Transition/Transition.cjs.map +0 -7
- package/primitives/Transition/index.cjs +0 -21
- package/primitives/Transition/index.cjs.map +0 -7
- package/primitives/index.cjs +0 -23
- package/primitives/index.cjs.map +0 -7
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';
|
|
2
|
+
import { Transition } from '../../primitives/index.js';
|
|
3
|
+
export interface AbstractFigureProps extends BaseProps {
|
|
4
|
+
$refs: {
|
|
5
|
+
img: HTMLImageElement;
|
|
6
|
+
};
|
|
7
|
+
$options: {
|
|
8
|
+
lazy: boolean;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
declare const AbstractFigure_base: import("@studiometa/js-toolkit").BaseDecorator<import("@studiometa/js-toolkit").WithMountWhenInViewInterface, Transition<BaseProps>, import("@studiometa/js-toolkit").WithMountWhenInViewProps>;
|
|
12
|
+
/**
|
|
13
|
+
* Figure class.
|
|
14
|
+
*/
|
|
15
|
+
export declare class AbstractFigure<T extends BaseProps = BaseProps> extends AbstractFigure_base<T & AbstractFigureProps> {
|
|
16
|
+
/**
|
|
17
|
+
* Config.
|
|
18
|
+
*/
|
|
19
|
+
static config: BaseConfig;
|
|
20
|
+
/**
|
|
21
|
+
* Get the transition target.
|
|
22
|
+
*/
|
|
23
|
+
get target(): HTMLImageElement;
|
|
24
|
+
/**
|
|
25
|
+
* Get the image source.
|
|
26
|
+
*/
|
|
27
|
+
get src(): string;
|
|
28
|
+
/**
|
|
29
|
+
* Set the image source.
|
|
30
|
+
*/
|
|
31
|
+
set src(value: string);
|
|
32
|
+
/**
|
|
33
|
+
* Get the original source.
|
|
34
|
+
*/
|
|
35
|
+
get original(): string;
|
|
36
|
+
/**
|
|
37
|
+
* Load on mount.
|
|
38
|
+
*/
|
|
39
|
+
mounted(): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { withMountWhenInView } from "@studiometa/js-toolkit";
|
|
2
|
+
import { Transition } from "../../primitives/index.js";
|
|
3
|
+
import { loadImage } from "./utils.js";
|
|
4
|
+
class AbstractFigure extends withMountWhenInView(Transition, {
|
|
5
|
+
threshold: [0, 1]
|
|
6
|
+
}) {
|
|
7
|
+
/**
|
|
8
|
+
* Config.
|
|
9
|
+
*/
|
|
10
|
+
static config = {
|
|
11
|
+
...Transition.config,
|
|
12
|
+
name: "AbstractFigure",
|
|
13
|
+
emits: ["load"],
|
|
14
|
+
refs: ["img"],
|
|
15
|
+
options: {
|
|
16
|
+
...Transition.config.options,
|
|
17
|
+
lazy: Boolean
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Get the transition target.
|
|
22
|
+
*/
|
|
23
|
+
get target() {
|
|
24
|
+
return this.$refs.img;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get the image source.
|
|
28
|
+
*/
|
|
29
|
+
get src() {
|
|
30
|
+
return this.$refs.img.src;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Set the image source.
|
|
34
|
+
*/
|
|
35
|
+
set src(value) {
|
|
36
|
+
this.$refs.img.src = value;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get the original source.
|
|
40
|
+
*/
|
|
41
|
+
get original() {
|
|
42
|
+
return this.$refs.img.dataset.src;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Load on mount.
|
|
46
|
+
*/
|
|
47
|
+
async mounted() {
|
|
48
|
+
const { img } = this.$refs;
|
|
49
|
+
if (!img || !(img instanceof HTMLImageElement)) {
|
|
50
|
+
this.$warn("The `img` refs is missing or not an `<img>` element.");
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const src = this.original;
|
|
54
|
+
if (this.$options.lazy && src && src !== this.src) {
|
|
55
|
+
await loadImage(src);
|
|
56
|
+
this.src = src;
|
|
57
|
+
this.enter();
|
|
58
|
+
this.$emit("load");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
AbstractFigure
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=AbstractFigure.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../packages/ui/atoms/Figure/AbstractFigure.ts"],
|
|
4
|
+
"sourcesContent": ["import { withMountWhenInView } from '@studiometa/js-toolkit';\nimport type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';\nimport { Transition } from '../../primitives/index.js';\nimport { loadImage } from './utils.js';\n\nexport interface AbstractFigureProps extends BaseProps {\n $refs: {\n img: HTMLImageElement;\n };\n $options: {\n lazy: boolean;\n };\n}\n\n/**\n * Figure class.\n */\nexport class AbstractFigure<\n T extends BaseProps = BaseProps,\n> extends withMountWhenInView<Transition>(Transition, {\n threshold: [0, 1],\n})<T & AbstractFigureProps> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n ...Transition.config,\n name: 'AbstractFigure',\n emits: ['load'],\n refs: ['img'],\n options: {\n ...Transition.config.options,\n lazy: Boolean,\n },\n };\n\n /**\n * Get the transition target.\n */\n get target() {\n return this.$refs.img;\n }\n\n /**\n * Get the image source.\n */\n get src() {\n return this.$refs.img.src;\n }\n\n /**\n * Set the image source.\n */\n set src(value: string) {\n this.$refs.img.src = value;\n }\n\n /**\n * Get the original source.\n */\n get original() {\n return this.$refs.img.dataset.src;\n }\n\n /**\n * Load on mount.\n */\n async mounted() {\n const { img } = this.$refs;\n\n if (!img || !(img instanceof HTMLImageElement)) {\n this.$warn('The `img` refs is missing or not an `<img>` element.');\n return;\n }\n\n const src = this.original;\n\n if (this.$options.lazy && src && src !== this.src) {\n await loadImage(src);\n this.src = src;\n this.enter();\n this.$emit('load');\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,2BAA2B;AAEpC,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAcnB,MAAM,uBAEH,oBAAgC,YAAY;AAAA,EACpD,WAAW,CAAC,GAAG,CAAC;AAClB,CAAC,EAA2B;AAAA;AAAA;AAAA;AAAA,EAI1B,OAAO,SAAqB;AAAA,IAC1B,GAAG,WAAW;AAAA,IACd,MAAM;AAAA,IACN,OAAO,CAAC,MAAM;AAAA,IACd,MAAM,CAAC,KAAK;AAAA,IACZ,SAAS;AAAA,MACP,GAAG,WAAW,OAAO;AAAA,MACrB,MAAM;AAAA,IACR;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,SAAS;AACX,WAAO,KAAK,MAAM;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,MAAM;AACR,WAAO,KAAK,MAAM,IAAI;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,IAAI,OAAe;AACrB,SAAK,MAAM,IAAI,MAAM;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,WAAW;AACb,WAAO,KAAK,MAAM,IAAI,QAAQ;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,UAAU;AACd,UAAM,EAAE,IAAI,IAAI,KAAK;AAErB,QAAI,CAAC,OAAO,EAAE,eAAe,mBAAmB;AAC9C,WAAK,MAAM,sDAAsD;AACjE;AAAA,IACF;AAEA,UAAM,MAAM,KAAK;AAEjB,QAAI,KAAK,SAAS,QAAQ,OAAO,QAAQ,KAAK,KAAK;AACjD,YAAM,UAAU,GAAG;AACnB,WAAK,MAAM;AACX,WAAK,MAAM;AACX,WAAK,MAAM,MAAM;AAAA,IACnB;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';
|
|
2
|
+
import { AbstractFigure } from './AbstractFigure.js';
|
|
3
|
+
export interface AbstractFigureDynamicProps extends BaseProps {
|
|
4
|
+
$options: {
|
|
5
|
+
disable: boolean;
|
|
6
|
+
step: number;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* AbstractFigureDynamic class.
|
|
11
|
+
*/
|
|
12
|
+
export declare class AbstractFigureDynamic<T extends BaseProps = BaseProps> extends AbstractFigure<T & AbstractFigureDynamicProps> {
|
|
13
|
+
/**
|
|
14
|
+
* Config.
|
|
15
|
+
*/
|
|
16
|
+
static config: BaseConfig;
|
|
17
|
+
/**
|
|
18
|
+
* Get the formatted source or the original based on the `disable` option.
|
|
19
|
+
*/
|
|
20
|
+
get original(): string;
|
|
21
|
+
/**
|
|
22
|
+
* Format the source with dynamic parameters.
|
|
23
|
+
*/
|
|
24
|
+
formatSrc(src: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Reassign the source from the original on resize.
|
|
27
|
+
*/
|
|
28
|
+
resized(): Promise<void>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { AbstractFigure } from "./AbstractFigure.js";
|
|
2
|
+
import { loadImage } from "./utils.js";
|
|
3
|
+
class AbstractFigureDynamic extends AbstractFigure {
|
|
4
|
+
/**
|
|
5
|
+
* Config.
|
|
6
|
+
*/
|
|
7
|
+
static config = {
|
|
8
|
+
...AbstractFigure.config,
|
|
9
|
+
name: "AbstractFigureDynamic",
|
|
10
|
+
options: {
|
|
11
|
+
...AbstractFigure.config.options,
|
|
12
|
+
disable: Boolean,
|
|
13
|
+
step: {
|
|
14
|
+
type: Number,
|
|
15
|
+
default: 50
|
|
16
|
+
},
|
|
17
|
+
lazy: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: true
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Get the formatted source or the original based on the `disable` option.
|
|
25
|
+
*/
|
|
26
|
+
get original() {
|
|
27
|
+
return this.$options.disable ? super.original : this.formatSrc(super.original);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Format the source with dynamic parameters.
|
|
31
|
+
*/
|
|
32
|
+
/* v8 ignore next 3 */
|
|
33
|
+
formatSrc(src) {
|
|
34
|
+
return src;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Reassign the source from the original on resize.
|
|
38
|
+
*/
|
|
39
|
+
async resized() {
|
|
40
|
+
const { original } = this;
|
|
41
|
+
await loadImage(original);
|
|
42
|
+
this.src = original;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
AbstractFigureDynamic
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=AbstractFigureDynamic.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../packages/ui/atoms/Figure/AbstractFigureDynamic.ts"],
|
|
4
|
+
"sourcesContent": ["import type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';\nimport {\n withLeadingSlash,\n withoutLeadingSlash,\n withoutTrailingSlash,\n} from '@studiometa/js-toolkit/utils';\nimport { AbstractFigure } from './AbstractFigure.js';\nimport { loadImage } from './utils.js';\n\nexport interface AbstractFigureDynamicProps extends BaseProps {\n $options: {\n disable: boolean;\n step: number;\n };\n}\n\n/**\n * AbstractFigureDynamic class.\n */\nexport class AbstractFigureDynamic<T extends BaseProps = BaseProps> extends AbstractFigure<\n T & AbstractFigureDynamicProps\n> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n ...AbstractFigure.config,\n name: 'AbstractFigureDynamic',\n options: {\n ...AbstractFigure.config.options,\n disable: Boolean,\n step: {\n type: Number,\n default: 50,\n },\n lazy: {\n type: Boolean,\n default: true,\n },\n },\n };\n\n /**\n * Get the formatted source or the original based on the `disable` option.\n */\n get original() {\n return this.$options.disable ? super.original : this.formatSrc(super.original);\n }\n\n /**\n * Format the source with dynamic parameters.\n */\n /* v8 ignore next 3 */\n formatSrc(src: string): string {\n return src;\n }\n\n /**\n * Reassign the source from the original on resize.\n */\n async resized() {\n const { original } = this;\n await loadImage(original);\n this.src = original;\n }\n}\n"],
|
|
5
|
+
"mappings": "AAMA,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAYnB,MAAM,8BAA+D,eAE1E;AAAA;AAAA;AAAA;AAAA,EAIA,OAAO,SAAqB;AAAA,IAC1B,GAAG,eAAe;AAAA,IAClB,MAAM;AAAA,IACN,SAAS;AAAA,MACP,GAAG,eAAe,OAAO;AAAA,MACzB,SAAS;AAAA,MACT,MAAM;AAAA,QACJ,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,MACA,MAAM;AAAA,QACJ,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,WAAW;AACb,WAAO,KAAK,SAAS,UAAU,MAAM,WAAW,KAAK,UAAU,MAAM,QAAQ;AAAA,EAC/E;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAAU,KAAqB;AAC7B,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,UAAU;AACd,UAAM,EAAE,SAAS,IAAI;AACrB,UAAM,UAAU,QAAQ;AACxB,SAAK,MAAM;AAAA,EACb;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/atoms/Figure/Figure.d.ts
CHANGED
|
@@ -1,49 +1,18 @@
|
|
|
1
1
|
import type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
img: HTMLImageElement;
|
|
6
|
-
};
|
|
7
|
-
$options: {
|
|
8
|
-
lazy: boolean;
|
|
9
|
-
};
|
|
2
|
+
import { AbstractFigure } from './AbstractFigure.js';
|
|
3
|
+
import type { AbstractFigureProps } from './AbstractFigure.js';
|
|
4
|
+
export interface FigureProps extends AbstractFigureProps {
|
|
10
5
|
}
|
|
11
|
-
/**
|
|
12
|
-
* Load the given image.
|
|
13
|
-
*/
|
|
14
|
-
export declare function loadImage(src: string): Promise<HTMLImageElement>;
|
|
15
|
-
declare const Figure_base: import("@studiometa/js-toolkit").BaseDecorator<import("@studiometa/js-toolkit").WithMountWhenInViewInterface, Transition<BaseProps>, import("@studiometa/js-toolkit").WithMountWhenInViewProps>;
|
|
16
6
|
/**
|
|
17
7
|
* Figure class.
|
|
18
8
|
*/
|
|
19
|
-
export declare class Figure<T extends BaseProps = BaseProps> extends
|
|
9
|
+
export declare class Figure<T extends BaseProps = BaseProps> extends AbstractFigure<T> {
|
|
20
10
|
/**
|
|
21
11
|
* Config.
|
|
22
12
|
*/
|
|
23
13
|
static config: BaseConfig;
|
|
24
|
-
/**
|
|
25
|
-
* Get the transition target.
|
|
26
|
-
*/
|
|
27
|
-
get target(): HTMLImageElement;
|
|
28
|
-
/**
|
|
29
|
-
* Get the image source.
|
|
30
|
-
*/
|
|
31
|
-
get src(): string;
|
|
32
|
-
/**
|
|
33
|
-
* Set the image source.
|
|
34
|
-
*/
|
|
35
|
-
set src(value: string);
|
|
36
|
-
/**
|
|
37
|
-
* Get the original source.
|
|
38
|
-
*/
|
|
39
|
-
get original(): string;
|
|
40
|
-
/**
|
|
41
|
-
* Load on mount.
|
|
42
|
-
*/
|
|
43
|
-
mounted(): Promise<void>;
|
|
44
14
|
/**
|
|
45
15
|
* Terminate the component on load.
|
|
46
16
|
*/
|
|
47
17
|
onLoad(): void;
|
|
48
18
|
}
|
|
49
|
-
export {};
|
package/atoms/Figure/Figure.js
CHANGED
|
@@ -1,74 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
function loadImage(src) {
|
|
4
|
-
return new Promise((resolve) => {
|
|
5
|
-
const img = new Image();
|
|
6
|
-
img.addEventListener("load", () => resolve(img));
|
|
7
|
-
img.src = src;
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
class Figure extends withMountWhenInView(
|
|
11
|
-
Transition,
|
|
12
|
-
{
|
|
13
|
-
threshold: [0, 1]
|
|
14
|
-
}
|
|
15
|
-
) {
|
|
1
|
+
import { AbstractFigure } from "./AbstractFigure.js";
|
|
2
|
+
class Figure extends AbstractFigure {
|
|
16
3
|
/**
|
|
17
4
|
* Config.
|
|
18
5
|
*/
|
|
19
6
|
static config = {
|
|
20
|
-
...
|
|
21
|
-
name: "Figure"
|
|
22
|
-
emits: ["load"],
|
|
23
|
-
refs: ["img"],
|
|
24
|
-
options: {
|
|
25
|
-
...Transition.config.options,
|
|
26
|
-
lazy: Boolean
|
|
27
|
-
}
|
|
7
|
+
...AbstractFigure.config,
|
|
8
|
+
name: "Figure"
|
|
28
9
|
};
|
|
29
|
-
/**
|
|
30
|
-
* Get the transition target.
|
|
31
|
-
*/
|
|
32
|
-
get target() {
|
|
33
|
-
return this.$refs.img;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Get the image source.
|
|
37
|
-
*/
|
|
38
|
-
get src() {
|
|
39
|
-
return this.$refs.img.src;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Set the image source.
|
|
43
|
-
*/
|
|
44
|
-
set src(value) {
|
|
45
|
-
this.$refs.img.src = value;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Get the original source.
|
|
49
|
-
*/
|
|
50
|
-
get original() {
|
|
51
|
-
return this.$refs.img.dataset.src;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Load on mount.
|
|
55
|
-
*/
|
|
56
|
-
async mounted() {
|
|
57
|
-
const { img } = this.$refs;
|
|
58
|
-
if (!img) {
|
|
59
|
-
throw new Error("[Figure] The `img` ref is required.");
|
|
60
|
-
}
|
|
61
|
-
if (!(img instanceof HTMLImageElement)) {
|
|
62
|
-
throw new Error("[Figure] The `img` ref must be an `<img>` element.");
|
|
63
|
-
}
|
|
64
|
-
const src = this.original;
|
|
65
|
-
if (this.$options.lazy && src && src !== this.src) {
|
|
66
|
-
await loadImage(src);
|
|
67
|
-
this.src = src;
|
|
68
|
-
this.enter();
|
|
69
|
-
this.$emit("load");
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
10
|
/**
|
|
73
11
|
* Terminate the component on load.
|
|
74
12
|
*/
|
|
@@ -77,7 +15,6 @@ class Figure extends withMountWhenInView(
|
|
|
77
15
|
}
|
|
78
16
|
}
|
|
79
17
|
export {
|
|
80
|
-
Figure
|
|
81
|
-
loadImage
|
|
18
|
+
Figure
|
|
82
19
|
};
|
|
83
20
|
//# sourceMappingURL=Figure.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/ui/atoms/Figure/Figure.ts"],
|
|
4
|
-
"sourcesContent": ["import { withMountWhenInView } from '@studiometa/js-toolkit';\nimport type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';\nimport {
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { withMountWhenInView } from '@studiometa/js-toolkit';\nimport type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';\nimport { AbstractFigure } from './AbstractFigure.js';\nimport type { AbstractFigureProps } from './AbstractFigure.js';\n\nexport interface FigureProps extends AbstractFigureProps {}\n\n/**\n * Figure class.\n */\nexport class Figure<T extends BaseProps = BaseProps> extends AbstractFigure<T> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n ...AbstractFigure.config,\n name: 'Figure',\n };\n\n /**\n * Terminate the component on load.\n */\n onLoad() {\n this.$terminate();\n }\n}\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,sBAAsB;AAQxB,MAAM,eAAgD,eAAkB;AAAA;AAAA;AAAA;AAAA,EAI7E,OAAO,SAAqB;AAAA,IAC1B,GAAG,eAAe;AAAA,IAClB,MAAM;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKA,SAAS;AACP,SAAK,WAAW;AAAA,EAClB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';
|
|
2
|
+
import { AbstractFigureDynamic } from './AbstractFigureDynamic.js';
|
|
3
|
+
export interface FigureShopifyProps extends BaseProps {
|
|
4
|
+
$options: {
|
|
5
|
+
crop?: 'top' | 'left' | 'right' | 'bottom' | 'center';
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Figure class.
|
|
10
|
+
*
|
|
11
|
+
* Manager lazyloading image sources.
|
|
12
|
+
*/
|
|
13
|
+
export declare class FigureShopify<T extends BaseProps = BaseProps> extends AbstractFigureDynamic<T & FigureShopifyProps> {
|
|
14
|
+
/**
|
|
15
|
+
* Config.
|
|
16
|
+
*/
|
|
17
|
+
static config: BaseConfig;
|
|
18
|
+
/**
|
|
19
|
+
* Format the source for Shopify CDN API.
|
|
20
|
+
* @see https://shopify.dev/docs/api/liquid/filters/image_url
|
|
21
|
+
*/
|
|
22
|
+
formatSrc(src: string): string;
|
|
23
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { AbstractFigureDynamic } from "./AbstractFigureDynamic.js";
|
|
2
|
+
import { normalizeSize } from "./utils.js";
|
|
3
|
+
class FigureShopify extends AbstractFigureDynamic {
|
|
4
|
+
/**
|
|
5
|
+
* Config.
|
|
6
|
+
*/
|
|
7
|
+
static config = {
|
|
8
|
+
...AbstractFigureDynamic.config,
|
|
9
|
+
name: "FigureShopify",
|
|
10
|
+
options: {
|
|
11
|
+
...AbstractFigureDynamic.config.options,
|
|
12
|
+
crop: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: null
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Format the source for Shopify CDN API.
|
|
20
|
+
* @see https://shopify.dev/docs/api/liquid/filters/image_url
|
|
21
|
+
*/
|
|
22
|
+
formatSrc(src) {
|
|
23
|
+
const { crop, step } = this.$options;
|
|
24
|
+
const url = new URL(src, "https://localhost");
|
|
25
|
+
const width = normalizeSize(this.$refs.img.offsetWidth, step) * window.devicePixelRatio;
|
|
26
|
+
const height = normalizeSize(this.$refs.img.offsetHeight, step) * window.devicePixelRatio;
|
|
27
|
+
url.searchParams.set("width", String(width));
|
|
28
|
+
url.searchParams.set("height", String(height));
|
|
29
|
+
if (crop) {
|
|
30
|
+
url.searchParams.set("crop", this.$options.crop);
|
|
31
|
+
}
|
|
32
|
+
return url.toString();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
FigureShopify
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=FigureShopify.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../packages/ui/atoms/Figure/FigureShopify.ts"],
|
|
4
|
+
"sourcesContent": ["import type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';\nimport { AbstractFigureDynamic } from './AbstractFigureDynamic.js';\nimport { normalizeSize } from './utils.js';\n\nexport interface FigureShopifyProps extends BaseProps {\n $options: {\n crop?: 'top' | 'left' | 'right' | 'bottom' | 'center';\n };\n}\n\n/**\n * Figure class.\n *\n * Manager lazyloading image sources.\n */\nexport class FigureShopify<T extends BaseProps = BaseProps> extends AbstractFigureDynamic<\n T & FigureShopifyProps\n> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n ...AbstractFigureDynamic.config,\n name: 'FigureShopify',\n options: {\n ...AbstractFigureDynamic.config.options,\n crop: {\n type: String,\n default: null,\n },\n },\n };\n\n /**\n * Format the source for Shopify CDN API.\n * @see https://shopify.dev/docs/api/liquid/filters/image_url\n */\n formatSrc(src: string): string {\n const { crop, step } = this.$options;\n\n const url = new URL(src, 'https://localhost');\n const width = normalizeSize(this.$refs.img.offsetWidth, step) * window.devicePixelRatio;\n const height = normalizeSize(this.$refs.img.offsetHeight, step) * window.devicePixelRatio;\n\n url.searchParams.set('width', String(width));\n url.searchParams.set('height', String(height));\n\n if (crop) {\n url.searchParams.set('crop', this.$options.crop);\n }\n\n return url.toString();\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,6BAA6B;AACtC,SAAS,qBAAqB;AAavB,MAAM,sBAAuD,sBAElE;AAAA;AAAA;AAAA;AAAA,EAIA,OAAO,SAAqB;AAAA,IAC1B,GAAG,sBAAsB;AAAA,IACzB,MAAM;AAAA,IACN,SAAS;AAAA,MACP,GAAG,sBAAsB,OAAO;AAAA,MAChC,MAAM;AAAA,QACJ,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAAU,KAAqB;AAC7B,UAAM,EAAE,MAAM,KAAK,IAAI,KAAK;AAE5B,UAAM,MAAM,IAAI,IAAI,KAAK,mBAAmB;AAC5C,UAAM,QAAQ,cAAc,KAAK,MAAM,IAAI,aAAa,IAAI,IAAI,OAAO;AACvE,UAAM,SAAS,cAAc,KAAK,MAAM,IAAI,cAAc,IAAI,IAAI,OAAO;AAEzE,QAAI,aAAa,IAAI,SAAS,OAAO,KAAK,CAAC;AAC3C,QAAI,aAAa,IAAI,UAAU,OAAO,MAAM,CAAC;AAE7C,QAAI,MAAM;AACR,UAAI,aAAa,IAAI,QAAQ,KAAK,SAAS,IAAI;AAAA,IACjD;AAEA,WAAO,IAAI,SAAS;AAAA,EACtB;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';
|
|
2
|
-
import {
|
|
2
|
+
import { AbstractFigureDynamic } from './AbstractFigureDynamic.js';
|
|
3
3
|
export interface FigureTwicpicsProps extends BaseProps {
|
|
4
4
|
$options: {
|
|
5
5
|
transform: string;
|
|
6
6
|
domain: string;
|
|
7
7
|
path: string;
|
|
8
|
-
step: number;
|
|
9
8
|
mode: string;
|
|
10
9
|
dpr: boolean;
|
|
11
10
|
};
|
|
12
11
|
}
|
|
13
12
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* Manager lazyloading image sources.
|
|
13
|
+
* FigureTwicpics class.
|
|
17
14
|
*/
|
|
18
|
-
export declare class FigureTwicpics<T extends BaseProps = BaseProps> extends
|
|
15
|
+
export declare class FigureTwicpics<T extends BaseProps = BaseProps> extends AbstractFigureDynamic<T & FigureTwicpicsProps> {
|
|
19
16
|
/**
|
|
20
17
|
* Config.
|
|
21
18
|
*/
|
|
@@ -28,11 +25,6 @@ export declare class FigureTwicpics<T extends BaseProps = BaseProps> extends Fig
|
|
|
28
25
|
* Get the Twicpics domain.
|
|
29
26
|
*/
|
|
30
27
|
get domain(): string;
|
|
31
|
-
/**
|
|
32
|
-
* Get formatted original source.
|
|
33
|
-
* If `disable` option is `true` returns the original src.
|
|
34
|
-
*/
|
|
35
|
-
get original(): string;
|
|
36
28
|
/**
|
|
37
29
|
* Get the current device pixel ratio
|
|
38
30
|
* Returns 1 if user agent is considered as a bot.
|
|
@@ -43,12 +35,4 @@ export declare class FigureTwicpics<T extends BaseProps = BaseProps> extends Fig
|
|
|
43
35
|
* Format the source for Twicpics.
|
|
44
36
|
*/
|
|
45
37
|
formatSrc(src: string): string;
|
|
46
|
-
/**
|
|
47
|
-
* Reassign the source from the original on resize.
|
|
48
|
-
*/
|
|
49
|
-
resized(): Promise<void>;
|
|
50
|
-
/**
|
|
51
|
-
* Do not terminate on image load as we need to set the src on resize.
|
|
52
|
-
*/
|
|
53
|
-
onLoad(): void;
|
|
54
38
|
}
|
|
@@ -3,21 +3,18 @@ import {
|
|
|
3
3
|
withoutLeadingSlash,
|
|
4
4
|
withoutTrailingSlash
|
|
5
5
|
} from "@studiometa/js-toolkit/utils";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
const { step } = that.$options;
|
|
9
|
-
return Math.ceil(that.$refs.img[prop] / step) * step;
|
|
10
|
-
}
|
|
6
|
+
import { AbstractFigureDynamic } from "./AbstractFigureDynamic.js";
|
|
7
|
+
import { normalizeSize } from "./utils.js";
|
|
11
8
|
const isBot = /bot|crawl|slurp|spider/i.test(navigator.userAgent);
|
|
12
|
-
class FigureTwicpics extends
|
|
9
|
+
class FigureTwicpics extends AbstractFigureDynamic {
|
|
13
10
|
/**
|
|
14
11
|
* Config.
|
|
15
12
|
*/
|
|
16
13
|
static config = {
|
|
17
|
-
...
|
|
14
|
+
...AbstractFigureDynamic.config,
|
|
18
15
|
name: "FigureTwicpics",
|
|
19
16
|
options: {
|
|
20
|
-
...
|
|
17
|
+
...AbstractFigureDynamic.config.options,
|
|
21
18
|
transform: String,
|
|
22
19
|
domain: String,
|
|
23
20
|
path: String,
|
|
@@ -46,15 +43,7 @@ class FigureTwicpics extends Figure {
|
|
|
46
43
|
* Get the Twicpics domain.
|
|
47
44
|
*/
|
|
48
45
|
get domain() {
|
|
49
|
-
|
|
50
|
-
return url.host;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Get formatted original source.
|
|
54
|
-
* If `disable` option is `true` returns the original src.
|
|
55
|
-
*/
|
|
56
|
-
get original() {
|
|
57
|
-
return this.$options.disable ? super.original : this.formatSrc(super.original);
|
|
46
|
+
return this.$options.domain || new URL(this.$refs.img.dataset.src).host;
|
|
58
47
|
}
|
|
59
48
|
/**
|
|
60
49
|
* Get the current device pixel ratio
|
|
@@ -71,33 +60,22 @@ class FigureTwicpics extends Figure {
|
|
|
71
60
|
* Format the source for Twicpics.
|
|
72
61
|
*/
|
|
73
62
|
formatSrc(src) {
|
|
63
|
+
const { transform, mode, step } = this.$options;
|
|
74
64
|
const url = new URL(src, "https://localhost");
|
|
75
65
|
url.host = this.domain;
|
|
76
66
|
url.port = "";
|
|
77
67
|
if (this.path && !url.pathname.startsWith(withLeadingSlash(this.path))) {
|
|
78
68
|
url.pathname = `/${this.path}${url.pathname}`;
|
|
79
69
|
}
|
|
80
|
-
const width = normalizeSize(this,
|
|
81
|
-
const height = normalizeSize(this,
|
|
70
|
+
const width = normalizeSize(this.$refs.img.offsetWidth, step) * this.devicePixelRatio;
|
|
71
|
+
const height = normalizeSize(this.$refs.img.offsetHeight, step) * this.devicePixelRatio;
|
|
82
72
|
url.searchParams.set(
|
|
83
73
|
"twic",
|
|
84
|
-
["v1",
|
|
74
|
+
["v1", transform, `${mode}=${width}x${height}`].filter(Boolean).join("/")
|
|
85
75
|
);
|
|
86
76
|
url.search = decodeURIComponent(url.search);
|
|
87
77
|
return url.toString();
|
|
88
78
|
}
|
|
89
|
-
/**
|
|
90
|
-
* Reassign the source from the original on resize.
|
|
91
|
-
*/
|
|
92
|
-
async resized() {
|
|
93
|
-
const { src } = await loadImage(this.original);
|
|
94
|
-
this.src = src;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Do not terminate on image load as we need to set the src on resize.
|
|
98
|
-
*/
|
|
99
|
-
onLoad() {
|
|
100
|
-
}
|
|
101
79
|
}
|
|
102
80
|
export {
|
|
103
81
|
FigureTwicpics
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/ui/atoms/Figure/FigureTwicpics.ts"],
|
|
4
|
-
"sourcesContent": ["import type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';\nimport {\n withLeadingSlash,\n withoutLeadingSlash,\n withoutTrailingSlash,\n} from '@studiometa/js-toolkit/utils';\nimport {
|
|
5
|
-
"mappings": "AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,
|
|
4
|
+
"sourcesContent": ["import type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';\nimport {\n withLeadingSlash,\n withoutLeadingSlash,\n withoutTrailingSlash,\n} from '@studiometa/js-toolkit/utils';\nimport { AbstractFigureDynamic } from './AbstractFigureDynamic.js';\nimport { normalizeSize } from './utils.js';\n\nexport interface FigureTwicpicsProps extends BaseProps {\n $options: {\n transform: string;\n domain: string;\n path: string;\n mode: string;\n dpr: boolean;\n };\n}\n\n/**\n * Determine if the user agent is a bot or not.\n */\nconst isBot = /bot|crawl|slurp|spider/i.test(navigator.userAgent);\n\n/**\n * FigureTwicpics class.\n */\nexport class FigureTwicpics<T extends BaseProps = BaseProps> extends AbstractFigureDynamic<\n T & FigureTwicpicsProps\n> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n ...AbstractFigureDynamic.config,\n name: 'FigureTwicpics',\n options: {\n ...AbstractFigureDynamic.config.options,\n transform: String,\n domain: String,\n path: String,\n disable: Boolean,\n step: {\n type: Number,\n default: 50,\n },\n mode: {\n type: String,\n default: 'cover',\n },\n dpr: {\n type: Boolean,\n default: true,\n },\n },\n };\n\n /**\n * Get the Twicpics path.\n */\n get path(): string {\n return withoutTrailingSlash(withoutLeadingSlash(this.$options.path));\n }\n\n /**\n * Get the Twicpics domain.\n */\n get domain(): string {\n return this.$options.domain || new URL(this.$refs.img.dataset.src).host;\n }\n\n /**\n * Get the current device pixel ratio\n * Returns 1 if user agent is considered as a bot.\n * Returns 1 if disabled by the `data-option-no-dpr` attribute.\n */\n get devicePixelRatio() {\n if (!this.$options.dpr || isBot) {\n return 1;\n }\n\n return window.devicePixelRatio;\n }\n\n /**\n * Format the source for Twicpics.\n */\n formatSrc(src: string): string {\n const { transform, mode, step } = this.$options;\n\n const url = new URL(src, 'https://localhost');\n url.host = this.domain;\n url.port = '';\n\n if (this.path && !url.pathname.startsWith(withLeadingSlash(this.path))) {\n url.pathname = `/${this.path}${url.pathname}`;\n }\n\n const width = normalizeSize(this.$refs.img.offsetWidth, step) * this.devicePixelRatio;\n const height = normalizeSize(this.$refs.img.offsetHeight, step) * this.devicePixelRatio;\n\n url.searchParams.set(\n 'twic',\n ['v1', transform, `${mode}=${width}x${height}`].filter(Boolean).join('/'),\n );\n\n url.search = decodeURIComponent(url.search);\n\n return url.toString();\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,6BAA6B;AACtC,SAAS,qBAAqB;AAe9B,MAAM,QAAQ,0BAA0B,KAAK,UAAU,SAAS;AAKzD,MAAM,uBAAwD,sBAEnE;AAAA;AAAA;AAAA;AAAA,EAIA,OAAO,SAAqB;AAAA,IAC1B,GAAG,sBAAsB;AAAA,IACzB,MAAM;AAAA,IACN,SAAS;AAAA,MACP,GAAG,sBAAsB,OAAO;AAAA,MAChC,WAAW;AAAA,MACX,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,SAAS;AAAA,MACT,MAAM;AAAA,QACJ,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,MACA,MAAM;AAAA,QACJ,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,MACA,KAAK;AAAA,QACH,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,OAAe;AACjB,WAAO,qBAAqB,oBAAoB,KAAK,SAAS,IAAI,CAAC;AAAA,EACrE;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,SAAiB;AACnB,WAAO,KAAK,SAAS,UAAU,IAAI,IAAI,KAAK,MAAM,IAAI,QAAQ,GAAG,EAAE;AAAA,EACrE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,IAAI,mBAAmB;AACrB,QAAI,CAAC,KAAK,SAAS,OAAO,OAAO;AAC/B,aAAO;AAAA,IACT;AAEA,WAAO,OAAO;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA,EAKA,UAAU,KAAqB;AAC7B,UAAM,EAAE,WAAW,MAAM,KAAK,IAAI,KAAK;AAEvC,UAAM,MAAM,IAAI,IAAI,KAAK,mBAAmB;AAC5C,QAAI,OAAO,KAAK;AAChB,QAAI,OAAO;AAEX,QAAI,KAAK,QAAQ,CAAC,IAAI,SAAS,WAAW,iBAAiB,KAAK,IAAI,CAAC,GAAG;AACtE,UAAI,WAAW,IAAI,KAAK,IAAI,GAAG,IAAI,QAAQ;AAAA,IAC7C;AAEA,UAAM,QAAQ,cAAc,KAAK,MAAM,IAAI,aAAa,IAAI,IAAI,KAAK;AACrE,UAAM,SAAS,cAAc,KAAK,MAAM,IAAI,cAAc,IAAI,IAAI,KAAK;AAEvE,QAAI,aAAa;AAAA,MACf;AAAA,MACA,CAAC,MAAM,WAAW,GAAG,IAAI,IAAI,KAAK,IAAI,MAAM,EAAE,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAAA,IAC1E;AAEA,QAAI,SAAS,mBAAmB,IAAI,MAAM;AAE1C,WAAO,IAAI,SAAS;AAAA,EACtB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/atoms/Figure/index.d.ts
CHANGED
package/atoms/Figure/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/ui/atoms/Figure/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './Figure.js';\nexport * from './FigureTwicpics.js';\n"],
|
|
5
|
-
"mappings": "AAAA,cAAc;AACd,cAAc;",
|
|
4
|
+
"sourcesContent": ["export * from './Figure.js';\nexport * from './FigureTwicpics.js';\nexport * from './FigureShopify.js';\n"],
|
|
5
|
+
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function loadImage(src) {
|
|
2
|
+
return new Promise((resolve) => {
|
|
3
|
+
const img = new Image();
|
|
4
|
+
img.addEventListener("load", () => resolve(img));
|
|
5
|
+
img.src = src;
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
function normalizeSize(size, step) {
|
|
9
|
+
return Math.ceil(size / step) * step;
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
loadImage,
|
|
13
|
+
normalizeSize
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=utils.js.map
|