@studiometa/ui 0.2.8 → 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/Cursor/Cursor.cjs +5 -1
- package/atoms/Cursor/Cursor.d.ts +6 -0
- package/atoms/Cursor/Cursor.js +1 -1
- 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/LargeText/LargeText.cjs +11 -11
- package/atoms/LargeText/LargeText.d.ts +2 -2
- package/atoms/LargeText/LargeText.js +1 -1
- package/atoms/LargeText/LargeText.twig +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/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 +12 -14
- 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/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/Frame.cjs +11 -18
- 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/organisms/Frame/FrameTarget.d.ts +16 -10
- package/package.json +2 -2
- package/primitives/Transition/Transition.cjs +3 -41
- package/primitives/Transition/Transition.d.ts +6 -66
- package/primitives/Transition/Transition.js +1 -1
|
@@ -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";
|
package/molecules/Menu/Menu.cjs
CHANGED
|
@@ -35,20 +35,11 @@ var import_utils = require("@studiometa/js-toolkit/utils");
|
|
|
35
35
|
var import_MenuBtn = __toESM(require("./MenuBtn.cjs"), 1);
|
|
36
36
|
var import_MenuList = __toESM(require("./MenuList.cjs"), 1);
|
|
37
37
|
var _Menu = class extends import_js_toolkit.Base {
|
|
38
|
-
getDirectChildren(name) {
|
|
39
|
-
if (!this.$children[name]) {
|
|
40
|
-
return [];
|
|
41
|
-
}
|
|
42
|
-
if (!this.$children.Menu) {
|
|
43
|
-
return this.$children[name];
|
|
44
|
-
}
|
|
45
|
-
return this.$children[name].filter((child) => this.$children.Menu.every((menu) => menu.$children[name] ? !menu.$children[name].includes(child) : true));
|
|
46
|
-
}
|
|
47
38
|
get menuList() {
|
|
48
|
-
return
|
|
39
|
+
return (0, import_js_toolkit.getDirectChildren)(this, "Menu", "MenuList")[0];
|
|
49
40
|
}
|
|
50
41
|
get menuBtn() {
|
|
51
|
-
return
|
|
42
|
+
return (0, import_js_toolkit.getDirectChildren)(this, "Menu", "MenuBtn")[0];
|
|
52
43
|
}
|
|
53
44
|
get shouldReactOnClick() {
|
|
54
45
|
return this.$options.mode === "click";
|
|
@@ -80,18 +71,18 @@ var _Menu = class extends import_js_toolkit.Base {
|
|
|
80
71
|
}
|
|
81
72
|
}
|
|
82
73
|
}
|
|
83
|
-
|
|
84
|
-
if (this.$children.MenuBtn[index]
|
|
74
|
+
onMenuBtnClick(index, event) {
|
|
75
|
+
if ((0, import_js_toolkit.isDirectChild)(this, "Menu", "MenuBtn", this.$children.MenuBtn[index]) && this.shouldReactOnClick) {
|
|
85
76
|
event.preventDefault();
|
|
86
77
|
this.toggle();
|
|
87
78
|
}
|
|
88
79
|
}
|
|
89
|
-
|
|
80
|
+
onMenuBtnMouseenter(index) {
|
|
90
81
|
if (this.$children.MenuBtn[index] === this.menuBtn && !this.shouldReactOnClick) {
|
|
91
82
|
this.open();
|
|
92
83
|
}
|
|
93
84
|
}
|
|
94
|
-
|
|
85
|
+
onMenuBtnMouseleave() {
|
|
95
86
|
if (this.shouldReactOnClick) {
|
|
96
87
|
return;
|
|
97
88
|
}
|
|
@@ -101,7 +92,7 @@ var _Menu = class extends import_js_toolkit.Base {
|
|
|
101
92
|
}
|
|
102
93
|
});
|
|
103
94
|
}
|
|
104
|
-
|
|
95
|
+
onMenuListMouseleave() {
|
|
105
96
|
if (this.shouldReactOnClick) {
|
|
106
97
|
return;
|
|
107
98
|
}
|
package/molecules/Menu/Menu.d.ts
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
* Menu: Menu[],
|
|
5
5
|
* MenuBtn: MenuBtn[],
|
|
6
6
|
* MenuList: MenuList[],
|
|
7
|
+
* },
|
|
8
|
+
* $options: {
|
|
9
|
+
* mode: 'click'|'hover'
|
|
7
10
|
* }
|
|
8
11
|
* }} MenuInterface
|
|
9
12
|
*/
|
|
@@ -29,14 +32,6 @@ export default class Menu extends Base {
|
|
|
29
32
|
};
|
|
30
33
|
};
|
|
31
34
|
};
|
|
32
|
-
/**
|
|
33
|
-
* Get direct children.
|
|
34
|
-
*
|
|
35
|
-
* @this {MenuInterface}
|
|
36
|
-
* @param {string} name
|
|
37
|
-
* @returns {any[]}
|
|
38
|
-
*/
|
|
39
|
-
getDirectChildren(this: MenuInterface, name: string): any[];
|
|
40
35
|
/**
|
|
41
36
|
* Get the first `MenuList` instance.
|
|
42
37
|
*
|
|
@@ -79,31 +74,33 @@ export default class Menu extends Base {
|
|
|
79
74
|
* Toggle menu items on button click;
|
|
80
75
|
*
|
|
81
76
|
* @this {MenuInterface}
|
|
77
|
+
* @param {number} index
|
|
82
78
|
* @param {MouseEvent} event
|
|
83
79
|
* @returns {void}
|
|
84
80
|
*/
|
|
85
|
-
|
|
81
|
+
onMenuBtnClick(this: MenuInterface, index: number, event: MouseEvent): void;
|
|
86
82
|
/**
|
|
87
83
|
* Open menu items on button mouse enter.
|
|
88
84
|
*
|
|
89
85
|
* @this {MenuInterface}
|
|
86
|
+
* @param {number} index
|
|
90
87
|
* @returns {void}
|
|
91
88
|
*/
|
|
92
|
-
|
|
89
|
+
onMenuBtnMouseenter(this: MenuInterface, index: number): void;
|
|
93
90
|
/**
|
|
94
91
|
* Close menu items on button mouse leave.
|
|
95
92
|
*
|
|
96
93
|
* @this {MenuInterface}
|
|
97
94
|
* @returns {void}
|
|
98
95
|
*/
|
|
99
|
-
|
|
96
|
+
onMenuBtnMouseleave(this: MenuInterface): void;
|
|
100
97
|
/**
|
|
101
98
|
* Close menu items on button mouse leave.
|
|
102
99
|
*
|
|
103
100
|
* @this {MenuInterface}
|
|
104
101
|
* @returns {void}
|
|
105
102
|
*/
|
|
106
|
-
|
|
103
|
+
onMenuListMouseleave(this: MenuInterface): void;
|
|
107
104
|
/**
|
|
108
105
|
* Close other non-parent menu items on menu items open.
|
|
109
106
|
*
|
|
@@ -134,6 +131,9 @@ export type MenuInterface = Menu & {
|
|
|
134
131
|
MenuBtn: MenuBtn[];
|
|
135
132
|
MenuList: MenuList[];
|
|
136
133
|
};
|
|
134
|
+
$options: {
|
|
135
|
+
mode: 'click' | 'hover';
|
|
136
|
+
};
|
|
137
137
|
};
|
|
138
138
|
import { Base } from "@studiometa/js-toolkit";
|
|
139
139
|
import MenuList from "./MenuList.js";
|
package/molecules/Menu/Menu.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Base as h}from"@studiometa/js-toolkit";import{nextTick as
|
|
1
|
+
import{Base as h,isDirectChild as r,getDirectChildren as s}from"@studiometa/js-toolkit";import{nextTick as o}from"@studiometa/js-toolkit/utils";import l from"./MenuBtn.js";import c from"./MenuList.js";class n extends h{static config={name:"Menu",debug:!0,components:{MenuBtn:l,MenuList:c,Menu:n},options:{mode:{type:String,default:"click"}}};get menuList(){return s(this,"Menu","MenuList")[0]}get menuBtn(){return s(this,"Menu","MenuBtn")[0]}get shouldReactOnClick(){return this.$options.mode==="click"}get isHover(){return this.menuBtn.isHover||this.menuList.isHover}mounted(){if(!this.menuBtn||!this.menuList){this.$destroy();return}this.menuBtn.$el.setAttribute("aria-controls",this.$id),this.menuList.$el.setAttribute("id",this.$id),this.menuList.close()}keyed({ENTER:t,ESC:e,isUp:i}){if(!!i){if(e){this.close();return}if(!this.shouldReactOnClick){const u=document.activeElement===this.menuBtn.$el;t&&u&&this.toggle()}}}onMenuBtnClick(t,e){r(this,"Menu","MenuBtn",this.$children.MenuBtn[t])&&this.shouldReactOnClick&&(e.preventDefault(),this.toggle())}onMenuBtnMouseenter(t){this.$children.MenuBtn[t]===this.menuBtn&&!this.shouldReactOnClick&&this.open()}onMenuBtnMouseleave(){this.shouldReactOnClick||o(()=>{this.isHover||this.close()})}onMenuListMouseleave(){this.shouldReactOnClick||o(()=>{this.isHover||this.close()})}onMenuListItemsOpen(t){const e=this.$children.MenuList[t];this.$children.MenuList.forEach(i=>{i.$el.contains(e.$el)||i.close()})}close(){this.menuList.close()}open(){this.menuList.open()}toggle(){this.menuList.toggle()}}export{n as default};
|
|
@@ -32,22 +32,18 @@ var MenuBtn = class extends import_js_toolkit.Base {
|
|
|
32
32
|
isHover = false;
|
|
33
33
|
onClick(event) {
|
|
34
34
|
event.stopPropagation();
|
|
35
|
-
this.$emit("btn-click", event);
|
|
36
35
|
}
|
|
37
36
|
onMouseenter(event) {
|
|
38
37
|
this.isHover = true;
|
|
39
38
|
event.stopPropagation();
|
|
40
|
-
this.$emit("btn-mouseenter", event);
|
|
41
39
|
}
|
|
42
40
|
onMouseleave(event) {
|
|
43
41
|
this.isHover = false;
|
|
44
42
|
event.stopPropagation();
|
|
45
|
-
this.$emit("btn-mouseleave", event);
|
|
46
43
|
}
|
|
47
44
|
};
|
|
48
45
|
__publicField(MenuBtn, "config", {
|
|
49
46
|
name: "MenuBtn",
|
|
50
|
-
debug: true
|
|
51
|
-
emits: ["btn-click", "btn-mouseenter", "btn-mouseleave"]
|
|
47
|
+
debug: true
|
|
52
48
|
});
|
|
53
49
|
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Base as
|
|
1
|
+
import{Base as o}from"@studiometa/js-toolkit";class t extends o{static config={name:"MenuBtn",debug:!0};isHover=!1;onClick(e){e.stopPropagation()}onMouseenter(e){this.isHover=!0,e.stopPropagation()}onMouseleave(e){this.isHover=!1,e.stopPropagation()}}export{t as default};
|
|
@@ -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 {
|
|
@@ -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?
|
|
@@ -54,10 +53,9 @@ export default class MenuList extends Transition {
|
|
|
54
53
|
/**
|
|
55
54
|
* Unset hover state.
|
|
56
55
|
*
|
|
57
|
-
* @param {MouseEvent} event
|
|
58
56
|
* @returns {void}
|
|
59
57
|
*/
|
|
60
|
-
onMouseleave(
|
|
58
|
+
onMouseleave(): void;
|
|
61
59
|
/**
|
|
62
60
|
* Display the menu items.
|
|
63
61
|
*
|
|
@@ -98,4 +96,4 @@ export type MenuListInterface = MenuList & {
|
|
|
98
96
|
MenuList: MenuList[];
|
|
99
97
|
};
|
|
100
98
|
};
|
|
101
|
-
|
|
99
|
+
export {};
|
|
@@ -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 %}
|
|
@@ -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;
|