diff --git a/elements/pfe-accordion/dist/pfe-accordion.js b/elements/pfe-accordion/dist/pfe-accordion.js new file mode 100644 index 0000000000..84f89d8bc4 --- /dev/null +++ b/elements/pfe-accordion/dist/pfe-accordion.js @@ -0,0 +1,674 @@ +import PFElement from '../../pfelement/dist/pfelement.js'; + +// @POLYFILL Array.prototype.findIndex +// https://tc39.github.io/ecma262/#sec-array.prototype.findIndex +if (!Array.prototype.findIndex) { + Object.defineProperty(Array.prototype, "findIndex", { + value: function(predicate) { + // 1. Let O be ? ToObject(this value). + if (this == null) { + throw new TypeError('"this" is null or not defined'); + } + + var o = Object(this); + + // 2. Let len be ? ToLength(? Get(O, "length")). + var len = o.length >>> 0; + + // 3. If IsCallable(predicate) is false, throw a TypeError exception. + if (typeof predicate !== "function") { + throw new TypeError("predicate must be a function"); + } + + // 4. If thisArg was supplied, let T be thisArg; else let T be undefined. + var thisArg = arguments[1]; + + // 5. Let k be 0. + var k = 0; + + // 6. Repeat, while k < len + while (k < len) { + // a. Let Pk be ! ToString(k). + // b. Let kValue be ? Get(O, Pk). + // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + // d. If testResult is true, return k. + var kValue = o[k]; + if (predicate.call(thisArg, kValue, k, o)) { + return k; + } + // e. Increase k by 1. + k++; + } + + // 7. Return -1. + return -1; + } + }); +} + +/*! + * PatternFly Elements: PfeAccordion 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * +*/ + +function generateId() { + return Math.random() + .toString(36) + .substr(2, 9); +} + +class PfeAccordion extends PFElement { + static get version() { + return "1.0.0-prerelease.54"; + } + + get html() { + return ``; + } + + static get properties() { + return {}; + } + + static get slots() { + return {"default":{"title":"Default","type":"array","namedSlot":false,"items":{"oneOf":[{"$ref":"pfe-accordion-header"},{"$ref":"pfe-accordion-panel"}]}}}; + } + static get tag() { + return "pfe-accordion"; + } + + get styleUrl() { + return "pfe-accordion.scss"; + } + + get templateUrl() { + return "pfe-accordion.html"; + } + + get schemaUrl() { + return "pfe-accordion.json"; + } + + static get cascadingAttributes() { + return { + on: "pfe-accordion-header, pfe-accordion-panel" + }; + } + + static get events() { + return { + change: `${this.tag}:change` + }; + } + + // Declare the type of this component + static get PfeType() { + return PFElement.PfeTypes.Container; + } + + static get observedAttributes() { + return ["pfe-disclosure"]; + } + + constructor() { + super(PfeAccordion, { type: PfeAccordion.PfeType }); + + this._linkPanels = this._linkPanels.bind(this); + this._observer = new MutationObserver(this._linkPanels); + } + + connectedCallback() { + super.connectedCallback(); + + this.setAttribute("role", "tablist"); + this.setAttribute("defined", ""); + + this.addEventListener(PfeAccordion.events.change, this._changeHandler); + this.addEventListener("keydown", this._keydownHandler); + + Promise.all([ + customElements.whenDefined(PfeAccordionHeader.tag), + customElements.whenDefined(PfeAccordionPanel.tag) + ]).then(() => { + if (this.children.length) { + this._linkPanels(); + } + + this._observer.observe(this, { childList: true }); + }); + } + + disconnectedCallback() { + this.removeEventListener(PfeAccordion.events.change, this._changeHandler); + this.removeEventListener("keydown", this._keydownHandler); + this._observer.disconnect(); + } + + attributeChangedCallback(attr, oldVal, newVal) { + super.attributeChangedCallback(attr, oldVal, newVal); + + if (attr === "pfe-disclosure") { + if (newVal === "true") { + this._allHeaders().forEach(header => + header.setAttribute("pfe-disclosure", "true") + ); + this._allPanels().forEach(panel => + panel.setAttribute("pfe-disclosure", "true") + ); + } else { + this._allHeaders().forEach(header => + header.setAttribute("pfe-disclosure", "false") + ); + this._allPanels().forEach(panel => + panel.setAttribute("pfe-disclosure", "false") + ); + } + } + } + + toggle(index) { + const headers = this._allHeaders(); + const panels = this._allPanels(); + const header = headers[index]; + const panel = panels[index]; + + if (!header || !panel) { + return; + } + + if (!header.expanded) { + this._expandHeader(header); + this._expandPanel(panel); + } else { + this._collapseHeader(header); + this._collapsePanel(panel); + } + } + + expand(index) { + const headers = this._allHeaders(); + const panels = this._allPanels(); + const header = headers[index]; + const panel = panels[index]; + + if (!header || !panel) { + return; + } + + this._expandHeader(header); + this._expandPanel(panel); + } + + expandAll() { + const headers = this._allHeaders(); + const panels = this._allPanels(); + + headers.forEach(header => this._expandHeader(header)); + panels.forEach(panel => this._expandPanel(panel)); + } + + collapse(index) { + const headers = this._allHeaders(); + const panels = this._allPanels(); + const header = headers[index]; + const panel = panels[index]; + + if (!header || !panel) { + return; + } + + this._collapseHeader(header); + this._collapsePanel(panel); + } + + collapseAll() { + const headers = this._allHeaders(); + const panels = this._allPanels(); + + headers.forEach(header => this._collapseHeader(header)); + panels.forEach(panel => this._collapsePanel(panel)); + } + + _linkPanels() { + const headers = this._allHeaders(); + headers.forEach(header => { + const panel = this._panelForHeader(header); + + if (!panel) { + return; + } + + header.setAttribute("aria-controls", panel.pfeId); + panel.setAttribute("aria-labelledby", header.pfeId); + }); + + if (headers.length === 1) { + if ( + this.hasAttribute("pfe-disclosure") && + this.getAttribute("pfe-disclosure") === "false" + ) { + return; + } + + this.setAttribute("pfe-disclosure", "true"); + } + + if (headers.length > 1) { + if (this.hasAttribute("pfe-disclosure")) { + this.removeAttribute("pfe-disclosure"); + } + } + } + + _changeHandler(evt) { + if (this.classList.contains("animating")) { + return; + } + + const header = evt.target; + const panel = evt.target.nextElementSibling; + + if (evt.detail.expanded) { + this._expandHeader(header); + this._expandPanel(panel); + } else { + this._collapseHeader(header); + this._collapsePanel(panel); + } + } + + _toggle(header, panel) {} + + _expandHeader(header) { + header.expanded = true; + } + + _expandPanel(panel) { + if (!panel) { + console.error( + `${PfeAccordion.tag}: Trying to expand a panel that doesn't exist` + ); + return; + } + + if (panel.expanded) { + return; + } + + panel.expanded = true; + + const height = panel.getBoundingClientRect().height; + this._animate(panel, 0, height); + } + + _collapseHeader(header) { + header.expanded = false; + } + + _collapsePanel(panel) { + if (!panel) { + console.error( + `${PfeAccordion.tag}: Trying to collapse a panel that doesn't exist` + ); + return; + } + + if (!panel.expanded) { + return; + } + + const height = panel.getBoundingClientRect().height; + panel.expanded = false; + + this._animate(panel, height, 0); + } + + _animate(panel, start, end) { + if (panel) { + const header = panel.previousElementSibling; + if (header) { + header.classList.add("animating"); + } + panel.classList.add("animating"); + panel.style.height = `${start}px`; + + requestAnimationFrame(() => { + requestAnimationFrame(() => { + panel.style.height = `${end}px`; + panel.addEventListener("transitionend", this._transitionEndHandler); + }); + }); + } + } + + _keydownHandler(evt) { + const currentHeader = evt.target; + + if (!this._isHeader(currentHeader)) { + return; + } + + let newHeader; + + switch (evt.key) { + case "ArrowDown": + case "Down": + case "ArrowRight": + case "Right": + newHeader = this._nextHeader(); + break; + case "ArrowUp": + case "Up": + case "ArrowLeft": + case "Left": + newHeader = this._previousHeader(); + break; + case "Home": + newHeader = this._firstHeader(); + break; + case "End": + newHeader = this._lastHeader(); + break; + default: + return; + } + + newHeader.shadowRoot.querySelector("button").focus(); + } + + _transitionEndHandler(evt) { + const header = evt.target.previousElementSibling; + if (header) { + header.classList.remove("animating"); + } + evt.target.style.height = ""; + evt.target.classList.remove("animating"); + evt.target.removeEventListener("transitionend", this._transitionEndHandler); + } + + _allHeaders() { + return [...this.querySelectorAll(PfeAccordionHeader.tag)]; + } + + _allPanels() { + return [...this.querySelectorAll(PfeAccordionPanel.tag)]; + } + + _panelForHeader(header) { + const next = header.nextElementSibling; + + if (!next) { + return; + } + + if (next.tagName.toLowerCase() !== PfeAccordionPanel.tag) { + console.error( + `${PfeAccordion.tag}: Sibling element to a header needs to be a panel` + ); + return; + } + + return next; + } + + _previousHeader() { + const headers = this._allHeaders(); + let newIndex = + headers.findIndex(header => header === document.activeElement) - 1; + return headers[(newIndex + headers.length) % headers.length]; + } + + _nextHeader() { + const headers = this._allHeaders(); + let newIndex = + headers.findIndex(header => header === document.activeElement) + 1; + return headers[newIndex % headers.length]; + } + + _firstHeader() { + const headers = this._allHeaders(); + return headers[0]; + } + + _lastHeader() { + const headers = this._allHeaders(); + return headers[headers.length - 1]; + } + + _isHeader(element) { + return element.tagName.toLowerCase() === PfeAccordionHeader.tag; + } +} + +class PfeAccordionHeader extends PFElement { + static get version() { + return "1.0.0-prerelease.54"; + } + + get html() { + return ``; + } + static get tag() { + return "pfe-accordion-header"; + } + + get styleUrl() { + return "pfe-accordion-header.scss"; + } + + get templateUrl() { + return "pfe-accordion-header.html"; + } + + get pfeId() { + return this.getAttribute("pfe-id"); + } + + set pfeId(id) { + if (!id) { + return; + } + + this.setAttribute("pfe-id", id); + } + + static get observedAttributes() { + return ["aria-expanded"]; + } + + constructor() { + super(PfeAccordionHeader); + + this.button = this.shadowRoot.querySelector("button"); + + this._init = this._init.bind(this); + this._clickHandler = this._clickHandler.bind(this); + this._observer = new MutationObserver(this._init); + } + + connectedCallback() { + super.connectedCallback(); + + if (this.children.length || this.textContent.trim().length) { + this._init(); + } + + this.addEventListener("click", this._clickHandler); + this._observer.observe(this, { childList: true }); + } + + disconnectedCallback() { + this.removeEventListener("click", this._clickHandler); + this._observer.disconnect(); + } + + get expanded() { + return this.hasAttribute("aria-expanded"); + } + + set expanded(val) { + val = Boolean(val); + + if (val) { + this.setAttribute("aria-expanded", true); + this.button.setAttribute("aria-expanded", true); + } else { + this.removeAttribute("aria-expanded"); + this.button.setAttribute("aria-expanded", false); + } + } + + _init() { + if (window.ShadyCSS) { + this._observer.disconnect(); + } + + if (!this.hasAttribute("role")) { + this.setAttribute("role", "heading"); + } + + if (!this.pfeId) { + this.pfeId = `${PfeAccordionHeader.tag}-${generateId()}`; + } + + const child = this.children[0]; + let isHeaderTag = false; + + if (child) { + switch (child.tagName) { + case "H1": + case "H2": + case "H3": + case "H4": + case "H5": + case "H6": + isHeaderTag = true; + break; + } + + const wrapperTag = document.createElement(child.tagName); + this.button.innerText = child.innerText; + + wrapperTag.appendChild(this.button); + this.shadowRoot.appendChild(wrapperTag); + } else { + this.button.innerText = this.textContent.trim(); + } + + if (!isHeaderTag) { + console.warn( + `${PfeAccordionHeader.tag}: The first child in the light DOM must be a Header level tag (h1, h2, h3, h4, h5, or h6)` + ); + } + + if (window.ShadyCSS) { + this._observer.observe(this, { childList: true }); + } + } + + _clickHandler(event) { + this.emitEvent(PfeAccordion.events.change, { + detail: { expanded: !this.expanded } + }); + } +} + +class PfeAccordionPanel extends PFElement { + static get version() { + return "1.0.0-prerelease.54"; + } + + get html() { + return `
+
+ +
+
`; + } + static get tag() { + return "pfe-accordion-panel"; + } + + get styleUrl() { + return "pfe-accordion-panel.scss"; + } + + get templateUrl() { + return "pfe-accordion-panel.html"; + } + + get pfeId() { + return this.getAttribute("pfe-id"); + } + + set pfeId(id) { + if (!id) { + return; + } + + this.setAttribute("pfe-id", id); + } + + constructor() { + super(PfeAccordionPanel); + } + + connectedCallback() { + super.connectedCallback(); + + if (!this.hasAttribute("role")) { + this.setAttribute("role", "region"); + } + + if (!this.pfeId) { + this.pfeId = `${PfeAccordionPanel.tag}-${generateId()}`; + } + } + + get expanded() { + return this.hasAttribute("expanded"); + } + + set expanded(val) { + const value = Boolean(val); + + if (value) { + this.setAttribute("expanded", ""); + } else { + this.removeAttribute("expanded"); + } + } +} + +PFElement.create(PfeAccordionHeader); +PFElement.create(PfeAccordionPanel); +PFElement.create(PfeAccordion); + +export default PfeAccordion; +//# sourceMappingURL=pfe-accordion.js.map diff --git a/elements/pfe-accordion/dist/pfe-accordion.js.map b/elements/pfe-accordion/dist/pfe-accordion.js.map new file mode 100644 index 0000000000..20bb0cfbfa --- /dev/null +++ b/elements/pfe-accordion/dist/pfe-accordion.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-accordion.js","sources":["../_temp/polyfills--pfe-accordion.js","../_temp/pfe-accordion.js"],"sourcesContent":["// @POLYFILL Array.prototype.findIndex\n// https://tc39.github.io/ecma262/#sec-array.prototype.findIndex\nif (!Array.prototype.findIndex) {\n Object.defineProperty(Array.prototype, \"findIndex\", {\n value: function(predicate) {\n // 1. Let O be ? ToObject(this value).\n if (this == null) {\n throw new TypeError('\"this\" is null or not defined');\n }\n\n var o = Object(this);\n\n // 2. Let len be ? ToLength(? Get(O, \"length\")).\n var len = o.length >>> 0;\n\n // 3. If IsCallable(predicate) is false, throw a TypeError exception.\n if (typeof predicate !== \"function\") {\n throw new TypeError(\"predicate must be a function\");\n }\n\n // 4. If thisArg was supplied, let T be thisArg; else let T be undefined.\n var thisArg = arguments[1];\n\n // 5. Let k be 0.\n var k = 0;\n\n // 6. Repeat, while k < len\n while (k < len) {\n // a. Let Pk be ! ToString(k).\n // b. Let kValue be ? Get(O, Pk).\n // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).\n // d. If testResult is true, return k.\n var kValue = o[k];\n if (predicate.call(thisArg, kValue, k, o)) {\n return k;\n }\n // e. Increase k by 1.\n k++;\n }\n\n // 7. Return -1.\n return -1;\n }\n });\n}\n","/*!\n * PatternFly Elements: PfeAccordion 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\n// Import polyfills: findIndex\nimport \"./polyfills--pfe-accordion.js\";\n\nimport PFElement from \"../../pfelement/dist/pfelement.js\";\n\nfunction generateId() {\n return Math.random()\n .toString(36)\n .substr(2, 9);\n}\n\nclass PfeAccordion extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return ``;\n }\n\n static get properties() {\n return {};\n }\n\n static get slots() {\n return {\"default\":{\"title\":\"Default\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-accordion-header\"},{\"$ref\":\"pfe-accordion-panel\"}]}}};\n }\n static get tag() {\n return \"pfe-accordion\";\n }\n\n get styleUrl() {\n return \"pfe-accordion.scss\";\n }\n\n get templateUrl() {\n return \"pfe-accordion.html\";\n }\n\n get schemaUrl() {\n return \"pfe-accordion.json\";\n }\n\n static get cascadingAttributes() {\n return {\n on: \"pfe-accordion-header, pfe-accordion-panel\"\n };\n }\n\n static get events() {\n return {\n change: `${this.tag}:change`\n };\n }\n\n // Declare the type of this component\n static get PfeType() {\n return PFElement.PfeTypes.Container;\n }\n\n static get observedAttributes() {\n return [\"pfe-disclosure\"];\n }\n\n constructor() {\n super(PfeAccordion, { type: PfeAccordion.PfeType });\n\n this._linkPanels = this._linkPanels.bind(this);\n this._observer = new MutationObserver(this._linkPanels);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n this.setAttribute(\"role\", \"tablist\");\n this.setAttribute(\"defined\", \"\");\n\n this.addEventListener(PfeAccordion.events.change, this._changeHandler);\n this.addEventListener(\"keydown\", this._keydownHandler);\n\n Promise.all([\n customElements.whenDefined(PfeAccordionHeader.tag),\n customElements.whenDefined(PfeAccordionPanel.tag)\n ]).then(() => {\n if (this.children.length) {\n this._linkPanels();\n }\n\n this._observer.observe(this, { childList: true });\n });\n }\n\n disconnectedCallback() {\n this.removeEventListener(PfeAccordion.events.change, this._changeHandler);\n this.removeEventListener(\"keydown\", this._keydownHandler);\n this._observer.disconnect();\n }\n\n attributeChangedCallback(attr, oldVal, newVal) {\n super.attributeChangedCallback(attr, oldVal, newVal);\n\n if (attr === \"pfe-disclosure\") {\n if (newVal === \"true\") {\n this._allHeaders().forEach(header =>\n header.setAttribute(\"pfe-disclosure\", \"true\")\n );\n this._allPanels().forEach(panel =>\n panel.setAttribute(\"pfe-disclosure\", \"true\")\n );\n } else {\n this._allHeaders().forEach(header =>\n header.setAttribute(\"pfe-disclosure\", \"false\")\n );\n this._allPanels().forEach(panel =>\n panel.setAttribute(\"pfe-disclosure\", \"false\")\n );\n }\n }\n }\n\n toggle(index) {\n const headers = this._allHeaders();\n const panels = this._allPanels();\n const header = headers[index];\n const panel = panels[index];\n\n if (!header || !panel) {\n return;\n }\n\n if (!header.expanded) {\n this._expandHeader(header);\n this._expandPanel(panel);\n } else {\n this._collapseHeader(header);\n this._collapsePanel(panel);\n }\n }\n\n expand(index) {\n const headers = this._allHeaders();\n const panels = this._allPanels();\n const header = headers[index];\n const panel = panels[index];\n\n if (!header || !panel) {\n return;\n }\n\n this._expandHeader(header);\n this._expandPanel(panel);\n }\n\n expandAll() {\n const headers = this._allHeaders();\n const panels = this._allPanels();\n\n headers.forEach(header => this._expandHeader(header));\n panels.forEach(panel => this._expandPanel(panel));\n }\n\n collapse(index) {\n const headers = this._allHeaders();\n const panels = this._allPanels();\n const header = headers[index];\n const panel = panels[index];\n\n if (!header || !panel) {\n return;\n }\n\n this._collapseHeader(header);\n this._collapsePanel(panel);\n }\n\n collapseAll() {\n const headers = this._allHeaders();\n const panels = this._allPanels();\n\n headers.forEach(header => this._collapseHeader(header));\n panels.forEach(panel => this._collapsePanel(panel));\n }\n\n _linkPanels() {\n const headers = this._allHeaders();\n headers.forEach(header => {\n const panel = this._panelForHeader(header);\n\n if (!panel) {\n return;\n }\n\n header.setAttribute(\"aria-controls\", panel.pfeId);\n panel.setAttribute(\"aria-labelledby\", header.pfeId);\n });\n\n if (headers.length === 1) {\n if (\n this.hasAttribute(\"pfe-disclosure\") &&\n this.getAttribute(\"pfe-disclosure\") === \"false\"\n ) {\n return;\n }\n\n this.setAttribute(\"pfe-disclosure\", \"true\");\n }\n\n if (headers.length > 1) {\n if (this.hasAttribute(\"pfe-disclosure\")) {\n this.removeAttribute(\"pfe-disclosure\");\n }\n }\n }\n\n _changeHandler(evt) {\n if (this.classList.contains(\"animating\")) {\n return;\n }\n\n const header = evt.target;\n const panel = evt.target.nextElementSibling;\n\n if (evt.detail.expanded) {\n this._expandHeader(header);\n this._expandPanel(panel);\n } else {\n this._collapseHeader(header);\n this._collapsePanel(panel);\n }\n }\n\n _toggle(header, panel) {}\n\n _expandHeader(header) {\n header.expanded = true;\n }\n\n _expandPanel(panel) {\n if (!panel) {\n console.error(\n `${PfeAccordion.tag}: Trying to expand a panel that doesn't exist`\n );\n return;\n }\n\n if (panel.expanded) {\n return;\n }\n\n panel.expanded = true;\n\n const height = panel.getBoundingClientRect().height;\n this._animate(panel, 0, height);\n }\n\n _collapseHeader(header) {\n header.expanded = false;\n }\n\n _collapsePanel(panel) {\n if (!panel) {\n console.error(\n `${PfeAccordion.tag}: Trying to collapse a panel that doesn't exist`\n );\n return;\n }\n\n if (!panel.expanded) {\n return;\n }\n\n const height = panel.getBoundingClientRect().height;\n panel.expanded = false;\n\n this._animate(panel, height, 0);\n }\n\n _animate(panel, start, end) {\n if (panel) {\n const header = panel.previousElementSibling;\n if (header) {\n header.classList.add(\"animating\");\n }\n panel.classList.add(\"animating\");\n panel.style.height = `${start}px`;\n\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n panel.style.height = `${end}px`;\n panel.addEventListener(\"transitionend\", this._transitionEndHandler);\n });\n });\n }\n }\n\n _keydownHandler(evt) {\n const currentHeader = evt.target;\n\n if (!this._isHeader(currentHeader)) {\n return;\n }\n\n let newHeader;\n\n switch (evt.key) {\n case \"ArrowDown\":\n case \"Down\":\n case \"ArrowRight\":\n case \"Right\":\n newHeader = this._nextHeader();\n break;\n case \"ArrowUp\":\n case \"Up\":\n case \"ArrowLeft\":\n case \"Left\":\n newHeader = this._previousHeader();\n break;\n case \"Home\":\n newHeader = this._firstHeader();\n break;\n case \"End\":\n newHeader = this._lastHeader();\n break;\n default:\n return;\n }\n\n newHeader.shadowRoot.querySelector(\"button\").focus();\n }\n\n _transitionEndHandler(evt) {\n const header = evt.target.previousElementSibling;\n if (header) {\n header.classList.remove(\"animating\");\n }\n evt.target.style.height = \"\";\n evt.target.classList.remove(\"animating\");\n evt.target.removeEventListener(\"transitionend\", this._transitionEndHandler);\n }\n\n _allHeaders() {\n return [...this.querySelectorAll(PfeAccordionHeader.tag)];\n }\n\n _allPanels() {\n return [...this.querySelectorAll(PfeAccordionPanel.tag)];\n }\n\n _panelForHeader(header) {\n const next = header.nextElementSibling;\n\n if (!next) {\n return;\n }\n\n if (next.tagName.toLowerCase() !== PfeAccordionPanel.tag) {\n console.error(\n `${PfeAccordion.tag}: Sibling element to a header needs to be a panel`\n );\n return;\n }\n\n return next;\n }\n\n _previousHeader() {\n const headers = this._allHeaders();\n let newIndex =\n headers.findIndex(header => header === document.activeElement) - 1;\n return headers[(newIndex + headers.length) % headers.length];\n }\n\n _nextHeader() {\n const headers = this._allHeaders();\n let newIndex =\n headers.findIndex(header => header === document.activeElement) + 1;\n return headers[newIndex % headers.length];\n }\n\n _firstHeader() {\n const headers = this._allHeaders();\n return headers[0];\n }\n\n _lastHeader() {\n const headers = this._allHeaders();\n return headers[headers.length - 1];\n }\n\n _isHeader(element) {\n return element.tagName.toLowerCase() === PfeAccordionHeader.tag;\n }\n}\n\nclass PfeAccordionHeader extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return ``;\n }\n static get tag() {\n return \"pfe-accordion-header\";\n }\n\n get styleUrl() {\n return \"pfe-accordion-header.scss\";\n }\n\n get templateUrl() {\n return \"pfe-accordion-header.html\";\n }\n\n get pfeId() {\n return this.getAttribute(\"pfe-id\");\n }\n\n set pfeId(id) {\n if (!id) {\n return;\n }\n\n this.setAttribute(\"pfe-id\", id);\n }\n\n static get observedAttributes() {\n return [\"aria-expanded\"];\n }\n\n constructor() {\n super(PfeAccordionHeader);\n\n this.button = this.shadowRoot.querySelector(\"button\");\n\n this._init = this._init.bind(this);\n this._clickHandler = this._clickHandler.bind(this);\n this._observer = new MutationObserver(this._init);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n if (this.children.length || this.textContent.trim().length) {\n this._init();\n }\n\n this.addEventListener(\"click\", this._clickHandler);\n this._observer.observe(this, { childList: true });\n }\n\n disconnectedCallback() {\n this.removeEventListener(\"click\", this._clickHandler);\n this._observer.disconnect();\n }\n\n get expanded() {\n return this.hasAttribute(\"aria-expanded\");\n }\n\n set expanded(val) {\n val = Boolean(val);\n\n if (val) {\n this.setAttribute(\"aria-expanded\", true);\n this.button.setAttribute(\"aria-expanded\", true);\n } else {\n this.removeAttribute(\"aria-expanded\");\n this.button.setAttribute(\"aria-expanded\", false);\n }\n }\n\n _init() {\n if (window.ShadyCSS) {\n this._observer.disconnect();\n }\n\n if (!this.hasAttribute(\"role\")) {\n this.setAttribute(\"role\", \"heading\");\n }\n\n if (!this.pfeId) {\n this.pfeId = `${PfeAccordionHeader.tag}-${generateId()}`;\n }\n\n const child = this.children[0];\n let isHeaderTag = false;\n\n if (child) {\n switch (child.tagName) {\n case \"H1\":\n case \"H2\":\n case \"H3\":\n case \"H4\":\n case \"H5\":\n case \"H6\":\n isHeaderTag = true;\n break;\n }\n\n const wrapperTag = document.createElement(child.tagName);\n this.button.innerText = child.innerText;\n\n wrapperTag.appendChild(this.button);\n this.shadowRoot.appendChild(wrapperTag);\n } else {\n this.button.innerText = this.textContent.trim();\n }\n\n if (!isHeaderTag) {\n console.warn(\n `${PfeAccordionHeader.tag}: The first child in the light DOM must be a Header level tag (h1, h2, h3, h4, h5, or h6)`\n );\n }\n\n if (window.ShadyCSS) {\n this._observer.observe(this, { childList: true });\n }\n }\n\n _clickHandler(event) {\n this.emitEvent(PfeAccordion.events.change, {\n detail: { expanded: !this.expanded }\n });\n }\n}\n\nclass PfeAccordionPanel extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
\n
\n \n
\n
`;\n }\n static get tag() {\n return \"pfe-accordion-panel\";\n }\n\n get styleUrl() {\n return \"pfe-accordion-panel.scss\";\n }\n\n get templateUrl() {\n return \"pfe-accordion-panel.html\";\n }\n\n get pfeId() {\n return this.getAttribute(\"pfe-id\");\n }\n\n set pfeId(id) {\n if (!id) {\n return;\n }\n\n this.setAttribute(\"pfe-id\", id);\n }\n\n constructor() {\n super(PfeAccordionPanel);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n if (!this.hasAttribute(\"role\")) {\n this.setAttribute(\"role\", \"region\");\n }\n\n if (!this.pfeId) {\n this.pfeId = `${PfeAccordionPanel.tag}-${generateId()}`;\n }\n }\n\n get expanded() {\n return this.hasAttribute(\"expanded\");\n }\n\n set expanded(val) {\n const value = Boolean(val);\n\n if (value) {\n this.setAttribute(\"expanded\", \"\");\n } else {\n this.removeAttribute(\"expanded\");\n }\n }\n}\n\nPFElement.create(PfeAccordionHeader);\nPFElement.create(PfeAccordionPanel);\nPFElement.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,EAAE,EAAE;MACP,OAAO;KACR;;IAED,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;GACjC;;EAED,WAAW,GAAG;IACZ,KAAK,CAAC,iBAAiB,CAAC,CAAC;GAC1B;;EAED,iBAAiB,GAAG;IAClB,KAAK,CAAC,iBAAiB,EAAE,CAAC;;IAE1B,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE;MAC9B,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;KACrC;;IAED,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;MACf,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;KACzD;GACF;;EAED,IAAI,QAAQ,GAAG;IACb,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;GACtC;;EAED,IAAI,QAAQ,CAAC,GAAG,EAAE;IAChB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;;IAE3B,IAAI,KAAK,EAAE;MACT,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;KACnC,MAAM;MACL,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;KAClC;GACF;CACF;;AAED,SAAS,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;AACrC,SAAS,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;AACpC,SAAS,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;;;;"} \ No newline at end of file diff --git a/elements/pfe-accordion/dist/pfe-accordion.json b/elements/pfe-accordion/dist/pfe-accordion.json new file mode 100644 index 0000000000..dbdad4c888 --- /dev/null +++ b/elements/pfe-accordion/dist/pfe-accordion.json @@ -0,0 +1,40 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Accordion", + "description": "This element renders content in an accordion.", + "type": "object", + "tag": "pfe-accordion", + "class": "pfe-accordion", + "category": "container", + "properties": { + "slots": { + "title": "Slots", + "description": "Definition of the supported slots", + "type": "object", + "properties": { + "default": { + "title": "Default", + "type": "array", + "namedSlot": false, + "items": { + "oneOf": [ + { + "$ref": "pfe-accordion-header" + }, + { + "$ref": "pfe-accordion-panel" + } + ] + } + } + } + }, + "attributes": { + "title": "Attributes", + "type": "object", + "properties": {} + } + }, + "required": ["slots", "attributes"], + "additionalProperties": false +} diff --git a/elements/pfe-accordion/dist/pfe-accordion.min.js b/elements/pfe-accordion/dist/pfe-accordion.min.js new file mode 100644 index 0000000000..10c0492ae8 --- /dev/null +++ b/elements/pfe-accordion/dist/pfe-accordion.min.js @@ -0,0 +1,27 @@ +import e from"../../pfelement/dist/pfelement.min.js"; +/*! + * PatternFly Elements: PfeAccordion 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * +*/ +function t(){return Math.random().toString(36).substr(2,9)}Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(e){if(null==this)throw new TypeError('"this" is null or not defined');var t=Object(this),r=t.length>>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var o=arguments[1],a=0;a:host{--pfe-accordion--BorderColor--accent:transparent;--pfe-accordion--BorderColor:var(--pfe-theme--color--surface--border, #d2d2d2);--pfe-accordion--BorderTopWidth:var(--pfe-theme--surface--border-width, 1px);--pfe-accordion--BorderRightWidth:0;--pfe-accordion--BorderBottomWidth:var(--pfe-theme--surface--border-width, 1px);--pfe-accordion--BorderLeftWidth:var(--pfe-theme--surface--border-width--heavy, 4px);--pfe-accordion--Color:var(--pfe-broadcasted--text, #3c3f42);--pfe-accordion--TextAlign:left;--pfe-accordion--accent:var(--pfe-theme--color--ui-accent, #06c);--pfe-accordion__base--Padding:var(--pfe-theme--container-spacer, 16px);display:block;position:relative;overflow:hidden;margin:0;color:#3c3f42;color:var(--pfe-accordion--Color,var(--pfe-broadcasted--text,#3c3f42))}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host{background-color:#fff!important;color:#151515!important}}:host([on=dark]){--pfe-accordion--accent:var(--pfe-theme--color--ui-accent--on-dark, #73bcf7)}:host([on=saturated]){--pfe-accordion--accent:var(--pfe-theme--color--ui-accent--on-saturated, #fff)}:host([pfe-disclosure=true]){--pfe-accordion--BorderRightWidth:var(--pfe-theme--surface--border-width, 1px);--pfe-accordion--BorderLeftWidth:var(--pfe-theme--surface--border-width, 1px);--pfe-accordion--BorderColor--accent:var(--pfe-theme--color--surface--border, #d2d2d2)}\n/*# sourceMappingURL=pfe-accordion.min.css.map */\n"}static get properties(){return{}}static get slots(){return{default:{title:"Default",type:"array",namedSlot:!1,items:{oneOf:[{$ref:"pfe-accordion-header"},{$ref:"pfe-accordion-panel"}]}}}}static get tag(){return"pfe-accordion"}get styleUrl(){return"pfe-accordion.scss"}get templateUrl(){return"pfe-accordion.html"}get schemaUrl(){return"pfe-accordion.json"}static get cascadingAttributes(){return{on:"pfe-accordion-header, pfe-accordion-panel"}}static get events(){return{change:`${this.tag}:change`}}static get PfeType(){return e.PfeTypes.Container}static get observedAttributes(){return["pfe-disclosure"]}constructor(){super(r,{type:r.PfeType}),this._linkPanels=this._linkPanels.bind(this),this._observer=new MutationObserver(this._linkPanels)}connectedCallback(){super.connectedCallback(),this.setAttribute("role","tablist"),this.setAttribute("defined",""),this.addEventListener(r.events.change,this._changeHandler),this.addEventListener("keydown",this._keydownHandler),Promise.all([customElements.whenDefined(o.tag),customElements.whenDefined(a.tag)]).then(()=>{this.children.length&&this._linkPanels(),this._observer.observe(this,{childList:!0})})}disconnectedCallback(){this.removeEventListener(r.events.change,this._changeHandler),this.removeEventListener("keydown",this._keydownHandler),this._observer.disconnect()}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),"pfe-disclosure"===e&&("true"===r?(this._allHeaders().forEach(e=>e.setAttribute("pfe-disclosure","true")),this._allPanels().forEach(e=>e.setAttribute("pfe-disclosure","true"))):(this._allHeaders().forEach(e=>e.setAttribute("pfe-disclosure","false")),this._allPanels().forEach(e=>e.setAttribute("pfe-disclosure","false"))))}toggle(e){const t=this._allHeaders(),r=this._allPanels(),o=t[e],a=r[e];o&&a&&(o.expanded?(this._collapseHeader(o),this._collapsePanel(a)):(this._expandHeader(o),this._expandPanel(a)))}expand(e){const t=this._allHeaders(),r=this._allPanels(),o=t[e],a=r[e];o&&a&&(this._expandHeader(o),this._expandPanel(a))}expandAll(){const e=this._allHeaders(),t=this._allPanels();e.forEach(e=>this._expandHeader(e)),t.forEach(e=>this._expandPanel(e))}collapse(e){const t=this._allHeaders(),r=this._allPanels(),o=t[e],a=r[e];o&&a&&(this._collapseHeader(o),this._collapsePanel(a))}collapseAll(){const e=this._allHeaders(),t=this._allPanels();e.forEach(e=>this._collapseHeader(e)),t.forEach(e=>this._collapsePanel(e))}_linkPanels(){const e=this._allHeaders();if(e.forEach(e=>{const t=this._panelForHeader(e);t&&(e.setAttribute("aria-controls",t.pfeId),t.setAttribute("aria-labelledby",e.pfeId))}),1===e.length){if(this.hasAttribute("pfe-disclosure")&&"false"===this.getAttribute("pfe-disclosure"))return;this.setAttribute("pfe-disclosure","true")}e.length>1&&this.hasAttribute("pfe-disclosure")&&this.removeAttribute("pfe-disclosure")}_changeHandler(e){if(this.classList.contains("animating"))return;const t=e.target,r=e.target.nextElementSibling;e.detail.expanded?(this._expandHeader(t),this._expandPanel(r)):(this._collapseHeader(t),this._collapsePanel(r))}_toggle(e,t){}_expandHeader(e){e.expanded=!0}_expandPanel(e){if(!e)return void console.error(`${r.tag}: Trying to expand a panel that doesn't exist`);if(e.expanded)return;e.expanded=!0;const t=e.getBoundingClientRect().height;this._animate(e,0,t)}_collapseHeader(e){e.expanded=!1}_collapsePanel(e){if(!e)return void console.error(`${r.tag}: Trying to collapse a panel that doesn't exist`);if(!e.expanded)return;const t=e.getBoundingClientRect().height;e.expanded=!1,this._animate(e,t,0)}_animate(e,t,r){if(e){const o=e.previousElementSibling;o&&o.classList.add("animating"),e.classList.add("animating"),e.style.height=`${t}px`,requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.style.height=`${r}px`,e.addEventListener("transitionend",this._transitionEndHandler)})})}}_keydownHandler(e){const t=e.target;if(!this._isHeader(t))return;let r;switch(e.key){case"ArrowDown":case"Down":case"ArrowRight":case"Right":r=this._nextHeader();break;case"ArrowUp":case"Up":case"ArrowLeft":case"Left":r=this._previousHeader();break;case"Home":r=this._firstHeader();break;case"End":r=this._lastHeader();break;default:return}r.shadowRoot.querySelector("button").focus()}_transitionEndHandler(e){const t=e.target.previousElementSibling;t&&t.classList.remove("animating"),e.target.style.height="",e.target.classList.remove("animating"),e.target.removeEventListener("transitionend",this._transitionEndHandler)}_allHeaders(){return[...this.querySelectorAll(o.tag)]}_allPanels(){return[...this.querySelectorAll(a.tag)]}_panelForHeader(e){const t=e.nextElementSibling;if(t){if(t.tagName.toLowerCase()===a.tag)return t;console.error(`${r.tag}: Sibling element to a header needs to be a panel`)}}_previousHeader(){const e=this._allHeaders();let t=e.findIndex(e=>e===document.activeElement)-1;return e[(t+e.length)%e.length]}_nextHeader(){const e=this._allHeaders();let t=e.findIndex(e=>e===document.activeElement)+1;return e[t%e.length]}_firstHeader(){return this._allHeaders()[0]}_lastHeader(){const e=this._allHeaders();return e[e.length-1]}_isHeader(e){return e.tagName.toLowerCase()===o.tag}}class o extends e{static get version(){return"1.0.0-prerelease.54"}get html(){return''}static get tag(){return"pfe-accordion-header"}get styleUrl(){return"pfe-accordion-header.scss"}get templateUrl(){return"pfe-accordion-header.html"}get pfeId(){return this.getAttribute("pfe-id")}set pfeId(e){e&&this.setAttribute("pfe-id",e)}static get observedAttributes(){return["aria-expanded"]}constructor(){super(o),this.button=this.shadowRoot.querySelector("button"),this._init=this._init.bind(this),this._clickHandler=this._clickHandler.bind(this),this._observer=new MutationObserver(this._init)}connectedCallback(){super.connectedCallback(),(this.children.length||this.textContent.trim().length)&&this._init(),this.addEventListener("click",this._clickHandler),this._observer.observe(this,{childList:!0})}disconnectedCallback(){this.removeEventListener("click",this._clickHandler),this._observer.disconnect()}get expanded(){return this.hasAttribute("aria-expanded")}set expanded(e){(e=Boolean(e))?(this.setAttribute("aria-expanded",!0),this.button.setAttribute("aria-expanded",!0)):(this.removeAttribute("aria-expanded"),this.button.setAttribute("aria-expanded",!1))}_init(){window.ShadyCSS&&this._observer.disconnect(),this.hasAttribute("role")||this.setAttribute("role","heading"),this.pfeId||(this.pfeId=`${o.tag}-${t()}`);const e=this.children[0];let r=!1;if(e){switch(e.tagName){case"H1":case"H2":case"H3":case"H4":case"H5":case"H6":r=!0}const t=document.createElement(e.tagName);this.button.innerText=e.innerText,t.appendChild(this.button),this.shadowRoot.appendChild(t)}else this.button.innerText=this.textContent.trim();r||console.warn(`${o.tag}: The first child in the light DOM must be a Header level tag (h1, h2, h3, h4, h5, or h6)`),window.ShadyCSS&&this._observer.observe(this,{childList:!0})}_clickHandler(e){this.emitEvent(r.events.change,{detail:{expanded:!this.expanded}})}}class a extends e{static get version(){return"1.0.0-prerelease.54"}get html(){return'
\n
\n \n
\n
'}static get tag(){return"pfe-accordion-panel"}get styleUrl(){return"pfe-accordion-panel.scss"}get templateUrl(){return"pfe-accordion-panel.html"}get pfeId(){return this.getAttribute("pfe-id")}set pfeId(e){e&&this.setAttribute("pfe-id",e)}constructor(){super(a)}connectedCallback(){super.connectedCallback(),this.hasAttribute("role")||this.setAttribute("role","region"),this.pfeId||(this.pfeId=`${a.tag}-${t()}`)}get expanded(){return this.hasAttribute("expanded")}set expanded(e){Boolean(e)?this.setAttribute("expanded",""):this.removeAttribute("expanded")}}e.create(o),e.create(a),e.create(r);export default r; +//# sourceMappingURL=pfe-accordion.min.js.map diff --git a/elements/pfe-accordion/dist/pfe-accordion.min.js.map b/elements/pfe-accordion/dist/pfe-accordion.min.js.map new file mode 100644 index 0000000000..3849a709a9 --- /dev/null +++ b/elements/pfe-accordion/dist/pfe-accordion.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-accordion.min.js","sources":["../_temp/pfe-accordion.js","../_temp/polyfills--pfe-accordion.js"],"sourcesContent":["/*!\n * PatternFly Elements: PfeAccordion 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\n// Import polyfills: findIndex\nimport \"./polyfills--pfe-accordion.js\";\n\nimport PFElement from \"../../pfelement/dist/pfelement.js\";\n\nfunction generateId() {\n return Math.random()\n .toString(36)\n .substr(2, 9);\n}\n\nclass PfeAccordion extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return ``;\n }\n\n static get properties() {\n return {};\n }\n\n static get slots() {\n return {\"default\":{\"title\":\"Default\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-accordion-header\"},{\"$ref\":\"pfe-accordion-panel\"}]}}};\n }\n static get tag() {\n return \"pfe-accordion\";\n }\n\n get styleUrl() {\n return \"pfe-accordion.scss\";\n }\n\n get templateUrl() {\n return \"pfe-accordion.html\";\n }\n\n get schemaUrl() {\n return \"pfe-accordion.json\";\n }\n\n static get cascadingAttributes() {\n return {\n on: \"pfe-accordion-header, pfe-accordion-panel\"\n };\n }\n\n static get events() {\n return {\n change: `${this.tag}:change`\n };\n }\n\n // Declare the type of this component\n static get PfeType() {\n return PFElement.PfeTypes.Container;\n }\n\n static get observedAttributes() {\n return [\"pfe-disclosure\"];\n }\n\n constructor() {\n super(PfeAccordion, { type: PfeAccordion.PfeType });\n\n this._linkPanels = this._linkPanels.bind(this);\n this._observer = new MutationObserver(this._linkPanels);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n this.setAttribute(\"role\", \"tablist\");\n this.setAttribute(\"defined\", \"\");\n\n this.addEventListener(PfeAccordion.events.change, this._changeHandler);\n this.addEventListener(\"keydown\", this._keydownHandler);\n\n Promise.all([\n customElements.whenDefined(PfeAccordionHeader.tag),\n customElements.whenDefined(PfeAccordionPanel.tag)\n ]).then(() => {\n if (this.children.length) {\n this._linkPanels();\n }\n\n this._observer.observe(this, { childList: true });\n });\n }\n\n disconnectedCallback() {\n this.removeEventListener(PfeAccordion.events.change, this._changeHandler);\n this.removeEventListener(\"keydown\", this._keydownHandler);\n this._observer.disconnect();\n }\n\n attributeChangedCallback(attr, oldVal, newVal) {\n super.attributeChangedCallback(attr, oldVal, newVal);\n\n if (attr === \"pfe-disclosure\") {\n if (newVal === \"true\") {\n this._allHeaders().forEach(header =>\n header.setAttribute(\"pfe-disclosure\", \"true\")\n );\n this._allPanels().forEach(panel =>\n panel.setAttribute(\"pfe-disclosure\", \"true\")\n );\n } else {\n this._allHeaders().forEach(header =>\n header.setAttribute(\"pfe-disclosure\", \"false\")\n );\n this._allPanels().forEach(panel =>\n panel.setAttribute(\"pfe-disclosure\", \"false\")\n );\n }\n }\n }\n\n toggle(index) {\n const headers = this._allHeaders();\n const panels = this._allPanels();\n const header = headers[index];\n const panel = panels[index];\n\n if (!header || !panel) {\n return;\n }\n\n if (!header.expanded) {\n this._expandHeader(header);\n this._expandPanel(panel);\n } else {\n this._collapseHeader(header);\n this._collapsePanel(panel);\n }\n }\n\n expand(index) {\n const headers = this._allHeaders();\n const panels = this._allPanels();\n const header = headers[index];\n const panel = panels[index];\n\n if (!header || !panel) {\n return;\n }\n\n this._expandHeader(header);\n this._expandPanel(panel);\n }\n\n expandAll() {\n const headers = this._allHeaders();\n const panels = this._allPanels();\n\n headers.forEach(header => this._expandHeader(header));\n panels.forEach(panel => this._expandPanel(panel));\n }\n\n collapse(index) {\n const headers = this._allHeaders();\n const panels = this._allPanels();\n const header = headers[index];\n const panel = panels[index];\n\n if (!header || !panel) {\n return;\n }\n\n this._collapseHeader(header);\n this._collapsePanel(panel);\n }\n\n collapseAll() {\n const headers = this._allHeaders();\n const panels = this._allPanels();\n\n headers.forEach(header => this._collapseHeader(header));\n panels.forEach(panel => this._collapsePanel(panel));\n }\n\n _linkPanels() {\n const headers = this._allHeaders();\n headers.forEach(header => {\n const panel = this._panelForHeader(header);\n\n if (!panel) {\n return;\n }\n\n header.setAttribute(\"aria-controls\", panel.pfeId);\n panel.setAttribute(\"aria-labelledby\", header.pfeId);\n });\n\n if (headers.length === 1) {\n if (\n this.hasAttribute(\"pfe-disclosure\") &&\n this.getAttribute(\"pfe-disclosure\") === \"false\"\n ) {\n return;\n }\n\n this.setAttribute(\"pfe-disclosure\", \"true\");\n }\n\n if (headers.length > 1) {\n if (this.hasAttribute(\"pfe-disclosure\")) {\n this.removeAttribute(\"pfe-disclosure\");\n }\n }\n }\n\n _changeHandler(evt) {\n if (this.classList.contains(\"animating\")) {\n return;\n }\n\n const header = evt.target;\n const panel = evt.target.nextElementSibling;\n\n if (evt.detail.expanded) {\n this._expandHeader(header);\n this._expandPanel(panel);\n } else {\n this._collapseHeader(header);\n this._collapsePanel(panel);\n }\n }\n\n _toggle(header, panel) {}\n\n _expandHeader(header) {\n header.expanded = true;\n }\n\n _expandPanel(panel) {\n if (!panel) {\n console.error(\n `${PfeAccordion.tag}: Trying to expand a panel that doesn't exist`\n );\n return;\n }\n\n if (panel.expanded) {\n return;\n }\n\n panel.expanded = true;\n\n const height = panel.getBoundingClientRect().height;\n this._animate(panel, 0, height);\n }\n\n _collapseHeader(header) {\n header.expanded = false;\n }\n\n _collapsePanel(panel) {\n if (!panel) {\n console.error(\n `${PfeAccordion.tag}: Trying to collapse a panel that doesn't exist`\n );\n return;\n }\n\n if (!panel.expanded) {\n return;\n }\n\n const height = panel.getBoundingClientRect().height;\n panel.expanded = false;\n\n this._animate(panel, height, 0);\n }\n\n _animate(panel, start, end) {\n if (panel) {\n const header = panel.previousElementSibling;\n if (header) {\n header.classList.add(\"animating\");\n }\n panel.classList.add(\"animating\");\n panel.style.height = `${start}px`;\n\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n panel.style.height = `${end}px`;\n panel.addEventListener(\"transitionend\", this._transitionEndHandler);\n });\n });\n }\n }\n\n _keydownHandler(evt) {\n const currentHeader = evt.target;\n\n if (!this._isHeader(currentHeader)) {\n return;\n }\n\n let newHeader;\n\n switch (evt.key) {\n case \"ArrowDown\":\n case \"Down\":\n case \"ArrowRight\":\n case \"Right\":\n newHeader = this._nextHeader();\n break;\n case \"ArrowUp\":\n case \"Up\":\n case \"ArrowLeft\":\n case \"Left\":\n newHeader = this._previousHeader();\n break;\n case \"Home\":\n newHeader = this._firstHeader();\n break;\n case \"End\":\n newHeader = this._lastHeader();\n break;\n default:\n return;\n }\n\n newHeader.shadowRoot.querySelector(\"button\").focus();\n }\n\n _transitionEndHandler(evt) {\n const header = evt.target.previousElementSibling;\n if (header) {\n header.classList.remove(\"animating\");\n }\n evt.target.style.height = \"\";\n evt.target.classList.remove(\"animating\");\n evt.target.removeEventListener(\"transitionend\", this._transitionEndHandler);\n }\n\n _allHeaders() {\n return [...this.querySelectorAll(PfeAccordionHeader.tag)];\n }\n\n _allPanels() {\n return [...this.querySelectorAll(PfeAccordionPanel.tag)];\n }\n\n _panelForHeader(header) {\n const next = header.nextElementSibling;\n\n if (!next) {\n return;\n }\n\n if (next.tagName.toLowerCase() !== PfeAccordionPanel.tag) {\n console.error(\n `${PfeAccordion.tag}: Sibling element to a header needs to be a panel`\n );\n return;\n }\n\n return next;\n }\n\n _previousHeader() {\n const headers = this._allHeaders();\n let newIndex =\n headers.findIndex(header => header === document.activeElement) - 1;\n return headers[(newIndex + headers.length) % headers.length];\n }\n\n _nextHeader() {\n const headers = this._allHeaders();\n let newIndex =\n headers.findIndex(header => header === document.activeElement) + 1;\n return headers[newIndex % headers.length];\n }\n\n _firstHeader() {\n const headers = this._allHeaders();\n return headers[0];\n }\n\n _lastHeader() {\n const headers = this._allHeaders();\n return headers[headers.length - 1];\n }\n\n _isHeader(element) {\n return element.tagName.toLowerCase() === PfeAccordionHeader.tag;\n }\n}\n\nclass PfeAccordionHeader extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return ``;\n }\n static get tag() {\n return \"pfe-accordion-header\";\n }\n\n get styleUrl() {\n return \"pfe-accordion-header.scss\";\n }\n\n get templateUrl() {\n return \"pfe-accordion-header.html\";\n }\n\n get pfeId() {\n return this.getAttribute(\"pfe-id\");\n }\n\n set pfeId(id) {\n if (!id) {\n return;\n }\n\n this.setAttribute(\"pfe-id\", id);\n }\n\n static get observedAttributes() {\n return [\"aria-expanded\"];\n }\n\n constructor() {\n super(PfeAccordionHeader);\n\n this.button = this.shadowRoot.querySelector(\"button\");\n\n this._init = this._init.bind(this);\n this._clickHandler = this._clickHandler.bind(this);\n this._observer = new MutationObserver(this._init);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n if (this.children.length || this.textContent.trim().length) {\n this._init();\n }\n\n this.addEventListener(\"click\", this._clickHandler);\n this._observer.observe(this, { childList: true });\n }\n\n disconnectedCallback() {\n this.removeEventListener(\"click\", this._clickHandler);\n this._observer.disconnect();\n }\n\n get expanded() {\n return this.hasAttribute(\"aria-expanded\");\n }\n\n set expanded(val) {\n val = Boolean(val);\n\n if (val) {\n this.setAttribute(\"aria-expanded\", true);\n this.button.setAttribute(\"aria-expanded\", true);\n } else {\n this.removeAttribute(\"aria-expanded\");\n this.button.setAttribute(\"aria-expanded\", false);\n }\n }\n\n _init() {\n if (window.ShadyCSS) {\n this._observer.disconnect();\n }\n\n if (!this.hasAttribute(\"role\")) {\n this.setAttribute(\"role\", \"heading\");\n }\n\n if (!this.pfeId) {\n this.pfeId = `${PfeAccordionHeader.tag}-${generateId()}`;\n }\n\n const child = this.children[0];\n let isHeaderTag = false;\n\n if (child) {\n switch (child.tagName) {\n case \"H1\":\n case \"H2\":\n case \"H3\":\n case \"H4\":\n case \"H5\":\n case \"H6\":\n isHeaderTag = true;\n break;\n }\n\n const wrapperTag = document.createElement(child.tagName);\n this.button.innerText = child.innerText;\n\n wrapperTag.appendChild(this.button);\n this.shadowRoot.appendChild(wrapperTag);\n } else {\n this.button.innerText = this.textContent.trim();\n }\n\n if (!isHeaderTag) {\n console.warn(\n `${PfeAccordionHeader.tag}: The first child in the light DOM must be a Header level tag (h1, h2, h3, h4, h5, or h6)`\n );\n }\n\n if (window.ShadyCSS) {\n this._observer.observe(this, { childList: true });\n }\n }\n\n _clickHandler(event) {\n this.emitEvent(PfeAccordion.events.change, {\n detail: { expanded: !this.expanded }\n });\n }\n}\n\nclass PfeAccordionPanel extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
\n
\n \n
\n
`;\n }\n static get tag() {\n return \"pfe-accordion-panel\";\n }\n\n get styleUrl() {\n return \"pfe-accordion-panel.scss\";\n }\n\n get templateUrl() {\n return \"pfe-accordion-panel.html\";\n }\n\n get pfeId() {\n return this.getAttribute(\"pfe-id\");\n }\n\n set pfeId(id) {\n if (!id) {\n return;\n }\n\n this.setAttribute(\"pfe-id\", id);\n }\n\n constructor() {\n super(PfeAccordionPanel);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n if (!this.hasAttribute(\"role\")) {\n this.setAttribute(\"role\", \"region\");\n }\n\n if (!this.pfeId) {\n this.pfeId = `${PfeAccordionPanel.tag}-${generateId()}`;\n }\n }\n\n get expanded() {\n return this.hasAttribute(\"expanded\");\n }\n\n set expanded(val) {\n const value = Boolean(val);\n\n if (value) {\n this.setAttribute(\"expanded\", \"\");\n } else {\n this.removeAttribute(\"expanded\");\n }\n }\n}\n\nPFElement.create(PfeAccordionHeader);\nPFElement.create(PfeAccordionPanel);\nPFElement.create(PfeAccordion);\n\nexport { PfeAccordion as default };\n","// @POLYFILL Array.prototype.findIndex\n// https://tc39.github.io/ecma262/#sec-array.prototype.findIndex\nif (!Array.prototype.findIndex) {\n Object.defineProperty(Array.prototype, \"findIndex\", {\n value: function(predicate) {\n // 1. Let O be ? ToObject(this value).\n if (this == null) {\n throw new TypeError('\"this\" is null or not defined');\n }\n\n var o = Object(this);\n\n // 2. Let len be ? ToLength(? Get(O, \"length\")).\n var len = o.length >>> 0;\n\n // 3. If IsCallable(predicate) is false, throw a TypeError exception.\n if (typeof predicate !== \"function\") {\n throw new TypeError(\"predicate must be a function\");\n }\n\n // 4. If thisArg was supplied, let T be thisArg; else let T be undefined.\n var thisArg = arguments[1];\n\n // 5. Let k be 0.\n var k = 0;\n\n // 6. Repeat, while k < len\n while (k < len) {\n // a. Let Pk be ! ToString(k).\n // b. Let kValue be ? Get(O, Pk).\n // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).\n // d. If testResult is true, return k.\n var kValue = o[k];\n if (predicate.call(thisArg, kValue, k, o)) {\n return k;\n }\n // e. Increase k by 1.\n k++;\n }\n\n // 7. Return -1.\n return -1;\n }\n });\n}\n"],"names":["generateId","Math","random","toString","substr","Array","prototype","findIndex","Object","defineProperty","value","predicate","this","TypeError","o","len","length","thisArg","arguments","k","kValue","call","PfeAccordion","PFElement","version","html","properties","slots","default","title","type","namedSlot","items","oneOf","$ref","tag","styleUrl","templateUrl","schemaUrl","cascadingAttributes","on","events","change","PfeType","PfeTypes","Container","observedAttributes","[object Object]","super","_linkPanels","bind","_observer","MutationObserver","connectedCallback","setAttribute","addEventListener","_changeHandler","_keydownHandler","Promise","all","customElements","whenDefined","PfeAccordionHeader","PfeAccordionPanel","then","children","observe","childList","removeEventListener","disconnect","attr","oldVal","newVal","attributeChangedCallback","_allHeaders","forEach","header","_allPanels","panel","index","headers","panels","expanded","_collapseHeader","_collapsePanel","_expandHeader","_expandPanel","_panelForHeader","pfeId","hasAttribute","getAttribute","removeAttribute","evt","classList","contains","target","nextElementSibling","detail","console","error","height","getBoundingClientRect","_animate","start","end","previousElementSibling","add","style","requestAnimationFrame","_transitionEndHandler","currentHeader","_isHeader","newHeader","key","_nextHeader","_previousHeader","_firstHeader","_lastHeader","shadowRoot","querySelector","focus","remove","querySelectorAll","next","tagName","toLowerCase","newIndex","document","activeElement","element","id","button","_init","_clickHandler","textContent","trim","val","Boolean","window","ShadyCSS","child","isHeaderTag","wrapperTag","createElement","innerText","appendChild","warn","event","emitEvent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0BxC,EAC9BC,qBACE,MAAO,sBAGTC,WACE,MAAO,qyKAQTU,iBACE,MAAO,sBAGTC,eACE,MAAO,2BAGTC,kBACE,MAAO,2BAGTmD,YACE,OAAO5E,KAAK8E,aAAa,UAG3BF,UAAU0C,GACHA,GAILtH,KAAK0C,aAAa,SAAU4E,GAG9BnF,cACEC,MAAMe,GAGRhB,oBACEC,MAAMK,oBAEDzC,KAAK6E,aAAa,SACrB7E,KAAK0C,aAAa,OAAQ,UAGvB1C,KAAK4E,QACR5E,KAAK4E,SAAWzB,EAAkB5B,OAAOnC,OAI7CkF,eACE,OAAOtE,KAAK6E,aAAa,YAG3BP,aAAasD,GACGC,QAAQD,GAGpB5H,KAAK0C,aAAa,WAAY,IAE9B1C,KAAK+E,gBAAgB,aAK3BpE,EAAU8H,OAAOvF,GACjBvC,EAAU8H,OAAOtF,GACjBxC,EAAU8H,OAAO/H"} \ No newline at end of file diff --git a/elements/pfe-accordion/dist/pfe-accordion.umd.js b/elements/pfe-accordion/dist/pfe-accordion.umd.js new file mode 100644 index 0000000000..2c3566d441 --- /dev/null +++ b/elements/pfe-accordion/dist/pfe-accordion.umd.js @@ -0,0 +1,843 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../../pfelement/dist/pfelement.umd')) : + typeof define === 'function' && define.amd ? define(['../../pfelement/dist/pfelement.umd'], factory) : + (global.PfeAccordion = factory(global.PFElement)); +}(this, (function (PFElement) { 'use strict'; + + PFElement = PFElement && PFElement.hasOwnProperty('default') ? PFElement['default'] : PFElement; + + // @POLYFILL Array.prototype.findIndex + // https://tc39.github.io/ecma262/#sec-array.prototype.findIndex + if (!Array.prototype.findIndex) { + Object.defineProperty(Array.prototype, "findIndex", { + value: function value(predicate) { + // 1. Let O be ? ToObject(this value). + if (this == null) { + throw new TypeError('"this" is null or not defined'); + } + + var o = Object(this); + + // 2. Let len be ? ToLength(? Get(O, "length")). + var len = o.length >>> 0; + + // 3. If IsCallable(predicate) is false, throw a TypeError exception. + if (typeof predicate !== "function") { + throw new TypeError("predicate must be a function"); + } + + // 4. If thisArg was supplied, let T be thisArg; else let T be undefined. + var thisArg = arguments[1]; + + // 5. Let k be 0. + var k = 0; + + // 6. Repeat, while k < len + while (k < len) { + // a. Let Pk be ! ToString(k). + // b. Let kValue be ? Get(O, Pk). + // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + // d. If testResult is true, return k. + var kValue = o[k]; + if (predicate.call(thisArg, kValue, k, o)) { + return k; + } + // e. Increase k by 1. + k++; + } + + // 7. Return -1. + return -1; + } + }); + } + + var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + }; + + var createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + }(); + + var get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + + if (getter === undefined) { + return undefined; + } + + return getter.call(receiver); + } + }; + + var inherits = function (subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + }; + + var possibleConstructorReturn = function (self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && (typeof call === "object" || typeof call === "function") ? call : self; + }; + + var toConsumableArray = function (arr) { + if (Array.isArray(arr)) { + for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; + + return arr2; + } else { + return Array.from(arr); + } + }; + + /*! + * PatternFly Elements: PfeAccordion 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + + function generateId() { + return Math.random().toString(36).substr(2, 9); + } + + var PfeAccordion = function (_PFElement) { + inherits(PfeAccordion, _PFElement); + createClass(PfeAccordion, [{ + key: "html", + get: function get$$1() { + return ""; + } + }, { + key: "styleUrl", + get: function get$$1() { + return "pfe-accordion.scss"; + } + }, { + key: "templateUrl", + get: function get$$1() { + return "pfe-accordion.html"; + } + }, { + key: "schemaUrl", + get: function get$$1() { + return "pfe-accordion.json"; + } + }], [{ + key: "version", + get: function get$$1() { + return "1.0.0-prerelease.54"; + } + }, { + key: "properties", + get: function get$$1() { + return {}; + } + }, { + key: "slots", + get: function get$$1() { + return { "default": { "title": "Default", "type": "array", "namedSlot": false, "items": { "oneOf": [{ "$ref": "pfe-accordion-header" }, { "$ref": "pfe-accordion-panel" }] } } }; + } + }, { + key: "tag", + get: function get$$1() { + return "pfe-accordion"; + } + }, { + key: "cascadingAttributes", + get: function get$$1() { + return { + on: "pfe-accordion-header, pfe-accordion-panel" + }; + } + }, { + key: "events", + get: function get$$1() { + return { + change: this.tag + ":change" + }; + } + + // Declare the type of this component + + }, { + key: "PfeType", + get: function get$$1() { + return PFElement.PfeTypes.Container; + } + }, { + key: "observedAttributes", + get: function get$$1() { + return ["pfe-disclosure"]; + } + }]); + + function PfeAccordion() { + classCallCheck(this, PfeAccordion); + + var _this = possibleConstructorReturn(this, (PfeAccordion.__proto__ || Object.getPrototypeOf(PfeAccordion)).call(this, PfeAccordion, { type: PfeAccordion.PfeType })); + + _this._linkPanels = _this._linkPanels.bind(_this); + _this._observer = new MutationObserver(_this._linkPanels); + return _this; + } + + createClass(PfeAccordion, [{ + key: "connectedCallback", + value: function connectedCallback() { + var _this2 = this; + + get(PfeAccordion.prototype.__proto__ || Object.getPrototypeOf(PfeAccordion.prototype), "connectedCallback", this).call(this); + + this.setAttribute("role", "tablist"); + this.setAttribute("defined", ""); + + this.addEventListener(PfeAccordion.events.change, this._changeHandler); + this.addEventListener("keydown", this._keydownHandler); + + Promise.all([customElements.whenDefined(PfeAccordionHeader.tag), customElements.whenDefined(PfeAccordionPanel.tag)]).then(function () { + if (_this2.children.length) { + _this2._linkPanels(); + } + + _this2._observer.observe(_this2, { childList: true }); + }); + } + }, { + key: "disconnectedCallback", + value: function disconnectedCallback() { + this.removeEventListener(PfeAccordion.events.change, this._changeHandler); + this.removeEventListener("keydown", this._keydownHandler); + this._observer.disconnect(); + } + }, { + key: "attributeChangedCallback", + value: function attributeChangedCallback(attr, oldVal, newVal) { + get(PfeAccordion.prototype.__proto__ || Object.getPrototypeOf(PfeAccordion.prototype), "attributeChangedCallback", this).call(this, attr, oldVal, newVal); + + if (attr === "pfe-disclosure") { + if (newVal === "true") { + this._allHeaders().forEach(function (header) { + return header.setAttribute("pfe-disclosure", "true"); + }); + this._allPanels().forEach(function (panel) { + return panel.setAttribute("pfe-disclosure", "true"); + }); + } else { + this._allHeaders().forEach(function (header) { + return header.setAttribute("pfe-disclosure", "false"); + }); + this._allPanels().forEach(function (panel) { + return panel.setAttribute("pfe-disclosure", "false"); + }); + } + } + } + }, { + key: "toggle", + value: function toggle(index) { + var headers = this._allHeaders(); + var panels = this._allPanels(); + var header = headers[index]; + var panel = panels[index]; + + if (!header || !panel) { + return; + } + + if (!header.expanded) { + this._expandHeader(header); + this._expandPanel(panel); + } else { + this._collapseHeader(header); + this._collapsePanel(panel); + } + } + }, { + key: "expand", + value: function expand(index) { + var headers = this._allHeaders(); + var panels = this._allPanels(); + var header = headers[index]; + var panel = panels[index]; + + if (!header || !panel) { + return; + } + + this._expandHeader(header); + this._expandPanel(panel); + } + }, { + key: "expandAll", + value: function expandAll() { + var _this3 = this; + + var headers = this._allHeaders(); + var panels = this._allPanels(); + + headers.forEach(function (header) { + return _this3._expandHeader(header); + }); + panels.forEach(function (panel) { + return _this3._expandPanel(panel); + }); + } + }, { + key: "collapse", + value: function collapse(index) { + var headers = this._allHeaders(); + var panels = this._allPanels(); + var header = headers[index]; + var panel = panels[index]; + + if (!header || !panel) { + return; + } + + this._collapseHeader(header); + this._collapsePanel(panel); + } + }, { + key: "collapseAll", + value: function collapseAll() { + var _this4 = this; + + var headers = this._allHeaders(); + var panels = this._allPanels(); + + headers.forEach(function (header) { + return _this4._collapseHeader(header); + }); + panels.forEach(function (panel) { + return _this4._collapsePanel(panel); + }); + } + }, { + key: "_linkPanels", + value: function _linkPanels() { + var _this5 = this; + + var headers = this._allHeaders(); + headers.forEach(function (header) { + var panel = _this5._panelForHeader(header); + + if (!panel) { + return; + } + + header.setAttribute("aria-controls", panel.pfeId); + panel.setAttribute("aria-labelledby", header.pfeId); + }); + + if (headers.length === 1) { + if (this.hasAttribute("pfe-disclosure") && this.getAttribute("pfe-disclosure") === "false") { + return; + } + + this.setAttribute("pfe-disclosure", "true"); + } + + if (headers.length > 1) { + if (this.hasAttribute("pfe-disclosure")) { + this.removeAttribute("pfe-disclosure"); + } + } + } + }, { + key: "_changeHandler", + value: function _changeHandler(evt) { + if (this.classList.contains("animating")) { + return; + } + + var header = evt.target; + var panel = evt.target.nextElementSibling; + + if (evt.detail.expanded) { + this._expandHeader(header); + this._expandPanel(panel); + } else { + this._collapseHeader(header); + this._collapsePanel(panel); + } + } + }, { + key: "_toggle", + value: function _toggle(header, panel) {} + }, { + key: "_expandHeader", + value: function _expandHeader(header) { + header.expanded = true; + } + }, { + key: "_expandPanel", + value: function _expandPanel(panel) { + if (!panel) { + console.error(PfeAccordion.tag + ": Trying to expand a panel that doesn't exist"); + return; + } + + if (panel.expanded) { + return; + } + + panel.expanded = true; + + var height = panel.getBoundingClientRect().height; + this._animate(panel, 0, height); + } + }, { + key: "_collapseHeader", + value: function _collapseHeader(header) { + header.expanded = false; + } + }, { + key: "_collapsePanel", + value: function _collapsePanel(panel) { + if (!panel) { + console.error(PfeAccordion.tag + ": Trying to collapse a panel that doesn't exist"); + return; + } + + if (!panel.expanded) { + return; + } + + var height = panel.getBoundingClientRect().height; + panel.expanded = false; + + this._animate(panel, height, 0); + } + }, { + key: "_animate", + value: function _animate(panel, start, end) { + var _this6 = this; + + if (panel) { + var header = panel.previousElementSibling; + if (header) { + header.classList.add("animating"); + } + panel.classList.add("animating"); + panel.style.height = start + "px"; + + requestAnimationFrame(function () { + requestAnimationFrame(function () { + panel.style.height = end + "px"; + panel.addEventListener("transitionend", _this6._transitionEndHandler); + }); + }); + } + } + }, { + key: "_keydownHandler", + value: function _keydownHandler(evt) { + var currentHeader = evt.target; + + if (!this._isHeader(currentHeader)) { + return; + } + + var newHeader = void 0; + + switch (evt.key) { + case "ArrowDown": + case "Down": + case "ArrowRight": + case "Right": + newHeader = this._nextHeader(); + break; + case "ArrowUp": + case "Up": + case "ArrowLeft": + case "Left": + newHeader = this._previousHeader(); + break; + case "Home": + newHeader = this._firstHeader(); + break; + case "End": + newHeader = this._lastHeader(); + break; + default: + return; + } + + newHeader.shadowRoot.querySelector("button").focus(); + } + }, { + key: "_transitionEndHandler", + value: function _transitionEndHandler(evt) { + var header = evt.target.previousElementSibling; + if (header) { + header.classList.remove("animating"); + } + evt.target.style.height = ""; + evt.target.classList.remove("animating"); + evt.target.removeEventListener("transitionend", this._transitionEndHandler); + } + }, { + key: "_allHeaders", + value: function _allHeaders() { + return [].concat(toConsumableArray(this.querySelectorAll(PfeAccordionHeader.tag))); + } + }, { + key: "_allPanels", + value: function _allPanels() { + return [].concat(toConsumableArray(this.querySelectorAll(PfeAccordionPanel.tag))); + } + }, { + key: "_panelForHeader", + value: function _panelForHeader(header) { + var next = header.nextElementSibling; + + if (!next) { + return; + } + + if (next.tagName.toLowerCase() !== PfeAccordionPanel.tag) { + console.error(PfeAccordion.tag + ": Sibling element to a header needs to be a panel"); + return; + } + + return next; + } + }, { + key: "_previousHeader", + value: function _previousHeader() { + var headers = this._allHeaders(); + var newIndex = headers.findIndex(function (header) { + return header === document.activeElement; + }) - 1; + return headers[(newIndex + headers.length) % headers.length]; + } + }, { + key: "_nextHeader", + value: function _nextHeader() { + var headers = this._allHeaders(); + var newIndex = headers.findIndex(function (header) { + return header === document.activeElement; + }) + 1; + return headers[newIndex % headers.length]; + } + }, { + key: "_firstHeader", + value: function _firstHeader() { + var headers = this._allHeaders(); + return headers[0]; + } + }, { + key: "_lastHeader", + value: function _lastHeader() { + var headers = this._allHeaders(); + return headers[headers.length - 1]; + } + }, { + key: "_isHeader", + value: function _isHeader(element) { + return element.tagName.toLowerCase() === PfeAccordionHeader.tag; + } + }]); + return PfeAccordion; + }(PFElement); + + var PfeAccordionHeader = function (_PFElement2) { + inherits(PfeAccordionHeader, _PFElement2); + createClass(PfeAccordionHeader, [{ + key: "html", + get: function get$$1() { + return ""; + } + }, { + key: "styleUrl", + get: function get$$1() { + return "pfe-accordion-header.scss"; + } + }, { + key: "templateUrl", + get: function get$$1() { + return "pfe-accordion-header.html"; + } + }, { + key: "pfeId", + get: function get$$1() { + return this.getAttribute("pfe-id"); + }, + set: function set$$1(id) { + if (!id) { + return; + } + + this.setAttribute("pfe-id", id); + } + }], [{ + key: "version", + get: function get$$1() { + return "1.0.0-prerelease.54"; + } + }, { + key: "tag", + get: function get$$1() { + return "pfe-accordion-header"; + } + }, { + key: "observedAttributes", + get: function get$$1() { + return ["aria-expanded"]; + } + }]); + + function PfeAccordionHeader() { + classCallCheck(this, PfeAccordionHeader); + + var _this7 = possibleConstructorReturn(this, (PfeAccordionHeader.__proto__ || Object.getPrototypeOf(PfeAccordionHeader)).call(this, PfeAccordionHeader)); + + _this7.button = _this7.shadowRoot.querySelector("button"); + + _this7._init = _this7._init.bind(_this7); + _this7._clickHandler = _this7._clickHandler.bind(_this7); + _this7._observer = new MutationObserver(_this7._init); + return _this7; + } + + createClass(PfeAccordionHeader, [{ + key: "connectedCallback", + value: function connectedCallback() { + get(PfeAccordionHeader.prototype.__proto__ || Object.getPrototypeOf(PfeAccordionHeader.prototype), "connectedCallback", this).call(this); + + if (this.children.length || this.textContent.trim().length) { + this._init(); + } + + this.addEventListener("click", this._clickHandler); + this._observer.observe(this, { childList: true }); + } + }, { + key: "disconnectedCallback", + value: function disconnectedCallback() { + this.removeEventListener("click", this._clickHandler); + this._observer.disconnect(); + } + }, { + key: "_init", + value: function _init() { + if (window.ShadyCSS) { + this._observer.disconnect(); + } + + if (!this.hasAttribute("role")) { + this.setAttribute("role", "heading"); + } + + if (!this.pfeId) { + this.pfeId = PfeAccordionHeader.tag + "-" + generateId(); + } + + var child = this.children[0]; + var isHeaderTag = false; + + if (child) { + switch (child.tagName) { + case "H1": + case "H2": + case "H3": + case "H4": + case "H5": + case "H6": + isHeaderTag = true; + break; + } + + var wrapperTag = document.createElement(child.tagName); + this.button.innerText = child.innerText; + + wrapperTag.appendChild(this.button); + this.shadowRoot.appendChild(wrapperTag); + } else { + this.button.innerText = this.textContent.trim(); + } + + if (!isHeaderTag) { + console.warn(PfeAccordionHeader.tag + ": The first child in the light DOM must be a Header level tag (h1, h2, h3, h4, h5, or h6)"); + } + + if (window.ShadyCSS) { + this._observer.observe(this, { childList: true }); + } + } + }, { + key: "_clickHandler", + value: function _clickHandler(event) { + this.emitEvent(PfeAccordion.events.change, { + detail: { expanded: !this.expanded } + }); + } + }, { + key: "expanded", + get: function get$$1() { + return this.hasAttribute("aria-expanded"); + }, + set: function set$$1(val) { + val = Boolean(val); + + if (val) { + this.setAttribute("aria-expanded", true); + this.button.setAttribute("aria-expanded", true); + } else { + this.removeAttribute("aria-expanded"); + this.button.setAttribute("aria-expanded", false); + } + } + }]); + return PfeAccordionHeader; + }(PFElement); + + var PfeAccordionPanel = function (_PFElement3) { + inherits(PfeAccordionPanel, _PFElement3); + createClass(PfeAccordionPanel, [{ + key: "html", + get: function get$$1() { + return "
\n
\n \n
\n
"; + } + }, { + key: "styleUrl", + get: function get$$1() { + return "pfe-accordion-panel.scss"; + } + }, { + key: "templateUrl", + get: function get$$1() { + return "pfe-accordion-panel.html"; + } + }, { + key: "pfeId", + get: function get$$1() { + return this.getAttribute("pfe-id"); + }, + set: function set$$1(id) { + if (!id) { + return; + } + + this.setAttribute("pfe-id", id); + } + }], [{ + key: "version", + get: function get$$1() { + return "1.0.0-prerelease.54"; + } + }, { + key: "tag", + get: function get$$1() { + return "pfe-accordion-panel"; + } + }]); + + function PfeAccordionPanel() { + classCallCheck(this, PfeAccordionPanel); + return possibleConstructorReturn(this, (PfeAccordionPanel.__proto__ || Object.getPrototypeOf(PfeAccordionPanel)).call(this, PfeAccordionPanel)); + } + + createClass(PfeAccordionPanel, [{ + key: "connectedCallback", + value: function connectedCallback() { + get(PfeAccordionPanel.prototype.__proto__ || Object.getPrototypeOf(PfeAccordionPanel.prototype), "connectedCallback", this).call(this); + + if (!this.hasAttribute("role")) { + this.setAttribute("role", "region"); + } + + if (!this.pfeId) { + this.pfeId = PfeAccordionPanel.tag + "-" + generateId(); + } + } + }, { + key: "expanded", + get: function get$$1() { + return this.hasAttribute("expanded"); + }, + set: function set$$1(val) { + var value = Boolean(val); + + if (value) { + this.setAttribute("expanded", ""); + } else { + this.removeAttribute("expanded"); + } + } + }]); + return PfeAccordionPanel; + }(PFElement); + + PFElement.create(PfeAccordionHeader); + PFElement.create(PfeAccordionPanel); + PFElement.create(PfeAccordion); + + return PfeAccordion; + +}))); +//# sourceMappingURL=pfe-accordion.umd.js.map diff --git a/elements/pfe-accordion/dist/pfe-accordion.umd.js.map b/elements/pfe-accordion/dist/pfe-accordion.umd.js.map new file mode 100644 index 0000000000..b4310220ac --- /dev/null +++ b/elements/pfe-accordion/dist/pfe-accordion.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-accordion.umd.js","sources":["../_temp/polyfills--pfe-accordion.js","../_temp/pfe-accordion.umd.js"],"sourcesContent":["// @POLYFILL Array.prototype.findIndex\n// https://tc39.github.io/ecma262/#sec-array.prototype.findIndex\nif (!Array.prototype.findIndex) {\n Object.defineProperty(Array.prototype, \"findIndex\", {\n value: function(predicate) {\n // 1. Let O be ? ToObject(this value).\n if (this == null) {\n throw new TypeError('\"this\" is null or not defined');\n }\n\n var o = Object(this);\n\n // 2. Let len be ? ToLength(? Get(O, \"length\")).\n var len = o.length >>> 0;\n\n // 3. If IsCallable(predicate) is false, throw a TypeError exception.\n if (typeof predicate !== \"function\") {\n throw new TypeError(\"predicate must be a function\");\n }\n\n // 4. If thisArg was supplied, let T be thisArg; else let T be undefined.\n var thisArg = arguments[1];\n\n // 5. Let k be 0.\n var k = 0;\n\n // 6. Repeat, while k < len\n while (k < len) {\n // a. Let Pk be ! ToString(k).\n // b. Let kValue be ? Get(O, Pk).\n // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).\n // d. If testResult is true, return k.\n var kValue = o[k];\n if (predicate.call(thisArg, kValue, k, o)) {\n return k;\n }\n // e. Increase k by 1.\n k++;\n }\n\n // 7. Return -1.\n return -1;\n }\n });\n}\n","/*!\n * PatternFly Elements: PfeAccordion 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\n// Import polyfills: findIndex\nimport \"./polyfills--pfe-accordion.js\";\n\nimport PFElement from \"../../pfelement/dist/pfelement.umd\";\n\nfunction generateId() {\n return Math.random()\n .toString(36)\n .substr(2, 9);\n}\n\nclass PfeAccordion extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return ``;\n }\n\n static get properties() {\n return {};\n }\n\n static get slots() {\n return {\"default\":{\"title\":\"Default\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-accordion-header\"},{\"$ref\":\"pfe-accordion-panel\"}]}}};\n }\n static get tag() {\n return \"pfe-accordion\";\n }\n\n get styleUrl() {\n return \"pfe-accordion.scss\";\n }\n\n get templateUrl() {\n return \"pfe-accordion.html\";\n }\n\n get schemaUrl() {\n return \"pfe-accordion.json\";\n }\n\n static get cascadingAttributes() {\n return {\n on: \"pfe-accordion-header, pfe-accordion-panel\"\n };\n }\n\n static get events() {\n return {\n change: `${this.tag}:change`\n };\n }\n\n // Declare the type of this component\n static get PfeType() {\n return PFElement.PfeTypes.Container;\n }\n\n static get observedAttributes() {\n return [\"pfe-disclosure\"];\n }\n\n constructor() {\n super(PfeAccordion, { type: PfeAccordion.PfeType });\n\n this._linkPanels = this._linkPanels.bind(this);\n this._observer = new MutationObserver(this._linkPanels);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n this.setAttribute(\"role\", \"tablist\");\n this.setAttribute(\"defined\", \"\");\n\n this.addEventListener(PfeAccordion.events.change, this._changeHandler);\n this.addEventListener(\"keydown\", this._keydownHandler);\n\n Promise.all([\n customElements.whenDefined(PfeAccordionHeader.tag),\n customElements.whenDefined(PfeAccordionPanel.tag)\n ]).then(() => {\n if (this.children.length) {\n this._linkPanels();\n }\n\n this._observer.observe(this, { childList: true });\n });\n }\n\n disconnectedCallback() {\n this.removeEventListener(PfeAccordion.events.change, this._changeHandler);\n this.removeEventListener(\"keydown\", this._keydownHandler);\n this._observer.disconnect();\n }\n\n attributeChangedCallback(attr, oldVal, newVal) {\n super.attributeChangedCallback(attr, oldVal, newVal);\n\n if (attr === \"pfe-disclosure\") {\n if (newVal === \"true\") {\n this._allHeaders().forEach(header =>\n header.setAttribute(\"pfe-disclosure\", \"true\")\n );\n this._allPanels().forEach(panel =>\n panel.setAttribute(\"pfe-disclosure\", \"true\")\n );\n } else {\n this._allHeaders().forEach(header =>\n header.setAttribute(\"pfe-disclosure\", \"false\")\n );\n this._allPanels().forEach(panel =>\n panel.setAttribute(\"pfe-disclosure\", \"false\")\n );\n }\n }\n }\n\n toggle(index) {\n const headers = this._allHeaders();\n const panels = this._allPanels();\n const header = headers[index];\n const panel = panels[index];\n\n if (!header || !panel) {\n return;\n }\n\n if (!header.expanded) {\n this._expandHeader(header);\n this._expandPanel(panel);\n } else {\n this._collapseHeader(header);\n this._collapsePanel(panel);\n }\n }\n\n expand(index) {\n const headers = this._allHeaders();\n const panels = this._allPanels();\n const header = headers[index];\n const panel = panels[index];\n\n if (!header || !panel) {\n return;\n }\n\n this._expandHeader(header);\n this._expandPanel(panel);\n }\n\n expandAll() {\n const headers = this._allHeaders();\n const panels = this._allPanels();\n\n headers.forEach(header => this._expandHeader(header));\n panels.forEach(panel => this._expandPanel(panel));\n }\n\n collapse(index) {\n const headers = this._allHeaders();\n const panels = this._allPanels();\n const header = headers[index];\n const panel = panels[index];\n\n if (!header || !panel) {\n return;\n }\n\n this._collapseHeader(header);\n this._collapsePanel(panel);\n }\n\n collapseAll() {\n const headers = this._allHeaders();\n const panels = this._allPanels();\n\n headers.forEach(header => this._collapseHeader(header));\n panels.forEach(panel => this._collapsePanel(panel));\n }\n\n _linkPanels() {\n const headers = this._allHeaders();\n headers.forEach(header => {\n const panel = this._panelForHeader(header);\n\n if (!panel) {\n return;\n }\n\n header.setAttribute(\"aria-controls\", panel.pfeId);\n panel.setAttribute(\"aria-labelledby\", header.pfeId);\n });\n\n if (headers.length === 1) {\n if (\n this.hasAttribute(\"pfe-disclosure\") &&\n this.getAttribute(\"pfe-disclosure\") === \"false\"\n ) {\n return;\n }\n\n this.setAttribute(\"pfe-disclosure\", \"true\");\n }\n\n if (headers.length > 1) {\n if (this.hasAttribute(\"pfe-disclosure\")) {\n this.removeAttribute(\"pfe-disclosure\");\n }\n }\n }\n\n _changeHandler(evt) {\n if (this.classList.contains(\"animating\")) {\n return;\n }\n\n const header = evt.target;\n const panel = evt.target.nextElementSibling;\n\n if (evt.detail.expanded) {\n this._expandHeader(header);\n this._expandPanel(panel);\n } else {\n this._collapseHeader(header);\n this._collapsePanel(panel);\n }\n }\n\n _toggle(header, panel) {}\n\n _expandHeader(header) {\n header.expanded = true;\n }\n\n _expandPanel(panel) {\n if (!panel) {\n console.error(\n `${PfeAccordion.tag}: Trying to expand a panel that doesn't exist`\n );\n return;\n }\n\n if (panel.expanded) {\n return;\n }\n\n panel.expanded = true;\n\n const height = panel.getBoundingClientRect().height;\n this._animate(panel, 0, height);\n }\n\n _collapseHeader(header) {\n header.expanded = false;\n }\n\n _collapsePanel(panel) {\n if (!panel) {\n console.error(\n `${PfeAccordion.tag}: Trying to collapse a panel that doesn't exist`\n );\n return;\n }\n\n if (!panel.expanded) {\n return;\n }\n\n const height = panel.getBoundingClientRect().height;\n panel.expanded = false;\n\n this._animate(panel, height, 0);\n }\n\n _animate(panel, start, end) {\n if (panel) {\n const header = panel.previousElementSibling;\n if (header) {\n header.classList.add(\"animating\");\n }\n panel.classList.add(\"animating\");\n panel.style.height = `${start}px`;\n\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n panel.style.height = `${end}px`;\n panel.addEventListener(\"transitionend\", this._transitionEndHandler);\n });\n });\n }\n }\n\n _keydownHandler(evt) {\n const currentHeader = evt.target;\n\n if (!this._isHeader(currentHeader)) {\n return;\n }\n\n let newHeader;\n\n switch (evt.key) {\n case \"ArrowDown\":\n case \"Down\":\n case \"ArrowRight\":\n case \"Right\":\n newHeader = this._nextHeader();\n break;\n case \"ArrowUp\":\n case \"Up\":\n case \"ArrowLeft\":\n case \"Left\":\n newHeader = this._previousHeader();\n break;\n case \"Home\":\n newHeader = this._firstHeader();\n break;\n case \"End\":\n newHeader = this._lastHeader();\n break;\n default:\n return;\n }\n\n newHeader.shadowRoot.querySelector(\"button\").focus();\n }\n\n _transitionEndHandler(evt) {\n const header = evt.target.previousElementSibling;\n if (header) {\n header.classList.remove(\"animating\");\n }\n evt.target.style.height = \"\";\n evt.target.classList.remove(\"animating\");\n evt.target.removeEventListener(\"transitionend\", this._transitionEndHandler);\n }\n\n _allHeaders() {\n return [...this.querySelectorAll(PfeAccordionHeader.tag)];\n }\n\n _allPanels() {\n return [...this.querySelectorAll(PfeAccordionPanel.tag)];\n }\n\n _panelForHeader(header) {\n const next = header.nextElementSibling;\n\n if (!next) {\n return;\n }\n\n if (next.tagName.toLowerCase() !== PfeAccordionPanel.tag) {\n console.error(\n `${PfeAccordion.tag}: Sibling element to a header needs to be a panel`\n );\n return;\n }\n\n return next;\n }\n\n _previousHeader() {\n const headers = this._allHeaders();\n let newIndex =\n headers.findIndex(header => header === document.activeElement) - 1;\n return headers[(newIndex + headers.length) % headers.length];\n }\n\n _nextHeader() {\n const headers = this._allHeaders();\n let newIndex =\n headers.findIndex(header => header === document.activeElement) + 1;\n return headers[newIndex % headers.length];\n }\n\n _firstHeader() {\n const headers = this._allHeaders();\n return headers[0];\n }\n\n _lastHeader() {\n const headers = this._allHeaders();\n return headers[headers.length - 1];\n }\n\n _isHeader(element) {\n return element.tagName.toLowerCase() === PfeAccordionHeader.tag;\n }\n}\n\nclass PfeAccordionHeader extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return ``;\n }\n static get tag() {\n return \"pfe-accordion-header\";\n }\n\n get styleUrl() {\n return \"pfe-accordion-header.scss\";\n }\n\n get templateUrl() {\n return \"pfe-accordion-header.html\";\n }\n\n get pfeId() {\n return this.getAttribute(\"pfe-id\");\n }\n\n set pfeId(id) {\n if (!id) {\n return;\n }\n\n this.setAttribute(\"pfe-id\", id);\n }\n\n static get observedAttributes() {\n return [\"aria-expanded\"];\n }\n\n constructor() {\n super(PfeAccordionHeader);\n\n this.button = this.shadowRoot.querySelector(\"button\");\n\n this._init = this._init.bind(this);\n this._clickHandler = this._clickHandler.bind(this);\n this._observer = new MutationObserver(this._init);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n if (this.children.length || this.textContent.trim().length) {\n this._init();\n }\n\n this.addEventListener(\"click\", this._clickHandler);\n this._observer.observe(this, { childList: true });\n }\n\n disconnectedCallback() {\n this.removeEventListener(\"click\", this._clickHandler);\n this._observer.disconnect();\n }\n\n get expanded() {\n return this.hasAttribute(\"aria-expanded\");\n }\n\n set expanded(val) {\n val = Boolean(val);\n\n if (val) {\n this.setAttribute(\"aria-expanded\", true);\n this.button.setAttribute(\"aria-expanded\", true);\n } else {\n this.removeAttribute(\"aria-expanded\");\n this.button.setAttribute(\"aria-expanded\", false);\n }\n }\n\n _init() {\n if (window.ShadyCSS) {\n this._observer.disconnect();\n }\n\n if (!this.hasAttribute(\"role\")) {\n this.setAttribute(\"role\", \"heading\");\n }\n\n if (!this.pfeId) {\n this.pfeId = `${PfeAccordionHeader.tag}-${generateId()}`;\n }\n\n const child = this.children[0];\n let isHeaderTag = false;\n\n if (child) {\n switch (child.tagName) {\n case \"H1\":\n case \"H2\":\n case \"H3\":\n case \"H4\":\n case \"H5\":\n case \"H6\":\n isHeaderTag = true;\n break;\n }\n\n const wrapperTag = document.createElement(child.tagName);\n this.button.innerText = child.innerText;\n\n wrapperTag.appendChild(this.button);\n this.shadowRoot.appendChild(wrapperTag);\n } else {\n this.button.innerText = this.textContent.trim();\n }\n\n if (!isHeaderTag) {\n console.warn(\n `${PfeAccordionHeader.tag}: The first child in the light DOM must be a Header level tag (h1, h2, h3, h4, h5, or h6)`\n );\n }\n\n if (window.ShadyCSS) {\n this._observer.observe(this, { childList: true });\n }\n }\n\n _clickHandler(event) {\n this.emitEvent(PfeAccordion.events.change, {\n detail: { expanded: !this.expanded }\n });\n }\n}\n\nclass PfeAccordionPanel extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
\n
\n \n
\n
`;\n }\n static get tag() {\n return \"pfe-accordion-panel\";\n }\n\n get styleUrl() {\n return \"pfe-accordion-panel.scss\";\n }\n\n get templateUrl() {\n return \"pfe-accordion-panel.html\";\n }\n\n get pfeId() {\n return this.getAttribute(\"pfe-id\");\n }\n\n set pfeId(id) {\n if (!id) {\n return;\n }\n\n this.setAttribute(\"pfe-id\", id);\n }\n\n constructor() {\n super(PfeAccordionPanel);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n if (!this.hasAttribute(\"role\")) {\n this.setAttribute(\"role\", \"region\");\n }\n\n if (!this.pfeId) {\n this.pfeId = `${PfeAccordionPanel.tag}-${generateId()}`;\n }\n }\n\n get expanded() {\n return this.hasAttribute(\"expanded\");\n }\n\n set expanded(val) {\n const value = Boolean(val);\n\n if (value) {\n this.setAttribute(\"expanded\", \"\");\n } else {\n this.removeAttribute(\"expanded\");\n }\n }\n}\n\nPFElement.create(PfeAccordionHeader);\nPFElement.create(PfeAccordionPanel);\nPFElement.create(PfeAccordion);\n\nexport { PfeAccordion as default };\n"],"names":["Array","prototype","findIndex","Object","defineProperty","value","predicate","TypeError","o","len","length","thisArg","arguments","k","kValue","call","generateId","Math","random","toString","substr","PfeAccordion","on","change","tag","PFElement","PfeTypes","Container","type","PfeType","_linkPanels","bind","_observer","MutationObserver","setAttribute","addEventListener","events","_changeHandler","_keydownHandler","Promise","all","customElements","whenDefined","PfeAccordionHeader","PfeAccordionPanel","then","children","observe","childList","removeEventListener","disconnect","attr","oldVal","newVal","_allHeaders","forEach","header","_allPanels","panel","index","headers","panels","expanded","_expandHeader","_expandPanel","_collapseHeader","_collapsePanel","_panelForHeader","pfeId","hasAttribute","getAttribute","removeAttribute","evt","classList","contains","target","nextElementSibling","detail","console","error","height","getBoundingClientRect","_animate","start","end","previousElementSibling","add","style","requestAnimationFrame","_transitionEndHandler","currentHeader","_isHeader","newHeader","key","_nextHeader","_previousHeader","_firstHeader","_lastHeader","shadowRoot","querySelector","focus","remove","querySelectorAll","next","tagName","toLowerCase","newIndex","document","activeElement","element","id","button","_init","_clickHandler","textContent","trim","window","ShadyCSS","child","isHeaderTag","wrapperTag","createElement","innerText","appendChild","warn","event","emitEvent","val","Boolean","create"],"mappings":";;;;;;;;EAAA;EACA;EACA,IAAI,CAACA,MAAMC,SAAN,CAAgBC,SAArB,EAAgC;EAC9BC,SAAOC,cAAP,CAAsBJ,MAAMC,SAA5B,EAAuC,WAAvC,EAAoD;EAClDI,WAAO,eAASC,SAAT,EAAoB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;6BAWgB;EACf,aAAO,qBAAP;EACD;;;EAsBD,+BAAc;EAAA;EAAA,gIACNlE,iBADM;EAEb;;;;0CAEmB;EAClB;;EAEA,UAAI,CAAC,KAAKyB,YAAL,CAAkB,MAAlB,CAAL,EAAgC;EAC9B,aAAKnC,YAAL,CAAkB,MAAlB,EAA0B,QAA1B;EACD;;EAED,UAAI,CAAC,KAAKkC,KAAV,EAAiB;EACf,aAAKA,KAAL,GAAgBxB,kBAAkBpB,GAAlC,SAAyCR,YAAzC;EACD;EACF;;;6BAEc;EACb,aAAO,KAAKqD,YAAL,CAAkB,UAAlB,CAAP;EACD;2BAEY0D,KAAK;EAChB,UAAM1H,QAAQ2H,QAAQD,GAAR,CAAd;;EAEA,UAAI1H,KAAJ,EAAW;EACT,aAAK6B,YAAL,CAAkB,UAAlB,EAA8B,EAA9B;EACD,OAFD,MAEO;EACL,aAAKqC,eAAL,CAAqB,UAArB;EACD;EACF;;;IAlE6B9C;;EAqEhCA,UAAUwG,MAAV,CAAiBtF,kBAAjB;EACAlB,UAAUwG,MAAV,CAAiBrF,iBAAjB;EACAnB,UAAUwG,MAAV,CAAiB5G,YAAjB;;;;;;;;"} \ No newline at end of file diff --git a/elements/pfe-accordion/dist/pfe-accordion.umd.min.js b/elements/pfe-accordion/dist/pfe-accordion.umd.min.js new file mode 100644 index 0000000000..e6bdc566d0 --- /dev/null +++ b/elements/pfe-accordion/dist/pfe-accordion.umd.min.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("../../pfelement/dist/pfelement.umd")):"function"==typeof define&&define.amd?define(["../../pfelement/dist/pfelement.umd"],t):e.PfeAccordion=t(e.PFElement)}(this,function(e){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e,Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(e,t){if(null==this)throw new TypeError('"this" is null or not defined');var r=Object(this),o=r.length>>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var a=t,n=0;n:host{--pfe-accordion--BorderColor--accent:transparent;--pfe-accordion--BorderColor:var(--pfe-theme--color--surface--border, #d2d2d2);--pfe-accordion--BorderTopWidth:var(--pfe-theme--surface--border-width, 1px);--pfe-accordion--BorderRightWidth:0;--pfe-accordion--BorderBottomWidth:var(--pfe-theme--surface--border-width, 1px);--pfe-accordion--BorderLeftWidth:var(--pfe-theme--surface--border-width--heavy, 4px);--pfe-accordion--Color:var(--pfe-broadcasted--text, #3c3f42);--pfe-accordion--TextAlign:left;--pfe-accordion--accent:var(--pfe-theme--color--ui-accent, #06c);--pfe-accordion__base--Padding:var(--pfe-theme--container-spacer, 16px);display:block;position:relative;overflow:hidden;margin:0;color:#3c3f42;color:var(--pfe-accordion--Color,var(--pfe-broadcasted--text,#3c3f42))}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host{background-color:#fff!important;color:#151515!important}}:host([on=dark]){--pfe-accordion--accent:var(--pfe-theme--color--ui-accent--on-dark, #73bcf7)}:host([on=saturated]){--pfe-accordion--accent:var(--pfe-theme--color--ui-accent--on-saturated, #fff)}:host([pfe-disclosure=true]){--pfe-accordion--BorderRightWidth:var(--pfe-theme--surface--border-width, 1px);--pfe-accordion--BorderLeftWidth:var(--pfe-theme--surface--border-width, 1px);--pfe-accordion--BorderColor--accent:var(--pfe-theme--color--surface--border, #d2d2d2)}\n/*# sourceMappingURL=pfe-accordion.min.css.map */\n"}},{key:"styleUrl",get:function(){return"pfe-accordion.scss"}},{key:"templateUrl",get:function(){return"pfe-accordion.html"}},{key:"schemaUrl",get:function(){return"pfe-accordion.json"}}],[{key:"version",get:function(){return"1.0.0-prerelease.54"}},{key:"properties",get:function(){return{}}},{key:"slots",get:function(){return{default:{title:"Default",type:"array",namedSlot:!1,items:{oneOf:[{$ref:"pfe-accordion-header"},{$ref:"pfe-accordion-panel"}]}}}}},{key:"tag",get:function(){return"pfe-accordion"}},{key:"cascadingAttributes",get:function(){return{on:"pfe-accordion-header, pfe-accordion-panel"}}},{key:"events",get:function(){return{change:this.tag+":change"}}},{key:"PfeType",get:function(){return e.PfeTypes.Container}},{key:"observedAttributes",get:function(){return["pfe-disclosure"]}}]),r(p,[{key:"connectedCallback",value:function(){var e=this;i(p.prototype.__proto__||Object.getPrototypeOf(p.prototype),"connectedCallback",this).call(this),this.setAttribute("role","tablist"),this.setAttribute("defined",""),this.addEventListener(p.events.change,this._changeHandler),this.addEventListener("keydown",this._keydownHandler),Promise.all([customElements.whenDefined(f.tag),customElements.whenDefined(h.tag)]).then(function(){e.children.length&&e._linkPanels(),e._observer.observe(e,{childList:!0})})}},{key:"disconnectedCallback",value:function(){this.removeEventListener(p.events.change,this._changeHandler),this.removeEventListener("keydown",this._keydownHandler),this._observer.disconnect()}},{key:"attributeChangedCallback",value:function(e,t,r){i(p.prototype.__proto__||Object.getPrototypeOf(p.prototype),"attributeChangedCallback",this).call(this,e,t,r),"pfe-disclosure"===e&&("true"===r?(this._allHeaders().forEach(function(e){return e.setAttribute("pfe-disclosure","true")}),this._allPanels().forEach(function(e){return e.setAttribute("pfe-disclosure","true")})):(this._allHeaders().forEach(function(e){return e.setAttribute("pfe-disclosure","false")}),this._allPanels().forEach(function(e){return e.setAttribute("pfe-disclosure","false")})))}},{key:"toggle",value:function(e){var t=this._allHeaders(),r=this._allPanels(),o=t[e],a=r[e];o&&a&&(o.expanded?(this._collapseHeader(o),this._collapsePanel(a)):(this._expandHeader(o),this._expandPanel(a)))}},{key:"expand",value:function(e){var t=this._allHeaders(),r=this._allPanels(),o=t[e],a=r[e];o&&a&&(this._expandHeader(o),this._expandPanel(a))}},{key:"expandAll",value:function(){var t=this,e=this._allHeaders(),r=this._allPanels();e.forEach(function(e){return t._expandHeader(e)}),r.forEach(function(e){return t._expandPanel(e)})}},{key:"collapse",value:function(e){var t=this._allHeaders(),r=this._allPanels(),o=t[e],a=r[e];o&&a&&(this._collapseHeader(o),this._collapsePanel(a))}},{key:"collapseAll",value:function(){var t=this,e=this._allHeaders(),r=this._allPanels();e.forEach(function(e){return t._collapseHeader(e)}),r.forEach(function(e){return t._collapsePanel(e)})}},{key:"_linkPanels",value:function(){var r=this,e=this._allHeaders();if(e.forEach(function(e){var t=r._panelForHeader(e);t&&(e.setAttribute("aria-controls",t.pfeId),t.setAttribute("aria-labelledby",e.pfeId))}),1===e.length){if(this.hasAttribute("pfe-disclosure")&&"false"===this.getAttribute("pfe-disclosure"))return;this.setAttribute("pfe-disclosure","true")}1:host{-webkit-transition:-webkit-transform .3s cubic-bezier(.465,.183,.153,.946);transition:-webkit-transform .3s cubic-bezier(.465,.183,.153,.946);transition:transform .3s cubic-bezier(.465,.183,.153,.946);transition:transform .3s cubic-bezier(.465,.183,.153,.946),-webkit-transform .3s cubic-bezier(.465,.183,.153,.946);-webkit-transition:-webkit-transform .3s var(--pfe-theme--animation-timing,cubic-bezier(.465,.183,.153,.946));transition:-webkit-transform .3s var(--pfe-theme--animation-timing,cubic-bezier(.465,.183,.153,.946));transition:transform .3s var(--pfe-theme--animation-timing,cubic-bezier(.465,.183,.153,.946));transition:transform .3s var(--pfe-theme--animation-timing,cubic-bezier(.465,.183,.153,.946)),-webkit-transform .3s var(--pfe-theme--animation-timing,cubic-bezier(.465,.183,.153,.946));display:block}:host>*{margin:0}:host button{--pfe-accordion--BorderBottomWidth:0;--pfe-accordion--ZIndex:3;--pfe-accordion__trigger--Padding:var(--pfe-accordion__base--Padding, var(--pfe-theme--container-spacer, 16px)) 50px var(--pfe-accordion__base--Padding, var(--pfe-theme--container-spacer, 16px)) calc(var(--pfe-accordion__base--Padding, var(--pfe-theme--container-spacer, 16px)) * 1.5);margin:0;width:100%;width:var(--pfe-accordion--Width,100%);max-width:calc(100% - 4px);max-width:calc(100% - var(--pfe-theme--surface--border-width--heavy,4px));height:auto;position:relative;background-color:transparent;background-color:var(--pfe-accordion--BackgroundColor,transparent);color:#3c3f42;color:var(--pfe-accordion--Color,var(--pfe-broadcasted--text,#3c3f42));border:0 solid #d2d2d2;border:0 var(--pfe-theme--surface--border-style,solid) var(--pfe-accordion--BorderColor,var(--pfe-theme--color--surface--border,#d2d2d2));border-top-width:1px;border-top-width:var(--pfe-accordion--BorderTopWidth,var(--pfe-theme--surface--border-width,1px));border-right-width:0;border-right-width:var(--pfe-accordion--BorderRightWidth,0);border-bottom-width:1px;border-bottom-width:var(--pfe-accordion--BorderBottomWidth,var(--pfe-theme--surface--border-width,1px));border-left:4px solid transparent;border-left:var(--pfe-accordion--BorderLeftWidth,var(--pfe-theme--surface--border-width--heavy,4px)) var(--pfe-theme--surface--border-style,solid) var(--pfe-accordion--BorderColor--accent,transparent);-webkit-box-shadow:var(--pfe-accordion--BoxShadow);box-shadow:var(--pfe-accordion--BoxShadow);z-index:var(--pfe-accordion--ZIndex);cursor:pointer;font-family:inherit;font-size:calc(16px * 1.1);font-size:var(--pfe-accordion--FontSize--header,calc(var(--pfe-theme--font-size,16px) * 1.1));font-weight:700;font-weight:var(--pfe-theme--font-weight--bold,700);text-align:left;text-align:var(--pfe-accordion--TextAlign,left);line-height:1.5;line-height:var(--pfe-theme--line-height,1.5);padding:var(--pfe-accordion__trigger--Padding)}:host button:hover{--pfe-accordion--BorderColor--accent:var(--pfe-accordion--accent, var(--pfe-theme--color--ui-accent, #06c))}:host button:hover{outline:0;border-left-width:4px;border-left-width:var(--pfe-theme--surface--border-width--heavy,4px)}:host button:focus{outline:0;text-decoration:underline}:host button::-moz-focus-inner{border:0}@supports (-ms-ime-align:auto){:host button{text-align:left}}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host button{padding:16px 24px}:host button:hover{border-left-color:#06c}}:host button[aria-expanded=true]{--pfe-accordion--BorderColor:var(--pfe-theme--color--surface--border, #d2d2d2);--pfe-accordion--BorderRightWidth:var(--pfe-theme--surface--border-width, 1px);--pfe-accordion--BorderLeftWidth:var(--pfe-theme--surface--border-width--heavy, 4px);--pfe-accordion--BackgroundColor:white;--pfe-accordion--Color:var(--pfe-theme--color--text, #151515);--pfe-accordion--BorderColor--accent:var(--pfe-accordion--accent, var(--pfe-theme--color--ui-accent, #06c));--pfe-accordion--BoxShadow:0 5px var(--pfe-theme--surface--border-width--heavy, 4px) rgba(140, 140, 140, 0.35);--pfe-accordion--ZIndex:3}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host button[aria-expanded=true]{border-bottom-width:0;border-left-color:#06c;border-right-color:#d2d2d2}}:host(:not([pfe-disclosure=true])) button::after{content:"";position:absolute;top:calc(16px + .4em);top:calc(var(--pfe-theme--container-spacer,16px) + .4em);display:block;border-style:solid;border-style:var(--pfe-theme--surface--border-style,solid);height:.4em;width:.4em;-webkit-transition:-webkit-transform .15s;transition:-webkit-transform .15s;transition:transform .15s;transition:transform .15s,-webkit-transform .15s;border-width:0 .1em .1em 0;-webkit-transform:rotate(45deg);transform:rotate(45deg);right:calc(16px * 1.3125);right:calc(var(--pfe-theme--container-spacer,16px) * 1.3125)}:host(:not([pfe-disclosure=true])) button[aria-expanded=true]::after{-webkit-transform:rotate(-135deg);transform:rotate(-135deg)}:host(:last-of-type) button:not([aria-expanded=true]){--pfe-accordion--BorderBottomWidth:var(--pfe-theme--surface--border-width, 1px)}:host(:last-of-type.animating) button{--pfe-accordion--BorderBottomWidth:0}:host([on=dark]) button[aria-expanded=true]{--pfe-accordion--BackgroundColor:rgba(247, 247, 249, 0.1);--pfe-accordion--Color:var(--pfe-broadcasted--text, #3c3f42);--pfe-accordion--BorderColor--accent:var(--pfe-theme--color--ui-accent--on-dark, #73bcf7);--pfe-accordion--BoxShadow:none}:host([on=saturated]) button[aria-expanded=true]{--pfe-accordion--BackgroundColor:rgba(0, 0, 0, 0.2);--pfe-accordion--Color:var(--pfe-broadcasted--text, #3c3f42);--pfe-accordion--BorderColor--accent:var(--pfe-theme--color--ui-accent--on-saturated, #fff);--pfe-accordion--BoxShadow:none}:host([pfe-disclosure=true]) button{padding-left:calc((16px * 3));padding-left:calc((var(--pfe-accordion__base--Padding,var(--pfe-theme--container-spacer,16px)) * 3))}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host([pfe-disclosure=true]) button{padding:16px 24px 16px 47px;border-right-color:#d2d2d2;border-left-color:#d2d2d2;border-left-width:1px}}:host([pfe-disclosure=true]) button::before{content:"";position:absolute;top:calc(16px + .55em);top:calc(var(--pfe-theme--container-spacer,16px) + .55em);display:block;border-style:solid;border-style:var(--pfe-theme--surface--border-style,solid);height:.4em;width:.4em;-webkit-transition:-webkit-transform .15s;transition:-webkit-transform .15s;transition:transform .15s;transition:transform .15s,-webkit-transform .15s;border-width:0 .1em .1em 0;-webkit-transform:rotate(45deg);transform:rotate(45deg);left:calc(16px * 1.3125);left:calc(var(--pfe-theme--container-spacer,16px) * 1.3125);-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}:host([pfe-disclosure=true]) button[aria-expanded=true]::before{-webkit-transform:rotate(45deg);transform:rotate(45deg)}:host([pfe-disclosure=true]) button:not([aria-expanded=true]):hover,:host([pfe-disclosure=true]) button[aria-expanded=true]{padding-left:calc(16px * 3 - 4px + 1px);padding-left:calc(var(--pfe-accordion__base--Padding,var(--pfe-theme--container-spacer,16px)) * 3 - var(--pfe-theme--surface--border-width--heavy,4px) + var(--pfe-theme--surface--border-width,1px))}:host([pfe-disclosure=true]) button:not([aria-expanded=true]):hover::before,:host([pfe-disclosure=true]) button[aria-expanded=true]::before{margin-left:calc((4px - 1px) * -1);margin-left:calc((var(--pfe-theme--surface--border-width--heavy,4px) - var(--pfe-theme--surface--border-width,1px)) * -1)}\n/*# sourceMappingURL=pfe-accordion-header.min.css.map */\n'}},{key:"styleUrl",get:function(){return"pfe-accordion-header.scss"}},{key:"templateUrl",get:function(){return"pfe-accordion-header.html"}},{key:"pfeId",get:function(){return this.getAttribute("pfe-id")},set:function(e){e&&this.setAttribute("pfe-id",e)}}],[{key:"version",get:function(){return"1.0.0-prerelease.54"}},{key:"tag",get:function(){return"pfe-accordion-header"}},{key:"observedAttributes",get:function(){return["aria-expanded"]}}]),r(l,[{key:"connectedCallback",value:function(){i(l.prototype.__proto__||Object.getPrototypeOf(l.prototype),"connectedCallback",this).call(this),(this.children.length||this.textContent.trim().length)&&this._init(),this.addEventListener("click",this._clickHandler),this._observer.observe(this,{childList:!0})}},{key:"disconnectedCallback",value:function(){this.removeEventListener("click",this._clickHandler),this._observer.disconnect()}},{key:"_init",value:function(){window.ShadyCSS&&this._observer.disconnect(),this.hasAttribute("role")||this.setAttribute("role","heading"),this.pfeId||(this.pfeId=l.tag+"-"+d());var e=this.children[0],t=!1;if(e){switch(e.tagName){case"H1":case"H2":case"H3":case"H4":case"H5":case"H6":t=!0}var r=document.createElement(e.tagName);this.button.innerText=e.innerText,r.appendChild(this.button),this.shadowRoot.appendChild(r)}else this.button.innerText=this.textContent.trim();t||console.warn(l.tag+": The first child in the light DOM must be a Header level tag (h1, h2, h3, h4, h5, or h6)"),window.ShadyCSS&&this._observer.observe(this,{childList:!0})}},{key:"_clickHandler",value:function(e){this.emitEvent(s.events.change,{detail:{expanded:!this.expanded}})}},{key:"expanded",get:function(){return this.hasAttribute("aria-expanded")},set:function(e){(e=Boolean(e))?(this.setAttribute("aria-expanded",!0),this.button.setAttribute("aria-expanded",!0)):(this.removeAttribute("aria-expanded"),this.button.setAttribute("aria-expanded",!1))}}]),l);function l(){t(this,l);var e=n(this,(l.__proto__||Object.getPrototypeOf(l)).call(this,l));return e.button=e.shadowRoot.querySelector("button"),e._init=e._init.bind(e),e._clickHandler=e._clickHandler.bind(e),e._observer=new MutationObserver(e._init),e}var h=(a(u,e),r(u,[{key:"html",get:function(){return'
\n
\n \n
\n
'}},{key:"styleUrl",get:function(){return"pfe-accordion-panel.scss"}},{key:"templateUrl",get:function(){return"pfe-accordion-panel.html"}},{key:"pfeId",get:function(){return this.getAttribute("pfe-id")},set:function(e){e&&this.setAttribute("pfe-id",e)}}],[{key:"version",get:function(){return"1.0.0-prerelease.54"}},{key:"tag",get:function(){return"pfe-accordion-panel"}}]),r(u,[{key:"connectedCallback",value:function(){i(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"connectedCallback",this).call(this),this.hasAttribute("role")||this.setAttribute("role","region"),this.pfeId||(this.pfeId=u.tag+"-"+d())}},{key:"expanded",get:function(){return this.hasAttribute("expanded")},set:function(e){Boolean(e)?this.setAttribute("expanded",""):this.removeAttribute("expanded")}}]),u);function u(){return t(this,u),n(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,u))}return e.create(f),e.create(h),e.create(s),s}); +//# sourceMappingURL=pfe-accordion.umd.min.js.map diff --git a/elements/pfe-accordion/dist/pfe-accordion.umd.min.js.map b/elements/pfe-accordion/dist/pfe-accordion.umd.min.js.map new file mode 100644 index 0000000000..d5c5bb31e4 --- /dev/null +++ b/elements/pfe-accordion/dist/pfe-accordion.umd.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-accordion.umd.min.js","sources":["../_temp/polyfills--pfe-accordion.js","../_temp/pfe-accordion.umd.js"],"sourcesContent":["// @POLYFILL Array.prototype.findIndex\n// https://tc39.github.io/ecma262/#sec-array.prototype.findIndex\nif (!Array.prototype.findIndex) {\n Object.defineProperty(Array.prototype, \"findIndex\", {\n value: function(predicate) {\n // 1. Let O be ? ToObject(this value).\n if (this == null) {\n throw new TypeError('\"this\" is null or not defined');\n }\n\n var o = Object(this);\n\n // 2. Let len be ? ToLength(? Get(O, \"length\")).\n var len = o.length >>> 0;\n\n // 3. If IsCallable(predicate) is false, throw a TypeError exception.\n if (typeof predicate !== \"function\") {\n throw new TypeError(\"predicate must be a function\");\n }\n\n // 4. If thisArg was supplied, let T be thisArg; else let T be undefined.\n var thisArg = arguments[1];\n\n // 5. Let k be 0.\n var k = 0;\n\n // 6. Repeat, while k < len\n while (k < len) {\n // a. Let Pk be ! ToString(k).\n // b. Let kValue be ? Get(O, Pk).\n // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).\n // d. If testResult is true, return k.\n var kValue = o[k];\n if (predicate.call(thisArg, kValue, k, o)) {\n return k;\n }\n // e. Increase k by 1.\n k++;\n }\n\n // 7. Return -1.\n return -1;\n }\n });\n}\n","/*!\n * PatternFly Elements: PfeAccordion 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\n// Import polyfills: findIndex\nimport \"./polyfills--pfe-accordion.js\";\n\nimport PFElement from \"../../pfelement/dist/pfelement.umd\";\n\nfunction generateId() {\n return Math.random()\n .toString(36)\n .substr(2, 9);\n}\n\nclass PfeAccordion extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return ``;\n }\n\n static get properties() {\n return {};\n }\n\n static get slots() {\n return {\"default\":{\"title\":\"Default\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-accordion-header\"},{\"$ref\":\"pfe-accordion-panel\"}]}}};\n }\n static get tag() {\n return \"pfe-accordion\";\n }\n\n get styleUrl() {\n return \"pfe-accordion.scss\";\n }\n\n get templateUrl() {\n return \"pfe-accordion.html\";\n }\n\n get schemaUrl() {\n return \"pfe-accordion.json\";\n }\n\n static get cascadingAttributes() {\n return {\n on: \"pfe-accordion-header, pfe-accordion-panel\"\n };\n }\n\n static get events() {\n return {\n change: `${this.tag}:change`\n };\n }\n\n // Declare the type of this component\n static get PfeType() {\n return PFElement.PfeTypes.Container;\n }\n\n static get observedAttributes() {\n return [\"pfe-disclosure\"];\n }\n\n constructor() {\n super(PfeAccordion, { type: PfeAccordion.PfeType });\n\n this._linkPanels = this._linkPanels.bind(this);\n this._observer = new MutationObserver(this._linkPanels);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n this.setAttribute(\"role\", \"tablist\");\n this.setAttribute(\"defined\", \"\");\n\n this.addEventListener(PfeAccordion.events.change, this._changeHandler);\n this.addEventListener(\"keydown\", this._keydownHandler);\n\n Promise.all([\n customElements.whenDefined(PfeAccordionHeader.tag),\n customElements.whenDefined(PfeAccordionPanel.tag)\n ]).then(() => {\n if (this.children.length) {\n this._linkPanels();\n }\n\n this._observer.observe(this, { childList: true });\n });\n }\n\n disconnectedCallback() {\n this.removeEventListener(PfeAccordion.events.change, this._changeHandler);\n this.removeEventListener(\"keydown\", this._keydownHandler);\n this._observer.disconnect();\n }\n\n attributeChangedCallback(attr, oldVal, newVal) {\n super.attributeChangedCallback(attr, oldVal, newVal);\n\n if (attr === \"pfe-disclosure\") {\n if (newVal === \"true\") {\n this._allHeaders().forEach(header =>\n header.setAttribute(\"pfe-disclosure\", \"true\")\n );\n this._allPanels().forEach(panel =>\n panel.setAttribute(\"pfe-disclosure\", \"true\")\n );\n } else {\n this._allHeaders().forEach(header =>\n header.setAttribute(\"pfe-disclosure\", \"false\")\n );\n this._allPanels().forEach(panel =>\n panel.setAttribute(\"pfe-disclosure\", \"false\")\n );\n }\n }\n }\n\n toggle(index) {\n const headers = this._allHeaders();\n const panels = this._allPanels();\n const header = headers[index];\n const panel = panels[index];\n\n if (!header || !panel) {\n return;\n }\n\n if (!header.expanded) {\n this._expandHeader(header);\n this._expandPanel(panel);\n } else {\n this._collapseHeader(header);\n this._collapsePanel(panel);\n }\n }\n\n expand(index) {\n const headers = this._allHeaders();\n const panels = this._allPanels();\n const header = headers[index];\n const panel = panels[index];\n\n if (!header || !panel) {\n return;\n }\n\n this._expandHeader(header);\n this._expandPanel(panel);\n }\n\n expandAll() {\n const headers = this._allHeaders();\n const panels = this._allPanels();\n\n headers.forEach(header => this._expandHeader(header));\n panels.forEach(panel => this._expandPanel(panel));\n }\n\n collapse(index) {\n const headers = this._allHeaders();\n const panels = this._allPanels();\n const header = headers[index];\n const panel = panels[index];\n\n if (!header || !panel) {\n return;\n }\n\n this._collapseHeader(header);\n this._collapsePanel(panel);\n }\n\n collapseAll() {\n const headers = this._allHeaders();\n const panels = this._allPanels();\n\n headers.forEach(header => this._collapseHeader(header));\n panels.forEach(panel => this._collapsePanel(panel));\n }\n\n _linkPanels() {\n const headers = this._allHeaders();\n headers.forEach(header => {\n const panel = this._panelForHeader(header);\n\n if (!panel) {\n return;\n }\n\n header.setAttribute(\"aria-controls\", panel.pfeId);\n panel.setAttribute(\"aria-labelledby\", header.pfeId);\n });\n\n if (headers.length === 1) {\n if (\n this.hasAttribute(\"pfe-disclosure\") &&\n this.getAttribute(\"pfe-disclosure\") === \"false\"\n ) {\n return;\n }\n\n this.setAttribute(\"pfe-disclosure\", \"true\");\n }\n\n if (headers.length > 1) {\n if (this.hasAttribute(\"pfe-disclosure\")) {\n this.removeAttribute(\"pfe-disclosure\");\n }\n }\n }\n\n _changeHandler(evt) {\n if (this.classList.contains(\"animating\")) {\n return;\n }\n\n const header = evt.target;\n const panel = evt.target.nextElementSibling;\n\n if (evt.detail.expanded) {\n this._expandHeader(header);\n this._expandPanel(panel);\n } else {\n this._collapseHeader(header);\n this._collapsePanel(panel);\n }\n }\n\n _toggle(header, panel) {}\n\n _expandHeader(header) {\n header.expanded = true;\n }\n\n _expandPanel(panel) {\n if (!panel) {\n console.error(\n `${PfeAccordion.tag}: Trying to expand a panel that doesn't exist`\n );\n return;\n }\n\n if (panel.expanded) {\n return;\n }\n\n panel.expanded = true;\n\n const height = panel.getBoundingClientRect().height;\n this._animate(panel, 0, height);\n }\n\n _collapseHeader(header) {\n header.expanded = false;\n }\n\n _collapsePanel(panel) {\n if (!panel) {\n console.error(\n `${PfeAccordion.tag}: Trying to collapse a panel that doesn't exist`\n );\n return;\n }\n\n if (!panel.expanded) {\n return;\n }\n\n const height = panel.getBoundingClientRect().height;\n panel.expanded = false;\n\n this._animate(panel, height, 0);\n }\n\n _animate(panel, start, end) {\n if (panel) {\n const header = panel.previousElementSibling;\n if (header) {\n header.classList.add(\"animating\");\n }\n panel.classList.add(\"animating\");\n panel.style.height = `${start}px`;\n\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n panel.style.height = `${end}px`;\n panel.addEventListener(\"transitionend\", this._transitionEndHandler);\n });\n });\n }\n }\n\n _keydownHandler(evt) {\n const currentHeader = evt.target;\n\n if (!this._isHeader(currentHeader)) {\n return;\n }\n\n let newHeader;\n\n switch (evt.key) {\n case \"ArrowDown\":\n case \"Down\":\n case \"ArrowRight\":\n case \"Right\":\n newHeader = this._nextHeader();\n break;\n case \"ArrowUp\":\n case \"Up\":\n case \"ArrowLeft\":\n case \"Left\":\n newHeader = this._previousHeader();\n break;\n case \"Home\":\n newHeader = this._firstHeader();\n break;\n case \"End\":\n newHeader = this._lastHeader();\n break;\n default:\n return;\n }\n\n newHeader.shadowRoot.querySelector(\"button\").focus();\n }\n\n _transitionEndHandler(evt) {\n const header = evt.target.previousElementSibling;\n if (header) {\n header.classList.remove(\"animating\");\n }\n evt.target.style.height = \"\";\n evt.target.classList.remove(\"animating\");\n evt.target.removeEventListener(\"transitionend\", this._transitionEndHandler);\n }\n\n _allHeaders() {\n return [...this.querySelectorAll(PfeAccordionHeader.tag)];\n }\n\n _allPanels() {\n return [...this.querySelectorAll(PfeAccordionPanel.tag)];\n }\n\n _panelForHeader(header) {\n const next = header.nextElementSibling;\n\n if (!next) {\n return;\n }\n\n if (next.tagName.toLowerCase() !== PfeAccordionPanel.tag) {\n console.error(\n `${PfeAccordion.tag}: Sibling element to a header needs to be a panel`\n );\n return;\n }\n\n return next;\n }\n\n _previousHeader() {\n const headers = this._allHeaders();\n let newIndex =\n headers.findIndex(header => header === document.activeElement) - 1;\n return headers[(newIndex + headers.length) % headers.length];\n }\n\n _nextHeader() {\n const headers = this._allHeaders();\n let newIndex =\n headers.findIndex(header => header === document.activeElement) + 1;\n return headers[newIndex % headers.length];\n }\n\n _firstHeader() {\n const headers = this._allHeaders();\n return headers[0];\n }\n\n _lastHeader() {\n const headers = this._allHeaders();\n return headers[headers.length - 1];\n }\n\n _isHeader(element) {\n return element.tagName.toLowerCase() === PfeAccordionHeader.tag;\n }\n}\n\nclass PfeAccordionHeader extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return ``;\n }\n static get tag() {\n return \"pfe-accordion-header\";\n }\n\n get styleUrl() {\n return \"pfe-accordion-header.scss\";\n }\n\n get templateUrl() {\n return \"pfe-accordion-header.html\";\n }\n\n get pfeId() {\n return this.getAttribute(\"pfe-id\");\n }\n\n set pfeId(id) {\n if (!id) {\n return;\n }\n\n this.setAttribute(\"pfe-id\", id);\n }\n\n static get observedAttributes() {\n return [\"aria-expanded\"];\n }\n\n constructor() {\n super(PfeAccordionHeader);\n\n this.button = this.shadowRoot.querySelector(\"button\");\n\n this._init = this._init.bind(this);\n this._clickHandler = this._clickHandler.bind(this);\n this._observer = new MutationObserver(this._init);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n if (this.children.length || this.textContent.trim().length) {\n this._init();\n }\n\n this.addEventListener(\"click\", this._clickHandler);\n this._observer.observe(this, { childList: true });\n }\n\n disconnectedCallback() {\n this.removeEventListener(\"click\", this._clickHandler);\n this._observer.disconnect();\n }\n\n get expanded() {\n return this.hasAttribute(\"aria-expanded\");\n }\n\n set expanded(val) {\n val = Boolean(val);\n\n if (val) {\n this.setAttribute(\"aria-expanded\", true);\n this.button.setAttribute(\"aria-expanded\", true);\n } else {\n this.removeAttribute(\"aria-expanded\");\n this.button.setAttribute(\"aria-expanded\", false);\n }\n }\n\n _init() {\n if (window.ShadyCSS) {\n this._observer.disconnect();\n }\n\n if (!this.hasAttribute(\"role\")) {\n this.setAttribute(\"role\", \"heading\");\n }\n\n if (!this.pfeId) {\n this.pfeId = `${PfeAccordionHeader.tag}-${generateId()}`;\n }\n\n const child = this.children[0];\n let isHeaderTag = false;\n\n if (child) {\n switch (child.tagName) {\n case \"H1\":\n case \"H2\":\n case \"H3\":\n case \"H4\":\n case \"H5\":\n case \"H6\":\n isHeaderTag = true;\n break;\n }\n\n const wrapperTag = document.createElement(child.tagName);\n this.button.innerText = child.innerText;\n\n wrapperTag.appendChild(this.button);\n this.shadowRoot.appendChild(wrapperTag);\n } else {\n this.button.innerText = this.textContent.trim();\n }\n\n if (!isHeaderTag) {\n console.warn(\n `${PfeAccordionHeader.tag}: The first child in the light DOM must be a Header level tag (h1, h2, h3, h4, h5, or h6)`\n );\n }\n\n if (window.ShadyCSS) {\n this._observer.observe(this, { childList: true });\n }\n }\n\n _clickHandler(event) {\n this.emitEvent(PfeAccordion.events.change, {\n detail: { expanded: !this.expanded }\n });\n }\n}\n\nclass PfeAccordionPanel extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
\n
\n \n
\n
`;\n }\n static get tag() {\n return \"pfe-accordion-panel\";\n }\n\n get styleUrl() {\n return \"pfe-accordion-panel.scss\";\n }\n\n get templateUrl() {\n return \"pfe-accordion-panel.html\";\n }\n\n get pfeId() {\n return this.getAttribute(\"pfe-id\");\n }\n\n set pfeId(id) {\n if (!id) {\n return;\n }\n\n this.setAttribute(\"pfe-id\", id);\n }\n\n constructor() {\n super(PfeAccordionPanel);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n if (!this.hasAttribute(\"role\")) {\n this.setAttribute(\"role\", \"region\");\n }\n\n if (!this.pfeId) {\n this.pfeId = `${PfeAccordionPanel.tag}-${generateId()}`;\n }\n }\n\n get expanded() {\n return this.hasAttribute(\"expanded\");\n }\n\n set expanded(val) {\n const value = Boolean(val);\n\n if (value) {\n this.setAttribute(\"expanded\", \"\");\n } else {\n this.removeAttribute(\"expanded\");\n }\n }\n}\n\nPFElement.create(PfeAccordionHeader);\nPFElement.create(PfeAccordionPanel);\nPFElement.create(PfeAccordion);\n\nexport { PfeAccordion as default };\n"],"names":["Array","prototype","findIndex","defineProperty","predicate","this","TypeError","o","Object","len","length","thisArg","k","kValue","call","generateId","Math","random","toString","substr","PfeAccordion","PFElement","default","title","type","namedSlot","items","oneOf","$ref","tag","PfeTypes","Container","setAttribute","addEventListener","events","change","_changeHandler","_keydownHandler","all","customElements","whenDefined","PfeAccordionHeader","PfeAccordionPanel","then","_this2","children","_linkPanels","_observer","observe","childList","removeEventListener","disconnect","attr","oldVal","newVal","_allHeaders","forEach","header","_allPanels","panel","index","headers","panels","expanded","_collapseHeader","_collapsePanel","_expandHeader","_expandPanel","_this3","_this4","_this5","_panelForHeader","pfeId","hasAttribute","getAttribute","removeAttribute","evt","classList","contains","target","nextElementSibling","detail","height","getBoundingClientRect","_animate","error","start","end","previousElementSibling","add","style","_this6","_transitionEndHandler","currentHeader","_isHeader","newHeader","key","_nextHeader","_previousHeader","_firstHeader","_lastHeader","shadowRoot","querySelector","focus","remove","querySelectorAll","next","tagName","toLowerCase","newIndex","document","activeElement","element","PfeType","_this","bind","MutationObserver","id","textContent","trim","_init","_clickHandler","window","ShadyCSS","child","isHeaderTag","wrapperTag","createElement","button","innerText","appendChild","warn","event","emitEvent","val","Boolean","_this7","create"],"mappings":"qUAEKA,MAAMC,UAAUC,kBACZC,eAAeH,MAAMC,UAAW,YAAa,OAC3C,SAASG,EAAT,MAEO,MAARC,WACI,IAAIC,UAAU,qCAGlBC,EAAIC,OAAOH,MAGXI,EAAMF,EAAEG,SAAW,KAGE,mB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UAGPtG,aAAa,iBAAiB,QAC9BgG,OAAOhG,aAAa,iBAAiB,UAErC2C,gBAAgB,sBAChBqD,OAAOhG,aAAa,iBAAiB,iGArCtCS,aAEDuF,OAASQ,EAAKnC,WAAWC,cAAc,YAEvCkB,MAAQgB,EAAKhB,MAAML,UACnBM,cAAgBe,EAAKf,cAAcN,UACnCpE,UAAY,IAAIqE,iBAAiBoB,EAAKhB,aA0FzC9E,OAA0BrB,q3KAmBrB,qEAIA,gEAIAhB,KAAKqE,aAAa,wBAGjB2C,GACHA,QAIArF,aAAa,SAAUqF,2CAjCrB,wDAaA,0KA8BFhH,KAAKoE,aAAa,cAChBzC,aAAa,OAAQ,UAGvB3B,KAAKmE,aACHA,MAAW9B,EAAkBb,QAAOd,6CAKpCV,KAAKoE,aAAa,0BAGd6D,GACGC,QAAQD,QAGftG,aAAa,WAAY,SAEzB2C,gBAAgB,0GAzBjBjC,WA8BVrB,EAAUoH,OAAOhG,GACjBpB,EAAUoH,OAAO/F,GACjBrB,EAAUoH,OAAOrH"} \ No newline at end of file diff --git a/elements/pfe-accordion/package-lock.json b/elements/pfe-accordion/package-lock.json index 312cd21e29..7b8df8ba01 100644 --- a/elements/pfe-accordion/package-lock.json +++ b/elements/pfe-accordion/package-lock.json @@ -1,6 +1,6 @@ { "name": "@patternfly/pfe-accordion", - "version": "1.0.0-prerelease.53", + "version": "1.0.0-prerelease.54", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/elements/pfe-accordion/package.json b/elements/pfe-accordion/package.json index 6aaff78d18..7077244026 100644 --- a/elements/pfe-accordion/package.json +++ b/elements/pfe-accordion/package.json @@ -9,7 +9,7 @@ "pfe-accordion-panel.js" ] }, - "version": "1.0.0-prerelease.53", + "version": "1.0.0-prerelease.54", "publishConfig": { "access": "public" }, @@ -53,7 +53,7 @@ "@patternfly/pfelement": "^1.0.0-prerelease.51" }, "devDependencies": { - "@patternfly/pfe-sass": "^1.0.0-prerelease.53" + "@patternfly/pfe-sass": "^1.0.0-prerelease.54" }, "generator-pfelement-version": "0.5.5", "bugs": { diff --git a/elements/pfe-autocomplete/dist/pfe-autocomplete.js b/elements/pfe-autocomplete/dist/pfe-autocomplete.js new file mode 100644 index 0000000000..c1b73c6907 --- /dev/null +++ b/elements/pfe-autocomplete/dist/pfe-autocomplete.js @@ -0,0 +1,686 @@ +import PFElement from '../../pfelement/dist/pfelement.js'; + +/*! + * PatternFly Elements: PfeAutocomplete 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * +*/ + +const KEYCODE = { + ENTER: 13, + DOWN: 40, + UP: 38, + ESC: 27 +}; + +// use this variable to debounce api call when user types very fast +let throttle = false; + +class PfeAutocomplete extends PFElement { + static get version() { + return "1.0.0-prerelease.54"; + } + + get html() { + return `
+ + + + + + + +
+`; + } + + static get properties() { + return {"debounce_timer":{"title":"Debounce","description":"The amount of time that should pass before the next API call is made","type":"string","prefixed":false},"init_value":{"title":"Initial value","description":"An initial value to show in the input field","type":"string","prefixed":false},"is_disabled":{"title":"Is disabled","description":"Disable the input","type":"boolean","prefixed":false}}; + } + + static get slots() { + return {"content":{"title":"Content","type":"array","namedSlot":false,"items":{"oneOf":[{"$ref":"input"}]},"required":true}}; + } + static get tag() { + return "pfe-autocomplete"; + } + + get schemaUrl() { + return "pfe-autocomplete.json"; + } + + get templateUrl() { + return "pfe-autocomplete.html"; + } + + get styleUrl() { + return "pfe-autocomplete.scss"; + } + + static get events() { + return { + search: `${this.tag}:search-event`, + select: `${this.tag}:option-selected`, + slotchange: `slotchange` + }; + } + + constructor() { + super(PfeAutocomplete); + + this._slotchangeHandler = this._slotchangeHandler.bind(this); + + this._slot = this.shadowRoot.querySelector("slot"); + this._slot.addEventListener( + PfeAutocomplete.events.slotchange, + this._slotchangeHandler + ); + } + + connectedCallback() { + super.connectedCallback(); + + this.loading = false; + this.debounce = this.debounce || 300; + this._ariaAnnounceTemplate = + "There are ${numOptions} suggestions. Use the up and down arrows to browse."; + + // clear button + this._clearBtn = this.shadowRoot.querySelector(".clear-search"); + this._clearBtn.addEventListener("click", this._clear.bind(this)); + + // search button + this._searchBtn = this.shadowRoot.querySelector(".search-button"); + this._searchBtn.addEventListener("click", this._search.bind(this)); + + this._dropdown = this.shadowRoot.querySelector("#dropdown"); + this._dropdown.data = []; + + this.activeIndex = null; + + this.addEventListener("keyup", this._inputKeyUp.bind(this)); + + // these two events, fire search + this.addEventListener( + PfeAutocomplete.events.search, + this._closeDroplist.bind(this) + ); + this.addEventListener( + PfeAutocomplete.events.select, + this._optionSelected.bind(this) + ); + } + + disconnectedCallback() { + this.removeEventListener("keyup", this._inputKeyUp); + + this.removeEventListener( + PfeAutocomplete.events.search, + this._closeDroplist + ); + this.removeEventListener( + PfeAutocomplete.events.select, + this._optionSelected + ); + this._slot.removeEventListener( + PfeAutocomplete.events.slotchange, + this._slotchangeHandler + ); + if (this._input) { + this._input.removeEventListener("input", this._inputChanged); + this._input.removeEventListener("blur", this._closeDroplist); + } + + this._clearBtn.removeEventListener("click", this._clear); + this._searchBtn.removeEventListener("click", this._search); + } + + static get observedAttributes() { + return ["init-value", "loading", "is-disabled"]; + } + + attributeChangedCallback(attr, oldVal, newVal) { + super.attributeChangedCallback(); + + let slotNodes = this.shadowRoot.querySelector("slot").assignedNodes(); + let slotElems = slotNodes.filter(n => n.nodeType === Node.ELEMENT_NODE); + let _input = slotElems[0]; + + let _clearBtn = this.shadowRoot.querySelector(".clear-search"); + let _searchBtn = this.shadowRoot.querySelector(".search-button"); + + switch (attr) { + case "loading": + if (!this.loading || _input.value === "") { + this.shadowRoot.querySelector(".loading").setAttribute("hidden", ""); + } else { + this.shadowRoot.querySelector(".loading").removeAttribute("hidden"); + } + break; + + case "init-value": + if (this["init-value"] !== newVal) { + // set inputbox and buttons in the inner component + _input.value = newVal; + if (newVal !== "" && !this.isDisabled) { + _searchBtn.removeAttribute("disabled"); + _clearBtn.removeAttribute("hidden"); + } else { + _searchBtn.setAttribute("disabled", ""); + _clearBtn.setAttribute("hidden", ""); + } + } + break; + + case "is-disabled": + if (this.isDisabled) { + _clearBtn.setAttribute("disabled", ""); + _searchBtn.setAttribute("disabled", ""); + _input.setAttribute("disabled", ""); + } else { + _clearBtn.removeAttribute("disabled"); + _searchBtn.removeAttribute("disabled"); + _input.removeAttribute("disabled"); + } + break; + } + } + + get selectedValue() { + return this.getAttribute("selected-value"); + } + + set selectedValue(val) { + this.setAttribute("selected-value", val); + } + + set isDisabled(value) { + if (value) { + this.setAttribute("is-disabled", ""); + } else { + this.removeAttribute("is-disabled"); + } + } + + get isDisabled() { + return this.hasAttribute("is-disabled"); + } + + set loading(value) { + const loading = Boolean(value); + if (loading) { + this.setAttribute("loading", ""); + } else { + this.removeAttribute("loading"); + } + } + + get loading() { + return this.hasAttribute("loading"); + } + + get initValue() { + return this.getAttribute("init-value"); + } + + set initValue(val) { + this.setAttribute("init-value", val); + } + + get debounce() { + return this.getAttribute("debounce"); + } + + set debounce(val) { + this.setAttribute("debounce", val); + } + + _slotchangeHandler() { + // input box + let slotNodes = this.shadowRoot.querySelector("slot").assignedNodes(); + let slotElems = slotNodes.filter(n => n.nodeType === Node.ELEMENT_NODE); + + if (slotElems.length === 0) { + console.error( + `${PfeAutocomplete.tag}: There must be a input tag in the light DOM` + ); + + return; + } + + this._input = slotElems[0]; + + if (this._input.tagName.toLowerCase() !== "input") { + console.error( + `${PfeAutocomplete.tag}: The only child in the light DOM must be an input tag` + ); + + return; + } + + this._input.addEventListener("input", this._inputChanged.bind(this)); + this._input.addEventListener("blur", this._closeDroplist.bind(this)); + + this._input.setAttribute("role", "combobox"); + + if (!this._input.hasAttribute("aria-label")) { + this._input.setAttribute("aria-label", "Search"); + } + + this._input.setAttribute("aria-autocomplete", "both"); + this._input.setAttribute("aria-haspopup", "true"); + this._input.setAttribute("type", "search"); + this._input.setAttribute("autocomplete", "off"); + this._input.setAttribute("autocorrect", "off"); + this._input.setAttribute("autocapitalize", "off"); + this._input.setAttribute("spellcheck", "false"); + + this._dropdown._ariaAnnounceTemplate = + this.getAttribute("aria-announce-template") || this._ariaAnnounceTemplate; + } + + _inputChanged() { + if (this._input.value === "") { + this._searchBtn.setAttribute("disabled", ""); + this._clearBtn.setAttribute("hidden", ""); + + this._reset(); + return; + } else { + if (!this._input.hasAttribute("disabled")) { + this._searchBtn.removeAttribute("disabled"); + } + this._clearBtn.removeAttribute("hidden"); + } + + if (throttle === false) { + throttle = true; + + window.setTimeout(() => { + this._sendAutocompleteRequest(this._input.value); + throttle = false; + }, this.debounce); + } + } + + _clear() { + this._input.value = ""; + this._clearBtn.setAttribute("hidden", ""); + this._searchBtn.setAttribute("disabled", ""); + this._input.focus(); + } + + _search() { + this._doSearch(this._input.value); + } + + _closeDroplist() { + this._dropdown.open = null; + this._dropdown.removeAttribute("active-index"); + } + + _openDroplist() { + this.activeIndex = null; + this._dropdown.setAttribute("open", true); + this._dropdown.setAttribute("active-index", null); + } + + _optionSelected(e) { + let selectedValue = e.detail.optionValue; + + // update input box with selected value from options list + this._input.value = selectedValue; + + // send search request + this._doSearch(selectedValue); + } + + _doSearch(searchQuery) { + this.emitEvent(PfeAutocomplete.events.search, { + detail: { searchValue: searchQuery }, + composed: true + }); + this._reset(); + this.selectedValue = searchQuery; + } + + _sendAutocompleteRequest(input) { + if (!this.autocompleteRequest) return; + + this.autocompleteRequest( + { query: input }, + this._autocompleteCallback.bind(this) + ); + } + + _autocompleteCallback(response) { + this._dropdown.data = response; + this._dropdown.reflow = true; + response.length !== 0 ? this._openDroplist() : this._closeDroplist(); + } + + _reset() { + this._dropdown.activeIndex = null; + this._input.setAttribute("aria-activedescendant", ""); + this._dropdown.data = []; + this._closeDroplist(); + } + + _activeOption(activeIndex) { + if (activeIndex === null || activeIndex === "null") return; + return this._dropdown.shadowRoot.querySelector( + "li:nth-child(" + (parseInt(activeIndex, 10) + 1) + ")" + ).innerHTML; + } + + _inputKeyUp(e) { + let key = e.keyCode; + + if ( + this._dropdown.data.length === 0 && + key !== KEYCODE.DOWN && + key !== KEYCODE.UP && + key !== KEYCODE.ENTER && + key !== KEYCODE.ESC + ) + return; + + let activeIndex = this._dropdown.activeIndex; + let optionsLength = this._dropdown.data.length; + + if (key == KEYCODE.ESC) { + this._closeDroplist(); + } else if (key === KEYCODE.UP) { + if (!this._dropdown.open) { + return; + } + + activeIndex = + activeIndex === null || activeIndex === "null" + ? optionsLength + : parseInt(activeIndex, 10); + + activeIndex -= 1; + + if (activeIndex < 0) { + activeIndex = optionsLength - 1; + } + + this._input.value = this._activeOption(activeIndex); + } else if (key === KEYCODE.DOWN) { + if (!this._dropdown.open) { + return; + } + + activeIndex = + activeIndex === null || activeIndex === "null" + ? -1 + : parseInt(activeIndex, 10); + activeIndex += 1; + + if (activeIndex > optionsLength - 1) { + activeIndex = 0; + } + + this._input.value = this._activeOption(activeIndex); + } else if (key === KEYCODE.ENTER) { + if (this._activeOption(activeIndex)) { + this.emitEvent(PfeAutocomplete.events.select, { + detail: { optionValue: this._activeOption(activeIndex) }, + composed: true + }); + + return; + } + + let selectedValue = this._input.value; + this._doSearch(selectedValue); + return; + } + + if (activeIndex !== null && activeIndex !== "null") { + this._input.setAttribute( + "aria-activedescendant", + "option-" + activeIndex + ); + } else { + this._input.setAttribute("aria-activedescendant", ""); + } + + this.activeIndex = activeIndex; + this._dropdown.activeIndex = activeIndex; + } +} + +/* +* - Attributes ------------------------------------ +* open | Set when the combo box dropdown is open +* active-index | Set selected option +* reflow | Re-renders the dropdown + +* - Events ---------------------------------------- +* pfe-autocomplete:option-selected | Fires when an option is selected. + event.details.optionValue contains the selected value. +*/ +class PfeSearchDroplist extends PFElement { + static get version() { + return "1.0.0-prerelease.54"; + } + + get html() { + return `
+
+
    +
+
`; + } + static get tag() { + return "pfe-search-droplist"; + } + + get templateUrl() { + return "pfe-search-droplist.html"; + } + + get styleUrl() { + return "pfe-search-droplist.scss"; + } + + constructor() { + super(PfeSearchDroplist); + } + + connectedCallback() { + super.connectedCallback(); + + this._ariaAnnounce = this.shadowRoot.querySelector( + ".suggestions-aria-help" + ); + + this.activeIndex = null; + this._ul = this.shadowRoot.querySelector("ul"); + this._ul.addEventListener("mousedown", this._optionSelected.bind(this)); + } + + disconnectedCallback() { + this._ul.removeEventListener("mousedown", this._optionSelected); + } + + _optionSelected(e) { + if (e.target.tagName === "LI") { + this.emitEvent(PfeAutocomplete.events.select, { + detail: { optionValue: e.target.innerText }, + composed: true + }); + } + } + + _renderOptions() { + this.reflow = ""; + + let options = this.data; + let ariaAnnounceText = ""; + + if (this._ariaAnnounceTemplate) { + ariaAnnounceText = this._ariaAnnounceTemplate.replace( + "${numOptions}", + options.length + ); + } + + this._ariaAnnounce.textContent = ariaAnnounceText; + this._ariaAnnounce.setAttribute("aria-live", "polite"); + + this._ul.innerHTML = `${options + .map((item, index) => { + return `
  • ${item}
  • `; + }) + .join("")}`; + } + + static get observedAttributes() { + return ["open", "reflow", "active-index"]; + } + + attributeChangedCallback(attr, oldVal, newVal) { + super.attributeChangedCallback(); + + if (this[name] !== newVal) { + this[name] = newVal; + } + + if (attr === "active-index" && oldVal !== newVal) { + this._activeIndexChanged(); + } + + if (attr === "reflow") { + this._renderOptions(); + } + } + + _activeIndexChanged() { + if ( + !this.data || + this.data.length === 0 || + this.activeIndex === null || + this.activeIndex === "null" + ) + return; + + // remove active class + if (this._ul.querySelector(".active")) { + this._ul.querySelector(".active").classList.remove("active"); + } + + // add active class to selected option + let activeOption = this._ul.querySelector( + "li:nth-child(" + (parseInt(this.activeIndex, 10) + 1) + ")" + ); + + activeOption.classList.add("active"); + + // scroll to selected element when selected item with keyboard is out of view + let ulWrapper = this.shadowRoot.querySelector(".droplist"); + let activeOptionHeight = activeOption.offsetHeight; + activeOptionHeight += parseInt( + window.getComputedStyle(activeOption).getPropertyValue("margin-bottom"), + 10 + ); + ulWrapper.scrollTop = + activeOption.offsetTop - ulWrapper.offsetHeight + activeOptionHeight; + } + + get open() { + return this.hasAttribute("open"); + } + + set open(val) { + val = Boolean(val); + + if (val) { + this.setAttribute("open", ""); + } else { + this.removeAttribute("open"); + } + } + + get activeIndex() { + return this.getAttribute("active-index"); + } + + set activeIndex(val) { + this.setAttribute("active-index", val); + } + + get reflow() { + return this.hasAttribute("reflow"); + } + + set reflow(val) { + val = Boolean(val); + + if (val) { + this.setAttribute("reflow", ""); + } else { + this.removeAttribute("reflow"); + } + } +} + +PFElement.create(PfeSearchDroplist); +PFElement.create(PfeAutocomplete); + +export default PfeAutocomplete; +//# sourceMappingURL=pfe-autocomplete.js.map diff --git a/elements/pfe-autocomplete/dist/pfe-autocomplete.js.map b/elements/pfe-autocomplete/dist/pfe-autocomplete.js.map new file mode 100644 index 0000000000..ec092399e4 --- /dev/null +++ b/elements/pfe-autocomplete/dist/pfe-autocomplete.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-autocomplete.js","sources":["../_temp/pfe-autocomplete.js"],"sourcesContent":["/*!\n * PatternFly Elements: PfeAutocomplete 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.js\";\n\nconst KEYCODE = {\n ENTER: 13,\n DOWN: 40,\n UP: 38,\n ESC: 27\n};\n\n// use this variable to debounce api call when user types very fast\nlet throttle = false;\n\nclass PfeAutocomplete extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
    \n \n\n \n\n \n\n \n
    \n`;\n }\n\n static get properties() {\n return {\"debounce_timer\":{\"title\":\"Debounce\",\"description\":\"The amount of time that should pass before the next API call is made\",\"type\":\"string\",\"prefixed\":false},\"init_value\":{\"title\":\"Initial value\",\"description\":\"An initial value to show in the input field\",\"type\":\"string\",\"prefixed\":false},\"is_disabled\":{\"title\":\"Is disabled\",\"description\":\"Disable the input\",\"type\":\"boolean\",\"prefixed\":false}};\n }\n\n static get slots() {\n return {\"content\":{\"title\":\"Content\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"input\"}]},\"required\":true}};\n }\n static get tag() {\n return \"pfe-autocomplete\";\n }\n\n get schemaUrl() {\n return \"pfe-autocomplete.json\";\n }\n\n get templateUrl() {\n return \"pfe-autocomplete.html\";\n }\n\n get styleUrl() {\n return \"pfe-autocomplete.scss\";\n }\n\n static get events() {\n return {\n search: `${this.tag}:search-event`,\n select: `${this.tag}:option-selected`,\n slotchange: `slotchange`\n };\n }\n\n constructor() {\n super(PfeAutocomplete);\n\n this._slotchangeHandler = this._slotchangeHandler.bind(this);\n\n this._slot = this.shadowRoot.querySelector(\"slot\");\n this._slot.addEventListener(\n PfeAutocomplete.events.slotchange,\n this._slotchangeHandler\n );\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n this.loading = false;\n this.debounce = this.debounce || 300;\n this._ariaAnnounceTemplate =\n \"There are ${numOptions} suggestions. Use the up and down arrows to browse.\";\n\n // clear button\n this._clearBtn = this.shadowRoot.querySelector(\".clear-search\");\n this._clearBtn.addEventListener(\"click\", this._clear.bind(this));\n\n // search button\n this._searchBtn = this.shadowRoot.querySelector(\".search-button\");\n this._searchBtn.addEventListener(\"click\", this._search.bind(this));\n\n this._dropdown = this.shadowRoot.querySelector(\"#dropdown\");\n this._dropdown.data = [];\n\n this.activeIndex = null;\n\n this.addEventListener(\"keyup\", this._inputKeyUp.bind(this));\n\n // these two events, fire search\n this.addEventListener(\n PfeAutocomplete.events.search,\n this._closeDroplist.bind(this)\n );\n this.addEventListener(\n PfeAutocomplete.events.select,\n this._optionSelected.bind(this)\n );\n }\n\n disconnectedCallback() {\n this.removeEventListener(\"keyup\", this._inputKeyUp);\n\n this.removeEventListener(\n PfeAutocomplete.events.search,\n this._closeDroplist\n );\n this.removeEventListener(\n PfeAutocomplete.events.select,\n this._optionSelected\n );\n this._slot.removeEventListener(\n PfeAutocomplete.events.slotchange,\n this._slotchangeHandler\n );\n if (this._input) {\n this._input.removeEventListener(\"input\", this._inputChanged);\n this._input.removeEventListener(\"blur\", this._closeDroplist);\n }\n\n this._clearBtn.removeEventListener(\"click\", this._clear);\n this._searchBtn.removeEventListener(\"click\", this._search);\n }\n\n static get observedAttributes() {\n return [\"init-value\", \"loading\", \"is-disabled\"];\n }\n\n attributeChangedCallback(attr, oldVal, newVal) {\n super.attributeChangedCallback();\n\n let slotNodes = this.shadowRoot.querySelector(\"slot\").assignedNodes();\n let slotElems = slotNodes.filter(n => n.nodeType === Node.ELEMENT_NODE);\n let _input = slotElems[0];\n\n let _clearBtn = this.shadowRoot.querySelector(\".clear-search\");\n let _searchBtn = this.shadowRoot.querySelector(\".search-button\");\n\n switch (attr) {\n case \"loading\":\n if (!this.loading || _input.value === \"\") {\n this.shadowRoot.querySelector(\".loading\").setAttribute(\"hidden\", \"\");\n } else {\n this.shadowRoot.querySelector(\".loading\").removeAttribute(\"hidden\");\n }\n break;\n\n case \"init-value\":\n if (this[\"init-value\"] !== newVal) {\n // set inputbox and buttons in the inner component\n _input.value = newVal;\n if (newVal !== \"\" && !this.isDisabled) {\n _searchBtn.removeAttribute(\"disabled\");\n _clearBtn.removeAttribute(\"hidden\");\n } else {\n _searchBtn.setAttribute(\"disabled\", \"\");\n _clearBtn.setAttribute(\"hidden\", \"\");\n }\n }\n break;\n\n case \"is-disabled\":\n if (this.isDisabled) {\n _clearBtn.setAttribute(\"disabled\", \"\");\n _searchBtn.setAttribute(\"disabled\", \"\");\n _input.setAttribute(\"disabled\", \"\");\n } else {\n _clearBtn.removeAttribute(\"disabled\");\n _searchBtn.removeAttribute(\"disabled\");\n _input.removeAttribute(\"disabled\");\n }\n break;\n }\n }\n\n get selectedValue() {\n return this.getAttribute(\"selected-value\");\n }\n\n set selectedValue(val) {\n this.setAttribute(\"selected-value\", val);\n }\n\n set isDisabled(value) {\n if (value) {\n this.setAttribute(\"is-disabled\", \"\");\n } else {\n this.removeAttribute(\"is-disabled\");\n }\n }\n\n get isDisabled() {\n return this.hasAttribute(\"is-disabled\");\n }\n\n set loading(value) {\n const loading = Boolean(value);\n if (loading) {\n this.setAttribute(\"loading\", \"\");\n } else {\n this.removeAttribute(\"loading\");\n }\n }\n\n get loading() {\n return this.hasAttribute(\"loading\");\n }\n\n get initValue() {\n return this.getAttribute(\"init-value\");\n }\n\n set initValue(val) {\n this.setAttribute(\"init-value\", val);\n }\n\n get debounce() {\n return this.getAttribute(\"debounce\");\n }\n\n set debounce(val) {\n this.setAttribute(\"debounce\", val);\n }\n\n _slotchangeHandler() {\n // input box\n let slotNodes = this.shadowRoot.querySelector(\"slot\").assignedNodes();\n let slotElems = slotNodes.filter(n => n.nodeType === Node.ELEMENT_NODE);\n\n if (slotElems.length === 0) {\n console.error(\n `${PfeAutocomplete.tag}: There must be a input tag in the light DOM`\n );\n\n return;\n }\n\n this._input = slotElems[0];\n\n if (this._input.tagName.toLowerCase() !== \"input\") {\n console.error(\n `${PfeAutocomplete.tag}: The only child in the light DOM must be an input tag`\n );\n\n return;\n }\n\n this._input.addEventListener(\"input\", this._inputChanged.bind(this));\n this._input.addEventListener(\"blur\", this._closeDroplist.bind(this));\n\n this._input.setAttribute(\"role\", \"combobox\");\n\n if (!this._input.hasAttribute(\"aria-label\")) {\n this._input.setAttribute(\"aria-label\", \"Search\");\n }\n\n this._input.setAttribute(\"aria-autocomplete\", \"both\");\n this._input.setAttribute(\"aria-haspopup\", \"true\");\n this._input.setAttribute(\"type\", \"search\");\n this._input.setAttribute(\"autocomplete\", \"off\");\n this._input.setAttribute(\"autocorrect\", \"off\");\n this._input.setAttribute(\"autocapitalize\", \"off\");\n this._input.setAttribute(\"spellcheck\", \"false\");\n\n this._dropdown._ariaAnnounceTemplate =\n this.getAttribute(\"aria-announce-template\") || this._ariaAnnounceTemplate;\n }\n\n _inputChanged() {\n if (this._input.value === \"\") {\n this._searchBtn.setAttribute(\"disabled\", \"\");\n this._clearBtn.setAttribute(\"hidden\", \"\");\n\n this._reset();\n return;\n } else {\n if (!this._input.hasAttribute(\"disabled\")) {\n this._searchBtn.removeAttribute(\"disabled\");\n }\n this._clearBtn.removeAttribute(\"hidden\");\n }\n\n if (throttle === false) {\n throttle = true;\n\n window.setTimeout(() => {\n this._sendAutocompleteRequest(this._input.value);\n throttle = false;\n }, this.debounce);\n }\n }\n\n _clear() {\n this._input.value = \"\";\n this._clearBtn.setAttribute(\"hidden\", \"\");\n this._searchBtn.setAttribute(\"disabled\", \"\");\n this._input.focus();\n }\n\n _search() {\n this._doSearch(this._input.value);\n }\n\n _closeDroplist() {\n this._dropdown.open = null;\n this._dropdown.removeAttribute(\"active-index\");\n }\n\n _openDroplist() {\n this.activeIndex = null;\n this._dropdown.setAttribute(\"open\", true);\n this._dropdown.setAttribute(\"active-index\", null);\n }\n\n _optionSelected(e) {\n let selectedValue = e.detail.optionValue;\n\n // update input box with selected value from options list\n this._input.value = selectedValue;\n\n // send search request\n this._doSearch(selectedValue);\n }\n\n _doSearch(searchQuery) {\n this.emitEvent(PfeAutocomplete.events.search, {\n detail: { searchValue: searchQuery },\n composed: true\n });\n this._reset();\n this.selectedValue = searchQuery;\n }\n\n _sendAutocompleteRequest(input) {\n if (!this.autocompleteRequest) return;\n\n this.autocompleteRequest(\n { query: input },\n this._autocompleteCallback.bind(this)\n );\n }\n\n _autocompleteCallback(response) {\n this._dropdown.data = response;\n this._dropdown.reflow = true;\n response.length !== 0 ? this._openDroplist() : this._closeDroplist();\n }\n\n _reset() {\n this._dropdown.activeIndex = null;\n this._input.setAttribute(\"aria-activedescendant\", \"\");\n this._dropdown.data = [];\n this._closeDroplist();\n }\n\n _activeOption(activeIndex) {\n if (activeIndex === null || activeIndex === \"null\") return;\n return this._dropdown.shadowRoot.querySelector(\n \"li:nth-child(\" + (parseInt(activeIndex, 10) + 1) + \")\"\n ).innerHTML;\n }\n\n _inputKeyUp(e) {\n let key = e.keyCode;\n\n if (\n this._dropdown.data.length === 0 &&\n key !== KEYCODE.DOWN &&\n key !== KEYCODE.UP &&\n key !== KEYCODE.ENTER &&\n key !== KEYCODE.ESC\n )\n return;\n\n let activeIndex = this._dropdown.activeIndex;\n let optionsLength = this._dropdown.data.length;\n\n if (key == KEYCODE.ESC) {\n this._closeDroplist();\n } else if (key === KEYCODE.UP) {\n if (!this._dropdown.open) {\n return;\n }\n\n activeIndex =\n activeIndex === null || activeIndex === \"null\"\n ? optionsLength\n : parseInt(activeIndex, 10);\n\n activeIndex -= 1;\n\n if (activeIndex < 0) {\n activeIndex = optionsLength - 1;\n }\n\n this._input.value = this._activeOption(activeIndex);\n } else if (key === KEYCODE.DOWN) {\n if (!this._dropdown.open) {\n return;\n }\n\n activeIndex =\n activeIndex === null || activeIndex === \"null\"\n ? -1\n : parseInt(activeIndex, 10);\n activeIndex += 1;\n\n if (activeIndex > optionsLength - 1) {\n activeIndex = 0;\n }\n\n this._input.value = this._activeOption(activeIndex);\n } else if (key === KEYCODE.ENTER) {\n if (this._activeOption(activeIndex)) {\n this.emitEvent(PfeAutocomplete.events.select, {\n detail: { optionValue: this._activeOption(activeIndex) },\n composed: true\n });\n\n return;\n }\n\n let selectedValue = this._input.value;\n this._doSearch(selectedValue);\n return;\n }\n\n if (activeIndex !== null && activeIndex !== \"null\") {\n this._input.setAttribute(\n \"aria-activedescendant\",\n \"option-\" + activeIndex\n );\n } else {\n this._input.setAttribute(\"aria-activedescendant\", \"\");\n }\n\n this.activeIndex = activeIndex;\n this._dropdown.activeIndex = activeIndex;\n }\n}\n\n/*\n* - Attributes ------------------------------------\n* open | Set when the combo box dropdown is open\n* active-index | Set selected option\n* reflow | Re-renders the dropdown\n\n* - Events ----------------------------------------\n* pfe-autocomplete:option-selected | Fires when an option is selected.\n event.details.optionValue contains the selected value.\n*/\nclass PfeSearchDroplist extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
    \n
    \n
      \n
    \n
    `;\n }\n static get tag() {\n return \"pfe-search-droplist\";\n }\n\n get templateUrl() {\n return \"pfe-search-droplist.html\";\n }\n\n get styleUrl() {\n return \"pfe-search-droplist.scss\";\n }\n\n constructor() {\n super(PfeSearchDroplist);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n this._ariaAnnounce = this.shadowRoot.querySelector(\n \".suggestions-aria-help\"\n );\n\n this.activeIndex = null;\n this._ul = this.shadowRoot.querySelector(\"ul\");\n this._ul.addEventListener(\"mousedown\", this._optionSelected.bind(this));\n }\n\n disconnectedCallback() {\n this._ul.removeEventListener(\"mousedown\", this._optionSelected);\n }\n\n _optionSelected(e) {\n if (e.target.tagName === \"LI\") {\n this.emitEvent(PfeAutocomplete.events.select, {\n detail: { optionValue: e.target.innerText },\n composed: true\n });\n }\n }\n\n _renderOptions() {\n this.reflow = \"\";\n\n let options = this.data;\n let ariaAnnounceText = \"\";\n\n if (this._ariaAnnounceTemplate) {\n ariaAnnounceText = this._ariaAnnounceTemplate.replace(\n \"${numOptions}\",\n options.length\n );\n }\n\n this._ariaAnnounce.textContent = ariaAnnounceText;\n this._ariaAnnounce.setAttribute(\"aria-live\", \"polite\");\n\n this._ul.innerHTML = `${options\n .map((item, index) => {\n return `
  • ${item}
  • `;\n })\n .join(\"\")}`;\n }\n\n static get observedAttributes() {\n return [\"open\", \"reflow\", \"active-index\"];\n }\n\n attributeChangedCallback(attr, oldVal, newVal) {\n super.attributeChangedCallback();\n\n if (this[name] !== newVal) {\n this[name] = newVal;\n }\n\n if (attr === \"active-index\" && oldVal !== newVal) {\n this._activeIndexChanged();\n }\n\n if (attr === \"reflow\") {\n this._renderOptions();\n }\n }\n\n _activeIndexChanged() {\n if (\n !this.data ||\n this.data.length === 0 ||\n this.activeIndex === null ||\n this.activeIndex === \"null\"\n )\n return;\n\n // remove active class\n if (this._ul.querySelector(\".active\")) {\n this._ul.querySelector(\".active\").classList.remove(\"active\");\n }\n\n // add active class to selected option\n let activeOption = this._ul.querySelector(\n \"li:nth-child(\" + (parseInt(this.activeIndex, 10) + 1) + \")\"\n );\n\n activeOption.classList.add(\"active\");\n\n // scroll to selected element when selected item with keyboard is out of view\n let ulWrapper = this.shadowRoot.querySelector(\".droplist\");\n let activeOptionHeight = activeOption.offsetHeight;\n activeOptionHeight += parseInt(\n window.getComputedStyle(activeOption).getPropertyValue(\"margin-bottom\"),\n 10\n );\n ulWrapper.scrollTop =\n activeOption.offsetTop - ulWrapper.offsetHeight + activeOptionHeight;\n }\n\n get open() {\n return this.hasAttribute(\"open\");\n }\n\n set open(val) {\n val = Boolean(val);\n\n if (val) {\n this.setAttribute(\"open\", \"\");\n } else {\n this.removeAttribute(\"open\");\n }\n }\n\n get activeIndex() {\n return this.getAttribute(\"active-index\");\n }\n\n set activeIndex(val) {\n this.setAttribute(\"active-index\", val);\n }\n\n get reflow() {\n return this.hasAttribute(\"reflow\");\n }\n\n set reflow(val) {\n val = Boolean(val);\n\n if (val) {\n this.setAttribute(\"reflow\", \"\");\n } else {\n this.removeAttribute(\"reflow\");\n }\n }\n}\n\nPFElement.create(PfeSearchDroplist);\nPFElement.create(PfeAutocomplete);\n\nexport default PfeAutocomplete;\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,AAEA;AACA,MAAM,OAAO,GAAG;EACd,KAAK,EAAE,EAAE;EACT,IAAI,EAAE,EAAE;EACR,EAAE,EAAE,EAAE;EACN,GAAG,EAAE,EAAE;CACR,CAAC;;;AAGF,IAAI,QAAQ,GAAG,KAAK,CAAC;;AAErB,MAAM,eAAe,SAAS,SAAS,CAAC;EACtC,WAAW,OAAO,GAAG;IACnB,OAAO,qBAAqB,CAAC;GAC9B;;EAED,IAAI,IAAI,GAAG;IACT,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yDAwC6C,CAAC,CAAC;GACxD;;EAED,WAAW,UAAU,GAAG;IACtB,OAAO,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,sEAAsE,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,6CAA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,EAAE,CAAC,CAAC;KACjC,MAAM;MACL,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;KAChC;GACF;CACF;;AAED,SAAS,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;AACpC,SAAS,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;;;;"} \ No newline at end of file diff --git a/elements/pfe-autocomplete/dist/pfe-autocomplete.json b/elements/pfe-autocomplete/dist/pfe-autocomplete.json new file mode 100644 index 0000000000..7c8a34eedd --- /dev/null +++ b/elements/pfe-autocomplete/dist/pfe-autocomplete.json @@ -0,0 +1,57 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Autocomplete", + "description": "Autocomplete provides options in a dropdown list as user types in an input box by showing result from an api call.", + "type": "object", + "tag": "pfe-autocomplete", + "class": "pfe-autocomplete", + "category": "content", + "properties": { + "slots": { + "title": "Slots", + "description": "Definition of the supported slots", + "type": "object", + "properties": { + "content": { + "title": "Content", + "type": "array", + "namedSlot": false, + "items": { + "oneOf": [ + { + "$ref": "input" + } + ] + }, + "required": true + } + } + }, + "attributes": { + "title": "Attributes", + "type": "object", + "properties": { + "debounce_timer": { + "title": "Debounce", + "description": "The amount of time that should pass before the next API call is made", + "type": "string", + "prefixed": false + }, + "init_value": { + "title": "Initial value", + "description": "An initial value to show in the input field", + "type": "string", + "prefixed": false + }, + "is_disabled": { + "title": "Is disabled", + "description": "Disable the input", + "type": "boolean", + "prefixed": false + } + } + } + }, + "required": ["slots", "attributes"], + "additionalProperties": false +} diff --git a/elements/pfe-autocomplete/dist/pfe-autocomplete.min.js b/elements/pfe-autocomplete/dist/pfe-autocomplete.min.js new file mode 100644 index 0000000000..46524f3cd4 --- /dev/null +++ b/elements/pfe-autocomplete/dist/pfe-autocomplete.min.js @@ -0,0 +1,26 @@ +import e from"../../pfelement/dist/pfelement.min.js"; +/*! + * PatternFly Elements: PfeAutocomplete 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * +*/const t={ENTER:13,DOWN:40,UP:38,ESC:27};let i=!1;class o extends e{static get version(){return"1.0.0-prerelease.54"}get html(){return'
    \n \n\n \n\n \n\n \n
    \n'}static get properties(){return{debounce_timer:{title:"Debounce",description:"The amount of time that should pass before the next API call is made",type:"string",prefixed:!1},init_value:{title:"Initial value",description:"An initial value to show in the input field",type:"string",prefixed:!1},is_disabled:{title:"Is disabled",description:"Disable the input",type:"boolean",prefixed:!1}}}static get slots(){return{content:{title:"Content",type:"array",namedSlot:!1,items:{oneOf:[{$ref:"input"}]},required:!0}}}static get tag(){return"pfe-autocomplete"}get schemaUrl(){return"pfe-autocomplete.json"}get templateUrl(){return"pfe-autocomplete.html"}get styleUrl(){return"pfe-autocomplete.scss"}static get events(){return{search:`${this.tag}:search-event`,select:`${this.tag}:option-selected`,slotchange:"slotchange"}}constructor(){super(o),this._slotchangeHandler=this._slotchangeHandler.bind(this),this._slot=this.shadowRoot.querySelector("slot"),this._slot.addEventListener(o.events.slotchange,this._slotchangeHandler)}connectedCallback(){super.connectedCallback(),this.loading=!1,this.debounce=this.debounce||300,this._ariaAnnounceTemplate="There are ${numOptions} suggestions. Use the up and down arrows to browse.",this._clearBtn=this.shadowRoot.querySelector(".clear-search"),this._clearBtn.addEventListener("click",this._clear.bind(this)),this._searchBtn=this.shadowRoot.querySelector(".search-button"),this._searchBtn.addEventListener("click",this._search.bind(this)),this._dropdown=this.shadowRoot.querySelector("#dropdown"),this._dropdown.data=[],this.activeIndex=null,this.addEventListener("keyup",this._inputKeyUp.bind(this)),this.addEventListener(o.events.search,this._closeDroplist.bind(this)),this.addEventListener(o.events.select,this._optionSelected.bind(this))}disconnectedCallback(){this.removeEventListener("keyup",this._inputKeyUp),this.removeEventListener(o.events.search,this._closeDroplist),this.removeEventListener(o.events.select,this._optionSelected),this._slot.removeEventListener(o.events.slotchange,this._slotchangeHandler),this._input&&(this._input.removeEventListener("input",this._inputChanged),this._input.removeEventListener("blur",this._closeDroplist)),this._clearBtn.removeEventListener("click",this._clear),this._searchBtn.removeEventListener("click",this._search)}static get observedAttributes(){return["init-value","loading","is-disabled"]}attributeChangedCallback(e,t,i){super.attributeChangedCallback();let o=this.shadowRoot.querySelector("slot").assignedNodes().filter(e=>e.nodeType===Node.ELEMENT_NODE)[0],r=this.shadowRoot.querySelector(".clear-search"),s=this.shadowRoot.querySelector(".search-button");switch(e){case"loading":this.loading&&""!==o.value?this.shadowRoot.querySelector(".loading").removeAttribute("hidden"):this.shadowRoot.querySelector(".loading").setAttribute("hidden","");break;case"init-value":this["init-value"]!==i&&(o.value=i,""===i||this.isDisabled?(s.setAttribute("disabled",""),r.setAttribute("hidden","")):(s.removeAttribute("disabled"),r.removeAttribute("hidden")));break;case"is-disabled":this.isDisabled?(r.setAttribute("disabled",""),s.setAttribute("disabled",""),o.setAttribute("disabled","")):(r.removeAttribute("disabled"),s.removeAttribute("disabled"),o.removeAttribute("disabled"))}}get selectedValue(){return this.getAttribute("selected-value")}set selectedValue(e){this.setAttribute("selected-value",e)}set isDisabled(e){e?this.setAttribute("is-disabled",""):this.removeAttribute("is-disabled")}get isDisabled(){return this.hasAttribute("is-disabled")}set loading(e){Boolean(e)?this.setAttribute("loading",""):this.removeAttribute("loading")}get loading(){return this.hasAttribute("loading")}get initValue(){return this.getAttribute("init-value")}set initValue(e){this.setAttribute("init-value",e)}get debounce(){return this.getAttribute("debounce")}set debounce(e){this.setAttribute("debounce",e)}_slotchangeHandler(){let e=this.shadowRoot.querySelector("slot").assignedNodes().filter(e=>e.nodeType===Node.ELEMENT_NODE);0!==e.length?(this._input=e[0],"input"===this._input.tagName.toLowerCase()?(this._input.addEventListener("input",this._inputChanged.bind(this)),this._input.addEventListener("blur",this._closeDroplist.bind(this)),this._input.setAttribute("role","combobox"),this._input.hasAttribute("aria-label")||this._input.setAttribute("aria-label","Search"),this._input.setAttribute("aria-autocomplete","both"),this._input.setAttribute("aria-haspopup","true"),this._input.setAttribute("type","search"),this._input.setAttribute("autocomplete","off"),this._input.setAttribute("autocorrect","off"),this._input.setAttribute("autocapitalize","off"),this._input.setAttribute("spellcheck","false"),this._dropdown._ariaAnnounceTemplate=this.getAttribute("aria-announce-template")||this._ariaAnnounceTemplate):console.error(`${o.tag}: The only child in the light DOM must be an input tag`)):console.error(`${o.tag}: There must be a input tag in the light DOM`)}_inputChanged(){if(""===this._input.value)return this._searchBtn.setAttribute("disabled",""),this._clearBtn.setAttribute("hidden",""),void this._reset();this._input.hasAttribute("disabled")||this._searchBtn.removeAttribute("disabled"),this._clearBtn.removeAttribute("hidden"),!1===i&&(i=!0,window.setTimeout(()=>{this._sendAutocompleteRequest(this._input.value),i=!1},this.debounce))}_clear(){this._input.value="",this._clearBtn.setAttribute("hidden",""),this._searchBtn.setAttribute("disabled",""),this._input.focus()}_search(){this._doSearch(this._input.value)}_closeDroplist(){this._dropdown.open=null,this._dropdown.removeAttribute("active-index")}_openDroplist(){this.activeIndex=null,this._dropdown.setAttribute("open",!0),this._dropdown.setAttribute("active-index",null)}_optionSelected(e){let t=e.detail.optionValue;this._input.value=t,this._doSearch(t)}_doSearch(e){this.emitEvent(o.events.search,{detail:{searchValue:e},composed:!0}),this._reset(),this.selectedValue=e}_sendAutocompleteRequest(e){this.autocompleteRequest&&this.autocompleteRequest({query:e},this._autocompleteCallback.bind(this))}_autocompleteCallback(e){this._dropdown.data=e,this._dropdown.reflow=!0,0!==e.length?this._openDroplist():this._closeDroplist()}_reset(){this._dropdown.activeIndex=null,this._input.setAttribute("aria-activedescendant",""),this._dropdown.data=[],this._closeDroplist()}_activeOption(e){if(null!==e&&"null"!==e)return this._dropdown.shadowRoot.querySelector("li:nth-child("+(parseInt(e,10)+1)+")").innerHTML}_inputKeyUp(e){let i=e.keyCode;if(0===this._dropdown.data.length&&i!==t.DOWN&&i!==t.UP&&i!==t.ENTER&&i!==t.ESC)return;let r=this._dropdown.activeIndex,s=this._dropdown.data.length;if(i==t.ESC)this._closeDroplist();else if(i===t.UP){if(!this._dropdown.open)return;r=null===r||"null"===r?s:parseInt(r,10),(r-=1)<0&&(r=s-1),this._input.value=this._activeOption(r)}else if(i===t.DOWN){if(!this._dropdown.open)return;r=null===r||"null"===r?-1:parseInt(r,10),(r+=1)>s-1&&(r=0),this._input.value=this._activeOption(r)}else if(i===t.ENTER){if(this._activeOption(r))return void this.emitEvent(o.events.select,{detail:{optionValue:this._activeOption(r)},composed:!0});let e=this._input.value;return void this._doSearch(e)}null!==r&&"null"!==r?this._input.setAttribute("aria-activedescendant","option-"+r):this._input.setAttribute("aria-activedescendant",""),this.activeIndex=r,this._dropdown.activeIndex=r}}class r extends e{static get version(){return"1.0.0-prerelease.54"}get html(){return'
    \n
    \n
      \n
    \n
    '}static get tag(){return"pfe-search-droplist"}get templateUrl(){return"pfe-search-droplist.html"}get styleUrl(){return"pfe-search-droplist.scss"}constructor(){super(r)}connectedCallback(){super.connectedCallback(),this._ariaAnnounce=this.shadowRoot.querySelector(".suggestions-aria-help"),this.activeIndex=null,this._ul=this.shadowRoot.querySelector("ul"),this._ul.addEventListener("mousedown",this._optionSelected.bind(this))}disconnectedCallback(){this._ul.removeEventListener("mousedown",this._optionSelected)}_optionSelected(e){"LI"===e.target.tagName&&this.emitEvent(o.events.select,{detail:{optionValue:e.target.innerText},composed:!0})}_renderOptions(){this.reflow="";let e=this.data,t="";this._ariaAnnounceTemplate&&(t=this._ariaAnnounceTemplate.replace("${numOptions}",e.length)),this._ariaAnnounce.textContent=t,this._ariaAnnounce.setAttribute("aria-live","polite"),this._ul.innerHTML=`${e.map((e,t)=>`
  • ${e}
  • `).join("")}`}static get observedAttributes(){return["open","reflow","active-index"]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(),this[name]!==i&&(this[name]=i),"active-index"===e&&t!==i&&this._activeIndexChanged(),"reflow"===e&&this._renderOptions()}_activeIndexChanged(){if(!this.data||0===this.data.length||null===this.activeIndex||"null"===this.activeIndex)return;this._ul.querySelector(".active")&&this._ul.querySelector(".active").classList.remove("active");let e=this._ul.querySelector("li:nth-child("+(parseInt(this.activeIndex,10)+1)+")");e.classList.add("active");let t=this.shadowRoot.querySelector(".droplist"),i=e.offsetHeight;i+=parseInt(window.getComputedStyle(e).getPropertyValue("margin-bottom"),10),t.scrollTop=e.offsetTop-t.offsetHeight+i}get open(){return this.hasAttribute("open")}set open(e){(e=Boolean(e))?this.setAttribute("open",""):this.removeAttribute("open")}get activeIndex(){return this.getAttribute("active-index")}set activeIndex(e){this.setAttribute("active-index",e)}get reflow(){return this.hasAttribute("reflow")}set reflow(e){(e=Boolean(e))?this.setAttribute("reflow",""):this.removeAttribute("reflow")}}e.create(r),e.create(o);export default o; +//# sourceMappingURL=pfe-autocomplete.min.js.map diff --git a/elements/pfe-autocomplete/dist/pfe-autocomplete.min.js.map b/elements/pfe-autocomplete/dist/pfe-autocomplete.min.js.map new file mode 100644 index 0000000000..9be69b92bc --- /dev/null +++ b/elements/pfe-autocomplete/dist/pfe-autocomplete.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-autocomplete.min.js","sources":["../_temp/pfe-autocomplete.js"],"sourcesContent":["/*!\n * PatternFly Elements: PfeAutocomplete 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.js\";\n\nconst KEYCODE = {\n ENTER: 13,\n DOWN: 40,\n UP: 38,\n ESC: 27\n};\n\n// use this variable to debounce api call when user types very fast\nlet throttle = false;\n\nclass PfeAutocomplete extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
    \n \n\n \n\n \n\n \n
    \n`;\n }\n\n static get properties() {\n return {\"debounce_timer\":{\"title\":\"Debounce\",\"description\":\"The amount of time that should pass before the next API call is made\",\"type\":\"string\",\"prefixed\":false},\"init_value\":{\"title\":\"Initial value\",\"description\":\"An initial value to show in the input field\",\"type\":\"string\",\"prefixed\":false},\"is_disabled\":{\"title\":\"Is disabled\",\"description\":\"Disable the input\",\"type\":\"boolean\",\"prefixed\":false}};\n }\n\n static get slots() {\n return {\"content\":{\"title\":\"Content\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"input\"}]},\"required\":true}};\n }\n static get tag() {\n return \"pfe-autocomplete\";\n }\n\n get schemaUrl() {\n return \"pfe-autocomplete.json\";\n }\n\n get templateUrl() {\n return \"pfe-autocomplete.html\";\n }\n\n get styleUrl() {\n return \"pfe-autocomplete.scss\";\n }\n\n static get events() {\n return {\n search: `${this.tag}:search-event`,\n select: `${this.tag}:option-selected`,\n slotchange: `slotchange`\n };\n }\n\n constructor() {\n super(PfeAutocomplete);\n\n this._slotchangeHandler = this._slotchangeHandler.bind(this);\n\n this._slot = this.shadowRoot.querySelector(\"slot\");\n this._slot.addEventListener(\n PfeAutocomplete.events.slotchange,\n this._slotchangeHandler\n );\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n this.loading = false;\n this.debounce = this.debounce || 300;\n this._ariaAnnounceTemplate =\n \"There are ${numOptions} suggestions. Use the up and down arrows to browse.\";\n\n // clear button\n this._clearBtn = this.shadowRoot.querySelector(\".clear-search\");\n this._clearBtn.addEventListener(\"click\", this._clear.bind(this));\n\n // search button\n this._searchBtn = this.shadowRoot.querySelector(\".search-button\");\n this._searchBtn.addEventListener(\"click\", this._search.bind(this));\n\n this._dropdown = this.shadowRoot.querySelector(\"#dropdown\");\n this._dropdown.data = [];\n\n this.activeIndex = null;\n\n this.addEventListener(\"keyup\", this._inputKeyUp.bind(this));\n\n // these two events, fire search\n this.addEventListener(\n PfeAutocomplete.events.search,\n this._closeDroplist.bind(this)\n );\n this.addEventListener(\n PfeAutocomplete.events.select,\n this._optionSelected.bind(this)\n );\n }\n\n disconnectedCallback() {\n this.removeEventListener(\"keyup\", this._inputKeyUp);\n\n this.removeEventListener(\n PfeAutocomplete.events.search,\n this._closeDroplist\n );\n this.removeEventListener(\n PfeAutocomplete.events.select,\n this._optionSelected\n );\n this._slot.removeEventListener(\n PfeAutocomplete.events.slotchange,\n this._slotchangeHandler\n );\n if (this._input) {\n this._input.removeEventListener(\"input\", this._inputChanged);\n this._input.removeEventListener(\"blur\", this._closeDroplist);\n }\n\n this._clearBtn.removeEventListener(\"click\", this._clear);\n this._searchBtn.removeEventListener(\"click\", this._search);\n }\n\n static get observedAttributes() {\n return [\"init-value\", \"loading\", \"is-disabled\"];\n }\n\n attributeChangedCallback(attr, oldVal, newVal) {\n super.attributeChangedCallback();\n\n let slotNodes = this.shadowRoot.querySelector(\"slot\").assignedNodes();\n let slotElems = slotNodes.filter(n => n.nodeType === Node.ELEMENT_NODE);\n let _input = slotElems[0];\n\n let _clearBtn = this.shadowRoot.querySelector(\".clear-search\");\n let _searchBtn = this.shadowRoot.querySelector(\".search-button\");\n\n switch (attr) {\n case \"loading\":\n if (!this.loading || _input.value === \"\") {\n this.shadowRoot.querySelector(\".loading\").setAttribute(\"hidden\", \"\");\n } else {\n this.shadowRoot.querySelector(\".loading\").removeAttribute(\"hidden\");\n }\n break;\n\n case \"init-value\":\n if (this[\"init-value\"] !== newVal) {\n // set inputbox and buttons in the inner component\n _input.value = newVal;\n if (newVal !== \"\" && !this.isDisabled) {\n _searchBtn.removeAttribute(\"disabled\");\n _clearBtn.removeAttribute(\"hidden\");\n } else {\n _searchBtn.setAttribute(\"disabled\", \"\");\n _clearBtn.setAttribute(\"hidden\", \"\");\n }\n }\n break;\n\n case \"is-disabled\":\n if (this.isDisabled) {\n _clearBtn.setAttribute(\"disabled\", \"\");\n _searchBtn.setAttribute(\"disabled\", \"\");\n _input.setAttribute(\"disabled\", \"\");\n } else {\n _clearBtn.removeAttribute(\"disabled\");\n _searchBtn.removeAttribute(\"disabled\");\n _input.removeAttribute(\"disabled\");\n }\n break;\n }\n }\n\n get selectedValue() {\n return this.getAttribute(\"selected-value\");\n }\n\n set selectedValue(val) {\n this.setAttribute(\"selected-value\", val);\n }\n\n set isDisabled(value) {\n if (value) {\n this.setAttribute(\"is-disabled\", \"\");\n } else {\n this.removeAttribute(\"is-disabled\");\n }\n }\n\n get isDisabled() {\n return this.hasAttribute(\"is-disabled\");\n }\n\n set loading(value) {\n const loading = Boolean(value);\n if (loading) {\n this.setAttribute(\"loading\", \"\");\n } else {\n this.removeAttribute(\"loading\");\n }\n }\n\n get loading() {\n return this.hasAttribute(\"loading\");\n }\n\n get initValue() {\n return this.getAttribute(\"init-value\");\n }\n\n set initValue(val) {\n this.setAttribute(\"init-value\", val);\n }\n\n get debounce() {\n return this.getAttribute(\"debounce\");\n }\n\n set debounce(val) {\n this.setAttribute(\"debounce\", val);\n }\n\n _slotchangeHandler() {\n // input box\n let slotNodes = this.shadowRoot.querySelector(\"slot\").assignedNodes();\n let slotElems = slotNodes.filter(n => n.nodeType === Node.ELEMENT_NODE);\n\n if (slotElems.length === 0) {\n console.error(\n `${PfeAutocomplete.tag}: There must be a input tag in the light DOM`\n );\n\n return;\n }\n\n this._input = slotElems[0];\n\n if (this._input.tagName.toLowerCase() !== \"input\") {\n console.error(\n `${PfeAutocomplete.tag}: The only child in the light DOM must be an input tag`\n );\n\n return;\n }\n\n this._input.addEventListener(\"input\", this._inputChanged.bind(this));\n this._input.addEventListener(\"blur\", this._closeDroplist.bind(this));\n\n this._input.setAttribute(\"role\", \"combobox\");\n\n if (!this._input.hasAttribute(\"aria-label\")) {\n this._input.setAttribute(\"aria-label\", \"Search\");\n }\n\n this._input.setAttribute(\"aria-autocomplete\", \"both\");\n this._input.setAttribute(\"aria-haspopup\", \"true\");\n this._input.setAttribute(\"type\", \"search\");\n this._input.setAttribute(\"autocomplete\", \"off\");\n this._input.setAttribute(\"autocorrect\", \"off\");\n this._input.setAttribute(\"autocapitalize\", \"off\");\n this._input.setAttribute(\"spellcheck\", \"false\");\n\n this._dropdown._ariaAnnounceTemplate =\n this.getAttribute(\"aria-announce-template\") || this._ariaAnnounceTemplate;\n }\n\n _inputChanged() {\n if (this._input.value === \"\") {\n this._searchBtn.setAttribute(\"disabled\", \"\");\n this._clearBtn.setAttribute(\"hidden\", \"\");\n\n this._reset();\n return;\n } else {\n if (!this._input.hasAttribute(\"disabled\")) {\n this._searchBtn.removeAttribute(\"disabled\");\n }\n this._clearBtn.removeAttribute(\"hidden\");\n }\n\n if (throttle === false) {\n throttle = true;\n\n window.setTimeout(() => {\n this._sendAutocompleteRequest(this._input.value);\n throttle = false;\n }, this.debounce);\n }\n }\n\n _clear() {\n this._input.value = \"\";\n this._clearBtn.setAttribute(\"hidden\", \"\");\n this._searchBtn.setAttribute(\"disabled\", \"\");\n this._input.focus();\n }\n\n _search() {\n this._doSearch(this._input.value);\n }\n\n _closeDroplist() {\n this._dropdown.open = null;\n this._dropdown.removeAttribute(\"active-index\");\n }\n\n _openDroplist() {\n this.activeIndex = null;\n this._dropdown.setAttribute(\"open\", true);\n this._dropdown.setAttribute(\"active-index\", null);\n }\n\n _optionSelected(e) {\n let selectedValue = e.detail.optionValue;\n\n // update input box with selected value from options list\n this._input.value = selectedValue;\n\n // send search request\n this._doSearch(selectedValue);\n }\n\n _doSearch(searchQuery) {\n this.emitEvent(PfeAutocomplete.events.search, {\n detail: { searchValue: searchQuery },\n composed: true\n });\n this._reset();\n this.selectedValue = searchQuery;\n }\n\n _sendAutocompleteRequest(input) {\n if (!this.autocompleteRequest) return;\n\n this.autocompleteRequest(\n { query: input },\n this._autocompleteCallback.bind(this)\n );\n }\n\n _autocompleteCallback(response) {\n this._dropdown.data = response;\n this._dropdown.reflow = true;\n response.length !== 0 ? this._openDroplist() : this._closeDroplist();\n }\n\n _reset() {\n this._dropdown.activeIndex = null;\n this._input.setAttribute(\"aria-activedescendant\", \"\");\n this._dropdown.data = [];\n this._closeDroplist();\n }\n\n _activeOption(activeIndex) {\n if (activeIndex === null || activeIndex === \"null\") return;\n return this._dropdown.shadowRoot.querySelector(\n \"li:nth-child(\" + (parseInt(activeIndex, 10) + 1) + \")\"\n ).innerHTML;\n }\n\n _inputKeyUp(e) {\n let key = e.keyCode;\n\n if (\n this._dropdown.data.length === 0 &&\n key !== KEYCODE.DOWN &&\n key !== KEYCODE.UP &&\n key !== KEYCODE.ENTER &&\n key !== KEYCODE.ESC\n )\n return;\n\n let activeIndex = this._dropdown.activeIndex;\n let optionsLength = this._dropdown.data.length;\n\n if (key == KEYCODE.ESC) {\n this._closeDroplist();\n } else if (key === KEYCODE.UP) {\n if (!this._dropdown.open) {\n return;\n }\n\n activeIndex =\n activeIndex === null || activeIndex === \"null\"\n ? optionsLength\n : parseInt(activeIndex, 10);\n\n activeIndex -= 1;\n\n if (activeIndex < 0) {\n activeIndex = optionsLength - 1;\n }\n\n this._input.value = this._activeOption(activeIndex);\n } else if (key === KEYCODE.DOWN) {\n if (!this._dropdown.open) {\n return;\n }\n\n activeIndex =\n activeIndex === null || activeIndex === \"null\"\n ? -1\n : parseInt(activeIndex, 10);\n activeIndex += 1;\n\n if (activeIndex > optionsLength - 1) {\n activeIndex = 0;\n }\n\n this._input.value = this._activeOption(activeIndex);\n } else if (key === KEYCODE.ENTER) {\n if (this._activeOption(activeIndex)) {\n this.emitEvent(PfeAutocomplete.events.select, {\n detail: { optionValue: this._activeOption(activeIndex) },\n composed: true\n });\n\n return;\n }\n\n let selectedValue = this._input.value;\n this._doSearch(selectedValue);\n return;\n }\n\n if (activeIndex !== null && activeIndex !== \"null\") {\n this._input.setAttribute(\n \"aria-activedescendant\",\n \"option-\" + activeIndex\n );\n } else {\n this._input.setAttribute(\"aria-activedescendant\", \"\");\n }\n\n this.activeIndex = activeIndex;\n this._dropdown.activeIndex = activeIndex;\n }\n}\n\n/*\n* - Attributes ------------------------------------\n* open | Set when the combo box dropdown is open\n* active-index | Set selected option\n* reflow | Re-renders the dropdown\n\n* - Events ----------------------------------------\n* pfe-autocomplete:option-selected | Fires when an option is selected.\n event.details.optionValue contains the selected value.\n*/\nclass PfeSearchDroplist extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
    \n
    \n
      \n
    \n
    `;\n }\n static get tag() {\n return \"pfe-search-droplist\";\n }\n\n get templateUrl() {\n return \"pfe-search-droplist.html\";\n }\n\n get styleUrl() {\n return \"pfe-search-droplist.scss\";\n }\n\n constructor() {\n super(PfeSearchDroplist);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n this._ariaAnnounce = this.shadowRoot.querySelector(\n \".suggestions-aria-help\"\n );\n\n this.activeIndex = null;\n this._ul = this.shadowRoot.querySelector(\"ul\");\n this._ul.addEventListener(\"mousedown\", this._optionSelected.bind(this));\n }\n\n disconnectedCallback() {\n this._ul.removeEventListener(\"mousedown\", this._optionSelected);\n }\n\n _optionSelected(e) {\n if (e.target.tagName === \"LI\") {\n this.emitEvent(PfeAutocomplete.events.select, {\n detail: { optionValue: e.target.innerText },\n composed: true\n });\n }\n }\n\n _renderOptions() {\n this.reflow = \"\";\n\n let options = this.data;\n let ariaAnnounceText = \"\";\n\n if (this._ariaAnnounceTemplate) {\n ariaAnnounceText = this._ariaAnnounceTemplate.replace(\n \"${numOptions}\",\n options.length\n );\n }\n\n this._ariaAnnounce.textContent = ariaAnnounceText;\n this._ariaAnnounce.setAttribute(\"aria-live\", \"polite\");\n\n this._ul.innerHTML = `${options\n .map((item, index) => {\n return `
  • ${item}
  • `;\n })\n .join(\"\")}`;\n }\n\n static get observedAttributes() {\n return [\"open\", \"reflow\", \"active-index\"];\n }\n\n attributeChangedCallback(attr, oldVal, newVal) {\n super.attributeChangedCallback();\n\n if (this[name] !== newVal) {\n this[name] = newVal;\n }\n\n if (attr === \"active-index\" && oldVal !== newVal) {\n this._activeIndexChanged();\n }\n\n if (attr === \"reflow\") {\n this._renderOptions();\n }\n }\n\n _activeIndexChanged() {\n if (\n !this.data ||\n this.data.length === 0 ||\n this.activeIndex === null ||\n this.activeIndex === \"null\"\n )\n return;\n\n // remove active class\n if (this._ul.querySelector(\".active\")) {\n this._ul.querySelector(\".active\").classList.remove(\"active\");\n }\n\n // add active class to selected option\n let activeOption = this._ul.querySelector(\n \"li:nth-child(\" + (parseInt(this.activeIndex, 10) + 1) + \")\"\n );\n\n activeOption.classList.add(\"active\");\n\n // scroll to selected element when selected item with keyboard is out of view\n let ulWrapper = this.shadowRoot.querySelector(\".droplist\");\n let activeOptionHeight = activeOption.offsetHeight;\n activeOptionHeight += parseInt(\n window.getComputedStyle(activeOption).getPropertyValue(\"margin-bottom\"),\n 10\n );\n ulWrapper.scrollTop =\n activeOption.offsetTop - ulWrapper.offsetHeight + activeOptionHeight;\n }\n\n get open() {\n return this.hasAttribute(\"open\");\n }\n\n set open(val) {\n val = Boolean(val);\n\n if (val) {\n this.setAttribute(\"open\", \"\");\n } else {\n this.removeAttribute(\"open\");\n }\n }\n\n get activeIndex() {\n return this.getAttribute(\"active-index\");\n }\n\n set activeIndex(val) {\n this.setAttribute(\"active-index\", val);\n }\n\n get reflow() {\n return this.hasAttribute(\"reflow\");\n }\n\n set reflow(val) {\n val = Boolean(val);\n\n if (val) {\n this.setAttribute(\"reflow\", \"\");\n } else {\n this.removeAttribute(\"reflow\");\n }\n }\n}\n\nPFElement.create(PfeSearchDroplist);\nPFElement.create(PfeAutocomplete);\n\nexport default PfeAutocomplete;\n"],"names":["KEYCODE","ENTER","DOWN","UP","ESC","throttle","PfeAutocomplete","PFElement","version","html","properties","debounce_timer","title","description","type","prefixed","init_value","is_disabled","slots","content","namedSlot","items","oneOf","$ref","required","tag","schemaUrl","templateUrl","styleUrl","events","search","this","select","slotchange","[object Object]","super","_slotchangeHandler","bind","_slot","shadowRoot","querySelector","addEventListener","connectedCallback","loading","debounce","_ariaAnnounceTemplate","_clearBtn","_clear","_searchBtn","_search","_dropdown","data","activeIndex","_inputKeyUp","_closeDroplist","_optionSelected","removeEventListener","_input","_inputChanged","observedAttributes","attr","oldVal","newVal","attributeChangedCallback","assignedNodes","filter","n","nodeType","Node","ELEMENT_NODE","value","removeAttribute","setAttribute","isDisabled","selectedValue","getAttribute","val","hasAttribute","Boolean","initValue","slotElems","length","tagName","toLowerCase","console","error","_reset","window","setTimeout","_sendAutocompleteRequest","focus","_doSearch","open","e","detail","optionValue","searchQuery","emitEvent","searchValue","composed","input","autocompleteRequest","query","_autocompleteCallback","response","reflow","_openDroplist","parseInt","innerHTML","key","keyCode","optionsLength","_activeOption","PfeSearchDroplist","_ariaAnnounce","_ul","target","innerText","options","ariaAnnounceText","replace","textContent","map","item","index","join","name","_activeIndexChanged","_renderOptions","classList","remove","activeOption","add","ulWrapper","activeOptionHeight","offsetHeight","getComputedStyle","getPropertyValue","scrollTop","offsetTop","create"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;EA2BA,MAAMA,EAAU,CACdC,MAAO,GACPC,KAAM,GACNC,GAAI,GACJC,IAAK,IAIP,IAAIC,GAAW,EAEf,MAAMC,UAAwBC,EAC5BC,qBACE,MAAO,sBAGTC,WACE,MAAO,urQA2CTC,wBACE,MAAO,CAACC,eAAiB,CAACC,MAAQ,WAAWC,YAAc,uEAAuEC,KAAO,SAASC,UAAW,GAAOC,WAAa,CAACJ,MAAQ,gBAAgBC,YAAc,8CAA8CC,KAAO,SAASC,UAAW,GAAOE,YAAc,CAACL,MAAQ,cAAcC,YAAc,oBAAoBC,KAAO,UAAUC,UAAW,IAG7YG,mBACE,MAAO,CAACC,QAAU,CAACP,MAAQ,UAAUE,KAAO,QAAQM,WAAY,EAAMC,MAAQ,CAACC,MAAQ,CAAC,CAACC,KAAO,WAAWC,UAAW,IAExHC,iBACE,MAAO,mBAGTC,gBACE,MAAO,wBAGTC,kBACE,MAAO,wBAGTC,eACE,MAAO,wBAGTC,oBACE,MAAO,CACLC,UAAWC,KAAKN,mBAChBO,UAAWD,KAAKN,sBAChBQ,WAAY,cAIhBC,cACEC,MAAM7B,GAENyB,KAAKK,mBAAqBL,KAAKK,mBAAmBC,KAAKN,MAEvDA,KAAKO,MAAQP,KAAKQ,WAAWC,cAAc,QAC3CT,KAAKO,MAAMG,iBACTnC,EAAgBuB,OAAOI,WACvBF,KAAKK,oBAITF,oBACEC,MAAMO,oBAENX,KAAKY,SAAU,EACfZ,KAA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AC1C8F,EAAqBH,EAAaI,aACtCD,GAAsB3B,SACpBpB,OAAOiD,iBAAiBL,GAAcM,iBAAiB,iBACvD,IAEFJ,EAAUK,UACRP,EAAaQ,UAAYN,EAAUE,aAAeD,EAGtD1C,WACE,OAAO7D,KAAK8C,aAAa,QAG3Be,SAAShB,IACPA,EAAME,QAAQF,IAGZ7C,KAAKyC,aAAa,OAAQ,IAE1BzC,KAAKwC,gBAAgB,QAIzBnB,kBACE,OAAOrB,KAAK4C,aAAa,gBAG3BvB,gBAAgBwB,GACd7C,KAAKyC,aAAa,eAAgBI,GAGpC6B,aACE,OAAO1E,KAAK8C,aAAa,UAG3B4B,WAAW7B,IACTA,EAAME,QAAQF,IAGZ7C,KAAKyC,aAAa,SAAU,IAE5BzC,KAAKwC,gBAAgB,WAK3BhE,EAAUqI,OAAO3B,GACjB1G,EAAUqI,OAAOtI"} \ No newline at end of file diff --git a/elements/pfe-autocomplete/dist/pfe-autocomplete.umd.js b/elements/pfe-autocomplete/dist/pfe-autocomplete.umd.js new file mode 100644 index 0000000000..3f51460376 --- /dev/null +++ b/elements/pfe-autocomplete/dist/pfe-autocomplete.umd.js @@ -0,0 +1,721 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../../pfelement/dist/pfelement.umd')) : + typeof define === 'function' && define.amd ? define(['../../pfelement/dist/pfelement.umd'], factory) : + (global.PfeAutocomplete = factory(global.PFElement)); +}(this, (function (PFElement) { 'use strict'; + + PFElement = PFElement && PFElement.hasOwnProperty('default') ? PFElement['default'] : PFElement; + + var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + }; + + var createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + }(); + + var get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + + if (getter === undefined) { + return undefined; + } + + return getter.call(receiver); + } + }; + + var inherits = function (subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + }; + + var possibleConstructorReturn = function (self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && (typeof call === "object" || typeof call === "function") ? call : self; + }; + + /*! + * PatternFly Elements: PfeAutocomplete 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + + var KEYCODE = { + ENTER: 13, + DOWN: 40, + UP: 38, + ESC: 27 + }; + + // use this variable to debounce api call when user types very fast + var throttle = false; + + var PfeAutocomplete = function (_PFElement) { + inherits(PfeAutocomplete, _PFElement); + createClass(PfeAutocomplete, [{ + key: "html", + get: function get$$1() { + return "
    \n \n\n \n\n \n\n \n
    \n"; + } + }, { + key: "schemaUrl", + get: function get$$1() { + return "pfe-autocomplete.json"; + } + }, { + key: "templateUrl", + get: function get$$1() { + return "pfe-autocomplete.html"; + } + }, { + key: "styleUrl", + get: function get$$1() { + return "pfe-autocomplete.scss"; + } + }], [{ + key: "version", + get: function get$$1() { + return "1.0.0-prerelease.54"; + } + }, { + key: "properties", + get: function get$$1() { + return { "debounce_timer": { "title": "Debounce", "description": "The amount of time that should pass before the next API call is made", "type": "string", "prefixed": false }, "init_value": { "title": "Initial value", "description": "An initial value to show in the input field", "type": "string", "prefixed": false }, "is_disabled": { "title": "Is disabled", "description": "Disable the input", "type": "boolean", "prefixed": false } }; + } + }, { + key: "slots", + get: function get$$1() { + return { "content": { "title": "Content", "type": "array", "namedSlot": false, "items": { "oneOf": [{ "$ref": "input" }] }, "required": true } }; + } + }, { + key: "tag", + get: function get$$1() { + return "pfe-autocomplete"; + } + }, { + key: "events", + get: function get$$1() { + return { + search: this.tag + ":search-event", + select: this.tag + ":option-selected", + slotchange: "slotchange" + }; + } + }]); + + function PfeAutocomplete() { + classCallCheck(this, PfeAutocomplete); + + var _this = possibleConstructorReturn(this, (PfeAutocomplete.__proto__ || Object.getPrototypeOf(PfeAutocomplete)).call(this, PfeAutocomplete)); + + _this._slotchangeHandler = _this._slotchangeHandler.bind(_this); + + _this._slot = _this.shadowRoot.querySelector("slot"); + _this._slot.addEventListener(PfeAutocomplete.events.slotchange, _this._slotchangeHandler); + return _this; + } + + createClass(PfeAutocomplete, [{ + key: "connectedCallback", + value: function connectedCallback() { + get(PfeAutocomplete.prototype.__proto__ || Object.getPrototypeOf(PfeAutocomplete.prototype), "connectedCallback", this).call(this); + + this.loading = false; + this.debounce = this.debounce || 300; + this._ariaAnnounceTemplate = "There are ${numOptions} suggestions. Use the up and down arrows to browse."; + + // clear button + this._clearBtn = this.shadowRoot.querySelector(".clear-search"); + this._clearBtn.addEventListener("click", this._clear.bind(this)); + + // search button + this._searchBtn = this.shadowRoot.querySelector(".search-button"); + this._searchBtn.addEventListener("click", this._search.bind(this)); + + this._dropdown = this.shadowRoot.querySelector("#dropdown"); + this._dropdown.data = []; + + this.activeIndex = null; + + this.addEventListener("keyup", this._inputKeyUp.bind(this)); + + // these two events, fire search + this.addEventListener(PfeAutocomplete.events.search, this._closeDroplist.bind(this)); + this.addEventListener(PfeAutocomplete.events.select, this._optionSelected.bind(this)); + } + }, { + key: "disconnectedCallback", + value: function disconnectedCallback() { + this.removeEventListener("keyup", this._inputKeyUp); + + this.removeEventListener(PfeAutocomplete.events.search, this._closeDroplist); + this.removeEventListener(PfeAutocomplete.events.select, this._optionSelected); + this._slot.removeEventListener(PfeAutocomplete.events.slotchange, this._slotchangeHandler); + if (this._input) { + this._input.removeEventListener("input", this._inputChanged); + this._input.removeEventListener("blur", this._closeDroplist); + } + + this._clearBtn.removeEventListener("click", this._clear); + this._searchBtn.removeEventListener("click", this._search); + } + }, { + key: "attributeChangedCallback", + value: function attributeChangedCallback(attr, oldVal, newVal) { + get(PfeAutocomplete.prototype.__proto__ || Object.getPrototypeOf(PfeAutocomplete.prototype), "attributeChangedCallback", this).call(this); + + var slotNodes = this.shadowRoot.querySelector("slot").assignedNodes(); + var slotElems = slotNodes.filter(function (n) { + return n.nodeType === Node.ELEMENT_NODE; + }); + var _input = slotElems[0]; + + var _clearBtn = this.shadowRoot.querySelector(".clear-search"); + var _searchBtn = this.shadowRoot.querySelector(".search-button"); + + switch (attr) { + case "loading": + if (!this.loading || _input.value === "") { + this.shadowRoot.querySelector(".loading").setAttribute("hidden", ""); + } else { + this.shadowRoot.querySelector(".loading").removeAttribute("hidden"); + } + break; + + case "init-value": + if (this["init-value"] !== newVal) { + // set inputbox and buttons in the inner component + _input.value = newVal; + if (newVal !== "" && !this.isDisabled) { + _searchBtn.removeAttribute("disabled"); + _clearBtn.removeAttribute("hidden"); + } else { + _searchBtn.setAttribute("disabled", ""); + _clearBtn.setAttribute("hidden", ""); + } + } + break; + + case "is-disabled": + if (this.isDisabled) { + _clearBtn.setAttribute("disabled", ""); + _searchBtn.setAttribute("disabled", ""); + _input.setAttribute("disabled", ""); + } else { + _clearBtn.removeAttribute("disabled"); + _searchBtn.removeAttribute("disabled"); + _input.removeAttribute("disabled"); + } + break; + } + } + }, { + key: "_slotchangeHandler", + value: function _slotchangeHandler() { + // input box + var slotNodes = this.shadowRoot.querySelector("slot").assignedNodes(); + var slotElems = slotNodes.filter(function (n) { + return n.nodeType === Node.ELEMENT_NODE; + }); + + if (slotElems.length === 0) { + console.error(PfeAutocomplete.tag + ": There must be a input tag in the light DOM"); + + return; + } + + this._input = slotElems[0]; + + if (this._input.tagName.toLowerCase() !== "input") { + console.error(PfeAutocomplete.tag + ": The only child in the light DOM must be an input tag"); + + return; + } + + this._input.addEventListener("input", this._inputChanged.bind(this)); + this._input.addEventListener("blur", this._closeDroplist.bind(this)); + + this._input.setAttribute("role", "combobox"); + + if (!this._input.hasAttribute("aria-label")) { + this._input.setAttribute("aria-label", "Search"); + } + + this._input.setAttribute("aria-autocomplete", "both"); + this._input.setAttribute("aria-haspopup", "true"); + this._input.setAttribute("type", "search"); + this._input.setAttribute("autocomplete", "off"); + this._input.setAttribute("autocorrect", "off"); + this._input.setAttribute("autocapitalize", "off"); + this._input.setAttribute("spellcheck", "false"); + + this._dropdown._ariaAnnounceTemplate = this.getAttribute("aria-announce-template") || this._ariaAnnounceTemplate; + } + }, { + key: "_inputChanged", + value: function _inputChanged() { + var _this2 = this; + + if (this._input.value === "") { + this._searchBtn.setAttribute("disabled", ""); + this._clearBtn.setAttribute("hidden", ""); + + this._reset(); + return; + } else { + if (!this._input.hasAttribute("disabled")) { + this._searchBtn.removeAttribute("disabled"); + } + this._clearBtn.removeAttribute("hidden"); + } + + if (throttle === false) { + throttle = true; + + window.setTimeout(function () { + _this2._sendAutocompleteRequest(_this2._input.value); + throttle = false; + }, this.debounce); + } + } + }, { + key: "_clear", + value: function _clear() { + this._input.value = ""; + this._clearBtn.setAttribute("hidden", ""); + this._searchBtn.setAttribute("disabled", ""); + this._input.focus(); + } + }, { + key: "_search", + value: function _search() { + this._doSearch(this._input.value); + } + }, { + key: "_closeDroplist", + value: function _closeDroplist() { + this._dropdown.open = null; + this._dropdown.removeAttribute("active-index"); + } + }, { + key: "_openDroplist", + value: function _openDroplist() { + this.activeIndex = null; + this._dropdown.setAttribute("open", true); + this._dropdown.setAttribute("active-index", null); + } + }, { + key: "_optionSelected", + value: function _optionSelected(e) { + var selectedValue = e.detail.optionValue; + + // update input box with selected value from options list + this._input.value = selectedValue; + + // send search request + this._doSearch(selectedValue); + } + }, { + key: "_doSearch", + value: function _doSearch(searchQuery) { + this.emitEvent(PfeAutocomplete.events.search, { + detail: { searchValue: searchQuery }, + composed: true + }); + this._reset(); + this.selectedValue = searchQuery; + } + }, { + key: "_sendAutocompleteRequest", + value: function _sendAutocompleteRequest(input) { + if (!this.autocompleteRequest) return; + + this.autocompleteRequest({ query: input }, this._autocompleteCallback.bind(this)); + } + }, { + key: "_autocompleteCallback", + value: function _autocompleteCallback(response) { + this._dropdown.data = response; + this._dropdown.reflow = true; + response.length !== 0 ? this._openDroplist() : this._closeDroplist(); + } + }, { + key: "_reset", + value: function _reset() { + this._dropdown.activeIndex = null; + this._input.setAttribute("aria-activedescendant", ""); + this._dropdown.data = []; + this._closeDroplist(); + } + }, { + key: "_activeOption", + value: function _activeOption(activeIndex) { + if (activeIndex === null || activeIndex === "null") return; + return this._dropdown.shadowRoot.querySelector("li:nth-child(" + (parseInt(activeIndex, 10) + 1) + ")").innerHTML; + } + }, { + key: "_inputKeyUp", + value: function _inputKeyUp(e) { + var key = e.keyCode; + + if (this._dropdown.data.length === 0 && key !== KEYCODE.DOWN && key !== KEYCODE.UP && key !== KEYCODE.ENTER && key !== KEYCODE.ESC) return; + + var activeIndex = this._dropdown.activeIndex; + var optionsLength = this._dropdown.data.length; + + if (key == KEYCODE.ESC) { + this._closeDroplist(); + } else if (key === KEYCODE.UP) { + if (!this._dropdown.open) { + return; + } + + activeIndex = activeIndex === null || activeIndex === "null" ? optionsLength : parseInt(activeIndex, 10); + + activeIndex -= 1; + + if (activeIndex < 0) { + activeIndex = optionsLength - 1; + } + + this._input.value = this._activeOption(activeIndex); + } else if (key === KEYCODE.DOWN) { + if (!this._dropdown.open) { + return; + } + + activeIndex = activeIndex === null || activeIndex === "null" ? -1 : parseInt(activeIndex, 10); + activeIndex += 1; + + if (activeIndex > optionsLength - 1) { + activeIndex = 0; + } + + this._input.value = this._activeOption(activeIndex); + } else if (key === KEYCODE.ENTER) { + if (this._activeOption(activeIndex)) { + this.emitEvent(PfeAutocomplete.events.select, { + detail: { optionValue: this._activeOption(activeIndex) }, + composed: true + }); + + return; + } + + var selectedValue = this._input.value; + this._doSearch(selectedValue); + return; + } + + if (activeIndex !== null && activeIndex !== "null") { + this._input.setAttribute("aria-activedescendant", "option-" + activeIndex); + } else { + this._input.setAttribute("aria-activedescendant", ""); + } + + this.activeIndex = activeIndex; + this._dropdown.activeIndex = activeIndex; + } + }, { + key: "selectedValue", + get: function get$$1() { + return this.getAttribute("selected-value"); + }, + set: function set$$1(val) { + this.setAttribute("selected-value", val); + } + }, { + key: "isDisabled", + set: function set$$1(value) { + if (value) { + this.setAttribute("is-disabled", ""); + } else { + this.removeAttribute("is-disabled"); + } + }, + get: function get$$1() { + return this.hasAttribute("is-disabled"); + } + }, { + key: "loading", + set: function set$$1(value) { + var loading = Boolean(value); + if (loading) { + this.setAttribute("loading", ""); + } else { + this.removeAttribute("loading"); + } + }, + get: function get$$1() { + return this.hasAttribute("loading"); + } + }, { + key: "initValue", + get: function get$$1() { + return this.getAttribute("init-value"); + }, + set: function set$$1(val) { + this.setAttribute("init-value", val); + } + }, { + key: "debounce", + get: function get$$1() { + return this.getAttribute("debounce"); + }, + set: function set$$1(val) { + this.setAttribute("debounce", val); + } + }], [{ + key: "observedAttributes", + get: function get$$1() { + return ["init-value", "loading", "is-disabled"]; + } + }]); + return PfeAutocomplete; + }(PFElement); + + /* + * - Attributes ------------------------------------ + * open | Set when the combo box dropdown is open + * active-index | Set selected option + * reflow | Re-renders the dropdown + + * - Events ---------------------------------------- + * pfe-autocomplete:option-selected | Fires when an option is selected. + event.details.optionValue contains the selected value. + */ + + + var PfeSearchDroplist = function (_PFElement2) { + inherits(PfeSearchDroplist, _PFElement2); + createClass(PfeSearchDroplist, [{ + key: "html", + get: function get$$1() { + return "
    \n
    \n
      \n
    \n
    "; + } + }, { + key: "templateUrl", + get: function get$$1() { + return "pfe-search-droplist.html"; + } + }, { + key: "styleUrl", + get: function get$$1() { + return "pfe-search-droplist.scss"; + } + }], [{ + key: "version", + get: function get$$1() { + return "1.0.0-prerelease.54"; + } + }, { + key: "tag", + get: function get$$1() { + return "pfe-search-droplist"; + } + }]); + + function PfeSearchDroplist() { + classCallCheck(this, PfeSearchDroplist); + return possibleConstructorReturn(this, (PfeSearchDroplist.__proto__ || Object.getPrototypeOf(PfeSearchDroplist)).call(this, PfeSearchDroplist)); + } + + createClass(PfeSearchDroplist, [{ + key: "connectedCallback", + value: function connectedCallback() { + get(PfeSearchDroplist.prototype.__proto__ || Object.getPrototypeOf(PfeSearchDroplist.prototype), "connectedCallback", this).call(this); + + this._ariaAnnounce = this.shadowRoot.querySelector(".suggestions-aria-help"); + + this.activeIndex = null; + this._ul = this.shadowRoot.querySelector("ul"); + this._ul.addEventListener("mousedown", this._optionSelected.bind(this)); + } + }, { + key: "disconnectedCallback", + value: function disconnectedCallback() { + this._ul.removeEventListener("mousedown", this._optionSelected); + } + }, { + key: "_optionSelected", + value: function _optionSelected(e) { + if (e.target.tagName === "LI") { + this.emitEvent(PfeAutocomplete.events.select, { + detail: { optionValue: e.target.innerText }, + composed: true + }); + } + } + }, { + key: "_renderOptions", + value: function _renderOptions() { + this.reflow = ""; + + var options = this.data; + var ariaAnnounceText = ""; + + if (this._ariaAnnounceTemplate) { + ariaAnnounceText = this._ariaAnnounceTemplate.replace("${numOptions}", options.length); + } + + this._ariaAnnounce.textContent = ariaAnnounceText; + this._ariaAnnounce.setAttribute("aria-live", "polite"); + + this._ul.innerHTML = "" + options.map(function (item, index) { + return "
  • " + item + "
  • "; + }).join(""); + } + }, { + key: "attributeChangedCallback", + value: function attributeChangedCallback(attr, oldVal, newVal) { + get(PfeSearchDroplist.prototype.__proto__ || Object.getPrototypeOf(PfeSearchDroplist.prototype), "attributeChangedCallback", this).call(this); + + if (this[name] !== newVal) { + this[name] = newVal; + } + + if (attr === "active-index" && oldVal !== newVal) { + this._activeIndexChanged(); + } + + if (attr === "reflow") { + this._renderOptions(); + } + } + }, { + key: "_activeIndexChanged", + value: function _activeIndexChanged() { + if (!this.data || this.data.length === 0 || this.activeIndex === null || this.activeIndex === "null") return; + + // remove active class + if (this._ul.querySelector(".active")) { + this._ul.querySelector(".active").classList.remove("active"); + } + + // add active class to selected option + var activeOption = this._ul.querySelector("li:nth-child(" + (parseInt(this.activeIndex, 10) + 1) + ")"); + + activeOption.classList.add("active"); + + // scroll to selected element when selected item with keyboard is out of view + var ulWrapper = this.shadowRoot.querySelector(".droplist"); + var activeOptionHeight = activeOption.offsetHeight; + activeOptionHeight += parseInt(window.getComputedStyle(activeOption).getPropertyValue("margin-bottom"), 10); + ulWrapper.scrollTop = activeOption.offsetTop - ulWrapper.offsetHeight + activeOptionHeight; + } + }, { + key: "open", + get: function get$$1() { + return this.hasAttribute("open"); + }, + set: function set$$1(val) { + val = Boolean(val); + + if (val) { + this.setAttribute("open", ""); + } else { + this.removeAttribute("open"); + } + } + }, { + key: "activeIndex", + get: function get$$1() { + return this.getAttribute("active-index"); + }, + set: function set$$1(val) { + this.setAttribute("active-index", val); + } + }, { + key: "reflow", + get: function get$$1() { + return this.hasAttribute("reflow"); + }, + set: function set$$1(val) { + val = Boolean(val); + + if (val) { + this.setAttribute("reflow", ""); + } else { + this.removeAttribute("reflow"); + } + } + }], [{ + key: "observedAttributes", + get: function get$$1() { + return ["open", "reflow", "active-index"]; + } + }]); + return PfeSearchDroplist; + }(PFElement); + + PFElement.create(PfeSearchDroplist); + PFElement.create(PfeAutocomplete); + + return PfeAutocomplete; + +}))); +//# sourceMappingURL=pfe-autocomplete.umd.js.map diff --git a/elements/pfe-autocomplete/dist/pfe-autocomplete.umd.js.map b/elements/pfe-autocomplete/dist/pfe-autocomplete.umd.js.map new file mode 100644 index 0000000000..a63c7c5689 --- /dev/null +++ b/elements/pfe-autocomplete/dist/pfe-autocomplete.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-autocomplete.umd.js","sources":["../_temp/pfe-autocomplete.umd.js"],"sourcesContent":["/*!\n * PatternFly Elements: PfeAutocomplete 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.umd\";\n\nconst KEYCODE = {\n ENTER: 13,\n DOWN: 40,\n UP: 38,\n ESC: 27\n};\n\n// use this variable to debounce api call when user types very fast\nlet throttle = false;\n\nclass PfeAutocomplete extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
    \n \n\n \n\n \n\n \n
    \n`;\n }\n\n static get properties() {\n return {\"debounce_timer\":{\"title\":\"Debounce\",\"description\":\"The amount of time that should pass before the next API call is made\",\"type\":\"string\",\"prefixed\":false},\"init_value\":{\"title\":\"Initial value\",\"description\":\"An initial value to show in the input field\",\"type\":\"string\",\"prefixed\":false},\"is_disabled\":{\"title\":\"Is disabled\",\"description\":\"Disable the input\",\"type\":\"boolean\",\"prefixed\":false}};\n }\n\n static get slots() {\n return {\"content\":{\"title\":\"Content\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"input\"}]},\"required\":true}};\n }\n static get tag() {\n return \"pfe-autocomplete\";\n }\n\n get schemaUrl() {\n return \"pfe-autocomplete.json\";\n }\n\n get templateUrl() {\n return \"pfe-autocomplete.html\";\n }\n\n get styleUrl() {\n return \"pfe-autocomplete.scss\";\n }\n\n static get events() {\n return {\n search: `${this.tag}:search-event`,\n select: `${this.tag}:option-selected`,\n slotchange: `slotchange`\n };\n }\n\n constructor() {\n super(PfeAutocomplete);\n\n this._slotchangeHandler = this._slotchangeHandler.bind(this);\n\n this._slot = this.shadowRoot.querySelector(\"slot\");\n this._slot.addEventListener(\n PfeAutocomplete.events.slotchange,\n this._slotchangeHandler\n );\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n this.loading = false;\n this.debounce = this.debounce || 300;\n this._ariaAnnounceTemplate =\n \"There are ${numOptions} suggestions. Use the up and down arrows to browse.\";\n\n // clear button\n this._clearBtn = this.shadowRoot.querySelector(\".clear-search\");\n this._clearBtn.addEventListener(\"click\", this._clear.bind(this));\n\n // search button\n this._searchBtn = this.shadowRoot.querySelector(\".search-button\");\n this._searchBtn.addEventListener(\"click\", this._search.bind(this));\n\n this._dropdown = this.shadowRoot.querySelector(\"#dropdown\");\n this._dropdown.data = [];\n\n this.activeIndex = null;\n\n this.addEventListener(\"keyup\", this._inputKeyUp.bind(this));\n\n // these two events, fire search\n this.addEventListener(\n PfeAutocomplete.events.search,\n this._closeDroplist.bind(this)\n );\n this.addEventListener(\n PfeAutocomplete.events.select,\n this._optionSelected.bind(this)\n );\n }\n\n disconnectedCallback() {\n this.removeEventListener(\"keyup\", this._inputKeyUp);\n\n this.removeEventListener(\n PfeAutocomplete.events.search,\n this._closeDroplist\n );\n this.removeEventListener(\n PfeAutocomplete.events.select,\n this._optionSelected\n );\n this._slot.removeEventListener(\n PfeAutocomplete.events.slotchange,\n this._slotchangeHandler\n );\n if (this._input) {\n this._input.removeEventListener(\"input\", this._inputChanged);\n this._input.removeEventListener(\"blur\", this._closeDroplist);\n }\n\n this._clearBtn.removeEventListener(\"click\", this._clear);\n this._searchBtn.removeEventListener(\"click\", this._search);\n }\n\n static get observedAttributes() {\n return [\"init-value\", \"loading\", \"is-disabled\"];\n }\n\n attributeChangedCallback(attr, oldVal, newVal) {\n super.attributeChangedCallback();\n\n let slotNodes = this.shadowRoot.querySelector(\"slot\").assignedNodes();\n let slotElems = slotNodes.filter(n => n.nodeType === Node.ELEMENT_NODE);\n let _input = slotElems[0];\n\n let _clearBtn = this.shadowRoot.querySelector(\".clear-search\");\n let _searchBtn = this.shadowRoot.querySelector(\".search-button\");\n\n switch (attr) {\n case \"loading\":\n if (!this.loading || _input.value === \"\") {\n this.shadowRoot.querySelector(\".loading\").setAttribute(\"hidden\", \"\");\n } else {\n this.shadowRoot.querySelector(\".loading\").removeAttribute(\"hidden\");\n }\n break;\n\n case \"init-value\":\n if (this[\"init-value\"] !== newVal) {\n // set inputbox and buttons in the inner component\n _input.value = newVal;\n if (newVal !== \"\" && !this.isDisabled) {\n _searchBtn.removeAttribute(\"disabled\");\n _clearBtn.removeAttribute(\"hidden\");\n } else {\n _searchBtn.setAttribute(\"disabled\", \"\");\n _clearBtn.setAttribute(\"hidden\", \"\");\n }\n }\n break;\n\n case \"is-disabled\":\n if (this.isDisabled) {\n _clearBtn.setAttribute(\"disabled\", \"\");\n _searchBtn.setAttribute(\"disabled\", \"\");\n _input.setAttribute(\"disabled\", \"\");\n } else {\n _clearBtn.removeAttribute(\"disabled\");\n _searchBtn.removeAttribute(\"disabled\");\n _input.removeAttribute(\"disabled\");\n }\n break;\n }\n }\n\n get selectedValue() {\n return this.getAttribute(\"selected-value\");\n }\n\n set selectedValue(val) {\n this.setAttribute(\"selected-value\", val);\n }\n\n set isDisabled(value) {\n if (value) {\n this.setAttribute(\"is-disabled\", \"\");\n } else {\n this.removeAttribute(\"is-disabled\");\n }\n }\n\n get isDisabled() {\n return this.hasAttribute(\"is-disabled\");\n }\n\n set loading(value) {\n const loading = Boolean(value);\n if (loading) {\n this.setAttribute(\"loading\", \"\");\n } else {\n this.removeAttribute(\"loading\");\n }\n }\n\n get loading() {\n return this.hasAttribute(\"loading\");\n }\n\n get initValue() {\n return this.getAttribute(\"init-value\");\n }\n\n set initValue(val) {\n this.setAttribute(\"init-value\", val);\n }\n\n get debounce() {\n return this.getAttribute(\"debounce\");\n }\n\n set debounce(val) {\n this.setAttribute(\"debounce\", val);\n }\n\n _slotchangeHandler() {\n // input box\n let slotNodes = this.shadowRoot.querySelector(\"slot\").assignedNodes();\n let slotElems = slotNodes.filter(n => n.nodeType === Node.ELEMENT_NODE);\n\n if (slotElems.length === 0) {\n console.error(\n `${PfeAutocomplete.tag}: There must be a input tag in the light DOM`\n );\n\n return;\n }\n\n this._input = slotElems[0];\n\n if (this._input.tagName.toLowerCase() !== \"input\") {\n console.error(\n `${PfeAutocomplete.tag}: The only child in the light DOM must be an input tag`\n );\n\n return;\n }\n\n this._input.addEventListener(\"input\", this._inputChanged.bind(this));\n this._input.addEventListener(\"blur\", this._closeDroplist.bind(this));\n\n this._input.setAttribute(\"role\", \"combobox\");\n\n if (!this._input.hasAttribute(\"aria-label\")) {\n this._input.setAttribute(\"aria-label\", \"Search\");\n }\n\n this._input.setAttribute(\"aria-autocomplete\", \"both\");\n this._input.setAttribute(\"aria-haspopup\", \"true\");\n this._input.setAttribute(\"type\", \"search\");\n this._input.setAttribute(\"autocomplete\", \"off\");\n this._input.setAttribute(\"autocorrect\", \"off\");\n this._input.setAttribute(\"autocapitalize\", \"off\");\n this._input.setAttribute(\"spellcheck\", \"false\");\n\n this._dropdown._ariaAnnounceTemplate =\n this.getAttribute(\"aria-announce-template\") || this._ariaAnnounceTemplate;\n }\n\n _inputChanged() {\n if (this._input.value === \"\") {\n this._searchBtn.setAttribute(\"disabled\", \"\");\n this._clearBtn.setAttribute(\"hidden\", \"\");\n\n this._reset();\n return;\n } else {\n if (!this._input.hasAttribute(\"disabled\")) {\n this._searchBtn.removeAttribute(\"disabled\");\n }\n this._clearBtn.removeAttribute(\"hidden\");\n }\n\n if (throttle === false) {\n throttle = true;\n\n window.setTimeout(() => {\n this._sendAutocompleteRequest(this._input.value);\n throttle = false;\n }, this.debounce);\n }\n }\n\n _clear() {\n this._input.value = \"\";\n this._clearBtn.setAttribute(\"hidden\", \"\");\n this._searchBtn.setAttribute(\"disabled\", \"\");\n this._input.focus();\n }\n\n _search() {\n this._doSearch(this._input.value);\n }\n\n _closeDroplist() {\n this._dropdown.open = null;\n this._dropdown.removeAttribute(\"active-index\");\n }\n\n _openDroplist() {\n this.activeIndex = null;\n this._dropdown.setAttribute(\"open\", true);\n this._dropdown.setAttribute(\"active-index\", null);\n }\n\n _optionSelected(e) {\n let selectedValue = e.detail.optionValue;\n\n // update input box with selected value from options list\n this._input.value = selectedValue;\n\n // send search request\n this._doSearch(selectedValue);\n }\n\n _doSearch(searchQuery) {\n this.emitEvent(PfeAutocomplete.events.search, {\n detail: { searchValue: searchQuery },\n composed: true\n });\n this._reset();\n this.selectedValue = searchQuery;\n }\n\n _sendAutocompleteRequest(input) {\n if (!this.autocompleteRequest) return;\n\n this.autocompleteRequest(\n { query: input },\n this._autocompleteCallback.bind(this)\n );\n }\n\n _autocompleteCallback(response) {\n this._dropdown.data = response;\n this._dropdown.reflow = true;\n response.length !== 0 ? this._openDroplist() : this._closeDroplist();\n }\n\n _reset() {\n this._dropdown.activeIndex = null;\n this._input.setAttribute(\"aria-activedescendant\", \"\");\n this._dropdown.data = [];\n this._closeDroplist();\n }\n\n _activeOption(activeIndex) {\n if (activeIndex === null || activeIndex === \"null\") return;\n return this._dropdown.shadowRoot.querySelector(\n \"li:nth-child(\" + (parseInt(activeIndex, 10) + 1) + \")\"\n ).innerHTML;\n }\n\n _inputKeyUp(e) {\n let key = e.keyCode;\n\n if (\n this._dropdown.data.length === 0 &&\n key !== KEYCODE.DOWN &&\n key !== KEYCODE.UP &&\n key !== KEYCODE.ENTER &&\n key !== KEYCODE.ESC\n )\n return;\n\n let activeIndex = this._dropdown.activeIndex;\n let optionsLength = this._dropdown.data.length;\n\n if (key == KEYCODE.ESC) {\n this._closeDroplist();\n } else if (key === KEYCODE.UP) {\n if (!this._dropdown.open) {\n return;\n }\n\n activeIndex =\n activeIndex === null || activeIndex === \"null\"\n ? optionsLength\n : parseInt(activeIndex, 10);\n\n activeIndex -= 1;\n\n if (activeIndex < 0) {\n activeIndex = optionsLength - 1;\n }\n\n this._input.value = this._activeOption(activeIndex);\n } else if (key === KEYCODE.DOWN) {\n if (!this._dropdown.open) {\n return;\n }\n\n activeIndex =\n activeIndex === null || activeIndex === \"null\"\n ? -1\n : parseInt(activeIndex, 10);\n activeIndex += 1;\n\n if (activeIndex > optionsLength - 1) {\n activeIndex = 0;\n }\n\n this._input.value = this._activeOption(activeIndex);\n } else if (key === KEYCODE.ENTER) {\n if (this._activeOption(activeIndex)) {\n this.emitEvent(PfeAutocomplete.events.select, {\n detail: { optionValue: this._activeOption(activeIndex) },\n composed: true\n });\n\n return;\n }\n\n let selectedValue = this._input.value;\n this._doSearch(selectedValue);\n return;\n }\n\n if (activeIndex !== null && activeIndex !== \"null\") {\n this._input.setAttribute(\n \"aria-activedescendant\",\n \"option-\" + activeIndex\n );\n } else {\n this._input.setAttribute(\"aria-activedescendant\", \"\");\n }\n\n this.activeIndex = activeIndex;\n this._dropdown.activeIndex = activeIndex;\n }\n}\n\n/*\n* - Attributes ------------------------------------\n* open | Set when the combo box dropdown is open\n* active-index | Set selected option\n* reflow | Re-renders the dropdown\n\n* - Events ----------------------------------------\n* pfe-autocomplete:option-selected | Fires when an option is selected.\n event.details.optionValue contains the selected value.\n*/\nclass PfeSearchDroplist extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
    \n
    \n
      \n
    \n
    `;\n }\n static get tag() {\n return \"pfe-search-droplist\";\n }\n\n get templateUrl() {\n return \"pfe-search-droplist.html\";\n }\n\n get styleUrl() {\n return \"pfe-search-droplist.scss\";\n }\n\n constructor() {\n super(PfeSearchDroplist);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n this._ariaAnnounce = this.shadowRoot.querySelector(\n \".suggestions-aria-help\"\n );\n\n this.activeIndex = null;\n this._ul = this.shadowRoot.querySelector(\"ul\");\n this._ul.addEventListener(\"mousedown\", this._optionSelected.bind(this));\n }\n\n disconnectedCallback() {\n this._ul.removeEventListener(\"mousedown\", this._optionSelected);\n }\n\n _optionSelected(e) {\n if (e.target.tagName === \"LI\") {\n this.emitEvent(PfeAutocomplete.events.select, {\n detail: { optionValue: e.target.innerText },\n composed: true\n });\n }\n }\n\n _renderOptions() {\n this.reflow = \"\";\n\n let options = this.data;\n let ariaAnnounceText = \"\";\n\n if (this._ariaAnnounceTemplate) {\n ariaAnnounceText = this._ariaAnnounceTemplate.replace(\n \"${numOptions}\",\n options.length\n );\n }\n\n this._ariaAnnounce.textContent = ariaAnnounceText;\n this._ariaAnnounce.setAttribute(\"aria-live\", \"polite\");\n\n this._ul.innerHTML = `${options\n .map((item, index) => {\n return `
  • ${item}
  • `;\n })\n .join(\"\")}`;\n }\n\n static get observedAttributes() {\n return [\"open\", \"reflow\", \"active-index\"];\n }\n\n attributeChangedCallback(attr, oldVal, newVal) {\n super.attributeChangedCallback();\n\n if (this[name] !== newVal) {\n this[name] = newVal;\n }\n\n if (attr === \"active-index\" && oldVal !== newVal) {\n this._activeIndexChanged();\n }\n\n if (attr === \"reflow\") {\n this._renderOptions();\n }\n }\n\n _activeIndexChanged() {\n if (\n !this.data ||\n this.data.length === 0 ||\n this.activeIndex === null ||\n this.activeIndex === \"null\"\n )\n return;\n\n // remove active class\n if (this._ul.querySelector(\".active\")) {\n this._ul.querySelector(\".active\").classList.remove(\"active\");\n }\n\n // add active class to selected option\n let activeOption = this._ul.querySelector(\n \"li:nth-child(\" + (parseInt(this.activeIndex, 10) + 1) + \")\"\n );\n\n activeOption.classList.add(\"active\");\n\n // scroll to selected element when selected item with keyboard is out of view\n let ulWrapper = this.shadowRoot.querySelector(\".droplist\");\n let activeOptionHeight = activeOption.offsetHeight;\n activeOptionHeight += parseInt(\n window.getComputedStyle(activeOption).getPropertyValue(\"margin-bottom\"),\n 10\n );\n ulWrapper.scrollTop =\n activeOption.offsetTop - ulWrapper.offsetHeight + activeOptionHeight;\n }\n\n get open() {\n return this.hasAttribute(\"open\");\n }\n\n set open(val) {\n val = Boolean(val);\n\n if (val) {\n this.setAttribute(\"open\", \"\");\n } else {\n this.removeAttribute(\"open\");\n }\n }\n\n get activeIndex() {\n return this.getAttribute(\"active-index\");\n }\n\n set activeIndex(val) {\n this.setAttribute(\"active-index\", val);\n }\n\n get reflow() {\n return this.hasAttribute(\"reflow\");\n }\n\n set reflow(val) {\n val = Boolean(val);\n\n if (val) {\n this.setAttribute(\"reflow\", \"\");\n } else {\n this.removeAttribute(\"reflow\");\n }\n }\n}\n\nPFElement.create(PfeSearchDroplist);\nPFElement.create(PfeAutocomplete);\n\nexport default PfeAutocomplete;\n"],"names":["KEYCODE","ENTER","DOWN","UP","ESC","throttle","PfeAutocomplete","search","tag","select","slotchange","_slotchangeHandler","bind","_slot","shadowRoot","querySelector","addEventListener","events","loading","debounce","_ariaAnnounceTemplate","_clearBtn","_clear","_searchBtn","_search","_dropdown","data","activeIndex","_inputKeyUp","_closeDroplist","_optionSelected","removeEventListener","_input","_inputChanged","attr","oldVal","newVal","slotNodes","assignedNodes","slotElems","filter","n","nodeType","Node","ELEMENT_NODE","value","setAttribute","removeAttribute","isDisabled","length","console","error","tagName","toLowerCase","hasAttribute","getAttribute","_reset","window","setTimeout","_sendAutocompleteRequest","focus","_doSearch","open","e","selectedValue","detail","optionValue","searchQuery","emitEvent","searchValue","composed","input","autocompleteRequest","query","_autocompleteCallback","response","reflow","_openDroplist","parseInt","innerHTML","key","keyCode","optionsLength","_activeOption","val","Boolean","PFElement","PfeSearchDroplist","_ariaAnnounce","_ul","target","innerText","options","ariaAnnounceText","replace","textContent","map","item","index","join","name","_activeIndexChanged","_renderOptions","classList","remove","activeOption","add","ulWrapper","activeOptionHeight","offsetHeight","getComputedStyle","getPropertyValue","scrollTop","offsetTop","create"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;EA2BA,IAAMA,UAAU;EACdC,SAAO,EADO;EAEdC,QAAM,EAFQ;EAGdC,MAAI,EAHU;EAIdC,OAAK;EAJS,CAAhB;;EAOA;EACA,IAAIC,WAAW,KAAf;;MAEMC;;;;6BAKO;EACT;EAyCD;;;6BAae;EACd,aAAO,uBAAP;EACD;;;6BAEiB;EAChB,aAAO,uBAAP;EACD;;;6BAEc;EACb,aAAO,uBAAP;EACD;;;6BArEoB;EACnB,a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AIA,GAAJ,EAAS;EACP,aAAKtC,YAAL,CAAkB,MAAlB,EAA0B,EAA1B;EACD,OAFD,MAEO;EACL,aAAKC,eAAL,CAAqB,MAArB;EACD;EACF;;;6BAEiB;EAChB,aAAO,KAAKQ,YAAL,CAAkB,cAAlB,CAAP;EACD;2BAEe6B,KAAK;EACnB,WAAKtC,YAAL,CAAkB,cAAlB,EAAkCsC,GAAlC;EACD;;;6BAEY;EACX,aAAO,KAAK9B,YAAL,CAAkB,QAAlB,CAAP;EACD;2BAEU8B,KAAK;EACdA,YAAMC,QAAQD,GAAR,CAAN;;EAEA,UAAIA,GAAJ,EAAS;EACP,aAAKtC,YAAL,CAAkB,QAAlB,EAA4B,EAA5B;EACD,OAFD,MAEO;EACL,aAAKC,eAAL,CAAqB,QAArB;EACD;EACF;;;6BAtF+B;EAC9B,aAAO,CAAC,MAAD,EAAS,QAAT,EAAmB,cAAnB,CAAP;EACD;;;IAhF6BuC;;EAuKhCA,UAAU4B,MAAV,CAAiB3B,iBAAjB;EACAD,UAAU4B,MAAV,CAAiB5G,eAAjB;;;;;;;;"} \ No newline at end of file diff --git a/elements/pfe-autocomplete/dist/pfe-autocomplete.umd.min.js b/elements/pfe-autocomplete/dist/pfe-autocomplete.umd.min.js new file mode 100644 index 0000000000..a9c778bc32 --- /dev/null +++ b/elements/pfe-autocomplete/dist/pfe-autocomplete.umd.min.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("../../pfelement/dist/pfelement.umd")):"function"==typeof define&&define.amd?define(["../../pfelement/dist/pfelement.umd"],t):e.PfeAutocomplete=t(e.PFElement)}(this,function(e){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e;function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(e,t,i){return t&&o(e.prototype,t),i&&o(e,i),e};function o(e,t){for(var i=0;i.sr-only{position:absolute;overflow:hidden;clip:rect(0,0,0,0);height:1px;width:1px;margin:-1px;padding:0;border:0}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host{color:#151515!important}}:host([on=dark]){--pfe-broadcasted--text:var(--pfe-theme--color--text--on-dark, #fff);--pfe-broadcasted--link:var(--pfe-theme--color--link--on-dark, #73bcf7);--pfe-broadcasted--link--hover:var(--pfe-theme--color--link--hover--on-dark, #bee1f4);--pfe-broadcasted--link--focus:var(--pfe-theme--color--link--focus--on-dark, #bee1f4);--pfe-broadcasted--link--visited:var(--pfe-theme--color--link--visited--on-dark, #bee1f4);--pfe-broadcasted--link-decoration:var(--pfe-theme--link-decoration--on-dark, none);--pfe-broadcasted--link-decoration--hover:var(--pfe-theme--link-decoration--hover--on-dark, underline);--pfe-broadcasted--link-decoration--focus:var(--pfe-theme--link-decoration--focus--on-dark, underline);--pfe-broadcasted--link-decoration--visited:var(--pfe-theme--link-decoration--visited--on-dark, none)}:host([on=saturated]){--pfe-broadcasted--text:var(--pfe-theme--color--text--on-saturated, #fff);--pfe-broadcasted--link:var(--pfe-theme--color--link--on-saturated, #fff);--pfe-broadcasted--link--hover:var(--pfe-theme--color--link--hover--on-saturated, #fafafa);--pfe-broadcasted--link--focus:var(--pfe-theme--color--link--focus--on-saturated, #fafafa);--pfe-broadcasted--link--visited:var(--pfe-theme--color--link--visited--on-saturated, #8476d1);--pfe-broadcasted--link-decoration:var(--pfe-theme--link-decoration--on-saturated, underline);--pfe-broadcasted--link-decoration--hover:var(--pfe-theme--link-decoration--hover--on-saturated, underline);--pfe-broadcasted--link-decoration--focus:var(--pfe-theme--link-decoration--focus--on-saturated, underline);--pfe-broadcasted--link-decoration--visited:var(--pfe-theme--link-decoration--visited--on-saturated, underline)}:host([on=light]){--pfe-broadcasted--text:var(--pfe-theme--color--text, #151515);--pfe-broadcasted--link:var(--pfe-theme--color--link, #06c);--pfe-broadcasted--link--hover:var(--pfe-theme--color--link--hover, #004080);--pfe-broadcasted--link--focus:var(--pfe-theme--color--link--focus, #004080);--pfe-broadcasted--link--visited:var(--pfe-theme--color--link--visited, #6753ac);--pfe-broadcasted--link-decoration:var(--pfe-theme--link-decoration, none);--pfe-broadcasted--link-decoration--hover:var(--pfe-theme--link-decoration--hover, underline);--pfe-broadcasted--link-decoration--focus:var(--pfe-theme--link-decoration--focus, underline);--pfe-broadcasted--link-decoration--visited:var(--pfe-theme--link-decoration--visited, none)}:host{display:block;position:relative;font-family:Overpass,Overpass,Helvetica,helvetica,arial,sans-serif;font-family:var(--pfe-theme--font-family, "Overpass", Overpass, Helvetica, helvetica, arial, sans-serif)}#input-box-wrapper{border-color:#0277bd;border-color:var(--pfe-theme--color--feedback--info,#0277bd)}#input-box-wrapper ::slotted(input){width:100%;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;-webkit-box-shadow:inset 0 0 .625rem 0 #fafafa!important;box-shadow:inset 0 0 .625rem 0 #fafafa!important;-webkit-box-shadow:var(--pfe-autocomplete--BoxShadow,var(--pfe-theme--box-shadow--inset,inset 0 0 .625rem 0 #fafafa))!important;box-shadow:var(--pfe-autocomplete--BoxShadow,var(--pfe-theme--box-shadow--inset,inset 0 0 .625rem 0 #fafafa))!important;padding-left:10px;padding-right:30px;border-radius:2px;border-radius:var(--pfe-theme--ui--border-radius,2px);background-color:#fff;background-color:var(--pfe-autocomplete--BackgroundColor,var(--pfe-theme--color--surface--lightest,#fff));border:1px solid #d2d2d2;border:var(--pfe-autocomplete--Border,var(--pfe-theme--ui--border-width,1px) var(--pfe-theme--ui--border-style,solid) var(--pfe-theme--color--surface--border,#d2d2d2));font-size:16px;font-size:var(--pfe-theme--font-size,16px);height:calc(20px * 2);height:calc(var(--pfe-theme--ui--element--size,20px) * 2);-webkit-transition:border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;transition:border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s;transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;opacity:1;outline:0}#input-box-wrapper ::slotted(input:disabled),#input-box-wrapper button:disabled{cursor:not-allowed;background-color:transparent;color:#ccc;opacity:.5}#input-box-wrapper ::slotted(input:focus),#input-box-wrapper button:focus{outline:0}#input-box-wrapper ::slotted(input),#input-box-wrapper button{-webkit-appearance:none}#input-box-wrapper ::slotted([type=search]::-ms-clear){display:none}#input-box-wrapper ::slotted(input[type=search]::-webkit-search-cancel-button),#input-box-wrapper ::slotted(input[type=search]::-webkit-search-decoration){-webkit-appearance:none}button{color:#6a6e73;color:var(--pfe-theme--color--ui-base,#6a6e73);background-color:transparent;border:none;position:absolute;top:0;bottom:0;cursor:pointer}button.clear-search{right:30px;width:20px;margin:2px 1px;background-color:#fff;background-color:var(--pfe-theme--color--surface--lightest,#fff)}button.clear-search:hover{color:#6a6e73;color:var(--pfe-theme--color--ui-base,#6a6e73)}button.clear-search svg{width:12px;stroke:#d2d2d2;stroke:var(--pfe-theme--color--surface--border,#d2d2d2)}button.clear-search:focus svg,button.clear-search:hover svg{opacity:1;stroke:#06c;stroke:var(--pfe-theme--color--link,#06c)}button[disabled].clear-search:focus svg,button[disabled].clear-search:hover svg{stroke:#d2d2d2;stroke:var(--pfe-theme--color--surface--border,#d2d2d2)}button.search-button{right:1px;width:30px}button.search-button svg{fill:#06c;fill:var(--pfe-theme--color--link,#06c);width:16px}button.search-button:focus svg,button.search-button:hover svg{fill:#004080;fill:var(--pfe-theme--color--link--hover,#004080)}button.search-button:disabled svg{fill:#d2d2d2;fill:var(--pfe-theme--color--ui-disabled,#d2d2d2)}.loading{position:absolute;width:30px;right:52px;top:0;bottom:0}.loading svg{width:26px;padding-top:7px}\n/*# sourceMappingURL=pfe-autocomplete.min.css.map */\n
    \n \n\n \n\n \n\n \n
    \n'}},{key:"schemaUrl",get:function(){return"pfe-autocomplete.json"}},{key:"templateUrl",get:function(){return"pfe-autocomplete.html"}},{key:"styleUrl",get:function(){return"pfe-autocomplete.scss"}}],[{key:"version",get:function(){return"1.0.0-prerelease.54"}},{key:"properties",get:function(){return{debounce_timer:{title:"Debounce",description:"The amount of time that should pass before the next API call is made",type:"string",prefixed:!1},init_value:{title:"Initial value",description:"An initial value to show in the input field",type:"string",prefixed:!1},is_disabled:{title:"Is disabled",description:"Disable the input",type:"boolean",prefixed:!1}}}},{key:"slots",get:function(){return{content:{title:"Content",type:"array",namedSlot:!1,items:{oneOf:[{$ref:"input"}]},required:!0}}}},{key:"tag",get:function(){return"pfe-autocomplete"}},{key:"events",get:function(){return{search:this.tag+":search-event",select:this.tag+":option-selected",slotchange:"slotchange"}}}]),i(p,[{key:"connectedCallback",value:function(){a(p.prototype.__proto__||Object.getPrototypeOf(p.prototype),"connectedCallback",this).call(this),this.loading=!1,this.debounce=this.debounce||300,this._ariaAnnounceTemplate="There are ${numOptions} suggestions. Use the up and down arrows to browse.",this._clearBtn=this.shadowRoot.querySelector(".clear-search"),this._clearBtn.addEventListener("click",this._clear.bind(this)),this._searchBtn=this.shadowRoot.querySelector(".search-button"),this._searchBtn.addEventListener("click",this._search.bind(this)),this._dropdown=this.shadowRoot.querySelector("#dropdown"),this._dropdown.data=[],this.activeIndex=null,this.addEventListener("keyup",this._inputKeyUp.bind(this)),this.addEventListener(p.events.search,this._closeDroplist.bind(this)),this.addEventListener(p.events.select,this._optionSelected.bind(this))}},{key:"disconnectedCallback",value:function(){this.removeEventListener("keyup",this._inputKeyUp),this.removeEventListener(p.events.search,this._closeDroplist),this.removeEventListener(p.events.select,this._optionSelected),this._slot.removeEventListener(p.events.slotchange,this._slotchangeHandler),this._input&&(this._input.removeEventListener("input",this._inputChanged),this._input.removeEventListener("blur",this._closeDroplist)),this._clearBtn.removeEventListener("click",this._clear),this._searchBtn.removeEventListener("click",this._search)}},{key:"attributeChangedCallback",value:function(e,t,i){a(p.prototype.__proto__||Object.getPrototypeOf(p.prototype),"attributeChangedCallback",this).call(this);var o=this.shadowRoot.querySelector("slot").assignedNodes().filter(function(e){return e.nodeType===Node.ELEMENT_NODE})[0],n=this.shadowRoot.querySelector(".clear-search"),r=this.shadowRoot.querySelector(".search-button");switch(e){case"loading":this.loading&&""!==o.value?this.shadowRoot.querySelector(".loading").removeAttribute("hidden"):this.shadowRoot.querySelector(".loading").setAttribute("hidden","");break;case"init-value":this["init-value"]!==i&&(""===(o.value=i)||this.isDisabled?(r.setAttribute("disabled",""),n.setAttribute("hidden","")):(r.removeAttribute("disabled"),n.removeAttribute("hidden")));break;case"is-disabled":this.isDisabled?(n.setAttribute("disabled",""),r.setAttribute("disabled",""),o.setAttribute("disabled","")):(n.removeAttribute("disabled"),r.removeAttribute("disabled"),o.removeAttribute("disabled"))}}},{key:"_slotchangeHandler",value:function(){var e=this.shadowRoot.querySelector("slot").assignedNodes().filter(function(e){return e.nodeType===Node.ELEMENT_NODE});0!==e.length?(this._input=e[0],"input"===this._input.tagName.toLowerCase()?(this._input.addEventListener("input",this._inputChanged.bind(this)),this._input.addEventListener("blur",this._closeDroplist.bind(this)),this._input.setAttribute("role","combobox"),this._input.hasAttribute("aria-label")||this._input.setAttribute("aria-label","Search"),this._input.setAttribute("aria-autocomplete","both"),this._input.setAttribute("aria-haspopup","true"),this._input.setAttribute("type","search"),this._input.setAttribute("autocomplete","off"),this._input.setAttribute("autocorrect","off"),this._input.setAttribute("autocapitalize","off"),this._input.setAttribute("spellcheck","false"),this._dropdown._ariaAnnounceTemplate=this.getAttribute("aria-announce-template")||this._ariaAnnounceTemplate):console.error(p.tag+": The only child in the light DOM must be an input tag")):console.error(p.tag+": There must be a input tag in the light DOM")}},{key:"_inputChanged",value:function(){var e=this;if(""===this._input.value)return this._searchBtn.setAttribute("disabled",""),this._clearBtn.setAttribute("hidden",""),void this._reset();this._input.hasAttribute("disabled")||this._searchBtn.removeAttribute("disabled"),this._clearBtn.removeAttribute("hidden"),!1===u&&(u=!0,window.setTimeout(function(){e._sendAutocompleteRequest(e._input.value),u=!1},this.debounce))}},{key:"_clear",value:function(){this._input.value="",this._clearBtn.setAttribute("hidden",""),this._searchBtn.setAttribute("disabled",""),this._input.focus()}},{key:"_search",value:function(){this._doSearch(this._input.value)}},{key:"_closeDroplist",value:function(){this._dropdown.open=null,this._dropdown.removeAttribute("active-index")}},{key:"_openDroplist",value:function(){this.activeIndex=null,this._dropdown.setAttribute("open",!0),this._dropdown.setAttribute("active-index",null)}},{key:"_optionSelected",value:function(e){var t=e.detail.optionValue;this._input.value=t,this._doSearch(t)}},{key:"_doSearch",value:function(e){this.emitEvent(p.events.search,{detail:{searchValue:e},composed:!0}),this._reset(),this.selectedValue=e}},{key:"_sendAutocompleteRequest",value:function(e){this.autocompleteRequest&&this.autocompleteRequest({query:e},this._autocompleteCallback.bind(this))}},{key:"_autocompleteCallback",value:function(e){this._dropdown.data=e,this._dropdown.reflow=!0,0!==e.length?this._openDroplist():this._closeDroplist()}},{key:"_reset",value:function(){this._dropdown.activeIndex=null,this._input.setAttribute("aria-activedescendant",""),this._dropdown.data=[],this._closeDroplist()}},{key:"_activeOption",value:function(e){if(null!==e&&"null"!==e)return this._dropdown.shadowRoot.querySelector("li:nth-child("+(parseInt(e,10)+1)+")").innerHTML}},{key:"_inputKeyUp",value:function(e){var t=e.keyCode;if(0!==this._dropdown.data.length||t===l||t===d||t===s||t===c){var i=this._dropdown.activeIndex,o=this._dropdown.data.length;if(t==c)this._closeDroplist();else if(t===d){if(!this._dropdown.open)return;i=null===i||"null"===i?o:parseInt(i,10),(i-=1)<0&&(i=o-1),this._input.value=this._activeOption(i)}else if(t===l){if(!this._dropdown.open)return;i=null===i||"null"===i?-1:parseInt(i,10),o-1<(i+=1)&&(i=0),this._input.value=this._activeOption(i)}else if(t===s){if(this._activeOption(i))return void this.emitEvent(p.events.select,{detail:{optionValue:this._activeOption(i)},composed:!0});var n=this._input.value;return void this._doSearch(n)}null!==i&&"null"!==i?this._input.setAttribute("aria-activedescendant","option-"+i):this._input.setAttribute("aria-activedescendant",""),this.activeIndex=i,this._dropdown.activeIndex=i}}},{key:"selectedValue",get:function(){return this.getAttribute("selected-value")},set:function(e){this.setAttribute("selected-value",e)}},{key:"isDisabled",set:function(e){e?this.setAttribute("is-disabled",""):this.removeAttribute("is-disabled")},get:function(){return this.hasAttribute("is-disabled")}},{key:"loading",set:function(e){Boolean(e)?this.setAttribute("loading",""):this.removeAttribute("loading")},get:function(){return this.hasAttribute("loading")}},{key:"initValue",get:function(){return this.getAttribute("init-value")},set:function(e){this.setAttribute("init-value",e)}},{key:"debounce",get:function(){return this.getAttribute("debounce")},set:function(e){this.setAttribute("debounce",e)}}],[{key:"observedAttributes",get:function(){return["init-value","loading","is-disabled"]}}]),p);function p(){t(this,p);var e=r(this,(p.__proto__||Object.getPrototypeOf(p)).call(this,p));return e._slotchangeHandler=e._slotchangeHandler.bind(e),e._slot=e.shadowRoot.querySelector("slot"),e._slot.addEventListener(p.events.slotchange,e._slotchangeHandler),e}var f=(n(b,e),i(b,[{key:"html",get:function(){return'
    \n
    \n
      \n
    \n
    '}},{key:"templateUrl",get:function(){return"pfe-search-droplist.html"}},{key:"styleUrl",get:function(){return"pfe-search-droplist.scss"}}],[{key:"version",get:function(){return"1.0.0-prerelease.54"}},{key:"tag",get:function(){return"pfe-search-droplist"}}]),i(b,[{key:"connectedCallback",value:function(){a(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"connectedCallback",this).call(this),this._ariaAnnounce=this.shadowRoot.querySelector(".suggestions-aria-help"),this.activeIndex=null,this._ul=this.shadowRoot.querySelector("ul"),this._ul.addEventListener("mousedown",this._optionSelected.bind(this))}},{key:"disconnectedCallback",value:function(){this._ul.removeEventListener("mousedown",this._optionSelected)}},{key:"_optionSelected",value:function(e){"LI"===e.target.tagName&&this.emitEvent(h.events.select,{detail:{optionValue:e.target.innerText},composed:!0})}},{key:"_renderOptions",value:function(){this.reflow="";var e=this.data,t="";this._ariaAnnounceTemplate&&(t=this._ariaAnnounceTemplate.replace("${numOptions}",e.length)),this._ariaAnnounce.textContent=t,this._ariaAnnounce.setAttribute("aria-live","polite"),this._ul.innerHTML=""+e.map(function(e,t){return'
  • '+e+"
  • "}).join("")}},{key:"attributeChangedCallback",value:function(e,t,i){a(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"attributeChangedCallback",this).call(this),this[name]!==i&&(this[name]=i),"active-index"===e&&t!==i&&this._activeIndexChanged(),"reflow"===e&&this._renderOptions()}},{key:"_activeIndexChanged",value:function(){if(this.data&&0!==this.data.length&&null!==this.activeIndex&&"null"!==this.activeIndex){this._ul.querySelector(".active")&&this._ul.querySelector(".active").classList.remove("active");var e=this._ul.querySelector("li:nth-child("+(parseInt(this.activeIndex,10)+1)+")");e.classList.add("active");var t=this.shadowRoot.querySelector(".droplist"),i=e.offsetHeight;i+=parseInt(window.getComputedStyle(e).getPropertyValue("margin-bottom"),10),t.scrollTop=e.offsetTop-t.offsetHeight+i}}},{key:"open",get:function(){return this.hasAttribute("open")},set:function(e){(e=Boolean(e))?this.setAttribute("open",""):this.removeAttribute("open")}},{key:"activeIndex",get:function(){return this.getAttribute("active-index")},set:function(e){this.setAttribute("active-index",e)}},{key:"reflow",get:function(){return this.hasAttribute("reflow")},set:function(e){(e=Boolean(e))?this.setAttribute("reflow",""):this.removeAttribute("reflow")}}],[{key:"observedAttributes",get:function(){return["open","reflow","active-index"]}}]),b);function b(){return t(this,b),r(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,b))}return e.create(f),e.create(h),h}); +//# sourceMappingURL=pfe-autocomplete.umd.min.js.map diff --git a/elements/pfe-autocomplete/dist/pfe-autocomplete.umd.min.js.map b/elements/pfe-autocomplete/dist/pfe-autocomplete.umd.min.js.map new file mode 100644 index 0000000000..02676f9aec --- /dev/null +++ b/elements/pfe-autocomplete/dist/pfe-autocomplete.umd.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-autocomplete.umd.min.js","sources":["../_temp/pfe-autocomplete.umd.js"],"sourcesContent":["/*!\n * PatternFly Elements: PfeAutocomplete 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.umd\";\n\nconst KEYCODE = {\n ENTER: 13,\n DOWN: 40,\n UP: 38,\n ESC: 27\n};\n\n// use this variable to debounce api call when user types very fast\nlet throttle = false;\n\nclass PfeAutocomplete extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
    \n \n\n \n\n \n\n \n
    \n`;\n }\n\n static get properties() {\n return {\"debounce_timer\":{\"title\":\"Debounce\",\"description\":\"The amount of time that should pass before the next API call is made\",\"type\":\"string\",\"prefixed\":false},\"init_value\":{\"title\":\"Initial value\",\"description\":\"An initial value to show in the input field\",\"type\":\"string\",\"prefixed\":false},\"is_disabled\":{\"title\":\"Is disabled\",\"description\":\"Disable the input\",\"type\":\"boolean\",\"prefixed\":false}};\n }\n\n static get slots() {\n return {\"content\":{\"title\":\"Content\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"input\"}]},\"required\":true}};\n }\n static get tag() {\n return \"pfe-autocomplete\";\n }\n\n get schemaUrl() {\n return \"pfe-autocomplete.json\";\n }\n\n get templateUrl() {\n return \"pfe-autocomplete.html\";\n }\n\n get styleUrl() {\n return \"pfe-autocomplete.scss\";\n }\n\n static get events() {\n return {\n search: `${this.tag}:search-event`,\n select: `${this.tag}:option-selected`,\n slotchange: `slotchange`\n };\n }\n\n constructor() {\n super(PfeAutocomplete);\n\n this._slotchangeHandler = this._slotchangeHandler.bind(this);\n\n this._slot = this.shadowRoot.querySelector(\"slot\");\n this._slot.addEventListener(\n PfeAutocomplete.events.slotchange,\n this._slotchangeHandler\n );\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n this.loading = false;\n this.debounce = this.debounce || 300;\n this._ariaAnnounceTemplate =\n \"There are ${numOptions} suggestions. Use the up and down arrows to browse.\";\n\n // clear button\n this._clearBtn = this.shadowRoot.querySelector(\".clear-search\");\n this._clearBtn.addEventListener(\"click\", this._clear.bind(this));\n\n // search button\n this._searchBtn = this.shadowRoot.querySelector(\".search-button\");\n this._searchBtn.addEventListener(\"click\", this._search.bind(this));\n\n this._dropdown = this.shadowRoot.querySelector(\"#dropdown\");\n this._dropdown.data = [];\n\n this.activeIndex = null;\n\n this.addEventListener(\"keyup\", this._inputKeyUp.bind(this));\n\n // these two events, fire search\n this.addEventListener(\n PfeAutocomplete.events.search,\n this._closeDroplist.bind(this)\n );\n this.addEventListener(\n PfeAutocomplete.events.select,\n this._optionSelected.bind(this)\n );\n }\n\n disconnectedCallback() {\n this.removeEventListener(\"keyup\", this._inputKeyUp);\n\n this.removeEventListener(\n PfeAutocomplete.events.search,\n this._closeDroplist\n );\n this.removeEventListener(\n PfeAutocomplete.events.select,\n this._optionSelected\n );\n this._slot.removeEventListener(\n PfeAutocomplete.events.slotchange,\n this._slotchangeHandler\n );\n if (this._input) {\n this._input.removeEventListener(\"input\", this._inputChanged);\n this._input.removeEventListener(\"blur\", this._closeDroplist);\n }\n\n this._clearBtn.removeEventListener(\"click\", this._clear);\n this._searchBtn.removeEventListener(\"click\", this._search);\n }\n\n static get observedAttributes() {\n return [\"init-value\", \"loading\", \"is-disabled\"];\n }\n\n attributeChangedCallback(attr, oldVal, newVal) {\n super.attributeChangedCallback();\n\n let slotNodes = this.shadowRoot.querySelector(\"slot\").assignedNodes();\n let slotElems = slotNodes.filter(n => n.nodeType === Node.ELEMENT_NODE);\n let _input = slotElems[0];\n\n let _clearBtn = this.shadowRoot.querySelector(\".clear-search\");\n let _searchBtn = this.shadowRoot.querySelector(\".search-button\");\n\n switch (attr) {\n case \"loading\":\n if (!this.loading || _input.value === \"\") {\n this.shadowRoot.querySelector(\".loading\").setAttribute(\"hidden\", \"\");\n } else {\n this.shadowRoot.querySelector(\".loading\").removeAttribute(\"hidden\");\n }\n break;\n\n case \"init-value\":\n if (this[\"init-value\"] !== newVal) {\n // set inputbox and buttons in the inner component\n _input.value = newVal;\n if (newVal !== \"\" && !this.isDisabled) {\n _searchBtn.removeAttribute(\"disabled\");\n _clearBtn.removeAttribute(\"hidden\");\n } else {\n _searchBtn.setAttribute(\"disabled\", \"\");\n _clearBtn.setAttribute(\"hidden\", \"\");\n }\n }\n break;\n\n case \"is-disabled\":\n if (this.isDisabled) {\n _clearBtn.setAttribute(\"disabled\", \"\");\n _searchBtn.setAttribute(\"disabled\", \"\");\n _input.setAttribute(\"disabled\", \"\");\n } else {\n _clearBtn.removeAttribute(\"disabled\");\n _searchBtn.removeAttribute(\"disabled\");\n _input.removeAttribute(\"disabled\");\n }\n break;\n }\n }\n\n get selectedValue() {\n return this.getAttribute(\"selected-value\");\n }\n\n set selectedValue(val) {\n this.setAttribute(\"selected-value\", val);\n }\n\n set isDisabled(value) {\n if (value) {\n this.setAttribute(\"is-disabled\", \"\");\n } else {\n this.removeAttribute(\"is-disabled\");\n }\n }\n\n get isDisabled() {\n return this.hasAttribute(\"is-disabled\");\n }\n\n set loading(value) {\n const loading = Boolean(value);\n if (loading) {\n this.setAttribute(\"loading\", \"\");\n } else {\n this.removeAttribute(\"loading\");\n }\n }\n\n get loading() {\n return this.hasAttribute(\"loading\");\n }\n\n get initValue() {\n return this.getAttribute(\"init-value\");\n }\n\n set initValue(val) {\n this.setAttribute(\"init-value\", val);\n }\n\n get debounce() {\n return this.getAttribute(\"debounce\");\n }\n\n set debounce(val) {\n this.setAttribute(\"debounce\", val);\n }\n\n _slotchangeHandler() {\n // input box\n let slotNodes = this.shadowRoot.querySelector(\"slot\").assignedNodes();\n let slotElems = slotNodes.filter(n => n.nodeType === Node.ELEMENT_NODE);\n\n if (slotElems.length === 0) {\n console.error(\n `${PfeAutocomplete.tag}: There must be a input tag in the light DOM`\n );\n\n return;\n }\n\n this._input = slotElems[0];\n\n if (this._input.tagName.toLowerCase() !== \"input\") {\n console.error(\n `${PfeAutocomplete.tag}: The only child in the light DOM must be an input tag`\n );\n\n return;\n }\n\n this._input.addEventListener(\"input\", this._inputChanged.bind(this));\n this._input.addEventListener(\"blur\", this._closeDroplist.bind(this));\n\n this._input.setAttribute(\"role\", \"combobox\");\n\n if (!this._input.hasAttribute(\"aria-label\")) {\n this._input.setAttribute(\"aria-label\", \"Search\");\n }\n\n this._input.setAttribute(\"aria-autocomplete\", \"both\");\n this._input.setAttribute(\"aria-haspopup\", \"true\");\n this._input.setAttribute(\"type\", \"search\");\n this._input.setAttribute(\"autocomplete\", \"off\");\n this._input.setAttribute(\"autocorrect\", \"off\");\n this._input.setAttribute(\"autocapitalize\", \"off\");\n this._input.setAttribute(\"spellcheck\", \"false\");\n\n this._dropdown._ariaAnnounceTemplate =\n this.getAttribute(\"aria-announce-template\") || this._ariaAnnounceTemplate;\n }\n\n _inputChanged() {\n if (this._input.value === \"\") {\n this._searchBtn.setAttribute(\"disabled\", \"\");\n this._clearBtn.setAttribute(\"hidden\", \"\");\n\n this._reset();\n return;\n } else {\n if (!this._input.hasAttribute(\"disabled\")) {\n this._searchBtn.removeAttribute(\"disabled\");\n }\n this._clearBtn.removeAttribute(\"hidden\");\n }\n\n if (throttle === false) {\n throttle = true;\n\n window.setTimeout(() => {\n this._sendAutocompleteRequest(this._input.value);\n throttle = false;\n }, this.debounce);\n }\n }\n\n _clear() {\n this._input.value = \"\";\n this._clearBtn.setAttribute(\"hidden\", \"\");\n this._searchBtn.setAttribute(\"disabled\", \"\");\n this._input.focus();\n }\n\n _search() {\n this._doSearch(this._input.value);\n }\n\n _closeDroplist() {\n this._dropdown.open = null;\n this._dropdown.removeAttribute(\"active-index\");\n }\n\n _openDroplist() {\n this.activeIndex = null;\n this._dropdown.setAttribute(\"open\", true);\n this._dropdown.setAttribute(\"active-index\", null);\n }\n\n _optionSelected(e) {\n let selectedValue = e.detail.optionValue;\n\n // update input box with selected value from options list\n this._input.value = selectedValue;\n\n // send search request\n this._doSearch(selectedValue);\n }\n\n _doSearch(searchQuery) {\n this.emitEvent(PfeAutocomplete.events.search, {\n detail: { searchValue: searchQuery },\n composed: true\n });\n this._reset();\n this.selectedValue = searchQuery;\n }\n\n _sendAutocompleteRequest(input) {\n if (!this.autocompleteRequest) return;\n\n this.autocompleteRequest(\n { query: input },\n this._autocompleteCallback.bind(this)\n );\n }\n\n _autocompleteCallback(response) {\n this._dropdown.data = response;\n this._dropdown.reflow = true;\n response.length !== 0 ? this._openDroplist() : this._closeDroplist();\n }\n\n _reset() {\n this._dropdown.activeIndex = null;\n this._input.setAttribute(\"aria-activedescendant\", \"\");\n this._dropdown.data = [];\n this._closeDroplist();\n }\n\n _activeOption(activeIndex) {\n if (activeIndex === null || activeIndex === \"null\") return;\n return this._dropdown.shadowRoot.querySelector(\n \"li:nth-child(\" + (parseInt(activeIndex, 10) + 1) + \")\"\n ).innerHTML;\n }\n\n _inputKeyUp(e) {\n let key = e.keyCode;\n\n if (\n this._dropdown.data.length === 0 &&\n key !== KEYCODE.DOWN &&\n key !== KEYCODE.UP &&\n key !== KEYCODE.ENTER &&\n key !== KEYCODE.ESC\n )\n return;\n\n let activeIndex = this._dropdown.activeIndex;\n let optionsLength = this._dropdown.data.length;\n\n if (key == KEYCODE.ESC) {\n this._closeDroplist();\n } else if (key === KEYCODE.UP) {\n if (!this._dropdown.open) {\n return;\n }\n\n activeIndex =\n activeIndex === null || activeIndex === \"null\"\n ? optionsLength\n : parseInt(activeIndex, 10);\n\n activeIndex -= 1;\n\n if (activeIndex < 0) {\n activeIndex = optionsLength - 1;\n }\n\n this._input.value = this._activeOption(activeIndex);\n } else if (key === KEYCODE.DOWN) {\n if (!this._dropdown.open) {\n return;\n }\n\n activeIndex =\n activeIndex === null || activeIndex === \"null\"\n ? -1\n : parseInt(activeIndex, 10);\n activeIndex += 1;\n\n if (activeIndex > optionsLength - 1) {\n activeIndex = 0;\n }\n\n this._input.value = this._activeOption(activeIndex);\n } else if (key === KEYCODE.ENTER) {\n if (this._activeOption(activeIndex)) {\n this.emitEvent(PfeAutocomplete.events.select, {\n detail: { optionValue: this._activeOption(activeIndex) },\n composed: true\n });\n\n return;\n }\n\n let selectedValue = this._input.value;\n this._doSearch(selectedValue);\n return;\n }\n\n if (activeIndex !== null && activeIndex !== \"null\") {\n this._input.setAttribute(\n \"aria-activedescendant\",\n \"option-\" + activeIndex\n );\n } else {\n this._input.setAttribute(\"aria-activedescendant\", \"\");\n }\n\n this.activeIndex = activeIndex;\n this._dropdown.activeIndex = activeIndex;\n }\n}\n\n/*\n* - Attributes ------------------------------------\n* open | Set when the combo box dropdown is open\n* active-index | Set selected option\n* reflow | Re-renders the dropdown\n\n* - Events ----------------------------------------\n* pfe-autocomplete:option-selected | Fires when an option is selected.\n event.details.optionValue contains the selected value.\n*/\nclass PfeSearchDroplist extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
    \n
    \n
      \n
    \n
    `;\n }\n static get tag() {\n return \"pfe-search-droplist\";\n }\n\n get templateUrl() {\n return \"pfe-search-droplist.html\";\n }\n\n get styleUrl() {\n return \"pfe-search-droplist.scss\";\n }\n\n constructor() {\n super(PfeSearchDroplist);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n this._ariaAnnounce = this.shadowRoot.querySelector(\n \".suggestions-aria-help\"\n );\n\n this.activeIndex = null;\n this._ul = this.shadowRoot.querySelector(\"ul\");\n this._ul.addEventListener(\"mousedown\", this._optionSelected.bind(this));\n }\n\n disconnectedCallback() {\n this._ul.removeEventListener(\"mousedown\", this._optionSelected);\n }\n\n _optionSelected(e) {\n if (e.target.tagName === \"LI\") {\n this.emitEvent(PfeAutocomplete.events.select, {\n detail: { optionValue: e.target.innerText },\n composed: true\n });\n }\n }\n\n _renderOptions() {\n this.reflow = \"\";\n\n let options = this.data;\n let ariaAnnounceText = \"\";\n\n if (this._ariaAnnounceTemplate) {\n ariaAnnounceText = this._ariaAnnounceTemplate.replace(\n \"${numOptions}\",\n options.length\n );\n }\n\n this._ariaAnnounce.textContent = ariaAnnounceText;\n this._ariaAnnounce.setAttribute(\"aria-live\", \"polite\");\n\n this._ul.innerHTML = `${options\n .map((item, index) => {\n return `
  • ${item}
  • `;\n })\n .join(\"\")}`;\n }\n\n static get observedAttributes() {\n return [\"open\", \"reflow\", \"active-index\"];\n }\n\n attributeChangedCallback(attr, oldVal, newVal) {\n super.attributeChangedCallback();\n\n if (this[name] !== newVal) {\n this[name] = newVal;\n }\n\n if (attr === \"active-index\" && oldVal !== newVal) {\n this._activeIndexChanged();\n }\n\n if (attr === \"reflow\") {\n this._renderOptions();\n }\n }\n\n _activeIndexChanged() {\n if (\n !this.data ||\n this.data.length === 0 ||\n this.activeIndex === null ||\n this.activeIndex === \"null\"\n )\n return;\n\n // remove active class\n if (this._ul.querySelector(\".active\")) {\n this._ul.querySelector(\".active\").classList.remove(\"active\");\n }\n\n // add active class to selected option\n let activeOption = this._ul.querySelector(\n \"li:nth-child(\" + (parseInt(this.activeIndex, 10) + 1) + \")\"\n );\n\n activeOption.classList.add(\"active\");\n\n // scroll to selected element when selected item with keyboard is out of view\n let ulWrapper = this.shadowRoot.querySelector(\".droplist\");\n let activeOptionHeight = activeOption.offsetHeight;\n activeOptionHeight += parseInt(\n window.getComputedStyle(activeOption).getPropertyValue(\"margin-bottom\"),\n 10\n );\n ulWrapper.scrollTop =\n activeOption.offsetTop - ulWrapper.offsetHeight + activeOptionHeight;\n }\n\n get open() {\n return this.hasAttribute(\"open\");\n }\n\n set open(val) {\n val = Boolean(val);\n\n if (val) {\n this.setAttribute(\"open\", \"\");\n } else {\n this.removeAttribute(\"open\");\n }\n }\n\n get activeIndex() {\n return this.getAttribute(\"active-index\");\n }\n\n set activeIndex(val) {\n this.setAttribute(\"active-index\", val);\n }\n\n get reflow() {\n return this.hasAttribute(\"reflow\");\n }\n\n set reflow(val) {\n val = Boolean(val);\n\n if (val) {\n this.setAttribute(\"reflow\", \"\");\n } else {\n this.removeAttribute(\"reflow\");\n }\n }\n}\n\nPFElement.create(PfeSearchDroplist);\nPFElement.create(PfeAutocomplete);\n\nexport default PfeAutocomplete;\n"],"names":["KEYCODE","throttle","PfeAutocomplete","PFElement","debounce_timer","title","description","type","prefixed","init_value","is_disabled","content","namedSlot","items","oneOf","$ref","required","this","tag","loading","debounce","_ariaAnnounceTemplate","_clearBtn","shadowRoot","querySelector","addEventListener","_clear","bind","_searchBtn","_search","_dropdown","data","activeIndex","_inputKeyUp","events","search","_closeDroplist","select","_optionSelected","removeEventListener","_slot","slotchange","_slotchangeHandler","_input","_inputChanged","attr","oldVal","newVal","assignedNodes","filter","n","nodeType","Node","ELEMENT_NODE","value","removeAttribute","setAttribute","isDisabled","slotElems","length","tagName","toLowerCase","hasAttribute","getAttribute","error","_reset","setTimeout","_sendAutocompleteRequest","_this2","focus","_doSearch","open","e","selectedValue","detail","optionValue","searchQuery","emitEvent","searchValue","input","autocompleteRequest","query","_autocompleteCallback","response","reflow","_openDroplist","parseInt","innerHTML","key","keyCode","optionsLength","_activeOption","val","Boolean","_this","PfeSearchDroplist","_ariaAnnounce","_ul","target","innerText","options","ariaAnnounceText","replace","textContent","map","item","index","join","name","_activeIndexChanged","_renderOptions","classList","remove","activeOption","add","ulWrapper","activeOptionHeight","offsetHeight","window","getComputedStyle","getPropertyValue","scrollTop","offsetTop","create"],"mappings":"q2CA2BMA,EACG,GADHA,EAEE,GAFFA,EAGA,GAHAA,EAIC,GAIHC,GAAW,EAETC,OAAwBC,wwQA6DnB,kEAIA,+DAIA,gEAnEA,+DAgDA,CAACC,eAAiB,CAACC,MAAQ,WAAWC,YAAc,uEAAuEC,KAAO,SAASC,UAAW,GAAOC,WAAa,CAACJ,MAAQ,gBAAgBC,YAAc,8CAA8CC,KAAO,SAASC,UAAW,GAAOE,YAAc,CAACL,MAAQ,cAAcC,YAAc,oBAAoBC,KAAO,UAAUC,UAAW,wCAIpY,CAACG,QAAU,CAACN,MAAQ,UAAUE,KAAO,QAAQK,WAAY,EAAMC,MAAQ,CAACC,MAAQ,CAAC,CAACC,KAAO,WAAWC,UAAW,sCAG/G,wDAgBA,QACMC,KAAKC,2BACLD,KAAKC,yMAoBbC,SAAU,OACVC,SAAWH,KAAKG,UAAY,SAC5BC,sBACH,kFAGGC,UAAYL,KAAKM,WAAWC,cAAc,sBAC1CF,UAAUG,iBAAiB,QAASR,KAAKS,OAAOC,KAAKV,YAGrDW,WAAaX,KAAKM,WAAWC,cAAc,uBAC3CI,WAAWH,iBAAiB,QAASR,KAAKY,QAAQF,KAAKV,YAEvDa,UAAYb,KAAKM,WAAWC,cAAc,kBAC1CM,UAAUC,KAAO,QAEjBC,YAAc,UAEdP,iBAAiB,QAASR,KAAKgB,YAAYN,KAAKV,YAGhDQ,iBACHvB,EAAgBgC,OAAOC,OACvBlB,KAAKmB,eAAeT,KAAKV,YAEtBQ,iBACHvB,EAAgBgC,OAAOG,OACvBpB,KAAKqB,gBAAgBX,KAAKV,2DAKvBsB,oBAAoB,QAAStB,KAAKgB,kBAElCM,oBACHrC,EAAgBgC,OAAOC,OACvBlB,KAAKmB,qBAEFG,oBACHrC,EAAgBgC,OAAOG,OACvBpB,KAAKqB,sBAEFE,MAAMD,oBACTrC,EAAgBg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,UAAUC,OAAO,cAIjDC,EAAehG,KAAKgF,IAAIzE,cAC1B,iBAAmB8D,SAASrE,KAAKe,YAAa,IAAM,GAAK,OAG9C+E,UAAUG,IAAI,cAGvBC,EAAYlG,KAAKM,WAAWC,cAAc,aAC1C4F,EAAqBH,EAAaI,gBAChB/B,SACpBgC,OAAOC,iBAAiBN,GAAcO,iBAAiB,iBACvD,MAEQC,UACRR,EAAaS,UAAYP,EAAUE,aAAeD,uCAI7CnG,KAAK6C,aAAa,sBAGlB8B,MACDC,QAAQD,SAGPpC,aAAa,OAAQ,SAErBD,gBAAgB,mDAKhBtC,KAAK8C,aAAa,8BAGX6B,QACTpC,aAAa,eAAgBoC,yCAI3B3E,KAAK6C,aAAa,wBAGhB8B,MACHC,QAAQD,SAGPpC,aAAa,SAAU,SAEvBD,gBAAgB,6DAnFhB,CAAC,OAAQ,SAAU,8GApDpBwC,WA4IV5F,EAAUwH,OAAO5B,GACjB5F,EAAUwH,OAAOzH"} \ No newline at end of file diff --git a/elements/pfe-autocomplete/package-lock.json b/elements/pfe-autocomplete/package-lock.json index 0756b1d1bf..78cad8083a 100644 --- a/elements/pfe-autocomplete/package-lock.json +++ b/elements/pfe-autocomplete/package-lock.json @@ -1,6 +1,6 @@ { "name": "@patternfly/pfe-autocomplete", - "version": "1.0.0-prerelease.53", + "version": "1.0.0-prerelease.54", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/elements/pfe-autocomplete/package.json b/elements/pfe-autocomplete/package.json index d3f81f8130..331ed0a1d6 100644 --- a/elements/pfe-autocomplete/package.json +++ b/elements/pfe-autocomplete/package.json @@ -4,7 +4,7 @@ "className": "PfeAutocomplete", "elementName": "pfe-autocomplete" }, - "version": "1.0.0-prerelease.53", + "version": "1.0.0-prerelease.54", "description": "Autocomplete element for PatternFly Elements", "keywords": [ "web-components", @@ -40,7 +40,7 @@ "@patternfly/pfelement": "^1.0.0-prerelease.51" }, "devDependencies": { - "@patternfly/pfe-sass": "^1.0.0-prerelease.53" + "@patternfly/pfe-sass": "^1.0.0-prerelease.54" }, "generator-pfelement-version": "0.5.5", "bugs": { diff --git a/elements/pfe-avatar/dist/pfe-avatar.js b/elements/pfe-avatar/dist/pfe-avatar.js new file mode 100644 index 0000000000..5ded779a1a --- /dev/null +++ b/elements/pfe-avatar/dist/pfe-avatar.js @@ -0,0 +1,490 @@ +import PFElement from '../../pfelement/dist/pfelement.js'; + +/** + * djb2 string hashing function. + * + * @see http://www.cse.yorku.ca/~oz/hash.html + * @param {String} str the string to hash. + * @return {Number} a positive integer + */ + +function hash(str) { + let hash = 5381; + let i = str.length; + + while (i) { + hash = (hash * 33) ^ str.charCodeAt(--i); + } + + return hash >>> 0; +} + +function h2rgb(v1, v2, vH) { + if (vH < 0) vH += 1; + if (vH > 1) vH -= 1; + if (6 * vH < 1) return v1 + (v2 - v1) * 6 * vH; + if (2 * vH < 1) return v2; + if (3 * vH < 2) return v1 + (v2 - v1) * (2 / 3 - vH) * 6; + return v1; +} + +/** + * Convert an HSL color to RGB. + * + * @param {Number} H the hue component + * @param {Number} S the saturation component + * @param {Number} L the luminance component + * @return {Array} [R, G, B] + * + * @see https://www.easyrgb.com/en/math.php + */ +function hsl2rgb(_H, _S, _L) { + let R, G, B; + + const H = Math.max(0, Math.min(1, _H)); + const S = Math.max(0, Math.min(1, _S)); + const L = Math.max(0, Math.min(1, _L)); + + if (S == 0) { + R = L * 255; + G = L * 255; + B = L * 255; + } else { + let a, b; + + if (L < 0.5) { + b = L * (1 + S); + } else { + b = L + S - S * L; + } + + a = 2 * L - b; + + R = Math.floor(255 * h2rgb(a, b, H + 1 / 3)); + G = Math.floor(255 * h2rgb(a, b, H)); + B = Math.floor(255 * h2rgb(a, b, H - 1 / 3)); + } + + return [R, G, B]; +} + +/** + * Convert an RGBcolor to HSL. + * + * @param {Number} R the red component + * @param {Number} G the green component + * @param {Number} B the blue component + * @return {Array} [H, S, L] + * + * @see https://www.easyrgb.com/en/math.php + */ +function rgb2hsl(_R, _G, _B) { + let H, S, L; + + const R = Math.max(0, Math.min(255, _R)); + const G = Math.max(0, Math.min(255, _G)); + const B = Math.max(0, Math.min(255, _B)); + + const r = R / 255; + const g = G / 255; + const b = B / 255; + + const var_min = Math.min(Math.min(r, g), b); + const var_max = Math.max(Math.max(r, g), b); + const del_max = var_max - var_min; + + L = (var_max + var_min) / 2; + + if (del_max === 0) { + H = 0; + S = 0; + } else { + if (L < 0.5) { + S = del_max / (var_max + var_min); + } else { + S = del_max / (2 - var_max - var_min); + } + + const del_r = ((var_max - r) / 6 + del_max / 2) / del_max; + const del_g = ((var_max - g) / 6 + del_max / 2) / del_max; + const del_b = ((var_max - b) / 6 + del_max / 2) / del_max; + + if (r == var_max) { + H = del_b - del_g; + } else if (g == var_max) { + H = 1 / 3 + del_r - del_b; + } else if (b == var_max) { + H = 2 / 3 + del_g - del_r; + } + + if (H < 0) { + H += 1; + } else if (H > 1) { + H -= 1; + } + } + + return [H, S, L]; +} + +/*! + * PatternFly Elements: PfeAvatar 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * +*/ + +class PfeAvatar extends PFElement { + static get version() { + return "1.0.0-prerelease.54"; + } + + get html() { + return ` +`; + } + static get tag() { + return "pfe-avatar"; + } + + get templateUrl() { + return "pfe-avatar.html"; + } + + get styleUrl() { + return "pfe-avatar.scss"; + } + + static get observedAttributes() { + return ["pfe-name", "pfe-pattern", "pfe-src", "pfe-shape"]; + } + + static get events() { + return { + connected: `${this.tag}:connected` + }; + } + + static get patterns() { + return { + triangles: "triangles", + squares: "squares" + }; + } + + static get defaultSize() { + return 128; + } + + static get defaultColors() { + return "#67accf #448087 #709c6b #a35252 #826cbb"; + } + + get name() { + return this.getAttribute("pfe-name"); + } + + set name(val) { + return this.setAttribute("pfe-name", val); + } + + get src() { + return this.getAttribute("pfe-src"); + } + + set src(href) { + return this.setAttribute("pfe-src", href); + } + + get pattern() { + return this.getAttribute("pfe-pattern") || PfeAvatar.patterns.squares; + } + + set pattern(name) { + if (!PfeAvatar.patterns[name]) { + this.log( + `invalid pattern "${name}", valid patterns are: ${Object.values( + PfeAvatar.patterns + )}` + ); + return; + } + return this.setAttribute("pfe-pattern", name); + } + + constructor() { + super(PfeAvatar); + } + + connectedCallback() { + super.connectedCallback(); + + this._initCanvas(); + + this.emitEvent(PfeAvatar.events.connected, { + bubbles: false + }); + } + + attributeChangedCallback(attr, oldValue, newValue) { + super.attributeChangedCallback(...arguments); + + if (this.connected) { + this.update(); + } else { + this.addEventListener(PfeAvatar.events.connected, () => this.update()); + } + } + + _initCanvas() { + this._canvas = this.shadowRoot.querySelector("canvas"); + const size = + this.var("--pfe-avatar--width").replace(/px$/, "") || + PfeAvatar.defaultSize; + this._canvas.width = size; + this._canvas.height = size; + + this._squareSize = this._canvas.width / 8; + this._triangleSize = this._canvas.width / 4; + + this._ctx = this._canvas.getContext("2d"); + } + + static _registerColors() { + this.colors = []; + const themeColors = this.var("--pfe-avatar--colors") || this.defaultColors; + + themeColors.split(/\s+/).forEach(colorCode => { + let pattern; + switch (colorCode.length) { + case 4: // ex: "#0fc" + pattern = /^#([A-f0-9])([A-f0-9])([A-f0-9])$/.exec(colorCode); + if (pattern) { + pattern.shift(); + const color = pattern.map(c => parseInt(c + c, 16)); + this._registerColor(color); + } else { + this.log(`[pfe-avatar] invalid color ${colorCode}`); + } + break; + case 7: // ex: "#00ffcc" + pattern = /^#([A-f0-9]{2})([A-f0-9]{2})([A-f0-9]{2})$/.exec( + colorCode + ); + if (pattern) { + pattern.shift(); + const color = pattern.map(c => parseInt(c, 16)); + this._registerColor(color); + } else { + this.log(`[pfe-avatar] invalid color ${colorCode}`); + } + } + }); + + return this.colors; + } + + static _registerColor(color) { + PfeAvatar.colors.push({ + color1: `rgb(${color.join(",")})`, + color2: `rgb(${this._adjustColor(color).join(",")})` + }); + } + + static _adjustColor(color) { + const dark = 0.1; + const l_adj = 0.1; // luminance adjustment + const hsl = rgb2hsl(...color); + + // if luminance is too dark already, then lighten the alternate color + // instead of darkening it. + hsl[2] += hsl[2] > dark ? -l_adj : l_adj; + + return hsl2rgb(...hsl); + } + + update() { + // if we have a src element, update the img, otherwise update the random pattern + if (this.hasAttribute("pfe-src")) { + this.shadowRoot.querySelector("img").src = this.src; + } else { + const bitPattern = hash(this.name).toString(2); + const arrPattern = bitPattern.split("").map(n => Number(n)); + this._colorIndex = Math.floor( + (PfeAvatar.colors.length * parseInt(bitPattern, 2)) / Math.pow(2, 32) + ); + this.color1 = PfeAvatar.colors[this._colorIndex].color1; + this.color2 = PfeAvatar.colors[this._colorIndex].color2; + + this._clear(); + this._drawBackground(); + if (this.pattern === PfeAvatar.patterns.squares) { + this._drawSquarePattern(arrPattern); + } else if (this.pattern === PfeAvatar.patterns.triangles) { + this._drawTrianglePattern(arrPattern); + } + // this._drawGradient(); + } + } + + _clear() { + this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height); + } + + _drawBackground() { + this._ctx.fillStyle = this.color1; + this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height); + } + + _drawSquarePattern(pattern) { + this._ctx.fillStyle = this.color2; + if (this._ctx) { + let i = pattern.length; + while (i--) { + if (pattern[i]) { + this._drawMirroredSquare(i % 4, Math.floor(i / 4)); + } + } + } + } + + /** + * Draw a square at the given position, mirrored onto both the left and right half of the canvas. + */ + _drawMirroredSquare(x, y) { + if (this._ctx) { + this._drawSquare(x, y); + this._drawSquare(7 - x, y); + } + } + + _drawSquare(x, y) { + this._ctx.fillRect( + this._squareSize * x, + this._squareSize * y, + this._squareSize, + this._squareSize + ); + } + + _drawTrianglePattern(pattern) { + this._ctx.fillStyle = this.color2; + if (this._ctx) { + let i = pattern.length; + while (i--) { + if (pattern[i]) { + const x = Math.floor(i / 2) % 2; + const y = Math.floor(i / 4); + const alt = i % 4; + + const p1 = [x, y]; + const p2 = [x, y]; + const p3 = [x, y]; + + switch (alt) { + case 0: + p2[1]++; + p3[0]++; + p3[1]++; + break; + case 1: + p2[0]++; + p3[0]++; + p3[1]++; + break; + case 2: + p2[0]++; + p3[1]++; + break; + case 3: + p1[0]++; + p2[0]++; + p2[1]++; + p3[1]++; + break; + } + + this._drawMirroredTriangle(p1, p2, p3); + } + } + } + } + + /** + * Draw a square at the given position in the top-left quadrant of the + * canvas, and mirrored to the other three quadrants. + */ + _drawMirroredTriangle(p1, p2, p3) { + if (this._ctx) { + this._drawTriangle(p1, p2, p3); + this._drawTriangle( + [4 - p1[0], p1[1]], + [4 - p2[0], p2[1]], + [4 - p3[0], p3[1]] + ); + } + } + + _drawTriangle(p1, p2, p3) { + this._ctx.beginPath(); + this._ctx.moveTo(...p1.map(c => c * this._triangleSize)); + this._ctx.lineTo(...p2.map(c => c * this._triangleSize)); + this._ctx.lineTo(...p3.map(c => c * this._triangleSize)); + this._ctx.closePath(); + this._ctx.fill(); + this._ctx.fill(); + } + + _drawGradient() { + const gradient = this._ctx.createLinearGradient( + 0, + this._canvas.height, + this._canvas.width, + 0 + ); + const color = this.color2; + let gradientColor1 = color; + let gradientColor2 = color; + if (/^#[A-f0-9]{3}$/.test(color)) { + // color is of the form "#fff" + gradientColor1 += "c"; + gradientColor2 += "0"; + } else if (/^#[A-f0-9]{6}$/.test(color)) { + // color is of the form "#ffffff" + gradientColor1 += "cc"; + gradientColor2 += "00"; + } + gradient.addColorStop(0, gradientColor1); + gradient.addColorStop(1, gradientColor2); + gradient.addColorStop(1, gradientColor1); + this._ctx.fillStyle = gradient; + this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height); + } +} + +PfeAvatar._registerColors(); + +PFElement.create(PfeAvatar); + +export default PfeAvatar; +//# sourceMappingURL=pfe-avatar.js.map diff --git a/elements/pfe-avatar/dist/pfe-avatar.js.map b/elements/pfe-avatar/dist/pfe-avatar.js.map new file mode 100644 index 0000000000..517886c80f --- /dev/null +++ b/elements/pfe-avatar/dist/pfe-avatar.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-avatar.js","sources":["../_temp/djb-hash.js","../_temp/hslrgb.js","../_temp/pfe-avatar.js"],"sourcesContent":["/**\n * djb2 string hashing function.\n *\n * @see http://www.cse.yorku.ca/~oz/hash.html\n * @param {String} str the string to hash.\n * @return {Number} a positive integer\n */\n\nfunction hash(str) {\n let hash = 5381;\n let i = str.length;\n\n while (i) {\n hash = (hash * 33) ^ str.charCodeAt(--i);\n }\n\n return hash >>> 0;\n}\n\nexport { hash };\n","function h2rgb(v1, v2, vH) {\n if (vH < 0) vH += 1;\n if (vH > 1) vH -= 1;\n if (6 * vH < 1) return v1 + (v2 - v1) * 6 * vH;\n if (2 * vH < 1) return v2;\n if (3 * vH < 2) return v1 + (v2 - v1) * (2 / 3 - vH) * 6;\n return v1;\n}\n\n/**\n * Convert an HSL color to RGB.\n *\n * @param {Number} H the hue component\n * @param {Number} S the saturation component\n * @param {Number} L the luminance component\n * @return {Array} [R, G, B]\n *\n * @see https://www.easyrgb.com/en/math.php\n */\nexport function hsl2rgb(_H, _S, _L) {\n let R, G, B;\n\n const H = Math.max(0, Math.min(1, _H));\n const S = Math.max(0, Math.min(1, _S));\n const L = Math.max(0, Math.min(1, _L));\n\n if (S == 0) {\n R = L * 255;\n G = L * 255;\n B = L * 255;\n } else {\n let a, b;\n\n if (L < 0.5) {\n b = L * (1 + S);\n } else {\n b = L + S - S * L;\n }\n\n a = 2 * L - b;\n\n R = Math.floor(255 * h2rgb(a, b, H + 1 / 3));\n G = Math.floor(255 * h2rgb(a, b, H));\n B = Math.floor(255 * h2rgb(a, b, H - 1 / 3));\n }\n\n return [R, G, B];\n}\n\n/**\n * Convert an RGBcolor to HSL.\n *\n * @param {Number} R the red component\n * @param {Number} G the green component\n * @param {Number} B the blue component\n * @return {Array} [H, S, L]\n *\n * @see https://www.easyrgb.com/en/math.php\n */\nexport function rgb2hsl(_R, _G, _B) {\n let H, S, L;\n\n const R = Math.max(0, Math.min(255, _R));\n const G = Math.max(0, Math.min(255, _G));\n const B = Math.max(0, Math.min(255, _B));\n\n const r = R / 255;\n const g = G / 255;\n const b = B / 255;\n\n const var_min = Math.min(Math.min(r, g), b);\n const var_max = Math.max(Math.max(r, g), b);\n const del_max = var_max - var_min;\n\n L = (var_max + var_min) / 2;\n\n if (del_max === 0) {\n H = 0;\n S = 0;\n } else {\n if (L < 0.5) {\n S = del_max / (var_max + var_min);\n } else {\n S = del_max / (2 - var_max - var_min);\n }\n\n const del_r = ((var_max - r) / 6 + del_max / 2) / del_max;\n const del_g = ((var_max - g) / 6 + del_max / 2) / del_max;\n const del_b = ((var_max - b) / 6 + del_max / 2) / del_max;\n\n if (r == var_max) {\n H = del_b - del_g;\n } else if (g == var_max) {\n H = 1 / 3 + del_r - del_b;\n } else if (b == var_max) {\n H = 2 / 3 + del_g - del_r;\n }\n\n if (H < 0) {\n H += 1;\n } else if (H > 1) {\n H -= 1;\n }\n }\n\n return [H, S, L];\n}\n","/*!\n * PatternFly Elements: PfeAvatar 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.js\";\nimport { hash } from \"./djb-hash.js\";\nimport { hsl2rgb, rgb2hsl } from \"./hslrgb.js\";\n\nclass PfeAvatar extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `\n`;\n }\n static get tag() {\n return \"pfe-avatar\";\n }\n\n get templateUrl() {\n return \"pfe-avatar.html\";\n }\n\n get styleUrl() {\n return \"pfe-avatar.scss\";\n }\n\n static get observedAttributes() {\n return [\"pfe-name\", \"pfe-pattern\", \"pfe-src\", \"pfe-shape\"];\n }\n\n static get events() {\n return {\n connected: `${this.tag}:connected`\n };\n }\n\n static get patterns() {\n return {\n triangles: \"triangles\",\n squares: \"squares\"\n };\n }\n\n static get defaultSize() {\n return 128;\n }\n\n static get defaultColors() {\n return \"#67accf #448087 #709c6b #a35252 #826cbb\";\n }\n\n get name() {\n return this.getAttribute(\"pfe-name\");\n }\n\n set name(val) {\n return this.setAttribute(\"pfe-name\", val);\n }\n\n get src() {\n return this.getAttribute(\"pfe-src\");\n }\n\n set src(href) {\n return this.setAttribute(\"pfe-src\", href);\n }\n\n get pattern() {\n return this.getAttribute(\"pfe-pattern\") || PfeAvatar.patterns.squares;\n }\n\n set pattern(name) {\n if (!PfeAvatar.patterns[name]) {\n this.log(\n `invalid pattern \"${name}\", valid patterns are: ${Object.values(\n PfeAvatar.patterns\n )}`\n );\n return;\n }\n return this.setAttribute(\"pfe-pattern\", name);\n }\n\n constructor() {\n super(PfeAvatar);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n this._initCanvas();\n\n this.emitEvent(PfeAvatar.events.connected, {\n bubbles: false\n });\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n super.attributeChangedCallback(...arguments);\n\n if (this.connected) {\n this.update();\n } else {\n this.addEventListener(PfeAvatar.events.connected, () => this.update());\n }\n }\n\n _initCanvas() {\n this._canvas = this.shadowRoot.querySelector(\"canvas\");\n const size =\n this.var(\"--pfe-avatar--width\").replace(/px$/, \"\") ||\n PfeAvatar.defaultSize;\n this._canvas.width = size;\n this._canvas.height = size;\n\n this._squareSize = this._canvas.width / 8;\n this._triangleSize = this._canvas.width / 4;\n\n this._ctx = this._canvas.getContext(\"2d\");\n }\n\n static _registerColors() {\n this.colors = [];\n const themeColors = this.var(\"--pfe-avatar--colors\") || this.defaultColors;\n\n themeColors.split(/\\s+/).forEach(colorCode => {\n let pattern;\n switch (colorCode.length) {\n case 4: // ex: \"#0fc\"\n pattern = /^#([A-f0-9])([A-f0-9])([A-f0-9])$/.exec(colorCode);\n if (pattern) {\n pattern.shift();\n const color = pattern.map(c => parseInt(c + c, 16));\n this._registerColor(color);\n } else {\n this.log(`[pfe-avatar] invalid color ${colorCode}`);\n }\n break;\n case 7: // ex: \"#00ffcc\"\n pattern = /^#([A-f0-9]{2})([A-f0-9]{2})([A-f0-9]{2})$/.exec(\n colorCode\n );\n if (pattern) {\n pattern.shift();\n const color = pattern.map(c => parseInt(c, 16));\n this._registerColor(color);\n } else {\n this.log(`[pfe-avatar] invalid color ${colorCode}`);\n }\n }\n });\n\n return this.colors;\n }\n\n static _registerColor(color) {\n PfeAvatar.colors.push({\n color1: `rgb(${color.join(\",\")})`,\n color2: `rgb(${this._adjustColor(color).join(\",\")})`\n });\n }\n\n static _adjustColor(color) {\n const dark = 0.1;\n const l_adj = 0.1; // luminance adjustment\n const hsl = rgb2hsl(...color);\n\n // if luminance is too dark already, then lighten the alternate color\n // instead of darkening it.\n hsl[2] += hsl[2] > dark ? -l_adj : l_adj;\n\n return hsl2rgb(...hsl);\n }\n\n update() {\n // if we have a src element, update the img, otherwise update the random pattern\n if (this.hasAttribute(\"pfe-src\")) {\n this.shadowRoot.querySelector(\"img\").src = this.src;\n } else {\n const bitPattern = hash(this.name).toString(2);\n const arrPattern = bitPattern.split(\"\").map(n => Number(n));\n this._colorIndex = Math.floor(\n (PfeAvatar.colors.length * parseInt(bitPattern, 2)) / Math.pow(2, 32)\n );\n this.color1 = PfeAvatar.colors[this._colorIndex].color1;\n this.color2 = PfeAvatar.colors[this._colorIndex].color2;\n\n this._clear();\n this._drawBackground();\n if (this.pattern === PfeAvatar.patterns.squares) {\n this._drawSquarePattern(arrPattern);\n } else if (this.pattern === PfeAvatar.patterns.triangles) {\n this._drawTrianglePattern(arrPattern);\n }\n // this._drawGradient();\n }\n }\n\n _clear() {\n this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);\n }\n\n _drawBackground() {\n this._ctx.fillStyle = this.color1;\n this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height);\n }\n\n _drawSquarePattern(pattern) {\n this._ctx.fillStyle = this.color2;\n if (this._ctx) {\n let i = pattern.length;\n while (i--) {\n if (pattern[i]) {\n this._drawMirroredSquare(i % 4, Math.floor(i / 4));\n }\n }\n }\n }\n\n /**\n * Draw a square at the given position, mirrored onto both the left and right half of the canvas.\n */\n _drawMirroredSquare(x, y) {\n if (this._ctx) {\n this._drawSquare(x, y);\n this._drawSquare(7 - x, y);\n }\n }\n\n _drawSquare(x, y) {\n this._ctx.fillRect(\n this._squareSize * x,\n this._squareSize * y,\n this._squareSize,\n this._squareSize\n );\n }\n\n _drawTrianglePattern(pattern) {\n this._ctx.fillStyle = this.color2;\n if (this._ctx) {\n let i = pattern.length;\n while (i--) {\n if (pattern[i]) {\n const x = Math.floor(i / 2) % 2;\n const y = Math.floor(i / 4);\n const alt = i % 4;\n\n const p1 = [x, y];\n const p2 = [x, y];\n const p3 = [x, y];\n\n switch (alt) {\n case 0:\n p2[1]++;\n p3[0]++;\n p3[1]++;\n break;\n case 1:\n p2[0]++;\n p3[0]++;\n p3[1]++;\n break;\n case 2:\n p2[0]++;\n p3[1]++;\n break;\n case 3:\n p1[0]++;\n p2[0]++;\n p2[1]++;\n p3[1]++;\n break;\n }\n\n this._drawMirroredTriangle(p1, p2, p3);\n }\n }\n }\n }\n\n /**\n * Draw a square at the given position in the top-left quadrant of the\n * canvas, and mirrored to the other three quadrants.\n */\n _drawMirroredTriangle(p1, p2, p3) {\n if (this._ctx) {\n this._drawTriangle(p1, p2, p3);\n this._drawTriangle(\n [4 - p1[0], p1[1]],\n [4 - p2[0], p2[1]],\n [4 - p3[0], p3[1]]\n );\n }\n }\n\n _drawTriangle(p1, p2, p3) {\n this._ctx.beginPath();\n this._ctx.moveTo(...p1.map(c => c * this._triangleSize));\n this._ctx.lineTo(...p2.map(c => c * this._triangleSize));\n this._ctx.lineTo(...p3.map(c => c * this._triangleSize));\n this._ctx.closePath();\n this._ctx.fill();\n this._ctx.fill();\n }\n\n _drawGradient() {\n const gradient = this._ctx.createLinearGradient(\n 0,\n this._canvas.height,\n this._canvas.width,\n 0\n );\n const color = this.color2;\n let gradientColor1 = color;\n let gradientColor2 = color;\n if (/^#[A-f0-9]{3}$/.test(color)) {\n // color is of the form \"#fff\"\n gradientColor1 += \"c\";\n gradientColor2 += \"0\";\n } else if (/^#[A-f0-9]{6}$/.test(color)) {\n // color is of the form \"#ffffff\"\n gradientColor1 += \"cc\";\n gradientColor2 += \"00\";\n }\n gradient.addColorStop(0, gradientColor1);\n gradient.addColorStop(1, gradientColor2);\n gradient.addColorStop(1, gradientColor1);\n this._ctx.fillStyle = gradient;\n this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height);\n }\n}\n\nPfeAvatar._registerColors();\n\nPFElement.create(PfeAvatar);\n\nexport default PfeAvatar;\n"],"names":[],"mappings":";;AAAA;;;;;;;;AAQA,SAAS,IAAI,CAAC,GAAG,EAAE;EACjB,IAAI,IAAI,GAAG,IAAI,CAAC;EAChB,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC;;EAEnB,OAAO,CAAC,EAAE;IACR,IAAI,GAAG,CAAC,IAAI,GAAG,EAAE,IAAI,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC;GAC1C;;EAED,OAAO,IAAI,KAAK,CAAC,CAAC;CACnB;;ACjBD,SAAS,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;EACzB,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;EACpB,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;EACpB,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC;EAC/C,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,CAAC;EAC1B,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;EACzD,OAAO,EAAE,CAAC;CACX;;;;;;;;;;;;AAYD,AAAO,SAAS,OAAO,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;EAClC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;;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CAAC,CAAC;IACzC,QAAQ,CAAC,YAAY,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;IACzC,QAAQ,CAAC,YAAY,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;IACzC,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC/B,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;GACnE;CACF;;AAED,SAAS,CAAC,eAAe,EAAE,CAAC;;AAE5B,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;;;;"} \ No newline at end of file diff --git a/elements/pfe-avatar/dist/pfe-avatar.min.js b/elements/pfe-avatar/dist/pfe-avatar.min.js new file mode 100644 index 0000000000..14fab14d35 --- /dev/null +++ b/elements/pfe-avatar/dist/pfe-avatar.min.js @@ -0,0 +1,27 @@ +import t from"../../pfelement/dist/pfelement.min.js";function e(t,e,a){return a<0&&(a+=1),a>1&&(a-=1),6*a<1?t+6*(e-t)*a:2*a<1?e:3*a<2?t+(e-t)*(2/3-a)*6:t} +/*! + * PatternFly Elements: PfeAvatar 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * +*/ +class a extends t{static get version(){return"1.0.0-prerelease.54"}get html(){return"\n"}static get tag(){return"pfe-avatar"}get templateUrl(){return"pfe-avatar.html"}get styleUrl(){return"pfe-avatar.scss"}static get observedAttributes(){return["pfe-name","pfe-pattern","pfe-src","pfe-shape"]}static get events(){return{connected:`${this.tag}:connected`}}static get patterns(){return{triangles:"triangles",squares:"squares"}}static get defaultSize(){return 128}static get defaultColors(){return"#67accf #448087 #709c6b #a35252 #826cbb"}get name(){return this.getAttribute("pfe-name")}set name(t){return this.setAttribute("pfe-name",t)}get src(){return this.getAttribute("pfe-src")}set src(t){return this.setAttribute("pfe-src",t)}get pattern(){return this.getAttribute("pfe-pattern")||a.patterns.squares}set pattern(t){if(a.patterns[t])return this.setAttribute("pfe-pattern",t);this.log(`invalid pattern "${t}", valid patterns are: ${Object.values(a.patterns)}`)}constructor(){super(a)}connectedCallback(){super.connectedCallback(),this._initCanvas(),this.emitEvent(a.events.connected,{bubbles:!1})}attributeChangedCallback(t,e,r){super.attributeChangedCallback(...arguments),this.connected?this.update():this.addEventListener(a.events.connected,()=>this.update())}_initCanvas(){this._canvas=this.shadowRoot.querySelector("canvas");const t=this.var("--pfe-avatar--width").replace(/px$/,"")||a.defaultSize;this._canvas.width=t,this._canvas.height=t,this._squareSize=this._canvas.width/8,this._triangleSize=this._canvas.width/4,this._ctx=this._canvas.getContext("2d")}static _registerColors(){return this.colors=[],(this.var("--pfe-avatar--colors")||this.defaultColors).split(/\s+/).forEach(t=>{let e;switch(t.length){case 4:if(e=/^#([A-f0-9])([A-f0-9])([A-f0-9])$/.exec(t)){e.shift();const t=e.map(t=>parseInt(t+t,16));this._registerColor(t)}else this.log(`[pfe-avatar] invalid color ${t}`);break;case 7:if(e=/^#([A-f0-9]{2})([A-f0-9]{2})([A-f0-9]{2})$/.exec(t)){e.shift();const t=e.map(t=>parseInt(t,16));this._registerColor(t)}else this.log(`[pfe-avatar] invalid color ${t}`)}}),this.colors}static _registerColor(t){a.colors.push({color1:`rgb(${t.join(",")})`,color2:`rgb(${this._adjustColor(t).join(",")})`})}static _adjustColor(t){const a=function(t,e,a){let r,i,s;const n=Math.max(0,Math.min(255,t))/255,h=Math.max(0,Math.min(255,e))/255,o=Math.max(0,Math.min(255,a))/255,c=Math.min(Math.min(n,h),o),l=Math.max(Math.max(n,h),o),d=l-c;if(s=(l+c)/2,0===d)r=0,i=0;else{i=s<.5?d/(l+c):d/(2-l-c);const t=((l-n)/6+d/2)/d,e=((l-h)/6+d/2)/d,a=((l-o)/6+d/2)/d;n==l?r=a-e:h==l?r=1/3+t-a:o==l&&(r=2/3+e-t),r<0?r+=1:r>1&&(r-=1)}return[r,i,s]}(...t);return a[2]+=a[2]>.1?-.1:.1,function(t,a,r){let i,s,n;const h=Math.max(0,Math.min(1,t)),o=Math.max(0,Math.min(1,a)),c=Math.max(0,Math.min(1,r));if(0==o)i=255*c,s=255*c,n=255*c;else{let t,a;t=2*c-(a=c<.5?c*(1+o):c+o-o*c),i=Math.floor(255*e(t,a,h+1/3)),s=Math.floor(255*e(t,a,h)),n=Math.floor(255*e(t,a,h-1/3))}return[i,s,n]}(...a)}update(){if(this.hasAttribute("pfe-src"))this.shadowRoot.querySelector("img").src=this.src;else{const t=function(t){let e=5381,a=t.length;for(;a;)e=33*e^t.charCodeAt(--a);return e>>>0}(this.name).toString(2),e=t.split("").map(t=>Number(t));this._colorIndex=Math.floor(a.colors.length*parseInt(t,2)/Math.pow(2,32)),this.color1=a.colors[this._colorIndex].color1,this.color2=a.colors[this._colorIndex].color2,this._clear(),this._drawBackground(),this.pattern===a.patterns.squares?this._drawSquarePattern(e):this.pattern===a.patterns.triangles&&this._drawTrianglePattern(e)}}_clear(){this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height)}_drawBackground(){this._ctx.fillStyle=this.color1,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height)}_drawSquarePattern(t){if(this._ctx.fillStyle=this.color2,this._ctx){let e=t.length;for(;e--;)t[e]&&this._drawMirroredSquare(e%4,Math.floor(e/4))}}_drawMirroredSquare(t,e){this._ctx&&(this._drawSquare(t,e),this._drawSquare(7-t,e))}_drawSquare(t,e){this._ctx.fillRect(this._squareSize*t,this._squareSize*e,this._squareSize,this._squareSize)}_drawTrianglePattern(t){if(this._ctx.fillStyle=this.color2,this._ctx){let e=t.length;for(;e--;)if(t[e]){const t=Math.floor(e/2)%2,a=Math.floor(e/4),r=[t,a],i=[t,a],s=[t,a];switch(e%4){case 0:i[1]++,s[0]++,s[1]++;break;case 1:i[0]++,s[0]++,s[1]++;break;case 2:i[0]++,s[1]++;break;case 3:r[0]++,i[0]++,i[1]++,s[1]++}this._drawMirroredTriangle(r,i,s)}}}_drawMirroredTriangle(t,e,a){this._ctx&&(this._drawTriangle(t,e,a),this._drawTriangle([4-t[0],t[1]],[4-e[0],e[1]],[4-a[0],a[1]]))}_drawTriangle(t,e,a){this._ctx.beginPath(),this._ctx.moveTo(...t.map(t=>t*this._triangleSize)),this._ctx.lineTo(...e.map(t=>t*this._triangleSize)),this._ctx.lineTo(...a.map(t=>t*this._triangleSize)),this._ctx.closePath(),this._ctx.fill(),this._ctx.fill()}_drawGradient(){const t=this._ctx.createLinearGradient(0,this._canvas.height,this._canvas.width,0),e=this.color2;let a=e,r=e;/^#[A-f0-9]{3}$/.test(e)?(a+="c",r+="0"):/^#[A-f0-9]{6}$/.test(e)&&(a+="cc",r+="00"),t.addColorStop(0,a),t.addColorStop(1,r),t.addColorStop(1,a),this._ctx.fillStyle=t,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height)}}a._registerColors(),t.create(a);export default a; +//# sourceMappingURL=pfe-avatar.min.js.map diff --git a/elements/pfe-avatar/dist/pfe-avatar.min.js.map b/elements/pfe-avatar/dist/pfe-avatar.min.js.map new file mode 100644 index 0000000000..ebec58749f --- /dev/null +++ b/elements/pfe-avatar/dist/pfe-avatar.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-avatar.min.js","sources":["../_temp/hslrgb.js","../_temp/pfe-avatar.js","../_temp/djb-hash.js"],"sourcesContent":["function h2rgb(v1, v2, vH) {\n if (vH < 0) vH += 1;\n if (vH > 1) vH -= 1;\n if (6 * vH < 1) return v1 + (v2 - v1) * 6 * vH;\n if (2 * vH < 1) return v2;\n if (3 * vH < 2) return v1 + (v2 - v1) * (2 / 3 - vH) * 6;\n return v1;\n}\n\n/**\n * Convert an HSL color to RGB.\n *\n * @param {Number} H the hue component\n * @param {Number} S the saturation component\n * @param {Number} L the luminance component\n * @return {Array} [R, G, B]\n *\n * @see https://www.easyrgb.com/en/math.php\n */\nexport function hsl2rgb(_H, _S, _L) {\n let R, G, B;\n\n const H = Math.max(0, Math.min(1, _H));\n const S = Math.max(0, Math.min(1, _S));\n const L = Math.max(0, Math.min(1, _L));\n\n if (S == 0) {\n R = L * 255;\n G = L * 255;\n B = L * 255;\n } else {\n let a, b;\n\n if (L < 0.5) {\n b = L * (1 + S);\n } else {\n b = L + S - S * L;\n }\n\n a = 2 * L - b;\n\n R = Math.floor(255 * h2rgb(a, b, H + 1 / 3));\n G = Math.floor(255 * h2rgb(a, b, H));\n B = Math.floor(255 * h2rgb(a, b, H - 1 / 3));\n }\n\n return [R, G, B];\n}\n\n/**\n * Convert an RGBcolor to HSL.\n *\n * @param {Number} R the red component\n * @param {Number} G the green component\n * @param {Number} B the blue component\n * @return {Array} [H, S, L]\n *\n * @see https://www.easyrgb.com/en/math.php\n */\nexport function rgb2hsl(_R, _G, _B) {\n let H, S, L;\n\n const R = Math.max(0, Math.min(255, _R));\n const G = Math.max(0, Math.min(255, _G));\n const B = Math.max(0, Math.min(255, _B));\n\n const r = R / 255;\n const g = G / 255;\n const b = B / 255;\n\n const var_min = Math.min(Math.min(r, g), b);\n const var_max = Math.max(Math.max(r, g), b);\n const del_max = var_max - var_min;\n\n L = (var_max + var_min) / 2;\n\n if (del_max === 0) {\n H = 0;\n S = 0;\n } else {\n if (L < 0.5) {\n S = del_max / (var_max + var_min);\n } else {\n S = del_max / (2 - var_max - var_min);\n }\n\n const del_r = ((var_max - r) / 6 + del_max / 2) / del_max;\n const del_g = ((var_max - g) / 6 + del_max / 2) / del_max;\n const del_b = ((var_max - b) / 6 + del_max / 2) / del_max;\n\n if (r == var_max) {\n H = del_b - del_g;\n } else if (g == var_max) {\n H = 1 / 3 + del_r - del_b;\n } else if (b == var_max) {\n H = 2 / 3 + del_g - del_r;\n }\n\n if (H < 0) {\n H += 1;\n } else if (H > 1) {\n H -= 1;\n }\n }\n\n return [H, S, L];\n}\n","/*!\n * PatternFly Elements: PfeAvatar 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.js\";\nimport { hash } from \"./djb-hash.js\";\nimport { hsl2rgb, rgb2hsl } from \"./hslrgb.js\";\n\nclass PfeAvatar extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `\n`;\n }\n static get tag() {\n return \"pfe-avatar\";\n }\n\n get templateUrl() {\n return \"pfe-avatar.html\";\n }\n\n get styleUrl() {\n return \"pfe-avatar.scss\";\n }\n\n static get observedAttributes() {\n return [\"pfe-name\", \"pfe-pattern\", \"pfe-src\", \"pfe-shape\"];\n }\n\n static get events() {\n return {\n connected: `${this.tag}:connected`\n };\n }\n\n static get patterns() {\n return {\n triangles: \"triangles\",\n squares: \"squares\"\n };\n }\n\n static get defaultSize() {\n return 128;\n }\n\n static get defaultColors() {\n return \"#67accf #448087 #709c6b #a35252 #826cbb\";\n }\n\n get name() {\n return this.getAttribute(\"pfe-name\");\n }\n\n set name(val) {\n return this.setAttribute(\"pfe-name\", val);\n }\n\n get src() {\n return this.getAttribute(\"pfe-src\");\n }\n\n set src(href) {\n return this.setAttribute(\"pfe-src\", href);\n }\n\n get pattern() {\n return this.getAttribute(\"pfe-pattern\") || PfeAvatar.patterns.squares;\n }\n\n set pattern(name) {\n if (!PfeAvatar.patterns[name]) {\n this.log(\n `invalid pattern \"${name}\", valid patterns are: ${Object.values(\n PfeAvatar.patterns\n )}`\n );\n return;\n }\n return this.setAttribute(\"pfe-pattern\", name);\n }\n\n constructor() {\n super(PfeAvatar);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n this._initCanvas();\n\n this.emitEvent(PfeAvatar.events.connected, {\n bubbles: false\n });\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n super.attributeChangedCallback(...arguments);\n\n if (this.connected) {\n this.update();\n } else {\n this.addEventListener(PfeAvatar.events.connected, () => this.update());\n }\n }\n\n _initCanvas() {\n this._canvas = this.shadowRoot.querySelector(\"canvas\");\n const size =\n this.var(\"--pfe-avatar--width\").replace(/px$/, \"\") ||\n PfeAvatar.defaultSize;\n this._canvas.width = size;\n this._canvas.height = size;\n\n this._squareSize = this._canvas.width / 8;\n this._triangleSize = this._canvas.width / 4;\n\n this._ctx = this._canvas.getContext(\"2d\");\n }\n\n static _registerColors() {\n this.colors = [];\n const themeColors = this.var(\"--pfe-avatar--colors\") || this.defaultColors;\n\n themeColors.split(/\\s+/).forEach(colorCode => {\n let pattern;\n switch (colorCode.length) {\n case 4: // ex: \"#0fc\"\n pattern = /^#([A-f0-9])([A-f0-9])([A-f0-9])$/.exec(colorCode);\n if (pattern) {\n pattern.shift();\n const color = pattern.map(c => parseInt(c + c, 16));\n this._registerColor(color);\n } else {\n this.log(`[pfe-avatar] invalid color ${colorCode}`);\n }\n break;\n case 7: // ex: \"#00ffcc\"\n pattern = /^#([A-f0-9]{2})([A-f0-9]{2})([A-f0-9]{2})$/.exec(\n colorCode\n );\n if (pattern) {\n pattern.shift();\n const color = pattern.map(c => parseInt(c, 16));\n this._registerColor(color);\n } else {\n this.log(`[pfe-avatar] invalid color ${colorCode}`);\n }\n }\n });\n\n return this.colors;\n }\n\n static _registerColor(color) {\n PfeAvatar.colors.push({\n color1: `rgb(${color.join(\",\")})`,\n color2: `rgb(${this._adjustColor(color).join(\",\")})`\n });\n }\n\n static _adjustColor(color) {\n const dark = 0.1;\n const l_adj = 0.1; // luminance adjustment\n const hsl = rgb2hsl(...color);\n\n // if luminance is too dark already, then lighten the alternate color\n // instead of darkening it.\n hsl[2] += hsl[2] > dark ? -l_adj : l_adj;\n\n return hsl2rgb(...hsl);\n }\n\n update() {\n // if we have a src element, update the img, otherwise update the random pattern\n if (this.hasAttribute(\"pfe-src\")) {\n this.shadowRoot.querySelector(\"img\").src = this.src;\n } else {\n const bitPattern = hash(this.name).toString(2);\n const arrPattern = bitPattern.split(\"\").map(n => Number(n));\n this._colorIndex = Math.floor(\n (PfeAvatar.colors.length * parseInt(bitPattern, 2)) / Math.pow(2, 32)\n );\n this.color1 = PfeAvatar.colors[this._colorIndex].color1;\n this.color2 = PfeAvatar.colors[this._colorIndex].color2;\n\n this._clear();\n this._drawBackground();\n if (this.pattern === PfeAvatar.patterns.squares) {\n this._drawSquarePattern(arrPattern);\n } else if (this.pattern === PfeAvatar.patterns.triangles) {\n this._drawTrianglePattern(arrPattern);\n }\n // this._drawGradient();\n }\n }\n\n _clear() {\n this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);\n }\n\n _drawBackground() {\n this._ctx.fillStyle = this.color1;\n this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height);\n }\n\n _drawSquarePattern(pattern) {\n this._ctx.fillStyle = this.color2;\n if (this._ctx) {\n let i = pattern.length;\n while (i--) {\n if (pattern[i]) {\n this._drawMirroredSquare(i % 4, Math.floor(i / 4));\n }\n }\n }\n }\n\n /**\n * Draw a square at the given position, mirrored onto both the left and right half of the canvas.\n */\n _drawMirroredSquare(x, y) {\n if (this._ctx) {\n this._drawSquare(x, y);\n this._drawSquare(7 - x, y);\n }\n }\n\n _drawSquare(x, y) {\n this._ctx.fillRect(\n this._squareSize * x,\n this._squareSize * y,\n this._squareSize,\n this._squareSize\n );\n }\n\n _drawTrianglePattern(pattern) {\n this._ctx.fillStyle = this.color2;\n if (this._ctx) {\n let i = pattern.length;\n while (i--) {\n if (pattern[i]) {\n const x = Math.floor(i / 2) % 2;\n const y = Math.floor(i / 4);\n const alt = i % 4;\n\n const p1 = [x, y];\n const p2 = [x, y];\n const p3 = [x, y];\n\n switch (alt) {\n case 0:\n p2[1]++;\n p3[0]++;\n p3[1]++;\n break;\n case 1:\n p2[0]++;\n p3[0]++;\n p3[1]++;\n break;\n case 2:\n p2[0]++;\n p3[1]++;\n break;\n case 3:\n p1[0]++;\n p2[0]++;\n p2[1]++;\n p3[1]++;\n break;\n }\n\n this._drawMirroredTriangle(p1, p2, p3);\n }\n }\n }\n }\n\n /**\n * Draw a square at the given position in the top-left quadrant of the\n * canvas, and mirrored to the other three quadrants.\n */\n _drawMirroredTriangle(p1, p2, p3) {\n if (this._ctx) {\n this._drawTriangle(p1, p2, p3);\n this._drawTriangle(\n [4 - p1[0], p1[1]],\n [4 - p2[0], p2[1]],\n [4 - p3[0], p3[1]]\n );\n }\n }\n\n _drawTriangle(p1, p2, p3) {\n this._ctx.beginPath();\n this._ctx.moveTo(...p1.map(c => c * this._triangleSize));\n this._ctx.lineTo(...p2.map(c => c * this._triangleSize));\n this._ctx.lineTo(...p3.map(c => c * this._triangleSize));\n this._ctx.closePath();\n this._ctx.fill();\n this._ctx.fill();\n }\n\n _drawGradient() {\n const gradient = this._ctx.createLinearGradient(\n 0,\n this._canvas.height,\n this._canvas.width,\n 0\n );\n const color = this.color2;\n let gradientColor1 = color;\n let gradientColor2 = color;\n if (/^#[A-f0-9]{3}$/.test(color)) {\n // color is of the form \"#fff\"\n gradientColor1 += \"c\";\n gradientColor2 += \"0\";\n } else if (/^#[A-f0-9]{6}$/.test(color)) {\n // color is of the form \"#ffffff\"\n gradientColor1 += \"cc\";\n gradientColor2 += \"00\";\n }\n gradient.addColorStop(0, gradientColor1);\n gradient.addColorStop(1, gradientColor2);\n gradient.addColorStop(1, gradientColor1);\n this._ctx.fillStyle = gradient;\n this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height);\n }\n}\n\nPfeAvatar._registerColors();\n\nPFElement.create(PfeAvatar);\n\nexport default PfeAvatar;\n","/**\n * djb2 string hashing function.\n *\n * @see http://www.cse.yorku.ca/~oz/hash.html\n * @param {String} str the string to hash.\n * @return {Number} a positive integer\n */\n\nfunction hash(str) {\n let hash = 5381;\n let i = str.length;\n\n while (i) {\n hash = (hash * 33) ^ str.charCodeAt(--i);\n }\n\n return hash >>> 0;\n}\n\nexport { hash };\n"],"names":["h2rgb","v1","v2","vH","PfeAvatar","PFElement","version","html","tag","templateUrl","styleUrl","observedAttributes","events","connected","this","patterns","triangles","squares","defaultSize","defaultColors","name","getAttribute","val","setAttribute","src","href","pattern","log","Object","values","[object Object]","super","connectedCallback","_initCanvas","emitEvent","bubbles","attr","oldValue","newValue","attributeChangedCallback","arguments","update","addEventListener","_canvas","shadowRoot","querySelector","size","var","replace","width","height","_squareSize","_triangleSize","_ctx","getContext","colors","split","forEach","colorCode","length","exec","shift","color","map","c","parseInt","_registerColor","push","color1","join","color2","_adjustColor","hsl","_R","_G","_B","H","S","L","r","Math","max","min","g","b","var_min","var_max","del_max","del_r","del_g","del_b","rgb2hsl","_H","_S","_L","R","G","B","a","floor","hsl2rgb","hasAttribute","bitPattern","str","hash","i","charCodeAt","toString","arrPattern","n","Number","_colorIndex","pow","_clear","_drawBackground","_drawSquarePattern","_drawTrianglePattern","clearRect","fillStyle","fillRect","_drawMirroredSquare","x","y","_drawSquare","p1","p2","p3","_drawMirroredTriangle","_drawTriangle","beginPath","moveTo","lineTo","closePath","fill","gradient","createLinearGradient","gradientColor1","gradientColor2","test","addColorStop","_registerColors","create"],"mappings":"qDAAA,SAASA,EAAMC,EAAIC,EAAIC,GAGrB,OAFIA,EAAK,IAAGA,GAAM,GACdA,EAAK,IAAGA,GAAM,GACd,EAAIA,EAAK,EAAUF,EAAiB,GAAXC,EAAKD,GAAUE,EACxC,EAAIA,EAAK,EAAUD,EACnB,EAAIC,EAAK,EAAUF,GAAMC,EAAKD,IAAO,EAAI,EAAIE,GAAM,EAChDF;;;;;;;;;;;;;;;;;;;;;;;;;ACuBT,MAAMG,UAAkBC,EACtBC,qBACE,MAAO,sBAGTC,WACE,MAAO,o/BAKTC,iBACE,MAAO,aAGTC,kBACE,MAAO,kBAGTC,eACE,MAAO,kBAGTC,gCACE,MAAO,CAAC,WAAY,cAAe,UAAW,aAGhDC,oBACE,MAAO,CACLC,aAAcC,KAAKN,iBAIvBO,sBACE,MAAO,CACLC,UAAW,YACXC,QAAS,WAIbC,yBACE,OAAO,IAGTC,2BACE,MAAO,0CAGTC,WACE,OAAON,KAAKO,aAAa,YAG3BD,SAASE,GACP,OAAOR,KAAKS,aAAa,WAAYD,GAGvCE,UACE,OAAOV,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H,GACzB1H,KAAKuC,KAAKiE,UAAYgB,EACtBxH,KAAKuC,KAAKkE,SAAS,EAAG,EAAGzG,KAAK6B,QAAQM,MAAOnC,KAAK6B,QAAQO,SAI9D9C,EAAUwI,kBAEVvI,EAAUwI,OAAOzI"} \ No newline at end of file diff --git a/elements/pfe-avatar/dist/pfe-avatar.umd.js b/elements/pfe-avatar/dist/pfe-avatar.umd.js new file mode 100644 index 0000000000..30ce1e1313 --- /dev/null +++ b/elements/pfe-avatar/dist/pfe-avatar.umd.js @@ -0,0 +1,622 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../../pfelement/dist/pfelement.umd')) : + typeof define === 'function' && define.amd ? define(['../../pfelement/dist/pfelement.umd'], factory) : + (global.PfeAvatar = factory(global.PFElement)); +}(this, (function (PFElement) { 'use strict'; + + PFElement = PFElement && PFElement.hasOwnProperty('default') ? PFElement['default'] : PFElement; + + /** + * djb2 string hashing function. + * + * @see http://www.cse.yorku.ca/~oz/hash.html + * @param {String} str the string to hash. + * @return {Number} a positive integer + */ + + function hash(str) { + var hash = 5381; + var i = str.length; + + while (i) { + hash = hash * 33 ^ str.charCodeAt(--i); + } + + return hash >>> 0; + } + + function h2rgb(v1, v2, vH) { + if (vH < 0) vH += 1; + if (vH > 1) vH -= 1; + if (6 * vH < 1) return v1 + (v2 - v1) * 6 * vH; + if (2 * vH < 1) return v2; + if (3 * vH < 2) return v1 + (v2 - v1) * (2 / 3 - vH) * 6; + return v1; + } + + /** + * Convert an HSL color to RGB. + * + * @param {Number} H the hue component + * @param {Number} S the saturation component + * @param {Number} L the luminance component + * @return {Array} [R, G, B] + * + * @see https://www.easyrgb.com/en/math.php + */ + function hsl2rgb(_H, _S, _L) { + var R = void 0, + G = void 0, + B = void 0; + + var H = Math.max(0, Math.min(1, _H)); + var S = Math.max(0, Math.min(1, _S)); + var L = Math.max(0, Math.min(1, _L)); + + if (S == 0) { + R = L * 255; + G = L * 255; + B = L * 255; + } else { + var a = void 0, + b = void 0; + + if (L < 0.5) { + b = L * (1 + S); + } else { + b = L + S - S * L; + } + + a = 2 * L - b; + + R = Math.floor(255 * h2rgb(a, b, H + 1 / 3)); + G = Math.floor(255 * h2rgb(a, b, H)); + B = Math.floor(255 * h2rgb(a, b, H - 1 / 3)); + } + + return [R, G, B]; + } + + /** + * Convert an RGBcolor to HSL. + * + * @param {Number} R the red component + * @param {Number} G the green component + * @param {Number} B the blue component + * @return {Array} [H, S, L] + * + * @see https://www.easyrgb.com/en/math.php + */ + function rgb2hsl(_R, _G, _B) { + var H = void 0, + S = void 0, + L = void 0; + + var R = Math.max(0, Math.min(255, _R)); + var G = Math.max(0, Math.min(255, _G)); + var B = Math.max(0, Math.min(255, _B)); + + var r = R / 255; + var g = G / 255; + var b = B / 255; + + var var_min = Math.min(Math.min(r, g), b); + var var_max = Math.max(Math.max(r, g), b); + var del_max = var_max - var_min; + + L = (var_max + var_min) / 2; + + if (del_max === 0) { + H = 0; + S = 0; + } else { + if (L < 0.5) { + S = del_max / (var_max + var_min); + } else { + S = del_max / (2 - var_max - var_min); + } + + var del_r = ((var_max - r) / 6 + del_max / 2) / del_max; + var del_g = ((var_max - g) / 6 + del_max / 2) / del_max; + var del_b = ((var_max - b) / 6 + del_max / 2) / del_max; + + if (r == var_max) { + H = del_b - del_g; + } else if (g == var_max) { + H = 1 / 3 + del_r - del_b; + } else if (b == var_max) { + H = 2 / 3 + del_g - del_r; + } + + if (H < 0) { + H += 1; + } else if (H > 1) { + H -= 1; + } + } + + return [H, S, L]; + } + + var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + }; + + var createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + }(); + + var get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + + if (getter === undefined) { + return undefined; + } + + return getter.call(receiver); + } + }; + + var inherits = function (subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + }; + + var possibleConstructorReturn = function (self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && (typeof call === "object" || typeof call === "function") ? call : self; + }; + + var toConsumableArray = function (arr) { + if (Array.isArray(arr)) { + for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; + + return arr2; + } else { + return Array.from(arr); + } + }; + + /*! + * PatternFly Elements: PfeAvatar 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + + var PfeAvatar = function (_PFElement) { + inherits(PfeAvatar, _PFElement); + createClass(PfeAvatar, [{ + key: "html", + get: function get$$1() { + return "\n"; + } + }, { + key: "templateUrl", + get: function get$$1() { + return "pfe-avatar.html"; + } + }, { + key: "styleUrl", + get: function get$$1() { + return "pfe-avatar.scss"; + } + }, { + key: "name", + get: function get$$1() { + return this.getAttribute("pfe-name"); + }, + set: function set$$1(val) { + return this.setAttribute("pfe-name", val); + } + }, { + key: "src", + get: function get$$1() { + return this.getAttribute("pfe-src"); + }, + set: function set$$1(href) { + return this.setAttribute("pfe-src", href); + } + }, { + key: "pattern", + get: function get$$1() { + return this.getAttribute("pfe-pattern") || PfeAvatar.patterns.squares; + }, + set: function set$$1(name) { + if (!PfeAvatar.patterns[name]) { + this.log("invalid pattern \"" + name + "\", valid patterns are: " + Object.values(PfeAvatar.patterns)); + return; + } + return this.setAttribute("pfe-pattern", name); + } + }], [{ + key: "version", + get: function get$$1() { + return "1.0.0-prerelease.54"; + } + }, { + key: "tag", + get: function get$$1() { + return "pfe-avatar"; + } + }, { + key: "observedAttributes", + get: function get$$1() { + return ["pfe-name", "pfe-pattern", "pfe-src", "pfe-shape"]; + } + }, { + key: "events", + get: function get$$1() { + return { + connected: this.tag + ":connected" + }; + } + }, { + key: "patterns", + get: function get$$1() { + return { + triangles: "triangles", + squares: "squares" + }; + } + }, { + key: "defaultSize", + get: function get$$1() { + return 128; + } + }, { + key: "defaultColors", + get: function get$$1() { + return "#67accf #448087 #709c6b #a35252 #826cbb"; + } + }]); + + function PfeAvatar() { + classCallCheck(this, PfeAvatar); + return possibleConstructorReturn(this, (PfeAvatar.__proto__ || Object.getPrototypeOf(PfeAvatar)).call(this, PfeAvatar)); + } + + createClass(PfeAvatar, [{ + key: "connectedCallback", + value: function connectedCallback() { + get(PfeAvatar.prototype.__proto__ || Object.getPrototypeOf(PfeAvatar.prototype), "connectedCallback", this).call(this); + + this._initCanvas(); + + this.emitEvent(PfeAvatar.events.connected, { + bubbles: false + }); + } + }, { + key: "attributeChangedCallback", + value: function attributeChangedCallback(attr, oldValue, newValue) { + var _this2 = this; + + get(PfeAvatar.prototype.__proto__ || Object.getPrototypeOf(PfeAvatar.prototype), "attributeChangedCallback", this).apply(this, arguments); + + if (this.connected) { + this.update(); + } else { + this.addEventListener(PfeAvatar.events.connected, function () { + return _this2.update(); + }); + } + } + }, { + key: "_initCanvas", + value: function _initCanvas() { + this._canvas = this.shadowRoot.querySelector("canvas"); + var size = this.var("--pfe-avatar--width").replace(/px$/, "") || PfeAvatar.defaultSize; + this._canvas.width = size; + this._canvas.height = size; + + this._squareSize = this._canvas.width / 8; + this._triangleSize = this._canvas.width / 4; + + this._ctx = this._canvas.getContext("2d"); + } + }, { + key: "update", + value: function update() { + // if we have a src element, update the img, otherwise update the random pattern + if (this.hasAttribute("pfe-src")) { + this.shadowRoot.querySelector("img").src = this.src; + } else { + var bitPattern = hash(this.name).toString(2); + var arrPattern = bitPattern.split("").map(function (n) { + return Number(n); + }); + this._colorIndex = Math.floor(PfeAvatar.colors.length * parseInt(bitPattern, 2) / Math.pow(2, 32)); + this.color1 = PfeAvatar.colors[this._colorIndex].color1; + this.color2 = PfeAvatar.colors[this._colorIndex].color2; + + this._clear(); + this._drawBackground(); + if (this.pattern === PfeAvatar.patterns.squares) { + this._drawSquarePattern(arrPattern); + } else if (this.pattern === PfeAvatar.patterns.triangles) { + this._drawTrianglePattern(arrPattern); + } + // this._drawGradient(); + } + } + }, { + key: "_clear", + value: function _clear() { + this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height); + } + }, { + key: "_drawBackground", + value: function _drawBackground() { + this._ctx.fillStyle = this.color1; + this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height); + } + }, { + key: "_drawSquarePattern", + value: function _drawSquarePattern(pattern) { + this._ctx.fillStyle = this.color2; + if (this._ctx) { + var i = pattern.length; + while (i--) { + if (pattern[i]) { + this._drawMirroredSquare(i % 4, Math.floor(i / 4)); + } + } + } + } + + /** + * Draw a square at the given position, mirrored onto both the left and right half of the canvas. + */ + + }, { + key: "_drawMirroredSquare", + value: function _drawMirroredSquare(x, y) { + if (this._ctx) { + this._drawSquare(x, y); + this._drawSquare(7 - x, y); + } + } + }, { + key: "_drawSquare", + value: function _drawSquare(x, y) { + this._ctx.fillRect(this._squareSize * x, this._squareSize * y, this._squareSize, this._squareSize); + } + }, { + key: "_drawTrianglePattern", + value: function _drawTrianglePattern(pattern) { + this._ctx.fillStyle = this.color2; + if (this._ctx) { + var i = pattern.length; + while (i--) { + if (pattern[i]) { + var x = Math.floor(i / 2) % 2; + var y = Math.floor(i / 4); + var alt = i % 4; + + var p1 = [x, y]; + var p2 = [x, y]; + var p3 = [x, y]; + + switch (alt) { + case 0: + p2[1]++; + p3[0]++; + p3[1]++; + break; + case 1: + p2[0]++; + p3[0]++; + p3[1]++; + break; + case 2: + p2[0]++; + p3[1]++; + break; + case 3: + p1[0]++; + p2[0]++; + p2[1]++; + p3[1]++; + break; + } + + this._drawMirroredTriangle(p1, p2, p3); + } + } + } + } + + /** + * Draw a square at the given position in the top-left quadrant of the + * canvas, and mirrored to the other three quadrants. + */ + + }, { + key: "_drawMirroredTriangle", + value: function _drawMirroredTriangle(p1, p2, p3) { + if (this._ctx) { + this._drawTriangle(p1, p2, p3); + this._drawTriangle([4 - p1[0], p1[1]], [4 - p2[0], p2[1]], [4 - p3[0], p3[1]]); + } + } + }, { + key: "_drawTriangle", + value: function _drawTriangle(p1, p2, p3) { + var _ctx, + _this3 = this, + _ctx2, + _ctx3; + + this._ctx.beginPath(); + (_ctx = this._ctx).moveTo.apply(_ctx, toConsumableArray(p1.map(function (c) { + return c * _this3._triangleSize; + }))); + (_ctx2 = this._ctx).lineTo.apply(_ctx2, toConsumableArray(p2.map(function (c) { + return c * _this3._triangleSize; + }))); + (_ctx3 = this._ctx).lineTo.apply(_ctx3, toConsumableArray(p3.map(function (c) { + return c * _this3._triangleSize; + }))); + this._ctx.closePath(); + this._ctx.fill(); + this._ctx.fill(); + } + }, { + key: "_drawGradient", + value: function _drawGradient() { + var gradient = this._ctx.createLinearGradient(0, this._canvas.height, this._canvas.width, 0); + var color = this.color2; + var gradientColor1 = color; + var gradientColor2 = color; + if (/^#[A-f0-9]{3}$/.test(color)) { + // color is of the form "#fff" + gradientColor1 += "c"; + gradientColor2 += "0"; + } else if (/^#[A-f0-9]{6}$/.test(color)) { + // color is of the form "#ffffff" + gradientColor1 += "cc"; + gradientColor2 += "00"; + } + gradient.addColorStop(0, gradientColor1); + gradient.addColorStop(1, gradientColor2); + gradient.addColorStop(1, gradientColor1); + this._ctx.fillStyle = gradient; + this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height); + } + }], [{ + key: "_registerColors", + value: function _registerColors() { + var _this4 = this; + + this.colors = []; + var themeColors = this.var("--pfe-avatar--colors") || this.defaultColors; + + themeColors.split(/\s+/).forEach(function (colorCode) { + var pattern = void 0; + switch (colorCode.length) { + case 4: + // ex: "#0fc" + pattern = /^#([A-f0-9])([A-f0-9])([A-f0-9])$/.exec(colorCode); + if (pattern) { + pattern.shift(); + var color = pattern.map(function (c) { + return parseInt(c + c, 16); + }); + _this4._registerColor(color); + } else { + _this4.log("[pfe-avatar] invalid color " + colorCode); + } + break; + case 7: + // ex: "#00ffcc" + pattern = /^#([A-f0-9]{2})([A-f0-9]{2})([A-f0-9]{2})$/.exec(colorCode); + if (pattern) { + pattern.shift(); + var _color = pattern.map(function (c) { + return parseInt(c, 16); + }); + _this4._registerColor(_color); + } else { + _this4.log("[pfe-avatar] invalid color " + colorCode); + } + } + }); + + return this.colors; + } + }, { + key: "_registerColor", + value: function _registerColor(color) { + PfeAvatar.colors.push({ + color1: "rgb(" + color.join(",") + ")", + color2: "rgb(" + this._adjustColor(color).join(",") + ")" + }); + } + }, { + key: "_adjustColor", + value: function _adjustColor(color) { + var dark = 0.1; + var l_adj = 0.1; // luminance adjustment + var hsl = rgb2hsl.apply(undefined, toConsumableArray(color)); + + // if luminance is too dark already, then lighten the alternate color + // instead of darkening it. + hsl[2] += hsl[2] > dark ? -l_adj : l_adj; + + return hsl2rgb.apply(undefined, toConsumableArray(hsl)); + } + }]); + return PfeAvatar; + }(PFElement); + + PfeAvatar._registerColors(); + + PFElement.create(PfeAvatar); + + return PfeAvatar; + +}))); +//# sourceMappingURL=pfe-avatar.umd.js.map diff --git a/elements/pfe-avatar/dist/pfe-avatar.umd.js.map b/elements/pfe-avatar/dist/pfe-avatar.umd.js.map new file mode 100644 index 0000000000..3ce3c5eeca --- /dev/null +++ b/elements/pfe-avatar/dist/pfe-avatar.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-avatar.umd.js","sources":["../_temp/djb-hash.js","../_temp/hslrgb.js","../_temp/pfe-avatar.umd.js"],"sourcesContent":["/**\n * djb2 string hashing function.\n *\n * @see http://www.cse.yorku.ca/~oz/hash.html\n * @param {String} str the string to hash.\n * @return {Number} a positive integer\n */\n\nfunction hash(str) {\n let hash = 5381;\n let i = str.length;\n\n while (i) {\n hash = (hash * 33) ^ str.charCodeAt(--i);\n }\n\n return hash >>> 0;\n}\n\nexport { hash };\n","function h2rgb(v1, v2, vH) {\n if (vH < 0) vH += 1;\n if (vH > 1) vH -= 1;\n if (6 * vH < 1) return v1 + (v2 - v1) * 6 * vH;\n if (2 * vH < 1) return v2;\n if (3 * vH < 2) return v1 + (v2 - v1) * (2 / 3 - vH) * 6;\n return v1;\n}\n\n/**\n * Convert an HSL color to RGB.\n *\n * @param {Number} H the hue component\n * @param {Number} S the saturation component\n * @param {Number} L the luminance component\n * @return {Array} [R, G, B]\n *\n * @see https://www.easyrgb.com/en/math.php\n */\nexport function hsl2rgb(_H, _S, _L) {\n let R, G, B;\n\n const H = Math.max(0, Math.min(1, _H));\n const S = Math.max(0, Math.min(1, _S));\n const L = Math.max(0, Math.min(1, _L));\n\n if (S == 0) {\n R = L * 255;\n G = L * 255;\n B = L * 255;\n } else {\n let a, b;\n\n if (L < 0.5) {\n b = L * (1 + S);\n } else {\n b = L + S - S * L;\n }\n\n a = 2 * L - b;\n\n R = Math.floor(255 * h2rgb(a, b, H + 1 / 3));\n G = Math.floor(255 * h2rgb(a, b, H));\n B = Math.floor(255 * h2rgb(a, b, H - 1 / 3));\n }\n\n return [R, G, B];\n}\n\n/**\n * Convert an RGBcolor to HSL.\n *\n * @param {Number} R the red component\n * @param {Number} G the green component\n * @param {Number} B the blue component\n * @return {Array} [H, S, L]\n *\n * @see https://www.easyrgb.com/en/math.php\n */\nexport function rgb2hsl(_R, _G, _B) {\n let H, S, L;\n\n const R = Math.max(0, Math.min(255, _R));\n const G = Math.max(0, Math.min(255, _G));\n const B = Math.max(0, Math.min(255, _B));\n\n const r = R / 255;\n const g = G / 255;\n const b = B / 255;\n\n const var_min = Math.min(Math.min(r, g), b);\n const var_max = Math.max(Math.max(r, g), b);\n const del_max = var_max - var_min;\n\n L = (var_max + var_min) / 2;\n\n if (del_max === 0) {\n H = 0;\n S = 0;\n } else {\n if (L < 0.5) {\n S = del_max / (var_max + var_min);\n } else {\n S = del_max / (2 - var_max - var_min);\n }\n\n const del_r = ((var_max - r) / 6 + del_max / 2) / del_max;\n const del_g = ((var_max - g) / 6 + del_max / 2) / del_max;\n const del_b = ((var_max - b) / 6 + del_max / 2) / del_max;\n\n if (r == var_max) {\n H = del_b - del_g;\n } else if (g == var_max) {\n H = 1 / 3 + del_r - del_b;\n } else if (b == var_max) {\n H = 2 / 3 + del_g - del_r;\n }\n\n if (H < 0) {\n H += 1;\n } else if (H > 1) {\n H -= 1;\n }\n }\n\n return [H, S, L];\n}\n","/*!\n * PatternFly Elements: PfeAvatar 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.umd\";\nimport { hash } from \"./djb-hash.js\";\nimport { hsl2rgb, rgb2hsl } from \"./hslrgb.js\";\n\nclass PfeAvatar extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `\n`;\n }\n static get tag() {\n return \"pfe-avatar\";\n }\n\n get templateUrl() {\n return \"pfe-avatar.html\";\n }\n\n get styleUrl() {\n return \"pfe-avatar.scss\";\n }\n\n static get observedAttributes() {\n return [\"pfe-name\", \"pfe-pattern\", \"pfe-src\", \"pfe-shape\"];\n }\n\n static get events() {\n return {\n connected: `${this.tag}:connected`\n };\n }\n\n static get patterns() {\n return {\n triangles: \"triangles\",\n squares: \"squares\"\n };\n }\n\n static get defaultSize() {\n return 128;\n }\n\n static get defaultColors() {\n return \"#67accf #448087 #709c6b #a35252 #826cbb\";\n }\n\n get name() {\n return this.getAttribute(\"pfe-name\");\n }\n\n set name(val) {\n return this.setAttribute(\"pfe-name\", val);\n }\n\n get src() {\n return this.getAttribute(\"pfe-src\");\n }\n\n set src(href) {\n return this.setAttribute(\"pfe-src\", href);\n }\n\n get pattern() {\n return this.getAttribute(\"pfe-pattern\") || PfeAvatar.patterns.squares;\n }\n\n set pattern(name) {\n if (!PfeAvatar.patterns[name]) {\n this.log(\n `invalid pattern \"${name}\", valid patterns are: ${Object.values(\n PfeAvatar.patterns\n )}`\n );\n return;\n }\n return this.setAttribute(\"pfe-pattern\", name);\n }\n\n constructor() {\n super(PfeAvatar);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n this._initCanvas();\n\n this.emitEvent(PfeAvatar.events.connected, {\n bubbles: false\n });\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n super.attributeChangedCallback(...arguments);\n\n if (this.connected) {\n this.update();\n } else {\n this.addEventListener(PfeAvatar.events.connected, () => this.update());\n }\n }\n\n _initCanvas() {\n this._canvas = this.shadowRoot.querySelector(\"canvas\");\n const size =\n this.var(\"--pfe-avatar--width\").replace(/px$/, \"\") ||\n PfeAvatar.defaultSize;\n this._canvas.width = size;\n this._canvas.height = size;\n\n this._squareSize = this._canvas.width / 8;\n this._triangleSize = this._canvas.width / 4;\n\n this._ctx = this._canvas.getContext(\"2d\");\n }\n\n static _registerColors() {\n this.colors = [];\n const themeColors = this.var(\"--pfe-avatar--colors\") || this.defaultColors;\n\n themeColors.split(/\\s+/).forEach(colorCode => {\n let pattern;\n switch (colorCode.length) {\n case 4: // ex: \"#0fc\"\n pattern = /^#([A-f0-9])([A-f0-9])([A-f0-9])$/.exec(colorCode);\n if (pattern) {\n pattern.shift();\n const color = pattern.map(c => parseInt(c + c, 16));\n this._registerColor(color);\n } else {\n this.log(`[pfe-avatar] invalid color ${colorCode}`);\n }\n break;\n case 7: // ex: \"#00ffcc\"\n pattern = /^#([A-f0-9]{2})([A-f0-9]{2})([A-f0-9]{2})$/.exec(\n colorCode\n );\n if (pattern) {\n pattern.shift();\n const color = pattern.map(c => parseInt(c, 16));\n this._registerColor(color);\n } else {\n this.log(`[pfe-avatar] invalid color ${colorCode}`);\n }\n }\n });\n\n return this.colors;\n }\n\n static _registerColor(color) {\n PfeAvatar.colors.push({\n color1: `rgb(${color.join(\",\")})`,\n color2: `rgb(${this._adjustColor(color).join(\",\")})`\n });\n }\n\n static _adjustColor(color) {\n const dark = 0.1;\n const l_adj = 0.1; // luminance adjustment\n const hsl = rgb2hsl(...color);\n\n // if luminance is too dark already, then lighten the alternate color\n // instead of darkening it.\n hsl[2] += hsl[2] > dark ? -l_adj : l_adj;\n\n return hsl2rgb(...hsl);\n }\n\n update() {\n // if we have a src element, update the img, otherwise update the random pattern\n if (this.hasAttribute(\"pfe-src\")) {\n this.shadowRoot.querySelector(\"img\").src = this.src;\n } else {\n const bitPattern = hash(this.name).toString(2);\n const arrPattern = bitPattern.split(\"\").map(n => Number(n));\n this._colorIndex = Math.floor(\n (PfeAvatar.colors.length * parseInt(bitPattern, 2)) / Math.pow(2, 32)\n );\n this.color1 = PfeAvatar.colors[this._colorIndex].color1;\n this.color2 = PfeAvatar.colors[this._colorIndex].color2;\n\n this._clear();\n this._drawBackground();\n if (this.pattern === PfeAvatar.patterns.squares) {\n this._drawSquarePattern(arrPattern);\n } else if (this.pattern === PfeAvatar.patterns.triangles) {\n this._drawTrianglePattern(arrPattern);\n }\n // this._drawGradient();\n }\n }\n\n _clear() {\n this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);\n }\n\n _drawBackground() {\n this._ctx.fillStyle = this.color1;\n this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height);\n }\n\n _drawSquarePattern(pattern) {\n this._ctx.fillStyle = this.color2;\n if (this._ctx) {\n let i = pattern.length;\n while (i--) {\n if (pattern[i]) {\n this._drawMirroredSquare(i % 4, Math.floor(i / 4));\n }\n }\n }\n }\n\n /**\n * Draw a square at the given position, mirrored onto both the left and right half of the canvas.\n */\n _drawMirroredSquare(x, y) {\n if (this._ctx) {\n this._drawSquare(x, y);\n this._drawSquare(7 - x, y);\n }\n }\n\n _drawSquare(x, y) {\n this._ctx.fillRect(\n this._squareSize * x,\n this._squareSize * y,\n this._squareSize,\n this._squareSize\n );\n }\n\n _drawTrianglePattern(pattern) {\n this._ctx.fillStyle = this.color2;\n if (this._ctx) {\n let i = pattern.length;\n while (i--) {\n if (pattern[i]) {\n const x = Math.floor(i / 2) % 2;\n const y = Math.floor(i / 4);\n const alt = i % 4;\n\n const p1 = [x, y];\n const p2 = [x, y];\n const p3 = [x, y];\n\n switch (alt) {\n case 0:\n p2[1]++;\n p3[0]++;\n p3[1]++;\n break;\n case 1:\n p2[0]++;\n p3[0]++;\n p3[1]++;\n break;\n case 2:\n p2[0]++;\n p3[1]++;\n break;\n case 3:\n p1[0]++;\n p2[0]++;\n p2[1]++;\n p3[1]++;\n break;\n }\n\n this._drawMirroredTriangle(p1, p2, p3);\n }\n }\n }\n }\n\n /**\n * Draw a square at the given position in the top-left quadrant of the\n * canvas, and mirrored to the other three quadrants.\n */\n _drawMirroredTriangle(p1, p2, p3) {\n if (this._ctx) {\n this._drawTriangle(p1, p2, p3);\n this._drawTriangle(\n [4 - p1[0], p1[1]],\n [4 - p2[0], p2[1]],\n [4 - p3[0], p3[1]]\n );\n }\n }\n\n _drawTriangle(p1, p2, p3) {\n this._ctx.beginPath();\n this._ctx.moveTo(...p1.map(c => c * this._triangleSize));\n this._ctx.lineTo(...p2.map(c => c * this._triangleSize));\n this._ctx.lineTo(...p3.map(c => c * this._triangleSize));\n this._ctx.closePath();\n this._ctx.fill();\n this._ctx.fill();\n }\n\n _drawGradient() {\n const gradient = this._ctx.createLinearGradient(\n 0,\n this._canvas.height,\n this._canvas.width,\n 0\n );\n const color = this.color2;\n let gradientColor1 = color;\n let gradientColor2 = color;\n if (/^#[A-f0-9]{3}$/.test(color)) {\n // color is of the form \"#fff\"\n gradientColor1 += \"c\";\n gradientColor2 += \"0\";\n } else if (/^#[A-f0-9]{6}$/.test(color)) {\n // color is of the form \"#ffffff\"\n gradientColor1 += \"cc\";\n gradientColor2 += \"00\";\n }\n gradient.addColorStop(0, gradientColor1);\n gradient.addColorStop(1, gradientColor2);\n gradient.addColorStop(1, gradientColor1);\n this._ctx.fillStyle = gradient;\n this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height);\n }\n}\n\nPfeAvatar._registerColors();\n\nPFElement.create(PfeAvatar);\n\nexport default PfeAvatar;\n"],"names":["hash","str","i","length","charCodeAt","h2rgb","v1","v2","vH","hsl2rgb","_H","_S","_L","R","G","B","H","Math","max","min","S","L","a","b","floor","rgb2hsl","_R","_G","_B","r","g","var_min","var_max","del_max","del_r","del_g","del_b","PfeAvatar","getAttribute","val","setAttribute","href","patterns","squares","name","log","Object","values","connected","tag","triangles","_initCanvas","emitEvent","events","bubbles","attr","oldValue","newValue","arguments","update","addEventListener","_canvas","shadowRoot","querySelector","size","var","replace","defaultSize","width","height","_squareSize","_triangleSize","_ctx","getContext","hasAttribute","src","bitPattern","toString","arrPattern","split","map","Number","n","_colorIndex","colors","parseInt","pow","color1","color2","_clear","_drawBackground","pattern","_drawSquarePattern","_drawTrianglePattern","clearRect","fillStyle","fillRect","_drawMirroredSquare","x","y","_drawSquare","alt","p1","p2","p3","_drawMirroredTriangle","_drawTriangle","beginPath","moveTo","c","lineTo","closePath","fill","gradient","createLinearGradient","color","gradientColor1","gradientColor2","test","addColorStop","themeColors","defaultColors","forEach","colorCode","exec","shift","_registerColor","push","join","_adjustColor","dark","l_adj","hsl","PFElement","_registerColors","create"],"mappings":";;;;;;;;EAAA;;;;;;;;EAQA,SAASA,IAAT,CAAcC,GAAd,EAAmB;EACjB,MAAID,OAAO,IAAX;EACA,MAAIE,IAAID,IAAIE,MAAZ;;EAEA,SAAOD,CAAP,EAAU;EACRF,WAAQA,OAAO,EAAR,GAAcC,IAAIG,UAAJ,CAAe,EAAEF,CAAjB,CAArB;EACD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sBAAU,6CAA6CiC,IAA7C,CACRD,SADQ,CAAV;EAGA,gBAAIhC,OAAJ,EAAa;EACXA,sBAAQkC,KAAR;EACA,kBAAMV,SAAQxB,QAAQX,GAAR,CAAY;EAAA,uBAAKK,SAASwB,CAAT,EAAY,EAAZ,CAAL;EAAA,eAAZ,CAAd;EACA,qBAAKiB,cAAL,CAAoBX,MAApB;EACD,aAJD,MAIO;EACL,qBAAKtE,GAAL,iCAAuC8E,SAAvC;EACD;EArBL;EAuBD,OAzBD;;EA2BA,aAAO,KAAKvC,MAAZ;EACD;;;qCAEqB+B,OAAO;EAC3B9E,gBAAU+C,MAAV,CAAiB2C,IAAjB,CAAsB;EACpBxC,yBAAe4B,MAAMa,IAAN,CAAW,GAAX,CAAf,MADoB;EAEpBxC,yBAAe,KAAKyC,YAAL,CAAkBd,KAAlB,EAAyBa,IAAzB,CAA8B,GAA9B,CAAf;EAFoB,OAAtB;EAID;;;mCAEmBb,OAAO;EACzB,UAAMe,OAAO,GAAb;EACA,UAAMC,QAAQ,GAAd,CAFyB;EAGzB,UAAMC,MAAM3G,2CAAW0F,KAAX,EAAZ;;EAEA;EACA;EACAiB,UAAI,CAAJ,KAAUA,IAAI,CAAJ,IAASF,IAAT,GAAgB,CAACC,KAAjB,GAAyBA,KAAnC;;EAEA,aAAO1H,2CAAW2H,GAAX,EAAP;EACD;;;IAzKqBC;;EA0UxBhG,UAAUiG,eAAV;;EAEAD,UAAUE,MAAV,CAAiBlG,SAAjB;;;;;;;;"} \ No newline at end of file diff --git a/elements/pfe-avatar/dist/pfe-avatar.umd.min.js b/elements/pfe-avatar/dist/pfe-avatar.umd.min.js new file mode 100644 index 0000000000..a691b89b1b --- /dev/null +++ b/elements/pfe-avatar/dist/pfe-avatar.umd.min.js @@ -0,0 +1,2 @@ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("../../pfelement/dist/pfelement.umd")):"function"==typeof define&&define.amd?define(["../../pfelement/dist/pfelement.umd"],e):t.PfeAvatar=e(t.PFElement)}(this,function(t){"use strict";function u(t,e,r){return r<0&&(r+=1),1:host{display:block;position:relative;width:128px;width:var(--pfe-avatar--size,var(--pfe-avatar--width,128px));height:128px;height:var(--pfe-avatar--size,var(--pfe-avatar--width,128px))}:host canvas{width:100%;height:100%;image-rendering:optimizeSpeed;image-rendering:-moz-crisp-edges;image-rendering:-webkit-optimize-contrast;image-rendering:-o-crisp-edges;image-rendering:-o-pixelated;image-rendering:pixelated;-ms-interpolation-mode:nearest-neighbor}:host([pfe-shape=rounded]) canvas,:host([pfe-shape=rounded]) img{border-radius:calc(128px / 8 + 1px);border-radius:calc(var(--pfe-avatar--size,var(--pfe-avatar--width,128px))/ 8 + 1px)}:host([pfe-shape=circle]) canvas,:host([pfe-shape=circle]) img{border-radius:50%}:host([pfe-src]) canvas{display:none}:host([pfe-src]) img{display:block;width:100%;height:100%;-o-object-fit:cover;object-fit:cover}:host(:not([pfe-src])) img{display:none}:host([hidden]){display:none}\n/*# sourceMappingURL=pfe-avatar.min.css.map */\n\n"}},{key:"templateUrl",get:function(){return"pfe-avatar.html"}},{key:"styleUrl",get:function(){return"pfe-avatar.scss"}},{key:"name",get:function(){return this.getAttribute("pfe-name")},set:function(t){return this.setAttribute("pfe-name",t)}},{key:"src",get:function(){return this.getAttribute("pfe-src")},set:function(t){return this.setAttribute("pfe-src",t)}},{key:"pattern",get:function(){return this.getAttribute("pfe-pattern")||i.patterns.squares},set:function(t){if(i.patterns[t])return this.setAttribute("pfe-pattern",t);this.log('invalid pattern "'+t+'", valid patterns are: '+Object.values(i.patterns))}}],[{key:"version",get:function(){return"1.0.0-prerelease.54"}},{key:"tag",get:function(){return"pfe-avatar"}},{key:"observedAttributes",get:function(){return["pfe-name","pfe-pattern","pfe-src","pfe-shape"]}},{key:"events",get:function(){return{connected:this.tag+":connected"}}},{key:"patterns",get:function(){return{triangles:"triangles",squares:"squares"}}},{key:"defaultSize",get:function(){return 128}},{key:"defaultColors",get:function(){return"#67accf #448087 #709c6b #a35252 #826cbb"}}]),e(i,[{key:"connectedCallback",value:function(){o(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"connectedCallback",this).call(this),this._initCanvas(),this.emitEvent(i.events.connected,{bubbles:!1})}},{key:"attributeChangedCallback",value:function(t,e,r){var a=this;o(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"attributeChangedCallback",this).apply(this,arguments),this.connected?this.update():this.addEventListener(i.events.connected,function(){return a.update()})}},{key:"_initCanvas",value:function(){this._canvas=this.shadowRoot.querySelector("canvas");var t=this.var("--pfe-avatar--width").replace(/px$/,"")||i.defaultSize;this._canvas.width=t,this._canvas.height=t,this._squareSize=this._canvas.width/8,this._triangleSize=this._canvas.width/4,this._ctx=this._canvas.getContext("2d")}},{key:"update",value:function(){if(this.hasAttribute("pfe-src"))this.shadowRoot.querySelector("img").src=this.src;else{var t=function(t){for(var e=5381,r=t.length;r;)e=33*e^t.charCodeAt(--r);return e>>>0}(this.name).toString(2),e=t.split("").map(function(t){return Number(t)});this._colorIndex=Math.floor(i.colors.length*parseInt(t,2)/Math.pow(2,32)),this.color1=i.colors[this._colorIndex].color1,this.color2=i.colors[this._colorIndex].color2,this._clear(),this._drawBackground(),this.pattern===i.patterns.squares?this._drawSquarePattern(e):this.pattern===i.patterns.triangles&&this._drawTrianglePattern(e)}}},{key:"_clear",value:function(){this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height)}},{key:"_drawBackground",value:function(){this._ctx.fillStyle=this.color1,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height)}},{key:"_drawSquarePattern",value:function(t){if(this._ctx.fillStyle=this.color2,this._ctx)for(var e=t.length;e--;)t[e]&&this._drawMirroredSquare(e%4,Math.floor(e/4))}},{key:"_drawMirroredSquare",value:function(t,e){this._ctx&&(this._drawSquare(t,e),this._drawSquare(7-t,e))}},{key:"_drawSquare",value:function(t,e){this._ctx.fillRect(this._squareSize*t,this._squareSize*e,this._squareSize,this._squareSize)}},{key:"_drawTrianglePattern",value:function(t){if(this._ctx.fillStyle=this.color2,this._ctx)for(var e=t.length;e--;)if(t[e]){var r=Math.floor(e/2)%2,a=Math.floor(e/4),i=[r,a],n=[r,a],o=[r,a];switch(e%4){case 0:n[1]++,o[0]++,o[1]++;break;case 1:n[0]++,o[0]++,o[1]++;break;case 2:n[0]++,o[1]++;break;case 3:i[0]++,n[0]++,n[1]++,o[1]++}this._drawMirroredTriangle(i,n,o)}}},{key:"_drawMirroredTriangle",value:function(t,e,r){this._ctx&&(this._drawTriangle(t,e,r),this._drawTriangle([4-t[0],t[1]],[4-e[0],e[1]],[4-r[0],r[1]]))}},{key:"_drawTriangle",value:function(t,e,r){var a,i,n,o=this;this._ctx.beginPath(),(a=this._ctx).moveTo.apply(a,s(t.map(function(t){return t*o._triangleSize}))),(i=this._ctx).lineTo.apply(i,s(e.map(function(t){return t*o._triangleSize}))),(n=this._ctx).lineTo.apply(n,s(r.map(function(t){return t*o._triangleSize}))),this._ctx.closePath(),this._ctx.fill(),this._ctx.fill()}},{key:"_drawGradient",value:function(){var t=this._ctx.createLinearGradient(0,this._canvas.height,this._canvas.width,0),e=this.color2,r=e,a=e;/^#[A-f0-9]{3}$/.test(e)?(r+="c",a+="0"):/^#[A-f0-9]{6}$/.test(e)&&(r+="cc",a+="00"),t.addColorStop(0,r),t.addColorStop(1,a),t.addColorStop(1,r),this._ctx.fillStyle=t,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height)}}],[{key:"_registerColors",value:function(){var i=this;return this.colors=[],(this.var("--pfe-avatar--colors")||this.defaultColors).split(/\s+/).forEach(function(t){var e=void 0;switch(t.length){case 4:if(e=/^#([A-f0-9])([A-f0-9])([A-f0-9])$/.exec(t)){e.shift();var r=e.map(function(t){return parseInt(t+t,16)});i._registerColor(r)}else i.log("[pfe-avatar] invalid color "+t);break;case 7:if(e=/^#([A-f0-9]{2})([A-f0-9]{2})([A-f0-9]{2})$/.exec(t)){e.shift();var a=e.map(function(t){return parseInt(t,16)});i._registerColor(a)}else i.log("[pfe-avatar] invalid color "+t)}}),this.colors}},{key:"_registerColor",value:function(t){i.colors.push({color1:"rgb("+t.join(",")+")",color2:"rgb("+this._adjustColor(t).join(",")+")"})}},{key:"_adjustColor",value:function(t){var e=function(t,e,r){var a,i=void 0,n=void 0,o=Math.max(0,Math.min(255,t))/255,s=Math.max(0,Math.min(255,e))/255,c=Math.max(0,Math.min(255,r))/255,l=Math.min(Math.min(o,s),c),h=Math.max(Math.max(o,s),c),u=h-l;if(a=(h+l)/2,0==u)n=i=0;else{n=a<.5?u/(h+l):u/(2-h-l);var f=((h-o)/6+u/2)/u,p=((h-s)/6+u/2)/u,d=((h-c)/6+u/2)/u;o==h?i=d-p:s==h?i=1/3+f-d:c==h&&(i=2/3+p-f),i<0?i+=1:1 1) vH -= 1;\n if (6 * vH < 1) return v1 + (v2 - v1) * 6 * vH;\n if (2 * vH < 1) return v2;\n if (3 * vH < 2) return v1 + (v2 - v1) * (2 / 3 - vH) * 6;\n return v1;\n}\n\n/**\n * Convert an HSL color to RGB.\n *\n * @param {Number} H the hue component\n * @param {Number} S the saturation component\n * @param {Number} L the luminance component\n * @return {Array} [R, G, B]\n *\n * @see https://www.easyrgb.com/en/math.php\n */\nexport function hsl2rgb(_H, _S, _L) {\n let R, G, B;\n\n const H = Math.max(0, Math.min(1, _H));\n const S = Math.max(0, Math.min(1, _S));\n const L = Math.max(0, Math.min(1, _L));\n\n if (S == 0) {\n R = L * 255;\n G = L * 255;\n B = L * 255;\n } else {\n let a, b;\n\n if (L < 0.5) {\n b = L * (1 + S);\n } else {\n b = L + S - S * L;\n }\n\n a = 2 * L - b;\n\n R = Math.floor(255 * h2rgb(a, b, H + 1 / 3));\n G = Math.floor(255 * h2rgb(a, b, H));\n B = Math.floor(255 * h2rgb(a, b, H - 1 / 3));\n }\n\n return [R, G, B];\n}\n\n/**\n * Convert an RGBcolor to HSL.\n *\n * @param {Number} R the red component\n * @param {Number} G the green component\n * @param {Number} B the blue component\n * @return {Array} [H, S, L]\n *\n * @see https://www.easyrgb.com/en/math.php\n */\nexport function rgb2hsl(_R, _G, _B) {\n let H, S, L;\n\n const R = Math.max(0, Math.min(255, _R));\n const G = Math.max(0, Math.min(255, _G));\n const B = Math.max(0, Math.min(255, _B));\n\n const r = R / 255;\n const g = G / 255;\n const b = B / 255;\n\n const var_min = Math.min(Math.min(r, g), b);\n const var_max = Math.max(Math.max(r, g), b);\n const del_max = var_max - var_min;\n\n L = (var_max + var_min) / 2;\n\n if (del_max === 0) {\n H = 0;\n S = 0;\n } else {\n if (L < 0.5) {\n S = del_max / (var_max + var_min);\n } else {\n S = del_max / (2 - var_max - var_min);\n }\n\n const del_r = ((var_max - r) / 6 + del_max / 2) / del_max;\n const del_g = ((var_max - g) / 6 + del_max / 2) / del_max;\n const del_b = ((var_max - b) / 6 + del_max / 2) / del_max;\n\n if (r == var_max) {\n H = del_b - del_g;\n } else if (g == var_max) {\n H = 1 / 3 + del_r - del_b;\n } else if (b == var_max) {\n H = 2 / 3 + del_g - del_r;\n }\n\n if (H < 0) {\n H += 1;\n } else if (H > 1) {\n H -= 1;\n }\n }\n\n return [H, S, L];\n}\n","/*!\n * PatternFly Elements: PfeAvatar 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.umd\";\nimport { hash } from \"./djb-hash.js\";\nimport { hsl2rgb, rgb2hsl } from \"./hslrgb.js\";\n\nclass PfeAvatar extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `\n`;\n }\n static get tag() {\n return \"pfe-avatar\";\n }\n\n get templateUrl() {\n return \"pfe-avatar.html\";\n }\n\n get styleUrl() {\n return \"pfe-avatar.scss\";\n }\n\n static get observedAttributes() {\n return [\"pfe-name\", \"pfe-pattern\", \"pfe-src\", \"pfe-shape\"];\n }\n\n static get events() {\n return {\n connected: `${this.tag}:connected`\n };\n }\n\n static get patterns() {\n return {\n triangles: \"triangles\",\n squares: \"squares\"\n };\n }\n\n static get defaultSize() {\n return 128;\n }\n\n static get defaultColors() {\n return \"#67accf #448087 #709c6b #a35252 #826cbb\";\n }\n\n get name() {\n return this.getAttribute(\"pfe-name\");\n }\n\n set name(val) {\n return this.setAttribute(\"pfe-name\", val);\n }\n\n get src() {\n return this.getAttribute(\"pfe-src\");\n }\n\n set src(href) {\n return this.setAttribute(\"pfe-src\", href);\n }\n\n get pattern() {\n return this.getAttribute(\"pfe-pattern\") || PfeAvatar.patterns.squares;\n }\n\n set pattern(name) {\n if (!PfeAvatar.patterns[name]) {\n this.log(\n `invalid pattern \"${name}\", valid patterns are: ${Object.values(\n PfeAvatar.patterns\n )}`\n );\n return;\n }\n return this.setAttribute(\"pfe-pattern\", name);\n }\n\n constructor() {\n super(PfeAvatar);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n this._initCanvas();\n\n this.emitEvent(PfeAvatar.events.connected, {\n bubbles: false\n });\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n super.attributeChangedCallback(...arguments);\n\n if (this.connected) {\n this.update();\n } else {\n this.addEventListener(PfeAvatar.events.connected, () => this.update());\n }\n }\n\n _initCanvas() {\n this._canvas = this.shadowRoot.querySelector(\"canvas\");\n const size =\n this.var(\"--pfe-avatar--width\").replace(/px$/, \"\") ||\n PfeAvatar.defaultSize;\n this._canvas.width = size;\n this._canvas.height = size;\n\n this._squareSize = this._canvas.width / 8;\n this._triangleSize = this._canvas.width / 4;\n\n this._ctx = this._canvas.getContext(\"2d\");\n }\n\n static _registerColors() {\n this.colors = [];\n const themeColors = this.var(\"--pfe-avatar--colors\") || this.defaultColors;\n\n themeColors.split(/\\s+/).forEach(colorCode => {\n let pattern;\n switch (colorCode.length) {\n case 4: // ex: \"#0fc\"\n pattern = /^#([A-f0-9])([A-f0-9])([A-f0-9])$/.exec(colorCode);\n if (pattern) {\n pattern.shift();\n const color = pattern.map(c => parseInt(c + c, 16));\n this._registerColor(color);\n } else {\n this.log(`[pfe-avatar] invalid color ${colorCode}`);\n }\n break;\n case 7: // ex: \"#00ffcc\"\n pattern = /^#([A-f0-9]{2})([A-f0-9]{2})([A-f0-9]{2})$/.exec(\n colorCode\n );\n if (pattern) {\n pattern.shift();\n const color = pattern.map(c => parseInt(c, 16));\n this._registerColor(color);\n } else {\n this.log(`[pfe-avatar] invalid color ${colorCode}`);\n }\n }\n });\n\n return this.colors;\n }\n\n static _registerColor(color) {\n PfeAvatar.colors.push({\n color1: `rgb(${color.join(\",\")})`,\n color2: `rgb(${this._adjustColor(color).join(\",\")})`\n });\n }\n\n static _adjustColor(color) {\n const dark = 0.1;\n const l_adj = 0.1; // luminance adjustment\n const hsl = rgb2hsl(...color);\n\n // if luminance is too dark already, then lighten the alternate color\n // instead of darkening it.\n hsl[2] += hsl[2] > dark ? -l_adj : l_adj;\n\n return hsl2rgb(...hsl);\n }\n\n update() {\n // if we have a src element, update the img, otherwise update the random pattern\n if (this.hasAttribute(\"pfe-src\")) {\n this.shadowRoot.querySelector(\"img\").src = this.src;\n } else {\n const bitPattern = hash(this.name).toString(2);\n const arrPattern = bitPattern.split(\"\").map(n => Number(n));\n this._colorIndex = Math.floor(\n (PfeAvatar.colors.length * parseInt(bitPattern, 2)) / Math.pow(2, 32)\n );\n this.color1 = PfeAvatar.colors[this._colorIndex].color1;\n this.color2 = PfeAvatar.colors[this._colorIndex].color2;\n\n this._clear();\n this._drawBackground();\n if (this.pattern === PfeAvatar.patterns.squares) {\n this._drawSquarePattern(arrPattern);\n } else if (this.pattern === PfeAvatar.patterns.triangles) {\n this._drawTrianglePattern(arrPattern);\n }\n // this._drawGradient();\n }\n }\n\n _clear() {\n this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);\n }\n\n _drawBackground() {\n this._ctx.fillStyle = this.color1;\n this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height);\n }\n\n _drawSquarePattern(pattern) {\n this._ctx.fillStyle = this.color2;\n if (this._ctx) {\n let i = pattern.length;\n while (i--) {\n if (pattern[i]) {\n this._drawMirroredSquare(i % 4, Math.floor(i / 4));\n }\n }\n }\n }\n\n /**\n * Draw a square at the given position, mirrored onto both the left and right half of the canvas.\n */\n _drawMirroredSquare(x, y) {\n if (this._ctx) {\n this._drawSquare(x, y);\n this._drawSquare(7 - x, y);\n }\n }\n\n _drawSquare(x, y) {\n this._ctx.fillRect(\n this._squareSize * x,\n this._squareSize * y,\n this._squareSize,\n this._squareSize\n );\n }\n\n _drawTrianglePattern(pattern) {\n this._ctx.fillStyle = this.color2;\n if (this._ctx) {\n let i = pattern.length;\n while (i--) {\n if (pattern[i]) {\n const x = Math.floor(i / 2) % 2;\n const y = Math.floor(i / 4);\n const alt = i % 4;\n\n const p1 = [x, y];\n const p2 = [x, y];\n const p3 = [x, y];\n\n switch (alt) {\n case 0:\n p2[1]++;\n p3[0]++;\n p3[1]++;\n break;\n case 1:\n p2[0]++;\n p3[0]++;\n p3[1]++;\n break;\n case 2:\n p2[0]++;\n p3[1]++;\n break;\n case 3:\n p1[0]++;\n p2[0]++;\n p2[1]++;\n p3[1]++;\n break;\n }\n\n this._drawMirroredTriangle(p1, p2, p3);\n }\n }\n }\n }\n\n /**\n * Draw a square at the given position in the top-left quadrant of the\n * canvas, and mirrored to the other three quadrants.\n */\n _drawMirroredTriangle(p1, p2, p3) {\n if (this._ctx) {\n this._drawTriangle(p1, p2, p3);\n this._drawTriangle(\n [4 - p1[0], p1[1]],\n [4 - p2[0], p2[1]],\n [4 - p3[0], p3[1]]\n );\n }\n }\n\n _drawTriangle(p1, p2, p3) {\n this._ctx.beginPath();\n this._ctx.moveTo(...p1.map(c => c * this._triangleSize));\n this._ctx.lineTo(...p2.map(c => c * this._triangleSize));\n this._ctx.lineTo(...p3.map(c => c * this._triangleSize));\n this._ctx.closePath();\n this._ctx.fill();\n this._ctx.fill();\n }\n\n _drawGradient() {\n const gradient = this._ctx.createLinearGradient(\n 0,\n this._canvas.height,\n this._canvas.width,\n 0\n );\n const color = this.color2;\n let gradientColor1 = color;\n let gradientColor2 = color;\n if (/^#[A-f0-9]{3}$/.test(color)) {\n // color is of the form \"#fff\"\n gradientColor1 += \"c\";\n gradientColor2 += \"0\";\n } else if (/^#[A-f0-9]{6}$/.test(color)) {\n // color is of the form \"#ffffff\"\n gradientColor1 += \"cc\";\n gradientColor2 += \"00\";\n }\n gradient.addColorStop(0, gradientColor1);\n gradient.addColorStop(1, gradientColor2);\n gradient.addColorStop(1, gradientColor1);\n this._ctx.fillStyle = gradient;\n this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height);\n }\n}\n\nPfeAvatar._registerColors();\n\nPFElement.create(PfeAvatar);\n\nexport default PfeAvatar;\n","/**\n * djb2 string hashing function.\n *\n * @see http://www.cse.yorku.ca/~oz/hash.html\n * @param {String} str the string to hash.\n * @return {Number} a positive integer\n */\n\nfunction hash(str) {\n let hash = 5381;\n let i = str.length;\n\n while (i) {\n hash = (hash * 33) ^ str.charCodeAt(--i);\n }\n\n return hash >>> 0;\n}\n\nexport { hash };\n"],"names":["h2rgb","v1","v2","vH","PfeAvatar","PFElement","this","getAttribute","val","setAttribute","href","patterns","squares","name","log","Object","values","tag","_initCanvas","emitEvent","events","connected","attr","oldValue","newValue","arguments","update","addEventListener","_this2","_canvas","shadowRoot","querySelector","size","var","replace","defaultSize","width","height","_squareSize","_triangleSize","_ctx","getContext","hasAttribute","src","bitPattern","str","hash","i","length","charCodeAt","toString","arrPattern","split","map","Number","n","_colorIndex","Math","floor","colors","parseInt","pow","color1","color2","_clear","_drawBackground","pattern","_drawSquarePattern","triangles","_drawTrianglePattern","clearRect","fillStyle","fillRect","_drawMirroredSquare","x","y","_drawSquare","p1","p2","p3","_drawMirroredTriangle","_drawTriangle","beginPath","moveTo","c","_this3","lineTo","closePath","fill","gradient","createLinearGradient","color","gradientColor1","gradientColor2","test","addColorStop","defaultColors","forEach","colorCode","exec","shift","_registerColor","push","join","_adjustColor","hsl","_R","_G","_B","L","H","S","r","max","min","g","b","var_min","var_max","del_max","del_r","del_g","del_b","_H","_S","_L","R","G","B","a","_registerColors","create"],"mappings":"qRAAA,SAASA,EAAMC,EAAIC,EAAIC,UACjBA,EAAK,IAAGA,GAAM,GACT,EAALA,IAAQA,GAAM,GACd,EAAIA,EAAK,EAAUF,EAAiB,GAAXC,EAAKD,GAAUE,EACxC,EAAIA,EAAK,EAAUD,EACnB,EAAIC,EAAK,EAAUF,GAAMC,EAAKD,IAAO,EAAI,EAAIE,GAAM,EAChDF,woBCuBHG,+TAAkBC,ukCAgBb,yDAIA,sDA6BAC,KAAKC,aAAa,0BAGlBC,UACAF,KAAKG,aAAa,WAAYD,sCAI9BF,KAAKC,aAAa,yBAGnBG,UACCJ,KAAKG,aAAa,UAAWC,0CAI7BJ,KAAKC,aAAa,gBAAkBH,EAAUO,SAASC,sBAGpDC,MACLT,EAAUO,SAASE,UAQjBP,KAAKG,aAAa,cAAeI,QAPjCC,wBACiBD,4BAA8BE,OAAOC,OACv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H,OAAO/H"} \ No newline at end of file diff --git a/elements/pfe-avatar/package-lock.json b/elements/pfe-avatar/package-lock.json index 9acf8b4552..e50354b6ac 100644 --- a/elements/pfe-avatar/package-lock.json +++ b/elements/pfe-avatar/package-lock.json @@ -1,6 +1,6 @@ { "name": "@patternfly/pfe-avatar", - "version": "1.0.0-prerelease.53", + "version": "1.0.0-prerelease.54", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/elements/pfe-avatar/package.json b/elements/pfe-avatar/package.json index 288959ed96..7fa9cd1b95 100644 --- a/elements/pfe-avatar/package.json +++ b/elements/pfe-avatar/package.json @@ -4,7 +4,7 @@ "className": "PfeAvatar", "elementName": "pfe-avatar" }, - "version": "1.0.0-prerelease.53", + "version": "1.0.0-prerelease.54", "description": "Avatar for PatternFly Elements", "keywords": [ "web-components", @@ -40,7 +40,7 @@ "@patternfly/pfelement": "^1.0.0-prerelease.51" }, "devDependencies": { - "@patternfly/pfe-sass": "^1.0.0-prerelease.53" + "@patternfly/pfe-sass": "^1.0.0-prerelease.54" }, "generator-pfelement-version": "0.6.8", "bugs": { diff --git a/elements/pfe-badge/dist/pfe-badge.js b/elements/pfe-badge/dist/pfe-badge.js new file mode 100644 index 0000000000..1408a704ef --- /dev/null +++ b/elements/pfe-badge/dist/pfe-badge.js @@ -0,0 +1,99 @@ +import PFElement from '../../pfelement/dist/pfelement.js'; + +/*! + * PatternFly Elements: PfeBadge 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * +*/ + +class PfeBadge extends PFElement { + static get version() { + return "1.0.0-prerelease.54"; + } + + get html() { + return ``; + } + + static get properties() { + return {"state":{"title":"Background color","type":"string","enum":["default","moderate","important","critical","success","info"],"default":"default","prefixed":true},"number":{"title":"Numeric Value","type":"number","prefixed":false},"pfe-threshold":{"title":"Threshold Value","type":"number","prefixed":false}}; + } + + static get slots() { + return {}; + } + static get tag() { + return "pfe-badge"; + } + + get templateUrl() { + return "pfe-badge.html"; + } + + get styleUrl() { + return "pfe-badge.scss"; + } + + get schemaUrl() { + return "pfe-badge.json"; + } + + static get observedAttributes() { + return ["number", "pfe-threshold"]; + } + + get threshold() { + return this.getAttribute("pfe-threshold"); + } + + constructor() { + super(PfeBadge); + this._textContainer = this.shadowRoot.querySelector("span"); + } + + attributeChangedCallback(attr, oldVal, newVal) { + switch (attr) { + case "pfe-threshold": + this.textContent = + Number(this.threshold) < Number(this.textContent) + ? `${this.threshold}+` + : this.textContent; + break; + case "number": + this.textContent = + this.threshold && Number(this.threshold) < Number(newVal) + ? `${this.threshold}+` + : newVal; + break; + default: + return; + } + this._textContainer.textContent = this.textContent; + } +} + +PFElement.create(PfeBadge); + +export default PfeBadge; +//# sourceMappingURL=pfe-badge.js.map diff --git a/elements/pfe-badge/dist/pfe-badge.js.map b/elements/pfe-badge/dist/pfe-badge.js.map new file mode 100644 index 0000000000..adbc6d00df --- /dev/null +++ b/elements/pfe-badge/dist/pfe-badge.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-badge.js","sources":["../_temp/pfe-badge.js"],"sourcesContent":["/*!\n * PatternFly Elements: PfeBadge 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.js\";\n\nclass PfeBadge extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return ``;\n }\n\n static get properties() {\n return {\"state\":{\"title\":\"Background color\",\"type\":\"string\",\"enum\":[\"default\",\"moderate\",\"important\",\"critical\",\"success\",\"info\"],\"default\":\"default\",\"prefixed\":true},\"number\":{\"title\":\"Numeric Value\",\"type\":\"number\",\"prefixed\":false},\"pfe-threshold\":{\"title\":\"Threshold Value\",\"type\":\"number\",\"prefixed\":false}};\n }\n\n static get slots() {\n return {};\n }\n static get tag() {\n return \"pfe-badge\";\n }\n\n get templateUrl() {\n return \"pfe-badge.html\";\n }\n\n get styleUrl() {\n return \"pfe-badge.scss\";\n }\n\n get schemaUrl() {\n return \"pfe-badge.json\";\n }\n\n static get observedAttributes() {\n return [\"number\", \"pfe-threshold\"];\n }\n\n get threshold() {\n return this.getAttribute(\"pfe-threshold\");\n }\n\n constructor() {\n super(PfeBadge);\n this._textContainer = this.shadowRoot.querySelector(\"span\");\n }\n\n attributeChangedCallback(attr, oldVal, newVal) {\n switch (attr) {\n case \"pfe-threshold\":\n this.textContent =\n Number(this.threshold) < Number(this.textContent)\n ? `${this.threshold}+`\n : this.textContent;\n break;\n case \"number\":\n this.textContent =\n this.threshold && Number(this.threshold) < Number(newVal)\n ? `${this.threshold}+`\n : newVal;\n break;\n default:\n return;\n }\n this._textContainer.textContent = this.textContent;\n }\n}\n\nPFElement.create(PfeBadge);\n\nexport default PfeBadge;\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,AAEA;AACA,MAAM,QAAQ,SAAS,SAAS,CAAC;EAC/B,WAAW,OAAO,GAAG;IACnB,OAAO,qBAAqB,CAAC;GAC9B;;EAED,IAAI,IAAI,GAAG;IACT,OAAO,CAAC;;qBAES,CAAC,CAAC;GACpB;;EAED,WAAW,UAAU,GAAG;IACtB,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;GAC1T;;EAED,WAAW,KAAK,GAAG;IACjB,OAAO,EAAE,CAAC;GACX;EACD,W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fe-badge.json b/elements/pfe-badge/dist/pfe-badge.json new file mode 100644 index 0000000000..5c94462cca --- /dev/null +++ b/elements/pfe-badge/dist/pfe-badge.json @@ -0,0 +1,49 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Badge", + "description": "This element creates a badge with a numerical value.", + "type": "object", + "tag": "pfe-badge", + "class": "pfe-badge", + "category": "content", + "properties": { + "slots": { + "title": "Slots", + "description": "Definition of the supported slots", + "type": "object", + "properties": {} + }, + "attributes": { + "title": "Attributes", + "type": "object", + "properties": { + "state": { + "title": "Background color", + "type": "string", + "enum": [ + "default", + "moderate", + "important", + "critical", + "success", + "info" + ], + "default": "default", + "prefixed": true + }, + "number": { + "title": "Numeric Value", + "type": "number", + "prefixed": false + }, + "pfe-threshold": { + "title": "Threshold Value", + "type": "number", + "prefixed": false + } + } + } + }, + "required": ["slots", "attributes"], + "additionalProperties": false +} diff --git a/elements/pfe-badge/dist/pfe-badge.min.js b/elements/pfe-badge/dist/pfe-badge.min.js new file mode 100644 index 0000000000..f834b2be19 --- /dev/null +++ b/elements/pfe-badge/dist/pfe-badge.min.js @@ -0,0 +1,26 @@ +import e from"../../pfelement/dist/pfelement.min.js"; +/*! + * PatternFly Elements: PfeBadge 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * +*/class t extends e{static get version(){return"1.0.0-prerelease.54"}get html(){return""}static get properties(){return{state:{title:"Background color",type:"string",enum:["default","moderate","important","critical","success","info"],default:"default",prefixed:!0},number:{title:"Numeric Value",type:"number",prefixed:!1},"pfe-threshold":{title:"Threshold Value",type:"number",prefixed:!1}}}static get slots(){return{}}static get tag(){return"pfe-badge"}get templateUrl(){return"pfe-badge.html"}get styleUrl(){return"pfe-badge.scss"}get schemaUrl(){return"pfe-badge.json"}static get observedAttributes(){return["number","pfe-threshold"]}get threshold(){return this.getAttribute("pfe-threshold")}constructor(){super(t),this._textContainer=this.shadowRoot.querySelector("span")}attributeChangedCallback(e,t,r){switch(e){case"pfe-threshold":this.textContent=Number(this.threshold):host{display:inline-block;line-height:calc(1.5 * .75);line-height:calc(var(--pfe-theme--line-height,1.5) * .75);text-align:center;text-rendering:optimizelegibility}span{background-color:#f0f0f0;background-color:var(--pfe-badge--BackgroundColor,var(--pfe-theme--color--feedback--default--lightest,#f0f0f0));border-radius:calc(2px * 30);border-radius:var(--pfe-badge--BorderRadius,calc(var(--pfe-theme--ui--border-radius,2px) * 30));color:#151515;color:var(--pfe-badge--Color,var(--pfe-theme--color--text,#151515));font-size:calc(16px * .75);font-size:var(--pfe-badge--FontSize,calc(var(--pfe-theme--font-size,16px) * .75));font-weight:600;font-weight:var(--pfe-badge--FontWeight,var(--pfe-theme--font-weight--semi-bold,600));min-width:calc(1px * 2);min-width:var(--pfe-badge--MinWidth,calc(var(--pfe-theme--ui--border-width,1px) * 2));padding-left:calc(16px / 2);padding-left:var(--pfe-badge--PaddingLeft,calc(var(--pfe-theme--container-padding,16px)/ 2));padding-right:calc(16px / 2);padding-right:var(--pfe-badge--PaddingRight,calc(var(--pfe-theme--container-padding,16px)/ 2))}:host([pfe-state=moderate]) span{--pfe-badge--BackgroundColor:var(--pfe-theme--color--feedback--moderate, #ffc024);--pfe-badge--Color:var(--pfe-theme--color--text--on-dark, #fff)}:host([pfe-state=important]) span{--pfe-badge--BackgroundColor:var(--pfe-theme--color--feedback--important, #d73401);--pfe-badge--Color:var(--pfe-theme--color--text--on-dark, #fff)}:host([pfe-state=critical]) span{--pfe-badge--BackgroundColor:var(--pfe-theme--color--feedback--critical, #bb0000);--pfe-badge--Color:var(--pfe-theme--color--text--on-dark, #fff)}:host([pfe-state=success]) span{--pfe-badge--BackgroundColor:var(--pfe-theme--color--feedback--success, #2e7d32);--pfe-badge--Color:var(--pfe-theme--color--text--on-dark, #fff)}:host([pfe-state=info]) span{--pfe-badge--BackgroundColor:var(--pfe-theme--color--feedback--info, #0277bd);--pfe-badge--Color:var(--pfe-theme--color--text--on-dark, #fff)}:host([hidden]){display:none}\n/*# sourceMappingURL=pfe-badge.min.css.map */\n`;\n }\n\n static get properties() {\n return {\"state\":{\"title\":\"Background color\",\"type\":\"string\",\"enum\":[\"default\",\"moderate\",\"important\",\"critical\",\"success\",\"info\"],\"default\":\"default\",\"prefixed\":true},\"number\":{\"title\":\"Numeric Value\",\"type\":\"number\",\"prefixed\":false},\"pfe-threshold\":{\"title\":\"Threshold Value\",\"type\":\"number\",\"prefixed\":false}};\n }\n\n static get slots() {\n return {};\n }\n static get tag() {\n return \"pfe-badge\";\n }\n\n get templateUrl() {\n return \"pfe-badge.html\";\n }\n\n get styleUrl() {\n return \"pfe-badge.scss\";\n }\n\n get schemaUrl() {\n return \"pfe-badge.json\";\n }\n\n static get observedAttributes() {\n return [\"number\", \"pfe-threshold\"];\n }\n\n get threshold() {\n return this.getAttribute(\"pfe-threshold\");\n }\n\n constructor() {\n super(PfeBadge);\n this._textContainer = this.shadowRoot.querySelector(\"span\");\n }\n\n attributeChangedCallback(attr, oldVal, newVal) {\n switch (attr) {\n case \"pfe-threshold\":\n this.textContent =\n Number(this.threshold) < Number(this.textContent)\n ? `${this.threshold}+`\n : this.textContent;\n break;\n case \"number\":\n this.textContent =\n this.threshold && Number(this.threshold) < Number(newVal)\n ? `${this.threshold}+`\n : newVal;\n break;\n default:\n return;\n }\n this._textContainer.textContent = this.textContent;\n }\n}\n\nPFElement.create(PfeBadge);\n\nexport default PfeBadge;\n"],"names":["PfeBadge","PFElement","version","html","properties","state","title","type","enum","default","prefixed","number","pfe-threshold","slots","tag","templateUrl","styleUrl","schemaUrl","observedAttributes","threshold","this","getAttribute","[object Object]","super","_textContainer","shadowRoot","querySelector","attr","oldVal","newVal","textContent","Number","create"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;EA2BA,MAAMA,UAAiBC,EACrBC,qBACE,MAAO,sBAGTC,WACE,MAAO,4hEAKTC,wBACE,MAAO,CAACC,MAAQ,CAACC,MAAQ,mBAAmBC,KAAO,SAASC,KAAO,CAAC,UAAU,WAAW,YAAY,WAAW,UAAU,QAAQC,QAAU,UAAUC,UAAW,GAAMC,OAAS,CAACL,MAAQ,gBAAgBC,KAAO,SAASG,UAAW,GAAOE,gBAAgB,CAACN,MAAQ,kBAAkBC,KAAO,SAASG,UAAW,IAGnTG,mBACE,MAAO,GAETC,iBACE,MAAO,YAGTC,kBACE,MAAO,iBAGTC,eACE,MAAO,iBAGTC,gBACE,MAAO,iBAGTC,gCACE,MAAO,CAAC,SAAU,iBAGpBC,gBACE,OAAOC,KAAKC,aAAa,iBAG3BC,cACEC,MAAMvB,GACNoB,KAAKI,eAAiBJ,KAAKK,WAAWC,cAAc,QAGtDJ,yBAAyBK,EAAMC,EAAQC,GACrC,OAAQF,GACN,IAAK,gBACHP,KAAKU,YACHC,OAAOX,KAAKD,WAAaY,OAAOX,KAAKU,gBAC9BV,KAAKD,aACRC,KAAKU,YACX,MACF,IAAK,SACHV,KAAKU,YACHV,KAAKD,WAAaY,OAAOX,KAAKD,WAAaY,OAAOF,MAC3CT,KAAKD,aACRU,EACN,MACF,QACE,OAEJT,KAAKI,eAAeM,YAAcV,KAAKU,aAI3C7B,EAAU+B,OAAOhC"} \ No newline at end of file diff --git a/elements/pfe-badge/dist/pfe-badge.umd.js b/elements/pfe-badge/dist/pfe-badge.umd.js new file mode 100644 index 0000000000..e200ccd905 --- /dev/null +++ b/elements/pfe-badge/dist/pfe-badge.umd.js @@ -0,0 +1,169 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../../pfelement/dist/pfelement.umd')) : + typeof define === 'function' && define.amd ? define(['../../pfelement/dist/pfelement.umd'], factory) : + (global.PfeBadge = factory(global.PFElement)); +}(this, (function (PFElement) { 'use strict'; + + PFElement = PFElement && PFElement.hasOwnProperty('default') ? PFElement['default'] : PFElement; + + var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + }; + + var createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + }(); + + var inherits = function (subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + }; + + var possibleConstructorReturn = function (self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && (typeof call === "object" || typeof call === "function") ? call : self; + }; + + /*! + * PatternFly Elements: PfeBadge 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + + var PfeBadge = function (_PFElement) { + inherits(PfeBadge, _PFElement); + createClass(PfeBadge, [{ + key: "html", + get: function get$$1() { + return ""; + } + }, { + key: "templateUrl", + get: function get$$1() { + return "pfe-badge.html"; + } + }, { + key: "styleUrl", + get: function get$$1() { + return "pfe-badge.scss"; + } + }, { + key: "schemaUrl", + get: function get$$1() { + return "pfe-badge.json"; + } + }, { + key: "threshold", + get: function get$$1() { + return this.getAttribute("pfe-threshold"); + } + }], [{ + key: "version", + get: function get$$1() { + return "1.0.0-prerelease.54"; + } + }, { + key: "properties", + get: function get$$1() { + return { "state": { "title": "Background color", "type": "string", "enum": ["default", "moderate", "important", "critical", "success", "info"], "default": "default", "prefixed": true }, "number": { "title": "Numeric Value", "type": "number", "prefixed": false }, "pfe-threshold": { "title": "Threshold Value", "type": "number", "prefixed": false } }; + } + }, { + key: "slots", + get: function get$$1() { + return {}; + } + }, { + key: "tag", + get: function get$$1() { + return "pfe-badge"; + } + }, { + key: "observedAttributes", + get: function get$$1() { + return ["number", "pfe-threshold"]; + } + }]); + + function PfeBadge() { + classCallCheck(this, PfeBadge); + + var _this = possibleConstructorReturn(this, (PfeBadge.__proto__ || Object.getPrototypeOf(PfeBadge)).call(this, PfeBadge)); + + _this._textContainer = _this.shadowRoot.querySelector("span"); + return _this; + } + + createClass(PfeBadge, [{ + key: "attributeChangedCallback", + value: function attributeChangedCallback(attr, oldVal, newVal) { + switch (attr) { + case "pfe-threshold": + this.textContent = Number(this.threshold) < Number(this.textContent) ? this.threshold + "+" : this.textContent; + break; + case "number": + this.textContent = this.threshold && Number(this.threshold) < Number(newVal) ? this.threshold + "+" : newVal; + break; + default: + return; + } + this._textContainer.textContent = this.textContent; + } + }]); + return PfeBadge; + }(PFElement); + + PFElement.create(PfeBadge); + + return PfeBadge; + +}))); +//# sourceMappingURL=pfe-badge.umd.js.map diff --git a/elements/pfe-badge/dist/pfe-badge.umd.js.map b/elements/pfe-badge/dist/pfe-badge.umd.js.map new file mode 100644 index 0000000000..78c246b271 --- /dev/null +++ b/elements/pfe-badge/dist/pfe-badge.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-badge.umd.js","sources":["../_temp/pfe-badge.umd.js"],"sourcesContent":["/*!\n * PatternFly Elements: PfeBadge 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.umd\";\n\nclass PfeBadge extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return ``;\n }\n\n static get properties() {\n return {\"state\":{\"title\":\"Background color\",\"type\":\"string\",\"enum\":[\"default\",\"moderate\",\"important\",\"critical\",\"success\",\"info\"],\"default\":\"default\",\"prefixed\":true},\"number\":{\"title\":\"Numeric Value\",\"type\":\"number\",\"prefixed\":false},\"pfe-threshold\":{\"title\":\"Threshold Value\",\"type\":\"number\",\"prefixed\":false}};\n }\n\n static get slots() {\n return {};\n }\n static get tag() {\n return \"pfe-badge\";\n }\n\n get templateUrl() {\n return \"pfe-badge.html\";\n }\n\n get styleUrl() {\n return \"pfe-badge.scss\";\n }\n\n get schemaUrl() {\n return \"pfe-badge.json\";\n }\n\n static get observedAttributes() {\n return [\"number\", \"pfe-threshold\"];\n }\n\n get threshold() {\n return this.getAttribute(\"pfe-threshold\");\n }\n\n constructor() {\n super(PfeBadge);\n this._textContainer = this.shadowRoot.querySelector(\"span\");\n }\n\n attributeChangedCallback(attr, oldVal, newVal) {\n switch (attr) {\n case \"pfe-threshold\":\n this.textContent =\n Number(this.threshold) < Number(this.textContent)\n ? `${this.threshold}+`\n : this.textContent;\n break;\n case \"number\":\n this.textContent =\n this.threshold && Number(this.threshold) < Number(newVal)\n ? `${this.threshold}+`\n : newVal;\n break;\n default:\n return;\n }\n this._textContainer.textContent = this.textContent;\n }\n}\n\nPFElement.create(PfeBadge);\n\nexport default PfeBadge;\n"],"names":["PfeBadge","getAttribute","_textContainer","shadowRoot","querySelector","attr","oldVal","newVal","textContent","Number","threshold","PFElement","create"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;MA2BMA;;;;6BAKO;EACT;EAGD;;;6BAaiB;EAChB,aAAO,gBAAP;EACD;;;6BAEc;EACb,aAAO,gBAAP;EACD;;;6BAEe;EACd,aAAO,gBAAP;EACD;;;6BAMe;EACd,aAAO,KAAKC,YAAL,CAAkB,eAAlB,CAAP;EACD;;;6BAvCoB;EACnB,aAAO,qBAAP;EACD;;;6BAQuB;EACtB,aAAO,EAAC,SAAQ,EAAC,SAAQ,kBAAT,EAA4B,QAAO,QAAnC,EAA4C,QAAO,CAAC,SAAD,EAAW,UAAX,EAAsB,WAAtB,EAAkC,UAAlC,EAA6C,SAA7C,EAAuD,MAAvD,CAAnD,EAAkH,WAAU,SAA5H,EAAsI,YAAW,IAAjJ,EAAT,EAAgK,UAAS,EAAC,SAAQ,eAAT,EAAyB,QAAO,QAAhC,EAAyC,YAAW,KAApD,EAAzK,EAAoO,iBAAgB,EAAC,SAAQ,iBAAT,EAA2B,QAAO,QAAlC,EAA2C,YAAW,KAAtD,EAApP,EAAP;EACD;;;6BAEkB;EACjB,aAAO,EAAP;EACD;;;6BACgB;EACf,aAAO,WAAP;EACD;;;6BAc+B;EAC9B,aAAO,CAAC,QAAD,EAAW,eAAX,CAAP;EACD;;;EAMD,sBAAc;EAAA;;EAAA,mHACND,QADM;;EAEZ,UAAKE,cAAL,GAAsB,MAAKC,UAAL,CAAgBC,aAAhB,CAA8B,MAA9B,CAAtB;EAFY;EAGb;;;;+CAEwBC,MAAMC,QAAQC,QAAQ;EAC7C,cAAQF,IAAR;EACE,aAAK,eAAL;EACE,eAAKG,WAAL,GACEC,OAAO,KAAKC,SAAZ,IAAyBD,OAAO,KAAKD,WAAZ,CAAzB,GACO,KAAKE,SADZ,SAEI,KAAKF,WAHX;EAIA;EACF,aAAK,QAAL;EACE,eAAKA,WAAL,GACE,KAAKE,SAAL,IAAkBD,OAAO,KAAKC,SAAZ,IAAyBD,OAAOF,MAAP,CAA3C,GACO,KAAKG,SADZ,SAEIH,MAHN;EAIA;EACF;EACE;EAdJ;EAgBA,WAAKL,cAAL,CAAoBM,WAApB,GAAkC,KAAKA,WAAvC;EACD;;;IAjEoBG;;EAoEvBA,UAAUC,MAAV,CAAiBZ,QAAjB;;;;;;;;"} \ No newline at end of file diff --git a/elements/pfe-badge/dist/pfe-badge.umd.min.js b/elements/pfe-badge/dist/pfe-badge.umd.min.js new file mode 100644 index 0000000000..69e85081d3 --- /dev/null +++ b/elements/pfe-badge/dist/pfe-badge.umd.min.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("../../pfelement/dist/pfelement.umd")):"function"==typeof define&&define.amd?define(["../../pfelement/dist/pfelement.umd"],t):e.PfeBadge=t(e.PFElement)}(this,function(e){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e;var t=function(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),e};function o(e,t){for(var r=0;r:host{display:inline-block;line-height:calc(1.5 * .75);line-height:calc(var(--pfe-theme--line-height,1.5) * .75);text-align:center;text-rendering:optimizelegibility}span{background-color:#f0f0f0;background-color:var(--pfe-badge--BackgroundColor,var(--pfe-theme--color--feedback--default--lightest,#f0f0f0));border-radius:calc(2px * 30);border-radius:var(--pfe-badge--BorderRadius,calc(var(--pfe-theme--ui--border-radius,2px) * 30));color:#151515;color:var(--pfe-badge--Color,var(--pfe-theme--color--text,#151515));font-size:calc(16px * .75);font-size:var(--pfe-badge--FontSize,calc(var(--pfe-theme--font-size,16px) * .75));font-weight:600;font-weight:var(--pfe-badge--FontWeight,var(--pfe-theme--font-weight--semi-bold,600));min-width:calc(1px * 2);min-width:var(--pfe-badge--MinWidth,calc(var(--pfe-theme--ui--border-width,1px) * 2));padding-left:calc(16px / 2);padding-left:var(--pfe-badge--PaddingLeft,calc(var(--pfe-theme--container-padding,16px)/ 2));padding-right:calc(16px / 2);padding-right:var(--pfe-badge--PaddingRight,calc(var(--pfe-theme--container-padding,16px)/ 2))}:host([pfe-state=moderate]) span{--pfe-badge--BackgroundColor:var(--pfe-theme--color--feedback--moderate, #ffc024);--pfe-badge--Color:var(--pfe-theme--color--text--on-dark, #fff)}:host([pfe-state=important]) span{--pfe-badge--BackgroundColor:var(--pfe-theme--color--feedback--important, #d73401);--pfe-badge--Color:var(--pfe-theme--color--text--on-dark, #fff)}:host([pfe-state=critical]) span{--pfe-badge--BackgroundColor:var(--pfe-theme--color--feedback--critical, #bb0000);--pfe-badge--Color:var(--pfe-theme--color--text--on-dark, #fff)}:host([pfe-state=success]) span{--pfe-badge--BackgroundColor:var(--pfe-theme--color--feedback--success, #2e7d32);--pfe-badge--Color:var(--pfe-theme--color--text--on-dark, #fff)}:host([pfe-state=info]) span{--pfe-badge--BackgroundColor:var(--pfe-theme--color--feedback--info, #0277bd);--pfe-badge--Color:var(--pfe-theme--color--text--on-dark, #fff)}:host([hidden]){display:none}\n/*# sourceMappingURL=pfe-badge.min.css.map */\n"}},{key:"templateUrl",get:function(){return"pfe-badge.html"}},{key:"styleUrl",get:function(){return"pfe-badge.scss"}},{key:"schemaUrl",get:function(){return"pfe-badge.json"}},{key:"threshold",get:function(){return this.getAttribute("pfe-threshold")}}],[{key:"version",get:function(){return"1.0.0-prerelease.54"}},{key:"properties",get:function(){return{state:{title:"Background color",type:"string",enum:["default","moderate","important","critical","success","info"],default:"default",prefixed:!0},number:{title:"Numeric Value",type:"number",prefixed:!1},"pfe-threshold":{title:"Threshold Value",type:"number",prefixed:!1}}}},{key:"slots",get:function(){return{}}},{key:"tag",get:function(){return"pfe-badge"}},{key:"observedAttributes",get:function(){return["number","pfe-threshold"]}}]),t(n,[{key:"attributeChangedCallback",value:function(e,t,r){switch(e){case"pfe-threshold":this.textContent=Number(this.threshold):host{display:inline-block;line-height:calc(1.5 * .75);line-height:calc(var(--pfe-theme--line-height,1.5) * .75);text-align:center;text-rendering:optimizelegibility}span{background-color:#f0f0f0;background-color:var(--pfe-badge--BackgroundColor,var(--pfe-theme--color--feedback--default--lightest,#f0f0f0));border-radius:calc(2px * 30);border-radius:var(--pfe-badge--BorderRadius,calc(var(--pfe-theme--ui--border-radius,2px) * 30));color:#151515;color:var(--pfe-badge--Color,var(--pfe-theme--color--text,#151515));font-size:calc(16px * .75);font-size:var(--pfe-badge--FontSize,calc(var(--pfe-theme--font-size,16px) * .75));font-weight:600;font-weight:var(--pfe-badge--FontWeight,var(--pfe-theme--font-weight--semi-bold,600));min-width:calc(1px * 2);min-width:var(--pfe-badge--MinWidth,calc(var(--pfe-theme--ui--border-width,1px) * 2));padding-left:calc(16px / 2);padding-left:var(--pfe-badge--PaddingLeft,calc(var(--pfe-theme--container-padding,16px)/ 2));padding-right:calc(16px / 2);padding-right:var(--pfe-badge--PaddingRight,calc(var(--pfe-theme--container-padding,16px)/ 2))}:host([pfe-state=moderate]) span{--pfe-badge--BackgroundColor:var(--pfe-theme--color--feedback--moderate, #ffc024);--pfe-badge--Color:var(--pfe-theme--color--text--on-dark, #fff)}:host([pfe-state=important]) span{--pfe-badge--BackgroundColor:var(--pfe-theme--color--feedback--important, #d73401);--pfe-badge--Color:var(--pfe-theme--color--text--on-dark, #fff)}:host([pfe-state=critical]) span{--pfe-badge--BackgroundColor:var(--pfe-theme--color--feedback--critical, #bb0000);--pfe-badge--Color:var(--pfe-theme--color--text--on-dark, #fff)}:host([pfe-state=success]) span{--pfe-badge--BackgroundColor:var(--pfe-theme--color--feedback--success, #2e7d32);--pfe-badge--Color:var(--pfe-theme--color--text--on-dark, #fff)}:host([pfe-state=info]) span{--pfe-badge--BackgroundColor:var(--pfe-theme--color--feedback--info, #0277bd);--pfe-badge--Color:var(--pfe-theme--color--text--on-dark, #fff)}:host([hidden]){display:none}\n/*# sourceMappingURL=pfe-badge.min.css.map */\n`;\n }\n\n static get properties() {\n return {\"state\":{\"title\":\"Background color\",\"type\":\"string\",\"enum\":[\"default\",\"moderate\",\"important\",\"critical\",\"success\",\"info\"],\"default\":\"default\",\"prefixed\":true},\"number\":{\"title\":\"Numeric Value\",\"type\":\"number\",\"prefixed\":false},\"pfe-threshold\":{\"title\":\"Threshold Value\",\"type\":\"number\",\"prefixed\":false}};\n }\n\n static get slots() {\n return {};\n }\n static get tag() {\n return \"pfe-badge\";\n }\n\n get templateUrl() {\n return \"pfe-badge.html\";\n }\n\n get styleUrl() {\n return \"pfe-badge.scss\";\n }\n\n get schemaUrl() {\n return \"pfe-badge.json\";\n }\n\n static get observedAttributes() {\n return [\"number\", \"pfe-threshold\"];\n }\n\n get threshold() {\n return this.getAttribute(\"pfe-threshold\");\n }\n\n constructor() {\n super(PfeBadge);\n this._textContainer = this.shadowRoot.querySelector(\"span\");\n }\n\n attributeChangedCallback(attr, oldVal, newVal) {\n switch (attr) {\n case \"pfe-threshold\":\n this.textContent =\n Number(this.threshold) < Number(this.textContent)\n ? `${this.threshold}+`\n : this.textContent;\n break;\n case \"number\":\n this.textContent =\n this.threshold && Number(this.threshold) < Number(newVal)\n ? `${this.threshold}+`\n : newVal;\n break;\n default:\n return;\n }\n this._textContainer.textContent = this.textContent;\n }\n}\n\nPFElement.create(PfeBadge);\n\nexport default PfeBadge;\n"],"names":["PfeBadge","PFElement","this","getAttribute","state","title","type","enum","default","prefixed","number","pfe-threshold","attr","oldVal","newVal","textContent","Number","threshold","_textContainer","_this","shadowRoot","querySelector","create"],"mappings":"yiBA2BMA,+TAAiBC,+mEAuBZ,wDAIA,yDAIA,0DAQAC,KAAKC,aAAa,yDArClB,+DAUA,CAACC,MAAQ,CAACC,MAAQ,mBAAmBC,KAAO,SAASC,KAAO,CAAC,UAAU,WAAW,YAAY,WAAW,UAAU,QAAQC,QAAU,UAAUC,UAAW,GAAMC,OAAS,CAACL,MAAQ,gBAAgBC,KAAO,SAASG,UAAW,GAAOE,gBAAgB,CAACN,MAAQ,kBAAkBC,KAAO,SAASG,UAAW,wCAI1S,qCAGA,6DAgBA,CAAC,SAAU,yEAYKG,EAAMC,EAAQC,UAC7BF,OACD,qBACEG,YACHC,OAAOd,KAAKe,WAAaD,OAAOd,KAAKa,aAC9Bb,KAAKe,cACRf,KAAKa,sBAER,cACEA,YACHb,KAAKe,WAAaD,OAAOd,KAAKe,WAAaD,OAAOF,GAC3CZ,KAAKe,cACRH,4BAKLI,eAAeH,YAAcb,KAAKa,qWArBjCf,aACDkB,eAAiBC,EAAKC,WAAWC,cAAc,iBAwBxDpB,EAAUqB,OAAOtB"} \ No newline at end of file diff --git a/elements/pfe-badge/package-lock.json b/elements/pfe-badge/package-lock.json index 496a820a0b..fc841b1b11 100644 --- a/elements/pfe-badge/package-lock.json +++ b/elements/pfe-badge/package-lock.json @@ -1,6 +1,6 @@ { "name": "@patternfly/pfe-badge", - "version": "1.0.0-prerelease.53", + "version": "1.0.0-prerelease.54", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/elements/pfe-badge/package.json b/elements/pfe-badge/package.json index 4d15c9b53a..b5f6fd55c4 100644 --- a/elements/pfe-badge/package.json +++ b/elements/pfe-badge/package.json @@ -4,7 +4,7 @@ "className": "PfeBadge", "elementName": "pfe-badge" }, - "version": "1.0.0-prerelease.53", + "version": "1.0.0-prerelease.54", "description": "Badge element for PatternFly Elements", "keywords": [ "web-components", @@ -50,7 +50,7 @@ "@patternfly/pfelement": "^1.0.0-prerelease.50" }, "devDependencies": { - "@patternfly/pfe-sass": "^1.0.0-prerelease.53" + "@patternfly/pfe-sass": "^1.0.0-prerelease.54" }, "generator-pfelement-version": "1.3.0" } diff --git a/elements/pfe-band/dist/pfe-band.js b/elements/pfe-band/dist/pfe-band.js new file mode 100644 index 0000000000..a9c568d66e --- /dev/null +++ b/elements/pfe-band/dist/pfe-band.js @@ -0,0 +1,233 @@ +import PFElement from '../../pfelement/dist/pfelement.js'; + +// @POLYFILL Element.matches +// https://developer.mozilla.org/en-US/docs/Web/API/Element/matches +if (!Element.prototype.matches) { + Element.prototype.matches = + Element.prototype.msMatchesSelector || + Element.prototype.webkitMatchesSelector; +} + +// @POLYFILL Element.closest +// https://developer.mozilla.org/en-US/docs/Web/API/Element/closest +if (!Element.prototype.closest) { + Element.prototype.closest = function(s) { + var el = this; + do { + if (el.matches(s)) return el; + el = el.parentElement || el.parentNode; + } while (el !== null && el.nodeType === 1); + return null; + }; +} + +// @POLYFILL Array.includes +// https://tc39.github.io/ecma262/#sec-array.prototype.includes +if (!Array.prototype.includes) { + Object.defineProperty(Array.prototype, "includes", { + value: function(valueToFind, fromIndex) { + if (this == null) { + throw new TypeError('"this" is null or not defined'); + } + + // 1. Let O be ? ToObject(this value). + var o = Object(this); + + // 2. Let len be ? ToLength(? Get(O, "length")). + var len = o.length >>> 0; + + // 3. If len is 0, return false. + if (len === 0) { + return false; + } + + // 4. Let n be ? ToInteger(fromIndex). + // (If fromIndex is undefined, this step produces the value 0.) + var n = fromIndex | 0; + + // 5. If n ≥ 0, then + // a. Let k be n. + // 6. Else n < 0, + // a. Let k be len + n. + // b. If k < 0, let k be 0. + var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0); + + function sameValueZero(x, y) { + return ( + x === y || + (typeof x === "number" && + typeof y === "number" && + isNaN(x) && + isNaN(y)) + ); + } + + // 7. Repeat, while k < len + while (k < len) { + // a. Let elementK be the result of ? Get(O, ! ToString(k)). + // b. If SameValueZero(valueToFind, elementK) is true, return true. + if (sameValueZero(o[k], valueToFind)) { + return true; + } + // c. Increase k by 1. + k++; + } + + // 8. Return false + return false; + } + }); +} + +/*! + * PatternFly Elements: PfeBand 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * +*/ + +class PfeBand extends PFElement { + static get version() { + return "1.0.0-prerelease.54"; + } + + get html() { + return `
    this.has_slot(`pfe-band--${slot}`) ? `pfe-has-${slot}` : "").join(" ")}> + ${this.has_slot("pfe-band--aside") && this.asidePosition.mobile === "top" ? `` : ""} + ${this.has_slot("pfe-band--header") ? `
    ` : ""} +
    + ${this.has_slot("pfe-band--aside") && this.asidePosition.mobile !== "top" ? `` : ""} + ${this.has_slot("pfe-band--footer") ? `
    ` : ""} +
    `; + } + + static get properties() { + return {"color":{"title":"Background color","type":"string","enum":["lightest","base","darker","darkest","complement","accent"],"default":"base","prefixed":true,"observer":"_colorChanged"},"img-src":{"title":"Background image","type":"string","prefixed":true,"observer":"_imgSrcChanged"},"aside-desktop":{"title":"Aside positioning (desktop)","type":"string","default":"right","enum":["right","left"],"prefixed":true,"observer":"_basicAttributeChanged","options":{"dependencies":[{"type":"slot","id":"aside"}]}},"aside-mobile":{"title":"Aside positioning (mobile)","type":"string","default":"bottom","enum":["top","bottom"],"prefixed":true,"observer":"_basicAttributeChanged","options":{"dependencies":[{"type":"slot","id":"aside"}]}},"aside-height":{"title":"Aside height","type":"string","default":"body","enum":["full","body"],"prefixed":true,"observer":"_basicAttributeChanged","options":{"dependencies":[{"type":"slot","id":"aside"}]}}}; + } + + static get slots() { + return {"header":{"title":"Header","type":"array","namedSlot":true,"maxItems":3,"items":{"title":"Body item","oneOf":[{"$ref":"raw"}]}},"body":{"title":"Body","type":"array","namedSlot":false,"items":{"oneOf":[{"$ref":"pfe-card"},{"$ref":"raw"}]}},"footer":{"title":"Footer","type":"array","namedSlot":true,"maxItems":3,"items":{"oneOf":[{"$ref":"pfe-cta"},{"$ref":"raw"}]}},"aside":{"title":"Aside","type":"array","namedSlot":true,"maxItems":5,"items":{"oneOf":[{"$ref":"pfe-card"},{"$ref":"raw"}]}}}; + } + static get tag() { + return "pfe-band"; + } + + get schemaUrl() { + return "pfe-band.json"; + } + + get templateUrl() { + return "pfe-band.html"; + } + + get styleUrl() { + return "pfe-band.scss"; + } + + get imageSrc() { + return this.getAttribute("pfe-img-src"); + } + + get backgroundColor() { + return this.getAttribute("pfe-color"); + } + + get asidePosition() { + return { + desktop: this.getAttribute("pfe-aside-desktop"), + mobile: this.getAttribute("pfe-aside-mobile"), + height: this.getAttribute("pfe-aside-height") + }; + } + + static get observedAttributes() { + return [ + "pfe-aside-desktop", + "pfe-aside-mobile", + "pfe-aside-height", + "pfe-color", + "pfe-img-src" + ]; + } + + static get cascadingAttributes() { + return { + "pfe-aside-desktop": ".pfe-band__container", + "pfe-aside-mobile": ".pfe-band__container", + "pfe-aside-height": ".pfe-band__container" + }; + } + + // Declare the type of this component + static get PfeType() { + return PFElement.PfeTypes.Container; + } + + constructor() { + super(PfeBand, { type: PfeBand.PfeType }); + } + + connectedCallback() { + super.connectedCallback(); + + // Initialize the background image attachment + if (this.imageSrc) { + this._imgSrcChanged("pfe-img-src", "", this.imageSrc); + } + } + + attributeChangedCallback(attr, oldValue, newValue) { + super.attributeChangedCallback(attr, oldValue, newValue); + // Strip the prefix form the attribute + attr = attr.replace("pfe-", ""); + // If the observer is defined in the attribute properties + if (this[attr] && this[attr].observer) { + // Get the observer function + let observer = this[this[attr].observer].bind(this); + // If it's a function, allow it to run + if (typeof observer === "function") observer(attr, oldValue, newValue); + } + } + + _basicAttributeChanged(attr, oldValue, newValue) { + this[attr].value = newValue; + } + + // Update the color attribute and contexts + _colorChanged(attr, oldValue, newValue) { + this[attr].value = newValue; + // Trigger an update in nested components + this.context_update(); + } + + // Update the background image + _imgSrcChanged(attr, oldValue, newValue) { + // Set the image as the background image + this.style.backgroundImage = newValue ? `url('${newValue}')` : ``; + } +} + +PFElement.create(PfeBand); + +export default PfeBand; +//# sourceMappingURL=pfe-band.js.map diff --git a/elements/pfe-band/dist/pfe-band.js.map b/elements/pfe-band/dist/pfe-band.js.map new file mode 100644 index 0000000000..55a355fe0f --- /dev/null +++ b/elements/pfe-band/dist/pfe-band.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-band.js","sources":["../_temp/polyfills--pfe-band.js","../_temp/pfe-band.js"],"sourcesContent":["// @POLYFILL Element.matches\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/matches\nif (!Element.prototype.matches) {\n Element.prototype.matches =\n Element.prototype.msMatchesSelector ||\n Element.prototype.webkitMatchesSelector;\n}\n\n// @POLYFILL Element.closest\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/closest\nif (!Element.prototype.closest) {\n Element.prototype.closest = function(s) {\n var el = this;\n do {\n if (el.matches(s)) return el;\n el = el.parentElement || el.parentNode;\n } while (el !== null && el.nodeType === 1);\n return null;\n };\n}\n\n// @POLYFILL Array.includes\n// https://tc39.github.io/ecma262/#sec-array.prototype.includes\nif (!Array.prototype.includes) {\n Object.defineProperty(Array.prototype, \"includes\", {\n value: function(valueToFind, fromIndex) {\n if (this == null) {\n throw new TypeError('\"this\" is null or not defined');\n }\n\n // 1. Let O be ? ToObject(this value).\n var o = Object(this);\n\n // 2. Let len be ? ToLength(? Get(O, \"length\")).\n var len = o.length >>> 0;\n\n // 3. If len is 0, return false.\n if (len === 0) {\n return false;\n }\n\n // 4. Let n be ? ToInteger(fromIndex).\n // (If fromIndex is undefined, this step produces the value 0.)\n var n = fromIndex | 0;\n\n // 5. If n ≥ 0, then\n // a. Let k be n.\n // 6. Else n < 0,\n // a. Let k be len + n.\n // b. If k < 0, let k be 0.\n var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);\n\n function sameValueZero(x, y) {\n return (\n x === y ||\n (typeof x === \"number\" &&\n typeof y === \"number\" &&\n isNaN(x) &&\n isNaN(y))\n );\n }\n\n // 7. Repeat, while k < len\n while (k < len) {\n // a. Let elementK be the result of ? Get(O, ! ToString(k)).\n // b. If SameValueZero(valueToFind, elementK) is true, return true.\n if (sameValueZero(o[k], valueToFind)) {\n return true;\n }\n // c. Increase k by 1.\n k++;\n }\n\n // 8. Return false\n return false;\n }\n });\n}\n","/*!\n * PatternFly Elements: PfeBand 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\n// Import polyfills: matches, closest, includes\nimport \"./polyfills--pfe-band.js\";\n\nimport PFElement from \"../../pfelement/dist/pfelement.js\";\n\nclass PfeBand extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
    this.has_slot(`pfe-band--${slot}`) ? `pfe-has-${slot}` : \"\").join(\" \")}>\n ${this.has_slot(\"pfe-band--aside\") && this.asidePosition.mobile === \"top\" ? `` : \"\"}\n ${this.has_slot(\"pfe-band--header\") ? `
    ` : \"\"}\n
    \n ${this.has_slot(\"pfe-band--aside\") && this.asidePosition.mobile !== \"top\" ? `` : \"\"}\n ${this.has_slot(\"pfe-band--footer\") ? `
    ` : \"\"}\n
    `;\n }\n\n static get properties() {\n return {\"color\":{\"title\":\"Background color\",\"type\":\"string\",\"enum\":[\"lightest\",\"base\",\"darker\",\"darkest\",\"complement\",\"accent\"],\"default\":\"base\",\"prefixed\":true,\"observer\":\"_colorChanged\"},\"img-src\":{\"title\":\"Background image\",\"type\":\"string\",\"prefixed\":true,\"observer\":\"_imgSrcChanged\"},\"aside-desktop\":{\"title\":\"Aside positioning (desktop)\",\"type\":\"string\",\"default\":\"right\",\"enum\":[\"right\",\"left\"],\"prefixed\":true,\"observer\":\"_basicAttributeChanged\",\"options\":{\"dependencies\":[{\"type\":\"slot\",\"id\":\"aside\"}]}},\"aside-mobile\":{\"title\":\"Aside positioning (mobile)\",\"type\":\"string\",\"default\":\"bottom\",\"enum\":[\"top\",\"bottom\"],\"prefixed\":true,\"observer\":\"_basicAttributeChanged\",\"options\":{\"dependencies\":[{\"type\":\"slot\",\"id\":\"aside\"}]}},\"aside-height\":{\"title\":\"Aside height\",\"type\":\"string\",\"default\":\"body\",\"enum\":[\"full\",\"body\"],\"prefixed\":true,\"observer\":\"_basicAttributeChanged\",\"options\":{\"dependencies\":[{\"type\":\"slot\",\"id\":\"aside\"}]}}};\n }\n\n static get slots() {\n return {\"header\":{\"title\":\"Header\",\"type\":\"array\",\"namedSlot\":true,\"maxItems\":3,\"items\":{\"title\":\"Body item\",\"oneOf\":[{\"$ref\":\"raw\"}]}},\"body\":{\"title\":\"Body\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-card\"},{\"$ref\":\"raw\"}]}},\"footer\":{\"title\":\"Footer\",\"type\":\"array\",\"namedSlot\":true,\"maxItems\":3,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-cta\"},{\"$ref\":\"raw\"}]}},\"aside\":{\"title\":\"Aside\",\"type\":\"array\",\"namedSlot\":true,\"maxItems\":5,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-card\"},{\"$ref\":\"raw\"}]}}};\n }\n static get tag() {\n return \"pfe-band\";\n }\n\n get schemaUrl() {\n return \"pfe-band.json\";\n }\n\n get templateUrl() {\n return \"pfe-band.html\";\n }\n\n get styleUrl() {\n return \"pfe-band.scss\";\n }\n\n get imageSrc() {\n return this.getAttribute(\"pfe-img-src\");\n }\n\n get backgroundColor() {\n return this.getAttribute(\"pfe-color\");\n }\n\n get asidePosition() {\n return {\n desktop: this.getAttribute(\"pfe-aside-desktop\"),\n mobile: this.getAttribute(\"pfe-aside-mobile\"),\n height: this.getAttribute(\"pfe-aside-height\")\n };\n }\n\n static get observedAttributes() {\n return [\n \"pfe-aside-desktop\",\n \"pfe-aside-mobile\",\n \"pfe-aside-height\",\n \"pfe-color\",\n \"pfe-img-src\"\n ];\n }\n\n static get cascadingAttributes() {\n return {\n \"pfe-aside-desktop\": \".pfe-band__container\",\n \"pfe-aside-mobile\": \".pfe-band__container\",\n \"pfe-aside-height\": \".pfe-band__container\"\n };\n }\n\n // Declare the type of this component\n static get PfeType() {\n return PFElement.PfeTypes.Container;\n }\n\n constructor() {\n super(PfeBand, { type: PfeBand.PfeType });\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n // Initialize the background image attachment\n if (this.imageSrc) {\n this._imgSrcChanged(\"pfe-img-src\", \"\", this.imageSrc);\n }\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n super.attributeChangedCallback(attr, oldValue, newValue);\n // Strip the prefix form the attribute\n attr = attr.replace(\"pfe-\", \"\");\n // If the observer is defined in the attribute properties\n if (this[attr] && this[attr].observer) {\n // Get the observer function\n let observer = this[this[attr].observer].bind(this);\n // If it's a function, allow it to run\n if (typeof observer === \"function\") observer(attr, oldValue, newValue);\n }\n }\n\n _basicAttributeChanged(attr, oldValue, newValue) {\n this[attr].value = newValue;\n }\n\n // Update the color attribute and contexts\n _colorChanged(attr, oldValue, newValue) {\n this[attr].value = newValue;\n // Trigger an update in nested components\n this.context_update();\n }\n\n // Update the background image\n _imgSrcChanged(attr, oldValue, newValue) {\n // Set the image as the background image\n this.style.backgroundImage = newValue ? `url('${newValue}')` : ``;\n }\n}\n\nPFElement.create(PfeBand);\n\nexport { PfeBand as default };\n"],"names":[],"mappings":";;AAAA;;AAEA,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE;EAC9B,OAAO,CAAC,SAAS,CAAC,OAAO;IACvB,OAAO,CAAC,SAAS,CAAC,iBAAiB;IACnC,OAAO,CAAC,SAAS,CAAC,qBAAqB,CAAC;CAC3C;;;;AAID,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE;EAC9B,OAAO,CAAC,SAAS,CAAC,OAAO,GAAG,SAAS,CAAC,EAAE;IACtC,IAAI,EAAE,GAAG,IAAI,CAAC;IACd,GAAG;MACD,IAAI,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;MAC7B,EAAE,GAAG,EAAE,CAAC,aAAa,IAAI,EAAE,CAAC,UAAU,CAAC;KACxC,QAAQ,EAAE,KAAK,IAAI,IAAI,EAAE,CAAC,QAAQ,KAAK,CAAC,EAAE;IAC3C,OAAO,IAAI,CAAC;GACb,CAAC;CACH;;;;AAID,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,EAAE;EAC7B,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,SAAS,EAAE,UAAU,EAAE;IACjD,KAAK,EAAE,SAAS,WAAW,EAAE,SAAS,E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AAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE;IACtC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,GAAG,QAAQ,CAAC;;IAE5B,IAAI,CAAC,cAAc,EAAE,CAAC;GACvB;;;EAGD,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE;;IAEvC,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,QAAQ,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;GACnE;CACF;;AAED,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;;;;"} \ No newline at end of file diff --git a/elements/pfe-band/dist/pfe-band.json b/elements/pfe-band/dist/pfe-band.json new file mode 100644 index 0000000000..b20d749abc --- /dev/null +++ b/elements/pfe-band/dist/pfe-band.json @@ -0,0 +1,156 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Band", + "description": "This element creates a header, body, footer, and aside region in which to place content or other components.", + "type": "object", + "tag": "pfe-band", + "class": "pfe-band", + "category": "container", + "properties": { + "slots": { + "title": "Slots", + "description": "Definition of the supported slots", + "type": "object", + "properties": { + "header": { + "title": "Header", + "type": "array", + "namedSlot": true, + "maxItems": 3, + "items": { + "title": "Body item", + "oneOf": [ + { + "$ref": "raw" + } + ] + } + }, + "body": { + "title": "Body", + "type": "array", + "namedSlot": false, + "items": { + "oneOf": [ + { + "$ref": "pfe-card" + }, + { + "$ref": "raw" + } + ] + } + }, + "footer": { + "title": "Footer", + "type": "array", + "namedSlot": true, + "maxItems": 3, + "items": { + "oneOf": [ + { + "$ref": "pfe-cta" + }, + { + "$ref": "raw" + } + ] + } + }, + "aside": { + "title": "Aside", + "type": "array", + "namedSlot": true, + "maxItems": 5, + "items": { + "oneOf": [ + { + "$ref": "pfe-card" + }, + { + "$ref": "raw" + } + ] + } + } + } + }, + "attributes": { + "title": "Attributes", + "type": "object", + "properties": { + "color": { + "title": "Background color", + "type": "string", + "enum": [ + "lightest", + "base", + "darker", + "darkest", + "complement", + "accent" + ], + "default": "base", + "prefixed": true, + "observer": "_colorChanged" + }, + "img-src": { + "title": "Background image", + "type": "string", + "prefixed": true, + "observer": "_imgSrcChanged" + }, + "aside-desktop": { + "title": "Aside positioning (desktop)", + "type": "string", + "default": "right", + "enum": ["right", "left"], + "prefixed": true, + "observer": "_basicAttributeChanged", + "options": { + "dependencies": [ + { + "type": "slot", + "id": "aside" + } + ] + } + }, + "aside-mobile": { + "title": "Aside positioning (mobile)", + "type": "string", + "default": "bottom", + "enum": ["top", "bottom"], + "prefixed": true, + "observer": "_basicAttributeChanged", + "options": { + "dependencies": [ + { + "type": "slot", + "id": "aside" + } + ] + } + }, + "aside-height": { + "title": "Aside height", + "type": "string", + "default": "body", + "enum": ["full", "body"], + "prefixed": true, + "observer": "_basicAttributeChanged", + "options": { + "dependencies": [ + { + "type": "slot", + "id": "aside" + } + ] + } + } + } + } + }, + "required": ["slots", "attributes"], + "additionalProperties": false +} diff --git a/elements/pfe-band/dist/pfe-band.min.js b/elements/pfe-band/dist/pfe-band.min.js new file mode 100644 index 0000000000..2789198adb --- /dev/null +++ b/elements/pfe-band/dist/pfe-band.min.js @@ -0,0 +1,26 @@ +import e from"../../pfelement/dist/pfelement.min.js";Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){var a=this;do{if(a.matches(e))return a;a=a.parentElement||a.parentNode}while(null!==a&&1===a.nodeType);return null}),Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{value:function(e,a){if(null==this)throw new TypeError('"this" is null or not defined');var r=Object(this),d=r.length>>>0;if(0===d)return!1;var o,t,i=0|a,n=Math.max(i>=0?i:d-Math.abs(i),0);for(;n@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host([pfe-color=accent]),:host([pfe-color=base]),:host([pfe-color=complement]),:host([pfe-color=darker]),:host([pfe-color=darkest]),:host([pfe-color=lightest]){background-color:#fff!important;color:#151515!important}}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host{color:#151515!important}}:host{--theme:var(--pfe-band--theme, light);display:block;position:relative;padding:calc(calc(16px * 4)/ 2) calc(16px * 1);padding:calc(var(--pfe-band--Padding--vertical,calc(var(--pfe-theme--container-spacer,16px) * 4))/ 2) var(--pfe-band--Padding--horizontal,calc(var(--pfe-theme--container-spacer,16px) * 1));border:1px solid transparent;border:var(--pfe-band--Border,var(--pfe-theme--surface--border-width,1px) var(--pfe-theme--surface--border-style,solid) transparent);background-color:#f0f0f0;background-color:var(--pfe-band--BackgroundColor,var(--pfe-theme--color--surface--base,#f0f0f0));background-position:center center;background-position:var(--pfe-band--BackgroundPosition,center center);color:#3c3f42;color:var(--pfe-broadcasted--text,#3c3f42)}@media screen and (min-width:768px){:host{--pfe-band--Width:calc( 768px - calc(var(--pfe-band--Padding--horizontal, calc( var(--pfe-theme--container-spacer, 16px) * 1)) * 4))}}@media screen and (min-width:992px){:host{--pfe-band--Width:calc( 992px - calc(var(--pfe-band--Padding--horizontal, calc( var(--pfe-theme--container-spacer, 16px) * 1)) * 4))}}@media screen and (min-width:1200px){:host{--pfe-band--Width:calc( 1200px - calc(var(--pfe-band--Padding--horizontal, calc( var(--pfe-theme--container-spacer, 16px) * 1)) * 4))}}@media (min-width:576px){:host{padding:calc(16px * 4) calc(16px * 1);padding:var(--pfe-band--Padding,var(--pfe-band--Padding--vertical,calc(var(--pfe-theme--container-spacer,16px) * 4)) var(--pfe-band--Padding--horizontal,calc(var(--pfe-theme--container-spacer,16px) * 1)))}}@media print{:host{background-color:#fff!important;background-image:none!important;-webkit-box-shadow:none!important;box-shadow:none!important}}@media print{:host{border-radius:3px;border:1px solid #d2d2d2;padding:calc(16px * 4)/2 calc(16px * 1);padding:calc(var(--pfe-theme--container-spacer,16px) * 4)/2 calc(var(--pfe-theme--container-spacer,16px) * 1)}}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host{background-color:#fff!important;color:#151515!important;background-image:none!important;padding:16px}}:host *,:host ::after,:host ::before{-webkit-box-sizing:border-box;box-sizing:border-box}:host([on=dark]){--pfe-broadcasted--text:var(--pfe-theme--color--text--on-dark, #fff);--pfe-broadcasted--link:var(--pfe-theme--color--link--on-dark, #73bcf7);--pfe-broadcasted--link--hover:var(--pfe-theme--color--link--hover--on-dark, #bee1f4);--pfe-broadcasted--link--focus:var(--pfe-theme--color--link--focus--on-dark, #bee1f4);--pfe-broadcasted--link--visited:var(--pfe-theme--color--link--visited--on-dark, #bee1f4);--pfe-broadcasted--link-decoration:var(--pfe-theme--link-decoration--on-dark, none);--pfe-broadcasted--link-decoration--hover:var(--pfe-theme--link-decoration--hover--on-dark, underline);--pfe-broadcasted--link-decoration--focus:var(--pfe-theme--link-decoration--focus--on-dark, underline);--pfe-broadcasted--link-decoration--visited:var(--pfe-theme--link-decoration--visited--on-dark, none)}:host([on=saturated]){--pfe-broadcasted--text:var(--pfe-theme--color--text--on-saturated, #fff);--pfe-broadcasted--link:var(--pfe-theme--color--link--on-saturated, #fff);--pfe-broadcasted--link--hover:var(--pfe-theme--color--link--hover--on-saturated, #fafafa);--pfe-broadcasted--link--focus:var(--pfe-theme--color--link--focus--on-saturated, #fafafa);--pfe-broadcasted--link--visited:var(--pfe-theme--color--link--visited--on-saturated, #8476d1);--pfe-broadcasted--link-decoration:var(--pfe-theme--link-decoration--on-saturated, underline);--pfe-broadcasted--link-decoration--hover:var(--pfe-theme--link-decoration--hover--on-saturated, underline);--pfe-broadcasted--link-decoration--focus:var(--pfe-theme--link-decoration--focus--on-saturated, underline);--pfe-broadcasted--link-decoration--visited:var(--pfe-theme--link-decoration--visited--on-saturated, underline)}:host([on=light]){--pfe-broadcasted--text:var(--pfe-theme--color--text, #151515);--pfe-broadcasted--link:var(--pfe-theme--color--link, #06c);--pfe-broadcasted--link--hover:var(--pfe-theme--color--link--hover, #004080);--pfe-broadcasted--link--focus:var(--pfe-theme--color--link--focus, #004080);--pfe-broadcasted--link--visited:var(--pfe-theme--color--link--visited, #6753ac);--pfe-broadcasted--link-decoration:var(--pfe-theme--link-decoration, none);--pfe-broadcasted--link-decoration--hover:var(--pfe-theme--link-decoration--hover, underline);--pfe-broadcasted--link-decoration--focus:var(--pfe-theme--link-decoration--focus, underline);--pfe-broadcasted--link-decoration--visited:var(--pfe-theme--link-decoration--visited, none)}:host([pfe-color=darker]){--pfe-band--BackgroundColor:var(--pfe-theme--color--surface--darker, #3c3f42);--pfe-band--theme:var(--pfe-theme--color--surface--darker--theme, dark)}:host([pfe-color=darkest]){--pfe-band--BackgroundColor:var(--pfe-theme--color--surface--darkest, #151515);--pfe-band--theme:var(--pfe-theme--color--surface--darkest--theme, dark)}:host([pfe-color=base]){--pfe-band--BackgroundColor:var(--pfe-theme--color--surface--base, #f0f0f0);--pfe-band--theme:var(--pfe-theme--color--surface--base--theme, light)}:host([pfe-color=lightest]){--pfe-band--BackgroundColor:var(--pfe-theme--color--surface--lightest, #fff);--pfe-band--theme:var(--pfe-theme--color--surface--lightest--theme, light)}:host([pfe-color=accent]){--pfe-band--BackgroundColor:var(--pfe-theme--color--surface--accent, #004080);--pfe-band--theme:var(--pfe-theme--color--surface--accent--theme, saturated)}:host([pfe-color=complement]){--pfe-band--BackgroundColor:var(--pfe-theme--color--surface--complement, #002952);--pfe-band--theme:var(--pfe-theme--color--surface--complement--theme, saturated)}:host([pfe-size=small]){--pfe-band--Padding:calc(var(--pfe-band--Padding--vertical, calc( var(--pfe-theme--container-spacer, 16px) * 4)) / 4) var(--pfe-band--Padding--horizontal, calc( var(--pfe-theme--container-spacer, 16px) * 1))}.pfe-band__container{--pfe-band__region--width:calc(1fr - var(--pfe-band--Width__aside--sm, 240px) - var(--pfe-band--gutter--horizontal, calc(var(--pfe-theme--container-spacer, 16px) * 3)));grid-template-areas:"body";position:relative;margin:0 auto;width:100%;max-width:auto;max-width:var(--pfe-band--Width,auto)}.pfe-band__container[pfe-has-aside]{grid-template-areas:"body" "aside"}@media (min-width:768px){.pfe-band__container[pfe-has-aside]{--pfe-band--layout:1fr var(--pfe-band--Width__aside--sm, 240px)}}@media (min-width:992px){.pfe-band__container[pfe-has-aside]{--pfe-band--layout:1fr var(--pfe-band--Width__aside--lg, 300px)}}.pfe-band__container[pfe-has-aside][pfe-aside-mobile=top]{grid-template-areas:"aside" "body"}@media (min-width:768px){.pfe-band__container[pfe-has-aside][pfe-aside-desktop=left]{grid-template-areas:"aside body";--pfe-band--layout:var(--pfe-band--Width__aside--sm, 240px) 1fr}.pfe-band__container[pfe-has-aside][pfe-aside-desktop=left]>.pfe-band__body{-ms-grid-row:1;-ms-grid-column:2}.pfe-band__container[pfe-has-aside][pfe-aside-desktop=left]>.pfe-band__aside{-ms-grid-row:1;-ms-grid-column:1}}@media (min-width:992px){.pfe-band__container[pfe-has-aside][pfe-aside-desktop=left]{--pfe-band--layout:var(--pfe-band--Width__aside--lg, 300px) 1fr}}.pfe-band__container[pfe-has-header]{grid-template-areas:"header" "body"}.pfe-band__container[pfe-has-header][pfe-has-aside]{grid-template-areas:"header" "body" "aside"}@media (min-width:768px){.pfe-band__container[pfe-has-header][pfe-has-aside]{grid-template-areas:"header header" "body aside"}.pfe-band__container[pfe-has-header][pfe-has-aside]>.pfe-band__header{-ms-grid-row:1;-ms-grid-column:1;-ms-grid-column-span:2}.pfe-band__container[pfe-has-header][pfe-has-aside]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-has-aside]>.pfe-band__aside{-ms-grid-row:2;-ms-grid-column:2}}.pfe-band__container[pfe-has-header][pfe-aside-mobile=top]{grid-template-areas:"aside" "header" "body"}@media (min-width:768px){.pfe-band__container[pfe-has-header][pfe-aside-height=full]{grid-template-areas:"header aside" "body aside"}.pfe-band__container[pfe-has-header][pfe-aside-height=full]>.pfe-band__header{-ms-grid-row:1;-ms-grid-column:1;-ms-grid-column-span:1}.pfe-band__container[pfe-has-header][pfe-aside-height=full]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-aside-height=full]>.pfe-band__aside{-ms-grid-row:1;-ms-grid-row-span:2;-ms-grid-column:2}}@media (min-width:768px){.pfe-band__container[pfe-has-header][pfe-aside-desktop=left]{grid-template-areas:"header header" "aside body"}.pfe-band__container[pfe-has-header][pfe-aside-desktop=left]>.pfe-band__header{-ms-grid-row:1;-ms-grid-column:1;-ms-grid-column-span:2}.pfe-band__container[pfe-has-header][pfe-aside-desktop=left]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:2}.pfe-band__container[pfe-has-header][pfe-aside-desktop=left]>.pfe-band__aside{-ms-grid-row:2;-ms-grid-row-span:1;-ms-grid-column:1}}@media (min-width:768px){.pfe-band__container[pfe-has-header][pfe-aside-desktop=left][pfe-aside-height=full]{grid-template-areas:"aside header" "aside body"}.pfe-band__container[pfe-has-header][pfe-aside-desktop=left][pfe-aside-height=full]>.pfe-band__header{-ms-grid-row:1;-ms-grid-column:2;-ms-grid-column-span:1}.pfe-band__container[pfe-has-header][pfe-aside-desktop=left][pfe-aside-height=full]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:2}.pfe-band__container[pfe-has-header][pfe-aside-desktop=left][pfe-aside-height=full]>.pfe-band__aside{-ms-grid-row:1;-ms-grid-row-span:2;-ms-grid-column:1}}.pfe-band__container[pfe-has-footer]{grid-template-areas:"body" "footer"}.pfe-band__container[pfe-has-footer][pfe-has-aside]{grid-template-areas:"body" "aside" "footer"}@media (min-width:768px){.pfe-band__container[pfe-has-footer][pfe-has-aside]{grid-template-areas:"body aside" "footer footer"}.pfe-band__container[pfe-has-footer][pfe-has-aside]>.pfe-band__body{-ms-grid-row:1;-ms-grid-column:1}.pfe-band__container[pfe-has-footer][pfe-has-aside]>.pfe-band__aside{-ms-grid-row:1;-ms-grid-row-span:1;-ms-grid-column:2}.pfe-band__container[pfe-has-footer][pfe-has-aside]>.pfe-band__footer{-ms-grid-row:2;-ms-grid-column:1;-ms-grid-column-span:2}}.pfe-band__container[pfe-has-footer][pfe-aside-mobile=top]{grid-template-areas:"aside" "body" "footer"}@media (min-width:768px){.pfe-band__container[pfe-has-footer][pfe-aside-height=full]{grid-template-areas:"body aside" "footer aside"}.pfe-band__container[pfe-has-footer][pfe-aside-height=full]>.pfe-band__body{-ms-grid-row:1;-ms-grid-column:1}.pfe-band__container[pfe-has-footer][pfe-aside-height=full]>.pfe-band__aside{-ms-grid-row:1;-ms-grid-row-span:2;-ms-grid-column:2}.pfe-band__container[pfe-has-footer][pfe-aside-height=full]>.pfe-band__footer{-ms-grid-row:2;-ms-grid-column:1;-ms-grid-column-span:1}}@media (min-width:768px){.pfe-band__container[pfe-has-footer][pfe-aside-desktop=left]{grid-template-areas:"aside body" "footer footer"}.pfe-band__container[pfe-has-footer][pfe-aside-desktop=left]>.pfe-band__body{-ms-grid-row:1;-ms-grid-column:2}.pfe-band__container[pfe-has-footer][pfe-aside-desktop=left]>.pfe-band__aside{-ms-grid-row:1;-ms-grid-row-span:1;-ms-grid-column:1}.pfe-band__container[pfe-has-footer][pfe-aside-desktop=left]>.pfe-band__footer{-ms-grid-row:2;-ms-grid-column:1;-ms-grid-column-span:2}}@media (min-width:768px){.pfe-band__container[pfe-has-footer][pfe-aside-desktop=left][pfe-aside-height=full]{grid-template-areas:"aside body" "aside footer"}.pfe-band__container[pfe-has-footer][pfe-aside-desktop=left][pfe-aside-height=full]>.pfe-band__body{-ms-grid-row:1;-ms-grid-column:2}.pfe-band__container[pfe-has-footer][pfe-aside-desktop=left][pfe-aside-height=full]>.pfe-band__aside{-ms-grid-row:1;-ms-grid-row-span:2;-ms-grid-column:1}.pfe-band__container[pfe-has-footer][pfe-aside-desktop=left][pfe-aside-height=full]>.pfe-band__footer{-ms-grid-row:2;-ms-grid-column:2;-ms-grid-column-span:1}}.pfe-band__container[pfe-has-header][pfe-has-footer]{grid-template-areas:"header" "body" "footer"}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-has-aside]{grid-template-areas:"header" "body" "footer" "aside"}@media (min-width:768px){.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-has-aside]{grid-template-areas:"header header" "body aside" "footer footer"}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-has-aside]>.pfe-band__header{-ms-grid-row:1;-ms-grid-column:1;-ms-grid-column-span:2}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-has-aside]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-has-aside]>.pfe-band__aside{-ms-grid-row:2;-ms-grid-row-span:1;-ms-grid-column:2}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-has-aside]>.pfe-band__footer{-ms-grid-row:3;-ms-grid-column:1;-ms-grid-column-span:2}}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-mobile=top]{grid-template-areas:"aside" "header" "body" "footer"}@media (min-width:768px){.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-height=full]{grid-template-areas:"header aside" "body aside" "footer aside"}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-height=full]>.pfe-band__header{-ms-grid-row:1;-ms-grid-column:1;-ms-grid-column-span:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-height=full]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-height=full]>.pfe-band__aside{-ms-grid-row:1;-ms-grid-row-span:3;-ms-grid-column:2}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-height=full]>.pfe-band__footer{-ms-grid-row:3;-ms-grid-column:1;-ms-grid-column-span:1}}@media (min-width:768px){.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-desktop=left]{grid-template-areas:"header header" "aside body" "footer footer"}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-desktop=left]>.pfe-band__header{-ms-grid-row:1;-ms-grid-column:1;-ms-grid-column-span:2}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-desktop=left]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:2}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-desktop=left]>.pfe-band__aside{-ms-grid-row:2;-ms-grid-row-span:1;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-desktop=left]>.pfe-band__footer{-ms-grid-row:3;-ms-grid-column:1;-ms-grid-column-span:2}}@media (min-width:768px){.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-desktop=left][pfe-aside-height=full]{grid-template-areas:"aside header" "aside body" "aside footer"}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-desktop=left][pfe-aside-height=full]>.pfe-band__header{-ms-grid-row:1;-ms-grid-column:2;-ms-grid-column-span:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-desktop=left][pfe-aside-height=full]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:2}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-desktop=left][pfe-aside-height=full]>.pfe-band__aside{-ms-grid-row:1;-ms-grid-row-span:3;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-desktop=left][pfe-aside-height=full]>.pfe-band__footer{-ms-grid-row:3;-ms-grid-column:2;-ms-grid-column-span:1}}@supports (display:grid){.pfe-band__container{display:-ms-grid;display:grid;grid-row-gap:16px;grid-row-gap:var(--pfe-band--gutter--vertical,var(--pfe-theme--container-spacer,16px));grid-column-gap:calc(16px * 3);grid-column-gap:var(--pfe-band--gutter--horizontal,calc(var(--pfe-theme--container-spacer,16px) * 3));margin-bottom:0;-ms-grid-columns:1fr;grid-template-columns:1fr;-ms-grid-columns:var(--pfe-band--layout,1fr);grid-template-columns:var(--pfe-band--layout,1fr);-ms-grid-rows:-webkit-max-content;-ms-grid-rows:max-content;grid-template-rows:-webkit-max-content;grid-template-rows:max-content}.pfe-band__container>:nth-child(1){-ms-grid-row:1;-ms-grid-column:1}.pfe-band__container>:nth-child(1){-ms-grid-row:1;-ms-grid-column:1}}.pfe-band__header{margin-bottom:16px;margin-bottom:var(--pfe-band--gutter--vertical,var(--pfe-theme--container-spacer,16px))}@supports (display:grid){.pfe-band__header{-ms-grid-row:1;-ms-grid-column:1;display:-ms-grid;display:grid;grid-row-gap:16px;grid-row-gap:var(--pfe-band--gutter--vertical,var(--pfe-theme--container-spacer,16px));grid-column-gap:calc(16px * 3);grid-column-gap:var(--pfe-band--gutter--horizontal,calc(var(--pfe-theme--container-spacer,16px) * 3));margin-bottom:0;grid-area:header;-ms-grid-columns:1fr;grid-template-columns:1fr;-ms-grid-columns:var(--pfe-band__header--layout,1fr);grid-template-columns:var(--pfe-band__header--layout,1fr)}.pfe-band__container[pfe-has-header][pfe-has-aside]>.pfe-band__header{-ms-grid-row:1;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-aside-mobile=top]>.pfe-band__header{-ms-grid-row:2;-ms-grid-column:1;-ms-grid-column-span:1}.pfe-band__container[pfe-has-header][pfe-has-footer]>.pfe-band__header{-ms-grid-row:1;-ms-grid-column:1;-ms-grid-column-span:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-has-aside]>.pfe-band__header{-ms-grid-row:1;-ms-grid-column:1;-ms-grid-column-span:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-mobile=top]>.pfe-band__header{-ms-grid-row:2;-ms-grid-column:1;-ms-grid-column-span:1}}.pfe-band__body{margin-bottom:16px;margin-bottom:var(--pfe-band--gutter--vertical,var(--pfe-theme--container-spacer,16px))}@supports (display:grid){.pfe-band__body{-ms-grid-row:1;-ms-grid-column:1;display:-ms-grid;display:grid;grid-row-gap:16px;grid-row-gap:var(--pfe-band--gutter--vertical,var(--pfe-theme--container-spacer,16px));grid-column-gap:calc(16px * 3);grid-column-gap:var(--pfe-band--gutter--horizontal,calc(var(--pfe-theme--container-spacer,16px) * 3));margin-bottom:0;grid-area:body;-ms-grid-columns:1fr;grid-template-columns:1fr;-ms-grid-columns:var(--pfe-band__body--layout,1fr);grid-template-columns:var(--pfe-band__body--layout,1fr)}.pfe-band__container[pfe-has-aside]>.pfe-band__body{-ms-grid-row:1;-ms-grid-column:1}.pfe-band__container[pfe-has-aside][pfe-aside-mobile=top]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:1}.pfe-band__container[pfe-has-header]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-has-aside]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-aside-mobile=top]>.pfe-band__body{-ms-grid-row:3;-ms-grid-column:1}.pfe-band__container[pfe-has-footer]>.pfe-band__body{-ms-grid-row:1;-ms-grid-column:1}.pfe-band__container[pfe-has-footer][pfe-has-aside]>.pfe-band__body{-ms-grid-row:1;-ms-grid-column:1}.pfe-band__container[pfe-has-footer][pfe-aside-mobile=top]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-has-footer]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-has-aside]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-mobile=top]>.pfe-band__body{-ms-grid-row:3;-ms-grid-column:1}}.pfe-band__aside{margin-bottom:16px;margin-bottom:var(--pfe-band--gutter--vertical,var(--pfe-theme--container-spacer,16px))}@supports (display:grid){.pfe-band__aside{-ms-grid-row:2;-ms-grid-column:1;display:-ms-grid;display:grid;grid-row-gap:16px;grid-row-gap:var(--pfe-band--gutter--vertical,var(--pfe-theme--container-spacer,16px));grid-column-gap:calc(16px * 3);grid-column-gap:var(--pfe-band--gutter--horizontal,calc(var(--pfe-theme--container-spacer,16px) * 3));margin-bottom:0;grid-area:aside;-ms-grid-columns:1fr;grid-template-columns:1fr;-ms-grid-columns:var(--pfe-band__aside--layout,1fr);grid-template-columns:var(--pfe-band__aside--layout,1fr)}.pfe-band__container[pfe-has-aside][pfe-aside-mobile=top]>.pfe-band__aside{-ms-grid-row:1;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-has-aside]>.pfe-band__aside{-ms-grid-row:3;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-aside-mobile=top]>.pfe-band__aside{-ms-grid-row:1;-ms-grid-column:1}.pfe-band__container[pfe-has-footer][pfe-has-aside]>.pfe-band__aside{-ms-grid-row:2;-ms-grid-row-span:1;-ms-grid-column:1}.pfe-band__container[pfe-has-footer][pfe-aside-mobile=top]>.pfe-band__aside{-ms-grid-row:1;-ms-grid-row-span:1;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-has-aside]>.pfe-band__aside{-ms-grid-row:4;-ms-grid-row-span:1;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-mobile=top]>.pfe-band__aside{-ms-grid-row:1;-ms-grid-row-span:1;-ms-grid-column:1}}.pfe-band__footer{margin-bottom:16px;margin-bottom:var(--pfe-band--gutter--vertical,var(--pfe-theme--container-spacer,16px))}@supports (display:grid){.pfe-band__footer{-ms-grid-row:2;-ms-grid-column:1;display:-ms-grid;display:grid;grid-row-gap:16px;grid-row-gap:var(--pfe-band--gutter--vertical,var(--pfe-theme--container-spacer,16px));grid-column-gap:calc(16px * 3);grid-column-gap:var(--pfe-band--gutter--horizontal,calc(var(--pfe-theme--container-spacer,16px) * 3));margin-bottom:0;grid-area:footer;-ms-grid-columns:1fr;grid-template-columns:1fr;-ms-grid-columns:var(--pfe-band__footer--layout,1fr);grid-template-columns:var(--pfe-band__footer--layout,1fr)}.pfe-band__container[pfe-has-footer][pfe-has-aside]>.pfe-band__footer{-ms-grid-row:3;-ms-grid-column:1}.pfe-band__container[pfe-has-footer][pfe-aside-mobile=top]>.pfe-band__footer{-ms-grid-row:3;-ms-grid-column:1;-ms-grid-column-span:1}.pfe-band__container[pfe-has-header][pfe-has-footer]>.pfe-band__footer{-ms-grid-row:3;-ms-grid-column:1;-ms-grid-column-span:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-has-aside]>.pfe-band__footer{-ms-grid-row:3;-ms-grid-column:1;-ms-grid-column-span:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-mobile=top]>.pfe-band__footer{-ms-grid-row:4;-ms-grid-column:1;-ms-grid-column-span:1}}.pfe-band__aside{-webkit-align-self:flex-start;-ms-flex-item-align:start;align-self:flex-start}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){.pfe-band__body{width:60%;float:left}.pfe-band__aside{float:left;width:35%;margin:0 2.5%}.pfe-band__footer{clear:both}.pfe-band__container::after{content:" ";display:block;clear:both}}\n/*# sourceMappingURL=pfe-band.min.css.map */\n
    this.has_slot(`pfe-band--${e}`)?`pfe-has-${e}`:"").join(" ")}>\n ${this.has_slot("pfe-band--aside")&&"top"===this.asidePosition.mobile?'':""}\n ${this.has_slot("pfe-band--header")?'
    ':""}\n
    \n ${this.has_slot("pfe-band--aside")&&"top"!==this.asidePosition.mobile?'':""}\n ${this.has_slot("pfe-band--footer")?'
    ':""}\n
    `}static get properties(){return{color:{title:"Background color",type:"string",enum:["lightest","base","darker","darkest","complement","accent"],default:"base",prefixed:!0,observer:"_colorChanged"},"img-src":{title:"Background image",type:"string",prefixed:!0,observer:"_imgSrcChanged"},"aside-desktop":{title:"Aside positioning (desktop)",type:"string",default:"right",enum:["right","left"],prefixed:!0,observer:"_basicAttributeChanged",options:{dependencies:[{type:"slot",id:"aside"}]}},"aside-mobile":{title:"Aside positioning (mobile)",type:"string",default:"bottom",enum:["top","bottom"],prefixed:!0,observer:"_basicAttributeChanged",options:{dependencies:[{type:"slot",id:"aside"}]}},"aside-height":{title:"Aside height",type:"string",default:"body",enum:["full","body"],prefixed:!0,observer:"_basicAttributeChanged",options:{dependencies:[{type:"slot",id:"aside"}]}}}}static get slots(){return{header:{title:"Header",type:"array",namedSlot:!0,maxItems:3,items:{title:"Body item",oneOf:[{$ref:"raw"}]}},body:{title:"Body",type:"array",namedSlot:!1,items:{oneOf:[{$ref:"pfe-card"},{$ref:"raw"}]}},footer:{title:"Footer",type:"array",namedSlot:!0,maxItems:3,items:{oneOf:[{$ref:"pfe-cta"},{$ref:"raw"}]}},aside:{title:"Aside",type:"array",namedSlot:!0,maxItems:5,items:{oneOf:[{$ref:"pfe-card"},{$ref:"raw"}]}}}}static get tag(){return"pfe-band"}get schemaUrl(){return"pfe-band.json"}get templateUrl(){return"pfe-band.html"}get styleUrl(){return"pfe-band.scss"}get imageSrc(){return this.getAttribute("pfe-img-src")}get backgroundColor(){return this.getAttribute("pfe-color")}get asidePosition(){return{desktop:this.getAttribute("pfe-aside-desktop"),mobile:this.getAttribute("pfe-aside-mobile"),height:this.getAttribute("pfe-aside-height")}}static get observedAttributes(){return["pfe-aside-desktop","pfe-aside-mobile","pfe-aside-height","pfe-color","pfe-img-src"]}static get cascadingAttributes(){return{"pfe-aside-desktop":".pfe-band__container","pfe-aside-mobile":".pfe-band__container","pfe-aside-height":".pfe-band__container"}}static get PfeType(){return e.PfeTypes.Container}constructor(){super(a,{type:a.PfeType})}connectedCallback(){super.connectedCallback(),this.imageSrc&&this._imgSrcChanged("pfe-img-src","",this.imageSrc)}attributeChangedCallback(e,a,r){if(super.attributeChangedCallback(e,a,r),this[e=e.replace("pfe-","")]&&this[e].observer){let d=this[this[e].observer].bind(this);"function"==typeof d&&d(e,a,r)}}_basicAttributeChanged(e,a,r){this[e].value=r}_colorChanged(e,a,r){this[e].value=r,this.context_update()}_imgSrcChanged(e,a,r){this.style.backgroundImage=r?`url('${r}')`:""}}e.create(a);export default a; +//# sourceMappingURL=pfe-band.min.js.map diff --git a/elements/pfe-band/dist/pfe-band.min.js.map b/elements/pfe-band/dist/pfe-band.min.js.map new file mode 100644 index 0000000000..f8c6884d5f --- /dev/null +++ b/elements/pfe-band/dist/pfe-band.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-band.min.js","sources":["../_temp/polyfills--pfe-band.js","../_temp/pfe-band.js"],"sourcesContent":["// @POLYFILL Element.matches\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/matches\nif (!Element.prototype.matches) {\n Element.prototype.matches =\n Element.prototype.msMatchesSelector ||\n Element.prototype.webkitMatchesSelector;\n}\n\n// @POLYFILL Element.closest\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/closest\nif (!Element.prototype.closest) {\n Element.prototype.closest = function(s) {\n var el = this;\n do {\n if (el.matches(s)) return el;\n el = el.parentElement || el.parentNode;\n } while (el !== null && el.nodeType === 1);\n return null;\n };\n}\n\n// @POLYFILL Array.includes\n// https://tc39.github.io/ecma262/#sec-array.prototype.includes\nif (!Array.prototype.includes) {\n Object.defineProperty(Array.prototype, \"includes\", {\n value: function(valueToFind, fromIndex) {\n if (this == null) {\n throw new TypeError('\"this\" is null or not defined');\n }\n\n // 1. Let O be ? ToObject(this value).\n var o = Object(this);\n\n // 2. Let len be ? ToLength(? Get(O, \"length\")).\n var len = o.length >>> 0;\n\n // 3. If len is 0, return false.\n if (len === 0) {\n return false;\n }\n\n // 4. Let n be ? ToInteger(fromIndex).\n // (If fromIndex is undefined, this step produces the value 0.)\n var n = fromIndex | 0;\n\n // 5. If n ≥ 0, then\n // a. Let k be n.\n // 6. Else n < 0,\n // a. Let k be len + n.\n // b. If k < 0, let k be 0.\n var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);\n\n function sameValueZero(x, y) {\n return (\n x === y ||\n (typeof x === \"number\" &&\n typeof y === \"number\" &&\n isNaN(x) &&\n isNaN(y))\n );\n }\n\n // 7. Repeat, while k < len\n while (k < len) {\n // a. Let elementK be the result of ? Get(O, ! ToString(k)).\n // b. If SameValueZero(valueToFind, elementK) is true, return true.\n if (sameValueZero(o[k], valueToFind)) {\n return true;\n }\n // c. Increase k by 1.\n k++;\n }\n\n // 8. Return false\n return false;\n }\n });\n}\n","/*!\n * PatternFly Elements: PfeBand 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\n// Import polyfills: matches, closest, includes\nimport \"./polyfills--pfe-band.js\";\n\nimport PFElement from \"../../pfelement/dist/pfelement.js\";\n\nclass PfeBand extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
    this.has_slot(`pfe-band--${slot}`) ? `pfe-has-${slot}` : \"\").join(\" \")}>\n ${this.has_slot(\"pfe-band--aside\") && this.asidePosition.mobile === \"top\" ? `` : \"\"}\n ${this.has_slot(\"pfe-band--header\") ? `
    ` : \"\"}\n
    \n ${this.has_slot(\"pfe-band--aside\") && this.asidePosition.mobile !== \"top\" ? `` : \"\"}\n ${this.has_slot(\"pfe-band--footer\") ? `
    ` : \"\"}\n
    `;\n }\n\n static get properties() {\n return {\"color\":{\"title\":\"Background color\",\"type\":\"string\",\"enum\":[\"lightest\",\"base\",\"darker\",\"darkest\",\"complement\",\"accent\"],\"default\":\"base\",\"prefixed\":true,\"observer\":\"_colorChanged\"},\"img-src\":{\"title\":\"Background image\",\"type\":\"string\",\"prefixed\":true,\"observer\":\"_imgSrcChanged\"},\"aside-desktop\":{\"title\":\"Aside positioning (desktop)\",\"type\":\"string\",\"default\":\"right\",\"enum\":[\"right\",\"left\"],\"prefixed\":true,\"observer\":\"_basicAttributeChanged\",\"options\":{\"dependencies\":[{\"type\":\"slot\",\"id\":\"aside\"}]}},\"aside-mobile\":{\"title\":\"Aside positioning (mobile)\",\"type\":\"string\",\"default\":\"bottom\",\"enum\":[\"top\",\"bottom\"],\"prefixed\":true,\"observer\":\"_basicAttributeChanged\",\"options\":{\"dependencies\":[{\"type\":\"slot\",\"id\":\"aside\"}]}},\"aside-height\":{\"title\":\"Aside height\",\"type\":\"string\",\"default\":\"body\",\"enum\":[\"full\",\"body\"],\"prefixed\":true,\"observer\":\"_basicAttributeChanged\",\"options\":{\"dependencies\":[{\"type\":\"slot\",\"id\":\"aside\"}]}}};\n }\n\n static get slots() {\n return {\"header\":{\"title\":\"Header\",\"type\":\"array\",\"namedSlot\":true,\"maxItems\":3,\"items\":{\"title\":\"Body item\",\"oneOf\":[{\"$ref\":\"raw\"}]}},\"body\":{\"title\":\"Body\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-card\"},{\"$ref\":\"raw\"}]}},\"footer\":{\"title\":\"Footer\",\"type\":\"array\",\"namedSlot\":true,\"maxItems\":3,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-cta\"},{\"$ref\":\"raw\"}]}},\"aside\":{\"title\":\"Aside\",\"type\":\"array\",\"namedSlot\":true,\"maxItems\":5,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-card\"},{\"$ref\":\"raw\"}]}}};\n }\n static get tag() {\n return \"pfe-band\";\n }\n\n get schemaUrl() {\n return \"pfe-band.json\";\n }\n\n get templateUrl() {\n return \"pfe-band.html\";\n }\n\n get styleUrl() {\n return \"pfe-band.scss\";\n }\n\n get imageSrc() {\n return this.getAttribute(\"pfe-img-src\");\n }\n\n get backgroundColor() {\n return this.getAttribute(\"pfe-color\");\n }\n\n get asidePosition() {\n return {\n desktop: this.getAttribute(\"pfe-aside-desktop\"),\n mobile: this.getAttribute(\"pfe-aside-mobile\"),\n height: this.getAttribute(\"pfe-aside-height\")\n };\n }\n\n static get observedAttributes() {\n return [\n \"pfe-aside-desktop\",\n \"pfe-aside-mobile\",\n \"pfe-aside-height\",\n \"pfe-color\",\n \"pfe-img-src\"\n ];\n }\n\n static get cascadingAttributes() {\n return {\n \"pfe-aside-desktop\": \".pfe-band__container\",\n \"pfe-aside-mobile\": \".pfe-band__container\",\n \"pfe-aside-height\": \".pfe-band__container\"\n };\n }\n\n // Declare the type of this component\n static get PfeType() {\n return PFElement.PfeTypes.Container;\n }\n\n constructor() {\n super(PfeBand, { type: PfeBand.PfeType });\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n // Initialize the background image attachment\n if (this.imageSrc) {\n this._imgSrcChanged(\"pfe-img-src\", \"\", this.imageSrc);\n }\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n super.attributeChangedCallback(attr, oldValue, newValue);\n // Strip the prefix form the attribute\n attr = attr.replace(\"pfe-\", \"\");\n // If the observer is defined in the attribute properties\n if (this[attr] && this[attr].observer) {\n // Get the observer function\n let observer = this[this[attr].observer].bind(this);\n // If it's a function, allow it to run\n if (typeof observer === \"function\") observer(attr, oldValue, newValue);\n }\n }\n\n _basicAttributeChanged(attr, oldValue, newValue) {\n this[attr].value = newValue;\n }\n\n // Update the color attribute and contexts\n _colorChanged(attr, oldValue, newValue) {\n this[attr].value = newValue;\n // Trigger an update in nested components\n this.context_update();\n }\n\n // Update the background image\n _imgSrcChanged(attr, oldValue, newValue) {\n // Set the image as the background image\n this.style.backgroundImage = newValue ? `url('${newValue}')` : ``;\n }\n}\n\nPFElement.create(PfeBand);\n\nexport { PfeBand as default };\n"],"names":["Element","prototype","matches","msMatchesSelector","webkitMatchesSelector","closest","s","el","this","parentElement","parentNode","nodeType","Array","includes","Object","defineProperty","value","valueToFind","fromIndex","TypeError","o","len","length","x","y","n","k","Math","max","abs","isNaN","PfeBand","PFElement","version","html","map","slot","has_slot","join","asidePosition","mobile","properties","color","title","type","enum","default","prefixed","observer","img-src","aside-desktop","options","dependencies","id","aside-mobile","aside-height","slots","header","namedSlot","maxItems","items","oneOf","$ref","body","footer","aside","tag","schemaUrl","templateUrl","styleUrl","imageSrc","getAttribute","backgroundColor","desktop","height","observedAttributes","cascadingAttributes","pfe-aside-desktop","pfe-aside-mobile","pfe-aside-height","PfeType","PfeTypes","Container","[object Object]","super","connectedCallback","_imgSrcChanged","attr","oldValue","newValue","attributeChangedCallback","replace","bind","context_update","style","backgroundImage","create"],"mappings":"qDAEKA,QAAQC,UAAUC,UACrBF,QAAQC,UAAUC,QAChBF,QAAQC,UAAUE,mBAClBH,QAAQC,UAAUG,uBAKjBJ,QAAQC,UAAUI,UACrBL,QAAQC,UAAUI,QAAU,SAASC,GACnC,IAAIC,EAAKC,KACT,EAAG,CACD,GAAID,EAAGL,QAAQI,GAAI,OAAOC,EAC1BA,EAAKA,EAAGE,eAAiBF,EAAGG,iBACd,OAAPH,GAA+B,IAAhBA,EAAGI,UAC3B,OAAO,OAMNC,MAAMX,UAAUY,UACnBC,OAAOC,eAAeH,MAAMX,UAAW,WAAY,CACjDe,MAAO,SAASC,EAAaC,GAC3B,GAAY,MAARV,KACF,MAAM,IAAIW,UAAU,iCAItB,IAAIC,EAAIN,OAAON,MAGXa,EAAMD,EAAEE,SAAW,EAGvB,GAAY,IAARD,EACF,OAAO,EAKT,IASuBE,EAAGC,EATtBC,EAAgB,EAAZP,EAOJQ,EAAIC,KAAKC,IAAIH,GAAK,EAAIA,EAAIJ,EAAMM,KAAKE,IAAIJ,GAAI,GAajD,KAAOC,EAAIL,GAAK,CAGd,IAdqBE,EAcHH,EA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GAAMvC,SAAU,CAErC,IAAIA,EAAWxC,KAAKA,KAAK+E,GAAMvC,UAAU4C,KAAKpF,MAEtB,mBAAbwC,GAAyBA,EAASuC,EAAMC,EAAUC,IAIjEN,uBAAuBI,EAAMC,EAAUC,GACrCjF,KAAK+E,GAAMvE,MAAQyE,EAIrBN,cAAcI,EAAMC,EAAUC,GAC5BjF,KAAK+E,GAAMvE,MAAQyE,EAEnBjF,KAAKqF,iBAIPV,eAAeI,EAAMC,EAAUC,GAE7BjF,KAAKsF,MAAMC,gBAAkBN,UAAmBA,MAAe,IAInEzD,EAAUgE,OAAOjE"} \ No newline at end of file diff --git a/elements/pfe-band/dist/pfe-band.umd.js b/elements/pfe-band/dist/pfe-band.umd.js new file mode 100644 index 0000000000..920d8734c2 --- /dev/null +++ b/elements/pfe-band/dist/pfe-band.umd.js @@ -0,0 +1,329 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../../pfelement/dist/pfelement.umd')) : + typeof define === 'function' && define.amd ? define(['../../pfelement/dist/pfelement.umd'], factory) : + (global.PfeBand = factory(global.PFElement)); +}(this, (function (PFElement) { 'use strict'; + + PFElement = PFElement && PFElement.hasOwnProperty('default') ? PFElement['default'] : PFElement; + + // @POLYFILL Element.matches + // https://developer.mozilla.org/en-US/docs/Web/API/Element/matches + if (!Element.prototype.matches) { + Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; + } + + // @POLYFILL Element.closest + // https://developer.mozilla.org/en-US/docs/Web/API/Element/closest + if (!Element.prototype.closest) { + Element.prototype.closest = function (s) { + var el = this; + do { + if (el.matches(s)) return el; + el = el.parentElement || el.parentNode; + } while (el !== null && el.nodeType === 1); + return null; + }; + } + + // @POLYFILL Array.includes + // https://tc39.github.io/ecma262/#sec-array.prototype.includes + if (!Array.prototype.includes) { + Object.defineProperty(Array.prototype, "includes", { + value: function value(valueToFind, fromIndex) { + if (this == null) { + throw new TypeError('"this" is null or not defined'); + } + + // 1. Let O be ? ToObject(this value). + var o = Object(this); + + // 2. Let len be ? ToLength(? Get(O, "length")). + var len = o.length >>> 0; + + // 3. If len is 0, return false. + if (len === 0) { + return false; + } + + // 4. Let n be ? ToInteger(fromIndex). + // (If fromIndex is undefined, this step produces the value 0.) + var n = fromIndex | 0; + + // 5. If n ≥ 0, then + // a. Let k be n. + // 6. Else n < 0, + // a. Let k be len + n. + // b. If k < 0, let k be 0. + var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0); + + function sameValueZero(x, y) { + return x === y || typeof x === "number" && typeof y === "number" && isNaN(x) && isNaN(y); + } + + // 7. Repeat, while k < len + while (k < len) { + // a. Let elementK be the result of ? Get(O, ! ToString(k)). + // b. If SameValueZero(valueToFind, elementK) is true, return true. + if (sameValueZero(o[k], valueToFind)) { + return true; + } + // c. Increase k by 1. + k++; + } + + // 8. Return false + return false; + } + }); + } + + var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + }; + + var createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + }(); + + var get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + + if (getter === undefined) { + return undefined; + } + + return getter.call(receiver); + } + }; + + var inherits = function (subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + }; + + var possibleConstructorReturn = function (self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && (typeof call === "object" || typeof call === "function") ? call : self; + }; + + /*! + * PatternFly Elements: PfeBand 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + + var PfeBand = function (_PFElement) { + inherits(PfeBand, _PFElement); + createClass(PfeBand, [{ + key: "html", + get: function get$$1() { + var _this2 = this; + + return "
    \n " + (this.has_slot("pfe-band--aside") && this.asidePosition.mobile === "top" ? "" : "") + "\n " + (this.has_slot("pfe-band--header") ? "
    " : "") + "\n
    \n " + (this.has_slot("pfe-band--aside") && this.asidePosition.mobile !== "top" ? "" : "") + "\n " + (this.has_slot("pfe-band--footer") ? "
    " : "") + "\n
    "; + } + }, { + key: "schemaUrl", + get: function get$$1() { + return "pfe-band.json"; + } + }, { + key: "templateUrl", + get: function get$$1() { + return "pfe-band.html"; + } + }, { + key: "styleUrl", + get: function get$$1() { + return "pfe-band.scss"; + } + }, { + key: "imageSrc", + get: function get$$1() { + return this.getAttribute("pfe-img-src"); + } + }, { + key: "backgroundColor", + get: function get$$1() { + return this.getAttribute("pfe-color"); + } + }, { + key: "asidePosition", + get: function get$$1() { + return { + desktop: this.getAttribute("pfe-aside-desktop"), + mobile: this.getAttribute("pfe-aside-mobile"), + height: this.getAttribute("pfe-aside-height") + }; + } + }], [{ + key: "version", + get: function get$$1() { + return "1.0.0-prerelease.54"; + } + }, { + key: "properties", + get: function get$$1() { + return { "color": { "title": "Background color", "type": "string", "enum": ["lightest", "base", "darker", "darkest", "complement", "accent"], "default": "base", "prefixed": true, "observer": "_colorChanged" }, "img-src": { "title": "Background image", "type": "string", "prefixed": true, "observer": "_imgSrcChanged" }, "aside-desktop": { "title": "Aside positioning (desktop)", "type": "string", "default": "right", "enum": ["right", "left"], "prefixed": true, "observer": "_basicAttributeChanged", "options": { "dependencies": [{ "type": "slot", "id": "aside" }] } }, "aside-mobile": { "title": "Aside positioning (mobile)", "type": "string", "default": "bottom", "enum": ["top", "bottom"], "prefixed": true, "observer": "_basicAttributeChanged", "options": { "dependencies": [{ "type": "slot", "id": "aside" }] } }, "aside-height": { "title": "Aside height", "type": "string", "default": "body", "enum": ["full", "body"], "prefixed": true, "observer": "_basicAttributeChanged", "options": { "dependencies": [{ "type": "slot", "id": "aside" }] } } }; + } + }, { + key: "slots", + get: function get$$1() { + return { "header": { "title": "Header", "type": "array", "namedSlot": true, "maxItems": 3, "items": { "title": "Body item", "oneOf": [{ "$ref": "raw" }] } }, "body": { "title": "Body", "type": "array", "namedSlot": false, "items": { "oneOf": [{ "$ref": "pfe-card" }, { "$ref": "raw" }] } }, "footer": { "title": "Footer", "type": "array", "namedSlot": true, "maxItems": 3, "items": { "oneOf": [{ "$ref": "pfe-cta" }, { "$ref": "raw" }] } }, "aside": { "title": "Aside", "type": "array", "namedSlot": true, "maxItems": 5, "items": { "oneOf": [{ "$ref": "pfe-card" }, { "$ref": "raw" }] } } }; + } + }, { + key: "tag", + get: function get$$1() { + return "pfe-band"; + } + }, { + key: "observedAttributes", + get: function get$$1() { + return ["pfe-aside-desktop", "pfe-aside-mobile", "pfe-aside-height", "pfe-color", "pfe-img-src"]; + } + }, { + key: "cascadingAttributes", + get: function get$$1() { + return { + "pfe-aside-desktop": ".pfe-band__container", + "pfe-aside-mobile": ".pfe-band__container", + "pfe-aside-height": ".pfe-band__container" + }; + } + + // Declare the type of this component + + }, { + key: "PfeType", + get: function get$$1() { + return PFElement.PfeTypes.Container; + } + }]); + + function PfeBand() { + classCallCheck(this, PfeBand); + return possibleConstructorReturn(this, (PfeBand.__proto__ || Object.getPrototypeOf(PfeBand)).call(this, PfeBand, { type: PfeBand.PfeType })); + } + + createClass(PfeBand, [{ + key: "connectedCallback", + value: function connectedCallback() { + get(PfeBand.prototype.__proto__ || Object.getPrototypeOf(PfeBand.prototype), "connectedCallback", this).call(this); + + // Initialize the background image attachment + if (this.imageSrc) { + this._imgSrcChanged("pfe-img-src", "", this.imageSrc); + } + } + }, { + key: "attributeChangedCallback", + value: function attributeChangedCallback(attr, oldValue, newValue) { + get(PfeBand.prototype.__proto__ || Object.getPrototypeOf(PfeBand.prototype), "attributeChangedCallback", this).call(this, attr, oldValue, newValue); + // Strip the prefix form the attribute + attr = attr.replace("pfe-", ""); + // If the observer is defined in the attribute properties + if (this[attr] && this[attr].observer) { + // Get the observer function + var observer = this[this[attr].observer].bind(this); + // If it's a function, allow it to run + if (typeof observer === "function") observer(attr, oldValue, newValue); + } + } + }, { + key: "_basicAttributeChanged", + value: function _basicAttributeChanged(attr, oldValue, newValue) { + this[attr].value = newValue; + } + + // Update the color attribute and contexts + + }, { + key: "_colorChanged", + value: function _colorChanged(attr, oldValue, newValue) { + this[attr].value = newValue; + // Trigger an update in nested components + this.context_update(); + } + + // Update the background image + + }, { + key: "_imgSrcChanged", + value: function _imgSrcChanged(attr, oldValue, newValue) { + // Set the image as the background image + this.style.backgroundImage = newValue ? "url('" + newValue + "')" : ""; + } + }]); + return PfeBand; + }(PFElement); + + PFElement.create(PfeBand); + + return PfeBand; + +}))); +//# sourceMappingURL=pfe-band.umd.js.map diff --git a/elements/pfe-band/dist/pfe-band.umd.js.map b/elements/pfe-band/dist/pfe-band.umd.js.map new file mode 100644 index 0000000000..9b0daf1d8d --- /dev/null +++ b/elements/pfe-band/dist/pfe-band.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-band.umd.js","sources":["../_temp/polyfills--pfe-band.js","../_temp/pfe-band.umd.js"],"sourcesContent":["// @POLYFILL Element.matches\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/matches\nif (!Element.prototype.matches) {\n Element.prototype.matches =\n Element.prototype.msMatchesSelector ||\n Element.prototype.webkitMatchesSelector;\n}\n\n// @POLYFILL Element.closest\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/closest\nif (!Element.prototype.closest) {\n Element.prototype.closest = function(s) {\n var el = this;\n do {\n if (el.matches(s)) return el;\n el = el.parentElement || el.parentNode;\n } while (el !== null && el.nodeType === 1);\n return null;\n };\n}\n\n// @POLYFILL Array.includes\n// https://tc39.github.io/ecma262/#sec-array.prototype.includes\nif (!Array.prototype.includes) {\n Object.defineProperty(Array.prototype, \"includes\", {\n value: function(valueToFind, fromIndex) {\n if (this == null) {\n throw new TypeError('\"this\" is null or not defined');\n }\n\n // 1. Let O be ? ToObject(this value).\n var o = Object(this);\n\n // 2. Let len be ? ToLength(? Get(O, \"length\")).\n var len = o.length >>> 0;\n\n // 3. If len is 0, return false.\n if (len === 0) {\n return false;\n }\n\n // 4. Let n be ? ToInteger(fromIndex).\n // (If fromIndex is undefined, this step produces the value 0.)\n var n = fromIndex | 0;\n\n // 5. If n ≥ 0, then\n // a. Let k be n.\n // 6. Else n < 0,\n // a. Let k be len + n.\n // b. If k < 0, let k be 0.\n var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);\n\n function sameValueZero(x, y) {\n return (\n x === y ||\n (typeof x === \"number\" &&\n typeof y === \"number\" &&\n isNaN(x) &&\n isNaN(y))\n );\n }\n\n // 7. Repeat, while k < len\n while (k < len) {\n // a. Let elementK be the result of ? Get(O, ! ToString(k)).\n // b. If SameValueZero(valueToFind, elementK) is true, return true.\n if (sameValueZero(o[k], valueToFind)) {\n return true;\n }\n // c. Increase k by 1.\n k++;\n }\n\n // 8. Return false\n return false;\n }\n });\n}\n","/*!\n * PatternFly Elements: PfeBand 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\n// Import polyfills: matches, closest, includes\nimport \"./polyfills--pfe-band.js\";\n\nimport PFElement from \"../../pfelement/dist/pfelement.umd\";\n\nclass PfeBand extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
    this.has_slot(`pfe-band--${slot}`) ? `pfe-has-${slot}` : \"\").join(\" \")}>\n ${this.has_slot(\"pfe-band--aside\") && this.asidePosition.mobile === \"top\" ? `` : \"\"}\n ${this.has_slot(\"pfe-band--header\") ? `
    ` : \"\"}\n
    \n ${this.has_slot(\"pfe-band--aside\") && this.asidePosition.mobile !== \"top\" ? `` : \"\"}\n ${this.has_slot(\"pfe-band--footer\") ? `
    ` : \"\"}\n
    `;\n }\n\n static get properties() {\n return {\"color\":{\"title\":\"Background color\",\"type\":\"string\",\"enum\":[\"lightest\",\"base\",\"darker\",\"darkest\",\"complement\",\"accent\"],\"default\":\"base\",\"prefixed\":true,\"observer\":\"_colorChanged\"},\"img-src\":{\"title\":\"Background image\",\"type\":\"string\",\"prefixed\":true,\"observer\":\"_imgSrcChanged\"},\"aside-desktop\":{\"title\":\"Aside positioning (desktop)\",\"type\":\"string\",\"default\":\"right\",\"enum\":[\"right\",\"left\"],\"prefixed\":true,\"observer\":\"_basicAttributeChanged\",\"options\":{\"dependencies\":[{\"type\":\"slot\",\"id\":\"aside\"}]}},\"aside-mobile\":{\"title\":\"Aside positioning (mobile)\",\"type\":\"string\",\"default\":\"bottom\",\"enum\":[\"top\",\"bottom\"],\"prefixed\":true,\"observer\":\"_basicAttributeChanged\",\"options\":{\"dependencies\":[{\"type\":\"slot\",\"id\":\"aside\"}]}},\"aside-height\":{\"title\":\"Aside height\",\"type\":\"string\",\"default\":\"body\",\"enum\":[\"full\",\"body\"],\"prefixed\":true,\"observer\":\"_basicAttributeChanged\",\"options\":{\"dependencies\":[{\"type\":\"slot\",\"id\":\"aside\"}]}}};\n }\n\n static get slots() {\n return {\"header\":{\"title\":\"Header\",\"type\":\"array\",\"namedSlot\":true,\"maxItems\":3,\"items\":{\"title\":\"Body item\",\"oneOf\":[{\"$ref\":\"raw\"}]}},\"body\":{\"title\":\"Body\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-card\"},{\"$ref\":\"raw\"}]}},\"footer\":{\"title\":\"Footer\",\"type\":\"array\",\"namedSlot\":true,\"maxItems\":3,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-cta\"},{\"$ref\":\"raw\"}]}},\"aside\":{\"title\":\"Aside\",\"type\":\"array\",\"namedSlot\":true,\"maxItems\":5,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-card\"},{\"$ref\":\"raw\"}]}}};\n }\n static get tag() {\n return \"pfe-band\";\n }\n\n get schemaUrl() {\n return \"pfe-band.json\";\n }\n\n get templateUrl() {\n return \"pfe-band.html\";\n }\n\n get styleUrl() {\n return \"pfe-band.scss\";\n }\n\n get imageSrc() {\n return this.getAttribute(\"pfe-img-src\");\n }\n\n get backgroundColor() {\n return this.getAttribute(\"pfe-color\");\n }\n\n get asidePosition() {\n return {\n desktop: this.getAttribute(\"pfe-aside-desktop\"),\n mobile: this.getAttribute(\"pfe-aside-mobile\"),\n height: this.getAttribute(\"pfe-aside-height\")\n };\n }\n\n static get observedAttributes() {\n return [\n \"pfe-aside-desktop\",\n \"pfe-aside-mobile\",\n \"pfe-aside-height\",\n \"pfe-color\",\n \"pfe-img-src\"\n ];\n }\n\n static get cascadingAttributes() {\n return {\n \"pfe-aside-desktop\": \".pfe-band__container\",\n \"pfe-aside-mobile\": \".pfe-band__container\",\n \"pfe-aside-height\": \".pfe-band__container\"\n };\n }\n\n // Declare the type of this component\n static get PfeType() {\n return PFElement.PfeTypes.Container;\n }\n\n constructor() {\n super(PfeBand, { type: PfeBand.PfeType });\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n // Initialize the background image attachment\n if (this.imageSrc) {\n this._imgSrcChanged(\"pfe-img-src\", \"\", this.imageSrc);\n }\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n super.attributeChangedCallback(attr, oldValue, newValue);\n // Strip the prefix form the attribute\n attr = attr.replace(\"pfe-\", \"\");\n // If the observer is defined in the attribute properties\n if (this[attr] && this[attr].observer) {\n // Get the observer function\n let observer = this[this[attr].observer].bind(this);\n // If it's a function, allow it to run\n if (typeof observer === \"function\") observer(attr, oldValue, newValue);\n }\n }\n\n _basicAttributeChanged(attr, oldValue, newValue) {\n this[attr].value = newValue;\n }\n\n // Update the color attribute and contexts\n _colorChanged(attr, oldValue, newValue) {\n this[attr].value = newValue;\n // Trigger an update in nested components\n this.context_update();\n }\n\n // Update the background image\n _imgSrcChanged(attr, oldValue, newValue) {\n // Set the image as the background image\n this.style.backgroundImage = newValue ? `url('${newValue}')` : ``;\n }\n}\n\nPFElement.create(PfeBand);\n\nexport { PfeBand as default };\n"],"names":["Element","prototype","matches","msMatchesSelector","webkitMatchesSelector","closest","s","el","parentElement","parentNode","nodeType","Array","includes","Object","defineProperty","value","valueToFind","fromIndex","TypeError","o","len","length","n","k","Math","max","abs","sameValueZero","x","y","isNaN","PfeBand","map","has_slot","slot","join","asidePosition","mobile","getAttribute","desktop","height","PFElement","PfeTypes","Container","type","PfeType","imageSrc","_imgSrcChanged","attr","oldValue","newValue","replace","observer","bind","context_update","style","backgroundImage","create"],"mappings":";;;;;;;;EAAA;EACA;EACA,IAAI,CAACA,QAAQC,SAAR,CAAkBC,OAAvB,EAAgC;EAC9BF,UAAQC,SAAR,CAAkBC,OAAlB,GACEF,QAAQC,SAAR,CAAkBE,iBAAlB,IACAH,QAAQC,SAAR,CAAkBG,qBAFpB;EAGD;;EAED;EACA;EACA,IAAI,CAACJ,QAAQC,SAAR,CAAkBI,OAAvB,EAAgC;EAC9BL,UAAQC,SAAR,CAAkBI,OAAlB,GAA4B,UAASC,CAAT,EAAY;EACtC,QAAIC,KAAK,IAAT;EACA,OAAG;EACD,UAAIA,GAAGL,OAAH,CAAWI,CAAX,CAAJ,EAAmB,OAAOC,EAAP;EACnBA,WAAKA,GAAGC,aAAH,IAAoBD,GAAGE,UAA5B;EACD,KAHD,QAGSF,OAAO,IAAP,IAAeA,GAAGG,QAAH,KAAgB,CAHxC;EAIA,WAAO,IAAP;EACD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D,QAAP,KAAoB,UAAxB,EAAoCA,SAASJ,IAAT,EAAeC,QAAf,EAAyBC,QAAzB;EACrC;EACF;;;6CAEsBF,MAAMC,UAAUC,UAAU;EAC/C,WAAKF,IAAL,EAAWjC,KAAX,GAAmBmC,QAAnB;EACD;;EAED;;;;oCACcF,MAAMC,UAAUC,UAAU;EACtC,WAAKF,IAAL,EAAWjC,KAAX,GAAmBmC,QAAnB;EACA;EACA,WAAKI,cAAL;EACD;;EAED;;;;qCACeN,MAAMC,UAAUC,UAAU;EACvC;EACA,WAAKK,KAAL,CAAWC,eAAX,GAA6BN,qBAAmBA,QAAnB,YAA7B;EACD;;;IAxHmBT;;EA2HtBA,UAAUgB,MAAV,CAAiB1B,OAAjB;;;;;;;;"} \ No newline at end of file diff --git a/elements/pfe-band/dist/pfe-band.umd.min.js b/elements/pfe-band/dist/pfe-band.umd.min.js new file mode 100644 index 0000000000..7cdf882908 --- /dev/null +++ b/elements/pfe-band/dist/pfe-band.umd.min.js @@ -0,0 +1,2 @@ +!function(e,a){"object"==typeof exports&&"undefined"!=typeof module?module.exports=a(require("../../pfelement/dist/pfelement.umd")):"function"==typeof define&&define.amd?define(["../../pfelement/dist/pfelement.umd"],a):e.PfeBand=a(e.PFElement)}(this,function(e){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e,Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){var a=this;do{if(a.matches(e))return a;a=a.parentElement||a.parentNode}while(null!==a&&1===a.nodeType);return null}),Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{value:function(e,a){if(null==this)throw new TypeError('"this" is null or not defined');var r=Object(this),o=r.length>>>0;if(0==o)return!1;var d,t,n=0|a,i=Math.max(0<=n?n:o-Math.abs(n),0);for(;i@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host([pfe-color=accent]),:host([pfe-color=base]),:host([pfe-color=complement]),:host([pfe-color=darker]),:host([pfe-color=darkest]),:host([pfe-color=lightest]){background-color:#fff!important;color:#151515!important}}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host{color:#151515!important}}:host{--theme:var(--pfe-band--theme, light);display:block;position:relative;padding:calc(calc(16px * 4)/ 2) calc(16px * 1);padding:calc(var(--pfe-band--Padding--vertical,calc(var(--pfe-theme--container-spacer,16px) * 4))/ 2) var(--pfe-band--Padding--horizontal,calc(var(--pfe-theme--container-spacer,16px) * 1));border:1px solid transparent;border:var(--pfe-band--Border,var(--pfe-theme--surface--border-width,1px) var(--pfe-theme--surface--border-style,solid) transparent);background-color:#f0f0f0;background-color:var(--pfe-band--BackgroundColor,var(--pfe-theme--color--surface--base,#f0f0f0));background-position:center center;background-position:var(--pfe-band--BackgroundPosition,center center);color:#3c3f42;color:var(--pfe-broadcasted--text,#3c3f42)}@media screen and (min-width:768px){:host{--pfe-band--Width:calc( 768px - calc(var(--pfe-band--Padding--horizontal, calc( var(--pfe-theme--container-spacer, 16px) * 1)) * 4))}}@media screen and (min-width:992px){:host{--pfe-band--Width:calc( 992px - calc(var(--pfe-band--Padding--horizontal, calc( var(--pfe-theme--container-spacer, 16px) * 1)) * 4))}}@media screen and (min-width:1200px){:host{--pfe-band--Width:calc( 1200px - calc(var(--pfe-band--Padding--horizontal, calc( var(--pfe-theme--container-spacer, 16px) * 1)) * 4))}}@media (min-width:576px){:host{padding:calc(16px * 4) calc(16px * 1);padding:var(--pfe-band--Padding,var(--pfe-band--Padding--vertical,calc(var(--pfe-theme--container-spacer,16px) * 4)) var(--pfe-band--Padding--horizontal,calc(var(--pfe-theme--container-spacer,16px) * 1)))}}@media print{:host{background-color:#fff!important;background-image:none!important;-webkit-box-shadow:none!important;box-shadow:none!important}}@media print{:host{border-radius:3px;border:1px solid #d2d2d2;padding:calc(16px * 4)/2 calc(16px * 1);padding:calc(var(--pfe-theme--container-spacer,16px) * 4)/2 calc(var(--pfe-theme--container-spacer,16px) * 1)}}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host{background-color:#fff!important;color:#151515!important;background-image:none!important;padding:16px}}:host *,:host ::after,:host ::before{-webkit-box-sizing:border-box;box-sizing:border-box}:host([on=dark]){--pfe-broadcasted--text:var(--pfe-theme--color--text--on-dark, #fff);--pfe-broadcasted--link:var(--pfe-theme--color--link--on-dark, #73bcf7);--pfe-broadcasted--link--hover:var(--pfe-theme--color--link--hover--on-dark, #bee1f4);--pfe-broadcasted--link--focus:var(--pfe-theme--color--link--focus--on-dark, #bee1f4);--pfe-broadcasted--link--visited:var(--pfe-theme--color--link--visited--on-dark, #bee1f4);--pfe-broadcasted--link-decoration:var(--pfe-theme--link-decoration--on-dark, none);--pfe-broadcasted--link-decoration--hover:var(--pfe-theme--link-decoration--hover--on-dark, underline);--pfe-broadcasted--link-decoration--focus:var(--pfe-theme--link-decoration--focus--on-dark, underline);--pfe-broadcasted--link-decoration--visited:var(--pfe-theme--link-decoration--visited--on-dark, none)}:host([on=saturated]){--pfe-broadcasted--text:var(--pfe-theme--color--text--on-saturated, #fff);--pfe-broadcasted--link:var(--pfe-theme--color--link--on-saturated, #fff);--pfe-broadcasted--link--hover:var(--pfe-theme--color--link--hover--on-saturated, #fafafa);--pfe-broadcasted--link--focus:var(--pfe-theme--color--link--focus--on-saturated, #fafafa);--pfe-broadcasted--link--visited:var(--pfe-theme--color--link--visited--on-saturated, #8476d1);--pfe-broadcasted--link-decoration:var(--pfe-theme--link-decoration--on-saturated, underline);--pfe-broadcasted--link-decoration--hover:var(--pfe-theme--link-decoration--hover--on-saturated, underline);--pfe-broadcasted--link-decoration--focus:var(--pfe-theme--link-decoration--focus--on-saturated, underline);--pfe-broadcasted--link-decoration--visited:var(--pfe-theme--link-decoration--visited--on-saturated, underline)}:host([on=light]){--pfe-broadcasted--text:var(--pfe-theme--color--text, #151515);--pfe-broadcasted--link:var(--pfe-theme--color--link, #06c);--pfe-broadcasted--link--hover:var(--pfe-theme--color--link--hover, #004080);--pfe-broadcasted--link--focus:var(--pfe-theme--color--link--focus, #004080);--pfe-broadcasted--link--visited:var(--pfe-theme--color--link--visited, #6753ac);--pfe-broadcasted--link-decoration:var(--pfe-theme--link-decoration, none);--pfe-broadcasted--link-decoration--hover:var(--pfe-theme--link-decoration--hover, underline);--pfe-broadcasted--link-decoration--focus:var(--pfe-theme--link-decoration--focus, underline);--pfe-broadcasted--link-decoration--visited:var(--pfe-theme--link-decoration--visited, none)}:host([pfe-color=darker]){--pfe-band--BackgroundColor:var(--pfe-theme--color--surface--darker, #3c3f42);--pfe-band--theme:var(--pfe-theme--color--surface--darker--theme, dark)}:host([pfe-color=darkest]){--pfe-band--BackgroundColor:var(--pfe-theme--color--surface--darkest, #151515);--pfe-band--theme:var(--pfe-theme--color--surface--darkest--theme, dark)}:host([pfe-color=base]){--pfe-band--BackgroundColor:var(--pfe-theme--color--surface--base, #f0f0f0);--pfe-band--theme:var(--pfe-theme--color--surface--base--theme, light)}:host([pfe-color=lightest]){--pfe-band--BackgroundColor:var(--pfe-theme--color--surface--lightest, #fff);--pfe-band--theme:var(--pfe-theme--color--surface--lightest--theme, light)}:host([pfe-color=accent]){--pfe-band--BackgroundColor:var(--pfe-theme--color--surface--accent, #004080);--pfe-band--theme:var(--pfe-theme--color--surface--accent--theme, saturated)}:host([pfe-color=complement]){--pfe-band--BackgroundColor:var(--pfe-theme--color--surface--complement, #002952);--pfe-band--theme:var(--pfe-theme--color--surface--complement--theme, saturated)}:host([pfe-size=small]){--pfe-band--Padding:calc(var(--pfe-band--Padding--vertical, calc( var(--pfe-theme--container-spacer, 16px) * 4)) / 4) var(--pfe-band--Padding--horizontal, calc( var(--pfe-theme--container-spacer, 16px) * 1))}.pfe-band__container{--pfe-band__region--width:calc(1fr - var(--pfe-band--Width__aside--sm, 240px) - var(--pfe-band--gutter--horizontal, calc(var(--pfe-theme--container-spacer, 16px) * 3)));grid-template-areas:"body";position:relative;margin:0 auto;width:100%;max-width:auto;max-width:var(--pfe-band--Width,auto)}.pfe-band__container[pfe-has-aside]{grid-template-areas:"body" "aside"}@media (min-width:768px){.pfe-band__container[pfe-has-aside]{--pfe-band--layout:1fr var(--pfe-band--Width__aside--sm, 240px)}}@media (min-width:992px){.pfe-band__container[pfe-has-aside]{--pfe-band--layout:1fr var(--pfe-band--Width__aside--lg, 300px)}}.pfe-band__container[pfe-has-aside][pfe-aside-mobile=top]{grid-template-areas:"aside" "body"}@media (min-width:768px){.pfe-band__container[pfe-has-aside][pfe-aside-desktop=left]{grid-template-areas:"aside body";--pfe-band--layout:var(--pfe-band--Width__aside--sm, 240px) 1fr}.pfe-band__container[pfe-has-aside][pfe-aside-desktop=left]>.pfe-band__body{-ms-grid-row:1;-ms-grid-column:2}.pfe-band__container[pfe-has-aside][pfe-aside-desktop=left]>.pfe-band__aside{-ms-grid-row:1;-ms-grid-column:1}}@media (min-width:992px){.pfe-band__container[pfe-has-aside][pfe-aside-desktop=left]{--pfe-band--layout:var(--pfe-band--Width__aside--lg, 300px) 1fr}}.pfe-band__container[pfe-has-header]{grid-template-areas:"header" "body"}.pfe-band__container[pfe-has-header][pfe-has-aside]{grid-template-areas:"header" "body" "aside"}@media (min-width:768px){.pfe-band__container[pfe-has-header][pfe-has-aside]{grid-template-areas:"header header" "body aside"}.pfe-band__container[pfe-has-header][pfe-has-aside]>.pfe-band__header{-ms-grid-row:1;-ms-grid-column:1;-ms-grid-column-span:2}.pfe-band__container[pfe-has-header][pfe-has-aside]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-has-aside]>.pfe-band__aside{-ms-grid-row:2;-ms-grid-column:2}}.pfe-band__container[pfe-has-header][pfe-aside-mobile=top]{grid-template-areas:"aside" "header" "body"}@media (min-width:768px){.pfe-band__container[pfe-has-header][pfe-aside-height=full]{grid-template-areas:"header aside" "body aside"}.pfe-band__container[pfe-has-header][pfe-aside-height=full]>.pfe-band__header{-ms-grid-row:1;-ms-grid-column:1;-ms-grid-column-span:1}.pfe-band__container[pfe-has-header][pfe-aside-height=full]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-aside-height=full]>.pfe-band__aside{-ms-grid-row:1;-ms-grid-row-span:2;-ms-grid-column:2}}@media (min-width:768px){.pfe-band__container[pfe-has-header][pfe-aside-desktop=left]{grid-template-areas:"header header" "aside body"}.pfe-band__container[pfe-has-header][pfe-aside-desktop=left]>.pfe-band__header{-ms-grid-row:1;-ms-grid-column:1;-ms-grid-column-span:2}.pfe-band__container[pfe-has-header][pfe-aside-desktop=left]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:2}.pfe-band__container[pfe-has-header][pfe-aside-desktop=left]>.pfe-band__aside{-ms-grid-row:2;-ms-grid-row-span:1;-ms-grid-column:1}}@media (min-width:768px){.pfe-band__container[pfe-has-header][pfe-aside-desktop=left][pfe-aside-height=full]{grid-template-areas:"aside header" "aside body"}.pfe-band__container[pfe-has-header][pfe-aside-desktop=left][pfe-aside-height=full]>.pfe-band__header{-ms-grid-row:1;-ms-grid-column:2;-ms-grid-column-span:1}.pfe-band__container[pfe-has-header][pfe-aside-desktop=left][pfe-aside-height=full]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:2}.pfe-band__container[pfe-has-header][pfe-aside-desktop=left][pfe-aside-height=full]>.pfe-band__aside{-ms-grid-row:1;-ms-grid-row-span:2;-ms-grid-column:1}}.pfe-band__container[pfe-has-footer]{grid-template-areas:"body" "footer"}.pfe-band__container[pfe-has-footer][pfe-has-aside]{grid-template-areas:"body" "aside" "footer"}@media (min-width:768px){.pfe-band__container[pfe-has-footer][pfe-has-aside]{grid-template-areas:"body aside" "footer footer"}.pfe-band__container[pfe-has-footer][pfe-has-aside]>.pfe-band__body{-ms-grid-row:1;-ms-grid-column:1}.pfe-band__container[pfe-has-footer][pfe-has-aside]>.pfe-band__aside{-ms-grid-row:1;-ms-grid-row-span:1;-ms-grid-column:2}.pfe-band__container[pfe-has-footer][pfe-has-aside]>.pfe-band__footer{-ms-grid-row:2;-ms-grid-column:1;-ms-grid-column-span:2}}.pfe-band__container[pfe-has-footer][pfe-aside-mobile=top]{grid-template-areas:"aside" "body" "footer"}@media (min-width:768px){.pfe-band__container[pfe-has-footer][pfe-aside-height=full]{grid-template-areas:"body aside" "footer aside"}.pfe-band__container[pfe-has-footer][pfe-aside-height=full]>.pfe-band__body{-ms-grid-row:1;-ms-grid-column:1}.pfe-band__container[pfe-has-footer][pfe-aside-height=full]>.pfe-band__aside{-ms-grid-row:1;-ms-grid-row-span:2;-ms-grid-column:2}.pfe-band__container[pfe-has-footer][pfe-aside-height=full]>.pfe-band__footer{-ms-grid-row:2;-ms-grid-column:1;-ms-grid-column-span:1}}@media (min-width:768px){.pfe-band__container[pfe-has-footer][pfe-aside-desktop=left]{grid-template-areas:"aside body" "footer footer"}.pfe-band__container[pfe-has-footer][pfe-aside-desktop=left]>.pfe-band__body{-ms-grid-row:1;-ms-grid-column:2}.pfe-band__container[pfe-has-footer][pfe-aside-desktop=left]>.pfe-band__aside{-ms-grid-row:1;-ms-grid-row-span:1;-ms-grid-column:1}.pfe-band__container[pfe-has-footer][pfe-aside-desktop=left]>.pfe-band__footer{-ms-grid-row:2;-ms-grid-column:1;-ms-grid-column-span:2}}@media (min-width:768px){.pfe-band__container[pfe-has-footer][pfe-aside-desktop=left][pfe-aside-height=full]{grid-template-areas:"aside body" "aside footer"}.pfe-band__container[pfe-has-footer][pfe-aside-desktop=left][pfe-aside-height=full]>.pfe-band__body{-ms-grid-row:1;-ms-grid-column:2}.pfe-band__container[pfe-has-footer][pfe-aside-desktop=left][pfe-aside-height=full]>.pfe-band__aside{-ms-grid-row:1;-ms-grid-row-span:2;-ms-grid-column:1}.pfe-band__container[pfe-has-footer][pfe-aside-desktop=left][pfe-aside-height=full]>.pfe-band__footer{-ms-grid-row:2;-ms-grid-column:2;-ms-grid-column-span:1}}.pfe-band__container[pfe-has-header][pfe-has-footer]{grid-template-areas:"header" "body" "footer"}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-has-aside]{grid-template-areas:"header" "body" "footer" "aside"}@media (min-width:768px){.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-has-aside]{grid-template-areas:"header header" "body aside" "footer footer"}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-has-aside]>.pfe-band__header{-ms-grid-row:1;-ms-grid-column:1;-ms-grid-column-span:2}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-has-aside]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-has-aside]>.pfe-band__aside{-ms-grid-row:2;-ms-grid-row-span:1;-ms-grid-column:2}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-has-aside]>.pfe-band__footer{-ms-grid-row:3;-ms-grid-column:1;-ms-grid-column-span:2}}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-mobile=top]{grid-template-areas:"aside" "header" "body" "footer"}@media (min-width:768px){.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-height=full]{grid-template-areas:"header aside" "body aside" "footer aside"}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-height=full]>.pfe-band__header{-ms-grid-row:1;-ms-grid-column:1;-ms-grid-column-span:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-height=full]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-height=full]>.pfe-band__aside{-ms-grid-row:1;-ms-grid-row-span:3;-ms-grid-column:2}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-height=full]>.pfe-band__footer{-ms-grid-row:3;-ms-grid-column:1;-ms-grid-column-span:1}}@media (min-width:768px){.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-desktop=left]{grid-template-areas:"header header" "aside body" "footer footer"}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-desktop=left]>.pfe-band__header{-ms-grid-row:1;-ms-grid-column:1;-ms-grid-column-span:2}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-desktop=left]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:2}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-desktop=left]>.pfe-band__aside{-ms-grid-row:2;-ms-grid-row-span:1;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-desktop=left]>.pfe-band__footer{-ms-grid-row:3;-ms-grid-column:1;-ms-grid-column-span:2}}@media (min-width:768px){.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-desktop=left][pfe-aside-height=full]{grid-template-areas:"aside header" "aside body" "aside footer"}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-desktop=left][pfe-aside-height=full]>.pfe-band__header{-ms-grid-row:1;-ms-grid-column:2;-ms-grid-column-span:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-desktop=left][pfe-aside-height=full]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:2}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-desktop=left][pfe-aside-height=full]>.pfe-band__aside{-ms-grid-row:1;-ms-grid-row-span:3;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-desktop=left][pfe-aside-height=full]>.pfe-band__footer{-ms-grid-row:3;-ms-grid-column:2;-ms-grid-column-span:1}}@supports (display:grid){.pfe-band__container{display:-ms-grid;display:grid;grid-row-gap:16px;grid-row-gap:var(--pfe-band--gutter--vertical,var(--pfe-theme--container-spacer,16px));grid-column-gap:calc(16px * 3);grid-column-gap:var(--pfe-band--gutter--horizontal,calc(var(--pfe-theme--container-spacer,16px) * 3));margin-bottom:0;-ms-grid-columns:1fr;grid-template-columns:1fr;-ms-grid-columns:var(--pfe-band--layout,1fr);grid-template-columns:var(--pfe-band--layout,1fr);-ms-grid-rows:-webkit-max-content;-ms-grid-rows:max-content;grid-template-rows:-webkit-max-content;grid-template-rows:max-content}.pfe-band__container>:nth-child(1){-ms-grid-row:1;-ms-grid-column:1}.pfe-band__container>:nth-child(1){-ms-grid-row:1;-ms-grid-column:1}}.pfe-band__header{margin-bottom:16px;margin-bottom:var(--pfe-band--gutter--vertical,var(--pfe-theme--container-spacer,16px))}@supports (display:grid){.pfe-band__header{-ms-grid-row:1;-ms-grid-column:1;display:-ms-grid;display:grid;grid-row-gap:16px;grid-row-gap:var(--pfe-band--gutter--vertical,var(--pfe-theme--container-spacer,16px));grid-column-gap:calc(16px * 3);grid-column-gap:var(--pfe-band--gutter--horizontal,calc(var(--pfe-theme--container-spacer,16px) * 3));margin-bottom:0;grid-area:header;-ms-grid-columns:1fr;grid-template-columns:1fr;-ms-grid-columns:var(--pfe-band__header--layout,1fr);grid-template-columns:var(--pfe-band__header--layout,1fr)}.pfe-band__container[pfe-has-header][pfe-has-aside]>.pfe-band__header{-ms-grid-row:1;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-aside-mobile=top]>.pfe-band__header{-ms-grid-row:2;-ms-grid-column:1;-ms-grid-column-span:1}.pfe-band__container[pfe-has-header][pfe-has-footer]>.pfe-band__header{-ms-grid-row:1;-ms-grid-column:1;-ms-grid-column-span:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-has-aside]>.pfe-band__header{-ms-grid-row:1;-ms-grid-column:1;-ms-grid-column-span:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-mobile=top]>.pfe-band__header{-ms-grid-row:2;-ms-grid-column:1;-ms-grid-column-span:1}}.pfe-band__body{margin-bottom:16px;margin-bottom:var(--pfe-band--gutter--vertical,var(--pfe-theme--container-spacer,16px))}@supports (display:grid){.pfe-band__body{-ms-grid-row:1;-ms-grid-column:1;display:-ms-grid;display:grid;grid-row-gap:16px;grid-row-gap:var(--pfe-band--gutter--vertical,var(--pfe-theme--container-spacer,16px));grid-column-gap:calc(16px * 3);grid-column-gap:var(--pfe-band--gutter--horizontal,calc(var(--pfe-theme--container-spacer,16px) * 3));margin-bottom:0;grid-area:body;-ms-grid-columns:1fr;grid-template-columns:1fr;-ms-grid-columns:var(--pfe-band__body--layout,1fr);grid-template-columns:var(--pfe-band__body--layout,1fr)}.pfe-band__container[pfe-has-aside]>.pfe-band__body{-ms-grid-row:1;-ms-grid-column:1}.pfe-band__container[pfe-has-aside][pfe-aside-mobile=top]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:1}.pfe-band__container[pfe-has-header]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-has-aside]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-aside-mobile=top]>.pfe-band__body{-ms-grid-row:3;-ms-grid-column:1}.pfe-band__container[pfe-has-footer]>.pfe-band__body{-ms-grid-row:1;-ms-grid-column:1}.pfe-band__container[pfe-has-footer][pfe-has-aside]>.pfe-band__body{-ms-grid-row:1;-ms-grid-column:1}.pfe-band__container[pfe-has-footer][pfe-aside-mobile=top]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-has-footer]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-has-aside]>.pfe-band__body{-ms-grid-row:2;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-mobile=top]>.pfe-band__body{-ms-grid-row:3;-ms-grid-column:1}}.pfe-band__aside{margin-bottom:16px;margin-bottom:var(--pfe-band--gutter--vertical,var(--pfe-theme--container-spacer,16px))}@supports (display:grid){.pfe-band__aside{-ms-grid-row:2;-ms-grid-column:1;display:-ms-grid;display:grid;grid-row-gap:16px;grid-row-gap:var(--pfe-band--gutter--vertical,var(--pfe-theme--container-spacer,16px));grid-column-gap:calc(16px * 3);grid-column-gap:var(--pfe-band--gutter--horizontal,calc(var(--pfe-theme--container-spacer,16px) * 3));margin-bottom:0;grid-area:aside;-ms-grid-columns:1fr;grid-template-columns:1fr;-ms-grid-columns:var(--pfe-band__aside--layout,1fr);grid-template-columns:var(--pfe-band__aside--layout,1fr)}.pfe-band__container[pfe-has-aside][pfe-aside-mobile=top]>.pfe-band__aside{-ms-grid-row:1;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-has-aside]>.pfe-band__aside{-ms-grid-row:3;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-aside-mobile=top]>.pfe-band__aside{-ms-grid-row:1;-ms-grid-column:1}.pfe-band__container[pfe-has-footer][pfe-has-aside]>.pfe-band__aside{-ms-grid-row:2;-ms-grid-row-span:1;-ms-grid-column:1}.pfe-band__container[pfe-has-footer][pfe-aside-mobile=top]>.pfe-band__aside{-ms-grid-row:1;-ms-grid-row-span:1;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-has-aside]>.pfe-band__aside{-ms-grid-row:4;-ms-grid-row-span:1;-ms-grid-column:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-mobile=top]>.pfe-band__aside{-ms-grid-row:1;-ms-grid-row-span:1;-ms-grid-column:1}}.pfe-band__footer{margin-bottom:16px;margin-bottom:var(--pfe-band--gutter--vertical,var(--pfe-theme--container-spacer,16px))}@supports (display:grid){.pfe-band__footer{-ms-grid-row:2;-ms-grid-column:1;display:-ms-grid;display:grid;grid-row-gap:16px;grid-row-gap:var(--pfe-band--gutter--vertical,var(--pfe-theme--container-spacer,16px));grid-column-gap:calc(16px * 3);grid-column-gap:var(--pfe-band--gutter--horizontal,calc(var(--pfe-theme--container-spacer,16px) * 3));margin-bottom:0;grid-area:footer;-ms-grid-columns:1fr;grid-template-columns:1fr;-ms-grid-columns:var(--pfe-band__footer--layout,1fr);grid-template-columns:var(--pfe-band__footer--layout,1fr)}.pfe-band__container[pfe-has-footer][pfe-has-aside]>.pfe-band__footer{-ms-grid-row:3;-ms-grid-column:1}.pfe-band__container[pfe-has-footer][pfe-aside-mobile=top]>.pfe-band__footer{-ms-grid-row:3;-ms-grid-column:1;-ms-grid-column-span:1}.pfe-band__container[pfe-has-header][pfe-has-footer]>.pfe-band__footer{-ms-grid-row:3;-ms-grid-column:1;-ms-grid-column-span:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-has-aside]>.pfe-band__footer{-ms-grid-row:3;-ms-grid-column:1;-ms-grid-column-span:1}.pfe-band__container[pfe-has-header][pfe-has-footer][pfe-aside-mobile=top]>.pfe-band__footer{-ms-grid-row:4;-ms-grid-column:1;-ms-grid-column-span:1}}.pfe-band__aside{-webkit-align-self:flex-start;-ms-flex-item-align:start;align-self:flex-start}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){.pfe-band__body{width:60%;float:left}.pfe-band__aside{float:left;width:35%;margin:0 2.5%}.pfe-band__footer{clear:both}.pfe-band__container::after{content:" ";display:block;clear:both}}\n/*# sourceMappingURL=pfe-band.min.css.map */\n
    \n "+(this.has_slot("pfe-band--aside")&&"top"===this.asidePosition.mobile?'':"")+"\n "+(this.has_slot("pfe-band--header")?'
    ':"")+'\n
    \n '+(this.has_slot("pfe-band--aside")&&"top"!==this.asidePosition.mobile?'':"")+"\n "+(this.has_slot("pfe-band--footer")?'
    ':"")+"\n
    "}},{key:"schemaUrl",get:function(){return"pfe-band.json"}},{key:"templateUrl",get:function(){return"pfe-band.html"}},{key:"styleUrl",get:function(){return"pfe-band.scss"}},{key:"imageSrc",get:function(){return this.getAttribute("pfe-img-src")}},{key:"backgroundColor",get:function(){return this.getAttribute("pfe-color")}},{key:"asidePosition",get:function(){return{desktop:this.getAttribute("pfe-aside-desktop"),mobile:this.getAttribute("pfe-aside-mobile"),height:this.getAttribute("pfe-aside-height")}}}],[{key:"version",get:function(){return"1.0.0-prerelease.54"}},{key:"properties",get:function(){return{color:{title:"Background color",type:"string",enum:["lightest","base","darker","darkest","complement","accent"],default:"base",prefixed:!0,observer:"_colorChanged"},"img-src":{title:"Background image",type:"string",prefixed:!0,observer:"_imgSrcChanged"},"aside-desktop":{title:"Aside positioning (desktop)",type:"string",default:"right",enum:["right","left"],prefixed:!0,observer:"_basicAttributeChanged",options:{dependencies:[{type:"slot",id:"aside"}]}},"aside-mobile":{title:"Aside positioning (mobile)",type:"string",default:"bottom",enum:["top","bottom"],prefixed:!0,observer:"_basicAttributeChanged",options:{dependencies:[{type:"slot",id:"aside"}]}},"aside-height":{title:"Aside height",type:"string",default:"body",enum:["full","body"],prefixed:!0,observer:"_basicAttributeChanged",options:{dependencies:[{type:"slot",id:"aside"}]}}}}},{key:"slots",get:function(){return{header:{title:"Header",type:"array",namedSlot:!0,maxItems:3,items:{title:"Body item",oneOf:[{$ref:"raw"}]}},body:{title:"Body",type:"array",namedSlot:!1,items:{oneOf:[{$ref:"pfe-card"},{$ref:"raw"}]}},footer:{title:"Footer",type:"array",namedSlot:!0,maxItems:3,items:{oneOf:[{$ref:"pfe-cta"},{$ref:"raw"}]}},aside:{title:"Aside",type:"array",namedSlot:!0,maxItems:5,items:{oneOf:[{$ref:"pfe-card"},{$ref:"raw"}]}}}}},{key:"tag",get:function(){return"pfe-band"}},{key:"observedAttributes",get:function(){return["pfe-aside-desktop","pfe-aside-mobile","pfe-aside-height","pfe-color","pfe-img-src"]}},{key:"cascadingAttributes",get:function(){return{"pfe-aside-desktop":".pfe-band__container","pfe-aside-mobile":".pfe-band__container","pfe-aside-height":".pfe-band__container"}}},{key:"PfeType",get:function(){return e.PfeTypes.Container}}]),a(d,[{key:"connectedCallback",value:function(){n(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),"connectedCallback",this).call(this),this.imageSrc&&this._imgSrcChanged("pfe-img-src","",this.imageSrc)}},{key:"attributeChangedCallback",value:function(e,a,r){if(n(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),"attributeChangedCallback",this).call(this,e,a,r),this[e=e.replace("pfe-","")]&&this[e].observer){var o=this[this[e].observer].bind(this);"function"==typeof o&&o(e,a,r)}}},{key:"_basicAttributeChanged",value:function(e,a,r){this[e].value=r}},{key:"_colorChanged",value:function(e,a,r){this[e].value=r,this.context_update()}},{key:"_imgSrcChanged",value:function(e,a,r){this.style.backgroundImage=r?"url('"+r+"')":""}}]),d);function d(){return function(e,a){if(!(e instanceof a))throw new TypeError("Cannot call a class as a function")}(this,d),function(e,a){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!a||"object"!=typeof a&&"function"!=typeof a?e:a}(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,d,{type:d.PfeType}))}return e.create(r),r}); +//# sourceMappingURL=pfe-band.umd.min.js.map diff --git a/elements/pfe-band/dist/pfe-band.umd.min.js.map b/elements/pfe-band/dist/pfe-band.umd.min.js.map new file mode 100644 index 0000000000..f4b8cce427 --- /dev/null +++ b/elements/pfe-band/dist/pfe-band.umd.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-band.umd.min.js","sources":["../_temp/polyfills--pfe-band.js","../_temp/pfe-band.umd.js"],"sourcesContent":["// @POLYFILL Element.matches\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/matches\nif (!Element.prototype.matches) {\n Element.prototype.matches =\n Element.prototype.msMatchesSelector ||\n Element.prototype.webkitMatchesSelector;\n}\n\n// @POLYFILL Element.closest\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/closest\nif (!Element.prototype.closest) {\n Element.prototype.closest = function(s) {\n var el = this;\n do {\n if (el.matches(s)) return el;\n el = el.parentElement || el.parentNode;\n } while (el !== null && el.nodeType === 1);\n return null;\n };\n}\n\n// @POLYFILL Array.includes\n// https://tc39.github.io/ecma262/#sec-array.prototype.includes\nif (!Array.prototype.includes) {\n Object.defineProperty(Array.prototype, \"includes\", {\n value: function(valueToFind, fromIndex) {\n if (this == null) {\n throw new TypeError('\"this\" is null or not defined');\n }\n\n // 1. Let O be ? ToObject(this value).\n var o = Object(this);\n\n // 2. Let len be ? ToLength(? Get(O, \"length\")).\n var len = o.length >>> 0;\n\n // 3. If len is 0, return false.\n if (len === 0) {\n return false;\n }\n\n // 4. Let n be ? ToInteger(fromIndex).\n // (If fromIndex is undefined, this step produces the value 0.)\n var n = fromIndex | 0;\n\n // 5. If n ≥ 0, then\n // a. Let k be n.\n // 6. Else n < 0,\n // a. Let k be len + n.\n // b. If k < 0, let k be 0.\n var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);\n\n function sameValueZero(x, y) {\n return (\n x === y ||\n (typeof x === \"number\" &&\n typeof y === \"number\" &&\n isNaN(x) &&\n isNaN(y))\n );\n }\n\n // 7. Repeat, while k < len\n while (k < len) {\n // a. Let elementK be the result of ? Get(O, ! ToString(k)).\n // b. If SameValueZero(valueToFind, elementK) is true, return true.\n if (sameValueZero(o[k], valueToFind)) {\n return true;\n }\n // c. Increase k by 1.\n k++;\n }\n\n // 8. Return false\n return false;\n }\n });\n}\n","/*!\n * PatternFly Elements: PfeBand 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\n// Import polyfills: matches, closest, includes\nimport \"./polyfills--pfe-band.js\";\n\nimport PFElement from \"../../pfelement/dist/pfelement.umd\";\n\nclass PfeBand extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
    this.has_slot(`pfe-band--${slot}`) ? `pfe-has-${slot}` : \"\").join(\" \")}>\n ${this.has_slot(\"pfe-band--aside\") && this.asidePosition.mobile === \"top\" ? `` : \"\"}\n ${this.has_slot(\"pfe-band--header\") ? `
    ` : \"\"}\n
    \n ${this.has_slot(\"pfe-band--aside\") && this.asidePosition.mobile !== \"top\" ? `` : \"\"}\n ${this.has_slot(\"pfe-band--footer\") ? `
    ` : \"\"}\n
    `;\n }\n\n static get properties() {\n return {\"color\":{\"title\":\"Background color\",\"type\":\"string\",\"enum\":[\"lightest\",\"base\",\"darker\",\"darkest\",\"complement\",\"accent\"],\"default\":\"base\",\"prefixed\":true,\"observer\":\"_colorChanged\"},\"img-src\":{\"title\":\"Background image\",\"type\":\"string\",\"prefixed\":true,\"observer\":\"_imgSrcChanged\"},\"aside-desktop\":{\"title\":\"Aside positioning (desktop)\",\"type\":\"string\",\"default\":\"right\",\"enum\":[\"right\",\"left\"],\"prefixed\":true,\"observer\":\"_basicAttributeChanged\",\"options\":{\"dependencies\":[{\"type\":\"slot\",\"id\":\"aside\"}]}},\"aside-mobile\":{\"title\":\"Aside positioning (mobile)\",\"type\":\"string\",\"default\":\"bottom\",\"enum\":[\"top\",\"bottom\"],\"prefixed\":true,\"observer\":\"_basicAttributeChanged\",\"options\":{\"dependencies\":[{\"type\":\"slot\",\"id\":\"aside\"}]}},\"aside-height\":{\"title\":\"Aside height\",\"type\":\"string\",\"default\":\"body\",\"enum\":[\"full\",\"body\"],\"prefixed\":true,\"observer\":\"_basicAttributeChanged\",\"options\":{\"dependencies\":[{\"type\":\"slot\",\"id\":\"aside\"}]}}};\n }\n\n static get slots() {\n return {\"header\":{\"title\":\"Header\",\"type\":\"array\",\"namedSlot\":true,\"maxItems\":3,\"items\":{\"title\":\"Body item\",\"oneOf\":[{\"$ref\":\"raw\"}]}},\"body\":{\"title\":\"Body\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-card\"},{\"$ref\":\"raw\"}]}},\"footer\":{\"title\":\"Footer\",\"type\":\"array\",\"namedSlot\":true,\"maxItems\":3,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-cta\"},{\"$ref\":\"raw\"}]}},\"aside\":{\"title\":\"Aside\",\"type\":\"array\",\"namedSlot\":true,\"maxItems\":5,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-card\"},{\"$ref\":\"raw\"}]}}};\n }\n static get tag() {\n return \"pfe-band\";\n }\n\n get schemaUrl() {\n return \"pfe-band.json\";\n }\n\n get templateUrl() {\n return \"pfe-band.html\";\n }\n\n get styleUrl() {\n return \"pfe-band.scss\";\n }\n\n get imageSrc() {\n return this.getAttribute(\"pfe-img-src\");\n }\n\n get backgroundColor() {\n return this.getAttribute(\"pfe-color\");\n }\n\n get asidePosition() {\n return {\n desktop: this.getAttribute(\"pfe-aside-desktop\"),\n mobile: this.getAttribute(\"pfe-aside-mobile\"),\n height: this.getAttribute(\"pfe-aside-height\")\n };\n }\n\n static get observedAttributes() {\n return [\n \"pfe-aside-desktop\",\n \"pfe-aside-mobile\",\n \"pfe-aside-height\",\n \"pfe-color\",\n \"pfe-img-src\"\n ];\n }\n\n static get cascadingAttributes() {\n return {\n \"pfe-aside-desktop\": \".pfe-band__container\",\n \"pfe-aside-mobile\": \".pfe-band__container\",\n \"pfe-aside-height\": \".pfe-band__container\"\n };\n }\n\n // Declare the type of this component\n static get PfeType() {\n return PFElement.PfeTypes.Container;\n }\n\n constructor() {\n super(PfeBand, { type: PfeBand.PfeType });\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n // Initialize the background image attachment\n if (this.imageSrc) {\n this._imgSrcChanged(\"pfe-img-src\", \"\", this.imageSrc);\n }\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n super.attributeChangedCallback(attr, oldValue, newValue);\n // Strip the prefix form the attribute\n attr = attr.replace(\"pfe-\", \"\");\n // If the observer is defined in the attribute properties\n if (this[attr] && this[attr].observer) {\n // Get the observer function\n let observer = this[this[attr].observer].bind(this);\n // If it's a function, allow it to run\n if (typeof observer === \"function\") observer(attr, oldValue, newValue);\n }\n }\n\n _basicAttributeChanged(attr, oldValue, newValue) {\n this[attr].value = newValue;\n }\n\n // Update the color attribute and contexts\n _colorChanged(attr, oldValue, newValue) {\n this[attr].value = newValue;\n // Trigger an update in nested components\n this.context_update();\n }\n\n // Update the background image\n _imgSrcChanged(attr, oldValue, newValue) {\n // Set the image as the background image\n this.style.backgroundImage = newValue ? `url('${newValue}')` : ``;\n }\n}\n\nPFElement.create(PfeBand);\n\nexport { PfeBand as default };\n"],"names":["Element","prototype","matches","msMatchesSelector","webkitMatchesSelector","closest","s","el","this","parentElement","parentNode","nodeType","Array","includes","defineProperty","valueToFind","fromIndex","TypeError","o","Object","len","length","x","y","n","k","Math","max","abs","isNaN","PfeBand","PFElement","map","_this2","has_slot","slot","join","asidePosition","mobile","getAttribute","color","title","type","enum","default","prefixed","observer","img-src","aside-desktop","options","dependencies","id","aside-mobile","aside-height","header","namedSlot","maxItems","items","oneOf","$ref","body","footer","aside","PfeTypes","Container","imageSrc","_imgSrcChanged","attr","oldValue","newValue","replace","bind","value","context_update","style","backgroundImage","PfeType","create"],"mappings":"gUAEKA,QAAQC,UAAUC,kBACbD,UAAUC,QAChBF,QAAQC,UAAUE,mBAClBH,QAAQC,UAAUG,uBAKjBJ,QAAQC,UAAUI,kBACbJ,UAAUI,QAAU,SAASC,OAC/BC,EAAKC,OACN,IACGD,EAAGL,QAAQI,GAAI,OAAOC,IACrBA,EAAGE,eAAiBF,EAAGG,iBACd,OAAPH,GAA+B,IAAhBA,EAAGI,iBACpB,OAMNC,MAAMX,UAAUY,iBACZC,eAAeF,MAAMX,UAAW,WAAY,OAC1C,SAASc,EAAaC,MACf,MAARR,WACI,IA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,OAEdI,wDAIQN,EAAMC,EAAUC,QAExBK,MAAMC,gBAAkBN,UAAmBA,mWAvC1CvC,EAAS,CAAEY,KAAMZ,EAAQ8C,kBA2CnC7C,EAAU8C,OAAO/C"} \ No newline at end of file diff --git a/elements/pfe-band/package-lock.json b/elements/pfe-band/package-lock.json index 58b7128068..1aa71eff59 100644 --- a/elements/pfe-band/package-lock.json +++ b/elements/pfe-band/package-lock.json @@ -1,6 +1,6 @@ { "name": "@patternfly/pfe-band", - "version": "1.0.0-prerelease.53", + "version": "1.0.0-prerelease.54", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/elements/pfe-band/package.json b/elements/pfe-band/package.json index 3647c3d301..65eff36c42 100644 --- a/elements/pfe-band/package.json +++ b/elements/pfe-band/package.json @@ -9,7 +9,7 @@ "js": "src/pfe-band.js" } }, - "version": "1.0.0-prerelease.53", + "version": "1.0.0-prerelease.54", "description": "Band container for PatternFly Elements", "keywords": [ "web-components", @@ -46,7 +46,7 @@ "@patternfly/pfelement": "^1.0.0-prerelease.51" }, "devDependencies": { - "@patternfly/pfe-sass": "^1.0.0-prerelease.53" + "@patternfly/pfe-sass": "^1.0.0-prerelease.54" }, "generator-rhelement-version": "0.6.8", "bugs": { diff --git a/elements/pfe-card/dist/pfe-card--lightdom.css b/elements/pfe-card/dist/pfe-card--lightdom.css new file mode 100644 index 0000000000..823357af59 --- /dev/null +++ b/elements/pfe-card/dist/pfe-card--lightdom.css @@ -0,0 +1,8 @@ +@media screen and (-ms-high-contrast: active), screen and (-ms-high-contrast: none) { + /* IE10+ */ + pfe-card img[pfe-overflow] { + max-width: 100%; + } +} + +/*# sourceMappingURL=pfe-card--lightdom.css.map */ diff --git a/elements/pfe-card/dist/pfe-card--lightdom.min.css b/elements/pfe-card/dist/pfe-card--lightdom.min.css new file mode 100644 index 0000000000..43d6eb88d6 --- /dev/null +++ b/elements/pfe-card/dist/pfe-card--lightdom.min.css @@ -0,0 +1,2 @@ +@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){pfe-card img[pfe-overflow]{max-width:100%}} +/*# sourceMappingURL=pfe-card--lightdom.min.css.map */ diff --git a/elements/pfe-card/dist/pfe-card--lightdom.min.css.map b/elements/pfe-card/dist/pfe-card--lightdom.min.css.map new file mode 100644 index 0000000000..b0b3a967fa --- /dev/null +++ b/elements/pfe-card/dist/pfe-card--lightdom.min.css.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../pfe-sass/mixins/_mixins.scss","../pfe-card--lightdom.scss"],"names":[],"mappings":"AAGM,6CAAA,oCCCF,2BACI,UAAA","file":"pfe-card--lightdom.min.css","sourcesContent":[]} \ No newline at end of file diff --git a/elements/pfe-card/dist/pfe-card.js b/elements/pfe-card/dist/pfe-card.js new file mode 100644 index 0000000000..214849c7ec --- /dev/null +++ b/elements/pfe-card/dist/pfe-card.js @@ -0,0 +1,222 @@ +import PFElement from '../../pfelement/dist/pfelement.js'; + +// @POLYFILL Element.matches +// https://developer.mozilla.org/en-US/docs/Web/API/Element/matches +if (!Element.prototype.matches) { + Element.prototype.matches = + Element.prototype.msMatchesSelector || + Element.prototype.webkitMatchesSelector; +} + +// @POLYFILL Element.closest +// https://developer.mozilla.org/en-US/docs/Web/API/Element/closest +if (!Element.prototype.closest) { + Element.prototype.closest = function(s) { + var el = this; + do { + if (el.matches(s)) return el; + el = el.parentElement || el.parentNode; + } while (el !== null && el.nodeType === 1); + return null; + }; +} + +// @POLYFILL Array.includes +// https://tc39.github.io/ecma262/#sec-array.prototype.includes +if (!Array.prototype.includes) { + Object.defineProperty(Array.prototype, "includes", { + value: function(valueToFind, fromIndex) { + if (this == null) { + throw new TypeError('"this" is null or not defined'); + } + + // 1. Let O be ? ToObject(this value). + var o = Object(this); + + // 2. Let len be ? ToLength(? Get(O, "length")). + var len = o.length >>> 0; + + // 3. If len is 0, return false. + if (len === 0) { + return false; + } + + // 4. Let n be ? ToInteger(fromIndex). + // (If fromIndex is undefined, this step produces the value 0.) + var n = fromIndex | 0; + + // 5. If n ≥ 0, then + // a. Let k be n. + // 6. Else n < 0, + // a. Let k be len + n. + // b. If k < 0, let k be 0. + var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0); + + function sameValueZero(x, y) { + return ( + x === y || + (typeof x === "number" && + typeof y === "number" && + isNaN(x) && + isNaN(y)) + ); + } + + // 7. Repeat, while k < len + while (k < len) { + // a. Let elementK be the result of ? Get(O, ! ToString(k)). + // b. If SameValueZero(valueToFind, elementK) is true, return true. + if (sameValueZero(o[k], valueToFind)) { + return true; + } + // c. Increase k by 1. + k++; + } + + // 8. Return false + return false; + } + }); +} + +/*! + * PatternFly Elements: PfeCard 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * +*/ + +class PfeCard extends PFElement { + static get version() { + return "1.0.0-prerelease.54"; + } + + get html() { + return `
    + +
    +
    + +
    +`; + } + + static get properties() { + return {"color":{"title":"Background color","type":"string","enum":["lightest","base","darker","darkest","complement","accent"],"default":"base","prefixed":true,"observer":"_colorChanged"},"img-src":{"title":"Background image","type":"string","observer":"_imgSrcChanged"},"size":{"title":"Padding size","type":"string","enum":["small"],"observer":"_basicAttributeChanged"}}; + } + + static get slots() { + return {"header":{"title":"Header","type":"array","namedSlot":true,"maxItems":3,"items":{"title":"Body item","oneOf":[{"$ref":"raw"}]}},"body":{"title":"Body","type":"array","namedSlot":false,"items":{"oneOf":[{"$ref":"pfe-card"},{"$ref":"raw"}]}},"footer":{"title":"Footer","type":"array","namedSlot":true,"maxItems":3,"items":{"oneOf":[{"$ref":"pfe-cta"},{"$ref":"raw"}]}}}; + } + static get tag() { + return "pfe-card"; + } + + get schemaUrl() { + return "pfe-card.json"; + } + + get templateUrl() { + return "pfe-card.html"; + } + + get styleUrl() { + return "pfe-card.scss"; + } + + get imageSrc() { + return this.getAttribute("pfe-img-src"); + } + + get backgroundColor() { + return this.getAttribute("pfe-color") || "base"; + } + + static get observedAttributes() { + return ["pfe-color", "pfe-img-src", "pfe-size"]; + } + + // Declare the type of this component + static get PfeType() { + return PFElement.PfeTypes.Container; + } + + constructor() { + super(PfeCard, { type: PfeCard.PfeType }); + this._observer = new MutationObserver(() => { + this._mapSchemaToSlots(this.tag, this.slots); + }); + } + + connectedCallback() { + super.connectedCallback(); + + // Initialize the background image attachment + if (this.imageSrc) { + this._imgSrcChanged("pfe-img-src", "", this.imageSrc); + } + + this._observer.observe(this, { childList: true }); + } + + disconnectedCallback() { + this._observer.disconnect(); + } + + attributeChangedCallback(attr, oldValue, newValue) { + super.attributeChangedCallback(attr, oldValue, newValue); + // Strip the prefix from the attribute + attr = attr.replace("pfe-", ""); + // If the observer is defined in the attribute properties + if (this[attr] && this[attr].observer) { + // Get the observer function + let observer = this[this[attr].observer].bind(this); + // If it's a function, allow it to run + if (typeof observer === "function") observer(attr, oldValue, newValue); + } + } + + _basicAttributeChanged(attr, oldValue, newValue) { + this[attr].value = newValue; + } + + // Update the color attribute and contexts + _colorChanged(attr, oldValue, newValue) { + this[attr].value = newValue; + // Trigger an update in nested components + this.context_update(); + } + + // Update the background image + _imgSrcChanged(attr, oldValue, newValue) { + // Set the image as the background image + this.style.backgroundImage = newValue ? `url('${newValue}')` : ``; + } +} + +PFElement.create(PfeCard); + +export default PfeCard; +//# sourceMappingURL=pfe-card.js.map diff --git a/elements/pfe-card/dist/pfe-card.js.map b/elements/pfe-card/dist/pfe-card.js.map new file mode 100644 index 0000000000..f364a9673f --- /dev/null +++ b/elements/pfe-card/dist/pfe-card.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-card.js","sources":["../_temp/polyfills--pfe-card.js","../_temp/pfe-card.js"],"sourcesContent":["// @POLYFILL Element.matches\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/matches\nif (!Element.prototype.matches) {\n Element.prototype.matches =\n Element.prototype.msMatchesSelector ||\n Element.prototype.webkitMatchesSelector;\n}\n\n// @POLYFILL Element.closest\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/closest\nif (!Element.prototype.closest) {\n Element.prototype.closest = function(s) {\n var el = this;\n do {\n if (el.matches(s)) return el;\n el = el.parentElement || el.parentNode;\n } while (el !== null && el.nodeType === 1);\n return null;\n };\n}\n\n// @POLYFILL Array.includes\n// https://tc39.github.io/ecma262/#sec-array.prototype.includes\nif (!Array.prototype.includes) {\n Object.defineProperty(Array.prototype, \"includes\", {\n value: function(valueToFind, fromIndex) {\n if (this == null) {\n throw new TypeError('\"this\" is null or not defined');\n }\n\n // 1. Let O be ? ToObject(this value).\n var o = Object(this);\n\n // 2. Let len be ? ToLength(? Get(O, \"length\")).\n var len = o.length >>> 0;\n\n // 3. If len is 0, return false.\n if (len === 0) {\n return false;\n }\n\n // 4. Let n be ? ToInteger(fromIndex).\n // (If fromIndex is undefined, this step produces the value 0.)\n var n = fromIndex | 0;\n\n // 5. If n ≥ 0, then\n // a. Let k be n.\n // 6. Else n < 0,\n // a. Let k be len + n.\n // b. If k < 0, let k be 0.\n var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);\n\n function sameValueZero(x, y) {\n return (\n x === y ||\n (typeof x === \"number\" &&\n typeof y === \"number\" &&\n isNaN(x) &&\n isNaN(y))\n );\n }\n\n // 7. Repeat, while k < len\n while (k < len) {\n // a. Let elementK be the result of ? Get(O, ! ToString(k)).\n // b. If SameValueZero(valueToFind, elementK) is true, return true.\n if (sameValueZero(o[k], valueToFind)) {\n return true;\n }\n // c. Increase k by 1.\n k++;\n }\n\n // 8. Return false\n return false;\n }\n });\n}\n","/*!\n * PatternFly Elements: PfeCard 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\n// Import polyfills: matches, closest, includes\nimport \"./polyfills--pfe-card.js\";\n\nimport PFElement from \"../../pfelement/dist/pfelement.js\";\n\nclass PfeCard extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
    \n \n
    \n
    \n \n
    \n
    \n \n
    `;\n }\n\n static get properties() {\n return {\"color\":{\"title\":\"Background color\",\"type\":\"string\",\"enum\":[\"lightest\",\"base\",\"darker\",\"darkest\",\"complement\",\"accent\"],\"default\":\"base\",\"prefixed\":true,\"observer\":\"_colorChanged\"},\"img-src\":{\"title\":\"Background image\",\"type\":\"string\",\"observer\":\"_imgSrcChanged\"},\"size\":{\"title\":\"Padding size\",\"type\":\"string\",\"enum\":[\"small\"],\"observer\":\"_basicAttributeChanged\"}};\n }\n\n static get slots() {\n return {\"header\":{\"title\":\"Header\",\"type\":\"array\",\"namedSlot\":true,\"maxItems\":3,\"items\":{\"title\":\"Body item\",\"oneOf\":[{\"$ref\":\"raw\"}]}},\"body\":{\"title\":\"Body\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-card\"},{\"$ref\":\"raw\"}]}},\"footer\":{\"title\":\"Footer\",\"type\":\"array\",\"namedSlot\":true,\"maxItems\":3,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-cta\"},{\"$ref\":\"raw\"}]}}};\n }\n static get tag() {\n return \"pfe-card\";\n }\n\n get schemaUrl() {\n return \"pfe-card.json\";\n }\n\n get templateUrl() {\n return \"pfe-card.html\";\n }\n\n get styleUrl() {\n return \"pfe-card.scss\";\n }\n\n get imageSrc() {\n return this.getAttribute(\"pfe-img-src\");\n }\n\n get backgroundColor() {\n return this.getAttribute(\"pfe-color\") || \"base\";\n }\n\n static get observedAttributes() {\n return [\"pfe-color\", \"pfe-img-src\", \"pfe-size\"];\n }\n\n // Declare the type of this component\n static get PfeType() {\n return PFElement.PfeTypes.Container;\n }\n\n constructor() {\n super(PfeCard, { type: PfeCard.PfeType });\n this._observer = new MutationObserver(() => {\n this._mapSchemaToSlots(this.tag, this.slots);\n });\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n // Initialize the background image attachment\n if (this.imageSrc) {\n this._imgSrcChanged(\"pfe-img-src\", \"\", this.imageSrc);\n }\n\n this._observer.observe(this, { childList: true });\n }\n\n disconnectedCallback() {\n this._observer.disconnect();\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n super.attributeChangedCallback(attr, oldValue, newValue);\n // Strip the prefix from the attribute\n attr = attr.replace(\"pfe-\", \"\");\n // If the observer is defined in the attribute properties\n if (this[attr] && this[attr].observer) {\n // Get the observer function\n let observer = this[this[attr].observer].bind(this);\n // If it's a function, allow it to run\n if (typeof observer === \"function\") observer(attr, oldValue, newValue);\n }\n }\n\n _basicAttributeChanged(attr, oldValue, newValue) {\n this[attr].value = newValue;\n }\n\n // Update the color attribute and contexts\n _colorChanged(attr, oldValue, newValue) {\n this[attr].value = newValue;\n // Trigger an update in nested components\n this.context_update();\n }\n\n // Update the background image\n _imgSrcChanged(attr, oldValue, newValue) {\n // Set the image as the background image\n this.style.backgroundImage = newValue ? `url('${newValue}')` : ``;\n }\n}\n\nPFElement.create(PfeCard);\n\nexport { PfeCard as default };\n"],"names":[],"mappings":";;AAAA;;AAEA,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE;EAC9B,OAAO,CAAC,SAAS,CAAC,OAAO;IACvB,OAAO,CAAC,SAAS,CAAC,iBAAiB;IACnC,OAAO,CAAC,SAAS,CAAC,qBAAqB,CAAC;CAC3C;;;;AAID,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE;EAC9B,OAAO,CAAC,SAAS,CAAC,OAAO,GAAG,SAAS,CAAC,EAAE;IACtC,IAAI,EAAE,GAAG,IAAI,CAAC;IACd,GAAG;MACD,IAAI,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;MAC7B,EAAE,GAAG,EAAE,CAAC,aAAa,IAAI,EAAE,CAAC,UAAU,CAAC;KACxC,QAAQ,EAAE,KAAK,IAAI,IAAI,EAAE,CAAC,QAAQ,KAAK,CAAC,EAAE;IAC3C,OAAO,IAAI,CAAC;GACb,CAAC;CACH;;;;AAID,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,EAAE;EAC7B,MAAM,CAAC,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ements/pfe-card/dist/pfe-card.json @@ -0,0 +1,97 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Card", + "description": "This element creates a header, body, and footer region in which to place content or other components.", + "type": "object", + "tag": "pfe-card", + "class": "pfe-card", + "category": "container", + "properties": { + "slots": { + "title": "Slots", + "description": "Definition of the supported slots", + "type": "object", + "properties": { + "header": { + "title": "Header", + "type": "array", + "namedSlot": true, + "maxItems": 3, + "items": { + "title": "Body item", + "oneOf": [ + { + "$ref": "raw" + } + ] + } + }, + "body": { + "title": "Body", + "type": "array", + "namedSlot": false, + "items": { + "oneOf": [ + { + "$ref": "pfe-card" + }, + { + "$ref": "raw" + } + ] + } + }, + "footer": { + "title": "Footer", + "type": "array", + "namedSlot": true, + "maxItems": 3, + "items": { + "oneOf": [ + { + "$ref": "pfe-cta" + }, + { + "$ref": "raw" + } + ] + } + } + } + }, + "attributes": { + "title": "Attributes", + "type": "object", + "properties": { + "color": { + "title": "Background color", + "type": "string", + "enum": [ + "lightest", + "base", + "darker", + "darkest", + "complement", + "accent" + ], + "default": "base", + "prefixed": true, + "observer": "_colorChanged" + }, + "img-src": { + "title": "Background image", + "type": "string", + "observer": "_imgSrcChanged" + }, + "size": { + "title": "Padding size", + "type": "string", + "enum": ["small"], + "observer": "_basicAttributeChanged" + } + } + } + }, + "required": ["slots", "attributes"], + "additionalProperties": false +} diff --git a/elements/pfe-card/dist/pfe-card.min.js b/elements/pfe-card/dist/pfe-card.min.js new file mode 100644 index 0000000000..c7b6f054a3 --- /dev/null +++ b/elements/pfe-card/dist/pfe-card.min.js @@ -0,0 +1,26 @@ +import e from"../../pfelement/dist/pfelement.min.js";Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){var r=this;do{if(r.matches(e))return r;r=r.parentElement||r.parentNode}while(null!==r&&1===r.nodeType);return null}),Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{value:function(e,r){if(null==this)throw new TypeError('"this" is null or not defined');var a=Object(this),t=a.length>>>0;if(0===t)return!1;var o,c,d=0|r,p=Math.max(d>=0?d:t-Math.abs(d),0);for(;p@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host([pfe-color=accent]),:host([pfe-color=base]),:host([pfe-color=complement]),:host([pfe-color=darker]),:host([pfe-color=darkest]),:host([pfe-color=lightest]){background-color:#fff!important;color:#151515!important}}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host{color:#151515!important}}:host{--theme:var(--pfe-card--theme, var(--pfe-theme--color--surface--base--theme, light));display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;justify-items:flex-start;-webkit-align-self:stretch;-ms-flex-item-align:stretch;align-self:stretch;padding:calc(16px * 2) calc(16px * 2) calc(16px * 2) calc(16px * 2);padding:var(--pfe-card--Padding,var(--pfe-card--PaddingTop,calc(var(--pfe-theme--container-spacer,16px) * 2)) var(--pfe-card--PaddingRight,calc(var(--pfe-theme--container-spacer,16px) * 2)) var(--pfe-card--PaddingBottom,calc(var(--pfe-theme--container-spacer,16px) * 2)) var(--pfe-card--PaddingLeft,calc(var(--pfe-theme--container-spacer,16px) * 2)));border:0 solid #d2d2d2;border:var(--pfe-card--Border,var(--pfe-card--BorderWidth,0) var(--pfe-card--BorderStyle,solid) var(--pfe-card--BorderColor,var(--pfe-theme--color--surface--border,#d2d2d2)));border-radius:3px;border-radius:var(--pfe-card--BorderRadius,var(--pfe-theme--surface--border-radius,3px));overflow:hidden;background-color:#f0f0f0;background-color:var(--pfe-card--BackgroundColor,var(--pfe-theme--color--surface--base,#f0f0f0));background-position:center center;background-position:var(--pfe-card--BackgroundPosition,center center);color:#3c3f42;color:var(--pfe-broadcasted--text,#3c3f42)}@media print{:host{background-color:#fff!important;background-image:none!important;-webkit-box-shadow:none!important;box-shadow:none!important}}@media print{:host{border-radius:3px;border:1px solid #d2d2d2}}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host{background-color:#fff!important;background-color:var(--pfe-theme--color--surface--lightest,#fff)!important;color:#151515!important;color:var(--pfe-theme--color--text,#151515)!important;background-image:none!important;border-radius:3px;border:1px solid #d2d2d2;padding:16px;padding:var(--pfe-theme--container-spacer,16px)}}:host([pfe-color=darker]){--pfe-card--BackgroundColor:var(--pfe-theme--color--surface--darker, #3c3f42);--pfe-card--theme:var(--pfe-theme--color--surface--darker--theme, dark)}:host([pfe-color=darkest]){--pfe-card--BackgroundColor:var(--pfe-theme--color--surface--darkest, #151515);--pfe-card--theme:var(--pfe-theme--color--surface--darkest--theme, dark)}:host([pfe-color=base]){--pfe-card--BackgroundColor:var(--pfe-theme--color--surface--base, #f0f0f0);--pfe-card--theme:var(--pfe-theme--color--surface--base--theme, light)}:host([pfe-color=lightest]){--pfe-card--BackgroundColor:var(--pfe-theme--color--surface--lightest, #fff);--pfe-card--theme:var(--pfe-theme--color--surface--lightest--theme, light)}:host([pfe-color=accent]){--pfe-card--BackgroundColor:var(--pfe-theme--color--surface--accent, #004080);--pfe-card--theme:var(--pfe-theme--color--surface--accent--theme, saturated)}:host([pfe-color=complement]){--pfe-card--BackgroundColor:var(--pfe-theme--color--surface--complement, #002952);--pfe-card--theme:var(--pfe-theme--color--surface--complement--theme, saturated)}:host([on=dark]){--pfe-broadcasted--text:var(--pfe-theme--color--text--on-dark, #fff);--pfe-broadcasted--link:var(--pfe-theme--color--link--on-dark, #73bcf7);--pfe-broadcasted--link--hover:var(--pfe-theme--color--link--hover--on-dark, #bee1f4);--pfe-broadcasted--link--focus:var(--pfe-theme--color--link--focus--on-dark, #bee1f4);--pfe-broadcasted--link--visited:var(--pfe-theme--color--link--visited--on-dark, #bee1f4);--pfe-broadcasted--link-decoration:var(--pfe-theme--link-decoration--on-dark, none);--pfe-broadcasted--link-decoration--hover:var(--pfe-theme--link-decoration--hover--on-dark, underline);--pfe-broadcasted--link-decoration--focus:var(--pfe-theme--link-decoration--focus--on-dark, underline);--pfe-broadcasted--link-decoration--visited:var(--pfe-theme--link-decoration--visited--on-dark, none)}:host([on=saturated]){--pfe-broadcasted--text:var(--pfe-theme--color--text--on-saturated, #fff);--pfe-broadcasted--link:var(--pfe-theme--color--link--on-saturated, #fff);--pfe-broadcasted--link--hover:var(--pfe-theme--color--link--hover--on-saturated, #fafafa);--pfe-broadcasted--link--focus:var(--pfe-theme--color--link--focus--on-saturated, #fafafa);--pfe-broadcasted--link--visited:var(--pfe-theme--color--link--visited--on-saturated, #8476d1);--pfe-broadcasted--link-decoration:var(--pfe-theme--link-decoration--on-saturated, underline);--pfe-broadcasted--link-decoration--hover:var(--pfe-theme--link-decoration--hover--on-saturated, underline);--pfe-broadcasted--link-decoration--focus:var(--pfe-theme--link-decoration--focus--on-saturated, underline);--pfe-broadcasted--link-decoration--visited:var(--pfe-theme--link-decoration--visited--on-saturated, underline)}:host([on=light]){--pfe-broadcasted--text:var(--pfe-theme--color--text, #151515);--pfe-broadcasted--link:var(--pfe-theme--color--link, #06c);--pfe-broadcasted--link--hover:var(--pfe-theme--color--link--hover, #004080);--pfe-broadcasted--link--focus:var(--pfe-theme--color--link--focus, #004080);--pfe-broadcasted--link--visited:var(--pfe-theme--color--link--visited, #6753ac);--pfe-broadcasted--link-decoration:var(--pfe-theme--link-decoration, none);--pfe-broadcasted--link-decoration--hover:var(--pfe-theme--link-decoration--hover, underline);--pfe-broadcasted--link-decoration--focus:var(--pfe-theme--link-decoration--focus, underline);--pfe-broadcasted--link-decoration--visited:var(--pfe-theme--link-decoration--visited, none)}:host([pfe-size=small]){--pfe-card--PaddingTop:var(--pfe-theme--container-spacer, 16px);--pfe-card--PaddingRight:var(--pfe-theme--container-spacer, 16px);--pfe-card--PaddingBottom:var(--pfe-theme--container-spacer, 16px);--pfe-card--PaddingLeft:var(--pfe-theme--container-spacer, 16px)}:host([pfe-border]:not([pfe-border=false])){--pfe-card--BorderWidth:1px}.pfe-card__body ::slotted([pfe-overflow~=top]),.pfe-card__footer ::slotted([pfe-overflow~=top]),.pfe-card__header ::slotted([pfe-overflow~=top]){z-index:1;margin-top:-2rem;margin-top:calc(-1 * calc(16px * 2))!important;margin-top:calc(-1 * var(--pfe-card--PaddingTop,calc(var(--pfe-theme--container-spacer,16px) * 2)))!important}:host([has_header]) .pfe-card__body ::slotted([pfe-overflow~=top]),:host([has_header]) .pfe-card__footer ::slotted([pfe-overflow~=top]),:host([has_header]) .pfe-card__header ::slotted([pfe-overflow~=top]){padding-top:16px;padding-top:var(--pfe-card--spacing,var(--pfe-theme--container-spacer,16px))}.pfe-card__body ::slotted([pfe-overflow~=right]),.pfe-card__footer ::slotted([pfe-overflow~=right]),.pfe-card__header ::slotted([pfe-overflow~=right]){margin-right:-2rem;margin-right:calc(-1 * calc(16px * 2));margin-right:calc(-1 * var(--pfe-card--PaddingRight,calc(var(--pfe-theme--container-spacer,16px) * 2)))}.pfe-card__body ::slotted([pfe-overflow~=bottom]),.pfe-card__footer ::slotted([pfe-overflow~=bottom]),.pfe-card__header ::slotted([pfe-overflow~=bottom]){margin-bottom:-2rem;margin-bottom:calc(-1 * calc(calc(16px * 2) + 3px));margin-bottom:calc(-1 * calc(var(--pfe-card--PaddingBottom,calc(var(--pfe-theme--container-spacer,16px) * 2)) + var(--pfe-card--BorderRadius,var(--pfe-theme--surface--border-radius,3px))));-webkit-align-self:flex-end;-ms-flex-item-align:end;align-self:flex-end}.pfe-card__body ::slotted([pfe-overflow~=left]),.pfe-card__footer ::slotted([pfe-overflow~=left]),.pfe-card__header ::slotted([pfe-overflow~=left]){margin-left:-2rem;margin-left:calc(-1 * calc(16px * 2));margin-left:calc(-1 * var(--pfe-card--PaddingLeft,calc(var(--pfe-theme--container-spacer,16px) * 2)))}.pfe-card__body ::slotted(img),.pfe-card__footer ::slotted(img),.pfe-card__header ::slotted(img){max-width:100%!important;-webkit-align-self:flex-start;-ms-flex-item-align:start;align-self:flex-start;-o-object-fit:cover;object-fit:cover}.pfe-card__body ::slotted(img:not[pfe-overflow]),.pfe-card__footer ::slotted(img:not[pfe-overflow]),.pfe-card__header ::slotted(img:not[pfe-overflow]){-webkit-align-self:flex-start;-ms-flex-item-align:start;align-self:flex-start}.pfe-card__body ::slotted(img[pfe-overflow~=right]),.pfe-card__footer ::slotted(img[pfe-overflow~=right]),.pfe-card__header ::slotted(img[pfe-overflow~=right]){max-width:calc(100% + 2rem)!important;max-width:calc(100% + calc(16px * 2))!important;max-width:calc(100% + var(--pfe-card--PaddingRight,calc(var(--pfe-theme--container-spacer,16px) * 2)))!important}.pfe-card__body ::slotted(img[pfe-overflow~=left]),.pfe-card__footer ::slotted(img[pfe-overflow~=left]),.pfe-card__header ::slotted(img[pfe-overflow~=left]){max-width:calc(100% + 2rem)!important;max-width:calc(100% + calc(16px * 2))!important;max-width:calc(100% + var(--pfe-card--PaddingLeft,calc(var(--pfe-theme--container-spacer,16px) * 2)))!important}.pfe-card__body ::slotted(img[pfe-overflow~=right][pfe-overflow~=left]),.pfe-card__footer ::slotted(img[pfe-overflow~=right][pfe-overflow~=left]),.pfe-card__header ::slotted(img[pfe-overflow~=right][pfe-overflow~=left]){max-width:calc(100% + 4rem)!important;max-width:calc(100% + calc(calc(16px * 2) + calc(16px * 2)))!important;max-width:calc(100% + calc(var(--pfe-card--PaddingRight,calc(var(--pfe-theme--container-spacer,16px) * 2)) + var(--pfe-card--PaddingLeft,calc(var(--pfe-theme--container-spacer,16px) * 2))))!important}.pfe-card__header{z-index:2;background-color:rgba(0,0,0,.09);background-color:var(--pfe-card__header--BackgroundColor,rgba(0,0,0,var(--pfe-theme--opacity,.09)));color:#3c3f42;color:var(--pfe-card__header--Color,var(--pfe-broadcasted--text,#3c3f42));margin-top:calc(calc(16px * 2) * -1)!important;margin-top:calc(var(--pfe-card--PaddingTop,calc(var(--pfe-theme--container-spacer,16px) * 2)) * -1)!important;margin-right:calc(calc(16px * 2) * -1);margin-right:calc(var(--pfe-card--PaddingRight,calc(var(--pfe-theme--container-spacer,16px) * 2)) * -1);margin-bottom:16px;margin-bottom:var(--pfe-card--spacing--vertical,var(--pfe-card--spacing,var(--pfe-theme--container-spacer,16px)));margin-left:calc(calc(16px * 2) * -1);margin-left:calc(var(--pfe-card--PaddingLeft,calc(var(--pfe-theme--container-spacer,16px) * 2)) * -1);padding-top:16px;padding-top:var(--pfe-card--spacing--vertical,var(--pfe-card--spacing,var(--pfe-theme--container-spacer,16px)));padding-right:calc(16px * 2);padding-right:var(--pfe-card--PaddingRight,calc(var(--pfe-theme--container-spacer,16px) * 2));padding-left:calc(16px * 2);padding-left:var(--pfe-card--PaddingLeft,calc(var(--pfe-theme--container-spacer,16px) * 2));padding-bottom:16px;padding-bottom:var(--pfe-card--spacing--vertical,var(--pfe-card--spacing,var(--pfe-theme--container-spacer,16px)))}:host([on=dark]) .pfe-card__header{background-color:rgba(255,255,255,.09);background-color:var(--pfe-card__header--BackgroundColor--dark,rgba(255,255,255,var(--pfe-theme--opacity,.09)))}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){.pfe-card__header{background-color:#fff!important;color:#151515!important;color:var(--pfe-theme--color--text,#151515)!important}}:host(:not([has_body]):not([has_footer])) .pfe-card__header{margin-bottom:calc(16px * 2);margin-bottom:var(--pfe-card--PaddingBottom,calc(var(--pfe-theme--container-spacer,16px) * 2))}.pfe-card__header ::slotted([pfe-overflow~=top]){--pfe-card__overflow--MarginTop:calc(var(--pfe-card--PaddingTop, calc(var(--pfe-theme--container-spacer, 16px) * 2)) * -1)}:host(:not([has_header])) .pfe-card__header{display:none}:host([has_body],[has_footer]) .pfe-card__header ::slotted([pfe-overflow~=bottom]){--pfe-card__overflow--MarginBottom:calc(var(--pfe-card--spacing--vertical, var(--pfe-card--spacing, var(--pfe-theme--container-spacer, 16px))) * -1)}.pfe-card__header ::slotted([pfe-overflow~=bottom]){--pfe-card__overflow--MarginBottom:calc(var(--pfe-card--PaddingBottom, calc(var(--pfe-theme--container-spacer, 16px) * 2)) * -1)}.pfe-card__header ::slotted(h1){margin-bottom:0}.pfe-card__header ::slotted(h2){margin-bottom:0}.pfe-card__header ::slotted(h3){margin-bottom:0}.pfe-card__header ::slotted(h4){margin-bottom:0}.pfe-card__header ::slotted(h5){margin-bottom:0}.pfe-card__header ::slotted(h6){margin-bottom:0}:host(:not([has_header])) .pfe-card__body ::slotted([pfe-overflow~=top]){--pfe-card__overflow--MarginTop:calc(var(--pfe-card--PaddingTop, calc(var(--pfe-theme--container-spacer, 16px) * 2)) * -1)}.pfe-card__body ::slotted([pfe-overflow~=top]){z-index:1;--pfe-card__overflow--MarginTop:calc(var(--pfe-card--spacing--vertical, var(--pfe-card--spacing, var(--pfe-theme--container-spacer, 16px))) * -1)}.pfe-card__body ::slotted([pfe-overflow~=bottom]){--pfe-card__overflow--MarginBottom:calc(var(--pfe-card--PaddingBottom, calc(var(--pfe-theme--container-spacer, 16px) * 2)) * -1)}:host([has_footer]) .pfe-card__body ::slotted([pfe-overflow~=bottom]){--pfe-card__overflow--MarginBottom:calc(var(--pfe-card--spacing--vertical, var(--pfe-card--spacing, var(--pfe-theme--container-spacer, 16px))) * -1)}:host(:not([has_footer])) .pfe-card__body{margin-bottom:0}.pfe-card__footer{margin-top:auto;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;flex-direction:var(--pfe-card__footer--Row,row);-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap;-webkit-flex-wrap:var(--pfe-card__footer--Wrap,wrap);-ms-flex-wrap:var(--pfe-card__footer--Wrap,wrap);flex-wrap:var(--pfe-card__footer--Wrap,wrap);-webkit-box-align:baseline;-webkit-align-items:baseline;-ms-flex-align:baseline;align-items:baseline;-webkit-box-align:var(--pfe-card__footer--AlignItems,baseline);-webkit-align-items:var(--pfe-card__footer--AlignItems,baseline);-ms-flex-align:var(--pfe-card__footer--AlignItems,baseline);align-items:var(--pfe-card__footer--AlignItems,baseline)}.pfe-card__footer ::slotted([pfe-overflow~=bottom]){--pfe-card__overflow--MarginBottom:calc(var(--pfe-card--PaddingBottom, calc(var(--pfe-theme--container-spacer, 16px) * 2)) * -1)}:host(:not([has_footer])) .pfe-card__footer{display:none}.pfe-card__body,.pfe-card__header{margin-bottom:16px;margin-bottom:var(--pfe-card--spacing--vertical,var(--pfe-card--spacing,var(--pfe-theme--container-spacer,16px)))}.pfe-card__body ::slotted(p:first-child),.pfe-card__header ::slotted(p:first-child){margin-top:0}.pfe-card__body ::slotted(h1:first-child),.pfe-card__header ::slotted(h1:first-child){margin-top:0}.pfe-card__body ::slotted(h2:first-child),.pfe-card__header ::slotted(h2:first-child){margin-top:0}.pfe-card__body ::slotted(h3:first-child),.pfe-card__header ::slotted(h3:first-child){margin-top:0}.pfe-card__body ::slotted(h4:first-child),.pfe-card__header ::slotted(h4:first-child){margin-top:0}.pfe-card__body ::slotted(h5:first-child),.pfe-card__header ::slotted(h5:first-child){margin-top:0}.pfe-card__body ::slotted(h6:first-child),.pfe-card__header ::slotted(h6:first-child){margin-top:0}\n/*# sourceMappingURL=pfe-card.min.css.map */\n
    \n \n
    \n
    \n \n
    \n'}static get properties(){return{color:{title:"Background color",type:"string",enum:["lightest","base","darker","darkest","complement","accent"],default:"base",prefixed:!0,observer:"_colorChanged"},"img-src":{title:"Background image",type:"string",observer:"_imgSrcChanged"},size:{title:"Padding size",type:"string",enum:["small"],observer:"_basicAttributeChanged"}}}static get slots(){return{header:{title:"Header",type:"array",namedSlot:!0,maxItems:3,items:{title:"Body item",oneOf:[{$ref:"raw"}]}},body:{title:"Body",type:"array",namedSlot:!1,items:{oneOf:[{$ref:"pfe-card"},{$ref:"raw"}]}},footer:{title:"Footer",type:"array",namedSlot:!0,maxItems:3,items:{oneOf:[{$ref:"pfe-cta"},{$ref:"raw"}]}}}}static get tag(){return"pfe-card"}get schemaUrl(){return"pfe-card.json"}get templateUrl(){return"pfe-card.html"}get styleUrl(){return"pfe-card.scss"}get imageSrc(){return this.getAttribute("pfe-img-src")}get backgroundColor(){return this.getAttribute("pfe-color")||"base"}static get observedAttributes(){return["pfe-color","pfe-img-src","pfe-size"]}static get PfeType(){return e.PfeTypes.Container}constructor(){super(r,{type:r.PfeType}),this._observer=new MutationObserver(()=>{this._mapSchemaToSlots(this.tag,this.slots)})}connectedCallback(){super.connectedCallback(),this.imageSrc&&this._imgSrcChanged("pfe-img-src","",this.imageSrc),this._observer.observe(this,{childList:!0})}disconnectedCallback(){this._observer.disconnect()}attributeChangedCallback(e,r,a){if(super.attributeChangedCallback(e,r,a),this[e=e.replace("pfe-","")]&&this[e].observer){let t=this[this[e].observer].bind(this);"function"==typeof t&&t(e,r,a)}}_basicAttributeChanged(e,r,a){this[e].value=a}_colorChanged(e,r,a){this[e].value=a,this.context_update()}_imgSrcChanged(e,r,a){this.style.backgroundImage=a?`url('${a}')`:""}}e.create(r);export default r; +//# sourceMappingURL=pfe-card.min.js.map diff --git a/elements/pfe-card/dist/pfe-card.min.js.map b/elements/pfe-card/dist/pfe-card.min.js.map new file mode 100644 index 0000000000..8d8821805e --- /dev/null +++ b/elements/pfe-card/dist/pfe-card.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-card.min.js","sources":["../_temp/polyfills--pfe-card.js","../_temp/pfe-card.js"],"sourcesContent":["// @POLYFILL Element.matches\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/matches\nif (!Element.prototype.matches) {\n Element.prototype.matches =\n Element.prototype.msMatchesSelector ||\n Element.prototype.webkitMatchesSelector;\n}\n\n// @POLYFILL Element.closest\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/closest\nif (!Element.prototype.closest) {\n Element.prototype.closest = function(s) {\n var el = this;\n do {\n if (el.matches(s)) return el;\n el = el.parentElement || el.parentNode;\n } while (el !== null && el.nodeType === 1);\n return null;\n };\n}\n\n// @POLYFILL Array.includes\n// https://tc39.github.io/ecma262/#sec-array.prototype.includes\nif (!Array.prototype.includes) {\n Object.defineProperty(Array.prototype, \"includes\", {\n value: function(valueToFind, fromIndex) {\n if (this == null) {\n throw new TypeError('\"this\" is null or not defined');\n }\n\n // 1. Let O be ? ToObject(this value).\n var o = Object(this);\n\n // 2. Let len be ? ToLength(? Get(O, \"length\")).\n var len = o.length >>> 0;\n\n // 3. If len is 0, return false.\n if (len === 0) {\n return false;\n }\n\n // 4. Let n be ? ToInteger(fromIndex).\n // (If fromIndex is undefined, this step produces the value 0.)\n var n = fromIndex | 0;\n\n // 5. If n ≥ 0, then\n // a. Let k be n.\n // 6. Else n < 0,\n // a. Let k be len + n.\n // b. If k < 0, let k be 0.\n var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);\n\n function sameValueZero(x, y) {\n return (\n x === y ||\n (typeof x === \"number\" &&\n typeof y === \"number\" &&\n isNaN(x) &&\n isNaN(y))\n );\n }\n\n // 7. Repeat, while k < len\n while (k < len) {\n // a. Let elementK be the result of ? Get(O, ! ToString(k)).\n // b. If SameValueZero(valueToFind, elementK) is true, return true.\n if (sameValueZero(o[k], valueToFind)) {\n return true;\n }\n // c. Increase k by 1.\n k++;\n }\n\n // 8. Return false\n return false;\n }\n });\n}\n","/*!\n * PatternFly Elements: PfeCard 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\n// Import polyfills: matches, closest, includes\nimport \"./polyfills--pfe-card.js\";\n\nimport PFElement from \"../../pfelement/dist/pfelement.js\";\n\nclass PfeCard extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
    \n \n
    \n
    \n \n
    \n
    \n \n
    `;\n }\n\n static get properties() {\n return {\"color\":{\"title\":\"Background color\",\"type\":\"string\",\"enum\":[\"lightest\",\"base\",\"darker\",\"darkest\",\"complement\",\"accent\"],\"default\":\"base\",\"prefixed\":true,\"observer\":\"_colorChanged\"},\"img-src\":{\"title\":\"Background image\",\"type\":\"string\",\"observer\":\"_imgSrcChanged\"},\"size\":{\"title\":\"Padding size\",\"type\":\"string\",\"enum\":[\"small\"],\"observer\":\"_basicAttributeChanged\"}};\n }\n\n static get slots() {\n return {\"header\":{\"title\":\"Header\",\"type\":\"array\",\"namedSlot\":true,\"maxItems\":3,\"items\":{\"title\":\"Body item\",\"oneOf\":[{\"$ref\":\"raw\"}]}},\"body\":{\"title\":\"Body\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-card\"},{\"$ref\":\"raw\"}]}},\"footer\":{\"title\":\"Footer\",\"type\":\"array\",\"namedSlot\":true,\"maxItems\":3,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-cta\"},{\"$ref\":\"raw\"}]}}};\n }\n static get tag() {\n return \"pfe-card\";\n }\n\n get schemaUrl() {\n return \"pfe-card.json\";\n }\n\n get templateUrl() {\n return \"pfe-card.html\";\n }\n\n get styleUrl() {\n return \"pfe-card.scss\";\n }\n\n get imageSrc() {\n return this.getAttribute(\"pfe-img-src\");\n }\n\n get backgroundColor() {\n return this.getAttribute(\"pfe-color\") || \"base\";\n }\n\n static get observedAttributes() {\n return [\"pfe-color\", \"pfe-img-src\", \"pfe-size\"];\n }\n\n // Declare the type of this component\n static get PfeType() {\n return PFElement.PfeTypes.Container;\n }\n\n constructor() {\n super(PfeCard, { type: PfeCard.PfeType });\n this._observer = new MutationObserver(() => {\n this._mapSchemaToSlots(this.tag, this.slots);\n });\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n // Initialize the background image attachment\n if (this.imageSrc) {\n this._imgSrcChanged(\"pfe-img-src\", \"\", this.imageSrc);\n }\n\n this._observer.observe(this, { childList: true });\n }\n\n disconnectedCallback() {\n this._observer.disconnect();\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n super.attributeChangedCallback(attr, oldValue, newValue);\n // Strip the prefix from the attribute\n attr = attr.replace(\"pfe-\", \"\");\n // If the observer is defined in the attribute properties\n if (this[attr] && this[attr].observer) {\n // Get the observer function\n let observer = this[this[attr].observer].bind(this);\n // If it's a function, allow it to run\n if (typeof observer === \"function\") observer(attr, oldValue, newValue);\n }\n }\n\n _basicAttributeChanged(attr, oldValue, newValue) {\n this[attr].value = newValue;\n }\n\n // Update the color attribute and contexts\n _colorChanged(attr, oldValue, newValue) {\n this[attr].value = newValue;\n // Trigger an update in nested components\n this.context_update();\n }\n\n // Update the background image\n _imgSrcChanged(attr, oldValue, newValue) {\n // Set the image as the background image\n this.style.backgroundImage = newValue ? `url('${newValue}')` : ``;\n }\n}\n\nPFElement.create(PfeCard);\n\nexport { PfeCard as default };\n"],"names":["Element","prototype","matches","msMatchesSelector","webkitMatchesSelector","closest","s","el","this","parentElement","parentNode","nodeType","Array","includes","Object","defineProperty","value","valueToFind","fromIndex","TypeError","o","len","length","x","y","n","k","Math","max","abs","isNaN","PfeCard","PFElement","version","html","properties","color","title","type","enum","default","prefixed","observer","img-src","size","slots","header","namedSlot","maxItems","items","oneOf","$ref","body","footer","tag","schemaUrl","templateUrl","styleUrl","imageSrc","getAttribute","backgroundColor","observedAttributes","PfeType","PfeTypes","Container","[object Object]","super","_observer","MutationObserver","_mapSchemaToSlots","connectedCallback","_imgSrcChanged","observe","childList","disconnect","attr","oldValue","newValue","attributeChangedCallback","replace","bind","context_update","style","backgroundImage","create"],"mappings":"qDAEKA,QAAQC,UAAUC,UACrBF,QAAQC,UAAUC,QAChBF,QAAQC,UAAUE,mBAClBH,QAAQC,UAAUG,uBAKjBJ,QAAQC,UAAUI,UACrBL,QAAQC,UAAUI,QAAU,SAASC,GACnC,IAAIC,EAAKC,KACT,EAAG,CACD,GAAID,EAAGL,QAAQI,GAAI,OAAOC,EAC1BA,EAAKA,EAAGE,eAAiBF,EAAGG,iBACd,OAAPH,GAA+B,IAAhBA,EAAGI,UAC3B,OAAO,OAMNC,MAAMX,UAAUY,UACnBC,OAAOC,eAAeH,MAAMX,UAAW,WAAY,CACjDe,MAAO,SAASC,EAAaC,GAC3B,GAAY,MAARV,KACF,MAAM,IAAIW,UAAU,iCAItB,IAAIC,EAAIN,OAAON,MAGXa,EAAMD,EAAEE,SAAW,EAGvB,GAAY,IAARD,EACF,OAAO,EAKT,IASuBE,EAAGC,EATtBC,EAAgB,EAAZP,EAOJQ,EAAIC,KAAKC,IAAIH,GAAK,EAAIA,EAAIJ,EAAMM,KAAKE,IAAIJ,GAAI,GAajD,KAAOC,EAAIL,GAAK,CAGd,IAdqBE,EAcHH,EAAEM,OAdIF,EAcAP,IAXR,iBAANM,GACO,iBAANC,GACPM,MAAMP,IACNO,MAAMN,GASR,OAAO,EAGTE,IAIF,OAAO;;;;;;;;;;;;;;;;;;;;;;;;GC5Cb,MAAMK,UAAgBC,EACpBC,qBACE,MAAO,sBAGTC,WACE,MAAO,gyeAaTC,wBACE,MAAO,CAACC,MAAQ,CAACC,MAAQ,mBAAmBC,KAAO,SAASC,KAAO,CAAC,WAAW,OAAO,SAAS,UAAU,aAA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,OAAQ,MAEVvE,KAAKmE,GAAMjC,SAAU,CAErC,IAAIA,EAAWlC,KAAKA,KAAKmE,GAAMjC,UAAUsC,KAAKxE,MAEtB,mBAAbkC,GAAyBA,EAASiC,EAAMC,EAAUC,IAIjEZ,uBAAuBU,EAAMC,EAAUC,GACrCrE,KAAKmE,GAAM3D,MAAQ6D,EAIrBZ,cAAcU,EAAMC,EAAUC,GAC5BrE,KAAKmE,GAAM3D,MAAQ6D,EAEnBrE,KAAKyE,iBAIPhB,eAAeU,EAAMC,EAAUC,GAE7BrE,KAAK0E,MAAMC,gBAAkBN,UAAmBA,MAAe,IAInE7C,EAAUoD,OAAOrD"} \ No newline at end of file diff --git a/elements/pfe-card/dist/pfe-card.umd.js b/elements/pfe-card/dist/pfe-card.umd.js new file mode 100644 index 0000000000..91be6e3e5d --- /dev/null +++ b/elements/pfe-card/dist/pfe-card.umd.js @@ -0,0 +1,320 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../../pfelement/dist/pfelement.umd')) : + typeof define === 'function' && define.amd ? define(['../../pfelement/dist/pfelement.umd'], factory) : + (global.PfeCard = factory(global.PFElement)); +}(this, (function (PFElement) { 'use strict'; + + PFElement = PFElement && PFElement.hasOwnProperty('default') ? PFElement['default'] : PFElement; + + // @POLYFILL Element.matches + // https://developer.mozilla.org/en-US/docs/Web/API/Element/matches + if (!Element.prototype.matches) { + Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; + } + + // @POLYFILL Element.closest + // https://developer.mozilla.org/en-US/docs/Web/API/Element/closest + if (!Element.prototype.closest) { + Element.prototype.closest = function (s) { + var el = this; + do { + if (el.matches(s)) return el; + el = el.parentElement || el.parentNode; + } while (el !== null && el.nodeType === 1); + return null; + }; + } + + // @POLYFILL Array.includes + // https://tc39.github.io/ecma262/#sec-array.prototype.includes + if (!Array.prototype.includes) { + Object.defineProperty(Array.prototype, "includes", { + value: function value(valueToFind, fromIndex) { + if (this == null) { + throw new TypeError('"this" is null or not defined'); + } + + // 1. Let O be ? ToObject(this value). + var o = Object(this); + + // 2. Let len be ? ToLength(? Get(O, "length")). + var len = o.length >>> 0; + + // 3. If len is 0, return false. + if (len === 0) { + return false; + } + + // 4. Let n be ? ToInteger(fromIndex). + // (If fromIndex is undefined, this step produces the value 0.) + var n = fromIndex | 0; + + // 5. If n ≥ 0, then + // a. Let k be n. + // 6. Else n < 0, + // a. Let k be len + n. + // b. If k < 0, let k be 0. + var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0); + + function sameValueZero(x, y) { + return x === y || typeof x === "number" && typeof y === "number" && isNaN(x) && isNaN(y); + } + + // 7. Repeat, while k < len + while (k < len) { + // a. Let elementK be the result of ? Get(O, ! ToString(k)). + // b. If SameValueZero(valueToFind, elementK) is true, return true. + if (sameValueZero(o[k], valueToFind)) { + return true; + } + // c. Increase k by 1. + k++; + } + + // 8. Return false + return false; + } + }); + } + + var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + }; + + var createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + }(); + + var get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + + if (getter === undefined) { + return undefined; + } + + return getter.call(receiver); + } + }; + + var inherits = function (subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + }; + + var possibleConstructorReturn = function (self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && (typeof call === "object" || typeof call === "function") ? call : self; + }; + + /*! + * PatternFly Elements: PfeCard 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + + var PfeCard = function (_PFElement) { + inherits(PfeCard, _PFElement); + createClass(PfeCard, [{ + key: "html", + get: function get$$1() { + return "
    \n \n
    \n
    \n \n
    \n
    \n \n
    "; + } + }, { + key: "schemaUrl", + get: function get$$1() { + return "pfe-card.json"; + } + }, { + key: "templateUrl", + get: function get$$1() { + return "pfe-card.html"; + } + }, { + key: "styleUrl", + get: function get$$1() { + return "pfe-card.scss"; + } + }, { + key: "imageSrc", + get: function get$$1() { + return this.getAttribute("pfe-img-src"); + } + }, { + key: "backgroundColor", + get: function get$$1() { + return this.getAttribute("pfe-color") || "base"; + } + }], [{ + key: "version", + get: function get$$1() { + return "1.0.0-prerelease.54"; + } + }, { + key: "properties", + get: function get$$1() { + return { "color": { "title": "Background color", "type": "string", "enum": ["lightest", "base", "darker", "darkest", "complement", "accent"], "default": "base", "prefixed": true, "observer": "_colorChanged" }, "img-src": { "title": "Background image", "type": "string", "observer": "_imgSrcChanged" }, "size": { "title": "Padding size", "type": "string", "enum": ["small"], "observer": "_basicAttributeChanged" } }; + } + }, { + key: "slots", + get: function get$$1() { + return { "header": { "title": "Header", "type": "array", "namedSlot": true, "maxItems": 3, "items": { "title": "Body item", "oneOf": [{ "$ref": "raw" }] } }, "body": { "title": "Body", "type": "array", "namedSlot": false, "items": { "oneOf": [{ "$ref": "pfe-card" }, { "$ref": "raw" }] } }, "footer": { "title": "Footer", "type": "array", "namedSlot": true, "maxItems": 3, "items": { "oneOf": [{ "$ref": "pfe-cta" }, { "$ref": "raw" }] } } }; + } + }, { + key: "tag", + get: function get$$1() { + return "pfe-card"; + } + }, { + key: "observedAttributes", + get: function get$$1() { + return ["pfe-color", "pfe-img-src", "pfe-size"]; + } + + // Declare the type of this component + + }, { + key: "PfeType", + get: function get$$1() { + return PFElement.PfeTypes.Container; + } + }]); + + function PfeCard() { + classCallCheck(this, PfeCard); + + var _this = possibleConstructorReturn(this, (PfeCard.__proto__ || Object.getPrototypeOf(PfeCard)).call(this, PfeCard, { type: PfeCard.PfeType })); + + _this._observer = new MutationObserver(function () { + _this._mapSchemaToSlots(_this.tag, _this.slots); + }); + return _this; + } + + createClass(PfeCard, [{ + key: "connectedCallback", + value: function connectedCallback() { + get(PfeCard.prototype.__proto__ || Object.getPrototypeOf(PfeCard.prototype), "connectedCallback", this).call(this); + + // Initialize the background image attachment + if (this.imageSrc) { + this._imgSrcChanged("pfe-img-src", "", this.imageSrc); + } + + this._observer.observe(this, { childList: true }); + } + }, { + key: "disconnectedCallback", + value: function disconnectedCallback() { + this._observer.disconnect(); + } + }, { + key: "attributeChangedCallback", + value: function attributeChangedCallback(attr, oldValue, newValue) { + get(PfeCard.prototype.__proto__ || Object.getPrototypeOf(PfeCard.prototype), "attributeChangedCallback", this).call(this, attr, oldValue, newValue); + // Strip the prefix from the attribute + attr = attr.replace("pfe-", ""); + // If the observer is defined in the attribute properties + if (this[attr] && this[attr].observer) { + // Get the observer function + var observer = this[this[attr].observer].bind(this); + // If it's a function, allow it to run + if (typeof observer === "function") observer(attr, oldValue, newValue); + } + } + }, { + key: "_basicAttributeChanged", + value: function _basicAttributeChanged(attr, oldValue, newValue) { + this[attr].value = newValue; + } + + // Update the color attribute and contexts + + }, { + key: "_colorChanged", + value: function _colorChanged(attr, oldValue, newValue) { + this[attr].value = newValue; + // Trigger an update in nested components + this.context_update(); + } + + // Update the background image + + }, { + key: "_imgSrcChanged", + value: function _imgSrcChanged(attr, oldValue, newValue) { + // Set the image as the background image + this.style.backgroundImage = newValue ? "url('" + newValue + "')" : ""; + } + }]); + return PfeCard; + }(PFElement); + + PFElement.create(PfeCard); + + return PfeCard; + +}))); +//# sourceMappingURL=pfe-card.umd.js.map diff --git a/elements/pfe-card/dist/pfe-card.umd.js.map b/elements/pfe-card/dist/pfe-card.umd.js.map new file mode 100644 index 0000000000..f9f71a1480 --- /dev/null +++ b/elements/pfe-card/dist/pfe-card.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-card.umd.js","sources":["../_temp/polyfills--pfe-card.js","../_temp/pfe-card.umd.js"],"sourcesContent":["// @POLYFILL Element.matches\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/matches\nif (!Element.prototype.matches) {\n Element.prototype.matches =\n Element.prototype.msMatchesSelector ||\n Element.prototype.webkitMatchesSelector;\n}\n\n// @POLYFILL Element.closest\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/closest\nif (!Element.prototype.closest) {\n Element.prototype.closest = function(s) {\n var el = this;\n do {\n if (el.matches(s)) return el;\n el = el.parentElement || el.parentNode;\n } while (el !== null && el.nodeType === 1);\n return null;\n };\n}\n\n// @POLYFILL Array.includes\n// https://tc39.github.io/ecma262/#sec-array.prototype.includes\nif (!Array.prototype.includes) {\n Object.defineProperty(Array.prototype, \"includes\", {\n value: function(valueToFind, fromIndex) {\n if (this == null) {\n throw new TypeError('\"this\" is null or not defined');\n }\n\n // 1. Let O be ? ToObject(this value).\n var o = Object(this);\n\n // 2. Let len be ? ToLength(? Get(O, \"length\")).\n var len = o.length >>> 0;\n\n // 3. If len is 0, return false.\n if (len === 0) {\n return false;\n }\n\n // 4. Let n be ? ToInteger(fromIndex).\n // (If fromIndex is undefined, this step produces the value 0.)\n var n = fromIndex | 0;\n\n // 5. If n ≥ 0, then\n // a. Let k be n.\n // 6. Else n < 0,\n // a. Let k be len + n.\n // b. If k < 0, let k be 0.\n var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);\n\n function sameValueZero(x, y) {\n return (\n x === y ||\n (typeof x === \"number\" &&\n typeof y === \"number\" &&\n isNaN(x) &&\n isNaN(y))\n );\n }\n\n // 7. Repeat, while k < len\n while (k < len) {\n // a. Let elementK be the result of ? Get(O, ! ToString(k)).\n // b. If SameValueZero(valueToFind, elementK) is true, return true.\n if (sameValueZero(o[k], valueToFind)) {\n return true;\n }\n // c. Increase k by 1.\n k++;\n }\n\n // 8. Return false\n return false;\n }\n });\n}\n","/*!\n * PatternFly Elements: PfeCard 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\n// Import polyfills: matches, closest, includes\nimport \"./polyfills--pfe-card.js\";\n\nimport PFElement from \"../../pfelement/dist/pfelement.umd\";\n\nclass PfeCard extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
    \n \n
    \n
    \n \n
    \n
    \n \n
    `;\n }\n\n static get properties() {\n return {\"color\":{\"title\":\"Background color\",\"type\":\"string\",\"enum\":[\"lightest\",\"base\",\"darker\",\"darkest\",\"complement\",\"accent\"],\"default\":\"base\",\"prefixed\":true,\"observer\":\"_colorChanged\"},\"img-src\":{\"title\":\"Background image\",\"type\":\"string\",\"observer\":\"_imgSrcChanged\"},\"size\":{\"title\":\"Padding size\",\"type\":\"string\",\"enum\":[\"small\"],\"observer\":\"_basicAttributeChanged\"}};\n }\n\n static get slots() {\n return {\"header\":{\"title\":\"Header\",\"type\":\"array\",\"namedSlot\":true,\"maxItems\":3,\"items\":{\"title\":\"Body item\",\"oneOf\":[{\"$ref\":\"raw\"}]}},\"body\":{\"title\":\"Body\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-card\"},{\"$ref\":\"raw\"}]}},\"footer\":{\"title\":\"Footer\",\"type\":\"array\",\"namedSlot\":true,\"maxItems\":3,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-cta\"},{\"$ref\":\"raw\"}]}}};\n }\n static get tag() {\n return \"pfe-card\";\n }\n\n get schemaUrl() {\n return \"pfe-card.json\";\n }\n\n get templateUrl() {\n return \"pfe-card.html\";\n }\n\n get styleUrl() {\n return \"pfe-card.scss\";\n }\n\n get imageSrc() {\n return this.getAttribute(\"pfe-img-src\");\n }\n\n get backgroundColor() {\n return this.getAttribute(\"pfe-color\") || \"base\";\n }\n\n static get observedAttributes() {\n return [\"pfe-color\", \"pfe-img-src\", \"pfe-size\"];\n }\n\n // Declare the type of this component\n static get PfeType() {\n return PFElement.PfeTypes.Container;\n }\n\n constructor() {\n super(PfeCard, { type: PfeCard.PfeType });\n this._observer = new MutationObserver(() => {\n this._mapSchemaToSlots(this.tag, this.slots);\n });\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n // Initialize the background image attachment\n if (this.imageSrc) {\n this._imgSrcChanged(\"pfe-img-src\", \"\", this.imageSrc);\n }\n\n this._observer.observe(this, { childList: true });\n }\n\n disconnectedCallback() {\n this._observer.disconnect();\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n super.attributeChangedCallback(attr, oldValue, newValue);\n // Strip the prefix from the attribute\n attr = attr.replace(\"pfe-\", \"\");\n // If the observer is defined in the attribute properties\n if (this[attr] && this[attr].observer) {\n // Get the observer function\n let observer = this[this[attr].observer].bind(this);\n // If it's a function, allow it to run\n if (typeof observer === \"function\") observer(attr, oldValue, newValue);\n }\n }\n\n _basicAttributeChanged(attr, oldValue, newValue) {\n this[attr].value = newValue;\n }\n\n // Update the color attribute and contexts\n _colorChanged(attr, oldValue, newValue) {\n this[attr].value = newValue;\n // Trigger an update in nested components\n this.context_update();\n }\n\n // Update the background image\n _imgSrcChanged(attr, oldValue, newValue) {\n // Set the image as the background image\n this.style.backgroundImage = newValue ? `url('${newValue}')` : ``;\n }\n}\n\nPFElement.create(PfeCard);\n\nexport { PfeCard as default };\n"],"names":["Element","prototype","matches","msMatchesSelector","webkitMatchesSelector","closest","s","el","parentElement","parentNode","nodeType","Array","includes","Object","defineProperty","value","valueToFind","fromIndex","TypeError","o","len","length","n","k","Math","max","abs","sameValueZero","x","y","isNaN","PfeCard","getAttribute","PFElement","PfeTypes","Container","type","PfeType","_observer","MutationObserver","_mapSchemaToSlots","tag","slots","imageSrc","_imgSrcChanged","observe","childList","disconnect","attr","oldValue","newValue","replace","observer","bind","context_update","style","backgroundImage","create"],"mappings":";;;;;;;;EAAA;EACA;EACA,IAAI,CAACA,QAAQC,SAAR,CAAkBC,OAAvB,EAAgC;EAC9BF,UAAQC,SAAR,CAAkBC,OAAlB,GACEF,QAAQC,SAAR,CAAkBE,iBAAlB,IACAH,QAAQC,SAAR,CAAkBG,qBAFpB;EAGD;;EAED;EACA;EACA,IAAI,CAACJ,QAAQC,SAAR,CAAkBI,OAAvB,EAAgC;EAC9BL,UAAQC,SAAR,CAAkBI,OAAlB,GAA4B,UAASC,CAAT,EAAY;EACtC,QAAIC,KAAK,IAAT;EACA,OAAG;EACD,UAAIA,GAAGL,OAAH,CAAWI,CAAX,CAAJ,EAAmB,OAAOC,EAAP;EACnBA,WAAKA,GAAGC,aAAH,IAAoBD,GAAGE,UAA5B;EACD,KAHD,QAGSF,OAAO,IAAP,IAAeA,GAAGG,QAAH,KAAgB,CAHxC;EAIA,WAAO,IAAP;EACD,GAPD;EAQD;;EAED;EACA;EACA,IAAI,CAACC,MAAMV,SAAN,CAAgBW,QAArB,EAA+B;EAC7BC,SAAOC,cAAP,CAAsBH,MAAMV,SAA5B,EAAuC,UAAvC,EAAmD;EACjDc,WAAO,eAASC,WAAT,EAAsBC,SAAtB,EAAiC;EACtC,UAAI,QAAQ,IAAZ,EAAkB;EAChB,cAAM,IAAIC,SAAJ,CAAc,+BAAd,CAAN;EACD;;EAED;EACA,UAAIC,IAAIN,OAAO,IAAP,CAAR;;EAEA;EACA,UAAIO,MAAMD,EAAEE,MAAF,KAAa,CAAvB;;EAEA;EACA,UAAID,QAAQ,CAAZ,EAAe;EACb,eAAO,KAAP;EACD;;EAED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gB,CAAjB;EAFY;EAKb;;;;0CAEmB;EAClB;;EAEA;EACA,UAAI,KAAKC,QAAT,EAAmB;EACjB,aAAKC,cAAL,CAAoB,aAApB,EAAmC,EAAnC,EAAuC,KAAKD,QAA5C;EACD;;EAED,WAAKL,SAAL,CAAeO,OAAf,CAAuB,IAAvB,EAA6B,EAAEC,WAAW,IAAb,EAA7B;EACD;;;6CAEsB;EACrB,WAAKR,SAAL,CAAeS,UAAf;EACD;;;+CAEwBC,MAAMC,UAAUC,UAAU;EACjD,gIAA+BF,IAA/B,EAAqCC,QAArC,EAA+CC,QAA/C;EACA;EACAF,aAAOA,KAAKG,OAAL,CAAa,MAAb,EAAqB,EAArB,CAAP;EACA;EACA,UAAI,KAAKH,IAAL,KAAc,KAAKA,IAAL,EAAWI,QAA7B,EAAuC;EACrC;EACA,YAAIA,WAAW,KAAK,KAAKJ,IAAL,EAAWI,QAAhB,EAA0BC,IAA1B,CAA+B,IAA/B,CAAf;EACA;EACA,YAAI,OAAOD,QAAP,KAAoB,UAAxB,EAAoCA,SAASJ,IAAT,EAAeC,QAAf,EAAyBC,QAAzB;EACrC;EACF;;;6CAEsBF,MAAMC,UAAUC,UAAU;EAC/C,WAAKF,IAAL,EAAWjC,KAAX,GAAmBmC,QAAnB;EACD;;EAED;;;;oCACcF,MAAMC,UAAUC,UAAU;EACtC,WAAKF,IAAL,EAAWjC,KAAX,GAAmBmC,QAAnB;EACA;EACA,WAAKI,cAAL;EACD;;EAED;;;;qCACeN,MAAMC,UAAUC,UAAU;EACvC;EACA,WAAKK,KAAL,CAAWC,eAAX,GAA6BN,qBAAmBA,QAAnB,YAA7B;EACD;;;IA7GmBjB;;EAgHtBA,UAAUwB,MAAV,CAAiB1B,OAAjB;;;;;;;;"} \ No newline at end of file diff --git a/elements/pfe-card/dist/pfe-card.umd.min.js b/elements/pfe-card/dist/pfe-card.umd.min.js new file mode 100644 index 0000000000..6a75925f8b --- /dev/null +++ b/elements/pfe-card/dist/pfe-card.umd.min.js @@ -0,0 +1,2 @@ +!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r(require("../../pfelement/dist/pfelement.umd")):"function"==typeof define&&define.amd?define(["../../pfelement/dist/pfelement.umd"],r):e.PfeCard=r(e.PFElement)}(this,function(e){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e,Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){var r=this;do{if(r.matches(e))return r;r=r.parentElement||r.parentNode}while(null!==r&&1===r.nodeType);return null}),Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{value:function(e,r){if(null==this)throw new TypeError('"this" is null or not defined');var t=Object(this),a=t.length>>>0;if(0==a)return!1;var o,c,d=0|r,n=Math.max(0<=d?d:a-Math.abs(d),0);for(;n@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host([pfe-color=accent]),:host([pfe-color=base]),:host([pfe-color=complement]),:host([pfe-color=darker]),:host([pfe-color=darkest]),:host([pfe-color=lightest]){background-color:#fff!important;color:#151515!important}}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host{color:#151515!important}}:host{--theme:var(--pfe-card--theme, var(--pfe-theme--color--surface--base--theme, light));display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;justify-items:flex-start;-webkit-align-self:stretch;-ms-flex-item-align:stretch;align-self:stretch;padding:calc(16px * 2) calc(16px * 2) calc(16px * 2) calc(16px * 2);padding:var(--pfe-card--Padding,var(--pfe-card--PaddingTop,calc(var(--pfe-theme--container-spacer,16px) * 2)) var(--pfe-card--PaddingRight,calc(var(--pfe-theme--container-spacer,16px) * 2)) var(--pfe-card--PaddingBottom,calc(var(--pfe-theme--container-spacer,16px) * 2)) var(--pfe-card--PaddingLeft,calc(var(--pfe-theme--container-spacer,16px) * 2)));border:0 solid #d2d2d2;border:var(--pfe-card--Border,var(--pfe-card--BorderWidth,0) var(--pfe-card--BorderStyle,solid) var(--pfe-card--BorderColor,var(--pfe-theme--color--surface--border,#d2d2d2)));border-radius:3px;border-radius:var(--pfe-card--BorderRadius,var(--pfe-theme--surface--border-radius,3px));overflow:hidden;background-color:#f0f0f0;background-color:var(--pfe-card--BackgroundColor,var(--pfe-theme--color--surface--base,#f0f0f0));background-position:center center;background-position:var(--pfe-card--BackgroundPosition,center center);color:#3c3f42;color:var(--pfe-broadcasted--text,#3c3f42)}@media print{:host{background-color:#fff!important;background-image:none!important;-webkit-box-shadow:none!important;box-shadow:none!important}}@media print{:host{border-radius:3px;border:1px solid #d2d2d2}}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host{background-color:#fff!important;background-color:var(--pfe-theme--color--surface--lightest,#fff)!important;color:#151515!important;color:var(--pfe-theme--color--text,#151515)!important;background-image:none!important;border-radius:3px;border:1px solid #d2d2d2;padding:16px;padding:var(--pfe-theme--container-spacer,16px)}}:host([pfe-color=darker]){--pfe-card--BackgroundColor:var(--pfe-theme--color--surface--darker, #3c3f42);--pfe-card--theme:var(--pfe-theme--color--surface--darker--theme, dark)}:host([pfe-color=darkest]){--pfe-card--BackgroundColor:var(--pfe-theme--color--surface--darkest, #151515);--pfe-card--theme:var(--pfe-theme--color--surface--darkest--theme, dark)}:host([pfe-color=base]){--pfe-card--BackgroundColor:var(--pfe-theme--color--surface--base, #f0f0f0);--pfe-card--theme:var(--pfe-theme--color--surface--base--theme, light)}:host([pfe-color=lightest]){--pfe-card--BackgroundColor:var(--pfe-theme--color--surface--lightest, #fff);--pfe-card--theme:var(--pfe-theme--color--surface--lightest--theme, light)}:host([pfe-color=accent]){--pfe-card--BackgroundColor:var(--pfe-theme--color--surface--accent, #004080);--pfe-card--theme:var(--pfe-theme--color--surface--accent--theme, saturated)}:host([pfe-color=complement]){--pfe-card--BackgroundColor:var(--pfe-theme--color--surface--complement, #002952);--pfe-card--theme:var(--pfe-theme--color--surface--complement--theme, saturated)}:host([on=dark]){--pfe-broadcasted--text:var(--pfe-theme--color--text--on-dark, #fff);--pfe-broadcasted--link:var(--pfe-theme--color--link--on-dark, #73bcf7);--pfe-broadcasted--link--hover:var(--pfe-theme--color--link--hover--on-dark, #bee1f4);--pfe-broadcasted--link--focus:var(--pfe-theme--color--link--focus--on-dark, #bee1f4);--pfe-broadcasted--link--visited:var(--pfe-theme--color--link--visited--on-dark, #bee1f4);--pfe-broadcasted--link-decoration:var(--pfe-theme--link-decoration--on-dark, none);--pfe-broadcasted--link-decoration--hover:var(--pfe-theme--link-decoration--hover--on-dark, underline);--pfe-broadcasted--link-decoration--focus:var(--pfe-theme--link-decoration--focus--on-dark, underline);--pfe-broadcasted--link-decoration--visited:var(--pfe-theme--link-decoration--visited--on-dark, none)}:host([on=saturated]){--pfe-broadcasted--text:var(--pfe-theme--color--text--on-saturated, #fff);--pfe-broadcasted--link:var(--pfe-theme--color--link--on-saturated, #fff);--pfe-broadcasted--link--hover:var(--pfe-theme--color--link--hover--on-saturated, #fafafa);--pfe-broadcasted--link--focus:var(--pfe-theme--color--link--focus--on-saturated, #fafafa);--pfe-broadcasted--link--visited:var(--pfe-theme--color--link--visited--on-saturated, #8476d1);--pfe-broadcasted--link-decoration:var(--pfe-theme--link-decoration--on-saturated, underline);--pfe-broadcasted--link-decoration--hover:var(--pfe-theme--link-decoration--hover--on-saturated, underline);--pfe-broadcasted--link-decoration--focus:var(--pfe-theme--link-decoration--focus--on-saturated, underline);--pfe-broadcasted--link-decoration--visited:var(--pfe-theme--link-decoration--visited--on-saturated, underline)}:host([on=light]){--pfe-broadcasted--text:var(--pfe-theme--color--text, #151515);--pfe-broadcasted--link:var(--pfe-theme--color--link, #06c);--pfe-broadcasted--link--hover:var(--pfe-theme--color--link--hover, #004080);--pfe-broadcasted--link--focus:var(--pfe-theme--color--link--focus, #004080);--pfe-broadcasted--link--visited:var(--pfe-theme--color--link--visited, #6753ac);--pfe-broadcasted--link-decoration:var(--pfe-theme--link-decoration, none);--pfe-broadcasted--link-decoration--hover:var(--pfe-theme--link-decoration--hover, underline);--pfe-broadcasted--link-decoration--focus:var(--pfe-theme--link-decoration--focus, underline);--pfe-broadcasted--link-decoration--visited:var(--pfe-theme--link-decoration--visited, none)}:host([pfe-size=small]){--pfe-card--PaddingTop:var(--pfe-theme--container-spacer, 16px);--pfe-card--PaddingRight:var(--pfe-theme--container-spacer, 16px);--pfe-card--PaddingBottom:var(--pfe-theme--container-spacer, 16px);--pfe-card--PaddingLeft:var(--pfe-theme--container-spacer, 16px)}:host([pfe-border]:not([pfe-border=false])){--pfe-card--BorderWidth:1px}.pfe-card__body ::slotted([pfe-overflow~=top]),.pfe-card__footer ::slotted([pfe-overflow~=top]),.pfe-card__header ::slotted([pfe-overflow~=top]){z-index:1;margin-top:-2rem;margin-top:calc(-1 * calc(16px * 2))!important;margin-top:calc(-1 * var(--pfe-card--PaddingTop,calc(var(--pfe-theme--container-spacer,16px) * 2)))!important}:host([has_header]) .pfe-card__body ::slotted([pfe-overflow~=top]),:host([has_header]) .pfe-card__footer ::slotted([pfe-overflow~=top]),:host([has_header]) .pfe-card__header ::slotted([pfe-overflow~=top]){padding-top:16px;padding-top:var(--pfe-card--spacing,var(--pfe-theme--container-spacer,16px))}.pfe-card__body ::slotted([pfe-overflow~=right]),.pfe-card__footer ::slotted([pfe-overflow~=right]),.pfe-card__header ::slotted([pfe-overflow~=right]){margin-right:-2rem;margin-right:calc(-1 * calc(16px * 2));margin-right:calc(-1 * var(--pfe-card--PaddingRight,calc(var(--pfe-theme--container-spacer,16px) * 2)))}.pfe-card__body ::slotted([pfe-overflow~=bottom]),.pfe-card__footer ::slotted([pfe-overflow~=bottom]),.pfe-card__header ::slotted([pfe-overflow~=bottom]){margin-bottom:-2rem;margin-bottom:calc(-1 * calc(calc(16px * 2) + 3px));margin-bottom:calc(-1 * calc(var(--pfe-card--PaddingBottom,calc(var(--pfe-theme--container-spacer,16px) * 2)) + var(--pfe-card--BorderRadius,var(--pfe-theme--surface--border-radius,3px))));-webkit-align-self:flex-end;-ms-flex-item-align:end;align-self:flex-end}.pfe-card__body ::slotted([pfe-overflow~=left]),.pfe-card__footer ::slotted([pfe-overflow~=left]),.pfe-card__header ::slotted([pfe-overflow~=left]){margin-left:-2rem;margin-left:calc(-1 * calc(16px * 2));margin-left:calc(-1 * var(--pfe-card--PaddingLeft,calc(var(--pfe-theme--container-spacer,16px) * 2)))}.pfe-card__body ::slotted(img),.pfe-card__footer ::slotted(img),.pfe-card__header ::slotted(img){max-width:100%!important;-webkit-align-self:flex-start;-ms-flex-item-align:start;align-self:flex-start;-o-object-fit:cover;object-fit:cover}.pfe-card__body ::slotted(img:not[pfe-overflow]),.pfe-card__footer ::slotted(img:not[pfe-overflow]),.pfe-card__header ::slotted(img:not[pfe-overflow]){-webkit-align-self:flex-start;-ms-flex-item-align:start;align-self:flex-start}.pfe-card__body ::slotted(img[pfe-overflow~=right]),.pfe-card__footer ::slotted(img[pfe-overflow~=right]),.pfe-card__header ::slotted(img[pfe-overflow~=right]){max-width:calc(100% + 2rem)!important;max-width:calc(100% + calc(16px * 2))!important;max-width:calc(100% + var(--pfe-card--PaddingRight,calc(var(--pfe-theme--container-spacer,16px) * 2)))!important}.pfe-card__body ::slotted(img[pfe-overflow~=left]),.pfe-card__footer ::slotted(img[pfe-overflow~=left]),.pfe-card__header ::slotted(img[pfe-overflow~=left]){max-width:calc(100% + 2rem)!important;max-width:calc(100% + calc(16px * 2))!important;max-width:calc(100% + var(--pfe-card--PaddingLeft,calc(var(--pfe-theme--container-spacer,16px) * 2)))!important}.pfe-card__body ::slotted(img[pfe-overflow~=right][pfe-overflow~=left]),.pfe-card__footer ::slotted(img[pfe-overflow~=right][pfe-overflow~=left]),.pfe-card__header ::slotted(img[pfe-overflow~=right][pfe-overflow~=left]){max-width:calc(100% + 4rem)!important;max-width:calc(100% + calc(calc(16px * 2) + calc(16px * 2)))!important;max-width:calc(100% + calc(var(--pfe-card--PaddingRight,calc(var(--pfe-theme--container-spacer,16px) * 2)) + var(--pfe-card--PaddingLeft,calc(var(--pfe-theme--container-spacer,16px) * 2))))!important}.pfe-card__header{z-index:2;background-color:rgba(0,0,0,.09);background-color:var(--pfe-card__header--BackgroundColor,rgba(0,0,0,var(--pfe-theme--opacity,.09)));color:#3c3f42;color:var(--pfe-card__header--Color,var(--pfe-broadcasted--text,#3c3f42));margin-top:calc(calc(16px * 2) * -1)!important;margin-top:calc(var(--pfe-card--PaddingTop,calc(var(--pfe-theme--container-spacer,16px) * 2)) * -1)!important;margin-right:calc(calc(16px * 2) * -1);margin-right:calc(var(--pfe-card--PaddingRight,calc(var(--pfe-theme--container-spacer,16px) * 2)) * -1);margin-bottom:16px;margin-bottom:var(--pfe-card--spacing--vertical,var(--pfe-card--spacing,var(--pfe-theme--container-spacer,16px)));margin-left:calc(calc(16px * 2) * -1);margin-left:calc(var(--pfe-card--PaddingLeft,calc(var(--pfe-theme--container-spacer,16px) * 2)) * -1);padding-top:16px;padding-top:var(--pfe-card--spacing--vertical,var(--pfe-card--spacing,var(--pfe-theme--container-spacer,16px)));padding-right:calc(16px * 2);padding-right:var(--pfe-card--PaddingRight,calc(var(--pfe-theme--container-spacer,16px) * 2));padding-left:calc(16px * 2);padding-left:var(--pfe-card--PaddingLeft,calc(var(--pfe-theme--container-spacer,16px) * 2));padding-bottom:16px;padding-bottom:var(--pfe-card--spacing--vertical,var(--pfe-card--spacing,var(--pfe-theme--container-spacer,16px)))}:host([on=dark]) .pfe-card__header{background-color:rgba(255,255,255,.09);background-color:var(--pfe-card__header--BackgroundColor--dark,rgba(255,255,255,var(--pfe-theme--opacity,.09)))}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){.pfe-card__header{background-color:#fff!important;color:#151515!important;color:var(--pfe-theme--color--text,#151515)!important}}:host(:not([has_body]):not([has_footer])) .pfe-card__header{margin-bottom:calc(16px * 2);margin-bottom:var(--pfe-card--PaddingBottom,calc(var(--pfe-theme--container-spacer,16px) * 2))}.pfe-card__header ::slotted([pfe-overflow~=top]){--pfe-card__overflow--MarginTop:calc(var(--pfe-card--PaddingTop, calc(var(--pfe-theme--container-spacer, 16px) * 2)) * -1)}:host(:not([has_header])) .pfe-card__header{display:none}:host([has_body],[has_footer]) .pfe-card__header ::slotted([pfe-overflow~=bottom]){--pfe-card__overflow--MarginBottom:calc(var(--pfe-card--spacing--vertical, var(--pfe-card--spacing, var(--pfe-theme--container-spacer, 16px))) * -1)}.pfe-card__header ::slotted([pfe-overflow~=bottom]){--pfe-card__overflow--MarginBottom:calc(var(--pfe-card--PaddingBottom, calc(var(--pfe-theme--container-spacer, 16px) * 2)) * -1)}.pfe-card__header ::slotted(h1){margin-bottom:0}.pfe-card__header ::slotted(h2){margin-bottom:0}.pfe-card__header ::slotted(h3){margin-bottom:0}.pfe-card__header ::slotted(h4){margin-bottom:0}.pfe-card__header ::slotted(h5){margin-bottom:0}.pfe-card__header ::slotted(h6){margin-bottom:0}:host(:not([has_header])) .pfe-card__body ::slotted([pfe-overflow~=top]){--pfe-card__overflow--MarginTop:calc(var(--pfe-card--PaddingTop, calc(var(--pfe-theme--container-spacer, 16px) * 2)) * -1)}.pfe-card__body ::slotted([pfe-overflow~=top]){z-index:1;--pfe-card__overflow--MarginTop:calc(var(--pfe-card--spacing--vertical, var(--pfe-card--spacing, var(--pfe-theme--container-spacer, 16px))) * -1)}.pfe-card__body ::slotted([pfe-overflow~=bottom]){--pfe-card__overflow--MarginBottom:calc(var(--pfe-card--PaddingBottom, calc(var(--pfe-theme--container-spacer, 16px) * 2)) * -1)}:host([has_footer]) .pfe-card__body ::slotted([pfe-overflow~=bottom]){--pfe-card__overflow--MarginBottom:calc(var(--pfe-card--spacing--vertical, var(--pfe-card--spacing, var(--pfe-theme--container-spacer, 16px))) * -1)}:host(:not([has_footer])) .pfe-card__body{margin-bottom:0}.pfe-card__footer{margin-top:auto;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;flex-direction:var(--pfe-card__footer--Row,row);-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap;-webkit-flex-wrap:var(--pfe-card__footer--Wrap,wrap);-ms-flex-wrap:var(--pfe-card__footer--Wrap,wrap);flex-wrap:var(--pfe-card__footer--Wrap,wrap);-webkit-box-align:baseline;-webkit-align-items:baseline;-ms-flex-align:baseline;align-items:baseline;-webkit-box-align:var(--pfe-card__footer--AlignItems,baseline);-webkit-align-items:var(--pfe-card__footer--AlignItems,baseline);-ms-flex-align:var(--pfe-card__footer--AlignItems,baseline);align-items:var(--pfe-card__footer--AlignItems,baseline)}.pfe-card__footer ::slotted([pfe-overflow~=bottom]){--pfe-card__overflow--MarginBottom:calc(var(--pfe-card--PaddingBottom, calc(var(--pfe-theme--container-spacer, 16px) * 2)) * -1)}:host(:not([has_footer])) .pfe-card__footer{display:none}.pfe-card__body,.pfe-card__header{margin-bottom:16px;margin-bottom:var(--pfe-card--spacing--vertical,var(--pfe-card--spacing,var(--pfe-theme--container-spacer,16px)))}.pfe-card__body ::slotted(p:first-child),.pfe-card__header ::slotted(p:first-child){margin-top:0}.pfe-card__body ::slotted(h1:first-child),.pfe-card__header ::slotted(h1:first-child){margin-top:0}.pfe-card__body ::slotted(h2:first-child),.pfe-card__header ::slotted(h2:first-child){margin-top:0}.pfe-card__body ::slotted(h3:first-child),.pfe-card__header ::slotted(h3:first-child){margin-top:0}.pfe-card__body ::slotted(h4:first-child),.pfe-card__header ::slotted(h4:first-child){margin-top:0}.pfe-card__body ::slotted(h5:first-child),.pfe-card__header ::slotted(h5:first-child){margin-top:0}.pfe-card__body ::slotted(h6:first-child),.pfe-card__header ::slotted(h6:first-child){margin-top:0}\n/*# sourceMappingURL=pfe-card.min.css.map */\n
    \n \n
    \n
    \n \n
    \n'}},{key:"schemaUrl",get:function(){return"pfe-card.json"}},{key:"templateUrl",get:function(){return"pfe-card.html"}},{key:"styleUrl",get:function(){return"pfe-card.scss"}},{key:"imageSrc",get:function(){return this.getAttribute("pfe-img-src")}},{key:"backgroundColor",get:function(){return this.getAttribute("pfe-color")||"base"}}],[{key:"version",get:function(){return"1.0.0-prerelease.54"}},{key:"properties",get:function(){return{color:{title:"Background color",type:"string",enum:["lightest","base","darker","darkest","complement","accent"],default:"base",prefixed:!0,observer:"_colorChanged"},"img-src":{title:"Background image",type:"string",observer:"_imgSrcChanged"},size:{title:"Padding size",type:"string",enum:["small"],observer:"_basicAttributeChanged"}}}},{key:"slots",get:function(){return{header:{title:"Header",type:"array",namedSlot:!0,maxItems:3,items:{title:"Body item",oneOf:[{$ref:"raw"}]}},body:{title:"Body",type:"array",namedSlot:!1,items:{oneOf:[{$ref:"pfe-card"},{$ref:"raw"}]}},footer:{title:"Footer",type:"array",namedSlot:!0,maxItems:3,items:{oneOf:[{$ref:"pfe-cta"},{$ref:"raw"}]}}}}},{key:"tag",get:function(){return"pfe-card"}},{key:"observedAttributes",get:function(){return["pfe-color","pfe-img-src","pfe-size"]}},{key:"PfeType",get:function(){return e.PfeTypes.Container}}]),r(o,[{key:"connectedCallback",value:function(){d(o.prototype.__proto__||Object.getPrototypeOf(o.prototype),"connectedCallback",this).call(this),this.imageSrc&&this._imgSrcChanged("pfe-img-src","",this.imageSrc),this._observer.observe(this,{childList:!0})}},{key:"disconnectedCallback",value:function(){this._observer.disconnect()}},{key:"attributeChangedCallback",value:function(e,r,t){if(d(o.prototype.__proto__||Object.getPrototypeOf(o.prototype),"attributeChangedCallback",this).call(this,e,r,t),this[e=e.replace("pfe-","")]&&this[e].observer){var a=this[this[e].observer].bind(this);"function"==typeof a&&a(e,r,t)}}},{key:"_basicAttributeChanged",value:function(e,r,t){this[e].value=t}},{key:"_colorChanged",value:function(e,r,t){this[e].value=t,this.context_update()}},{key:"_imgSrcChanged",value:function(e,r,t){this.style.backgroundImage=t?"url('"+t+"')":""}}]),o);function o(){!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,o);var e=function(e,r){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!r||"object"!=typeof r&&"function"!=typeof r?e:r}(this,(o.__proto__||Object.getPrototypeOf(o)).call(this,o,{type:o.PfeType}));return e._observer=new MutationObserver(function(){e._mapSchemaToSlots(e.tag,e.slots)}),e}return e.create(t),t}); +//# sourceMappingURL=pfe-card.umd.min.js.map diff --git a/elements/pfe-card/dist/pfe-card.umd.min.js.map b/elements/pfe-card/dist/pfe-card.umd.min.js.map new file mode 100644 index 0000000000..95a7568843 --- /dev/null +++ b/elements/pfe-card/dist/pfe-card.umd.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-card.umd.min.js","sources":["../_temp/polyfills--pfe-card.js","../_temp/pfe-card.umd.js"],"sourcesContent":["// @POLYFILL Element.matches\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/matches\nif (!Element.prototype.matches) {\n Element.prototype.matches =\n Element.prototype.msMatchesSelector ||\n Element.prototype.webkitMatchesSelector;\n}\n\n// @POLYFILL Element.closest\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/closest\nif (!Element.prototype.closest) {\n Element.prototype.closest = function(s) {\n var el = this;\n do {\n if (el.matches(s)) return el;\n el = el.parentElement || el.parentNode;\n } while (el !== null && el.nodeType === 1);\n return null;\n };\n}\n\n// @POLYFILL Array.includes\n// https://tc39.github.io/ecma262/#sec-array.prototype.includes\nif (!Array.prototype.includes) {\n Object.defineProperty(Array.prototype, \"includes\", {\n value: function(valueToFind, fromIndex) {\n if (this == null) {\n throw new TypeError('\"this\" is null or not defined');\n }\n\n // 1. Let O be ? ToObject(this value).\n var o = Object(this);\n\n // 2. Let len be ? ToLength(? Get(O, \"length\")).\n var len = o.length >>> 0;\n\n // 3. If len is 0, return false.\n if (len === 0) {\n return false;\n }\n\n // 4. Let n be ? ToInteger(fromIndex).\n // (If fromIndex is undefined, this step produces the value 0.)\n var n = fromIndex | 0;\n\n // 5. If n ≥ 0, then\n // a. Let k be n.\n // 6. Else n < 0,\n // a. Let k be len + n.\n // b. If k < 0, let k be 0.\n var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);\n\n function sameValueZero(x, y) {\n return (\n x === y ||\n (typeof x === \"number\" &&\n typeof y === \"number\" &&\n isNaN(x) &&\n isNaN(y))\n );\n }\n\n // 7. Repeat, while k < len\n while (k < len) {\n // a. Let elementK be the result of ? Get(O, ! ToString(k)).\n // b. If SameValueZero(valueToFind, elementK) is true, return true.\n if (sameValueZero(o[k], valueToFind)) {\n return true;\n }\n // c. Increase k by 1.\n k++;\n }\n\n // 8. Return false\n return false;\n }\n });\n}\n","/*!\n * PatternFly Elements: PfeCard 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\n// Import polyfills: matches, closest, includes\nimport \"./polyfills--pfe-card.js\";\n\nimport PFElement from \"../../pfelement/dist/pfelement.umd\";\n\nclass PfeCard extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
    \n \n
    \n
    \n \n
    \n
    \n \n
    `;\n }\n\n static get properties() {\n return {\"color\":{\"title\":\"Background color\",\"type\":\"string\",\"enum\":[\"lightest\",\"base\",\"darker\",\"darkest\",\"complement\",\"accent\"],\"default\":\"base\",\"prefixed\":true,\"observer\":\"_colorChanged\"},\"img-src\":{\"title\":\"Background image\",\"type\":\"string\",\"observer\":\"_imgSrcChanged\"},\"size\":{\"title\":\"Padding size\",\"type\":\"string\",\"enum\":[\"small\"],\"observer\":\"_basicAttributeChanged\"}};\n }\n\n static get slots() {\n return {\"header\":{\"title\":\"Header\",\"type\":\"array\",\"namedSlot\":true,\"maxItems\":3,\"items\":{\"title\":\"Body item\",\"oneOf\":[{\"$ref\":\"raw\"}]}},\"body\":{\"title\":\"Body\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-card\"},{\"$ref\":\"raw\"}]}},\"footer\":{\"title\":\"Footer\",\"type\":\"array\",\"namedSlot\":true,\"maxItems\":3,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-cta\"},{\"$ref\":\"raw\"}]}}};\n }\n static get tag() {\n return \"pfe-card\";\n }\n\n get schemaUrl() {\n return \"pfe-card.json\";\n }\n\n get templateUrl() {\n return \"pfe-card.html\";\n }\n\n get styleUrl() {\n return \"pfe-card.scss\";\n }\n\n get imageSrc() {\n return this.getAttribute(\"pfe-img-src\");\n }\n\n get backgroundColor() {\n return this.getAttribute(\"pfe-color\") || \"base\";\n }\n\n static get observedAttributes() {\n return [\"pfe-color\", \"pfe-img-src\", \"pfe-size\"];\n }\n\n // Declare the type of this component\n static get PfeType() {\n return PFElement.PfeTypes.Container;\n }\n\n constructor() {\n super(PfeCard, { type: PfeCard.PfeType });\n this._observer = new MutationObserver(() => {\n this._mapSchemaToSlots(this.tag, this.slots);\n });\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n // Initialize the background image attachment\n if (this.imageSrc) {\n this._imgSrcChanged(\"pfe-img-src\", \"\", this.imageSrc);\n }\n\n this._observer.observe(this, { childList: true });\n }\n\n disconnectedCallback() {\n this._observer.disconnect();\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n super.attributeChangedCallback(attr, oldValue, newValue);\n // Strip the prefix from the attribute\n attr = attr.replace(\"pfe-\", \"\");\n // If the observer is defined in the attribute properties\n if (this[attr] && this[attr].observer) {\n // Get the observer function\n let observer = this[this[attr].observer].bind(this);\n // If it's a function, allow it to run\n if (typeof observer === \"function\") observer(attr, oldValue, newValue);\n }\n }\n\n _basicAttributeChanged(attr, oldValue, newValue) {\n this[attr].value = newValue;\n }\n\n // Update the color attribute and contexts\n _colorChanged(attr, oldValue, newValue) {\n this[attr].value = newValue;\n // Trigger an update in nested components\n this.context_update();\n }\n\n // Update the background image\n _imgSrcChanged(attr, oldValue, newValue) {\n // Set the image as the background image\n this.style.backgroundImage = newValue ? `url('${newValue}')` : ``;\n }\n}\n\nPFElement.create(PfeCard);\n\nexport { PfeCard as default };\n"],"names":["Element","prototype","matches","msMatchesSelector","webkitMatchesSelector","closest","s","el","this","parentElement","parentNode","nodeType","Array","includes","defineProperty","valueToFind","fromIndex","TypeError","o","Object","len","length","x","y","n","k","Math","max","abs","isNaN","PfeCard","PFElement","getAttribute","color","title","type","enum","default","prefixed","observer","img-src","size","header","namedSlot","maxItems","items","oneOf","$ref","body","footer","PfeTypes","Container","imageSrc","_imgSrcChanged","_observer","observe","childList","disconnect","attr","oldValue","newValue","replace","bind","value","context_update","style","backgroundImage","PfeType","MutationObserver","_mapSchemaToSlots","_this","tag","slots","create"],"mappings":"gUAEKA,QAAQC,UAAUC,kBACbD,UAAUC,QAChBF,QAAQC,UAAUE,mBAClBH,QAAQC,UAAUG,uBAKjBJ,QAAQC,UAAUI,kBACbJ,UAAUI,QAAU,SAASC,OAC/BC,EAAKC,OACN,IACGD,EAAGL,QAA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AO,WAAW,CAACA,KAAO,6CAGtW,4DAwBA,CAAC,YAAa,cAAe,mDAK7BhB,EAAUmB,SAASC,8JActB3C,KAAK4C,eACFC,eAAe,cAAe,GAAI7C,KAAK4C,eAGzCE,UAAUC,QAAQ/C,KAAM,CAAEgD,WAAW,wDAIrCF,UAAUG,8DAGQC,EAAMC,EAAUC,6GACRF,EAAMC,EAAUC,GAI3CpD,OAFGkD,EAAKG,QAAQ,OAAQ,MAEVrD,KAAKkD,GAAMnB,SAAU,KAEjCA,EAAW/B,KAAKA,KAAKkD,GAAMnB,UAAUuB,KAAKtD,MAEtB,mBAAb+B,GAAyBA,EAASmB,EAAMC,EAAUC,mDAI1CF,EAAMC,EAAUC,QAChCF,GAAMK,MAAQH,wCAIPF,EAAMC,EAAUC,QACvBF,GAAMK,MAAQH,OAEdI,wDAIQN,EAAMC,EAAUC,QAExBK,MAAMC,gBAAkBN,UAAmBA,mWAhD1C9B,EAAS,CAAEK,KAAML,EAAQqC,oBAC1Bb,UAAY,IAAIc,iBAAiB,aAC/BC,kBAAkBC,EAAKC,IAAKD,EAAKE,kBAkD5CzC,EAAU0C,OAAO3C"} \ No newline at end of file diff --git a/elements/pfe-card/package-lock.json b/elements/pfe-card/package-lock.json index 05cf053437..af08b49ecb 100644 --- a/elements/pfe-card/package-lock.json +++ b/elements/pfe-card/package-lock.json @@ -1,6 +1,6 @@ { "name": "@patternfly/pfe-card", - "version": "1.0.0-prerelease.53", + "version": "1.0.0-prerelease.54", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/elements/pfe-card/package.json b/elements/pfe-card/package.json index df46ad1f1b..8446331e23 100644 --- a/elements/pfe-card/package.json +++ b/elements/pfe-card/package.json @@ -4,7 +4,7 @@ "className": "PfeCard", "elementName": "pfe-card" }, - "version": "1.0.0-prerelease.53", + "version": "1.0.0-prerelease.54", "publishConfig": { "access": "public" }, @@ -49,7 +49,7 @@ "@patternfly/pfelement": "^1.0.0-prerelease.51" }, "devDependencies": { - "@patternfly/pfe-sass": "^1.0.0-prerelease.53" + "@patternfly/pfe-sass": "^1.0.0-prerelease.54" }, "generator-pfelement-version": "0.5.0", "bugs": { diff --git a/elements/pfe-collapse/dist/pfe-collapse.js b/elements/pfe-collapse/dist/pfe-collapse.js new file mode 100644 index 0000000000..f25595085e --- /dev/null +++ b/elements/pfe-collapse/dist/pfe-collapse.js @@ -0,0 +1,492 @@ +import PFElement from '../../pfelement/dist/pfelement.js'; + +/*! + * PatternFly Elements: PfeCollapse 1.0.0-prerelease.53 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * +*/ + +function generateId() { + return Math.random() + .toString(36) + .substr(2, 9); +} + +class PfeCollapseToggle extends PFElement { + static get version() { + return "1.0.0-prerelease.53"; + } + + get html() { + return ``; + } + + static get properties() { + return {}; + } + + static get slots() { + return {"default":{"title":"Default","type":"array","namedSlot":false,"items":{"oneOf":[{"$ref":"pfe-collapsibe-toggle"},{"$ref":"pfe-collapse-panel"}]}}}; + } + static get tag() { + return "pfe-collapse-toggle"; + } + + get templateUrl() { + return "pfe-collapse-toggle.html"; + } + + get styleUrl() { + return "pfe-collapse-toggle.scss"; + } + + get pfeId() { + return this.getAttribute("pfe-id"); + } + + set pfeId(id) { + if (!id) { + return; + } + + this.setAttribute("pfe-id", id); + } + + get expanded() { + return this.getAttribute("aria-expanded") === "true"; + } + + set expanded(val) { + const value = Boolean(val); + this.setAttribute("aria-expanded", value); + } + + static get observedAttributes() { + return ["aria-controls"]; + } + + constructor(pfeClass, { setTabIndex = true, addKeydownHandler = true } = {}) { + super(pfeClass || PfeCollapseToggle); + + this.controlledPanel = false; + this._setTabIndex = setTabIndex; + this._addKeydownHandler = addKeydownHandler; + + this.addEventListener("click", this._clickHandler); + + if (addKeydownHandler) { + this.addEventListener("keydown", this._keydownHandler); + } + } + + connectedCallback() { + super.connectedCallback(); + + this.expanded = false; + + // if (this.id && this.id !== "") { + if (this.id) { + this.pfeId = this.id; + } + + const generatedId = `${PfeCollapseToggle.tag}-${generateId()}`; + + if (!this.id) { + this.id = generatedId; + } + + if (!this.pfeId) { + this.pfeId = generatedId; + } + + this.setAttribute("role", "button"); + + if (this._setTabIndex) { + this.setAttribute("tabindex", 0); + } + + if (!this.controlledPanel) { + this._connectPanel(this.getAttribute("aria-controls")); + } + } + + disconnectedCallback() { + this.removeEventListener("click", this._clickHandler); + + if (this._addKeydownHandler) { + this.removeEventListener("keydown", this._keydownHandler); + } + } + + attributeChangedCallback(attr, oldVal, newVal) { + super.attributeChangedCallback(attr, oldVal, newVal); + + if (!newVal) { + return; + } + + this._connectPanel(newVal); + } + + toggle() { + if (this.hasAttribute("disabled")) { + return; + } + + this.expanded = !this.expanded; + + // one last try to hook up a panel + if (!this.controlledPanel) { + this._connectPanel(this.getAttribute("aria-controls")); + } + + if (this.controlledPanel) { + this.controlledPanel.expanded = this.expanded; + + this.emitEvent(PfeCollapse.events.change, { + detail: { + expanded: this.expanded, + toggle: this, + panel: this.controlledPanel + } + }); + } else { + console.warn( + `${this.tag}: This toggle doesn't have a panel associated with it` + ); + } + } + + _clickHandler() { + this.toggle(); + } + + _keydownHandler(event) { + const key = event.key; + + switch (key) { + case " ": + case "Spacebar": + case "Enter": + this.toggle(); + break; + } + } + + _connectPanel(id) { + // this can be an issue if the pfe-collapse is located within + // a shadow root + if (this.getRootNode) { + this.controlledPanel = this.getRootNode().querySelector(`#${id}`); + } else { + this.controlledPanel = document.querySelector(`#${id}`); + } + } +} + +class PfeCollapsePanel extends PFElement { + static get version() { + return "1.0.0-prerelease.53"; + } + + get html() { + return ``; + } + + static get properties() { + return {}; + } + + static get slots() { + return {"default":{"title":"Default","type":"array","namedSlot":false,"items":{"oneOf":[{"$ref":"pfe-collapsibe-toggle"},{"$ref":"pfe-collapse-panel"}]}}}; + } + static get tag() { + return "pfe-collapse-panel"; + } + + static get events() { + return { + animationStart: `${this.tag}:animation-start`, + animationEnd: `${this.tag}:animation-end` + }; + } + + get templateUrl() { + return "pfe-collapse-panel.html"; + } + + get styleUrl() { + return "pfe-collapse-panel.scss"; + } + + get pfeId() { + return this.getAttribute("pfe-id"); + } + + set pfeId(id) { + if (!id) { + return; + } + + this.setAttribute("pfe-id", id); + } + + get animates() { + return this.getAttribute("pfe-animation") === "false" ? false : true; + } + + get expanded() { + return this.hasAttribute("pfe-expanded"); + } + + set expanded(val) { + const value = Boolean(val); + + if (value) { + this.setAttribute("pfe-expanded", ""); + + if (this.animates) { + const height = this.getBoundingClientRect().height; + this._fireAnimationEvent("opening"); + this._animate(0, height); + } + } else { + if (this.hasAttribute("pfe-expanded")) { + const height = this.getBoundingClientRect().height; + this.removeAttribute("pfe-expanded"); + + if (this.animates) { + this._fireAnimationEvent("closing"); + this._animate(height, 0); + } + } + } + } + + constructor(pfeClass) { + super(pfeClass || PfeCollapsePanel); + } + + connectedCallback() { + super.connectedCallback(); + + this.expanded = false; + + // if (this.id && this.id !== "") { + if (this.id) { + this.pfeId = this.id; + } + + const generatedId = `${PfeCollapsePanel.tag}-${generateId()}`; + + if (!this.id) { + this.id = generatedId; + } + + if (!this.pfeId) { + this.pfeId = generatedId; + } + } + + _animate(start, end) { + this.classList.add("animating"); + this.style.height = `${start}px`; + + requestAnimationFrame(() => { + requestAnimationFrame(() => { + this.style.height = `${end}px`; + this.classList.add("animating"); + this.addEventListener("transitionend", this._transitionEndHandler); + }); + }); + } + + _transitionEndHandler(event) { + event.target.style.height = ""; + event.target.classList.remove("animating"); + event.target.removeEventListener( + "transitionend", + this._transitionEndHandler + ); + + this.emitEvent(PfeCollapsePanel.events.animationEnd, { + detail: { + expanded: this.expanded, + panel: this + } + }); + } + + _fireAnimationEvent(state) { + this.emitEvent(PfeCollapsePanel.events.animationStart, { + detail: { + state: state, + panel: this + } + }); + } +} + +class PfeCollapse extends PFElement { + static get version() { + return "1.0.0-prerelease.53"; + } + + get html() { + return ``; + } + + static get properties() { + return {}; + } + + static get slots() { + return {"default":{"title":"Default","type":"array","namedSlot":false,"items":{"oneOf":[{"$ref":"pfe-collapsibe-toggle"},{"$ref":"pfe-collapse-panel"}]}}}; + } + static get tag() { + return "pfe-collapse"; + } + + get templateUrl() { + return "pfe-collapse.html"; + } + + get styleUrl() { + return "pfe-collapse.scss"; + } + + get schemaUrl() { + return "pfe-collapse.json"; + } + + get animates() { + return this.getAttribute("pfe-animation") === "false" ? false : true; + } + + static get observedAttributes() { + return ["pfe-animation"]; + } + + static get events() { + return { + change: `${this.tag}:change` + }; + } + + constructor(pfeClass) { + super(pfeClass || PfeCollapse); + + this._toggle = null; + this._panel = null; + this._linkControls = this._linkControls.bind(this); + this._changeHandler = this._changeHandler.bind(this); + this._observer = new MutationObserver(this._linkControls); + + this.addEventListener(PfeCollapse.events.change, this._changeHandler); + this.addEventListener( + PfeCollapse.events.animationStart, + this._animationStartHandler + ); + this.addEventListener( + PfeCollapse.events.animationEnd, + this._animationEndHandler + ); + } + + connectedCallback() { + super.connectedCallback(); + + Promise.all([ + customElements.whenDefined(PfeCollapsePanel.tag), + customElements.whenDefined(PfeCollapseToggle.tag) + ]).then(() => { + if (this.children.length) { + this._linkControls(); + } + + this._observer.observe(this, { childList: true }); + }); + } + + disconnectedCallback() { + this.removeEventListener(PfeCollapse.events.change, this._changeHandler); + this.removeEventListener( + PfeCollapse.events.animationStart, + this._animationStartHandler + ); + this.removeEventListener( + PfeCollapse.events.animationEnd, + this._animationEndHandler + ); + this._observer.disconnect(); + } + + attributeChangedCallback(attr, oldVal, newVal) { + super.attributeChangedCallback(attr, oldVal, newVal); + + if (!newVal) { + return; + } + + if (newVal !== "false" && newVal !== "true") { + return; + } + + if (this._panel) { + this._panel.setAttribute("pfe-animation", newVal); + } + } + + toggle() { + this._toggle.toggle(); + } + + _linkControls() { + this._toggle = this.querySelector(PfeCollapseToggle.tag); + this._panel = this.querySelector(PfeCollapsePanel.tag); + + this._toggle.setAttribute("aria-controls", this._panel.pfeId); + } + + _animationStartHandler() { + this.classList.add("animating"); + } + + _animationEndHandler() { + this.classList.remove("animating"); + } + + _changeHandler(event) {} +} + +PFElement.create(PfeCollapse); +PFElement.create(PfeCollapseToggle); +PFElement.create(PfeCollapsePanel); + +export { PfeCollapse, PfeCollapseToggle, PfeCollapsePanel }; +//# sourceMappingURL=pfe-collapse.js.map diff --git a/elements/pfe-collapse/dist/pfe-collapse.js.map b/elements/pfe-collapse/dist/pfe-collapse.js.map new file mode 100644 index 0000000000..4795cb1e9e --- /dev/null +++ b/elements/pfe-collapse/dist/pfe-collapse.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-collapse.js","sources":["../_temp/pfe-collapse.js"],"sourcesContent":["/*!\n * PatternFly Elements: PfeCollapse 1.0.0-prerelease.53\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.js\";\n\nfunction generateId() {\n return Math.random()\n .toString(36)\n .substr(2, 9);\n}\n\nclass PfeCollapseToggle extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.53\";\n }\n\n get html() {\n return ``;\n }\n\n static get properties() {\n return {};\n }\n\n static get slots() {\n return {\"default\":{\"title\":\"Default\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-collapsibe-toggle\"},{\"$ref\":\"pfe-collapse-panel\"}]}}};\n }\n static get tag() {\n return \"pfe-collapse-toggle\";\n }\n\n get templateUrl() {\n return \"pfe-collapse-toggle.html\";\n }\n\n get styleUrl() {\n return \"pfe-collapse-toggle.scss\";\n }\n\n get pfeId() {\n return this.getAttribute(\"pfe-id\");\n }\n\n set pfeId(id) {\n if (!id) {\n return;\n }\n\n this.setAttribute(\"pfe-id\", id);\n }\n\n get expanded() {\n return this.getAttribute(\"aria-expanded\") === \"true\";\n }\n\n set expanded(val) {\n const value = Boolean(val);\n this.setAttribute(\"aria-expanded\", value);\n }\n\n static get observedAttributes() {\n return [\"aria-controls\"];\n }\n\n constructor(pfeClass, { setTabIndex = true, addKeydownHandler = true } = {}) {\n super(pfeClass || PfeCollapseToggle);\n\n this.controlledPanel = false;\n this._setTabIndex = setTabIndex;\n this._addKeydownHandler = addKeydownHandler;\n\n this.addEventListener(\"click\", this._clickHandler);\n\n if (addKeydownHandler) {\n this.addEventListener(\"keydown\", this._keydownHandler);\n }\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n this.expanded = false;\n\n // if (this.id && this.id !== \"\") {\n if (this.id) {\n this.pfeId = this.id;\n }\n\n const generatedId = `${PfeCollapseToggle.tag}-${generateId()}`;\n\n if (!this.id) {\n this.id = generatedId;\n }\n\n if (!this.pfeId) {\n this.pfeId = generatedId;\n }\n\n this.setAttribute(\"role\", \"button\");\n\n if (this._setTabIndex) {\n this.setAttribute(\"tabindex\", 0);\n }\n\n if (!this.controlledPanel) {\n this._connectPanel(this.getAttribute(\"aria-controls\"));\n }\n }\n\n disconnectedCallback() {\n this.removeEventListener(\"click\", this._clickHandler);\n\n if (this._addKeydownHandler) {\n this.removeEventListener(\"keydown\", this._keydownHandler);\n }\n }\n\n attributeChangedCallback(attr, oldVal, newVal) {\n super.attributeChangedCallback(attr, oldVal, newVal);\n\n if (!newVal) {\n return;\n }\n\n this._connectPanel(newVal);\n }\n\n toggle() {\n if (this.hasAttribute(\"disabled\")) {\n return;\n }\n\n this.expanded = !this.expanded;\n\n // one last try to hook up a panel\n if (!this.controlledPanel) {\n this._connectPanel(this.getAttribute(\"aria-controls\"));\n }\n\n if (this.controlledPanel) {\n this.controlledPanel.expanded = this.expanded;\n\n this.emitEvent(PfeCollapse.events.change, {\n detail: {\n expanded: this.expanded,\n toggle: this,\n panel: this.controlledPanel\n }\n });\n } else {\n console.warn(\n `${this.tag}: This toggle doesn't have a panel associated with it`\n );\n }\n }\n\n _clickHandler() {\n this.toggle();\n }\n\n _keydownHandler(event) {\n const key = event.key;\n\n switch (key) {\n case \" \":\n case \"Spacebar\":\n case \"Enter\":\n this.toggle();\n break;\n }\n }\n\n _connectPanel(id) {\n // this can be an issue if the pfe-collapse is located within\n // a shadow root\n if (this.getRootNode) {\n this.controlledPanel = this.getRootNode().querySelector(`#${id}`);\n } else {\n this.controlledPanel = document.querySelector(`#${id}`);\n }\n }\n}\n\nclass PfeCollapsePanel extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.53\";\n }\n\n get html() {\n return ``;\n }\n\n static get properties() {\n return {};\n }\n\n static get slots() {\n return {\"default\":{\"title\":\"Default\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-collapsibe-toggle\"},{\"$ref\":\"pfe-collapse-panel\"}]}}};\n }\n static get tag() {\n return \"pfe-collapse-panel\";\n }\n\n static get events() {\n return {\n animationStart: `${this.tag}:animation-start`,\n animationEnd: `${this.tag}:animation-end`\n };\n }\n\n get templateUrl() {\n return \"pfe-collapse-panel.html\";\n }\n\n get styleUrl() {\n return \"pfe-collapse-panel.scss\";\n }\n\n get pfeId() {\n return this.getAttribute(\"pfe-id\");\n }\n\n set pfeId(id) {\n if (!id) {\n return;\n }\n\n this.setAttribute(\"pfe-id\", id);\n }\n\n get animates() {\n return this.getAttribute(\"pfe-animation\") === \"false\" ? false : true;\n }\n\n get expanded() {\n return this.hasAttribute(\"pfe-expanded\");\n }\n\n set expanded(val) {\n const value = Boolean(val);\n\n if (value) {\n this.setAttribute(\"pfe-expanded\", \"\");\n\n if (this.animates) {\n const height = this.getBoundingClientRect().height;\n this._fireAnimationEvent(\"opening\");\n this._animate(0, height);\n }\n } else {\n if (this.hasAttribute(\"pfe-expanded\")) {\n const height = this.getBoundingClientRect().height;\n this.removeAttribute(\"pfe-expanded\");\n\n if (this.animates) {\n this._fireAnimationEvent(\"closing\");\n this._animate(height, 0);\n }\n }\n }\n }\n\n constructor(pfeClass) {\n super(pfeClass || PfeCollapsePanel);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n this.expanded = false;\n\n // if (this.id && this.id !== \"\") {\n if (this.id) {\n this.pfeId = this.id;\n }\n\n const generatedId = `${PfeCollapsePanel.tag}-${generateId()}`;\n\n if (!this.id) {\n this.id = generatedId;\n }\n\n if (!this.pfeId) {\n this.pfeId = generatedId;\n }\n }\n\n _animate(start, end) {\n this.classList.add(\"animating\");\n this.style.height = `${start}px`;\n\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n this.style.height = `${end}px`;\n this.classList.add(\"animating\");\n this.addEventListener(\"transitionend\", this._transitionEndHandler);\n });\n });\n }\n\n _transitionEndHandler(event) {\n event.target.style.height = \"\";\n event.target.classList.remove(\"animating\");\n event.target.removeEventListener(\n \"transitionend\",\n this._transitionEndHandler\n );\n\n this.emitEvent(PfeCollapsePanel.events.animationEnd, {\n detail: {\n expanded: this.expanded,\n panel: this\n }\n });\n }\n\n _fireAnimationEvent(state) {\n this.emitEvent(PfeCollapsePanel.events.animationStart, {\n detail: {\n state: state,\n panel: this\n }\n });\n }\n}\n\nclass PfeCollapse extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.53\";\n }\n\n get html() {\n return ``;\n }\n\n static get properties() {\n return {};\n }\n\n static get slots() {\n return {\"default\":{\"title\":\"Default\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-collapsibe-toggle\"},{\"$ref\":\"pfe-collapse-panel\"}]}}};\n }\n static get tag() {\n return \"pfe-collapse\";\n }\n\n get templateUrl() {\n return \"pfe-collapse.html\";\n }\n\n get styleUrl() {\n return \"pfe-collapse.scss\";\n }\n\n get schemaUrl() {\n return \"pfe-collapse.json\";\n }\n\n get animates() {\n return this.getAttribute(\"pfe-animation\") === \"false\" ? false : true;\n }\n\n static get observedAttributes() {\n return [\"pfe-animation\"];\n }\n\n static get events() {\n return {\n change: `${this.tag}:change`\n };\n }\n\n constructor(pfeClass) {\n super(pfeClass || PfeCollapse);\n\n this._toggle = null;\n this._panel = null;\n this._linkControls = this._linkControls.bind(this);\n this._changeHandler = this._changeHandler.bind(this);\n this._observer = new MutationObserver(this._linkControls);\n\n this.addEventListener(PfeCollapse.events.change, this._changeHandler);\n this.addEventListener(\n PfeCollapse.events.animationStart,\n this._animationStartHandler\n );\n this.addEventListener(\n PfeCollapse.events.animationEnd,\n this._animationEndHandler\n );\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n Promise.all([\n customElements.whenDefined(PfeCollapsePanel.tag),\n customElements.whenDefined(PfeCollapseToggle.tag)\n ]).then(() => {\n if (this.children.length) {\n this._linkControls();\n }\n\n this._observer.observe(this, { childList: true });\n });\n }\n\n disconnectedCallback() {\n this.removeEventListener(PfeCollapse.events.change, this._changeHandler);\n this.removeEventListener(\n PfeCollapse.events.animationStart,\n this._animationStartHandler\n );\n this.removeEventListener(\n PfeCollapse.events.animationEnd,\n this._animationEndHandler\n );\n this._observer.disconnect();\n }\n\n attributeChangedCallback(attr, oldVal, newVal) {\n super.attributeChangedCallback(attr, oldVal, newVal);\n\n if (!newVal) {\n return;\n }\n\n if (newVal !== \"false\" && newVal !== \"true\") {\n return;\n }\n\n if (this._panel) {\n this._panel.setAttribute(\"pfe-animation\", newVal);\n }\n }\n\n toggle() {\n this._toggle.toggle();\n }\n\n _linkControls() {\n this._toggle = this.querySelector(PfeCollapseToggle.tag);\n this._panel = this.querySelector(PfeCollapsePanel.tag);\n\n this._toggle.setAttribute(\"aria-controls\", this._panel.pfeId);\n }\n\n _animationStartHandler() {\n this.classList.add(\"animating\");\n }\n\n _animationEndHandler() {\n this.classList.remove(\"animating\");\n }\n\n _changeHandler(event) {}\n}\n\nPFElement.create(PfeCollapse);\nPFElement.create(PfeCollapseToggle);\nPFElement.create(PfeCollapsePanel);\n\nexport { PfeCollapse, PfeCollapseToggle, PfeCollapsePanel };\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,AAEA;AACA,SAAS,UAAU,GAAG;EACpB,OAAO,IAAI,CAAC,MAAM,EAAE;KACjB,QAAQ,CAAC,EAAE,CAAC;KACZ,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CACjB;;AAED,MAAM,iBAAiB,SAAS,SAAS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,aAAa,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACzD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;;IAEvD,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,eAAe,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;GAC/D;;EAED,sBAAsB,GAAG;IACvB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;GACjC;;EAED,oBAAoB,GAAG;IACrB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;GACpC;;EAED,cAAc,CAAC,KAAK,EAAE,EAAE;CACzB;;AAED,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAC9B,SAAS,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;AACpC,SAAS,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;;;;"} \ No newline at end of file diff --git a/elements/pfe-collapse/dist/pfe-collapse.json b/elements/pfe-collapse/dist/pfe-collapse.json new file mode 100644 index 0000000000..6813b28d1e --- /dev/null +++ b/elements/pfe-collapse/dist/pfe-collapse.json @@ -0,0 +1,35 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Collapse", + "description": "Collapse element", + "type": "object", + "tag": "pfe-collapse", + "class": "pfe-collapse", + "category": "content", + "properties": { + "slots": { + "title": "Slots", + "description": "Definition of the supported slots", + "type": "object", + "properties": { + "default": { + "title": "Default", + "type": "array", + "namedSlot": false, + "items": { + "oneOf": [ + { + "$ref": "pfe-collapsibe-toggle" + }, + { + "$ref": "pfe-collapse-panel" + } + ] + } + } + } + } + }, + "required": ["slots", "attributes"], + "additionalProperties": false +} diff --git a/elements/pfe-collapse/dist/pfe-collapse.min.js b/elements/pfe-collapse/dist/pfe-collapse.min.js new file mode 100644 index 0000000000..c600828813 --- /dev/null +++ b/elements/pfe-collapse/dist/pfe-collapse.min.js @@ -0,0 +1,26 @@ +import t from"../../pfelement/dist/pfelement.min.js"; +/*! + * PatternFly Elements: PfeCollapse 1.0.0-prerelease.53 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * +*/function e(){return Math.random().toString(36).substr(2,9)}class n extends t{static get version(){return"1.0.0-prerelease.53"}get html(){return""}static get properties(){return{}}static get slots(){return{default:{title:"Default",type:"array",namedSlot:!1,items:{oneOf:[{$ref:"pfe-collapsibe-toggle"},{$ref:"pfe-collapse-panel"}]}}}}static get tag(){return"pfe-collapse-toggle"}get templateUrl(){return"pfe-collapse-toggle.html"}get styleUrl(){return"pfe-collapse-toggle.scss"}get pfeId(){return this.getAttribute("pfe-id")}set pfeId(t){t&&this.setAttribute("pfe-id",t)}get expanded(){return"true"===this.getAttribute("aria-expanded")}set expanded(t){const e=Boolean(t);this.setAttribute("aria-expanded",e)}static get observedAttributes(){return["aria-controls"]}constructor(t,{setTabIndex:e=!0,addKeydownHandler:i=!0}={}){super(t||n),this.controlledPanel=!1,this._setTabIndex=e,this._addKeydownHandler=i,this.addEventListener("click",this._clickHandler),i&&this.addEventListener("keydown",this._keydownHandler)}connectedCallback(){super.connectedCallback(),this.expanded=!1,this.id&&(this.pfeId=this.id);const t=`${n.tag}-${e()}`;this.id||(this.id=t),this.pfeId||(this.pfeId=t),this.setAttribute("role","button"),this._setTabIndex&&this.setAttribute("tabindex",0),this.controlledPanel||this._connectPanel(this.getAttribute("aria-controls"))}disconnectedCallback(){this.removeEventListener("click",this._clickHandler),this._addKeydownHandler&&this.removeEventListener("keydown",this._keydownHandler)}attributeChangedCallback(t,e,n){super.attributeChangedCallback(t,e,n),n&&this._connectPanel(n)}toggle(){this.hasAttribute("disabled")||(this.expanded=!this.expanded,this.controlledPanel||this._connectPanel(this.getAttribute("aria-controls")),this.controlledPanel?(this.controlledPanel.expanded=this.expanded,this.emitEvent(s.events.change,{detail:{expanded:this.expanded,toggle:this,panel:this.controlledPanel}})):console.warn(`${this.tag}: This toggle doesn't have a panel associated with it`))}_clickHandler(){this.toggle()}_keydownHandler(t){switch(t.key){case" ":case"Spacebar":case"Enter":this.toggle()}}_connectPanel(t){this.getRootNode?this.controlledPanel=this.getRootNode().querySelector(`#${t}`):this.controlledPanel=document.querySelector(`#${t}`)}}class i extends t{static get version(){return"1.0.0-prerelease.53"}get html(){return""}static get properties(){return{}}static get slots(){return{default:{title:"Default",type:"array",namedSlot:!1,items:{oneOf:[{$ref:"pfe-collapsibe-toggle"},{$ref:"pfe-collapse-panel"}]}}}}static get tag(){return"pfe-collapse-panel"}static get events(){return{animationStart:`${this.tag}:animation-start`,animationEnd:`${this.tag}:animation-end`}}get templateUrl(){return"pfe-collapse-panel.html"}get styleUrl(){return"pfe-collapse-panel.scss"}get pfeId(){return this.getAttribute("pfe-id")}set pfeId(t){t&&this.setAttribute("pfe-id",t)}get animates(){return"false"!==this.getAttribute("pfe-animation")}get expanded(){return this.hasAttribute("pfe-expanded")}set expanded(t){if(Boolean(t)){if(this.setAttribute("pfe-expanded",""),this.animates){const t=this.getBoundingClientRect().height;this._fireAnimationEvent("opening"),this._animate(0,t)}}else if(this.hasAttribute("pfe-expanded")){const t=this.getBoundingClientRect().height;this.removeAttribute("pfe-expanded"),this.animates&&(this._fireAnimationEvent("closing"),this._animate(t,0))}}constructor(t){super(t||i)}connectedCallback(){super.connectedCallback(),this.expanded=!1,this.id&&(this.pfeId=this.id);const t=`${i.tag}-${e()}`;this.id||(this.id=t),this.pfeId||(this.pfeId=t)}_animate(t,e){this.classList.add("animating"),this.style.height=`${t}px`,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.style.height=`${e}px`,this.classList.add("animating"),this.addEventListener("transitionend",this._transitionEndHandler)})})}_transitionEndHandler(t){t.target.style.height="",t.target.classList.remove("animating"),t.target.removeEventListener("transitionend",this._transitionEndHandler),this.emitEvent(i.events.animationEnd,{detail:{expanded:this.expanded,panel:this}})}_fireAnimationEvent(t){this.emitEvent(i.events.animationStart,{detail:{state:t,panel:this}})}}class s extends t{static get version(){return"1.0.0-prerelease.53"}get html(){return""}static get properties(){return{}}static get slots(){return{default:{title:"Default",type:"array",namedSlot:!1,items:{oneOf:[{$ref:"pfe-collapsibe-toggle"},{$ref:"pfe-collapse-panel"}]}}}}static get tag(){return"pfe-collapse"}get templateUrl(){return"pfe-collapse.html"}get styleUrl(){return"pfe-collapse.scss"}get schemaUrl(){return"pfe-collapse.json"}get animates(){return"false"!==this.getAttribute("pfe-animation")}static get observedAttributes(){return["pfe-animation"]}static get events(){return{change:`${this.tag}:change`}}constructor(t){super(t||s),this._toggle=null,this._panel=null,this._linkControls=this._linkControls.bind(this),this._changeHandler=this._changeHandler.bind(this),this._observer=new MutationObserver(this._linkControls),this.addEventListener(s.events.change,this._changeHandler),this.addEventListener(s.events.animationStart,this._animationStartHandler),this.addEventListener(s.events.animationEnd,this._animationEndHandler)}connectedCallback(){super.connectedCallback(),Promise.all([customElements.whenDefined(i.tag),customElements.whenDefined(n.tag)]).then(()=>{this.children.length&&this._linkControls(),this._observer.observe(this,{childList:!0})})}disconnectedCallback(){this.removeEventListener(s.events.change,this._changeHandler),this.removeEventListener(s.events.animationStart,this._animationStartHandler),this.removeEventListener(s.events.animationEnd,this._animationEndHandler),this._observer.disconnect()}attributeChangedCallback(t,e,n){super.attributeChangedCallback(t,e,n),n&&("false"!==n&&"true"!==n||this._panel&&this._panel.setAttribute("pfe-animation",n))}toggle(){this._toggle.toggle()}_linkControls(){this._toggle=this.querySelector(n.tag),this._panel=this.querySelector(i.tag),this._toggle.setAttribute("aria-controls",this._panel.pfeId)}_animationStartHandler(){this.classList.add("animating")}_animationEndHandler(){this.classList.remove("animating")}_changeHandler(t){}}t.create(s),t.create(n),t.create(i);export{s as PfeCollapse,n as PfeCollapseToggle,i as PfeCollapsePanel}; +//# sourceMappingURL=pfe-collapse.min.js.map diff --git a/elements/pfe-collapse/dist/pfe-collapse.min.js.map b/elements/pfe-collapse/dist/pfe-collapse.min.js.map new file mode 100644 index 0000000000..0b5dd8f5f1 --- /dev/null +++ b/elements/pfe-collapse/dist/pfe-collapse.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-collapse.min.js","sources":["../_temp/pfe-collapse.js"],"sourcesContent":["/*!\n * PatternFly Elements: PfeCollapse 1.0.0-prerelease.53\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.js\";\n\nfunction generateId() {\n return Math.random()\n .toString(36)\n .substr(2, 9);\n}\n\nclass PfeCollapseToggle extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.53\";\n }\n\n get html() {\n return ``;\n }\n\n static get properties() {\n return {};\n }\n\n static get slots() {\n return {\"default\":{\"title\":\"Default\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-collapsibe-toggle\"},{\"$ref\":\"pfe-collapse-panel\"}]}}};\n }\n static get tag() {\n return \"pfe-collapse-toggle\";\n }\n\n get templateUrl() {\n return \"pfe-collapse-toggle.html\";\n }\n\n get styleUrl() {\n return \"pfe-collapse-toggle.scss\";\n }\n\n get pfeId() {\n return this.getAttribute(\"pfe-id\");\n }\n\n set pfeId(id) {\n if (!id) {\n return;\n }\n\n this.setAttribute(\"pfe-id\", id);\n }\n\n get expanded() {\n return this.getAttribute(\"aria-expanded\") === \"true\";\n }\n\n set expanded(val) {\n const value = Boolean(val);\n this.setAttribute(\"aria-expanded\", value);\n }\n\n static get observedAttributes() {\n return [\"aria-controls\"];\n }\n\n constructor(pfeClass, { setTabIndex = true, addKeydownHandler = true } = {}) {\n super(pfeClass || PfeCollapseToggle);\n\n this.controlledPanel = false;\n this._setTabIndex = setTabIndex;\n this._addKeydownHandler = addKeydownHandler;\n\n this.addEventListener(\"click\", this._clickHandler);\n\n if (addKeydownHandler) {\n this.addEventListener(\"keydown\", this._keydownHandler);\n }\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n this.expanded = false;\n\n // if (this.id && this.id !== \"\") {\n if (this.id) {\n this.pfeId = this.id;\n }\n\n const generatedId = `${PfeCollapseToggle.tag}-${generateId()}`;\n\n if (!this.id) {\n this.id = generatedId;\n }\n\n if (!this.pfeId) {\n this.pfeId = generatedId;\n }\n\n this.setAttribute(\"role\", \"button\");\n\n if (this._setTabIndex) {\n this.setAttribute(\"tabindex\", 0);\n }\n\n if (!this.controlledPanel) {\n this._connectPanel(this.getAttribute(\"aria-controls\"));\n }\n }\n\n disconnectedCallback() {\n this.removeEventListener(\"click\", this._clickHandler);\n\n if (this._addKeydownHandler) {\n this.removeEventListener(\"keydown\", this._keydownHandler);\n }\n }\n\n attributeChangedCallback(attr, oldVal, newVal) {\n super.attributeChangedCallback(attr, oldVal, newVal);\n\n if (!newVal) {\n return;\n }\n\n this._connectPanel(newVal);\n }\n\n toggle() {\n if (this.hasAttribute(\"disabled\")) {\n return;\n }\n\n this.expanded = !this.expanded;\n\n // one last try to hook up a panel\n if (!this.controlledPanel) {\n this._connectPanel(this.getAttribute(\"aria-controls\"));\n }\n\n if (this.controlledPanel) {\n this.controlledPanel.expanded = this.expanded;\n\n this.emitEvent(PfeCollapse.events.change, {\n detail: {\n expanded: this.expanded,\n toggle: this,\n panel: this.controlledPanel\n }\n });\n } else {\n console.warn(\n `${this.tag}: This toggle doesn't have a panel associated with it`\n );\n }\n }\n\n _clickHandler() {\n this.toggle();\n }\n\n _keydownHandler(event) {\n const key = event.key;\n\n switch (key) {\n case \" \":\n case \"Spacebar\":\n case \"Enter\":\n this.toggle();\n break;\n }\n }\n\n _connectPanel(id) {\n // this can be an issue if the pfe-collapse is located within\n // a shadow root\n if (this.getRootNode) {\n this.controlledPanel = this.getRootNode().querySelector(`#${id}`);\n } else {\n this.controlledPanel = document.querySelector(`#${id}`);\n }\n }\n}\n\nclass PfeCollapsePanel extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.53\";\n }\n\n get html() {\n return ``;\n }\n\n static get properties() {\n return {};\n }\n\n static get slots() {\n return {\"default\":{\"title\":\"Default\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-collapsibe-toggle\"},{\"$ref\":\"pfe-collapse-panel\"}]}}};\n }\n static get tag() {\n return \"pfe-collapse-panel\";\n }\n\n static get events() {\n return {\n animationStart: `${this.tag}:animation-start`,\n animationEnd: `${this.tag}:animation-end`\n };\n }\n\n get templateUrl() {\n return \"pfe-collapse-panel.html\";\n }\n\n get styleUrl() {\n return \"pfe-collapse-panel.scss\";\n }\n\n get pfeId() {\n return this.getAttribute(\"pfe-id\");\n }\n\n set pfeId(id) {\n if (!id) {\n return;\n }\n\n this.setAttribute(\"pfe-id\", id);\n }\n\n get animates() {\n return this.getAttribute(\"pfe-animation\") === \"false\" ? false : true;\n }\n\n get expanded() {\n return this.hasAttribute(\"pfe-expanded\");\n }\n\n set expanded(val) {\n const value = Boolean(val);\n\n if (value) {\n this.setAttribute(\"pfe-expanded\", \"\");\n\n if (this.animates) {\n const height = this.getBoundingClientRect().height;\n this._fireAnimationEvent(\"opening\");\n this._animate(0, height);\n }\n } else {\n if (this.hasAttribute(\"pfe-expanded\")) {\n const height = this.getBoundingClientRect().height;\n this.removeAttribute(\"pfe-expanded\");\n\n if (this.animates) {\n this._fireAnimationEvent(\"closing\");\n this._animate(height, 0);\n }\n }\n }\n }\n\n constructor(pfeClass) {\n super(pfeClass || PfeCollapsePanel);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n this.expanded = false;\n\n // if (this.id && this.id !== \"\") {\n if (this.id) {\n this.pfeId = this.id;\n }\n\n const generatedId = `${PfeCollapsePanel.tag}-${generateId()}`;\n\n if (!this.id) {\n this.id = generatedId;\n }\n\n if (!this.pfeId) {\n this.pfeId = generatedId;\n }\n }\n\n _animate(start, end) {\n this.classList.add(\"animating\");\n this.style.height = `${start}px`;\n\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n this.style.height = `${end}px`;\n this.classList.add(\"animating\");\n this.addEventListener(\"transitionend\", this._transitionEndHandler);\n });\n });\n }\n\n _transitionEndHandler(event) {\n event.target.style.height = \"\";\n event.target.classList.remove(\"animating\");\n event.target.removeEventListener(\n \"transitionend\",\n this._transitionEndHandler\n );\n\n this.emitEvent(PfeCollapsePanel.events.animationEnd, {\n detail: {\n expanded: this.expanded,\n panel: this\n }\n });\n }\n\n _fireAnimationEvent(state) {\n this.emitEvent(PfeCollapsePanel.events.animationStart, {\n detail: {\n state: state,\n panel: this\n }\n });\n }\n}\n\nclass PfeCollapse extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.53\";\n }\n\n get html() {\n return ``;\n }\n\n static get properties() {\n return {};\n }\n\n static get slots() {\n return {\"default\":{\"title\":\"Default\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-collapsibe-toggle\"},{\"$ref\":\"pfe-collapse-panel\"}]}}};\n }\n static get tag() {\n return \"pfe-collapse\";\n }\n\n get templateUrl() {\n return \"pfe-collapse.html\";\n }\n\n get styleUrl() {\n return \"pfe-collapse.scss\";\n }\n\n get schemaUrl() {\n return \"pfe-collapse.json\";\n }\n\n get animates() {\n return this.getAttribute(\"pfe-animation\") === \"false\" ? false : true;\n }\n\n static get observedAttributes() {\n return [\"pfe-animation\"];\n }\n\n static get events() {\n return {\n change: `${this.tag}:change`\n };\n }\n\n constructor(pfeClass) {\n super(pfeClass || PfeCollapse);\n\n this._toggle = null;\n this._panel = null;\n this._linkControls = this._linkControls.bind(this);\n this._changeHandler = this._changeHandler.bind(this);\n this._observer = new MutationObserver(this._linkControls);\n\n this.addEventListener(PfeCollapse.events.change, this._changeHandler);\n this.addEventListener(\n PfeCollapse.events.animationStart,\n this._animationStartHandler\n );\n this.addEventListener(\n PfeCollapse.events.animationEnd,\n this._animationEndHandler\n );\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n Promise.all([\n customElements.whenDefined(PfeCollapsePanel.tag),\n customElements.whenDefined(PfeCollapseToggle.tag)\n ]).then(() => {\n if (this.children.length) {\n this._linkControls();\n }\n\n this._observer.observe(this, { childList: true });\n });\n }\n\n disconnectedCallback() {\n this.removeEventListener(PfeCollapse.events.change, this._changeHandler);\n this.removeEventListener(\n PfeCollapse.events.animationStart,\n this._animationStartHandler\n );\n this.removeEventListener(\n PfeCollapse.events.animationEnd,\n this._animationEndHandler\n );\n this._observer.disconnect();\n }\n\n attributeChangedCallback(attr, oldVal, newVal) {\n super.attributeChangedCallback(attr, oldVal, newVal);\n\n if (!newVal) {\n return;\n }\n\n if (newVal !== \"false\" && newVal !== \"true\") {\n return;\n }\n\n if (this._panel) {\n this._panel.setAttribute(\"pfe-animation\", newVal);\n }\n }\n\n toggle() {\n this._toggle.toggle();\n }\n\n _linkControls() {\n this._toggle = this.querySelector(PfeCollapseToggle.tag);\n this._panel = this.querySelector(PfeCollapsePanel.tag);\n\n this._toggle.setAttribute(\"aria-controls\", this._panel.pfeId);\n }\n\n _animationStartHandler() {\n this.classList.add(\"animating\");\n }\n\n _animationEndHandler() {\n this.classList.remove(\"animating\");\n }\n\n _changeHandler(event) {}\n}\n\nPFElement.create(PfeCollapse);\nPFElement.create(PfeCollapseToggle);\nPFElement.create(PfeCollapsePanel);\n\nexport { PfeCollapse, PfeCollapseToggle, PfeCollapsePanel };\n"],"names":["generateId","Math","random","toString","substr","PfeCollapseToggle","PFElement","version","html","properties","slots","default","title","type","namedSlot","items","oneOf","$ref","tag","templateUrl","styleUrl","pfeId","this","getAttribute","id","setAttribute","expanded","val","value","Boolean","observedAttributes","[object Object]","pfeClass","setTabIndex","addKeydownHandler","super","controlledPanel","_setTabIndex","_addKeydownHandler","addEventListener","_clickHandler","_keydownHandler","connectedCallback","generatedId","_connectPanel","removeEventListener","attr","oldVal","newVal","attributeChangedCallback","hasAttribute","emitEvent","PfeCollapse","events","change","detail","toggle","panel","console","warn","event","key","getRootNode","querySelector","document","PfeCollapsePanel","animationStart","animationEnd","animates","height","getBoundingClientRect","_fireAnimationEvent","_animate","removeAttribute","start","end","classList","add","style","requestAnimationFrame","_transitionEndHandler","target","remove","state","schemaUrl","_toggle","_panel","_linkControls","bind","_changeHandler","_observer","MutationObserver","_animationStartHandler","_animationEndHandler","Promise","all","customElements","whenDefined","then","children","length","observe","childList","disconnect","create"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;EA2BA,SAASA,IACP,OAAOC,KAAKC,SACTC,SAAS,IACTC,OAAO,EAAG,GAGf,MAAMC,UAA0BC,EAC9BC,qBACE,MAAO,sBAGTC,WACE,MAAO,6HAKTC,wBACE,MAAO,GAGTC,mBACE,MAAO,CAACC,QAAU,CAACC,MAAQ,UAAUC,KAAO,QAAQC,WAAY,EAAMC,MAAQ,CAACC,MAAQ,CAAC,CAACC,KAAO,yBAAyB,CAACA,KAAO,0BAEnIC,iBACE,MAAO,sBAGTC,kBACE,MAAO,2BAGTC,eACE,MAAO,2BAGTC,YACE,OAAOC,KAAKC,aAAa,UAG3BF,UAAUG,GACHA,GAILF,KAAKG,aAAa,SAAUD,GAG9BE,eACE,MAA8C,SAAvCJ,KAAKC,aAAa,iBAG3BG,aAAaC,GACX,MAAMC,EAAQC,QAAQF,GACtBL,KAAKG,aAAa,gBAAiBG,GAGrCE,gCACE,MAAO,CAAC,iBAGVC,YAAYC,GAAUC,YAAEA,GAAc,EAAIC,kBAAEA,GAAoB,GAAS,IACvEC,MAAMH,GAAY3B,GAElBiB,KAAKc,iBAAkB,EACvBd,KAAKe,aAAeJ,EACpBX,KAAKgB,mBAAqBJ,EAE1BZ,KAAKiB,iBAAiB,QAASjB,KAAKkB,eAEhCN,GACFZ,KAAKiB,iBAAiB,UAAWjB,KAAKmB,iBAI1CV,oBACEI,MAAMO,oBAENpB,KAAKI,UAAW,EAGZJ,KAAKE,KACPF,KAAKD,MAAQC,KAAKE,IAGpB,MAAMmB,KAAiBtC,EAAkBa,OAAOlB,MAE3CsB,KAAKE,KACRF,KAAKE,GAAKmB,GAGPrB,KAAKD,QACRC,KAAKD,MAAQsB,GAGfrB,KAAKG,aAAa,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AKmE,gBACzDnE,KAAKuB,oBACHO,EAAYC,OAAOa,eACnB5C,KAAKsE,wBAEPtE,KAAKuB,oBACHO,EAAYC,OAAOc,aACnB7C,KAAKuE,sBAEPvE,KAAKoE,UAAUa,aAGjBxE,yBAAyBe,EAAMC,EAAQC,GACrCb,MAAMc,yBAAyBH,EAAMC,EAAQC,GAExCA,IAIU,UAAXA,GAAiC,SAAXA,GAItB1B,KAAKgE,QACPhE,KAAKgE,OAAO7D,aAAa,gBAAiBuB,IAI9CjB,SACET,KAAK+D,QAAQ7B,SAGfzB,gBACET,KAAK+D,QAAU/D,KAAKyC,cAAc1D,EAAkBa,KACpDI,KAAKgE,OAAShE,KAAKyC,cAAcE,EAAiB/C,KAElDI,KAAK+D,QAAQ5D,aAAa,gBAAiBH,KAAKgE,OAAOjE,OAGzDU,yBACET,KAAKsD,UAAUC,IAAI,aAGrB9C,uBACET,KAAKsD,UAAUM,OAAO,aAGxBnD,eAAe6B,KAGjBtD,EAAUkG,OAAOpD,GACjB9C,EAAUkG,OAAOnG,GACjBC,EAAUkG,OAAOvC"} \ No newline at end of file diff --git a/elements/pfe-collapse/dist/pfe-collapse.umd.js b/elements/pfe-collapse/dist/pfe-collapse.umd.js new file mode 100644 index 0000000000..646e92d6cc --- /dev/null +++ b/elements/pfe-collapse/dist/pfe-collapse.umd.js @@ -0,0 +1,634 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('../../pfelement/dist/pfelement.umd')) : + typeof define === 'function' && define.amd ? define(['exports', '../../pfelement/dist/pfelement.umd'], factory) : + (factory((global.PfeCollapse = {}),global.PFElement)); +}(this, (function (exports,PFElement) { 'use strict'; + + PFElement = PFElement && PFElement.hasOwnProperty('default') ? PFElement['default'] : PFElement; + + var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + }; + + var createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + }(); + + var get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + + if (getter === undefined) { + return undefined; + } + + return getter.call(receiver); + } + }; + + var inherits = function (subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + }; + + var possibleConstructorReturn = function (self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && (typeof call === "object" || typeof call === "function") ? call : self; + }; + + /*! + * PatternFly Elements: PfeCollapse 1.0.0-prerelease.53 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + + function generateId() { + return Math.random().toString(36).substr(2, 9); + } + + var PfeCollapseToggle = function (_PFElement) { + inherits(PfeCollapseToggle, _PFElement); + createClass(PfeCollapseToggle, [{ + key: "html", + get: function get$$1() { + return ""; + } + }, { + key: "templateUrl", + get: function get$$1() { + return "pfe-collapse-toggle.html"; + } + }, { + key: "styleUrl", + get: function get$$1() { + return "pfe-collapse-toggle.scss"; + } + }, { + key: "pfeId", + get: function get$$1() { + return this.getAttribute("pfe-id"); + }, + set: function set$$1(id) { + if (!id) { + return; + } + + this.setAttribute("pfe-id", id); + } + }, { + key: "expanded", + get: function get$$1() { + return this.getAttribute("aria-expanded") === "true"; + }, + set: function set$$1(val) { + var value = Boolean(val); + this.setAttribute("aria-expanded", value); + } + }], [{ + key: "version", + get: function get$$1() { + return "1.0.0-prerelease.53"; + } + }, { + key: "properties", + get: function get$$1() { + return {}; + } + }, { + key: "slots", + get: function get$$1() { + return { "default": { "title": "Default", "type": "array", "namedSlot": false, "items": { "oneOf": [{ "$ref": "pfe-collapsibe-toggle" }, { "$ref": "pfe-collapse-panel" }] } } }; + } + }, { + key: "tag", + get: function get$$1() { + return "pfe-collapse-toggle"; + } + }, { + key: "observedAttributes", + get: function get$$1() { + return ["aria-controls"]; + } + }]); + + function PfeCollapseToggle(pfeClass) { + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref$setTabIndex = _ref.setTabIndex, + setTabIndex = _ref$setTabIndex === undefined ? true : _ref$setTabIndex, + _ref$addKeydownHandle = _ref.addKeydownHandler, + addKeydownHandler = _ref$addKeydownHandle === undefined ? true : _ref$addKeydownHandle; + + classCallCheck(this, PfeCollapseToggle); + + var _this = possibleConstructorReturn(this, (PfeCollapseToggle.__proto__ || Object.getPrototypeOf(PfeCollapseToggle)).call(this, pfeClass || PfeCollapseToggle)); + + _this.controlledPanel = false; + _this._setTabIndex = setTabIndex; + _this._addKeydownHandler = addKeydownHandler; + + _this.addEventListener("click", _this._clickHandler); + + if (addKeydownHandler) { + _this.addEventListener("keydown", _this._keydownHandler); + } + return _this; + } + + createClass(PfeCollapseToggle, [{ + key: "connectedCallback", + value: function connectedCallback() { + get(PfeCollapseToggle.prototype.__proto__ || Object.getPrototypeOf(PfeCollapseToggle.prototype), "connectedCallback", this).call(this); + + this.expanded = false; + + // if (this.id && this.id !== "") { + if (this.id) { + this.pfeId = this.id; + } + + var generatedId = PfeCollapseToggle.tag + "-" + generateId(); + + if (!this.id) { + this.id = generatedId; + } + + if (!this.pfeId) { + this.pfeId = generatedId; + } + + this.setAttribute("role", "button"); + + if (this._setTabIndex) { + this.setAttribute("tabindex", 0); + } + + if (!this.controlledPanel) { + this._connectPanel(this.getAttribute("aria-controls")); + } + } + }, { + key: "disconnectedCallback", + value: function disconnectedCallback() { + this.removeEventListener("click", this._clickHandler); + + if (this._addKeydownHandler) { + this.removeEventListener("keydown", this._keydownHandler); + } + } + }, { + key: "attributeChangedCallback", + value: function attributeChangedCallback(attr, oldVal, newVal) { + get(PfeCollapseToggle.prototype.__proto__ || Object.getPrototypeOf(PfeCollapseToggle.prototype), "attributeChangedCallback", this).call(this, attr, oldVal, newVal); + + if (!newVal) { + return; + } + + this._connectPanel(newVal); + } + }, { + key: "toggle", + value: function toggle() { + if (this.hasAttribute("disabled")) { + return; + } + + this.expanded = !this.expanded; + + // one last try to hook up a panel + if (!this.controlledPanel) { + this._connectPanel(this.getAttribute("aria-controls")); + } + + if (this.controlledPanel) { + this.controlledPanel.expanded = this.expanded; + + this.emitEvent(PfeCollapse.events.change, { + detail: { + expanded: this.expanded, + toggle: this, + panel: this.controlledPanel + } + }); + } else { + console.warn(this.tag + ": This toggle doesn't have a panel associated with it"); + } + } + }, { + key: "_clickHandler", + value: function _clickHandler() { + this.toggle(); + } + }, { + key: "_keydownHandler", + value: function _keydownHandler(event) { + var key = event.key; + + switch (key) { + case " ": + case "Spacebar": + case "Enter": + this.toggle(); + break; + } + } + }, { + key: "_connectPanel", + value: function _connectPanel(id) { + // this can be an issue if the pfe-collapse is located within + // a shadow root + if (this.getRootNode) { + this.controlledPanel = this.getRootNode().querySelector("#" + id); + } else { + this.controlledPanel = document.querySelector("#" + id); + } + } + }]); + return PfeCollapseToggle; + }(PFElement); + + var PfeCollapsePanel = function (_PFElement2) { + inherits(PfeCollapsePanel, _PFElement2); + createClass(PfeCollapsePanel, [{ + key: "html", + get: function get$$1() { + return ""; + } + }, { + key: "templateUrl", + get: function get$$1() { + return "pfe-collapse-panel.html"; + } + }, { + key: "styleUrl", + get: function get$$1() { + return "pfe-collapse-panel.scss"; + } + }, { + key: "pfeId", + get: function get$$1() { + return this.getAttribute("pfe-id"); + }, + set: function set$$1(id) { + if (!id) { + return; + } + + this.setAttribute("pfe-id", id); + } + }, { + key: "animates", + get: function get$$1() { + return this.getAttribute("pfe-animation") === "false" ? false : true; + } + }, { + key: "expanded", + get: function get$$1() { + return this.hasAttribute("pfe-expanded"); + }, + set: function set$$1(val) { + var value = Boolean(val); + + if (value) { + this.setAttribute("pfe-expanded", ""); + + if (this.animates) { + var height = this.getBoundingClientRect().height; + this._fireAnimationEvent("opening"); + this._animate(0, height); + } + } else { + if (this.hasAttribute("pfe-expanded")) { + var _height = this.getBoundingClientRect().height; + this.removeAttribute("pfe-expanded"); + + if (this.animates) { + this._fireAnimationEvent("closing"); + this._animate(_height, 0); + } + } + } + } + }], [{ + key: "version", + get: function get$$1() { + return "1.0.0-prerelease.53"; + } + }, { + key: "properties", + get: function get$$1() { + return {}; + } + }, { + key: "slots", + get: function get$$1() { + return { "default": { "title": "Default", "type": "array", "namedSlot": false, "items": { "oneOf": [{ "$ref": "pfe-collapsibe-toggle" }, { "$ref": "pfe-collapse-panel" }] } } }; + } + }, { + key: "tag", + get: function get$$1() { + return "pfe-collapse-panel"; + } + }, { + key: "events", + get: function get$$1() { + return { + animationStart: this.tag + ":animation-start", + animationEnd: this.tag + ":animation-end" + }; + } + }]); + + function PfeCollapsePanel(pfeClass) { + classCallCheck(this, PfeCollapsePanel); + return possibleConstructorReturn(this, (PfeCollapsePanel.__proto__ || Object.getPrototypeOf(PfeCollapsePanel)).call(this, pfeClass || PfeCollapsePanel)); + } + + createClass(PfeCollapsePanel, [{ + key: "connectedCallback", + value: function connectedCallback() { + get(PfeCollapsePanel.prototype.__proto__ || Object.getPrototypeOf(PfeCollapsePanel.prototype), "connectedCallback", this).call(this); + + this.expanded = false; + + // if (this.id && this.id !== "") { + if (this.id) { + this.pfeId = this.id; + } + + var generatedId = PfeCollapsePanel.tag + "-" + generateId(); + + if (!this.id) { + this.id = generatedId; + } + + if (!this.pfeId) { + this.pfeId = generatedId; + } + } + }, { + key: "_animate", + value: function _animate(start, end) { + var _this3 = this; + + this.classList.add("animating"); + this.style.height = start + "px"; + + requestAnimationFrame(function () { + requestAnimationFrame(function () { + _this3.style.height = end + "px"; + _this3.classList.add("animating"); + _this3.addEventListener("transitionend", _this3._transitionEndHandler); + }); + }); + } + }, { + key: "_transitionEndHandler", + value: function _transitionEndHandler(event) { + event.target.style.height = ""; + event.target.classList.remove("animating"); + event.target.removeEventListener("transitionend", this._transitionEndHandler); + + this.emitEvent(PfeCollapsePanel.events.animationEnd, { + detail: { + expanded: this.expanded, + panel: this + } + }); + } + }, { + key: "_fireAnimationEvent", + value: function _fireAnimationEvent(state) { + this.emitEvent(PfeCollapsePanel.events.animationStart, { + detail: { + state: state, + panel: this + } + }); + } + }]); + return PfeCollapsePanel; + }(PFElement); + + var PfeCollapse = function (_PFElement3) { + inherits(PfeCollapse, _PFElement3); + createClass(PfeCollapse, [{ + key: "html", + get: function get$$1() { + return ""; + } + }, { + key: "templateUrl", + get: function get$$1() { + return "pfe-collapse.html"; + } + }, { + key: "styleUrl", + get: function get$$1() { + return "pfe-collapse.scss"; + } + }, { + key: "schemaUrl", + get: function get$$1() { + return "pfe-collapse.json"; + } + }, { + key: "animates", + get: function get$$1() { + return this.getAttribute("pfe-animation") === "false" ? false : true; + } + }], [{ + key: "version", + get: function get$$1() { + return "1.0.0-prerelease.53"; + } + }, { + key: "properties", + get: function get$$1() { + return {}; + } + }, { + key: "slots", + get: function get$$1() { + return { "default": { "title": "Default", "type": "array", "namedSlot": false, "items": { "oneOf": [{ "$ref": "pfe-collapsibe-toggle" }, { "$ref": "pfe-collapse-panel" }] } } }; + } + }, { + key: "tag", + get: function get$$1() { + return "pfe-collapse"; + } + }, { + key: "observedAttributes", + get: function get$$1() { + return ["pfe-animation"]; + } + }, { + key: "events", + get: function get$$1() { + return { + change: this.tag + ":change" + }; + } + }]); + + function PfeCollapse(pfeClass) { + classCallCheck(this, PfeCollapse); + + var _this4 = possibleConstructorReturn(this, (PfeCollapse.__proto__ || Object.getPrototypeOf(PfeCollapse)).call(this, pfeClass || PfeCollapse)); + + _this4._toggle = null; + _this4._panel = null; + _this4._linkControls = _this4._linkControls.bind(_this4); + _this4._changeHandler = _this4._changeHandler.bind(_this4); + _this4._observer = new MutationObserver(_this4._linkControls); + + _this4.addEventListener(PfeCollapse.events.change, _this4._changeHandler); + _this4.addEventListener(PfeCollapse.events.animationStart, _this4._animationStartHandler); + _this4.addEventListener(PfeCollapse.events.animationEnd, _this4._animationEndHandler); + return _this4; + } + + createClass(PfeCollapse, [{ + key: "connectedCallback", + value: function connectedCallback() { + var _this5 = this; + + get(PfeCollapse.prototype.__proto__ || Object.getPrototypeOf(PfeCollapse.prototype), "connectedCallback", this).call(this); + + Promise.all([customElements.whenDefined(PfeCollapsePanel.tag), customElements.whenDefined(PfeCollapseToggle.tag)]).then(function () { + if (_this5.children.length) { + _this5._linkControls(); + } + + _this5._observer.observe(_this5, { childList: true }); + }); + } + }, { + key: "disconnectedCallback", + value: function disconnectedCallback() { + this.removeEventListener(PfeCollapse.events.change, this._changeHandler); + this.removeEventListener(PfeCollapse.events.animationStart, this._animationStartHandler); + this.removeEventListener(PfeCollapse.events.animationEnd, this._animationEndHandler); + this._observer.disconnect(); + } + }, { + key: "attributeChangedCallback", + value: function attributeChangedCallback(attr, oldVal, newVal) { + get(PfeCollapse.prototype.__proto__ || Object.getPrototypeOf(PfeCollapse.prototype), "attributeChangedCallback", this).call(this, attr, oldVal, newVal); + + if (!newVal) { + return; + } + + if (newVal !== "false" && newVal !== "true") { + return; + } + + if (this._panel) { + this._panel.setAttribute("pfe-animation", newVal); + } + } + }, { + key: "toggle", + value: function toggle() { + this._toggle.toggle(); + } + }, { + key: "_linkControls", + value: function _linkControls() { + this._toggle = this.querySelector(PfeCollapseToggle.tag); + this._panel = this.querySelector(PfeCollapsePanel.tag); + + this._toggle.setAttribute("aria-controls", this._panel.pfeId); + } + }, { + key: "_animationStartHandler", + value: function _animationStartHandler() { + this.classList.add("animating"); + } + }, { + key: "_animationEndHandler", + value: function _animationEndHandler() { + this.classList.remove("animating"); + } + }, { + key: "_changeHandler", + value: function _changeHandler(event) {} + }]); + return PfeCollapse; + }(PFElement); + + PFElement.create(PfeCollapse); + PFElement.create(PfeCollapseToggle); + PFElement.create(PfeCollapsePanel); + + exports.PfeCollapse = PfeCollapse; + exports.PfeCollapseToggle = PfeCollapseToggle; + exports.PfeCollapsePanel = PfeCollapsePanel; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}))); +//# sourceMappingURL=pfe-collapse.umd.js.map diff --git a/elements/pfe-collapse/dist/pfe-collapse.umd.js.map b/elements/pfe-collapse/dist/pfe-collapse.umd.js.map new file mode 100644 index 0000000000..461d27c718 --- /dev/null +++ b/elements/pfe-collapse/dist/pfe-collapse.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-collapse.umd.js","sources":["../_temp/pfe-collapse.umd.js"],"sourcesContent":["/*!\n * PatternFly Elements: PfeCollapse 1.0.0-prerelease.53\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.umd\";\n\nfunction generateId() {\n return Math.random()\n .toString(36)\n .substr(2, 9);\n}\n\nclass PfeCollapseToggle extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.53\";\n }\n\n get html() {\n return ``;\n }\n\n static get properties() {\n return {};\n }\n\n static get slots() {\n return {\"default\":{\"title\":\"Default\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-collapsibe-toggle\"},{\"$ref\":\"pfe-collapse-panel\"}]}}};\n }\n static get tag() {\n return \"pfe-collapse-toggle\";\n }\n\n get templateUrl() {\n return \"pfe-collapse-toggle.html\";\n }\n\n get styleUrl() {\n return \"pfe-collapse-toggle.scss\";\n }\n\n get pfeId() {\n return this.getAttribute(\"pfe-id\");\n }\n\n set pfeId(id) {\n if (!id) {\n return;\n }\n\n this.setAttribute(\"pfe-id\", id);\n }\n\n get expanded() {\n return this.getAttribute(\"aria-expanded\") === \"true\";\n }\n\n set expanded(val) {\n const value = Boolean(val);\n this.setAttribute(\"aria-expanded\", value);\n }\n\n static get observedAttributes() {\n return [\"aria-controls\"];\n }\n\n constructor(pfeClass, { setTabIndex = true, addKeydownHandler = true } = {}) {\n super(pfeClass || PfeCollapseToggle);\n\n this.controlledPanel = false;\n this._setTabIndex = setTabIndex;\n this._addKeydownHandler = addKeydownHandler;\n\n this.addEventListener(\"click\", this._clickHandler);\n\n if (addKeydownHandler) {\n this.addEventListener(\"keydown\", this._keydownHandler);\n }\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n this.expanded = false;\n\n // if (this.id && this.id !== \"\") {\n if (this.id) {\n this.pfeId = this.id;\n }\n\n const generatedId = `${PfeCollapseToggle.tag}-${generateId()}`;\n\n if (!this.id) {\n this.id = generatedId;\n }\n\n if (!this.pfeId) {\n this.pfeId = generatedId;\n }\n\n this.setAttribute(\"role\", \"button\");\n\n if (this._setTabIndex) {\n this.setAttribute(\"tabindex\", 0);\n }\n\n if (!this.controlledPanel) {\n this._connectPanel(this.getAttribute(\"aria-controls\"));\n }\n }\n\n disconnectedCallback() {\n this.removeEventListener(\"click\", this._clickHandler);\n\n if (this._addKeydownHandler) {\n this.removeEventListener(\"keydown\", this._keydownHandler);\n }\n }\n\n attributeChangedCallback(attr, oldVal, newVal) {\n super.attributeChangedCallback(attr, oldVal, newVal);\n\n if (!newVal) {\n return;\n }\n\n this._connectPanel(newVal);\n }\n\n toggle() {\n if (this.hasAttribute(\"disabled\")) {\n return;\n }\n\n this.expanded = !this.expanded;\n\n // one last try to hook up a panel\n if (!this.controlledPanel) {\n this._connectPanel(this.getAttribute(\"aria-controls\"));\n }\n\n if (this.controlledPanel) {\n this.controlledPanel.expanded = this.expanded;\n\n this.emitEvent(PfeCollapse.events.change, {\n detail: {\n expanded: this.expanded,\n toggle: this,\n panel: this.controlledPanel\n }\n });\n } else {\n console.warn(\n `${this.tag}: This toggle doesn't have a panel associated with it`\n );\n }\n }\n\n _clickHandler() {\n this.toggle();\n }\n\n _keydownHandler(event) {\n const key = event.key;\n\n switch (key) {\n case \" \":\n case \"Spacebar\":\n case \"Enter\":\n this.toggle();\n break;\n }\n }\n\n _connectPanel(id) {\n // this can be an issue if the pfe-collapse is located within\n // a shadow root\n if (this.getRootNode) {\n this.controlledPanel = this.getRootNode().querySelector(`#${id}`);\n } else {\n this.controlledPanel = document.querySelector(`#${id}`);\n }\n }\n}\n\nclass PfeCollapsePanel extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.53\";\n }\n\n get html() {\n return ``;\n }\n\n static get properties() {\n return {};\n }\n\n static get slots() {\n return {\"default\":{\"title\":\"Default\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-collapsibe-toggle\"},{\"$ref\":\"pfe-collapse-panel\"}]}}};\n }\n static get tag() {\n return \"pfe-collapse-panel\";\n }\n\n static get events() {\n return {\n animationStart: `${this.tag}:animation-start`,\n animationEnd: `${this.tag}:animation-end`\n };\n }\n\n get templateUrl() {\n return \"pfe-collapse-panel.html\";\n }\n\n get styleUrl() {\n return \"pfe-collapse-panel.scss\";\n }\n\n get pfeId() {\n return this.getAttribute(\"pfe-id\");\n }\n\n set pfeId(id) {\n if (!id) {\n return;\n }\n\n this.setAttribute(\"pfe-id\", id);\n }\n\n get animates() {\n return this.getAttribute(\"pfe-animation\") === \"false\" ? false : true;\n }\n\n get expanded() {\n return this.hasAttribute(\"pfe-expanded\");\n }\n\n set expanded(val) {\n const value = Boolean(val);\n\n if (value) {\n this.setAttribute(\"pfe-expanded\", \"\");\n\n if (this.animates) {\n const height = this.getBoundingClientRect().height;\n this._fireAnimationEvent(\"opening\");\n this._animate(0, height);\n }\n } else {\n if (this.hasAttribute(\"pfe-expanded\")) {\n const height = this.getBoundingClientRect().height;\n this.removeAttribute(\"pfe-expanded\");\n\n if (this.animates) {\n this._fireAnimationEvent(\"closing\");\n this._animate(height, 0);\n }\n }\n }\n }\n\n constructor(pfeClass) {\n super(pfeClass || PfeCollapsePanel);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n this.expanded = false;\n\n // if (this.id && this.id !== \"\") {\n if (this.id) {\n this.pfeId = this.id;\n }\n\n const generatedId = `${PfeCollapsePanel.tag}-${generateId()}`;\n\n if (!this.id) {\n this.id = generatedId;\n }\n\n if (!this.pfeId) {\n this.pfeId = generatedId;\n }\n }\n\n _animate(start, end) {\n this.classList.add(\"animating\");\n this.style.height = `${start}px`;\n\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n this.style.height = `${end}px`;\n this.classList.add(\"animating\");\n this.addEventListener(\"transitionend\", this._transitionEndHandler);\n });\n });\n }\n\n _transitionEndHandler(event) {\n event.target.style.height = \"\";\n event.target.classList.remove(\"animating\");\n event.target.removeEventListener(\n \"transitionend\",\n this._transitionEndHandler\n );\n\n this.emitEvent(PfeCollapsePanel.events.animationEnd, {\n detail: {\n expanded: this.expanded,\n panel: this\n }\n });\n }\n\n _fireAnimationEvent(state) {\n this.emitEvent(PfeCollapsePanel.events.animationStart, {\n detail: {\n state: state,\n panel: this\n }\n });\n }\n}\n\nclass PfeCollapse extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.53\";\n }\n\n get html() {\n return ``;\n }\n\n static get properties() {\n return {};\n }\n\n static get slots() {\n return {\"default\":{\"title\":\"Default\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-collapsibe-toggle\"},{\"$ref\":\"pfe-collapse-panel\"}]}}};\n }\n static get tag() {\n return \"pfe-collapse\";\n }\n\n get templateUrl() {\n return \"pfe-collapse.html\";\n }\n\n get styleUrl() {\n return \"pfe-collapse.scss\";\n }\n\n get schemaUrl() {\n return \"pfe-collapse.json\";\n }\n\n get animates() {\n return this.getAttribute(\"pfe-animation\") === \"false\" ? false : true;\n }\n\n static get observedAttributes() {\n return [\"pfe-animation\"];\n }\n\n static get events() {\n return {\n change: `${this.tag}:change`\n };\n }\n\n constructor(pfeClass) {\n super(pfeClass || PfeCollapse);\n\n this._toggle = null;\n this._panel = null;\n this._linkControls = this._linkControls.bind(this);\n this._changeHandler = this._changeHandler.bind(this);\n this._observer = new MutationObserver(this._linkControls);\n\n this.addEventListener(PfeCollapse.events.change, this._changeHandler);\n this.addEventListener(\n PfeCollapse.events.animationStart,\n this._animationStartHandler\n );\n this.addEventListener(\n PfeCollapse.events.animationEnd,\n this._animationEndHandler\n );\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n Promise.all([\n customElements.whenDefined(PfeCollapsePanel.tag),\n customElements.whenDefined(PfeCollapseToggle.tag)\n ]).then(() => {\n if (this.children.length) {\n this._linkControls();\n }\n\n this._observer.observe(this, { childList: true });\n });\n }\n\n disconnectedCallback() {\n this.removeEventListener(PfeCollapse.events.change, this._changeHandler);\n this.removeEventListener(\n PfeCollapse.events.animationStart,\n this._animationStartHandler\n );\n this.removeEventListener(\n PfeCollapse.events.animationEnd,\n this._animationEndHandler\n );\n this._observer.disconnect();\n }\n\n attributeChangedCallback(attr, oldVal, newVal) {\n super.attributeChangedCallback(attr, oldVal, newVal);\n\n if (!newVal) {\n return;\n }\n\n if (newVal !== \"false\" && newVal !== \"true\") {\n return;\n }\n\n if (this._panel) {\n this._panel.setAttribute(\"pfe-animation\", newVal);\n }\n }\n\n toggle() {\n this._toggle.toggle();\n }\n\n _linkControls() {\n this._toggle = this.querySelector(PfeCollapseToggle.tag);\n this._panel = this.querySelector(PfeCollapsePanel.tag);\n\n this._toggle.setAttribute(\"aria-controls\", this._panel.pfeId);\n }\n\n _animationStartHandler() {\n this.classList.add(\"animating\");\n }\n\n _animationEndHandler() {\n this.classList.remove(\"animating\");\n }\n\n _changeHandler(event) {}\n}\n\nPFElement.create(PfeCollapse);\nPFElement.create(PfeCollapseToggle);\nPFElement.create(PfeCollapsePanel);\n\nexport { PfeCollapse, PfeCollapseToggle, PfeCollapsePanel };\n"],"names":["generateId","Math","random","toString","substr","PfeCollapseToggle","getAttribute","id","setAttribute","val","value","Boolean","pfeClass","setTabIndex","addKeydownHandler","controlledPanel","_setTabIndex","_addKeydownHandler","addEventListener","_clickHandler","_keydownHandler","expanded","pfeId","generatedId","tag","_connectPanel","removeEventListener","attr","oldVal","newVal","hasAttribute","emitEvent","PfeCollapse","events","change","detail","toggle","panel","console","warn","event","key","getRootNode","querySelector","document","PFElement","PfeCollapsePanel","animates","height","getBoundingClientRect","_fireAnimationEvent","_animate","removeAttribute","animationStart","animationEnd","start","end","classList","add","style","requestAnimationFrame","_transitionEndHandler","target","remove","state","_toggle","_panel","_linkControls","bind","_changeHandler","_observer","MutationObserver","_animationStartHandler","_animationEndHandler","Promise","all","customElements","whenDefined","then","children","length","observe","childList","disconnect","create"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;EA2BA,SAASA,UAAT,GAAsB;EACpB,SAAOC,KAAKC,MAAL,GACJC,QADI,CACK,EADL,EAEJC,MAFI,CAEG,CAFH,EAEM,CAFN,CAAP;EAGD;;MAEKC;;;;6BAKO;EACT;EAGD;;;6BAaiB;EAChB,aAAO,0BAAP;EACD;;;6BAEc;EACb,aAAO,0BAAP;EACD;;;6BAEW;EACV,aAAO,KAAKC,YAAL,CAAkB,QAAlB,CAAP;EACD;2BAESC,IAAI;EACZ,UAAI,CAACA,EAAL,EAAS;EACP;EACD;;EAED,WAAKC,YAAL,CAAkB,QAAlB,EAA4BD,EAA5B;EACD;;;6BAEc;EACb,aAAO,KAAKD,YAAL,CAAkB,eAAlB,MAAuC,MAA9C;EACD;2BAEYG,KAAK;EAChB,UAAMC,QAAQC,QAAQF,GAAR,CAAd;EACA,WAAKD,YAAL,CAAkB,eAAlB,EAAmCE,KAAnC;EACD;;;6BAhDoB;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SAAL,CAAea,UAAf;EACD;;;+CAEwBxD,MAAMC,QAAQC,QAAQ;EAC7C,wIAA+BF,IAA/B,EAAqCC,MAArC,EAA6CC,MAA7C;;EAEA,UAAI,CAACA,MAAL,EAAa;EACX;EACD;;EAED,UAAIA,WAAW,OAAX,IAAsBA,WAAW,MAArC,EAA6C;EAC3C;EACD;;EAED,UAAI,KAAKqC,MAAT,EAAiB;EACf,aAAKA,MAAL,CAAY1D,YAAZ,CAAyB,eAAzB,EAA0CqB,MAA1C;EACD;EACF;;;+BAEQ;EACP,WAAKoC,OAAL,CAAa7B,MAAb;EACD;;;sCAEe;EACd,WAAK6B,OAAL,GAAe,KAAKtB,aAAL,CAAmBtC,kBAAkBmB,GAArC,CAAf;EACA,WAAK0C,MAAL,GAAc,KAAKvB,aAAL,CAAmBG,iBAAiBtB,GAApC,CAAd;;EAEA,WAAKyC,OAAL,CAAazD,YAAb,CAA0B,eAA1B,EAA2C,KAAK0D,MAAL,CAAY5C,KAAvD;EACD;;;+CAEwB;EACvB,WAAKmC,SAAL,CAAeC,GAAf,CAAmB,WAAnB;EACD;;;6CAEsB;EACrB,WAAKD,SAAL,CAAeM,MAAf,CAAsB,WAAtB;EACD;;;qCAEcvB,OAAO;;;IAnIEK;;EAsI1BA,UAAUuC,MAAV,CAAiBpD,WAAjB;EACAa,UAAUuC,MAAV,CAAiB/E,iBAAjB;EACAwC,UAAUuC,MAAV,CAAiBtC,gBAAjB;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/elements/pfe-collapse/dist/pfe-collapse.umd.min.js b/elements/pfe-collapse/dist/pfe-collapse.umd.min.js new file mode 100644 index 0000000000..3d6049c246 --- /dev/null +++ b/elements/pfe-collapse/dist/pfe-collapse.umd.min.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("../../pfelement/dist/pfelement.umd")):"function"==typeof define&&define.amd?define(["exports","../../pfelement/dist/pfelement.umd"],t):t(e.PfeCollapse={},e.PFElement)}(this,function(e,t){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var n=function(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e};function i(e,t){for(var n=0;n:host{display:block;cursor:default}\n/*# sourceMappingURL=pfe-collapse-toggle.min.css.map */\n"}},{key:"templateUrl",get:function(){return"pfe-collapse-toggle.html"}},{key:"styleUrl",get:function(){return"pfe-collapse-toggle.scss"}},{key:"pfeId",get:function(){return this.getAttribute("pfe-id")},set:function(e){e&&this.setAttribute("pfe-id",e)}},{key:"expanded",get:function(){return"true"===this.getAttribute("aria-expanded")},set:function(e){var t=Boolean(e);this.setAttribute("aria-expanded",t)}}],[{key:"version",get:function(){return"1.0.0-prerelease.53"}},{key:"properties",get:function(){return{}}},{key:"slots",get:function(){return{default:{title:"Default",type:"array",namedSlot:!1,items:{oneOf:[{$ref:"pfe-collapsibe-toggle"},{$ref:"pfe-collapse-panel"}]}}}}},{key:"tag",get:function(){return"pfe-collapse-toggle"}},{key:"observedAttributes",get:function(){return["aria-controls"]}}]),n(d,[{key:"connectedCallback",value:function(){r(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),"connectedCallback",this).call(this),this.expanded=!1,this.id&&(this.pfeId=this.id);var e=d.tag+"-"+o();this.id||(this.id=e),this.pfeId||(this.pfeId=e),this.setAttribute("role","button"),this._setTabIndex&&this.setAttribute("tabindex",0),this.controlledPanel||this._connectPanel(this.getAttribute("aria-controls"))}},{key:"disconnectedCallback",value:function(){this.removeEventListener("click",this._clickHandler),this._addKeydownHandler&&this.removeEventListener("keydown",this._keydownHandler)}},{key:"attributeChangedCallback",value:function(e,t,n){r(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),"attributeChangedCallback",this).call(this,e,t,n),n&&this._connectPanel(n)}},{key:"toggle",value:function(){this.hasAttribute("disabled")||(this.expanded=!this.expanded,this.controlledPanel||this._connectPanel(this.getAttribute("aria-controls")),this.controlledPanel?(this.controlledPanel.expanded=this.expanded,this.emitEvent(h.events.change,{detail:{expanded:this.expanded,toggle:this,panel:this.controlledPanel}})):console.warn(this.tag+": This toggle doesn't have a panel associated with it"))}},{key:"_clickHandler",value:function(){this.toggle()}},{key:"_keydownHandler",value:function(e){switch(e.key){case" ":case"Spacebar":case"Enter":this.toggle()}}},{key:"_connectPanel",value:function(e){this.getRootNode?this.controlledPanel=this.getRootNode().querySelector("#"+e):this.controlledPanel=document.querySelector("#"+e)}}]),d);function d(e){var t=1:host{display:none;overflow:hidden;will-change:height}:host([pfe-expanded]){display:block;position:relative}:host(.animating){display:block;-webkit-transition:height .3s ease-in-out;transition:height .3s ease-in-out}\n/*# sourceMappingURL=pfe-collapse-panel.min.css.map */\n"}},{key:"templateUrl",get:function(){return"pfe-collapse-panel.html"}},{key:"styleUrl",get:function(){return"pfe-collapse-panel.scss"}},{key:"pfeId",get:function(){return this.getAttribute("pfe-id")},set:function(e){e&&this.setAttribute("pfe-id",e)}},{key:"animates",get:function(){return"false"!==this.getAttribute("pfe-animation")}},{key:"expanded",get:function(){return this.hasAttribute("pfe-expanded")},set:function(e){if(Boolean(e)){if(this.setAttribute("pfe-expanded",""),this.animates){var t=this.getBoundingClientRect().height;this._fireAnimationEvent("opening"),this._animate(0,t)}}else if(this.hasAttribute("pfe-expanded")){var n=this.getBoundingClientRect().height;this.removeAttribute("pfe-expanded"),this.animates&&(this._fireAnimationEvent("closing"),this._animate(n,0))}}}],[{key:"version",get:function(){return"1.0.0-prerelease.53"}},{key:"properties",get:function(){return{}}},{key:"slots",get:function(){return{default:{title:"Default",type:"array",namedSlot:!1,items:{oneOf:[{$ref:"pfe-collapsibe-toggle"},{$ref:"pfe-collapse-panel"}]}}}}},{key:"tag",get:function(){return"pfe-collapse-panel"}},{key:"events",get:function(){return{animationStart:this.tag+":animation-start",animationEnd:this.tag+":animation-end"}}}]),n(p,[{key:"connectedCallback",value:function(){r(p.prototype.__proto__||Object.getPrototypeOf(p.prototype),"connectedCallback",this).call(this),this.expanded=!1,this.id&&(this.pfeId=this.id);var e=p.tag+"-"+o();this.id||(this.id=e),this.pfeId||(this.pfeId=e)}},{key:"_animate",value:function(e,t){var n=this;this.classList.add("animating"),this.style.height=e+"px",requestAnimationFrame(function(){requestAnimationFrame(function(){n.style.height=t+"px",n.classList.add("animating"),n.addEventListener("transitionend",n._transitionEndHandler)})})}},{key:"_transitionEndHandler",value:function(e){e.target.style.height="",e.target.classList.remove("animating"),e.target.removeEventListener("transitionend",this._transitionEndHandler),this.emitEvent(p.events.animationEnd,{detail:{expanded:this.expanded,panel:this}})}},{key:"_fireAnimationEvent",value:function(e){this.emitEvent(p.events.animationStart,{detail:{state:e,panel:this}})}}]),p);function p(e){return s(this,p),l(this,(p.__proto__||Object.getPrototypeOf(p)).call(this,e||p))}var h=(a(f,t),n(f,[{key:"html",get:function(){return""}},{key:"templateUrl",get:function(){return"pfe-collapse.html"}},{key:"styleUrl",get:function(){return"pfe-collapse.scss"}},{key:"schemaUrl",get:function(){return"pfe-collapse.json"}},{key:"animates",get:function(){return"false"!==this.getAttribute("pfe-animation")}}],[{key:"version",get:function(){return"1.0.0-prerelease.53"}},{key:"properties",get:function(){return{}}},{key:"slots",get:function(){return{default:{title:"Default",type:"array",namedSlot:!1,items:{oneOf:[{$ref:"pfe-collapsibe-toggle"},{$ref:"pfe-collapse-panel"}]}}}}},{key:"tag",get:function(){return"pfe-collapse"}},{key:"observedAttributes",get:function(){return["pfe-animation"]}},{key:"events",get:function(){return{change:this.tag+":change"}}}]),n(f,[{key:"connectedCallback",value:function(){var e=this;r(f.prototype.__proto__||Object.getPrototypeOf(f.prototype),"connectedCallback",this).call(this),Promise.all([customElements.whenDefined(u.tag),customElements.whenDefined(c.tag)]).then(function(){e.children.length&&e._linkControls(),e._observer.observe(e,{childList:!0})})}},{key:"disconnectedCallback",value:function(){this.removeEventListener(f.events.change,this._changeHandler),this.removeEventListener(f.events.animationStart,this._animationStartHandler),this.removeEventListener(f.events.animationEnd,this._animationEndHandler),this._observer.disconnect()}},{key:"attributeChangedCallback",value:function(e,t,n){r(f.prototype.__proto__||Object.getPrototypeOf(f.prototype),"attributeChangedCallback",this).call(this,e,t,n),n&&("false"!==n&&"true"!==n||this._panel&&this._panel.setAttribute("pfe-animation",n))}},{key:"toggle",value:function(){this._toggle.toggle()}},{key:"_linkControls",value:function(){this._toggle=this.querySelector(c.tag),this._panel=this.querySelector(u.tag),this._toggle.setAttribute("aria-controls",this._panel.pfeId)}},{key:"_animationStartHandler",value:function(){this.classList.add("animating")}},{key:"_animationEndHandler",value:function(){this.classList.remove("animating")}},{key:"_changeHandler",value:function(e){}}]),f);function f(e){s(this,f);var t=l(this,(f.__proto__||Object.getPrototypeOf(f)).call(this,e||f));return t._toggle=null,t._panel=null,t._linkControls=t._linkControls.bind(t),t._changeHandler=t._changeHandler.bind(t),t._observer=new MutationObserver(t._linkControls),t.addEventListener(f.events.change,t._changeHandler),t.addEventListener(f.events.animationStart,t._animationStartHandler),t.addEventListener(f.events.animationEnd,t._animationEndHandler),t}t.create(h),t.create(c),t.create(u),e.PfeCollapse=h,e.PfeCollapseToggle=c,e.PfeCollapsePanel=u,Object.defineProperty(e,"__esModule",{value:!0})}); +//# sourceMappingURL=pfe-collapse.umd.min.js.map diff --git a/elements/pfe-collapse/dist/pfe-collapse.umd.min.js.map b/elements/pfe-collapse/dist/pfe-collapse.umd.min.js.map new file mode 100644 index 0000000000..15de1ab88a --- /dev/null +++ b/elements/pfe-collapse/dist/pfe-collapse.umd.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-collapse.umd.min.js","sources":["../_temp/pfe-collapse.umd.js"],"sourcesContent":["/*!\n * PatternFly Elements: PfeCollapse 1.0.0-prerelease.53\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.umd\";\n\nfunction generateId() {\n return Math.random()\n .toString(36)\n .substr(2, 9);\n}\n\nclass PfeCollapseToggle extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.53\";\n }\n\n get html() {\n return ``;\n }\n\n static get properties() {\n return {};\n }\n\n static get slots() {\n return {\"default\":{\"title\":\"Default\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-collapsibe-toggle\"},{\"$ref\":\"pfe-collapse-panel\"}]}}};\n }\n static get tag() {\n return \"pfe-collapse-toggle\";\n }\n\n get templateUrl() {\n return \"pfe-collapse-toggle.html\";\n }\n\n get styleUrl() {\n return \"pfe-collapse-toggle.scss\";\n }\n\n get pfeId() {\n return this.getAttribute(\"pfe-id\");\n }\n\n set pfeId(id) {\n if (!id) {\n return;\n }\n\n this.setAttribute(\"pfe-id\", id);\n }\n\n get expanded() {\n return this.getAttribute(\"aria-expanded\") === \"true\";\n }\n\n set expanded(val) {\n const value = Boolean(val);\n this.setAttribute(\"aria-expanded\", value);\n }\n\n static get observedAttributes() {\n return [\"aria-controls\"];\n }\n\n constructor(pfeClass, { setTabIndex = true, addKeydownHandler = true } = {}) {\n super(pfeClass || PfeCollapseToggle);\n\n this.controlledPanel = false;\n this._setTabIndex = setTabIndex;\n this._addKeydownHandler = addKeydownHandler;\n\n this.addEventListener(\"click\", this._clickHandler);\n\n if (addKeydownHandler) {\n this.addEventListener(\"keydown\", this._keydownHandler);\n }\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n this.expanded = false;\n\n // if (this.id && this.id !== \"\") {\n if (this.id) {\n this.pfeId = this.id;\n }\n\n const generatedId = `${PfeCollapseToggle.tag}-${generateId()}`;\n\n if (!this.id) {\n this.id = generatedId;\n }\n\n if (!this.pfeId) {\n this.pfeId = generatedId;\n }\n\n this.setAttribute(\"role\", \"button\");\n\n if (this._setTabIndex) {\n this.setAttribute(\"tabindex\", 0);\n }\n\n if (!this.controlledPanel) {\n this._connectPanel(this.getAttribute(\"aria-controls\"));\n }\n }\n\n disconnectedCallback() {\n this.removeEventListener(\"click\", this._clickHandler);\n\n if (this._addKeydownHandler) {\n this.removeEventListener(\"keydown\", this._keydownHandler);\n }\n }\n\n attributeChangedCallback(attr, oldVal, newVal) {\n super.attributeChangedCallback(attr, oldVal, newVal);\n\n if (!newVal) {\n return;\n }\n\n this._connectPanel(newVal);\n }\n\n toggle() {\n if (this.hasAttribute(\"disabled\")) {\n return;\n }\n\n this.expanded = !this.expanded;\n\n // one last try to hook up a panel\n if (!this.controlledPanel) {\n this._connectPanel(this.getAttribute(\"aria-controls\"));\n }\n\n if (this.controlledPanel) {\n this.controlledPanel.expanded = this.expanded;\n\n this.emitEvent(PfeCollapse.events.change, {\n detail: {\n expanded: this.expanded,\n toggle: this,\n panel: this.controlledPanel\n }\n });\n } else {\n console.warn(\n `${this.tag}: This toggle doesn't have a panel associated with it`\n );\n }\n }\n\n _clickHandler() {\n this.toggle();\n }\n\n _keydownHandler(event) {\n const key = event.key;\n\n switch (key) {\n case \" \":\n case \"Spacebar\":\n case \"Enter\":\n this.toggle();\n break;\n }\n }\n\n _connectPanel(id) {\n // this can be an issue if the pfe-collapse is located within\n // a shadow root\n if (this.getRootNode) {\n this.controlledPanel = this.getRootNode().querySelector(`#${id}`);\n } else {\n this.controlledPanel = document.querySelector(`#${id}`);\n }\n }\n}\n\nclass PfeCollapsePanel extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.53\";\n }\n\n get html() {\n return ``;\n }\n\n static get properties() {\n return {};\n }\n\n static get slots() {\n return {\"default\":{\"title\":\"Default\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-collapsibe-toggle\"},{\"$ref\":\"pfe-collapse-panel\"}]}}};\n }\n static get tag() {\n return \"pfe-collapse-panel\";\n }\n\n static get events() {\n return {\n animationStart: `${this.tag}:animation-start`,\n animationEnd: `${this.tag}:animation-end`\n };\n }\n\n get templateUrl() {\n return \"pfe-collapse-panel.html\";\n }\n\n get styleUrl() {\n return \"pfe-collapse-panel.scss\";\n }\n\n get pfeId() {\n return this.getAttribute(\"pfe-id\");\n }\n\n set pfeId(id) {\n if (!id) {\n return;\n }\n\n this.setAttribute(\"pfe-id\", id);\n }\n\n get animates() {\n return this.getAttribute(\"pfe-animation\") === \"false\" ? false : true;\n }\n\n get expanded() {\n return this.hasAttribute(\"pfe-expanded\");\n }\n\n set expanded(val) {\n const value = Boolean(val);\n\n if (value) {\n this.setAttribute(\"pfe-expanded\", \"\");\n\n if (this.animates) {\n const height = this.getBoundingClientRect().height;\n this._fireAnimationEvent(\"opening\");\n this._animate(0, height);\n }\n } else {\n if (this.hasAttribute(\"pfe-expanded\")) {\n const height = this.getBoundingClientRect().height;\n this.removeAttribute(\"pfe-expanded\");\n\n if (this.animates) {\n this._fireAnimationEvent(\"closing\");\n this._animate(height, 0);\n }\n }\n }\n }\n\n constructor(pfeClass) {\n super(pfeClass || PfeCollapsePanel);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n this.expanded = false;\n\n // if (this.id && this.id !== \"\") {\n if (this.id) {\n this.pfeId = this.id;\n }\n\n const generatedId = `${PfeCollapsePanel.tag}-${generateId()}`;\n\n if (!this.id) {\n this.id = generatedId;\n }\n\n if (!this.pfeId) {\n this.pfeId = generatedId;\n }\n }\n\n _animate(start, end) {\n this.classList.add(\"animating\");\n this.style.height = `${start}px`;\n\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n this.style.height = `${end}px`;\n this.classList.add(\"animating\");\n this.addEventListener(\"transitionend\", this._transitionEndHandler);\n });\n });\n }\n\n _transitionEndHandler(event) {\n event.target.style.height = \"\";\n event.target.classList.remove(\"animating\");\n event.target.removeEventListener(\n \"transitionend\",\n this._transitionEndHandler\n );\n\n this.emitEvent(PfeCollapsePanel.events.animationEnd, {\n detail: {\n expanded: this.expanded,\n panel: this\n }\n });\n }\n\n _fireAnimationEvent(state) {\n this.emitEvent(PfeCollapsePanel.events.animationStart, {\n detail: {\n state: state,\n panel: this\n }\n });\n }\n}\n\nclass PfeCollapse extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.53\";\n }\n\n get html() {\n return ``;\n }\n\n static get properties() {\n return {};\n }\n\n static get slots() {\n return {\"default\":{\"title\":\"Default\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"pfe-collapsibe-toggle\"},{\"$ref\":\"pfe-collapse-panel\"}]}}};\n }\n static get tag() {\n return \"pfe-collapse\";\n }\n\n get templateUrl() {\n return \"pfe-collapse.html\";\n }\n\n get styleUrl() {\n return \"pfe-collapse.scss\";\n }\n\n get schemaUrl() {\n return \"pfe-collapse.json\";\n }\n\n get animates() {\n return this.getAttribute(\"pfe-animation\") === \"false\" ? false : true;\n }\n\n static get observedAttributes() {\n return [\"pfe-animation\"];\n }\n\n static get events() {\n return {\n change: `${this.tag}:change`\n };\n }\n\n constructor(pfeClass) {\n super(pfeClass || PfeCollapse);\n\n this._toggle = null;\n this._panel = null;\n this._linkControls = this._linkControls.bind(this);\n this._changeHandler = this._changeHandler.bind(this);\n this._observer = new MutationObserver(this._linkControls);\n\n this.addEventListener(PfeCollapse.events.change, this._changeHandler);\n this.addEventListener(\n PfeCollapse.events.animationStart,\n this._animationStartHandler\n );\n this.addEventListener(\n PfeCollapse.events.animationEnd,\n this._animationEndHandler\n );\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n Promise.all([\n customElements.whenDefined(PfeCollapsePanel.tag),\n customElements.whenDefined(PfeCollapseToggle.tag)\n ]).then(() => {\n if (this.children.length) {\n this._linkControls();\n }\n\n this._observer.observe(this, { childList: true });\n });\n }\n\n disconnectedCallback() {\n this.removeEventListener(PfeCollapse.events.change, this._changeHandler);\n this.removeEventListener(\n PfeCollapse.events.animationStart,\n this._animationStartHandler\n );\n this.removeEventListener(\n PfeCollapse.events.animationEnd,\n this._animationEndHandler\n );\n this._observer.disconnect();\n }\n\n attributeChangedCallback(attr, oldVal, newVal) {\n super.attributeChangedCallback(attr, oldVal, newVal);\n\n if (!newVal) {\n return;\n }\n\n if (newVal !== \"false\" && newVal !== \"true\") {\n return;\n }\n\n if (this._panel) {\n this._panel.setAttribute(\"pfe-animation\", newVal);\n }\n }\n\n toggle() {\n this._toggle.toggle();\n }\n\n _linkControls() {\n this._toggle = this.querySelector(PfeCollapseToggle.tag);\n this._panel = this.querySelector(PfeCollapsePanel.tag);\n\n this._toggle.setAttribute(\"aria-controls\", this._panel.pfeId);\n }\n\n _animationStartHandler() {\n this.classList.add(\"animating\");\n }\n\n _animationEndHandler() {\n this.classList.remove(\"animating\");\n }\n\n _changeHandler(event) {}\n}\n\nPFElement.create(PfeCollapse);\nPFElement.create(PfeCollapseToggle);\nPFElement.create(PfeCollapsePanel);\n\nexport { PfeCollapse, PfeCollapseToggle, PfeCollapsePanel };\n"],"names":["generateId","Math","random","toString","substr","PfeCollapseToggle","PFElement","this","getAttribute","id","setAttribute","val","value","Boolean","default","title","type","namedSlot","items","oneOf","$ref","expanded","pfeId","generatedId","tag","_setTabIndex","controlledPanel","_connectPanel","removeEventListener","_clickHandler","_addKeydownHandler","_keydownHandler","attr","oldVal","newVal","hasAttribute","emitEvent","PfeCollapse","events","change","warn","toggle","event","key","getRootNode","querySelector","document","pfeClass","setTabIndex","addKeydownHandler","addEventListener","_this","PfeCollapsePanel","animates","height","getBoundingClientRect","_fireAnimationEvent","_animate","removeAttribute","start","end","classList","add","style","_this3","_transitionEndHandler","target","remove","animationEnd","state","animationStart","all","customElements","whenDefined","then","_this5","children","length","_linkControls","_observer","observe","childList","_changeHandler","_animationStartHandler","_animationEndHandler","disconnect","_panel","_toggle","_this4","bind","MutationObserver","create"],"mappings":"q2CA2BA,SAASA,WACAC,KAAKC,SACTC,SAAS,IACTC,OAAO,EAAG,OAGTC,OAA0BC,gNAuBrB,kEAIA,gEAIAC,KAAKC,aAAa,wBAGjBC,GACHA,QAIAC,aAAa,SAAUD,0CAIkB,SAAvCF,KAAKC,aAAa,+BAGdG,OACLC,EAAQC,QAAQF,QACjBD,aAAa,gBAAiBE,2CA9C5B,+DAUA,uCAIA,CAACE,QAAU,CAACC,MAAQ,UAAUC,KAAO,QAAQC,WAAY,EAAMC,MAAQ,CAACC,MAAQ,CAAC,CAACC,KAAO,yBAAyB,CAACA,KAAO,4DAG1H,uEAiCA,CAAC,0KAoBHC,UAAW,EAGZd,KAAKE,UACFa,MAAQf,KAAKE,QAGdc,EAAiBlB,EAAkBmB,QAAOxB,IAE3CO,KAAKE,UACHA,GAAKc,GAGPhB,KAAKe,aACHA,MAAQC,QAGVb,aAAa,OAAQ,UAEtBH,KAAKkB,mBACFf,aAAa,WAAY,GAG3BH,KAAKmB,sBACHC,cAAcpB,KAAKC,aAAa,sEAKlCoB,oBAAoB,QAASrB,KAAKsB,eAEnCtB,KAAKuB,yBACFF,oBAAoB,UAAWrB,KAAKwB,kEAIpBC,EAAMC,EAAQC,0GACNF,EAAMC,EAAQC,GAExCA,QAIAP,cAAcO,oCAIf3B,KAAK4B,aAAa,mBAIjBd,UAAYd,KAAKc,SAGjBd,KAAKmB,sBACHC,cAA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C,EAAkBmB,UAC/C8D,OAAS/E,KAAKsC,cAAcO,EAAiB5B,UAE7C+D,QAAQ7E,aAAa,gBAAiBH,KAAK+E,OAAOhE,6DAIlDuC,UAAUC,IAAI,iEAIdD,UAAUM,OAAO,oDAGTzB,sBAnFHK,4EACJA,GAAYV,aAEbkD,QAAU,OACVD,OAAS,OACTR,cAAgBU,EAAKV,cAAcW,UACnCP,eAAiBM,EAAKN,eAAeO,UACrCV,UAAY,IAAIW,iBAAiBF,EAAKV,iBAEtC5B,iBAAiBb,EAAYC,OAAOC,OAAQiD,EAAKN,kBACjDhC,iBACHb,EAAYC,OAAOgC,eACnBkB,EAAKL,0BAEFjC,iBACHb,EAAYC,OAAO8B,aACnBoB,EAAKJ,wBAsEX9E,EAAUqF,OAAOtD,GACjB/B,EAAUqF,OAAOtF,GACjBC,EAAUqF,OAAOvC"} \ No newline at end of file diff --git a/elements/pfe-content-set/dist/pfe-content-set.js b/elements/pfe-content-set/dist/pfe-content-set.js new file mode 100644 index 0000000000..79644719db --- /dev/null +++ b/elements/pfe-content-set/dist/pfe-content-set.js @@ -0,0 +1,259 @@ +import PFElement from '../../pfelement/dist/pfelement.js'; +import '../../pfe-accordion/dist/pfe-accordion.js'; +import '../../pfe-tabs/dist/pfe-tabs.js'; + +/*! + * PatternFly Elements: PfeContentSet 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * +*/ + +class PfeContentSet extends PFElement { + static get version() { + return "1.0.0-prerelease.54"; + } + + get html() { + return ``; + } + + static get properties() { + return {"vertical":{"title":"Vertical orientation","type":"boolean","default":false,"prefixed":false},"variant":{"title":"Variant","type":"string","enum":["wind","earth"],"default":"wind","prefixed":true},"align":{"title":"Align","type":"string","enum":["center"],"prefixed":true},"breakpoint":{"title":"Custom breakpoint","type":"string","prefixed":true},"tab-history":{"title":"Tab history","type":"boolean","default":false,"prefixed":true}}; + } + + static get slots() { + return {"default":{"title":"Default","type":"array","namedSlot":false,"items":{"oneOf":[{"$ref":"raw"}]}}}; + } + static get tag() { + return "pfe-content-set"; + } + + get templateUrl() { + return "pfe-content-set.html"; + } + + get styleUrl() { + return "pfe-content-set.scss"; + } + + get schemaUrl() { + return "pfe-content-set.json"; + } + + static get pfeType() { + return PFElement.pfeType.combo; + } + + static get cascadingAttributes() { + return { + "pfe-tab-history": "pfe-tabs" + }; + } + + static get observedAttributes() { + return ["pfe-tab-history"]; + } + + get isTab() { + var breakpointValue; + if (this.hasAttribute("pfe-breakpoint")) { + breakpointValue = this.getAttributeNode("pfe-breakpoint").value; + breakpointValue = breakpointValue.replace(/\D/g, ""); + } else { + breakpointValue = 700; + } + return this.parentNode + ? this.parentNode.offsetWidth > breakpointValue + : window.outerWidth > breakpointValue; + } + + get contentSetId() { + return this.id || this.getAttribute("pfe-id") || this.randomId; + } + + constructor() { + super(PfeContentSet, { delayRender: true }); + + this._init = this._init.bind(this); + this._observer = new MutationObserver(this._init); + } + + connectedCallback() { + super.connectedCallback(); + + if (this.children.length) { + this._init(); + } + + this._observer.observe(this, { childList: true }); + } + + disconnectedCallback() { + this._observer.disconnect(); + } + + _init() { + if (window.ShadyCSS) { + this._observer.disconnect(); + } + + if (this.isTab) { + this._buildTabs(); + } else { + this._buildAccordion(); + } + + this.render(); + this.context_update(); + + if (window.ShadyCSS) { + setTimeout(() => { + this._observer.observe(this, { childList: true }); + }, 0); + } + } + + _buildAccordion() { + let accordion; + + // Use the existing accordion if it exists + const existingAccordion = this.querySelector( + `[pfe-id="${this.contentSetId}"]` + ); + + // Use a document fragment for efficiency + const fragment = document.createDocumentFragment(); + + // Create the accordion wrapper component or use the existing component + if (!existingAccordion) { + // Create the accordion wrapper component with a unique ID + accordion = document.createElement("pfe-accordion"); + accordion.setAttribute("pfe-id", this.contentSetId); + } else { + accordion = existingAccordion; + } + + // Iterate over each element in the light DOM + [...this.children].forEach(child => { + // If one of them has the attribute indicating they belong in the header region + if (child.hasAttribute("pfe-content-set--header")) { + const header = document.createElement("pfe-accordion-header"); + + header.appendChild(child); + accordion.appendChild(header); + } + + if (child.hasAttribute("pfe-content-set--panel")) { + const panel = document.createElement("pfe-accordion-panel"); + + panel.appendChild(child); + accordion.appendChild(panel); + } + }); + + if (!existingAccordion) { + fragment.appendChild(accordion); + this.appendChild(fragment); + } + } + + _buildTabs() { + let tabs; + + // Use the existing tabs if they exist + let existingTabs = this.querySelector(`[pfe-id="${this.contentSetId}"]`); + + // Use a document fragment for efficiency + const fragment = document.createDocumentFragment(); + + // Create the tabs wrapper component or use the existing tabs + if (!existingTabs) { + tabs = document.createElement("pfe-tabs"); + tabs.setAttribute("pfe-id", this.contentSetId); + } else { + tabs = existingTabs; + } + + // Iterate over each element in the light DOM + [...this.children].forEach(child => { + // If one of them has the attribute indicating they belong in the panel region + if (child.hasAttribute("pfe-content-set--header")) { + const header = document.createElement("pfe-tab"); + + header.setAttribute("slot", "tab"); + + if (child.id) { + header.setAttribute("pfe-id", child.id); + } + + header.appendChild(child); + tabs.appendChild(header); + } + + if (child.hasAttribute("pfe-content-set--panel")) { + const panel = document.createElement("pfe-tab-panel"); + + panel.setAttribute("slot", "panel"); + + if (child.id) { + panel.setAttribute("pfe-id", child.id); + } + + panel.appendChild(child); + tabs.appendChild(panel); + } + }); + + if (!existingTabs) { + fragment.appendChild(tabs); + } + + // If the orientation is set to vertical, add that attribute to the tabs + if (this.vertical.value !== null && this.vertical.value !== false) { + tabs.setAttribute("vertical", true); + } + + // Pass the variant attribute down to the tabs component + if (this.variant.value !== this.variant.default) { + tabs.setAttribute("pfe-variant", this.variant.value); + } + + if (this.align.value) { + tabs.setAttribute("pfe-tab-align", this.align.value); + } + + if (this.hasAttribute("pfe-tab-history")) { + tabs.setAttribute("pfe-tab-history", true); + } + + if (!existingTabs) { + this.appendChild(fragment); + } + } +} + +PFElement.create(PfeContentSet); + +export default PfeContentSet; +//# sourceMappingURL=pfe-content-set.js.map diff --git a/elements/pfe-content-set/dist/pfe-content-set.js.map b/elements/pfe-content-set/dist/pfe-content-set.js.map new file mode 100644 index 0000000000..dd3dda7bdf --- /dev/null +++ b/elements/pfe-content-set/dist/pfe-content-set.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-content-set.js","sources":["../_temp/pfe-content-set.js"],"sourcesContent":["/*!\n * PatternFly Elements: PfeContentSet 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.js\";\nimport PfeAccordion from \"../../pfe-accordion/dist/pfe-accordion.js\";\nimport PfeTabs from \"../../pfe-tabs/dist/pfe-tabs.js\";\n\nclass PfeContentSet extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return ``;\n }\n\n static get properties() {\n return {\"vertical\":{\"title\":\"Vertical orientation\",\"type\":\"boolean\",\"default\":false,\"prefixed\":false},\"variant\":{\"title\":\"Variant\",\"type\":\"string\",\"enum\":[\"wind\",\"earth\"],\"default\":\"wind\",\"prefixed\":true},\"align\":{\"title\":\"Align\",\"type\":\"string\",\"enum\":[\"center\"],\"prefixed\":true},\"breakpoint\":{\"title\":\"Custom breakpoint\",\"type\":\"string\",\"prefixed\":true},\"tab-history\":{\"title\":\"Tab history\",\"type\":\"boolean\",\"default\":false,\"prefixed\":true}};\n }\n\n static get slots() {\n return {\"default\":{\"title\":\"Default\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"raw\"}]}}};\n }\n static get tag() {\n return \"pfe-content-set\";\n }\n\n get templateUrl() {\n return \"pfe-content-set.html\";\n }\n\n get styleUrl() {\n return \"pfe-content-set.scss\";\n }\n\n get schemaUrl() {\n return \"pfe-content-set.json\";\n }\n\n static get pfeType() {\n return PFElement.pfeType.combo;\n }\n\n static get cascadingAttributes() {\n return {\n \"pfe-tab-history\": \"pfe-tabs\"\n };\n }\n\n static get observedAttributes() {\n return [\"pfe-tab-history\"];\n }\n\n get isTab() {\n var breakpointValue;\n if (this.hasAttribute(\"pfe-breakpoint\")) {\n breakpointValue = this.getAttributeNode(\"pfe-breakpoint\").value;\n breakpointValue = breakpointValue.replace(/\\D/g, \"\");\n } else {\n breakpointValue = 700;\n }\n return this.parentNode\n ? this.parentNode.offsetWidth > breakpointValue\n : window.outerWidth > breakpointValue;\n }\n\n get contentSetId() {\n return this.id || this.getAttribute(\"pfe-id\") || this.randomId;\n }\n\n constructor() {\n super(PfeContentSet, { delayRender: true });\n\n this._init = this._init.bind(this);\n this._observer = new MutationObserver(this._init);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n if (this.children.length) {\n this._init();\n }\n\n this._observer.observe(this, { childList: true });\n }\n\n disconnectedCallback() {\n this._observer.disconnect();\n }\n\n _init() {\n if (window.ShadyCSS) {\n this._observer.disconnect();\n }\n\n if (this.isTab) {\n this._buildTabs();\n } else {\n this._buildAccordion();\n }\n\n this.render();\n this.context_update();\n\n if (window.ShadyCSS) {\n setTimeout(() => {\n this._observer.observe(this, { childList: true });\n }, 0);\n }\n }\n\n _buildAccordion() {\n let accordion;\n\n // Use the existing accordion if it exists\n const existingAccordion = this.querySelector(\n `[pfe-id=\"${this.contentSetId}\"]`\n );\n\n // Use a document fragment for efficiency\n const fragment = document.createDocumentFragment();\n\n // Create the accordion wrapper component or use the existing component\n if (!existingAccordion) {\n // Create the accordion wrapper component with a unique ID\n accordion = document.createElement(\"pfe-accordion\");\n accordion.setAttribute(\"pfe-id\", this.contentSetId);\n } else {\n accordion = existingAccordion;\n }\n\n // Iterate over each element in the light DOM\n [...this.children].forEach(child => {\n // If one of them has the attribute indicating they belong in the header region\n if (child.hasAttribute(\"pfe-content-set--header\")) {\n const header = document.createElement(\"pfe-accordion-header\");\n\n header.appendChild(child);\n accordion.appendChild(header);\n }\n\n if (child.hasAttribute(\"pfe-content-set--panel\")) {\n const panel = document.createElement(\"pfe-accordion-panel\");\n\n panel.appendChild(child);\n accordion.appendChild(panel);\n }\n });\n\n if (!existingAccordion) {\n fragment.appendChild(accordion);\n this.appendChild(fragment);\n }\n }\n\n _buildTabs() {\n let tabs;\n\n // Use the existing tabs if they exist\n let existingTabs = this.querySelector(`[pfe-id=\"${this.contentSetId}\"]`);\n\n // Use a document fragment for efficiency\n const fragment = document.createDocumentFragment();\n\n // Create the tabs wrapper component or use the existing tabs\n if (!existingTabs) {\n tabs = document.createElement(\"pfe-tabs\");\n tabs.setAttribute(\"pfe-id\", this.contentSetId);\n } else {\n tabs = existingTabs;\n }\n\n // Iterate over each element in the light DOM\n [...this.children].forEach(child => {\n // If one of them has the attribute indicating they belong in the panel region\n if (child.hasAttribute(\"pfe-content-set--header\")) {\n const header = document.createElement(\"pfe-tab\");\n\n header.setAttribute(\"slot\", \"tab\");\n\n if (child.id) {\n header.setAttribute(\"pfe-id\", child.id);\n }\n\n header.appendChild(child);\n tabs.appendChild(header);\n }\n\n if (child.hasAttribute(\"pfe-content-set--panel\")) {\n const panel = document.createElement(\"pfe-tab-panel\");\n\n panel.setAttribute(\"slot\", \"panel\");\n\n if (child.id) {\n panel.setAttribute(\"pfe-id\", child.id);\n }\n\n panel.appendChild(child);\n tabs.appendChild(panel);\n }\n });\n\n if (!existingTabs) {\n fragment.appendChild(tabs);\n }\n\n // If the orientation is set to vertical, add that attribute to the tabs\n if (this.vertical.value !== null && this.vertical.value !== false) {\n tabs.setAttribute(\"vertical\", true);\n }\n\n // Pass the variant attribute down to the tabs component\n if (this.variant.value !== this.variant.default) {\n tabs.setAttribute(\"pfe-variant\", this.variant.value);\n }\n\n if (this.align.value) {\n tabs.setAttribute(\"pfe-tab-align\", this.align.value);\n }\n\n if (this.hasAttribute(\"pfe-tab-history\")) {\n tabs.setAttribute(\"pfe-tab-history\", true);\n }\n\n if (!existingTabs) {\n this.appendChild(fragment);\n }\n }\n}\n\nPFElement.create(PfeContentSet);\n\nexport default PfeContentSet;\n"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,AAIA;AACA,MAAM,aAAa,SAAS,SAAS,CAAC;EAC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AK,EAAE;MACpB,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KACtD;;IAED,IAAI,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,EAAE;MACxC,IAAI,CAAC,YAAY,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;KAC5C;;IAED,IAAI,CAAC,YAAY,EAAE;MACjB,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;KAC5B;GACF;CACF;;AAED,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;;;;"} \ No newline at end of file diff --git a/elements/pfe-content-set/dist/pfe-content-set.json b/elements/pfe-content-set/dist/pfe-content-set.json new file mode 100644 index 0000000000..b6816554f3 --- /dev/null +++ b/elements/pfe-content-set/dist/pfe-content-set.json @@ -0,0 +1,69 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Content set", + "description": "This element creates a flexible component that renders an accordion or tabset depending on screen size.", + "type": "object", + "tag": "pfe-content-set", + "class": "pfe-content-set", + "category": "combo", + "properties": { + "slots": { + "title": "Slots", + "description": "Definition of the supported slots", + "type": "object", + "properties": { + "default": { + "title": "Default", + "type": "array", + "namedSlot": false, + "items": { + "oneOf": [ + { + "$ref": "raw" + } + ] + } + } + } + }, + "attributes": { + "title": "Attributes", + "type": "object", + "properties": { + "vertical": { + "title": "Vertical orientation", + "type": "boolean", + "default": false, + "prefixed": false + }, + "variant": { + "title": "Variant", + "type": "string", + "enum": ["wind", "earth"], + "default": "wind", + "prefixed": true + }, + "align": { + "title": "Align", + "type": "string", + "enum": ["center"], + "prefixed": true + }, + "breakpoint": { + "title": "Custom breakpoint", + "type": "string", + "prefixed": true + }, + "tab-history": { + "title": "Tab history", + "type": "boolean", + "default": false, + "prefixed": true + } + }, + "required": ["orientation", "variant", "on"] + } + }, + "required": ["slots", "attributes"], + "additionalProperties": false +} diff --git a/elements/pfe-content-set/dist/pfe-content-set.min.js b/elements/pfe-content-set/dist/pfe-content-set.min.js new file mode 100644 index 0000000000..567d937994 --- /dev/null +++ b/elements/pfe-content-set/dist/pfe-content-set.min.js @@ -0,0 +1,26 @@ +import t from"../../pfelement/dist/pfelement.min.js";import"../../pfe-accordion/dist/pfe-accordion.min.js";import"../../pfe-tabs/dist/pfe-tabs.min.js"; +/*! + * PatternFly Elements: PfeContentSet 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * +*/class e extends t{static get version(){return"1.0.0-prerelease.54"}get html(){return""}static get properties(){return{vertical:{title:"Vertical orientation",type:"boolean",default:!1,prefixed:!1},variant:{title:"Variant",type:"string",enum:["wind","earth"],default:"wind",prefixed:!0},align:{title:"Align",type:"string",enum:["center"],prefixed:!0},breakpoint:{title:"Custom breakpoint",type:"string",prefixed:!0},"tab-history":{title:"Tab history",type:"boolean",default:!1,prefixed:!0}}}static get slots(){return{default:{title:"Default",type:"array",namedSlot:!1,items:{oneOf:[{$ref:"raw"}]}}}}static get tag(){return"pfe-content-set"}get templateUrl(){return"pfe-content-set.html"}get styleUrl(){return"pfe-content-set.scss"}get schemaUrl(){return"pfe-content-set.json"}static get pfeType(){return t.pfeType.combo}static get cascadingAttributes(){return{"pfe-tab-history":"pfe-tabs"}}static get observedAttributes(){return["pfe-tab-history"]}get isTab(){var t;return t=this.hasAttribute("pfe-breakpoint")?(t=this.getAttributeNode("pfe-breakpoint").value).replace(/\D/g,""):700,this.parentNode?this.parentNode.offsetWidth>t:window.outerWidth>t}get contentSetId(){return this.id||this.getAttribute("pfe-id")||this.randomId}constructor(){super(e,{delayRender:!0}),this._init=this._init.bind(this),this._observer=new MutationObserver(this._init)}connectedCallback(){super.connectedCallback(),this.children.length&&this._init(),this._observer.observe(this,{childList:!0})}disconnectedCallback(){this._observer.disconnect()}_init(){window.ShadyCSS&&this._observer.disconnect(),this.isTab?this._buildTabs():this._buildAccordion(),this.render(),this.context_update(),window.ShadyCSS&&setTimeout(()=>{this._observer.observe(this,{childList:!0})},0)}_buildAccordion(){let t;const e=this.querySelector(`[pfe-id="${this.contentSetId}"]`),i=document.createDocumentFragment();e?t=e:(t=document.createElement("pfe-accordion")).setAttribute("pfe-id",this.contentSetId),[...this.children].forEach(e=>{if(e.hasAttribute("pfe-content-set--header")){const i=document.createElement("pfe-accordion-header");i.appendChild(e),t.appendChild(i)}if(e.hasAttribute("pfe-content-set--panel")){const i=document.createElement("pfe-accordion-panel");i.appendChild(e),t.appendChild(i)}}),e||(i.appendChild(t),this.appendChild(i))}_buildTabs(){let t,e=this.querySelector(`[pfe-id="${this.contentSetId}"]`);const i=document.createDocumentFragment();e?t=e:(t=document.createElement("pfe-tabs")).setAttribute("pfe-id",this.contentSetId),[...this.children].forEach(e=>{if(e.hasAttribute("pfe-content-set--header")){const i=document.createElement("pfe-tab");i.setAttribute("slot","tab"),e.id&&i.setAttribute("pfe-id",e.id),i.appendChild(e),t.appendChild(i)}if(e.hasAttribute("pfe-content-set--panel")){const i=document.createElement("pfe-tab-panel");i.setAttribute("slot","panel"),e.id&&i.setAttribute("pfe-id",e.id),i.appendChild(e),t.appendChild(i)}}),e||i.appendChild(t),null!==this.vertical.value&&!1!==this.vertical.value&&t.setAttribute("vertical",!0),this.variant.value!==this.variant.default&&t.setAttribute("pfe-variant",this.variant.value),this.align.value&&t.setAttribute("pfe-tab-align",this.align.value),this.hasAttribute("pfe-tab-history")&&t.setAttribute("pfe-tab-history",!0),e||this.appendChild(i)}}t.create(e);export default e; +//# sourceMappingURL=pfe-content-set.min.js.map diff --git a/elements/pfe-content-set/dist/pfe-content-set.min.js.map b/elements/pfe-content-set/dist/pfe-content-set.min.js.map new file mode 100644 index 0000000000..9efd7c8ab3 --- /dev/null +++ b/elements/pfe-content-set/dist/pfe-content-set.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-content-set.min.js","sources":["../_temp/pfe-content-set.js"],"sourcesContent":["/*!\n * PatternFly Elements: PfeContentSet 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.js\";\nimport PfeAccordion from \"../../pfe-accordion/dist/pfe-accordion.js\";\nimport PfeTabs from \"../../pfe-tabs/dist/pfe-tabs.js\";\n\nclass PfeContentSet extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return ``;\n }\n\n static get properties() {\n return {\"vertical\":{\"title\":\"Vertical orientation\",\"type\":\"boolean\",\"default\":false,\"prefixed\":false},\"variant\":{\"title\":\"Variant\",\"type\":\"string\",\"enum\":[\"wind\",\"earth\"],\"default\":\"wind\",\"prefixed\":true},\"align\":{\"title\":\"Align\",\"type\":\"string\",\"enum\":[\"center\"],\"prefixed\":true},\"breakpoint\":{\"title\":\"Custom breakpoint\",\"type\":\"string\",\"prefixed\":true},\"tab-history\":{\"title\":\"Tab history\",\"type\":\"boolean\",\"default\":false,\"prefixed\":true}};\n }\n\n static get slots() {\n return {\"default\":{\"title\":\"Default\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"raw\"}]}}};\n }\n static get tag() {\n return \"pfe-content-set\";\n }\n\n get templateUrl() {\n return \"pfe-content-set.html\";\n }\n\n get styleUrl() {\n return \"pfe-content-set.scss\";\n }\n\n get schemaUrl() {\n return \"pfe-content-set.json\";\n }\n\n static get pfeType() {\n return PFElement.pfeType.combo;\n }\n\n static get cascadingAttributes() {\n return {\n \"pfe-tab-history\": \"pfe-tabs\"\n };\n }\n\n static get observedAttributes() {\n return [\"pfe-tab-history\"];\n }\n\n get isTab() {\n var breakpointValue;\n if (this.hasAttribute(\"pfe-breakpoint\")) {\n breakpointValue = this.getAttributeNode(\"pfe-breakpoint\").value;\n breakpointValue = breakpointValue.replace(/\\D/g, \"\");\n } else {\n breakpointValue = 700;\n }\n return this.parentNode\n ? this.parentNode.offsetWidth > breakpointValue\n : window.outerWidth > breakpointValue;\n }\n\n get contentSetId() {\n return this.id || this.getAttribute(\"pfe-id\") || this.randomId;\n }\n\n constructor() {\n super(PfeContentSet, { delayRender: true });\n\n this._init = this._init.bind(this);\n this._observer = new MutationObserver(this._init);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n if (this.children.length) {\n this._init();\n }\n\n this._observer.observe(this, { childList: true });\n }\n\n disconnectedCallback() {\n this._observer.disconnect();\n }\n\n _init() {\n if (window.ShadyCSS) {\n this._observer.disconnect();\n }\n\n if (this.isTab) {\n this._buildTabs();\n } else {\n this._buildAccordion();\n }\n\n this.render();\n this.context_update();\n\n if (window.ShadyCSS) {\n setTimeout(() => {\n this._observer.observe(this, { childList: true });\n }, 0);\n }\n }\n\n _buildAccordion() {\n let accordion;\n\n // Use the existing accordion if it exists\n const existingAccordion = this.querySelector(\n `[pfe-id=\"${this.contentSetId}\"]`\n );\n\n // Use a document fragment for efficiency\n const fragment = document.createDocumentFragment();\n\n // Create the accordion wrapper component or use the existing component\n if (!existingAccordion) {\n // Create the accordion wrapper component with a unique ID\n accordion = document.createElement(\"pfe-accordion\");\n accordion.setAttribute(\"pfe-id\", this.contentSetId);\n } else {\n accordion = existingAccordion;\n }\n\n // Iterate over each element in the light DOM\n [...this.children].forEach(child => {\n // If one of them has the attribute indicating they belong in the header region\n if (child.hasAttribute(\"pfe-content-set--header\")) {\n const header = document.createElement(\"pfe-accordion-header\");\n\n header.appendChild(child);\n accordion.appendChild(header);\n }\n\n if (child.hasAttribute(\"pfe-content-set--panel\")) {\n const panel = document.createElement(\"pfe-accordion-panel\");\n\n panel.appendChild(child);\n accordion.appendChild(panel);\n }\n });\n\n if (!existingAccordion) {\n fragment.appendChild(accordion);\n this.appendChild(fragment);\n }\n }\n\n _buildTabs() {\n let tabs;\n\n // Use the existing tabs if they exist\n let existingTabs = this.querySelector(`[pfe-id=\"${this.contentSetId}\"]`);\n\n // Use a document fragment for efficiency\n const fragment = document.createDocumentFragment();\n\n // Create the tabs wrapper component or use the existing tabs\n if (!existingTabs) {\n tabs = document.createElement(\"pfe-tabs\");\n tabs.setAttribute(\"pfe-id\", this.contentSetId);\n } else {\n tabs = existingTabs;\n }\n\n // Iterate over each element in the light DOM\n [...this.children].forEach(child => {\n // If one of them has the attribute indicating they belong in the panel region\n if (child.hasAttribute(\"pfe-content-set--header\")) {\n const header = document.createElement(\"pfe-tab\");\n\n header.setAttribute(\"slot\", \"tab\");\n\n if (child.id) {\n header.setAttribute(\"pfe-id\", child.id);\n }\n\n header.appendChild(child);\n tabs.appendChild(header);\n }\n\n if (child.hasAttribute(\"pfe-content-set--panel\")) {\n const panel = document.createElement(\"pfe-tab-panel\");\n\n panel.setAttribute(\"slot\", \"panel\");\n\n if (child.id) {\n panel.setAttribute(\"pfe-id\", child.id);\n }\n\n panel.appendChild(child);\n tabs.appendChild(panel);\n }\n });\n\n if (!existingTabs) {\n fragment.appendChild(tabs);\n }\n\n // If the orientation is set to vertical, add that attribute to the tabs\n if (this.vertical.value !== null && this.vertical.value !== false) {\n tabs.setAttribute(\"vertical\", true);\n }\n\n // Pass the variant attribute down to the tabs component\n if (this.variant.value !== this.variant.default) {\n tabs.setAttribute(\"pfe-variant\", this.variant.value);\n }\n\n if (this.align.value) {\n tabs.setAttribute(\"pfe-tab-align\", this.align.value);\n }\n\n if (this.hasAttribute(\"pfe-tab-history\")) {\n tabs.setAttribute(\"pfe-tab-history\", true);\n }\n\n if (!existingTabs) {\n this.appendChild(fragment);\n }\n }\n}\n\nPFElement.create(PfeContentSet);\n\nexport default PfeContentSet;\n"],"names":["PfeContentSet","PFElement","version","html","properties","vertical","title","type","default","prefixed","variant","enum","align","breakpoint","tab-history","slots","namedSlot","items","oneOf","$ref","tag","templateUrl","styleUrl","schemaUrl","pfeType","combo","cascadingAttributes","pfe-tab-history","observedAttributes","isTab","breakpointValue","this","hasAttribute","getAttributeNode","value","replace","parentNode","offsetWidth","window","outerWidth","contentSetId","id","getAttribute","randomId","[object Object]","super","delayRender","_init","bind","_observer","MutationObserver","connectedCallback","children","length","observe","childList","disconnect","ShadyCSS","_buildTabs","_buildAccordion","render","context_update","setTimeout","accordion","existingAccordion","querySelector","fragment","document","createDocumentFragment","createElement","setAttribute","forEach","child","header","appendChild","panel","tabs","existingTabs","create"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;EA6BA,MAAMA,UAAsBC,EAC1BC,qBACE,MAAO,sBAGTC,WACE,MAAO,uIAKTC,wBACE,MAAO,CAACC,SAAW,CAACC,MAAQ,uBAAuBC,KAAO,UAAUC,SAAU,EAAMC,UAAW,GAAOC,QAAU,CAACJ,MAAQ,UAAUC,KAAO,SAASI,KAAO,CAAC,OAAO,SAASH,QAAU,OAAOC,UAAW,GAAMG,MAAQ,CAACN,MAAQ,QAAQC,KAAO,SAASI,KAAO,CAAC,UAAUF,UAAW,GAAMI,WAAa,CAACP,MAAQ,oBAAoBC,KAAO,SAASE,UAAW,GAAMK,cAAc,CAACR,MAAQ,cAAcC,KAAO,UAAUC,SAAU,EAAMC,UAAW,IAGvbM,mBACE,MAAO,CAACP,QAAU,CAACF,MAAQ,UAAUC,KAAO,QAAQS,WAAY,EAAMC,MAAQ,CAACC,MAAQ,CAAC,CAACC,KAAO,WAElGC,iBACE,MAAO,kBAGTC,kBACE,MAAO,uBAGTC,eACE,MAAO,uBAGTC,gBACE,MAAO,uBAGTC,qBACE,OAAOvB,EAAUuB,QAAQC,MAG3BC,iCACE,MAAO,CACLC,kBAAmB,YAIvBC,gCACE,MAAO,CAAC,mBAGVC,YACE,IAAIC,EAOJ,OAJEA,EAFEC,KAAKC,aAAa,mBACpBF,EAAkBC,KAAKE,iBAAiB,kBAAkBC,OACxBC,QAAQ,MAAO,IAE/B,IAEbJ,KAAKK,WACRL,KAAKK,WAAWC,YAAcP,EAC9BQ,OAAOC,WAAaT,EAG1BU,mBACE,OAAOT,KAAKU,IAAMV,KAAKW,aAAa,WAAaX,KAAKY,SAGxDC,cACEC,MAAM7C,EAAe,CAAE8C,aAAa,IAEpCf,KAAKgB,MAAQhB,KAAKgB,MAAMC,K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E,EAAM/B,IACRgC,EAAOH,aAAa,SAAUE,EAAM/B,IAGtCgC,EAAOC,YAAYF,GACnBI,EAAKF,YAAYD,GAGnB,GAAID,EAAMxC,aAAa,0BAA2B,CAChD,MAAM2C,EAAQR,SAASE,cAAc,iBAErCM,EAAML,aAAa,OAAQ,SAEvBE,EAAM/B,IACRkC,EAAML,aAAa,SAAUE,EAAM/B,IAGrCkC,EAAMD,YAAYF,GAClBI,EAAKF,YAAYC,MAIhBE,GACHX,EAASQ,YAAYE,GAIK,OAAxB7C,KAAK1B,SAAS6B,QAA0C,IAAxBH,KAAK1B,SAAS6B,OAChD0C,EAAKN,aAAa,YAAY,GAI5BvC,KAAKrB,QAAQwB,QAAUH,KAAKrB,QAAQF,SACtCoE,EAAKN,aAAa,cAAevC,KAAKrB,QAAQwB,OAG5CH,KAAKnB,MAAMsB,OACb0C,EAAKN,aAAa,gBAAiBvC,KAAKnB,MAAMsB,OAG5CH,KAAKC,aAAa,oBACpB4C,EAAKN,aAAa,mBAAmB,GAGlCO,GACH9C,KAAK2C,YAAYR,IAKvBjE,EAAU6E,OAAO9E"} \ No newline at end of file diff --git a/elements/pfe-content-set/dist/pfe-content-set.umd.js b/elements/pfe-content-set/dist/pfe-content-set.umd.js new file mode 100644 index 0000000000..ff83a5ec0d --- /dev/null +++ b/elements/pfe-content-set/dist/pfe-content-set.umd.js @@ -0,0 +1,374 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../../pfelement/dist/pfelement.umd'), require('../../pfe-accordion/dist/pfe-accordion.umd'), require('../../pfe-tabs/dist/pfe-tabs.umd')) : + typeof define === 'function' && define.amd ? define(['../../pfelement/dist/pfelement.umd', '../../pfe-accordion/dist/pfe-accordion.umd', '../../pfe-tabs/dist/pfe-tabs.umd'], factory) : + (global.PfeContentSet = factory(global.PFElement,global.PfeAccordion,global.PfeTabs)); +}(this, (function (PFElement,pfeAccordion_umd,pfeTabs_umd) { 'use strict'; + + PFElement = PFElement && PFElement.hasOwnProperty('default') ? PFElement['default'] : PFElement; + pfeAccordion_umd = pfeAccordion_umd && pfeAccordion_umd.hasOwnProperty('default') ? pfeAccordion_umd['default'] : pfeAccordion_umd; + pfeTabs_umd = pfeTabs_umd && pfeTabs_umd.hasOwnProperty('default') ? pfeTabs_umd['default'] : pfeTabs_umd; + + var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + }; + + var createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + }(); + + var get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + + if (getter === undefined) { + return undefined; + } + + return getter.call(receiver); + } + }; + + var inherits = function (subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + }; + + var possibleConstructorReturn = function (self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && (typeof call === "object" || typeof call === "function") ? call : self; + }; + + var toConsumableArray = function (arr) { + if (Array.isArray(arr)) { + for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; + + return arr2; + } else { + return Array.from(arr); + } + }; + + /*! + * PatternFly Elements: PfeContentSet 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + + var PfeContentSet = function (_PFElement) { + inherits(PfeContentSet, _PFElement); + createClass(PfeContentSet, [{ + key: "html", + get: function get$$1() { + return ""; + } + }, { + key: "templateUrl", + get: function get$$1() { + return "pfe-content-set.html"; + } + }, { + key: "styleUrl", + get: function get$$1() { + return "pfe-content-set.scss"; + } + }, { + key: "schemaUrl", + get: function get$$1() { + return "pfe-content-set.json"; + } + }, { + key: "isTab", + get: function get$$1() { + var breakpointValue; + if (this.hasAttribute("pfe-breakpoint")) { + breakpointValue = this.getAttributeNode("pfe-breakpoint").value; + breakpointValue = breakpointValue.replace(/\D/g, ""); + } else { + breakpointValue = 700; + } + return this.parentNode ? this.parentNode.offsetWidth > breakpointValue : window.outerWidth > breakpointValue; + } + }, { + key: "contentSetId", + get: function get$$1() { + return this.id || this.getAttribute("pfe-id") || this.randomId; + } + }], [{ + key: "version", + get: function get$$1() { + return "1.0.0-prerelease.54"; + } + }, { + key: "properties", + get: function get$$1() { + return { "vertical": { "title": "Vertical orientation", "type": "boolean", "default": false, "prefixed": false }, "variant": { "title": "Variant", "type": "string", "enum": ["wind", "earth"], "default": "wind", "prefixed": true }, "align": { "title": "Align", "type": "string", "enum": ["center"], "prefixed": true }, "breakpoint": { "title": "Custom breakpoint", "type": "string", "prefixed": true }, "tab-history": { "title": "Tab history", "type": "boolean", "default": false, "prefixed": true } }; + } + }, { + key: "slots", + get: function get$$1() { + return { "default": { "title": "Default", "type": "array", "namedSlot": false, "items": { "oneOf": [{ "$ref": "raw" }] } } }; + } + }, { + key: "tag", + get: function get$$1() { + return "pfe-content-set"; + } + }, { + key: "pfeType", + get: function get$$1() { + return PFElement.pfeType.combo; + } + }, { + key: "cascadingAttributes", + get: function get$$1() { + return { + "pfe-tab-history": "pfe-tabs" + }; + } + }, { + key: "observedAttributes", + get: function get$$1() { + return ["pfe-tab-history"]; + } + }]); + + function PfeContentSet() { + classCallCheck(this, PfeContentSet); + + var _this = possibleConstructorReturn(this, (PfeContentSet.__proto__ || Object.getPrototypeOf(PfeContentSet)).call(this, PfeContentSet, { delayRender: true })); + + _this._init = _this._init.bind(_this); + _this._observer = new MutationObserver(_this._init); + return _this; + } + + createClass(PfeContentSet, [{ + key: "connectedCallback", + value: function connectedCallback() { + get(PfeContentSet.prototype.__proto__ || Object.getPrototypeOf(PfeContentSet.prototype), "connectedCallback", this).call(this); + + if (this.children.length) { + this._init(); + } + + this._observer.observe(this, { childList: true }); + } + }, { + key: "disconnectedCallback", + value: function disconnectedCallback() { + this._observer.disconnect(); + } + }, { + key: "_init", + value: function _init() { + var _this2 = this; + + if (window.ShadyCSS) { + this._observer.disconnect(); + } + + if (this.isTab) { + this._buildTabs(); + } else { + this._buildAccordion(); + } + + this.render(); + this.context_update(); + + if (window.ShadyCSS) { + setTimeout(function () { + _this2._observer.observe(_this2, { childList: true }); + }, 0); + } + } + }, { + key: "_buildAccordion", + value: function _buildAccordion() { + var accordion = void 0; + + // Use the existing accordion if it exists + var existingAccordion = this.querySelector("[pfe-id=\"" + this.contentSetId + "\"]"); + + // Use a document fragment for efficiency + var fragment = document.createDocumentFragment(); + + // Create the accordion wrapper component or use the existing component + if (!existingAccordion) { + // Create the accordion wrapper component with a unique ID + accordion = document.createElement("pfe-accordion"); + accordion.setAttribute("pfe-id", this.contentSetId); + } else { + accordion = existingAccordion; + } + + // Iterate over each element in the light DOM + [].concat(toConsumableArray(this.children)).forEach(function (child) { + // If one of them has the attribute indicating they belong in the header region + if (child.hasAttribute("pfe-content-set--header")) { + var header = document.createElement("pfe-accordion-header"); + + header.appendChild(child); + accordion.appendChild(header); + } + + if (child.hasAttribute("pfe-content-set--panel")) { + var panel = document.createElement("pfe-accordion-panel"); + + panel.appendChild(child); + accordion.appendChild(panel); + } + }); + + if (!existingAccordion) { + fragment.appendChild(accordion); + this.appendChild(fragment); + } + } + }, { + key: "_buildTabs", + value: function _buildTabs() { + var tabs = void 0; + + // Use the existing tabs if they exist + var existingTabs = this.querySelector("[pfe-id=\"" + this.contentSetId + "\"]"); + + // Use a document fragment for efficiency + var fragment = document.createDocumentFragment(); + + // Create the tabs wrapper component or use the existing tabs + if (!existingTabs) { + tabs = document.createElement("pfe-tabs"); + tabs.setAttribute("pfe-id", this.contentSetId); + } else { + tabs = existingTabs; + } + + // Iterate over each element in the light DOM + [].concat(toConsumableArray(this.children)).forEach(function (child) { + // If one of them has the attribute indicating they belong in the panel region + if (child.hasAttribute("pfe-content-set--header")) { + var header = document.createElement("pfe-tab"); + + header.setAttribute("slot", "tab"); + + if (child.id) { + header.setAttribute("pfe-id", child.id); + } + + header.appendChild(child); + tabs.appendChild(header); + } + + if (child.hasAttribute("pfe-content-set--panel")) { + var panel = document.createElement("pfe-tab-panel"); + + panel.setAttribute("slot", "panel"); + + if (child.id) { + panel.setAttribute("pfe-id", child.id); + } + + panel.appendChild(child); + tabs.appendChild(panel); + } + }); + + if (!existingTabs) { + fragment.appendChild(tabs); + } + + // If the orientation is set to vertical, add that attribute to the tabs + if (this.vertical.value !== null && this.vertical.value !== false) { + tabs.setAttribute("vertical", true); + } + + // Pass the variant attribute down to the tabs component + if (this.variant.value !== this.variant.default) { + tabs.setAttribute("pfe-variant", this.variant.value); + } + + if (this.align.value) { + tabs.setAttribute("pfe-tab-align", this.align.value); + } + + if (this.hasAttribute("pfe-tab-history")) { + tabs.setAttribute("pfe-tab-history", true); + } + + if (!existingTabs) { + this.appendChild(fragment); + } + } + }]); + return PfeContentSet; + }(PFElement); + + PFElement.create(PfeContentSet); + + return PfeContentSet; + +}))); +//# sourceMappingURL=pfe-content-set.umd.js.map diff --git a/elements/pfe-content-set/dist/pfe-content-set.umd.js.map b/elements/pfe-content-set/dist/pfe-content-set.umd.js.map new file mode 100644 index 0000000000..c80b73bf23 --- /dev/null +++ b/elements/pfe-content-set/dist/pfe-content-set.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-content-set.umd.js","sources":["../_temp/pfe-content-set.umd.js"],"sourcesContent":["/*!\n * PatternFly Elements: PfeContentSet 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.umd\";\nimport PfeAccordion from \"../../pfe-accordion/dist/pfe-accordion.umd\";\nimport PfeTabs from \"../../pfe-tabs/dist/pfe-tabs.umd\";\n\nclass PfeContentSet extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return ``;\n }\n\n static get properties() {\n return {\"vertical\":{\"title\":\"Vertical orientation\",\"type\":\"boolean\",\"default\":false,\"prefixed\":false},\"variant\":{\"title\":\"Variant\",\"type\":\"string\",\"enum\":[\"wind\",\"earth\"],\"default\":\"wind\",\"prefixed\":true},\"align\":{\"title\":\"Align\",\"type\":\"string\",\"enum\":[\"center\"],\"prefixed\":true},\"breakpoint\":{\"title\":\"Custom breakpoint\",\"type\":\"string\",\"prefixed\":true},\"tab-history\":{\"title\":\"Tab history\",\"type\":\"boolean\",\"default\":false,\"prefixed\":true}};\n }\n\n static get slots() {\n return {\"default\":{\"title\":\"Default\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"raw\"}]}}};\n }\n static get tag() {\n return \"pfe-content-set\";\n }\n\n get templateUrl() {\n return \"pfe-content-set.html\";\n }\n\n get styleUrl() {\n return \"pfe-content-set.scss\";\n }\n\n get schemaUrl() {\n return \"pfe-content-set.json\";\n }\n\n static get pfeType() {\n return PFElement.pfeType.combo;\n }\n\n static get cascadingAttributes() {\n return {\n \"pfe-tab-history\": \"pfe-tabs\"\n };\n }\n\n static get observedAttributes() {\n return [\"pfe-tab-history\"];\n }\n\n get isTab() {\n var breakpointValue;\n if (this.hasAttribute(\"pfe-breakpoint\")) {\n breakpointValue = this.getAttributeNode(\"pfe-breakpoint\").value;\n breakpointValue = breakpointValue.replace(/\\D/g, \"\");\n } else {\n breakpointValue = 700;\n }\n return this.parentNode\n ? this.parentNode.offsetWidth > breakpointValue\n : window.outerWidth > breakpointValue;\n }\n\n get contentSetId() {\n return this.id || this.getAttribute(\"pfe-id\") || this.randomId;\n }\n\n constructor() {\n super(PfeContentSet, { delayRender: true });\n\n this._init = this._init.bind(this);\n this._observer = new MutationObserver(this._init);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n if (this.children.length) {\n this._init();\n }\n\n this._observer.observe(this, { childList: true });\n }\n\n disconnectedCallback() {\n this._observer.disconnect();\n }\n\n _init() {\n if (window.ShadyCSS) {\n this._observer.disconnect();\n }\n\n if (this.isTab) {\n this._buildTabs();\n } else {\n this._buildAccordion();\n }\n\n this.render();\n this.context_update();\n\n if (window.ShadyCSS) {\n setTimeout(() => {\n this._observer.observe(this, { childList: true });\n }, 0);\n }\n }\n\n _buildAccordion() {\n let accordion;\n\n // Use the existing accordion if it exists\n const existingAccordion = this.querySelector(\n `[pfe-id=\"${this.contentSetId}\"]`\n );\n\n // Use a document fragment for efficiency\n const fragment = document.createDocumentFragment();\n\n // Create the accordion wrapper component or use the existing component\n if (!existingAccordion) {\n // Create the accordion wrapper component with a unique ID\n accordion = document.createElement(\"pfe-accordion\");\n accordion.setAttribute(\"pfe-id\", this.contentSetId);\n } else {\n accordion = existingAccordion;\n }\n\n // Iterate over each element in the light DOM\n [...this.children].forEach(child => {\n // If one of them has the attribute indicating they belong in the header region\n if (child.hasAttribute(\"pfe-content-set--header\")) {\n const header = document.createElement(\"pfe-accordion-header\");\n\n header.appendChild(child);\n accordion.appendChild(header);\n }\n\n if (child.hasAttribute(\"pfe-content-set--panel\")) {\n const panel = document.createElement(\"pfe-accordion-panel\");\n\n panel.appendChild(child);\n accordion.appendChild(panel);\n }\n });\n\n if (!existingAccordion) {\n fragment.appendChild(accordion);\n this.appendChild(fragment);\n }\n }\n\n _buildTabs() {\n let tabs;\n\n // Use the existing tabs if they exist\n let existingTabs = this.querySelector(`[pfe-id=\"${this.contentSetId}\"]`);\n\n // Use a document fragment for efficiency\n const fragment = document.createDocumentFragment();\n\n // Create the tabs wrapper component or use the existing tabs\n if (!existingTabs) {\n tabs = document.createElement(\"pfe-tabs\");\n tabs.setAttribute(\"pfe-id\", this.contentSetId);\n } else {\n tabs = existingTabs;\n }\n\n // Iterate over each element in the light DOM\n [...this.children].forEach(child => {\n // If one of them has the attribute indicating they belong in the panel region\n if (child.hasAttribute(\"pfe-content-set--header\")) {\n const header = document.createElement(\"pfe-tab\");\n\n header.setAttribute(\"slot\", \"tab\");\n\n if (child.id) {\n header.setAttribute(\"pfe-id\", child.id);\n }\n\n header.appendChild(child);\n tabs.appendChild(header);\n }\n\n if (child.hasAttribute(\"pfe-content-set--panel\")) {\n const panel = document.createElement(\"pfe-tab-panel\");\n\n panel.setAttribute(\"slot\", \"panel\");\n\n if (child.id) {\n panel.setAttribute(\"pfe-id\", child.id);\n }\n\n panel.appendChild(child);\n tabs.appendChild(panel);\n }\n });\n\n if (!existingTabs) {\n fragment.appendChild(tabs);\n }\n\n // If the orientation is set to vertical, add that attribute to the tabs\n if (this.vertical.value !== null && this.vertical.value !== false) {\n tabs.setAttribute(\"vertical\", true);\n }\n\n // Pass the variant attribute down to the tabs component\n if (this.variant.value !== this.variant.default) {\n tabs.setAttribute(\"pfe-variant\", this.variant.value);\n }\n\n if (this.align.value) {\n tabs.setAttribute(\"pfe-tab-align\", this.align.value);\n }\n\n if (this.hasAttribute(\"pfe-tab-history\")) {\n tabs.setAttribute(\"pfe-tab-history\", true);\n }\n\n if (!existingTabs) {\n this.appendChild(fragment);\n }\n }\n}\n\nPFElement.create(PfeContentSet);\n\nexport default PfeContentSet;\n"],"names":["PfeContentSet","breakpointValue","hasAttribute","getAttributeNode","value","replace","parentNode","offsetWidth","window","outerWidth","id","getAttribute","randomId","PFElement","pfeType","combo","delayRender","_init","bind","_observer","MutationObserver","children","length","observe","childList","disconnect","ShadyCSS","isTab","_buildTabs","_buildAccordion","render","context_update","setTimeout","accordion","existingAccordion","querySelector","contentSetId","fragment","document","createDocumentFragment","createElement","setAttribute","forEach","child","header","appendChild","panel","tabs","existingTabs","vertical","variant","default","align","create"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;MA6BMA;;;;6BAKO;EACT;EAGD;;;6BAaiB;EAChB,aAAO,sBAAP;EACD;;;6BAEc;EACb,aAAO,sBAAP;EACD;;;6BAEe;EACd,aAAO,sBAAP;EACD;;;6BAgBW;EACV,UAAIC,eAAJ;EACA,UAAI,KAAKC,YAAL,CAAkB,gBAAlB,CAAJ,EAAyC;EACvCD,0BAAkB,KAAKE,gBAAL,CAAsB,gBAAtB,EAAwCC,KAA1D;EACAH,0BAAkBA,gBAAgBI,OAAhB,CAAwB,KAAxB,EAA+B,EAA/B,CAAlB;EACD,OAHD,MAGO;EACLJ,0BAAkB,GAAlB;EACD;EACD,aAAO,KAAKK,UAAL,GACH,KAAKA,UAAL,CAAgBC,WAAhB,GAA8BN,eAD3B,GAEHO,OAAOC,UAAP,GAAoBR,eAFxB;EAGD;;;6BAEkB;EACjB,aAAO,KAAKS,EAAL,IAAW,KAAKC,YAAL,CAAkB,QAAlB,CAAX,IAA0C,KAAKC,QAAtD;EACD;;;6BA9DoB;EACnB,aAAO,qBAAP;EACD;;;6BAQuB;EACtB,aAAO,EAAC,YAAW,EAAC,SAAQ,sBAAT,EAAgC,QAAO,SAAvC,EAAiD,WAAU,KAA3D,EAAiE,YAAW,KAA5E,EAAZ,EAA+F,WAAU,EAAC,SAAQ,SAAT,EAAmB,QAAO,QAA1B,EAAmC,QAAO,CAAC,MAAD,EAAQ,OAAR,CAA1C,EAA2D,WAAU,MAArE,EAA4E,YAAW,IAAvF,EAAzG,EAAsM,SAAQ,EAAC,SAAQ,OAAT,EAA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lB,EAA8B,IAA9B;EACD;;EAED;EACA,UAAI,KAAKS,OAAL,CAAa9C,KAAb,KAAuB,KAAK8C,OAAL,CAAaC,OAAxC,EAAiD;EAC/CJ,aAAKN,YAAL,CAAkB,aAAlB,EAAiC,KAAKS,OAAL,CAAa9C,KAA9C;EACD;;EAED,UAAI,KAAKgD,KAAL,CAAWhD,KAAf,EAAsB;EACpB2C,aAAKN,YAAL,CAAkB,eAAlB,EAAmC,KAAKW,KAAL,CAAWhD,KAA9C;EACD;;EAED,UAAI,KAAKF,YAAL,CAAkB,iBAAlB,CAAJ,EAA0C;EACxC6C,aAAKN,YAAL,CAAkB,iBAAlB,EAAqC,IAArC;EACD;;EAED,UAAI,CAACO,YAAL,EAAmB;EACjB,aAAKH,WAAL,CAAiBR,QAAjB;EACD;EACF;;;IA/NyBxB;;EAkO5BA,UAAUwC,MAAV,CAAiBrD,aAAjB;;;;;;;;"} \ No newline at end of file diff --git a/elements/pfe-content-set/dist/pfe-content-set.umd.min.js b/elements/pfe-content-set/dist/pfe-content-set.umd.min.js new file mode 100644 index 0000000000..d143234776 --- /dev/null +++ b/elements/pfe-content-set/dist/pfe-content-set.umd.min.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("../../pfelement/dist/pfelement.umd"),require("../../pfe-accordion/dist/pfe-accordion.umd"),require("../../pfe-tabs/dist/pfe-tabs.umd")):"function"==typeof define&&define.amd?define(["../../pfelement/dist/pfelement.umd","../../pfe-accordion/dist/pfe-accordion.umd","../../pfe-tabs/dist/pfe-tabs.umd"],t):e.PfeContentSet=t(e.PFElement,e.PfeAccordion,e.PfeTabs)}(this,function(e,t,n){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e,t=t&&t.hasOwnProperty("default")?t.default:t,n=n&&n.hasOwnProperty("default")?n.default:n;var i=function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e};function r(e,t){for(var n=0;n:host{display:block}:host([hidden]){display:none}\n/*# sourceMappingURL=pfe-content-set.min.css.map */\n"}},{key:"templateUrl",get:function(){return"pfe-content-set.html"}},{key:"styleUrl",get:function(){return"pfe-content-set.scss"}},{key:"schemaUrl",get:function(){return"pfe-content-set.json"}},{key:"isTab",get:function(){var e;return e=this.hasAttribute("pfe-breakpoint")?(e=this.getAttributeNode("pfe-breakpoint").value).replace(/\D/g,""):700,this.parentNode?this.parentNode.offsetWidth>e:window.outerWidth>e}},{key:"contentSetId",get:function(){return this.id||this.getAttribute("pfe-id")||this.randomId}}],[{key:"version",get:function(){return"1.0.0-prerelease.54"}},{key:"properties",get:function(){return{vertical:{title:"Vertical orientation",type:"boolean",default:!1,prefixed:!1},variant:{title:"Variant",type:"string",enum:["wind","earth"],default:"wind",prefixed:!0},align:{title:"Align",type:"string",enum:["center"],prefixed:!0},breakpoint:{title:"Custom breakpoint",type:"string",prefixed:!0},"tab-history":{title:"Tab history",type:"boolean",default:!1,prefixed:!0}}}},{key:"slots",get:function(){return{default:{title:"Default",type:"array",namedSlot:!1,items:{oneOf:[{$ref:"raw"}]}}}}},{key:"tag",get:function(){return"pfe-content-set"}},{key:"pfeType",get:function(){return e.pfeType.combo}},{key:"cascadingAttributes",get:function(){return{"pfe-tab-history":"pfe-tabs"}}},{key:"observedAttributes",get:function(){return["pfe-tab-history"]}}]),i(s,[{key:"connectedCallback",value:function(){(function e(t,n,i){null===t&&(t=Function.prototype);var r=Object.getOwnPropertyDescriptor(t,n);if(void 0===r){var o=Object.getPrototypeOf(t);return null===o?void 0:e(o,n,i)}if("value"in r)return r.value;var a=r.get;return void 0!==a?a.call(i):void 0})(s.prototype.__proto__||Object.getPrototypeOf(s.prototype),"connectedCallback",this).call(this),this.children.length&&this._init(),this._observer.observe(this,{childList:!0})}},{key:"disconnectedCallback",value:function(){this._observer.disconnect()}},{key:"_init",value:function(){var e=this;window.ShadyCSS&&this._observer.disconnect(),this.isTab?this._buildTabs():this._buildAccordion(),this.render(),this.context_update(),window.ShadyCSS&&setTimeout(function(){e._observer.observe(e,{childList:!0})},0)}},{key:"_buildAccordion",value:function(){var i=void 0,e=this.querySelector('[pfe-id="'+this.contentSetId+'"]'),t=document.createDocumentFragment();e?i=e:(i=document.createElement("pfe-accordion")).setAttribute("pfe-id",this.contentSetId),[].concat(o(this.children)).forEach(function(e){if(e.hasAttribute("pfe-content-set--header")){var t=document.createElement("pfe-accordion-header");t.appendChild(e),i.appendChild(t)}if(e.hasAttribute("pfe-content-set--panel")){var n=document.createElement("pfe-accordion-panel");n.appendChild(e),i.appendChild(n)}}),e||(t.appendChild(i),this.appendChild(t))}},{key:"_buildTabs",value:function(){var i=void 0,e=this.querySelector('[pfe-id="'+this.contentSetId+'"]'),t=document.createDocumentFragment();e?i=e:(i=document.createElement("pfe-tabs")).setAttribute("pfe-id",this.contentSetId),[].concat(o(this.children)).forEach(function(e){if(e.hasAttribute("pfe-content-set--header")){var t=document.createElement("pfe-tab");t.setAttribute("slot","tab"),e.id&&t.setAttribute("pfe-id",e.id),t.appendChild(e),i.appendChild(t)}if(e.hasAttribute("pfe-content-set--panel")){var n=document.createElement("pfe-tab-panel");n.setAttribute("slot","panel"),e.id&&n.setAttribute("pfe-id",e.id),n.appendChild(e),i.appendChild(n)}}),e||t.appendChild(i),null!==this.vertical.value&&!1!==this.vertical.value&&i.setAttribute("vertical",!0),this.variant.value!==this.variant.default&&i.setAttribute("pfe-variant",this.variant.value),this.align.value&&i.setAttribute("pfe-tab-align",this.align.value),this.hasAttribute("pfe-tab-history")&&i.setAttribute("pfe-tab-history",!0),e||this.appendChild(t)}}]),s);function s(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s);var e=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,s,{delayRender:!0}));return e._init=e._init.bind(e),e._observer=new MutationObserver(e._init),e}return e.create(a),a}); +//# sourceMappingURL=pfe-content-set.umd.min.js.map diff --git a/elements/pfe-content-set/dist/pfe-content-set.umd.min.js.map b/elements/pfe-content-set/dist/pfe-content-set.umd.min.js.map new file mode 100644 index 0000000000..ee50112e90 --- /dev/null +++ b/elements/pfe-content-set/dist/pfe-content-set.umd.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-content-set.umd.min.js","sources":["../_temp/pfe-content-set.umd.js"],"sourcesContent":["/*!\n * PatternFly Elements: PfeContentSet 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.umd\";\nimport PfeAccordion from \"../../pfe-accordion/dist/pfe-accordion.umd\";\nimport PfeTabs from \"../../pfe-tabs/dist/pfe-tabs.umd\";\n\nclass PfeContentSet extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return ``;\n }\n\n static get properties() {\n return {\"vertical\":{\"title\":\"Vertical orientation\",\"type\":\"boolean\",\"default\":false,\"prefixed\":false},\"variant\":{\"title\":\"Variant\",\"type\":\"string\",\"enum\":[\"wind\",\"earth\"],\"default\":\"wind\",\"prefixed\":true},\"align\":{\"title\":\"Align\",\"type\":\"string\",\"enum\":[\"center\"],\"prefixed\":true},\"breakpoint\":{\"title\":\"Custom breakpoint\",\"type\":\"string\",\"prefixed\":true},\"tab-history\":{\"title\":\"Tab history\",\"type\":\"boolean\",\"default\":false,\"prefixed\":true}};\n }\n\n static get slots() {\n return {\"default\":{\"title\":\"Default\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"oneOf\":[{\"$ref\":\"raw\"}]}}};\n }\n static get tag() {\n return \"pfe-content-set\";\n }\n\n get templateUrl() {\n return \"pfe-content-set.html\";\n }\n\n get styleUrl() {\n return \"pfe-content-set.scss\";\n }\n\n get schemaUrl() {\n return \"pfe-content-set.json\";\n }\n\n static get pfeType() {\n return PFElement.pfeType.combo;\n }\n\n static get cascadingAttributes() {\n return {\n \"pfe-tab-history\": \"pfe-tabs\"\n };\n }\n\n static get observedAttributes() {\n return [\"pfe-tab-history\"];\n }\n\n get isTab() {\n var breakpointValue;\n if (this.hasAttribute(\"pfe-breakpoint\")) {\n breakpointValue = this.getAttributeNode(\"pfe-breakpoint\").value;\n breakpointValue = breakpointValue.replace(/\\D/g, \"\");\n } else {\n breakpointValue = 700;\n }\n return this.parentNode\n ? this.parentNode.offsetWidth > breakpointValue\n : window.outerWidth > breakpointValue;\n }\n\n get contentSetId() {\n return this.id || this.getAttribute(\"pfe-id\") || this.randomId;\n }\n\n constructor() {\n super(PfeContentSet, { delayRender: true });\n\n this._init = this._init.bind(this);\n this._observer = new MutationObserver(this._init);\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n if (this.children.length) {\n this._init();\n }\n\n this._observer.observe(this, { childList: true });\n }\n\n disconnectedCallback() {\n this._observer.disconnect();\n }\n\n _init() {\n if (window.ShadyCSS) {\n this._observer.disconnect();\n }\n\n if (this.isTab) {\n this._buildTabs();\n } else {\n this._buildAccordion();\n }\n\n this.render();\n this.context_update();\n\n if (window.ShadyCSS) {\n setTimeout(() => {\n this._observer.observe(this, { childList: true });\n }, 0);\n }\n }\n\n _buildAccordion() {\n let accordion;\n\n // Use the existing accordion if it exists\n const existingAccordion = this.querySelector(\n `[pfe-id=\"${this.contentSetId}\"]`\n );\n\n // Use a document fragment for efficiency\n const fragment = document.createDocumentFragment();\n\n // Create the accordion wrapper component or use the existing component\n if (!existingAccordion) {\n // Create the accordion wrapper component with a unique ID\n accordion = document.createElement(\"pfe-accordion\");\n accordion.setAttribute(\"pfe-id\", this.contentSetId);\n } else {\n accordion = existingAccordion;\n }\n\n // Iterate over each element in the light DOM\n [...this.children].forEach(child => {\n // If one of them has the attribute indicating they belong in the header region\n if (child.hasAttribute(\"pfe-content-set--header\")) {\n const header = document.createElement(\"pfe-accordion-header\");\n\n header.appendChild(child);\n accordion.appendChild(header);\n }\n\n if (child.hasAttribute(\"pfe-content-set--panel\")) {\n const panel = document.createElement(\"pfe-accordion-panel\");\n\n panel.appendChild(child);\n accordion.appendChild(panel);\n }\n });\n\n if (!existingAccordion) {\n fragment.appendChild(accordion);\n this.appendChild(fragment);\n }\n }\n\n _buildTabs() {\n let tabs;\n\n // Use the existing tabs if they exist\n let existingTabs = this.querySelector(`[pfe-id=\"${this.contentSetId}\"]`);\n\n // Use a document fragment for efficiency\n const fragment = document.createDocumentFragment();\n\n // Create the tabs wrapper component or use the existing tabs\n if (!existingTabs) {\n tabs = document.createElement(\"pfe-tabs\");\n tabs.setAttribute(\"pfe-id\", this.contentSetId);\n } else {\n tabs = existingTabs;\n }\n\n // Iterate over each element in the light DOM\n [...this.children].forEach(child => {\n // If one of them has the attribute indicating they belong in the panel region\n if (child.hasAttribute(\"pfe-content-set--header\")) {\n const header = document.createElement(\"pfe-tab\");\n\n header.setAttribute(\"slot\", \"tab\");\n\n if (child.id) {\n header.setAttribute(\"pfe-id\", child.id);\n }\n\n header.appendChild(child);\n tabs.appendChild(header);\n }\n\n if (child.hasAttribute(\"pfe-content-set--panel\")) {\n const panel = document.createElement(\"pfe-tab-panel\");\n\n panel.setAttribute(\"slot\", \"panel\");\n\n if (child.id) {\n panel.setAttribute(\"pfe-id\", child.id);\n }\n\n panel.appendChild(child);\n tabs.appendChild(panel);\n }\n });\n\n if (!existingTabs) {\n fragment.appendChild(tabs);\n }\n\n // If the orientation is set to vertical, add that attribute to the tabs\n if (this.vertical.value !== null && this.vertical.value !== false) {\n tabs.setAttribute(\"vertical\", true);\n }\n\n // Pass the variant attribute down to the tabs component\n if (this.variant.value !== this.variant.default) {\n tabs.setAttribute(\"pfe-variant\", this.variant.value);\n }\n\n if (this.align.value) {\n tabs.setAttribute(\"pfe-tab-align\", this.align.value);\n }\n\n if (this.hasAttribute(\"pfe-tab-history\")) {\n tabs.setAttribute(\"pfe-tab-history\", true);\n }\n\n if (!existingTabs) {\n this.appendChild(fragment);\n }\n }\n}\n\nPFElement.create(PfeContentSet);\n\nexport default PfeContentSet;\n"],"names":["PfeContentSet","PFElement","breakpointValue","this","hasAttribute","getAttributeNode","value","replace","parentNode","offsetWidth","window","outerWidth","id","getAttribute","randomId","vertical","title","type","default","prefixed","variant","enum","align","breakpoint","tab-history","namedSlot","items","oneOf","$ref","pfeType","combo","children","length","_init","_observer","observe","childList","disconnect","ShadyCSS","isTab","_buildTabs","_buildAccordion","render","context_update","_this2","accordion","existingAccordion","querySelector","contentSetId","fragment","document","createDocumentFragment","createElement","setAttribute","forEach","child","header","appendChild","panel","tabs","existingTabs","delayRender","_this","bind","MutationObserver","create"],"mappings":"+8BA6BMA,+TAAsBC,0NAuBjB,8DAIA,+DAIA,yDAkBHC,WACAC,KAAKC,aAAa,qBACFD,KAAKE,iBAAiB,kBAAkBC,OACxBC,QAAQ,MAAO,IAE/B,IAEbJ,KAAKK,WACRL,KAAKK,WAAWC,YAAcP,EAC9BQ,OAAOC,WAAaT,8CAIjBC,KAAKS,IAAMT,KAAKU,aAA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6C,mBAGjDC,EAAWC,SAASC,yBAGrBS,IAIIA,KAHAV,SAASE,cAAc,aACzBC,aAAa,SAAUlD,KAAK6C,0BAM/B7C,KAAK4B,WAAUuB,QAAQ,eAErBC,EAAMnD,aAAa,2BAA4B,KAC3CoD,EAASN,SAASE,cAAc,aAE/BC,aAAa,OAAQ,OAExBE,EAAM3C,MACDyC,aAAa,SAAUE,EAAM3C,MAG/B6C,YAAYF,KACdE,YAAYD,MAGfD,EAAMnD,aAAa,0BAA2B,KAC1CsD,EAAQR,SAASE,cAAc,mBAE/BC,aAAa,OAAQ,SAEvBE,EAAM3C,MACFyC,aAAa,SAAUE,EAAM3C,MAG/B6C,YAAYF,KACbE,YAAYC,MAIhBE,KACMH,YAAYE,GAIK,OAAxBxD,KAAKY,SAAST,QAA0C,IAAxBH,KAAKY,SAAST,SAC3C+C,aAAa,YAAY,GAI5BlD,KAAKiB,QAAQd,QAAUH,KAAKiB,QAAQF,WACjCmC,aAAa,cAAelD,KAAKiB,QAAQd,OAG5CH,KAAKmB,MAAMhB,SACR+C,aAAa,gBAAiBlD,KAAKmB,MAAMhB,OAG5CH,KAAKC,aAAa,sBACfiD,aAAa,mBAAmB,GAGlCO,QACEH,YAAYR,4VA3JbjD,EAAe,CAAE6D,aAAa,cAE/B5B,MAAQ6B,EAAK7B,MAAM8B,UACnB7B,UAAY,IAAI8B,iBAAiBF,EAAK7B,gBA6J/ChC,EAAUgE,OAAOjE"} \ No newline at end of file diff --git a/elements/pfe-content-set/package-lock.json b/elements/pfe-content-set/package-lock.json index 1b9f147eed..cf9204e855 100644 --- a/elements/pfe-content-set/package-lock.json +++ b/elements/pfe-content-set/package-lock.json @@ -1,6 +1,6 @@ { "name": "@patternfly/pfe-content-set", - "version": "1.0.0-prerelease.53", + "version": "1.0.0-prerelease.54", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/elements/pfe-content-set/package.json b/elements/pfe-content-set/package.json index df2058b578..94da8d8ca7 100644 --- a/elements/pfe-content-set/package.json +++ b/elements/pfe-content-set/package.json @@ -4,7 +4,7 @@ "className": "PfeContentSet", "elementName": "pfe-content-set" }, - "version": "1.0.0-prerelease.53", + "version": "1.0.0-prerelease.54", "description": "This PatternFly Element dynamically hides and shows content; the style is determined by the available space.", "keywords": [ "web-components", @@ -45,8 +45,8 @@ ], "license": "MIT", "dependencies": { - "@patternfly/pfe-accordion": "^1.0.0-prerelease.53", - "@patternfly/pfe-tabs": "^1.0.0-prerelease.53", + "@patternfly/pfe-accordion": "^1.0.0-prerelease.54", + "@patternfly/pfe-tabs": "^1.0.0-prerelease.54", "@patternfly/pfelement": "^1.0.0-prerelease.51" }, "generator-pfelement-version": "1.1.0", diff --git a/elements/pfe-cta/dist/pfe-cta--lightdom.css b/elements/pfe-cta/dist/pfe-cta--lightdom.css new file mode 100644 index 0000000000..998c97b72b --- /dev/null +++ b/elements/pfe-cta/dist/pfe-cta--lightdom.css @@ -0,0 +1,46 @@ +pfe-cta a { + color: inherit !important; + text-decoration: none !important; +} + +pfe-cta a:focus { + outline: none !important; +} + +pfe-cta[pfe-variant="wind"] a:hover { + text-decoration: underline !important; +} + +@media screen and (-ms-high-contrast: active), screen and (-ms-high-contrast: none) { + /* IE10+ */ + pfe-cta[pfe-priority] a, + pfe-cta[aria-disabled="true"] a { + padding: 16px calc(16px * 2) !important; + padding: var(--pfe-cta--Padding, var(--pfe-theme--container-padding, 16px) calc(var(--pfe-theme--container-padding, 16px) * 2)) !important; + } + .pfe-cta--wrapper { + white-space: nowrap; + } + .pfe-cta--wrapper > a, + .pfe-cta--wrapper > button { + white-space: normal; + } +} + +@supports (-ms-ime-align: auto) { + /* Microsoft Edge Browser 16+ (All) */ + pfe-cta[pfe-priority] a, + pfe-cta[aria-disabled="true"] a { + padding: 16px calc(16px * 2) !important; + padding: var(--pfe-cta--Padding, var(--pfe-theme--container-padding, 16px) calc(var(--pfe-theme--container-padding, 16px) * 2)) !important; + } + .pfe-cta--wrapper { + white-space: nowrap; + } + .pfe-cta--wrapper > a, + .pfe-cta--wrapper > button { + white-space: normal; + } +} + +/*# sourceMappingURL=pfe-cta--lightdom.css.map */ diff --git a/elements/pfe-cta/dist/pfe-cta--lightdom.min.css b/elements/pfe-cta/dist/pfe-cta--lightdom.min.css new file mode 100644 index 0000000000..185c1baff6 --- /dev/null +++ b/elements/pfe-cta/dist/pfe-cta--lightdom.min.css @@ -0,0 +1,2 @@ +pfe-cta a{color:inherit!important;text-decoration:none!important}pfe-cta a:focus{outline:0!important}pfe-cta[pfe-variant=wind] a:hover{text-decoration:underline!important}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){pfe-cta[aria-disabled=true] a,pfe-cta[pfe-priority] a{padding:16px calc(16px * 2)!important;padding:var(--pfe-cta--Padding,var(--pfe-theme--container-padding,16px) calc(var(--pfe-theme--container-padding,16px) * 2))!important}.pfe-cta--wrapper{white-space:nowrap}.pfe-cta--wrapper>a,.pfe-cta--wrapper>button{white-space:normal}}@supports (-ms-ime-align:auto){pfe-cta[aria-disabled=true] a,pfe-cta[pfe-priority] a{padding:16px calc(16px * 2)!important;padding:var(--pfe-cta--Padding,var(--pfe-theme--container-padding,16px) calc(var(--pfe-theme--container-padding,16px) * 2))!important}.pfe-cta--wrapper{white-space:nowrap}.pfe-cta--wrapper>a,.pfe-cta--wrapper>button{white-space:normal}} +/*# sourceMappingURL=pfe-cta--lightdom.min.css.map */ diff --git a/elements/pfe-cta/dist/pfe-cta--lightdom.min.css.map b/elements/pfe-cta/dist/pfe-cta--lightdom.min.css.map new file mode 100644 index 0000000000..0c4b48dd4d --- /dev/null +++ b/elements/pfe-cta/dist/pfe-cta--lightdom.min.css.map @@ -0,0 +1 @@ +{"version":3,"sources":["../pfe-cta--lightdom.scss","../../../pfe-sass/mixins/_mixins.scss","pfe-cta--lightdom.css"],"names":[],"mappings":"AAKA,UAEI,MAAA,kBACA,gBAAA,eAHJ,gBAKM,QAAA,YALN,kCASI,gBAAA,oBCXE,6CAAA,oCCaJ,8BFGA,wBAEE,QAAA,KAAA,yBAAA,QAAA,8HASF,kBACE,YAAA,OAEF,oBETA,yBFWE,YAAA,QCtBgC,+BCmBlC,8BFbA,wBAEE,QAAA,KAAA,yBAAA,QAAA,8HASF,kBACE,YAAA,OAEF,oBEOA,yBFLE,YAAA","file":"pfe-cta--lightdom.min.css","sourcesContent":[null,null,"pfe-cta a {\n color: inherit !important;\n text-decoration: none !important;\n}\n\npfe-cta a:focus {\n outline: none !important;\n}\n\npfe-cta[pfe-variant=\"wind\"] a:hover {\n text-decoration: underline !important;\n}\n\n@media screen and (-ms-high-contrast: active), screen and (-ms-high-contrast: none) {\n /* IE10+ */\n pfe-cta[pfe-priority] a,\n pfe-cta[aria-disabled=\"true\"] a {\n padding: 16px calc(16px * 2) !important;\n padding: var(--pfe-cta--Padding, var(--pfe-theme--container-padding, 16px) calc(var(--pfe-theme--container-padding, 16px) * 2)) !important;\n }\n .pfe-cta--wrapper {\n white-space: nowrap;\n }\n .pfe-cta--wrapper > a,\n .pfe-cta--wrapper > button {\n white-space: normal;\n }\n}\n\n@supports (-ms-ime-align: auto) {\n /* Microsoft Edge Browser 16+ (All) */\n pfe-cta[pfe-priority] a,\n pfe-cta[aria-disabled=\"true\"] a {\n padding: 16px calc(16px * 2) !important;\n padding: var(--pfe-cta--Padding, var(--pfe-theme--container-padding, 16px) calc(var(--pfe-theme--container-padding, 16px) * 2)) !important;\n }\n .pfe-cta--wrapper {\n white-space: nowrap;\n }\n .pfe-cta--wrapper > a,\n .pfe-cta--wrapper > button {\n white-space: normal;\n }\n}\n\n/*# sourceMappingURL=pfe-cta--lightdom.css.map */\n"]} \ No newline at end of file diff --git a/elements/pfe-cta/dist/pfe-cta.js b/elements/pfe-cta/dist/pfe-cta.js new file mode 100644 index 0000000000..258b078a74 --- /dev/null +++ b/elements/pfe-cta/dist/pfe-cta.js @@ -0,0 +1,241 @@ +import PFElement from '../../pfelement/dist/pfelement.js'; + +/*! + * PatternFly Elements: PfeCta 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * +*/ + +class PfeCta extends PFElement { + static get version() { + return "1.0.0-prerelease.54"; + } + + get html() { + return ` + ${this.isDefault ? ` ` : ``} + +`; + } + + static get properties() { + return {"priority":{"title":"Priority","type":"string","prefixed":true,"enum":["primary","secondary"],"observer":"_basicAttributeChanged"},"color":{"title":"Color","type":"string","prefixed":true,"enum":["accent","base","complement","lightest"],"observer":"_basicAttributeChanged"},"variant":{"title":"Style variant","type":"string","prefixed":true,"enum":["wind"],"observer":"_basicAttributeChanged"}}; + } + + static get slots() { + return {"link":{"title":"Link","type":"array","maxItems":1,"namedSlot":false,"items":{"oneOf":[{"$ref":"a"},{"$ref":"button"}]}}}; + } + static get tag() { + return "pfe-cta"; + } + + get styleUrl() { + return "pfe-cta.scss"; + } + + get templateUrl() { + return "pfe-cta.html"; + } + + get schemaUrl() { + return "pfe-cta.json"; + } + + get isDefault() { + return this.hasAttribute("pfe-priority") ? false : true; + } + + // Declare the type of this component + static get PfeType() { + return PFElement.PfeTypes.Content; + } + + static get events() { + return { + select: `${this.tag}:select` + }; + } + + static get observedAttributes() { + return ["pfe-priority", "pfe-color", "pfe-variant"]; + } + + click(event) { + this.emitEvent(PfeCta.events.select, { + detail: Object.assign(this.data, { + originEvent: event + }) + }); + } + + constructor() { + super(PfeCta); + this.cta = null; + + this._init = this._init.bind(this); + this._focusHandler = this._focusHandler.bind(this); + this._blurHandler = this._blurHandler.bind(this); + this._clickHandler = this._clickHandler.bind(this); + this._keyupHandler = this._keyupHandler.bind(this); + } + + connectedCallback() { + super.connectedCallback(); + + // Get the slot + this._slot = this.shadowRoot.querySelector("slot"); + + // Attach the slotchange listener + this._slot.addEventListener("slotchange", this._init); + + if (this.children.length) { + this._init(); + } + } + + disconnectedCallback() { + // Remove the slot change listeners + this._slot.removeEventListener("slotchange", this._init); + + // Remove the focus state listeners + if (this.cta) { + this.cta.removeEventListener("focus", this._focusHandler); + this.cta.removeEventListener("blur", this._blurHandler); + this.cta.removeEventListener("click", this._clickHandler); + this.cta.removeEventListener("keyup", this._keyupHandler); + } + } + + attributeChangedCallback(attr, oldValue, newValue) { + super.attributeChangedCallback(attr, oldValue, newValue); + // Strip the prefix form the attribute + attr = attr.replace("pfe-", ""); + // If the observer is defined in the attribute properties + if (this[attr] && this[attr].observer) { + // Get the observer function + let observer = this[this[attr].observer].bind(this); + // If it's a function, allow it to run + if (typeof observer === "function") observer(attr, oldValue, newValue); + } + } + + // Initialize the component + _init() { + const supportedTags = ["a", "button"]; // add input later + let supportedTag = false; + + // If the first child does not exist or that child is not a supported tag + if (this.firstElementChild) { + supportedTags.forEach(tag => { + if (this.firstElementChild.tagName.toLowerCase() === tag) { + supportedTag = true; + } + }); + } + + if (!this.firstElementChild || !supportedTag) { + console.warn( + `${PfeCta.tag}: The first child in the light DOM must be a supported call-to-action tag (, + +`; + } + + static get properties() { + return {"label":{"title":"Menu button label","type":"string","default":"Dropdown","prefixed":true},"is_disabled":{"title":"Disable menu button","type":"boolean","default":false,"prefixed":false}}; + } + + static get slots() { + return {}; + } + static get tag() { + return "pfe-dropdown"; + } + + get templateUrl() { + return "pfe-dropdown.html"; + } + + get styleUrl() { + return "pfe-dropdown.scss"; + } + + get schemaUrl() { + return "pfe-dropdown.json"; + } + + static get observedAttributes() { + return ["pfe-label", "is_disabled"]; + } + + set pfeDropdownOptions(options) { + this._modifyDOM(options); + } + + static get events() { + return { + change: `${this.tag}:change` + }; + } + + constructor() { + super(PfeDropdown); + + // state + this.isOpen = false; + + this._init = this._init.bind(this); + + // elements + this._container = this.shadowRoot.querySelector(`#${this.tag}-container`); + this._toggle = this.shadowRoot.querySelector(`#${this.tag}-toggle`); + this._toggle_text = this._toggle.querySelector(`.${this.tag}__toggle-text`); + this._menu = this.shadowRoot.querySelector(`#${this.tag}-menu`); + + // events + this.open = this.open.bind(this); + this.close = this.close.bind(this); + + this._clickHandler = this._clickHandler.bind(this); + this._toggleKeydownHandler = this._toggleKeydownHandler.bind(this); + this._itemKeydownHandler = this._itemKeydownHandler.bind(this); + this._itemClickHandler = this._itemClickHandler.bind(this); + this._outsideClickHandler = this._outsideClickHandler.bind(this); + } + + connectedCallback() { + super.connectedCallback(); + document.addEventListener("click", this._outsideClickHandler); + Promise.all([ + customElements.whenDefined(PfeDropdown.tag), + customElements.whenDefined(PfeDropdownItem.tag) + ]).then(() => { + this._init(); + }); + } + + disconnectedCallback() { + this._toggle.removeEventListener("click", this._clickHandler); + this._toggle.removeEventListener("keydown", this._toggleKeydownHandler); + this._allItems().forEach(item => { + item.removeEventListener("keydown", this._itemKeydownHandler); + item.removeEventListener("click", this._itemClickHandler); + }); + } + + attributeChangedCallback(attr, oldValue, newValue) { + switch (attr) { + case "pfe-label": + this._toggle_text.textContent = newValue; + break; + case "is_disabled": + this._setDisabled(); + break; + default: + break; + } + } + + _init() { + if (this.children.length) { + if (!this.hasAttribute("is_disabled")) { + this._toggle.addEventListener("click", this._clickHandler); + this._toggle.addEventListener("keydown", this._toggleKeydownHandler); + this._allItems().forEach(item => { + item.addEventListener("keydown", this._itemKeydownHandler); + item.addEventListener("click", this._itemClickHandler); + }); + } + } + } + + // Event handler for click event on Dropdown button + _clickHandler(event) { + this.isOpen ? this.close(event) : this.open(event); + return this; + } + + // Event handler for click event on Dropdown Item + _itemClickHandler(event) { + let pfeType; + if (event.target.parentElement.attributes["pfe-item-type"]) { + pfeType = event.target.parentElement.attributes["pfe-item-type"].value; + } + this._selectItem(event.target, pfeType); + return this; + } + + // Event handler for keydown events on Dropdown Menu + _itemKeydownHandler(event) { + let newItem; + let pfeType; + if (event.target.attributes["pfe-item-type"]) { + pfeType = event.target.attributes["pfe-item-type"].value; + } + // active dropdown item index + const currentIndex = this._allItems().findIndex( + item => item === document.activeElement + ); + switch (event.keyCode) { + case KEYCODE.ENTER: + this._selectItem(event.target.children[0], pfeType); + break; + case KEYCODE.ESC: + this.close(event); + break; + case KEYCODE.RIGHT: + case KEYCODE.DOWN: + // get the following item + newItem = this._itemContainer(this._nextItem(currentIndex, 1)); + break; + case KEYCODE.LEFT: + case KEYCODE.UP: + // get the previous item + newItem = this._itemContainer(this._nextItem(currentIndex, -1)); + break; + case KEYCODE.HOME: + newItem = this._firstItem(); + break; + case KEYCODE.END: + newItem = this._lastItem(); + break; + case KEYCODE.TAB: + this.close(); + break; + default: + break; + } + if (newItem) { + newItem.setAttribute("tabindex", "-1"); + newItem.focus(); + } + return this; + } + + // Event handler for click event outside the Dropdown element + _outsideClickHandler(event) { + // Check if the clicked element is the dropdown object + let isSelf = event.target === this; + // Check if the clicked element contains or is contained by the dropdown element + let isChild = event.target.closest("pfe-dropdown"); + let insideWrapper = + event.target.tagName.indexOf("-") > -1 + ? event.target.shadowRoot.querySelector("pfe-dropdown") + : null; + // Check states to determine if the dropdown menu should close + if (!isSelf && !(isChild || insideWrapper)) { + this.close(); + } + } + + // Event handler for keydown event on Dropdown + _toggleKeydownHandler(event) { + switch (event.keyCode) { + case KEYCODE.ENTER: + case KEYCODE.DOWN: + if (this._allDisabled()) { + // toggle the dropdown if all items disabled + this.toggle(event); + } else { + // otherwise, get the next enabled item + this.open(); + const item = this._itemContainer(this._nextItem(-1, 1)); + item.setAttribute("tabindex", "-1"); + item.focus(); + } + break; + case KEYCODE.TAB: + this.close(); + break; + default: + break; + } + return this; + } + + // modify DOM if custom options are passed in an array + _modifyDOM(options) { + options.forEach(el => { + let item; + switch (el.type) { + case "link": + item = document.createElement("a"); + item.setAttribute("href", el.href ? el.href : "#"); + break; + case "action": + item = document.createElement("button"); + break; + default: + break; + } + const option = document.createElement("pfe-dropdown-item"); + option.setAttribute("pfe-item-type", el.type); + if (el.is_disabled) { + option.setAttribute("is_disabled", el.is_disabled); + } + if (item) { + item.innerText = el.text ? el.text : ""; + option.appendChild(item); + } + this.appendChild(option); + }); + } + + _setDisabled() { + const isDisabled = this.hasAttribute("is_disabled"); + if (isDisabled) { + this.setAttribute("aria-disabled", "true"); + this.setAttribute("tabindex", "-1"); + } else { + this.removeAttribute("is_disabled"); + this.setAttribute("aria-disabled", "false"); + this.removeAttribute("tabindex"); + } + } + + _allItems() { + return [ + ...this.querySelectorAll( + `${this.tag}-item:not([pfe-item-type='separator'])` + ) + ]; + } + + _allDisabled() { + return ( + this._allItems().find(item => !item.hasAttribute("is_disabled")) === + undefined + ); + } + + _nextItem(currentPosition, direction) { + const items = this._allItems(); + let index = (currentPosition + direction) % items.length; + index = index < 0 ? index + items.length : index; + let item = items[index]; + while (item && item.hasAttribute("is_disabled")) { + index += direction; + item = items[index % items.length]; + } + return item; + } + + _firstItem() { + const items = this._allItems(); + return items[0]; + } + + _lastItem() { + const items = this._allItems(); + return items[items.length - 1]; + } + + _selectItem(item, type) { + if (type === "action") { + this.emitEvent(PfeDropdown.events.change, { + detail: { action: item.innerText } + }); + this.close(event); + } else { + item.click(); + } + } + + addDropdownOptions(options) { + this._modifyDOM(options); + } + + open(event) { + if (event) { + event.preventDefault(); + } + this.isOpen = true; + this._menu.classList.add("open"); + this._toggle.setAttribute("aria-expanded", true); + return this; + } + + close(event) { + if (event) { + event.preventDefault(); + } + this.isOpen = false; + this._menu.classList.remove("open"); + this._toggle.setAttribute("aria-expanded", false); + return this; + } + + toggle(event) { + this.isOpen ? this.close(event) : this.open(event); + } + + _itemContainer(item) { + // used to apply the focus state to the item's container + return item.shadowRoot.querySelector(`.${this.tag}-item__container`); + } +} + +PFElement.create(PfeDropdownItem); +PFElement.create(PfeDropdown); + +export default PfeDropdown; +//# sourceMappingURL=pfe-dropdown.js.map diff --git a/elements/pfe-dropdown/dist/pfe-dropdown.js.map b/elements/pfe-dropdown/dist/pfe-dropdown.js.map new file mode 100644 index 0000000000..daf35eff16 --- /dev/null +++ b/elements/pfe-dropdown/dist/pfe-dropdown.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-dropdown.js","sources":["../_temp/pfe-dropdown-item.js","../_temp/pfe-dropdown.js"],"sourcesContent":["/*!\n * PatternFly Elements: PfeDropdown 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.js\";\n\nclass PfeDropdownItem extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
  • \n \n
  • `;\n }\n\n static get properties() {\n return {\"item-type\":{\"title\":\"List item type\",\"type\":\"string\",\"enum\":[\"link\",\"action\",\"separator\"],\"default\":null,\"prefixed\":true}};\n }\n\n static get slots() {\n return {};\n }\n static get tag() {\n return \"pfe-dropdown-item\";\n }\n\n get templateUrl() {\n return \"pfe-dropdown-item.html\";\n }\n\n get styleUrl() {\n return \"pfe-dropdown-item.scss\";\n }\n\n get schemaUrl() {\n return \"pfe-dropdown-item.json\";\n }\n\n static get observedAttributes() {\n return [\"pfe-item-type\", \"is_disabled\"];\n }\n\n constructor() {\n super(PfeDropdownItem);\n\n this._container = this.shadowRoot.querySelector(`.${this.tag}__container`);\n this._item = this.shadowRoot.querySelector(\"slot\").assignedNodes()[1];\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n switch (attr) {\n case \"pfe-item-type\":\n this._setAccessibility();\n break;\n case \"is_disabled\":\n this._setDisabled();\n break;\n default:\n break;\n }\n }\n\n connectedCallback() {\n super.connectedCallback();\n }\n\n _setAccessibility() {\n if (this._container) {\n const type = this.getAttribute(\"pfe-item-type\");\n if (type) {\n switch (type) {\n case \"link\":\n this._container.setAttribute(\"role\", \"none\");\n this._item && this._item.setAttribute(\"role\", \"menuitem\");\n break;\n case \"action\":\n this._container.setAttribute(\"role\", \"menuitem\");\n this._item && this._item.removeAttribute(\"role\");\n break;\n case \"separator\":\n this._container.setAttribute(\"role\", \"separator\");\n break;\n default:\n break;\n }\n }\n }\n }\n\n _setDisabled() {\n const isDisabled = this.hasAttribute(\"is_disabled\");\n if (isDisabled) {\n this.removeAttribute(\"tabindex\");\n this.setAttribute(\"aria-disabled\", \"true\");\n } else {\n this.removeAttribute(\"is_disabled\");\n this.setAttribute(\"tabindex\", \"0\");\n this.setAttribute(\"aria-disabled\", \"false\");\n }\n }\n}\n\nexport default PfeDropdownItem;\n","/*!\n * PatternFly Elements: PfeDropdown 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.js\";\nimport PfeDropdownItem from \"./pfe-dropdown-item.js\";\n\n// @POLYFILL Element.closest\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/closest\nif (!Element.prototype.closest) {\n Element.prototype.closest = function(s) {\n var el = this;\n do {\n if (el.matches(s)) return el;\n el = el.parentElement || el.parentNode;\n } while (el !== null && el.nodeType === 1);\n return null;\n };\n}\n\n// @POLYFILL Element.matches\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/matches\nif (!Element.prototype.matches) {\n Element.prototype.matches =\n Element.prototype.msMatchesSelector ||\n Element.prototype.webkitMatchesSelector;\n}\n\nconst KEYCODE = {\n DOWN: 40,\n END: 35,\n ENTER: 13,\n ESC: 27,\n HOME: 36,\n LEFT: 37,\n RIGHT: 39,\n SPACE: 0 || 32,\n UP: 38,\n TAB: 9\n};\n\nclass PfeDropdown extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
    \n \n
      \n \n
    \n
    `;\n }\n\n static get properties() {\n return {\"label\":{\"title\":\"Menu button label\",\"type\":\"string\",\"default\":\"Dropdown\",\"prefixed\":true},\"is_disabled\":{\"title\":\"Disable menu button\",\"type\":\"boolean\",\"default\":false,\"prefixed\":false}};\n }\n\n static get slots() {\n return {};\n }\n static get tag() {\n return \"pfe-dropdown\";\n }\n\n get templateUrl() {\n return \"pfe-dropdown.html\";\n }\n\n get styleUrl() {\n return \"pfe-dropdown.scss\";\n }\n\n get schemaUrl() {\n return \"pfe-dropdown.json\";\n }\n\n static get observedAttributes() {\n return [\"pfe-label\", \"is_disabled\"];\n }\n\n set pfeDropdownOptions(options) {\n this._modifyDOM(options);\n }\n\n static get events() {\n return {\n change: `${this.tag}:change`\n };\n }\n\n constructor() {\n super(PfeDropdown);\n\n // state\n this.isOpen = false;\n\n this._init = this._init.bind(this);\n\n // elements\n this._container = this.shadowRoot.querySelector(`#${this.tag}-container`);\n this._toggle = this.shadowRoot.querySelector(`#${this.tag}-toggle`);\n this._toggle_text = this._toggle.querySelector(`.${this.tag}__toggle-text`);\n this._menu = this.shadowRoot.querySelector(`#${this.tag}-menu`);\n\n // events\n this.open = this.open.bind(this);\n this.close = this.close.bind(this);\n\n this._clickHandler = this._clickHandler.bind(this);\n this._toggleKeydownHandler = this._toggleKeydownHandler.bind(this);\n this._itemKeydownHandler = this._itemKeydownHandler.bind(this);\n this._itemClickHandler = this._itemClickHandler.bind(this);\n this._outsideClickHandler = this._outsideClickHandler.bind(this);\n }\n\n connectedCallback() {\n super.connectedCallback();\n document.addEventListener(\"click\", this._outsideClickHandler);\n Promise.all([\n customElements.whenDefined(PfeDropdown.tag),\n customElements.whenDefined(PfeDropdownItem.tag)\n ]).then(() => {\n this._init();\n });\n }\n\n disconnectedCallback() {\n this._toggle.removeEventListener(\"click\", this._clickHandler);\n this._toggle.removeEventListener(\"keydown\", this._toggleKeydownHandler);\n this._allItems().forEach(item => {\n item.removeEventListener(\"keydown\", this._itemKeydownHandler);\n item.removeEventListener(\"click\", this._itemClickHandler);\n });\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n switch (attr) {\n case \"pfe-label\":\n this._toggle_text.textContent = newValue;\n break;\n case \"is_disabled\":\n this._setDisabled();\n break;\n default:\n break;\n }\n }\n\n _init() {\n if (this.children.length) {\n if (!this.hasAttribute(\"is_disabled\")) {\n this._toggle.addEventListener(\"click\", this._clickHandler);\n this._toggle.addEventListener(\"keydown\", this._toggleKeydownHandler);\n this._allItems().forEach(item => {\n item.addEventListener(\"keydown\", this._itemKeydownHandler);\n item.addEventListener(\"click\", this._itemClickHandler);\n });\n }\n }\n }\n\n // Event handler for click event on Dropdown button\n _clickHandler(event) {\n this.isOpen ? this.close(event) : this.open(event);\n return this;\n }\n\n // Event handler for click event on Dropdown Item\n _itemClickHandler(event) {\n let pfeType;\n if (event.target.parentElement.attributes[\"pfe-item-type\"]) {\n pfeType = event.target.parentElement.attributes[\"pfe-item-type\"].value;\n }\n this._selectItem(event.target, pfeType);\n return this;\n }\n\n // Event handler for keydown events on Dropdown Menu\n _itemKeydownHandler(event) {\n let newItem;\n let pfeType;\n if (event.target.attributes[\"pfe-item-type\"]) {\n pfeType = event.target.attributes[\"pfe-item-type\"].value;\n }\n // active dropdown item index\n const currentIndex = this._allItems().findIndex(\n item => item === document.activeElement\n );\n switch (event.keyCode) {\n case KEYCODE.ENTER:\n this._selectItem(event.target.children[0], pfeType);\n break;\n case KEYCODE.ESC:\n this.close(event);\n break;\n case KEYCODE.RIGHT:\n case KEYCODE.DOWN:\n // get the following item\n newItem = this._itemContainer(this._nextItem(currentIndex, 1));\n break;\n case KEYCODE.LEFT:\n case KEYCODE.UP:\n // get the previous item\n newItem = this._itemContainer(this._nextItem(currentIndex, -1));\n break;\n case KEYCODE.HOME:\n newItem = this._firstItem();\n break;\n case KEYCODE.END:\n newItem = this._lastItem();\n break;\n case KEYCODE.TAB:\n this.close();\n break;\n default:\n break;\n }\n if (newItem) {\n newItem.setAttribute(\"tabindex\", \"-1\");\n newItem.focus();\n }\n return this;\n }\n\n // Event handler for click event outside the Dropdown element\n _outsideClickHandler(event) {\n // Check if the clicked element is the dropdown object\n let isSelf = event.target === this;\n // Check if the clicked element contains or is contained by the dropdown element\n let isChild = event.target.closest(\"pfe-dropdown\");\n let insideWrapper =\n event.target.tagName.indexOf(\"-\") > -1\n ? event.target.shadowRoot.querySelector(\"pfe-dropdown\")\n : null;\n // Check states to determine if the dropdown menu should close\n if (!isSelf && !(isChild || insideWrapper)) {\n this.close();\n }\n }\n\n // Event handler for keydown event on Dropdown\n _toggleKeydownHandler(event) {\n switch (event.keyCode) {\n case KEYCODE.ENTER:\n case KEYCODE.DOWN:\n if (this._allDisabled()) {\n // toggle the dropdown if all items disabled\n this.toggle(event);\n } else {\n // otherwise, get the next enabled item\n this.open();\n const item = this._itemContainer(this._nextItem(-1, 1));\n item.setAttribute(\"tabindex\", \"-1\");\n item.focus();\n }\n break;\n case KEYCODE.TAB:\n this.close();\n break;\n default:\n break;\n }\n return this;\n }\n\n // modify DOM if custom options are passed in an array\n _modifyDOM(options) {\n options.forEach(el => {\n let item;\n switch (el.type) {\n case \"link\":\n item = document.createElement(\"a\");\n item.setAttribute(\"href\", el.href ? el.href : \"#\");\n break;\n case \"action\":\n item = document.createElement(\"button\");\n break;\n default:\n break;\n }\n const option = document.createElement(\"pfe-dropdown-item\");\n option.setAttribute(\"pfe-item-type\", el.type);\n if (el.is_disabled) {\n option.setAttribute(\"is_disabled\", el.is_disabled);\n }\n if (item) {\n item.innerText = el.text ? el.text : \"\";\n option.appendChild(item);\n }\n this.appendChild(option);\n });\n }\n\n _setDisabled() {\n const isDisabled = this.hasAttribute(\"is_disabled\");\n if (isDisabled) {\n this.setAttribute(\"aria-disabled\", \"true\");\n this.setAttribute(\"tabindex\", \"-1\");\n } else {\n this.removeAttribute(\"is_disabled\");\n this.setAttribute(\"aria-disabled\", \"false\");\n this.removeAttribute(\"tabindex\");\n }\n }\n\n _allItems() {\n return [\n ...this.querySelectorAll(\n `${this.tag}-item:not([pfe-item-type='separator'])`\n )\n ];\n }\n\n _allDisabled() {\n return (\n this._allItems().find(item => !item.hasAttribute(\"is_disabled\")) ===\n undefined\n );\n }\n\n _nextItem(currentPosition, direction) {\n const items = this._allItems();\n let index = (currentPosition + direction) % items.length;\n index = index < 0 ? index + items.length : index;\n let item = items[index];\n while (item && item.hasAttribute(\"is_disabled\")) {\n index += direction;\n item = items[index % items.length];\n }\n return item;\n }\n\n _firstItem() {\n const items = this._allItems();\n return items[0];\n }\n\n _lastItem() {\n const items = this._allItems();\n return items[items.length - 1];\n }\n\n _selectItem(item, type) {\n if (type === \"action\") {\n this.emitEvent(PfeDropdown.events.change, {\n detail: { action: item.innerText }\n });\n this.close(event);\n } else {\n item.click();\n }\n }\n\n addDropdownOptions(options) {\n this._modifyDOM(options);\n }\n\n open(event) {\n if (event) {\n event.preventDefault();\n }\n this.isOpen = true;\n this._menu.classList.add(\"open\");\n this._toggle.setAttribute(\"aria-expanded\", true);\n return this;\n }\n\n close(event) {\n if (event) {\n event.preventDefault();\n }\n this.isOpen = false;\n this._menu.classList.remove(\"open\");\n this._toggle.setAttribute(\"aria-expanded\", false);\n return this;\n }\n\n toggle(event) {\n this.isOpen ? this.close(event) : this.open(event);\n }\n\n _itemContainer(item) {\n // used to apply the focus state to the item's container\n return item.shadowRoot.querySelector(`.${this.tag}-item__container`);\n }\n}\n\nPFElement.create(PfeDropdownItem);\nPFElement.create(PfeDropdown);\n\nexport default PfeDropdown;\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,AAEA;AACA,MAAM,eAAe,SAAS,SAAS,CAAC;EACtC,WAAW,O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AAC,KAAK,EAAE;IACX,IAAI,KAAK,EAAE;MACT,KAAK,CAAC,cAAc,EAAE,CAAC;KACxB;IACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACpB,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACpC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;IAClD,OAAO,IAAI,CAAC;GACb;;EAED,MAAM,CAAC,KAAK,EAAE;IACZ,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;GACpD;;EAED,cAAc,CAAC,IAAI,EAAE;;IAEnB,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC;GACtE;CACF;;AAED,SAAS,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;AAClC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;;;;"} \ No newline at end of file diff --git a/elements/pfe-dropdown/dist/pfe-dropdown.json b/elements/pfe-dropdown/dist/pfe-dropdown.json new file mode 100644 index 0000000000..ca48e7fe4e --- /dev/null +++ b/elements/pfe-dropdown/dist/pfe-dropdown.json @@ -0,0 +1,38 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Dropdown", + "description": "Provides a dropdown list of actions and/or links", + "type": "object", + "tag": "pfe-dropdown", + "class": "pfe-dropdown", + "category": "content", + "properties": { + "slots": { + "title": "Slots", + "description": "Definition of the supported slots", + "type": "object", + "properties": {} + }, + "attributes": { + "title": "Attributes", + "type": "object", + "properties": { + "label": { + "title": "Menu button label", + "type": "string", + "default": "Dropdown", + "prefixed": true + }, + "is_disabled": { + "title": "Disable menu button", + "type": "boolean", + "default": false, + "prefixed": false + } + }, + "required": ["pfe-label"] + } + }, + "required": ["slots", "attributes"], + "additionalProperties": false +} diff --git a/elements/pfe-dropdown/dist/pfe-dropdown.min.js b/elements/pfe-dropdown/dist/pfe-dropdown.min.js new file mode 100644 index 0000000000..3b2731ce74 --- /dev/null +++ b/elements/pfe-dropdown/dist/pfe-dropdown.min.js @@ -0,0 +1,50 @@ +import e from"../../pfelement/dist/pfelement.min.js"; +/*! + * PatternFly Elements: PfeDropdown 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * +*/class t extends e{static get version(){return"1.0.0-prerelease.54"}get html(){return'
  • \n \n
  • '}static get properties(){return{"item-type":{title:"List item type",type:"string",enum:["link","action","separator"],default:null,prefixed:!0}}}static get slots(){return{}}static get tag(){return"pfe-dropdown-item"}get templateUrl(){return"pfe-dropdown-item.html"}get styleUrl(){return"pfe-dropdown-item.scss"}get schemaUrl(){return"pfe-dropdown-item.json"}static get observedAttributes(){return["pfe-item-type","is_disabled"]}constructor(){super(t),this._container=this.shadowRoot.querySelector(`.${this.tag}__container`),this._item=this.shadowRoot.querySelector("slot").assignedNodes()[1]}attributeChangedCallback(e,t,o){switch(e){case"pfe-item-type":this._setAccessibility();break;case"is_disabled":this._setDisabled()}}connectedCallback(){super.connectedCallback()}_setAccessibility(){if(this._container){const e=this.getAttribute("pfe-item-type");if(e)switch(e){case"link":this._container.setAttribute("role","none"),this._item&&this._item.setAttribute("role","menuitem");break;case"action":this._container.setAttribute("role","menuitem"),this._item&&this._item.removeAttribute("role");break;case"separator":this._container.setAttribute("role","separator")}}}_setDisabled(){this.hasAttribute("is_disabled")?(this.removeAttribute("tabindex"),this.setAttribute("aria-disabled","true")):(this.removeAttribute("is_disabled"),this.setAttribute("tabindex","0"),this.setAttribute("aria-disabled","false"))}} +/*! + * PatternFly Elements: PfeDropdown 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * +*/Element.prototype.closest||(Element.prototype.closest=function(e){var t=this;do{if(t.matches(e))return t;t=t.parentElement||t.parentNode}while(null!==t&&1===t.nodeType);return null}),Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector);const o={DOWN:40,END:35,ENTER:13,ESC:27,HOME:36,LEFT:37,RIGHT:39,SPACE:32,UP:38,TAB:9};class r extends e{static get version(){return"1.0.0-prerelease.54"}get html(){return'
    \n \n \n
    '}static get properties(){return{label:{title:"Menu button label",type:"string",default:"Dropdown",prefixed:!0},is_disabled:{title:"Disable menu button",type:"boolean",default:!1,prefixed:!1}}}static get slots(){return{}}static get tag(){return"pfe-dropdown"}get templateUrl(){return"pfe-dropdown.html"}get styleUrl(){return"pfe-dropdown.scss"}get schemaUrl(){return"pfe-dropdown.json"}static get observedAttributes(){return["pfe-label","is_disabled"]}set pfeDropdownOptions(e){this._modifyDOM(e)}static get events(){return{change:`${this.tag}:change`}}constructor(){super(r),this.isOpen=!1,this._init=this._init.bind(this),this._container=this.shadowRoot.querySelector(`#${this.tag}-container`),this._toggle=this.shadowRoot.querySelector(`#${this.tag}-toggle`),this._toggle_text=this._toggle.querySelector(`.${this.tag}__toggle-text`),this._menu=this.shadowRoot.querySelector(`#${this.tag}-menu`),this.open=this.open.bind(this),this.close=this.close.bind(this),this._clickHandler=this._clickHandler.bind(this),this._toggleKeydownHandler=this._toggleKeydownHandler.bind(this),this._itemKeydownHandler=this._itemKeydownHandler.bind(this),this._itemClickHandler=this._itemClickHandler.bind(this),this._outsideClickHandler=this._outsideClickHandler.bind(this)}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this._outsideClickHandler),Promise.all([customElements.whenDefined(r.tag),customElements.whenDefined(t.tag)]).then(()=>{this._init()})}disconnectedCallback(){this._toggle.removeEventListener("click",this._clickHandler),this._toggle.removeEventListener("keydown",this._toggleKeydownHandler),this._allItems().forEach(e=>{e.removeEventListener("keydown",this._itemKeydownHandler),e.removeEventListener("click",this._itemClickHandler)})}attributeChangedCallback(e,t,o){switch(e){case"pfe-label":this._toggle_text.textContent=o;break;case"is_disabled":this._setDisabled()}}_init(){this.children.length&&(this.hasAttribute("is_disabled")||(this._toggle.addEventListener("click",this._clickHandler),this._toggle.addEventListener("keydown",this._toggleKeydownHandler),this._allItems().forEach(e=>{e.addEventListener("keydown",this._itemKeydownHandler),e.addEventListener("click",this._itemClickHandler)})))}_clickHandler(e){return this.isOpen?this.close(e):this.open(e),this}_itemClickHandler(e){let t;return e.target.parentElement.attributes["pfe-item-type"]&&(t=e.target.parentElement.attributes["pfe-item-type"].value),this._selectItem(e.target,t),this}_itemKeydownHandler(e){let t,r;e.target.attributes["pfe-item-type"]&&(r=e.target.attributes["pfe-item-type"].value);const i=this._allItems().findIndex(e=>e===document.activeElement);switch(e.keyCode){case o.ENTER:this._selectItem(e.target.children[0],r);break;case o.ESC:this.close(e);break;case o.RIGHT:case o.DOWN:t=this._itemContainer(this._nextItem(i,1));break;case o.LEFT:case o.UP:t=this._itemContainer(this._nextItem(i,-1));break;case o.HOME:t=this._firstItem();break;case o.END:t=this._lastItem();break;case o.TAB:this.close()}return t&&(t.setAttribute("tabindex","-1"),t.focus()),this}_outsideClickHandler(e){let t=e.target===this,o=e.target.closest("pfe-dropdown"),r=e.target.tagName.indexOf("-")>-1?e.target.shadowRoot.querySelector("pfe-dropdown"):null;t||o||r||this.close()}_toggleKeydownHandler(e){switch(e.keyCode){case o.ENTER:case o.DOWN:if(this._allDisabled())this.toggle(e);else{this.open();const e=this._itemContainer(this._nextItem(-1,1));e.setAttribute("tabindex","-1"),e.focus()}break;case o.TAB:this.close()}return this}_modifyDOM(e){e.forEach(e=>{let t;switch(e.type){case"link":(t=document.createElement("a")).setAttribute("href",e.href?e.href:"#");break;case"action":t=document.createElement("button")}const o=document.createElement("pfe-dropdown-item");o.setAttribute("pfe-item-type",e.type),e.is_disabled&&o.setAttribute("is_disabled",e.is_disabled),t&&(t.innerText=e.text?e.text:"",o.appendChild(t)),this.appendChild(o)})}_setDisabled(){this.hasAttribute("is_disabled")?(this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1")):(this.removeAttribute("is_disabled"),this.setAttribute("aria-disabled","false"),this.removeAttribute("tabindex"))}_allItems(){return[...this.querySelectorAll(`${this.tag}-item:not([pfe-item-type='separator'])`)]}_allDisabled(){return void 0===this._allItems().find(e=>!e.hasAttribute("is_disabled"))}_nextItem(e,t){const o=this._allItems();let r=(e+t)%o.length,i=o[r=r<0?r+o.length:r];for(;i&&i.hasAttribute("is_disabled");)i=o[(r+=t)%o.length];return i}_firstItem(){return this._allItems()[0]}_lastItem(){const e=this._allItems();return e[e.length-1]}_selectItem(e,t){"action"===t?(this.emitEvent(r.events.change,{detail:{action:e.innerText}}),this.close(event)):e.click()}addDropdownOptions(e){this._modifyDOM(e)}open(e){return e&&e.preventDefault(),this.isOpen=!0,this._menu.classList.add("open"),this._toggle.setAttribute("aria-expanded",!0),this}close(e){return e&&e.preventDefault(),this.isOpen=!1,this._menu.classList.remove("open"),this._toggle.setAttribute("aria-expanded",!1),this}toggle(e){this.isOpen?this.close(e):this.open(e)}_itemContainer(e){return e.shadowRoot.querySelector(`.${this.tag}-item__container`)}}e.create(t),e.create(r);export default r; +//# sourceMappingURL=pfe-dropdown.min.js.map diff --git a/elements/pfe-dropdown/dist/pfe-dropdown.min.js.map b/elements/pfe-dropdown/dist/pfe-dropdown.min.js.map new file mode 100644 index 0000000000..a8f9ce0061 --- /dev/null +++ b/elements/pfe-dropdown/dist/pfe-dropdown.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-dropdown.min.js","sources":["../_temp/pfe-dropdown-item.js","../_temp/pfe-dropdown.js"],"sourcesContent":["/*!\n * PatternFly Elements: PfeDropdown 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.js\";\n\nclass PfeDropdownItem extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
  • \n \n
  • `;\n }\n\n static get properties() {\n return {\"item-type\":{\"title\":\"List item type\",\"type\":\"string\",\"enum\":[\"link\",\"action\",\"separator\"],\"default\":null,\"prefixed\":true}};\n }\n\n static get slots() {\n return {};\n }\n static get tag() {\n return \"pfe-dropdown-item\";\n }\n\n get templateUrl() {\n return \"pfe-dropdown-item.html\";\n }\n\n get styleUrl() {\n return \"pfe-dropdown-item.scss\";\n }\n\n get schemaUrl() {\n return \"pfe-dropdown-item.json\";\n }\n\n static get observedAttributes() {\n return [\"pfe-item-type\", \"is_disabled\"];\n }\n\n constructor() {\n super(PfeDropdownItem);\n\n this._container = this.shadowRoot.querySelector(`.${this.tag}__container`);\n this._item = this.shadowRoot.querySelector(\"slot\").assignedNodes()[1];\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n switch (attr) {\n case \"pfe-item-type\":\n this._setAccessibility();\n break;\n case \"is_disabled\":\n this._setDisabled();\n break;\n default:\n break;\n }\n }\n\n connectedCallback() {\n super.connectedCallback();\n }\n\n _setAccessibility() {\n if (this._container) {\n const type = this.getAttribute(\"pfe-item-type\");\n if (type) {\n switch (type) {\n case \"link\":\n this._container.setAttribute(\"role\", \"none\");\n this._item && this._item.setAttribute(\"role\", \"menuitem\");\n break;\n case \"action\":\n this._container.setAttribute(\"role\", \"menuitem\");\n this._item && this._item.removeAttribute(\"role\");\n break;\n case \"separator\":\n this._container.setAttribute(\"role\", \"separator\");\n break;\n default:\n break;\n }\n }\n }\n }\n\n _setDisabled() {\n const isDisabled = this.hasAttribute(\"is_disabled\");\n if (isDisabled) {\n this.removeAttribute(\"tabindex\");\n this.setAttribute(\"aria-disabled\", \"true\");\n } else {\n this.removeAttribute(\"is_disabled\");\n this.setAttribute(\"tabindex\", \"0\");\n this.setAttribute(\"aria-disabled\", \"false\");\n }\n }\n}\n\nexport default PfeDropdownItem;\n","/*!\n * PatternFly Elements: PfeDropdown 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.js\";\nimport PfeDropdownItem from \"./pfe-dropdown-item.js\";\n\n// @POLYFILL Element.closest\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/closest\nif (!Element.prototype.closest) {\n Element.prototype.closest = function(s) {\n var el = this;\n do {\n if (el.matches(s)) return el;\n el = el.parentElement || el.parentNode;\n } while (el !== null && el.nodeType === 1);\n return null;\n };\n}\n\n// @POLYFILL Element.matches\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/matches\nif (!Element.prototype.matches) {\n Element.prototype.matches =\n Element.prototype.msMatchesSelector ||\n Element.prototype.webkitMatchesSelector;\n}\n\nconst KEYCODE = {\n DOWN: 40,\n END: 35,\n ENTER: 13,\n ESC: 27,\n HOME: 36,\n LEFT: 37,\n RIGHT: 39,\n SPACE: 0 || 32,\n UP: 38,\n TAB: 9\n};\n\nclass PfeDropdown extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
    \n \n
      \n \n
    \n
    `;\n }\n\n static get properties() {\n return {\"label\":{\"title\":\"Menu button label\",\"type\":\"string\",\"default\":\"Dropdown\",\"prefixed\":true},\"is_disabled\":{\"title\":\"Disable menu button\",\"type\":\"boolean\",\"default\":false,\"prefixed\":false}};\n }\n\n static get slots() {\n return {};\n }\n static get tag() {\n return \"pfe-dropdown\";\n }\n\n get templateUrl() {\n return \"pfe-dropdown.html\";\n }\n\n get styleUrl() {\n return \"pfe-dropdown.scss\";\n }\n\n get schemaUrl() {\n return \"pfe-dropdown.json\";\n }\n\n static get observedAttributes() {\n return [\"pfe-label\", \"is_disabled\"];\n }\n\n set pfeDropdownOptions(options) {\n this._modifyDOM(options);\n }\n\n static get events() {\n return {\n change: `${this.tag}:change`\n };\n }\n\n constructor() {\n super(PfeDropdown);\n\n // state\n this.isOpen = false;\n\n this._init = this._init.bind(this);\n\n // elements\n this._container = this.shadowRoot.querySelector(`#${this.tag}-container`);\n this._toggle = this.shadowRoot.querySelector(`#${this.tag}-toggle`);\n this._toggle_text = this._toggle.querySelector(`.${this.tag}__toggle-text`);\n this._menu = this.shadowRoot.querySelector(`#${this.tag}-menu`);\n\n // events\n this.open = this.open.bind(this);\n this.close = this.close.bind(this);\n\n this._clickHandler = this._clickHandler.bind(this);\n this._toggleKeydownHandler = this._toggleKeydownHandler.bind(this);\n this._itemKeydownHandler = this._itemKeydownHandler.bind(this);\n this._itemClickHandler = this._itemClickHandler.bind(this);\n this._outsideClickHandler = this._outsideClickHandler.bind(this);\n }\n\n connectedCallback() {\n super.connectedCallback();\n document.addEventListener(\"click\", this._outsideClickHandler);\n Promise.all([\n customElements.whenDefined(PfeDropdown.tag),\n customElements.whenDefined(PfeDropdownItem.tag)\n ]).then(() => {\n this._init();\n });\n }\n\n disconnectedCallback() {\n this._toggle.removeEventListener(\"click\", this._clickHandler);\n this._toggle.removeEventListener(\"keydown\", this._toggleKeydownHandler);\n this._allItems().forEach(item => {\n item.removeEventListener(\"keydown\", this._itemKeydownHandler);\n item.removeEventListener(\"click\", this._itemClickHandler);\n });\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n switch (attr) {\n case \"pfe-label\":\n this._toggle_text.textContent = newValue;\n break;\n case \"is_disabled\":\n this._setDisabled();\n break;\n default:\n break;\n }\n }\n\n _init() {\n if (this.children.length) {\n if (!this.hasAttribute(\"is_disabled\")) {\n this._toggle.addEventListener(\"click\", this._clickHandler);\n this._toggle.addEventListener(\"keydown\", this._toggleKeydownHandler);\n this._allItems().forEach(item => {\n item.addEventListener(\"keydown\", this._itemKeydownHandler);\n item.addEventListener(\"click\", this._itemClickHandler);\n });\n }\n }\n }\n\n // Event handler for click event on Dropdown button\n _clickHandler(event) {\n this.isOpen ? this.close(event) : this.open(event);\n return this;\n }\n\n // Event handler for click event on Dropdown Item\n _itemClickHandler(event) {\n let pfeType;\n if (event.target.parentElement.attributes[\"pfe-item-type\"]) {\n pfeType = event.target.parentElement.attributes[\"pfe-item-type\"].value;\n }\n this._selectItem(event.target, pfeType);\n return this;\n }\n\n // Event handler for keydown events on Dropdown Menu\n _itemKeydownHandler(event) {\n let newItem;\n let pfeType;\n if (event.target.attributes[\"pfe-item-type\"]) {\n pfeType = event.target.attributes[\"pfe-item-type\"].value;\n }\n // active dropdown item index\n const currentIndex = this._allItems().findIndex(\n item => item === document.activeElement\n );\n switch (event.keyCode) {\n case KEYCODE.ENTER:\n this._selectItem(event.target.children[0], pfeType);\n break;\n case KEYCODE.ESC:\n this.close(event);\n break;\n case KEYCODE.RIGHT:\n case KEYCODE.DOWN:\n // get the following item\n newItem = this._itemContainer(this._nextItem(currentIndex, 1));\n break;\n case KEYCODE.LEFT:\n case KEYCODE.UP:\n // get the previous item\n newItem = this._itemContainer(this._nextItem(currentIndex, -1));\n break;\n case KEYCODE.HOME:\n newItem = this._firstItem();\n break;\n case KEYCODE.END:\n newItem = this._lastItem();\n break;\n case KEYCODE.TAB:\n this.close();\n break;\n default:\n break;\n }\n if (newItem) {\n newItem.setAttribute(\"tabindex\", \"-1\");\n newItem.focus();\n }\n return this;\n }\n\n // Event handler for click event outside the Dropdown element\n _outsideClickHandler(event) {\n // Check if the clicked element is the dropdown object\n let isSelf = event.target === this;\n // Check if the clicked element contains or is contained by the dropdown element\n let isChild = event.target.closest(\"pfe-dropdown\");\n let insideWrapper =\n event.target.tagName.indexOf(\"-\") > -1\n ? event.target.shadowRoot.querySelector(\"pfe-dropdown\")\n : null;\n // Check states to determine if the dropdown menu should close\n if (!isSelf && !(isChild || insideWrapper)) {\n this.close();\n }\n }\n\n // Event handler for keydown event on Dropdown\n _toggleKeydownHandler(event) {\n switch (event.keyCode) {\n case KEYCODE.ENTER:\n case KEYCODE.DOWN:\n if (this._allDisabled()) {\n // toggle the dropdown if all items disabled\n this.toggle(event);\n } else {\n // otherwise, get the next enabled item\n this.open();\n const item = this._itemContainer(this._nextItem(-1, 1));\n item.setAttribute(\"tabindex\", \"-1\");\n item.focus();\n }\n break;\n case KEYCODE.TAB:\n this.close();\n break;\n default:\n break;\n }\n return this;\n }\n\n // modify DOM if custom options are passed in an array\n _modifyDOM(options) {\n options.forEach(el => {\n let item;\n switch (el.type) {\n case \"link\":\n item = document.createElement(\"a\");\n item.setAttribute(\"href\", el.href ? el.href : \"#\");\n break;\n case \"action\":\n item = document.createElement(\"button\");\n break;\n default:\n break;\n }\n const option = document.createElement(\"pfe-dropdown-item\");\n option.setAttribute(\"pfe-item-type\", el.type);\n if (el.is_disabled) {\n option.setAttribute(\"is_disabled\", el.is_disabled);\n }\n if (item) {\n item.innerText = el.text ? el.text : \"\";\n option.appendChild(item);\n }\n this.appendChild(option);\n });\n }\n\n _setDisabled() {\n const isDisabled = this.hasAttribute(\"is_disabled\");\n if (isDisabled) {\n this.setAttribute(\"aria-disabled\", \"true\");\n this.setAttribute(\"tabindex\", \"-1\");\n } else {\n this.removeAttribute(\"is_disabled\");\n this.setAttribute(\"aria-disabled\", \"false\");\n this.removeAttribute(\"tabindex\");\n }\n }\n\n _allItems() {\n return [\n ...this.querySelectorAll(\n `${this.tag}-item:not([pfe-item-type='separator'])`\n )\n ];\n }\n\n _allDisabled() {\n return (\n this._allItems().find(item => !item.hasAttribute(\"is_disabled\")) ===\n undefined\n );\n }\n\n _nextItem(currentPosition, direction) {\n const items = this._allItems();\n let index = (currentPosition + direction) % items.length;\n index = index < 0 ? index + items.length : index;\n let item = items[index];\n while (item && item.hasAttribute(\"is_disabled\")) {\n index += direction;\n item = items[index % items.length];\n }\n return item;\n }\n\n _firstItem() {\n const items = this._allItems();\n return items[0];\n }\n\n _lastItem() {\n const items = this._allItems();\n return items[items.length - 1];\n }\n\n _selectItem(item, type) {\n if (type === \"action\") {\n this.emitEvent(PfeDropdown.events.change, {\n detail: { action: item.innerText }\n });\n this.close(event);\n } else {\n item.click();\n }\n }\n\n addDropdownOptions(options) {\n this._modifyDOM(options);\n }\n\n open(event) {\n if (event) {\n event.preventDefault();\n }\n this.isOpen = true;\n this._menu.classList.add(\"open\");\n this._toggle.setAttribute(\"aria-expanded\", true);\n return this;\n }\n\n close(event) {\n if (event) {\n event.preventDefault();\n }\n this.isOpen = false;\n this._menu.classList.remove(\"open\");\n this._toggle.setAttribute(\"aria-expanded\", false);\n return this;\n }\n\n toggle(event) {\n this.isOpen ? this.close(event) : this.open(event);\n }\n\n _itemContainer(item) {\n // used to apply the focus state to the item's container\n return item.shadowRoot.querySelector(`.${this.tag}-item__container`);\n }\n}\n\nPFElement.create(PfeDropdownItem);\nPFElement.create(PfeDropdown);\n\nexport default PfeDropdown;\n"],"names":["PfeDropdownItem","PFElement","version","html","properties","item-type","title","type","enum","default","prefixed","slots","tag","templateUrl","styleUrl","schemaUrl","observedAttributes","[object Object]","super","this","_container","shadowRoot","querySelector","_item","assignedNodes","attr","oldValue","newValue","_setAccessibility","_setDisabled","connectedCallback","getAttribute","setAttribute","removeAttribute","hasAttribute","Element","prototype","closest","s","el","matches","parentElement","parentNode","nodeType","msMatchesSelector","webkitMatchesSelector","KEYCODE","DOWN","END","ENTER","ESC","HOME","LEFT","RIGHT","SPACE","UP","TAB","PfeDropdown","label","is_disabled","pfeDropdownOptions","options","_modifyDOM","events","change","isOpen","_init","bind","_toggle","_toggle_text","_menu","open","close","_clickHandler","_toggleKeydownHandler","_itemKeydownHandler","_itemClickHandler","_outsideClickHandler","document","addEventListener","Promise","all","customElements","whenDefined","then","removeEventListener","_allItems","forEach","item","textContent","children","length","event","pfeType","target","attributes","value","_selectItem","newItem","currentIndex","findIndex","activeElement","keyCode","_itemContainer","_nextItem","_firstItem","_lastItem","focus","isSelf","isChild","insideWrapper","tagName","indexOf","_allDisabled","toggle","createElement","href","option","innerText","text","appendChild","querySelectorAll","undefined","find","currentPosition","direction","items","index","emitEvent","detail","action","click","preventDefault","classList","add","remove","create"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;EA2BA,MAAMA,UAAwBC,EAC5BC,qBACE,MAAO,sBAGTC,WACE,MAAO,qqDAOTC,wBACE,MAAO,CAACC,YAAY,CAACC,MAAQ,iBAAiBC,K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EAAK2C,QAITlH,mBAAmB4C,GACjB1C,KAAK2C,WAAWD,GAGlB5C,KAAK2E,GAOH,OANIA,GACFA,EAAMwC,iBAERjH,KAAK8C,QAAS,EACd9C,KAAKmD,MAAM+D,UAAUC,IAAI,QACzBnH,KAAKiD,QAAQpC,aAAa,iBAAiB,GACpCb,KAGTF,MAAM2E,GAOJ,OANIA,GACFA,EAAMwC,iBAERjH,KAAK8C,QAAS,EACd9C,KAAKmD,MAAM+D,UAAUE,OAAO,QAC5BpH,KAAKiD,QAAQpC,aAAa,iBAAiB,GACpCb,KAGTF,OAAO2E,GACLzE,KAAK8C,OAAS9C,KAAKqD,MAAMoB,GAASzE,KAAKoD,KAAKqB,GAG9C3E,eAAeuE,GAEb,OAAOA,EAAKnE,WAAWC,kBAAkBH,KAAKP,wBAIlDX,EAAUuI,OAAOxI,GACjBC,EAAUuI,OAAO/E"} \ No newline at end of file diff --git a/elements/pfe-dropdown/dist/pfe-dropdown.umd.js b/elements/pfe-dropdown/dist/pfe-dropdown.umd.js new file mode 100644 index 0000000000..332ab1e09b --- /dev/null +++ b/elements/pfe-dropdown/dist/pfe-dropdown.umd.js @@ -0,0 +1,694 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../../pfelement/dist/pfelement.umd')) : + typeof define === 'function' && define.amd ? define(['../../pfelement/dist/pfelement.umd'], factory) : + (global.PfeDropdown = factory(global.PFElement)); +}(this, (function (PFElement) { 'use strict'; + + PFElement = PFElement && PFElement.hasOwnProperty('default') ? PFElement['default'] : PFElement; + + var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + }; + + var createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + }(); + + var get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + + if (getter === undefined) { + return undefined; + } + + return getter.call(receiver); + } + }; + + var inherits = function (subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + }; + + var possibleConstructorReturn = function (self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && (typeof call === "object" || typeof call === "function") ? call : self; + }; + + var toConsumableArray = function (arr) { + if (Array.isArray(arr)) { + for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; + + return arr2; + } else { + return Array.from(arr); + } + }; + + /*! + * PatternFly Elements: PfeDropdown 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + + var PfeDropdownItem = function (_PFElement) { + inherits(PfeDropdownItem, _PFElement); + createClass(PfeDropdownItem, [{ + key: "html", + get: function get$$1() { + return "
  • \n \n
  • "; + } + }, { + key: "templateUrl", + get: function get$$1() { + return "pfe-dropdown-item.html"; + } + }, { + key: "styleUrl", + get: function get$$1() { + return "pfe-dropdown-item.scss"; + } + }, { + key: "schemaUrl", + get: function get$$1() { + return "pfe-dropdown-item.json"; + } + }], [{ + key: "version", + get: function get$$1() { + return "1.0.0-prerelease.54"; + } + }, { + key: "properties", + get: function get$$1() { + return { "item-type": { "title": "List item type", "type": "string", "enum": ["link", "action", "separator"], "default": null, "prefixed": true } }; + } + }, { + key: "slots", + get: function get$$1() { + return {}; + } + }, { + key: "tag", + get: function get$$1() { + return "pfe-dropdown-item"; + } + }, { + key: "observedAttributes", + get: function get$$1() { + return ["pfe-item-type", "is_disabled"]; + } + }]); + + function PfeDropdownItem() { + classCallCheck(this, PfeDropdownItem); + + var _this = possibleConstructorReturn(this, (PfeDropdownItem.__proto__ || Object.getPrototypeOf(PfeDropdownItem)).call(this, PfeDropdownItem)); + + _this._container = _this.shadowRoot.querySelector("." + _this.tag + "__container"); + _this._item = _this.shadowRoot.querySelector("slot").assignedNodes()[1]; + return _this; + } + + createClass(PfeDropdownItem, [{ + key: "attributeChangedCallback", + value: function attributeChangedCallback(attr, oldValue, newValue) { + switch (attr) { + case "pfe-item-type": + this._setAccessibility(); + break; + case "is_disabled": + this._setDisabled(); + break; + default: + break; + } + } + }, { + key: "connectedCallback", + value: function connectedCallback() { + get(PfeDropdownItem.prototype.__proto__ || Object.getPrototypeOf(PfeDropdownItem.prototype), "connectedCallback", this).call(this); + } + }, { + key: "_setAccessibility", + value: function _setAccessibility() { + if (this._container) { + var type = this.getAttribute("pfe-item-type"); + if (type) { + switch (type) { + case "link": + this._container.setAttribute("role", "none"); + this._item && this._item.setAttribute("role", "menuitem"); + break; + case "action": + this._container.setAttribute("role", "menuitem"); + this._item && this._item.removeAttribute("role"); + break; + case "separator": + this._container.setAttribute("role", "separator"); + break; + default: + break; + } + } + } + } + }, { + key: "_setDisabled", + value: function _setDisabled() { + var isDisabled = this.hasAttribute("is_disabled"); + if (isDisabled) { + this.removeAttribute("tabindex"); + this.setAttribute("aria-disabled", "true"); + } else { + this.removeAttribute("is_disabled"); + this.setAttribute("tabindex", "0"); + this.setAttribute("aria-disabled", "false"); + } + } + }]); + return PfeDropdownItem; + }(PFElement); + + /*! + * PatternFly Elements: PfeDropdown 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + + // @POLYFILL Element.closest + // https://developer.mozilla.org/en-US/docs/Web/API/Element/closest + if (!Element.prototype.closest) { + Element.prototype.closest = function (s) { + var el = this; + do { + if (el.matches(s)) return el; + el = el.parentElement || el.parentNode; + } while (el !== null && el.nodeType === 1); + return null; + }; + } + + // @POLYFILL Element.matches + // https://developer.mozilla.org/en-US/docs/Web/API/Element/matches + if (!Element.prototype.matches) { + Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; + } + + var KEYCODE = { + DOWN: 40, + END: 35, + ENTER: 13, + ESC: 27, + HOME: 36, + LEFT: 37, + RIGHT: 39, + SPACE: 32, + UP: 38, + TAB: 9 + }; + + var PfeDropdown = function (_PFElement) { + inherits(PfeDropdown, _PFElement); + createClass(PfeDropdown, [{ + key: "html", + get: function get$$1() { + return "
    \n \n
      \n \n
    \n
    "; + } + }, { + key: "templateUrl", + get: function get$$1() { + return "pfe-dropdown.html"; + } + }, { + key: "styleUrl", + get: function get$$1() { + return "pfe-dropdown.scss"; + } + }, { + key: "schemaUrl", + get: function get$$1() { + return "pfe-dropdown.json"; + } + }, { + key: "pfeDropdownOptions", + set: function set$$1(options) { + this._modifyDOM(options); + } + }], [{ + key: "version", + get: function get$$1() { + return "1.0.0-prerelease.54"; + } + }, { + key: "properties", + get: function get$$1() { + return { "label": { "title": "Menu button label", "type": "string", "default": "Dropdown", "prefixed": true }, "is_disabled": { "title": "Disable menu button", "type": "boolean", "default": false, "prefixed": false } }; + } + }, { + key: "slots", + get: function get$$1() { + return {}; + } + }, { + key: "tag", + get: function get$$1() { + return "pfe-dropdown"; + } + }, { + key: "observedAttributes", + get: function get$$1() { + return ["pfe-label", "is_disabled"]; + } + }, { + key: "events", + get: function get$$1() { + return { + change: this.tag + ":change" + }; + } + }]); + + function PfeDropdown() { + classCallCheck(this, PfeDropdown); + + // state + var _this = possibleConstructorReturn(this, (PfeDropdown.__proto__ || Object.getPrototypeOf(PfeDropdown)).call(this, PfeDropdown)); + + _this.isOpen = false; + + _this._init = _this._init.bind(_this); + + // elements + _this._container = _this.shadowRoot.querySelector("#" + _this.tag + "-container"); + _this._toggle = _this.shadowRoot.querySelector("#" + _this.tag + "-toggle"); + _this._toggle_text = _this._toggle.querySelector("." + _this.tag + "__toggle-text"); + _this._menu = _this.shadowRoot.querySelector("#" + _this.tag + "-menu"); + + // events + _this.open = _this.open.bind(_this); + _this.close = _this.close.bind(_this); + + _this._clickHandler = _this._clickHandler.bind(_this); + _this._toggleKeydownHandler = _this._toggleKeydownHandler.bind(_this); + _this._itemKeydownHandler = _this._itemKeydownHandler.bind(_this); + _this._itemClickHandler = _this._itemClickHandler.bind(_this); + _this._outsideClickHandler = _this._outsideClickHandler.bind(_this); + return _this; + } + + createClass(PfeDropdown, [{ + key: "connectedCallback", + value: function connectedCallback() { + var _this2 = this; + + get(PfeDropdown.prototype.__proto__ || Object.getPrototypeOf(PfeDropdown.prototype), "connectedCallback", this).call(this); + document.addEventListener("click", this._outsideClickHandler); + Promise.all([customElements.whenDefined(PfeDropdown.tag), customElements.whenDefined(PfeDropdownItem.tag)]).then(function () { + _this2._init(); + }); + } + }, { + key: "disconnectedCallback", + value: function disconnectedCallback() { + var _this3 = this; + + this._toggle.removeEventListener("click", this._clickHandler); + this._toggle.removeEventListener("keydown", this._toggleKeydownHandler); + this._allItems().forEach(function (item) { + item.removeEventListener("keydown", _this3._itemKeydownHandler); + item.removeEventListener("click", _this3._itemClickHandler); + }); + } + }, { + key: "attributeChangedCallback", + value: function attributeChangedCallback(attr, oldValue, newValue) { + switch (attr) { + case "pfe-label": + this._toggle_text.textContent = newValue; + break; + case "is_disabled": + this._setDisabled(); + break; + default: + break; + } + } + }, { + key: "_init", + value: function _init() { + var _this4 = this; + + if (this.children.length) { + if (!this.hasAttribute("is_disabled")) { + this._toggle.addEventListener("click", this._clickHandler); + this._toggle.addEventListener("keydown", this._toggleKeydownHandler); + this._allItems().forEach(function (item) { + item.addEventListener("keydown", _this4._itemKeydownHandler); + item.addEventListener("click", _this4._itemClickHandler); + }); + } + } + } + + // Event handler for click event on Dropdown button + + }, { + key: "_clickHandler", + value: function _clickHandler(event) { + this.isOpen ? this.close(event) : this.open(event); + return this; + } + + // Event handler for click event on Dropdown Item + + }, { + key: "_itemClickHandler", + value: function _itemClickHandler(event) { + var pfeType = void 0; + if (event.target.parentElement.attributes["pfe-item-type"]) { + pfeType = event.target.parentElement.attributes["pfe-item-type"].value; + } + this._selectItem(event.target, pfeType); + return this; + } + + // Event handler for keydown events on Dropdown Menu + + }, { + key: "_itemKeydownHandler", + value: function _itemKeydownHandler(event) { + var newItem = void 0; + var pfeType = void 0; + if (event.target.attributes["pfe-item-type"]) { + pfeType = event.target.attributes["pfe-item-type"].value; + } + // active dropdown item index + var currentIndex = this._allItems().findIndex(function (item) { + return item === document.activeElement; + }); + switch (event.keyCode) { + case KEYCODE.ENTER: + this._selectItem(event.target.children[0], pfeType); + break; + case KEYCODE.ESC: + this.close(event); + break; + case KEYCODE.RIGHT: + case KEYCODE.DOWN: + // get the following item + newItem = this._itemContainer(this._nextItem(currentIndex, 1)); + break; + case KEYCODE.LEFT: + case KEYCODE.UP: + // get the previous item + newItem = this._itemContainer(this._nextItem(currentIndex, -1)); + break; + case KEYCODE.HOME: + newItem = this._firstItem(); + break; + case KEYCODE.END: + newItem = this._lastItem(); + break; + case KEYCODE.TAB: + this.close(); + break; + default: + break; + } + if (newItem) { + newItem.setAttribute("tabindex", "-1"); + newItem.focus(); + } + return this; + } + + // Event handler for click event outside the Dropdown element + + }, { + key: "_outsideClickHandler", + value: function _outsideClickHandler(event) { + // Check if the clicked element is the dropdown object + var isSelf = event.target === this; + // Check if the clicked element contains or is contained by the dropdown element + var isChild = event.target.closest("pfe-dropdown"); + var insideWrapper = event.target.tagName.indexOf("-") > -1 ? event.target.shadowRoot.querySelector("pfe-dropdown") : null; + // Check states to determine if the dropdown menu should close + if (!isSelf && !(isChild || insideWrapper)) { + this.close(); + } + } + + // Event handler for keydown event on Dropdown + + }, { + key: "_toggleKeydownHandler", + value: function _toggleKeydownHandler(event) { + switch (event.keyCode) { + case KEYCODE.ENTER: + case KEYCODE.DOWN: + if (this._allDisabled()) { + // toggle the dropdown if all items disabled + this.toggle(event); + } else { + // otherwise, get the next enabled item + this.open(); + var item = this._itemContainer(this._nextItem(-1, 1)); + item.setAttribute("tabindex", "-1"); + item.focus(); + } + break; + case KEYCODE.TAB: + this.close(); + break; + default: + break; + } + return this; + } + + // modify DOM if custom options are passed in an array + + }, { + key: "_modifyDOM", + value: function _modifyDOM(options) { + var _this5 = this; + + options.forEach(function (el) { + var item = void 0; + switch (el.type) { + case "link": + item = document.createElement("a"); + item.setAttribute("href", el.href ? el.href : "#"); + break; + case "action": + item = document.createElement("button"); + break; + default: + break; + } + var option = document.createElement("pfe-dropdown-item"); + option.setAttribute("pfe-item-type", el.type); + if (el.is_disabled) { + option.setAttribute("is_disabled", el.is_disabled); + } + if (item) { + item.innerText = el.text ? el.text : ""; + option.appendChild(item); + } + _this5.appendChild(option); + }); + } + }, { + key: "_setDisabled", + value: function _setDisabled() { + var isDisabled = this.hasAttribute("is_disabled"); + if (isDisabled) { + this.setAttribute("aria-disabled", "true"); + this.setAttribute("tabindex", "-1"); + } else { + this.removeAttribute("is_disabled"); + this.setAttribute("aria-disabled", "false"); + this.removeAttribute("tabindex"); + } + } + }, { + key: "_allItems", + value: function _allItems() { + return [].concat(toConsumableArray(this.querySelectorAll(this.tag + "-item:not([pfe-item-type='separator'])"))); + } + }, { + key: "_allDisabled", + value: function _allDisabled() { + return this._allItems().find(function (item) { + return !item.hasAttribute("is_disabled"); + }) === undefined; + } + }, { + key: "_nextItem", + value: function _nextItem(currentPosition, direction) { + var items = this._allItems(); + var index = (currentPosition + direction) % items.length; + index = index < 0 ? index + items.length : index; + var item = items[index]; + while (item && item.hasAttribute("is_disabled")) { + index += direction; + item = items[index % items.length]; + } + return item; + } + }, { + key: "_firstItem", + value: function _firstItem() { + var items = this._allItems(); + return items[0]; + } + }, { + key: "_lastItem", + value: function _lastItem() { + var items = this._allItems(); + return items[items.length - 1]; + } + }, { + key: "_selectItem", + value: function _selectItem(item, type) { + if (type === "action") { + this.emitEvent(PfeDropdown.events.change, { + detail: { action: item.innerText } + }); + this.close(event); + } else { + item.click(); + } + } + }, { + key: "addDropdownOptions", + value: function addDropdownOptions(options) { + this._modifyDOM(options); + } + }, { + key: "open", + value: function open(event) { + if (event) { + event.preventDefault(); + } + this.isOpen = true; + this._menu.classList.add("open"); + this._toggle.setAttribute("aria-expanded", true); + return this; + } + }, { + key: "close", + value: function close(event) { + if (event) { + event.preventDefault(); + } + this.isOpen = false; + this._menu.classList.remove("open"); + this._toggle.setAttribute("aria-expanded", false); + return this; + } + }, { + key: "toggle", + value: function toggle(event) { + this.isOpen ? this.close(event) : this.open(event); + } + }, { + key: "_itemContainer", + value: function _itemContainer(item) { + // used to apply the focus state to the item's container + return item.shadowRoot.querySelector("." + this.tag + "-item__container"); + } + }]); + return PfeDropdown; + }(PFElement); + + PFElement.create(PfeDropdownItem); + PFElement.create(PfeDropdown); + + return PfeDropdown; + +}))); +//# sourceMappingURL=pfe-dropdown.umd.js.map diff --git a/elements/pfe-dropdown/dist/pfe-dropdown.umd.js.map b/elements/pfe-dropdown/dist/pfe-dropdown.umd.js.map new file mode 100644 index 0000000000..2f7ae416de --- /dev/null +++ b/elements/pfe-dropdown/dist/pfe-dropdown.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-dropdown.umd.js","sources":["../_temp/pfe-dropdown-item.js","../_temp/pfe-dropdown.umd.js"],"sourcesContent":["/*!\n * PatternFly Elements: PfeDropdown 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.js\";\n\nclass PfeDropdownItem extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
  • \n \n
  • `;\n }\n\n static get properties() {\n return {\"item-type\":{\"title\":\"List item type\",\"type\":\"string\",\"enum\":[\"link\",\"action\",\"separator\"],\"default\":null,\"prefixed\":true}};\n }\n\n static get slots() {\n return {};\n }\n static get tag() {\n return \"pfe-dropdown-item\";\n }\n\n get templateUrl() {\n return \"pfe-dropdown-item.html\";\n }\n\n get styleUrl() {\n return \"pfe-dropdown-item.scss\";\n }\n\n get schemaUrl() {\n return \"pfe-dropdown-item.json\";\n }\n\n static get observedAttributes() {\n return [\"pfe-item-type\", \"is_disabled\"];\n }\n\n constructor() {\n super(PfeDropdownItem);\n\n this._container = this.shadowRoot.querySelector(`.${this.tag}__container`);\n this._item = this.shadowRoot.querySelector(\"slot\").assignedNodes()[1];\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n switch (attr) {\n case \"pfe-item-type\":\n this._setAccessibility();\n break;\n case \"is_disabled\":\n this._setDisabled();\n break;\n default:\n break;\n }\n }\n\n connectedCallback() {\n super.connectedCallback();\n }\n\n _setAccessibility() {\n if (this._container) {\n const type = this.getAttribute(\"pfe-item-type\");\n if (type) {\n switch (type) {\n case \"link\":\n this._container.setAttribute(\"role\", \"none\");\n this._item && this._item.setAttribute(\"role\", \"menuitem\");\n break;\n case \"action\":\n this._container.setAttribute(\"role\", \"menuitem\");\n this._item && this._item.removeAttribute(\"role\");\n break;\n case \"separator\":\n this._container.setAttribute(\"role\", \"separator\");\n break;\n default:\n break;\n }\n }\n }\n }\n\n _setDisabled() {\n const isDisabled = this.hasAttribute(\"is_disabled\");\n if (isDisabled) {\n this.removeAttribute(\"tabindex\");\n this.setAttribute(\"aria-disabled\", \"true\");\n } else {\n this.removeAttribute(\"is_disabled\");\n this.setAttribute(\"tabindex\", \"0\");\n this.setAttribute(\"aria-disabled\", \"false\");\n }\n }\n}\n\nexport default PfeDropdownItem;\n","/*!\n * PatternFly Elements: PfeDropdown 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.umd\";\nimport PfeDropdownItem from \"./pfe-dropdown-item.js\";\n\n// @POLYFILL Element.closest\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/closest\nif (!Element.prototype.closest) {\n Element.prototype.closest = function(s) {\n var el = this;\n do {\n if (el.matches(s)) return el;\n el = el.parentElement || el.parentNode;\n } while (el !== null && el.nodeType === 1);\n return null;\n };\n}\n\n// @POLYFILL Element.matches\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/matches\nif (!Element.prototype.matches) {\n Element.prototype.matches =\n Element.prototype.msMatchesSelector ||\n Element.prototype.webkitMatchesSelector;\n}\n\nconst KEYCODE = {\n DOWN: 40,\n END: 35,\n ENTER: 13,\n ESC: 27,\n HOME: 36,\n LEFT: 37,\n RIGHT: 39,\n SPACE: 0 || 32,\n UP: 38,\n TAB: 9\n};\n\nclass PfeDropdown extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
    \n \n
      \n \n
    \n
    `;\n }\n\n static get properties() {\n return {\"label\":{\"title\":\"Menu button label\",\"type\":\"string\",\"default\":\"Dropdown\",\"prefixed\":true},\"is_disabled\":{\"title\":\"Disable menu button\",\"type\":\"boolean\",\"default\":false,\"prefixed\":false}};\n }\n\n static get slots() {\n return {};\n }\n static get tag() {\n return \"pfe-dropdown\";\n }\n\n get templateUrl() {\n return \"pfe-dropdown.html\";\n }\n\n get styleUrl() {\n return \"pfe-dropdown.scss\";\n }\n\n get schemaUrl() {\n return \"pfe-dropdown.json\";\n }\n\n static get observedAttributes() {\n return [\"pfe-label\", \"is_disabled\"];\n }\n\n set pfeDropdownOptions(options) {\n this._modifyDOM(options);\n }\n\n static get events() {\n return {\n change: `${this.tag}:change`\n };\n }\n\n constructor() {\n super(PfeDropdown);\n\n // state\n this.isOpen = false;\n\n this._init = this._init.bind(this);\n\n // elements\n this._container = this.shadowRoot.querySelector(`#${this.tag}-container`);\n this._toggle = this.shadowRoot.querySelector(`#${this.tag}-toggle`);\n this._toggle_text = this._toggle.querySelector(`.${this.tag}__toggle-text`);\n this._menu = this.shadowRoot.querySelector(`#${this.tag}-menu`);\n\n // events\n this.open = this.open.bind(this);\n this.close = this.close.bind(this);\n\n this._clickHandler = this._clickHandler.bind(this);\n this._toggleKeydownHandler = this._toggleKeydownHandler.bind(this);\n this._itemKeydownHandler = this._itemKeydownHandler.bind(this);\n this._itemClickHandler = this._itemClickHandler.bind(this);\n this._outsideClickHandler = this._outsideClickHandler.bind(this);\n }\n\n connectedCallback() {\n super.connectedCallback();\n document.addEventListener(\"click\", this._outsideClickHandler);\n Promise.all([\n customElements.whenDefined(PfeDropdown.tag),\n customElements.whenDefined(PfeDropdownItem.tag)\n ]).then(() => {\n this._init();\n });\n }\n\n disconnectedCallback() {\n this._toggle.removeEventListener(\"click\", this._clickHandler);\n this._toggle.removeEventListener(\"keydown\", this._toggleKeydownHandler);\n this._allItems().forEach(item => {\n item.removeEventListener(\"keydown\", this._itemKeydownHandler);\n item.removeEventListener(\"click\", this._itemClickHandler);\n });\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n switch (attr) {\n case \"pfe-label\":\n this._toggle_text.textContent = newValue;\n break;\n case \"is_disabled\":\n this._setDisabled();\n break;\n default:\n break;\n }\n }\n\n _init() {\n if (this.children.length) {\n if (!this.hasAttribute(\"is_disabled\")) {\n this._toggle.addEventListener(\"click\", this._clickHandler);\n this._toggle.addEventListener(\"keydown\", this._toggleKeydownHandler);\n this._allItems().forEach(item => {\n item.addEventListener(\"keydown\", this._itemKeydownHandler);\n item.addEventListener(\"click\", this._itemClickHandler);\n });\n }\n }\n }\n\n // Event handler for click event on Dropdown button\n _clickHandler(event) {\n this.isOpen ? this.close(event) : this.open(event);\n return this;\n }\n\n // Event handler for click event on Dropdown Item\n _itemClickHandler(event) {\n let pfeType;\n if (event.target.parentElement.attributes[\"pfe-item-type\"]) {\n pfeType = event.target.parentElement.attributes[\"pfe-item-type\"].value;\n }\n this._selectItem(event.target, pfeType);\n return this;\n }\n\n // Event handler for keydown events on Dropdown Menu\n _itemKeydownHandler(event) {\n let newItem;\n let pfeType;\n if (event.target.attributes[\"pfe-item-type\"]) {\n pfeType = event.target.attributes[\"pfe-item-type\"].value;\n }\n // active dropdown item index\n const currentIndex = this._allItems().findIndex(\n item => item === document.activeElement\n );\n switch (event.keyCode) {\n case KEYCODE.ENTER:\n this._selectItem(event.target.children[0], pfeType);\n break;\n case KEYCODE.ESC:\n this.close(event);\n break;\n case KEYCODE.RIGHT:\n case KEYCODE.DOWN:\n // get the following item\n newItem = this._itemContainer(this._nextItem(currentIndex, 1));\n break;\n case KEYCODE.LEFT:\n case KEYCODE.UP:\n // get the previous item\n newItem = this._itemContainer(this._nextItem(currentIndex, -1));\n break;\n case KEYCODE.HOME:\n newItem = this._firstItem();\n break;\n case KEYCODE.END:\n newItem = this._lastItem();\n break;\n case KEYCODE.TAB:\n this.close();\n break;\n default:\n break;\n }\n if (newItem) {\n newItem.setAttribute(\"tabindex\", \"-1\");\n newItem.focus();\n }\n return this;\n }\n\n // Event handler for click event outside the Dropdown element\n _outsideClickHandler(event) {\n // Check if the clicked element is the dropdown object\n let isSelf = event.target === this;\n // Check if the clicked element contains or is contained by the dropdown element\n let isChild = event.target.closest(\"pfe-dropdown\");\n let insideWrapper =\n event.target.tagName.indexOf(\"-\") > -1\n ? event.target.shadowRoot.querySelector(\"pfe-dropdown\")\n : null;\n // Check states to determine if the dropdown menu should close\n if (!isSelf && !(isChild || insideWrapper)) {\n this.close();\n }\n }\n\n // Event handler for keydown event on Dropdown\n _toggleKeydownHandler(event) {\n switch (event.keyCode) {\n case KEYCODE.ENTER:\n case KEYCODE.DOWN:\n if (this._allDisabled()) {\n // toggle the dropdown if all items disabled\n this.toggle(event);\n } else {\n // otherwise, get the next enabled item\n this.open();\n const item = this._itemContainer(this._nextItem(-1, 1));\n item.setAttribute(\"tabindex\", \"-1\");\n item.focus();\n }\n break;\n case KEYCODE.TAB:\n this.close();\n break;\n default:\n break;\n }\n return this;\n }\n\n // modify DOM if custom options are passed in an array\n _modifyDOM(options) {\n options.forEach(el => {\n let item;\n switch (el.type) {\n case \"link\":\n item = document.createElement(\"a\");\n item.setAttribute(\"href\", el.href ? el.href : \"#\");\n break;\n case \"action\":\n item = document.createElement(\"button\");\n break;\n default:\n break;\n }\n const option = document.createElement(\"pfe-dropdown-item\");\n option.setAttribute(\"pfe-item-type\", el.type);\n if (el.is_disabled) {\n option.setAttribute(\"is_disabled\", el.is_disabled);\n }\n if (item) {\n item.innerText = el.text ? el.text : \"\";\n option.appendChild(item);\n }\n this.appendChild(option);\n });\n }\n\n _setDisabled() {\n const isDisabled = this.hasAttribute(\"is_disabled\");\n if (isDisabled) {\n this.setAttribute(\"aria-disabled\", \"true\");\n this.setAttribute(\"tabindex\", \"-1\");\n } else {\n this.removeAttribute(\"is_disabled\");\n this.setAttribute(\"aria-disabled\", \"false\");\n this.removeAttribute(\"tabindex\");\n }\n }\n\n _allItems() {\n return [\n ...this.querySelectorAll(\n `${this.tag}-item:not([pfe-item-type='separator'])`\n )\n ];\n }\n\n _allDisabled() {\n return (\n this._allItems().find(item => !item.hasAttribute(\"is_disabled\")) ===\n undefined\n );\n }\n\n _nextItem(currentPosition, direction) {\n const items = this._allItems();\n let index = (currentPosition + direction) % items.length;\n index = index < 0 ? index + items.length : index;\n let item = items[index];\n while (item && item.hasAttribute(\"is_disabled\")) {\n index += direction;\n item = items[index % items.length];\n }\n return item;\n }\n\n _firstItem() {\n const items = this._allItems();\n return items[0];\n }\n\n _lastItem() {\n const items = this._allItems();\n return items[items.length - 1];\n }\n\n _selectItem(item, type) {\n if (type === \"action\") {\n this.emitEvent(PfeDropdown.events.change, {\n detail: { action: item.innerText }\n });\n this.close(event);\n } else {\n item.click();\n }\n }\n\n addDropdownOptions(options) {\n this._modifyDOM(options);\n }\n\n open(event) {\n if (event) {\n event.preventDefault();\n }\n this.isOpen = true;\n this._menu.classList.add(\"open\");\n this._toggle.setAttribute(\"aria-expanded\", true);\n return this;\n }\n\n close(event) {\n if (event) {\n event.preventDefault();\n }\n this.isOpen = false;\n this._menu.classList.remove(\"open\");\n this._toggle.setAttribute(\"aria-expanded\", false);\n return this;\n }\n\n toggle(event) {\n this.isOpen ? this.close(event) : this.open(event);\n }\n\n _itemContainer(item) {\n // used to apply the focus state to the item's container\n return item.shadowRoot.querySelector(`.${this.tag}-item__container`);\n }\n}\n\nPFElement.create(PfeDropdownItem);\nPFElement.create(PfeDropdown);\n\nexport default PfeDropdown;\n"],"names":["PfeDropdownItem","_container","shadowRoot","querySelector","tag","_item","assignedNodes","attr","oldValue","newValue","_setAccessibility","_setDisabled","type","getAttribute","setAttribute","removeAttribute","isDisabled","hasAttribute","PFElement","Element","prototype","closest","s","el","matches","parentElement","parentNode","nodeType","msMatchesSelector","webkitMatchesSelector","KEYCODE","DOWN","END","ENTER","ESC","HOME","LEFT","RIGHT","SPACE","UP","TAB","PfeDropdown","options","_modifyDOM","change","isOpen","_init","bind","_toggle","_toggle_text","_menu","open","close","_clickHandler","_toggleKeydownHandler","_itemKeydownHandler","_itemClickHandler","_outsideClickHandler","document","addEventListener","Promise","all","customElements","whenDefined","then","removeEventListener","_allItems","forEach","item","textContent","children","length","event","pfeType","target","attributes","value","_selectItem","newItem","currentIndex","findIndex","activeElement","keyCode","_itemContainer","_nextItem","_firstItem","_lastItem","focus","isSelf","isChild","insideWrapper","tagName","indexOf","_allDisabled","toggle","createElement","href","option","is_disabled","innerText","text","appendChild","querySelectorAll","find","undefined","currentPosition","direction","items","index","emitEvent","events","detail","action","click","preventDefault","classList","add","remove","create"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;MA2BMA;;;;6BAKO;EACT;EAKD;;;6BAaiB;EAChB,aAAO,wBAAP;EACD;;;6BAEc;EACb,aAAO,wBAAP;EACD;;;6BAEe;EACd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.umd.min.js new file mode 100644 index 0000000000..fa03db5d00 --- /dev/null +++ b/elements/pfe-dropdown/dist/pfe-dropdown.umd.min.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("../../pfelement/dist/pfelement.umd.min"),require("../../pfelement/dist/pfelement.umd")):"function"==typeof define&&define.amd?define(["../../pfelement/dist/pfelement.umd.min","../../pfelement/dist/pfelement.umd"],t):e.PfeDropdown=t(e.PFElement,e.PFElement)}(this,function(e,t){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e,t=t&&t.hasOwnProperty("default")?t.default:t;function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(e,t,o){return t&&n(e.prototype,t),o&&n(e,o),e};function n(e,t){for(var o=0;o::slotted(*){display:block;width:100%;padding:calc(16px * .5) calc(16px * .5);padding:var(--pfe-dropdown--spacing--vertical,var(--pfe-dropdown--SpacingHorizontal,calc(var(--pfe-theme--container-padding,16px) * .5))) var(--pfe-dropdown--spacing--horizontal,var(--pfe-dropdown--SpacingHorizontal,calc(var(--pfe-theme--container-padding,16px) * .5)));color:#030303;color:var(--pfe-dropdown--Color,#030303);font-size:16px;font-size:var(--pfe-dropdown--FontSize,var(--pfe-theme--font-size,16px));font-weight:400;font-weight:var(--pfe-dropdown--FontWeight,400);line-height:1.5;line-height:var(--pfe-dropdown--LineHeight,var(--pfe-theme--line-height,1.5));text-align:left;text-align:var(--pfe-dropdown--TextAlign,left);white-space:nowrap;-webkit-box-sizing:border-box;box-sizing:border-box;text-decoration:none;font-family:inherit;font-family:var(--pfe-theme--font-family,inherit);cursor:pointer}::slotted(button){background-color:transparent;background-color:var(--pfe-dropdown--BackgroundColor,transparent);border:none;border:var(--pfe-dropdown--Border,none)}.pfe-dropdown-item__container:active,.pfe-dropdown-item__container:focus,.pfe-dropdown-item__container:hover{background-color:#f0f0f0;background-color:var(--pfe-dropdown--BackgroundColor--hover,var(--pfe-theme--color--surface--lighter,#f0f0f0));color:#151515;color:var(--pfe-dropdown--Color--hover,#151515)}:host([pfe-item-type=separator]) .pfe-dropdown-item__container{height:1px;background-color:#f0f0f0}:host([is_disabled]) .pfe-dropdown-item__container{pointer-events:none;--pfe-dropdown--Color:#6a6e73}\n/*# sourceMappingURL=pfe-dropdown-item.min.css.map */\n
  • \n \n
  • '}},{key:"templateUrl",get:function(){return"pfe-dropdown-item.html"}},{key:"styleUrl",get:function(){return"pfe-dropdown-item.scss"}},{key:"schemaUrl",get:function(){return"pfe-dropdown-item.json"}}],[{key:"version",get:function(){return"1.0.0-prerelease.54"}},{key:"properties",get:function(){return{"item-type":{title:"List item type",type:"string",enum:["link","action","separator"],default:null,prefixed:!0}}}},{key:"slots",get:function(){return{}}},{key:"tag",get:function(){return"pfe-dropdown-item"}},{key:"observedAttributes",get:function(){return["pfe-item-type","is_disabled"]}}]),r(s,[{key:"attributeChangedCallback",value:function(e,t,o){switch(e){case"pfe-item-type":this._setAccessibility();break;case"is_disabled":this._setDisabled()}}},{key:"connectedCallback",value:function(){a(s.prototype.__proto__||Object.getPrototypeOf(s.prototype),"connectedCallback",this).call(this)}},{key:"_setAccessibility",value:function(){if(this._container){var e=this.getAttribute("pfe-item-type");if(e)switch(e){case"link":this._container.setAttribute("role","none"),this._item&&this._item.setAttribute("role","menuitem");break;case"action":this._container.setAttribute("role","menuitem"),this._item&&this._item.removeAttribute("role");break;case"separator":this._container.setAttribute("role","separator")}}}},{key:"_setDisabled",value:function(){this.hasAttribute("is_disabled")?(this.removeAttribute("tabindex"),this.setAttribute("aria-disabled","true")):(this.removeAttribute("is_disabled"),this.setAttribute("tabindex","0"),this.setAttribute("aria-disabled","false"))}}]),s);function s(){o(this,s);var e=d(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,s));return e._container=e.shadowRoot.querySelector("."+e.tag+"__container"),e._item=e.shadowRoot.querySelector("slot").assignedNodes()[1],e}Element.prototype.closest||(Element.prototype.closest=function(e){var t=this;do{if(t.matches(e))return t;t=t.parentElement||t.parentNode}while(null!==t&&1===t.nodeType);return null}),Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector);var p=40,c=35,f=13,u=27,h=36,b=37,m=39,g=38,_=9,v=(i(w,t),r(w,[{key:"html",get:function(){return'
    \n \n \n
    '}},{key:"templateUrl",get:function(){return"pfe-dropdown.html"}},{key:"styleUrl",get:function(){return"pfe-dropdown.scss"}},{key:"schemaUrl",get:function(){return"pfe-dropdown.json"}},{key:"pfeDropdownOptions",set:function(e){this._modifyDOM(e)}}],[{key:"version",get:function(){return"1.0.0-prerelease.54"}},{key:"properties",get:function(){return{label:{title:"Menu button label",type:"string",default:"Dropdown",prefixed:!0},is_disabled:{title:"Disable menu button",type:"boolean",default:!1,prefixed:!1}}}},{key:"slots",get:function(){return{}}},{key:"tag",get:function(){return"pfe-dropdown"}},{key:"observedAttributes",get:function(){return["pfe-label","is_disabled"]}},{key:"events",get:function(){return{change:this.tag+":change"}}}]),r(w,[{key:"connectedCallback",value:function(){var e=this;a(w.prototype.__proto__||Object.getPrototypeOf(w.prototype),"connectedCallback",this).call(this),document.addEventListener("click",this._outsideClickHandler),Promise.all([customElements.whenDefined(w.tag),customElements.whenDefined(l.tag)]).then(function(){e._init()})}},{key:"disconnectedCallback",value:function(){var t=this;this._toggle.removeEventListener("click",this._clickHandler),this._toggle.removeEventListener("keydown",this._toggleKeydownHandler),this._allItems().forEach(function(e){e.removeEventListener("keydown",t._itemKeydownHandler),e.removeEventListener("click",t._itemClickHandler)})}},{key:"attributeChangedCallback",value:function(e,t,o){switch(e){case"pfe-label":this._toggle_text.textContent=o;break;case"is_disabled":this._setDisabled()}}},{key:"_init",value:function(){var t=this;this.children.length&&(this.hasAttribute("is_disabled")||(this._toggle.addEventListener("click",this._clickHandler),this._toggle.addEventListener("keydown",this._toggleKeydownHandler),this._allItems().forEach(function(e){e.addEventListener("keydown",t._itemKeydownHandler),e.addEventListener("click",t._itemClickHandler)})))}},{key:"_clickHandler",value:function(e){return this.isOpen?this.close(e):this.open(e),this}},{key:"_itemClickHandler",value:function(e){var t=void 0;return e.target.parentElement.attributes["pfe-item-type"]&&(t=e.target.parentElement.attributes["pfe-item-type"].value),this._selectItem(e.target,t),this}},{key:"_itemKeydownHandler",value:function(e){var t=void 0,o=void 0;e.target.attributes["pfe-item-type"]&&(o=e.target.attributes["pfe-item-type"].value);var r=this._allItems().findIndex(function(e){return e===document.activeElement});switch(e.keyCode){case f:this._selectItem(e.target.children[0],o);break;case u:this.close(e);break;case m:case p:t=this._itemContainer(this._nextItem(r,1));break;case b:case g:t=this._itemContainer(this._nextItem(r,-1));break;case h:t=this._firstItem();break;case c:t=this._lastItem();break;case _:this.close()}return t&&(t.setAttribute("tabindex","-1"),t.focus()),this}},{key:"_outsideClickHandler",value:function(e){var t=e.target===this,o=e.target.closest("pfe-dropdown"),r=-1::slotted(*){display:block;width:100%;padding:calc(16px * .5) calc(16px * .5);padding:var(--pfe-dropdown--spacing--vertical,var(--pfe-dropdown--SpacingHorizontal,calc(var(--pfe-theme--container-padding,16px) * .5))) var(--pfe-dropdown--spacing--horizontal,var(--pfe-dropdown--SpacingHorizontal,calc(var(--pfe-theme--container-padding,16px) * .5)));color:#030303;color:var(--pfe-dropdown--Color,#030303);font-size:16px;font-size:var(--pfe-dropdown--FontSize,var(--pfe-theme--font-size,16px));font-weight:400;font-weight:var(--pfe-dropdown--FontWeight,400);line-height:1.5;line-height:var(--pfe-dropdown--LineHeight,var(--pfe-theme--line-height,1.5));text-align:left;text-align:var(--pfe-dropdown--TextAlign,left);white-space:nowrap;-webkit-box-sizing:border-box;box-sizing:border-box;text-decoration:none;font-family:inherit;font-family:var(--pfe-theme--font-family,inherit);cursor:pointer}::slotted(button){background-color:transparent;background-color:var(--pfe-dropdown--BackgroundColor,transparent);border:none;border:var(--pfe-dropdown--Border,none)}.pfe-dropdown-item__container:active,.pfe-dropdown-item__container:focus,.pfe-dropdown-item__container:hover{background-color:#f0f0f0;background-color:var(--pfe-dropdown--BackgroundColor--hover,var(--pfe-theme--color--surface--lighter,#f0f0f0));color:#151515;color:var(--pfe-dropdown--Color--hover,#151515)}:host([pfe-item-type=separator]) .pfe-dropdown-item__container{height:1px;background-color:#f0f0f0}:host([is_disabled]) .pfe-dropdown-item__container{pointer-events:none;--pfe-dropdown--Color:#6a6e73}\n/*# sourceMappingURL=pfe-dropdown-item.min.css.map */\n
  • \n \n
  • `;\n }\n\n static get properties() {\n return {\"item-type\":{\"title\":\"List item type\",\"type\":\"string\",\"enum\":[\"link\",\"action\",\"separator\"],\"default\":null,\"prefixed\":true}};\n }\n\n static get slots() {\n return {};\n }\n static get tag() {\n return \"pfe-dropdown-item\";\n }\n\n get templateUrl() {\n return \"pfe-dropdown-item.html\";\n }\n\n get styleUrl() {\n return \"pfe-dropdown-item.scss\";\n }\n\n get schemaUrl() {\n return \"pfe-dropdown-item.json\";\n }\n\n static get observedAttributes() {\n return [\"pfe-item-type\", \"is_disabled\"];\n }\n\n constructor() {\n super(PfeDropdownItem);\n\n this._container = this.shadowRoot.querySelector(`.${this.tag}__container`);\n this._item = this.shadowRoot.querySelector(\"slot\").assignedNodes()[1];\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n switch (attr) {\n case \"pfe-item-type\":\n this._setAccessibility();\n break;\n case \"is_disabled\":\n this._setDisabled();\n break;\n default:\n break;\n }\n }\n\n connectedCallback() {\n super.connectedCallback();\n }\n\n _setAccessibility() {\n if (this._container) {\n const type = this.getAttribute(\"pfe-item-type\");\n if (type) {\n switch (type) {\n case \"link\":\n this._container.setAttribute(\"role\", \"none\");\n this._item && this._item.setAttribute(\"role\", \"menuitem\");\n break;\n case \"action\":\n this._container.setAttribute(\"role\", \"menuitem\");\n this._item && this._item.removeAttribute(\"role\");\n break;\n case \"separator\":\n this._container.setAttribute(\"role\", \"separator\");\n break;\n default:\n break;\n }\n }\n }\n }\n\n _setDisabled() {\n const isDisabled = this.hasAttribute(\"is_disabled\");\n if (isDisabled) {\n this.removeAttribute(\"tabindex\");\n this.setAttribute(\"aria-disabled\", \"true\");\n } else {\n this.removeAttribute(\"is_disabled\");\n this.setAttribute(\"tabindex\", \"0\");\n this.setAttribute(\"aria-disabled\", \"false\");\n }\n }\n}\n\nexport default PfeDropdownItem;\n","/*!\n * PatternFly Elements: PfeDropdown 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.umd\";\nimport PfeDropdownItem from \"./pfe-dropdown-item.js\";\n\n// @POLYFILL Element.closest\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/closest\nif (!Element.prototype.closest) {\n Element.prototype.closest = function(s) {\n var el = this;\n do {\n if (el.matches(s)) return el;\n el = el.parentElement || el.parentNode;\n } while (el !== null && el.nodeType === 1);\n return null;\n };\n}\n\n// @POLYFILL Element.matches\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/matches\nif (!Element.prototype.matches) {\n Element.prototype.matches =\n Element.prototype.msMatchesSelector ||\n Element.prototype.webkitMatchesSelector;\n}\n\nconst KEYCODE = {\n DOWN: 40,\n END: 35,\n ENTER: 13,\n ESC: 27,\n HOME: 36,\n LEFT: 37,\n RIGHT: 39,\n SPACE: 0 || 32,\n UP: 38,\n TAB: 9\n};\n\nclass PfeDropdown extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
    \n \n
      \n \n
    \n
    `;\n }\n\n static get properties() {\n return {\"label\":{\"title\":\"Menu button label\",\"type\":\"string\",\"default\":\"Dropdown\",\"prefixed\":true},\"is_disabled\":{\"title\":\"Disable menu button\",\"type\":\"boolean\",\"default\":false,\"prefixed\":false}};\n }\n\n static get slots() {\n return {};\n }\n static get tag() {\n return \"pfe-dropdown\";\n }\n\n get templateUrl() {\n return \"pfe-dropdown.html\";\n }\n\n get styleUrl() {\n return \"pfe-dropdown.scss\";\n }\n\n get schemaUrl() {\n return \"pfe-dropdown.json\";\n }\n\n static get observedAttributes() {\n return [\"pfe-label\", \"is_disabled\"];\n }\n\n set pfeDropdownOptions(options) {\n this._modifyDOM(options);\n }\n\n static get events() {\n return {\n change: `${this.tag}:change`\n };\n }\n\n constructor() {\n super(PfeDropdown);\n\n // state\n this.isOpen = false;\n\n this._init = this._init.bind(this);\n\n // elements\n this._container = this.shadowRoot.querySelector(`#${this.tag}-container`);\n this._toggle = this.shadowRoot.querySelector(`#${this.tag}-toggle`);\n this._toggle_text = this._toggle.querySelector(`.${this.tag}__toggle-text`);\n this._menu = this.shadowRoot.querySelector(`#${this.tag}-menu`);\n\n // events\n this.open = this.open.bind(this);\n this.close = this.close.bind(this);\n\n this._clickHandler = this._clickHandler.bind(this);\n this._toggleKeydownHandler = this._toggleKeydownHandler.bind(this);\n this._itemKeydownHandler = this._itemKeydownHandler.bind(this);\n this._itemClickHandler = this._itemClickHandler.bind(this);\n this._outsideClickHandler = this._outsideClickHandler.bind(this);\n }\n\n connectedCallback() {\n super.connectedCallback();\n document.addEventListener(\"click\", this._outsideClickHandler);\n Promise.all([\n customElements.whenDefined(PfeDropdown.tag),\n customElements.whenDefined(PfeDropdownItem.tag)\n ]).then(() => {\n this._init();\n });\n }\n\n disconnectedCallback() {\n this._toggle.removeEventListener(\"click\", this._clickHandler);\n this._toggle.removeEventListener(\"keydown\", this._toggleKeydownHandler);\n this._allItems().forEach(item => {\n item.removeEventListener(\"keydown\", this._itemKeydownHandler);\n item.removeEventListener(\"click\", this._itemClickHandler);\n });\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n switch (attr) {\n case \"pfe-label\":\n this._toggle_text.textContent = newValue;\n break;\n case \"is_disabled\":\n this._setDisabled();\n break;\n default:\n break;\n }\n }\n\n _init() {\n if (this.children.length) {\n if (!this.hasAttribute(\"is_disabled\")) {\n this._toggle.addEventListener(\"click\", this._clickHandler);\n this._toggle.addEventListener(\"keydown\", this._toggleKeydownHandler);\n this._allItems().forEach(item => {\n item.addEventListener(\"keydown\", this._itemKeydownHandler);\n item.addEventListener(\"click\", this._itemClickHandler);\n });\n }\n }\n }\n\n // Event handler for click event on Dropdown button\n _clickHandler(event) {\n this.isOpen ? this.close(event) : this.open(event);\n return this;\n }\n\n // Event handler for click event on Dropdown Item\n _itemClickHandler(event) {\n let pfeType;\n if (event.target.parentElement.attributes[\"pfe-item-type\"]) {\n pfeType = event.target.parentElement.attributes[\"pfe-item-type\"].value;\n }\n this._selectItem(event.target, pfeType);\n return this;\n }\n\n // Event handler for keydown events on Dropdown Menu\n _itemKeydownHandler(event) {\n let newItem;\n let pfeType;\n if (event.target.attributes[\"pfe-item-type\"]) {\n pfeType = event.target.attributes[\"pfe-item-type\"].value;\n }\n // active dropdown item index\n const currentIndex = this._allItems().findIndex(\n item => item === document.activeElement\n );\n switch (event.keyCode) {\n case KEYCODE.ENTER:\n this._selectItem(event.target.children[0], pfeType);\n break;\n case KEYCODE.ESC:\n this.close(event);\n break;\n case KEYCODE.RIGHT:\n case KEYCODE.DOWN:\n // get the following item\n newItem = this._itemContainer(this._nextItem(currentIndex, 1));\n break;\n case KEYCODE.LEFT:\n case KEYCODE.UP:\n // get the previous item\n newItem = this._itemContainer(this._nextItem(currentIndex, -1));\n break;\n case KEYCODE.HOME:\n newItem = this._firstItem();\n break;\n case KEYCODE.END:\n newItem = this._lastItem();\n break;\n case KEYCODE.TAB:\n this.close();\n break;\n default:\n break;\n }\n if (newItem) {\n newItem.setAttribute(\"tabindex\", \"-1\");\n newItem.focus();\n }\n return this;\n }\n\n // Event handler for click event outside the Dropdown element\n _outsideClickHandler(event) {\n // Check if the clicked element is the dropdown object\n let isSelf = event.target === this;\n // Check if the clicked element contains or is contained by the dropdown element\n let isChild = event.target.closest(\"pfe-dropdown\");\n let insideWrapper =\n event.target.tagName.indexOf(\"-\") > -1\n ? event.target.shadowRoot.querySelector(\"pfe-dropdown\")\n : null;\n // Check states to determine if the dropdown menu should close\n if (!isSelf && !(isChild || insideWrapper)) {\n this.close();\n }\n }\n\n // Event handler for keydown event on Dropdown\n _toggleKeydownHandler(event) {\n switch (event.keyCode) {\n case KEYCODE.ENTER:\n case KEYCODE.DOWN:\n if (this._allDisabled()) {\n // toggle the dropdown if all items disabled\n this.toggle(event);\n } else {\n // otherwise, get the next enabled item\n this.open();\n const item = this._itemContainer(this._nextItem(-1, 1));\n item.setAttribute(\"tabindex\", \"-1\");\n item.focus();\n }\n break;\n case KEYCODE.TAB:\n this.close();\n break;\n default:\n break;\n }\n return this;\n }\n\n // modify DOM if custom options are passed in an array\n _modifyDOM(options) {\n options.forEach(el => {\n let item;\n switch (el.type) {\n case \"link\":\n item = document.createElement(\"a\");\n item.setAttribute(\"href\", el.href ? el.href : \"#\");\n break;\n case \"action\":\n item = document.createElement(\"button\");\n break;\n default:\n break;\n }\n const option = document.createElement(\"pfe-dropdown-item\");\n option.setAttribute(\"pfe-item-type\", el.type);\n if (el.is_disabled) {\n option.setAttribute(\"is_disabled\", el.is_disabled);\n }\n if (item) {\n item.innerText = el.text ? el.text : \"\";\n option.appendChild(item);\n }\n this.appendChild(option);\n });\n }\n\n _setDisabled() {\n const isDisabled = this.hasAttribute(\"is_disabled\");\n if (isDisabled) {\n this.setAttribute(\"aria-disabled\", \"true\");\n this.setAttribute(\"tabindex\", \"-1\");\n } else {\n this.removeAttribute(\"is_disabled\");\n this.setAttribute(\"aria-disabled\", \"false\");\n this.removeAttribute(\"tabindex\");\n }\n }\n\n _allItems() {\n return [\n ...this.querySelectorAll(\n `${this.tag}-item:not([pfe-item-type='separator'])`\n )\n ];\n }\n\n _allDisabled() {\n return (\n this._allItems().find(item => !item.hasAttribute(\"is_disabled\")) ===\n undefined\n );\n }\n\n _nextItem(currentPosition, direction) {\n const items = this._allItems();\n let index = (currentPosition + direction) % items.length;\n index = index < 0 ? index + items.length : index;\n let item = items[index];\n while (item && item.hasAttribute(\"is_disabled\")) {\n index += direction;\n item = items[index % items.length];\n }\n return item;\n }\n\n _firstItem() {\n const items = this._allItems();\n return items[0];\n }\n\n _lastItem() {\n const items = this._allItems();\n return items[items.length - 1];\n }\n\n _selectItem(item, type) {\n if (type === \"action\") {\n this.emitEvent(PfeDropdown.events.change, {\n detail: { action: item.innerText }\n });\n this.close(event);\n } else {\n item.click();\n }\n }\n\n addDropdownOptions(options) {\n this._modifyDOM(options);\n }\n\n open(event) {\n if (event) {\n event.preventDefault();\n }\n this.isOpen = true;\n this._menu.classList.add(\"open\");\n this._toggle.setAttribute(\"aria-expanded\", true);\n return this;\n }\n\n close(event) {\n if (event) {\n event.preventDefault();\n }\n this.isOpen = false;\n this._menu.classList.remove(\"open\");\n this._toggle.setAttribute(\"aria-expanded\", false);\n return this;\n }\n\n toggle(event) {\n this.isOpen ? this.close(event) : this.open(event);\n }\n\n _itemContainer(item) {\n // used to apply the focus state to the item's container\n return item.shadowRoot.querySelector(`.${this.tag}-item__container`);\n }\n}\n\nPFElement.create(PfeDropdownItem);\nPFElement.create(PfeDropdown);\n\nexport default PfeDropdown;\n"],"names":["PfeDropdownItem","PFElement","item-type","title","type","enum","default","prefixed","attr","oldValue","newValue","_setAccessibility","_setDisabled","this","_container","getAttribute","setAttribute","_item","removeAttribute","hasAttribute","_this","shadowRoot","querySelector","tag","assignedNodes","Element","prototype","closest","s","el","matches","parentElement","parentNode","nodeType","msMatchesSelector","webkitMatchesSelector","KEYCODE","PfeDropdown","options","_modifyDOM","label","is_disabled","addEventListener","_outsideClickHandler","all","customElements","whenDefined","then","_init","_toggle","removeEventListener","_clickHandler","_toggleKeydownHandler","_allItems","forEach","_this3","_itemKeydownHandler","_itemClickHandler","_toggle_text","textContent","children","length","_this4","event","isOpen","close","open","pfeType","target","attributes","value","_selectItem","newItem","currentIndex","findIndex","item","document","activeElement","keyCode","_itemContainer","_nextItem","_firstItem","_lastItem","focus","isSelf","isChild","insideWrapper","tagName","indexOf","_allDisabled","toggle","createElement","href","option","innerText","text","appendChild","querySelectorAll","undefined","find","currentPosition","direction","items","index","emitEvent","events","change","action","click","preventDefault","_menu","classList","add","remove","bind","create"],"mappings":"u/CA2BMA,OAAwBC,wvDAyBnB,gEAIA,iEAIA,iEA/BA,+DAYA,CAACC,YAAY,CAACC,MAAQ,iBAAiBC,KAAO,SAASC,KAAO,CAAC,OAAO,SAAS,aAAaC,QAAU,KAAKC,UAAW,wCAItH,qCAGA,qEAgBA,CAAC,gBAAiB,uEAUFC,EAAMC,EAAUC,UAC/BF,OACD,qBACEG,8BAEF,mBACEC,4MAYLC,KAAKC,WAAY,KACbV,EAAOS,KAAKE,aAAa,oBAC3BX,SACMA,OACD,YACEU,WAAWE,aAAa,OAAQ,aAChCC,OAASJ,KAAKI,MAAMD,aAAa,OAAQ,sBAE3C,cACEF,WAAWE,aAAa,OAAQ,iBAChCC,OAASJ,KAAKI,MAAMC,gBAAgB,kBAEtC,iBACEJ,WAAWE,aAAa,OAAQ,sDAU1BH,KAAKM,aAAa,qBAE9BD,gBAAgB,iBAChBF,aAAa,gBAAiB,eAE9BE,gBAAgB,o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AGFkD,QACAC,OAASnD,KAAKoD,MAAMF,GAASlD,KAAKqD,KAAKH,0CAG/BY,UAENA,EAAKtD,WAAWC,kBAAkBT,KAAKU,qHApSxCc,aAGD2B,QAAS,IAEThB,MAAQ5B,EAAK4B,MAAMkE,UAGnBpG,WAAaM,EAAKC,WAAWC,kBAAkBF,EAAKG,oBACpD0B,QAAU7B,EAAKC,WAAWC,kBAAkBF,EAAKG,iBACjDmC,aAAetC,EAAK6B,QAAQ3B,kBAAkBF,EAAKG,uBACnDuF,MAAQ1F,EAAKC,WAAWC,kBAAkBF,EAAKG,eAG/C2C,KAAO9C,EAAK8C,KAAKgD,UACjBjD,MAAQ7C,EAAK6C,MAAMiD,UAEnB/D,cAAgB/B,EAAK+B,cAAc+D,UACnC9D,sBAAwBhC,EAAKgC,sBAAsB8D,UACnD1D,oBAAsBpC,EAAKoC,oBAAoB0D,UAC/CzD,kBAAoBrC,EAAKqC,kBAAkByD,UAC3CvE,qBAAuBvB,EAAKuB,qBAAqBuE,mBAmRhDC,OAAOnH,KACPmH,OAAO9E"} \ No newline at end of file diff --git a/elements/pfe-dropdown/package-lock.json b/elements/pfe-dropdown/package-lock.json index 786bc7a24c..566049a3fe 100644 --- a/elements/pfe-dropdown/package-lock.json +++ b/elements/pfe-dropdown/package-lock.json @@ -1,6 +1,6 @@ { "name": "@patternfly/pfe-dropdown", - "version": "1.0.0-prerelease.53", + "version": "1.0.0-prerelease.54", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/elements/pfe-dropdown/package.json b/elements/pfe-dropdown/package.json index da300179c6..65d3e92df4 100644 --- a/elements/pfe-dropdown/package.json +++ b/elements/pfe-dropdown/package.json @@ -4,7 +4,7 @@ "className": "PfeDropdown", "elementName": "pfe-dropdown" }, - "version": "1.0.0-prerelease.53", + "version": "1.0.0-prerelease.54", "description": "Dropdown element for PatternFly Elements", "keywords": [ "web-components", @@ -34,7 +34,7 @@ "@patternfly/pfelement": "^1.0.0-prerelease.50" }, "devDependencies": { - "@patternfly/pfe-sass": "^1.0.0-prerelease.53" + "@patternfly/pfe-sass": "^1.0.0-prerelease.54" }, "generator-pfelement-version": "1.3.0" } diff --git a/elements/pfe-health-index/dist/pfe-health-index.js b/elements/pfe-health-index/dist/pfe-health-index.js new file mode 100644 index 0000000000..cf631596d7 --- /dev/null +++ b/elements/pfe-health-index/dist/pfe-health-index.js @@ -0,0 +1,170 @@ +import PFElement from '../../pfelement/dist/pfelement.js'; + +/*! + * PatternFly Elements: PfeHealthIndex 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * +*/ + +class PfeHealthIndex extends PFElement { + static get version() { + return "1.0.0-prerelease.54"; + } + + get html() { + return `${this.props.size.value !== "lg" ? ` + ${this.props.size.value === "mini" ? ` +
    +
    +
    +
    +
    + ` : ` +
    +
    +
    +
    +
    +
    +
    +
    +
    + `} +` : ` +
    +
    +
    A
    +
    +
    +
    +
    B
    +
    +
    +
    +
    C
    +
    +
    +
    +
    D
    +
    +
    +
    +
    E
    +
    +
    +
    +
    F
    +
    +
    +
    +`}`; + } + + static get properties() { + return {"health-index":{"title":"Health Index","type":"string","enum":["A","B","C","D","E","F"],"default":"A","prefixed":false},"size":{"title":"Size","type":"string","enum":["mini","lg"],"default":null,"prefixed":false}}; + } + + static get slots() { + return {}; + } + static get tag() { + return "pfe-health-index"; + } + + get schemaUrl() { + return "pfe-health-index.json"; + } + + get templateUrl() { + return "pfe-health-index.html"; + } + + get styleUrl() { + return "pfe-health-index.scss"; + } + + static get observedAttributes() { + return ["health-index", "size"]; + } + + constructor() { + super(PfeHealthIndex, { delayRender: true }); + } + + attributeChangedCallback(attr, oldValue, newValue) { + super.attributeChangedCallback(attr, oldValue, newValue); + + switch (attr) { + case "size": + this.props.size.value = newValue; + this.render(); + this.updateHealthIndex(this.getAttribute("health-index"), oldValue); + break; + case "health-index": + this.props.size.value = this.getAttribute("size"); + this.render(); + this.updateHealthIndex(newValue); + break; + default: + break; + } + } + + updateHealthIndex(grade, oldValue) { + const healthIndex = grade.toLowerCase(); + const healthIndexUpperCase = grade.toUpperCase(); + const boxes = [...this.shadowRoot.querySelectorAll(".box")]; + this.innerHTML = healthIndexUpperCase; + + if (this.props.size.value === "mini") { + this.shadowRoot.querySelector(".box").classList.remove(oldValue); + this.shadowRoot.querySelector(".box").classList.add(healthIndex); + } + + boxes.forEach(box => { + if (box.classList.contains(healthIndex)) { + box.classList.add("active"); + } else { + box.classList.remove("active"); + } + }); + + if (this.props.size.value !== "lg") { + this.shadowRoot.querySelector( + "#healthIndex" + ).innerText = healthIndexUpperCase; + } + + if (!this.shadowRoot.querySelector(".box.active")) { + console.warn( + `${PfeHealthIndex.tag}: a valid health-index was not provided. Please use A, B, C, D, E, or F` + ); + } + } +} + +PFElement.create(PfeHealthIndex); + +export default PfeHealthIndex; +//# sourceMappingURL=pfe-health-index.js.map diff --git a/elements/pfe-health-index/dist/pfe-health-index.js.map b/elements/pfe-health-index/dist/pfe-health-index.js.map new file mode 100644 index 0000000000..95cf045540 --- /dev/null +++ b/elements/pfe-health-index/dist/pfe-health-index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-health-index.js","sources":["../_temp/pfe-health-index.js"],"sourcesContent":["/*!\n * PatternFly Elements: PfeHealthIndex 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.js\";\n\nclass PfeHealthIndex extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `${this.props.size.value !== \"lg\" ? `\n ${this.props.size.value === \"mini\" ? `\n
    \n
    \n
    \n
    \n
    \n ` : `\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n `}\n` : `\n
    \n
    \n
    A
    \n
    \n
    \n
    \n
    B
    \n
    \n
    \n
    \n
    C
    \n
    \n
    \n
    \n
    D
    \n
    \n
    \n
    \n
    E
    \n
    \n
    \n
    \n
    F
    \n
    \n
    \n
    \n`}`;\n }\n\n static get properties() {\n return {\"health-index\":{\"title\":\"Health Index\",\"type\":\"string\",\"enum\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"F\"],\"default\":\"A\",\"prefixed\":false},\"size\":{\"title\":\"Size\",\"type\":\"string\",\"enum\":[\"mini\",\"lg\"],\"default\":null,\"prefixed\":false}};\n }\n\n static get slots() {\n return {};\n }\n static get tag() {\n return \"pfe-health-index\";\n }\n\n get schemaUrl() {\n return \"pfe-health-index.json\";\n }\n\n get templateUrl() {\n return \"pfe-health-index.html\";\n }\n\n get styleUrl() {\n return \"pfe-health-index.scss\";\n }\n\n static get observedAttributes() {\n return [\"health-index\", \"size\"];\n }\n\n constructor() {\n super(PfeHealthIndex, { delayRender: true });\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n super.attributeChangedCallback(attr, oldValue, newValue);\n\n switch (attr) {\n case \"size\":\n this.props.size.value = newValue;\n this.render();\n this.updateHealthIndex(this.getAttribute(\"health-index\"), oldValue);\n break;\n case \"health-index\":\n this.props.size.value = this.getAttribute(\"size\");\n this.render();\n this.updateHealthIndex(newValue);\n break;\n default:\n break;\n }\n }\n\n updateHealthIndex(grade, oldValue) {\n const healthIndex = grade.toLowerCase();\n const healthIndexUpperCase = grade.toUpperCase();\n const boxes = [...this.shadowRoot.querySelectorAll(\".box\")];\n this.innerHTML = healthIndexUpperCase;\n\n if (this.props.size.value === \"mini\") {\n this.shadowRoot.querySelector(\".box\").classList.remove(oldValue);\n this.shadowRoot.querySelector(\".box\").classList.add(healthIndex);\n }\n\n boxes.forEach(box => {\n if (box.classList.contains(healthIndex)) {\n box.classList.add(\"active\");\n } else {\n box.classList.remove(\"active\");\n }\n });\n\n if (this.props.size.value !== \"lg\") {\n this.shadowRoot.querySelector(\n \"#healthIndex\"\n ).innerText = healthIndexUpperCase;\n }\n\n if (!this.shadowRoot.querySelector(\".box.active\")) {\n console.warn(\n `${PfeHealthIndex.tag}: a valid health-index was not provided. Please use A, B, C, D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,EAAE;MACpC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;MACjE,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;KAClE;;IAED,KAAK,CAAC,OAAO,CAAC,GAAG,IAAI;MACnB,IAAI,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;QACvC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;OAC7B,MAAM;QACL,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;OAChC;KACF,CAAC,CAAC;;IAEH,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,IAAI,EAAE;MAClC,IAAI,CAAC,UAAU,CAAC,aAAa;QAC3B,cAAc;OACf,CAAC,SAAS,GAAG,oBAAoB,CAAC;KACpC;;IAED,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,aAAa,CAAC,EAAE;MACjD,OAAO,CAAC,IAAI;QACV,CAAC,EAAE,cAAc,CAAC,GAAG,CAAC,uEAAuE,CAAC;OAC/F,CAAC;KACH;GACF;CACF;;AAED,SAAS,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;;;;"} \ No newline at end of file diff --git a/elements/pfe-health-index/dist/pfe-health-index.json b/elements/pfe-health-index/dist/pfe-health-index.json new file mode 100644 index 0000000000..50162574b8 --- /dev/null +++ b/elements/pfe-health-index/dist/pfe-health-index.json @@ -0,0 +1,40 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Health Index", + "description": "Shows a health index", + "type": "object", + "tag": "pfe-health-index", + "class": "pfe-health-index", + "category": "content", + "properties": { + "slots": { + "title": "Slots", + "description": "Definition of the supported slots", + "type": "object", + "properties": {} + }, + "attributes": { + "title": "Attributes", + "type": "object", + "properties": { + "health-index": { + "title": "Health Index", + "type": "string", + "enum": ["A", "B", "C", "D", "E", "F"], + "default": "A", + "prefixed": false + }, + "size": { + "title": "Size", + "type": "string", + "enum": ["mini", "lg"], + "default": null, + "prefixed": false + } + }, + "required": ["health-index"] + } + }, + "required": ["slots", "attributes"], + "additionalProperties": false +} diff --git a/elements/pfe-health-index/dist/pfe-health-index.min.js b/elements/pfe-health-index/dist/pfe-health-index.min.js new file mode 100644 index 0000000000..49c3f61843 --- /dev/null +++ b/elements/pfe-health-index/dist/pfe-health-index.min.js @@ -0,0 +1,26 @@ +import e from"../../pfelement/dist/pfelement.min.js"; +/*! + * PatternFly Elements: PfeHealthIndex 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * +*/class o extends e{static get version(){return"1.0.0-prerelease.54"}get html(){return`${"lg"!==this.props.size.value?`\n ${"mini"===this.props.size.value?'\n
    \n
    \n
    \n
    \n
    \n ':'\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n '}\n`:'\n
    \n
    \n
    A
    \n
    \n
    \n
    \n
    B
    \n
    \n
    \n
    \n
    C
    \n
    \n
    \n
    \n
    D
    \n
    \n
    \n
    \n
    E
    \n
    \n
    \n
    \n
    F
    \n
    \n
    \n
    \n'}`}static get properties(){return{"health-index":{title:"Health Index",type:"string",enum:["A","B","C","D","E","F"],default:"A",prefixed:!1},size:{title:"Size",type:"string",enum:["mini","lg"],default:null,prefixed:!1}}}static get slots(){return{}}static get tag(){return"pfe-health-index"}get schemaUrl(){return"pfe-health-index.json"}get templateUrl(){return"pfe-health-index.html"}get styleUrl(){return"pfe-health-index.scss"}static get observedAttributes(){return["health-index","size"]}constructor(){super(o,{delayRender:!0})}attributeChangedCallback(e,o,t){switch(super.attributeChangedCallback(e,o,t),e){case"size":this.props.size.value=t,this.render(),this.updateHealthIndex(this.getAttribute("health-index"),o);break;case"health-index":this.props.size.value=this.getAttribute("size"),this.render(),this.updateHealthIndex(t)}}updateHealthIndex(e,t){const i=e.toLowerCase(),a=e.toUpperCase(),r=[...this.shadowRoot.querySelectorAll(".box")];this.innerHTML=a,"mini"===this.props.size.value&&(this.shadowRoot.querySelector(".box").classList.remove(t),this.shadowRoot.querySelector(".box").classList.add(i)),r.forEach(e=>{e.classList.contains(i)?e.classList.add("active"):e.classList.remove("active")}),"lg"!==this.props.size.value&&(this.shadowRoot.querySelector("#healthIndex").innerText=a),this.shadowRoot.querySelector(".box.active")||console.warn(`${o.tag}: a valid health-index was not provided. Please use A, B, C, D, E, or F`)}}e.create(o);export default o; +//# sourceMappingURL=pfe-health-index.min.js.map diff --git a/elements/pfe-health-index/dist/pfe-health-index.min.js.map b/elements/pfe-health-index/dist/pfe-health-index.min.js.map new file mode 100644 index 0000000000..722939d16b --- /dev/null +++ b/elements/pfe-health-index/dist/pfe-health-index.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-health-index.min.js","sources":["../_temp/pfe-health-index.js"],"sourcesContent":["/*!\n * PatternFly Elements: PfeHealthIndex 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.js\";\n\nclass PfeHealthIndex extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `${this.props.size.value !== \"lg\" ? `\n ${this.props.size.value === \"mini\" ? `\n
    \n
    \n
    \n
    \n
    \n ` : `\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n `}\n` : `\n
    \n
    \n
    A
    \n
    \n
    \n
    \n
    B
    \n
    \n
    \n
    \n
    C
    \n
    \n
    \n
    \n
    D
    \n
    \n
    \n
    \n
    E
    \n
    \n
    \n
    \n
    F
    \n
    \n
    \n
    \n`}`;\n }\n\n static get properties() {\n return {\"health-index\":{\"title\":\"Health Index\",\"type\":\"string\",\"enum\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"F\"],\"default\":\"A\",\"prefixed\":false},\"size\":{\"title\":\"Size\",\"type\":\"string\",\"enum\":[\"mini\",\"lg\"],\"default\":null,\"prefixed\":false}};\n }\n\n static get slots() {\n return {};\n }\n static get tag() {\n return \"pfe-health-index\";\n }\n\n get schemaUrl() {\n return \"pfe-health-index.json\";\n }\n\n get templateUrl() {\n return \"pfe-health-index.html\";\n }\n\n get styleUrl() {\n return \"pfe-health-index.scss\";\n }\n\n static get observedAttributes() {\n return [\"health-index\", \"size\"];\n }\n\n constructor() {\n super(PfeHealthIndex, { delayRender: true });\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n super.attributeChangedCallback(attr, oldValue, newValue);\n\n switch (attr) {\n case \"size\":\n this.props.size.value = newValue;\n this.render();\n this.updateHealthIndex(this.getAttribute(\"health-index\"), oldValue);\n break;\n case \"health-index\":\n this.props.size.value = this.getAttribute(\"size\");\n this.render();\n this.updateHealthIndex(newValue);\n break;\n default:\n break;\n }\n }\n\n updateHealthIndex(grade, oldValue) {\n const healthIndex = grade.toLowerCase();\n const healthIndexUpperCase = grade.toUpperCase();\n const boxes = [...this.shadowRoot.querySelectorAll(\".box\")];\n this.innerHTML = healthIndexUpperCase;\n\n if (this.props.size.value === \"mini\") {\n this.shadowRoot.querySelector(\".box\").classList.remove(oldValue);\n this.shadowRoot.querySelector(\".box\").classList.add(healthIndex);\n }\n\n boxes.forEach(box => {\n if (box.classList.contains(healthIndex)) {\n box.classList.add(\"active\");\n } else {\n box.classList.remove(\"active\");\n }\n });\n\n if (this.props.size.value !== \"lg\") {\n this.shadowRoot.querySelector(\n \"#healthIndex\"\n ).innerText = healthIndexUpperCase;\n }\n\n if (!this.shadowRoot.querySelector(\".box.active\")) {\n console.warn(\n `${PfeHealthIndex.tag}: a valid health-index was not provided. Please use A, B, C, D, E, or F`\n );\n }\n }\n}\n\nPFElement.create(PfeHealthIndex);\n\nexport default PfeHealthIndex;\n"],"names":["PfeHealthIndex","PFElement","version","html","this","props","size","value","properties","health-index","title","type","enum","default","prefixed","slots","tag","schemaUrl","templateUrl","styleUrl","observedAttributes","[object Object]","super","delayRender","attr","oldValue","newValue","attributeChangedCallback","render","updateHealthIndex","getAttribute","grade","healthIndex","toLowerCase","healthIndexUpperCase","toUpperCase","boxes","shadowRoot","querySelectorAll","innerHTML","querySelector","classList","remove","add","forEach","box","contains","innerText","console","warn","create"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;EA2BA,MAAMA,UAAuBC,EAC3BC,qBACE,MAAO,sBAGTC,WACE,00QAEgC,OAA1BC,KAAKC,MAAMC,KAAKC,aACI,SAA1BH,KAAKC,MAAMC,KAAKC,MAAmB,+IAMjC,gSAWF,knBA8BFC,wBACE,MAAO,CAACC,eAAe,CAACC,MAAQ,eAAeC,KAAO,SAASC,KAAO,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,KAAKC,QAAU,IAAIC,UAAW,GAAOR,KAAO,CAACI,MAAQ,OAAOC,KAAO,SAASC,KAAO,CAAC,OAAO,MAAMC,QAAU,KAAKC,UAAW,IAGxNC,mBACE,MAAO,GAETC,iBACE,MAAO,mBAGTC,gBACE,MAAO,wBAGTC,kBACE,MAAO,wBAGTC,eACE,MAAO,wBAGTC,gCACE,MAAO,CAAC,eAAgB,QAG1BC,cACEC,MAAMtB,EAAgB,CAAEuB,aAAa,IAGvCF,yBAAyBG,EAAMC,EAAUC,GAGvC,OAFAJ,MAAMK,yBAAyBH,EAAMC,EAAUC,GAEvCF,GACN,IAAK,OACHpB,KAAKC,MAAMC,KAAKC,MAAQmB,EACxBtB,KAAKwB,SACLxB,KAAKyB,kBAAkBzB,KAAK0B,aAAa,gBAAiBL,GAC1D,MACF,IAAK,eACHrB,KAAKC,MAAMC,KAAKC,MAAQH,KAAK0B,aAAa,QAC1C1B,KAAKwB,SACLxB,KAAKyB,kBAAkBH,IAO7BL,kBAAkBU,EAAON,GACvB,MAAMO,EAAcD,EAAME,cACpBC,EAAuBH,EAAMI,cAC7BC,EAAQ,IAAIhC,KAAKiC,WAAWC,iBAAiB,SACnDlC,KAAKmC,UAAYL,EAEa,SAA1B9B,KAAKC,MAAMC,KAAKC,QAClBH,KAAKiC,WAAWG,cAAc,QAAQC,UAAUC,OAAOjB,GACvDrB,KAAKiC,WAAWG,cAAc,QAAQC,UAAUE,IAAIX,IAGtDI,EAAMQ,QAAQC,IACRA,EAAIJ,UAAUK,SAASd,GACzBa,EAAIJ,UAAUE,IAAI,UAElBE,EAAIJ,UAAUC,OAAO,YAIK,OAA1BtC,KAAKC,MAAMC,KAAKC,QAClBH,KAAKiC,WAAWG,cACd,gBACAO,UAAYb,GAGX9B,KAAKiC,WAAWG,cAAc,gBACjCQ,QAAQC,QACHjD,EAAegB,+EAM1Bf,EAAUiD,OAAOlD"} \ No newline at end of file diff --git a/elements/pfe-health-index/dist/pfe-health-index.umd.js b/elements/pfe-health-index/dist/pfe-health-index.umd.js new file mode 100644 index 0000000000..eca565c9a5 --- /dev/null +++ b/elements/pfe-health-index/dist/pfe-health-index.umd.js @@ -0,0 +1,229 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../../pfelement/dist/pfelement.umd')) : + typeof define === 'function' && define.amd ? define(['../../pfelement/dist/pfelement.umd'], factory) : + (global.PfeHealthIndex = factory(global.PFElement)); +}(this, (function (PFElement) { 'use strict'; + + PFElement = PFElement && PFElement.hasOwnProperty('default') ? PFElement['default'] : PFElement; + + var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + }; + + var createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + }(); + + var get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + + if (getter === undefined) { + return undefined; + } + + return getter.call(receiver); + } + }; + + var inherits = function (subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + }; + + var possibleConstructorReturn = function (self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && (typeof call === "object" || typeof call === "function") ? call : self; + }; + + var toConsumableArray = function (arr) { + if (Array.isArray(arr)) { + for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; + + return arr2; + } else { + return Array.from(arr); + } + }; + + /*! + * PatternFly Elements: PfeHealthIndex 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + + var PfeHealthIndex = function (_PFElement) { + inherits(PfeHealthIndex, _PFElement); + createClass(PfeHealthIndex, [{ + key: "html", + get: function get$$1() { + return "" + (this.props.size.value !== "lg" ? "\n " + (this.props.size.value === "mini" ? "\n
    \n
    \n
    \n
    \n
    \n " : "\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n ") + "\n" : "\n
    \n
    \n
    A
    \n
    \n
    \n
    \n
    B
    \n
    \n
    \n
    \n
    C
    \n
    \n
    \n
    \n
    D
    \n
    \n
    \n
    \n
    E
    \n
    \n
    \n
    \n
    F
    \n
    \n
    \n
    \n"); + } + }, { + key: "schemaUrl", + get: function get$$1() { + return "pfe-health-index.json"; + } + }, { + key: "templateUrl", + get: function get$$1() { + return "pfe-health-index.html"; + } + }, { + key: "styleUrl", + get: function get$$1() { + return "pfe-health-index.scss"; + } + }], [{ + key: "version", + get: function get$$1() { + return "1.0.0-prerelease.54"; + } + }, { + key: "properties", + get: function get$$1() { + return { "health-index": { "title": "Health Index", "type": "string", "enum": ["A", "B", "C", "D", "E", "F"], "default": "A", "prefixed": false }, "size": { "title": "Size", "type": "string", "enum": ["mini", "lg"], "default": null, "prefixed": false } }; + } + }, { + key: "slots", + get: function get$$1() { + return {}; + } + }, { + key: "tag", + get: function get$$1() { + return "pfe-health-index"; + } + }, { + key: "observedAttributes", + get: function get$$1() { + return ["health-index", "size"]; + } + }]); + + function PfeHealthIndex() { + classCallCheck(this, PfeHealthIndex); + return possibleConstructorReturn(this, (PfeHealthIndex.__proto__ || Object.getPrototypeOf(PfeHealthIndex)).call(this, PfeHealthIndex, { delayRender: true })); + } + + createClass(PfeHealthIndex, [{ + key: "attributeChangedCallback", + value: function attributeChangedCallback(attr, oldValue, newValue) { + get(PfeHealthIndex.prototype.__proto__ || Object.getPrototypeOf(PfeHealthIndex.prototype), "attributeChangedCallback", this).call(this, attr, oldValue, newValue); + + switch (attr) { + case "size": + this.props.size.value = newValue; + this.render(); + this.updateHealthIndex(this.getAttribute("health-index"), oldValue); + break; + case "health-index": + this.props.size.value = this.getAttribute("size"); + this.render(); + this.updateHealthIndex(newValue); + break; + default: + break; + } + } + }, { + key: "updateHealthIndex", + value: function updateHealthIndex(grade, oldValue) { + var healthIndex = grade.toLowerCase(); + var healthIndexUpperCase = grade.toUpperCase(); + var boxes = [].concat(toConsumableArray(this.shadowRoot.querySelectorAll(".box"))); + this.innerHTML = healthIndexUpperCase; + + if (this.props.size.value === "mini") { + this.shadowRoot.querySelector(".box").classList.remove(oldValue); + this.shadowRoot.querySelector(".box").classList.add(healthIndex); + } + + boxes.forEach(function (box) { + if (box.classList.contains(healthIndex)) { + box.classList.add("active"); + } else { + box.classList.remove("active"); + } + }); + + if (this.props.size.value !== "lg") { + this.shadowRoot.querySelector("#healthIndex").innerText = healthIndexUpperCase; + } + + if (!this.shadowRoot.querySelector(".box.active")) { + console.warn(PfeHealthIndex.tag + ": a valid health-index was not provided. Please use A, B, C, D, E, or F"); + } + } + }]); + return PfeHealthIndex; + }(PFElement); + + PFElement.create(PfeHealthIndex); + + return PfeHealthIndex; + +}))); +//# sourceMappingURL=pfe-health-index.umd.js.map diff --git a/elements/pfe-health-index/dist/pfe-health-index.umd.js.map b/elements/pfe-health-index/dist/pfe-health-index.umd.js.map new file mode 100644 index 0000000000..8ef408e567 --- /dev/null +++ b/elements/pfe-health-index/dist/pfe-health-index.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-health-index.umd.js","sources":["../_temp/pfe-health-index.umd.js"],"sourcesContent":["/*!\n * PatternFly Elements: PfeHealthIndex 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.umd\";\n\nclass PfeHealthIndex extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `${this.props.size.value !== \"lg\" ? `\n ${this.props.size.value === \"mini\" ? `\n
    \n
    \n
    \n
    \n
    \n ` : `\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n `}\n` : `\n
    \n
    \n
    A
    \n
    \n
    \n
    \n
    B
    \n
    \n
    \n
    \n
    C
    \n
    \n
    \n
    \n
    D
    \n
    \n
    \n
    \n
    E
    \n
    \n
    \n
    \n
    F
    \n
    \n
    \n
    \n`}`;\n }\n\n static get properties() {\n return {\"health-index\":{\"title\":\"Health Index\",\"type\":\"string\",\"enum\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"F\"],\"default\":\"A\",\"prefixed\":false},\"size\":{\"title\":\"Size\",\"type\":\"string\",\"enum\":[\"mini\",\"lg\"],\"default\":null,\"prefixed\":false}};\n }\n\n static get slots() {\n return {};\n }\n static get tag() {\n return \"pfe-health-index\";\n }\n\n get schemaUrl() {\n return \"pfe-health-index.json\";\n }\n\n get templateUrl() {\n return \"pfe-health-index.html\";\n }\n\n get styleUrl() {\n return \"pfe-health-index.scss\";\n }\n\n static get observedAttributes() {\n return [\"health-index\", \"size\"];\n }\n\n constructor() {\n super(PfeHealthIndex, { delayRender: true });\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n super.attributeChangedCallback(attr, oldValue, newValue);\n\n switch (attr) {\n case \"size\":\n this.props.size.value = newValue;\n this.render();\n this.updateHealthIndex(this.getAttribute(\"health-index\"), oldValue);\n break;\n case \"health-index\":\n this.props.size.value = this.getAttribute(\"size\");\n this.render();\n this.updateHealthIndex(newValue);\n break;\n default:\n break;\n }\n }\n\n updateHealthIndex(grade, oldValue) {\n const healthIndex = grade.toLowerCase();\n const healthIndexUpperCase = grade.toUpperCase();\n const boxes = [...this.shadowRoot.querySelectorAll(\".box\")];\n this.innerHTML = healthIndexUpperCase;\n\n if (this.props.size.value === \"mini\") {\n this.shadowRoot.querySelector(\".box\").classList.remove(oldValue);\n this.shadowRoot.querySelector(\".box\").classList.add(healthIndex);\n }\n\n boxes.forEach(box => {\n if (box.classList.contains(healthIndex)) {\n box.classList.add(\"active\");\n } else {\n box.classList.remove(\"active\");\n }\n });\n\n if (this.props.size.value !== \"lg\") {\n this.shadowRoot.querySelector(\n \"#healthIndex\"\n ).innerText = healthIndexUpperCase;\n }\n\n if (!this.shadowRoot.querySelector(\".box.active\")) {\n console.warn(\n `${PfeHealthIndex.tag}: a valid health-index was not provided. Please use A, B, C, D, E, or F`\n );\n }\n }\n}\n\nPFElement.create(PfeHealthIndex);\n\nexport default PfeHealthIndex;\n"],"names":["PfeHealthIndex","props","size","value","delayRender","attr","oldValue","newValue","render","updateHealthIndex","getAttribute","grade","healthIndex","toLowerCase","healthIndexUpperCase","toUpperCase","boxes","shadowRoot","querySelectorAll","innerHTML","querySelector","classList","remove","add","forEach","box","contains","innerText","console","warn","tag","PFElement","create"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,EAAmD;EACjDQ,gBAAQC,IAAR,CACK7B,eAAe8B,GADpB;EAGD;EACF;;;IAxI0BC;;EA2I7BA,UAAUC,MAAV,CAAiBhC,cAAjB;;;;;;;;"} \ No newline at end of file diff --git a/elements/pfe-health-index/dist/pfe-health-index.umd.min.js b/elements/pfe-health-index/dist/pfe-health-index.umd.min.js new file mode 100644 index 0000000000..0c371eef91 --- /dev/null +++ b/elements/pfe-health-index/dist/pfe-health-index.umd.min.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("../../pfelement/dist/pfelement.umd")):"function"==typeof define&&define.amd?define(["../../pfelement/dist/pfelement.umd"],t):e.PfeHealthIndex=t(e.PFElement)}(this,function(e){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e;var t=function(e,t,o){return t&&i(e.prototype,t),o&&i(e,o),e};function i(e,t){for(var o=0;o@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host{color:#151515!important}}:host([on=dark]){--pfe-broadcasted--text:var(--pfe-theme--color--text--on-dark, #fff);--pfe-broadcasted--link:var(--pfe-theme--color--link--on-dark, #73bcf7);--pfe-broadcasted--link--hover:var(--pfe-theme--color--link--hover--on-dark, #bee1f4);--pfe-broadcasted--link--focus:var(--pfe-theme--color--link--focus--on-dark, #bee1f4);--pfe-broadcasted--link--visited:var(--pfe-theme--color--link--visited--on-dark, #bee1f4);--pfe-broadcasted--link-decoration:var(--pfe-theme--link-decoration--on-dark, none);--pfe-broadcasted--link-decoration--hover:var(--pfe-theme--link-decoration--hover--on-dark, underline);--pfe-broadcasted--link-decoration--focus:var(--pfe-theme--link-decoration--focus--on-dark, underline);--pfe-broadcasted--link-decoration--visited:var(--pfe-theme--link-decoration--visited--on-dark, none)}:host([on=saturated]){--pfe-broadcasted--text:var(--pfe-theme--color--text--on-saturated, #fff);--pfe-broadcasted--link:var(--pfe-theme--color--link--on-saturated, #fff);--pfe-broadcasted--link--hover:var(--pfe-theme--color--link--hover--on-saturated, #fafafa);--pfe-broadcasted--link--focus:var(--pfe-theme--color--link--focus--on-saturated, #fafafa);--pfe-broadcasted--link--visited:var(--pfe-theme--color--link--visited--on-saturated, #8476d1);--pfe-broadcasted--link-decoration:var(--pfe-theme--link-decoration--on-saturated, underline);--pfe-broadcasted--link-decoration--hover:var(--pfe-theme--link-decoration--hover--on-saturated, underline);--pfe-broadcasted--link-decoration--focus:var(--pfe-theme--link-decoration--focus--on-saturated, underline);--pfe-broadcasted--link-decoration--visited:var(--pfe-theme--link-decoration--visited--on-saturated, underline)}:host([on=light]){--pfe-broadcasted--text:var(--pfe-theme--color--text, #151515);--pfe-broadcasted--link:var(--pfe-theme--color--link, #06c);--pfe-broadcasted--link--hover:var(--pfe-theme--color--link--hover, #004080);--pfe-broadcasted--link--focus:var(--pfe-theme--color--link--focus, #004080);--pfe-broadcasted--link--visited:var(--pfe-theme--color--link--visited, #6753ac);--pfe-broadcasted--link-decoration:var(--pfe-theme--link-decoration, none);--pfe-broadcasted--link-decoration--hover:var(--pfe-theme--link-decoration--hover, underline);--pfe-broadcasted--link-decoration--focus:var(--pfe-theme--link-decoration--focus, underline);--pfe-broadcasted--link-decoration--visited:var(--pfe-theme--link-decoration--visited, none)}:host{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center}:host([hidden]){display:none}.box.a{--pfe-health-index--accent:#3f9c35;--pfe-health-index--accent--text:var(--pfe-theme--color--text--on-dark, #fff)}.box.b{--pfe-health-index--accent:#92d400;--pfe-health-index--accent--text:var(--pfe-theme--color--text--on-dark, #fff)}.box.c{--pfe-health-index--accent:#efaa00;--pfe-health-index--accent--text:var(--pfe-theme--color--text--on-dark, #fff)}.box.d{--pfe-health-index--accent:#ec7a08;--pfe-health-index--accent--text:var(--pfe-theme--color--text--on-dark, #fff)}.box.e{--pfe-health-index--accent:#cc0000;--pfe-health-index--accent--text:var(--pfe-theme--color--text--on-dark, #fff)}.box.f{--pfe-health-index--accent:#523333;--pfe-health-index--accent--text:var(--pfe-theme--color--text--on-dark, #fff)}:host(:not([size=lg]):not([size=mini])) .box{background-color:#fff;background-color:var(--pfe-theme--color--surface--lightest,#fff);width:calc(20px / 2);width:calc(var(--pfe-theme--ui--element--size,20px)/ 2);height:20px;height:var(--pfe-theme--ui--element--size,20px);border-right:1px solid #d2d2d2;border-right:var(--pfe-theme--ui--border-width,1px) var(--pfe-theme--ui--border-style,solid) var(--pfe-theme--color--surface--border,#d2d2d2)}:host(:not([size=lg]):not([size=mini])) .box:last-child{border-right:0}:host(:not([size=lg]):not([size=mini])) .box.active{background-color:var(--pfe-health-index--accent)}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host(:not([size=lg]):not([size=mini])) .box.active.a{background-color:#3f9c35}:host(:not([size=lg]):not([size=mini])) .box.active.b{background-color:#92d400}:host(:not([size=lg]):not([size=mini])) .box.active.c{background-color:#efaa00}:host(:not([size=lg]):not([size=mini])) .box.active.d{background-color:#ec7a08}:host(:not([size=lg]):not([size=mini])) .box.active.e{background-color:#c00}:host(:not([size=lg]):not([size=mini])) .box.active.f{background-color:#523333}}:host([size=mini]) .box{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;width:20px;width:var(--pfe-theme--ui--element--size,20px);height:20px;height:var(--pfe-theme--ui--element--size,20px);-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;font-size:1em;border-radius:2px;border-radius:var(--pfe-theme--ui--border-radius,2px);background-color:var(--pfe-health-index--accent);color:var(--pfe-health-index--accent--text)}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host([size=mini]) .box.a{background-color:#3f9c35;color:#fff}:host([size=mini]) .box.b{background-color:#92d400;color:#fff}:host([size=mini]) .box.c{background-color:#efaa00;color:#fff}:host([size=mini]) .box.d{background-color:#ec7a08;color:#fff}:host([size=mini]) .box.e{background-color:#c00;color:#fff}:host([size=mini]) .box.f{background-color:#523333;color:#fff}}:host([size=lg]) .box{background-color:#fff;background-color:var(--pfe-theme--color--surface--lightest,#fff);color:#6a6e73;color:var(--pfe-theme--color--ui-disabled--text,#6a6e73);border-top:calc(1px * 2) solid #f5f5f5;border-top:calc(var(--pfe-theme--ui--border-width,1px) * 2) var(--pfe-theme--ui--border-style,solid) var(--pfe-theme--color--surface--border--lightest,#f5f5f5)}:host([size=lg]) .box:first-child{margin-left:0;border-left:calc(1px * 2) solid #f5f5f5;border-left:calc(var(--pfe-theme--ui--border-width,1px) * 2) var(--pfe-theme--ui--border-style,solid) var(--pfe-theme--color--surface--border--lightest,#f5f5f5)}:host([size=lg]) .box.active:first-child{border-left:none}:host([size=lg]) .box:last-child{margin-right:0;border-right:calc(1px * 2) solid #f5f5f5;border-right:calc(var(--pfe-theme--ui--border-width,1px) * 2) var(--pfe-theme--ui--border-style,solid) var(--pfe-theme--color--surface--border--lightest,#f5f5f5)}:host([size=lg]) .box.active:last-child{border-right:0}:host([size=lg]) .box>.bottom{height:.5em;margin:0 .5px}:host([size=lg]) .box .grade{padding:6px calc(20px / 2);padding:6px calc(var(--pfe-theme--ui--element--size,20px)/ 2)}:host([size=lg]) .box.active .grade{margin:calc(1px * -2) .5px 0 .5px;margin:calc(var(--pfe-theme--ui--border-width,1px) * -2) .5px 0 .5px;padding-top:.5em}:host([size=lg]) .box.active .grade,:host([size=lg]) .box>.bottom{background-color:var(--pfe-health-index--accent);color:var(--pfe-health-index--accent--text)}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host([size=lg]) .box.a>.bottom,:host([size=lg]) .box.active.a .grade{background-color:#3f9c35;color:#fff}:host([size=lg]) .box.active.b .grade,:host([size=lg]) .box.b>.bottom{background-color:#92d400;color:#fff}:host([size=lg]) .box.active.c .grade,:host([size=lg]) .box.c>.bottom{background-color:#efaa00;color:#fff}:host([size=lg]) .box.active.d .grade,:host([size=lg]) .box.d>.bottom{background-color:#ec7a08;color:#fff}:host([size=lg]) .box.active.e .grade,:host([size=lg]) .box.e>.bottom{background-color:#c00;color:#fff}:host([size=lg]) .box.active.f .grade,:host([size=lg]) .box.f>.bottom{background-color:#523333;color:#fff}}:host(:not([size=mini])) .box-container{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}:host(:not([size=lg]):not([size=mini])) .box-container{border:1px solid #d2d2d2;border:var(--pfe-theme--ui--border-width,1px) var(--pfe-theme--ui--border-style,solid) var(--pfe-theme--color--surface--border,#d2d2d2);margin-left:calc(16px * .5);margin-left:calc(var(--pfe-theme--container-spacer,16px) * .5)}:host([size=mini],[size=lg]) .box-container{border:none}:host([size=mini]) .box-container{margin:0}:host([size=lg]) .box-container{margin-left:0}\n/*# sourceMappingURL=pfe-health-index.min.css.map */\n"+("lg"!==this.props.size.value?"\n "+("mini"===this.props.size.value?'\n
    \n
    \n
    \n
    \n
    \n ':'\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n ')+"\n":'\n
    \n
    \n
    A
    \n
    \n
    \n
    \n
    B
    \n
    \n
    \n
    \n
    C
    \n
    \n
    \n
    \n
    D
    \n
    \n
    \n
    \n
    E
    \n
    \n
    \n
    \n
    F
    \n
    \n
    \n
    \n')}},{key:"schemaUrl",get:function(){return"pfe-health-index.json"}},{key:"templateUrl",get:function(){return"pfe-health-index.html"}},{key:"styleUrl",get:function(){return"pfe-health-index.scss"}}],[{key:"version",get:function(){return"1.0.0-prerelease.54"}},{key:"properties",get:function(){return{"health-index":{title:"Health Index",type:"string",enum:["A","B","C","D","E","F"],default:"A",prefixed:!1},size:{title:"Size",type:"string",enum:["mini","lg"],default:null,prefixed:!1}}}},{key:"slots",get:function(){return{}}},{key:"tag",get:function(){return"pfe-health-index"}},{key:"observedAttributes",get:function(){return["health-index","size"]}}]),t(a,[{key:"attributeChangedCallback",value:function(e,t,o){switch(function e(t,o,i){null===t&&(t=Function.prototype);var r=Object.getOwnPropertyDescriptor(t,o);if(void 0===r){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,o,i)}if("value"in r)return r.value;var n=r.get;return void 0!==n?n.call(i):void 0}(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"attributeChangedCallback",this).call(this,e,t,o),e){case"size":this.props.size.value=o,this.render(),this.updateHealthIndex(this.getAttribute("health-index"),t);break;case"health-index":this.props.size.value=this.getAttribute("size"),this.render(),this.updateHealthIndex(o)}}},{key:"updateHealthIndex",value:function(e,t){var o=e.toLowerCase(),i=e.toUpperCase(),r=[].concat(function(e){if(Array.isArray(e)){for(var t=0,o=Array(e.length);t@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host{color:#151515!important}}:host([on=dark]){--pfe-broadcasted--text:var(--pfe-theme--color--text--on-dark, #fff);--pfe-broadcasted--link:var(--pfe-theme--color--link--on-dark, #73bcf7);--pfe-broadcasted--link--hover:var(--pfe-theme--color--link--hover--on-dark, #bee1f4);--pfe-broadcasted--link--focus:var(--pfe-theme--color--link--focus--on-dark, #bee1f4);--pfe-broadcasted--link--visited:var(--pfe-theme--color--link--visited--on-dark, #bee1f4);--pfe-broadcasted--link-decoration:var(--pfe-theme--link-decoration--on-dark, none);--pfe-broadcasted--link-decoration--hover:var(--pfe-theme--link-decoration--hover--on-dark, underline);--pfe-broadcasted--link-decoration--focus:var(--pfe-theme--link-decoration--focus--on-dark, underline);--pfe-broadcasted--link-decoration--visited:var(--pfe-theme--link-decoration--visited--on-dark, none)}:host([on=saturated]){--pfe-broadcasted--text:var(--pfe-theme--color--text--on-saturated, #fff);--pfe-broadcasted--link:var(--pfe-theme--color--link--on-saturated, #fff);--pfe-broadcasted--link--hover:var(--pfe-theme--color--link--hover--on-saturated, #fafafa);--pfe-broadcasted--link--focus:var(--pfe-theme--color--link--focus--on-saturated, #fafafa);--pfe-broadcasted--link--visited:var(--pfe-theme--color--link--visited--on-saturated, #8476d1);--pfe-broadcasted--link-decoration:var(--pfe-theme--link-decoration--on-saturated, underline);--pfe-broadcasted--link-decoration--hover:var(--pfe-theme--link-decoration--hover--on-saturated, underline);--pfe-broadcasted--link-decoration--focus:var(--pfe-theme--link-decoration--focus--on-saturated, underline);--pfe-broadcasted--link-decoration--visited:var(--pfe-theme--link-decoration--visited--on-saturated, underline)}:host([on=light]){--pfe-broadcasted--text:var(--pfe-theme--color--text, #151515);--pfe-broadcasted--link:var(--pfe-theme--color--link, #06c);--pfe-broadcasted--link--hover:var(--pfe-theme--color--link--hover, #004080);--pfe-broadcasted--link--focus:var(--pfe-theme--color--link--focus, #004080);--pfe-broadcasted--link--visited:var(--pfe-theme--color--link--visited, #6753ac);--pfe-broadcasted--link-decoration:var(--pfe-theme--link-decoration, none);--pfe-broadcasted--link-decoration--hover:var(--pfe-theme--link-decoration--hover, underline);--pfe-broadcasted--link-decoration--focus:var(--pfe-theme--link-decoration--focus, underline);--pfe-broadcasted--link-decoration--visited:var(--pfe-theme--link-decoration--visited, none)}:host{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center}:host([hidden]){display:none}.box.a{--pfe-health-index--accent:#3f9c35;--pfe-health-index--accent--text:var(--pfe-theme--color--text--on-dark, #fff)}.box.b{--pfe-health-index--accent:#92d400;--pfe-health-index--accent--text:var(--pfe-theme--color--text--on-dark, #fff)}.box.c{--pfe-health-index--accent:#efaa00;--pfe-health-index--accent--text:var(--pfe-theme--color--text--on-dark, #fff)}.box.d{--pfe-health-index--accent:#ec7a08;--pfe-health-index--accent--text:var(--pfe-theme--color--text--on-dark, #fff)}.box.e{--pfe-health-index--accent:#cc0000;--pfe-health-index--accent--text:var(--pfe-theme--color--text--on-dark, #fff)}.box.f{--pfe-health-index--accent:#523333;--pfe-health-index--accent--text:var(--pfe-theme--color--text--on-dark, #fff)}:host(:not([size=lg]):not([size=mini])) .box{background-color:#fff;background-color:var(--pfe-theme--color--surface--lightest,#fff);width:calc(20px / 2);width:calc(var(--pfe-theme--ui--element--size,20px)/ 2);height:20px;height:var(--pfe-theme--ui--element--size,20px);border-right:1px solid #d2d2d2;border-right:var(--pfe-theme--ui--border-width,1px) var(--pfe-theme--ui--border-style,solid) var(--pfe-theme--color--surface--border,#d2d2d2)}:host(:not([size=lg]):not([size=mini])) .box:last-child{border-right:0}:host(:not([size=lg]):not([size=mini])) .box.active{background-color:var(--pfe-health-index--accent)}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host(:not([size=lg]):not([size=mini])) .box.active.a{background-color:#3f9c35}:host(:not([size=lg]):not([size=mini])) .box.active.b{background-color:#92d400}:host(:not([size=lg]):not([size=mini])) .box.active.c{background-color:#efaa00}:host(:not([size=lg]):not([size=mini])) .box.active.d{background-color:#ec7a08}:host(:not([size=lg]):not([size=mini])) .box.active.e{background-color:#c00}:host(:not([size=lg]):not([size=mini])) .box.active.f{background-color:#523333}}:host([size=mini]) .box{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;width:20px;width:var(--pfe-theme--ui--element--size,20px);height:20px;height:var(--pfe-theme--ui--element--size,20px);-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;font-size:1em;border-radius:2px;border-radius:var(--pfe-theme--ui--border-radius,2px);background-color:var(--pfe-health-index--accent);color:var(--pfe-health-index--accent--text)}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host([size=mini]) .box.a{background-color:#3f9c35;color:#fff}:host([size=mini]) .box.b{background-color:#92d400;color:#fff}:host([size=mini]) .box.c{background-color:#efaa00;color:#fff}:host([size=mini]) .box.d{background-color:#ec7a08;color:#fff}:host([size=mini]) .box.e{background-color:#c00;color:#fff}:host([size=mini]) .box.f{background-color:#523333;color:#fff}}:host([size=lg]) .box{background-color:#fff;background-color:var(--pfe-theme--color--surface--lightest,#fff);color:#6a6e73;color:var(--pfe-theme--color--ui-disabled--text,#6a6e73);border-top:calc(1px * 2) solid #f5f5f5;border-top:calc(var(--pfe-theme--ui--border-width,1px) * 2) var(--pfe-theme--ui--border-style,solid) var(--pfe-theme--color--surface--border--lightest,#f5f5f5)}:host([size=lg]) .box:first-child{margin-left:0;border-left:calc(1px * 2) solid #f5f5f5;border-left:calc(var(--pfe-theme--ui--border-width,1px) * 2) var(--pfe-theme--ui--border-style,solid) var(--pfe-theme--color--surface--border--lightest,#f5f5f5)}:host([size=lg]) .box.active:first-child{border-left:none}:host([size=lg]) .box:last-child{margin-right:0;border-right:calc(1px * 2) solid #f5f5f5;border-right:calc(var(--pfe-theme--ui--border-width,1px) * 2) var(--pfe-theme--ui--border-style,solid) var(--pfe-theme--color--surface--border--lightest,#f5f5f5)}:host([size=lg]) .box.active:last-child{border-right:0}:host([size=lg]) .box>.bottom{height:.5em;margin:0 .5px}:host([size=lg]) .box .grade{padding:6px calc(20px / 2);padding:6px calc(var(--pfe-theme--ui--element--size,20px)/ 2)}:host([size=lg]) .box.active .grade{margin:calc(1px * -2) .5px 0 .5px;margin:calc(var(--pfe-theme--ui--border-width,1px) * -2) .5px 0 .5px;padding-top:.5em}:host([size=lg]) .box.active .grade,:host([size=lg]) .box>.bottom{background-color:var(--pfe-health-index--accent);color:var(--pfe-health-index--accent--text)}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host([size=lg]) .box.a>.bottom,:host([size=lg]) .box.active.a .grade{background-color:#3f9c35;color:#fff}:host([size=lg]) .box.active.b .grade,:host([size=lg]) .box.b>.bottom{background-color:#92d400;color:#fff}:host([size=lg]) .box.active.c .grade,:host([size=lg]) .box.c>.bottom{background-color:#efaa00;color:#fff}:host([size=lg]) .box.active.d .grade,:host([size=lg]) .box.d>.bottom{background-color:#ec7a08;color:#fff}:host([size=lg]) .box.active.e .grade,:host([size=lg]) .box.e>.bottom{background-color:#c00;color:#fff}:host([size=lg]) .box.active.f .grade,:host([size=lg]) .box.f>.bottom{background-color:#523333;color:#fff}}:host(:not([size=mini])) .box-container{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}:host(:not([size=lg]):not([size=mini])) .box-container{border:1px solid #d2d2d2;border:var(--pfe-theme--ui--border-width,1px) var(--pfe-theme--ui--border-style,solid) var(--pfe-theme--color--surface--border,#d2d2d2);margin-left:calc(16px * .5);margin-left:calc(var(--pfe-theme--container-spacer,16px) * .5)}:host([size=mini],[size=lg]) .box-container{border:none}:host([size=mini]) .box-container{margin:0}:host([size=lg]) .box-container{margin-left:0}\n/*# sourceMappingURL=pfe-health-index.min.css.map */\n${this.props.size.value !== \"lg\" ? `\n ${this.props.size.value === \"mini\" ? `\n
    \n
    \n
    \n
    \n
    \n ` : `\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n `}\n` : `\n
    \n
    \n
    A
    \n
    \n
    \n
    \n
    B
    \n
    \n
    \n
    \n
    C
    \n
    \n
    \n
    \n
    D
    \n
    \n
    \n
    \n
    E
    \n
    \n
    \n
    \n
    F
    \n
    \n
    \n
    \n`}`;\n }\n\n static get properties() {\n return {\"health-index\":{\"title\":\"Health Index\",\"type\":\"string\",\"enum\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"F\"],\"default\":\"A\",\"prefixed\":false},\"size\":{\"title\":\"Size\",\"type\":\"string\",\"enum\":[\"mini\",\"lg\"],\"default\":null,\"prefixed\":false}};\n }\n\n static get slots() {\n return {};\n }\n static get tag() {\n return \"pfe-health-index\";\n }\n\n get schemaUrl() {\n return \"pfe-health-index.json\";\n }\n\n get templateUrl() {\n return \"pfe-health-index.html\";\n }\n\n get styleUrl() {\n return \"pfe-health-index.scss\";\n }\n\n static get observedAttributes() {\n return [\"health-index\", \"size\"];\n }\n\n constructor() {\n super(PfeHealthIndex, { delayRender: true });\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n super.attributeChangedCallback(attr, oldValue, newValue);\n\n switch (attr) {\n case \"size\":\n this.props.size.value = newValue;\n this.render();\n this.updateHealthIndex(this.getAttribute(\"health-index\"), oldValue);\n break;\n case \"health-index\":\n this.props.size.value = this.getAttribute(\"size\");\n this.render();\n this.updateHealthIndex(newValue);\n break;\n default:\n break;\n }\n }\n\n updateHealthIndex(grade, oldValue) {\n const healthIndex = grade.toLowerCase();\n const healthIndexUpperCase = grade.toUpperCase();\n const boxes = [...this.shadowRoot.querySelectorAll(\".box\")];\n this.innerHTML = healthIndexUpperCase;\n\n if (this.props.size.value === \"mini\") {\n this.shadowRoot.querySelector(\".box\").classList.remove(oldValue);\n this.shadowRoot.querySelector(\".box\").classList.add(healthIndex);\n }\n\n boxes.forEach(box => {\n if (box.classList.contains(healthIndex)) {\n box.classList.add(\"active\");\n } else {\n box.classList.remove(\"active\");\n }\n });\n\n if (this.props.size.value !== \"lg\") {\n this.shadowRoot.querySelector(\n \"#healthIndex\"\n ).innerText = healthIndexUpperCase;\n }\n\n if (!this.shadowRoot.querySelector(\".box.active\")) {\n console.warn(\n `${PfeHealthIndex.tag}: a valid health-index was not provided. Please use A, B, C, D, E, or F`\n );\n }\n }\n}\n\nPFElement.create(PfeHealthIndex);\n\nexport default PfeHealthIndex;\n"],"names":["PfeHealthIndex","PFElement","this","props","size","value","health-index","title","type","enum","default","prefixed","attr","oldValue","newValue","render","updateHealthIndex","getAttribute","grade","healthIndex","toLowerCase","healthIndexUpperCase","toUpperCase","boxes","shadowRoot","querySelectorAll","innerHTML","querySelector","classList","remove","add","forEach","box","contains","innerText","warn","tag","delayRender","create"],"mappings":"+iBA2BMA,+TAAuBC,82QAQO,OAA1BC,KAAKC,MAAMC,KAAKC,cACI,SAA1BH,KAAKC,MAAMC,KAAKC,glCA2DT,kEAIA,+DAIA,gEA1EA,+DAuDA,CAACC,eAAe,CAACC,MAAQ,eAAeC,KAAO,SAASC,KAAO,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,KAAKC,QAAU,IAAIC,UAAW,GAAOP,KAAO,CAACG,MAAQ,OAAOC,KAAO,SAASC,KAAO,CAAC,OAAO,MAAMC,QAAU,KAAKC,UAAW,wCAI/M,qCAGA,oEAgBA,CAAC,eAAgB,gEAODC,EAAMC,EAAUC,yWACRF,EAAMC,EAAUC,GAEvCF,OACD,YACET,MAAMC,KAAKC,MAAQS,OACnBC,cACAC,kBAAkBd,KAAKe,aAAa,gBAAiBJ,aAEvD,oBACEV,MAAMC,KAAKC,MAAQH,KAAKe,aAAa,aACrCF,cACAC,kBAAkBF,8CAOXI,EAAOL,OACjBM,EAAcD,EAAME,cACpBC,EAAuBH,EAAMI,cAC7BC,mIAAYrB,KAAKsB,WAAWC,iBAAiB,eAC9CC,UAAYL,EAEa,SAA1BnB,KAAKC,MAAMC,KAAKC,aACbmB,WAAWG,cAAc,QAAQC,UAAUC,OAAOhB,QAClDW,WAAWG,cAAc,QAAQC,UAAUE,IAAIX,MAGhDY,QAAQ,YACRC,EAAIJ,UAAUK,SAASd,KACrBS,UAAUE,IAAI,YAEdF,UAAUC,OAAO,YAIK,OAA1B3B,KAAKC,MAAMC,KAAKC,aACbmB,WAAWG,cACd,gBACAO,UAAYb,GAGXnB,KAAKsB,WAAWG,cAAc,wBACzBQ,KACHnC,EAAeoC,waAjDhBpC,EAAgB,CAAEqC,aAAa,YAuDzCpC,EAAUqC,OAAOtC"} \ No newline at end of file diff --git a/elements/pfe-health-index/package-lock.json b/elements/pfe-health-index/package-lock.json index 066935d33d..095983804a 100644 --- a/elements/pfe-health-index/package-lock.json +++ b/elements/pfe-health-index/package-lock.json @@ -1,6 +1,6 @@ { "name": "@patternfly/pfe-health-index", - "version": "1.0.0-prerelease.53", + "version": "1.0.0-prerelease.54", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/elements/pfe-health-index/package.json b/elements/pfe-health-index/package.json index 921e1c7ac6..1dde3e09f3 100644 --- a/elements/pfe-health-index/package.json +++ b/elements/pfe-health-index/package.json @@ -4,7 +4,7 @@ "className": "PfeHealthIndex", "elementName": "pfe-health-index" }, - "version": "1.0.0-prerelease.53", + "version": "1.0.0-prerelease.54", "publishConfig": { "access": "public" }, @@ -42,7 +42,7 @@ "@patternfly/pfelement": "^1.0.0-prerelease.51" }, "devDependencies": { - "@patternfly/pfe-sass": "^1.0.0-prerelease.53" + "@patternfly/pfe-sass": "^1.0.0-prerelease.54" }, "generator-pfelement-version": "0.6.3", "bugs": { diff --git a/elements/pfe-icon-panel/dist/pfe-icon-panel.js b/elements/pfe-icon-panel/dist/pfe-icon-panel.js new file mode 100644 index 0000000000..f9602fc903 --- /dev/null +++ b/elements/pfe-icon-panel/dist/pfe-icon-panel.js @@ -0,0 +1,88 @@ +import PFElement from '../../pfelement/dist/pfelement.js'; +import '../../pfe-icon/dist/pfe-icon.js'; + +/*! + * PatternFly Elements: PfeIconPanel 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * +*/ + +class PfeIconPanel extends PFElement { + static get version() { + return "1.0.0-prerelease.54"; + } + + get html() { + return ` +
    + + + +
    `; + } + + static get properties() { + return {"icon":{"title":"Icon","type":"string","prefixed":false},"color":{"title":"Color","type":"string","enum":["complement","accent","lightest","base","darker","darkest","critical","important","moderate","success","info"],"default":"darker","prefixed":true},"centered":{"title":"Centered","type":"boolean","prefixed":true,"default":false},"stacked":{"title":"Stacked","type":"boolean","prefixed":true,"default":false},"circled":{"title":"Circled","type":"boolean","default":true,"prefixed":true}}; + } + + static get slots() { + return {"header":{"title":"Header","type":"array","namedSlot":true,"items":{"title":"Header item","oneOf":[{"$ref":"raw"}]}},"body":{"title":"Body","type":"array","namedSlot":false,"items":{"title":"Body item","oneOf":[{"$ref":"raw"}]}},"footer":{"title":"Footer","type":"array","namedSlot":true,"maxItems":3,"items":{"title":"Footer item","oneOf":[{"$ref":"raw"}]}}}; + } + static get tag() { + return "pfe-icon-panel"; + } + + get styleUrl() { + return "pfe-icon-panel.scss"; + } + + get templateUrl() { + return "pfe-icon-panel.html"; + } + + get schemaUrl() { + return "pfe-icon-panel.json"; + } + + static get observedAttributes() { + return ["icon", "pfe-circled", "pfe-color", "pfe-stacked", "pfe-centered"]; + } + + static get cascadingAttributes() { + return { + icon: "pfe-icon", + "pfe-circled": "pfe-icon", + "pfe-color": "pfe-icon" + }; + } + + constructor() { + super(PfeIconPanel); + } +} + +PFElement.create(PfeIconPanel); + +export default PfeIconPanel; +//# sourceMappingURL=pfe-icon-panel.js.map diff --git a/elements/pfe-icon-panel/dist/pfe-icon-panel.js.map b/elements/pfe-icon-panel/dist/pfe-icon-panel.js.map new file mode 100644 index 0000000000..e3b783f3a7 --- /dev/null +++ b/elements/pfe-icon-panel/dist/pfe-icon-panel.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-icon-panel.js","sources":["../_temp/pfe-icon-panel.js"],"sourcesContent":["/*!\n * PatternFly Elements: PfeIconPanel 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.js\";\nimport \"../../pfe-icon/dist/pfe-icon.js\";\n\nclass PfeIconPanel extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `\n
    \n \n \n \n
    `;\n }\n\n static get properties() {\n return {\"icon\":{\"title\":\"Icon\",\"type\":\"string\",\"prefixed\":false},\"color\":{\"title\":\"Color\",\"type\":\"string\",\"enum\":[\"complement\",\"accent\",\"lightest\",\"base\",\"darker\",\"darkest\",\"critical\",\"important\",\"moderate\",\"success\",\"info\"],\"default\":\"darker\",\"prefixed\":true},\"centered\":{\"title\":\"Centered\",\"type\":\"boolean\",\"prefixed\":true,\"default\":false},\"stacked\":{\"title\":\"Stacked\",\"type\":\"boolean\",\"prefixed\":true,\"default\":false},\"circled\":{\"title\":\"Circled\",\"type\":\"boolean\",\"default\":true,\"prefixed\":true}};\n }\n\n static get slots() {\n return {\"header\":{\"title\":\"Header\",\"type\":\"array\",\"namedSlot\":true,\"items\":{\"title\":\"Header item\",\"oneOf\":[{\"$ref\":\"raw\"}]}},\"body\":{\"title\":\"Body\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"title\":\"Body item\",\"oneOf\":[{\"$ref\":\"raw\"}]}},\"footer\":{\"title\":\"Footer\",\"type\":\"array\",\"namedSlot\":true,\"maxItems\":3,\"items\":{\"title\":\"Footer item\",\"oneOf\":[{\"$ref\":\"raw\"}]}}};\n }\n static get tag() {\n return \"pfe-icon-panel\";\n }\n\n get styleUrl() {\n return \"pfe-icon-panel.scss\";\n }\n\n get templateUrl() {\n return \"pfe-icon-panel.html\";\n }\n\n get schemaUrl() {\n return \"pfe-icon-panel.json\";\n }\n\n static get observedAttributes() {\n return [\"icon\", \"pfe-circled\", \"pfe-color\", \"pfe-stacked\", \"pfe-centered\"];\n }\n\n static get cascadingAttributes() {\n return {\n icon: \"pfe-icon\",\n \"pfe-circled\": \"pfe-icon\",\n \"pfe-color\": \"pfe-icon\"\n };\n }\n\n constructor() {\n super(PfeIconPanel);\n }\n}\n\nPFElement.create(PfeIconPanel);\n\nexport default PfeIconPanel;\n"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,AAGA;AACA,MAAM,YAAY,SAAS,SAAS,CAAC;EACnC,WAAW,OAAO,GAAG;IACnB,OAAO,qBAAqB,CAAC;GAC9B;;EAED,IAAI,IAAI,GAAG;IACT,OAAO,CAAC;;4BAEgB,EAAE,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,KAAK,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;;;;;MAKlF,CAAC,CAAC;GACL;;EAED,WAAW,UAAU,GAAG;IACtB,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,MAA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AW,GAAG,GAAG;IACf,OAAO,gBAAgB,CAAC;GACzB;;EAED,IAAI,QAAQ,GAAG;IACb,OAAO,qBAAqB,CAAC;GAC9B;;EAED,IAAI,WAAW,GAAG;IAChB,OAAO,qBAAqB,CAAC;GAC9B;;EAED,IAAI,SAAS,GAAG;IACd,OAAO,qBAAqB,CAAC;GAC9B;;EAED,WAAW,kBAAkB,GAAG;IAC9B,OAAO,CAAC,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;GAC5E;;EAED,WAAW,mBAAmB,GAAG;IAC/B,OAAO;MACL,IAAI,EAAE,UAAU;MAChB,aAAa,EAAE,UAAU;MACzB,WAAW,EAAE,UAAU;KACxB,CAAC;GACH;;EAED,WAAW,GAAG;IACZ,KAAK,CAAC,YAAY,CAAC,CAAC;GACrB;CACF;;AAED,SAAS,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;;;;"} \ No newline at end of file diff --git a/elements/pfe-icon-panel/dist/pfe-icon-panel.json b/elements/pfe-icon-panel/dist/pfe-icon-panel.json new file mode 100644 index 0000000000..bb638f127f --- /dev/null +++ b/elements/pfe-icon-panel/dist/pfe-icon-panel.json @@ -0,0 +1,109 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Icon Panel", + "description": "This element creates a header, body, and footer region in which to place content or other components.", + "type": "object", + "tag": "pfe-icon-panel", + "class": "pfe-icon-panel", + "category": "combo", + "properties": { + "slots": { + "title": "Slots", + "description": "Definition of the supported slots", + "type": "object", + "properties": { + "header": { + "title": "Header", + "type": "array", + "namedSlot": true, + "items": { + "title": "Header item", + "oneOf": [ + { + "$ref": "raw" + } + ] + } + }, + "body": { + "title": "Body", + "type": "array", + "namedSlot": false, + "items": { + "title": "Body item", + "oneOf": [ + { + "$ref": "raw" + } + ] + } + }, + "footer": { + "title": "Footer", + "type": "array", + "namedSlot": true, + "maxItems": 3, + "items": { + "title": "Footer item", + "oneOf": [ + { + "$ref": "raw" + } + ] + } + } + } + }, + "attributes": { + "title": "Attributes", + "type": "object", + "properties": { + "icon": { + "title": "Icon", + "type": "string", + "prefixed": false + }, + "color": { + "title": "Color", + "type": "string", + "enum": [ + "complement", + "accent", + "lightest", + "base", + "darker", + "darkest", + "critical", + "important", + "moderate", + "success", + "info" + ], + "default": "darker", + "prefixed": true + }, + "centered": { + "title": "Centered", + "type": "boolean", + "prefixed": true, + "default": false + }, + "stacked": { + "title": "Stacked", + "type": "boolean", + "prefixed": true, + "default": false + }, + "circled": { + "title": "Circled", + "type": "boolean", + "default": true, + "prefixed": true + } + }, + "required": ["icon"] + } + }, + "required": ["slots", "attributes"], + "additionalProperties": false +} diff --git a/elements/pfe-icon-panel/dist/pfe-icon-panel.min.js b/elements/pfe-icon-panel/dist/pfe-icon-panel.min.js new file mode 100644 index 0000000000..9091da2be1 --- /dev/null +++ b/elements/pfe-icon-panel/dist/pfe-icon-panel.min.js @@ -0,0 +1,26 @@ +import e from"../../pfelement/dist/pfelement.min.js";import"../../pfe-icon/dist/pfe-icon.min.js"; +/*! + * PatternFly Elements: PfeIconPanel 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * +*/class t extends e{static get version(){return"1.0.0-prerelease.54"}get html(){return`\n
    \n \n \n \n
    `}static get properties(){return{icon:{title:"Icon",type:"string",prefixed:!1},color:{title:"Color",type:"string",enum:["complement","accent","lightest","base","darker","darkest","critical","important","moderate","success","info"],default:"darker",prefixed:!0},centered:{title:"Centered",type:"boolean",prefixed:!0,default:!1},stacked:{title:"Stacked",type:"boolean",prefixed:!0,default:!1},circled:{title:"Circled",type:"boolean",default:!0,prefixed:!0}}}static get slots(){return{header:{title:"Header",type:"array",namedSlot:!0,items:{title:"Header item",oneOf:[{$ref:"raw"}]}},body:{title:"Body",type:"array",namedSlot:!1,items:{title:"Body item",oneOf:[{$ref:"raw"}]}},footer:{title:"Footer",type:"array",namedSlot:!0,maxItems:3,items:{title:"Footer item",oneOf:[{$ref:"raw"}]}}}}static get tag(){return"pfe-icon-panel"}get styleUrl(){return"pfe-icon-panel.scss"}get templateUrl(){return"pfe-icon-panel.html"}get schemaUrl(){return"pfe-icon-panel.json"}static get observedAttributes(){return["icon","pfe-circled","pfe-color","pfe-stacked","pfe-centered"]}static get cascadingAttributes(){return{icon:"pfe-icon","pfe-circled":"pfe-icon","pfe-color":"pfe-icon"}}constructor(){super(t)}}e.create(t);export default t; +//# sourceMappingURL=pfe-icon-panel.min.js.map diff --git a/elements/pfe-icon-panel/dist/pfe-icon-panel.min.js.map b/elements/pfe-icon-panel/dist/pfe-icon-panel.min.js.map new file mode 100644 index 0000000000..1dcc1c7699 --- /dev/null +++ b/elements/pfe-icon-panel/dist/pfe-icon-panel.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-icon-panel.min.js","sources":["../_temp/pfe-icon-panel.js"],"sourcesContent":["/*!\n * PatternFly Elements: PfeIconPanel 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.js\";\nimport \"../../pfe-icon/dist/pfe-icon.js\";\n\nclass PfeIconPanel extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `\n
    \n \n \n \n
    `;\n }\n\n static get properties() {\n return {\"icon\":{\"title\":\"Icon\",\"type\":\"string\",\"prefixed\":false},\"color\":{\"title\":\"Color\",\"type\":\"string\",\"enum\":[\"complement\",\"accent\",\"lightest\",\"base\",\"darker\",\"darkest\",\"critical\",\"important\",\"moderate\",\"success\",\"info\"],\"default\":\"darker\",\"prefixed\":true},\"centered\":{\"title\":\"Centered\",\"type\":\"boolean\",\"prefixed\":true,\"default\":false},\"stacked\":{\"title\":\"Stacked\",\"type\":\"boolean\",\"prefixed\":true,\"default\":false},\"circled\":{\"title\":\"Circled\",\"type\":\"boolean\",\"default\":true,\"prefixed\":true}};\n }\n\n static get slots() {\n return {\"header\":{\"title\":\"Header\",\"type\":\"array\",\"namedSlot\":true,\"items\":{\"title\":\"Header item\",\"oneOf\":[{\"$ref\":\"raw\"}]}},\"body\":{\"title\":\"Body\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"title\":\"Body item\",\"oneOf\":[{\"$ref\":\"raw\"}]}},\"footer\":{\"title\":\"Footer\",\"type\":\"array\",\"namedSlot\":true,\"maxItems\":3,\"items\":{\"title\":\"Footer item\",\"oneOf\":[{\"$ref\":\"raw\"}]}}};\n }\n static get tag() {\n return \"pfe-icon-panel\";\n }\n\n get styleUrl() {\n return \"pfe-icon-panel.scss\";\n }\n\n get templateUrl() {\n return \"pfe-icon-panel.html\";\n }\n\n get schemaUrl() {\n return \"pfe-icon-panel.json\";\n }\n\n static get observedAttributes() {\n return [\"icon\", \"pfe-circled\", \"pfe-color\", \"pfe-stacked\", \"pfe-centered\"];\n }\n\n static get cascadingAttributes() {\n return {\n icon: \"pfe-icon\",\n \"pfe-circled\": \"pfe-icon\",\n \"pfe-color\": \"pfe-icon\"\n };\n }\n\n constructor() {\n super(PfeIconPanel);\n }\n}\n\nPFElement.create(PfeIconPanel);\n\nexport default PfeIconPanel;\n"],"names":["PfeIconPanel","PFElement","version","html","this","getAttribute","properties","icon","title","type","prefixed","color","enum","default","centered","stacked","circled","slots","header","namedSlot","items","oneOf","$ref","body","footer","maxItems","tag","styleUrl","templateUrl","schemaUrl","observedAttributes","cascadingAttributes","pfe-circled","pfe-color","[object Object]","super","create"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;EA4BA,MAAMA,UAAqBC,EACzBC,qBACE,MAAO,sBAGTC,WACE,y+CAE+D,SAArCC,KAAKC,aAAa,eAA4B,KAAO,6QAQjFC,wBACE,MAAO,CAACC,KAAO,CAACC,MAAQ,OAAOC,KAAO,SAASC,UAAW,GAAOC,MAAQ,CAACH,MAAQ,QAAQC,KAAO,SAASG,KAAO,CAAC,aAAa,SAAS,WAAW,OAAO,SAAS,UAAU,WAAW,YAAY,WAAW,UAAU,QAAQC,QAAU,SAASH,UAAW,GAAMI,SAAW,CAACN,MAAQ,WAAWC,KAAO,UAAUC,UAAW,EAAKG,SAAU,GAAOE,QAAU,CAACP,MAAQ,UAAUC,KAAO,UAAUC,UAAW,EAAKG,SAAU,GAAOG,QAAU,CAACR,MAAQ,UAAUC,KAAO,UAAUI,SAAU,EAAKH,UAAW,IAG/eO,mBACE,MAAO,CAACC,OAAS,CAACV,MAAQ,SAASC,KAAO,QAAQU,WAAY,EAAKC,MAAQ,CAACZ,MAAQ,cAAca,MAAQ,CAAC,CAACC,KAAO,UAAUC,KAAO,CAACf,MAAQ,OAAOC,KAAO,QAAQU,WAAY,EAAMC,MAAQ,CAACZ,MAAQ,YAAYa,MAAQ,CAAC,CAACC,KAAO,UAAUE,OAAS,CAAChB,MAAQ,SAASC,KAAO,QAAQU,WAAY,EAAKM,SAAW,EAAEL,MAAQ,CAACZ,MAAQ,cAAca,MAAQ,CAAC,CAACC,KAAO,WAEvWI,iBACE,MAAO,iBAGTC,eACE,MAAO,sBAGTC,kBACE,MAAO,sBAGTC,gBACE,MAAO,sBAGTC,gCACE,MAAO,CAAC,OAAQ,cAAe,YAAa,cAAe,gBAG7DC,iCACE,MAAO,CACLxB,KAAM,WACNyB,cAAe,WACfC,YAAa,YAIjBC,cACEC,MAAMnC,IAIVC,EAAUmC,OAAOpC"} \ No newline at end of file diff --git a/elements/pfe-icon-panel/dist/pfe-icon-panel.umd.js b/elements/pfe-icon-panel/dist/pfe-icon-panel.umd.js new file mode 100644 index 0000000000..7993295891 --- /dev/null +++ b/elements/pfe-icon-panel/dist/pfe-icon-panel.umd.js @@ -0,0 +1,153 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../../pfelement/dist/pfelement.umd'), require('../../pfe-icon/dist/pfe-icon.umd')) : + typeof define === 'function' && define.amd ? define(['../../pfelement/dist/pfelement.umd', '../../pfe-icon/dist/pfe-icon.umd'], factory) : + (global.PfeIconPanel = factory(global.PFElement)); +}(this, (function (PFElement) { 'use strict'; + + PFElement = PFElement && PFElement.hasOwnProperty('default') ? PFElement['default'] : PFElement; + + var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + }; + + var createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + }(); + + var inherits = function (subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + }; + + var possibleConstructorReturn = function (self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && (typeof call === "object" || typeof call === "function") ? call : self; + }; + + /*! + * PatternFly Elements: PfeIconPanel 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + + var PfeIconPanel = function (_PFElement) { + inherits(PfeIconPanel, _PFElement); + createClass(PfeIconPanel, [{ + key: "html", + get: function get$$1() { + return "\n
    \n \n \n \n
    "; + } + }, { + key: "styleUrl", + get: function get$$1() { + return "pfe-icon-panel.scss"; + } + }, { + key: "templateUrl", + get: function get$$1() { + return "pfe-icon-panel.html"; + } + }, { + key: "schemaUrl", + get: function get$$1() { + return "pfe-icon-panel.json"; + } + }], [{ + key: "version", + get: function get$$1() { + return "1.0.0-prerelease.54"; + } + }, { + key: "properties", + get: function get$$1() { + return { "icon": { "title": "Icon", "type": "string", "prefixed": false }, "color": { "title": "Color", "type": "string", "enum": ["complement", "accent", "lightest", "base", "darker", "darkest", "critical", "important", "moderate", "success", "info"], "default": "darker", "prefixed": true }, "centered": { "title": "Centered", "type": "boolean", "prefixed": true, "default": false }, "stacked": { "title": "Stacked", "type": "boolean", "prefixed": true, "default": false }, "circled": { "title": "Circled", "type": "boolean", "default": true, "prefixed": true } }; + } + }, { + key: "slots", + get: function get$$1() { + return { "header": { "title": "Header", "type": "array", "namedSlot": true, "items": { "title": "Header item", "oneOf": [{ "$ref": "raw" }] } }, "body": { "title": "Body", "type": "array", "namedSlot": false, "items": { "title": "Body item", "oneOf": [{ "$ref": "raw" }] } }, "footer": { "title": "Footer", "type": "array", "namedSlot": true, "maxItems": 3, "items": { "title": "Footer item", "oneOf": [{ "$ref": "raw" }] } } }; + } + }, { + key: "tag", + get: function get$$1() { + return "pfe-icon-panel"; + } + }, { + key: "observedAttributes", + get: function get$$1() { + return ["icon", "pfe-circled", "pfe-color", "pfe-stacked", "pfe-centered"]; + } + }, { + key: "cascadingAttributes", + get: function get$$1() { + return { + icon: "pfe-icon", + "pfe-circled": "pfe-icon", + "pfe-color": "pfe-icon" + }; + } + }]); + + function PfeIconPanel() { + classCallCheck(this, PfeIconPanel); + return possibleConstructorReturn(this, (PfeIconPanel.__proto__ || Object.getPrototypeOf(PfeIconPanel)).call(this, PfeIconPanel)); + } + + return PfeIconPanel; + }(PFElement); + + PFElement.create(PfeIconPanel); + + return PfeIconPanel; + +}))); +//# sourceMappingURL=pfe-icon-panel.umd.js.map diff --git a/elements/pfe-icon-panel/dist/pfe-icon-panel.umd.js.map b/elements/pfe-icon-panel/dist/pfe-icon-panel.umd.js.map new file mode 100644 index 0000000000..86190c8166 --- /dev/null +++ b/elements/pfe-icon-panel/dist/pfe-icon-panel.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-icon-panel.umd.js","sources":["../_temp/pfe-icon-panel.umd.js"],"sourcesContent":["/*!\n * PatternFly Elements: PfeIconPanel 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.umd\";\nimport \"../../pfe-icon/dist/pfe-icon.umd\";\n\nclass PfeIconPanel extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `\n
    \n \n \n \n
    `;\n }\n\n static get properties() {\n return {\"icon\":{\"title\":\"Icon\",\"type\":\"string\",\"prefixed\":false},\"color\":{\"title\":\"Color\",\"type\":\"string\",\"enum\":[\"complement\",\"accent\",\"lightest\",\"base\",\"darker\",\"darkest\",\"critical\",\"important\",\"moderate\",\"success\",\"info\"],\"default\":\"darker\",\"prefixed\":true},\"centered\":{\"title\":\"Centered\",\"type\":\"boolean\",\"prefixed\":true,\"default\":false},\"stacked\":{\"title\":\"Stacked\",\"type\":\"boolean\",\"prefixed\":true,\"default\":false},\"circled\":{\"title\":\"Circled\",\"type\":\"boolean\",\"default\":true,\"prefixed\":true}};\n }\n\n static get slots() {\n return {\"header\":{\"title\":\"Header\",\"type\":\"array\",\"namedSlot\":true,\"items\":{\"title\":\"Header item\",\"oneOf\":[{\"$ref\":\"raw\"}]}},\"body\":{\"title\":\"Body\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"title\":\"Body item\",\"oneOf\":[{\"$ref\":\"raw\"}]}},\"footer\":{\"title\":\"Footer\",\"type\":\"array\",\"namedSlot\":true,\"maxItems\":3,\"items\":{\"title\":\"Footer item\",\"oneOf\":[{\"$ref\":\"raw\"}]}}};\n }\n static get tag() {\n return \"pfe-icon-panel\";\n }\n\n get styleUrl() {\n return \"pfe-icon-panel.scss\";\n }\n\n get templateUrl() {\n return \"pfe-icon-panel.html\";\n }\n\n get schemaUrl() {\n return \"pfe-icon-panel.json\";\n }\n\n static get observedAttributes() {\n return [\"icon\", \"pfe-circled\", \"pfe-color\", \"pfe-stacked\", \"pfe-centered\"];\n }\n\n static get cascadingAttributes() {\n return {\n icon: \"pfe-icon\",\n \"pfe-circled\": \"pfe-icon\",\n \"pfe-color\": \"pfe-icon\"\n };\n }\n\n constructor() {\n super(PfeIconPanel);\n }\n}\n\nPFElement.create(PfeIconPanel);\n\nexport default PfeIconPanel;\n"],"names":["PfeIconPanel","getAttribute","icon","PFElement","create"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;MA4BMA;;;;6BAKO;EACT,o/CAE0B,KAAKC,YAAL,CAAkB,aAAlB,MAAqC,MAArC,GAA8C,IAA9C,GAAqD,IAF/E;EAQD;;;6BAac;EACb,aAAO,qBAAP;EACD;;;6BAEiB;EAChB,aAAO,qBAAP;EACD;;;6BAEe;EACd,aAAO,qBAAP;EACD;;;6BApCoB;EACnB,aAAO,qBAAP;EACD;;;6BAauB;EACtB,aAAO,EAAC,QAAO,EAAC,SAAQ,MAAT,EAAgB,QAAO,QAAvB,EAAgC,YAAW,KAA3C,EAAR,EAA0D,SAAQ,EAAC,SAAQ,OAAT,EAAiB,QAAO,QAAxB,EAAiC,QAAO,CAAC,YAAD,EAAc,QAAd,EAAuB,UAAvB,EAAkC,MAAlC,EAAyC,QAAzC,EAAkD,SAAlD,EAA4D,UAA5D,EAAuE,WAAvE,EAAmF,UAAnF,EAA8F,SAA9F,EAAwG,MAAxG,CAAxC,EAAwJ,WAAU,QAAlK,EAA2K,YAAW,IAAtL,EAAlE,EAA8P,YAAW,EAAC,SAAQ,UAAT,EAAoB,QAAO,SAA3B,EAAqC,YAAW,IAAhD,EAAqD,WAAU,KAA/D,EAAzQ,EAA+U,WAAU,EAAC,SAAQ,SAAT,EAAmB,QAAO,SAA1B,EAAoC,YAAW,IAA/C,EAAoD,WAAU,KAA9D,EAAzV,EAA8Z,WAAU,EAAC,SAAQ,SAAT,EAAmB,QAAO,SAA1B,EAAoC,WAAU,IAA9C,EAAmD,YAAW,IAA9D,EAAxa,EAAP;EACD;;;6BAEkB;EACjB,aAAO,EAAC,UAAS,EAAC,SAAQ,QAAT,EAAkB,QAAO,OAAzB,EAAiC,aAAY,IAA7C,EAAkD,SAAQ,EAAC,SAAQ,aAAT,EAAuB,SAAQ,CAAC,EAAC,QAAO,KAAR,EAAD,CAA/B,EAA1D,EAAV,EAAsH,QAAO,EAAC,SAAQ,MAAT,EAAgB,QAAO,OAAvB,EAA+B,aAAY,KAA3C,EAAiD,SAAQ,EAAC,SAAQ,WAAT,EAAqB,SAAQ,CAAC,EAAC,QAAO,KAAR,EAAD,CAA7B,EAAzD,EAA7H,EAAsO,UAAS,EAAC,SAAQ,QAAT,EAAkB,QAAO,OAAzB,EAAiC,aAAY,IAA7C,EAAkD,YAAW,CAA7D,EAA+D,SAAQ,EAAC,SAAQ,aAAT,EAAuB,SAAQ,CAAC,EAAC,QAAO,KAAR,EAAD,CAA/B,EAAvE,EAA/O,EAAP;EACD;;;6BACgB;EACf,aAAO,gBAAP;EACD;;;6BAc+B;EAC9B,aAAO,CAAC,MAAD,EAAS,aAAT,EAAwB,WAAxB,EAAqC,aAArC,EAAoD,cAApD,CAAP;EACD;;;6BAEgC;EAC/B,aAAO;EACLC,cAAM,UADD;EAEL,uBAAe,UAFV;EAGL,qBAAa;EAHR,OAAP;EAKD;;;EAED,0BAAc;EAAA;EAAA,sHACNF,YADM;EAEb;;;IArDwBG;;EAwD3BA,UAAUC,MAAV,CAAiBJ,YAAjB;;;;;;;;"} \ No newline at end of file diff --git a/elements/pfe-icon-panel/dist/pfe-icon-panel.umd.min.js b/elements/pfe-icon-panel/dist/pfe-icon-panel.umd.min.js new file mode 100644 index 0000000000..f53d8488ed --- /dev/null +++ b/elements/pfe-icon-panel/dist/pfe-icon-panel.umd.min.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("../../pfelement/dist/pfelement.umd"),require("../../pfe-icon/dist/pfe-icon.umd")):"function"==typeof define&&define.amd?define(["../../pfelement/dist/pfelement.umd","../../pfe-icon/dist/pfe-icon.umd"],t):e.PfeIconPanel=t(e.PFElement)}(this,function(e){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e;var t=function(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e};function o(e,t){for(var n=0;n:host{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-content:flex-start;-ms-flex-line-pack:start;align-content:flex-start;-webkit-box-align:start;-webkit-align-items:flex-start;-ms-flex-align:start;align-items:flex-start;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column}@media (min-width:576px){:host{-webkit-box-orient:horizontal;-webkit-box-direction:normal;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row}}:host([pfe-stacked]:not([pfe-stacked=false])){-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column}:host([pfe-stacked]:not([pfe-stacked=false])[pfe-centered]:not([pfe-centered=false])){-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;text-align:center}.pfe-icon-panel__content{margin-top:16px;margin-top:var(--pfe-theme--container-spacer,16px);margin-left:0}@media (min-width:576px){.pfe-icon-panel__content{margin-top:0;margin-left:16px;margin-left:var(--pfe-theme--container-spacer,16px)}}:host([pfe-stacked]:not([pfe-stacked=false])) .pfe-icon-panel__content{margin-top:16px;margin-top:var(--pfe-theme--container-spacer,16px);margin-left:0}.pfe-icon-panel__footer{margin-top:24px;margin-top:var(--pfe-theme--content-spacer,24px)}\n/*# sourceMappingURL=pfe-icon-panel.min.css.map */\n\n
    \n \n \n \n
    '}},{key:"styleUrl",get:function(){return"pfe-icon-panel.scss"}},{key:"templateUrl",get:function(){return"pfe-icon-panel.html"}},{key:"schemaUrl",get:function(){return"pfe-icon-panel.json"}}],[{key:"version",get:function(){return"1.0.0-prerelease.54"}},{key:"properties",get:function(){return{icon:{title:"Icon",type:"string",prefixed:!1},color:{title:"Color",type:"string",enum:["complement","accent","lightest","base","darker","darkest","critical","important","moderate","success","info"],default:"darker",prefixed:!0},centered:{title:"Centered",type:"boolean",prefixed:!0,default:!1},stacked:{title:"Stacked",type:"boolean",prefixed:!0,default:!1},circled:{title:"Circled",type:"boolean",default:!0,prefixed:!0}}}},{key:"slots",get:function(){return{header:{title:"Header",type:"array",namedSlot:!0,items:{title:"Header item",oneOf:[{$ref:"raw"}]}},body:{title:"Body",type:"array",namedSlot:!1,items:{title:"Body item",oneOf:[{$ref:"raw"}]}},footer:{title:"Footer",type:"array",namedSlot:!0,maxItems:3,items:{title:"Footer item",oneOf:[{$ref:"raw"}]}}}}},{key:"tag",get:function(){return"pfe-icon-panel"}},{key:"observedAttributes",get:function(){return["icon","pfe-circled","pfe-color","pfe-stacked","pfe-centered"]}},{key:"cascadingAttributes",get:function(){return{icon:"pfe-icon","pfe-circled":"pfe-icon","pfe-color":"pfe-icon"}}}]),i);function i(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,i),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,i))}return e.create(n),n}); +//# sourceMappingURL=pfe-icon-panel.umd.min.js.map diff --git a/elements/pfe-icon-panel/dist/pfe-icon-panel.umd.min.js.map b/elements/pfe-icon-panel/dist/pfe-icon-panel.umd.min.js.map new file mode 100644 index 0000000000..9b292385f0 --- /dev/null +++ b/elements/pfe-icon-panel/dist/pfe-icon-panel.umd.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-icon-panel.umd.min.js","sources":["../_temp/pfe-icon-panel.umd.js"],"sourcesContent":["/*!\n * PatternFly Elements: PfeIconPanel 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.umd\";\nimport \"../../pfe-icon/dist/pfe-icon.umd\";\n\nclass PfeIconPanel extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `\n
    \n \n \n \n
    `;\n }\n\n static get properties() {\n return {\"icon\":{\"title\":\"Icon\",\"type\":\"string\",\"prefixed\":false},\"color\":{\"title\":\"Color\",\"type\":\"string\",\"enum\":[\"complement\",\"accent\",\"lightest\",\"base\",\"darker\",\"darkest\",\"critical\",\"important\",\"moderate\",\"success\",\"info\"],\"default\":\"darker\",\"prefixed\":true},\"centered\":{\"title\":\"Centered\",\"type\":\"boolean\",\"prefixed\":true,\"default\":false},\"stacked\":{\"title\":\"Stacked\",\"type\":\"boolean\",\"prefixed\":true,\"default\":false},\"circled\":{\"title\":\"Circled\",\"type\":\"boolean\",\"default\":true,\"prefixed\":true}};\n }\n\n static get slots() {\n return {\"header\":{\"title\":\"Header\",\"type\":\"array\",\"namedSlot\":true,\"items\":{\"title\":\"Header item\",\"oneOf\":[{\"$ref\":\"raw\"}]}},\"body\":{\"title\":\"Body\",\"type\":\"array\",\"namedSlot\":false,\"items\":{\"title\":\"Body item\",\"oneOf\":[{\"$ref\":\"raw\"}]}},\"footer\":{\"title\":\"Footer\",\"type\":\"array\",\"namedSlot\":true,\"maxItems\":3,\"items\":{\"title\":\"Footer item\",\"oneOf\":[{\"$ref\":\"raw\"}]}}};\n }\n static get tag() {\n return \"pfe-icon-panel\";\n }\n\n get styleUrl() {\n return \"pfe-icon-panel.scss\";\n }\n\n get templateUrl() {\n return \"pfe-icon-panel.html\";\n }\n\n get schemaUrl() {\n return \"pfe-icon-panel.json\";\n }\n\n static get observedAttributes() {\n return [\"icon\", \"pfe-circled\", \"pfe-color\", \"pfe-stacked\", \"pfe-centered\"];\n }\n\n static get cascadingAttributes() {\n return {\n icon: \"pfe-icon\",\n \"pfe-circled\": \"pfe-icon\",\n \"pfe-color\": \"pfe-icon\"\n };\n }\n\n constructor() {\n super(PfeIconPanel);\n }\n}\n\nPFElement.create(PfeIconPanel);\n\nexport default PfeIconPanel;\n"],"names":["PfeIconPanel","PFElement","this","getAttribute","icon","title","type","prefixed","color","enum","default","centered","stacked","circled","header","namedSlot","items","oneOf","$ref","body","footer","maxItems","create"],"mappings":"4nBA4BMA,+TAAqBC,6gDAQwC,SAArCC,KAAKC,aAAa,eAA4B,KAAO,sTAoBxE,gEAIA,8DAIA,8DAlCA,+DAeA,CAACC,KAAO,CAACC,MAAQ,OAAOC,KAAO,SAASC,UAAW,GAAOC,MAAQ,CAACH,MAAQ,QAAQC,KAAO,SAASG,KAAO,CAAC,aAAa,SAAS,WAAW,OAAO,SAAS,UAAU,WAAW,YAAY,WAAW,UAAU,QAAQC,QAAU,SAASH,UAAW,GAAMI,SAAW,CAACN,MAAQ,WAAWC,KAAO,UAAUC,UAAW,EAAKG,SAAU,GAAOE,QAAU,CAACP,MAAQ,UAAUC,KAAO,UAAUC,UAAW,EAAKG,SAAU,GAAOG,QAAU,CAACR,MAAQ,UAAUC,KAAO,UAAUI,SAAU,EAAKH,UAAW,wCAIte,CAACO,OAAS,CAACT,MAAQ,SAASC,KAAO,QAAQS,WAAY,EAAKC,MAAQ,CAACX,MAAQ,cAAcY,MAAQ,CAAC,CAACC,KAAO,UAAUC,KAAO,CAACd,MAAQ,OAAOC,KAAO,QAAQS,WAAY,EAAMC,MAAQ,CAACX,MAAQ,YAAYY,MAAQ,CAAC,CAACC,KAAO,UAAUE,OAAS,CAACf,MAAQ,SAASC,KAAO,QAAQS,WAAY,EAAKM,SAAW,EAAEL,MAAQ,CAACX,MAAQ,cAAcY,MAAQ,CAAC,CAACC,KAAO,6CAG9V,kEAgBA,CAAC,OAAQ,cAAe,YAAa,cAAe,kEAIpD,MACC,yBACS,uBACF,qWAKTlB,WAIVC,EAAUqB,OAAOtB"} \ No newline at end of file diff --git a/elements/pfe-icon-panel/package-lock.json b/elements/pfe-icon-panel/package-lock.json index 9797722034..06c25b7df5 100644 --- a/elements/pfe-icon-panel/package-lock.json +++ b/elements/pfe-icon-panel/package-lock.json @@ -1,6 +1,6 @@ { "name": "@patternfly/pfe-icon-panel", - "version": "1.0.0-prerelease.53", + "version": "1.0.0-prerelease.54", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/elements/pfe-icon-panel/package.json b/elements/pfe-icon-panel/package.json index c9c7987a34..376547eb88 100644 --- a/elements/pfe-icon-panel/package.json +++ b/elements/pfe-icon-panel/package.json @@ -4,7 +4,7 @@ "className": "PfeIconPanel", "elementName": "pfe-icon-panel" }, - "version": "1.0.0-prerelease.53", + "version": "1.0.0-prerelease.54", "publishConfig": { "access": "public" }, @@ -42,7 +42,7 @@ "@patternfly/pfelement": "^1.0.0-prerelease.51" }, "devDependencies": { - "@patternfly/pfe-sass": "^1.0.0-prerelease.53" + "@patternfly/pfe-sass": "^1.0.0-prerelease.54" }, "generator-pfelement-version": "0.5.0", "bugs": { diff --git a/elements/pfe-icon/dist/pfe-icon.js b/elements/pfe-icon/dist/pfe-icon.js new file mode 100644 index 0000000000..db1d564561 --- /dev/null +++ b/elements/pfe-icon/dist/pfe-icon.js @@ -0,0 +1,277 @@ +import PFElement from '../../pfelement/dist/pfelement.js'; + +class PfeIconSet { + /** + * Run the icon set's name resolver to turn an icon name into an icon path, id, etc. + */ + resolveIconName(iconName) { + return this._resolveIconName(iconName, this.name, this.path); + } + + /** + * Create a new icon set. Icon sets have a name (ie, a namespace). For + * example, an icon with a name of "rh-logo" represents a "logo" icon from the + * "rh" set. Icon set names are always separated from the rest of the icon + * name with a hyphen `-`. This means that set names cannot contain a hyphen. + * + * @param {String} name the namespace of the icon set + * @param {String} path the web-accessible path to the icon set (for instance, a CDN) + * @param {Function} resolveIconName an optional function to combine the path and an icon name into a final path. The function will be passed the namespaced icon name (for example, "rh-api" where rh is the namespace and api is the individual icon's name) + * @returns {Object} an object with the status of the icon set installation, such as `{ result: true, text: 'icon set installed' }` or `{ result: false, text: 'icon set is already installed' }` + */ + constructor(name, path, resolveIconName) { + this.name = name; + this.path = path; + this._resolveIconName = resolveIconName; + } +} + +/** + * An 'init' function to add the PFE built-in icon sets to the current page. + */ +function addBuiltIns(PfeIcon) { + [ + { + name: "web", + path: "https://access.redhat.com/webassets/avalon/j/lib/rh-iconfont-svgs" + }, + { + name: "rh", + path: "https://access.redhat.com/webassets/avalon/j/lib/rh-iconfont-svgs" + } + ].forEach(set => + PfeIcon.addIconSet(set.name, set.path, (name, iconSetName, iconSetPath) => { + const regex = new RegExp(`^${iconSetName}(-icon)?-(.*)`); + const [, , iconName] = regex.exec(name); + + const iconId = `${iconSetName}-icon-${iconName}`; + const iconPath = `${iconSetPath}/${iconId}.svg`; + + return iconPath; + }) + ); +} + +/*! + * PatternFly Elements: PfeIcon 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * +*/ + +/** + * Sets the id attribute on the element and points the CSS `filter` at that id. + */ +function _setRandomFilterId(el) { + const randomId = + "filter-" + + Math.random() + .toString() + .slice(2, 10); + + // set the CSS filter property to point at the given id + el.shadowRoot.querySelector("svg image").style.filter = `url(#${randomId})`; + + // set the id attribute on the SVG filter element to match + el.shadowRoot.querySelector("svg filter").setAttribute("id", randomId); +} + +class PfeIcon extends PFElement { + static get version() { + return "1.0.0-prerelease.54"; + } + + get html() { + return `
    + +
    + + + + + + +`; + } + + static get properties() { + return {"icon":{"title":"Icon","type":"string","prefixed":false},"size":{"title":"Size","type":"string","enum":["xl","lg","md","sm","2x","3x","4x"],"prefixed":true},"color":{"title":"Color","type":"string","enum":["complement","accent","lightest","base","darker","darkest","critical","important","moderate","success","info"],"prefixed":true},"circled":{"title":"Circled","type":"boolean","default":false,"prefixed":true}}; + } + + static get slots() { + return {}; + } + static get tag() { + return "pfe-icon"; + } + + get templateUrl() { + return "pfe-icon.html"; + } + + get styleUrl() { + return "pfe-icon.scss"; + } + + get schemaUrl() { + return "pfe-icon.json"; + } + + // Declare the type of this component + static get PfeType() { + return PFElement.PfeTypes.Content; + } + + static get EVENTS() { + return { + ADD_ICON_SET: `${this.tag}:add-icon-set` + }; + } + + get upgraded() { + return this.image.hasAttribute("xlink:href"); + } + + get has_fallback() { + return this.children.length > 0 || this.innerText.length > 0; + } + + static get observedAttributes() { + return ["icon", "on-fail", "pfe-circled", "pfe-color"]; + } + + _iconLoad() { + this.classList.remove("load-failed"); + } + + _iconLoadError() { + this.classList.add("load-failed"); + if (this.has_fallback) { + this.classList.add("has-fallback"); + } + } + + constructor() { + super(PfeIcon, { type: PfeIcon.PfeType }); + + this._iconLoad = this._iconLoad.bind(this); + this._iconLoadError = this._iconLoadError.bind(this); + + this.image = this.shadowRoot.querySelector("svg image"); + if (this.image) { + this.image.addEventListener("load", this._iconLoad); + this.image.addEventListener("error", this._iconLoadError); + } + + // Attach a listener for the registration of an icon set + // Leaving this attached allows for the registered set to be updated + document.body.addEventListener(PfeIcon.EVENTS.ADD_ICON_SET, () => + this.updateIcon() + ); + } + + disconnectedCallback() { + super.disconnectedCallback(); + + if (this.image) { + this.image.removeEventListener("load", this._iconLoad); + this.image.removeEventListener("error", this._iconLoadError); + } + } + + attributeChangedCallback(attr, oldValue, newValue) { + super.attributeChangedCallback(...arguments); + this.updateIcon(newValue); + this.context_update(); + } + + updateIcon(iconName = this.getAttribute("icon")) { + const { set } = PfeIcon.getIconSet(iconName); + if (set) { + const iconPath = set.resolveIconName(iconName); + this.image.setAttribute("xlink:href", iconPath); + _setRandomFilterId(this); + } + } + + /** + * Get an icon set by providing the set's name, _or_ the name of an icon from that set. + * + * @param {String} iconName the name of the set, or the name of an icon from that set. + * @return {PfeIconSet} the icon set + */ + static getIconSet(iconName) { + let set; + if (iconName) { + const [setName] = iconName.split("-"); + set = this._iconSets[setName]; + } + return { set }; + } + + static addIconSet(name, path, resolveIconName) { + let resolveFunction; + + if (typeof resolveIconName === "function") { + resolveFunction = resolveIconName; + } else if ( + typeof resolveIconName === "undefined" && + this._iconSets[name] && + typeof this._iconSets[name]._resolveIconName === "function" + ) { + resolveFunction = this._iconSets[name]._resolveIconName; + } else if ( + typeof resolveIconName !== "function" && + typeof resolveIconName !== "undefined" + ) { + console.warn( + `${this.tag}: The third input to addIconSet should be a function that parses and returns the icon's filename.` + ); + } else { + console.warn( + `${this.tag}: The set ${name} needs a resolve function for the icon names.` + ); + } + + // Register the icon set and set up the event indicating the change + this._iconSets[name] = new PfeIconSet(name, path, resolveFunction); + + document.body.dispatchEvent( + new CustomEvent(this.EVENTS.ADD_ICON_SET, { + bubbles: false, + detail: { + set: this._iconSets[name] + } + }) + ); + } +} + +PfeIcon._iconSets = {}; + +addBuiltIns(PfeIcon); + +PFElement.create(PfeIcon); + +export default PfeIcon; +//# sourceMappingURL=pfe-icon.js.map diff --git a/elements/pfe-icon/dist/pfe-icon.js.map b/elements/pfe-icon/dist/pfe-icon.js.map new file mode 100644 index 0000000000..f34fdcfff6 --- /dev/null +++ b/elements/pfe-icon/dist/pfe-icon.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-icon.js","sources":["../_temp/icon-set.js","../_temp/builtin-icon-sets.js","../_temp/pfe-icon.js"],"sourcesContent":["class PfeIconSet {\n /**\n * Run the icon set's name resolver to turn an icon name into an icon path, id, etc.\n */\n resolveIconName(iconName) {\n return this._resolveIconName(iconName, this.name, this.path);\n }\n\n /**\n * Create a new icon set. Icon sets have a name (ie, a namespace). For\n * example, an icon with a name of \"rh-logo\" represents a \"logo\" icon from the\n * \"rh\" set. Icon set names are always separated from the rest of the icon\n * name with a hyphen `-`. This means that set names cannot contain a hyphen.\n *\n * @param {String} name the namespace of the icon set\n * @param {String} path the web-accessible path to the icon set (for instance, a CDN)\n * @param {Function} resolveIconName an optional function to combine the path and an icon name into a final path. The function will be passed the namespaced icon name (for example, \"rh-api\" where rh is the namespace and api is the individual icon's name)\n * @returns {Object} an object with the status of the icon set installation, such as `{ result: true, text: 'icon set installed' }` or `{ result: false, text: 'icon set is already installed' }`\n */\n constructor(name, path, resolveIconName) {\n this.name = name;\n this.path = path;\n this._resolveIconName = resolveIconName;\n }\n}\n\nexport default PfeIconSet;\n","/**\n * An 'init' function to add the PFE built-in icon sets to the current page.\n */\nexport function addBuiltIns(PfeIcon) {\n [\n {\n name: \"web\",\n path: \"https://access.redhat.com/webassets/avalon/j/lib/rh-iconfont-svgs\"\n },\n {\n name: \"rh\",\n path: \"https://access.redhat.com/webassets/avalon/j/lib/rh-iconfont-svgs\"\n }\n ].forEach(set =>\n PfeIcon.addIconSet(set.name, set.path, (name, iconSetName, iconSetPath) => {\n const regex = new RegExp(`^${iconSetName}(-icon)?-(.*)`);\n const [, , iconName] = regex.exec(name);\n\n const iconId = `${iconSetName}-icon-${iconName}`;\n const iconPath = `${iconSetPath}/${iconId}.svg`;\n\n return iconPath;\n })\n );\n}\n","/*!\n * PatternFly Elements: PfeIcon 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.js\";\nimport PfeIconSet from \"./icon-set.js\";\nimport { addBuiltIns } from \"./builtin-icon-sets.js\";\n\n/**\n * Sets the id attribute on the element and points the CSS `filter` at that id.\n */\nfunction _setRandomFilterId(el) {\n const randomId =\n \"filter-\" +\n Math.random()\n .toString()\n .slice(2, 10);\n\n // set the CSS filter property to point at the given id\n el.shadowRoot.querySelector(\"svg image\").style.filter = `url(#${randomId})`;\n\n // set the id attribute on the SVG filter element to match\n el.shadowRoot.querySelector(\"svg filter\").setAttribute(\"id\", randomId);\n}\n\nclass PfeIcon extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
    \n \n
    \n\n \n \n \n \n \n`;\n }\n\n static get properties() {\n return {\"icon\":{\"title\":\"Icon\",\"type\":\"string\",\"prefixed\":false},\"size\":{\"title\":\"Size\",\"type\":\"string\",\"enum\":[\"xl\",\"lg\",\"md\",\"sm\",\"2x\",\"3x\",\"4x\"],\"prefixed\":true},\"color\":{\"title\":\"Color\",\"type\":\"string\",\"enum\":[\"complement\",\"accent\",\"lightest\",\"base\",\"darker\",\"darkest\",\"critical\",\"important\",\"moderate\",\"success\",\"info\"],\"prefixed\":true},\"circled\":{\"title\":\"Circled\",\"type\":\"boolean\",\"default\":false,\"prefixed\":true}};\n }\n\n static get slots() {\n return {};\n }\n static get tag() {\n return \"pfe-icon\";\n }\n\n get templateUrl() {\n return \"pfe-icon.html\";\n }\n\n get styleUrl() {\n return \"pfe-icon.scss\";\n }\n\n get schemaUrl() {\n return \"pfe-icon.json\";\n }\n\n // Declare the type of this component\n static get PfeType() {\n return PFElement.PfeTypes.Content;\n }\n\n static get EVENTS() {\n return {\n ADD_ICON_SET: `${this.tag}:add-icon-set`\n };\n }\n\n get upgraded() {\n return this.image.hasAttribute(\"xlink:href\");\n }\n\n get has_fallback() {\n return this.children.length > 0 || this.innerText.length > 0;\n }\n\n static get observedAttributes() {\n return [\"icon\", \"on-fail\", \"pfe-circled\", \"pfe-color\"];\n }\n\n _iconLoad() {\n this.classList.remove(\"load-failed\");\n }\n\n _iconLoadError() {\n this.classList.add(\"load-failed\");\n if (this.has_fallback) {\n this.classList.add(\"has-fallback\");\n }\n }\n\n constructor() {\n super(PfeIcon, { type: PfeIcon.PfeType });\n\n this._iconLoad = this._iconLoad.bind(this);\n this._iconLoadError = this._iconLoadError.bind(this);\n\n this.image = this.shadowRoot.querySelector(\"svg image\");\n if (this.image) {\n this.image.addEventListener(\"load\", this._iconLoad);\n this.image.addEventListener(\"error\", this._iconLoadError);\n }\n\n // Attach a listener for the registration of an icon set\n // Leaving this attached allows for the registered set to be updated\n document.body.addEventListener(PfeIcon.EVENTS.ADD_ICON_SET, () =>\n this.updateIcon()\n );\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n\n if (this.image) {\n this.image.removeEventListener(\"load\", this._iconLoad);\n this.image.removeEventListener(\"error\", this._iconLoadError);\n }\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n super.attributeChangedCallback(...arguments);\n this.updateIcon(newValue);\n this.context_update();\n }\n\n updateIcon(iconName = this.getAttribute(\"icon\")) {\n const { set } = PfeIcon.getIconSet(iconName);\n if (set) {\n const iconPath = set.resolveIconName(iconName);\n this.image.setAttribute(\"xlink:href\", iconPath);\n _setRandomFilterId(this);\n }\n }\n\n /**\n * Get an icon set by providing the set's name, _or_ the name of an icon from that set.\n *\n * @param {String} iconName the name of the set, or the name of an icon from that set.\n * @return {PfeIconSet} the icon set\n */\n static getIconSet(iconName) {\n let set;\n if (iconName) {\n const [setName] = iconName.split(\"-\");\n set = this._iconSets[setName];\n }\n return { set };\n }\n\n static addIconSet(name, path, resolveIconName) {\n let resolveFunction;\n\n if (typeof resolveIconName === \"function\") {\n resolveFunction = resolveIconName;\n } else if (\n typeof resolveIconName === \"undefined\" &&\n this._iconSets[name] &&\n typeof this._iconSets[name]._resolveIconName === \"function\"\n ) {\n resolveFunction = this._iconSets[name]._resolveIconName;\n } else if (\n typeof resolveIconName !== \"function\" &&\n typeof resolveIconName !== \"undefined\"\n ) {\n console.warn(\n `${this.tag}: The third input to addIconSet should be a function that parses and returns the icon's filename.`\n );\n } else {\n console.warn(\n `${this.tag}: The set ${name} needs a resolve function for the icon names.`\n );\n }\n\n // Register the icon set and set up the event indicating the change\n this._iconSets[name] = new PfeIconSet(name, path, resolveFunction);\n\n document.body.dispatchEvent(\n new CustomEvent(this.EVENTS.ADD_ICON_SET, {\n bubbles: false,\n detail: {\n set: this._iconSets[name]\n }\n })\n );\n }\n}\n\nPfeIcon._iconSets = {};\n\naddBuiltIns(PfeIcon);\n\nPFElement.create(PfeIcon);\n\nexport default PfeIcon;\n"],"names":[],"mappings":";;AAAA,MAAM,UAAU,CAAC;;;;EAIf,eAAe,CAAC,QAAQ,EAAE;IACxB,OAAO,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;GAC9D;;;;;;;;;;;;;EAaD,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE;IACvC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACjB,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;GACzC;CACF;;ACxBD;;;AAGA,AAAO,SAAS,WAAW,CAAC,OAAO,EAAE;EACnC;IACE;MACE,IAAI,EAAE,KAAK;MACX,IAAI,EAAE,mEAAmE;KAC1E;IACD;MACE,IAAI,EAAE,IAAI;MACV,IAAI,EAAE,mEAAmE;KAC1E;GACF,CAAC,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,WAAW,KAAK;MACzE,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC;MACzD,MAAM,KAAK,QAAQ,CAAC,GAAG,KAAK,CAAC,IAA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AAI,CAAC,CAAC,gBAAgB,CAAC;KACzD,MAAM;MACL,OAAO,eAAe,KAAK,UAAU;MACrC,OAAO,eAAe,KAAK,WAAW;MACtC;MACA,OAAO,CAAC,IAAI;QACV,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,iGAAiG,CAAC;OAC/G,CAAC;KACH,MAAM;MACL,OAAO,CAAC,IAAI;QACV,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,6CAA6C,CAAC;OAC5E,CAAC;KACH;;;IAGD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC;;IAEnE,QAAQ,CAAC,IAAI,CAAC,aAAa;MACzB,IAAI,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE;QACxC,OAAO,EAAE,KAAK;QACd,MAAM,EAAE;UACN,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC1B;OACF,CAAC;KACH,CAAC;GACH;CACF;;AAED,OAAO,CAAC,SAAS,GAAG,EAAE,CAAC;;AAEvB,WAAW,CAAC,OAAO,CAAC,CAAC;;AAErB,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;;;;"} \ No newline at end of file diff --git a/elements/pfe-icon/dist/pfe-icon.json b/elements/pfe-icon/dist/pfe-icon.json new file mode 100644 index 0000000000..d26e881034 --- /dev/null +++ b/elements/pfe-icon/dist/pfe-icon.json @@ -0,0 +1,55 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Icon", + "description": "This element renders an icon", + "type": "object", + "tag": "pfe-icon", + "class": "pfe-icon", + "category": "content", + "properties": { + "attributes": { + "title": "Attributes", + "type": "object", + "properties": { + "icon": { + "title": "Icon", + "type": "string", + "prefixed": false + }, + "size": { + "title": "Size", + "type": "string", + "enum": ["xl", "lg", "md", "sm", "2x", "3x", "4x"], + "prefixed": true + }, + "color": { + "title": "Color", + "type": "string", + "enum": [ + "complement", + "accent", + "lightest", + "base", + "darker", + "darkest", + "critical", + "important", + "moderate", + "success", + "info" + ], + "prefixed": true + }, + "circled": { + "title": "Circled", + "type": "boolean", + "default": false, + "prefixed": true + } + }, + "required": ["icon", "circled"] + } + }, + "required": ["attributes"], + "additionalProperties": false +} diff --git a/elements/pfe-icon/dist/pfe-icon.min.js b/elements/pfe-icon/dist/pfe-icon.min.js new file mode 100644 index 0000000000..9b295d9572 --- /dev/null +++ b/elements/pfe-icon/dist/pfe-icon.min.js @@ -0,0 +1,27 @@ +import e from"../../pfelement/dist/pfelement.min.js";class o{resolveIconName(e){return this._resolveIconName(e,this.name,this.path)}constructor(e,o,t){this.name=e,this.path=o,this._resolveIconName=t}}class t extends e{static get version(){return"1.0.0-prerelease.54"}get html(){return'
    \n \n
    \n\n \n \n \n \n \n'}static get properties(){return{icon:{title:"Icon",type:"string",prefixed:!1},size:{title:"Size",type:"string",enum:["xl","lg","md","sm","2x","3x","4x"],prefixed:!0},color:{title:"Color",type:"string",enum:["complement","accent","lightest","base","darker","darkest","critical","important","moderate","success","info"],prefixed:!0},circled:{title:"Circled",type:"boolean",default:!1,prefixed:!0}}}static get slots(){return{}}static get tag(){return"pfe-icon"}get templateUrl(){return"pfe-icon.html"}get styleUrl(){return"pfe-icon.scss"}get schemaUrl(){return"pfe-icon.json"}static get PfeType(){return e.PfeTypes.Content}static get EVENTS(){return{ADD_ICON_SET:`${this.tag}:add-icon-set`}}get upgraded(){return this.image.hasAttribute("xlink:href")}get has_fallback(){return this.children.length>0||this.innerText.length>0}static get observedAttributes(){return["icon","on-fail","pfe-circled","pfe-color"]}_iconLoad(){this.classList.remove("load-failed")}_iconLoadError(){this.classList.add("load-failed"),this.has_fallback&&this.classList.add("has-fallback")}constructor(){super(t,{type:t.PfeType}),this._iconLoad=this._iconLoad.bind(this),this._iconLoadError=this._iconLoadError.bind(this),this.image=this.shadowRoot.querySelector("svg image"),this.image&&(this.image.addEventListener("load",this._iconLoad),this.image.addEventListener("error",this._iconLoadError)),document.body.addEventListener(t.EVENTS.ADD_ICON_SET,()=>this.updateIcon())}disconnectedCallback(){super.disconnectedCallback(),this.image&&(this.image.removeEventListener("load",this._iconLoad),this.image.removeEventListener("error",this._iconLoadError))}attributeChangedCallback(e,o,t){super.attributeChangedCallback(...arguments),this.updateIcon(t),this.context_update()}updateIcon(e=this.getAttribute("icon")){const{set:o}=t.getIconSet(e);if(o){const t=o.resolveIconName(e);this.image.setAttribute("xlink:href",t), +/*! + * PatternFly Elements: PfeIcon 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * +*/ +function(e){const o="filter-"+Math.random().toString().slice(2,10);e.shadowRoot.querySelector("svg image").style.filter=`url(#${o})`,e.shadowRoot.querySelector("svg filter").setAttribute("id",o)}(this)}}static getIconSet(e){let o;if(e){const[t]=e.split("-");o=this._iconSets[t]}return{set:o}}static addIconSet(e,t,i){let r;"function"==typeof i?r=i:void 0===i&&this._iconSets[e]&&"function"==typeof this._iconSets[e]._resolveIconName?r=this._iconSets[e]._resolveIconName:"function"!=typeof i&&void 0!==i?console.warn(`${this.tag}: The third input to addIconSet should be a function that parses and returns the icon's filename.`):console.warn(`${this.tag}: The set ${e} needs a resolve function for the icon names.`),this._iconSets[e]=new o(e,t,r),document.body.dispatchEvent(new CustomEvent(this.EVENTS.ADD_ICON_SET,{bubbles:!1,detail:{set:this._iconSets[e]}}))}}t._iconSets={},function(e){[{name:"web",path:"https://access.redhat.com/webassets/avalon/j/lib/rh-iconfont-svgs"},{name:"rh",path:"https://access.redhat.com/webassets/avalon/j/lib/rh-iconfont-svgs"}].forEach(o=>e.addIconSet(o.name,o.path,(e,o,t)=>{const i=new RegExp(`^${o}(-icon)?-(.*)`),[,,r]=i.exec(e);return`${t}/${`${o}-icon-${r}`}.svg`}))}(t),e.create(t);export default t; +//# sourceMappingURL=pfe-icon.min.js.map diff --git a/elements/pfe-icon/dist/pfe-icon.min.js.map b/elements/pfe-icon/dist/pfe-icon.min.js.map new file mode 100644 index 0000000000..6b4ecba94e --- /dev/null +++ b/elements/pfe-icon/dist/pfe-icon.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-icon.min.js","sources":["../_temp/icon-set.js","../_temp/pfe-icon.js","../_temp/builtin-icon-sets.js"],"sourcesContent":["class PfeIconSet {\n /**\n * Run the icon set's name resolver to turn an icon name into an icon path, id, etc.\n */\n resolveIconName(iconName) {\n return this._resolveIconName(iconName, this.name, this.path);\n }\n\n /**\n * Create a new icon set. Icon sets have a name (ie, a namespace). For\n * example, an icon with a name of \"rh-logo\" represents a \"logo\" icon from the\n * \"rh\" set. Icon set names are always separated from the rest of the icon\n * name with a hyphen `-`. This means that set names cannot contain a hyphen.\n *\n * @param {String} name the namespace of the icon set\n * @param {String} path the web-accessible path to the icon set (for instance, a CDN)\n * @param {Function} resolveIconName an optional function to combine the path and an icon name into a final path. The function will be passed the namespaced icon name (for example, \"rh-api\" where rh is the namespace and api is the individual icon's name)\n * @returns {Object} an object with the status of the icon set installation, such as `{ result: true, text: 'icon set installed' }` or `{ result: false, text: 'icon set is already installed' }`\n */\n constructor(name, path, resolveIconName) {\n this.name = name;\n this.path = path;\n this._resolveIconName = resolveIconName;\n }\n}\n\nexport default PfeIconSet;\n","/*!\n * PatternFly Elements: PfeIcon 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.js\";\nimport PfeIconSet from \"./icon-set.js\";\nimport { addBuiltIns } from \"./builtin-icon-sets.js\";\n\n/**\n * Sets the id attribute on the element and points the CSS `filter` at that id.\n */\nfunction _setRandomFilterId(el) {\n const randomId =\n \"filter-\" +\n Math.random()\n .toString()\n .slice(2, 10);\n\n // set the CSS filter property to point at the given id\n el.shadowRoot.querySelector(\"svg image\").style.filter = `url(#${randomId})`;\n\n // set the id attribute on the SVG filter element to match\n el.shadowRoot.querySelector(\"svg filter\").setAttribute(\"id\", randomId);\n}\n\nclass PfeIcon extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
    \n \n
    \n\n \n \n \n \n \n`;\n }\n\n static get properties() {\n return {\"icon\":{\"title\":\"Icon\",\"type\":\"string\",\"prefixed\":false},\"size\":{\"title\":\"Size\",\"type\":\"string\",\"enum\":[\"xl\",\"lg\",\"md\",\"sm\",\"2x\",\"3x\",\"4x\"],\"prefixed\":true},\"color\":{\"title\":\"Color\",\"type\":\"string\",\"enum\":[\"complement\",\"accent\",\"lightest\",\"base\",\"darker\",\"darkest\",\"critical\",\"important\",\"moderate\",\"success\",\"info\"],\"prefixed\":true},\"circled\":{\"title\":\"Circled\",\"type\":\"boolean\",\"default\":false,\"prefixed\":true}};\n }\n\n static get slots() {\n return {};\n }\n static get tag() {\n return \"pfe-icon\";\n }\n\n get templateUrl() {\n return \"pfe-icon.html\";\n }\n\n get styleUrl() {\n return \"pfe-icon.scss\";\n }\n\n get schemaUrl() {\n return \"pfe-icon.json\";\n }\n\n // Declare the type of this component\n static get PfeType() {\n return PFElement.PfeTypes.Content;\n }\n\n static get EVENTS() {\n return {\n ADD_ICON_SET: `${this.tag}:add-icon-set`\n };\n }\n\n get upgraded() {\n return this.image.hasAttribute(\"xlink:href\");\n }\n\n get has_fallback() {\n return this.children.length > 0 || this.innerText.length > 0;\n }\n\n static get observedAttributes() {\n return [\"icon\", \"on-fail\", \"pfe-circled\", \"pfe-color\"];\n }\n\n _iconLoad() {\n this.classList.remove(\"load-failed\");\n }\n\n _iconLoadError() {\n this.classList.add(\"load-failed\");\n if (this.has_fallback) {\n this.classList.add(\"has-fallback\");\n }\n }\n\n constructor() {\n super(PfeIcon, { type: PfeIcon.PfeType });\n\n this._iconLoad = this._iconLoad.bind(this);\n this._iconLoadError = this._iconLoadError.bind(this);\n\n this.image = this.shadowRoot.querySelector(\"svg image\");\n if (this.image) {\n this.image.addEventListener(\"load\", this._iconLoad);\n this.image.addEventListener(\"error\", this._iconLoadError);\n }\n\n // Attach a listener for the registration of an icon set\n // Leaving this attached allows for the registered set to be updated\n document.body.addEventListener(PfeIcon.EVENTS.ADD_ICON_SET, () =>\n this.updateIcon()\n );\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n\n if (this.image) {\n this.image.removeEventListener(\"load\", this._iconLoad);\n this.image.removeEventListener(\"error\", this._iconLoadError);\n }\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n super.attributeChangedCallback(...arguments);\n this.updateIcon(newValue);\n this.context_update();\n }\n\n updateIcon(iconName = this.getAttribute(\"icon\")) {\n const { set } = PfeIcon.getIconSet(iconName);\n if (set) {\n const iconPath = set.resolveIconName(iconName);\n this.image.setAttribute(\"xlink:href\", iconPath);\n _setRandomFilterId(this);\n }\n }\n\n /**\n * Get an icon set by providing the set's name, _or_ the name of an icon from that set.\n *\n * @param {String} iconName the name of the set, or the name of an icon from that set.\n * @return {PfeIconSet} the icon set\n */\n static getIconSet(iconName) {\n let set;\n if (iconName) {\n const [setName] = iconName.split(\"-\");\n set = this._iconSets[setName];\n }\n return { set };\n }\n\n static addIconSet(name, path, resolveIconName) {\n let resolveFunction;\n\n if (typeof resolveIconName === \"function\") {\n resolveFunction = resolveIconName;\n } else if (\n typeof resolveIconName === \"undefined\" &&\n this._iconSets[name] &&\n typeof this._iconSets[name]._resolveIconName === \"function\"\n ) {\n resolveFunction = this._iconSets[name]._resolveIconName;\n } else if (\n typeof resolveIconName !== \"function\" &&\n typeof resolveIconName !== \"undefined\"\n ) {\n console.warn(\n `${this.tag}: The third input to addIconSet should be a function that parses and returns the icon's filename.`\n );\n } else {\n console.warn(\n `${this.tag}: The set ${name} needs a resolve function for the icon names.`\n );\n }\n\n // Register the icon set and set up the event indicating the change\n this._iconSets[name] = new PfeIconSet(name, path, resolveFunction);\n\n document.body.dispatchEvent(\n new CustomEvent(this.EVENTS.ADD_ICON_SET, {\n bubbles: false,\n detail: {\n set: this._iconSets[name]\n }\n })\n );\n }\n}\n\nPfeIcon._iconSets = {};\n\naddBuiltIns(PfeIcon);\n\nPFElement.create(PfeIcon);\n\nexport default PfeIcon;\n","/**\n * An 'init' function to add the PFE built-in icon sets to the current page.\n */\nexport function addBuiltIns(PfeIcon) {\n [\n {\n name: \"web\",\n path: \"https://access.redhat.com/webassets/avalon/j/lib/rh-iconfont-svgs\"\n },\n {\n name: \"rh\",\n path: \"https://access.redhat.com/webassets/avalon/j/lib/rh-iconfont-svgs\"\n }\n ].forEach(set =>\n PfeIcon.addIconSet(set.name, set.path, (name, iconSetName, iconSetPath) => {\n const regex = new RegExp(`^${iconSetName}(-icon)?-(.*)`);\n const [, , iconName] = regex.exec(name);\n\n const iconId = `${iconSetName}-icon-${iconName}`;\n const iconPath = `${iconSetPath}/${iconId}.svg`;\n\n return iconPath;\n })\n );\n}\n"],"names":["PfeIconSet","[object Object]","iconName","this","_resolveIconName","name","path","resolveIconName","PfeIcon","PFElement","version","html","properties","icon","title","type","prefixed","size","enum","color","circled","default","slots","tag","templateUrl","styleUrl","schemaUrl","PfeType","PfeTypes","Content","EVENTS","ADD_ICON_SET","upgraded","image","hasAttribute","has_fallback","children","length","innerText","observedAttributes","classList","remove","add","super","_iconLoad","bind","_iconLoadError","shadowRoot","querySelector","addEventListener","document","body","updateIcon","disconnectedCallback","removeEventListener","attr","oldValue","newValue","attributeChangedCallback","arguments","context_update","getAttribute","set","getIconSet","iconPath","setAttribute","el","randomId","Math","random","toString","slice","style","filter","_setRandomFilterId","setName","split","_iconSets","resolveFunction","console","warn","dispatchEvent","CustomEvent","bubbles","detail","forEach","addIconSet","iconSetName","iconSetPath","regex","RegExp","exec","addBuiltIns","create"],"mappings":"qDAAA,MAAMA,EAIJC,gBAAgBC,GACd,OAAOC,KAAKC,iBAAiBF,EAAUC,KAAKE,KAAMF,KAAKG,MAczDL,YAAYI,EAAMC,EAAMC,GACtBJ,KAAKE,KAAOA,EACZF,KAAKG,KAAOA,EACZH,KAAKC,iBAA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GAElD5B,SAASC,KAAK8B,cACZ,IAAIC,YAAY/E,KAAK2B,OAAOC,aAAc,CACxCoD,SAAS,EACTC,OAAQ,CACNtB,IAAK3D,KAAK0E,UAAUxE,QAO9BG,EAAQqE,UAAY,GCxNb,SAAqBrE,GAC1B,CACE,CACEH,KAAM,MACNC,KAAM,qEAER,CACED,KAAM,KACNC,KAAM,sEAER+E,QAAQvB,GACRtD,EAAQ8E,WAAWxB,EAAIzD,KAAMyD,EAAIxD,KAAM,CAACD,EAAMkF,EAAaC,KACzD,MAAMC,EAAQ,IAAIC,WAAWH,qBAClBrF,GAAYuF,EAAME,KAAKtF,GAKlC,SAFoBmF,QADFD,UAAoBrF,aD2M5C0F,CAAYpF,GAEZC,EAAUoF,OAAOrF"} \ No newline at end of file diff --git a/elements/pfe-icon/dist/pfe-icon.umd.js b/elements/pfe-icon/dist/pfe-icon.umd.js new file mode 100644 index 0000000000..cf21dc39bf --- /dev/null +++ b/elements/pfe-icon/dist/pfe-icon.umd.js @@ -0,0 +1,419 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../../pfelement/dist/pfelement.umd')) : + typeof define === 'function' && define.amd ? define(['../../pfelement/dist/pfelement.umd'], factory) : + (global.PfeIcon = factory(global.PFElement)); +}(this, (function (PFElement) { 'use strict'; + + PFElement = PFElement && PFElement.hasOwnProperty('default') ? PFElement['default'] : PFElement; + + var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + }; + + var createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + }(); + + var get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + + if (getter === undefined) { + return undefined; + } + + return getter.call(receiver); + } + }; + + var inherits = function (subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + }; + + var possibleConstructorReturn = function (self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && (typeof call === "object" || typeof call === "function") ? call : self; + }; + + var slicedToArray = function () { + function sliceIterator(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"]) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; + } + + return function (arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if (Symbol.iterator in Object(arr)) { + return sliceIterator(arr, i); + } else { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + } + }; + }(); + + var PfeIconSet = function () { + createClass(PfeIconSet, [{ + key: "resolveIconName", + + /** + * Run the icon set's name resolver to turn an icon name into an icon path, id, etc. + */ + value: function resolveIconName(iconName) { + return this._resolveIconName(iconName, this.name, this.path); + } + + /** + * Create a new icon set. Icon sets have a name (ie, a namespace). For + * example, an icon with a name of "rh-logo" represents a "logo" icon from the + * "rh" set. Icon set names are always separated from the rest of the icon + * name with a hyphen `-`. This means that set names cannot contain a hyphen. + * + * @param {String} name the namespace of the icon set + * @param {String} path the web-accessible path to the icon set (for instance, a CDN) + * @param {Function} resolveIconName an optional function to combine the path and an icon name into a final path. The function will be passed the namespaced icon name (for example, "rh-api" where rh is the namespace and api is the individual icon's name) + * @returns {Object} an object with the status of the icon set installation, such as `{ result: true, text: 'icon set installed' }` or `{ result: false, text: 'icon set is already installed' }` + */ + + }]); + + function PfeIconSet(name, path, resolveIconName) { + classCallCheck(this, PfeIconSet); + + this.name = name; + this.path = path; + this._resolveIconName = resolveIconName; + } + + return PfeIconSet; + }(); + + /** + * An 'init' function to add the PFE built-in icon sets to the current page. + */ + function addBuiltIns(PfeIcon) { + [{ + name: "web", + path: "https://access.redhat.com/webassets/avalon/j/lib/rh-iconfont-svgs" + }, { + name: "rh", + path: "https://access.redhat.com/webassets/avalon/j/lib/rh-iconfont-svgs" + }].forEach(function (set$$1) { + return PfeIcon.addIconSet(set$$1.name, set$$1.path, function (name, iconSetName, iconSetPath) { + var regex = new RegExp("^" + iconSetName + "(-icon)?-(.*)"); + + var _regex$exec = regex.exec(name), + _regex$exec2 = slicedToArray(_regex$exec, 3), + iconName = _regex$exec2[2]; + + var iconId = iconSetName + "-icon-" + iconName; + var iconPath = iconSetPath + "/" + iconId + ".svg"; + + return iconPath; + }); + }); + } + + /*! + * PatternFly Elements: PfeIcon 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + + /** + * Sets the id attribute on the element and points the CSS `filter` at that id. + */ + function _setRandomFilterId(el) { + var randomId = "filter-" + Math.random().toString().slice(2, 10); + + // set the CSS filter property to point at the given id + el.shadowRoot.querySelector("svg image").style.filter = "url(#" + randomId + ")"; + + // set the id attribute on the SVG filter element to match + el.shadowRoot.querySelector("svg filter").setAttribute("id", randomId); + } + + var PfeIcon = function (_PFElement) { + inherits(PfeIcon, _PFElement); + createClass(PfeIcon, [{ + key: "_iconLoad", + value: function _iconLoad() { + this.classList.remove("load-failed"); + } + }, { + key: "_iconLoadError", + value: function _iconLoadError() { + this.classList.add("load-failed"); + if (this.has_fallback) { + this.classList.add("has-fallback"); + } + } + }, { + key: "html", + get: function get$$1() { + return "
    \n \n
    \n\n \n \n \n \n \n"; + } + }, { + key: "templateUrl", + get: function get$$1() { + return "pfe-icon.html"; + } + }, { + key: "styleUrl", + get: function get$$1() { + return "pfe-icon.scss"; + } + }, { + key: "schemaUrl", + get: function get$$1() { + return "pfe-icon.json"; + } + + // Declare the type of this component + + }, { + key: "upgraded", + get: function get$$1() { + return this.image.hasAttribute("xlink:href"); + } + }, { + key: "has_fallback", + get: function get$$1() { + return this.children.length > 0 || this.innerText.length > 0; + } + }], [{ + key: "version", + get: function get$$1() { + return "1.0.0-prerelease.54"; + } + }, { + key: "properties", + get: function get$$1() { + return { "icon": { "title": "Icon", "type": "string", "prefixed": false }, "size": { "title": "Size", "type": "string", "enum": ["xl", "lg", "md", "sm", "2x", "3x", "4x"], "prefixed": true }, "color": { "title": "Color", "type": "string", "enum": ["complement", "accent", "lightest", "base", "darker", "darkest", "critical", "important", "moderate", "success", "info"], "prefixed": true }, "circled": { "title": "Circled", "type": "boolean", "default": false, "prefixed": true } }; + } + }, { + key: "slots", + get: function get$$1() { + return {}; + } + }, { + key: "tag", + get: function get$$1() { + return "pfe-icon"; + } + }, { + key: "PfeType", + get: function get$$1() { + return PFElement.PfeTypes.Content; + } + }, { + key: "EVENTS", + get: function get$$1() { + return { + ADD_ICON_SET: this.tag + ":add-icon-set" + }; + } + }, { + key: "observedAttributes", + get: function get$$1() { + return ["icon", "on-fail", "pfe-circled", "pfe-color"]; + } + }]); + + function PfeIcon() { + classCallCheck(this, PfeIcon); + + var _this = possibleConstructorReturn(this, (PfeIcon.__proto__ || Object.getPrototypeOf(PfeIcon)).call(this, PfeIcon, { type: PfeIcon.PfeType })); + + _this._iconLoad = _this._iconLoad.bind(_this); + _this._iconLoadError = _this._iconLoadError.bind(_this); + + _this.image = _this.shadowRoot.querySelector("svg image"); + if (_this.image) { + _this.image.addEventListener("load", _this._iconLoad); + _this.image.addEventListener("error", _this._iconLoadError); + } + + // Attach a listener for the registration of an icon set + // Leaving this attached allows for the registered set to be updated + document.body.addEventListener(PfeIcon.EVENTS.ADD_ICON_SET, function () { + return _this.updateIcon(); + }); + return _this; + } + + createClass(PfeIcon, [{ + key: "disconnectedCallback", + value: function disconnectedCallback() { + get(PfeIcon.prototype.__proto__ || Object.getPrototypeOf(PfeIcon.prototype), "disconnectedCallback", this).call(this); + + if (this.image) { + this.image.removeEventListener("load", this._iconLoad); + this.image.removeEventListener("error", this._iconLoadError); + } + } + }, { + key: "attributeChangedCallback", + value: function attributeChangedCallback(attr, oldValue, newValue) { + get(PfeIcon.prototype.__proto__ || Object.getPrototypeOf(PfeIcon.prototype), "attributeChangedCallback", this).apply(this, arguments); + this.updateIcon(newValue); + this.context_update(); + } + }, { + key: "updateIcon", + value: function updateIcon() { + var iconName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getAttribute("icon"); + + var _PfeIcon$getIconSet = PfeIcon.getIconSet(iconName), + set$$1 = _PfeIcon$getIconSet.set; + + if (set$$1) { + var iconPath = set$$1.resolveIconName(iconName); + this.image.setAttribute("xlink:href", iconPath); + _setRandomFilterId(this); + } + } + + /** + * Get an icon set by providing the set's name, _or_ the name of an icon from that set. + * + * @param {String} iconName the name of the set, or the name of an icon from that set. + * @return {PfeIconSet} the icon set + */ + + }], [{ + key: "getIconSet", + value: function getIconSet(iconName) { + var set$$1 = void 0; + if (iconName) { + var _iconName$split = iconName.split("-"), + _iconName$split2 = slicedToArray(_iconName$split, 1), + setName = _iconName$split2[0]; + + set$$1 = this._iconSets[setName]; + } + return { set: set$$1 }; + } + }, { + key: "addIconSet", + value: function addIconSet(name, path, resolveIconName) { + var resolveFunction = void 0; + + if (typeof resolveIconName === "function") { + resolveFunction = resolveIconName; + } else if (typeof resolveIconName === "undefined" && this._iconSets[name] && typeof this._iconSets[name]._resolveIconName === "function") { + resolveFunction = this._iconSets[name]._resolveIconName; + } else if (typeof resolveIconName !== "function" && typeof resolveIconName !== "undefined") { + console.warn(this.tag + ": The third input to addIconSet should be a function that parses and returns the icon's filename."); + } else { + console.warn(this.tag + ": The set " + name + " needs a resolve function for the icon names."); + } + + // Register the icon set and set up the event indicating the change + this._iconSets[name] = new PfeIconSet(name, path, resolveFunction); + + document.body.dispatchEvent(new CustomEvent(this.EVENTS.ADD_ICON_SET, { + bubbles: false, + detail: { + set: this._iconSets[name] + } + })); + } + }]); + return PfeIcon; + }(PFElement); + + PfeIcon._iconSets = {}; + + addBuiltIns(PfeIcon); + + PFElement.create(PfeIcon); + + return PfeIcon; + +}))); +//# sourceMappingURL=pfe-icon.umd.js.map diff --git a/elements/pfe-icon/dist/pfe-icon.umd.js.map b/elements/pfe-icon/dist/pfe-icon.umd.js.map new file mode 100644 index 0000000000..33efb0a7a4 --- /dev/null +++ b/elements/pfe-icon/dist/pfe-icon.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pfe-icon.umd.js","sources":["../_temp/icon-set.js","../_temp/builtin-icon-sets.js","../_temp/pfe-icon.umd.js"],"sourcesContent":["class PfeIconSet {\n /**\n * Run the icon set's name resolver to turn an icon name into an icon path, id, etc.\n */\n resolveIconName(iconName) {\n return this._resolveIconName(iconName, this.name, this.path);\n }\n\n /**\n * Create a new icon set. Icon sets have a name (ie, a namespace). For\n * example, an icon with a name of \"rh-logo\" represents a \"logo\" icon from the\n * \"rh\" set. Icon set names are always separated from the rest of the icon\n * name with a hyphen `-`. This means that set names cannot contain a hyphen.\n *\n * @param {String} name the namespace of the icon set\n * @param {String} path the web-accessible path to the icon set (for instance, a CDN)\n * @param {Function} resolveIconName an optional function to combine the path and an icon name into a final path. The function will be passed the namespaced icon name (for example, \"rh-api\" where rh is the namespace and api is the individual icon's name)\n * @returns {Object} an object with the status of the icon set installation, such as `{ result: true, text: 'icon set installed' }` or `{ result: false, text: 'icon set is already installed' }`\n */\n constructor(name, path, resolveIconName) {\n this.name = name;\n this.path = path;\n this._resolveIconName = resolveIconName;\n }\n}\n\nexport default PfeIconSet;\n","/**\n * An 'init' function to add the PFE built-in icon sets to the current page.\n */\nexport function addBuiltIns(PfeIcon) {\n [\n {\n name: \"web\",\n path: \"https://access.redhat.com/webassets/avalon/j/lib/rh-iconfont-svgs\"\n },\n {\n name: \"rh\",\n path: \"https://access.redhat.com/webassets/avalon/j/lib/rh-iconfont-svgs\"\n }\n ].forEach(set =>\n PfeIcon.addIconSet(set.name, set.path, (name, iconSetName, iconSetPath) => {\n const regex = new RegExp(`^${iconSetName}(-icon)?-(.*)`);\n const [, , iconName] = regex.exec(name);\n\n const iconId = `${iconSetName}-icon-${iconName}`;\n const iconPath = `${iconSetPath}/${iconId}.svg`;\n\n return iconPath;\n })\n );\n}\n","/*!\n * PatternFly Elements: PfeIcon 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.umd\";\nimport PfeIconSet from \"./icon-set.js\";\nimport { addBuiltIns } from \"./builtin-icon-sets.js\";\n\n/**\n * Sets the id attribute on the element and points the CSS `filter` at that id.\n */\nfunction _setRandomFilterId(el) {\n const randomId =\n \"filter-\" +\n Math.random()\n .toString()\n .slice(2, 10);\n\n // set the CSS filter property to point at the given id\n el.shadowRoot.querySelector(\"svg image\").style.filter = `url(#${randomId})`;\n\n // set the id attribute on the SVG filter element to match\n el.shadowRoot.querySelector(\"svg filter\").setAttribute(\"id\", randomId);\n}\n\nclass PfeIcon extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
    \n \n
    \n\n \n \n \n \n \n`;\n }\n\n static get properties() {\n return {\"icon\":{\"title\":\"Icon\",\"type\":\"string\",\"prefixed\":false},\"size\":{\"title\":\"Size\",\"type\":\"string\",\"enum\":[\"xl\",\"lg\",\"md\",\"sm\",\"2x\",\"3x\",\"4x\"],\"prefixed\":true},\"color\":{\"title\":\"Color\",\"type\":\"string\",\"enum\":[\"complement\",\"accent\",\"lightest\",\"base\",\"darker\",\"darkest\",\"critical\",\"important\",\"moderate\",\"success\",\"info\"],\"prefixed\":true},\"circled\":{\"title\":\"Circled\",\"type\":\"boolean\",\"default\":false,\"prefixed\":true}};\n }\n\n static get slots() {\n return {};\n }\n static get tag() {\n return \"pfe-icon\";\n }\n\n get templateUrl() {\n return \"pfe-icon.html\";\n }\n\n get styleUrl() {\n return \"pfe-icon.scss\";\n }\n\n get schemaUrl() {\n return \"pfe-icon.json\";\n }\n\n // Declare the type of this component\n static get PfeType() {\n return PFElement.PfeTypes.Content;\n }\n\n static get EVENTS() {\n return {\n ADD_ICON_SET: `${this.tag}:add-icon-set`\n };\n }\n\n get upgraded() {\n return this.image.hasAttribute(\"xlink:href\");\n }\n\n get has_fallback() {\n return this.children.length > 0 || this.innerText.length > 0;\n }\n\n static get observedAttributes() {\n return [\"icon\", \"on-fail\", \"pfe-circled\", \"pfe-color\"];\n }\n\n _iconLoad() {\n this.classList.remove(\"load-failed\");\n }\n\n _iconLoadError() {\n this.classList.add(\"load-failed\");\n if (this.has_fallback) {\n this.classList.add(\"has-fallback\");\n }\n }\n\n constructor() {\n super(PfeIcon, { type: PfeIcon.PfeType });\n\n this._iconLoad = this._iconLoad.bind(this);\n this._iconLoadError = this._iconLoadError.bind(this);\n\n this.image = this.shadowRoot.querySelector(\"svg image\");\n if (this.image) {\n this.image.addEventListener(\"load\", this._iconLoad);\n this.image.addEventListener(\"error\", this._iconLoadError);\n }\n\n // Attach a listener for the registration of an icon set\n // Leaving this attached allows for the registered set to be updated\n document.body.addEventListener(PfeIcon.EVENTS.ADD_ICON_SET, () =>\n this.updateIcon()\n );\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n\n if (this.image) {\n this.image.removeEventListener(\"load\", this._iconLoad);\n this.image.removeEventListener(\"error\", this._iconLoadError);\n }\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n super.attributeChangedCallback(...arguments);\n this.updateIcon(newValue);\n this.context_update();\n }\n\n updateIcon(iconName = this.getAttribute(\"icon\")) {\n const { set } = PfeIcon.getIconSet(iconName);\n if (set) {\n const iconPath = set.resolveIconName(iconName);\n this.image.setAttribute(\"xlink:href\", iconPath);\n _setRandomFilterId(this);\n }\n }\n\n /**\n * Get an icon set by providing the set's name, _or_ the name of an icon from that set.\n *\n * @param {String} iconName the name of the set, or the name of an icon from that set.\n * @return {PfeIconSet} the icon set\n */\n static getIconSet(iconName) {\n let set;\n if (iconName) {\n const [setName] = iconName.split(\"-\");\n set = this._iconSets[setName];\n }\n return { set };\n }\n\n static addIconSet(name, path, resolveIconName) {\n let resolveFunction;\n\n if (typeof resolveIconName === \"function\") {\n resolveFunction = resolveIconName;\n } else if (\n typeof resolveIconName === \"undefined\" &&\n this._iconSets[name] &&\n typeof this._iconSets[name]._resolveIconName === \"function\"\n ) {\n resolveFunction = this._iconSets[name]._resolveIconName;\n } else if (\n typeof resolveIconName !== \"function\" &&\n typeof resolveIconName !== \"undefined\"\n ) {\n console.warn(\n `${this.tag}: The third input to addIconSet should be a function that parses and returns the icon's filename.`\n );\n } else {\n console.warn(\n `${this.tag}: The set ${name} needs a resolve function for the icon names.`\n );\n }\n\n // Register the icon set and set up the event indicating the change\n this._iconSets[name] = new PfeIconSet(name, path, resolveFunction);\n\n document.body.dispatchEvent(\n new CustomEvent(this.EVENTS.ADD_ICON_SET, {\n bubbles: false,\n detail: {\n set: this._iconSets[name]\n }\n })\n );\n }\n}\n\nPfeIcon._iconSets = {};\n\naddBuiltIns(PfeIcon);\n\nPFElement.create(PfeIcon);\n\nexport default PfeIcon;\n"],"names":["PfeIconSet","iconName","_resolveIconName","name","path","resolveIconName","addBuiltIns","PfeIcon","forEach","addIconSet","set","iconSetName","iconSetPath","regex","RegExp","exec","iconId","iconPath","_setRandomFilterId","el","randomId","Math","random","toString","slice","shadowRoot","querySelector","style","filter","setAttribute","classList","remove","add","has_fallback","image","hasAttribute","children","length","innerText","PFElement","PfeTypes","Content","ADD_ICON_SET","tag","type","PfeType","_iconLoad","bind","_iconLoadError","addEventListener","document","body","EVENTS","updateIcon","removeEventListener","attr","oldValue","newValue","arguments","context_update","getAttribute","getIconSet","split","setName","_iconSets","resolveFunction","console","warn","dispatchEvent","CustomEvent","bubbles","detail","create"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAAMA;;;;EACJ;;;sCAGgBC,UAAU;EACxB,aAAO,KAAKC,gBAAL,CAAsBD,QAAtB,EAAgC,KAAKE,IAArC,EAA2C,KAAKC,IAAhD,CAAP;EACD;;EAED;;;;;;;;;;;;;;EAWA,sBAAYD,IAAZ,EAAkBC,IAAlB,EAAwBC,eAAxB,EAAyC;EAAA;;EACvC,SAAKF,IAAL,GAAYA,IAAZ;EACA,SAAKC,IAAL,GAAYA,IAAZ;EACA,SAAKF,gBAAL,GAAwBG,eAAxB;EACD;;;;;ECvBH;;;AAGA,EAAO,SAASC,WAAT,CAAqBC,OAArB,EAA8B;EACnC,GACE;EACEJ,UAAM,KADR;EAEEC,UAAM;EAFR,GADF,EAKE;EACED,UAAM,IADR;EAEEC,UAAM;EAFR,GALF,EASEI,OATF,CASU;EAAA,WACRD,QAAQE,UAAR,CAAmBC,OAAIP,IAAvB,EAA6BO,OAAIN,IAAjC,EAAuC,UAACD,IAAD,EAAOQ,WAAP,EAAoBC,WAApB,EAAoC;EACzE,UAAMC,QAAQ,IAAIC,MAAJ,OAAeH,WAAf,mBAAd;;EADyE,wBAElDE,MAAME,IAAN,CAAWZ,IAAX,CAFkD;EAAA;EAAA,UAE9DF,QAF8D;;EAIzE,UAAMe,SAAYL,WAAZ,cAAgCV,QAAtC;EACA,UAAMgB,WAAcL,WAAd,SAA6BI,MAA7B,SAAN;;EAEA,aAAOC,QAAP;EACD,KARD,CAD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AqBD,gBAA5B,KAAiD,UAH5C,EAIL;EACA+D,0BAAkB,KAAKD,SAAL,CAAe7D,IAAf,EAAqBD,gBAAvC;EACD,OANM,MAMA,IACL,OAAOG,eAAP,KAA2B,UAA3B,IACA,OAAOA,eAAP,KAA2B,WAFtB,EAGL;EACA6D,gBAAQC,IAAR,CACK,KAAKxB,GADV;EAGD,OAPM,MAOA;EACLuB,gBAAQC,IAAR,CACK,KAAKxB,GADV,kBAC0BxC,IAD1B;EAGD;;EAED;EACA,WAAK6D,SAAL,CAAe7D,IAAf,IAAuB,IAAIH,UAAJ,CAAeG,IAAf,EAAqBC,IAArB,EAA2B6D,eAA3B,CAAvB;;EAEAf,eAASC,IAAT,CAAciB,aAAd,CACE,IAAIC,WAAJ,CAAgB,KAAKjB,MAAL,CAAYV,YAA5B,EAA0C;EACxC4B,iBAAS,KAD+B;EAExCC,gBAAQ;EACN7D,eAAK,KAAKsD,SAAL,CAAe7D,IAAf;EADC;EAFgC,OAA1C,CADF;EAQD;;;IA1KmBoC;;EA6KtBhC,QAAQyD,SAAR,GAAoB,EAApB;;EAEA1D,YAAYC,OAAZ;;EAEAgC,UAAUiC,MAAV,CAAiBjE,OAAjB;;;;;;;;"} \ No newline at end of file diff --git a/elements/pfe-icon/dist/pfe-icon.umd.min.js b/elements/pfe-icon/dist/pfe-icon.umd.min.js new file mode 100644 index 0000000000..140b316f24 --- /dev/null +++ b/elements/pfe-icon/dist/pfe-icon.umd.min.js @@ -0,0 +1,2 @@ +!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o(require("../../pfelement/dist/pfelement.umd")):"function"==typeof define&&define.amd?define(["../../pfelement/dist/pfelement.umd"],o):e.PfeIcon=o(e.PFElement)}(this,function(e){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e;function r(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}var o=function(e,o,t){return o&&n(e.prototype,o),t&&n(e,t),e};function n(e,o){for(var t=0;t@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host{color:#151515!important}}:host([on=dark]){--pfe-broadcasted--text:var(--pfe-theme--color--text--on-dark, #fff);--pfe-broadcasted--link:var(--pfe-theme--color--link--on-dark, #73bcf7);--pfe-broadcasted--link--hover:var(--pfe-theme--color--link--hover--on-dark, #bee1f4);--pfe-broadcasted--link--focus:var(--pfe-theme--color--link--focus--on-dark, #bee1f4);--pfe-broadcasted--link--visited:var(--pfe-theme--color--link--visited--on-dark, #bee1f4);--pfe-broadcasted--link-decoration:var(--pfe-theme--link-decoration--on-dark, none);--pfe-broadcasted--link-decoration--hover:var(--pfe-theme--link-decoration--hover--on-dark, underline);--pfe-broadcasted--link-decoration--focus:var(--pfe-theme--link-decoration--focus--on-dark, underline);--pfe-broadcasted--link-decoration--visited:var(--pfe-theme--link-decoration--visited--on-dark, none)}:host([on=saturated]){--pfe-broadcasted--text:var(--pfe-theme--color--text--on-saturated, #fff);--pfe-broadcasted--link:var(--pfe-theme--color--link--on-saturated, #fff);--pfe-broadcasted--link--hover:var(--pfe-theme--color--link--hover--on-saturated, #fafafa);--pfe-broadcasted--link--focus:var(--pfe-theme--color--link--focus--on-saturated, #fafafa);--pfe-broadcasted--link--visited:var(--pfe-theme--color--link--visited--on-saturated, #8476d1);--pfe-broadcasted--link-decoration:var(--pfe-theme--link-decoration--on-saturated, underline);--pfe-broadcasted--link-decoration--hover:var(--pfe-theme--link-decoration--hover--on-saturated, underline);--pfe-broadcasted--link-decoration--focus:var(--pfe-theme--link-decoration--focus--on-saturated, underline);--pfe-broadcasted--link-decoration--visited:var(--pfe-theme--link-decoration--visited--on-saturated, underline)}:host([on=light]){--pfe-broadcasted--text:var(--pfe-theme--color--text, #151515);--pfe-broadcasted--link:var(--pfe-theme--color--link, #06c);--pfe-broadcasted--link--hover:var(--pfe-theme--color--link--hover, #004080);--pfe-broadcasted--link--focus:var(--pfe-theme--color--link--focus, #004080);--pfe-broadcasted--link--visited:var(--pfe-theme--color--link--visited, #6753ac);--pfe-broadcasted--link-decoration:var(--pfe-theme--link-decoration, none);--pfe-broadcasted--link-decoration--hover:var(--pfe-theme--link-decoration--hover, underline);--pfe-broadcasted--link-decoration--focus:var(--pfe-theme--link-decoration--focus, underline);--pfe-broadcasted--link-decoration--visited:var(--pfe-theme--link-decoration--visited, none)}:host{--theme:var(--pfe-icon--theme, light);position:relative;display:inline-block;max-width:calc(1em + 0 * 2);max-width:calc(var(--pfe-icon--size,var(--pfe-theme--icon-size,1em)) + var(--pfe-icon--Padding,0) * 2);width:-webkit-fit-content!important;width:-moz-fit-content!important;width:fit-content!important;max-height:calc(1em + 0 * 2);max-height:calc(var(--pfe-icon--size,var(--pfe-theme--icon-size,1em)) + var(--pfe-icon--Padding,0) * 2);height:-webkit-fit-content!important;height:-moz-fit-content!important;height:fit-content!important;line-height:0}:host([data-block]){display:block;margin-bottom:16px;margin-bottom:var(--pfe-icon--spacing,var(--pfe-theme--container-spacer,16px));margin-top:16px;margin-top:var(--pfe-icon--spacing,var(--pfe-theme--container-spacer,16px))}:host([data-block]):first-child{margin-top:0}:host svg{width:1em;width:var(--pfe-icon--size,var(--pfe-theme--icon-size,1em));height:1em;height:var(--pfe-icon--size,var(--pfe-theme--icon-size,1em))}:host(:not(.load-failed)){vertical-align:middle;border-radius:50%;background-color:transparent;background-color:var(--pfe-icon--BackgroundColor,transparent);border:0 solid transparent;border:var(--pfe-icon--BorderWidth,0) var(--pfe-theme--ui--border-style,solid) var(--pfe-icon--BorderColor,var(--pfe-icon--color,transparent));padding:0;padding:var(--pfe-icon--Padding,0)}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host(:not(.load-failed)){background-color:#fff!important}:host(:not(.load-failed)) svg filter feFlood{flood-color:#000!important}}@supports (-ms-accelerator:true){:host(:not(.load-failed)){background-color:#fff!important}:host(:not(.load-failed)) svg filter feFlood{flood-color:#000!important}}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){:host(:not(.load-failed)) svg image{-webkit-filter:none;filter:none}}:host(:not(.load-failed)) filter feFlood{flood-color:#3c3f42;flood-color:var(--pfe-icon--Color,var(--pfe-icon--color,var(--pfe-broadcasted--text,#3c3f42)))}:host(:not(.load-failed)) .pfe-icon--fallback{display:none}:host([pfe-size="2x"]){--pfe-icon--size:2em}:host([pfe-size="3x"]){--pfe-icon--size:3em}:host([pfe-size="4x"]){--pfe-icon--size:4em}:host([pfe-size=xl]){--pfe-icon--size:100px}:host([pfe-size=lg]){--pfe-icon--size:64px}:host([pfe-size=md]){--pfe-icon--size:32px}:host([pfe-size=sm]){--pfe-icon--size:14px}:host([pfe-color=critical]){--pfe-icon--color:var(--pfe-theme--color--feedback--critical, #bb0000);--pfe-icon--theme:dark}:host([pfe-color=important]){--pfe-icon--color:var(--pfe-theme--color--feedback--important, #d73401);--pfe-icon--theme:dark}:host([pfe-color=moderate]){--pfe-icon--color:var(--pfe-theme--color--feedback--moderate, #ffc024)}:host([pfe-color=success]){--pfe-icon--color:var(--pfe-theme--color--feedback--success, #2e7d32);--pfe-icon--theme:dark}:host([pfe-color=info]){--pfe-icon--color:var(--pfe-theme--color--feedback--info, #0277bd);--pfe-icon--theme:dark}:host([pfe-color=default]){--pfe-icon--color:var(--pfe-theme--color--feedback--default, #4f5255);--pfe-icon--theme:dark}:host([pfe-color=lightest]){--pfe-icon--color:var(--pfe-theme--color--surface--lightest, #fff);--pfe-icon--theme:light}:host([pfe-color=base]){--pfe-icon--color:var(--pfe-theme--color--surface--base, #f0f0f0);--pfe-icon--theme:light}:host([pfe-color=darker]){--pfe-icon--color:var(--pfe-theme--color--surface--darker, #3c3f42);--pfe-icon--theme:dark}:host([pfe-color=darkest]){--pfe-icon--color:var(--pfe-theme--color--surface--darkest, #151515);--pfe-icon--theme:dark}:host([pfe-color=complement]){--pfe-icon--color:var(--pfe-theme--color--surface--complement, #002952);--pfe-icon--theme:saturated}:host([pfe-color=accent]){--pfe-icon--color:var(--pfe-theme--color--surface--accent, #004080);--pfe-icon--theme:saturated}:host([pfe-circled]:not([pfe-circled=false])){--pfe-icon--BackgroundColor:var(--pfe-icon--color, var(--pfe-theme--color--surface--lightest, #fff));--pfe-icon--Color:var(--pfe-broadcasted--text, #3c3f42);--pfe-icon--Padding:0.5em;--pfe-icon--BorderWidth:var(--pfe-theme--ui--border-width, 1px);--pfe-icon--BorderColor:var(--pfe-icon--color, var(--pfe-theme--color--surface--border, #d2d2d2))}:host(.load-failed) svg image{display:none}:host(.load-failed.has-fallback) svg,:host(.load-failed[on-fail=collapse]) svg{display:none}:host(.load-failed[on-fail=collapse]){--pfe-icon--size:0}\n/*# sourceMappingURL=pfe-icon.min.css.map */\n
    \n \n
    \n\n \n \n \n \n \n'}},{key:"templateUrl",get:function(){return"pfe-icon.html"}},{key:"styleUrl",get:function(){return"pfe-icon.scss"}},{key:"schemaUrl",get:function(){return"pfe-icon.json"}},{key:"upgraded",get:function(){return this.image.hasAttribute("xlink:href")}},{key:"has_fallback",get:function(){return 0\n PfeIcon.addIconSet(set.name, set.path, (name, iconSetName, iconSetPath) => {\n const regex = new RegExp(`^${iconSetName}(-icon)?-(.*)`);\n const [, , iconName] = regex.exec(name);\n\n const iconId = `${iconSetName}-icon-${iconName}`;\n const iconPath = `${iconSetPath}/${iconId}.svg`;\n\n return iconPath;\n })\n );\n}\n","/*!\n * PatternFly Elements: PfeIcon 1.0.0-prerelease.54\n * @license\n * Copyright 2020 Red Hat, Inc.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n*/\n\nimport PFElement from \"../../pfelement/dist/pfelement.umd\";\nimport PfeIconSet from \"./icon-set.js\";\nimport { addBuiltIns } from \"./builtin-icon-sets.js\";\n\n/**\n * Sets the id attribute on the element and points the CSS `filter` at that id.\n */\nfunction _setRandomFilterId(el) {\n const randomId =\n \"filter-\" +\n Math.random()\n .toString()\n .slice(2, 10);\n\n // set the CSS filter property to point at the given id\n el.shadowRoot.querySelector(\"svg image\").style.filter = `url(#${randomId})`;\n\n // set the id attribute on the SVG filter element to match\n el.shadowRoot.querySelector(\"svg filter\").setAttribute(\"id\", randomId);\n}\n\nclass PfeIcon extends PFElement {\n static get version() {\n return \"1.0.0-prerelease.54\";\n }\n\n get html() {\n return `
    \n \n
    \n\n \n \n \n \n \n`;\n }\n\n static get properties() {\n return {\"icon\":{\"title\":\"Icon\",\"type\":\"string\",\"prefixed\":false},\"size\":{\"title\":\"Size\",\"type\":\"string\",\"enum\":[\"xl\",\"lg\",\"md\",\"sm\",\"2x\",\"3x\",\"4x\"],\"prefixed\":true},\"color\":{\"title\":\"Color\",\"type\":\"string\",\"enum\":[\"complement\",\"accent\",\"lightest\",\"base\",\"darker\",\"darkest\",\"critical\",\"important\",\"moderate\",\"success\",\"info\"],\"prefixed\":true},\"circled\":{\"title\":\"Circled\",\"type\":\"boolean\",\"default\":false,\"prefixed\":true}};\n }\n\n static get slots() {\n return {};\n }\n static get tag() {\n return \"pfe-icon\";\n }\n\n get templateUrl() {\n return \"pfe-icon.html\";\n }\n\n get styleUrl() {\n return \"pfe-icon.scss\";\n }\n\n get schemaUrl() {\n return \"pfe-icon.json\";\n }\n\n // Declare the type of this component\n static get PfeType() {\n return PFElement.PfeTypes.Content;\n }\n\n static get EVENTS() {\n return {\n ADD_ICON_SET: `${this.tag}:add-icon-set`\n };\n }\n\n get upgraded() {\n return this.image.hasAttribute(\"xlink:href\");\n }\n\n get has_fallback() {\n return this.children.length > 0 || this.innerText.length > 0;\n }\n\n static get observedAttributes() {\n return [\"icon\", \"on-fail\", \"pfe-circled\", \"pfe-color\"];\n }\n\n _iconLoad() {\n this.classList.remove(\"load-failed\");\n }\n\n _iconLoadError() {\n this.classList.add(\"load-failed\");\n if (this.has_fallback) {\n this.classList.add(\"has-fallback\");\n }\n }\n\n constructor() {\n super(PfeIcon, { type: PfeIcon.PfeType });\n\n this._iconLoad = this._iconLoad.bind(this);\n this._iconLoadError = this._iconLoadError.bind(this);\n\n this.image = this.shadowRoot.querySelector(\"svg image\");\n if (this.image) {\n this.image.addEventListener(\"load\", this._iconLoad);\n this.image.addEventListener(\"error\", this._iconLoadError);\n }\n\n // Attach a listener for the registration of an icon set\n // Leaving this attached allows for the registered set to be updated\n document.body.addEventListener(PfeIcon.EVENTS.ADD_ICON_SET, () =>\n this.updateIcon()\n );\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n\n if (this.image) {\n this.image.removeEventListener(\"load\", this._iconLoad);\n this.image.removeEventListener(\"error\", this._iconLoadError);\n }\n }\n\n attributeChangedCallback(attr, oldValue, newValue) {\n super.attributeChangedCallback(...arguments);\n this.updateIcon(newValue);\n this.context_update();\n }\n\n updateIcon(iconName = this.getAttribute(\"icon\")) {\n const { set } = PfeIcon.getIconSet(iconName);\n if (set) {\n const iconPath = set.resolveIconName(iconName);\n this.image.setAttribute(\"xlink:href\", iconPath);\n _setRandomFilterId(this);\n }\n }\n\n /**\n * Get an icon set by providing the set's name, _or_ the name of an icon from that set.\n *\n * @param {String} iconName the name of the set, or the name of an icon from that set.\n * @return {PfeIconSet} the icon set\n */\n static getIconSet(iconName) {\n let set;\n if (iconName) {\n const [setName] = iconName.split(\"-\");\n set = this._iconSets[setName];\n }\n return { set };\n }\n\n static addIconSet(name, path, resolveIconName) {\n let resolveFunction;\n\n if (typeof resolveIconName === \"function\") {\n resolveFunction = resolveIconName;\n } else if (\n typeof resolveIconName === \"undefined\" &&\n this._iconSets[name] &&\n typeof this._iconSets[name]._resolveIconName === \"function\"\n ) {\n resolveFunction = this._iconSets[name]._resolveIconName;\n } else if (\n typeof resolveIconName !== \"function\" &&\n typeof resolveIconName !== \"undefined\"\n ) {\n console.warn(\n `${this.tag}: The third input to addIconSet should be a function that parses and returns the icon's filename.`\n );\n } else {\n console.warn(\n `${this.tag}: The set ${name} needs a resolve function for the icon names.`\n );\n }\n\n // Register the icon set and set up the event indicating the change\n this._iconSets[name] = new PfeIconSet(name, path, resolveFunction);\n\n document.body.dispatchEvent(\n new CustomEvent(this.EVENTS.ADD_ICON_SET, {\n bubbles: false,\n detail: {\n set: this._iconSets[name]\n }\n })\n );\n }\n}\n\nPfeIcon._iconSets = {};\n\naddBuiltIns(PfeIcon);\n\nPFElement.create(PfeIcon);\n\nexport default PfeIcon;\n"],"names":["PfeIconSet","iconName","this","_resolveIconName","name","path","resolveIconName","PfeIcon","PFElement","classList","remove","add","has_fallback","image","hasAttribute","children","length","innerText","icon","title","type","prefixed","size","enum","color","circled","default","PfeTypes","Content","tag","removeEventListener","_iconLoad","_iconLoadError","attr","oldValue","newValue","arguments","updateIcon","context_update","getAttribute","set","getIconSet","iconPath","setAttribute","el","randomId","Math","random","toString","slice","shadowRoot","querySelector","style","filter","split","setName","_iconSets","resolveFunction","warn","body","dispatchEvent","CustomEvent","EVENTS","ADD_ICON_SET","PfeType","_this","bind","addEventListener","forEach","addIconSet","iconSetName","iconSetPath","RegExp","exec","create"],"mappings":"6wCAAMA,8CAIYC,UACPC,KAAKC,iBAAiBF,EAAUC,KAAKE,KAAMF,KAAKG,wBAc7CD,EAAMC,EAAMC,kBACjBF,KAA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M,KAA1BC,cACDrD,KAAKsD,UAAUD,SAEhB,CAAEf,0CAGOpC,EAAMC,EAAMC,OACxBmD,SAE2B,mBAApBnD,IACSA,OAES,IAApBA,GACPJ,KAAKsD,UAAUpD,IACkC,mBAA1CF,KAAKsD,UAAUpD,GAAMD,mBAEVD,KAAKsD,UAAUpD,GAAMD,iBAEZ,mBAApBG,QACoB,IAApBA,UAECoD,KACHxD,KAAK2B,iHAGF6B,KACHxD,KAAK2B,iBAAgBzB,wDAKvBoD,UAAUpD,GAAQ,IAAIJ,EAAWI,EAAMC,EAAMoD,YAEzCE,KAAKC,cACZ,IAAIC,YAAY3D,KAAK4D,OAAOC,aAAc,UAC/B,SACD,KACD7D,KAAKsD,UAAUpD,oQAxFpBG,EAAS,CAAEa,KAAMb,EAAQyD,oBAE1BjC,UAAYkC,EAAKlC,UAAUmC,UAC3BlC,eAAiBiC,EAAKjC,eAAekC,UAErCrD,MAAQoD,EAAKf,WAAWC,cAAc,aACvCc,EAAKpD,UACFA,MAAMsD,iBAAiB,OAAQF,EAAKlC,aACpClB,MAAMsD,iBAAiB,QAASF,EAAKjC,0BAKnC2B,KAAKQ,iBAAiB5D,EAAQuD,OAAOC,aAAc,kBAC1DE,EAAK5B,wBAiFX9B,EAAQiD,UAAY,GDxNQjD,EC0NhBA,GDxNR,MACQ,WACA,qEAER,MACQ,UACA,sEAER6D,QAAQ,mBACR7D,EAAQ8D,WAAW7B,EAAIpC,KAAMoC,EAAInC,KAAM,SAACD,EAAMkE,EAAaC,SAC3C,IAAIC,WAAWF,mBACAG,KAAKrE,UAGdmE,MADFD,gCC6MxB9D,EAAUkE,OAAOnE"} \ No newline at end of file diff --git a/elements/pfe-icon/package-lock.json b/elements/pfe-icon/package-lock.json index f6444fe7b7..b1fd9c9acb 100644 --- a/elements/pfe-icon/package-lock.json +++ b/elements/pfe-icon/package-lock.json @@ -1,6 +1,6 @@ { "name": "@patternfly/pfe-icon", - "version": "1.0.0-prerelease.53", + "version": "1.0.0-prerelease.54", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/elements/pfe-icon/package.json b/elements/pfe-icon/package.json index f3759ad18b..dcd04883b6 100644 --- a/elements/pfe-icon/package.json +++ b/elements/pfe-icon/package.json @@ -4,7 +4,7 @@ "className": "PfeIcon", "elementName": "pfe-icon" }, - "version": "1.0.0-prerelease.53", + "version": "1.0.0-prerelease.54", "publishConfig": { "access": "public" }, @@ -38,7 +38,7 @@ "@patternfly/pfelement": "^1.0.0-prerelease.51" }, "devDependencies": { - "@patternfly/pfe-sass": "^1.0.0-prerelease.53" + "@patternfly/pfe-sass": "^1.0.0-prerelease.54" }, "generator-pfelement-version": "1.1.0", "bugs": { diff --git a/elements/pfe-jump-links/dist/pfe-jump-links.js b/elements/pfe-jump-links/dist/pfe-jump-links.js new file mode 100644 index 0000000000..1051449ca9 --- /dev/null +++ b/elements/pfe-jump-links/dist/pfe-jump-links.js @@ -0,0 +1,564 @@ +import PFElement from '../../pfelement/dist/pfelement.js'; + +/*! + * PatternFly Elements: PfeJumpLinks 1.0.0-prerelease.54 + * @license + * Copyright 2020 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * +*/ + +const pfeJumpLinksNavObserverConfig = { + childList: true, + subtree: true, + characterData: true, + attributes: true +}; + +const pfeJumpLinksPanelObserverConfig = { + childList: true, + subtree: true, + characterData: true, + attributes: true +}; + +class PfeJumpLinks extends PFElement { + static get version() { + return "1.0.0-prerelease.54"; + } + + get html() { + return ``; + } + + static get properties() { + return {}; + } + + static get slots() { + return {"default":{"title":"Default slot","type":"array","namedSlot":false,"items":{"oneOf":[{"$ref":"raw"}]}}}; + } + static get tag() { + return "pfe-jump-links"; + } + + get schemaUrl() { + return "pfe-jump-links.json"; + } + + get templateUrl() { + return "pfe-jump-links.html"; + } + + get styleUrl() { + return "pfe-jump-links.scss"; + } + + static get PfeType() { + return PFElement.PfeTypes.Content; + } + + constructor() { + super(PfeJumpLinks, { type: PfeJumpLinks.PfeType }); + } +} + +class PfeJumpLinksNav extends PFElement { + static get version() { + return "1.0.0-prerelease.54"; + } + + get html() { + return ` + ${this.hasAttribute("pfe-c-horizontal") ? `` : + ` + + + ` + } + + ${this.hasAttribute("pfe-c-horizontal") ? `` : + ` + ` + }`; + } + static get tag() { + return "pfe-jump-links-nav"; + } + + get schemaUrl() { + return "pfe-jump-links-nav.json"; + } + + get templateUrl() { + return "pfe-jump-links-nav.html"; + } + + get styleUrl() { + return "pfe-jump-links-nav.scss"; + } + + static get PfeType() { + return PFElement.PfeTypes.Content; + } + + constructor() { + super(PfeJumpLinksNav, { type: PfeJumpLinksNav.PfeType }); + + this._buildNav = this._buildNav.bind(this); + this._mutationCallback = this._mutationCallback.bind(this); + this._menuContainer = this.shadowRoot.querySelector("#container"); + this._observer = new MutationObserver(this._mutationCallback); + this._reportHeight = this._reportHeight.bind(this); + this.panel = document.querySelector(`[pfe-c-scrolltarget=${this.id}]`); + + window.addEventListener("resize", () => {}); + } + + connectedCallback() { + super.connectedCallback(); + //Check that the light DOM is there + if (this.hasAttribute("autobuild")) { + this._buildNav(); + } else { + //Check that the light DOM is valid + if (this._isValidLightDom()) { + const menu = this.querySelector("ul"); + menu.classList.add("pfe-jump-links-nav"); + this._menuContainer.innerHTML = menu.outerHTML; + + let div = document.createElement("div"); + + div.innerHTML = ``; + + if (this.getAttribute("sr-text")) { + this.shadowRoot.querySelector("nav").prepend(div); + } + + let html = ""; + if (this.querySelector("[slot='pfe-jump-links-nav--heading']")) { + html = this.querySelector( + "[slot='pfe-jump-links-nav--heading']" + ).cloneNode(true); + } + if (!this.hasAttribute("pfe-c-horizontal") && html !== "") { + this.shadowRoot + .querySelector("pfe-accordion-header") + .appendChild(html); + } else { + const heading = document.createElement("h3"); + heading.id = "pfe-jump-links-nav--heading"; + + this.shadowRoot + .querySelector("pfe-accordion-header") + .appendChild(heading); + this.shadowRoot.querySelector( + "#pfe-jump-links-nav--heading" + ).innerHTML = "Jump to section"; + } + } + } + this._reportHeight(); + + this._observer.observe(this, pfeJumpLinksNavObserverConfig); + + this.panel = document.querySelector(`[pfe-c-scrolltarget="${this.id}"]`); + + this.panel.addEventListener( + PfeJumpLinksPanel.events.change, + this._buildNav + ); + } + + disconnectedCallback() { + this._observer.disconnect(); + this.panel.removeEventListener( + PfeJumpLinksPanel.events.change, + this._buildNav + ); + this.removeEventListener("click"); + } + + _rebuildNav() { + this._buildNav(); + } + + _buildNav() { + const buildLinkList = () => { + let linkList = ``; + if (!this.panel) { + this.panel = document.querySelector( + `[pfe-c-scrolltarget="${this.id}"]` + ); + } + let panelSections = this.panel.querySelectorAll( + ".pfe-jump-links-panel__section" + ); + + for (let i = 0; i < panelSections.length; i++) { + let arr = [...panelSections]; + if (arr[i].classList.contains("has-sub-section")) { + let linkListItem = ` +
    `; + } + linkList += linkSubItem; + } else { + let linkListItem = ` + + `; + linkList += linkListItem; + } + } + return linkList; + }; + + let html = ` +