Major overhaul to the theme and now functioning.
This commit is contained in:
1 parent
5823ca3c39
commit
a475dfeab6
5218 files changed
+1643729
-13229
No files matched your search
Generated
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// Types
|
||||
import type { DirectiveBinding } from 'vue';
|
||||
interface ClickOutsideBindingArgs {
|
||||
handler: (e: MouseEvent) => void;
|
||||
closeConditional?: (e: Event) => boolean;
|
||||
include?: () => HTMLElement[];
|
||||
}
|
||||
interface ClickOutsideDirectiveBinding extends DirectiveBinding {
|
||||
value: ((e: MouseEvent) => void) | ClickOutsideBindingArgs;
|
||||
}
|
||||
export declare const ClickOutside: {
|
||||
// [data-app] may not be found
|
||||
// if using bind, inserted makes
|
||||
// sure that the root element is
|
||||
// available, iOS does not support
|
||||
// clicks on body
|
||||
mounted(el: HTMLElement, binding: ClickOutsideDirectiveBinding): void;
|
||||
beforeUnmount(el: HTMLElement, binding: ClickOutsideDirectiveBinding): void;
|
||||
};
|
||||
export default ClickOutside;
|
||||
Generated
Vendored
+92
@@ -0,0 +1,92 @@
|
||||
// Utilities
|
||||
import { attachedRoot } from "../../util/index.js"; // Types
|
||||
function defaultConditional() {
|
||||
return true;
|
||||
}
|
||||
function checkEvent(e, el, binding) {
|
||||
// The include element callbacks below can be expensive
|
||||
// so we should avoid calling them when we're not active.
|
||||
// Explicitly check for false to allow fallback compatibility
|
||||
// with non-toggleable components
|
||||
if (!e || checkIsActive(e, binding) === false) return false;
|
||||
|
||||
// If we're clicking inside the shadowroot, then the app root doesn't get the same
|
||||
// level of introspection as to _what_ we're clicking. We want to check to see if
|
||||
// our target is the shadowroot parent container, and if it is, ignore.
|
||||
const root = attachedRoot(el);
|
||||
if (typeof ShadowRoot !== 'undefined' && root instanceof ShadowRoot && root.host === e.target) return false;
|
||||
|
||||
// Check if additional elements were passed to be included in check
|
||||
// (click must be outside all included elements, if any)
|
||||
const elements = (typeof binding.value === 'object' && binding.value.include || (() => []))();
|
||||
// Add the root element for the component this directive was defined on
|
||||
elements.push(el);
|
||||
|
||||
// Check if it's a click outside our elements, and then if our callback returns true.
|
||||
// Non-toggleable components should take action in their callback and return falsy.
|
||||
// Toggleable can return true if it wants to deactivate.
|
||||
// Note that, because we're in the capture phase, this callback will occur before
|
||||
// the bubbling click event on any outside elements.
|
||||
return !elements.some(el => el?.contains(e.target));
|
||||
}
|
||||
function checkIsActive(e, binding) {
|
||||
const isActive = typeof binding.value === 'object' && binding.value.closeConditional || defaultConditional;
|
||||
return isActive(e);
|
||||
}
|
||||
function directive(e, el, binding) {
|
||||
const handler = typeof binding.value === 'function' ? binding.value : binding.value.handler;
|
||||
|
||||
// Clicks in the Shadow DOM change their target while using setTimeout, so the original target is saved here
|
||||
e.shadowTarget = e.target;
|
||||
el._clickOutside.lastMousedownWasOutside && checkEvent(e, el, binding) && setTimeout(() => {
|
||||
checkIsActive(e, binding) && handler && handler(e);
|
||||
}, 0);
|
||||
}
|
||||
function handleShadow(el, callback) {
|
||||
const root = attachedRoot(el);
|
||||
callback(document);
|
||||
if (typeof ShadowRoot !== 'undefined' && root instanceof ShadowRoot) {
|
||||
callback(root);
|
||||
}
|
||||
}
|
||||
export const ClickOutside = {
|
||||
// [data-app] may not be found
|
||||
// if using bind, inserted makes
|
||||
// sure that the root element is
|
||||
// available, iOS does not support
|
||||
// clicks on body
|
||||
mounted(el, binding) {
|
||||
const onClick = e => directive(e, el, binding);
|
||||
const onMousedown = e => {
|
||||
el._clickOutside.lastMousedownWasOutside = checkEvent(e, el, binding);
|
||||
};
|
||||
handleShadow(el, app => {
|
||||
app.addEventListener('click', onClick, true);
|
||||
app.addEventListener('mousedown', onMousedown, true);
|
||||
});
|
||||
if (!el._clickOutside) {
|
||||
el._clickOutside = {
|
||||
lastMousedownWasOutside: false
|
||||
};
|
||||
}
|
||||
el._clickOutside[binding.instance.$.uid] = {
|
||||
onClick,
|
||||
onMousedown
|
||||
};
|
||||
},
|
||||
beforeUnmount(el, binding) {
|
||||
if (!el._clickOutside) return;
|
||||
handleShadow(el, app => {
|
||||
if (!app || !el._clickOutside?.[binding.instance.$.uid]) return;
|
||||
const {
|
||||
onClick,
|
||||
onMousedown
|
||||
} = el._clickOutside[binding.instance.$.uid];
|
||||
app.removeEventListener('click', onClick, true);
|
||||
app.removeEventListener('mousedown', onMousedown, true);
|
||||
});
|
||||
delete el._clickOutside[binding.instance.$.uid];
|
||||
}
|
||||
};
|
||||
export default ClickOutside;
|
||||
//# sourceMappingURL=index.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","names":["attachedRoot","defaultConditional","checkEvent","e","el","binding","checkIsActive","root","ShadowRoot","host","target","elements","value","include","push","some","contains","isActive","closeConditional","directive","handler","shadowTarget","_clickOutside","lastMousedownWasOutside","setTimeout","handleShadow","callback","document","ClickOutside","mounted","onClick","onMousedown","app","addEventListener","instance","$","uid","beforeUnmount","removeEventListener"],"sources":["../../../src/directives/click-outside/index.ts"],"sourcesContent":["// Utilities\nimport { attachedRoot } from '@/util'\n\n// Types\nimport type { DirectiveBinding } from 'vue'\n\ninterface ClickOutsideBindingArgs {\n handler: (e: MouseEvent) => void\n closeConditional?: (e: Event) => boolean\n include?: () => HTMLElement[]\n}\n\ninterface ClickOutsideDirectiveBinding extends DirectiveBinding {\n value: ((e: MouseEvent) => void) | ClickOutsideBindingArgs\n}\n\nfunction defaultConditional () {\n return true\n}\n\nfunction checkEvent (e: MouseEvent, el: HTMLElement, binding: ClickOutsideDirectiveBinding): boolean {\n // The include element callbacks below can be expensive\n // so we should avoid calling them when we're not active.\n // Explicitly check for false to allow fallback compatibility\n // with non-toggleable components\n if (!e || checkIsActive(e, binding) === false) return false\n\n // If we're clicking inside the shadowroot, then the app root doesn't get the same\n // level of introspection as to _what_ we're clicking. We want to check to see if\n // our target is the shadowroot parent container, and if it is, ignore.\n const root = attachedRoot(el)\n if (\n typeof ShadowRoot !== 'undefined' &&\n root instanceof ShadowRoot &&\n root.host === e.target\n ) return false\n\n // Check if additional elements were passed to be included in check\n // (click must be outside all included elements, if any)\n const elements = ((typeof binding.value === 'object' && binding.value.include) || (() => []))()\n // Add the root element for the component this directive was defined on\n elements.push(el)\n\n // Check if it's a click outside our elements, and then if our callback returns true.\n // Non-toggleable components should take action in their callback and return falsy.\n // Toggleable can return true if it wants to deactivate.\n // Note that, because we're in the capture phase, this callback will occur before\n // the bubbling click event on any outside elements.\n return !elements.some(el => el?.contains(e.target as Node))\n}\n\nfunction checkIsActive (e: MouseEvent, binding: ClickOutsideDirectiveBinding): boolean | void {\n const isActive = (typeof binding.value === 'object' && binding.value.closeConditional) || defaultConditional\n\n return isActive(e)\n}\n\nfunction directive (e: MouseEvent, el: HTMLElement, binding: ClickOutsideDirectiveBinding) {\n const handler = typeof binding.value === 'function' ? binding.value : binding.value.handler\n\n // Clicks in the Shadow DOM change their target while using setTimeout, so the original target is saved here\n e.shadowTarget = e.target\n\n el._clickOutside!.lastMousedownWasOutside && checkEvent(e, el, binding) && setTimeout(() => {\n checkIsActive(e, binding) && handler && handler(e)\n }, 0)\n}\n\nfunction handleShadow (el: HTMLElement, callback: Function): void {\n const root = attachedRoot(el)\n\n callback(document)\n\n if (typeof ShadowRoot !== 'undefined' && root instanceof ShadowRoot) {\n callback(root)\n }\n}\n\nexport const ClickOutside = {\n // [data-app] may not be found\n // if using bind, inserted makes\n // sure that the root element is\n // available, iOS does not support\n // clicks on body\n mounted (el: HTMLElement, binding: ClickOutsideDirectiveBinding) {\n const onClick = (e: Event) => directive(e as MouseEvent, el, binding)\n const onMousedown = (e: Event) => {\n el._clickOutside!.lastMousedownWasOutside = checkEvent(e as MouseEvent, el, binding)\n }\n\n handleShadow(el, (app: HTMLElement) => {\n app.addEventListener('click', onClick, true)\n app.addEventListener('mousedown', onMousedown, true)\n })\n if (!el._clickOutside) {\n el._clickOutside = {\n lastMousedownWasOutside: false,\n }\n }\n\n el._clickOutside[binding.instance!.$.uid] = {\n onClick,\n onMousedown,\n }\n },\n\n beforeUnmount (el: HTMLElement, binding: ClickOutsideDirectiveBinding) {\n if (!el._clickOutside) return\n\n handleShadow(el, (app: HTMLElement) => {\n if (!app || !el._clickOutside?.[binding.instance!.$.uid]) return\n\n const { onClick, onMousedown } = el._clickOutside[binding.instance!.$.uid]!\n\n app.removeEventListener('click', onClick, true)\n app.removeEventListener('mousedown', onMousedown, true)\n })\n\n delete el._clickOutside[binding.instance!.$.uid]\n },\n}\n\nexport default ClickOutside\n"]Line truncated
|
||||
Generated
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
import { VNode, VNodeDirective } from 'vue';
|
||||
declare function updateColor(el: HTMLElement, binding: VNodeDirective, node: VNode): void;
|
||||
declare function update(el: HTMLElement, binding: VNodeDirective, node: VNode): void;
|
||||
export declare const Color: {
|
||||
bind: typeof updateColor;
|
||||
update: typeof update;
|
||||
};
|
||||
export default Color;
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
// @ts-nocheck
|
||||
/* eslint-disable */
|
||||
// Utilities
|
||||
import { classToHex, isCssColor, parseGradient } from "../../util/colorUtils.js";
|
||||
import colors from "../../util/colors.js"; // Types
|
||||
function setTextColor(el, color, currentTheme) {
|
||||
const cssColor = !isCssColor(color) ? classToHex(color, colors, currentTheme) : color;
|
||||
el.style.color = cssColor;
|
||||
el.style.caretColor = cssColor;
|
||||
}
|
||||
function setBackgroundColor(el, color, currentTheme) {
|
||||
const cssColor = !isCssColor(color) ? classToHex(color, colors, currentTheme) : color;
|
||||
el.style.backgroundColor = cssColor;
|
||||
el.style.borderColor = cssColor;
|
||||
}
|
||||
function setBorderColor(el, color, currentTheme, modifiers) {
|
||||
const cssColor = !isCssColor(color) ? classToHex(color, colors, currentTheme) : color;
|
||||
if (!modifiers || !Object.keys(modifiers).length) {
|
||||
el.style.borderColor = cssColor;
|
||||
return;
|
||||
}
|
||||
if (modifiers.top) el.style.borderTopColor = cssColor;
|
||||
if (modifiers.right) el.style.borderRightColor = cssColor;
|
||||
if (modifiers.bottom) el.style.borderBottomColor = cssColor;
|
||||
if (modifiers.left) el.style.borderLeftColor = cssColor;
|
||||
}
|
||||
function setGradientColor(el, gradient, currentTheme) {
|
||||
el.style.backgroundImage = `linear-gradient(${parseGradient(gradient, colors, currentTheme)})`;
|
||||
}
|
||||
function updateColor(el, binding, node) {
|
||||
const currentTheme = node.context.$vuetify.theme.currentTheme;
|
||||
if (binding.arg === undefined) {
|
||||
setBackgroundColor(el, binding.value, currentTheme);
|
||||
} else if (binding.arg === 'text') {
|
||||
setTextColor(el, binding.value, currentTheme);
|
||||
} else if (binding.arg === 'border') {
|
||||
setBorderColor(el, binding.value, currentTheme, binding.modifiers);
|
||||
} else if (binding.arg === 'gradient') {
|
||||
setGradientColor(el, binding.value, currentTheme);
|
||||
}
|
||||
}
|
||||
function update(el, binding, node) {
|
||||
if (binding.value === binding.oldValue) return;
|
||||
updateColor(el, binding, node);
|
||||
}
|
||||
export const Color = {
|
||||
bind: updateColor,
|
||||
update
|
||||
};
|
||||
export default Color;
|
||||
//# sourceMappingURL=index.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","names":["classToHex","isCssColor","parseGradient","colors","setTextColor","el","color","currentTheme","cssColor","style","caretColor","setBackgroundColor","backgroundColor","borderColor","setBorderColor","modifiers","Object","keys","length","top","borderTopColor","right","borderRightColor","bottom","borderBottomColor","left","borderLeftColor","setGradientColor","gradient","backgroundImage","updateColor","binding","node","context","$vuetify","theme","arg","undefined","value","update","oldValue","Color","bind"],"sources":["../../../src/directives/color/index.ts"],"sourcesContent":["// @ts-nocheck\n/* eslint-disable */\n\n// Utilities\nimport {\n classToHex,\n isCssColor,\n parseGradient,\n} from '../../util/colorUtils'\nimport colors from '../../util/colors'\n\n// Types\nimport { VuetifyThemeVariant } from 'types/services/theme'\nimport { VNode, VNodeDirective } from 'vue'\n\ninterface BorderModifiers {\n top?: Boolean\n right?: Boolean\n bottom?: Boolean\n left?: Boolean\n}\n\nfunction setTextColor (\n el: HTMLElement,\n color: string,\n currentTheme: Partial<VuetifyThemeVariant>,\n) {\n const cssColor = !isCssColor(color) ? classToHex(color, colors, currentTheme) : color\n\n el.style.color = cssColor\n el.style.caretColor = cssColor\n}\n\nfunction setBackgroundColor (\n el: HTMLElement,\n color: string,\n currentTheme: Partial<VuetifyThemeVariant>,\n) {\n const cssColor = !isCssColor(color) ? classToHex(color, colors, currentTheme) : color\n\n el.style.backgroundColor = cssColor\n el.style.borderColor = cssColor\n}\n\nfunction setBorderColor (\n el: HTMLElement,\n color: string,\n currentTheme: Partial<VuetifyThemeVariant>,\n modifiers?: BorderModifiers,\n) {\n const cssColor = !isCssColor(color) ? classToHex(color, colors, currentTheme) : color\n\n if (!modifiers || !Object.keys(modifiers).length) {\n el.style.borderColor = cssColor\n return\n }\n\n if (modifiers.top) el.style.borderTopColor = cssColor\n if (modifiers.right) el.style.borderRightColor = cssColor\n if (modifiers.bottom) el.style.borderBottomColor = cssColor\n if (modifiers.left) el.style.borderLeftColor = cssColor\n}\n\nfunction setGradientColor (\n el: HTMLElement,\n gradient: string,\n currentTheme: Partial<VuetifyThemeVariant>,\n) {\n el.style.backgroundImage = `linear-gradient(${\n parseGradient(gradient, colors, currentTheme)\n })`\n}\n\nfunction updateColor (\n el: HTMLElement,\n binding: VNodeDirective,\n node: VNode\n) {\n const currentTheme = node.context!.$vuetify.theme.currentTheme\n\n if (binding.arg === undefined) {\n setBackgroundColor(el, binding.value, currentTheme)\n } else if (binding.arg === 'text') {\n setTextColor(el, binding.value, currentTheme)\n } else if (binding.arg === 'border') {\n setBorderColor(el, binding.value, currentTheme, binding.modifiers)\n } else if (binding.arg === 'gradient') {\n setGradientColor(el, binding.value, currentTheme)\n }\n}\n\nfunction update (\n el: HTMLElement,\n binding: VNodeDirective,\n node: VNode\n) {\n if (binding.value === binding.oldValue) return\n\n updateColor(el, binding, node)\n}\n\nexport const Color = {\n bind: updateColor,\n update,\n}\n\nexport default Color\n"],"mappings":"AAAA;AACA;AAEA;AAAA,SAEEA,UAAU,EACVC,UAAU,EACVC,aAAa;AAAA,OAERC,MAAM,8BAEb;AAWA,SAASC,YAAYA,CACnBC,EAAe,EACfC,KAAa,EACbC,YAA0C,EAC1C;EACA,MAAMC,QAAQ,GAAG,CAACP,UAAU,CAACK,KAAK,CAAC,GAAGN,UAAU,CAACM,KAAK,EAAEH,MAAM,EAAEI,YAAY,CAAC,GAAGD,KAAK;EAErFD,EAAE,CAACI,KAAK,CAACH,KAAK,GAAGE,QAAQ;EACzBH,EAAE,CAACI,KAAK,CAACC,UAAU,GAAGF,QAAQ;AAChC;AAEA,SAASG,kBAAkBA,CACzBN,EAAe,EACfC,KAAa,EACbC,YAA0C,EAC1C;EACA,MAAMC,QAAQ,GAAG,CAACP,UAAU,CAACK,KAAK,CAAC,GAAGN,UAAU,CAACM,KAAK,EAAEH,MAAM,EAAEI,YAAY,CAAC,GAAGD,KAAK;EAErFD,EAAE,CAACI,KAAK,CAACG,eAAe,GAAGJ,QAAQ;EACnCH,EAAE,CAACI,KAAK,CAACI,WAAW,GAAGL,QAAQ;AACjC;AAEA,SAASM,cAAcA,CACrBT,EAAe,EACfC,KAAa,EACbC,YAA0C,EAC1CQ,SAA2B,EAC3B;EACA,MAAMP,QAAQ,GAAG,CAACP,UAAU,CAACK,KAAK,CAAC,GAAGN,UAAU,CAACM,KAAK,EAAEH,MAAM,EAAEI,YAAY,CAAC,GAAGD,KAAK;EAErF,IAAI,CAACS,SAAS,IAAI,CAACC,MAAM,CAACC,IAAI,CAACF,SAAS,CAAC,CAACG,MAAM,EAAE;IAChDb,EAAE,CAACI,KAAK,CAACI,WAAW,GAAGL,QAAQ;IAC/B;EACF;EAEA,IAAIO,SAAS,CAACI,GAAG,EAAEd,EAAE,CAACI,KAAK,CAACW,cAAc,GAAGZ,QAAQ;EACrD,IAAIO,SAAS,CAACM,KAAK,EAAEhB,EAAE,CAACI,KAAK,CAACa,gBAAgB,GAAGd,QAAQ;EACzD,IAAIO,SAAS,CAACQ,MAAM,EAAElB,EAAE,CAACI,KAAK,CAACe,iBAAiB,GAAGhB,QAAQ;EAC3D,IAAIO,SAAS,CAACU,IAAI,EAAEpB,EAAE,CAACI,KAAK,CAACiB,eAAe,GAAGlB,QAAQ;AACzD;AAEA,SAASmB,gBAAgBA,CACvBtB,EAAe,EACfuB,QAAgB,EAChBrB,YAA0C,EAC1C;EACAF,EAAE,CAACI,KAAK,CAACoB,eAAe,GAAG,mBACzB3B,aAAa,CAAC0B,QAAQ,EAAEzB,MAAM,EAAEI,YAAY,CAAC,GAC5C;AACL;AAEA,SAASuB,WAAWA,CAClBzB,EAAe,EACf0B,OAAuB,EACvBC,IAAW,EACX;EACA,MAAMzB,YAAY,GAAGyB,IAAI,CAACC,OAAO,CAAEC,QAAQ,CAACC,KAAK,CAAC5B,YAAY;EAE9D,IAAIwB,OAAO,CAACK,GAAG,KAAKC,SAAS,EAAE;IAC7B1B,kBAAkB,CAACN,EAAE,EAAE0B,OAAO,CAACO,KAAK,EAAE/B,YAAY,CAAC;EACrD,CAAC,MAAM,IAAIwB,OAAO,CAACK,GAAG,KAAK,MAAM,EAAE;IACjChC,YAAY,CAACC,EAAE,EAAE0B,OAAO,CAALine truncated
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
export { ClickOutside } from './click-outside/index.js';
|
||||
// export { Color } from './color'
|
||||
export { Intersect } from './intersect/index.js';
|
||||
export { Mutate } from './mutate/index.js';
|
||||
export { Resize } from './resize/index.js';
|
||||
export { Ripple } from './ripple/index.js';
|
||||
export { Scroll } from './scroll/index.js';
|
||||
export { Touch } from './touch/index.js';
|
||||
export { Tooltip } from './tooltip/index.js';
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
export { ClickOutside } from "./click-outside/index.js"; // export { Color } from './color'
|
||||
export { Intersect } from "./intersect/index.js";
|
||||
export { Mutate } from "./mutate/index.js";
|
||||
export { Resize } from "./resize/index.js";
|
||||
export { Ripple } from "./ripple/index.js";
|
||||
export { Scroll } from "./scroll/index.js";
|
||||
export { Touch } from "./touch/index.js";
|
||||
export { Tooltip } from "./tooltip/index.js";
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","names":["ClickOutside","Intersect","Mutate","Resize","Ripple","Scroll","Touch","Tooltip"],"sources":["../../src/directives/index.ts"],"sourcesContent":["export { ClickOutside } from './click-outside'\n// export { Color } from './color'\nexport { Intersect } from './intersect'\nexport { Mutate } from './mutate'\nexport { Resize } from './resize'\nexport { Ripple } from './ripple'\nexport { Scroll } from './scroll'\nexport { Touch } from './touch'\nexport { Tooltip } from './tooltip'\n"],"mappings":"SAASA,YAAY,oCACrB;AAAA,SACSC,SAAS;AAAA,SACTC,MAAM;AAAA,SACNC,MAAM;AAAA,SACNC,MAAM;AAAA,SACNC,MAAM;AAAA,SACNC,KAAK;AAAA,SACLC,OAAO","ignoreList":[]}
|
||||
Generated
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// Types
|
||||
import type { DirectiveBinding } from 'vue';
|
||||
type ObserveHandler = (isIntersecting: boolean, entries: IntersectionObserverEntry[], observer: IntersectionObserver) => void;
|
||||
export interface ObserveDirectiveBinding extends Omit<DirectiveBinding, 'modifiers' | 'value'> {
|
||||
value?: ObserveHandler | {
|
||||
handler: ObserveHandler;
|
||||
options?: IntersectionObserverInit;
|
||||
};
|
||||
modifiers: {
|
||||
once?: boolean;
|
||||
quiet?: boolean;
|
||||
};
|
||||
}
|
||||
declare function mounted(el: HTMLElement, binding: ObserveDirectiveBinding): void;
|
||||
declare function unmounted(el: HTMLElement, binding: ObserveDirectiveBinding): void;
|
||||
export declare const Intersect: {
|
||||
mounted: typeof mounted;
|
||||
unmounted: typeof unmounted;
|
||||
};
|
||||
export default Intersect;
|
||||
Generated
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
// Utilities
|
||||
import { SUPPORTS_INTERSECTION } from "../../util/index.js"; // Types
|
||||
function mounted(el, binding) {
|
||||
if (!SUPPORTS_INTERSECTION) return;
|
||||
const modifiers = binding.modifiers || {};
|
||||
const value = binding.value;
|
||||
const {
|
||||
handler,
|
||||
options
|
||||
} = typeof value === 'object' ? value : {
|
||||
handler: value,
|
||||
options: {}
|
||||
};
|
||||
const observer = new IntersectionObserver(function () {
|
||||
let entries = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
||||
let observer = arguments.length > 1 ? arguments[1] : undefined;
|
||||
const _observe = el._observe?.[binding.instance.$.uid];
|
||||
if (!_observe) return; // Just in case, should never fire
|
||||
|
||||
const isIntersecting = entries.some(entry => entry.isIntersecting);
|
||||
|
||||
// If is not quiet or has already been
|
||||
// initted, invoke the user callback
|
||||
if (handler && (!modifiers.quiet || _observe.init) && (!modifiers.once || isIntersecting || _observe.init)) {
|
||||
handler(isIntersecting, entries, observer);
|
||||
}
|
||||
if (isIntersecting && modifiers.once) unmounted(el, binding);else _observe.init = true;
|
||||
}, options);
|
||||
el._observe = Object(el._observe);
|
||||
el._observe[binding.instance.$.uid] = {
|
||||
init: false,
|
||||
observer
|
||||
};
|
||||
observer.observe(el);
|
||||
}
|
||||
function unmounted(el, binding) {
|
||||
const observe = el._observe?.[binding.instance.$.uid];
|
||||
if (!observe) return;
|
||||
observe.observer.unobserve(el);
|
||||
delete el._observe[binding.instance.$.uid];
|
||||
}
|
||||
export const Intersect = {
|
||||
mounted,
|
||||
unmounted
|
||||
};
|
||||
export default Intersect;
|
||||
//# sourceMappingURL=index.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","names":["SUPPORTS_INTERSECTION","mounted","el","binding","modifiers","value","handler","options","observer","IntersectionObserver","entries","arguments","length","undefined","_observe","instance","$","uid","isIntersecting","some","entry","quiet","init","once","unmounted","Object","observe","unobserve","Intersect"],"sources":["../../../src/directives/intersect/index.ts"],"sourcesContent":["// Utilities\nimport { SUPPORTS_INTERSECTION } from '@/util'\n\n// Types\nimport type {\n DirectiveBinding,\n} from 'vue'\n\ntype ObserveHandler = (\n isIntersecting: boolean,\n entries: IntersectionObserverEntry[],\n observer: IntersectionObserver,\n) => void\n\nexport interface ObserveDirectiveBinding extends Omit<DirectiveBinding, 'modifiers' | 'value'> {\n value?: ObserveHandler | { handler: ObserveHandler, options?: IntersectionObserverInit }\n modifiers: {\n once?: boolean\n quiet?: boolean\n }\n}\n\nfunction mounted (el: HTMLElement, binding: ObserveDirectiveBinding) {\n if (!SUPPORTS_INTERSECTION) return\n\n const modifiers = binding.modifiers || {}\n const value = binding.value\n const { handler, options } = typeof value === 'object'\n ? value\n : { handler: value, options: {} }\n\n const observer = new IntersectionObserver((\n entries: IntersectionObserverEntry[] = [],\n observer: IntersectionObserver\n ) => {\n const _observe = el._observe?.[binding.instance!.$.uid]\n if (!_observe) return // Just in case, should never fire\n\n const isIntersecting = entries.some(entry => entry.isIntersecting)\n\n // If is not quiet or has already been\n // initted, invoke the user callback\n if (\n handler && (\n !modifiers.quiet ||\n _observe.init\n ) && (\n !modifiers.once ||\n isIntersecting ||\n _observe.init\n )\n ) {\n handler(isIntersecting, entries, observer)\n }\n\n if (isIntersecting && modifiers.once) unmounted(el, binding)\n else _observe.init = true\n }, options)\n\n el._observe = Object(el._observe)\n el._observe![binding.instance!.$.uid] = { init: false, observer }\n\n observer.observe(el)\n}\n\nfunction unmounted (el: HTMLElement, binding: ObserveDirectiveBinding) {\n const observe = el._observe?.[binding.instance!.$.uid]\n if (!observe) return\n\n observe.observer.unobserve(el)\n delete el._observe![binding.instance!.$.uid]\n}\n\nexport const Intersect = {\n mounted,\n unmounted,\n}\n\nexport default Intersect\n"],"mappings":"AAAA;AAAA,SACSA,qBAAqB,+BAE9B;AAmBA,SAASC,OAAOA,CAAEC,EAAe,EAAEC,OAAgC,EAAE;EACnE,IAAI,CAACH,qBAAqB,EAAE;EAE5B,MAAMI,SAAS,GAAGD,OAAO,CAACC,SAAS,IAAI,CAAC,CAAC;EACzC,MAAMC,KAAK,GAAGF,OAAO,CAACE,KAAK;EAC3B,MAAM;IAAEC,OAAO;IAAEC;EAAQ,CAAC,GAAG,OAAOF,KAAK,KAAK,QAAQ,GAClDA,KAAK,GACL;IAAEC,OAAO,EAAED,KAAK;IAAEE,OAAO,EAAE,CAAC;EAAE,CAAC;EAEnC,MAAMC,QAAQ,GAAG,IAAIC,oBAAoB,CAAC,YAGrC;IAAA,IAFHC,OAAoC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;IAAA,IACzCH,QAA8B,GAAAG,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;IAE9B,MAAMC,QAAQ,GAAGZ,EAAE,CAACY,QAAQ,GAAGX,OAAO,CAACY,QAAQ,CAAEC,CAAC,CAACC,GAAG,CAAC;IACvD,IAAI,CAACH,QAAQ,EAAE,OAAM,CAAC;;IAEtB,MAAMI,cAAc,GAAGR,OAAO,CAACS,IAAI,CAACC,KAAK,IAAIA,KAAK,CAACF,cAAc,CAAC;;IAElE;IACA;IACA,IACEZ,OAAO,KACL,CAACF,SAAS,CAACiB,KAAK,IAChBP,QAAQ,CAACQ,IAAI,CACd,KACC,CAAClB,SAAS,CAACmB,IAAI,IACfL,cAAc,IACdJ,QAAQ,CAACQ,IAAI,CACd,EACD;MACAhB,OAAO,CAACY,cAAc,EAAER,OAAO,EAAEF,QAAQ,CAAC;IAC5C;IAEA,IAAIU,cAAc,IAAId,SAAS,CAACmB,IAAI,EAAEC,SAAS,CAACtB,EAAE,EAAEC,OAAO,CAAC,MACvDW,QAAQ,CAACQ,IAAI,GAAG,IAAI;EAC3B,CAAC,EAAEf,OAAO,CAAC;EAEXL,EAAE,CAACY,QAAQ,GAAGW,MAAM,CAACvB,EAAE,CAACY,QAAQ,CAAC;EACjCZ,EAAE,CAACY,QAAQ,CAAEX,OAAO,CAACY,QAAQ,CAAEC,CAAC,CAACC,GAAG,CAAC,GAAG;IAAEK,IAAI,EAAE,KAAK;IAAEd;EAAS,CAAC;EAEjEA,QAAQ,CAACkB,OAAO,CAACxB,EAAE,CAAC;AACtB;AAEA,SAASsB,SAASA,CAAEtB,EAAe,EAAEC,OAAgC,EAAE;EACrE,MAAMuB,OAAO,GAAGxB,EAAE,CAACY,QAAQ,GAAGX,OAAO,CAACY,QAAQ,CAAEC,CAAC,CAACC,GAAG,CAAC;EACtD,IAAI,CAACS,OAAO,EAAE;EAEdA,OAAO,CAAClB,QAAQ,CAACmB,SAAS,CAACzB,EAAE,CAAC;EAC9B,OAAOA,EAAE,CAACY,QAAQ,CAAEX,OAAO,CAACY,QAAQ,CAAEC,CAAC,CAACC,GAAG,CAAC;AAC9C;AAEA,OAAO,MAAMW,SAAS,GAAG;EACvB3B,OAAO;EACPuB;AACF,CAAC;AAED,eAAeI,SAAS","ignoreList":[]}
|
||||
Generated
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
// Types
|
||||
import type { DirectiveBinding } from 'vue';
|
||||
import type { MutationOptions } from '../../composables/mutationObserver.js';
|
||||
export interface MutationDirectiveBinding extends Omit<DirectiveBinding, 'modifiers' | 'value'> {
|
||||
value: MutationCallback | {
|
||||
handler: MutationCallback;
|
||||
options?: MutationObserverInit;
|
||||
};
|
||||
modifiers: MutationOptions;
|
||||
}
|
||||
declare function mounted(el: HTMLElement, binding: MutationDirectiveBinding): void;
|
||||
declare function unmounted(el: HTMLElement, binding: MutationDirectiveBinding): void;
|
||||
export declare const Mutate: {
|
||||
mounted: typeof mounted;
|
||||
unmounted: typeof unmounted;
|
||||
};
|
||||
export default Mutate;
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
// Types
|
||||
|
||||
function mounted(el, binding) {
|
||||
const modifiers = binding.modifiers || {};
|
||||
const value = binding.value;
|
||||
const {
|
||||
once,
|
||||
immediate,
|
||||
...modifierKeys
|
||||
} = modifiers;
|
||||
const defaultValue = !Object.keys(modifierKeys).length;
|
||||
const {
|
||||
handler,
|
||||
options
|
||||
} = typeof value === 'object' ? value : {
|
||||
handler: value,
|
||||
options: {
|
||||
attributes: modifierKeys?.attr ?? defaultValue,
|
||||
characterData: modifierKeys?.char ?? defaultValue,
|
||||
childList: modifierKeys?.child ?? defaultValue,
|
||||
subtree: modifierKeys?.sub ?? defaultValue
|
||||
}
|
||||
};
|
||||
const observer = new MutationObserver(function () {
|
||||
let mutations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
||||
let observer = arguments.length > 1 ? arguments[1] : undefined;
|
||||
handler?.(mutations, observer);
|
||||
if (once) unmounted(el, binding);
|
||||
});
|
||||
if (immediate) handler?.([], observer);
|
||||
el._mutate = Object(el._mutate);
|
||||
el._mutate[binding.instance.$.uid] = {
|
||||
observer
|
||||
};
|
||||
observer.observe(el, options);
|
||||
}
|
||||
function unmounted(el, binding) {
|
||||
if (!el._mutate?.[binding.instance.$.uid]) return;
|
||||
el._mutate[binding.instance.$.uid].observer.disconnect();
|
||||
delete el._mutate[binding.instance.$.uid];
|
||||
}
|
||||
export const Mutate = {
|
||||
mounted,
|
||||
unmounted
|
||||
};
|
||||
export default Mutate;
|
||||
//# sourceMappingURL=index.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","names":["mounted","el","binding","modifiers","value","once","immediate","modifierKeys","defaultValue","Object","keys","length","handler","options","attributes","attr","characterData","char","childList","child","subtree","sub","observer","MutationObserver","mutations","arguments","undefined","unmounted","_mutate","instance","$","uid","observe","disconnect","Mutate"],"sources":["../../../src/directives/mutate/index.ts"],"sourcesContent":["// Types\nimport type { DirectiveBinding } from 'vue'\nimport type { MutationOptions } from '@/composables/mutationObserver'\n\nexport interface MutationDirectiveBinding extends Omit<DirectiveBinding, 'modifiers' | 'value'> {\n value: MutationCallback | { handler: MutationCallback, options?: MutationObserverInit }\n modifiers: MutationOptions\n}\n\nfunction mounted (el: HTMLElement, binding: MutationDirectiveBinding) {\n const modifiers = binding.modifiers || {}\n const value = binding.value\n const { once, immediate, ...modifierKeys } = modifiers\n const defaultValue = !Object.keys(modifierKeys).length\n\n const { handler, options } = typeof value === 'object'\n ? value\n : {\n handler: value,\n options: {\n attributes: modifierKeys?.attr ?? defaultValue,\n characterData: modifierKeys?.char ?? defaultValue,\n childList: modifierKeys?.child ?? defaultValue,\n subtree: modifierKeys?.sub ?? defaultValue,\n },\n }\n\n const observer = new MutationObserver((\n mutations: MutationRecord[] = [],\n observer: MutationObserver\n ) => {\n handler?.(mutations, observer)\n\n if (once) unmounted(el, binding)\n })\n\n if (immediate) handler?.([], observer)\n\n el._mutate = Object(el._mutate)\n el._mutate![binding.instance!.$.uid] = { observer }\n\n observer.observe(el, options)\n}\n\nfunction unmounted (el: HTMLElement, binding: MutationDirectiveBinding) {\n if (!el._mutate?.[binding.instance!.$.uid]) return\n\n el._mutate[binding.instance!.$.uid]!.observer.disconnect()\n delete el._mutate[binding.instance!.$.uid]\n}\n\nexport const Mutate = {\n mounted,\n unmounted,\n}\n\nexport default Mutate\n"],"mappings":"AAAA;;AASA,SAASA,OAAOA,CAAEC,EAAe,EAAEC,OAAiC,EAAE;EACpE,MAAMC,SAAS,GAAGD,OAAO,CAACC,SAAS,IAAI,CAAC,CAAC;EACzC,MAAMC,KAAK,GAAGF,OAAO,CAACE,KAAK;EAC3B,MAAM;IAAEC,IAAI;IAAEC,SAAS;IAAE,GAAGC;EAAa,CAAC,GAAGJ,SAAS;EACtD,MAAMK,YAAY,GAAG,CAACC,MAAM,CAACC,IAAI,CAACH,YAAY,CAAC,CAACI,MAAM;EAEtD,MAAM;IAAEC,OAAO;IAAEC;EAAQ,CAAC,GAAG,OAAOT,KAAK,KAAK,QAAQ,GAClDA,KAAK,GACL;IACAQ,OAAO,EAAER,KAAK;IACdS,OAAO,EAAE;MACPC,UAAU,EAAEP,YAAY,EAAEQ,IAAI,IAAIP,YAAY;MAC9CQ,aAAa,EAAET,YAAY,EAAEU,IAAI,IAAIT,YAAY;MACjDU,SAAS,EAAEX,YAAY,EAAEY,KAAK,IAAIX,YAAY;MAC9CY,OAAO,EAAEb,YAAY,EAAEc,GAAG,IAAIb;IAChC;EACF,CAAC;EAEH,MAAMc,QAAQ,GAAG,IAAIC,gBAAgB,CAAC,YAGjC;IAAA,IAFHC,SAA2B,GAAAC,SAAA,CAAAd,MAAA,QAAAc,SAAA,QAAAC,SAAA,GAAAD,SAAA,MAAG,EAAE;IAAA,IAChCH,QAA0B,GAAAG,SAAA,CAAAd,MAAA,OAAAc,SAAA,MAAAC,SAAA;IAE1Bd,OAAO,GAAGY,SAAS,EAAEF,QAAQ,CAAC;IAE9B,IAAIjB,IAAI,EAAEsB,SAAS,CAAC1B,EAAE,EAAEC,OAAO,CAAC;EAClC,CAAC,CAAC;EAEF,IAAII,SAAS,EAAEM,OAAO,GAAG,EAAE,EAAEU,QAAQ,CAAC;EAEtCrB,EAAE,CAAC2B,OAAO,GAAGnB,MAAM,CAACR,EAAE,CAAC2B,OAAO,CAAC;EAC/B3B,EAAE,CAAC2B,OAAO,CAAE1B,OAAO,CAAC2B,QAAQ,CAAEC,CAAC,CAACC,GAAG,CAAC,GAAG;IAAET;EAAS,CAAC;EAEnDA,QAAQ,CAACU,OAAO,CAAC/B,EAAE,EAAEY,OAAO,CAAC;AAC/B;AAEA,SAASc,SAASA,CAAE1B,EAAe,EAAEC,OAAiC,EAAE;EACtE,IAAI,CAACD,EAAE,CAAC2B,OAAO,GAAG1B,OAAO,CAAC2B,QAAQ,CAAEC,CAAC,CAACC,GAAG,CAAC,EAAE;EAE5C9B,EAAE,CAAC2B,OAAO,CAAC1B,OAAO,CAAC2B,QAAQ,CAAEC,CAAC,CAACC,GAAG,CAAC,CAAET,QAAQ,CAACW,UAAU,CAAC,CAAC;EAC1D,OAAOhC,EAAE,CAAC2B,OAAO,CAAC1B,OAAO,CAAC2B,QAAQ,CAAEC,CAAC,CAACC,GAAG,CAAC;AAC5C;AAEA,OAAO,MAAMG,MAAM,GAAG;EACpBlC,OAAO;EACP2B;AACF,CAAC;AAED,eAAeO,MAAM","ignoreList":[]}
|
||||
Generated
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
// Types
|
||||
import type { DirectiveBinding } from 'vue';
|
||||
interface ResizeDirectiveBinding extends Omit<DirectiveBinding, 'modifiers'> {
|
||||
value: () => void;
|
||||
modifiers?: {
|
||||
active?: boolean;
|
||||
quiet?: boolean;
|
||||
};
|
||||
}
|
||||
declare function mounted(el: HTMLElement, binding: ResizeDirectiveBinding): void;
|
||||
declare function unmounted(el: HTMLElement, binding: ResizeDirectiveBinding): void;
|
||||
export declare const Resize: {
|
||||
mounted: typeof mounted;
|
||||
unmounted: typeof unmounted;
|
||||
};
|
||||
export default Resize;
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// Types
|
||||
|
||||
function mounted(el, binding) {
|
||||
const handler = binding.value;
|
||||
const options = {
|
||||
passive: !binding.modifiers?.active
|
||||
};
|
||||
window.addEventListener('resize', handler, options);
|
||||
el._onResize = Object(el._onResize);
|
||||
el._onResize[binding.instance.$.uid] = {
|
||||
handler,
|
||||
options
|
||||
};
|
||||
if (!binding.modifiers?.quiet) {
|
||||
handler();
|
||||
}
|
||||
}
|
||||
function unmounted(el, binding) {
|
||||
if (!el._onResize?.[binding.instance.$.uid]) return;
|
||||
const {
|
||||
handler,
|
||||
options
|
||||
} = el._onResize[binding.instance.$.uid];
|
||||
window.removeEventListener('resize', handler, options);
|
||||
delete el._onResize[binding.instance.$.uid];
|
||||
}
|
||||
export const Resize = {
|
||||
mounted,
|
||||
unmounted
|
||||
};
|
||||
export default Resize;
|
||||
//# sourceMappingURL=index.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","names":["mounted","el","binding","handler","value","options","passive","modifiers","active","window","addEventListener","_onResize","Object","instance","$","uid","quiet","unmounted","removeEventListener","Resize"],"sources":["../../../src/directives/resize/index.ts"],"sourcesContent":["// Types\nimport type { DirectiveBinding } from 'vue'\n\ninterface ResizeDirectiveBinding extends Omit<DirectiveBinding, 'modifiers'> {\n value: () => void\n modifiers?: {\n active?: boolean\n quiet?: boolean\n }\n}\n\nfunction mounted (el: HTMLElement, binding: ResizeDirectiveBinding) {\n const handler = binding.value\n const options: AddEventListenerOptions = {\n passive: !binding.modifiers?.active,\n }\n\n window.addEventListener('resize', handler, options)\n\n el._onResize = Object(el._onResize)\n el._onResize![binding.instance!.$.uid] = {\n handler,\n options,\n }\n\n if (!binding.modifiers?.quiet) {\n handler()\n }\n}\n\nfunction unmounted (el: HTMLElement, binding: ResizeDirectiveBinding) {\n if (!el._onResize?.[binding.instance!.$.uid]) return\n\n const { handler, options } = el._onResize[binding.instance!.$.uid]!\n\n window.removeEventListener('resize', handler, options)\n\n delete el._onResize[binding.instance!.$.uid]\n}\n\nexport const Resize = {\n mounted,\n unmounted,\n}\n\nexport default Resize\n"],"mappings":"AAAA;;AAWA,SAASA,OAAOA,CAAEC,EAAe,EAAEC,OAA+B,EAAE;EAClE,MAAMC,OAAO,GAAGD,OAAO,CAACE,KAAK;EAC7B,MAAMC,OAAgC,GAAG;IACvCC,OAAO,EAAE,CAACJ,OAAO,CAACK,SAAS,EAAEC;EAC/B,CAAC;EAEDC,MAAM,CAACC,gBAAgB,CAAC,QAAQ,EAAEP,OAAO,EAAEE,OAAO,CAAC;EAEnDJ,EAAE,CAACU,SAAS,GAAGC,MAAM,CAACX,EAAE,CAACU,SAAS,CAAC;EACnCV,EAAE,CAACU,SAAS,CAAET,OAAO,CAACW,QAAQ,CAAEC,CAAC,CAACC,GAAG,CAAC,GAAG;IACvCZ,OAAO;IACPE;EACF,CAAC;EAED,IAAI,CAACH,OAAO,CAACK,SAAS,EAAES,KAAK,EAAE;IAC7Bb,OAAO,CAAC,CAAC;EACX;AACF;AAEA,SAASc,SAASA,CAAEhB,EAAe,EAAEC,OAA+B,EAAE;EACpE,IAAI,CAACD,EAAE,CAACU,SAAS,GAAGT,OAAO,CAACW,QAAQ,CAAEC,CAAC,CAACC,GAAG,CAAC,EAAE;EAE9C,MAAM;IAAEZ,OAAO;IAAEE;EAAQ,CAAC,GAAGJ,EAAE,CAACU,SAAS,CAACT,OAAO,CAACW,QAAQ,CAAEC,CAAC,CAACC,GAAG,CAAE;EAEnEN,MAAM,CAACS,mBAAmB,CAAC,QAAQ,EAAEf,OAAO,EAAEE,OAAO,CAAC;EAEtD,OAAOJ,EAAE,CAACU,SAAS,CAACT,OAAO,CAACW,QAAQ,CAAEC,CAAC,CAACC,GAAG,CAAC;AAC9C;AAEA,OAAO,MAAMI,MAAM,GAAG;EACpBnB,OAAO;EACPiB;AACF,CAAC;AAED,eAAeE,MAAM","ignoreList":[]}
|
||||
Generated
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
.v-ripple__container {
|
||||
color: inherit;
|
||||
border-radius: inherit;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
left: 0;
|
||||
top: 0;
|
||||
overflow: hidden;
|
||||
z-index: 0;
|
||||
pointer-events: none;
|
||||
contain: strict;
|
||||
}
|
||||
.v-ripple__animation {
|
||||
color: inherit;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
border-radius: 50%;
|
||||
background: currentColor;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
overflow: hidden;
|
||||
will-change: transform, opacity;
|
||||
}
|
||||
.v-ripple__animation--enter {
|
||||
transition: none;
|
||||
opacity: 0;
|
||||
}
|
||||
.v-ripple__animation--in {
|
||||
transition: transform 0.25s cubic-bezier(0, 0, 0.2, 1), opacity 0.1s cubic-bezier(0, 0, 0.2, 1);
|
||||
opacity: calc(0.25 * var(--v-theme-overlay-multiplier));
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.v-ripple__animation--in {
|
||||
transition-property: opacity;
|
||||
transition-duration: 0.1s;
|
||||
}
|
||||
}
|
||||
.v-ripple__animation--out {
|
||||
transition: opacity 0.3s cubic-bezier(0, 0, 0.2, 1);
|
||||
opacity: 0;
|
||||
}
|
||||
Generated
Vendored
+45
@@ -0,0 +1,45 @@
|
||||
@use '../../styles/tools'
|
||||
@use './variables' as *
|
||||
|
||||
@include tools.layer('components')
|
||||
.v-ripple
|
||||
&__container
|
||||
color: inherit
|
||||
border-radius: inherit
|
||||
position: absolute
|
||||
width: 100%
|
||||
height: 100%
|
||||
left: 0
|
||||
top: 0
|
||||
overflow: hidden
|
||||
z-index: 0
|
||||
pointer-events: none
|
||||
contain: strict
|
||||
|
||||
&__animation
|
||||
color: inherit
|
||||
position: absolute
|
||||
top: 0
|
||||
left: 0
|
||||
border-radius: 50%
|
||||
background: currentColor
|
||||
opacity: 0
|
||||
pointer-events: none
|
||||
overflow: hidden
|
||||
will-change: transform, opacity
|
||||
|
||||
&--enter
|
||||
transition: none
|
||||
opacity: 0
|
||||
|
||||
&--in
|
||||
transition: $ripple-animation-transition-in
|
||||
opacity: $ripple-animation-visible-opacity
|
||||
|
||||
@media (prefers-reduced-motion: reduce)
|
||||
transition-property: opacity
|
||||
transition-duration: 0.1s
|
||||
|
||||
&--out
|
||||
transition: $ripple-animation-transition-out
|
||||
opacity: 0
|
||||
Generated
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
@use '../../styles/settings';
|
||||
|
||||
$ripple-animation-transition-in: transform .25s settings.$decelerated-easing,
|
||||
opacity .1s settings.$decelerated-easing !default;
|
||||
$ripple-animation-transition-out: opacity .3s settings.$decelerated-easing !default;
|
||||
$ripple-animation-visible-opacity: calc(.25 * var(--v-theme-overlay-multiplier)) !default;
|
||||
Generated
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
// Styles
|
||||
|
||||
// Types
|
||||
import type { DirectiveBinding } from 'vue';
|
||||
export interface RippleDirectiveBinding extends Omit<DirectiveBinding, 'modifiers' | 'value'> {
|
||||
value?: boolean | {
|
||||
class?: string;
|
||||
keys?: string[];
|
||||
};
|
||||
modifiers: {
|
||||
center?: boolean;
|
||||
circle?: boolean;
|
||||
stop?: boolean;
|
||||
};
|
||||
}
|
||||
declare function mounted(el: HTMLElement, binding: RippleDirectiveBinding): void;
|
||||
declare function unmounted(el: HTMLElement): void;
|
||||
declare function updated(el: HTMLElement, binding: RippleDirectiveBinding): void;
|
||||
export declare const Ripple: {
|
||||
mounted: typeof mounted;
|
||||
unmounted: typeof unmounted;
|
||||
updated: typeof updated;
|
||||
};
|
||||
export default Ripple;
|
||||
+297
@@ -0,0 +1,297 @@
|
||||
// Styles
|
||||
import "./VRipple.css";
|
||||
|
||||
// Utilities
|
||||
import { isObject } from "../../util/index.js"; // Types
|
||||
const stopSymbol = Symbol('rippleStop');
|
||||
const DELAY_RIPPLE = 80;
|
||||
function transform(el, value) {
|
||||
el.style.transform = value;
|
||||
el.style.webkitTransform = value;
|
||||
}
|
||||
function isTouchEvent(e) {
|
||||
return e.constructor.name === 'TouchEvent';
|
||||
}
|
||||
function isKeyboardEvent(e) {
|
||||
return e.constructor.name === 'KeyboardEvent';
|
||||
}
|
||||
const calculate = function (e, el) {
|
||||
let value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
||||
let localX = 0;
|
||||
let localY = 0;
|
||||
if (!isKeyboardEvent(e)) {
|
||||
const offset = el.getBoundingClientRect();
|
||||
const target = isTouchEvent(e) ? e.touches[e.touches.length - 1] : e;
|
||||
localX = target.clientX - offset.left;
|
||||
localY = target.clientY - offset.top;
|
||||
}
|
||||
let radius = 0;
|
||||
let scale = 0.3;
|
||||
if (el._ripple?.circle) {
|
||||
scale = 0.15;
|
||||
radius = el.clientWidth / 2;
|
||||
radius = value.center ? radius : radius + Math.sqrt((localX - radius) ** 2 + (localY - radius) ** 2) / 4;
|
||||
} else {
|
||||
radius = Math.sqrt(el.clientWidth ** 2 + el.clientHeight ** 2) / 2;
|
||||
}
|
||||
const centerX = `${(el.clientWidth - radius * 2) / 2}px`;
|
||||
const centerY = `${(el.clientHeight - radius * 2) / 2}px`;
|
||||
const x = value.center ? centerX : `${localX - radius}px`;
|
||||
const y = value.center ? centerY : `${localY - radius}px`;
|
||||
return {
|
||||
radius,
|
||||
scale,
|
||||
x,
|
||||
y,
|
||||
centerX,
|
||||
centerY
|
||||
};
|
||||
};
|
||||
const ripples = {
|
||||
/* eslint-disable max-statements */
|
||||
show(e, el) {
|
||||
let value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
||||
if (!el?._ripple?.enabled) {
|
||||
return;
|
||||
}
|
||||
const container = document.createElement('span');
|
||||
const animation = document.createElement('span');
|
||||
container.appendChild(animation);
|
||||
container.className = 'v-ripple__container';
|
||||
if (value.class) {
|
||||
container.className += ` ${value.class}`;
|
||||
}
|
||||
const {
|
||||
radius,
|
||||
scale,
|
||||
x,
|
||||
y,
|
||||
centerX,
|
||||
centerY
|
||||
} = calculate(e, el, value);
|
||||
const size = `${radius * 2}px`;
|
||||
animation.className = 'v-ripple__animation';
|
||||
animation.style.width = size;
|
||||
animation.style.height = size;
|
||||
el.appendChild(container);
|
||||
const computed = window.getComputedStyle(el);
|
||||
if (computed && computed.position === 'static') {
|
||||
el.style.position = 'relative';
|
||||
el.dataset.previousPosition = 'static';
|
||||
}
|
||||
animation.classList.add('v-ripple__animation--enter');
|
||||
animation.classList.add('v-ripple__animation--visible');
|
||||
transform(animation, `translate(${x}, ${y}) scale3d(${scale},${scale},${scale})`);
|
||||
animation.dataset.activated = String(performance.now());
|
||||
requestAnimationFrame(() => {
|
||||
requestAnimationFrame(() => {
|
||||
animation.classList.remove('v-ripple__animation--enter');
|
||||
animation.classList.add('v-ripple__animation--in');
|
||||
transform(animation, `translate(${centerX}, ${centerY}) scale3d(1,1,1)`);
|
||||
});
|
||||
});
|
||||
},
|
||||
hide(el) {
|
||||
if (!el?._ripple?.enabled) return;
|
||||
const ripples = el.getElementsByClassName('v-ripple__animation');
|
||||
if (ripples.length === 0) return;
|
||||
const animation = Array.from(ripples).findLast(ripple => !ripple.dataset.isHiding);
|
||||
if (!animation) return;else animation.dataset.isHiding = 'true';
|
||||
const diff = performance.now() - Number(animation.dataset.activated);
|
||||
const delay = Math.max(250 - diff, 0);
|
||||
setTimeout(() => {
|
||||
animation.classList.remove('v-ripple__animation--in');
|
||||
animation.classList.add('v-ripple__animation--out');
|
||||
setTimeout(() => {
|
||||
const ripples = el.getElementsByClassName('v-ripple__animation');
|
||||
if (ripples.length === 1 && el.dataset.previousPosition) {
|
||||
el.style.position = el.dataset.previousPosition;
|
||||
delete el.dataset.previousPosition;
|
||||
}
|
||||
if (animation.parentNode?.parentNode === el) el.removeChild(animation.parentNode);
|
||||
}, 300);
|
||||
}, delay);
|
||||
}
|
||||
};
|
||||
function isRippleEnabled(value) {
|
||||
return typeof value === 'undefined' || !!value;
|
||||
}
|
||||
function rippleShow(e) {
|
||||
const value = {};
|
||||
const element = e.currentTarget;
|
||||
if (!element?._ripple || element._ripple.touched || e[stopSymbol]) return;
|
||||
|
||||
// Don't allow the event to trigger ripples on any other elements
|
||||
e[stopSymbol] = true;
|
||||
if (isTouchEvent(e)) {
|
||||
element._ripple.touched = true;
|
||||
element._ripple.isTouch = true;
|
||||
} else {
|
||||
// It's possible for touch events to fire
|
||||
// as mouse events on Android/iOS, this
|
||||
// will skip the event call if it has
|
||||
// already been registered as touch
|
||||
if (element._ripple.isTouch) return;
|
||||
}
|
||||
value.center = element._ripple.centered || isKeyboardEvent(e);
|
||||
if (element._ripple.class) {
|
||||
value.class = element._ripple.class;
|
||||
}
|
||||
if (isTouchEvent(e)) {
|
||||
// already queued that shows or hides the ripple
|
||||
if (element._ripple.showTimerCommit) return;
|
||||
element._ripple.showTimerCommit = () => {
|
||||
ripples.show(e, element, value);
|
||||
};
|
||||
element._ripple.showTimer = window.setTimeout(() => {
|
||||
if (element?._ripple?.showTimerCommit) {
|
||||
element._ripple.showTimerCommit();
|
||||
element._ripple.showTimerCommit = null;
|
||||
}
|
||||
}, DELAY_RIPPLE);
|
||||
} else {
|
||||
ripples.show(e, element, value);
|
||||
}
|
||||
}
|
||||
function rippleStop(e) {
|
||||
e[stopSymbol] = true;
|
||||
}
|
||||
function rippleHide(e) {
|
||||
const element = e.currentTarget;
|
||||
if (!element?._ripple) return;
|
||||
window.clearTimeout(element._ripple.showTimer);
|
||||
|
||||
// The touch interaction occurs before the show timer is triggered.
|
||||
// We still want to show ripple effect.
|
||||
if (e.type === 'touchend' && element._ripple.showTimerCommit) {
|
||||
element._ripple.showTimerCommit();
|
||||
element._ripple.showTimerCommit = null;
|
||||
|
||||
// re-queue ripple hiding
|
||||
element._ripple.showTimer = window.setTimeout(() => {
|
||||
rippleHide(e);
|
||||
});
|
||||
return;
|
||||
}
|
||||
window.setTimeout(() => {
|
||||
if (element._ripple) {
|
||||
element._ripple.touched = false;
|
||||
}
|
||||
});
|
||||
ripples.hide(element);
|
||||
}
|
||||
function rippleCancelShow(e) {
|
||||
const element = e.currentTarget;
|
||||
if (!element?._ripple) return;
|
||||
if (element._ripple.showTimerCommit) {
|
||||
element._ripple.showTimerCommit = null;
|
||||
}
|
||||
window.clearTimeout(element._ripple.showTimer);
|
||||
}
|
||||
let keyboardRipple = false;
|
||||
function keyboardRippleShow(e, keys) {
|
||||
if (!keyboardRipple && keys.includes(e.key)) {
|
||||
keyboardRipple = true;
|
||||
rippleShow(e);
|
||||
}
|
||||
}
|
||||
function keyboardRippleHide(e) {
|
||||
keyboardRipple = false;
|
||||
rippleHide(e);
|
||||
}
|
||||
function focusRippleHide(e) {
|
||||
if (keyboardRipple) {
|
||||
keyboardRipple = false;
|
||||
rippleHide(e);
|
||||
}
|
||||
}
|
||||
function updateRipple(el, binding, wasEnabled) {
|
||||
const {
|
||||
value,
|
||||
modifiers
|
||||
} = binding;
|
||||
const enabled = isRippleEnabled(value);
|
||||
if (!enabled) {
|
||||
ripples.hide(el);
|
||||
}
|
||||
el._ripple = el._ripple ?? {};
|
||||
el._ripple.enabled = enabled;
|
||||
el._ripple.centered = modifiers.center;
|
||||
el._ripple.circle = modifiers.circle;
|
||||
const bindingValue = isObject(value) ? value : {};
|
||||
if (bindingValue.class) {
|
||||
el._ripple.class = bindingValue.class;
|
||||
}
|
||||
const allowedKeys = bindingValue.keys ?? ['Enter', 'Space'];
|
||||
el._ripple.keyDownHandler = e => keyboardRippleShow(e, allowedKeys);
|
||||
if (enabled && !wasEnabled) {
|
||||
if (modifiers.stop) {
|
||||
el.addEventListener('touchstart', rippleStop, {
|
||||
passive: true
|
||||
});
|
||||
el.addEventListener('mousedown', rippleStop);
|
||||
return;
|
||||
}
|
||||
el.addEventListener('touchstart', rippleShow, {
|
||||
passive: true
|
||||
});
|
||||
el.addEventListener('touchend', rippleHide, {
|
||||
passive: true
|
||||
});
|
||||
el.addEventListener('touchmove', rippleCancelShow, {
|
||||
passive: true
|
||||
});
|
||||
el.addEventListener('touchcancel', rippleHide);
|
||||
el.addEventListener('mousedown', rippleShow);
|
||||
el.addEventListener('mouseup', rippleHide);
|
||||
el.addEventListener('mouseleave', rippleHide);
|
||||
el.addEventListener('keydown', el._ripple.keyDownHandler);
|
||||
el.addEventListener('keyup', keyboardRippleHide);
|
||||
el.addEventListener('blur', focusRippleHide);
|
||||
|
||||
// Anchor tags can be dragged, causes other hides to fail - #1537
|
||||
el.addEventListener('dragstart', rippleHide, {
|
||||
passive: true
|
||||
});
|
||||
} else if (!enabled && wasEnabled) {
|
||||
removeListeners(el);
|
||||
}
|
||||
}
|
||||
function removeListeners(el) {
|
||||
el.removeEventListener('touchstart', rippleStop);
|
||||
el.removeEventListener('mousedown', rippleStop);
|
||||
el.removeEventListener('touchstart', rippleShow);
|
||||
el.removeEventListener('touchend', rippleHide);
|
||||
el.removeEventListener('touchmove', rippleCancelShow);
|
||||
el.removeEventListener('touchcancel', rippleHide);
|
||||
el.removeEventListener('mousedown', rippleShow);
|
||||
el.removeEventListener('mouseup', rippleHide);
|
||||
el.removeEventListener('mouseleave', rippleHide);
|
||||
if (el._ripple?.keyDownHandler) {
|
||||
el.removeEventListener('keydown', el._ripple.keyDownHandler);
|
||||
}
|
||||
el.removeEventListener('keyup', keyboardRippleHide);
|
||||
el.removeEventListener('blur', focusRippleHide);
|
||||
el.removeEventListener('dragstart', rippleHide);
|
||||
}
|
||||
function mounted(el, binding) {
|
||||
updateRipple(el, binding, false);
|
||||
}
|
||||
function unmounted(el) {
|
||||
removeListeners(el);
|
||||
delete el._ripple;
|
||||
}
|
||||
function updated(el, binding) {
|
||||
if (binding.value === binding.oldValue) {
|
||||
return;
|
||||
}
|
||||
const wasEnabled = isRippleEnabled(binding.oldValue);
|
||||
updateRipple(el, binding, wasEnabled);
|
||||
}
|
||||
export const Ripple = {
|
||||
mounted,
|
||||
unmounted,
|
||||
updated
|
||||
};
|
||||
export default Ripple;
|
||||
//# sourceMappingURL=index.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","names":["isObject","stopSymbol","Symbol","DELAY_RIPPLE","transform","el","value","style","webkitTransform","isTouchEvent","e","constructor","name","isKeyboardEvent","calculate","arguments","length","undefined","localX","localY","offset","getBoundingClientRect","target","touches","clientX","left","clientY","top","radius","scale","_ripple","circle","clientWidth","center","Math","sqrt","clientHeight","centerX","centerY","x","y","ripples","show","enabled","container","document","createElement","animation","appendChild","className","class","size","width","height","computed","window","getComputedStyle","position","dataset","previousPosition","classList","add","activated","String","performance","now","requestAnimationFrame","remove","hide","getElementsByClassName","Array","from","findLast","ripple","isHiding","diff","Number","delay","max","setTimeout","parentNode","removeChild","isRippleEnabled","rippleShow","element","currentTarget","touched","isTouch","centered","showTimerCommit","showTimer","rippleStop","rippleHide","clearTimeout","type","rippleCancelShow","keyboardRipple","keyboardRippleShow","keys","includes","key","keyboardRippleHide","focusRippleHide","updateRipple","binding","wasEnabled","modifiers","bindingValue","allowedKeys","keyDownHandler","stop","addEventListener","passive","removeListeners","removeEventListener","mounted","unmounted","updated","oldValue","Ripple"],"sources":["../../../src/directives/ripple/index.ts"],"sourcesContent":["// Styles\nimport './VRipple.sass'\n\n// Utilities\nimport { isObject } from '@/util'\n\n// Types\nimport type { DirectiveBinding } from 'vue'\n\nconst stopSymbol = Symbol('rippleStop')\n\ntype VuetifyRippleEvent = (MouseEvent | TouchEvent | KeyboardEvent) & { [stopSymbol]?: boolean }\n\nconst DELAY_RIPPLE = 80\n\nfunction transform (el: HTMLElement, value: string) {\n el.style.transform = value\n el.style.webkitTransform = value\n}\n\ninterface RippleOptions {\n class?: string\n center?: boolean\n circle?: boolean\n}\n\nexport interface RippleDirectiveBinding extends Omit<DirectiveBinding, 'modifiers' | 'value'> {\n value?: boolean | {\n class?: string\n keys?: string[]\n }\n modifiers: {\n center?: boolean\n circle?: boolean\n stop?: boolean\n }\n}\n\nfunction isTouchEvent (e: VuetifyRippleEvent): e is TouchEvent {\n return e.constructor.name === 'TouchEvent'\n}\n\nfunction isKeyboardEvent (e: VuetifyRippleEvent): e is KeyboardEvent {\n return e.constructor.name === 'KeyboardEvent'\n}\n\nconst calculate = (\n e: VuetifyRippleEvent,\n el: HTMLElement,\n value: RippleOptions = {}\n) => {\n let localX = 0\n let localY = 0\n\n if (!isKeyboardEvent(e)) {\n const offset = el.getBoundingClientRect()\n const target = isTouchEvent(e) ? e.touches[e.touches.length - 1] : e\n\n localX = target.clientX - offset.left\n localY = target.clientY - offset.top\n }\n\n let radius = 0\n let scale = 0.3\n if (el._ripple?.circle) {\n scale = 0.15\n radius = el.clientWidth / 2\n radius = value.center ? radius : radius + Math.sqrt((localX - radius) ** 2 + (localY - radius) ** 2) / 4\n } else {\n radius = Math.sqrt(el.clientWidth ** 2 + el.clientHeight ** 2) / 2\n }\n\n const centerX = `${(el.clientWidth - (radius * 2)) / 2}px`\n const centerY = `${(el.clientHeight - (radius * 2)) / 2}px`\n\n const x = value.center ? centerX : `${localX - radius}px`\n const y = value.center ? centerY : `${localY - radius}px`\n\n return { radius, scale, x, y, centerX, centerY }\n}\n\nconst ripples = {\n /* eslint-disable max-statements */\n show (\n e: VuetifyRippleEvent,\n el: HTMLElement,\n value: RippleOptions = {}\n ) {\n if (!el?._ripple?.enabled) {\n return\n }\n\n const container = document.createElement('span')\n const animation = document.createElement('span')\n\n container.appendChild(animation)\n container.className = 'v-ripple__container'\n\n if (value.class) {\n container.className += ` ${value.class}`\n }\n\n const { radius, scale, x, y, centerX, centerY } = calculate(e, el, value)\n\n const size = `${radius * 2}px`\n animation.className = 'v-ripple__animation'\n animation.style.width = size\n animation.style.height = size\n\n el.appendChild(container)\n\n const computed = window.getComputedStyle(el)\n if (computed && computed.position === 'static') {\n el.style.position = 'relative'\n el.dataset.previousPosition = 'static'\n }\n\n animation.classList.add('v-ripple__animation--enter')\n animation.classList.add('v-ripple__animation--visible')\n transform(animation, `translate(${x}, ${y}) scale3d(${scale},${scale},${scale})`)\n animation.dataset.activated = String(performance.now())\n\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n animation.classList.remove('v-ripple__animation--enter')\n animation.classList.add('v-ripple__animation--in')\n transform(animatioLine truncated
|
||||
Generated
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
// Types
|
||||
import type { DirectiveBinding } from 'vue';
|
||||
interface ScrollDirectiveBinding extends Omit<DirectiveBinding, 'modifiers'> {
|
||||
value: EventListener | {
|
||||
handler: EventListener;
|
||||
options?: AddEventListenerOptions;
|
||||
} | (EventListenerObject & {
|
||||
options?: AddEventListenerOptions;
|
||||
});
|
||||
modifiers?: {
|
||||
self?: boolean;
|
||||
};
|
||||
}
|
||||
declare function mounted(el: HTMLElement, binding: ScrollDirectiveBinding): void;
|
||||
declare function unmounted(el: HTMLElement, binding: ScrollDirectiveBinding): void;
|
||||
declare function updated(el: HTMLElement, binding: ScrollDirectiveBinding): void;
|
||||
export declare const Scroll: {
|
||||
mounted: typeof mounted;
|
||||
unmounted: typeof unmounted;
|
||||
updated: typeof updated;
|
||||
};
|
||||
export default Scroll;
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
// Types
|
||||
|
||||
function mounted(el, binding) {
|
||||
const {
|
||||
self = false
|
||||
} = binding.modifiers ?? {};
|
||||
const value = binding.value;
|
||||
const options = typeof value === 'object' && value.options || {
|
||||
passive: true
|
||||
};
|
||||
const handler = typeof value === 'function' || 'handleEvent' in value ? value : value.handler;
|
||||
const target = self ? el : binding.arg ? document.querySelector(binding.arg) : window;
|
||||
if (!target) return;
|
||||
target.addEventListener('scroll', handler, options);
|
||||
el._onScroll = Object(el._onScroll);
|
||||
el._onScroll[binding.instance.$.uid] = {
|
||||
handler,
|
||||
options,
|
||||
// Don't reference self
|
||||
target: self ? undefined : target
|
||||
};
|
||||
}
|
||||
function unmounted(el, binding) {
|
||||
if (!el._onScroll?.[binding.instance.$.uid]) return;
|
||||
const {
|
||||
handler,
|
||||
options,
|
||||
target = el
|
||||
} = el._onScroll[binding.instance.$.uid];
|
||||
target.removeEventListener('scroll', handler, options);
|
||||
delete el._onScroll[binding.instance.$.uid];
|
||||
}
|
||||
function updated(el, binding) {
|
||||
if (binding.value === binding.oldValue) return;
|
||||
unmounted(el, binding);
|
||||
mounted(el, binding);
|
||||
}
|
||||
export const Scroll = {
|
||||
mounted,
|
||||
unmounted,
|
||||
updated
|
||||
};
|
||||
export default Scroll;
|
||||
//# sourceMappingURL=index.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","names":["mounted","el","binding","self","modifiers","value","options","passive","handler","target","arg","document","querySelector","window","addEventListener","_onScroll","Object","instance","$","uid","undefined","unmounted","removeEventListener","updated","oldValue","Scroll"],"sources":["../../../src/directives/scroll/index.ts"],"sourcesContent":["// Types\nimport type { DirectiveBinding } from 'vue'\n\ninterface ScrollDirectiveBinding extends Omit<DirectiveBinding, 'modifiers'> {\n value: EventListener | {\n handler: EventListener\n options?: AddEventListenerOptions\n } | EventListenerObject & { options?: AddEventListenerOptions }\n modifiers?: {\n self?: boolean\n }\n}\n\nfunction mounted (el: HTMLElement, binding: ScrollDirectiveBinding) {\n const { self = false } = binding.modifiers ?? {}\n const value = binding.value\n const options = (typeof value === 'object' && value.options) || { passive: true }\n const handler = typeof value === 'function' || 'handleEvent' in value ? value : value.handler\n\n const target = self\n ? el\n : binding.arg\n ? document.querySelector(binding.arg)\n : window\n\n if (!target) return\n\n target.addEventListener('scroll', handler, options)\n\n el._onScroll = Object(el._onScroll)\n el._onScroll![binding.instance!.$.uid] = {\n handler,\n options,\n // Don't reference self\n target: self ? undefined : target,\n }\n}\n\nfunction unmounted (el: HTMLElement, binding: ScrollDirectiveBinding) {\n if (!el._onScroll?.[binding.instance!.$.uid]) return\n\n const { handler, options, target = el } = el._onScroll[binding.instance!.$.uid]!\n\n target.removeEventListener('scroll', handler, options)\n delete el._onScroll[binding.instance!.$.uid]\n}\n\nfunction updated (el: HTMLElement, binding: ScrollDirectiveBinding) {\n if (binding.value === binding.oldValue) return\n\n unmounted(el, binding)\n mounted(el, binding)\n}\n\nexport const Scroll = {\n mounted,\n unmounted,\n updated,\n}\n\nexport default Scroll\n"],"mappings":"AAAA;;AAaA,SAASA,OAAOA,CAAEC,EAAe,EAAEC,OAA+B,EAAE;EAClE,MAAM;IAAEC,IAAI,GAAG;EAAM,CAAC,GAAGD,OAAO,CAACE,SAAS,IAAI,CAAC,CAAC;EAChD,MAAMC,KAAK,GAAGH,OAAO,CAACG,KAAK;EAC3B,MAAMC,OAAO,GAAI,OAAOD,KAAK,KAAK,QAAQ,IAAIA,KAAK,CAACC,OAAO,IAAK;IAAEC,OAAO,EAAE;EAAK,CAAC;EACjF,MAAMC,OAAO,GAAG,OAAOH,KAAK,KAAK,UAAU,IAAI,aAAa,IAAIA,KAAK,GAAGA,KAAK,GAAGA,KAAK,CAACG,OAAO;EAE7F,MAAMC,MAAM,GAAGN,IAAI,GACfF,EAAE,GACFC,OAAO,CAACQ,GAAG,GACTC,QAAQ,CAACC,aAAa,CAACV,OAAO,CAACQ,GAAG,CAAC,GACnCG,MAAM;EAEZ,IAAI,CAACJ,MAAM,EAAE;EAEbA,MAAM,CAACK,gBAAgB,CAAC,QAAQ,EAAEN,OAAO,EAAEF,OAAO,CAAC;EAEnDL,EAAE,CAACc,SAAS,GAAGC,MAAM,CAACf,EAAE,CAACc,SAAS,CAAC;EACnCd,EAAE,CAACc,SAAS,CAAEb,OAAO,CAACe,QAAQ,CAAEC,CAAC,CAACC,GAAG,CAAC,GAAG;IACvCX,OAAO;IACPF,OAAO;IACP;IACAG,MAAM,EAAEN,IAAI,GAAGiB,SAAS,GAAGX;EAC7B,CAAC;AACH;AAEA,SAASY,SAASA,CAAEpB,EAAe,EAAEC,OAA+B,EAAE;EACpE,IAAI,CAACD,EAAE,CAACc,SAAS,GAAGb,OAAO,CAACe,QAAQ,CAAEC,CAAC,CAACC,GAAG,CAAC,EAAE;EAE9C,MAAM;IAAEX,OAAO;IAAEF,OAAO;IAAEG,MAAM,GAAGR;EAAG,CAAC,GAAGA,EAAE,CAACc,SAAS,CAACb,OAAO,CAACe,QAAQ,CAAEC,CAAC,CAACC,GAAG,CAAE;EAEhFV,MAAM,CAACa,mBAAmB,CAAC,QAAQ,EAAEd,OAAO,EAAEF,OAAO,CAAC;EACtD,OAAOL,EAAE,CAACc,SAAS,CAACb,OAAO,CAACe,QAAQ,CAAEC,CAAC,CAACC,GAAG,CAAC;AAC9C;AAEA,SAASI,OAAOA,CAAEtB,EAAe,EAAEC,OAA+B,EAAE;EAClE,IAAIA,OAAO,CAACG,KAAK,KAAKH,OAAO,CAACsB,QAAQ,EAAE;EAExCH,SAAS,CAACpB,EAAE,EAAEC,OAAO,CAAC;EACtBF,OAAO,CAACC,EAAE,EAAEC,OAAO,CAAC;AACtB;AAEA,OAAO,MAAMuB,MAAM,GAAG;EACpBzB,OAAO;EACPqB,SAAS;EACTE;AACF,CAAC;AAED,eAAeE,MAAM","ignoreList":[]}
|
||||
Generated
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
// Types
|
||||
import type { DirectiveBinding } from 'vue';
|
||||
import type { Anchor } from '../../util/index.js';
|
||||
export interface TooltipDirectiveBinding extends Omit<DirectiveBinding<string>, 'arg' | 'value'> {
|
||||
arg?: {
|
||||
[T in Anchor]: T extends `${infer A} ${infer B}` ? `${A}-${B}` : T;
|
||||
}[Anchor];
|
||||
value: boolean | string | Record<string, any>;
|
||||
}
|
||||
export declare const Tooltip: import("../../composables/directiveComponent.js").CustomDirective<TooltipDirectiveBinding>;
|
||||
export default Tooltip;
|
||||
Generated
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// Components
|
||||
import { VTooltip } from "../../components/VTooltip/index.js"; // Composables
|
||||
import { useDirectiveComponent } from "../../composables/directiveComponent.js"; // Utilities
|
||||
import { isObject } from "../../util/index.js"; // Types
|
||||
export const Tooltip = useDirectiveComponent(VTooltip, binding => {
|
||||
const disabled = isObject(binding.value) ? !binding.value.text : ['', false, null].includes(binding.value); // undefined means true
|
||||
|
||||
return {
|
||||
activator: disabled ? null : 'parent',
|
||||
location: binding.arg?.replace('-', ' '),
|
||||
text: typeof binding.value === 'boolean' ? undefined : binding.value
|
||||
};
|
||||
});
|
||||
export default Tooltip;
|
||||
//# sourceMappingURL=index.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","names":["VTooltip","useDirectiveComponent","isObject","Tooltip","binding","disabled","value","text","includes","activator","location","arg","replace","undefined"],"sources":["../../../src/directives/tooltip/index.ts"],"sourcesContent":["// Components\nimport { VTooltip } from '@/components/VTooltip'\n\n// Composables\nimport { useDirectiveComponent } from '@/composables/directiveComponent'\n\n// Utilities\nimport { isObject } from '@/util'\n\n// Types\nimport type { DirectiveBinding } from 'vue'\nimport type { Anchor } from '@/util'\n\nexport interface TooltipDirectiveBinding extends Omit<DirectiveBinding<string>, 'arg' | 'value'> {\n arg?: { [T in Anchor]: T extends `${infer A} ${infer B}` ? `${A}-${B}` : T }[Anchor]\n value: boolean | string | Record<string, any>\n}\n\nexport const Tooltip = useDirectiveComponent<TooltipDirectiveBinding>(VTooltip, binding => {\n const disabled = isObject(binding.value)\n ? !binding.value.text\n : ['', false, null].includes(binding.value) // undefined means true\n\n return {\n activator: disabled ? null : 'parent',\n location: binding.arg?.replace('-', ' '),\n text: typeof binding.value === 'boolean' ? undefined : binding.value,\n }\n})\n\nexport default Tooltip\n"],"mappings":"AAAA;AAAA,SACSA,QAAQ,8CAEjB;AAAA,SACSC,qBAAqB,mDAE9B;AAAA,SACSC,QAAQ,+BAEjB;AASA,OAAO,MAAMC,OAAO,GAAGF,qBAAqB,CAA0BD,QAAQ,EAAEI,OAAO,IAAI;EACzF,MAAMC,QAAQ,GAAGH,QAAQ,CAACE,OAAO,CAACE,KAAK,CAAC,GACpC,CAACF,OAAO,CAACE,KAAK,CAACC,IAAI,GACnB,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,CAACC,QAAQ,CAACJ,OAAO,CAACE,KAAK,CAAC,EAAC;;EAE9C,OAAO;IACLG,SAAS,EAAEJ,QAAQ,GAAG,IAAI,GAAG,QAAQ;IACrCK,QAAQ,EAAEN,OAAO,CAACO,GAAG,EAAEC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;IACxCL,IAAI,EAAE,OAAOH,OAAO,CAACE,KAAK,KAAK,SAAS,GAAGO,SAAS,GAAGT,OAAO,CAACE;EACjE,CAAC;AACH,CAAC,CAAC;AAEF,eAAeH,OAAO","ignoreList":[]}
|
||||
Generated
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
// Types
|
||||
import type { DirectiveBinding } from 'vue';
|
||||
export interface TouchHandlers {
|
||||
start?: (wrapperEvent: {
|
||||
originalEvent: TouchEvent;
|
||||
} & TouchData) => void;
|
||||
end?: (wrapperEvent: {
|
||||
originalEvent: TouchEvent;
|
||||
} & TouchData) => void;
|
||||
move?: (wrapperEvent: {
|
||||
originalEvent: TouchEvent;
|
||||
} & TouchData) => void;
|
||||
left?: (wrapper: TouchData) => void;
|
||||
right?: (wrapper: TouchData) => void;
|
||||
up?: (wrapper: TouchData) => void;
|
||||
down?: (wrapper: TouchData) => void;
|
||||
}
|
||||
export interface TouchData {
|
||||
touchstartX: number;
|
||||
touchstartY: number;
|
||||
touchmoveX: number;
|
||||
touchmoveY: number;
|
||||
touchendX: number;
|
||||
touchendY: number;
|
||||
offsetX: number;
|
||||
offsetY: number;
|
||||
}
|
||||
export type TouchWrapper = TouchHandlers & TouchData;
|
||||
export interface TouchValue extends TouchHandlers {
|
||||
parent?: boolean;
|
||||
options?: AddEventListenerOptions;
|
||||
}
|
||||
export interface TouchStoredHandlers {
|
||||
touchstart: (e: TouchEvent) => void;
|
||||
touchend: (e: TouchEvent) => void;
|
||||
touchmove: (e: TouchEvent) => void;
|
||||
}
|
||||
export interface TouchDirectiveBinding extends Omit<DirectiveBinding, 'value'> {
|
||||
value?: TouchValue;
|
||||
}
|
||||
declare function mounted(el: HTMLElement, binding: TouchDirectiveBinding): void;
|
||||
declare function unmounted(el: HTMLElement, binding: TouchDirectiveBinding): void;
|
||||
export declare const Touch: {
|
||||
mounted: typeof mounted;
|
||||
unmounted: typeof unmounted;
|
||||
};
|
||||
export default Touch;
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
// Utilities
|
||||
import { keys } from "../../util/index.js"; // Types
|
||||
const handleGesture = wrapper => {
|
||||
const {
|
||||
touchstartX,
|
||||
touchendX,
|
||||
touchstartY,
|
||||
touchendY
|
||||
} = wrapper;
|
||||
const dirRatio = 0.5;
|
||||
const minDistance = 16;
|
||||
wrapper.offsetX = touchendX - touchstartX;
|
||||
wrapper.offsetY = touchendY - touchstartY;
|
||||
if (Math.abs(wrapper.offsetY) < dirRatio * Math.abs(wrapper.offsetX)) {
|
||||
wrapper.left && touchendX < touchstartX - minDistance && wrapper.left(wrapper);
|
||||
wrapper.right && touchendX > touchstartX + minDistance && wrapper.right(wrapper);
|
||||
}
|
||||
if (Math.abs(wrapper.offsetX) < dirRatio * Math.abs(wrapper.offsetY)) {
|
||||
wrapper.up && touchendY < touchstartY - minDistance && wrapper.up(wrapper);
|
||||
wrapper.down && touchendY > touchstartY + minDistance && wrapper.down(wrapper);
|
||||
}
|
||||
};
|
||||
function touchstart(event, wrapper) {
|
||||
const touch = event.changedTouches[0];
|
||||
wrapper.touchstartX = touch.clientX;
|
||||
wrapper.touchstartY = touch.clientY;
|
||||
wrapper.start?.({
|
||||
originalEvent: event,
|
||||
...wrapper
|
||||
});
|
||||
}
|
||||
function touchend(event, wrapper) {
|
||||
const touch = event.changedTouches[0];
|
||||
wrapper.touchendX = touch.clientX;
|
||||
wrapper.touchendY = touch.clientY;
|
||||
wrapper.end?.({
|
||||
originalEvent: event,
|
||||
...wrapper
|
||||
});
|
||||
handleGesture(wrapper);
|
||||
}
|
||||
function touchmove(event, wrapper) {
|
||||
const touch = event.changedTouches[0];
|
||||
wrapper.touchmoveX = touch.clientX;
|
||||
wrapper.touchmoveY = touch.clientY;
|
||||
wrapper.move?.({
|
||||
originalEvent: event,
|
||||
...wrapper
|
||||
});
|
||||
}
|
||||
function createHandlers() {
|
||||
let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
const wrapper = {
|
||||
touchstartX: 0,
|
||||
touchstartY: 0,
|
||||
touchendX: 0,
|
||||
touchendY: 0,
|
||||
touchmoveX: 0,
|
||||
touchmoveY: 0,
|
||||
offsetX: 0,
|
||||
offsetY: 0,
|
||||
left: value.left,
|
||||
right: value.right,
|
||||
up: value.up,
|
||||
down: value.down,
|
||||
start: value.start,
|
||||
move: value.move,
|
||||
end: value.end
|
||||
};
|
||||
return {
|
||||
touchstart: e => touchstart(e, wrapper),
|
||||
touchend: e => touchend(e, wrapper),
|
||||
touchmove: e => touchmove(e, wrapper)
|
||||
};
|
||||
}
|
||||
function mounted(el, binding) {
|
||||
const value = binding.value;
|
||||
const target = value?.parent ? el.parentElement : el;
|
||||
const options = value?.options ?? {
|
||||
passive: true
|
||||
};
|
||||
const uid = binding.instance?.$.uid; // TODO: use custom uid generator
|
||||
|
||||
if (!target || uid === undefined) return;
|
||||
const handlers = createHandlers(binding.value);
|
||||
target._touchHandlers = target._touchHandlers ?? Object.create(null);
|
||||
target._touchHandlers[uid] = handlers;
|
||||
keys(handlers).forEach(eventName => {
|
||||
target.addEventListener(eventName, handlers[eventName], options);
|
||||
});
|
||||
}
|
||||
function unmounted(el, binding) {
|
||||
const target = binding.value?.parent ? el.parentElement : el;
|
||||
const uid = binding.instance?.$.uid;
|
||||
if (!target?._touchHandlers || uid === undefined) return;
|
||||
const handlers = target._touchHandlers[uid];
|
||||
keys(handlers).forEach(eventName => {
|
||||
target.removeEventListener(eventName, handlers[eventName]);
|
||||
});
|
||||
delete target._touchHandlers[uid];
|
||||
}
|
||||
export const Touch = {
|
||||
mounted,
|
||||
unmounted
|
||||
};
|
||||
export default Touch;
|
||||
//# sourceMappingURL=index.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","names":["keys","handleGesture","wrapper","touchstartX","touchendX","touchstartY","touchendY","dirRatio","minDistance","offsetX","offsetY","Math","abs","left","right","up","down","touchstart","event","touch","changedTouches","clientX","clientY","start","originalEvent","touchend","end","touchmove","touchmoveX","touchmoveY","move","createHandlers","value","arguments","length","undefined","e","mounted","el","binding","target","parent","parentElement","options","passive","uid","instance","$","handlers","_touchHandlers","Object","create","forEach","eventName","addEventListener","unmounted","removeEventListener","Touch"],"sources":["../../../src/directives/touch/index.ts"],"sourcesContent":["// Utilities\nimport { keys } from '@/util'\n\n// Types\nimport type {\n DirectiveBinding,\n} from 'vue'\n\nexport interface TouchHandlers {\n start?: (wrapperEvent: { originalEvent: TouchEvent } & TouchData) => void\n end?: (wrapperEvent: { originalEvent: TouchEvent } & TouchData) => void\n move?: (wrapperEvent: { originalEvent: TouchEvent } & TouchData) => void\n left?: (wrapper: TouchData) => void\n right?: (wrapper: TouchData) => void\n up?: (wrapper: TouchData) => void\n down?: (wrapper: TouchData) => void\n}\n\nexport interface TouchData {\n touchstartX: number\n touchstartY: number\n touchmoveX: number\n touchmoveY: number\n touchendX: number\n touchendY: number\n offsetX: number\n offsetY: number\n}\n\nexport type TouchWrapper = TouchHandlers & TouchData\n\nexport interface TouchValue extends TouchHandlers {\n parent?: boolean\n options?: AddEventListenerOptions\n}\n\nexport interface TouchStoredHandlers {\n touchstart: (e: TouchEvent) => void\n touchend: (e: TouchEvent) => void\n touchmove: (e: TouchEvent) => void\n}\n\nexport interface TouchDirectiveBinding extends Omit<DirectiveBinding, 'value'> {\n value?: TouchValue\n}\n\nconst handleGesture = (wrapper: TouchWrapper) => {\n const { touchstartX, touchendX, touchstartY, touchendY } = wrapper\n const dirRatio = 0.5\n const minDistance = 16\n wrapper.offsetX = touchendX - touchstartX\n wrapper.offsetY = touchendY - touchstartY\n\n if (Math.abs(wrapper.offsetY) < dirRatio * Math.abs(wrapper.offsetX)) {\n wrapper.left && (touchendX < touchstartX - minDistance) && wrapper.left(wrapper)\n wrapper.right && (touchendX > touchstartX + minDistance) && wrapper.right(wrapper)\n }\n\n if (Math.abs(wrapper.offsetX) < dirRatio * Math.abs(wrapper.offsetY)) {\n wrapper.up && (touchendY < touchstartY - minDistance) && wrapper.up(wrapper)\n wrapper.down && (touchendY > touchstartY + minDistance) && wrapper.down(wrapper)\n }\n}\n\nfunction touchstart (event: TouchEvent, wrapper: TouchWrapper) {\n const touch = event.changedTouches[0]\n wrapper.touchstartX = touch.clientX\n wrapper.touchstartY = touch.clientY\n\n wrapper.start?.({ originalEvent: event, ...wrapper })\n}\n\nfunction touchend (event: TouchEvent, wrapper: TouchWrapper) {\n const touch = event.changedTouches[0]\n wrapper.touchendX = touch.clientX\n wrapper.touchendY = touch.clientY\n\n wrapper.end?.({ originalEvent: event, ...wrapper })\n\n handleGesture(wrapper)\n}\n\nfunction touchmove (event: TouchEvent, wrapper: TouchWrapper) {\n const touch = event.changedTouches[0]\n wrapper.touchmoveX = touch.clientX\n wrapper.touchmoveY = touch.clientY\n\n wrapper.move?.({ originalEvent: event, ...wrapper })\n}\n\nfunction createHandlers (value: TouchHandlers = {}): TouchStoredHandlers {\n const wrapper = {\n touchstartX: 0,\n touchstartY: 0,\n touchendX: 0,\n touchendY: 0,\n touchmoveX: 0,\n touchmoveY: 0,\n offsetX: 0,\n offsetY: 0,\n left: value.left,\n right: value.right,\n up: value.up,\n down: value.down,\n start: value.start,\n move: value.move,\n end: value.end,\n }\n\n return {\n touchstart: (e: TouchEvent) => touchstart(e, wrapper),\n touchend: (e: TouchEvent) => touchend(e, wrapper),\n touchmove: (e: TouchEvent) => touchmove(e, wrapper),\n }\n}\n\nfunction mounted (el: HTMLElement, binding: TouchDirectiveBinding) {\n const value = binding.value\n const target = value?.parent ? el.parentElement : el\n const options = value?.options ?? { passive: true }\n const uid = binding.instance?.$.uid // TODO: use custom uid generator\n\n if (!target || uid === undefined) return\n\n const handlers = createHandlers(binding.value)\n\n target._touchHandlers = target._touchHandlers ?? Object.create(null)\n target._touchHandlers![uid] = handlers\n\n keys(handlers).forEach(eventName => {\n target.addEventListener(eventName, handlers[eventName], options)\n })\n}\n\nfunction unmounted (el: HTMLElement, binding: TouchDirectiveBinding) {\n const target = binding.value?.parent ? el.parentElement : el\n const uid = binding.instance?.$.uid\n\n if (!target?._touchHandlers || uid === undefined) return\n\n const handlers = target._touchHandlers[uid]\n\n keys(handlers).forEach(eventName => Line truncated
|
||||
Reference in new issue
Block a user