@studiometa/ui 0.2.8 → 0.2.9
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 +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/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 -2
- 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/organisms/Frame/Frame.cjs +9 -15
- package/organisms/Frame/Frame.d.ts +4 -14
- 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
package/atoms/Cursor/Cursor.cjs
CHANGED
|
@@ -51,7 +51,7 @@ var Cursor = class extends import_js_toolkit.Base {
|
|
|
51
51
|
}
|
|
52
52
|
this.pointerX = x;
|
|
53
53
|
this.pointerY = y;
|
|
54
|
-
let scale =
|
|
54
|
+
let { scale } = this.$options;
|
|
55
55
|
if (!event) {
|
|
56
56
|
this.pointerScale = scale;
|
|
57
57
|
return;
|
|
@@ -96,6 +96,10 @@ __publicField(Cursor, "config", {
|
|
|
96
96
|
type: String,
|
|
97
97
|
default: "[data-cursor-shrink], [data-cursor-shrink] *"
|
|
98
98
|
},
|
|
99
|
+
scale: {
|
|
100
|
+
type: Number,
|
|
101
|
+
default: 1
|
|
102
|
+
},
|
|
99
103
|
growTo: {
|
|
100
104
|
type: Number,
|
|
101
105
|
default: 2
|
package/atoms/Cursor/Cursor.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* @typedef {Object} CursorOptions
|
|
7
7
|
* @property {string} growSelectors
|
|
8
8
|
* @property {string} shrinkSelectors
|
|
9
|
+
* @property {number} scale
|
|
9
10
|
* @property {number} growTo
|
|
10
11
|
* @property {number} shrinkTo
|
|
11
12
|
* @property {number} translateDampFactor
|
|
@@ -37,6 +38,10 @@ export default class Cursor extends Base {
|
|
|
37
38
|
type: StringConstructor;
|
|
38
39
|
default: string;
|
|
39
40
|
};
|
|
41
|
+
scale: {
|
|
42
|
+
type: NumberConstructor;
|
|
43
|
+
default: number;
|
|
44
|
+
};
|
|
40
45
|
growTo: {
|
|
41
46
|
type: NumberConstructor;
|
|
42
47
|
default: number;
|
|
@@ -125,6 +130,7 @@ export type BaseOptions = import('@studiometa/js-toolkit/Base').BaseOptions;
|
|
|
125
130
|
export type CursorOptions = {
|
|
126
131
|
growSelectors: string;
|
|
127
132
|
shrinkSelectors: string;
|
|
133
|
+
scale: number;
|
|
128
134
|
growTo: number;
|
|
129
135
|
shrinkTo: number;
|
|
130
136
|
translateDampFactor: number;
|
package/atoms/Cursor/Cursor.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Base as n}from"@studiometa/js-toolkit";import{damp as a,matrix as c}from"@studiometa/js-toolkit/utils";class l extends n{static config={name:"Cursor",options:{growSelectors:{type:String,default:"a, a *, button, button *, [data-cursor-grow], [data-cursor-grow] *"},shrinkSelectors:{type:String,default:"[data-cursor-shrink], [data-cursor-shrink] *"},growTo:{type:Number,default:2},shrinkTo:{type:Number,default:.5},translateDampFactor:{type:Number,default:.25},growDampFactor:{type:Number,default:.25},shrinkDampFactor:{type:Number,default:.25}}};x=0;y=0;scale=0;pointerX=0;pointerY=0;pointerScale=0;mounted(){this.x=0,this.y=0,this.scale=0,this.pointerX=0,this.pointerY=0,this.pointerScale=0,this.render({x:this.x,y:this.y,scale:this.scale})}moved({event:t,x:i,y:s,isDown:r}){this.$services.has("ticked")||this.$services.enable("ticked"),this.pointerX=i,this.pointerY=s;let
|
|
1
|
+
import{Base as n}from"@studiometa/js-toolkit";import{damp as a,matrix as c}from"@studiometa/js-toolkit/utils";class l extends n{static config={name:"Cursor",options:{growSelectors:{type:String,default:"a, a *, button, button *, [data-cursor-grow], [data-cursor-grow] *"},shrinkSelectors:{type:String,default:"[data-cursor-shrink], [data-cursor-shrink] *"},scale:{type:Number,default:1},growTo:{type:Number,default:2},shrinkTo:{type:Number,default:.5},translateDampFactor:{type:Number,default:.25},growDampFactor:{type:Number,default:.25},shrinkDampFactor:{type:Number,default:.25}}};x=0;y=0;scale=0;pointerX=0;pointerY=0;pointerScale=0;mounted(){this.x=0,this.y=0,this.scale=0,this.pointerX=0,this.pointerY=0,this.pointerScale=0,this.render({x:this.x,y:this.y,scale:this.scale})}moved({event:t,x:i,y:s,isDown:r}){this.$services.has("ticked")||this.$services.enable("ticked"),this.pointerX=i,this.pointerY=s;let{scale:e}=this.$options;if(!t){this.pointerScale=e;return}const o=t.target instanceof Element&&t.target.matches(this.$options.growSelectors)||!1,h=r||t.target instanceof Element&&t.target.matches(this.$options.shrinkSelectors)||!1;o&&(e=this.$options.growTo),h&&(e=this.$options.shrinkTo),this.pointerScale=e}ticked(){this.x=a(this.pointerX,this.x,this.$options.translateDampFactor),this.y=a(this.pointerY,this.y,this.$options.translateDampFactor),this.scale=a(this.pointerScale,this.scale,this.pointerScale<this.scale?this.$options.shrinkDampFactor:this.$options.growDampFactor),this.render({x:this.x,y:this.y,scale:this.scale}),this.x===this.pointerX&&this.y===this.pointerY&&this.scale===this.pointerScale&&this.$services.disable("ticked")}render({x:t,y:i,scale:s}){const r=c({translateX:t,translateY:i,scaleX:s,scaleY:s});this.$el.style.transform=`translateZ(0) ${r}`}}export{l as default};
|
|
@@ -30,11 +30,11 @@ module.exports = __toCommonJS(LargeText_exports);
|
|
|
30
30
|
var import_js_toolkit = require("@studiometa/js-toolkit");
|
|
31
31
|
var import_utils = require("@studiometa/js-toolkit/utils");
|
|
32
32
|
var LargeText = class extends (0, import_js_toolkit.withMountWhenInView)(import_js_toolkit.Base, { rootMargin: "50%" }) {
|
|
33
|
-
|
|
33
|
+
x = 0;
|
|
34
34
|
deltaY = 0;
|
|
35
35
|
transform = {
|
|
36
36
|
skewX: 0,
|
|
37
|
-
|
|
37
|
+
x: 0
|
|
38
38
|
};
|
|
39
39
|
width = 0;
|
|
40
40
|
mounted() {
|
|
@@ -47,17 +47,17 @@ var LargeText = class extends (0, import_js_toolkit.withMountWhenInView)(import_
|
|
|
47
47
|
this.deltaY = props.delta.y;
|
|
48
48
|
}
|
|
49
49
|
ticked() {
|
|
50
|
-
this.
|
|
51
|
-
this.transform.
|
|
50
|
+
this.x -= (Math.abs(this.deltaY) + 1) * this.$options.sensitivity;
|
|
51
|
+
this.transform.x = (0, import_utils.damp)(this.x, this.transform.x, 0.25);
|
|
52
52
|
if (this.$options.skew) {
|
|
53
|
-
this.transform.skewX = (0, import_utils.damp)((0, import_utils.clamp)(this.deltaY
|
|
53
|
+
this.transform.skewX = (0, import_utils.damp)((0, import_utils.clamp)(this.deltaY * -1, -50, 50) * this.$options.skewSensitivity, this.transform.skewX, 0.25);
|
|
54
54
|
}
|
|
55
|
-
if (this.
|
|
56
|
-
this.
|
|
57
|
-
this.transform.
|
|
58
|
-
} else if (this.$options.sensitivity < 0 && this.
|
|
59
|
-
this.
|
|
60
|
-
this.transform.
|
|
55
|
+
if (this.x <= this.width * -1) {
|
|
56
|
+
this.x = 0;
|
|
57
|
+
this.transform.x += this.width;
|
|
58
|
+
} else if (this.$options.sensitivity < 0 && this.x >= this.width) {
|
|
59
|
+
this.x = 0;
|
|
60
|
+
this.transform.x -= this.width;
|
|
61
61
|
}
|
|
62
62
|
return () => {
|
|
63
63
|
(0, import_utils.transform)(this.$refs.target, this.transform);
|
|
@@ -34,7 +34,7 @@ export default class LargeText extends Base {
|
|
|
34
34
|
* Translate X.
|
|
35
35
|
* @type {number}
|
|
36
36
|
*/
|
|
37
|
-
|
|
37
|
+
x: number;
|
|
38
38
|
/**
|
|
39
39
|
* Scroll delta Y.
|
|
40
40
|
* @type {number}
|
|
@@ -45,7 +45,7 @@ export default class LargeText extends Base {
|
|
|
45
45
|
*/
|
|
46
46
|
transform: {
|
|
47
47
|
skewX: number;
|
|
48
|
-
|
|
48
|
+
x: number;
|
|
49
49
|
};
|
|
50
50
|
/**
|
|
51
51
|
* Target width.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Base as
|
|
1
|
+
import{Base as s,withMountWhenInView as e}from"@studiometa/js-toolkit";import{damp as t,clamp as h,transform as r}from"@studiometa/js-toolkit/utils";class a extends e(s,{rootMargin:"50%"}){static config={name:"LargeText",refs:["target"],options:{skew:Boolean,sensitivity:{type:Number,default:1},skewSensitivity:{type:Number,default:1}}};x=0;deltaY=0;transform={skewX:0,x:0};width=0;mounted(){this.width=this.$refs.target.clientWidth}resized(){this.width=this.$refs.target.clientWidth}scrolled(i){this.deltaY=i.delta.y}ticked(){return this.x-=(Math.abs(this.deltaY)+1)*this.$options.sensitivity,this.transform.x=t(this.x,this.transform.x,.25),this.$options.skew&&(this.transform.skewX=t(h(this.deltaY*-1,-50,50)*this.$options.skewSensitivity,this.transform.skewX,.25)),this.x<=this.width*-1?(this.x=0,this.transform.x+=this.width):this.$options.sensitivity<0&&this.x>=this.width&&(this.x=0,this.transform.x-=this.width),()=>{r(this.$refs.target,this.transform)}}}export{a as default};
|
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) {
|
|
@@ -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 n 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 s extends n{static config={...n.config,name:"MenuList",emits:["items-open","items-close","items-mouseleave"],components:{MenuList:s}};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(
|
|
1
|
+
import n 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 s extends n{static config={...n.config,name:"MenuList",emits:["items-open","items-close","items-mouseleave"],components:{MenuList:s}};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(){console.log(this.$id,"toggle",this.isOpen),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{s 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 %}
|
|
@@ -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("FrameForm");
|
|
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,8 +87,8 @@ 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(event, index) {
|
|
91
|
+
if (!(0, import_js_toolkit.isDirectChild)(this, "Frame", "FrameAnchor", this.$children.FrameAnchor[index])) {
|
|
98
92
|
return;
|
|
99
93
|
}
|
|
100
94
|
this.$log("onAFrameClick", event, index);
|
|
@@ -105,8 +99,8 @@ var _Frame = class extends import_js_toolkit.Base {
|
|
|
105
99
|
}
|
|
106
100
|
this.goTo(anchor.href);
|
|
107
101
|
}
|
|
108
|
-
|
|
109
|
-
if (!
|
|
102
|
+
onFrameFormSubmit(event, index) {
|
|
103
|
+
if (!(0, import_js_toolkit.isDirectChild)(this, "Frame", "FrameForm", this.$children.FrameForm[index])) {
|
|
110
104
|
return;
|
|
111
105
|
}
|
|
112
106
|
this.$log("onFrameFormFrameSubmit", event);
|
|
@@ -133,10 +127,10 @@ var _Frame = class extends import_js_toolkit.Base {
|
|
|
133
127
|
newFrame.$children.registerAll();
|
|
134
128
|
this.$emit("after-fetch", url, content);
|
|
135
129
|
this.$emit("before-leave");
|
|
136
|
-
await Promise.all(this.
|
|
130
|
+
await Promise.all(this.directChildrenFrameTarget.map((target) => target.leave()));
|
|
137
131
|
this.$emit("after-leave");
|
|
138
132
|
this.$emit("before-content");
|
|
139
|
-
this.
|
|
133
|
+
this.directChildrenFrameTarget.map((target, index) => target.updateContent(newFrame.directChildrenFrameTarget[index]));
|
|
140
134
|
if (this.$options.history) {
|
|
141
135
|
document.title = doc.title;
|
|
142
136
|
(0, import_utils.historyPush)({ path: parsedUrl.pathname, search: parsedUrl.searchParams });
|
|
@@ -150,7 +144,7 @@ var _Frame = class extends import_js_toolkit.Base {
|
|
|
150
144
|
await (0, import_utils.nextFrame)();
|
|
151
145
|
this.$emit("after-content");
|
|
152
146
|
this.$emit("before-enter");
|
|
153
|
-
await Promise.all(this.
|
|
147
|
+
await Promise.all(this.directChildrenFrameTarget.map((target) => target.enter()));
|
|
154
148
|
this.$emit("after-enter");
|
|
155
149
|
}
|
|
156
150
|
async fetch(url) {
|
|
@@ -48,21 +48,11 @@ export default class Frame extends Base {
|
|
|
48
48
|
* @returns {any[]}
|
|
49
49
|
*/
|
|
50
50
|
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
51
|
/**
|
|
62
52
|
* Get direct `FrameTarget` children.
|
|
63
53
|
* @returns {FrameTarget[]}
|
|
64
54
|
*/
|
|
65
|
-
get
|
|
55
|
+
get directChildrenFrameTarget(): FrameTarget[];
|
|
66
56
|
/**
|
|
67
57
|
* Mounted hook.
|
|
68
58
|
* @returns {void}
|
|
@@ -100,7 +90,7 @@ export default class Frame extends Base {
|
|
|
100
90
|
* @param {number} index
|
|
101
91
|
* @returns {void}
|
|
102
92
|
*/
|
|
103
|
-
|
|
93
|
+
onFrameAnchorClick(this: FrameInterface, event: MouseEvent, index: number): void;
|
|
104
94
|
/**
|
|
105
95
|
* Prevent submit on forms.
|
|
106
96
|
*
|
|
@@ -109,7 +99,7 @@ export default class Frame extends Base {
|
|
|
109
99
|
* @param {number} index
|
|
110
100
|
* @returns {void}
|
|
111
101
|
*/
|
|
112
|
-
|
|
102
|
+
onFrameFormSubmit(this: FrameInterface, event: SubmitEvent, index: number): void;
|
|
113
103
|
/**
|
|
114
104
|
* Parge an HTML string into a DOM object.
|
|
115
105
|
* @param {string} string
|
|
@@ -147,6 +137,6 @@ export type FrameInterface = Frame & {
|
|
|
147
137
|
};
|
|
148
138
|
};
|
|
149
139
|
import { Base } from "@studiometa/js-toolkit";
|
|
140
|
+
import FrameTarget from "./FrameTarget.js";
|
|
150
141
|
import FrameAnchor from "./FrameAnchor.js";
|
|
151
142
|
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"],log:!0,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(t=>this.$children.Frame.every(r=>r.$children[e]?!r.$children[e].includes(t):!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,t){if(!c(this,"Frame","FrameAnchor",this.$children.FrameAnchor[t]))return;this.$log("onAFrameClick",e,t),e.preventDefault();const r=this.$children.FrameAnchor[t];r.href!==window.location.href&&this.goTo(r.href)}onFrameFormSubmit(e,t){if(!c(this,"Frame","FrameForm",this.$children.FrameForm[t]))return;this.$log("onFrameFormFrameSubmit",e),e.preventDefault();const r=this.$children.FrameForm[t],i=new URL(r.action);i.search=new URLSearchParams(new FormData(r.$el)).toString(),this.goTo(i.toString())}parseHTML(e=""){return new DOMParser().parseFromString(e,"text/html")}async goTo(e,t=null){this.$log("goTo",e);const r=new URL(e);if(r.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:r.pathname,search:r.searchParams})),t&&(document.scrollingElement.scrollTop=t.top,document.scrollingElement.scrollLeft=t.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 t=a.get(e);if(t)return t.status==="pending"?t.promise:t.content;const r=fetch(e);try{a.set(e,{promise:r,status:"pending",content:void 0});const i=await r.then(n=>n.text());return a.set(e,{promise:r,status:"resolved",content:i}),i}catch(i){return a.set(e,{promise:r,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};
|
|
@@ -32,12 +32,8 @@ var FrameForm = class extends import_js_toolkit.Base {
|
|
|
32
32
|
get action() {
|
|
33
33
|
return this.$el.action;
|
|
34
34
|
}
|
|
35
|
-
onSubmit(event) {
|
|
36
|
-
this.$emit("frame-submit", event);
|
|
37
|
-
}
|
|
38
35
|
};
|
|
39
36
|
__publicField(FrameForm, "config", {
|
|
40
|
-
name: "FrameForm"
|
|
41
|
-
emits: ["frame-submit"]
|
|
37
|
+
name: "FrameForm"
|
|
42
38
|
});
|
|
43
39
|
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
export default class FrameForm extends Base {
|
|
10
10
|
static config: {
|
|
11
11
|
name: string;
|
|
12
|
-
emits: string[];
|
|
13
12
|
};
|
|
14
13
|
/**
|
|
15
14
|
* Get the form action.
|
|
@@ -18,13 +17,6 @@ export default class FrameForm extends Base {
|
|
|
18
17
|
* @returns {string}
|
|
19
18
|
*/
|
|
20
19
|
get action(): string;
|
|
21
|
-
/**
|
|
22
|
-
* Dispatch the form `submit` event.
|
|
23
|
-
*
|
|
24
|
-
* @param {SubmitEvent} event
|
|
25
|
-
* @returns {void}
|
|
26
|
-
*/
|
|
27
|
-
onSubmit(event: SubmitEvent): void;
|
|
28
20
|
}
|
|
29
21
|
export type FrameFormInterface = FrameForm & {
|
|
30
22
|
$el: HTMLFormElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Base as e}from"@studiometa/js-toolkit";class
|
|
1
|
+
import{Base as e}from"@studiometa/js-toolkit";class t extends e{static config={name:"FrameForm"};get action(){return this.$el.action}}export{t as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studiometa/ui",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "A set of opiniated, unstyled and accessible components",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://github.com/studiometa/ui#readme",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@studiometa/js-toolkit": "^2.
|
|
32
|
+
"@studiometa/js-toolkit": "^2.4.1",
|
|
33
33
|
"deepmerge": "^4.2.2"
|
|
34
34
|
}
|
|
35
35
|
}
|