This commit is contained in:
2022-07-21 03:28:35 +00:00
parent d7c883d6df
commit 51b34b0e1d
30103 changed files with 4152204 additions and 23 deletions
+78
View File
@@ -0,0 +1,78 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.ClickOutside = void 0;
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function defaultConditional() {
return true;
}
function directive(e, el, binding) {
var handler = typeof binding.value === 'function' ? binding.value : binding.value.handler;
var isActive = _typeof(binding.value) === 'object' && binding.value.closeConditional || defaultConditional; // 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 || isActive(e) === false) return; // If click was triggered programmaticaly (domEl.click()) then
// it shouldn't be treated as click-outside
// Chrome/Firefox support isTrusted property
// IE/Edge support pointerType property (empty if not triggered
// by pointing device)
if ('isTrusted' in e && !e.isTrusted || 'pointerType' in e && !e.pointerType) return; // Check if additional elements were passed to be included in check
// (click must be outside all included elements, if any)
var elements = (_typeof(binding.value) === 'object' && binding.value.include || function () {
return [];
})(); // 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.
!elements.some(function (el) {
return el.contains(e.target);
}) && setTimeout(function () {
isActive(e) && handler && handler(e);
}, 0);
}
var 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
inserted: function inserted(el, binding) {
var onClick = function onClick(e) {
return directive(e, el, binding);
}; // iOS does not recognize click events on document
// or body, this is the entire purpose of the v-app
// component and [data-app], stop removing this
var app = document.querySelector('[data-app]') || document.body; // This is only for unit tests
app.addEventListener('click', onClick, true);
el._clickOutside = onClick;
},
unbind: function unbind(el) {
if (!el._clickOutside) return;
var app = document.querySelector('[data-app]') || document.body; // This is only for unit tests
app && app.removeEventListener('click', el._clickOutside, true);
delete el._clickOutside;
}
};
exports.ClickOutside = ClickOutside;
var _default = ClickOutside;
exports.default = _default;
//# sourceMappingURL=index.js.map
File diff suppressed because one or more lines are too long
+71
View File
@@ -0,0 +1,71 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.Color = void 0;
var _colorUtils = require("../../util/colorUtils");
var _colors = _interopRequireDefault(require("../../util/colors"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// Utilities
function setTextColor(el, color, currentTheme) {
var cssColor = !(0, _colorUtils.isCssColor)(color) ? (0, _colorUtils.classToHex)(color, _colors.default, currentTheme) : color;
el.style.color = cssColor;
el.style.caretColor = cssColor;
}
function setBackgroundColor(el, color, currentTheme) {
var cssColor = !(0, _colorUtils.isCssColor)(color) ? (0, _colorUtils.classToHex)(color, _colors.default, currentTheme) : color;
el.style.backgroundColor = cssColor;
el.style.borderColor = cssColor;
}
function setBorderColor(el, color, currentTheme, modifiers) {
var cssColor = !(0, _colorUtils.isCssColor)(color) ? (0, _colorUtils.classToHex)(color, _colors.default, 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(".concat((0, _colorUtils.parseGradient)(gradient, _colors.default, currentTheme), ")");
}
function updateColor(el, binding, node) {
var 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);
}
var Color = {
bind: updateColor,
update: update
};
exports.Color = Color;
var _default = Color;
exports.default = _default;
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/directives/color/index.ts"],"names":[],"mappings":"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","sourcesContent":["// 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"],"sourceRoot":"","file":"index.js"}
+62
View File
@@ -0,0 +1,62 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "ClickOutside", {
enumerable: true,
get: function get() {
return _clickOutside.ClickOutside;
}
});
Object.defineProperty(exports, "Intersect", {
enumerable: true,
get: function get() {
return _intersect.Intersect;
}
});
Object.defineProperty(exports, "Mutate", {
enumerable: true,
get: function get() {
return _mutate.Mutate;
}
});
Object.defineProperty(exports, "Resize", {
enumerable: true,
get: function get() {
return _resize.Resize;
}
});
Object.defineProperty(exports, "Ripple", {
enumerable: true,
get: function get() {
return _ripple.Ripple;
}
});
Object.defineProperty(exports, "Scroll", {
enumerable: true,
get: function get() {
return _scroll.Scroll;
}
});
Object.defineProperty(exports, "Touch", {
enumerable: true,
get: function get() {
return _touch.Touch;
}
});
var _clickOutside = require("./click-outside");
var _intersect = require("./intersect");
var _mutate = require("./mutate");
var _resize = require("./resize");
var _ripple = require("./ripple");
var _scroll = require("./scroll");
var _touch = require("./touch");
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../src/directives/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["export { ClickOutside } from './click-outside'\nexport { Intersect } from './intersect'\nexport { Mutate } from './mutate'\nexport { Resize } from './resize'\nexport { Ripple } from './ripple'\nexport { Scroll } from './scroll'\nexport { Touch } from './touch'\n"],"sourceRoot":"","file":"index.js"}
+65
View File
@@ -0,0 +1,65 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.Intersect = void 0;
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function inserted(el, binding) {
var modifiers = binding.modifiers || {};
var value = binding.value;
var _ref = _typeof(value) === 'object' ? value : {
handler: value,
options: {}
},
handler = _ref.handler,
options = _ref.options;
var observer = new IntersectionObserver(function () {
var entries = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var observer = arguments.length > 1 ? arguments[1] : undefined;
/* istanbul ignore if */
if (!el._observe) return; // Just in case, should never fire
// If is not quiet or has already been
// initted, invoke the user callback
if (handler && (!modifiers.quiet || el._observe.init)) {
var isIntersecting = Boolean(entries.find(function (entry) {
return entry.isIntersecting;
}));
handler(entries, observer, isIntersecting);
} // If has already been initted and
// has the once modifier, unbind
if (el._observe.init && modifiers.once) unbind(el); // Otherwise, mark the observer as initted
else el._observe.init = true;
}, options);
el._observe = {
init: false,
observer: observer
};
observer.observe(el);
}
function unbind(el) {
/* istanbul ignore if */
if (!el._observe) return;
el._observe.observer.unobserve(el);
delete el._observe;
}
var Intersect = {
inserted: inserted,
unbind: unbind
};
exports.Intersect = Intersect;
var _default = Intersect;
exports.default = _default;
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/directives/intersect/index.ts"],"names":[],"mappings":";;;;;;;;;AAgBA,SAAS,QAAT,CAAmB,EAAnB,EAAoC,OAApC,EAAkE;AAChE,MAAM,SAAS,GAAG,OAAO,CAAC,SAAR,IAAqB,EAAvC;AACA,MAAM,KAAK,GAAG,OAAO,CAAC,KAAtB;;AAFgE,aAGnC,QAAO,KAAP,MAAiB,QAAjB,GACzB,KADyB,GAEzB;AAAE,IAAA,OAAO,EAAE,KAAX;AAAkB,IAAA,OAAO,EAAE;AAA3B,GAL4D;AAAA,MAGxD,OAHwD,QAGxD,OAHwD;AAAA,MAG/C,OAH+C,QAG/C,OAH+C;;AAMhE,MAAM,QAAQ,GAAG,IAAI,oBAAJ,CAAyB,YAGtC;AAAA,QAFF,OAEE,uEAFqC,EAErC;AAAA,QADF,QACE;;AACF;AACA,QAAI,CAAC,EAAE,CAAC,QAAR,EAAkB,OAFhB,CAEuB;AAEzB;AACA;;AACA,QACE,OAAO,KACL,CAAC,SAAS,CAAC,KAAX,IACA,EAAE,CAAC,QAAH,CAAY,IAFP,CADT,EAKE;AACA,UAAM,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,IAAR,CAAa,UAAA,KAAK;AAAA,eAAI,KAAK,CAAC,cAAV;AAAA,OAAlB,CAAD,CAA9B;AAEA,MAAA,OAAO,CAAC,OAAD,EAAU,QAAV,EAAoB,cAApB,CAAP;AACD,KAfC,CAiBF;AACA;;;AACA,QAAI,EAAE,CAAC,QAAH,CAAY,IAAZ,IAAoB,SAAS,CAAC,IAAlC,EAAwC,MAAM,CAAC,EAAD,CAAN,CAAxC,CACA;AADA,SAEM,EAAE,CAAC,QAAH,CAAY,IAAZ,GAAmB,IAApB;AACN,GAzBgB,EAyBd,OAzBc,CAAjB;AA2BA,EAAA,EAAE,CAAC,QAAH,GAAc;AAAE,IAAA,IAAI,EAAE,KAAR;AAAe,IAAA,QAAQ,EAAR;AAAf,GAAd;AAEA,EAAA,QAAQ,CAAC,OAAT,CAAiB,EAAjB;AACD;;AAED,SAAS,MAAT,CAAiB,EAAjB,EAAgC;AAC9B;AACA,MAAI,CAAC,EAAE,CAAC,QAAR,EAAkB;;AAElB,EAAA,EAAE,CAAC,QAAH,CAAY,QAAZ,CAAqB,SAArB,CAA+B,EAA/B;;AACA,SAAO,EAAE,CAAC,QAAV;AACD;;AAEM,IAAM,SAAS,GAAG;AACvB,EAAA,QAAQ,EAAR,QADuB;AAEvB,EAAA,MAAM,EAAN;AAFuB,CAAlB;;eAKQ,S","sourcesContent":["import { VNodeDirective } from 'vue/types/vnode'\n\ntype ObserveHandler = (\n entries: IntersectionObserverEntry[],\n observer: IntersectionObserver,\n isIntersecting: boolean,\n) => void\n\ninterface ObserveVNodeDirective extends Omit<VNodeDirective, 'modifiers'> {\n value?: ObserveHandler | { handler: ObserveHandler, options?: IntersectionObserverInit }\n modifiers?: {\n once?: boolean\n quiet?: boolean\n }\n}\n\nfunction inserted (el: HTMLElement, binding: ObserveVNodeDirective) {\n const modifiers = binding.modifiers || {}\n const value = binding.value\n const { handler, options } = typeof value === 'object'\n ? value\n : { handler: value, options: {} }\n const observer = new IntersectionObserver((\n entries: IntersectionObserverEntry[] = [],\n observer: IntersectionObserver\n ) => {\n /* istanbul ignore if */\n if (!el._observe) return // Just in case, should never fire\n\n // If is not quiet or has already been\n // initted, invoke the user callback\n if (\n handler && (\n !modifiers.quiet ||\n el._observe.init\n )\n ) {\n const isIntersecting = Boolean(entries.find(entry => entry.isIntersecting))\n\n handler(entries, observer, isIntersecting)\n }\n\n // If has already been initted and\n // has the once modifier, unbind\n if (el._observe.init && modifiers.once) unbind(el)\n // Otherwise, mark the observer as initted\n else (el._observe.init = true)\n }, options)\n\n el._observe = { init: false, observer }\n\n observer.observe(el)\n}\n\nfunction unbind (el: HTMLElement) {\n /* istanbul ignore if */\n if (!el._observe) return\n\n el._observe.observer.unobserve(el)\n delete el._observe\n}\n\nexport const Intersect = {\n inserted,\n unbind,\n}\n\nexport default Intersect\n"],"sourceRoot":"","file":"index.js"}
+67
View File
@@ -0,0 +1,67 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.Mutate = void 0;
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function inserted(el, binding) {
var modifiers = binding.modifiers || {};
var value = binding.value;
var callback = _typeof(value) === 'object' ? value.handler : value;
var once = modifiers.once,
modifierKeys = _objectWithoutProperties(modifiers, ["once"]);
var hasModifiers = Object.keys(modifierKeys).length > 0; // Options take top priority
var options = _typeof(value) === 'object' && value.options ? value.options : hasModifiers // If we have modifiers, use only those provided
? {
attributes: modifierKeys.attr,
childList: modifierKeys.child,
subtree: modifierKeys.sub,
characterData: modifierKeys.char // Defaults to everything on
} : {
attributes: true,
childList: true,
subtree: true,
characterData: true
};
var observer = new MutationObserver(function (mutationsList, observer) {
/* istanbul ignore if */
if (!el._mutate) return; // Just in case, should never fire
callback(mutationsList, observer); // If has the once modifier, unbind
once && unbind(el);
});
observer.observe(el, options);
el._mutate = {
observer: observer
};
}
function unbind(el) {
/* istanbul ignore if */
if (!el._mutate) return;
el._mutate.observer.disconnect();
delete el._mutate;
}
var Mutate = {
inserted: inserted,
unbind: unbind
};
exports.Mutate = Mutate;
var _default = Mutate;
exports.default = _default;
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/directives/mutate/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAkBA,SAAS,QAAT,CAAmB,EAAnB,EAAoC,OAApC,EAAiE;AAC/D,MAAM,SAAS,GAAG,OAAO,CAAC,SAAR,IAAqB,EAAvC;AACA,MAAM,KAAK,GAAG,OAAO,CAAC,KAAtB;AACA,MAAM,QAAQ,GAAG,QAAO,KAAP,MAAiB,QAAjB,GAA4B,KAAK,CAAC,OAAlC,GAA4C,KAA7D;;AAH+D,MAIvD,IAJuD,GAI7B,SAJ6B,CAIvD,IAJuD;AAAA,MAI9C,YAJ8C,4BAI7B,SAJ6B;;AAK/D,MAAM,YAAY,GAAG,MAAM,CAAC,IAAP,CAAY,YAAZ,EAA0B,MAA1B,GAAmC,CAAxD,CAL+D,CAO/D;;AACA,MAAM,OAAO,GAAG,QAAO,KAAP,MAAiB,QAAjB,IAA6B,KAAK,CAAC,OAAnC,GACZ,KAAK,CAAC,OADM,GAEZ,YAAY,CACZ;AADY,IAEV;AACA,IAAA,UAAU,EAAE,YAAY,CAAC,IADzB;AAEA,IAAA,SAAS,EAAE,YAAY,CAAC,KAFxB;AAGA,IAAA,OAAO,EAAE,YAAY,CAAC,GAHtB;AAIA,IAAA,aAAa,EAAE,YAAY,CAAC,IAJ5B,CAMF;;AANE,GAFU,GASV;AACA,IAAA,UAAU,EAAE,IADZ;AAEA,IAAA,SAAS,EAAE,IAFX;AAGA,IAAA,OAAO,EAAE,IAHT;AAIA,IAAA,aAAa,EAAE;AAJf,GAXN;AAkBA,MAAM,QAAQ,GAAG,IAAI,gBAAJ,CAAqB,UACpC,aADoC,EAEpC,QAFoC,EAGlC;AACF;AACA,QAAI,CAAC,EAAE,CAAC,OAAR,EAAiB,OAFf,CAEsB;;AAExB,IAAA,QAAQ,CAAC,aAAD,EAAgB,QAAhB,CAAR,CAJE,CAMF;;AACA,IAAA,IAAI,IAAI,MAAM,CAAC,EAAD,CAAd;AACD,GAXgB,CAAjB;AAaA,EAAA,QAAQ,CAAC,OAAT,CAAiB,EAAjB,EAAqB,OAArB;AACA,EAAA,EAAE,CAAC,OAAH,GAAa;AAAE,IAAA,QAAQ,EAAR;AAAF,GAAb;AACD;;AAED,SAAS,MAAT,CAAiB,EAAjB,EAAgC;AAC9B;AACA,MAAI,CAAC,EAAE,CAAC,OAAR,EAAiB;;AAEjB,EAAA,EAAE,CAAC,OAAH,CAAW,QAAX,CAAoB,UAApB;;AACA,SAAO,EAAE,CAAC,OAAV;AACD;;AAEM,IAAM,MAAM,GAAG;AACpB,EAAA,QAAQ,EAAR,QADoB;AAEpB,EAAA,MAAM,EAAN;AAFoB,CAAf;;eAKQ,M","sourcesContent":["import { VNodeDirective } from 'vue'\n\ntype MutateHandler = (\n mutationsList: MutationRecord[],\n observer: MutationObserver,\n) => void\n\ninterface MutateVNodeDirective extends Omit<VNodeDirective, 'modifiers'> {\n value?: MutateHandler | { handler: MutateHandler, options?: MutationObserverInit }\n modifiers?: {\n once?: boolean\n attr?: boolean\n child?: boolean\n sub?: boolean\n char?: boolean\n }\n}\n\nfunction inserted (el: HTMLElement, binding: MutateVNodeDirective) {\n const modifiers = binding.modifiers || {}\n const value = binding.value\n const callback = typeof value === 'object' ? value.handler : value!\n const { once, ...modifierKeys } = modifiers\n const hasModifiers = Object.keys(modifierKeys).length > 0\n\n // Options take top priority\n const options = typeof value === 'object' && value.options\n ? value.options\n : hasModifiers\n // If we have modifiers, use only those provided\n ? {\n attributes: modifierKeys.attr,\n childList: modifierKeys.child,\n subtree: modifierKeys.sub,\n characterData: modifierKeys.char,\n }\n // Defaults to everything on\n : {\n attributes: true,\n childList: true,\n subtree: true,\n characterData: true,\n }\n\n const observer = new MutationObserver((\n mutationsList: MutationRecord[],\n observer: MutationObserver\n ) => {\n /* istanbul ignore if */\n if (!el._mutate) return // Just in case, should never fire\n\n callback(mutationsList, observer)\n\n // If has the once modifier, unbind\n once && unbind(el)\n })\n\n observer.observe(el, options)\n el._mutate = { observer }\n}\n\nfunction unbind (el: HTMLElement) {\n /* istanbul ignore if */\n if (!el._mutate) return\n\n el._mutate.observer.disconnect()\n delete el._mutate\n}\n\nexport const Mutate = {\n inserted,\n unbind,\n}\n\nexport default Mutate\n"],"sourceRoot":"","file":"index.js"}
+40
View File
@@ -0,0 +1,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.Resize = void 0;
function inserted(el, binding) {
var callback = binding.value;
var options = binding.options || {
passive: true
};
window.addEventListener('resize', callback, options);
el._onResize = {
callback: callback,
options: options
};
if (!binding.modifiers || !binding.modifiers.quiet) {
callback();
}
}
function unbind(el) {
if (!el._onResize) return;
var _el$_onResize = el._onResize,
callback = _el$_onResize.callback,
options = _el$_onResize.options;
window.removeEventListener('resize', callback, options);
delete el._onResize;
}
var Resize = {
inserted: inserted,
unbind: unbind
};
exports.Resize = Resize;
var _default = Resize;
exports.default = _default;
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/directives/resize/index.ts"],"names":[],"mappings":";;;;;;;AAOA,SAAS,QAAT,CAAmB,EAAnB,EAAoC,OAApC,EAAiE;AAC/D,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAzB;AACA,MAAM,OAAO,GAAG,OAAO,CAAC,OAAR,IAAmB;AAAE,IAAA,OAAO,EAAE;AAAX,GAAnC;AAEA,EAAA,MAAM,CAAC,gBAAP,CAAwB,QAAxB,EAAkC,QAAlC,EAA4C,OAA5C;AACA,EAAA,EAAE,CAAC,SAAH,GAAe;AACb,IAAA,QAAQ,EAAR,QADa;AAEb,IAAA,OAAO,EAAP;AAFa,GAAf;;AAKA,MAAI,CAAC,OAAO,CAAC,SAAT,IAAsB,CAAC,OAAO,CAAC,SAAR,CAAkB,KAA7C,EAAoD;AAClD,IAAA,QAAQ;AACT;AACF;;AAED,SAAS,MAAT,CAAiB,EAAjB,EAAgC;AAC9B,MAAI,CAAC,EAAE,CAAC,SAAR,EAAmB;AADW,sBAGA,EAAE,CAAC,SAHH;AAAA,MAGtB,QAHsB,iBAGtB,QAHsB;AAAA,MAGZ,OAHY,iBAGZ,OAHY;AAI9B,EAAA,MAAM,CAAC,mBAAP,CAA2B,QAA3B,EAAqC,QAArC,EAA+C,OAA/C;AACA,SAAO,EAAE,CAAC,SAAV;AACD;;AAEM,IAAM,MAAM,GAAG;AACpB,EAAA,QAAQ,EAAR,QADoB;AAEpB,EAAA,MAAM,EAAN;AAFoB,CAAf;;eAKQ,M","sourcesContent":["import { VNodeDirective } from 'vue/types/vnode'\n\ninterface ResizeVNodeDirective extends VNodeDirective {\n value?: () => void\n options?: boolean | AddEventListenerOptions\n}\n\nfunction inserted (el: HTMLElement, binding: ResizeVNodeDirective) {\n const callback = binding.value!\n const options = binding.options || { passive: true }\n\n window.addEventListener('resize', callback, options)\n el._onResize = {\n callback,\n options,\n }\n\n if (!binding.modifiers || !binding.modifiers.quiet) {\n callback()\n }\n}\n\nfunction unbind (el: HTMLElement) {\n if (!el._onResize) return\n\n const { callback, options } = el._onResize\n window.removeEventListener('resize', callback, options)\n delete el._onResize\n}\n\nexport const Resize = {\n inserted,\n unbind,\n}\n\nexport default Resize\n"],"sourceRoot":"","file":"index.js"}
+344
View File
@@ -0,0 +1,344 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.Ripple = void 0;
require("../../../src/directives/ripple/VRipple.sass");
var _console = require("../../util/console");
var _helpers = require("../../util/helpers");
// Styles
// Utilities
var DELAY_RIPPLE = 80;
function transform(el, value) {
el.style['transform'] = value;
el.style['webkitTransform'] = value;
}
function opacity(el, value) {
el.style['opacity'] = value.toString();
}
function isTouchEvent(e) {
return e.constructor.name === 'TouchEvent';
}
function isKeyboardEvent(e) {
return e.constructor.name === 'KeyboardEvent';
}
var calculate = function calculate(e, el) {
var value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var localX = 0;
var localY = 0;
if (!isKeyboardEvent(e)) {
var offset = el.getBoundingClientRect();
var target = isTouchEvent(e) ? e.touches[e.touches.length - 1] : e;
localX = target.clientX - offset.left;
localY = target.clientY - offset.top;
}
var radius = 0;
var scale = 0.3;
if (el._ripple && el._ripple.circle) {
scale = 0.15;
radius = el.clientWidth / 2;
radius = value.center ? radius : radius + Math.sqrt(Math.pow(localX - radius, 2) + Math.pow(localY - radius, 2)) / 4;
} else {
radius = Math.sqrt(Math.pow(el.clientWidth, 2) + Math.pow(el.clientHeight, 2)) / 2;
}
var centerX = "".concat((el.clientWidth - radius * 2) / 2, "px");
var centerY = "".concat((el.clientHeight - radius * 2) / 2, "px");
var x = value.center ? centerX : "".concat(localX - radius, "px");
var y = value.center ? centerY : "".concat(localY - radius, "px");
return {
radius: radius,
scale: scale,
x: x,
y: y,
centerX: centerX,
centerY: centerY
};
};
var ripples = {
/* eslint-disable max-statements */
show: function show(e, el) {
var value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
if (!el._ripple || !el._ripple.enabled) {
return;
}
var container = document.createElement('span');
var animation = document.createElement('span');
container.appendChild(animation);
container.className = 'v-ripple__container';
if (value.class) {
container.className += " ".concat(value.class);
}
var _calculate = calculate(e, el, value),
radius = _calculate.radius,
scale = _calculate.scale,
x = _calculate.x,
y = _calculate.y,
centerX = _calculate.centerX,
centerY = _calculate.centerY;
var size = "".concat(radius * 2, "px");
animation.className = 'v-ripple__animation';
animation.style.width = size;
animation.style.height = size;
el.appendChild(container);
var 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(".concat(x, ", ").concat(y, ") scale3d(").concat(scale, ",").concat(scale, ",").concat(scale, ")"));
opacity(animation, 0);
animation.dataset.activated = String(performance.now());
setTimeout(function () {
animation.classList.remove('v-ripple__animation--enter');
animation.classList.add('v-ripple__animation--in');
transform(animation, "translate(".concat(centerX, ", ").concat(centerY, ") scale3d(1,1,1)"));
opacity(animation, 0.25);
}, 0);
},
hide: function hide(el) {
if (!el || !el._ripple || !el._ripple.enabled) return;
var ripples = el.getElementsByClassName('v-ripple__animation');
if (ripples.length === 0) return;
var animation = ripples[ripples.length - 1];
if (animation.dataset.isHiding) return;else animation.dataset.isHiding = 'true';
var diff = performance.now() - Number(animation.dataset.activated);
var delay = Math.max(250 - diff, 0);
setTimeout(function () {
animation.classList.remove('v-ripple__animation--in');
animation.classList.add('v-ripple__animation--out');
opacity(animation, 0);
setTimeout(function () {
var ripples = el.getElementsByClassName('v-ripple__animation');
if (ripples.length === 1 && el.dataset.previousPosition) {
el.style.position = el.dataset.previousPosition;
delete el.dataset.previousPosition;
}
animation.parentNode && el.removeChild(animation.parentNode);
}, 300);
}, delay);
}
};
function isRippleEnabled(value) {
return typeof value === 'undefined' || !!value;
}
function rippleShow(e) {
var value = {};
var element = e.currentTarget;
if (!element || !element._ripple || element._ripple.touched) return;
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 = function () {
ripples.show(e, element, value);
};
element._ripple.showTimer = window.setTimeout(function () {
if (element && element._ripple && element._ripple.showTimerCommit) {
element._ripple.showTimerCommit();
element._ripple.showTimerCommit = null;
}
}, DELAY_RIPPLE);
} else {
ripples.show(e, element, value);
}
}
function rippleHide(e) {
var element = e.currentTarget;
if (!element || !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 = setTimeout(function () {
rippleHide(e);
});
return;
}
window.setTimeout(function () {
if (element._ripple) {
element._ripple.touched = false;
}
});
ripples.hide(element);
}
function rippleCancelShow(e) {
var element = e.currentTarget;
if (!element || !element._ripple) return;
if (element._ripple.showTimerCommit) {
element._ripple.showTimerCommit = null;
}
window.clearTimeout(element._ripple.showTimer);
}
var keyboardRipple = false;
function keyboardRippleShow(e) {
if (!keyboardRipple && (e.keyCode === _helpers.keyCodes.enter || e.keyCode === _helpers.keyCodes.space)) {
keyboardRipple = true;
rippleShow(e);
}
}
function keyboardRippleHide(e) {
keyboardRipple = false;
rippleHide(e);
}
function updateRipple(el, binding, wasEnabled) {
var enabled = isRippleEnabled(binding.value);
if (!enabled) {
ripples.hide(el);
}
el._ripple = el._ripple || {};
el._ripple.enabled = enabled;
var value = binding.value || {};
if (value.center) {
el._ripple.centered = true;
}
if (value.class) {
el._ripple.class = binding.value.class;
}
if (value.circle) {
el._ripple.circle = value.circle;
}
if (enabled && !wasEnabled) {
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', keyboardRippleShow);
el.addEventListener('keyup', keyboardRippleHide); // 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('mousedown', rippleShow);
el.removeEventListener('touchstart', rippleShow);
el.removeEventListener('touchend', rippleHide);
el.removeEventListener('touchmove', rippleCancelShow);
el.removeEventListener('touchcancel', rippleHide);
el.removeEventListener('mouseup', rippleHide);
el.removeEventListener('mouseleave', rippleHide);
el.removeEventListener('keydown', keyboardRippleShow);
el.removeEventListener('keyup', keyboardRippleHide);
el.removeEventListener('dragstart', rippleHide);
}
function directive(el, binding, node) {
updateRipple(el, binding, false);
if (process.env.NODE_ENV === 'development') {
// warn if an inline element is used, waiting for el to be in the DOM first
node.context && node.context.$nextTick(function () {
var computed = window.getComputedStyle(el);
if (computed && computed.display === 'inline') {
var context = node.fnOptions ? [node.fnOptions, node.context] : [node.componentInstance];
_console.consoleWarn.apply(void 0, ['v-ripple can only be used on block-level elements'].concat(context));
}
});
}
}
function unbind(el) {
delete el._ripple;
removeListeners(el);
}
function update(el, binding) {
if (binding.value === binding.oldValue) {
return;
}
var wasEnabled = isRippleEnabled(binding.oldValue);
updateRipple(el, binding, wasEnabled);
}
var Ripple = {
bind: directive,
unbind: unbind,
update: update
};
exports.Ripple = Ripple;
var _default = Ripple;
exports.default = _default;
//# sourceMappingURL=index.js.map
File diff suppressed because one or more lines are too long
+49
View File
@@ -0,0 +1,49 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.Scroll = void 0;
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function inserted(el, binding) {
var _ref = binding.modifiers || {},
_ref$self = _ref.self,
self = _ref$self === void 0 ? false : _ref$self;
var value = binding.value;
var options = _typeof(value) === 'object' && value.options || {
passive: true
};
var handler = typeof value === 'function' || 'handleEvent' in value ? value : value.handler;
var target = self ? el : binding.arg ? document.querySelector(binding.arg) : window;
if (!target) return;
target.addEventListener('scroll', handler, options);
el._onScroll = {
handler: handler,
options: options,
// Don't reference self
target: self ? undefined : target
};
}
function unbind(el) {
if (!el._onScroll) return;
var _el$_onScroll = el._onScroll,
handler = _el$_onScroll.handler,
options = _el$_onScroll.options,
_el$_onScroll$target = _el$_onScroll.target,
target = _el$_onScroll$target === void 0 ? el : _el$_onScroll$target;
target.removeEventListener('scroll', handler, options);
delete el._onScroll;
}
var Scroll = {
inserted: inserted,
unbind: unbind
};
exports.Scroll = Scroll;
var _default = Scroll;
exports.default = _default;
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/directives/scroll/index.ts"],"names":[],"mappings":";;;;;;;;;AAaA,SAAS,QAAT,CAAmB,EAAnB,EAAoC,OAApC,EAAiE;AAAA,aACtC,OAAO,CAAC,SAAR,IAAqB,EADiB;AAAA,uBACvD,IADuD;AAAA,MACvD,IADuD,0BAChD,KADgD;;AAE/D,MAAM,KAAK,GAAG,OAAO,CAAC,KAAtB;AACA,MAAM,OAAO,GAAI,QAAO,KAAP,MAAiB,QAAjB,IAA6B,KAAK,CAAC,OAApC,IAAgD;AAAE,IAAA,OAAO,EAAE;AAAX,GAAhE;AACA,MAAM,OAAO,GAAG,OAAO,KAAP,KAAiB,UAAjB,IAA+B,iBAAiB,KAAhD,GAAwD,KAAxD,GAAgE,KAAK,CAAC,OAAtF;AAEA,MAAM,MAAM,GAAG,IAAI,GACf,EADe,GAEf,OAAO,CAAC,GAAR,GACE,QAAQ,CAAC,aAAT,CAAuB,OAAO,CAAC,GAA/B,CADF,GAEE,MAJN;AAMA,MAAI,CAAC,MAAL,EAAa;AAEb,EAAA,MAAM,CAAC,gBAAP,CAAwB,QAAxB,EAAkC,OAAlC,EAA2C,OAA3C;AAEA,EAAA,EAAE,CAAC,SAAH,GAAe;AACb,IAAA,OAAO,EAAP,OADa;AAEb,IAAA,OAAO,EAAP,OAFa;AAGb;AACA,IAAA,MAAM,EAAE,IAAI,GAAG,SAAH,GAAe;AAJd,GAAf;AAMD;;AAED,SAAS,MAAT,CAAiB,EAAjB,EAAgC;AAC9B,MAAI,CAAC,EAAE,CAAC,SAAR,EAAmB;AADW,sBAGY,EAAE,CAAC,SAHf;AAAA,MAGtB,OAHsB,iBAGtB,OAHsB;AAAA,MAGb,OAHa,iBAGb,OAHa;AAAA,2CAGJ,MAHI;AAAA,MAGJ,MAHI,qCAGK,EAHL;AAK9B,EAAA,MAAM,CAAC,mBAAP,CAA2B,QAA3B,EAAqC,OAArC,EAA8C,OAA9C;AACA,SAAO,EAAE,CAAC,SAAV;AACD;;AAEM,IAAM,MAAM,GAAG;AACpB,EAAA,QAAQ,EAAR,QADoB;AAEpB,EAAA,MAAM,EAAN;AAFoB,CAAf;;eAKQ,M","sourcesContent":["import { VNodeDirective } from 'vue/types/vnode'\nimport { DirectiveOptions } from 'vue'\n\ninterface ScrollVNodeDirective extends Omit<VNodeDirective, 'modifiers'> {\n value: EventListener | {\n handler: EventListener\n options?: boolean | AddEventListenerOptions\n } | EventListenerObject & { options?: boolean | AddEventListenerOptions }\n modifiers?: {\n self?: boolean\n }\n}\n\nfunction inserted (el: HTMLElement, binding: ScrollVNodeDirective) {\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 = {\n handler,\n options,\n // Don't reference self\n target: self ? undefined : target,\n }\n}\n\nfunction unbind (el: HTMLElement) {\n if (!el._onScroll) return\n\n const { handler, options, target = el } = el._onScroll\n\n target.removeEventListener('scroll', handler, options)\n delete el._onScroll\n}\n\nexport const Scroll = {\n inserted,\n unbind,\n} as DirectiveOptions\n\nexport default Scroll\n"],"sourceRoot":"","file":"index.js"}
+117
View File
@@ -0,0 +1,117 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.Touch = void 0;
var _helpers = require("../../util/helpers");
var handleGesture = function handleGesture(wrapper) {
var touchstartX = wrapper.touchstartX,
touchendX = wrapper.touchendX,
touchstartY = wrapper.touchstartY,
touchendY = wrapper.touchendY;
var dirRatio = 0.5;
var 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) {
var touch = event.changedTouches[0];
wrapper.touchstartX = touch.clientX;
wrapper.touchstartY = touch.clientY;
wrapper.start && wrapper.start(Object.assign(event, wrapper));
}
function _touchend(event, wrapper) {
var touch = event.changedTouches[0];
wrapper.touchendX = touch.clientX;
wrapper.touchendY = touch.clientY;
wrapper.end && wrapper.end(Object.assign(event, wrapper));
handleGesture(wrapper);
}
function _touchmove(event, wrapper) {
var touch = event.changedTouches[0];
wrapper.touchmoveX = touch.clientX;
wrapper.touchmoveY = touch.clientY;
wrapper.move && wrapper.move(Object.assign(event, wrapper));
}
function createHandlers(value) {
var 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: function touchstart(e) {
return _touchstart(e, wrapper);
},
touchend: function touchend(e) {
return _touchend(e, wrapper);
},
touchmove: function touchmove(e) {
return _touchmove(e, wrapper);
}
};
}
function inserted(el, binding, vnode) {
var value = binding.value;
var target = value.parent ? el.parentElement : el;
var options = value.options || {
passive: true
}; // Needed to pass unit tests
if (!target) return;
var handlers = createHandlers(binding.value);
target._touchHandlers = Object(target._touchHandlers);
target._touchHandlers[vnode.context._uid] = handlers;
(0, _helpers.keys)(handlers).forEach(function (eventName) {
target.addEventListener(eventName, handlers[eventName], options);
});
}
function unbind(el, binding, vnode) {
var target = binding.value.parent ? el.parentElement : el;
if (!target || !target._touchHandlers) return;
var handlers = target._touchHandlers[vnode.context._uid];
(0, _helpers.keys)(handlers).forEach(function (eventName) {
target.removeEventListener(eventName, handlers[eventName]);
});
delete target._touchHandlers[vnode.context._uid];
}
var Touch = {
inserted: inserted,
unbind: unbind
};
exports.Touch = Touch;
var _default = Touch;
exports.default = _default;
//# sourceMappingURL=index.js.map
File diff suppressed because one or more lines are too long