Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

polythene-core

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

polythene-core - npm Package Compare versions

Comparing version 1.3.3 to 1.4.0

716

dist/polythene-core.js

@@ -1,716 +0,2 @@

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.polythene = {})));
}(this, (function (exports) { 'use strict';
var isClient = typeof document !== "undefined";
var isServer = !isClient;
var evts = {
"animation": "animationend",
"OAnimation": "oAnimationEnd",
"MozAnimation": "animationend",
"WebkitAnimation": "webkitAnimationEnd"
};
var getAnimationEndEvent = function getAnimationEndEvent() {
if (isClient) {
var el = document.createElement("fakeelement");
for (var a in evts) {
if (el.style[a] !== undefined) {
return evts[a];
}
}
}
};
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var modes = {
hidden: "hidden",
visible: "visible",
exposing: "exposing",
hiding: "hiding"
};
var Conditional = {
getInitialState: function getInitialState(vnode, createStream) {
var attrs = vnode.attrs;
if (!attrs.didHide) {
return {};
}
var visible = attrs.permanent || attrs.show;
var mode = createStream(attrs.permanent ? modes.visible : visible ? modes.visible : modes.hidden);
return {
mode: mode,
redrawOnUpdate: createStream.merge([mode])
};
},
onUpdate: function onUpdate(_ref) {
var state = _ref.state,
attrs = _ref.attrs;
if (!attrs.didHide) {
return;
}
var mode = state.mode();
if (attrs.permanent) {
if (mode === modes.visible && attrs.show) {
state.mode(modes.exposing);
} else if (mode === modes.exposing && !attrs.show) {
state.mode(modes.hiding);
}
} else {
// "normal" type
if (mode === modes.hidden && attrs.show) {
state.mode(modes.visible);
} else if (mode === modes.visible && !attrs.show) {
state.mode(modes.hiding);
}
}
},
view: function view(_ref2, _ref3) {
var state = _ref2.state,
attrs = _ref2.attrs;
var h = _ref3.renderer;
var placeholder = h("span", { className: attrs.placeholderClassName });
// No didHide callback passed: use normal visibility evaluation
if (!attrs.didHide) {
return attrs.permanent || attrs.inactive || attrs.show ? h(attrs.instance, attrs) : placeholder;
}
// else: use didHide to reset the state after hiding
var mode = state.mode();
var visible = mode !== modes.hidden;
return visible ? h(attrs.instance, _extends({}, attrs, {
didHide: function didHide(args) {
return attrs.didHide(args), state.mode(attrs.permanent ? modes.visible : modes.hidden);
}
}, mode === modes.hiding && {
show: true,
hide: true
})) : placeholder;
}
};
Conditional.displayName = "Conditional";
var r = function r(acc, p) {
return acc[p] = 1, acc;
};
/*
Separately handled props:
- class
- element
*/
var defaultAttrs = [
// Universal
"key", "style", "href", "id",
// React
"tabIndex",
// Mithril
"tabindex", "oninit", "oncreate", "onupdate", "onbeforeremove", "onremove", "onbeforeupdate"];
var filterSupportedAttributes = function filterSupportedAttributes(attrs) {
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref$add = _ref.add,
addAttrs = _ref$add === undefined ? [] : _ref$add,
_ref$remove = _ref.remove,
removeAttrs = _ref$remove === undefined ? [] : _ref$remove;
var removeLookup = removeAttrs.reduce(r, {});
var supported = defaultAttrs.concat(addAttrs).filter(function (item) {
return !removeLookup[item];
}).reduce(r, {});
return Object.keys(attrs).reduce(function (acc, key) {
return supported[key] ? acc[key] = attrs[key] : null, acc;
}, {});
};
var unpackAttrs = function unpackAttrs(attrs) {
return typeof attrs === "function" ? attrs() : attrs;
};
var sizeClasses = function sizeClasses(classes) {
return {
small: classes.small,
regular: classes.regular,
medium: classes.medium,
large: classes.large,
fab: classes.fab
};
};
var classForSize = function classForSize(classes) {
var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "regular";
return sizeClasses(classes)[size];
};
var isTouch = isServer ? false : "ontouchstart" in document.documentElement;
var pointerStartEvent = isTouch ? ["touchstart", "click"] : ["click"];
var pointerEndEvent = isTouch ? ["click", "mouseup"] : ["mouseup"];
var pointerStartMoveEvent = isTouch ? ["touchstart", "mousedown"] : ["mousedown"];
var pointerMoveEvent = isTouch ? ["touchmove", "mousemove"] : ["mousemove"];
var pointerEndMoveEvent = isTouch ? ["touchend", "mouseup"] : ["mouseup"];
if (isClient) {
document.querySelector("html").classList.add(isTouch ? "pe-touch" : "pe-no-touch");
}
var listeners = {};
// https://gist.github.com/Eartz/fe651f2fadcc11444549
var throttle = function throttle(func) {
var s = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.05;
var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : isClient ? window : {};
var wait = false;
return function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var later = function later() {
return func.apply(context, args);
};
if (!wait) {
later();
wait = true;
setTimeout(function () {
return wait = false;
}, s);
}
};
};
var subscribe = function subscribe(eventName, listener, delay) {
listeners[eventName] = listeners[eventName] || [];
listeners[eventName].push(delay ? throttle(listener, delay) : listener);
};
var unsubscribe = function unsubscribe(eventName, listener) {
if (!listeners[eventName]) {
return;
}
var index = listeners[eventName].indexOf(listener);
if (index > -1) {
listeners[eventName].splice(index, 1);
}
};
var emit = function emit(eventName, event) {
if (!listeners[eventName]) {
return;
}
listeners[eventName].forEach(function (listener) {
return listener(event);
});
};
if (isClient) {
window.addEventListener("resize", function (e) {
return emit("resize", e);
});
window.addEventListener("scroll", function (e) {
return emit("scroll", e);
});
window.addEventListener("keydown", function (e) {
return emit("keydown", e);
});
window.addEventListener(pointerEndEvent, function (e) {
return emit(pointerEndEvent, e);
});
}
var _extends$1 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var Multi = function Multi(_ref) {
var mOptions = _ref.options,
renderer = _ref.renderer;
var items = []; // This is shared between all instances of a type (Dialog, Notification, ...)
var current = void 0;
var getInitialState = function getInitialState(vnode, createStream) {
current = createStream(null);
return {
current: current,
redrawOnUpdate: createStream.merge([current])
};
};
/*
@param e: { id, eventName }
*/
var onChange = function onChange(e) {
if (!current) {
console.error("Cannot set state. Did you set a root element like Dialog to show instances?"); // eslint-disable-line no-console
}
current(e.id);
emit(mOptions.name, e);
};
var itemIndex = function itemIndex(id) {
var item = findItem(id);
return items.indexOf(item);
};
var removeItem = function removeItem(id) {
var index = itemIndex(id);
if (index !== -1) {
items.splice(index, 1);
onChange({ id: id, name: "removeItem" });
}
};
var replaceItem = function replaceItem(id, newItem) {
var index = itemIndex(id);
if (index !== -1) {
items[index] = newItem;
}
};
var findItem = function findItem(id) {
// traditional for loop for IE10
for (var i = 0; i < items.length; i++) {
if (items[i].instanceId === id) {
return items[i];
}
}
};
var next = function next() {
if (items.length) {
items[0].show = true;
}
onChange({ id: items.length ? items[0].instanceId : null, name: "next" });
};
var remove = function remove() {
var instanceId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : mOptions.defaultId;
if (mOptions.queue) {
items.shift();
next();
} else {
removeItem(instanceId);
}
};
var removeAll = function removeAll() {
items.length = 0;
onChange({ id: null, name: "removeAll" });
};
var setPauseState = function setPauseState(pause, instanceId) {
var item = findItem(instanceId);
if (item) {
item.pause = pause;
item.unpause = !pause;
onChange({ id: instanceId, name: pause ? "pause" : "unpause" });
}
};
var createItem = function createItem(itemAttrs, instanceId, spawn) {
var resolveShow = void 0;
var resolveHide = void 0;
var attrs = unpackAttrs(itemAttrs);
var didShow = function didShow() {
if (attrs.didShow) {
attrs.didShow(instanceId);
}
onChange({ id: instanceId, name: "didShow" });
return resolveShow(instanceId);
};
var showPromise = new Promise(function (resolve) {
return resolveShow = resolve;
});
var didHide = function didHide() {
if (attrs.didHide) {
attrs.didHide(instanceId);
}
onChange({ id: instanceId, name: "didHide" });
remove(instanceId);
return resolveHide(instanceId);
};
var hidePromise = new Promise(function (resolve) {
return resolveHide = resolve;
});
return _extends$1({}, mOptions, {
instanceId: instanceId,
spawn: spawn,
attrs: itemAttrs,
show: mOptions.queue ? false : true,
showPromise: showPromise,
hidePromise: hidePromise,
didShow: didShow,
didHide: didHide
});
};
var count = function count() {
return items.length;
};
var pause = function pause() {
var instanceId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : mOptions.defaultId;
return setPauseState(true, instanceId);
};
var unpause = function unpause() {
var instanceId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : mOptions.defaultId;
return setPauseState(false, instanceId);
};
var show = function show() {
var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var spawnOpts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var instanceId = spawnOpts.id || mOptions.defaultId;
var spawn = spawnOpts.spawn || mOptions.defaultId;
var item = createItem(attrs, instanceId, spawn);
onChange({ id: instanceId, name: "show" });
if (mOptions.queue) {
items.push(item);
if (items.length === 1) {
next();
}
} else {
var storedItem = findItem(instanceId);
if (!storedItem) {
items.push(item);
} else {
replaceItem(instanceId, item);
}
}
return item.showPromise;
};
var hide = function hide() {
var spawnOpts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var instanceId = spawnOpts.id || mOptions.defaultId;
var item = mOptions.queue && items.length ? items[0] : findItem(instanceId);
if (item) {
item.hide = true;
}
onChange({ id: instanceId, name: "hide" });
return item ? item.hidePromise : Promise.resolve(instanceId);
};
var clear = removeAll;
var view = function view(_ref2) {
var attrs = _ref2.attrs;
var spawn = attrs.spawn || mOptions.defaultId;
var candidates = items.filter(function (item) {
return item.show && item.spawn === spawn;
});
if (mOptions.htmlShowClass && isClient && document.documentElement) {
document.documentElement.classList[candidates.length ? "add" : "remove"](mOptions.htmlShowClass);
}
return !candidates.length ? renderer(mOptions.placeholder) // placeholder because we cannot return null
: renderer(mOptions.holderSelector, {
className: attrs.position === "container" ? "pe-multiple--container" : "pe-multiple--screen"
}, candidates.map(function (itemData) {
return renderer(mOptions.instance, _extends$1({}, {
fromMultipleClassName: mOptions.className,
fromMultipleClear: clear,
fromMultipleDidHide: itemData.didHide,
fromMultipleDidShow: itemData.didShow,
hide: itemData.hide,
holderSelector: mOptions.holderSelector,
instanceId: itemData.instanceId,
key: itemData.key,
pause: itemData.pause,
show: itemData.show,
spawnId: spawn,
transitions: mOptions.transitions,
unpause: itemData.unpause
}, unpackAttrs(itemData.attrs)));
}));
};
return {
clear: clear,
count: count,
getInitialState: getInitialState,
hide: hide,
pause: pause,
remove: remove,
show: show,
unpause: unpause,
view: view
};
};
Multi.displayName = "Multi";
var getStyle = function getStyle(_ref) {
var element = _ref.element,
selector = _ref.selector,
pseudoSelector = _ref.pseudoSelector,
prop = _ref.prop;
var el = selector ? element.querySelector(selector) : element;
if (!el) {
return;
}
return el.currentStyle ? el.currentStyle[prop] : window.getComputedStyle ? document.defaultView.getComputedStyle(el, pseudoSelector).getPropertyValue(prop) : null;
};
var stylePropCompare = function stylePropCompare(_ref2) {
var element = _ref2.element,
selector = _ref2.selector,
pseudoSelector = _ref2.pseudoSelector,
prop = _ref2.prop,
equals = _ref2.equals,
contains = _ref2.contains;
var el = selector ? element.querySelector(selector) : element;
if (!el) {
return false;
}
if (equals !== undefined) {
return equals === document.defaultView.getComputedStyle(el, pseudoSelector).getPropertyValue(prop);
}
if (contains !== undefined) {
return document.defaultView.getComputedStyle(el, pseudoSelector).getPropertyValue(prop).indexOf(contains) !== -1;
}
};
var isRTL = function isRTL(_ref3) {
var _ref3$element = _ref3.element,
element = _ref3$element === undefined ? document : _ref3$element,
selector = _ref3.selector;
return stylePropCompare({ element: element, selector: selector, prop: "direction", equals: "rtl" });
};
var styleDurationToMs = function styleDurationToMs(durationStr) {
var parsed = parseFloat(durationStr) * (durationStr.indexOf("ms") === -1 ? 1000 : 1);
return isNaN(parsed) ? 0 : parsed;
};
var _extends$2 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
// defaults
var DEFAULT_DURATION = .240;
var DEFAULT_DELAY = 0;
// const TRANSITION = "both";
// See: transition
var show = function show(opts) {
return transition(opts, "show");
};
var hide = function hide(opts) {
return transition(opts, "hide");
};
/*
opts:
- el
- duration
- delay
- showClass
- transitionClass
- before
- show
- hide
- after
- timingFunction
- state (show, hide)
*/
var transition = function transition(opts, state) {
var el = opts.el;
if (!el) {
return Promise.resolve();
} else {
return new Promise(function (resolve) {
var style = el.style;
var computedStyle = isClient ? window.getComputedStyle(el) : {};
var duration = opts.hasDuration ? opts.duration * 1000.0 : styleDurationToMs(computedStyle.transitionDuration);
var delay = opts.hasDelay ? opts.delay * 1000.0 : styleDurationToMs(computedStyle.transitionDelay);
var timingFunction = opts.timingFunction || computedStyle.transitionTimingFunction;
if (opts.transitionClass) {
var transitionClassElement = opts.transitionClassElement || el;
transitionClassElement.classList.add(opts.transitionClass);
}
var before = function before() {
style.transitionDuration = "0ms";
style.transitionDelay = "0ms";
opts.before();
};
var maybeBefore = opts.before && state === "show" ? before : opts.before && state === "hide" ? before : null;
var after = opts.after ? function () {
return opts.after();
} : null;
var applyTransition = function applyTransition() {
style.transitionDuration = duration + "ms";
style.transitionDelay = delay + "ms";
if (timingFunction) {
style.transitionTimingFunction = timingFunction;
}
if (opts.showClass) {
var showClassElement = opts.showClassElement || el;
showClassElement.classList[state === "show" ? "add" : "remove"](opts.showClass);
}
if (opts.transition) {
opts.transition();
}
};
var doTransition = function doTransition() {
applyTransition();
setTimeout(function () {
if (after) {
after();
}
if (opts.transitionClass) {
var _transitionClassElement = opts.transitionClassElement || el;
_transitionClassElement.classList.remove(opts.transitionClass);
el.offsetHeight; // force reflow
}
resolve();
}, duration + delay);
};
var maybeDelayTransition = function maybeDelayTransition() {
if (duration === 0) {
doTransition();
} else {
setTimeout(doTransition, 0);
}
};
if (maybeBefore) {
maybeBefore();
el.offsetHeight; // force reflow
setTimeout(function () {
maybeDelayTransition();
}, 0);
} else {
maybeDelayTransition();
}
});
}
};
var transitionComponent = function transitionComponent(_ref) {
var isShow = _ref.isShow,
state = _ref.state,
attrs = _ref.attrs,
domElements = _ref.domElements,
beforeTransition = _ref.beforeTransition,
afterTransition = _ref.afterTransition,
showClass = _ref.showClass,
transitionClass = _ref.transitionClass;
if (state.transitioning()) {
return Promise.resolve();
}
state.transitioning(true);
state.visible(isShow ? true : false);
if (beforeTransition) {
beforeTransition();
}
var duration = attrs[isShow ? "showDuration" : "hideDuration"];
var delay = attrs[isShow ? "showDelay" : "hideDelay"];
var timingFunction = attrs[isShow ? "showTimingFunction" : "hideTimingFunction"];
var transitions = attrs.transitions;
var fn = isShow ? show : hide;
var opts1 = _extends$2({}, attrs, domElements, {
showClass: showClass,
transitionClass: transitionClass,
duration: duration,
delay: delay,
timingFunction: timingFunction
});
var opts2 = _extends$2({}, opts1, transitions && transitions[isShow ? "show" : "hide"](opts1));
var opts3 = _extends$2({}, opts2, {
duration: opts2.duration !== undefined ? opts2.duration : DEFAULT_DURATION,
hasDuration: opts2.duration !== undefined,
delay: opts2.delay !== undefined ? opts2.delay : DEFAULT_DELAY,
hasDelay: opts2.delay !== undefined
});
return fn(opts3).then(function () {
var id = state.instanceId;
if (attrs[isShow ? "fromMultipleDidShow" : "fromMultipleDidHide"]) {
attrs[isShow ? "fromMultipleDidShow" : "fromMultipleDidHide"](id); // when used with Multiple; this will call attrs.didShow / attrs.didHide
} else if (attrs[isShow ? "didShow" : "didHide"]) {
attrs[isShow ? "didShow" : "didHide"](id); // when used directly
}
if (afterTransition) {
afterTransition();
}
state.transitioning(false);
});
};
var deprecation = function deprecation(component, _ref) {
var option = _ref.option,
newOption = _ref.newOption,
newComponent = _ref.newComponent;
return option && console.warn(component + ": option '" + option + "' is deprecated and will be removed in later versions. Use '" + newOption + "' instead."), newComponent && !newOption && console.warn(component + ": this component is deprecated and will be removed in later versions. Use '" + newComponent + "' instead."), newComponent && newOption && console.warn(component + ": this component is deprecated and will be removed in later versions. Use '" + newComponent + "' with option '" + newOption + "' instead.") // eslint-disable-line no-console
;
};
var iconDropdownUp = "<svg xmlns=\"http://www.w3.org/2000/svg\" id=\"dd-up-svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M7 14l5-5 5 5z\"/></svg>";
var iconDropdownDown = "<svg xmlns=\"http://www.w3.org/2000/svg\" id=\"dd-down-svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M7 10l5 5 5-5z\"/></svg>";
exports.getAnimationEndEvent = getAnimationEndEvent;
exports.Conditional = Conditional;
exports.filterSupportedAttributes = filterSupportedAttributes;
exports.unpackAttrs = unpackAttrs;
exports.classForSize = classForSize;
exports.isClient = isClient;
exports.isServer = isServer;
exports.isTouch = isTouch;
exports.pointerStartEvent = pointerStartEvent;
exports.pointerEndEvent = pointerEndEvent;
exports.pointerStartMoveEvent = pointerStartMoveEvent;
exports.pointerMoveEvent = pointerMoveEvent;
exports.pointerEndMoveEvent = pointerEndMoveEvent;
exports.Multi = Multi;
exports.show = show;
exports.hide = hide;
exports.transitionComponent = transitionComponent;
exports.throttle = throttle;
exports.subscribe = subscribe;
exports.unsubscribe = unsubscribe;
exports.emit = emit;
exports.getStyle = getStyle;
exports.stylePropCompare = stylePropCompare;
exports.isRTL = isRTL;
exports.styleDurationToMs = styleDurationToMs;
exports.deprecation = deprecation;
exports.iconDropdownUp = iconDropdownUp;
exports.iconDropdownDown = iconDropdownDown;
Object.defineProperty(exports, '__esModule', { value: true });
})));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).polythene={})}(this,function(e){"use strict";const t="undefined"!=typeof document,n=!t,i={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"animationend",WebkitAnimation:"webkitAnimationEnd"},o="hidden",s="visible",d="exposing",r="hiding",a={getInitialState:(e,t)=>{const n=e.attrs;if(!n.didHide)return{};const i=n.permanent||n.show,d=t(n.permanent?s:i?s:o);return{mode:d,redrawOnUpdate:t.merge([d])}},onUpdate:({state:e,attrs:t})=>{if(!t.didHide)return;const n=e.mode();t.permanent?n===s&&t.show?e.mode(d):n!==d||t.show||e.mode(r):n===o&&t.show?e.mode(s):n!==s||t.show||e.mode(r)},view:({state:e,attrs:t},{renderer:n})=>{const i=n("span",{className:t.placeholderClassName});if(!t.didHide)return t.permanent||t.inactive||t.show?n(t.instance,t):i;const d=e.mode();return d!==o?n(t.instance,Object.assign({},t,{didHide:n=>(t.didHide(n),e.mode(t.permanent?s:o))},d===r&&{show:!0,hide:!0})):i},displayName:"Conditional"},l=(e,t)=>(e[t]=1,e),u=["key","style","href","id","tabIndex","tabindex","oninit","oncreate","onupdate","onbeforeremove","onremove","onbeforeupdate"],m=e=>"function"==typeof e?e():e,c=!n&&"ontouchstart"in document.documentElement,p=c?["touchstart","click"]:["click"],h=c?["click","mouseup"]:["mouseup"],w=c?["touchstart","mousedown"]:["mousedown"],f=c?["touchmove","mousemove"]:["mousemove"],g=c?["touchend","mouseup"]:["mouseup"];t&&document.querySelector("html").classList.add(c?"pe-touch":"pe-no-touch");const v={},y=(e,n=.05,i=(t?window:{}))=>{let o=!1;return(...t)=>{o||((()=>e.apply(i,t))(),o=!0,setTimeout(()=>o=!1,n))}},S=(e,t)=>{v[e]&&v[e].forEach(e=>e(t))};t&&(window.addEventListener("resize",e=>S("resize",e)),window.addEventListener("scroll",e=>S("scroll",e)),window.addEventListener("keydown",e=>S("keydown",e)),window.addEventListener(h,e=>S(h,e)));const b=({options:e,renderer:n})=>{const i=[];let o;const s=t=>{o||console.error("Cannot set state. Did you set a root element like Dialog to show instances?"),o(t.id),S(e.name,t)},d=e=>{const t=r(e);return i.indexOf(t)},r=e=>{for(let t=0;t<i.length;t++)if(i[t].instanceId===e)return i[t]},a=()=>{i.length&&(i[0].show=!0),s({id:i.length?i[0].instanceId:null,name:"next"})},l=(t=e.defaultId)=>{e.queue?(i.shift(),a()):(e=>{const t=d(e);-1!==t&&(i.splice(t,1),s({id:e,name:"removeItem"}))})(t)},u=(e,t)=>{const n=r(t);n&&(n.pause=e,n.unpause=!e,s({id:t,name:e?"pause":"unpause"}))},c=()=>{i.length=0,s({id:null,name:"removeAll"})};return{clear:c,count:()=>i.length,getInitialState:(e,t)=>({current:o=t(null),redrawOnUpdate:t.merge([o])}),hide:(t={})=>{const n=t.id||e.defaultId,o=e.queue&&i.length?i[0]:r(n);return o&&(o.hide=!0),s({id:n,name:"hide"}),o?o.hidePromise:Promise.resolve(n)},pause:(t=e.defaultId)=>u(!0,t),remove:l,show:(t={},n={})=>{const o=n.id||e.defaultId,u=((t,n,i)=>{let o,d;const r=m(t),a=new Promise(e=>o=e),u=new Promise(e=>d=e);return Object.assign({},e,{instanceId:n,spawn:i,attrs:t,show:!e.queue,showPromise:a,hidePromise:u,didShow:()=>(r.didShow&&r.didShow(n),s({id:n,name:"didShow"}),o(n)),didHide:()=>(r.didHide&&r.didHide(n),s({id:n,name:"didHide"}),l(n),d(n))})})(t,o,n.spawn||e.defaultId);s({id:o,name:"show"}),e.queue?(i.push(u),1===i.length&&a()):r(o)?((e,t)=>{const n=d(e);-1!==n&&(i[n]=t)})(o,u):i.push(u);return u.showPromise},unpause:(t=e.defaultId)=>u(!1,t),view:({attrs:o})=>{const s=o.spawn||e.defaultId,d=i.filter(e=>e.show&&e.spawn===s);return e.htmlShowClass&&t&&document.documentElement&&document.documentElement.classList[d.length?"add":"remove"](e.htmlShowClass),d.length?n(e.holderSelector,{className:"container"===o.position?"pe-multiple--container":"pe-multiple--screen"},d.map(t=>n(e.instance,Object.assign({},{fromMultipleClassName:e.className,fromMultipleClear:c,fromMultipleDidHide:t.didHide,fromMultipleDidShow:t.didShow,hide:t.hide,holderSelector:e.holderSelector,instanceId:t.instanceId,key:t.key,pause:t.pause,show:t.show,spawnId:s,transitions:e.transitions,unpause:t.unpause},m(t.attrs))))):n(e.placeholder)}}};b.displayName="Multi";const C=({element:e,selector:t,pseudoSelector:n,prop:i,equals:o,contains:s})=>{const d=t?e.querySelector(t):e;return!!d&&(void 0!==o?o===document.defaultView.getComputedStyle(d,n).getPropertyValue(i):void 0!==s?-1!==document.defaultView.getComputedStyle(d,n).getPropertyValue(i).indexOf(s):void 0)},D=e=>{const t=parseFloat(e)*(-1===e.indexOf("ms")?1e3:1);return isNaN(t)?0:t},E=e=>M(e,"show"),I=e=>M(e,"hide"),M=(e,n)=>{const i=e.el;return i?new Promise(o=>{const s=i.style,d=t?window.getComputedStyle(i):{},r=e.hasDuration?1e3*e.duration:D(d.transitionDuration),a=e.hasDelay?1e3*e.delay:D(d.transitionDelay),l=e.timingFunction||d.transitionTimingFunction;if(e.transitionClass){(e.transitionClassElement||i).classList.add(e.transitionClass)}const u=()=>{s.transitionDuration="0ms",s.transitionDelay="0ms",e.before()},m=e.before&&"show"===n?u:e.before&&"hide"===n?u:null,c=e.after?()=>e.after():null,p=()=>{(()=>{s.transitionDuration=r+"ms",s.transitionDelay=a+"ms",l&&(s.transitionTimingFunction=l),e.showClass&&(e.showClassElement||i).classList["show"===n?"add":"remove"](e.showClass);e.transition&&e.transition()})(),setTimeout(()=>{if(c&&c(),e.transitionClass){(e.transitionClassElement||i).classList.remove(e.transitionClass),i.offsetHeight}o()},r+a)},h=()=>{0===r?p():setTimeout(p,0)};m?(m(),i.offsetHeight,setTimeout(()=>{h()},0)):h()}):Promise.resolve()};e.getAnimationEndEvent=(()=>{if(t){const e=document.createElement("fakeelement");for(let t in i)if(void 0!==e.style[t])return i[t]}}),e.Conditional=a,e.filterSupportedAttributes=((e,{add:t=[],remove:n=[]}={})=>{const i=n.reduce(l,{}),o=u.concat(t).filter(e=>!i[e]).reduce(l,{});return Object.keys(e).reduce((t,n)=>(o[n]&&(t[n]=e[n]),t),{})}),e.unpackAttrs=m,e.classForSize=((e,t="regular")=>(e=>({small:e.small,regular:e.regular,medium:e.medium,large:e.large,fab:e.fab}))(e)[t]),e.isClient=t,e.isServer=n,e.isTouch=c,e.pointerStartEvent=p,e.pointerEndEvent=h,e.pointerStartMoveEvent=w,e.pointerMoveEvent=f,e.pointerEndMoveEvent=g,e.Multi=b,e.show=E,e.hide=I,e.transitionComponent=(({isShow:e,state:t,attrs:n,domElements:i,beforeTransition:o,afterTransition:s,showClass:d,transitionClass:r})=>{if(t.transitioning())return Promise.resolve();t.transitioning(!0),t.visible(!!e),o&&o();const a=n[e?"showDuration":"hideDuration"],l=n[e?"showDelay":"hideDelay"],u=n[e?"showTimingFunction":"hideTimingFunction"],m=n.transitions,c=e?E:I,p=Object.assign({},n,i,{showClass:d,transitionClass:r,duration:a,delay:l,timingFunction:u}),h=Object.assign({},p,m&&m[e?"show":"hide"](p));return c(Object.assign({},h,{duration:void 0!==h.duration?h.duration:.24,hasDuration:void 0!==h.duration,delay:void 0!==h.delay?h.delay:0,hasDelay:void 0!==h.delay})).then(()=>{const i=t.instanceId;n[e?"fromMultipleDidShow":"fromMultipleDidHide"]?n[e?"fromMultipleDidShow":"fromMultipleDidHide"](i):n[e?"didShow":"didHide"]&&n[e?"didShow":"didHide"](i),s&&s(),t.transitioning(!1)})}),e.throttle=y,e.subscribe=((e,t,n)=>{v[e]=v[e]||[],v[e].push(n?y(t,n):t)}),e.unsubscribe=((e,t)=>{if(!v[e])return;const n=v[e].indexOf(t);n>-1&&v[e].splice(n,1)}),e.emit=S,e.getStyle=(({element:e,selector:t,pseudoSelector:n,prop:i})=>{const o=t?e.querySelector(t):e;if(o)return o.currentStyle?o.currentStyle[i]:window.getComputedStyle?document.defaultView.getComputedStyle(o,n).getPropertyValue(i):null}),e.stylePropCompare=C,e.isRTL=(({element:e=document,selector:t})=>C({element:e,selector:t,prop:"direction",equals:"rtl"})),e.styleDurationToMs=D,e.deprecation=((e,{option:t,newOption:n,newComponent:i})=>(t&&console.warn(`${e}: option '${t}' is deprecated and will be removed in later versions. Use '${n}' instead.`),i&&!n&&console.warn(`${e}: this component is deprecated and will be removed in later versions. Use '${i}' instead.`),i&&n&&console.warn(`${e}: this component is deprecated and will be removed in later versions. Use '${i}' with option '${n}' instead.`))),e.iconDropdownUp='<svg xmlns="http://www.w3.org/2000/svg" id="dd-up-svg" width="24" height="24" viewBox="0 0 24 24"><path d="M7 14l5-5 5 5z"/></svg>',e.iconDropdownDown='<svg xmlns="http://www.w3.org/2000/svg" id="dd-down-svg" width="24" height="24" viewBox="0 0 24 24"><path d="M7 10l5 5 5-5z"/></svg>',Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=polythene-core.js.map

4

package.json
{
"name": "polythene-core",
"version": "1.3.3",
"version": "1.4.0",
"description": "",

@@ -9,3 +9,3 @@ "main": "dist/polythene-core",

"clean": "rm -rf dist/*",
"rollup": "../../node_modules/rollup/bin/rollup -c ../../scripts/rollup.umd.js && ../../node_modules/rollup/bin/rollup -c ../../scripts/rollup.es.js",
"rollup": "../../node_modules/rollup/bin/rollup -c ../../scripts/bundling/rollup.umd.js && ../../node_modules/rollup/bin/rollup -c ../../scripts/bundling/rollup.es.js",
"build": "npm run clean && npm run rollup"

@@ -12,0 +12,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc