@studiometa/ui 0.2.7 → 0.2.10
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/Cursor/Cursor.cjs +5 -1
- package/atoms/Cursor/Cursor.d.ts +6 -0
- package/atoms/Cursor/Cursor.js +1 -1
- package/atoms/LargeText/LargeText.cjs +14 -14
- package/atoms/LargeText/LargeText.d.ts +3 -4
- package/atoms/LargeText/LargeText.js +1 -1
- package/atoms/LargeText/LargeText.twig +1 -1
- package/atoms/ScrollAnimation/AbstractScrollAnimation.cjs +18 -59
- package/atoms/ScrollAnimation/AbstractScrollAnimation.d.ts +28 -55
- package/atoms/ScrollAnimation/AbstractScrollAnimation.js +1 -1
- package/atoms/ScrollAnimation/ScrollAnimation.d.ts +9 -4
- package/atoms/ScrollAnimation/animationScrollWithEase.cjs +3 -24
- package/atoms/ScrollAnimation/animationScrollWithEase.js +1 -1
- package/molecules/Menu/Menu.cjs +7 -16
- package/molecules/Menu/Menu.d.ts +12 -12
- package/molecules/Menu/Menu.js +1 -1
- package/molecules/Menu/MenuBtn.cjs +1 -5
- package/molecules/Menu/MenuBtn.d.ts +0 -1
- package/molecules/Menu/MenuBtn.js +1 -1
- package/molecules/Menu/MenuList.cjs +1 -3
- package/molecules/Menu/MenuList.d.ts +1 -2
- package/molecules/Menu/MenuList.js +1 -1
- package/molecules/Modal/Modal.cjs +11 -3
- package/molecules/Modal/Modal.d.ts +17 -5
- package/molecules/Modal/Modal.js +1 -1
- package/molecules/Modal/Modal.twig +5 -2
- package/molecules/Modal/StyledModal.twig +5 -2
- package/molecules/Panel/StyledPanel.twig +8 -3
- package/molecules/Slider/AbstractSliderChild.cjs +8 -1
- package/molecules/Slider/AbstractSliderChild.d.ts +2 -2
- package/molecules/Slider/AbstractSliderChild.js +1 -1
- package/molecules/Slider/SliderBtn.d.ts +8 -0
- package/molecules/Slider/SliderCount.d.ts +8 -0
- package/molecules/Slider/SliderDots.d.ts +8 -0
- package/molecules/Slider/SliderDrag.cjs +5 -1
- package/molecules/Slider/SliderDrag.d.ts +7 -0
- package/molecules/Slider/SliderDrag.js +1 -1
- package/molecules/Slider/SliderItem.cjs +3 -3
- package/molecules/Slider/SliderItem.d.ts +5 -1
- package/molecules/Slider/SliderItem.js +1 -1
- package/molecules/Slider/SliderProgress.cjs +7 -3
- package/molecules/Slider/SliderProgress.d.ts +8 -0
- package/molecules/Slider/SliderProgress.js +1 -1
- package/organisms/Frame/Frame.cjs +14 -19
- package/organisms/Frame/Frame.d.ts +6 -17
- package/organisms/Frame/Frame.js +1 -1
- package/organisms/Frame/FrameAnchor.cjs +1 -5
- package/organisms/Frame/FrameAnchor.d.ts +0 -8
- package/organisms/Frame/FrameAnchor.js +1 -1
- package/organisms/Frame/FrameForm.cjs +1 -5
- package/organisms/Frame/FrameForm.d.ts +0 -8
- package/organisms/Frame/FrameForm.js +1 -1
- package/package.json +2 -2
|
@@ -59,9 +59,8 @@ var _MenuList = class extends import_Transition.default {
|
|
|
59
59
|
onMouseenter() {
|
|
60
60
|
this.isHover = true;
|
|
61
61
|
}
|
|
62
|
-
onMouseleave(
|
|
62
|
+
onMouseleave() {
|
|
63
63
|
this.isHover = false;
|
|
64
|
-
this.$emit("items-mouseleave", event);
|
|
65
64
|
}
|
|
66
65
|
open() {
|
|
67
66
|
if (this.isOpen) {
|
|
@@ -97,7 +96,6 @@ var _MenuList = class extends import_Transition.default {
|
|
|
97
96
|
this.$emit("items-close");
|
|
98
97
|
}
|
|
99
98
|
toggle() {
|
|
100
|
-
console.log(this.$id, "toggle", this.isOpen);
|
|
101
99
|
if (this.isOpen) {
|
|
102
100
|
this.close();
|
|
103
101
|
} else {
|
|
@@ -54,10 +54,9 @@ export default class MenuList extends Transition {
|
|
|
54
54
|
/**
|
|
55
55
|
* Unset hover state.
|
|
56
56
|
*
|
|
57
|
-
* @param {MouseEvent} event
|
|
58
57
|
* @returns {void}
|
|
59
58
|
*/
|
|
60
|
-
onMouseleave(
|
|
59
|
+
onMouseleave(): void;
|
|
61
60
|
/**
|
|
62
61
|
* Display the menu items.
|
|
63
62
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import s from"../../primitives/Transition/Transition.js";const o=["a[href]:not([inert])","area[href]:not([inert])","input:not([disabled]):not([inert])","select:not([disabled]):not([inert])","textarea:not([disabled]):not([inert])","button:not([disabled]):not([inert])","iframe:not([inert])","audio:not([inert])","video:not([inert])","[contenteditable]:not([inert])","[tabindex]:not([inert])"].join(",");class n extends s{static config={...s.config,name:"MenuList",emits:["items-open","items-close","items-mouseleave"],components:{MenuList:n}};isOpen=!1;isHover=!1;get $options(){const e=super.$options;return e.leaveKeep=!0,e.enterKeep=!0,e}mounted(){this.__updateTabIndexes("close")}onMouseenter(){this.isHover=!0}onMouseleave(){this.isHover=!1}open(){if(this.isOpen)return;const e=t=>{this.$el.contains(t.target)||(document.removeEventListener("click",e),this.close())};document.addEventListener("click",e),this.__updateTabIndexes("open"),this.$el.setAttribute("aria-hidden","false"),this.isOpen=!0,this.enter(),this.$emit("items-open")}close(){!this.isOpen||(this.$children.MenuList.forEach(e=>{e.close()}),document.activeElement instanceof HTMLElement&&this.$el.contains(document.activeElement)&&document.activeElement.blur(),this.$el.setAttribute("aria-hidden","true"),this.__updateTabIndexes("close"),this.isOpen=!1,this.leave(),this.$emit("items-close"))}toggle(){this.isOpen?this.close():this.open()}__updateTabIndexes(e="open"){Array.from(this.$el.querySelectorAll(o)).filter(i=>this.__filterFocusableItems(i)).forEach(i=>{e==="close"?i.setAttribute("tabindex","-1"):i.removeAttribute("tabindex")})}__filterFocusableItems(e){let t=e.parentElement;for(;t&&(!t.__base__||!t.__base__.has(this.constructor));)t=t.parentElement;return t===null||t===this.$el}}export{n as default};
|
|
@@ -89,7 +89,9 @@ var Modal = class extends import_js_toolkit.Base {
|
|
|
89
89
|
return Promise.resolve();
|
|
90
90
|
}
|
|
91
91
|
this.$refs.modal.setAttribute("aria-hidden", "false");
|
|
92
|
-
|
|
92
|
+
if (this.$options.scrollLock) {
|
|
93
|
+
document.documentElement.style.overflow = "hidden";
|
|
94
|
+
}
|
|
93
95
|
this.isOpen = true;
|
|
94
96
|
this.$emit("open");
|
|
95
97
|
const refs = this.$refs;
|
|
@@ -111,7 +113,9 @@ var Modal = class extends import_js_toolkit.Base {
|
|
|
111
113
|
return Promise.resolve();
|
|
112
114
|
}
|
|
113
115
|
this.$refs.modal.setAttribute("aria-hidden", "true");
|
|
114
|
-
|
|
116
|
+
if (this.$options.scrollLock) {
|
|
117
|
+
document.documentElement.style.overflow = "";
|
|
118
|
+
}
|
|
115
119
|
this.isOpen = false;
|
|
116
120
|
untrap();
|
|
117
121
|
this.$emit("close");
|
|
@@ -125,7 +129,7 @@ var Modal = class extends import_js_toolkit.Base {
|
|
|
125
129
|
};
|
|
126
130
|
__publicField(Modal, "config", {
|
|
127
131
|
name: "Modal",
|
|
128
|
-
refs: ["close", "container", "content", "modal", "open", "overlay"],
|
|
132
|
+
refs: ["close[]", "container", "content", "modal", "open[]", "overlay"],
|
|
129
133
|
emits: ["open", "close"],
|
|
130
134
|
options: {
|
|
131
135
|
move: String,
|
|
@@ -141,6 +145,10 @@ __publicField(Modal, "config", {
|
|
|
141
145
|
}
|
|
142
146
|
}
|
|
143
147
|
})
|
|
148
|
+
},
|
|
149
|
+
scrollLock: {
|
|
150
|
+
type: Boolean,
|
|
151
|
+
default: true
|
|
144
152
|
}
|
|
145
153
|
}
|
|
146
154
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {Object} ModalRefs
|
|
3
|
-
* @property {HTMLElement} close
|
|
3
|
+
* @property {HTMLElement} close[]
|
|
4
4
|
* @property {HTMLElement} container
|
|
5
5
|
* @property {HTMLElement} content
|
|
6
6
|
* @property {HTMLElement} modal
|
|
7
|
-
* @property {HTMLElement} open
|
|
7
|
+
* @property {HTMLElement} open[]
|
|
8
8
|
* @property {HTMLElement} overlay
|
|
9
9
|
*/
|
|
10
10
|
/**
|
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
*/
|
|
14
14
|
/**
|
|
15
15
|
* @typedef {Object} ModalOptions
|
|
16
|
-
* @property {String} move
|
|
17
|
-
* @property {String} autofocus
|
|
18
|
-
* @property {
|
|
16
|
+
* @property {String} move A selector where to move the modal to.
|
|
17
|
+
* @property {String} autofocus A selector for the element to set the focus to when the modal opens.
|
|
18
|
+
* @property {Boolean} scrollLock Lock or allow scroll in the documentElement.
|
|
19
|
+
* @property {ModalStylesOption} styles The styles for the different state of the modal.
|
|
19
20
|
*/
|
|
20
21
|
/**
|
|
21
22
|
* @typedef {Object} ModalPrivateInterface
|
|
@@ -54,6 +55,13 @@ export default class Modal extends Base {
|
|
|
54
55
|
*/
|
|
55
56
|
default: () => ModalStylesOption;
|
|
56
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* @return {ModalScrollLockOption}
|
|
60
|
+
*/
|
|
61
|
+
scrollLock: {
|
|
62
|
+
type: BooleanConstructor;
|
|
63
|
+
default: boolean;
|
|
64
|
+
};
|
|
57
65
|
};
|
|
58
66
|
};
|
|
59
67
|
/**
|
|
@@ -141,6 +149,10 @@ export type ModalOptions = {
|
|
|
141
149
|
* A selector for the element to set the focus to when the modal opens.
|
|
142
150
|
*/
|
|
143
151
|
autofocus: string;
|
|
152
|
+
/**
|
|
153
|
+
* Lock or allow scroll in the documentElement.
|
|
154
|
+
*/
|
|
155
|
+
scrollLock: boolean;
|
|
144
156
|
/**
|
|
145
157
|
* The styles for the different state of the modal.
|
|
146
158
|
*/
|
package/molecules/Modal/Modal.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Base as n}from"@studiometa/js-toolkit";import{transition as r,focusTrap as l}from"@studiometa/js-toolkit/utils";const{trap:a,untrap:c,saveActiveElement:f}=l();class h extends n{static config={name:"Modal",refs:["close","container","content","modal","open","overlay"],emits:["open","close"],options:{move:String,autofocus:{type:String,default:"[autofocus]"},styles:{type:Object,default:()=>({modal:{closed:{opacity:"0",pointerEvents:"none",visibility:"hidden"}}})}}};get onOpenClick(){return this.open}get onCloseClick(){return this.close}get onOverlayClick(){return this.close}mounted(){if(this.isOpen=!1,this.close(),this.$options.move){const e=document.querySelector(this.$options.move)||document.body;this.__refsBackup=this.$refs,this.__refModalPlaceholder=document.createComment(""),this.__refModalParentBackup=this.$refs.modal.parentElement||this.$el,this.__refModalParentBackup.insertBefore(this.__refModalPlaceholder,this.$refs.modal),e.appendChild(this.$refs.modal)}}get $refs(){const e=super.$refs;return this.$options.move&&this.__refsBackup&&Object.entries(this.__refsBackup).forEach(([t,s])=>{e[t]||(e[t]=s)}),e}destroyed(){return this.close(),this.$options.move&&this.__refModalParentBackup&&(this.__refModalParentBackup.insertBefore(this.$refs.modal,this.__refModalPlaceholder),this.__refModalPlaceholder.remove(),delete this.__refModalPlaceholder,delete this.__refModalParentBackup),this}keyed({event:e,isUp:t,isDown:s,ESC:o}){!this.isOpen||(s&&a(this.$refs.modal,e),o&&t&&this.close())}async open(){if(this.isOpen)return Promise.resolve();this.$refs.modal.setAttribute("aria-hidden","false"),document.documentElement.style.overflow="hidden",this.isOpen=!0,this.$emit("open");const e=this.$refs;return Promise.all(Object.entries(this.$options.styles).map(([t,{open:s,active:o,closed:i}={open:"",active:"",closed:""}])=>r(e[t],{from:i,active:o,to:s},"keep"))).then(()=>(this.$options.autofocus&&this.$refs.modal.querySelector(this.$options.autofocus)&&(f(),this.$refs.modal.querySelector(this.$options.autofocus).focus()),Promise.resolve()))}async close(){if(!this.isOpen)return Promise.resolve();this.$refs.modal.setAttribute("aria-hidden","true"),document.documentElement.style.overflow="",this.isOpen=!1,c(),this.$emit("close");const e=this.$refs;return Promise.all(Object.entries(this.$options.styles).map(([t,{open:s,active:o,closed:i}={open:"",active:"",closed:""}])=>r(e[t],{from:s,active:o,to:i},"keep"))).then(()=>Promise.resolve())}}export{h as default};
|
|
1
|
+
import{Base as n}from"@studiometa/js-toolkit";import{transition as r,focusTrap as l}from"@studiometa/js-toolkit/utils";const{trap:a,untrap:c,saveActiveElement:f}=l();class h extends n{static config={name:"Modal",refs:["close[]","container","content","modal","open[]","overlay"],emits:["open","close"],options:{move:String,autofocus:{type:String,default:"[autofocus]"},styles:{type:Object,default:()=>({modal:{closed:{opacity:"0",pointerEvents:"none",visibility:"hidden"}}})},scrollLock:{type:Boolean,default:!0}}};get onOpenClick(){return this.open}get onCloseClick(){return this.close}get onOverlayClick(){return this.close}mounted(){if(this.isOpen=!1,this.close(),this.$options.move){const e=document.querySelector(this.$options.move)||document.body;this.__refsBackup=this.$refs,this.__refModalPlaceholder=document.createComment(""),this.__refModalParentBackup=this.$refs.modal.parentElement||this.$el,this.__refModalParentBackup.insertBefore(this.__refModalPlaceholder,this.$refs.modal),e.appendChild(this.$refs.modal)}}get $refs(){const e=super.$refs;return this.$options.move&&this.__refsBackup&&Object.entries(this.__refsBackup).forEach(([t,s])=>{e[t]||(e[t]=s)}),e}destroyed(){return this.close(),this.$options.move&&this.__refModalParentBackup&&(this.__refModalParentBackup.insertBefore(this.$refs.modal,this.__refModalPlaceholder),this.__refModalPlaceholder.remove(),delete this.__refModalPlaceholder,delete this.__refModalParentBackup),this}keyed({event:e,isUp:t,isDown:s,ESC:o}){!this.isOpen||(s&&a(this.$refs.modal,e),o&&t&&this.close())}async open(){if(this.isOpen)return Promise.resolve();this.$refs.modal.setAttribute("aria-hidden","false"),this.$options.scrollLock&&(document.documentElement.style.overflow="hidden"),this.isOpen=!0,this.$emit("open");const e=this.$refs;return Promise.all(Object.entries(this.$options.styles).map(([t,{open:s,active:o,closed:i}={open:"",active:"",closed:""}])=>r(e[t],{from:i,active:o,to:s},"keep"))).then(()=>(this.$options.autofocus&&this.$refs.modal.querySelector(this.$options.autofocus)&&(f(),this.$refs.modal.querySelector(this.$options.autofocus).focus()),Promise.resolve()))}async close(){if(!this.isOpen)return Promise.resolve();this.$refs.modal.setAttribute("aria-hidden","true"),this.$options.scrollLock&&(document.documentElement.style.overflow=""),this.isOpen=!1,c(),this.$emit("close");const e=this.$refs;return Promise.all(Object.entries(this.$options.styles).map(([t,{open:s,active:o,closed:i}={open:"",active:"",closed:""}])=>r(e[t],{from:s,active:o,to:i},"keep"))).then(()=>Promise.resolve())}}export{h as default};
|
|
@@ -83,7 +83,10 @@
|
|
|
83
83
|
|
|
84
84
|
<div {{ html_attributes(attributes) }}>
|
|
85
85
|
{% block open %}
|
|
86
|
-
{% include '@ui/atoms/Button/Button.twig' with {
|
|
86
|
+
{% include '@ui/atoms/Button/Button.twig' with {
|
|
87
|
+
label: 'Open',
|
|
88
|
+
attr: { data_ref: 'open[]' }
|
|
89
|
+
} %}
|
|
87
90
|
{% endblock %}
|
|
88
91
|
<div {{ html_attributes(modal_attributes) }}>
|
|
89
92
|
<div {{ html_attributes(overlay_attributes) }}></div>
|
|
@@ -93,7 +96,7 @@
|
|
|
93
96
|
<div class="absolute top-0 right-0 m-2">
|
|
94
97
|
{% include '@ui/atoms/Button/Button.twig' with {
|
|
95
98
|
label: 'Close',
|
|
96
|
-
attr: { data_ref: 'close' }
|
|
99
|
+
attr: { data_ref: 'close[]' }
|
|
97
100
|
} %}
|
|
98
101
|
</div>
|
|
99
102
|
{% endblock %}
|
|
@@ -26,14 +26,17 @@
|
|
|
26
26
|
{% extends '@ui/molecules/Modal/Modal.twig' %}
|
|
27
27
|
|
|
28
28
|
{% block open %}
|
|
29
|
-
{% include '@ui/atoms/Button/StyledButton.twig' with {
|
|
29
|
+
{% include '@ui/atoms/Button/StyledButton.twig' with {
|
|
30
|
+
label: 'Open',
|
|
31
|
+
attr: { data_ref: 'open[]' }
|
|
32
|
+
} %}
|
|
30
33
|
{% endblock %}
|
|
31
34
|
|
|
32
35
|
{% block close %}
|
|
33
36
|
<div class="absolute top-0 right-0 m-2">
|
|
34
37
|
{% include '@ui/atoms/Button/StyledButton.twig' with {
|
|
35
38
|
label: 'Close',
|
|
36
|
-
attr: { data_ref: 'close' }
|
|
39
|
+
attr: { data_ref: 'close[]' }
|
|
37
40
|
} %}
|
|
38
41
|
</div>
|
|
39
42
|
{% endblock %}
|
|
@@ -12,17 +12,22 @@
|
|
|
12
12
|
|
|
13
13
|
{% extends '@ui/molecules/Panel/Panel.twig' %}
|
|
14
14
|
|
|
15
|
-
{% set container_attr =
|
|
15
|
+
{% set container_attr =
|
|
16
|
+
merge_html_attributes(container_attr ?? null, required = { class: 'bg-white' })
|
|
17
|
+
%}
|
|
16
18
|
|
|
17
19
|
{% block open %}
|
|
18
|
-
{% include '@ui/atoms/Button/StyledButton.twig' with {
|
|
20
|
+
{% include '@ui/atoms/Button/StyledButton.twig' with {
|
|
21
|
+
label: 'Open',
|
|
22
|
+
attr: { data_ref: 'open[]' }
|
|
23
|
+
} %}
|
|
19
24
|
{% endblock %}
|
|
20
25
|
|
|
21
26
|
{% block close %}
|
|
22
27
|
<div class="absolute top-0 right-0 m-2">
|
|
23
28
|
{% include '@ui/atoms/Button/StyledButton.twig' with {
|
|
24
29
|
label: 'Close',
|
|
25
|
-
attr: { data_ref: 'close' }
|
|
30
|
+
attr: { data_ref: 'close[]' }
|
|
26
31
|
} %}
|
|
27
32
|
</div>
|
|
28
33
|
{% endblock %}
|
|
@@ -51,7 +51,14 @@ var AbstractSliderChild = class extends import_js_toolkit.Base {
|
|
|
51
51
|
}
|
|
52
52
|
handleEvent(event) {
|
|
53
53
|
if (event.type === "index") {
|
|
54
|
-
|
|
54
|
+
import_utils.domScheduler.read(() => {
|
|
55
|
+
const callback = this.update(event.detail[0]);
|
|
56
|
+
if ((0, import_utils.isFunction)(callback)) {
|
|
57
|
+
import_utils.domScheduler.write(() => {
|
|
58
|
+
callback();
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
});
|
|
55
62
|
}
|
|
56
63
|
}
|
|
57
64
|
update(index) {
|
|
@@ -45,9 +45,9 @@ export default class AbstractSliderChild extends Base {
|
|
|
45
45
|
*
|
|
46
46
|
* @this {AbstractSliderChildInterface}
|
|
47
47
|
* @param {number} index The new active index.
|
|
48
|
-
* @returns {void}
|
|
48
|
+
* @returns {void|(()=>void)}
|
|
49
49
|
*/
|
|
50
|
-
update(this: AbstractSliderChildInterface, index: number): void;
|
|
50
|
+
update(this: AbstractSliderChildInterface, index: number): void | (() => void);
|
|
51
51
|
}
|
|
52
52
|
export type AbstractSliderChildInterface = AbstractSliderChild & {
|
|
53
53
|
$parent: Slider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Base as
|
|
1
|
+
import{Base as r}from"@studiometa/js-toolkit";import{nextFrame as d,domScheduler as i,isFunction as n}from"@studiometa/js-toolkit/utils";import o from"./Slider.js";class a extends r{static config={name:"AbstractSliderChild"};$parent;mounted(){if(!(this.$parent instanceof o))throw new Error(`The \`${this.$options.name}\` component must be a direct child of a \`Slider\` component.`);this.$parent.$on("index",this)}resized(){d(()=>{this.update(this.$parent.currentIndex)})}destroyed(){this.$parent.$off("index",this)}handleEvent(e){e.type==="index"&&i.read(()=>{const t=this.update(e.detail[0]);n(t)&&i.write(()=>{t()})})}update(e){throw new Error(`The \`AbstractSliderChild.update(${e})\` method must be implemented.`)}}export{a as default};
|
|
@@ -17,6 +17,14 @@ export default class SliderBtn extends AbstractSliderChild {
|
|
|
17
17
|
next: BooleanConstructor;
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Update attributes.
|
|
22
|
+
*
|
|
23
|
+
* @this {SliderBtnInterface}
|
|
24
|
+
* @param {number} index
|
|
25
|
+
* @returns {void}
|
|
26
|
+
*/
|
|
27
|
+
update(this: SliderBtnInterface, index: number): void;
|
|
20
28
|
/**
|
|
21
29
|
* Go prev or next on click.
|
|
22
30
|
*
|
|
@@ -12,6 +12,14 @@ export default class SliderCount extends AbstractSliderChild {
|
|
|
12
12
|
name: string;
|
|
13
13
|
refs: string[];
|
|
14
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Update the current counter indicator.
|
|
17
|
+
*
|
|
18
|
+
* @this {SliderCountInterface}
|
|
19
|
+
* @param {number} index The new active index.
|
|
20
|
+
* @returns {void}
|
|
21
|
+
*/
|
|
22
|
+
update(this: SliderCountInterface, index: number): void;
|
|
15
23
|
}
|
|
16
24
|
export type SliderCountInterface = SliderCount & {
|
|
17
25
|
$refs: {
|
|
@@ -16,6 +16,14 @@ export default class SliderDots extends AbstractSliderChild {
|
|
|
16
16
|
name: string;
|
|
17
17
|
refs: string[];
|
|
18
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* Update dots classes according to the new index.
|
|
21
|
+
*
|
|
22
|
+
* @this {SliderDotsInterface}
|
|
23
|
+
* @param {number} index
|
|
24
|
+
* @returns {void}
|
|
25
|
+
*/
|
|
26
|
+
update(this: SliderDotsInterface, index: number): void;
|
|
19
27
|
/**
|
|
20
28
|
* Go to the given index on dot click.
|
|
21
29
|
*
|
|
@@ -35,6 +35,10 @@ var SliderDrag = class extends (0, import_js_toolkit.withDrag)(import_js_toolkit
|
|
|
35
35
|
};
|
|
36
36
|
__publicField(SliderDrag, "config", {
|
|
37
37
|
name: "SliderDrag",
|
|
38
|
-
emits: ["start", "drag", "drop", "inertia", "stop"]
|
|
38
|
+
emits: ["start", "drag", "drop", "inertia", "stop"],
|
|
39
|
+
sensitivity: {
|
|
40
|
+
type: Number,
|
|
41
|
+
default: 1
|
|
42
|
+
}
|
|
39
43
|
});
|
|
40
44
|
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -2,9 +2,16 @@
|
|
|
2
2
|
* SliderDrag class.
|
|
3
3
|
*/
|
|
4
4
|
export default class SliderDrag extends Base {
|
|
5
|
+
/**
|
|
6
|
+
* Config.
|
|
7
|
+
*/
|
|
5
8
|
static config: {
|
|
6
9
|
name: string;
|
|
7
10
|
emits: string[];
|
|
11
|
+
sensitivity: {
|
|
12
|
+
type: NumberConstructor;
|
|
13
|
+
default: number;
|
|
14
|
+
};
|
|
8
15
|
};
|
|
9
16
|
/**
|
|
10
17
|
* Emit drag events.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Base as e,withDrag as
|
|
1
|
+
import{Base as e,withDrag as i}from"@studiometa/js-toolkit";class a extends i(e){static config={name:"SliderDrag",emits:["start","drag","drop","inertia","stop"],sensitivity:{type:Number,default:1}};dragged(t){this.$emit(t.mode,t)}}export{a as default};
|
|
@@ -80,9 +80,9 @@ var SliderItem = class extends (0, import_js_toolkit.withIntersectionObserver)(i
|
|
|
80
80
|
this.render();
|
|
81
81
|
}
|
|
82
82
|
render() {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
})
|
|
83
|
+
import_utils.domScheduler.write(() => {
|
|
84
|
+
(0, import_utils.transform)(this.$el, { x: this.dampedX });
|
|
85
|
+
});
|
|
86
86
|
}
|
|
87
87
|
willBeVisible(targetPosition) {
|
|
88
88
|
return this.rect.x + targetPosition < window.innerWidth * 1.5 && this.rect.x + targetPosition + this.rect.width > window.innerWidth * -0.5;
|
|
@@ -52,6 +52,9 @@ export default class SliderItem extends Base {
|
|
|
52
52
|
/**
|
|
53
53
|
* Ticked hook.
|
|
54
54
|
*
|
|
55
|
+
* @todo create AbstractSliderItem with `render` method
|
|
56
|
+
* @todo add state to SliderItem
|
|
57
|
+
* @todo add origin to SliderItem
|
|
55
58
|
* @returns {void}
|
|
56
59
|
*/
|
|
57
60
|
ticked(): void;
|
|
@@ -82,7 +85,8 @@ export default class SliderItem extends Base {
|
|
|
82
85
|
*/
|
|
83
86
|
moveInstantly(targetPosition: number): void;
|
|
84
87
|
/**
|
|
85
|
-
* Render the
|
|
88
|
+
* Render the component.
|
|
89
|
+
*
|
|
86
90
|
* @returns {void}
|
|
87
91
|
*/
|
|
88
92
|
render(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Base as
|
|
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,.2,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};
|
|
@@ -34,9 +34,13 @@ var import_utils = require("@studiometa/js-toolkit/utils");
|
|
|
34
34
|
var import_AbstractSliderChild = __toESM(require("./AbstractSliderChild.cjs"), 1);
|
|
35
35
|
var SliderProgress = class extends import_AbstractSliderChild.default {
|
|
36
36
|
update(index) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
import_utils.domScheduler.read(() => {
|
|
38
|
+
const unit = this.$refs.progress.clientWidth / (this.$parent.indexMax + 1);
|
|
39
|
+
import_utils.domScheduler.write(() => {
|
|
40
|
+
this.$refs.progress.style.transform = (0, import_utils.matrix)({
|
|
41
|
+
translateX: (0, import_utils.map)(index, 0, this.$parent.indexMax, (this.$refs.progress.clientWidth - unit) * -1, 0)
|
|
42
|
+
});
|
|
43
|
+
});
|
|
40
44
|
});
|
|
41
45
|
}
|
|
42
46
|
};
|
|
@@ -17,6 +17,14 @@ export default class SliderProgress extends AbstractSliderChild {
|
|
|
17
17
|
name: string;
|
|
18
18
|
refs: string[];
|
|
19
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Update the progress indicator.
|
|
22
|
+
*
|
|
23
|
+
* @this {SliderProgressInterface}
|
|
24
|
+
* @param {number} index The new active index.
|
|
25
|
+
* @returns {void}
|
|
26
|
+
*/
|
|
27
|
+
update(this: SliderProgressInterface, index: number): void;
|
|
20
28
|
}
|
|
21
29
|
export type SliderProgressInterface = SliderProgress & {
|
|
22
30
|
$refs: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{matrix as t,map as
|
|
1
|
+
import{matrix as t,map as i,domScheduler as r}from"@studiometa/js-toolkit/utils";import a from"./AbstractSliderChild.js";class o extends a{static config={name:"SliderProgress",refs:["progress"]};update(e){r.read(()=>{const s=this.$refs.progress.clientWidth/(this.$parent.indexMax+1);r.write(()=>{this.$refs.progress.style.transform=t({translateX:i(e,0,this.$parent.indexMax,(this.$refs.progress.clientWidth-s)*-1,0)})})})}}export{o as default};
|
|
@@ -55,14 +55,8 @@ var _Frame = class extends import_js_toolkit.Base {
|
|
|
55
55
|
}
|
|
56
56
|
return this.$children[name].filter((child) => this.$children.Frame.every((frame) => frame.$children[name] ? !frame.$children[name].includes(child) : true));
|
|
57
57
|
}
|
|
58
|
-
get
|
|
59
|
-
return
|
|
60
|
-
}
|
|
61
|
-
get directChildFrameForm() {
|
|
62
|
-
return this.getDirectChild("form");
|
|
63
|
-
}
|
|
64
|
-
get directChildFrameTarget() {
|
|
65
|
-
return this.getDirectChild("FrameTarget");
|
|
58
|
+
get directChildrenFrameTarget() {
|
|
59
|
+
return (0, import_js_toolkit.getDirectChildren)(this, "Frame", "FrameTarget");
|
|
66
60
|
}
|
|
67
61
|
mounted() {
|
|
68
62
|
if (this.$options.history) {
|
|
@@ -93,11 +87,11 @@ var _Frame = class extends import_js_toolkit.Base {
|
|
|
93
87
|
onWindowPopstate(event) {
|
|
94
88
|
this.goTo(window.location.href, event.state);
|
|
95
89
|
}
|
|
96
|
-
|
|
97
|
-
if (!
|
|
90
|
+
onFrameAnchorClick(index, event) {
|
|
91
|
+
if (!(0, import_js_toolkit.isDirectChild)(this, "Frame", "FrameAnchor", this.$children.FrameAnchor[index])) {
|
|
98
92
|
return;
|
|
99
93
|
}
|
|
100
|
-
this.$log("onAFrameClick",
|
|
94
|
+
this.$log("onAFrameClick", index, event);
|
|
101
95
|
event.preventDefault();
|
|
102
96
|
const anchor = this.$children.FrameAnchor[index];
|
|
103
97
|
if (anchor.href === window.location.href) {
|
|
@@ -105,14 +99,16 @@ var _Frame = class extends import_js_toolkit.Base {
|
|
|
105
99
|
}
|
|
106
100
|
this.goTo(anchor.href);
|
|
107
101
|
}
|
|
108
|
-
|
|
109
|
-
if (!
|
|
102
|
+
onFrameFormSubmit(index, event) {
|
|
103
|
+
if (!(0, import_js_toolkit.isDirectChild)(this, "Frame", "FrameForm", this.$children.FrameForm[index])) {
|
|
110
104
|
return;
|
|
111
105
|
}
|
|
112
|
-
this.$log("onFrameFormFrameSubmit", event);
|
|
106
|
+
this.$log("onFrameFormFrameSubmit", index, event);
|
|
113
107
|
event.preventDefault();
|
|
114
108
|
const form = this.$children.FrameForm[index];
|
|
115
|
-
|
|
109
|
+
const url = new URL(form.action);
|
|
110
|
+
url.search = new URLSearchParams(new FormData(form.$el)).toString();
|
|
111
|
+
this.goTo(url.toString());
|
|
116
112
|
}
|
|
117
113
|
parseHTML(string = "") {
|
|
118
114
|
return new DOMParser().parseFromString(string, "text/html");
|
|
@@ -131,10 +127,10 @@ var _Frame = class extends import_js_toolkit.Base {
|
|
|
131
127
|
newFrame.$children.registerAll();
|
|
132
128
|
this.$emit("after-fetch", url, content);
|
|
133
129
|
this.$emit("before-leave");
|
|
134
|
-
await Promise.all(this.
|
|
130
|
+
await Promise.all(this.directChildrenFrameTarget.map((target) => target.leave()));
|
|
135
131
|
this.$emit("after-leave");
|
|
136
132
|
this.$emit("before-content");
|
|
137
|
-
this.
|
|
133
|
+
this.directChildrenFrameTarget.map((target, index) => target.updateContent(newFrame.directChildrenFrameTarget[index]));
|
|
138
134
|
if (this.$options.history) {
|
|
139
135
|
document.title = doc.title;
|
|
140
136
|
(0, import_utils.historyPush)({ path: parsedUrl.pathname, search: parsedUrl.searchParams });
|
|
@@ -148,7 +144,7 @@ var _Frame = class extends import_js_toolkit.Base {
|
|
|
148
144
|
await (0, import_utils.nextFrame)();
|
|
149
145
|
this.$emit("after-content");
|
|
150
146
|
this.$emit("before-enter");
|
|
151
|
-
await Promise.all(this.
|
|
147
|
+
await Promise.all(this.directChildrenFrameTarget.map((target) => target.enter()));
|
|
152
148
|
this.$emit("after-enter");
|
|
153
149
|
}
|
|
154
150
|
async fetch(url) {
|
|
@@ -196,7 +192,6 @@ __publicField(Frame, "config", {
|
|
|
196
192
|
"before-enter",
|
|
197
193
|
"after-enter"
|
|
198
194
|
],
|
|
199
|
-
log: true,
|
|
200
195
|
components: {
|
|
201
196
|
FrameAnchor: import_FrameAnchor.default,
|
|
202
197
|
FrameForm: import_FrameForm.default,
|
|
@@ -24,7 +24,6 @@ export default class Frame extends Base {
|
|
|
24
24
|
static config: {
|
|
25
25
|
name: string;
|
|
26
26
|
emits: string[];
|
|
27
|
-
log: boolean;
|
|
28
27
|
components: {
|
|
29
28
|
FrameAnchor: typeof FrameAnchor;
|
|
30
29
|
FrameForm: typeof FrameForm;
|
|
@@ -48,21 +47,11 @@ export default class Frame extends Base {
|
|
|
48
47
|
* @returns {any[]}
|
|
49
48
|
*/
|
|
50
49
|
getDirectChild(this: FrameInterface, name: string): any[];
|
|
51
|
-
/**
|
|
52
|
-
* Get direct `FrameAnchor` children.
|
|
53
|
-
* @returns {FrameAnchor[]}
|
|
54
|
-
*/
|
|
55
|
-
get directChildFrameAnchor(): FrameAnchor[];
|
|
56
|
-
/**
|
|
57
|
-
* Get direct `FrameForm` children.
|
|
58
|
-
* @returns {FrameForm[]}
|
|
59
|
-
*/
|
|
60
|
-
get directChildFrameForm(): FrameForm[];
|
|
61
50
|
/**
|
|
62
51
|
* Get direct `FrameTarget` children.
|
|
63
52
|
* @returns {FrameTarget[]}
|
|
64
53
|
*/
|
|
65
|
-
get
|
|
54
|
+
get directChildrenFrameTarget(): FrameTarget[];
|
|
66
55
|
/**
|
|
67
56
|
* Mounted hook.
|
|
68
57
|
* @returns {void}
|
|
@@ -96,20 +85,20 @@ export default class Frame extends Base {
|
|
|
96
85
|
* Prevent click on `FrameAnchor`.
|
|
97
86
|
*
|
|
98
87
|
* @this {FrameInterface}
|
|
99
|
-
* @param {MouseEvent} event
|
|
100
88
|
* @param {number} index
|
|
89
|
+
* @param {MouseEvent} event
|
|
101
90
|
* @returns {void}
|
|
102
91
|
*/
|
|
103
|
-
|
|
92
|
+
onFrameAnchorClick(this: FrameInterface, index: number, event: MouseEvent): void;
|
|
104
93
|
/**
|
|
105
94
|
* Prevent submit on forms.
|
|
106
95
|
*
|
|
107
96
|
* @this {FrameInterface}
|
|
108
|
-
* @param {SubmitEvent} event
|
|
109
97
|
* @param {number} index
|
|
98
|
+
* @param {SubmitEvent} event
|
|
110
99
|
* @returns {void}
|
|
111
100
|
*/
|
|
112
|
-
|
|
101
|
+
onFrameFormSubmit(this: FrameInterface, index: number, event: SubmitEvent): void;
|
|
113
102
|
/**
|
|
114
103
|
* Parge an HTML string into a DOM object.
|
|
115
104
|
* @param {string} string
|
|
@@ -147,6 +136,6 @@ export type FrameInterface = Frame & {
|
|
|
147
136
|
};
|
|
148
137
|
};
|
|
149
138
|
import { Base } from "@studiometa/js-toolkit";
|
|
139
|
+
import FrameTarget from "./FrameTarget.js";
|
|
150
140
|
import FrameAnchor from "./FrameAnchor.js";
|
|
151
141
|
import FrameForm from "./FrameForm.js";
|
|
152
|
-
import FrameTarget from "./FrameTarget.js";
|
package/organisms/Frame/Frame.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Base as
|
|
1
|
+
import{Base as f,isDirectChild as c,getDirectChildren as p}from"@studiometa/js-toolkit";import{nextFrame as m,historyPush as w}from"@studiometa/js-toolkit/utils";import g from"./FrameAnchor.js";import F from"./FrameForm.js";import u from"./FrameTarget.js";function $(){return{left:window.pageXOffset,top:window.pageYOffset}}const a=new Map;class s extends f{static config={name:"Frame",emits:["before-fetch","after-fetch","before-leave","after-leave","before-content","after-content","before-enter","after-enter"],components:{FrameAnchor:g,FrameForm:F,FrameTarget:u,Frame:s},options:{history:Boolean}};get id(){return this.$el.id}getDirectChild(e){return this.$children[e]?this.$children.Frame?this.$children[e].filter(r=>this.$children.Frame.every(t=>t.$children[e]?!t.$children[e].includes(r):!0)):this.$children[e]:[]}get directChildrenFrameTarget(){return p(this,"Frame","FrameTarget")}mounted(){this.$options.history&&window.addEventListener("popstate",this)}destroyed(){window.removeEventListener("popstate",this)}handleEvent(e){e.type==="popstate"&&this.onWindowPopstate(e),e.type==="beforeunload"&&this.onWindowUnload()}onWindowUnload(){const{history:e}=window;!e.state||e.replaceState({...e.state,scroll:$()},"")}onWindowPopstate(e){this.goTo(window.location.href,e.state)}onFrameAnchorClick(e,r){if(!c(this,"Frame","FrameAnchor",this.$children.FrameAnchor[e]))return;this.$log("onAFrameClick",e,r),r.preventDefault();const t=this.$children.FrameAnchor[e];t.href!==window.location.href&&this.goTo(t.href)}onFrameFormSubmit(e,r){if(!c(this,"Frame","FrameForm",this.$children.FrameForm[e]))return;this.$log("onFrameFormFrameSubmit",e,r),r.preventDefault();const t=this.$children.FrameForm[e],i=new URL(t.action);i.search=new URLSearchParams(new FormData(t.$el)).toString(),this.goTo(i.toString())}parseHTML(e=""){return new DOMParser().parseFromString(e,"text/html")}async goTo(e,r=null){this.$log("goTo",e);const t=new URL(e);if(t.origin!==window.location.origin)throw new Error("Cross origin request are not allowed.");this.$emit("before-fetch",e);const i=await this.fetch(e),n=this.parseHTML(i),l=n.querySelector(`#${this.id}`),h=new s(l);h.$children.registerAll(),this.$emit("after-fetch",e,i),this.$emit("before-leave"),await Promise.all(this.directChildrenFrameTarget.map(o=>o.leave())),this.$emit("after-leave"),this.$emit("before-content"),this.directChildrenFrameTarget.map((o,d)=>o.updateContent(h.directChildrenFrameTarget[d])),this.$options.history&&(document.title=n.title,w({path:t.pathname,search:t.searchParams})),r&&(document.scrollingElement.scrollTop=r.top,document.scrollingElement.scrollLeft=r.left),await m(),this.$root.$update(),await m(),this.$emit("after-content"),this.$emit("before-enter"),await Promise.all(this.directChildrenFrameTarget.map(o=>o.enter())),this.$emit("after-enter")}async fetch(e){const r=a.get(e);if(r)return r.status==="pending"?r.promise:r.content;const t=fetch(e);try{a.set(e,{promise:t,status:"pending",content:void 0});const i=await t.then(n=>n.text());return a.set(e,{promise:t,status:"resolved",content:i}),i}catch(i){return a.set(e,{promise:t,status:"error",content:i}),i}}}export{s as default};
|
|
@@ -32,12 +32,8 @@ var FrameAnchor = class extends import_js_toolkit.Base {
|
|
|
32
32
|
get href() {
|
|
33
33
|
return this.$el.href;
|
|
34
34
|
}
|
|
35
|
-
onClick(event) {
|
|
36
|
-
this.$emit("frame-click", event);
|
|
37
|
-
}
|
|
38
35
|
};
|
|
39
36
|
__publicField(FrameAnchor, "config", {
|
|
40
|
-
name: "FrameAnchor"
|
|
41
|
-
emits: ["frame-click"]
|
|
37
|
+
name: "FrameAnchor"
|
|
42
38
|
});
|
|
43
39
|
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -12,7 +12,6 @@ export default class FrameAnchor extends Base {
|
|
|
12
12
|
*/
|
|
13
13
|
static config: {
|
|
14
14
|
name: string;
|
|
15
|
-
emits: string[];
|
|
16
15
|
};
|
|
17
16
|
/**
|
|
18
17
|
* Get the URL.
|
|
@@ -21,13 +20,6 @@ export default class FrameAnchor extends Base {
|
|
|
21
20
|
* @returns {string}
|
|
22
21
|
*/
|
|
23
22
|
get href(): string;
|
|
24
|
-
/**
|
|
25
|
-
* Dispatch the link click event.
|
|
26
|
-
*
|
|
27
|
-
* @param {MouseEvent} event
|
|
28
|
-
* @returns {void}
|
|
29
|
-
*/
|
|
30
|
-
onClick(event: MouseEvent): void;
|
|
31
23
|
}
|
|
32
24
|
export type FrameAnchorInterface = FrameAnchor & {
|
|
33
25
|
$el: HTMLAnchorElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Base as
|
|
1
|
+
import{Base as e}from"@studiometa/js-toolkit";class r extends e{static config={name:"FrameAnchor"};get href(){return this.$el.href}}export{r as default};
|