@studiometa/js-toolkit 1.7.2 → 2.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Base/index.d.ts +217 -0
- package/Base/index.js +237 -0
- package/Base/managers/ChildrenManager.d.ts +108 -0
- package/Base/managers/ChildrenManager.js +124 -0
- package/Base/managers/EventsManager.d.ts +190 -0
- package/Base/managers/EventsManager.js +195 -0
- package/Base/managers/OptionsManager.d.ts +120 -0
- package/Base/managers/OptionsManager.js +180 -0
- package/Base/managers/RefsManager.d.ts +84 -0
- package/Base/managers/RefsManager.js +83 -0
- package/{abstracts/Base/classes/Services.d.ts → Base/managers/ServicesManager.d.ts} +22 -7
- package/Base/managers/ServicesManager.js +115 -0
- package/{abstracts/Base → Base}/utils.d.ts +0 -30
- package/Base/utils.js +43 -0
- package/README.md +12 -70
- package/decorators/index.js +1 -2
- package/decorators/withBreakpointManager.d.ts +5 -5
- package/decorators/withBreakpointManager.js +41 -79
- package/decorators/withBreakpointObserver.d.ts +4 -4
- package/decorators/withBreakpointObserver.js +54 -77
- package/decorators/withDrag.d.ts +6 -6
- package/decorators/withDrag.js +17 -41
- package/decorators/withExtraConfig.d.ts +6 -6
- package/decorators/withExtraConfig.js +2 -24
- package/decorators/withIntersectionObserver.d.ts +4 -4
- package/decorators/withIntersectionObserver.js +17 -60
- package/decorators/withMountWhenInView.d.ts +8 -8
- package/decorators/withMountWhenInView.js +23 -51
- package/helpers/createApp.d.ts +4 -4
- package/helpers/createApp.js +10 -12
- package/helpers/importOnInteraction.d.ts +6 -6
- package/helpers/importOnInteraction.js +7 -8
- package/helpers/importWhenIdle.d.ts +4 -4
- package/helpers/importWhenIdle.js +7 -8
- package/helpers/importWhenVisible.d.ts +6 -6
- package/helpers/importWhenVisible.js +9 -16
- package/helpers/index.d.ts +1 -3
- package/helpers/index.js +1 -4
- package/helpers/utils.js +2 -3
- package/index.d.ts +19 -5
- package/index.js +5 -6
- package/index.modern.js +1 -3230
- package/index.umd.js +1 -3586
- package/package.json +3 -6
- package/{abstracts → services}/Service.d.ts +0 -0
- package/services/Service.js +63 -0
- package/services/drag.js +144 -180
- package/services/index.js +1 -2
- package/services/key.js +56 -98
- package/services/load.d.ts +1 -1
- package/services/load.js +22 -51
- package/services/pointer.js +118 -157
- package/services/raf.js +37 -65
- package/services/resize.js +46 -98
- package/services/scroll.js +81 -120
- package/utils/collide/boundingRectToCircle.js +7 -6
- package/utils/collide/collideCircleCircle.js +1 -2
- package/utils/collide/collideCircleRect.js +1 -2
- package/utils/collide/collidePointCircle.js +1 -2
- package/utils/collide/collidePointRect.js +1 -2
- package/utils/collide/collideRectRect.js +1 -2
- package/utils/collide/index.js +1 -2
- package/utils/css/classes.js +2 -3
- package/utils/css/index.js +1 -2
- package/utils/css/matrix.js +1 -2
- package/utils/css/styles.js +3 -8
- package/utils/css/transition.js +67 -140
- package/utils/debounce.js +3 -4
- package/utils/focusTrap.js +4 -5
- package/utils/history.js +12 -19
- package/utils/index.d.ts +2 -1
- package/utils/index.js +2 -2
- package/utils/keyCodes.js +1 -2
- package/utils/math/clamp.js +1 -2
- package/utils/math/clamp01.js +1 -2
- package/utils/math/damp.js +1 -2
- package/utils/math/index.js +1 -2
- package/utils/math/inertiaFinalValue.js +1 -2
- package/utils/math/lerp.js +1 -2
- package/utils/math/map.js +1 -2
- package/utils/math/round.js +1 -2
- package/utils/memoize.d.ts +30 -0
- package/utils/memoize.js +30 -0
- package/utils/nextFrame.js +4 -9
- package/utils/object/autoBind.js +11 -19
- package/utils/object/getAllProperties.d.ts +6 -3
- package/utils/object/getAllProperties.js +10 -8
- package/utils/object/index.js +1 -2
- package/utils/object/isObject.js +2 -4
- package/utils/string/index.js +1 -2
- package/utils/string/withLeadingCharacters.js +1 -2
- package/utils/string/withLeadingSlash.js +1 -2
- package/utils/string/withTrailingCharacters.js +1 -2
- package/utils/string/withTrailingSlash.js +1 -2
- package/utils/string/withoutLeadingCharacters.js +1 -2
- package/utils/string/withoutLeadingCharactersRecursive.js +1 -2
- package/utils/string/withoutLeadingSlash.js +1 -2
- package/utils/string/withoutTrailingCharacters.js +1 -2
- package/utils/string/withoutTrailingCharactersRecursive.js +1 -2
- package/utils/string/withoutTrailingSlash.js +1 -2
- package/utils/throttle.js +2 -3
- package/abstracts/Base/children.d.ts +0 -16
- package/abstracts/Base/children.js +0 -66
- package/abstracts/Base/children.js.map +0 -1
- package/abstracts/Base/classes/Options.d.ts +0 -37
- package/abstracts/Base/classes/Options.js +0 -182
- package/abstracts/Base/classes/Options.js.map +0 -1
- package/abstracts/Base/classes/Services.js +0 -120
- package/abstracts/Base/classes/Services.js.map +0 -1
- package/abstracts/Base/components.d.ts +0 -22
- package/abstracts/Base/components.js +0 -67
- package/abstracts/Base/components.js.map +0 -1
- package/abstracts/Base/events.d.ts +0 -8
- package/abstracts/Base/events.js +0 -185
- package/abstracts/Base/events.js.map +0 -1
- package/abstracts/Base/index.d.ts +0 -176
- package/abstracts/Base/index.js +0 -215
- package/abstracts/Base/index.js.map +0 -1
- package/abstracts/Base/options.d.ts +0 -17
- package/abstracts/Base/options.js +0 -112
- package/abstracts/Base/options.js.map +0 -1
- package/abstracts/Base/refs.d.ts +0 -30
- package/abstracts/Base/refs.js +0 -60
- package/abstracts/Base/refs.js.map +0 -1
- package/abstracts/Base/utils.js +0 -102
- package/abstracts/Base/utils.js.map +0 -1
- package/abstracts/EventManager.d.ts +0 -41
- package/abstracts/EventManager.js +0 -88
- package/abstracts/EventManager.js.map +0 -1
- package/abstracts/Service.js +0 -82
- package/abstracts/Service.js.map +0 -1
- package/abstracts/index.d.ts +0 -4
- package/abstracts/index.js +0 -5
- package/abstracts/index.js.map +0 -1
- package/components/Accordion/Accordion.d.ts +0 -83
- package/components/Accordion/Accordion.js +0 -121
- package/components/Accordion/Accordion.js.map +0 -1
- package/components/Accordion/AccordionItem.d.ts +0 -122
- package/components/Accordion/AccordionItem.js +0 -327
- package/components/Accordion/AccordionItem.js.map +0 -1
- package/components/Accordion/index.d.ts +0 -27
- package/components/Accordion/index.js +0 -39
- package/components/Accordion/index.js.map +0 -1
- package/components/Cursor.d.ts +0 -138
- package/components/Cursor.js +0 -167
- package/components/Cursor.js.map +0 -1
- package/components/Draggable.d.ts +0 -49
- package/components/Draggable.js +0 -77
- package/components/Draggable.js.map +0 -1
- package/components/Modal.d.ts +0 -158
- package/components/Modal.js +0 -270
- package/components/Modal.js.map +0 -1
- package/components/Tabs.d.ts +0 -108
- package/components/Tabs.js +0 -195
- package/components/Tabs.js.map +0 -1
- package/components/index.d.ts +0 -6
- package/components/index.js +0 -7
- package/components/index.js.map +0 -1
- package/decorators/index.js.map +0 -1
- package/decorators/withBreakpointManager.js.map +0 -1
- package/decorators/withBreakpointObserver.js.map +0 -1
- package/decorators/withDrag.js.map +0 -1
- package/decorators/withExtraConfig.js.map +0 -1
- package/decorators/withIntersectionObserver.js.map +0 -1
- package/decorators/withMountWhenInView.js.map +0 -1
- package/full.d.ts +0 -10
- package/full.js +0 -12
- package/full.js.map +0 -1
- package/full.modern.js +0 -7523
- package/full.modern.js.map +0 -1
- package/full.umd.js +0 -8277
- package/full.umd.js.map +0 -1
- package/helpers/createApp.js.map +0 -1
- package/helpers/createBase.d.ts +0 -7
- package/helpers/createBase.js +0 -7
- package/helpers/createBase.js.map +0 -1
- package/helpers/defineComponent.d.ts +0 -11
- package/helpers/defineComponent.js +0 -68
- package/helpers/defineComponent.js.map +0 -1
- package/helpers/importOnInteraction.js.map +0 -1
- package/helpers/importWhenIdle.js.map +0 -1
- package/helpers/importWhenVisible.js.map +0 -1
- package/helpers/index.js.map +0 -1
- package/helpers/utils.js.map +0 -1
- package/index.js.map +0 -1
- package/index.modern.js.map +0 -1
- package/index.umd.js.map +0 -1
- package/services/drag.js.map +0 -1
- package/services/index.js.map +0 -1
- package/services/key.js.map +0 -1
- package/services/load.js.map +0 -1
- package/services/pointer.js.map +0 -1
- package/services/raf.js.map +0 -1
- package/services/resize.js.map +0 -1
- package/services/scroll.js.map +0 -1
- package/utils/collide/boundingRectToCircle.js.map +0 -1
- package/utils/collide/collideCircleCircle.js.map +0 -1
- package/utils/collide/collideCircleRect.js.map +0 -1
- package/utils/collide/collidePointCircle.js.map +0 -1
- package/utils/collide/collidePointRect.js.map +0 -1
- package/utils/collide/collideRectRect.js.map +0 -1
- package/utils/collide/index.js.map +0 -1
- package/utils/css/classes.js.map +0 -1
- package/utils/css/index.js.map +0 -1
- package/utils/css/matrix.js.map +0 -1
- package/utils/css/styles.js.map +0 -1
- package/utils/css/transition.js.map +0 -1
- package/utils/debounce.js.map +0 -1
- package/utils/focusTrap.js.map +0 -1
- package/utils/history.js.map +0 -1
- package/utils/index.js.map +0 -1
- package/utils/keyCodes.js.map +0 -1
- package/utils/math/clamp.js.map +0 -1
- package/utils/math/clamp01.js.map +0 -1
- package/utils/math/damp.js.map +0 -1
- package/utils/math/index.js.map +0 -1
- package/utils/math/inertiaFinalValue.js.map +0 -1
- package/utils/math/lerp.js.map +0 -1
- package/utils/math/map.js.map +0 -1
- package/utils/math/round.js.map +0 -1
- package/utils/nextFrame.js.map +0 -1
- package/utils/object/autoBind.js.map +0 -1
- package/utils/object/getAllProperties.js.map +0 -1
- package/utils/object/index.js.map +0 -1
- package/utils/object/isObject.js.map +0 -1
- package/utils/string/index.js.map +0 -1
- package/utils/string/withLeadingCharacters.js.map +0 -1
- package/utils/string/withLeadingSlash.js.map +0 -1
- package/utils/string/withTrailingCharacters.js.map +0 -1
- package/utils/string/withTrailingSlash.js.map +0 -1
- package/utils/string/withoutLeadingCharacters.js.map +0 -1
- package/utils/string/withoutLeadingCharactersRecursive.js.map +0 -1
- package/utils/string/withoutLeadingSlash.js.map +0 -1
- package/utils/string/withoutTrailingCharacters.js.map +0 -1
- package/utils/string/withoutTrailingCharactersRecursive.js.map +0 -1
- package/utils/string/withoutTrailingSlash.js.map +0 -1
- package/utils/throttle.js.map +0 -1
package/components/Modal.d.ts
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {Object} ModalRefs
|
|
3
|
-
* @property {HTMLElement} close
|
|
4
|
-
* @property {HTMLElement} container
|
|
5
|
-
* @property {HTMLElement} content
|
|
6
|
-
* @property {HTMLElement} modal
|
|
7
|
-
* @property {HTMLElement} open
|
|
8
|
-
* @property {HTMLElement} overlay
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* @typedef {import('../utils/css/styles.js').CssStyleObject} CssStyleObject
|
|
12
|
-
* @typedef {Partial<Record<'open'|'active'|'closed', string|CssStyleObject>>} ModalStates
|
|
13
|
-
* @typedef {Partial<Record<keyof ModalRefs, ModalStates>>} ModalStylesOption
|
|
14
|
-
*/
|
|
15
|
-
/**
|
|
16
|
-
* @typedef {Object} ModalOptions
|
|
17
|
-
* @property {String} move A selector where to move the modal to.
|
|
18
|
-
* @property {String} autofocus A selector for the element to set the focus to when the modal opens.
|
|
19
|
-
* @property {ModalStylesOption} styles The styles for the different state of the modal.
|
|
20
|
-
*/
|
|
21
|
-
/**
|
|
22
|
-
* @typedef {Object} ModalPrivateInterface
|
|
23
|
-
* @property {ModalRefs} $refs
|
|
24
|
-
* @property {ModalOptions} $options
|
|
25
|
-
* @property {Boolean} isOpen
|
|
26
|
-
* @property {Comment} refModalPlaceholder
|
|
27
|
-
* @property {HTMLElement} refModalParentBackup
|
|
28
|
-
* @property {Function} refModalUnbindGetRefFilter
|
|
29
|
-
*/
|
|
30
|
-
/**
|
|
31
|
-
* @typedef {Modal & ModalPrivateInterface} ModalInterface
|
|
32
|
-
*/
|
|
33
|
-
/**
|
|
34
|
-
* Modal class.
|
|
35
|
-
*/
|
|
36
|
-
export default class Modal extends Base {
|
|
37
|
-
/**
|
|
38
|
-
* Modal options.
|
|
39
|
-
*/
|
|
40
|
-
static config: {
|
|
41
|
-
name: string;
|
|
42
|
-
refs: string[];
|
|
43
|
-
options: {
|
|
44
|
-
move: StringConstructor;
|
|
45
|
-
autofocus: {
|
|
46
|
-
type: StringConstructor;
|
|
47
|
-
default: string;
|
|
48
|
-
};
|
|
49
|
-
styles: {
|
|
50
|
-
type: ObjectConstructor;
|
|
51
|
-
/**
|
|
52
|
-
* @return {ModalStylesOption}
|
|
53
|
-
*/
|
|
54
|
-
default: () => ModalStylesOption;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Open the modal on click on the `open` ref.
|
|
60
|
-
*
|
|
61
|
-
* @return {Function} The component's `open` method.
|
|
62
|
-
*/
|
|
63
|
-
get onOpenClick(): Function;
|
|
64
|
-
/**
|
|
65
|
-
* Close the modal on click on the `close` ref.
|
|
66
|
-
*
|
|
67
|
-
* @return {Function} The component's `close` method.
|
|
68
|
-
*/
|
|
69
|
-
get onCloseClick(): Function;
|
|
70
|
-
/**
|
|
71
|
-
* Close the modal on click on the `overlay` ref.
|
|
72
|
-
*
|
|
73
|
-
* @return {Function} The component's `close` method.
|
|
74
|
-
*/
|
|
75
|
-
get onOverlayClick(): Function;
|
|
76
|
-
/**
|
|
77
|
-
* Initialize the component's behaviours.
|
|
78
|
-
*
|
|
79
|
-
* @this {ModalInterface}
|
|
80
|
-
*/
|
|
81
|
-
mounted(): ModalInterface;
|
|
82
|
-
isOpen: boolean;
|
|
83
|
-
refModalPlaceholder: Comment;
|
|
84
|
-
refModalParentBackup: any;
|
|
85
|
-
refModalUnbindGetRefFilter: any;
|
|
86
|
-
/**
|
|
87
|
-
* Unbind all events on destroy.
|
|
88
|
-
*
|
|
89
|
-
* @this {ModalInterface}
|
|
90
|
-
* @return {Modal} The Modal instance.
|
|
91
|
-
*/
|
|
92
|
-
destroyed(): Modal;
|
|
93
|
-
/**
|
|
94
|
-
* Close the modal on `ESC` and trap the tabulation.
|
|
95
|
-
*
|
|
96
|
-
* @this {ModalInterface}
|
|
97
|
-
* @param {Object} options
|
|
98
|
-
* @param {KeyboardEvent} options.event The original keyboard event
|
|
99
|
-
* @param {Boolean} options.isUp Is it a keyup event?
|
|
100
|
-
* @param {Boolean} options.isDown Is it a keydown event?
|
|
101
|
-
* @param {Boolean} options.ESC Is it the ESC key?
|
|
102
|
-
*/
|
|
103
|
-
keyed({ event, isUp, isDown, ESC }: {
|
|
104
|
-
event: KeyboardEvent;
|
|
105
|
-
isUp: boolean;
|
|
106
|
-
isDown: boolean;
|
|
107
|
-
ESC: boolean;
|
|
108
|
-
}): void;
|
|
109
|
-
/**
|
|
110
|
-
* Open the modal.
|
|
111
|
-
*
|
|
112
|
-
* @this {ModalInterface}
|
|
113
|
-
* @return {Promise<ModalInterface>} The Modal instance.
|
|
114
|
-
*/
|
|
115
|
-
open(): Promise<ModalInterface>;
|
|
116
|
-
/**
|
|
117
|
-
* Close the modal.
|
|
118
|
-
*
|
|
119
|
-
* @this {ModalInterface}
|
|
120
|
-
* @return {Promise<ModalInterface>} The Modal instance.
|
|
121
|
-
*/
|
|
122
|
-
close(): Promise<ModalInterface>;
|
|
123
|
-
}
|
|
124
|
-
export type ModalRefs = {
|
|
125
|
-
close: HTMLElement;
|
|
126
|
-
container: HTMLElement;
|
|
127
|
-
content: HTMLElement;
|
|
128
|
-
modal: HTMLElement;
|
|
129
|
-
open: HTMLElement;
|
|
130
|
-
overlay: HTMLElement;
|
|
131
|
-
};
|
|
132
|
-
export type CssStyleObject = import('../utils/css/styles.js').CssStyleObject;
|
|
133
|
-
export type ModalStates = Partial<Record<'open' | 'active' | 'closed', string | CssStyleObject>>;
|
|
134
|
-
export type ModalStylesOption = Partial<Record<keyof ModalRefs, ModalStates>>;
|
|
135
|
-
export type ModalOptions = {
|
|
136
|
-
/**
|
|
137
|
-
* A selector where to move the modal to.
|
|
138
|
-
*/
|
|
139
|
-
move: string;
|
|
140
|
-
/**
|
|
141
|
-
* A selector for the element to set the focus to when the modal opens.
|
|
142
|
-
*/
|
|
143
|
-
autofocus: string;
|
|
144
|
-
/**
|
|
145
|
-
* The styles for the different state of the modal.
|
|
146
|
-
*/
|
|
147
|
-
styles: ModalStylesOption;
|
|
148
|
-
};
|
|
149
|
-
export type ModalPrivateInterface = {
|
|
150
|
-
$refs: ModalRefs;
|
|
151
|
-
$options: ModalOptions;
|
|
152
|
-
isOpen: boolean;
|
|
153
|
-
refModalPlaceholder: Comment;
|
|
154
|
-
refModalParentBackup: HTMLElement;
|
|
155
|
-
refModalUnbindGetRefFilter: Function;
|
|
156
|
-
};
|
|
157
|
-
export type ModalInterface = Modal & ModalPrivateInterface;
|
|
158
|
-
import Base from "../abstracts/Base/index.js";
|
package/components/Modal.js
DELETED
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
10
|
-
|
|
11
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
|
-
|
|
13
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
14
|
-
|
|
15
|
-
import Base from '../abstracts/Base/index.js';
|
|
16
|
-
import transition from '../utils/css/transition.js';
|
|
17
|
-
import { trap, untrap, saveActiveElement } from '../utils/focusTrap.js';
|
|
18
|
-
|
|
19
|
-
var Modal = function (_Base) {
|
|
20
|
-
_inherits(Modal, _Base);
|
|
21
|
-
|
|
22
|
-
var _super = _createSuper(Modal);
|
|
23
|
-
|
|
24
|
-
function Modal() {
|
|
25
|
-
_classCallCheck(this, Modal);
|
|
26
|
-
|
|
27
|
-
return _super.apply(this, arguments);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
_createClass(Modal, [{
|
|
31
|
-
key: "onOpenClick",
|
|
32
|
-
get: function get() {
|
|
33
|
-
return this.open;
|
|
34
|
-
}
|
|
35
|
-
}, {
|
|
36
|
-
key: "onCloseClick",
|
|
37
|
-
get: function get() {
|
|
38
|
-
return this.close;
|
|
39
|
-
}
|
|
40
|
-
}, {
|
|
41
|
-
key: "onOverlayClick",
|
|
42
|
-
get: function get() {
|
|
43
|
-
return this.close;
|
|
44
|
-
}
|
|
45
|
-
}, {
|
|
46
|
-
key: "mounted",
|
|
47
|
-
value: function mounted() {
|
|
48
|
-
this.isOpen = false;
|
|
49
|
-
this.close();
|
|
50
|
-
|
|
51
|
-
if (this.$options.move) {
|
|
52
|
-
var target = document.querySelector(this.$options.move) || document.body;
|
|
53
|
-
var refsBackup = this.$refs;
|
|
54
|
-
this.refModalPlaceholder = document.createComment('');
|
|
55
|
-
this.refModalParentBackup = this.$refs.modal.parentElement || this.$el;
|
|
56
|
-
this.refModalParentBackup.insertBefore(this.refModalPlaceholder, this.$refs.modal);
|
|
57
|
-
this.refModalUnbindGetRefFilter = this.$on('get:refs', function (refs) {
|
|
58
|
-
Object.entries(refsBackup).forEach(function (_ref) {
|
|
59
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
60
|
-
key = _ref2[0],
|
|
61
|
-
ref = _ref2[1];
|
|
62
|
-
|
|
63
|
-
if (!refs[key]) {
|
|
64
|
-
refs[key] = ref;
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
target.appendChild(this.$refs.modal);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return this;
|
|
72
|
-
}
|
|
73
|
-
}, {
|
|
74
|
-
key: "destroyed",
|
|
75
|
-
value: function destroyed() {
|
|
76
|
-
this.close();
|
|
77
|
-
|
|
78
|
-
if (this.$options.move && this.refModalParentBackup) {
|
|
79
|
-
this.refModalParentBackup.insertBefore(this.$refs.modal, this.refModalPlaceholder);
|
|
80
|
-
this.refModalUnbindGetRefFilter();
|
|
81
|
-
this.refModalPlaceholder.remove();
|
|
82
|
-
delete this.refModalPlaceholder;
|
|
83
|
-
delete this.refModalParentBackup;
|
|
84
|
-
delete this.refModalUnbindGetRefFilter;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return this;
|
|
88
|
-
}
|
|
89
|
-
}, {
|
|
90
|
-
key: "keyed",
|
|
91
|
-
value: function keyed(_ref3) {
|
|
92
|
-
var event = _ref3.event,
|
|
93
|
-
isUp = _ref3.isUp,
|
|
94
|
-
isDown = _ref3.isDown,
|
|
95
|
-
ESC = _ref3.ESC;
|
|
96
|
-
|
|
97
|
-
if (!this.isOpen) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (isDown) {
|
|
102
|
-
trap(this.$refs.modal, event);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (ESC && isUp) {
|
|
106
|
-
this.close();
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}, {
|
|
110
|
-
key: "open",
|
|
111
|
-
value: function () {
|
|
112
|
-
var _open = _asyncToGenerator(_regeneratorRuntime.mark(function _callee() {
|
|
113
|
-
var _this = this;
|
|
114
|
-
|
|
115
|
-
var refs;
|
|
116
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
117
|
-
while (1) {
|
|
118
|
-
switch (_context.prev = _context.next) {
|
|
119
|
-
case 0:
|
|
120
|
-
if (!this.isOpen) {
|
|
121
|
-
_context.next = 2;
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return _context.abrupt("return", Promise.resolve(this));
|
|
126
|
-
|
|
127
|
-
case 2:
|
|
128
|
-
this.$refs.modal.setAttribute('aria-hidden', 'false');
|
|
129
|
-
document.documentElement.style.overflow = 'hidden';
|
|
130
|
-
this.isOpen = true;
|
|
131
|
-
this.$emit('open');
|
|
132
|
-
refs = this.$refs;
|
|
133
|
-
return _context.abrupt("return", Promise.all(Object.entries(this.$options.styles).map(function (_ref4) {
|
|
134
|
-
var _ref5 = _slicedToArray(_ref4, 2),
|
|
135
|
-
refName = _ref5[0],
|
|
136
|
-
_ref5$ = _ref5[1];
|
|
137
|
-
|
|
138
|
-
_ref5$ = _ref5$ === void 0 ? {
|
|
139
|
-
open: '',
|
|
140
|
-
active: '',
|
|
141
|
-
closed: ''
|
|
142
|
-
} : _ref5$;
|
|
143
|
-
var open = _ref5$.open,
|
|
144
|
-
active = _ref5$.active,
|
|
145
|
-
closed = _ref5$.closed;
|
|
146
|
-
return transition(refs[refName], {
|
|
147
|
-
from: closed,
|
|
148
|
-
active: active,
|
|
149
|
-
to: open
|
|
150
|
-
}, 'keep');
|
|
151
|
-
})).then(function () {
|
|
152
|
-
if (_this.$options.autofocus && _this.$refs.modal.querySelector(_this.$options.autofocus)) {
|
|
153
|
-
saveActiveElement();
|
|
154
|
-
|
|
155
|
-
var autofocusElement = _this.$refs.modal.querySelector(_this.$options.autofocus);
|
|
156
|
-
|
|
157
|
-
autofocusElement.focus();
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return Promise.resolve(_this);
|
|
161
|
-
}));
|
|
162
|
-
|
|
163
|
-
case 8:
|
|
164
|
-
case "end":
|
|
165
|
-
return _context.stop();
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}, _callee, this);
|
|
169
|
-
}));
|
|
170
|
-
|
|
171
|
-
function open() {
|
|
172
|
-
return _open.apply(this, arguments);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return open;
|
|
176
|
-
}()
|
|
177
|
-
}, {
|
|
178
|
-
key: "close",
|
|
179
|
-
value: function () {
|
|
180
|
-
var _close = _asyncToGenerator(_regeneratorRuntime.mark(function _callee2() {
|
|
181
|
-
var _this2 = this;
|
|
182
|
-
|
|
183
|
-
var refs;
|
|
184
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
185
|
-
while (1) {
|
|
186
|
-
switch (_context2.prev = _context2.next) {
|
|
187
|
-
case 0:
|
|
188
|
-
if (this.isOpen) {
|
|
189
|
-
_context2.next = 2;
|
|
190
|
-
break;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
return _context2.abrupt("return", Promise.resolve(this));
|
|
194
|
-
|
|
195
|
-
case 2:
|
|
196
|
-
this.$refs.modal.setAttribute('aria-hidden', 'true');
|
|
197
|
-
document.documentElement.style.overflow = '';
|
|
198
|
-
this.isOpen = false;
|
|
199
|
-
untrap();
|
|
200
|
-
this.$emit('close');
|
|
201
|
-
refs = this.$refs;
|
|
202
|
-
return _context2.abrupt("return", Promise.all(Object.entries(this.$options.styles).map(function (_ref6) {
|
|
203
|
-
var _ref7 = _slicedToArray(_ref6, 2),
|
|
204
|
-
refName = _ref7[0],
|
|
205
|
-
_ref7$ = _ref7[1];
|
|
206
|
-
|
|
207
|
-
_ref7$ = _ref7$ === void 0 ? {
|
|
208
|
-
open: '',
|
|
209
|
-
active: '',
|
|
210
|
-
closed: ''
|
|
211
|
-
} : _ref7$;
|
|
212
|
-
var open = _ref7$.open,
|
|
213
|
-
active = _ref7$.active,
|
|
214
|
-
closed = _ref7$.closed;
|
|
215
|
-
return transition(refs[refName], {
|
|
216
|
-
from: open,
|
|
217
|
-
active: active,
|
|
218
|
-
to: closed
|
|
219
|
-
}, 'keep');
|
|
220
|
-
})).then(function () {
|
|
221
|
-
return Promise.resolve(_this2);
|
|
222
|
-
}));
|
|
223
|
-
|
|
224
|
-
case 9:
|
|
225
|
-
case "end":
|
|
226
|
-
return _context2.stop();
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}, _callee2, this);
|
|
230
|
-
}));
|
|
231
|
-
|
|
232
|
-
function close() {
|
|
233
|
-
return _close.apply(this, arguments);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
return close;
|
|
237
|
-
}()
|
|
238
|
-
}]);
|
|
239
|
-
|
|
240
|
-
return Modal;
|
|
241
|
-
}(Base);
|
|
242
|
-
|
|
243
|
-
_defineProperty(Modal, "config", {
|
|
244
|
-
name: 'Modal',
|
|
245
|
-
refs: ['close', 'container', 'content', 'modal', 'open', 'overlay'],
|
|
246
|
-
options: {
|
|
247
|
-
move: String,
|
|
248
|
-
autofocus: {
|
|
249
|
-
type: String,
|
|
250
|
-
default: '[autofocus]'
|
|
251
|
-
},
|
|
252
|
-
styles: {
|
|
253
|
-
type: Object,
|
|
254
|
-
default: function _default() {
|
|
255
|
-
return {
|
|
256
|
-
modal: {
|
|
257
|
-
closed: {
|
|
258
|
-
opacity: '0',
|
|
259
|
-
pointerEvents: 'none',
|
|
260
|
-
visibility: 'hidden'
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
export { Modal as default };
|
|
270
|
-
//# sourceMappingURL=Modal.js.map
|
package/components/Modal.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../packages/js-toolkit/components/Modal.js"],"names":["Base","transition","trap","untrap","saveActiveElement","Modal","open","close","isOpen","$options","move","target","document","querySelector","body","refsBackup","$refs","refModalPlaceholder","createComment","refModalParentBackup","modal","parentElement","$el","insertBefore","refModalUnbindGetRefFilter","$on","refs","Object","entries","forEach","key","ref","appendChild","remove","event","isUp","isDown","ESC","Promise","resolve","setAttribute","documentElement","style","overflow","$emit","all","styles","map","refName","active","closed","from","to","then","autofocus","autofocusElement","focus","name","options","String","type","default","opacity","pointerEvents","visibility"],"mappings":";;;;;;;;;;;;;;AAAA,OAAOA,IAAP,MAAiB,4BAAjB;AACA,OAAOC,UAAP,MAAuB,4BAAvB;AACA,SAASC,IAAT,EAAeC,MAAf,EAAuBC,iBAAvB,QAAgD,uBAAhD;;IA0CqBC,K;;;;;;;;;;;;;SAiCnB,eAAkB;AAChB,aAAO,KAAKC,IAAZ;AACD;;;SAOD,eAAmB;AACjB,aAAO,KAAKC,KAAZ;AACD;;;SAOD,eAAqB;AACnB,aAAO,KAAKA,KAAZ;AACD;;;WAOD,mBAAU;AACR,WAAKC,MAAL,GAAc,KAAd;AACA,WAAKD,KAAL;;AAEA,UAAI,KAAKE,QAAL,CAAcC,IAAlB,EAAwB;AACtB,YAAMC,MAAM,GAAGC,QAAQ,CAACC,aAAT,CAAuB,KAAKJ,QAAL,CAAcC,IAArC,KAA8CE,QAAQ,CAACE,IAAtE;AACA,YAAMC,UAAU,GAAG,KAAKC,KAAxB;AAEA,aAAKC,mBAAL,GAA2BL,QAAQ,CAACM,aAAT,CAAuB,EAAvB,CAA3B;AACA,aAAKC,oBAAL,GAA4B,KAAKH,KAAL,CAAWI,KAAX,CAAiBC,aAAjB,IAAkC,KAAKC,GAAnE;AACA,aAAKH,oBAAL,CAA0BI,YAA1B,CAAuC,KAAKN,mBAA5C,EAAiE,KAAKD,KAAL,CAAWI,KAA5E;AAEA,aAAKI,0BAAL,GAAkC,KAAKC,GAAL,CAChC,UADgC,EAKhC,UAACC,IAAD,EAAU;AACRC,UAAAA,MAAM,CAACC,OAAP,CAAeb,UAAf,EAA2Bc,OAA3B,CAAmC,gBAAgB;AAAA;AAAA,gBAAdC,GAAc;AAAA,gBAATC,GAAS;;AACjD,gBAAI,CAACL,IAAI,CAACI,GAAD,CAAT,EAAgB;AACdJ,cAAAA,IAAI,CAACI,GAAD,CAAJ,GAAYC,GAAZ;AACD;AACF,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WAAV,EAAuB,SAAvB,EAAkC,OAAlC,EAA2C,MAA3C,EAAmD,SAAnD,CAFQ;AAGdgC,EAAAA,OAAO,EAAE;AACPhD,IAAAA,IAAI,EAAEiD,MADC;AAEPL,IAAAA,SAAS,EAAE;AAAEM,MAAAA,IAAI,EAAED,MAAR;AAAgBE,MAAAA,OAAO,EAAE;AAAzB,KAFJ;AAGPf,IAAAA,MAAM,EAAE;AACNc,MAAAA,IAAI,EAAEjC,MADA;AAKNkC,MAAAA,OAAO,EAAE;AAAA,eAAO;AACdzC,UAAAA,KAAK,EAAE;AACL8B,YAAAA,MAAM,EAAE;AACNY,cAAAA,OAAO,EAAE,GADH;AAENC,cAAAA,aAAa,EAAE,MAFT;AAGNC,cAAAA,UAAU,EAAE;AAHN;AADH;AADO,SAAP;AAAA;AALH;AAHD;AAHK,C;;SAJG3D,K","sourcesContent":["import Base from '../abstracts/Base/index.js';\nimport transition from '../utils/css/transition.js';\nimport { trap, untrap, saveActiveElement } from '../utils/focusTrap.js';\n\n/**\n * @typedef {Object} ModalRefs\n * @property {HTMLElement} close\n * @property {HTMLElement} container\n * @property {HTMLElement} content\n * @property {HTMLElement} modal\n * @property {HTMLElement} open\n * @property {HTMLElement} overlay\n */\n\n/**\n * @typedef {import('../utils/css/styles.js').CssStyleObject} CssStyleObject\n * @typedef {Partial<Record<'open'|'active'|'closed', string|CssStyleObject>>} ModalStates\n * @typedef {Partial<Record<keyof ModalRefs, ModalStates>>} ModalStylesOption\n */\n\n/**\n * @typedef {Object} ModalOptions\n * @property {String} move A selector where to move the modal to.\n * @property {String} autofocus A selector for the element to set the focus to when the modal opens.\n * @property {ModalStylesOption} styles The styles for the different state of the modal.\n */\n\n/**\n * @typedef {Object} ModalPrivateInterface\n * @property {ModalRefs} $refs\n * @property {ModalOptions} $options\n * @property {Boolean} isOpen\n * @property {Comment} refModalPlaceholder\n * @property {HTMLElement} refModalParentBackup\n * @property {Function} refModalUnbindGetRefFilter\n */\n\n/**\n * @typedef {Modal & ModalPrivateInterface} ModalInterface\n */\n\n/**\n * Modal class.\n */\nexport default class Modal extends Base {\n /**\n * Modal options.\n */\n static config = {\n name: 'Modal',\n refs: ['close', 'container', 'content', 'modal', 'open', 'overlay'],\n options: {\n move: String,\n autofocus: { type: String, default: '[autofocus]' },\n styles: {\n type: Object,\n /**\n * @return {ModalStylesOption}\n */\n default: () => ({\n modal: {\n closed: {\n opacity: '0',\n pointerEvents: 'none',\n visibility: 'hidden',\n },\n },\n }),\n },\n },\n };\n\n /**\n * Open the modal on click on the `open` ref.\n *\n * @return {Function} The component's `open` method.\n */\n get onOpenClick() {\n return this.open;\n }\n\n /**\n * Close the modal on click on the `close` ref.\n *\n * @return {Function} The component's `close` method.\n */\n get onCloseClick() {\n return this.close;\n }\n\n /**\n * Close the modal on click on the `overlay` ref.\n *\n * @return {Function} The component's `close` method.\n */\n get onOverlayClick() {\n return this.close;\n }\n\n /**\n * Initialize the component's behaviours.\n *\n * @this {ModalInterface}\n */\n mounted() {\n this.isOpen = false;\n this.close();\n\n if (this.$options.move) {\n const target = document.querySelector(this.$options.move) || document.body;\n const refsBackup = this.$refs;\n\n this.refModalPlaceholder = document.createComment('');\n this.refModalParentBackup = this.$refs.modal.parentElement || this.$el;\n this.refModalParentBackup.insertBefore(this.refModalPlaceholder, this.$refs.modal);\n\n this.refModalUnbindGetRefFilter = this.$on(\n 'get:refs',\n /**\n * @param {ModalRefs} refs\n */\n (refs) => {\n Object.entries(refsBackup).forEach(([key, ref]) => {\n if (!refs[key]) {\n refs[key] = ref;\n }\n });\n }\n );\n target.appendChild(this.$refs.modal);\n }\n\n return this;\n }\n\n /**\n * Unbind all events on destroy.\n *\n * @this {ModalInterface}\n * @return {Modal} The Modal instance.\n */\n destroyed() {\n this.close();\n\n if (this.$options.move && this.refModalParentBackup) {\n this.refModalParentBackup.insertBefore(this.$refs.modal, this.refModalPlaceholder);\n this.refModalUnbindGetRefFilter();\n this.refModalPlaceholder.remove();\n delete this.refModalPlaceholder;\n delete this.refModalParentBackup;\n delete this.refModalUnbindGetRefFilter;\n }\n\n return this;\n }\n\n /**\n * Close the modal on `ESC` and trap the tabulation.\n *\n * @this {ModalInterface}\n * @param {Object} options\n * @param {KeyboardEvent} options.event The original keyboard event\n * @param {Boolean} options.isUp Is it a keyup event?\n * @param {Boolean} options.isDown Is it a keydown event?\n * @param {Boolean} options.ESC Is it the ESC key?\n */\n keyed({ event, isUp, isDown, ESC }) {\n if (!this.isOpen) {\n return;\n }\n\n if (isDown) {\n trap(this.$refs.modal, event);\n }\n\n if (ESC && isUp) {\n this.close();\n }\n }\n\n /**\n * Open the modal.\n *\n * @this {ModalInterface}\n * @return {Promise<ModalInterface>} The Modal instance.\n */\n async open() {\n if (this.isOpen) {\n return Promise.resolve(this);\n }\n\n this.$refs.modal.setAttribute('aria-hidden', 'false');\n document.documentElement.style.overflow = 'hidden';\n\n this.isOpen = true;\n this.$emit('open');\n\n /** @type {ModalRefs} */\n const refs = this.$refs;\n\n return Promise.all(\n Object.entries(this.$options.styles).map(\n ([refName, { open, active, closed } = { open: '', active: '', closed: '' }]) =>\n transition(\n refs[refName],\n {\n from: closed,\n active,\n to: open,\n },\n 'keep'\n )\n )\n ).then(() => {\n if (this.$options.autofocus && this.$refs.modal.querySelector(this.$options.autofocus)) {\n saveActiveElement();\n /** @type {HTMLElement} */\n const autofocusElement = this.$refs.modal.querySelector(this.$options.autofocus);\n autofocusElement.focus();\n }\n return Promise.resolve(this);\n });\n }\n\n /**\n * Close the modal.\n *\n * @this {ModalInterface}\n * @return {Promise<ModalInterface>} The Modal instance.\n */\n async close() {\n if (!this.isOpen) {\n return Promise.resolve(this);\n }\n\n this.$refs.modal.setAttribute('aria-hidden', 'true');\n document.documentElement.style.overflow = '';\n\n this.isOpen = false;\n untrap();\n this.$emit('close');\n\n /** @type {ModalRefs} */\n const refs = this.$refs;\n\n return Promise.all(\n Object.entries(this.$options.styles).map(\n ([refName, { open, active, closed } = { open: '', active: '', closed: '' }]) =>\n transition(\n refs[refName],\n {\n from: open,\n active,\n to: closed,\n },\n 'keep'\n )\n )\n ).then(() => Promise.resolve(this));\n }\n}\n"],"file":"Modal.js"}
|
package/components/Tabs.d.ts
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {import('../abstracts/Base').BaseOptions} BaseOptions
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* @typedef {Object} TabItem
|
|
6
|
-
* @property {HTMLElement} btn
|
|
7
|
-
* @property {HTMLElement} content
|
|
8
|
-
* @property {Boolean} isEnabled
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* @typedef {Object} TabsRefs
|
|
12
|
-
* @property {HTMLElement[]} btn
|
|
13
|
-
* @property {HTMLElement[]} content
|
|
14
|
-
*/
|
|
15
|
-
/**
|
|
16
|
-
* @typedef {import('../utils/css/styles.js').CssStyleObject} CssStyleObject
|
|
17
|
-
* @typedef {Partial<Record<'open'|'active'|'closed', string|CssStyleObject>>} TabsStates
|
|
18
|
-
* @typedef {Partial<Record<keyof TabsRefs, TabsStates>>} TabsStylesOption
|
|
19
|
-
*/
|
|
20
|
-
/**
|
|
21
|
-
* @typedef {Object} TabsOptions
|
|
22
|
-
* @property {TabsStylesOption} styles
|
|
23
|
-
*/
|
|
24
|
-
/**
|
|
25
|
-
* @typedef {Object} TabsPrivateInterface
|
|
26
|
-
* @property {TabsOptions} $options
|
|
27
|
-
* @property {TabsRefs} $refs
|
|
28
|
-
* @property {Array<TabItem>} items
|
|
29
|
-
*/
|
|
30
|
-
/**
|
|
31
|
-
* @typedef {Tabs & TabsPrivateInterface} TabsInterface
|
|
32
|
-
*/
|
|
33
|
-
/**
|
|
34
|
-
* Tabs class.
|
|
35
|
-
*/
|
|
36
|
-
export default class Tabs extends Base {
|
|
37
|
-
/**
|
|
38
|
-
* Tabs config.
|
|
39
|
-
*/
|
|
40
|
-
static config: {
|
|
41
|
-
name: string;
|
|
42
|
-
refs: string[];
|
|
43
|
-
options: {
|
|
44
|
-
styles: {
|
|
45
|
-
type: ObjectConstructor;
|
|
46
|
-
/**
|
|
47
|
-
* @return {TabsStylesOption}
|
|
48
|
-
*/
|
|
49
|
-
default: () => TabsStylesOption;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Initialize the component's behaviours.
|
|
55
|
-
* @this {TabsInterface}
|
|
56
|
-
* @return {void}
|
|
57
|
-
*/
|
|
58
|
-
mounted(): void;
|
|
59
|
-
items: any;
|
|
60
|
-
/**
|
|
61
|
-
* Switch tab on button click.
|
|
62
|
-
*
|
|
63
|
-
* @this {TabsInterface}
|
|
64
|
-
* @param {Event} event The click event object.
|
|
65
|
-
* @param {Number} index The index of the clicked button.
|
|
66
|
-
* @return {void}
|
|
67
|
-
*/
|
|
68
|
-
onBtnClick(event: Event, index: number): void;
|
|
69
|
-
/**
|
|
70
|
-
* Enable the given tab and its associated content.
|
|
71
|
-
*
|
|
72
|
-
* @this {TabsInterface}
|
|
73
|
-
* @param {TabItem} item The item to enable.
|
|
74
|
-
* @return {Promise<TabsInterface>} Tabs instance.
|
|
75
|
-
*/
|
|
76
|
-
enableItem(item: TabItem): Promise<TabsInterface>;
|
|
77
|
-
/**
|
|
78
|
-
* Disable the given tab and its associated content.
|
|
79
|
-
*
|
|
80
|
-
* @this {TabsInterface}
|
|
81
|
-
* @param {TabItem} item The item to disable.
|
|
82
|
-
* @return {Promise<TabsInterface>} The Tabs instance.
|
|
83
|
-
*/
|
|
84
|
-
disableItem(item: TabItem): Promise<TabsInterface>;
|
|
85
|
-
}
|
|
86
|
-
export type BaseOptions = import('../abstracts/Base').BaseOptions;
|
|
87
|
-
export type TabItem = {
|
|
88
|
-
btn: HTMLElement;
|
|
89
|
-
content: HTMLElement;
|
|
90
|
-
isEnabled: boolean;
|
|
91
|
-
};
|
|
92
|
-
export type TabsRefs = {
|
|
93
|
-
btn: HTMLElement[];
|
|
94
|
-
content: HTMLElement[];
|
|
95
|
-
};
|
|
96
|
-
export type CssStyleObject = import('../utils/css/styles.js').CssStyleObject;
|
|
97
|
-
export type TabsStates = Partial<Record<'open' | 'active' | 'closed', string | CssStyleObject>>;
|
|
98
|
-
export type TabsStylesOption = Partial<Record<keyof TabsRefs, TabsStates>>;
|
|
99
|
-
export type TabsOptions = {
|
|
100
|
-
styles: TabsStylesOption;
|
|
101
|
-
};
|
|
102
|
-
export type TabsPrivateInterface = {
|
|
103
|
-
$options: TabsOptions;
|
|
104
|
-
$refs: TabsRefs;
|
|
105
|
-
items: Array<TabItem>;
|
|
106
|
-
};
|
|
107
|
-
export type TabsInterface = Tabs & TabsPrivateInterface;
|
|
108
|
-
import Base from "../abstracts/Base/index.js";
|