@studiometa/ui 0.2.1 → 0.2.4
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/AnchorScrollTo/AnchorScrollTo.cjs +47 -0
- package/atoms/AnchorScrollTo/AnchorScrollTo.d.ts +31 -0
- package/atoms/AnchorScrollTo/AnchorScrollTo.js +1 -0
- package/atoms/Cursor/Cursor.cjs +14 -22
- package/atoms/Cursor/Cursor.d.ts +2 -2
- package/atoms/Cursor/Cursor.js +1 -103
- package/atoms/Figure/Figure.cjs +9 -14
- package/atoms/Figure/Figure.d.ts +1 -1
- package/atoms/Figure/Figure.js +1 -27
- package/atoms/LargeText/LargeText.cjs +82 -0
- package/atoms/LargeText/LargeText.d.ts +94 -0
- package/atoms/LargeText/LargeText.js +1 -0
- package/atoms/LazyInclude/LazyInclude.cjs +67 -0
- package/atoms/LazyInclude/LazyInclude.d.ts +64 -0
- package/atoms/LazyInclude/LazyInclude.js +1 -0
- package/atoms/Prefetch/AbstractPrefetch.cjs +79 -0
- package/atoms/Prefetch/AbstractPrefetch.d.ts +52 -0
- package/atoms/Prefetch/AbstractPrefetch.js +1 -0
- package/atoms/Prefetch/PrefetchWhenOver.cjs +43 -0
- package/atoms/Prefetch/PrefetchWhenOver.d.ts +21 -0
- package/atoms/Prefetch/PrefetchWhenOver.js +1 -0
- package/atoms/Prefetch/PrefetchWhenVisible.cjs +44 -0
- package/atoms/Prefetch/PrefetchWhenVisible.d.ts +21 -0
- package/atoms/Prefetch/PrefetchWhenVisible.js +1 -0
- package/atoms/Prefetch/index.cjs +33 -0
- package/atoms/Prefetch/index.d.ts +3 -0
- package/atoms/Prefetch/index.js +1 -0
- package/atoms/index.cjs +19 -18
- package/atoms/index.d.ts +5 -1
- package/atoms/index.js +1 -6
- package/index.cjs +11 -15
- package/index.js +1 -3
- package/molecules/Accordion/Accordion.cjs +12 -34
- package/molecules/Accordion/Accordion.js +1 -35
- package/molecules/Accordion/AccordionCore.cjs +8 -13
- package/molecules/Accordion/AccordionCore.d.ts +2 -2
- package/molecules/Accordion/AccordionCore.js +1 -34
- package/molecules/Accordion/AccordionItem.cjs +70 -114
- package/molecules/Accordion/AccordionItem.d.ts +15 -16
- package/molecules/Accordion/AccordionItem.js +1 -178
- package/molecules/Menu/Menu.cjs +148 -0
- package/molecules/Menu/Menu.d.ts +140 -0
- package/molecules/Menu/Menu.js +1 -0
- package/molecules/Menu/MenuBtn.cjs +53 -0
- package/molecules/Menu/MenuBtn.d.ts +39 -0
- package/molecules/Menu/MenuBtn.js +1 -0
- package/molecules/Menu/MenuList.cjs +134 -0
- package/molecules/Menu/MenuList.d.ts +101 -0
- package/molecules/Menu/MenuList.js +1 -0
- package/molecules/Menu/index.cjs +33 -0
- package/molecules/Menu/index.d.ts +3 -0
- package/molecules/Menu/index.js +1 -0
- package/molecules/Modal/Modal.cjs +42 -72
- package/molecules/Modal/Modal.d.ts +11 -11
- package/molecules/Modal/Modal.js +1 -151
- package/molecules/Modal/ModalWithTransition.cjs +70 -0
- package/molecules/Modal/ModalWithTransition.d.ts +29 -0
- package/molecules/Modal/ModalWithTransition.js +1 -0
- package/molecules/Panel/Panel.cjs +114 -0
- package/molecules/Panel/Panel.d.ts +42 -0
- package/molecules/Panel/Panel.js +1 -0
- package/molecules/Slider/AbstractSliderChild.cjs +64 -0
- package/molecules/Slider/AbstractSliderChild.d.ts +59 -0
- package/molecules/Slider/AbstractSliderChild.js +1 -0
- package/molecules/Slider/Slider.cjs +230 -0
- package/molecules/Slider/Slider.d.ts +245 -0
- package/molecules/Slider/Slider.js +1 -0
- package/molecules/Slider/SliderBtn.cjs +58 -0
- package/molecules/Slider/SliderBtn.d.ts +31 -0
- package/molecules/Slider/SliderBtn.js +1 -0
- package/molecules/Slider/SliderCount.cjs +43 -0
- package/molecules/Slider/SliderCount.d.ts +21 -0
- package/molecules/Slider/SliderCount.js +1 -0
- package/molecules/Slider/SliderDots.cjs +48 -0
- package/molecules/Slider/SliderDots.d.ts +33 -0
- package/molecules/Slider/SliderDots.js +1 -0
- package/molecules/Slider/SliderDrag.cjs +40 -0
- package/molecules/Slider/SliderDrag.d.ts +16 -0
- package/molecules/Slider/SliderDrag.js +1 -0
- package/molecules/Slider/SliderItem.cjs +107 -0
- package/molecules/Slider/SliderItem.d.ts +106 -0
- package/molecules/Slider/SliderItem.js +1 -0
- package/molecules/Slider/SliderProgress.cjs +47 -0
- package/molecules/Slider/SliderProgress.d.ts +27 -0
- package/molecules/Slider/SliderProgress.js +1 -0
- package/molecules/Slider/index.cjs +43 -0
- package/molecules/Slider/index.d.ts +8 -0
- package/molecules/Slider/index.js +1 -0
- package/molecules/Sticky/Sticky.cjs +11 -19
- package/molecules/Sticky/Sticky.d.ts +8 -8
- package/molecules/Sticky/Sticky.js +1 -107
- package/molecules/TableOfContent/TableOfContent.cjs +66 -0
- package/molecules/TableOfContent/TableOfContent.d.ts +59 -0
- package/molecules/TableOfContent/TableOfContent.js +1 -0
- package/molecules/TableOfContent/TableOfContentAnchor.cjs +60 -0
- package/molecules/TableOfContent/TableOfContentAnchor.d.ts +36 -0
- package/molecules/TableOfContent/TableOfContentAnchor.js +1 -0
- package/molecules/TableOfContent/index.cjs +31 -0
- package/molecules/TableOfContent/index.d.ts +2 -0
- package/molecules/TableOfContent/index.js +1 -0
- package/molecules/Tabs/Tabs.cjs +54 -82
- package/molecules/Tabs/Tabs.d.ts +7 -8
- package/molecules/Tabs/Tabs.js +1 -126
- package/molecules/index.cjs +18 -17
- package/molecules/index.d.ts +6 -1
- package/molecules/index.js +1 -12
- package/organisms/Frame/Frame.cjs +171 -0
- package/organisms/Frame/Frame.d.ts +119 -0
- package/organisms/Frame/Frame.js +1 -0
- package/organisms/Frame/FrameAnchor.cjs +43 -0
- package/organisms/Frame/FrameAnchor.d.ts +35 -0
- package/organisms/Frame/FrameAnchor.js +1 -0
- package/organisms/Frame/FrameForm.cjs +43 -0
- package/organisms/Frame/FrameForm.d.ts +32 -0
- package/organisms/Frame/FrameForm.js +1 -0
- package/organisms/Frame/FrameTarget.cjs +92 -0
- package/organisms/Frame/FrameTarget.d.ts +47 -0
- package/organisms/Frame/FrameTarget.js +1 -0
- package/organisms/Frame/index.cjs +35 -0
- package/organisms/Frame/index.d.ts +4 -0
- package/organisms/Frame/index.js +1 -0
- package/organisms/index.cjs +9 -12
- package/organisms/index.d.ts +1 -1
- package/organisms/index.js +1 -0
- package/package.json +3 -4
- package/primitives/Draggable/Draggable.cjs +15 -28
- package/primitives/Draggable/Draggable.d.ts +0 -5
- package/primitives/Draggable/Draggable.js +1 -38
- package/primitives/Sentinel/Sentinel.cjs +8 -13
- package/primitives/Sentinel/Sentinel.js +1 -15
- package/primitives/Transition/Transition.cjs +66 -0
- package/primitives/Transition/Transition.d.ts +67 -0
- package/primitives/Transition/Transition.js +1 -0
- package/primitives/index.cjs +12 -17
- package/primitives/index.d.ts +1 -0
- package/primitives/index.js +1 -6
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
var __publicField = (obj, key, value) => {
|
|
23
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
24
|
+
return value;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// packages/ui/molecules/Menu/Menu.js
|
|
28
|
+
var Menu_exports = {};
|
|
29
|
+
__export(Menu_exports, {
|
|
30
|
+
default: () => Menu
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(Menu_exports);
|
|
33
|
+
var import_js_toolkit = require("@studiometa/js-toolkit");
|
|
34
|
+
var import_utils = require("@studiometa/js-toolkit/utils");
|
|
35
|
+
var import_MenuBtn = __toESM(require("./MenuBtn.cjs"), 1);
|
|
36
|
+
var import_MenuList = __toESM(require("./MenuList.cjs"), 1);
|
|
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
|
+
get menuList() {
|
|
48
|
+
return this.getDirectChildren("MenuList")[0];
|
|
49
|
+
}
|
|
50
|
+
get menuBtn() {
|
|
51
|
+
return this.getDirectChildren("MenuBtn")[0];
|
|
52
|
+
}
|
|
53
|
+
get shouldReactOnClick() {
|
|
54
|
+
return this.$options.mode === "click";
|
|
55
|
+
}
|
|
56
|
+
get isHover() {
|
|
57
|
+
return this.menuBtn.isHover || this.menuList.isHover;
|
|
58
|
+
}
|
|
59
|
+
mounted() {
|
|
60
|
+
if (!this.menuBtn || !this.menuList) {
|
|
61
|
+
this.$destroy();
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
this.menuBtn.$el.setAttribute("aria-controls", this.$id);
|
|
65
|
+
this.menuList.$el.setAttribute("id", this.$id);
|
|
66
|
+
this.menuList.close();
|
|
67
|
+
}
|
|
68
|
+
keyed({ ENTER, ESC, isUp }) {
|
|
69
|
+
if (!isUp) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (ESC) {
|
|
73
|
+
this.close();
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (!this.shouldReactOnClick) {
|
|
77
|
+
const hasFocusElementWithin = document.activeElement === this.menuBtn.$el;
|
|
78
|
+
if (ENTER && hasFocusElementWithin) {
|
|
79
|
+
this.toggle();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
onMenuBtnBtnClick(event, index) {
|
|
84
|
+
if (this.$children.MenuBtn[index] === this.menuBtn && this.shouldReactOnClick) {
|
|
85
|
+
event.preventDefault();
|
|
86
|
+
this.toggle();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
onMenuBtnBtnMouseenter(event, index) {
|
|
90
|
+
if (this.$children.MenuBtn[index] === this.menuBtn && !this.shouldReactOnClick) {
|
|
91
|
+
this.open();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
onMenuBtnBtnMouseleave() {
|
|
95
|
+
if (this.shouldReactOnClick) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
(0, import_utils.nextTick)(() => {
|
|
99
|
+
if (!this.isHover) {
|
|
100
|
+
this.close();
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
onMenuListItemsMouseleave() {
|
|
105
|
+
if (this.shouldReactOnClick) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
(0, import_utils.nextTick)(() => {
|
|
109
|
+
if (!this.isHover) {
|
|
110
|
+
this.close();
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
onMenuListItemsOpen(index) {
|
|
115
|
+
const targetMenu = this.$children.MenuList[index];
|
|
116
|
+
this.$children.MenuList.forEach((menuItem) => {
|
|
117
|
+
if (!menuItem.$el.contains(targetMenu.$el)) {
|
|
118
|
+
menuItem.close();
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
close() {
|
|
123
|
+
this.menuList.close();
|
|
124
|
+
}
|
|
125
|
+
open() {
|
|
126
|
+
this.menuList.open();
|
|
127
|
+
}
|
|
128
|
+
toggle() {
|
|
129
|
+
this.menuList.toggle();
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
var Menu = _Menu;
|
|
133
|
+
__publicField(Menu, "config", {
|
|
134
|
+
name: "Menu",
|
|
135
|
+
debug: true,
|
|
136
|
+
components: {
|
|
137
|
+
MenuBtn: import_MenuBtn.default,
|
|
138
|
+
MenuList: import_MenuList.default,
|
|
139
|
+
Menu: _Menu
|
|
140
|
+
},
|
|
141
|
+
options: {
|
|
142
|
+
mode: {
|
|
143
|
+
type: String,
|
|
144
|
+
default: "click"
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Menu & {
|
|
3
|
+
* $children: {
|
|
4
|
+
* Menu: Menu[],
|
|
5
|
+
* MenuBtn: MenuBtn[],
|
|
6
|
+
* MenuList: MenuList[],
|
|
7
|
+
* }
|
|
8
|
+
* }} MenuInterface
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Menu class.
|
|
12
|
+
*/
|
|
13
|
+
export default class Menu extends Base {
|
|
14
|
+
/**
|
|
15
|
+
* Config.
|
|
16
|
+
*/
|
|
17
|
+
static config: {
|
|
18
|
+
name: string;
|
|
19
|
+
debug: boolean;
|
|
20
|
+
components: {
|
|
21
|
+
MenuBtn: typeof MenuBtn;
|
|
22
|
+
MenuList: typeof MenuList;
|
|
23
|
+
Menu: typeof Menu;
|
|
24
|
+
};
|
|
25
|
+
options: {
|
|
26
|
+
mode: {
|
|
27
|
+
type: StringConstructor;
|
|
28
|
+
default: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
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
|
+
/**
|
|
41
|
+
* Get the first `MenuList` instance.
|
|
42
|
+
*
|
|
43
|
+
* @this {MenuInterface}
|
|
44
|
+
* @returns {MenuList}
|
|
45
|
+
*/
|
|
46
|
+
get menuList(): MenuList;
|
|
47
|
+
/**
|
|
48
|
+
* Get the first `MenuBtn` instance.
|
|
49
|
+
*
|
|
50
|
+
* @this {MenuInterface}
|
|
51
|
+
* @returns {MenuBtn}
|
|
52
|
+
*/
|
|
53
|
+
get menuBtn(): MenuBtn;
|
|
54
|
+
/**
|
|
55
|
+
* @todo test breakpoint to switch between click and hover.
|
|
56
|
+
*/
|
|
57
|
+
get shouldReactOnClick(): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Wether the button or the items are hovered.
|
|
60
|
+
*
|
|
61
|
+
* @returns {boolean}
|
|
62
|
+
*/
|
|
63
|
+
get isHover(): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Set attributes on mounted, destroy the component if it is missing required
|
|
66
|
+
* child components.
|
|
67
|
+
*
|
|
68
|
+
* @returns {void}
|
|
69
|
+
*/
|
|
70
|
+
mounted(): void;
|
|
71
|
+
/**
|
|
72
|
+
* Keyboard management.
|
|
73
|
+
*
|
|
74
|
+
* @param {import('@studiometa/js-toolkit/services/key').KeyServiceProps} options
|
|
75
|
+
* @returns {void}
|
|
76
|
+
*/
|
|
77
|
+
keyed({ ENTER, ESC, isUp }: import('@studiometa/js-toolkit/services/key').KeyServiceProps): void;
|
|
78
|
+
/**
|
|
79
|
+
* Toggle menu items on button click;
|
|
80
|
+
*
|
|
81
|
+
* @this {MenuInterface}
|
|
82
|
+
* @param {MouseEvent} event
|
|
83
|
+
* @returns {void}
|
|
84
|
+
*/
|
|
85
|
+
onMenuBtnBtnClick(this: MenuInterface, event: MouseEvent, index: any): void;
|
|
86
|
+
/**
|
|
87
|
+
* Open menu items on button mouse enter.
|
|
88
|
+
*
|
|
89
|
+
* @this {MenuInterface}
|
|
90
|
+
* @returns {void}
|
|
91
|
+
*/
|
|
92
|
+
onMenuBtnBtnMouseenter(this: MenuInterface, event: any, index: any): void;
|
|
93
|
+
/**
|
|
94
|
+
* Close menu items on button mouse leave.
|
|
95
|
+
*
|
|
96
|
+
* @this {MenuInterface}
|
|
97
|
+
* @returns {void}
|
|
98
|
+
*/
|
|
99
|
+
onMenuBtnBtnMouseleave(this: MenuInterface): void;
|
|
100
|
+
/**
|
|
101
|
+
* Close menu items on button mouse leave.
|
|
102
|
+
*
|
|
103
|
+
* @this {MenuInterface}
|
|
104
|
+
* @returns {void}
|
|
105
|
+
*/
|
|
106
|
+
onMenuListItemsMouseleave(this: MenuInterface): void;
|
|
107
|
+
/**
|
|
108
|
+
* Close other non-parent menu items on menu items open.
|
|
109
|
+
*
|
|
110
|
+
* @this {MenuInterface}
|
|
111
|
+
* @param {number} index
|
|
112
|
+
* @returns {void}
|
|
113
|
+
*/
|
|
114
|
+
onMenuListItemsOpen(this: MenuInterface, index: number): void;
|
|
115
|
+
/**
|
|
116
|
+
* Close the menu.
|
|
117
|
+
* @returns {void}
|
|
118
|
+
*/
|
|
119
|
+
close(): void;
|
|
120
|
+
/**
|
|
121
|
+
* Open the menu.
|
|
122
|
+
* @returns {void}
|
|
123
|
+
*/
|
|
124
|
+
open(): void;
|
|
125
|
+
/**
|
|
126
|
+
* Toggle the menu.
|
|
127
|
+
* @returns {void}
|
|
128
|
+
*/
|
|
129
|
+
toggle(): void;
|
|
130
|
+
}
|
|
131
|
+
export type MenuInterface = Menu & {
|
|
132
|
+
$children: {
|
|
133
|
+
Menu: Menu[];
|
|
134
|
+
MenuBtn: MenuBtn[];
|
|
135
|
+
MenuList: MenuList[];
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
import { Base } from "@studiometa/js-toolkit";
|
|
139
|
+
import MenuList from "./MenuList.js";
|
|
140
|
+
import MenuBtn from "./MenuBtn.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Base as h}from"@studiometa/js-toolkit";import{nextTick as s}from"@studiometa/js-toolkit/utils";import u from"./MenuBtn.js";import o from"./MenuList.js";class n extends h{static config={name:"Menu",debug:!0,components:{MenuBtn:u,MenuList:o,Menu:n},options:{mode:{type:String,default:"click"}}};getDirectChildren(t){return this.$children[t]?this.$children.Menu?this.$children[t].filter(e=>this.$children.Menu.every(i=>i.$children[t]?!i.$children[t].includes(e):!0)):this.$children[t]:[]}get menuList(){return this.getDirectChildren("MenuList")[0]}get menuBtn(){return this.getDirectChildren("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 r=document.activeElement===this.menuBtn.$el;t&&r&&this.toggle()}}}onMenuBtnBtnClick(t,e){this.$children.MenuBtn[e]===this.menuBtn&&this.shouldReactOnClick&&(t.preventDefault(),this.toggle())}onMenuBtnBtnMouseenter(t,e){this.$children.MenuBtn[e]===this.menuBtn&&!this.shouldReactOnClick&&this.open()}onMenuBtnBtnMouseleave(){this.shouldReactOnClick||s(()=>{this.isHover||this.close()})}onMenuListItemsMouseleave(){this.shouldReactOnClick||s(()=>{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};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var __publicField = (obj, key, value) => {
|
|
20
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// packages/ui/molecules/Menu/MenuBtn.js
|
|
25
|
+
var MenuBtn_exports = {};
|
|
26
|
+
__export(MenuBtn_exports, {
|
|
27
|
+
default: () => MenuBtn
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(MenuBtn_exports);
|
|
30
|
+
var import_js_toolkit = require("@studiometa/js-toolkit");
|
|
31
|
+
var MenuBtn = class extends import_js_toolkit.Base {
|
|
32
|
+
isHover = false;
|
|
33
|
+
onClick(event) {
|
|
34
|
+
event.stopPropagation();
|
|
35
|
+
this.$emit("btn-click", event);
|
|
36
|
+
}
|
|
37
|
+
onMouseenter(event) {
|
|
38
|
+
this.isHover = true;
|
|
39
|
+
event.stopPropagation();
|
|
40
|
+
this.$emit("btn-mouseenter", event);
|
|
41
|
+
}
|
|
42
|
+
onMouseleave(event) {
|
|
43
|
+
this.isHover = false;
|
|
44
|
+
event.stopPropagation();
|
|
45
|
+
this.$emit("btn-mouseleave", event);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
__publicField(MenuBtn, "config", {
|
|
49
|
+
name: "MenuBtn",
|
|
50
|
+
debug: true,
|
|
51
|
+
emits: ["btn-click", "btn-mouseenter", "btn-mouseleave"]
|
|
52
|
+
});
|
|
53
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MenuBtn class.
|
|
3
|
+
*/
|
|
4
|
+
export default class MenuBtn extends Base {
|
|
5
|
+
/**
|
|
6
|
+
* Config.
|
|
7
|
+
*/
|
|
8
|
+
static config: {
|
|
9
|
+
name: string;
|
|
10
|
+
debug: boolean;
|
|
11
|
+
emits: string[];
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Wether the button is hovered or not.
|
|
15
|
+
* @type {boolean}
|
|
16
|
+
*/
|
|
17
|
+
isHover: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Dispatch the click event.
|
|
20
|
+
*
|
|
21
|
+
* @param {MouseEvent} event
|
|
22
|
+
* @returns {void}
|
|
23
|
+
*/
|
|
24
|
+
onClick(event: MouseEvent): void;
|
|
25
|
+
/**
|
|
26
|
+
* Dispatch the mouseenter event.
|
|
27
|
+
*
|
|
28
|
+
* @param {MouseEvent} event
|
|
29
|
+
* @returns {void}
|
|
30
|
+
*/
|
|
31
|
+
onMouseenter(event: MouseEvent): void;
|
|
32
|
+
/**
|
|
33
|
+
* Dispatch the mouseleave event.
|
|
34
|
+
* @param {MouseEvent} event
|
|
35
|
+
* @returns {void}
|
|
36
|
+
*/
|
|
37
|
+
onMouseleave(event: MouseEvent): void;
|
|
38
|
+
}
|
|
39
|
+
import { Base } from "@studiometa/js-toolkit";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Base as t}from"@studiometa/js-toolkit";class o extends t{static config={name:"MenuBtn",debug:!0,emits:["btn-click","btn-mouseenter","btn-mouseleave"]};isHover=!1;onClick(e){e.stopPropagation(),this.$emit("btn-click",e)}onMouseenter(e){this.isHover=!0,e.stopPropagation(),this.$emit("btn-mouseenter",e)}onMouseleave(e){this.isHover=!1,e.stopPropagation(),this.$emit("btn-mouseleave",e)}}export{o as default};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
var __publicField = (obj, key, value) => {
|
|
23
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
24
|
+
return value;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// packages/ui/molecules/Menu/MenuList.js
|
|
28
|
+
var MenuList_exports = {};
|
|
29
|
+
__export(MenuList_exports, {
|
|
30
|
+
default: () => MenuList
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(MenuList_exports);
|
|
33
|
+
var import_Transition = __toESM(require("../../primitives/Transition/Transition.cjs"), 1);
|
|
34
|
+
var FOCUSABLE_ELEMENTS = [
|
|
35
|
+
"a[href]:not([inert])",
|
|
36
|
+
"area[href]:not([inert])",
|
|
37
|
+
"input:not([disabled]):not([inert])",
|
|
38
|
+
"select:not([disabled]):not([inert])",
|
|
39
|
+
"textarea:not([disabled]):not([inert])",
|
|
40
|
+
"button:not([disabled]):not([inert])",
|
|
41
|
+
"iframe:not([inert])",
|
|
42
|
+
"audio:not([inert])",
|
|
43
|
+
"video:not([inert])",
|
|
44
|
+
"[contenteditable]:not([inert])",
|
|
45
|
+
"[tabindex]:not([inert])"
|
|
46
|
+
].join(",");
|
|
47
|
+
var _MenuList = class extends import_Transition.default {
|
|
48
|
+
isOpen = false;
|
|
49
|
+
isHover = false;
|
|
50
|
+
get $options() {
|
|
51
|
+
const options = super.$options;
|
|
52
|
+
options.leaveKeep = true;
|
|
53
|
+
options.enterKeep = true;
|
|
54
|
+
return options;
|
|
55
|
+
}
|
|
56
|
+
mounted() {
|
|
57
|
+
this.__updateTabIndexes("close");
|
|
58
|
+
}
|
|
59
|
+
onMouseenter() {
|
|
60
|
+
this.isHover = true;
|
|
61
|
+
}
|
|
62
|
+
onMouseleave(event) {
|
|
63
|
+
this.isHover = false;
|
|
64
|
+
this.$emit("items-mouseleave", event);
|
|
65
|
+
}
|
|
66
|
+
open() {
|
|
67
|
+
if (this.isOpen) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const clickOutsideHandler = (event) => {
|
|
71
|
+
if (!this.$el.contains(event.target)) {
|
|
72
|
+
document.removeEventListener("click", clickOutsideHandler);
|
|
73
|
+
this.close();
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
document.addEventListener("click", clickOutsideHandler);
|
|
77
|
+
this.__updateTabIndexes("open");
|
|
78
|
+
this.$el.setAttribute("aria-hidden", "false");
|
|
79
|
+
this.isOpen = true;
|
|
80
|
+
this.enter();
|
|
81
|
+
this.$emit("items-open");
|
|
82
|
+
}
|
|
83
|
+
close() {
|
|
84
|
+
if (!this.isOpen) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
this.$children.MenuList.forEach((menuItem) => {
|
|
88
|
+
menuItem.close();
|
|
89
|
+
});
|
|
90
|
+
if (document.activeElement instanceof HTMLElement && this.$el.contains(document.activeElement)) {
|
|
91
|
+
document.activeElement.blur();
|
|
92
|
+
}
|
|
93
|
+
this.$el.setAttribute("aria-hidden", "true");
|
|
94
|
+
this.__updateTabIndexes("close");
|
|
95
|
+
this.isOpen = false;
|
|
96
|
+
this.leave();
|
|
97
|
+
this.$emit("items-close");
|
|
98
|
+
}
|
|
99
|
+
toggle() {
|
|
100
|
+
console.log(this.$id, "toggle", this.isOpen);
|
|
101
|
+
if (this.isOpen) {
|
|
102
|
+
this.close();
|
|
103
|
+
} else {
|
|
104
|
+
this.open();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
__updateTabIndexes(mode = "open") {
|
|
108
|
+
const focusableItems = Array.from(this.$el.querySelectorAll(FOCUSABLE_ELEMENTS)).filter((item) => this.__filterFocusableItems(item));
|
|
109
|
+
focusableItems.forEach((item) => {
|
|
110
|
+
if (mode === "close") {
|
|
111
|
+
item.setAttribute("tabindex", "-1");
|
|
112
|
+
} else {
|
|
113
|
+
item.removeAttribute("tabindex");
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
__filterFocusableItems(item) {
|
|
118
|
+
let ancestor = item.parentElement;
|
|
119
|
+
while (ancestor && (!ancestor.__base__ || !ancestor.__base__.has(this.constructor))) {
|
|
120
|
+
ancestor = ancestor.parentElement;
|
|
121
|
+
}
|
|
122
|
+
return ancestor === null || ancestor === this.$el;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
var MenuList = _MenuList;
|
|
126
|
+
__publicField(MenuList, "config", {
|
|
127
|
+
...import_Transition.default.config,
|
|
128
|
+
name: "MenuList",
|
|
129
|
+
emits: ["items-open", "items-close", "items-mouseleave"],
|
|
130
|
+
components: {
|
|
131
|
+
MenuList: _MenuList
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {MenuList & {
|
|
3
|
+
* $children: {
|
|
4
|
+
* MenuList: MenuList[]
|
|
5
|
+
* }
|
|
6
|
+
* }} MenuListInterface
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* MenuList class.
|
|
10
|
+
*/
|
|
11
|
+
export default class MenuList extends Transition {
|
|
12
|
+
/**
|
|
13
|
+
* Config.
|
|
14
|
+
*/
|
|
15
|
+
static config: {
|
|
16
|
+
name: string;
|
|
17
|
+
emits: string[];
|
|
18
|
+
components: {
|
|
19
|
+
MenuList: typeof MenuList;
|
|
20
|
+
};
|
|
21
|
+
options: {
|
|
22
|
+
enterFrom: StringConstructor;
|
|
23
|
+
enterActive: StringConstructor;
|
|
24
|
+
enterTo: StringConstructor;
|
|
25
|
+
enterKeep: BooleanConstructor;
|
|
26
|
+
leaveFrom: StringConstructor;
|
|
27
|
+
leaveActive: StringConstructor;
|
|
28
|
+
leaveTo: StringConstructor;
|
|
29
|
+
leaveKeep: BooleanConstructor;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Are the menu items visible?
|
|
34
|
+
* @type {boolean}
|
|
35
|
+
*/
|
|
36
|
+
isOpen: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Wether the component is hovered.
|
|
39
|
+
* @type {boolean}
|
|
40
|
+
*/
|
|
41
|
+
isHover: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Update tab indexes on mount.
|
|
44
|
+
*
|
|
45
|
+
* @returns {void}
|
|
46
|
+
*/
|
|
47
|
+
mounted(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Set hover state.
|
|
50
|
+
*
|
|
51
|
+
* @returns {void}
|
|
52
|
+
*/
|
|
53
|
+
onMouseenter(): void;
|
|
54
|
+
/**
|
|
55
|
+
* Unset hover state.
|
|
56
|
+
*
|
|
57
|
+
* @param {MouseEvent} event
|
|
58
|
+
* @returns {void}
|
|
59
|
+
*/
|
|
60
|
+
onMouseleave(event: MouseEvent): void;
|
|
61
|
+
/**
|
|
62
|
+
* Display the menu items.
|
|
63
|
+
*
|
|
64
|
+
* @returns {void}
|
|
65
|
+
*/
|
|
66
|
+
open(): void;
|
|
67
|
+
/**
|
|
68
|
+
* Hide the menu items.
|
|
69
|
+
*
|
|
70
|
+
* @this {MenuListInterface}
|
|
71
|
+
* @returns {void}
|
|
72
|
+
*/
|
|
73
|
+
close(this: MenuListInterface): void;
|
|
74
|
+
/**
|
|
75
|
+
* Toggle the menu items.
|
|
76
|
+
* @returns {void}
|
|
77
|
+
*/
|
|
78
|
+
toggle(): void;
|
|
79
|
+
/**
|
|
80
|
+
* Update `tabindex` attribute of child focusable elements.
|
|
81
|
+
*
|
|
82
|
+
* @private
|
|
83
|
+
* @param {'open'|'close'} mode
|
|
84
|
+
* @returns {void}
|
|
85
|
+
*/
|
|
86
|
+
private __updateTabIndexes;
|
|
87
|
+
/**
|
|
88
|
+
* Filter out items which are inside a child `MenuList` instance.
|
|
89
|
+
*
|
|
90
|
+
* @private
|
|
91
|
+
* @param {HTMLElement} item
|
|
92
|
+
* @returns {boolean}
|
|
93
|
+
*/
|
|
94
|
+
private __filterFocusableItems;
|
|
95
|
+
}
|
|
96
|
+
export type MenuListInterface = MenuList & {
|
|
97
|
+
$children: {
|
|
98
|
+
MenuList: MenuList[];
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
import Transition from "../../primitives/Transition/Transition.js";
|
|
@@ -0,0 +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(e){this.isHover=!1,this.$emit("items-mouseleave",e)}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};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// packages/ui/molecules/Menu/index.js
|
|
23
|
+
var Menu_exports = {};
|
|
24
|
+
__export(Menu_exports, {
|
|
25
|
+
Menu: () => import_Menu.default,
|
|
26
|
+
MenuBtn: () => import_MenuBtn.default,
|
|
27
|
+
MenuList: () => import_MenuList.default
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(Menu_exports);
|
|
30
|
+
var import_Menu = __toESM(require("./Menu.cjs"), 1);
|
|
31
|
+
var import_MenuBtn = __toESM(require("./MenuBtn.cjs"), 1);
|
|
32
|
+
var import_MenuList = __toESM(require("./MenuList.cjs"), 1);
|
|
33
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as a}from"./Menu.js";import{default as o}from"./MenuBtn.js";import{default as u}from"./MenuList.js";export{a as Menu,o as MenuBtn,u as MenuList};
|