duck-vue-components 0.0.0
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/README.md +29 -0
- package/dist/MyButton-C1krVCi6.cjs +36 -0
- package/dist/MyButton-C7riFwH6.js +28 -0
- package/dist/_plugin-vue_export-helper-DQXgr64F.cjs +13 -0
- package/dist/_plugin-vue_export-helper-DbXABBKy.js +8 -0
- package/dist/affix-CYU-9qMr.cjs +71 -0
- package/dist/affix-D9EM8_Um.js +66 -0
- package/dist/button-CGv1WHzT.cjs +132 -0
- package/dist/button-tOWSPPxz.js +126 -0
- package/dist/chunk-CZWwpsFl.cjs +43 -0
- package/dist/chunk-pbuEa-1d.js +13 -0
- package/dist/config.cjs +1 -0
- package/dist/config.js +1 -0
- package/dist/constants/json.cjs +4 -0
- package/dist/constants/json.d.cts +2 -0
- package/dist/constants/json.d.ts +2 -0
- package/dist/constants/json.js +2 -0
- package/dist/constants.cjs +14 -0
- package/dist/constants.d.cts +3 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.js +3 -0
- package/dist/controls/MyButton.cjs +3 -0
- package/dist/controls/MyButton.d.cts +2 -0
- package/dist/controls/MyButton.d.ts +2 -0
- package/dist/controls/MyButton.js +2 -0
- package/dist/controls/affix.cjs +8 -0
- package/dist/controls/affix.d.cts +2 -0
- package/dist/controls/affix.d.ts +2 -0
- package/dist/controls/affix.js +2 -0
- package/dist/controls/button.cjs +8 -0
- package/dist/controls/button.js +2 -0
- package/dist/controls.cjs +18 -0
- package/dist/controls.d.cts +10 -0
- package/dist/controls.d.ts +10 -0
- package/dist/controls.js +5 -0
- package/dist/dom-CllENWMY.js +346 -0
- package/dist/dom-DS4YqkjW.cjs +580 -0
- package/dist/index-1ELDRrC5.d.ts +1397 -0
- package/dist/index-5JdIJn1m.d.cts +74 -0
- package/dist/index-6KzLtJFy.d.cts +157 -0
- package/dist/index-BGkTN1DD.d.cts +15 -0
- package/dist/index-BHq-BMCP.d.ts +74 -0
- package/dist/index-BI-hrf4t.d.ts +332 -0
- package/dist/index-BtOBjeH7.d.ts +10 -0
- package/dist/index-C-uY4885.d.cts +23 -0
- package/dist/index-C5SJLWEN.d.ts +23 -0
- package/dist/index-CSvc8L11.d.cts +51 -0
- package/dist/index-CeemHBNT.d.ts +51 -0
- package/dist/index-CfkAYIKD.d.cts +80 -0
- package/dist/index-CiJC-ieW.d.ts +157 -0
- package/dist/index-DamAmum6.d.ts +15 -0
- package/dist/index-DhOoJCHW.d.cts +1397 -0
- package/dist/index-PhthUD7x.d.cts +10 -0
- package/dist/index-oDsyZ3t2.d.cts +332 -0
- package/dist/index-x9xs2cbA.d.ts +80 -0
- package/dist/json-BkkaM20u.cjs +31034 -0
- package/dist/json-D-_zTSK6.js +31023 -0
- package/dist/locale-DhlAaV1Q.js +597 -0
- package/dist/locale-WzzxOobw.cjs +658 -0
- package/dist/locale.cjs +12 -0
- package/dist/locale.js +2 -0
- package/dist/objects-CLXPNOUW.js +134 -0
- package/dist/objects-o7u5s_lI.cjs +272 -0
- package/dist/packages/config.cjs +10 -0
- package/dist/packages/config.d.cts +2 -0
- package/dist/packages/config.d.ts +2 -0
- package/dist/packages/config.js +5 -0
- package/dist/packages/constants/json.cjs +4 -0
- package/dist/packages/constants/json.js +2 -0
- package/dist/packages/constants.cjs +78 -0
- package/dist/packages/constants.js +67 -0
- package/dist/packages/controls/MyButton.cjs +3 -0
- package/dist/packages/controls/MyButton.js +2 -0
- package/dist/packages/controls/affix.cjs +8 -0
- package/dist/packages/controls/affix.js +2 -0
- package/dist/packages/controls/button.cjs +8 -0
- package/dist/packages/controls/button.d.cts +2 -0
- package/dist/packages/controls/button.d.ts +2 -0
- package/dist/packages/controls/button.js +2 -0
- package/dist/packages/controls.cjs +31 -0
- package/dist/packages/controls.js +12 -0
- package/dist/packages/locale.cjs +12 -0
- package/dist/packages/locale.d.cts +39 -0
- package/dist/packages/locale.d.ts +39 -0
- package/dist/packages/locale.js +2 -0
- package/dist/packages/stores.cjs +337 -0
- package/dist/packages/stores.js +320 -0
- package/dist/packages/utils/dom.cjs +32 -0
- package/dist/packages/utils/dom.d.cts +2 -0
- package/dist/packages/utils/dom.d.ts +2 -0
- package/dist/packages/utils/dom.js +2 -0
- package/dist/packages/utils/vue/props.cjs +63 -0
- package/dist/packages/utils/vue/props.d.cts +2 -0
- package/dist/packages/utils/vue/props.d.ts +2 -0
- package/dist/packages/utils/vue/props.js +56 -0
- package/dist/packages/utils/vue.cjs +32 -0
- package/dist/packages/utils/vue.d.cts +3 -0
- package/dist/packages/utils/vue.d.ts +3 -0
- package/dist/packages/utils/vue.js +24 -0
- package/dist/packages/utils.cjs +190 -0
- package/dist/packages/utils.js +6 -0
- package/dist/packages.cjs +15 -0
- package/dist/packages.d.cts +3 -0
- package/dist/packages.d.ts +3 -0
- package/dist/packages.js +3 -0
- package/dist/stores.cjs +17 -0
- package/dist/stores.d.cts +805 -0
- package/dist/stores.d.ts +805 -0
- package/dist/stores.js +4 -0
- package/dist/style.css +15 -0
- package/dist/utils/dom.cjs +32 -0
- package/dist/utils/dom.js +2 -0
- package/dist/utils/vue/props.cjs +7 -0
- package/dist/utils/vue/props.js +2 -0
- package/dist/utils/vue.cjs +11 -0
- package/dist/utils/vue.js +3 -0
- package/dist/utils-DlBKdS0t.js +696 -0
- package/dist/utils-egS_3P4w.cjs +850 -0
- package/dist/utils.cjs +190 -0
- package/dist/utils.d.cts +5 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +6 -0
- package/package.json +184 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_button = require("../button-CGv1WHzT.cjs");
|
|
3
|
+
Object.defineProperty(exports, "RwButton", {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
get: function() {
|
|
6
|
+
return require_button.button_exports;
|
|
7
|
+
}
|
|
8
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_MyButton = require("./MyButton-C1krVCi6.cjs");
|
|
3
|
+
const require_button = require("./button-CGv1WHzT.cjs");
|
|
4
|
+
const require_affix = require("./affix-CYU-9qMr.cjs");
|
|
5
|
+
require("./packages/controls.cjs");
|
|
6
|
+
exports.MyButton = require_MyButton.MyButton_default;
|
|
7
|
+
Object.defineProperty(exports, "RwAffix", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function() {
|
|
10
|
+
return require_affix.affix_exports;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "RwButton", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function() {
|
|
16
|
+
return require_button.button_exports;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { t as _default } from "./index-PhthUD7x.cjs";
|
|
2
|
+
import { t as affix_d_exports } from "./index-C-uY4885.cjs";
|
|
3
|
+
import { t as button_d_exports } from "./index-CSvc8L11.cjs";
|
|
4
|
+
|
|
5
|
+
//#region src/packages/controls/index.d.ts
|
|
6
|
+
declare namespace index_d_exports {
|
|
7
|
+
export { _default as MyButton, affix_d_exports as RwAffix, button_d_exports as RwButton };
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { _default as MyButton, affix_d_exports as RwAffix, button_d_exports as RwButton, index_d_exports as t };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { t as _default } from "./index-BtOBjeH7.js";
|
|
2
|
+
import { t as affix_d_exports } from "./index-C5SJLWEN.js";
|
|
3
|
+
import { t as button_d_exports } from "./index-CeemHBNT.js";
|
|
4
|
+
|
|
5
|
+
//#region src/packages/controls/index.d.ts
|
|
6
|
+
declare namespace index_d_exports {
|
|
7
|
+
export { _default as MyButton, affix_d_exports as RwAffix, button_d_exports as RwButton };
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { _default as MyButton, affix_d_exports as RwAffix, button_d_exports as RwButton, index_d_exports as t };
|
package/dist/controls.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { t as MyButton_default } from "./MyButton-C7riFwH6.js";
|
|
2
|
+
import { t as button_exports } from "./button-tOWSPPxz.js";
|
|
3
|
+
import { t as affix_exports } from "./affix-D9EM8_Um.js";
|
|
4
|
+
import "./packages/controls.js";
|
|
5
|
+
export { MyButton_default as MyButton, affix_exports as RwAffix, button_exports as RwButton };
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import { E as isStringNumber, T as isString$1, b as isNumber, i as entriesOf, k as isWindow, s as keysOf, v as isFunction, x as isObject$1 } from "./objects-CLXPNOUW.js";
|
|
2
|
+
import { isClient, isIOS } from "@vueuse/core";
|
|
3
|
+
import { camelize, capitalize, hyphenate, hyphenate as kebabCase } from "@vue/shared";
|
|
4
|
+
//#region src/packages/utils/dom/aria.ts
|
|
5
|
+
const FOCUSABLE_ELEMENT_SELECTORS = `a[href],button:not([disabled]),button:not([hidden]),:not([tabindex="-1"]),input:not([disabled]),input:not([type="hidden"]),select:not([disabled]),textarea:not([disabled])`;
|
|
6
|
+
/**
|
|
7
|
+
* Determine if the testing element is visible on screen no matter if its on the viewport or not
|
|
8
|
+
*/
|
|
9
|
+
const isVisible = (element) => {
|
|
10
|
+
if (process?.env?.NODE_ENV === "test") return true;
|
|
11
|
+
return getComputedStyle(element).position === "fixed" ? false : element.offsetParent !== null;
|
|
12
|
+
};
|
|
13
|
+
const obtainAllFocusableElements = (element) => {
|
|
14
|
+
return Array.from(element.querySelectorAll(FOCUSABLE_ELEMENT_SELECTORS)).filter((item) => isFocusable(item) && isVisible(item));
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* @desc Determine if target element is focusable
|
|
18
|
+
* @param element {HTMLElement}
|
|
19
|
+
* @returns {Boolean} true if it is focusable
|
|
20
|
+
*/
|
|
21
|
+
const isFocusable = (element) => {
|
|
22
|
+
if (element.tabIndex > 0 || element.tabIndex === 0 && element.getAttribute("tabIndex") !== null) return true;
|
|
23
|
+
if (element.tabIndex < 0 || element.hasAttribute("disabled") || element.getAttribute("aria-disabled") === "true") return false;
|
|
24
|
+
switch (element.nodeName) {
|
|
25
|
+
case "A": return !!element.href && element.rel !== "ignore";
|
|
26
|
+
case "INPUT": return !(element.type === "hidden" || element.type === "file");
|
|
27
|
+
case "BUTTON":
|
|
28
|
+
case "SELECT":
|
|
29
|
+
case "TEXTAREA": return true;
|
|
30
|
+
default: return false;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* @desc Set Attempt to set focus on the current node.
|
|
35
|
+
* @param element
|
|
36
|
+
* The node to attempt to focus on.
|
|
37
|
+
* @returns
|
|
38
|
+
* true if element is focused.
|
|
39
|
+
*/
|
|
40
|
+
const attemptFocus = (element) => {
|
|
41
|
+
if (!isFocusable(element)) return false;
|
|
42
|
+
element.focus?.();
|
|
43
|
+
return document.activeElement === element;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Trigger an event
|
|
47
|
+
* mouseenter, mouseleave, mouseover, keyup, change, click, etc.
|
|
48
|
+
* @param {HTMLElement} elm
|
|
49
|
+
* @param {String} name
|
|
50
|
+
* @param {*} opts
|
|
51
|
+
*/
|
|
52
|
+
const triggerEvent = function(elm, name, ...opts) {
|
|
53
|
+
let eventName;
|
|
54
|
+
if (name.includes("mouse") || name.includes("click")) eventName = "MouseEvents";
|
|
55
|
+
else if (name.includes("key")) eventName = "KeyboardEvent";
|
|
56
|
+
else eventName = "HTMLEvents";
|
|
57
|
+
const evt = document.createEvent(eventName);
|
|
58
|
+
evt.initEvent(name, ...opts);
|
|
59
|
+
elm.dispatchEvent(evt);
|
|
60
|
+
return elm;
|
|
61
|
+
};
|
|
62
|
+
const isLeaf = (el) => !el.getAttribute("aria-owns");
|
|
63
|
+
const getSibling = (el, distance, elClass) => {
|
|
64
|
+
const { parentNode } = el;
|
|
65
|
+
if (!parentNode) return null;
|
|
66
|
+
const siblings = parentNode.querySelectorAll(elClass);
|
|
67
|
+
return siblings[Array.prototype.indexOf.call(siblings, el) + distance] || null;
|
|
68
|
+
};
|
|
69
|
+
const focusNode = (el) => {
|
|
70
|
+
if (!el) return;
|
|
71
|
+
el.focus();
|
|
72
|
+
!isLeaf(el) && el.click();
|
|
73
|
+
};
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/packages/utils/dom/event.ts
|
|
76
|
+
const composeEventHandlers = (theirsHandler, oursHandler, { checkForDefaultPrevented = true } = {}) => {
|
|
77
|
+
const handleEvent = (event) => {
|
|
78
|
+
const shouldPrevent = theirsHandler?.(event);
|
|
79
|
+
if (checkForDefaultPrevented === false || !shouldPrevent) return oursHandler?.(event);
|
|
80
|
+
};
|
|
81
|
+
return handleEvent;
|
|
82
|
+
};
|
|
83
|
+
const whenMouse = (handler) => {
|
|
84
|
+
return (e) => e.pointerType === "mouse" ? handler(e) : void 0;
|
|
85
|
+
};
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/packages/utils/browser.ts
|
|
88
|
+
const isFirefox = () => isClient && /firefox/i.test(window.navigator.userAgent);
|
|
89
|
+
const loadScript = (src, options = {}) => {
|
|
90
|
+
const { async = true, type = "text/javascript", defer = true } = options;
|
|
91
|
+
return new Promise((resolve, reject) => {
|
|
92
|
+
const script = document.createElement("script");
|
|
93
|
+
script.src = src;
|
|
94
|
+
script.type = type;
|
|
95
|
+
script.async = async;
|
|
96
|
+
script.defer = defer;
|
|
97
|
+
script.onload = () => {
|
|
98
|
+
resolve();
|
|
99
|
+
};
|
|
100
|
+
script.onerror = () => {
|
|
101
|
+
reject();
|
|
102
|
+
};
|
|
103
|
+
document.body.appendChild(script);
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/packages/utils/dom/position.ts
|
|
108
|
+
const isInContainer = (el, container) => {
|
|
109
|
+
if (!isClient || !el || !container) return false;
|
|
110
|
+
const elRect = el.getBoundingClientRect();
|
|
111
|
+
let containerRect;
|
|
112
|
+
if (container instanceof Element) containerRect = container.getBoundingClientRect();
|
|
113
|
+
else containerRect = {
|
|
114
|
+
top: 0,
|
|
115
|
+
right: window.innerWidth,
|
|
116
|
+
bottom: window.innerHeight,
|
|
117
|
+
left: 0
|
|
118
|
+
};
|
|
119
|
+
return elRect.top < containerRect.bottom && elRect.bottom > containerRect.top && elRect.right > containerRect.left && elRect.left < containerRect.right;
|
|
120
|
+
};
|
|
121
|
+
const getOffsetTop = (el) => {
|
|
122
|
+
let offset = 0;
|
|
123
|
+
let parent = el;
|
|
124
|
+
while (parent) {
|
|
125
|
+
offset += parent.offsetTop;
|
|
126
|
+
parent = parent.offsetParent;
|
|
127
|
+
}
|
|
128
|
+
return offset;
|
|
129
|
+
};
|
|
130
|
+
const getOffsetTopDistance = (el, containerEl) => {
|
|
131
|
+
return Math.abs(getOffsetTop(el) - getOffsetTop(containerEl));
|
|
132
|
+
};
|
|
133
|
+
const getClientXY = (event) => {
|
|
134
|
+
let clientX;
|
|
135
|
+
let clientY;
|
|
136
|
+
if (event.type === "touchend") {
|
|
137
|
+
clientY = event.changedTouches[0].clientY;
|
|
138
|
+
clientX = event.changedTouches[0].clientX;
|
|
139
|
+
} else if (event.type.startsWith("touch")) {
|
|
140
|
+
clientY = event.touches[0].clientY;
|
|
141
|
+
clientX = event.touches[0].clientX;
|
|
142
|
+
} else {
|
|
143
|
+
clientY = event.clientY;
|
|
144
|
+
clientX = event.clientX;
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
clientX,
|
|
148
|
+
clientY
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/packages/utils/easings.ts
|
|
153
|
+
function easeInOutCubic(t, b, c, d) {
|
|
154
|
+
const cc = c - b;
|
|
155
|
+
t /= d / 2;
|
|
156
|
+
if (t < 1) return cc / 2 * t * t * t + b;
|
|
157
|
+
return cc / 2 * ((t -= 2) * t * t + 2) + b;
|
|
158
|
+
}
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/packages/utils/raf.ts
|
|
161
|
+
const rAF = (fn) => isClient ? window.requestAnimationFrame(fn) : setTimeout(fn, 16);
|
|
162
|
+
const cAF = (handle) => isClient ? window.cancelAnimationFrame(handle) : clearTimeout(handle);
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/packages/utils/strings.ts
|
|
165
|
+
/**
|
|
166
|
+
* fork from {@link https://github.com/sindresorhus/escape-string-regexp}
|
|
167
|
+
*/
|
|
168
|
+
const escapeStringRegexp = (string = "") => string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
|
|
169
|
+
const capitalize$1 = (str) => capitalize(str);
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region src/packages/utils/error.ts
|
|
172
|
+
var ElementPlusError = class extends Error {
|
|
173
|
+
constructor(m) {
|
|
174
|
+
super(m);
|
|
175
|
+
this.name = "ElementPlusError";
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
function throwError(scope, m) {
|
|
179
|
+
throw new ElementPlusError(`[${scope}] ${m}`);
|
|
180
|
+
}
|
|
181
|
+
function debugWarn(scope, message) {
|
|
182
|
+
if (process?.env?.NODE_ENV !== "production") {
|
|
183
|
+
const error = isString$1(scope) ? new ElementPlusError(`[${scope}] ${message}`) : scope;
|
|
184
|
+
console.warn(error);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/packages/utils/dom/style.ts
|
|
189
|
+
const SCOPE = "utils/dom/style";
|
|
190
|
+
const classNameToArray = (cls = "") => cls.split(" ").filter((item) => !!item.trim());
|
|
191
|
+
const hasClass = (el, cls) => {
|
|
192
|
+
if (!el || !cls) return false;
|
|
193
|
+
if (cls.includes(" ")) throw new Error("className should not contain space.");
|
|
194
|
+
return el.classList.contains(cls);
|
|
195
|
+
};
|
|
196
|
+
const addClass = (el, cls) => {
|
|
197
|
+
if (!el || !cls.trim()) return;
|
|
198
|
+
el.classList.add(...classNameToArray(cls));
|
|
199
|
+
};
|
|
200
|
+
const removeClass = (el, cls) => {
|
|
201
|
+
if (!el || !cls.trim()) return;
|
|
202
|
+
el.classList.remove(...classNameToArray(cls));
|
|
203
|
+
};
|
|
204
|
+
const getStyle = (element, styleName) => {
|
|
205
|
+
if (!isClient || !element || !styleName) return "";
|
|
206
|
+
let key = camelize(styleName);
|
|
207
|
+
if (key === "float") key = "cssFloat";
|
|
208
|
+
try {
|
|
209
|
+
const style = element.style[key];
|
|
210
|
+
if (style) return style;
|
|
211
|
+
const computed = document.defaultView?.getComputedStyle(element, "");
|
|
212
|
+
return computed ? computed[key] : "";
|
|
213
|
+
} catch {
|
|
214
|
+
return element.style[key];
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
const setStyle = (element, styleName, value) => {
|
|
218
|
+
if (!element || !styleName) return;
|
|
219
|
+
if (isObject$1(styleName)) entriesOf(styleName).forEach(([prop, value]) => setStyle(element, prop, value));
|
|
220
|
+
else {
|
|
221
|
+
const key = camelize(styleName);
|
|
222
|
+
element.style[key] = value;
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
const removeStyle = (element, style) => {
|
|
226
|
+
if (!element || !style) return;
|
|
227
|
+
if (isObject$1(style)) keysOf(style).forEach((prop) => removeStyle(element, prop));
|
|
228
|
+
else setStyle(element, style, "");
|
|
229
|
+
};
|
|
230
|
+
function addUnit(value, defaultUnit = "px") {
|
|
231
|
+
if (!value) return "";
|
|
232
|
+
if (isNumber(value) || isStringNumber(value)) return `${value}${defaultUnit}`;
|
|
233
|
+
else if (isString$1(value)) return value;
|
|
234
|
+
debugWarn(SCOPE, "binding value must be a string or number");
|
|
235
|
+
}
|
|
236
|
+
//#endregion
|
|
237
|
+
//#region src/packages/utils/dom/scroll.ts
|
|
238
|
+
const isScroll = (el, isVertical) => {
|
|
239
|
+
if (!isClient) return false;
|
|
240
|
+
const key = {
|
|
241
|
+
undefined: "overflow",
|
|
242
|
+
true: "overflow-y",
|
|
243
|
+
false: "overflow-x"
|
|
244
|
+
}[String(isVertical)];
|
|
245
|
+
const overflow = getStyle(el, key);
|
|
246
|
+
return [
|
|
247
|
+
"scroll",
|
|
248
|
+
"auto",
|
|
249
|
+
"overlay"
|
|
250
|
+
].some((s) => overflow.includes(s));
|
|
251
|
+
};
|
|
252
|
+
const getScrollContainer = (el, isVertical) => {
|
|
253
|
+
if (!isClient) return;
|
|
254
|
+
let parent = el;
|
|
255
|
+
while (parent) {
|
|
256
|
+
if ([
|
|
257
|
+
window,
|
|
258
|
+
document,
|
|
259
|
+
document.documentElement
|
|
260
|
+
].includes(parent)) return window;
|
|
261
|
+
if (isScroll(parent, isVertical)) return parent;
|
|
262
|
+
parent = parent.parentNode;
|
|
263
|
+
}
|
|
264
|
+
return parent;
|
|
265
|
+
};
|
|
266
|
+
let scrollBarWidth;
|
|
267
|
+
const getScrollBarWidth = (namespace) => {
|
|
268
|
+
if (!isClient) return 0;
|
|
269
|
+
if (scrollBarWidth !== void 0) return scrollBarWidth;
|
|
270
|
+
const outer = document.createElement("div");
|
|
271
|
+
outer.className = `${namespace}-scrollbar__wrap`;
|
|
272
|
+
outer.style.visibility = "hidden";
|
|
273
|
+
outer.style.width = "100px";
|
|
274
|
+
outer.style.position = "absolute";
|
|
275
|
+
outer.style.top = "-9999px";
|
|
276
|
+
document.body.appendChild(outer);
|
|
277
|
+
const widthNoScroll = outer.offsetWidth;
|
|
278
|
+
outer.style.overflow = "scroll";
|
|
279
|
+
const inner = document.createElement("div");
|
|
280
|
+
inner.style.width = "100%";
|
|
281
|
+
outer.appendChild(inner);
|
|
282
|
+
const widthWithScroll = inner.offsetWidth;
|
|
283
|
+
outer.parentNode?.removeChild(outer);
|
|
284
|
+
scrollBarWidth = widthNoScroll - widthWithScroll;
|
|
285
|
+
return scrollBarWidth;
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* Scroll with in the container element, positioning the **selected** element at the top
|
|
289
|
+
* of the container
|
|
290
|
+
*/
|
|
291
|
+
function scrollIntoView(container, selected) {
|
|
292
|
+
if (!isClient) return;
|
|
293
|
+
if (!selected) {
|
|
294
|
+
container.scrollTop = 0;
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
const offsetParents = [];
|
|
298
|
+
let pointer = selected.offsetParent;
|
|
299
|
+
while (pointer !== null && container !== pointer && container.contains(pointer)) {
|
|
300
|
+
offsetParents.push(pointer);
|
|
301
|
+
pointer = pointer.offsetParent;
|
|
302
|
+
}
|
|
303
|
+
const top = selected.offsetTop + offsetParents.reduce((prev, curr) => prev + curr.offsetTop, 0);
|
|
304
|
+
const bottom = top + selected.offsetHeight;
|
|
305
|
+
const viewRectTop = container.scrollTop;
|
|
306
|
+
const viewRectBottom = viewRectTop + container.clientHeight;
|
|
307
|
+
if (top < viewRectTop) container.scrollTop = top;
|
|
308
|
+
else if (bottom > viewRectBottom) container.scrollTop = bottom - container.clientHeight;
|
|
309
|
+
}
|
|
310
|
+
function animateScrollTo(container, from, to, duration, callback) {
|
|
311
|
+
const startTime = Date.now();
|
|
312
|
+
let handle;
|
|
313
|
+
const scroll = () => {
|
|
314
|
+
const time = Date.now() - startTime;
|
|
315
|
+
const nextScrollTop = easeInOutCubic(time > duration ? duration : time, from, to, duration);
|
|
316
|
+
if (isWindow(container)) container.scrollTo(window.pageXOffset, nextScrollTop);
|
|
317
|
+
else container.scrollTop = nextScrollTop;
|
|
318
|
+
if (time < duration) handle = rAF(scroll);
|
|
319
|
+
else if (isFunction(callback)) callback();
|
|
320
|
+
};
|
|
321
|
+
scroll();
|
|
322
|
+
return () => {
|
|
323
|
+
handle && cAF(handle);
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
const getScrollElement = (target, container) => {
|
|
327
|
+
if (isWindow(container)) return target.ownerDocument.documentElement;
|
|
328
|
+
return container;
|
|
329
|
+
};
|
|
330
|
+
const getScrollTop = (container) => {
|
|
331
|
+
if (isWindow(container)) return window.scrollY;
|
|
332
|
+
return container.scrollTop;
|
|
333
|
+
};
|
|
334
|
+
//#endregion
|
|
335
|
+
//#region src/packages/utils/dom/element.ts
|
|
336
|
+
const getElement = ((target) => {
|
|
337
|
+
if (!isClient || target === "") return null;
|
|
338
|
+
if (isString$1(target)) try {
|
|
339
|
+
return document.querySelector(target);
|
|
340
|
+
} catch {
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
return target;
|
|
344
|
+
});
|
|
345
|
+
//#endregion
|
|
346
|
+
export { isInContainer as A, isFocusable as B, kebabCase as C, getClientXY as D, easeInOutCubic as E, composeEventHandlers as F, isVisible as H, whenMouse as I, attemptFocus as L, isFirefox as M, isIOS as N, getOffsetTop as O, loadScript as P, focusNode as R, hyphenate as S, rAF as T, obtainAllFocusableElements as U, isLeaf as V, triggerEvent as W, debugWarn as _, getScrollElement as a, capitalize$1 as b, scrollIntoView as c, classNameToArray as d, getStyle as f, setStyle as g, removeStyle as h, getScrollContainer as i, isClient as j, getOffsetTopDistance as k, addClass as l, removeClass as m, animateScrollTo as n, getScrollTop as o, hasClass as p, getScrollBarWidth as r, isScroll as s, getElement as t, addUnit as u, throwError as v, cAF as w, escapeStringRegexp as x, camelize as y, getSibling as z };
|