@studiometa/ui 0.2.3 → 0.2.6

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.
Files changed (163) hide show
  1. package/atoms/AnchorScrollTo/AnchorScrollTo.cjs +8 -13
  2. package/atoms/AnchorScrollTo/AnchorScrollTo.js +1 -26
  3. package/atoms/Button/Button.twig +68 -0
  4. package/atoms/Button/StyledButton.twig +47 -0
  5. package/atoms/Cursor/Cursor.cjs +14 -22
  6. package/atoms/Cursor/Cursor.d.ts +2 -2
  7. package/atoms/Cursor/Cursor.js +1 -103
  8. package/atoms/Cursor/Cursor.twig +28 -0
  9. package/atoms/Figure/Figure.cjs +20 -16
  10. package/atoms/Figure/Figure.d.ts +19 -1
  11. package/atoms/Figure/Figure.js +1 -27
  12. package/atoms/Figure/Figure.twig +120 -0
  13. package/atoms/Figure/FigureTwicPics.cjs +72 -0
  14. package/atoms/Figure/FigureTwicPics.d.ts +48 -0
  15. package/atoms/Figure/FigureTwicPics.js +1 -0
  16. package/atoms/Figure/index.cjs +31 -0
  17. package/atoms/Figure/index.d.ts +2 -0
  18. package/atoms/Figure/index.js +1 -0
  19. package/atoms/Icon/Icon.twig +13 -0
  20. package/atoms/LargeText/LargeText.cjs +15 -23
  21. package/atoms/LargeText/LargeText.d.ts +3 -3
  22. package/atoms/LargeText/LargeText.js +1 -64
  23. package/atoms/LargeText/LargeText.twig +49 -0
  24. package/atoms/LazyInclude/LazyInclude.cjs +8 -13
  25. package/atoms/LazyInclude/LazyInclude.d.ts +4 -4
  26. package/atoms/LazyInclude/LazyInclude.js +1 -46
  27. package/atoms/Prefetch/AbstractPrefetch.cjs +8 -13
  28. package/atoms/Prefetch/AbstractPrefetch.d.ts +1 -1
  29. package/atoms/Prefetch/AbstractPrefetch.js +1 -58
  30. package/atoms/Prefetch/PrefetchWhenOver.cjs +12 -34
  31. package/atoms/Prefetch/PrefetchWhenOver.d.ts +1 -1
  32. package/atoms/Prefetch/PrefetchWhenOver.js +1 -35
  33. package/atoms/Prefetch/PrefetchWhenVisible.cjs +12 -34
  34. package/atoms/Prefetch/PrefetchWhenVisible.d.ts +1 -1
  35. package/atoms/Prefetch/PrefetchWhenVisible.js +1 -36
  36. package/atoms/Prefetch/index.cjs +9 -16
  37. package/atoms/Prefetch/index.js +1 -8
  38. package/atoms/ScrollAnimation/AbstractScrollAnimation.cjs +126 -0
  39. package/atoms/ScrollAnimation/AbstractScrollAnimation.d.ts +133 -0
  40. package/atoms/ScrollAnimation/AbstractScrollAnimation.js +1 -0
  41. package/atoms/ScrollAnimation/ScrollAnimation.cjs +51 -0
  42. package/atoms/ScrollAnimation/ScrollAnimation.d.ts +55 -0
  43. package/atoms/ScrollAnimation/ScrollAnimation.js +1 -0
  44. package/atoms/ScrollAnimation/ScrollAnimationChild.cjs +51 -0
  45. package/atoms/ScrollAnimation/ScrollAnimationChild.d.ts +13 -0
  46. package/atoms/ScrollAnimation/ScrollAnimationChild.js +1 -0
  47. package/atoms/ScrollAnimation/ScrollAnimationChildWithEase.cjs +41 -0
  48. package/atoms/ScrollAnimation/ScrollAnimationChildWithEase.d.ts +6 -0
  49. package/atoms/ScrollAnimation/ScrollAnimationChildWithEase.js +1 -0
  50. package/atoms/ScrollAnimation/ScrollAnimationParent.cjs +48 -0
  51. package/atoms/ScrollAnimation/ScrollAnimationParent.d.ts +35 -0
  52. package/atoms/ScrollAnimation/ScrollAnimationParent.js +1 -0
  53. package/atoms/ScrollAnimation/ScrollAnimationWithEase.cjs +41 -0
  54. package/atoms/ScrollAnimation/ScrollAnimationWithEase.d.ts +6 -0
  55. package/atoms/ScrollAnimation/ScrollAnimationWithEase.js +1 -0
  56. package/atoms/ScrollAnimation/animationScrollWithEase.cjs +70 -0
  57. package/atoms/ScrollAnimation/animationScrollWithEase.d.ts +11 -0
  58. package/atoms/ScrollAnimation/animationScrollWithEase.js +1 -0
  59. package/atoms/ScrollAnimation/index.cjs +41 -0
  60. package/atoms/ScrollAnimation/index.d.ts +7 -0
  61. package/atoms/ScrollAnimation/index.js +1 -0
  62. package/atoms/index.cjs +13 -19
  63. package/atoms/index.d.ts +2 -1
  64. package/atoms/index.js +1 -13
  65. package/index.cjs +12 -15
  66. package/index.d.ts +1 -0
  67. package/index.js +1 -3
  68. package/molecules/Accordion/Accordion.cjs +12 -34
  69. package/molecules/Accordion/Accordion.js +1 -35
  70. package/molecules/Accordion/Accordion.twig +54 -0
  71. package/molecules/Accordion/AccordionCore.cjs +8 -13
  72. package/molecules/Accordion/AccordionCore.d.ts +2 -2
  73. package/molecules/Accordion/AccordionCore.js +1 -34
  74. package/molecules/Accordion/AccordionItem.cjs +70 -114
  75. package/molecules/Accordion/AccordionItem.d.ts +7 -6
  76. package/molecules/Accordion/AccordionItem.js +1 -178
  77. package/molecules/Menu/Menu.cjs +148 -0
  78. package/molecules/Menu/Menu.d.ts +140 -0
  79. package/molecules/Menu/Menu.js +1 -0
  80. package/molecules/Menu/MenuBtn.cjs +53 -0
  81. package/molecules/Menu/MenuBtn.d.ts +39 -0
  82. package/molecules/Menu/MenuBtn.js +1 -0
  83. package/molecules/Menu/MenuList.cjs +134 -0
  84. package/molecules/Menu/MenuList.d.ts +101 -0
  85. package/molecules/Menu/MenuList.js +1 -0
  86. package/molecules/Menu/index.cjs +33 -0
  87. package/molecules/Menu/index.d.ts +3 -0
  88. package/molecules/Menu/index.js +1 -0
  89. package/molecules/Modal/Modal.cjs +42 -71
  90. package/molecules/Modal/Modal.d.ts +5 -5
  91. package/molecules/Modal/Modal.js +1 -150
  92. package/molecules/Modal/Modal.twig +108 -0
  93. package/molecules/Modal/ModalWithTransition.cjs +13 -43
  94. package/molecules/Modal/ModalWithTransition.js +1 -69
  95. package/molecules/Modal/StyledModal.twig +39 -0
  96. package/molecules/Panel/Panel.cjs +42 -76
  97. package/molecules/Panel/Panel.js +1 -117
  98. package/molecules/Panel/Panel.twig +73 -0
  99. package/molecules/Panel/StyledPanel.twig +28 -0
  100. package/molecules/Slider/AbstractSliderChild.cjs +10 -20
  101. package/molecules/Slider/AbstractSliderChild.d.ts +6 -2
  102. package/molecules/Slider/AbstractSliderChild.js +1 -43
  103. package/molecules/Slider/Slider.cjs +14 -24
  104. package/molecules/Slider/Slider.d.ts +6 -6
  105. package/molecules/Slider/Slider.js +1 -209
  106. package/molecules/Slider/SliderBtn.cjs +9 -16
  107. package/molecules/Slider/SliderBtn.d.ts +1 -1
  108. package/molecules/Slider/SliderBtn.js +1 -34
  109. package/molecules/Slider/SliderCount.cjs +9 -16
  110. package/molecules/Slider/SliderCount.js +1 -19
  111. package/molecules/Slider/SliderDots.cjs +9 -16
  112. package/molecules/Slider/SliderDots.js +1 -24
  113. package/molecules/Slider/SliderDrag.cjs +8 -13
  114. package/molecules/Slider/SliderDrag.js +1 -19
  115. package/molecules/Slider/SliderItem.cjs +14 -37
  116. package/molecules/Slider/SliderItem.js +1 -105
  117. package/molecules/Slider/SliderProgress.cjs +9 -16
  118. package/molecules/Slider/SliderProgress.js +1 -23
  119. package/molecules/Slider/index.cjs +9 -16
  120. package/molecules/Slider/index.js +1 -18
  121. package/molecules/Sticky/Sticky.cjs +11 -19
  122. package/molecules/Sticky/Sticky.d.ts +8 -8
  123. package/molecules/Sticky/Sticky.js +1 -107
  124. package/molecules/Sticky/Sticky.twig +31 -0
  125. package/molecules/TableOfContent/TableOfContent.cjs +9 -16
  126. package/molecules/TableOfContent/TableOfContent.d.ts +1 -1
  127. package/molecules/TableOfContent/TableOfContent.js +1 -42
  128. package/molecules/TableOfContent/TableOfContentAnchor.cjs +8 -13
  129. package/molecules/TableOfContent/TableOfContentAnchor.js +1 -39
  130. package/molecules/TableOfContent/index.cjs +9 -16
  131. package/molecules/TableOfContent/index.js +1 -6
  132. package/molecules/Tabs/Tabs.cjs +54 -82
  133. package/molecules/Tabs/Tabs.d.ts +5 -4
  134. package/molecules/Tabs/Tabs.js +1 -126
  135. package/molecules/Tabs/Tabs.twig +20 -0
  136. package/molecules/index.cjs +13 -18
  137. package/molecules/index.d.ts +1 -0
  138. package/molecules/index.js +1 -18
  139. package/organisms/Frame/Frame.cjs +107 -99
  140. package/organisms/Frame/Frame.d.ts +37 -4
  141. package/organisms/Frame/Frame.js +1 -171
  142. package/organisms/Frame/FrameAnchor.cjs +8 -13
  143. package/organisms/Frame/FrameAnchor.js +1 -22
  144. package/organisms/Frame/FrameForm.cjs +8 -13
  145. package/organisms/Frame/FrameForm.js +1 -22
  146. package/organisms/Frame/FrameTarget.cjs +31 -73
  147. package/organisms/Frame/FrameTarget.js +1 -109
  148. package/organisms/Frame/index.cjs +9 -16
  149. package/organisms/Frame/index.js +1 -10
  150. package/organisms/ImageGrid/ImageGrid.twig +42 -0
  151. package/organisms/index.cjs +9 -13
  152. package/organisms/index.js +1 -1
  153. package/package.json +3 -4
  154. package/primitives/Draggable/Draggable.cjs +15 -28
  155. package/primitives/Draggable/Draggable.d.ts +0 -5
  156. package/primitives/Draggable/Draggable.js +1 -38
  157. package/primitives/Sentinel/Sentinel.cjs +8 -13
  158. package/primitives/Sentinel/Sentinel.js +1 -15
  159. package/primitives/Transition/Transition.cjs +12 -17
  160. package/primitives/Transition/Transition.d.ts +2 -4
  161. package/primitives/Transition/Transition.js +1 -45
  162. package/primitives/index.cjs +9 -16
  163. package/primitives/index.js +1 -8
@@ -1,178 +1 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __objRest = (source, exclude) => {
7
- var target = {};
8
- for (var prop in source)
9
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
10
- target[prop] = source[prop];
11
- if (source != null && __getOwnPropSymbols)
12
- for (var prop of __getOwnPropSymbols(source)) {
13
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
14
- target[prop] = source[prop];
15
- }
16
- return target;
17
- };
18
- var __publicField = (obj, key, value) => {
19
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
20
- return value;
21
- };
22
- var __async = (__this, __arguments, generator) => {
23
- return new Promise((resolve, reject) => {
24
- var fulfilled = (value) => {
25
- try {
26
- step(generator.next(value));
27
- } catch (e) {
28
- reject(e);
29
- }
30
- };
31
- var rejected = (value) => {
32
- try {
33
- step(generator.throw(value));
34
- } catch (e) {
35
- reject(e);
36
- }
37
- };
38
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
39
- step((generator = generator.apply(__this, __arguments)).next());
40
- });
41
- };
42
- import deepmerge from "deepmerge";
43
- import { Base } from "@studiometa/js-toolkit";
44
- import { transition } from "@studiometa/js-toolkit/utils";
45
- import Accordion from "./AccordionCore.js";
46
- const _AccordionItem = class extends Base {
47
- mounted() {
48
- if (this.$parent && this.$parent instanceof Accordion && this.$parent.$options.item) {
49
- Object.entries(this.$parent.$options.item).forEach(([key, value]) => {
50
- if (key in this.$options) {
51
- const type = _AccordionItem.config.options[key].type || _AccordionItem.config.options[key];
52
- if (type === Array || type === Object) {
53
- this.$options[key] = deepmerge(this.$options[key], value);
54
- } else {
55
- this.$options[key] = value;
56
- }
57
- }
58
- });
59
- }
60
- this.$refs.btn.setAttribute("id", this.$id);
61
- this.$refs.btn.setAttribute("aria-controls", this.contentId);
62
- this.$refs.content.setAttribute("aria-labelledby", this.$id);
63
- this.$refs.content.setAttribute("id", this.contentId);
64
- const { isOpen } = this.$options;
65
- this.updateAttributes(isOpen);
66
- const _a = this.$options.styles, { container } = _a, otherStyles = __objRest(_a, ["container"]);
67
- const refs = this.$refs;
68
- Object.entries(otherStyles).filter(([refName]) => refs[refName]).forEach(([refName, { open, closed } = { open: "", closed: "" }]) => {
69
- transition(refs[refName], { to: isOpen ? open : closed }, "keep");
70
- });
71
- }
72
- destroyed() {
73
- this.$refs.container.style.visibility = "";
74
- this.$refs.container.style.height = "";
75
- }
76
- onBtnClick() {
77
- if (this.$options.isOpen) {
78
- this.close();
79
- } else {
80
- this.open();
81
- }
82
- }
83
- get contentId() {
84
- return `content-${this.$id}`;
85
- }
86
- updateAttributes(isOpen) {
87
- this.$refs.container.style.visibility = isOpen ? "" : "invisible";
88
- this.$refs.container.style.height = isOpen ? "" : "0";
89
- this.$refs.content.setAttribute("aria-hidden", isOpen ? "false" : "true");
90
- this.$refs.btn.setAttribute("aria-expanded", isOpen ? "true" : "false");
91
- }
92
- open() {
93
- return __async(this, null, function* () {
94
- if (this.$options.isOpen) {
95
- return;
96
- }
97
- this.$log("open");
98
- this.$emit("open");
99
- this.$options.isOpen = true;
100
- this.updateAttributes(this.$options.isOpen);
101
- this.$refs.container.style.visibility = "";
102
- const _a = this.$options.styles, { container } = _a, otherStyles = __objRest(_a, ["container"]);
103
- const refs = this.$refs;
104
- yield Promise.all([
105
- transition(refs.container, {
106
- from: { height: "0" },
107
- active: container.active,
108
- to: { height: `${refs.content.offsetHeight}px` }
109
- }).then(() => {
110
- if (this.$options.isOpen) {
111
- refs.content.style.position = "";
112
- }
113
- return Promise.resolve();
114
- }),
115
- ...Object.entries(otherStyles).filter(([refName]) => refs[refName]).map(([refName, { open, active, closed } = { open: "", active: "", closed: "" }]) => transition(refs[refName], {
116
- from: closed,
117
- active,
118
- to: open
119
- }, "keep"))
120
- ]);
121
- });
122
- }
123
- close() {
124
- return __async(this, null, function* () {
125
- if (!this.$options.isOpen) {
126
- return;
127
- }
128
- this.$log("close");
129
- this.$emit("close");
130
- this.$options.isOpen = false;
131
- const height = this.$refs.container.offsetHeight;
132
- this.$refs.content.style.position = "absolute";
133
- const _a = this.$options.styles, { container } = _a, otherStyles = __objRest(_a, ["container"]);
134
- const refs = this.$refs;
135
- yield Promise.all([
136
- transition(refs.container, {
137
- from: { height: `${height}px` },
138
- active: container.active,
139
- to: { height: "0" }
140
- }).then(() => {
141
- if (!this.$options.isOpen) {
142
- refs.container.style.height = "0";
143
- refs.container.style.visibility = "invisible";
144
- this.updateAttributes(this.$options.isOpen);
145
- }
146
- return Promise.resolve();
147
- }),
148
- ...Object.entries(otherStyles).filter(([refName]) => refs[refName]).map(([refName, { open, active, closed } = { open: "", active: "", closed: "" }]) => transition(refs[refName], {
149
- from: open,
150
- active,
151
- to: closed
152
- }, "keep"))
153
- ]);
154
- });
155
- }
156
- };
157
- let AccordionItem = _AccordionItem;
158
- __publicField(AccordionItem, "config", {
159
- name: "AccordionItem",
160
- refs: ["btn", "content", "container"],
161
- emits: ["open", "close"],
162
- options: {
163
- isOpen: Boolean,
164
- styles: {
165
- type: Object,
166
- default: () => ({
167
- container: {
168
- open: "",
169
- active: "",
170
- closed: ""
171
- }
172
- })
173
- }
174
- }
175
- });
176
- export {
177
- AccordionItem as default
178
- };
1
+ import a from"deepmerge";import{Base as l}from"@studiometa/js-toolkit";import{transition as r}from"@studiometa/js-toolkit/utils";import f from"./AccordionCore.js";class c extends l{static config={name:"AccordionItem",refs:["btn","content","container"],emits:["open","close"],options:{isOpen:Boolean,styles:{type:Object,default:()=>({container:{open:"",active:"",closed:""}}),merge:!0}}};mounted(){this.$parent&&this.$parent instanceof f&&this.$parent.$options.item&&Object.entries(this.$parent.$options.item).forEach(([t,o])=>{if(t in this.$options){const n=c.config.options[t].type||c.config.options[t];n===Array||n===Object?this.$options[t]=a(this.$options[t],o):this.$options[t]=o}}),this.$refs.btn.setAttribute("id",this.$id),this.$refs.btn.setAttribute("aria-controls",this.contentId),this.$refs.content.setAttribute("aria-labelledby",this.$id),this.$refs.content.setAttribute("id",this.contentId);const{isOpen:i}=this.$options;this.updateAttributes(i);const{container:h,...s}=this.$options.styles,e=this.$refs;Object.entries(s).filter(([t])=>e[t]).forEach(([t,{open:o,closed:n}={open:"",closed:""}])=>{r(e[t],{to:i?o:n},"keep")})}destroyed(){this.$refs.container.style.visibility="",this.$refs.container.style.height=""}onBtnClick(){this.$options.isOpen?this.close():this.open()}get contentId(){return`content-${this.$id}`}updateAttributes(i){this.$refs.container.style.visibility=i?"":"invisible",this.$refs.container.style.height=i?"":"0",this.$refs.content.setAttribute("aria-hidden",i?"false":"true"),this.$refs.btn.setAttribute("aria-expanded",i?"true":"false")}async open(){if(this.$options.isOpen)return;this.$log("open"),this.$emit("open"),this.$options.isOpen=!0,this.updateAttributes(this.$options.isOpen),this.$refs.container.style.visibility="";const{container:i,...h}=this.$options.styles,s=this.$refs;await Promise.all([r(s.container,{from:{height:"0"},active:i.active,to:{height:`${s.content.offsetHeight}px`}}).then(()=>(this.$options.isOpen&&(s.content.style.position=""),Promise.resolve())),...Object.entries(h).filter(([e])=>s[e]).map(([e,{open:t,active:o,closed:n}={open:"",active:"",closed:""}])=>r(s[e],{from:n,active:o,to:t},"keep"))])}async close(){if(!this.$options.isOpen)return;this.$log("close"),this.$emit("close"),this.$options.isOpen=!1;const i=this.$refs.container.offsetHeight;this.$refs.content.style.position="absolute";const{container:h,...s}=this.$options.styles,e=this.$refs;await Promise.all([r(e.container,{from:{height:`${i}px`},active:h.active,to:{height:"0"}}).then(()=>(this.$options.isOpen||(e.container.style.height="0",e.container.style.visibility="invisible",this.updateAttributes(this.$options.isOpen)),Promise.resolve())),...Object.entries(s).filter(([t])=>e[t]).map(([t,{open:o,active:n,closed:p}={open:"",active:"",closed:""}])=>r(e[t],{from:o,active:n,to:p},"keep"))])}}export{c as default};
@@ -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};