@travelopia/web-components 0.5.26 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accordion/index.js +1 -1
- package/dist/accordion/index.js.map +1 -1
- package/dist/declarations.d.ts +235 -54
- package/dist/form/index.js +1 -1
- package/dist/form/index.js.map +1 -1
- package/dist/lightbox/index.js +1 -1
- package/dist/lightbox/index.js.map +1 -1
- package/dist/lightbox/style.css +1 -1
- package/dist/modal/index.js +1 -1
- package/dist/modal/index.js.map +1 -1
- package/dist/multi-select/index.js +1 -1
- package/dist/multi-select/index.js.map +1 -1
- package/dist/slider/index.js +1 -1
- package/dist/slider/index.js.map +1 -1
- package/dist/tabs/index.js +1 -1
- package/dist/tabs/index.js.map +1 -1
- package/package.json +1 -1
package/dist/accordion/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(()=>{"use strict";class e extends HTMLElement{static get observedAttributes(){return["collapse-all","expand-all"]}attributeChangedCallback(e="",t="",s=""){t!==s&&(this.update(),"yes"!==s||"collapse-all"!==e&&"expand-all"!==e||this.dispatchEvent(new CustomEvent(e,{bubbles:!0})))}update(){const e=this.querySelectorAll("tp-accordion-item");if(!e)return;let t="";"yes"===this.getAttribute("expand-all")?t="expand-all":"yes"===this.getAttribute("collapse-all")&&(t="collapse-all"),""!==t&&e.forEach((e=>{"expand-all"===t?e.setAttribute("open","yes"):"collapse-all"===t&&e.removeAttribute("open")}))}}class t extends HTMLElement{}class s extends HTMLElement{
|
|
1
|
+
(()=>{"use strict";class e extends HTMLElement{static get observedAttributes(){return["collapse-all","expand-all"]}attributeChangedCallback(e="",t="",s=""){t!==s&&(this.update(),"yes"!==s||"collapse-all"!==e&&"expand-all"!==e||this.dispatchEvent(new CustomEvent(e,{bubbles:!0})))}update(){const e=this.querySelectorAll("tp-accordion-item");if(!e)return;let t="";"yes"===this.getAttribute("expand-all")?t="expand-all":"yes"===this.getAttribute("collapse-all")&&(t="collapse-all"),""!==t&&e.forEach((e=>{"expand-all"===t?e.setAttribute("open","yes"):"collapse-all"===t&&e.removeAttribute("open")}))}}class t extends HTMLElement{}class s extends HTMLElement{constructor(){var e;super(),null===(e=this.querySelector("button"))||void 0===e||e.addEventListener("click",this.toggle.bind(this))}toggle(){const e=this.closest("tp-accordion-item");e&&("yes"!==e.getAttribute("open")?e.setAttribute("open","yes"):e.removeAttribute("open"))}}class l extends HTMLElement{constructor(){var e;super(),null===(e=this.querySelector("button"))||void 0===e||e.addEventListener("click",(()=>this.collapseAll()))}collapseAll(){const e=this.closest("tp-accordion");e&&(e.removeAttribute("expand-all"),e.setAttribute("collapse-all","yes"))}}class o extends HTMLElement{constructor(){var e;super(),null===(e=this.querySelector("button"))||void 0===e||e.addEventListener("click",this.expandAll.bind(this))}expandAll(){const e=this.closest("tp-accordion");e&&(e.setAttribute("expand-all","yes"),e.removeAttribute("collapse-all"))}}class n extends HTMLElement{constructor(){super(),"yes"===this.getAttribute("open-by-default")&&this.setAttribute("open","yes")}static get observedAttributes(){return["open"]}attributeChangedCallback(e,t,s){t!==s&&"open"===e&&("yes"===s?this.open():this.close(),this.removeAttribute("open-by-default"))}open(){const e=this.querySelector("tp-accordion-content");e&&(this.dispatchEvent(new CustomEvent("before-open",{bubbles:!0})),((e,t=300,s=(()=>{}))=>{e.style.height=`${e.scrollHeight}px`,setTimeout((()=>{e.style.height="auto",s&&s()}),t)})(e,600),this.dispatchEvent(new CustomEvent("open",{bubbles:!0})))}close(){const e=this.querySelector("tp-accordion-content");e&&(this.dispatchEvent(new CustomEvent("before-close",{bubbles:!0})),((e,t=300,s=(()=>{}))=>{e.style.height=`${e.scrollHeight}px`,e.offsetHeight,e.style.height="0px",setTimeout((()=>{e.style.height="0px",s&&s()}),t)})(e,600),this.dispatchEvent(new CustomEvent("close",{bubbles:!0})))}}customElements.define("tp-accordion",e),customElements.define("tp-accordion-content",t),customElements.define("tp-accordion-handle",s),customElements.define("tp-accordion-collapse-all",l),customElements.define("tp-accordion-expand-all",o),customElements.define("tp-accordion-item",n)})();
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dist/accordion/index.js","mappings":"mBAQO,MAAMA,UAA2BC,YAMvC,6BAAWC,GACV,MAAO,CAAE,eAAgB,aAC1B,CASA,wBAAAC,CAA0BC,EAAe,GAAIC,EAAmB,GAAIC,EAAmB,IACjFD,IAAaC,IAIlBC,KAAKC,SAEA,QAAUF,GAAc,iBAAmBF,GAAQ,eAAiBA,GACxEG,KAAKE,cAAe,IAAIC,YAAaN,EAAM,CAAEO,SAAS,KAExD,CAKA,MAAAH,GAEC,MAAMI,EAAqDL,KAAKM,iBAAkB,qBAClF,IAAOD,EACN,OAID,IAAIE,EAAiB,GAChB,QAAUP,KAAKQ,aAAc,cACjCD,EAAS,aACE,QAAUP,KAAKQ,aAAc,kBACxCD,EAAS,gBAIL,KAAOA,GAKZF,EAAeI,SAAWC,IACpB,eAAiBH,EACrBG,EAAcC,aAAc,OAAQ,OACzB,iBAAmBJ,GAC9BG,EAAcE,gBAAiB,O,GAGlC,ECjEM,MAAMC,UAAkCnB,aCKxC,MAAMoB,UAAiCpB,YAI7C,iBAAAqB,G,MAC+B,QAA9B,EAAAf,KAAKgB,cAAe,iBAAU,SAAEC,iBAAkB,QAASjB,KAAKkB,OAAOC,KAAMnB,MAC9E,CAKA,MAAAkB,GACC,MAAMR,EAA+CV,KAAKoB,QAAS,qBAC5DV,IAIF,QAAUA,EAAcF,aAAc,QAC1CE,EAAcC,aAAc,OAAQ,OAEpCD,EAAcE,gBAAiB,QAEjC,ECtBM,MAAMS,UAAsC3B,YAIlD,iBAAAqB,G,MAC+B,QAA9B,EAAAf,KAAKgB,cAAe,iBAAU,SAAEC,iBAAkB,SAAS,IAAMjB,KAAKsB,eACvE,CAKA,WAAAA,GAEC,MAAMC,EAAuCvB,KAAKoB,QAAS,gBACpDG,IAKPA,EAAUX,gBAAiB,c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lBF,GACJA,G,GAECD,EAAU,EDqBXQ,CAAgBV,EAAS,KACzB7B,KAAKE,cAAe,IAAIC,YAAa,QAAS,CAAEC,SAAS,KAE3D,EEvDDoC,eAAeC,OAAQ,eAAgBhD,GACvC+C,eAAeC,OAAQ,uBAAwB5B,GAC/C2B,eAAeC,OAAQ,sBAAuB3B,GAC9C0B,eAAeC,OAAQ,4BAA6BpB,GACpDmB,eAAeC,OAAQ,0BAA2BjB,GAClDgB,eAAeC,OAAQ,oBAAqBf,E","sources":["webpack://@travelopia/web-components/./src/accordion/tp-accordion.ts","webpack://@travelopia/web-components/./src/accordion/tp-accordion-content.ts","webpack://@travelopia/web-components/./src/accordion/tp-accordion-handle.ts","webpack://@travelopia/web-components/./src/accordion/tp-accordion-collapse-all.ts","webpack://@travelopia/web-components/./src/accordion/tp-accordion-expand-all.ts","webpack://@travelopia/web-components/./src/accordion/tp-accordion-item.ts","webpack://@travelopia/web-components/./src/utility.ts","webpack://@travelopia/web-components/./src/accordion/index.ts"],"sourcesContent":["/**\n * Internal dependencies.\n */\nimport { TPAccordionItemElement } from './tp-accordion-item';\n\n/**\n * TP Accordion.\n */\nexport class TPAccordionElement extends HTMLElement {\n\t/**\n\t * Get observed attributes.\n\t *\n\t * @return {Array} List of observed attributes.\n\t */\n\tstatic get observedAttributes(): string[] {\n\t\treturn [ 'collapse-all', 'expand-all' ];\n\t}\n\n\t/**\n\t * Attribute changed callback.\n\t *\n\t * @param {string} name Attribute name.\n\t * @param {string} oldValue Old value.\n\t * @param {string} newValue New value.\n\t */\n\tattributeChangedCallback( name: string = '', oldValue: string = '', newValue: string = '' ): void {\n\t\tif ( oldValue === newValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.update();\n\n\t\tif ( 'yes' === newValue && ( 'collapse-all' === name || 'expand-all' === name ) ) {\n\t\t\tthis.dispatchEvent( new CustomEvent( name, { bubbles: true } ) );\n\t\t}\n\t}\n\n\t/**\n\t * Update.\n\t */\n\tupdate(): void {\n\t\t// Get accordion items.\n\t\tconst accordionItems: NodeListOf<TPAccordionItemElement> = this.querySelectorAll( 'tp-accordion-item' );\n\t\tif ( ! accordionItems ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Determine action.\n\t\tlet action: string = '';\n\t\tif ( 'yes' === this.getAttribute( 'expand-all' ) ) {\n\t\t\taction = 'expand-all';\n\t\t} else if ( 'yes' === this.getAttribute( 'collapse-all' ) ) {\n\t\t\taction = 'collapse-all';\n\t\t}\n\n\t\t// Check if we have an action.\n\t\tif ( '' === action ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Expand or collapse accordion items.\n\t\taccordionItems.forEach( ( accordionItem: TPAccordionItemElement ): void => {\n\t\t\tif ( 'expand-all' === action ) {\n\t\t\t\taccordionItem.setAttribute( 'open', 'yes' );\n\t\t\t} else if ( 'collapse-all' === action ) {\n\t\t\t\taccordionItem.removeAttribute( 'open' );\n\t\t\t}\n\t\t} );\n\t}\n}\n","/**\n * TP Accordion Content.\n */\nexport class TPAccordionContentElement extends HTMLElement {\n}\n","/**\n * Internal dependencies.\n */\nimport { TPAccordionItemElement } from './tp-accordion-item';\n\n/**\n * TP Accordion Handle.\n */\nexport class TPAccordionHandleElement extends HTMLElement {\n\t/**\n\t * Connected callback.\n\t */\n\tconnectedCallback(): void {\n\t\tthis.querySelector( 'button' )?.addEventListener( 'click', this.toggle.bind( this ) );\n\t}\n\n\t/**\n\t * Toggle accordion.\n\t */\n\ttoggle(): void {\n\t\tconst accordionItem: TPAccordionItemElement | null = this.closest( 'tp-accordion-item' );\n\t\tif ( ! accordionItem ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( 'yes' !== accordionItem.getAttribute( 'open' ) ) {\n\t\t\taccordionItem.setAttribute( 'open', 'yes' );\n\t\t} else {\n\t\t\taccordionItem.removeAttribute( 'open' );\n\t\t}\n\t}\n}\n","/**\n * Internal dependencies.\n */\nimport { TPAccordionElement } from './tp-accordion';\n\n/**\n * TP Accordion Collapse All.\n */\nexport class TPAccordionCollapseAllElement extends HTMLElement {\n\t/**\n\t * Connected callback.\n\t */\n\tconnectedCallback(): void {\n\t\tthis.querySelector( 'button' )?.addEventListener( 'click', () => this.collapseAll() );\n\t}\n\n\t/**\n\t * Collapse All.\n\t */\n\tcollapseAll(): void {\n\t\t// Get accordion element.\n\t\tconst accordion: TPAccordionElement | null = this.closest( 'tp-accordion' );\n\t\tif ( ! accordion ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Set attributes for expand-all and collapse-all.\n\t\taccordion.removeAttribute( 'expand-all' );\n\t\taccordion.setAttribute( 'collapse-all', 'yes' );\n\t}\n}\n","/**\n * Internal dependencies.\n */\nimport { TPAccordionElement } from './tp-accordion';\n\n/**\n * TP Accordion Expand All.\n */\nexport class TPAccordionExpandAllElement extends HTMLElement {\n\t/**\n\t * Connected callback.\n\t */\n\tconnectedCallback(): void {\n\t\tthis.querySelector( 'button' )?.addEventListener( 'click', this.expandAll.bind( this ) );\n\t}\n\n\t/**\n\t * Expand all.\n\t */\n\texpandAll() {\n\t\t// Get accordion.\n\t\tconst accordion: TPAccordionElement | null = this.closest( 'tp-accordion' );\n\t\tif ( ! accordion ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Set attributes for expand-all and collapse-all.\n\t\taccordion.setAttribute( 'expand-all', 'yes' );\n\t\taccordion.removeAttribute( 'collapse-all' );\n\t}\n}\n","/**\n * Internal dependencies.\n */\nimport { TPAccordionContentElement } from './tp-accordion-content';\nimport { slideElementDown, slideElementUp } from '../utility';\n\n/**\n * TP Accordion Item.\n */\nexport class TPAccordionItemElement extends HTMLElement {\n\t/**\n\t * Connected callbacl.\n\t */\n\tconnectedCallback(): void {\n\t\tif ( 'yes' === this.getAttribute( 'open-by-default' ) ) {\n\t\t\tthis.setAttribute( 'open', 'yes' );\n\t\t}\n\t}\n\n\t/**\n\t * Get observed attributes.\n\t *\n\t * @return {Array} List of observed attributes.\n\t */\n\tstatic get observedAttributes(): string[] {\n\t\treturn [ 'open' ];\n\t}\n\n\t/**\n\t * Attributes callback.\n\t *\n\t * Fired on attribute change.\n\t *\n\t * @param {string} name Attribute Name.\n\t * @param {string} oldValue Old Value.\n\t * @param {string} newValue New Value.\n\t */\n\tattributeChangedCallback( name: string, oldValue: string, newValue: string ): void {\n\t\tif ( oldValue === newValue || 'open' !== name ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( 'yes' === newValue ) {\n\t\t\tthis.open();\n\t\t} else {\n\t\t\tthis.close();\n\t\t}\n\n\t\tthis.removeAttribute( 'open-by-default' );\n\t}\n\n\t/**\n\t * Open accordion item.\n\t */\n\topen(): void {\n\t\tconst content: TPAccordionContentElement | null = this.querySelector( 'tp-accordion-content' );\n\t\tif ( content ) {\n\t\t\tthis.dispatchEvent( new CustomEvent( 'before-open', { bubbles: true } ) );\n\t\t\tslideElementDown( content, 600 );\n\t\t\tthis.dispatchEvent( new CustomEvent( 'open', { bubbles: true } ) );\n\t\t}\n\t}\n\n\t/**\n\t * Close accordion item.\n\t */\n\tclose(): void {\n\t\tconst content: TPAccordionContentElement | null = this.querySelector( 'tp-accordion-content' );\n\t\tif ( content ) {\n\t\t\tthis.dispatchEvent( new CustomEvent( 'before-close', { bubbles: true } ) );\n\t\t\tslideElementUp( content, 600 );\n\t\t\tthis.dispatchEvent( new CustomEvent( 'close', { bubbles: true } ) );\n\t\t}\n\t}\n}\n","/**\n * Utility functions.\n */\n\n/**\n * Slide element down.\n *\n * @param {HTMLElement|null} element Target element.\n * @param {number} duration Animation duration.\n * @param {Function} callback Callback function.\n */\nexport const slideElementDown = ( element: HTMLElement, duration: number = 300, callback: Function = () => {} ) => { // eslint-disable-line\n\t// Get element height.\n\telement.style.height = `${ element.scrollHeight }px`;\n\n\t// Set timeout.\n\tsetTimeout( () => {\n\t\t// Set element's height.\n\t\telement.style.height = 'auto';\n\n\t\t// If callback is available, call the function.\n\t\tif ( callback ) {\n\t\t\tcallback();\n\t\t}\n\t}, duration );\n};\n\n/**\n * Slide element up.\n *\n * @param {HTMLElement|null} element Target element.\n * @param {number} duration Animation duration.\n * @param {Function} callback Callback function.\n */\nexport const slideElementUp = ( element: HTMLElement, duration: number = 300, callback: Function = () => {} ) => { // eslint-disable-line\n\t// Get element height.\n\telement.style.height = `${ element.scrollHeight }px`;\n\telement.offsetHeight; // eslint-disable-line\n\telement.style.height = '0px';\n\n\t// Set timeout.\n\tsetTimeout( () => {\n\t\t// Set element's height.\n\t\telement.style.height = '0px';\n\n\t\t// If callback is available, call the function.\n\t\tif ( callback ) {\n\t\t\tcallback();\n\t\t}\n\t}, duration );\n};\n","/**\n * Styles.\n */\nimport './style.scss';\n\n/**\n * Components.\n */\nimport { TPAccordionElement } from './tp-accordion';\nimport { TPAccordionContentElement } from './tp-accordion-content';\nimport { TPAccordionHandleElement } from './tp-accordion-handle';\nimport { TPAccordionCollapseAllElement } from './tp-accordion-collapse-all';\nimport { TPAccordionExpandAllElement } from './tp-accordion-expand-all';\nimport { TPAccordionItemElement } from './tp-accordion-item';\n\n/**\n * Initialize.\n */\ncustomElements.define( 'tp-accordion', TPAccordionElement );\ncustomElements.define( 'tp-accordion-content', TPAccordionContentElement );\ncustomElements.define( 'tp-accordion-handle', TPAccordionHandleElement );\ncustomElements.define( 'tp-accordion-collapse-all', TPAccordionCollapseAllElement );\ncustomElements.define( 'tp-accordion-expand-all', TPAccordionExpandAllElement );\ncustomElements.define( 'tp-accordion-item', TPAccordionItemElement );\n"],"names":["TPAccordionElement","HTMLElement","observedAttributes","attributeChangedCallback","name","oldValue","newValue","this","update","dispatchEvent","CustomEvent","bubbles","accordionItems","querySelectorAll","action","getAttribute","forEach","accordionItem","setAttribute","removeAttribute","TPAccordionContentElement","TPAccordionHandleElement","connectedCallback","querySelector","addEventListener","toggle","bind","closest","TPAccordionCollapseAllElement","collapseAll","accordion","TPAccordionExpandAllElement","expandAll","TPAccordionItemElement","open","close","content","element","duration","callback","style","height","scrollHeight","setTimeout","slideElementDown","offsetHeight","slideElementUp","customElements","define"],"s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AAe,IAAIC,YAAa,QAAS,CAAEC,SAAS,KAE3D,EEzDDqC,eAAeC,OAAQ,eAAgBjD,GACvCgD,eAAeC,OAAQ,uBAAwB7B,GAC/C4B,eAAeC,OAAQ,sBAAuB5B,GAC9C2B,eAAeC,OAAQ,4BAA6BpB,GACpDmB,eAAeC,OAAQ,0BAA2BjB,GAClDgB,eAAeC,OAAQ,oBAAqBf,E","sources":["webpack://@travelopia/web-components/./src/accordion/tp-accordion.ts","webpack://@travelopia/web-components/./src/accordion/tp-accordion-content.ts","webpack://@travelopia/web-components/./src/accordion/tp-accordion-handle.ts","webpack://@travelopia/web-components/./src/accordion/tp-accordion-collapse-all.ts","webpack://@travelopia/web-components/./src/accordion/tp-accordion-expand-all.ts","webpack://@travelopia/web-components/./src/accordion/tp-accordion-item.ts","webpack://@travelopia/web-components/./src/utility.ts","webpack://@travelopia/web-components/./src/accordion/index.ts"],"sourcesContent":["/**\n * Internal dependencies.\n */\nimport { TPAccordionItemElement } from './tp-accordion-item';\n\n/**\n * TP Accordion.\n */\nexport class TPAccordionElement extends HTMLElement {\n\t/**\n\t * Get observed attributes.\n\t *\n\t * @return {Array} List of observed attributes.\n\t */\n\tstatic get observedAttributes(): string[] {\n\t\treturn [ 'collapse-all', 'expand-all' ];\n\t}\n\n\t/**\n\t * Attribute changed callback.\n\t *\n\t * @param {string} name Attribute name.\n\t * @param {string} oldValue Old value.\n\t * @param {string} newValue New value.\n\t */\n\tattributeChangedCallback( name: string = '', oldValue: string = '', newValue: string = '' ): void {\n\t\tif ( oldValue === newValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.update();\n\n\t\tif ( 'yes' === newValue && ( 'collapse-all' === name || 'expand-all' === name ) ) {\n\t\t\tthis.dispatchEvent( new CustomEvent( name, { bubbles: true } ) );\n\t\t}\n\t}\n\n\t/**\n\t * Update.\n\t */\n\tupdate(): void {\n\t\t// Get accordion items.\n\t\tconst accordionItems: NodeListOf<TPAccordionItemElement> = this.querySelectorAll( 'tp-accordion-item' );\n\t\tif ( ! accordionItems ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Determine action.\n\t\tlet action: string = '';\n\t\tif ( 'yes' === this.getAttribute( 'expand-all' ) ) {\n\t\t\taction = 'expand-all';\n\t\t} else if ( 'yes' === this.getAttribute( 'collapse-all' ) ) {\n\t\t\taction = 'collapse-all';\n\t\t}\n\n\t\t// Check if we have an action.\n\t\tif ( '' === action ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Expand or collapse accordion items.\n\t\taccordionItems.forEach( ( accordionItem: TPAccordionItemElement ): void => {\n\t\t\tif ( 'expand-all' === action ) {\n\t\t\t\taccordionItem.setAttribute( 'open', 'yes' );\n\t\t\t} else if ( 'collapse-all' === action ) {\n\t\t\t\taccordionItem.removeAttribute( 'open' );\n\t\t\t}\n\t\t} );\n\t}\n}\n","/**\n * TP Accordion Content.\n */\nexport class TPAccordionContentElement extends HTMLElement {\n}\n","/**\n * Internal dependencies.\n */\nimport { TPAccordionItemElement } from './tp-accordion-item';\n\n/**\n * TP Accordion Handle.\n */\nexport class TPAccordionHandleElement extends HTMLElement {\n\t/**\n\t * Constructor.\n\t */\n\tconstructor() {\n\t\tsuper();\n\t\tthis.querySelector( 'button' )?.addEventListener( 'click', this.toggle.bind( this ) );\n\t}\n\n\t/**\n\t * Toggle accordion.\n\t */\n\ttoggle(): void {\n\t\tconst accordionItem: TPAccordionItemElement | null = this.closest( 'tp-accordion-item' );\n\t\tif ( ! accordionItem ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( 'yes' !== accordionItem.getAttribute( 'open' ) ) {\n\t\t\taccordionItem.setAttribute( 'open', 'yes' );\n\t\t} else {\n\t\t\taccordionItem.removeAttribute( 'open' );\n\t\t}\n\t}\n}\n","/**\n * Internal dependencies.\n */\nimport { TPAccordionElement } from './tp-accordion';\n\n/**\n * TP Accordion Collapse All.\n */\nexport class TPAccordionCollapseAllElement extends HTMLElement {\n\t/**\n\t * Constructor.\n\t */\n\tconstructor() {\n\t\tsuper();\n\t\tthis.querySelector( 'button' )?.addEventListener( 'click', () => this.collapseAll() );\n\t}\n\n\t/**\n\t * Collapse All.\n\t */\n\tcollapseAll(): void {\n\t\t// Get accordion element.\n\t\tconst accordion: TPAccordionElement | null = this.closest( 'tp-accordion' );\n\t\tif ( ! accordion ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Set attributes for expand-all and collapse-all.\n\t\taccordion.removeAttribute( 'expand-all' );\n\t\taccordion.setAttribute( 'collapse-all', 'yes' );\n\t}\n}\n","/**\n * Internal dependencies.\n */\nimport { TPAccordionElement } from './tp-accordion';\n\n/**\n * TP Accordion Expand All.\n */\nexport class TPAccordionExpandAllElement extends HTMLElement {\n\t/**\n\t * Constructor.\n\t */\n\tconstructor() {\n\t\tsuper();\n\t\tthis.querySelector( 'button' )?.addEventListener( 'click', this.expandAll.bind( this ) );\n\t}\n\n\t/**\n\t * Expand all.\n\t */\n\texpandAll() {\n\t\t// Get accordion.\n\t\tconst accordion: TPAccordionElement | null = this.closest( 'tp-accordion' );\n\t\tif ( ! accordion ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Set attributes for expand-all and collapse-all.\n\t\taccordion.setAttribute( 'expand-all', 'yes' );\n\t\taccordion.removeAttribute( 'collapse-all' );\n\t}\n}\n","/**\n * Internal dependencies.\n */\nimport { TPAccordionContentElement } from './tp-accordion-content';\nimport { slideElementDown, slideElementUp } from '../utility';\n\n/**\n * TP Accordion Item.\n */\nexport class TPAccordionItemElement extends HTMLElement {\n\t/**\n\t * Constructor.\n\t */\n\tconstructor() {\n\t\tsuper();\n\n\t\tif ( 'yes' === this.getAttribute( 'open-by-default' ) ) {\n\t\t\tthis.setAttribute( 'open', 'yes' );\n\t\t}\n\t}\n\n\t/**\n\t * Get observed attributes.\n\t *\n\t * @return {Array} List of observed attributes.\n\t */\n\tstatic get observedAttributes(): string[] {\n\t\treturn [ 'open' ];\n\t}\n\n\t/**\n\t * Attributes callback.\n\t *\n\t * Fired on attribute change.\n\t *\n\t * @param {string} name Attribute Name.\n\t * @param {string} oldValue Old Value.\n\t * @param {string} newValue New Value.\n\t */\n\tattributeChangedCallback( name: string, oldValue: string, newValue: string ): void {\n\t\tif ( oldValue === newValue || 'open' !== name ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( 'yes' === newValue ) {\n\t\t\tthis.open();\n\t\t} else {\n\t\t\tthis.close();\n\t\t}\n\n\t\tthis.removeAttribute( 'open-by-default' );\n\t}\n\n\t/**\n\t * Open accordion item.\n\t */\n\topen(): void {\n\t\tconst content: TPAccordionContentElement | null = this.querySelector( 'tp-accordion-content' );\n\t\tif ( content ) {\n\t\t\tthis.dispatchEvent( new CustomEvent( 'before-open', { bubbles: true } ) );\n\t\t\tslideElementDown( content, 600 );\n\t\t\tthis.dispatchEvent( new CustomEvent( 'open', { bubbles: true } ) );\n\t\t}\n\t}\n\n\t/**\n\t * Close accordion item.\n\t */\n\tclose(): void {\n\t\tconst content: TPAccordionContentElement | null = this.querySelector( 'tp-accordion-content' );\n\t\tif ( content ) {\n\t\t\tthis.dispatchEvent( new CustomEvent( 'before-close', { bubbles: true } ) );\n\t\t\tslideElementUp( content, 600 );\n\t\t\tthis.dispatchEvent( new CustomEvent( 'close', { bubbles: true } ) );\n\t\t}\n\t}\n}\n","/**\n * Utility functions.\n */\n\n/**\n * Slide element down.\n *\n * @param {HTMLElement|null} element Target element.\n * @param {number} duration Animation duration.\n * @param {Function} callback Callback function.\n */\nexport const slideElementDown = ( element: HTMLElement, duration: number = 300, callback: Function = () => {} ) => { // eslint-disable-line\n\t// Get element height.\n\telement.style.height = `${ element.scrollHeight }px`;\n\n\t// Set timeout.\n\tsetTimeout( () => {\n\t\t// Set element's height.\n\t\telement.style.height = 'auto';\n\n\t\t// If callback is available, call the function.\n\t\tif ( callback ) {\n\t\t\tcallback();\n\t\t}\n\t}, duration );\n};\n\n/**\n * Slide element up.\n *\n * @param {HTMLElement|null} element Target element.\n * @param {number} duration Animation duration.\n * @param {Function} callback Callback function.\n */\nexport const slideElementUp = ( element: HTMLElement, duration: number = 300, callback: Function = () => {} ) => { // eslint-disable-line\n\t// Get element height.\n\telement.style.height = `${ element.scrollHeight }px`;\n\telement.offsetHeight; // eslint-disable-line\n\telement.style.height = '0px';\n\n\t// Set timeout.\n\tsetTimeout( () => {\n\t\t// Set element's height.\n\t\telement.style.height = '0px';\n\n\t\t// If callback is available, call the function.\n\t\tif ( callback ) {\n\t\t\tcallback();\n\t\t}\n\t}, duration );\n};\n","/**\n * Styles.\n */\nimport './style.scss';\n\n/**\n * Components.\n */\nimport { TPAccordionElement } from './tp-accordion';\nimport { TPAccordionContentElement } from './tp-accordion-content';\nimport { TPAccordionHandleElement } from './tp-accordion-handle';\nimport { TPAccordionCollapseAllElement } from './tp-accordion-collapse-all';\nimport { TPAccordionExpandAllElement } from './tp-accordion-expand-all';\nimport { TPAccordionItemElement } from './tp-accordion-item';\n\n/**\n * Initialize.\n */\ncustomElements.define( 'tp-accordion', TPAccordionElement );\ncustomElements.define( 'tp-accordion-content', TPAccordionContentElement );\ncustomElements.define( 'tp-accordion-handle', TPAccordionHandleElement );\ncustomElements.define( 'tp-accordion-collapse-all', TPAccordionCollapseAllElement );\ncustomElements.define( 'tp-accordion-expand-all', TPAccordionExpandAllElement );\ncustomElements.define( 'tp-accordion-item', TPAccordionItemElement );\n"],"names":["TPAccordionElement","HTMLElement","observedAttributes","attributeChangedCallback","name","oldValue","newValue","this","update","dispatchEvent","CustomEvent","bubbles","accordionItems","querySelectorAll","action","getAttribute","forEach","accordionItem","setAttribute","removeAttribute","TPAccordionContentElement","TPAccordionHandleElement","constructor","super","querySelector","addEventListener","toggle","bind","closest","TPAccordionCollapseAllElement","collapseAll","accordion","TPAccordionExpandAllElement","expandAll","TPAccordionItemElement","open","close","content","element","duration","callback","style","height","scrollHeight","setTimeout","slideElementDown","offsetHeight","slideElementUp","customElements","define"],"sourceRoot":""}
|
package/dist/declarations.d.ts
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export class TPAccordionCollapseAllElement extends HTMLElement {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Constructor.
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
constructor();
|
|
9
9
|
/**
|
|
10
10
|
* Collapse All.
|
|
11
11
|
*/
|
|
@@ -23,9 +23,9 @@ export class TPAccordionContentElement extends HTMLElement {
|
|
|
23
23
|
*/
|
|
24
24
|
export class TPAccordionExpandAllElement extends HTMLElement {
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* Constructor.
|
|
27
27
|
*/
|
|
28
|
-
|
|
28
|
+
constructor();
|
|
29
29
|
/**
|
|
30
30
|
* Expand all.
|
|
31
31
|
*/
|
|
@@ -37,9 +37,9 @@ export class TPAccordionExpandAllElement extends HTMLElement {
|
|
|
37
37
|
*/
|
|
38
38
|
export class TPAccordionHandleElement extends HTMLElement {
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* Constructor.
|
|
41
41
|
*/
|
|
42
|
-
|
|
42
|
+
constructor();
|
|
43
43
|
/**
|
|
44
44
|
* Toggle accordion.
|
|
45
45
|
*/
|
|
@@ -51,9 +51,9 @@ export class TPAccordionHandleElement extends HTMLElement {
|
|
|
51
51
|
*/
|
|
52
52
|
export class TPAccordionItemElement extends HTMLElement {
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
54
|
+
* Constructor.
|
|
55
55
|
*/
|
|
56
|
-
|
|
56
|
+
constructor();
|
|
57
57
|
/**
|
|
58
58
|
* Get observed attributes.
|
|
59
59
|
*
|
|
@@ -115,9 +115,9 @@ export class TPFormErrorElement extends HTMLElement {
|
|
|
115
115
|
*/
|
|
116
116
|
export class TPFormFieldElement extends HTMLElement {
|
|
117
117
|
/**
|
|
118
|
-
*
|
|
118
|
+
* Constructor.
|
|
119
119
|
*/
|
|
120
|
-
|
|
120
|
+
constructor();
|
|
121
121
|
/**
|
|
122
122
|
* Update validation when the field has changed.
|
|
123
123
|
*/
|
|
@@ -200,10 +200,6 @@ export class TPFormElement extends HTMLElement {
|
|
|
200
200
|
* Constructor.
|
|
201
201
|
*/
|
|
202
202
|
constructor();
|
|
203
|
-
/**
|
|
204
|
-
* Connected callback.
|
|
205
|
-
*/
|
|
206
|
-
connectedCallback(): void;
|
|
207
203
|
/**
|
|
208
204
|
* Handle form submission.
|
|
209
205
|
*
|
|
@@ -222,14 +218,213 @@ export class TPFormElement extends HTMLElement {
|
|
|
222
218
|
resetValidation(): void;
|
|
223
219
|
}
|
|
224
220
|
|
|
221
|
+
/**
|
|
222
|
+
* TP Lightbox Close.
|
|
223
|
+
*/
|
|
224
|
+
export class TPLightboxCloseElement extends HTMLElement {
|
|
225
|
+
/**
|
|
226
|
+
* Constructor.
|
|
227
|
+
*/
|
|
228
|
+
constructor();
|
|
229
|
+
/**
|
|
230
|
+
* Close the lightbox.
|
|
231
|
+
*/
|
|
232
|
+
close(): void;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* TP Lightbox Content.
|
|
237
|
+
*/
|
|
238
|
+
export class TPLightboxContentElement extends HTMLElement {
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* TP Slider Count.
|
|
243
|
+
*/
|
|
244
|
+
export class TPLightboxCountElement extends HTMLElement {
|
|
245
|
+
/**
|
|
246
|
+
* Get observed attributes.
|
|
247
|
+
*
|
|
248
|
+
* @return {Array} Observed attributes.
|
|
249
|
+
*/
|
|
250
|
+
static get observedAttributes(): string[];
|
|
251
|
+
/**
|
|
252
|
+
* Get format.
|
|
253
|
+
*
|
|
254
|
+
* @return {string} Format.
|
|
255
|
+
*/
|
|
256
|
+
get format(): string;
|
|
257
|
+
/**
|
|
258
|
+
* Set format.
|
|
259
|
+
*
|
|
260
|
+
* @param {string} format Format.
|
|
261
|
+
*/
|
|
262
|
+
set format(format: string);
|
|
263
|
+
/**
|
|
264
|
+
* Attribute changed callback.
|
|
265
|
+
*/
|
|
266
|
+
attributeChangedCallback(): void;
|
|
267
|
+
/**
|
|
268
|
+
* Update component.
|
|
269
|
+
*/
|
|
270
|
+
update(): void;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* TP Lightbox Close.
|
|
275
|
+
*/
|
|
276
|
+
export class TPLightboxNextElement extends HTMLElement {
|
|
277
|
+
/**
|
|
278
|
+
* Constructor.
|
|
279
|
+
*/
|
|
280
|
+
constructor();
|
|
281
|
+
/**
|
|
282
|
+
* Navigate next.
|
|
283
|
+
*/
|
|
284
|
+
next(): void;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* TP Lightbox Close.
|
|
289
|
+
*/
|
|
290
|
+
export class TPLightboxPreviousElement extends HTMLElement {
|
|
291
|
+
/**
|
|
292
|
+
* Constructor.
|
|
293
|
+
*/
|
|
294
|
+
constructor();
|
|
295
|
+
/**
|
|
296
|
+
* Navigate previous.
|
|
297
|
+
*/
|
|
298
|
+
previous(): void;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* TP Lightbox Trigger.
|
|
303
|
+
*/
|
|
304
|
+
export class TPLightboxTriggerElement extends HTMLElement {
|
|
305
|
+
/**
|
|
306
|
+
* Constructor.
|
|
307
|
+
*/
|
|
308
|
+
constructor();
|
|
309
|
+
/**
|
|
310
|
+
* Trigger the lightbox.
|
|
311
|
+
*/
|
|
312
|
+
trigger(): void;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
import { TPLightboxTriggerElement } from './tp-lightbox-trigger';
|
|
316
|
+
/**
|
|
317
|
+
* TP Lightbox.
|
|
318
|
+
*/
|
|
319
|
+
export class TPLightboxElement extends HTMLElement {
|
|
320
|
+
/**
|
|
321
|
+
* Properties.
|
|
322
|
+
*/
|
|
323
|
+
protected currentTemplate: HTMLTemplateElement | null;
|
|
324
|
+
protected currentGroup: string;
|
|
325
|
+
protected allGroups: NodeListOf<TPLightboxTriggerElement> | null;
|
|
326
|
+
/**
|
|
327
|
+
* Constructor.
|
|
328
|
+
*/
|
|
329
|
+
constructor();
|
|
330
|
+
/**
|
|
331
|
+
* Get observed attributes.
|
|
332
|
+
*
|
|
333
|
+
* @return {Array} List of observed attributes.
|
|
334
|
+
*/
|
|
335
|
+
static get observedAttributes(): string[];
|
|
336
|
+
/**
|
|
337
|
+
* Attribute changed callback.
|
|
338
|
+
*
|
|
339
|
+
* @param {string} name Attribute name.
|
|
340
|
+
* @param {string} oldValue Old value.
|
|
341
|
+
* @param {string} newValue New value.
|
|
342
|
+
*/
|
|
343
|
+
attributeChangedCallback(name?: string, oldValue?: string, newValue?: string): void;
|
|
344
|
+
/**
|
|
345
|
+
* Get template.
|
|
346
|
+
*/
|
|
347
|
+
get template(): HTMLTemplateElement | null;
|
|
348
|
+
/**
|
|
349
|
+
* Set template.
|
|
350
|
+
*
|
|
351
|
+
* @param {HTMLTemplateElement} template The template.
|
|
352
|
+
*/
|
|
353
|
+
set template(template: HTMLTemplateElement | null);
|
|
354
|
+
/**
|
|
355
|
+
* Get current group.
|
|
356
|
+
*/
|
|
357
|
+
get group(): string;
|
|
358
|
+
/**
|
|
359
|
+
* Set current group.
|
|
360
|
+
*
|
|
361
|
+
* @param {string} group Group name.
|
|
362
|
+
*/
|
|
363
|
+
set group(group: string);
|
|
364
|
+
/**
|
|
365
|
+
* Get current index.
|
|
366
|
+
*/
|
|
367
|
+
get currentIndex(): number;
|
|
368
|
+
/**
|
|
369
|
+
* Set current index.
|
|
370
|
+
*
|
|
371
|
+
* @param {number} index Current index.
|
|
372
|
+
*/
|
|
373
|
+
set currentIndex(index: number);
|
|
374
|
+
/**
|
|
375
|
+
* Trigger the target that matches the current index within current group.
|
|
376
|
+
*/
|
|
377
|
+
triggerCurrentIndexTarget(): void;
|
|
378
|
+
/**
|
|
379
|
+
* Open lightbox.
|
|
380
|
+
*/
|
|
381
|
+
open(): void;
|
|
382
|
+
/**
|
|
383
|
+
* Close lightbox.
|
|
384
|
+
*/
|
|
385
|
+
close(): void;
|
|
386
|
+
/**
|
|
387
|
+
* Navigate previous.
|
|
388
|
+
*/
|
|
389
|
+
previous(): void;
|
|
390
|
+
/**
|
|
391
|
+
* Navigate next.
|
|
392
|
+
*/
|
|
393
|
+
next(): void;
|
|
394
|
+
/**
|
|
395
|
+
* Update all groups and save it to memory.
|
|
396
|
+
*
|
|
397
|
+
* @param {NodeList} allGroups All groups.
|
|
398
|
+
*/
|
|
399
|
+
updateAllGroups(allGroups?: NodeListOf<TPLightboxTriggerElement> | null): void;
|
|
400
|
+
/**
|
|
401
|
+
* Get all groups from memory.
|
|
402
|
+
*/
|
|
403
|
+
getAllGroups(): NodeListOf<TPLightboxTriggerElement> | null;
|
|
404
|
+
/**
|
|
405
|
+
* Prepare navigation.
|
|
406
|
+
*/
|
|
407
|
+
prepareNavigation(): void;
|
|
408
|
+
/**
|
|
409
|
+
* Prepare image loading.
|
|
410
|
+
*/
|
|
411
|
+
prepareImageLoading(): void;
|
|
412
|
+
/**
|
|
413
|
+
* Handle when the dialog is clicked.
|
|
414
|
+
*
|
|
415
|
+
* @param {Event} e Click event.
|
|
416
|
+
*/
|
|
417
|
+
handleDialogClick(e: MouseEvent): void;
|
|
418
|
+
}
|
|
419
|
+
|
|
225
420
|
/**
|
|
226
421
|
* TP Modal Close.
|
|
227
422
|
*/
|
|
228
423
|
export class TPModalCloseElement extends HTMLElement {
|
|
229
424
|
/**
|
|
230
|
-
*
|
|
425
|
+
* Constructor.
|
|
231
426
|
*/
|
|
232
|
-
|
|
427
|
+
constructor();
|
|
233
428
|
/**
|
|
234
429
|
* Close the modal.
|
|
235
430
|
*/
|
|
@@ -244,10 +439,6 @@ export class TPModalElement extends HTMLElement {
|
|
|
244
439
|
* Constructor.
|
|
245
440
|
*/
|
|
246
441
|
constructor();
|
|
247
|
-
/**
|
|
248
|
-
* Connected callback.
|
|
249
|
-
*/
|
|
250
|
-
connectedCallback(): void;
|
|
251
442
|
/**
|
|
252
443
|
* Open the modal.
|
|
253
444
|
*/
|
|
@@ -269,13 +460,9 @@ export class TPModalElement extends HTMLElement {
|
|
|
269
460
|
*/
|
|
270
461
|
export class TPMultiSelectFieldElement extends HTMLElement {
|
|
271
462
|
/**
|
|
272
|
-
*
|
|
273
|
-
*/
|
|
274
|
-
private initialized;
|
|
275
|
-
/**
|
|
276
|
-
* Connected callback.
|
|
463
|
+
* Constructor.
|
|
277
464
|
*/
|
|
278
|
-
|
|
465
|
+
constructor();
|
|
279
466
|
/**
|
|
280
467
|
* Toggle opening this component.
|
|
281
468
|
*/
|
|
@@ -287,13 +474,9 @@ export class TPMultiSelectFieldElement extends HTMLElement {
|
|
|
287
474
|
*/
|
|
288
475
|
export class TPMultiSelectOptionElement extends HTMLElement {
|
|
289
476
|
/**
|
|
290
|
-
*
|
|
291
|
-
*/
|
|
292
|
-
private initialized;
|
|
293
|
-
/**
|
|
294
|
-
* Connected callback.
|
|
477
|
+
* Constructor.
|
|
295
478
|
*/
|
|
296
|
-
|
|
479
|
+
constructor();
|
|
297
480
|
/**
|
|
298
481
|
* Select / un-select this option.
|
|
299
482
|
*
|
|
@@ -313,9 +496,9 @@ export class TPMultiSelectOptionsElement extends HTMLElement {
|
|
|
313
496
|
*/
|
|
314
497
|
export class TPMultiSelectPillElement extends HTMLElement {
|
|
315
498
|
/**
|
|
316
|
-
*
|
|
499
|
+
* Constructor.
|
|
317
500
|
*/
|
|
318
|
-
|
|
501
|
+
constructor();
|
|
319
502
|
/**
|
|
320
503
|
* Handle button click.
|
|
321
504
|
*
|
|
@@ -333,9 +516,9 @@ export class TPMultiSelectPillElement extends HTMLElement {
|
|
|
333
516
|
*/
|
|
334
517
|
export class TPMultiSelectPillsElement extends HTMLElement {
|
|
335
518
|
/**
|
|
336
|
-
*
|
|
519
|
+
* Constructor.
|
|
337
520
|
*/
|
|
338
|
-
|
|
521
|
+
constructor();
|
|
339
522
|
/**
|
|
340
523
|
* Update this component.
|
|
341
524
|
*/
|
|
@@ -353,9 +536,9 @@ export class TPMultiSelectPlaceholderElement extends HTMLElement {
|
|
|
353
536
|
*/
|
|
354
537
|
export class TPMultiSelectSearchElement extends HTMLElement {
|
|
355
538
|
/**
|
|
356
|
-
*
|
|
539
|
+
* Constructor.
|
|
357
540
|
*/
|
|
358
|
-
|
|
541
|
+
constructor();
|
|
359
542
|
/**
|
|
360
543
|
* Handle keyboard inputs.
|
|
361
544
|
*
|
|
@@ -387,9 +570,9 @@ export class TPMultiSelectSearchElement extends HTMLElement {
|
|
|
387
570
|
*/
|
|
388
571
|
export class TPMultiSelectSelectAllElement extends HTMLElement {
|
|
389
572
|
/**
|
|
390
|
-
*
|
|
573
|
+
* Constructor.
|
|
391
574
|
*/
|
|
392
|
-
|
|
575
|
+
constructor();
|
|
393
576
|
/**
|
|
394
577
|
* Handle value changed.
|
|
395
578
|
*/
|
|
@@ -437,10 +620,6 @@ export class TPMultiSelectElement extends HTMLElement {
|
|
|
437
620
|
* Constructor.
|
|
438
621
|
*/
|
|
439
622
|
constructor();
|
|
440
|
-
/**
|
|
441
|
-
* Connected callback.
|
|
442
|
-
*/
|
|
443
|
-
connectedCallback(): void;
|
|
444
623
|
/**
|
|
445
624
|
* Get observed attributes.
|
|
446
625
|
*
|
|
@@ -534,9 +713,9 @@ export class TPMultiSelectElement extends HTMLElement {
|
|
|
534
713
|
*/
|
|
535
714
|
export class TPSliderArrowElement extends HTMLElement {
|
|
536
715
|
/**
|
|
537
|
-
*
|
|
716
|
+
* Constructor.
|
|
538
717
|
*/
|
|
539
|
-
|
|
718
|
+
constructor();
|
|
540
719
|
/**
|
|
541
720
|
* Handle when the button is clicked.
|
|
542
721
|
*/
|
|
@@ -580,9 +759,9 @@ export class TPSliderCountElement extends HTMLElement {
|
|
|
580
759
|
*/
|
|
581
760
|
export class TPSliderNavItemElement extends HTMLElement {
|
|
582
761
|
/**
|
|
583
|
-
*
|
|
762
|
+
* Constructor.
|
|
584
763
|
*/
|
|
585
|
-
|
|
764
|
+
constructor();
|
|
586
765
|
/**
|
|
587
766
|
* Handle when the button is clicked.
|
|
588
767
|
*/
|
|
@@ -606,9 +785,9 @@ export class TPSliderNavElement extends HTMLElement {
|
|
|
606
785
|
*/
|
|
607
786
|
export class TPSliderSlideElement extends HTMLElement {
|
|
608
787
|
/**
|
|
609
|
-
*
|
|
788
|
+
* Constructor.
|
|
610
789
|
*/
|
|
611
|
-
|
|
790
|
+
constructor();
|
|
612
791
|
/**
|
|
613
792
|
* Handle slide height change.
|
|
614
793
|
*/
|
|
@@ -637,6 +816,8 @@ export class TPSliderElement extends HTMLElement {
|
|
|
637
816
|
* Properties.
|
|
638
817
|
*/
|
|
639
818
|
protected touchStartX: number;
|
|
819
|
+
protected touchStartY: number;
|
|
820
|
+
protected swipeThreshold: number;
|
|
640
821
|
protected responsiveSettings: {
|
|
641
822
|
[key: string]: any;
|
|
642
823
|
};
|
|
@@ -792,9 +973,9 @@ export class TPSliderElement extends HTMLElement {
|
|
|
792
973
|
*/
|
|
793
974
|
export class TPTabsNavItemElement extends HTMLElement {
|
|
794
975
|
/**
|
|
795
|
-
*
|
|
976
|
+
* Constructor.
|
|
796
977
|
*/
|
|
797
|
-
|
|
978
|
+
constructor();
|
|
798
979
|
/**
|
|
799
980
|
* Handle link click.
|
|
800
981
|
*
|
|
@@ -833,9 +1014,9 @@ export class TPTabsTabElement extends HTMLElement {
|
|
|
833
1014
|
*/
|
|
834
1015
|
export class TPTabsElement extends HTMLElement {
|
|
835
1016
|
/**
|
|
836
|
-
*
|
|
1017
|
+
* Constructor.
|
|
837
1018
|
*/
|
|
838
|
-
|
|
1019
|
+
constructor();
|
|
839
1020
|
/**
|
|
840
1021
|
* Get observed attributes.
|
|
841
1022
|
*
|
package/dist/form/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(()=>{"use strict";var t={d:(e,r)=>{for(var i in r)t.o(r,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:r[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{errorMessage:()=>l,name:()=>
|
|
1
|
+
(()=>{"use strict";var t={d:(e,r)=>{for(var i in r)t.o(r,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:r[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{errorMessage:()=>l,name:()=>a,validator:()=>d});var r={};t.r(r),t.d(r,{errorMessage:()=>v,name:()=>u,validator:()=>m});var i={};t.r(i),t.d(i,{errorMessage:()=>b,name:()=>h,validator:()=>c});var s={};t.r(s),t.d(s,{errorMessage:()=>p,name:()=>g,validator:()=>f});var n={};t.r(n),t.d(n,{errorMessage:()=>y,name:()=>E,validator:()=>A});const o=(t="")=>{const{tpFormErrors:e}=window;return e&&""!==t&&t in e&&"string"==typeof e[t]?e[t]:""},a="required",l="This field is required",d={validate:t=>{var e,r;return null!==(r=""!==(null===(e=t.getField())||void 0===e?void 0:e.value))&&void 0!==r?r:""},getErrorMessage:()=>o(a)},u="email",v="Please enter a valid email address",m={validate:t=>{var e,r;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(null!==(r=null===(e=t.getField())||void 0===e?void 0:e.value)&&void 0!==r?r:"")},getErrorMessage:()=>o(u)},h="min-length",b="Must be at least %1 characters",c={validate:t=>{var e,r,i;const s=parseInt(null!==(e=t.getAttribute("min-length"))&&void 0!==e?e:"0"),n=null!==(i=null===(r=t.getField())||void 0===r?void 0:r.value)&&void 0!==i?i:"";return""===n||n.length>=s},getErrorMessage:t=>{var e;const r=o(h),i=null!==(e=t.getAttribute("min-length"))&&void 0!==e?e:"";return r.replace("%1",i)}},g="max-length",p="Must be less than %1 characters",f={validate:t=>{var e,r,i;const s=parseInt(null!==(e=t.getAttribute("max-length"))&&void 0!==e?e:"0"),n=null!==(i=null===(r=t.getField())||void 0===r?void 0:r.value)&&void 0!==i?i:"";return""===n||n.length<=s},getErrorMessage:t=>{var e;const r=o(g),i=null!==(e=t.getAttribute("max-length"))&&void 0!==e?e:"";return r.replace("%1",i)}},E="no-empty-spaces",y="This field should not contain only whitespaces",A={validate:t=>{const e=t.getField();return!!e&&(""===e.value||""!==e.value.trim())},getErrorMessage:()=>o(E)};class M extends HTMLElement{constructor(){var t;super(),this.form=this.querySelector("form"),null===(t=this.form)||void 0===t||t.addEventListener("submit",this.handleFormSubmit.bind(this))}handleFormSubmit(t){const e=this.validate();e&&"yes"!==this.getAttribute("prevent-submit")||(t.preventDefault(),t.stopImmediatePropagation());const r=this.querySelector("tp-form-submit");r&&(e?r.setAttribute("submitting","yes"):r.removeAttribute("submitting")),e&&this.dispatchEvent(new CustomEvent("submit-validation-success",{bubbles:!0}))}validate(){this.dispatchEvent(new CustomEvent("validate",{bubbles:!0}));const t=this.querySelectorAll("tp-form-field");if(!t)return this.dispatchEvent(new CustomEvent("validation-success",{bubbles:!0})),!0;let e=!0;return t.forEach((t=>{t.validate()||(e=!1)})),e?this.dispatchEvent(new CustomEvent("validation-success",{bubbles:!0})):this.dispatchEvent(new CustomEvent("validation-error",{bubbles:!0})),e}resetValidation(){const t=this.querySelectorAll("tp-form-field");if(!t)return;t.forEach((t=>{t.removeAttribute("valid"),t.removeAttribute("error")}));const e=this.querySelector("tp-form-submit");null==e||e.removeAttribute("submitting")}}class w extends HTMLElement{constructor(){super();const t=this.getField();null==t||t.addEventListener("keyup",this.handleFieldChanged.bind(this)),null==t||t.addEventListener("change",this.handleFieldChanged.bind(this))}handleFieldChanged(){(this.getAttribute("valid")||this.getAttribute("error"))&&this.validate()}static get observedAttributes(){return["valid","error"]}attributeChangedCallback(t="",e="",r=""){"valid"!==t&&"error"!==t||e===r||this.dispatchEvent(new CustomEvent("validate",{bubbles:!0})),this.update()}update(){var t;const{tpFormValidators:e}=window;if(!e)return;const r=null!==(t=this.getAttribute("error"))&&void 0!==t?t:"";""!==r&&r in e&&"function"==typeof e[r].getErrorMessage?this.setErrorMessage(e[r].getErrorMessage(this)):this.removeErrorMessage()}getField(){return this.querySelector("input,select,textarea")}validate(){const{tpFormValidators:t}=window;if(!t)return!0;if(this.offsetWidth<=0||this.offsetHeight<=0)return!0;let e=!0,r="";return this.getAttributeNames().every((i=>!(i in t)||"function"!=typeof t[i].validate||!1!==t[i].validate(this)||(e=!1,r=i,!1))),e?(this.setAttribute("valid","yes"),this.removeAttribute("error")):(this.removeAttribute("valid"),this.setAttribute("error",r)),e}setErrorMessage(t=""){const e=this.querySelector("tp-form-error");if(e)e.innerHTML=t;else{const e=document.createElement("tp-form-error");e.innerHTML=t,this.appendChild(e)}this.dispatchEvent(new CustomEvent("validation-error"))}removeErrorMessage(){var t;null===(t=this.querySelector("tp-form-error"))||void 0===t||t.remove(),this.dispatchEvent(new CustomEvent("validation-success"))}}class F extends HTMLElement{}class C extends HTMLElement{static get observedAttributes(){return["submitting-text","original-text","submitting"]}attributeChangedCallback(t="",e="",r=""){e!==r&&this.update()}update(){var t,e;const r=this.querySelector('button[type="submit"]');if(!r)return;const i=null!==(t=this.getAttribute("submitting-text"))&&void 0!==t?t:"",s=null!==(e=this.getAttribute("original-text"))&&void 0!==e?e:r.innerHTML;"yes"===this.getAttribute("submitting")?(r.setAttribute("disabled","disabled"),this.setAttribute("original-text",s),r.innerHTML=i):(r.removeAttribute("disabled"),this.removeAttribute("submitting"),this.removeAttribute("original-text"),r.innerHTML=s)}}const S=[e,r,i,s,n];window.tpFormValidators={},window.tpFormErrors={},S.forEach((({name:t,validator:e,errorMessage:r})=>{window.tpFormValidators[t]=e,window.tpFormErrors[t]=r})),customElements.define("tp-form",M),customElements.define("tp-form-field",w),customElements.define("tp-form-error",F),customElements.define("tp-form-submit",C)})();
|
|
2
2
|
//# sourceMappingURL=index.js.map
|