export * from '@primeuix/utils'; import { getScrollableParents } from '@primeuix/utils/dom'; import { isNotEmpty } from '@primeuix/utils/object'; import { uuid } from '@primeuix/utils/uuid'; function _typeof$1(o) { "@babel/helpers - typeof"; return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof$1(o); } function _classCallCheck$1(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } function _defineProperties$1(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey$1(o.key), o); } } function _createClass$1(e, r, t) { return r && _defineProperties$1(e.prototype, r), Object.defineProperty(e, "prototype", { writable: !1 }), e; } function _toPropertyKey$1(t) { var i = _toPrimitive$1(t, "string"); return "symbol" == _typeof$1(i) ? i : i + ""; } function _toPrimitive$1(t, r) { if ("object" != _typeof$1(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r); if ("object" != _typeof$1(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return (String )(t); } var ConnectedOverlayScrollHandler = /*#__PURE__*/function () { function ConnectedOverlayScrollHandler(element) { var listener = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {}; _classCallCheck$1(this, ConnectedOverlayScrollHandler); this.element = element; this.listener = listener; } return _createClass$1(ConnectedOverlayScrollHandler, [{ key: "bindScrollListener", value: function bindScrollListener() { this.scrollableParents = getScrollableParents(this.element); for (var i = 0; i < this.scrollableParents.length; i++) { this.scrollableParents[i].addEventListener('scroll', this.listener); } } }, { key: "unbindScrollListener", value: function unbindScrollListener() { if (this.scrollableParents) { for (var i = 0; i < this.scrollableParents.length; i++) { this.scrollableParents[i].removeEventListener('scroll', this.listener); } } } }, { key: "destroy", value: function destroy() { this.unbindScrollListener(); this.element = null; this.listener = null; this.scrollableParents = null; } }]); }(); function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); } function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); } function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } } function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", { writable: !1 }), e; } function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return (String )(t); } var _default = /*#__PURE__*/function () { function _default(_ref) { var init = _ref.init, type = _ref.type; _classCallCheck(this, _default); _defineProperty(this, "helpers", void 0); _defineProperty(this, "type", void 0); this.helpers = new Set(init); this.type = type; } return _createClass(_default, [{ key: "add", value: function add(instance) { this.helpers.add(instance); } }, { key: "update", value: function update() { // @todo } }, { key: "delete", value: function _delete(instance) { this.helpers["delete"](instance); } }, { key: "clear", value: function clear() { this.helpers.clear(); } }, { key: "get", value: function get(parentInstance, slots) { var children = this._get(parentInstance, slots); var computed = children ? this._recursive(_toConsumableArray(this.helpers), children) : null; return isNotEmpty(computed) ? computed : null; } }, { key: "_isMatched", value: function _isMatched(instance, key) { var _parent$vnode; var parent = instance === null || instance === void 0 ? void 0 : instance.parent; return (parent === null || parent === void 0 || (_parent$vnode = parent.vnode) === null || _parent$vnode === void 0 ? void 0 : _parent$vnode.key) === key || parent && this._isMatched(parent, key) || false; } }, { key: "_get", value: function _get(parentInstance, slots) { var _ref2, _ref2$default; return ((_ref2 = slots || (parentInstance === null || parentInstance === void 0 ? void 0 : parentInstance.$slots)) === null || _ref2 === void 0 || (_ref2$default = _ref2["default"]) === null || _ref2$default === void 0 ? void 0 : _ref2$default.call(_ref2)) || null; } }, { key: "_recursive", value: function _recursive() { var _this = this; var helpers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; var children = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; var components = []; children.forEach(function (child) { if (child.children instanceof Array) { components = components.concat(_this._recursive(components, child.children)); } else if (child.type.name === _this.type) { components.push(child); } else if (isNotEmpty(child.key)) { components = components.concat(helpers.filter(function (c) { return _this._isMatched(c, child.key); }).map(function (c) { return c.vnode; })); } }); return components; } }]); }(); function UniqueComponentId () { var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'pv_id_'; return uuid(prefix); } function getVNodeProp(vnode, prop) { if (vnode) { var props = vnode.props; if (props) { var kebabProp = prop.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase(); var propName = Object.prototype.hasOwnProperty.call(props, kebabProp) ? kebabProp : prop; return vnode.type["extends"].props[prop].type === Boolean && props[propName] === '' ? true : props[propName]; } } return null; } export { ConnectedOverlayScrollHandler, _default as HelperSet, UniqueComponentId, getVNodeProp }; //# sourceMappingURL=index.mjs.map