balm-ui
Version:
A modular and customizable UI library based on Material Design and Vue 3
1 lines • 31.1 kB
JavaScript
!function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e(require("vue")):"function"===typeof define&&define.amd?define("UiSegmentedButton",["vue"],e):"object"===typeof exports?exports.UiSegmentedButton=e(require("vue")):t.UiSegmentedButton=e(t.Vue)}("undefined"!==typeof self?self:this,(function(t){return function(){"use strict";var e={744:function(t){var e=function(t){return function(t){return!!t&&"object"===typeof t}(t)&&!function(t){var e=Object.prototype.toString.call(t);return"[object RegExp]"===e||"[object Date]"===e||function(t){return t.$$typeof===n}(t)}(t)};var n="function"===typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function i(t,e){return!1!==e.clone&&e.isMergeableObject(t)?c((n=t,Array.isArray(n)?[]:{}),t,e):t;var n}function r(t,e,n){return t.concat(e).map((function(t){return i(t,n)}))}function o(t){return Object.keys(t).concat(function(t){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter((function(e){return Object.propertyIsEnumerable.call(t,e)})):[]}(t))}function a(t,e){try{return e in t}catch(n){return!1}}function s(t,e,n){var r={};return n.isMergeableObject(t)&&o(t).forEach((function(e){r[e]=i(t[e],n)})),o(e).forEach((function(o){(function(t,e){return a(t,e)&&!(Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))})(t,o)||(a(t,o)&&n.isMergeableObject(e[o])?r[o]=function(t,e){if(!e.customMerge)return c;var n=e.customMerge(t);return"function"===typeof n?n:c}(o,n)(t[o],e[o],n):r[o]=i(e[o],n))})),r}function c(t,n,o){(o=o||{}).arrayMerge=o.arrayMerge||r,o.isMergeableObject=o.isMergeableObject||e,o.cloneUnlessOtherwiseSpecified=i;var a=Array.isArray(n);return a===Array.isArray(t)?a?o.arrayMerge(t,n,o):s(t,n,o):i(n,o)}c.all=function(t,e){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce((function(t,n){return c(t,n,e)}),{})};var u=c;t.exports=u},154:function(e){e.exports=t}},n={};function i(t){var r=n[t];if(void 0!==r)return r.exports;var o=n[t]={exports:{}};return e[t](o,o.exports,i),o.exports}i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,{a:e}),e},i.d=function(t,e){for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};var r={};i.d(r,{default:function(){return lt}});var o=i(744),a=i.n(o);const s=/(?:^\[object\s(.*?)\]$)/;var c=t=>Object.prototype.toString.call(t).replace(s,"$1").toLowerCase();const u=t=>{let{componentProps:e,propName:n,props:i}=t,r=i[n];if("object"===c(r)){const t=e[n].default;e[n].default=()=>a()(t,r)}else Array.isArray(r)?e[n].default=()=>r:e[n].default=r},l=t=>{let{componentMixins:e,propName:n,props:i}=t;if(e.length){let t=e.length;for(;t--;)if(e[t].props&&void 0!==e[t].props[n]){u({componentProps:e[t].props,propName:n,props:i});break}}};var d=(t,e)=>{for(const n of Object.keys(e))t.props?void 0===t.props[n]?l({componentMixins:t.mixins,propName:n,props:e}):u({componentProps:t.props,propName:n,props:e}):l({componentMixins:t.mixins,propName:n,props:e})};var p=(t,e)=>{for(const n of Object.keys(e))if(/^Ui[A-Z]{1}[A-Za-z]+$/.test(n)){const i=t[n],r=e[n];d(i,r)}};var f=t=>{const e={install(e){p(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{});for(let n in t){const i=t[n];e.component(i.name,i)}}};return e},h=i(154),m=function(t,e){return m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},m(t,e)};function g(t,e){if("function"!==typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}m(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var v=function(){return v=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},v.apply(this,arguments)};Object.create;function y(t){var e="function"===typeof Symbol&&Symbol.iterator,n=e&&t[e],i=0;if(n)return n.call(t);if(t&&"number"===typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function S(t,e){var n="function"===typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,r,o=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)a.push(i.value)}catch(s){r={error:s}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return a}function b(t,e,n){if(n||2===arguments.length)for(var i,r=0,o=e.length;r<o;r++)!i&&r in e||(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return t.concat(i||Array.prototype.slice.call(e))}Object.create;"function"===typeof SuppressedError&&SuppressedError;var A=function(){function t(t){void 0===t&&(t={}),this.adapter=t}return Object.defineProperty(t,"cssClasses",{get:function(){return{}},enumerable:!1,configurable:!0}),Object.defineProperty(t,"strings",{get:function(){return{}},enumerable:!1,configurable:!0}),Object.defineProperty(t,"numbers",{get:function(){return{}},enumerable:!1,configurable:!0}),Object.defineProperty(t,"defaultAdapter",{get:function(){return{}},enumerable:!1,configurable:!0}),t.prototype.init=function(){},t.prototype.destroy=function(){},t}(),C=".mdc-segmented-button__segment",E="selected",T="change",I="mdc-segmented-button--single-select",O=function(t){function e(n){return t.call(this,v(v({},e.defaultAdapter),n))||this}return g(e,t),Object.defineProperty(e,"defaultAdapter",{get:function(){return{hasClass:function(){return!1},getSegments:function(){return[]},selectSegment:function(){},unselectSegment:function(){},notifySelectedChange:function(){}}},enumerable:!1,configurable:!0}),e.prototype.selectSegment=function(t){this.adapter.selectSegment(t)},e.prototype.unselectSegment=function(t){this.adapter.unselectSegment(t)},e.prototype.getSelectedSegments=function(){return this.adapter.getSegments().filter((function(t){return t.selected}))},e.prototype.isSegmentSelected=function(t){return this.adapter.getSegments().some((function(e){return(e.index===t||e.segmentId===t)&&e.selected}))},e.prototype.isSingleSelect=function(){return this.adapter.hasClass(I)},e.prototype.handleSelected=function(t){this.isSingleSelect()&&this.unselectPrevSelected(t.index),this.adapter.notifySelectedChange(t)},e.prototype.unselectPrevSelected=function(t){var e,n;try{for(var i=y(this.getSelectedSegments()),r=i.next();!r.done;r=i.next()){var o=r.value;o.index!==t&&this.unselectSegment(o.index)}}catch(a){e={error:a}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}},e}(A),w=function(){function t(t,e){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];this.root=t,this.initialize.apply(this,b([],S(n))),this.foundation=void 0===e?this.getDefaultFoundation():e,this.foundation.init(),this.initialSyncWithDOM()}return t.attachTo=function(e){return new t(e,new A({}))},t.prototype.initialize=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e]},t.prototype.getDefaultFoundation=function(){throw new Error("Subclasses must override getDefaultFoundation to return a properly configured foundation class")},t.prototype.initialSyncWithDOM=function(){},t.prototype.destroy=function(){this.foundation.destroy()},t.prototype.listen=function(t,e,n){this.root.addEventListener(t,e,n)},t.prototype.unlisten=function(t,e,n){this.root.removeEventListener(t,e,n)},t.prototype.emit=function(t,e,n){var i;void 0===n&&(n=!1),"function"===typeof CustomEvent?i=new CustomEvent(t,{bubbles:n,detail:e}):(i=document.createEvent("CustomEvent")).initCustomEvent(t,n,!1,e),this.root.dispatchEvent(i)},t}();function _(t){return void 0===t&&(t=window),!!function(t){void 0===t&&(t=window);var e=!1;try{var n={get passive(){return e=!0,!1}},i=function(){};t.document.addEventListener("test",i,n),t.document.removeEventListener("test",i,n)}catch(r){e=!1}return e}(t)&&{passive:!0}}function x(t,e){return(t.matches||t.webkitMatchesSelector||t.msMatchesSelector).call(t,e)}var D,R={BG_FOCUSED:"mdc-ripple-upgraded--background-focused",FG_ACTIVATION:"mdc-ripple-upgraded--foreground-activation",FG_DEACTIVATION:"mdc-ripple-upgraded--foreground-deactivation",ROOT:"mdc-ripple-upgraded",UNBOUNDED:"mdc-ripple-upgraded--unbounded"},V={VAR_FG_SCALE:"--mdc-ripple-fg-scale",VAR_FG_SIZE:"--mdc-ripple-fg-size",VAR_FG_TRANSLATE_END:"--mdc-ripple-fg-translate-end",VAR_FG_TRANSLATE_START:"--mdc-ripple-fg-translate-start",VAR_LEFT:"--mdc-ripple-left",VAR_TOP:"--mdc-ripple-top"},N={DEACTIVATION_TIMEOUT_MS:225,FG_DEACTIVATION_MS:150,INITIAL_ORIGIN_SCALE:.6,PADDING:10,TAP_DELAY_MS:300};var B=["touchstart","pointerdown","mousedown","keydown"],U=["touchend","pointerup","mouseup","contextmenu"],H=[],L=function(t){function e(n){var i=t.call(this,v(v({},e.defaultAdapter),n))||this;return i.activationAnimationHasEnded=!1,i.activationTimer=0,i.fgDeactivationRemovalTimer=0,i.fgScale="0",i.frame={width:0,height:0},i.initialSize=0,i.layoutFrame=0,i.maxRadius=0,i.unboundedCoords={left:0,top:0},i.activationState=i.defaultActivationState(),i.activationTimerCallback=function(){i.activationAnimationHasEnded=!0,i.runDeactivationUXLogicIfReady()},i.activateHandler=function(t){i.activateImpl(t)},i.deactivateHandler=function(){i.deactivateImpl()},i.focusHandler=function(){i.handleFocus()},i.blurHandler=function(){i.handleBlur()},i.resizeHandler=function(){i.layout()},i}return g(e,t),Object.defineProperty(e,"cssClasses",{get:function(){return R},enumerable:!1,configurable:!0}),Object.defineProperty(e,"strings",{get:function(){return V},enumerable:!1,configurable:!0}),Object.defineProperty(e,"numbers",{get:function(){return N},enumerable:!1,configurable:!0}),Object.defineProperty(e,"defaultAdapter",{get:function(){return{addClass:function(){},browserSupportsCssVars:function(){return!0},computeBoundingRect:function(){return{top:0,right:0,bottom:0,left:0,width:0,height:0}},containsEventTarget:function(){return!0},deregisterDocumentInteractionHandler:function(){},deregisterInteractionHandler:function(){},deregisterResizeHandler:function(){},getWindowPageOffset:function(){return{x:0,y:0}},isSurfaceActive:function(){return!0},isSurfaceDisabled:function(){return!0},isUnbounded:function(){return!0},registerDocumentInteractionHandler:function(){},registerInteractionHandler:function(){},registerResizeHandler:function(){},removeClass:function(){},updateCssVariable:function(){}}},enumerable:!1,configurable:!0}),e.prototype.init=function(){var t=this,n=this.supportsPressRipple();if(this.registerRootHandlers(n),n){var i=e.cssClasses,r=i.ROOT,o=i.UNBOUNDED;requestAnimationFrame((function(){t.adapter.addClass(r),t.adapter.isUnbounded()&&(t.adapter.addClass(o),t.layoutInternal())}))}},e.prototype.destroy=function(){var t=this;if(this.supportsPressRipple()){this.activationTimer&&(clearTimeout(this.activationTimer),this.activationTimer=0,this.adapter.removeClass(e.cssClasses.FG_ACTIVATION)),this.fgDeactivationRemovalTimer&&(clearTimeout(this.fgDeactivationRemovalTimer),this.fgDeactivationRemovalTimer=0,this.adapter.removeClass(e.cssClasses.FG_DEACTIVATION));var n=e.cssClasses,i=n.ROOT,r=n.UNBOUNDED;requestAnimationFrame((function(){t.adapter.removeClass(i),t.adapter.removeClass(r),t.removeCssVars()}))}this.deregisterRootHandlers(),this.deregisterDeactivationHandlers()},e.prototype.activate=function(t){this.activateImpl(t)},e.prototype.deactivate=function(){this.deactivateImpl()},e.prototype.layout=function(){var t=this;this.layoutFrame&&cancelAnimationFrame(this.layoutFrame),this.layoutFrame=requestAnimationFrame((function(){t.layoutInternal(),t.layoutFrame=0}))},e.prototype.setUnbounded=function(t){var n=e.cssClasses.UNBOUNDED;t?this.adapter.addClass(n):this.adapter.removeClass(n)},e.prototype.handleFocus=function(){var t=this;requestAnimationFrame((function(){return t.adapter.addClass(e.cssClasses.BG_FOCUSED)}))},e.prototype.handleBlur=function(){var t=this;requestAnimationFrame((function(){return t.adapter.removeClass(e.cssClasses.BG_FOCUSED)}))},e.prototype.supportsPressRipple=function(){return this.adapter.browserSupportsCssVars()},e.prototype.defaultActivationState=function(){return{activationEvent:void 0,hasDeactivationUXRun:!1,isActivated:!1,isProgrammatic:!1,wasActivatedByPointer:!1,wasElementMadeActive:!1}},e.prototype.registerRootHandlers=function(t){var e,n;if(t){try{for(var i=y(B),r=i.next();!r.done;r=i.next()){var o=r.value;this.adapter.registerInteractionHandler(o,this.activateHandler)}}catch(a){e={error:a}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}this.adapter.isUnbounded()&&this.adapter.registerResizeHandler(this.resizeHandler)}this.adapter.registerInteractionHandler("focus",this.focusHandler),this.adapter.registerInteractionHandler("blur",this.blurHandler)},e.prototype.registerDeactivationHandlers=function(t){var e,n;if("keydown"===t.type)this.adapter.registerInteractionHandler("keyup",this.deactivateHandler);else try{for(var i=y(U),r=i.next();!r.done;r=i.next()){var o=r.value;this.adapter.registerDocumentInteractionHandler(o,this.deactivateHandler)}}catch(a){e={error:a}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}},e.prototype.deregisterRootHandlers=function(){var t,e;try{for(var n=y(B),i=n.next();!i.done;i=n.next()){var r=i.value;this.adapter.deregisterInteractionHandler(r,this.activateHandler)}}catch(o){t={error:o}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}this.adapter.deregisterInteractionHandler("focus",this.focusHandler),this.adapter.deregisterInteractionHandler("blur",this.blurHandler),this.adapter.isUnbounded()&&this.adapter.deregisterResizeHandler(this.resizeHandler)},e.prototype.deregisterDeactivationHandlers=function(){var t,e;this.adapter.deregisterInteractionHandler("keyup",this.deactivateHandler);try{for(var n=y(U),i=n.next();!i.done;i=n.next()){var r=i.value;this.adapter.deregisterDocumentInteractionHandler(r,this.deactivateHandler)}}catch(o){t={error:o}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}},e.prototype.removeCssVars=function(){var t=this,n=e.strings;Object.keys(n).forEach((function(e){0===e.indexOf("VAR_")&&t.adapter.updateCssVariable(n[e],null)}))},e.prototype.activateImpl=function(t){var e=this;if(!this.adapter.isSurfaceDisabled()){var n=this.activationState;if(!n.isActivated){var i=this.previousActivationEvent;if(!(i&&void 0!==t&&i.type!==t.type))n.isActivated=!0,n.isProgrammatic=void 0===t,n.activationEvent=t,n.wasActivatedByPointer=!n.isProgrammatic&&(void 0!==t&&("mousedown"===t.type||"touchstart"===t.type||"pointerdown"===t.type)),void 0!==t&&H.length>0&&H.some((function(t){return e.adapter.containsEventTarget(t)}))?this.resetActivationState():(void 0!==t&&(H.push(t.target),this.registerDeactivationHandlers(t)),n.wasElementMadeActive=this.checkElementMadeActive(t),n.wasElementMadeActive&&this.animateActivation(),requestAnimationFrame((function(){H=[],n.wasElementMadeActive||void 0===t||" "!==t.key&&32!==t.keyCode||(n.wasElementMadeActive=e.checkElementMadeActive(t),n.wasElementMadeActive&&e.animateActivation()),n.wasElementMadeActive||(e.activationState=e.defaultActivationState())})))}}},e.prototype.checkElementMadeActive=function(t){return void 0===t||"keydown"!==t.type||this.adapter.isSurfaceActive()},e.prototype.animateActivation=function(){var t=this,n=e.strings,i=n.VAR_FG_TRANSLATE_START,r=n.VAR_FG_TRANSLATE_END,o=e.cssClasses,a=o.FG_DEACTIVATION,s=o.FG_ACTIVATION,c=e.numbers.DEACTIVATION_TIMEOUT_MS;this.layoutInternal();var u="",l="";if(!this.adapter.isUnbounded()){var d=this.getFgTranslationCoordinates(),p=d.startPoint,f=d.endPoint;u=p.x+"px, "+p.y+"px",l=f.x+"px, "+f.y+"px"}this.adapter.updateCssVariable(i,u),this.adapter.updateCssVariable(r,l),clearTimeout(this.activationTimer),clearTimeout(this.fgDeactivationRemovalTimer),this.rmBoundedActivationClasses(),this.adapter.removeClass(a),this.adapter.computeBoundingRect(),this.adapter.addClass(s),this.activationTimer=setTimeout((function(){t.activationTimerCallback()}),c)},e.prototype.getFgTranslationCoordinates=function(){var t,e=this.activationState,n=e.activationEvent;return{startPoint:t={x:(t=e.wasActivatedByPointer?function(t,e,n){if(!t)return{x:0,y:0};var i,r,o=e.x,a=e.y,s=o+n.left,c=a+n.top;if("touchstart"===t.type){var u=t;i=u.changedTouches[0].pageX-s,r=u.changedTouches[0].pageY-c}else{var l=t;i=l.pageX-s,r=l.pageY-c}return{x:i,y:r}}(n,this.adapter.getWindowPageOffset(),this.adapter.computeBoundingRect()):{x:this.frame.width/2,y:this.frame.height/2}).x-this.initialSize/2,y:t.y-this.initialSize/2},endPoint:{x:this.frame.width/2-this.initialSize/2,y:this.frame.height/2-this.initialSize/2}}},e.prototype.runDeactivationUXLogicIfReady=function(){var t=this,n=e.cssClasses.FG_DEACTIVATION,i=this.activationState,r=i.hasDeactivationUXRun,o=i.isActivated;(r||!o)&&this.activationAnimationHasEnded&&(this.rmBoundedActivationClasses(),this.adapter.addClass(n),this.fgDeactivationRemovalTimer=setTimeout((function(){t.adapter.removeClass(n)}),N.FG_DEACTIVATION_MS))},e.prototype.rmBoundedActivationClasses=function(){var t=e.cssClasses.FG_ACTIVATION;this.adapter.removeClass(t),this.activationAnimationHasEnded=!1,this.adapter.computeBoundingRect()},e.prototype.resetActivationState=function(){var t=this;this.previousActivationEvent=this.activationState.activationEvent,this.activationState=this.defaultActivationState(),setTimeout((function(){return t.previousActivationEvent=void 0}),e.numbers.TAP_DELAY_MS)},e.prototype.deactivateImpl=function(){var t=this,e=this.activationState;if(e.isActivated){var n=v({},e);e.isProgrammatic?(requestAnimationFrame((function(){t.animateDeactivation(n)})),this.resetActivationState()):(this.deregisterDeactivationHandlers(),requestAnimationFrame((function(){t.activationState.hasDeactivationUXRun=!0,t.animateDeactivation(n),t.resetActivationState()})))}},e.prototype.animateDeactivation=function(t){var e=t.wasActivatedByPointer,n=t.wasElementMadeActive;(e||n)&&this.runDeactivationUXLogicIfReady()},e.prototype.layoutInternal=function(){var t=this;this.frame=this.adapter.computeBoundingRect();var n=Math.max(this.frame.height,this.frame.width);this.maxRadius=this.adapter.isUnbounded()?n:Math.sqrt(Math.pow(t.frame.width,2)+Math.pow(t.frame.height,2))+e.numbers.PADDING;var i=Math.floor(n*e.numbers.INITIAL_ORIGIN_SCALE);this.adapter.isUnbounded()&&i%2!==0?this.initialSize=i-1:this.initialSize=i,this.fgScale=""+this.maxRadius/this.initialSize,this.updateLayoutCssVars()},e.prototype.updateLayoutCssVars=function(){var t=e.strings,n=t.VAR_FG_SIZE,i=t.VAR_LEFT,r=t.VAR_TOP,o=t.VAR_FG_SCALE;this.adapter.updateCssVariable(n,this.initialSize+"px"),this.adapter.updateCssVariable(o,this.fgScale),this.adapter.isUnbounded()&&(this.unboundedCoords={left:Math.round(this.frame.width/2-this.initialSize/2),top:Math.round(this.frame.height/2-this.initialSize/2)},this.adapter.updateCssVariable(i,this.unboundedCoords.left+"px"),this.adapter.updateCssVariable(r,this.unboundedCoords.top+"px"))},e}(A),M=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.disabled=!1,e}return g(e,t),e.attachTo=function(t,n){void 0===n&&(n={isUnbounded:void 0});var i=new e(t);return void 0!==n.isUnbounded&&(i.unbounded=n.isUnbounded),i},e.createAdapter=function(t){return{addClass:function(e){return t.root.classList.add(e)},browserSupportsCssVars:function(){return function(t,e){void 0===e&&(e=!1);var n,i=t.CSS;if("boolean"===typeof D&&!e)return D;if(!i||"function"!==typeof i.supports)return!1;var r=i.supports("--css-vars","yes"),o=i.supports("(--css-vars: yes)")&&i.supports("color","#00000000");return n=r||o,e||(D=n),n}(window)},computeBoundingRect:function(){return t.root.getBoundingClientRect()},containsEventTarget:function(e){return t.root.contains(e)},deregisterDocumentInteractionHandler:function(t,e){return document.documentElement.removeEventListener(t,e,_())},deregisterInteractionHandler:function(e,n){return t.root.removeEventListener(e,n,_())},deregisterResizeHandler:function(t){return window.removeEventListener("resize",t)},getWindowPageOffset:function(){return{x:window.pageXOffset,y:window.pageYOffset}},isSurfaceActive:function(){return x(t.root,":active")},isSurfaceDisabled:function(){return Boolean(t.disabled)},isUnbounded:function(){return Boolean(t.unbounded)},registerDocumentInteractionHandler:function(t,e){return document.documentElement.addEventListener(t,e,_())},registerInteractionHandler:function(e,n){return t.root.addEventListener(e,n,_())},registerResizeHandler:function(t){return window.addEventListener("resize",t)},removeClass:function(e){return t.root.classList.remove(e)},updateCssVariable:function(e,n){return t.root.style.setProperty(e,n)}}},Object.defineProperty(e.prototype,"unbounded",{get:function(){return Boolean(this.isUnbounded)},set:function(t){this.isUnbounded=Boolean(t),this.setUnbounded()},enumerable:!1,configurable:!0}),e.prototype.activate=function(){this.foundation.activate()},e.prototype.deactivate=function(){this.foundation.deactivate()},e.prototype.layout=function(){this.foundation.layout()},e.prototype.getDefaultFoundation=function(){return new L(e.createAdapter(this))},e.prototype.initialSyncWithDOM=function(){var t=this.root;this.isUnbounded="mdcRippleIsUnbounded"in t.dataset},e.prototype.setUnbounded=function(){this.foundation.setUnbounded(Boolean(this.isUnbounded))},e}(w),P="true",F="false",j="aria-checked",k="aria-pressed",z="data-segment-id",G="click",q="selected",$="mdc-segmented-button__segment--selected",X={bottom:0,height:0,left:0,right:0,top:0,width:0},W=function(t){function e(n){return t.call(this,v(v({},e.defaultAdapter),n))||this}return g(e,t),Object.defineProperty(e,"defaultAdapter",{get:function(){return{isSingleSelect:function(){return!1},getAttr:function(){return""},setAttr:function(){},addClass:function(){},removeClass:function(){},hasClass:function(){return!1},notifySelectedChange:function(){},getRootBoundingClientRect:function(){return X}}},enumerable:!1,configurable:!0}),e.prototype.isSelected=function(){return this.adapter.hasClass($)},e.prototype.setSelected=function(){this.adapter.addClass($),this.setAriaAttr(P)},e.prototype.setUnselected=function(){this.adapter.removeClass($),this.setAriaAttr(F)},e.prototype.getSegmentId=function(){var t;return null!==(t=this.adapter.getAttr(z))&&void 0!==t?t:void 0},e.prototype.handleClick=function(){this.adapter.isSingleSelect()?this.setSelected():this.toggleSelection(),this.adapter.notifySelectedChange(this.isSelected())},e.prototype.getDimensions=function(){return this.adapter.getRootBoundingClientRect()},e.prototype.toggleSelection=function(){this.isSelected()?this.setUnselected():this.setSelected()},e.prototype.setAriaAttr=function(t){this.adapter.isSingleSelect()?this.adapter.setAttr(j,t):this.adapter.setAttr(k,t)},e}(A),Y=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return g(e,t),Object.defineProperty(e.prototype,"ripple",{get:function(){return this.rippleComponent},enumerable:!1,configurable:!0}),e.attachTo=function(t){return new e(t)},e.prototype.initialize=function(t){var e=this;void 0===t&&(t=function(t,e){return new M(t,e)});var n=v(v({},M.createAdapter(this)),{computeBoundingRect:function(){return e.foundation.getDimensions()}});this.rippleComponent=t(this.root,new L(n))},e.prototype.initialSyncWithDOM=function(){var t=this;this.handleClick=function(){t.foundation.handleClick()},this.listen(G,this.handleClick)},e.prototype.destroy=function(){this.ripple.destroy(),this.unlisten(G,this.handleClick),t.prototype.destroy.call(this)},e.prototype.getDefaultFoundation=function(){var t=this;return new W({isSingleSelect:function(){return t.isSingleSelect},getAttr:function(e){return t.root.getAttribute(e)},setAttr:function(e,n){t.root.setAttribute(e,n)},addClass:function(e){t.root.classList.add(e)},removeClass:function(e){t.root.classList.remove(e)},hasClass:function(e){return t.root.classList.contains(e)},notifySelectedChange:function(e){t.emit(q,{index:t.index,selected:e,segmentId:t.getSegmentId()},!0)},getRootBoundingClientRect:function(){return t.root.getBoundingClientRect()}})},e.prototype.setIndex=function(t){this.index=t},e.prototype.setIsSingleSelect=function(t){this.isSingleSelect=t},e.prototype.isSelected=function(){return this.foundation.isSelected()},e.prototype.setSelected=function(){this.foundation.setSelected()},e.prototype.setUnselected=function(){this.foundation.setUnselected()},e.prototype.getSegmentId=function(){return this.foundation.getSegmentId()},e}(w),Z=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return g(e,t),e.attachTo=function(t){return new e(t)},Object.defineProperty(e.prototype,"segments",{get:function(){return this.segmentsList.slice()},enumerable:!1,configurable:!0}),e.prototype.initialize=function(t){void 0===t&&(t=function(t){return new Y(t)}),this.segmentFactory=t,this.segmentsList=this.instantiateSegments(this.segmentFactory)},e.prototype.instantiateSegments=function(t){return[].slice.call(this.root.querySelectorAll(C)).map((function(e){return t(e)}))},e.prototype.initialSyncWithDOM=function(){var t=this;this.handleSelected=function(e){t.foundation.handleSelected(e.detail)},this.listen(E,this.handleSelected);for(var e=this.foundation.isSingleSelect(),n=0;n<this.segmentsList.length;n++){var i=this.segmentsList[n];i.setIndex(n),i.setIsSingleSelect(e)}var r=this.segmentsList.filter((function(t){return t.isSelected()}));if(e&&0===r.length&&this.segmentsList.length>0)throw new Error("No segment selected in singleSelect mdc-segmented-button");if(e&&r.length>1)throw new Error("Multiple segments selected in singleSelect mdc-segmented-button")},e.prototype.destroy=function(){var e,n;try{for(var i=y(this.segmentsList),r=i.next();!r.done;r=i.next()){r.value.destroy()}}catch(o){e={error:o}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}this.unlisten(E,this.handleSelected),t.prototype.destroy.call(this)},e.prototype.getDefaultFoundation=function(){var t=this;return new O({hasClass:function(e){return t.root.classList.contains(e)},getSegments:function(){return t.mappedSegments()},selectSegment:function(e){var n=t.mappedSegments().find((function(t){return t.index===e||t.segmentId===e}));n&&t.segmentsList[n.index].setSelected()},unselectSegment:function(e){var n=t.mappedSegments().find((function(t){return t.index===e||t.segmentId===e}));n&&t.segmentsList[n.index].setUnselected()},notifySelectedChange:function(e){t.emit(T,e,!0)}})},e.prototype.getSelectedSegments=function(){return this.foundation.getSelectedSegments()},e.prototype.selectSegment=function(t){this.foundation.selectSegment(t)},e.prototype.unselectSegment=function(t){this.foundation.unselectSegment(t)},e.prototype.isSegmentSelected=function(t){return this.foundation.isSegmentSelected(t)},e.prototype.mappedSegments=function(){return this.segmentsList.map((function(t,e){return{index:e,selected:t.isSelected(),segmentId:t.getSegmentId()}}))},e}(w);const K={cssClasses:{icon:"material-icons"},EVENTS:{CLICK:"click"},getMaterialIconClass:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return[K.cssClasses.icon,...e]}};var J=K;const Q={icon:{type:String,default:""}};const tt=["role"],et=(0,h.createElementVNode)("div",{class:"mdc-segmented-button__ripple"},null,-1),nt=["textContent"],it={cssClasses:{icon:"mdc-segmented-button__icon",label:"mdc-segmented-button__label",touch:"mdc-segmented-button--touch"}},rt={name:"UiSegmentedButton",customOptions:{UI_GLOBAL:J,UI_SEGMENTED_BUTTON:it}};var ot=Object.assign(rt,{props:{selected:{type:Boolean,default:!1},...Q,text:{type:String,default:""}},emits:[J.EVENTS.CLICK],setup(t,e){let{emit:n}=e;const i=t,r=n,o=(0,h.ref)(null),{handleClick:a}=function(t){let{emit:e}=t;return{handleClick:function(t){e(K.EVENTS.CLICK,t)}}}({emit:r}),{materialIcon:s}=function(t){return{materialIcon:(0,h.computed)((()=>t.icon||!1))}}(i),c=(0,h.computed)((()=>o.value&&o.value.classList.contains(it.cssClasses.touch))),u=(0,h.computed)((()=>({"mdc-segmented-button__segment":!0,"mdc-segmented-button__segment--selected":i.selected,"mdc-segmented-button--touch":c.value})));return(e,n)=>((0,h.openBlock)(),(0,h.createElementBlock)("button",{ref_key:"segmentedButton",ref:o,class:(0,h.normalizeClass)(u.value),role:e.$parent.singleSelect?"radio":null,onClick:n[0]||(n[0]=function(){return(0,h.unref)(a)&&(0,h.unref)(a)(...arguments)})},[et,(0,h.renderSlot)(e.$slots,"before",{iconClass:it.cssClasses.icon},(()=>[(0,h.unref)(s)?((0,h.openBlock)(),(0,h.createElementBlock)("i",{key:0,class:(0,h.normalizeClass)((0,h.unref)(J).getMaterialIconClass(it.cssClasses.icon)),"aria-hidden":"true",textContent:(0,h.toDisplayString)((0,h.unref)(s))},null,10,nt)):(0,h.createCommentVNode)("",!0)])),(0,h.renderSlot)(e.$slots,"default",{textClass:it.cssClasses.label},(()=>[t.text?((0,h.openBlock)(),(0,h.createElementBlock)("span",{key:0,class:(0,h.normalizeClass)(it.cssClasses.label)},(0,h.toDisplayString)(t.text),3)):(0,h.createCommentVNode)("",!0)])),(0,h.renderSlot)(e.$slots,"after",{iconClass:it.cssClasses.icon})],10,tt))}});var at=ot;const st=["role"],ct={EVENTS:{CHANGE:"update:modelValue",SELECTED:"selected"}},ut={name:"UiSegmentedButtons",customOptions:{UI_SEGMENTED_BUTTONS:ct}};var lt=f({UiSegmentedButtons:Object.assign(ut,{props:{modelValue:{type:[Array,Number],default:()=>[]},items:{type:Array,default:()=>[]},singleSelect:{type:Boolean,default:!1}},emits:[ct.EVENTS.CHANGE,ct.EVENTS.SELECTED],setup(t,e){let{emit:n}=e;const i=t,r=n,o=(0,h.ref)(null),a=(0,h.reactive)({selectedValue:i.modelValue}),{selectedValue:s}=(0,h.toRefs)(a),c=(0,h.computed)((()=>({"mdc-segmented-button":!0,"mdc-segmented-button--single-select":i.singleSelect}))),u=(0,h.computed)((()=>i.singleSelect?"radiogroup":"group"));return(0,h.watch)((()=>i.modelValue),(t=>{a.selectedValue=t})),(0,h.onMounted)((()=>{try{!function(t){const e=new Z(t);e.listen(T,(t=>{let{detail:e}=t;const n=e.index;let o=a.selectedValue;i.singleSelect?o=n:(e.selected?(o.push(n),o=[...new Set(o)]):o=o.filter((t=>t!==n)),o.sort(((t,e)=>t-e))),r(ct.EVENTS.CHANGE,o),r(ct.EVENTS.SELECTED,n)}));const n=e.segments.filter(((t,e)=>a.selectedValue.includes(e)));n.length&&n.forEach((t=>t.setSelected()))}(o.value)}catch(t){}})),(e,n)=>((0,h.openBlock)(),(0,h.createElementBlock)("div",{ref_key:"segmentedButtons",ref:o,class:(0,h.normalizeClass)(c.value),role:u.value},[(0,h.renderSlot)(e.$slots,"default",{},(()=>[((0,h.openBlock)(!0),(0,h.createElementBlock)(h.Fragment,null,(0,h.renderList)(t.items,((e,n)=>((0,h.openBlock)(),(0,h.createBlock)(at,{key:n,text:e.text||null,icon:e.icon||null,selected:!!t.singleSelect&&n===(0,h.unref)(s),onClick:t=>{return e=n,void(i.singleSelect&&(a.selectedValue=e,r(ct.EVENTS.CHANGE,a.selectedValue),r(ct.EVENTS.SELECTED,e)));var e}},null,8,["text","icon","selected","onClick"])))),128))]))],10,st))}}),UiSegmentedButton:at});return r=r.default}()}));