monobill-mintui 0.4.2 → 0.4.3
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/Icon-BTuYBm_3.cjs +1 -0
- package/dist/Icon-ByNhn8tE.js +77 -0
- package/dist/button-CAQ8mBQ2.js +575 -0
- package/dist/button-DuNZkwFV.cjs +1 -0
- package/dist/button.cjs +1 -0
- package/dist/button.d.ts +1 -0
- package/dist/button.js +2 -0
- package/dist/card-C1AqNkxK.cjs +1 -0
- package/dist/card-LNjZ86sr.js +58 -0
- package/dist/card.cjs +1 -0
- package/dist/card.d.ts +1 -0
- package/dist/card.js +2 -0
- package/dist/checkbox-Bkgxfl0k.js +169 -0
- package/dist/checkbox-DgwXHIbu.cjs +1 -0
- package/dist/checkbox.cjs +1 -0
- package/dist/checkbox.d.ts +1 -0
- package/dist/checkbox.js +1 -0
- package/dist/choice-BAk8Jd5E.cjs +1 -0
- package/dist/choice-Cs16XiRh.js +204 -0
- package/dist/choice.cjs +1 -0
- package/dist/choice.d.ts +1 -0
- package/dist/choice.js +1 -0
- package/dist/grid-ByGfCtMT.cjs +1 -0
- package/dist/grid-DhnNax_w.js +62 -0
- package/dist/grid.cjs +1 -0
- package/dist/grid.d.ts +1 -0
- package/dist/grid.js +2 -0
- package/dist/icon-D8dpuFVm.js +701 -0
- package/dist/icon-Dut5ZPmM.cjs +1 -0
- package/dist/icon.cjs +1 -0
- package/dist/icon.d.ts +1 -0
- package/dist/icon.js +3 -0
- package/dist/index.cjs +1 -63
- package/dist/index.d.ts +35 -0
- package/dist/index.js +16 -2756
- package/dist/link-B-z-io7I.cjs +1 -0
- package/dist/link-DC8l274I.js +75 -0
- package/dist/link.cjs +1 -0
- package/dist/link.d.ts +1 -0
- package/dist/link.js +2 -0
- package/dist/mintui-elements.d.ts +78 -0
- package/dist/modal-BZYcRU3i.js +98 -0
- package/dist/modal-C_ukm1We.cjs +1 -0
- package/dist/modal.cjs +1 -0
- package/dist/modal.d.ts +1 -0
- package/dist/modal.js +1 -0
- package/dist/page-CJ3M0wAd.cjs +1 -0
- package/dist/page-aBsDfG3x.js +112 -0
- package/dist/page.cjs +1 -0
- package/dist/page.d.ts +1 -0
- package/dist/page.js +2 -0
- package/dist/popover-7bn3gySt.js +181 -0
- package/dist/popover-CuSBQ8Jm.cjs +1 -0
- package/dist/popover.cjs +1 -0
- package/dist/popover.d.ts +1 -0
- package/dist/popover.js +1 -0
- package/dist/spinner-DqXU-cr-.js +111 -0
- package/dist/spinner-GtQIe8rS.cjs +63 -0
- package/dist/spinner.cjs +1 -0
- package/dist/spinner.d.ts +1 -0
- package/dist/spinner.js +2 -0
- package/dist/stack-D0noPfD1.js +114 -0
- package/dist/stack-tFy8YlX2.cjs +1 -0
- package/dist/stack.cjs +1 -0
- package/dist/stack.d.ts +1 -0
- package/dist/stack.js +2 -0
- package/dist/styles.css +1 -0
- package/dist/switch-DQ0Eaz6M.js +138 -0
- package/dist/switch-DeQNPnla.cjs +1 -0
- package/dist/switch.cjs +1 -0
- package/dist/switch.d.ts +1 -0
- package/dist/switch.js +2 -0
- package/dist/text-CoinZsjJ.cjs +1 -0
- package/dist/text-q58TQcH-.js +111 -0
- package/dist/text.cjs +1 -0
- package/dist/text.d.ts +1 -0
- package/dist/text.js +2 -0
- package/package.json +50 -23
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`./spinner-GtQIe8rS.cjs`),require(`./icon-Dut5ZPmM.cjs`);var e=class extends HTMLElement{static get observedAttributes(){return[`variant`,`tone`,`disabled`,`loading`,`button-type`,`full-width`,`icon-position`,`icon`]}constructor(){super(),this._button=null,this._clickHandler=null,this._isHandlingClick=!1}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`inline-block`),this.render(),this._button&&this.setupEventListeners(),this.isFullWidth()&&this.classList.add(`w-full`)}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(e,t,n){t!==n&&this.render()}getVariant(){return this.getAttribute(`variant`)||`solid`}getTone(){return this.getAttribute(`tone`)||`neutral`}isDisabled(){return this.hasAttribute(`disabled`)}isLoading(){return this.hasAttribute(`loading`)}getType(){return(this.getAttribute(`button-type`)||`default`)===`submit`?`submit`:`button`}isFullWidth(){return this.hasAttribute(`full-width`)}getIconPosition(){return this.getAttribute(`icon-position`)||`left`}getIcon(){return this.getAttribute(`icon`)||``}isIconOnly(){if(!(this.getIcon()||this._button?.querySelector(`[slot="icon"], .mint-button-icon, mint-icon`)))return!1;let e=this._button?.querySelector(`.mint-button-content`);if(e&&e.textContent.trim())return!1;if(this._button){for(let e=this._button.firstChild;e;e=e.nextSibling)if(e.nodeType===Node.TEXT_NODE&&e.textContent.trim()||e.nodeType===Node.ELEMENT_NODE&&e.tagName!==`MINT-ICON`&&e.tagName!==`MINT-SPINNER`&&!e.querySelector?.(`mint-spinner`)&&!e.hasAttribute?.(`slot`)&&e.className!==`mint-button-icon`&&!(e.className===`mr-2`&&e.querySelector(`mint-spinner`))&&e.textContent.trim())return!1}return!0}getButtonClasses(){let e=this.isIconOnly(),t=this.getVariant(),n=[`inline-flex`,`items-center`,`justify-center`,`font-medium`,`rounded-lg`,`box-border`,...e?[`p-1.5`,`aspect-square`,`w-[2rem]`,`h-[2rem]`]:[`px-3.5`,`py-1.5`,`min-h-[2rem]`],`text-sm`,`transition-all`,`duration-200`,`outline-none`,`focus:outline-none`,`focus-visible:ring-2`,`focus-visible:ring-offset-2`,`[&.mint-button-active>*]:scale-95`,`[&>*]:transition-transform`,`[&>*]:duration-100`,`disabled:opacity-50`,`disabled:cursor-not-allowed`],r=this.getTone(),i={"solid-action":[`bg-slate-800`,`dark:bg-slate-600`,`text-white`,`hover:bg-slate-950`,`dark:hover:bg-slate-700`,`active:bg-slate-900`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]`,`dark:active:bg-slate-700`,`disabled:active:bg-slate-800`,`dark:disabled:active:bg-slate-600`,`disabled:active:shadow-none`,`focus-visible:ring-slate-500`,`dark:focus-visible:ring-slate-400`,`shadow-sm`,`hover:shadow`,`dark:shadow-gray-900/50`,`border-2`,`border-transparent`],"solid-neutral":[`bg-white`,`dark:bg-gray-700`,`text-gray-900`,`dark:text-white`,`hover:bg-gray-50`,`dark:hover:bg-gray-600`,`active:bg-gray-100`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:active:bg-gray-800`,`disabled:active:bg-white`,`dark:disabled:active:bg-gray-700`,`disabled:active:shadow-none`,`focus-visible:ring-gray-400`,`dark:focus-visible:ring-gray-500`,`shadow-sm`,`hover:shadow`,`dark:shadow-gray-900/50`,`border-2`,`border-gray-200`,`dark:border-gray-600`],"solid-info":[`bg-blue-800`,`dark:bg-blue-600`,`text-white`,`hover:bg-blue-950`,`dark:hover:bg-blue-700`,`active:bg-blue-900`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]`,`dark:active:bg-blue-700`,`disabled:active:bg-blue-800`,`dark:disabled:active:bg-blue-600`,`disabled:active:shadow-none`,`focus-visible:ring-blue-500`,`dark:focus-visible:ring-blue-400`,`shadow-sm`,`hover:shadow`,`dark:shadow-gray-900/50`,`border-2`,`border-transparent`],"solid-warning":[`bg-amber-800`,`dark:bg-amber-600`,`text-white`,`hover:bg-amber-950`,`dark:hover:bg-amber-700`,`active:bg-amber-900`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]`,`dark:active:bg-amber-700`,`disabled:active:bg-amber-800`,`dark:disabled:active:bg-amber-600`,`disabled:active:shadow-none`,`focus-visible:ring-amber-500`,`dark:focus-visible:ring-amber-400`,`shadow-sm`,`hover:shadow`,`dark:shadow-gray-900/50`,`border-2`,`border-transparent`],"solid-danger":[`bg-red-800`,`dark:bg-red-600`,`text-white`,`hover:bg-red-950`,`dark:hover:bg-red-700`,`active:bg-red-900`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]`,`dark:active:bg-red-700`,`disabled:active:bg-red-800`,`dark:disabled:active:bg-red-600`,`disabled:active:shadow-none`,`focus-visible:ring-red-500`,`dark:focus-visible:ring-red-400`,`shadow-sm`,`hover:shadow`,`dark:shadow-gray-900/50`,`border-2`,`border-transparent`],"outline-action":[`bg-transparent`,`border-2`,`border-slate-700`,`dark:border-slate-500`,`text-slate-800`,`dark:text-slate-600`,`hover:bg-slate-800`,`dark:hover:bg-slate-600`,`hover:text-white`,`active:bg-slate-900`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]`,`dark:active:bg-slate-700`,`disabled:active:bg-transparent`,`dark:disabled:active:bg-transparent`,`disabled:active:shadow-none`,`focus-visible:ring-slate-500`,`dark:focus-visible:ring-slate-400`,`shadow-none`,`hover:shadow-sm`],"outline-neutral":[`bg-transparent`,`border-2`,`border-gray-300`,`dark:border-gray-500`,`text-gray-700`,`dark:text-gray-200`,`hover:bg-white`,`dark:hover:bg-gray-700`,`hover:text-gray-900`,`dark:hover:text-white`,`active:bg-gray-50`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:active:bg-gray-800`,`disabled:active:bg-transparent`,`dark:disabled:active:bg-transparent`,`disabled:active:shadow-none`,`focus-visible:ring-gray-400`,`dark:focus-visible:ring-gray-500`,`shadow-none`,`hover:shadow-sm`],"outline-info":[`bg-transparent`,`border-2`,`border-blue-700`,`dark:border-blue-500`,`text-blue-800`,`dark:text-blue-600`,`hover:bg-blue-800`,`dark:hover:bg-blue-600`,`hover:text-white`,`active:bg-blue-900`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]`,`dark:active:bg-blue-700`,`disabled:active:bg-transparent`,`dark:disabled:active:bg-transparent`,`disabled:active:shadow-none`,`focus-visible:ring-blue-500`,`dark:focus-visible:ring-blue-400`,`shadow-none`,`hover:shadow-sm`],"outline-warning":[`bg-transparent`,`border-2`,`border-amber-700`,`dark:border-amber-500`,`text-amber-800`,`dark:text-amber-600`,`hover:bg-amber-800`,`dark:hover:bg-amber-600`,`hover:text-white`,`active:bg-amber-900`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]`,`dark:active:bg-amber-700`,`disabled:active:bg-transparent`,`dark:disabled:active:bg-transparent`,`disabled:active:shadow-none`,`focus-visible:ring-amber-500`,`dark:focus-visible:ring-amber-400`,`shadow-none`,`hover:shadow-sm`],"outline-danger":[`bg-transparent`,`border-2`,`border-red-700`,`dark:border-red-500`,`text-red-800`,`dark:text-red-600`,`hover:bg-red-800`,`dark:hover:bg-red-600`,`hover:text-white`,`active:bg-red-900`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]`,`dark:active:bg-red-700`,`disabled:active:bg-transparent`,`dark:disabled:active:bg-transparent`,`disabled:active:shadow-none`,`focus-visible:ring-red-500`,`dark:focus-visible:ring-red-400`,`shadow-none`,`hover:shadow-sm`],"ghost-action":[`bg-transparent`,`text-slate-800`,`dark:text-slate-400`,`active:bg-gray-100`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:active:bg-gray-800`,`disabled:active:bg-transparent`,`dark:disabled:active:bg-transparent`,`disabled:active:shadow-none`,`focus-visible:ring-gray-400`,`dark:focus-visible:ring-gray-500`,`shadow-none`,`hover:shadow-none`,`border-2`,`border-transparent`],"ghost-neutral":[`bg-transparent`,`text-gray-700`,`dark:text-gray-200`,`active:bg-gray-50`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:active:bg-gray-800`,`active:text-gray-900`,`dark:active:text-white`,`disabled:active:bg-transparent`,`dark:disabled:active:bg-transparent`,`disabled:active:shadow-none`,`focus-visible:ring-gray-400`,`dark:focus-visible:ring-gray-500`,`shadow-none`,`hover:shadow-none`,`border-2`,`border-transparent`],"ghost-info":[`bg-transparent`,`text-blue-800`,`dark:text-blue-400`,`active:bg-gray-100`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:active:bg-gray-800`,`disabled:active:bg-transparent`,`dark:disabled:active:bg-transparent`,`disabled:active:shadow-none`,`focus-visible:ring-gray-400`,`dark:focus-visible:ring-gray-500`,`shadow-none`,`hover:shadow-none`,`border-2`,`border-transparent`],"ghost-warning":[`bg-transparent`,`text-amber-800`,`dark:text-amber-400`,`active:bg-gray-100`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:active:bg-gray-800`,`disabled:active:bg-transparent`,`dark:disabled:active:bg-transparent`,`disabled:active:shadow-none`,`focus-visible:ring-gray-400`,`dark:focus-visible:ring-gray-500`,`shadow-none`,`hover:shadow-none`,`border-2`,`border-transparent`],"ghost-danger":[`bg-transparent`,`text-red-800`,`dark:text-red-400`,`active:bg-gray-100`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:active:bg-gray-800`,`disabled:active:bg-transparent`,`dark:disabled:active:bg-transparent`,`disabled:active:shadow-none`,`focus-visible:ring-gray-400`,`dark:focus-visible:ring-gray-500`,`shadow-none`,`hover:shadow-none`,`border-2`,`border-transparent`],"link-action":[`bg-transparent`,`text-slate-800`,`dark:text-slate-400`,`hover:text-slate-950`,`dark:hover:text-slate-200`,`active:text-slate-900`,`dark:active:text-slate-300`,`disabled:active:bg-transparent`,`dark:disabled:active:bg-transparent`,`disabled:active:shadow-none`,`focus-visible:ring-slate-500`,`dark:focus-visible:ring-slate-400`,`shadow-none`,`hover:shadow-none`,`border-2`,`border-transparent`],"link-neutral":[`bg-transparent`,`text-gray-700`,`dark:text-gray-300`,`hover:text-gray-900`,`dark:hover:text-gray-100`,`active:text-gray-950`,`dark:active:text-gray-200`,`disabled:active:bg-transparent`,`dark:disabled:active:bg-transparent`,`disabled:active:shadow-none`,`focus-visible:ring-gray-400`,`dark:focus-visible:ring-gray-500`,`shadow-none`,`hover:shadow-none`,`border-2`,`border-transparent`],"link-info":[`bg-transparent`,`text-blue-800`,`dark:text-blue-400`,`hover:text-blue-950`,`dark:hover:text-blue-300`,`active:text-blue-900`,`dark:active:text-blue-200`,`disabled:active:bg-transparent`,`dark:disabled:active:bg-transparent`,`disabled:active:shadow-none`,`focus-visible:ring-blue-500`,`dark:focus-visible:ring-blue-400`,`shadow-none`,`hover:shadow-none`,`border-2`,`border-transparent`],"link-warning":[`bg-transparent`,`text-amber-800`,`dark:text-amber-400`,`hover:text-amber-950`,`dark:hover:text-amber-300`,`active:text-amber-900`,`dark:active:text-amber-200`,`disabled:active:bg-transparent`,`dark:disabled:active:bg-transparent`,`disabled:active:shadow-none`,`focus-visible:ring-amber-500`,`dark:focus-visible:ring-amber-400`,`shadow-none`,`hover:shadow-none`,`border-2`,`border-transparent`],"link-danger":[`bg-transparent`,`text-red-800`,`dark:text-red-400`,`hover:text-red-950`,`dark:hover:text-red-300`,`active:text-red-900`,`dark:active:text-red-200`,`disabled:active:bg-transparent`,`dark:disabled:active:bg-transparent`,`disabled:active:shadow-none`,`focus-visible:ring-red-500`,`dark:focus-visible:ring-red-400`,`shadow-none`,`hover:shadow-none`,`border-2`,`border-transparent`]},a=i[`${t}-${r}`]||i[`solid-neutral`],o=[...n,...a];return this.isFullWidth()&&o.push(`w-full`),o.join(` `)}render(){let e=this.isDisabled()||this.isLoading(),t=this.getType();if(!this._button){for(this._button=document.createElement(`button`);this.firstChild;)this._button.appendChild(this.firstChild);this.appendChild(this._button),this.setupEventListeners()}this._button.type=t,this._button.disabled=e;let n=this._button.querySelector(`mint-spinner`);if(this.isLoading())if(n)n.setAttribute(`data-button-variant`,this.getVariant()),n.setAttribute(`data-button-tone`,this.getTone()),n.render();else{let e=document.createElement(`span`);e.className=`mr-2 inline-flex items-center`;let t=document.createElement(`mint-spinner`);t.setAttribute(`size`,`default`),t.setAttribute(`data-button-variant`,this.getVariant()),t.setAttribute(`data-button-tone`,this.getTone()),t.style.width=`0.875rem`,t.style.height=`0.875rem`,e.appendChild(t),this._button.insertBefore(e,this._button.firstChild)}else n&&n.parentElement?.remove();for(;this.firstChild&&this.firstChild!==this._button;)this._button.appendChild(this.firstChild);let r=this.getIcon(),i=this._button.querySelector(`[slot="icon"], .mint-button-icon, mint-icon`);r?(i&&i.tagName!==`MINT-ICON`&&(i.remove(),i=null),!i||i.tagName!==`MINT-ICON`?(i=document.createElement(`mint-icon`),i.setAttribute(`name`,r),i.className=`mint-button-icon`):i.setAttribute(`name`,r)):i&&i.tagName===`MINT-ICON`&&(i.remove(),i=null),i||=this._button.querySelector(`[slot="icon"], .mint-button-icon`);let a=this.getIconPosition(),o=this._button.querySelector(`.mint-button-content`);if(o){let e=i&&i.tagName===`MINT-ICON`;if(i&&!i.parentElement){let t=this._button.querySelector(`mint-spinner`)?.parentElement;e||a===`left`?t?t.insertAdjacentElement(`afterend`,i):this._button.insertBefore(i,o):o.insertAdjacentElement(`afterend`,i)}else if(i&&(e||a===`left`)&&i.nextSibling!==o){i.remove();let e=this._button.querySelector(`mint-spinner`)?.parentElement;e?e.insertAdjacentElement(`afterend`,i):this._button.insertBefore(i,o)}else i&&!e&&a===`right`&&i.previousSibling!==o&&(i.remove(),o.insertAdjacentElement(`afterend`,i))}else{let e=[];for(let t=this._button.firstChild;t;t=t.nextSibling)t.tagName!==`MINT-SPINNER`&&!t.querySelector?.(`mint-spinner`)&&t!==i&&!t.hasAttribute?.(`slot`)&&!(t.className===`mr-2`&&t.querySelector(`mint-spinner`))&&e.push(t);if(e.length>0){o=document.createElement(`span`),o.className=`mint-button-content inline-flex items-center`,e.forEach(e=>{o.appendChild(e)});let t=this._button.querySelector(`mint-spinner`)?.parentElement;i&&a===`left`?t?(t.insertAdjacentElement(`afterend`,i),i.insertAdjacentElement(`afterend`,o)):(this._button.insertBefore(i,this._button.firstChild),i.insertAdjacentElement(`afterend`,o)):i&&a===`right`?t?(t.insertAdjacentElement(`afterend`,o),o.insertAdjacentElement(`afterend`,i)):(this._button.insertBefore(o,this._button.firstChild),o.insertAdjacentElement(`afterend`,i)):t?t.insertAdjacentElement(`afterend`,o):this._button.insertBefore(o,this._button.firstChild)}else if(i&&i.tagName===`MINT-ICON`&&!i.parentElement){let e=this._button.querySelector(`mint-spinner`)?.parentElement;e?e.insertAdjacentElement(`afterend`,i):this._button.insertBefore(i,this._button.firstChild)}}let s=this.isIconOnly();i&&(i.classList.contains(`mint-button-icon`)||i.classList.add(`mint-button-icon`),i.classList.remove(`mr-1.5`,`ml-1.5`),s?i.tagName===`MINT-ICON`?(i.style.width=`1rem`,i.style.height=`1rem`,i.style.maxWidth=`1rem`,i.style.maxHeight=`1rem`,i.style.flexShrink=`0`):(i.style.maxWidth=`1rem`,i.style.maxHeight=`1rem`,i.style.flexShrink=`0`,i.tagName===`svg`&&(i.style.width=`1rem`,i.style.height=`1rem`)):a===`left`?i.classList.add(`mr-1.5`):i.classList.add(`ml-1.5`));let c=this.getButtonClasses();this._button.className=c}setupEventListeners(){this._button&&!this._clickHandler&&(this._clickHandler=this.handleClick.bind(this),this._button.addEventListener(`click`,this._clickHandler,!0),this._button.addEventListener(`mousedown`,this._handleMouseDown),this._button.addEventListener(`mouseup`,this._handleMouseUp),this._button.addEventListener(`mouseleave`,this._handleMouseLeave),this._button.addEventListener(`touchstart`,this._handleTouchStart),this._button.addEventListener(`touchend`,this._handleTouchEnd),this._button.addEventListener(`touchcancel`,this._handleTouchCancel))}removeEventListeners(){this._button&&(this._clickHandler&&=(this._button.removeEventListener(`click`,this._clickHandler,!0),null),this._button.removeEventListener(`mousedown`,this._handleMouseDown),this._button.removeEventListener(`mouseup`,this._handleMouseUp),this._button.removeEventListener(`mouseleave`,this._handleMouseLeave),this._button.removeEventListener(`touchstart`,this._handleTouchStart),this._button.removeEventListener(`touchend`,this._handleTouchEnd),this._button.removeEventListener(`touchcancel`,this._handleTouchCancel))}_handleMouseDown=()=>{this._button&&!this.isDisabled()&&!this.isLoading()&&this._button.classList.add(`mint-button-active`)};_handleMouseUp=()=>{this._button&&this._button.classList.remove(`mint-button-active`)};_handleMouseLeave=()=>{this._button&&this._button.classList.remove(`mint-button-active`)};_handleTouchStart=()=>{this._button&&!this.isDisabled()&&!this.isLoading()&&this._button.classList.add(`mint-button-active`)};_handleTouchEnd=()=>{this._button&&this._button.classList.remove(`mint-button-active`)};_handleTouchCancel=()=>{this._button&&this._button.classList.remove(`mint-button-active`)};handleClick(e){if(this.isDisabled()||this.isLoading()){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();return}if(e.stopPropagation(),e.stopImmediatePropagation(),this._isHandlingClick){e.preventDefault();return}this._isHandlingClick=!0,e.preventDefault(),this.dispatchEvent(new CustomEvent(`click`,{detail:{originalEvent:e},bubbles:!0,cancelable:!0,composed:!0})),requestAnimationFrame(()=>{this._isHandlingClick=!1})}};customElements.get(`mint-button`)||customElements.define(`mint-button`,e),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
|
package/dist/button.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./button-DuNZkwFV.cjs`);module.exports=e.t;
|
package/dist/button.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MintButton as default } from './mintui-elements'
|
package/dist/button.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=class extends HTMLElement{static get observedAttributes(){return[]}constructor(){super()}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`block`),this.render()}attributeChangedCallback(e,t,n){t!==n&&this.render()}getCardClasses(){return[`rounded-lg`,`shadow`,`bg-white`,`dark:bg-gray-800`,`border`,`border-gray-200`,`dark:border-gray-700`,`overflow-hidden`,`transition-colors`,`duration-200`].join(` `)}render(){let e=this.getCardClasses();[`rounded-lg`,`shadow`,`bg-white`,`dark:bg-gray-800`,`border`,`border-gray-200`,`dark:border-gray-700`,`overflow-hidden`,`transition-colors`,`duration-200`].forEach(e=>this.classList.remove(e)),e.split(` `).forEach(e=>{e&&this.classList.add(e)}),[`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`block`].forEach(e=>{this.classList.contains(e)||this.classList.add(e)})}};customElements.get(`mint-card`)||customElements.define(`mint-card`,e),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//#region src/components/card/Card.js
|
|
2
|
+
var e = class extends HTMLElement {
|
|
3
|
+
static get observedAttributes() {
|
|
4
|
+
return [];
|
|
5
|
+
}
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
}
|
|
9
|
+
connectedCallback() {
|
|
10
|
+
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "block"), this.render();
|
|
11
|
+
}
|
|
12
|
+
attributeChangedCallback(e, t, n) {
|
|
13
|
+
t !== n && this.render();
|
|
14
|
+
}
|
|
15
|
+
getCardClasses() {
|
|
16
|
+
return [
|
|
17
|
+
"rounded-lg",
|
|
18
|
+
"shadow",
|
|
19
|
+
"bg-white",
|
|
20
|
+
"dark:bg-gray-800",
|
|
21
|
+
"border",
|
|
22
|
+
"border-gray-200",
|
|
23
|
+
"dark:border-gray-700",
|
|
24
|
+
"overflow-hidden",
|
|
25
|
+
"transition-colors",
|
|
26
|
+
"duration-200"
|
|
27
|
+
].join(" ");
|
|
28
|
+
}
|
|
29
|
+
render() {
|
|
30
|
+
let e = this.getCardClasses();
|
|
31
|
+
[
|
|
32
|
+
"rounded-lg",
|
|
33
|
+
"shadow",
|
|
34
|
+
"bg-white",
|
|
35
|
+
"dark:bg-gray-800",
|
|
36
|
+
"border",
|
|
37
|
+
"border-gray-200",
|
|
38
|
+
"dark:border-gray-700",
|
|
39
|
+
"overflow-hidden",
|
|
40
|
+
"transition-colors",
|
|
41
|
+
"duration-200"
|
|
42
|
+
].forEach((e) => this.classList.remove(e)), e.split(" ").forEach((e) => {
|
|
43
|
+
e && this.classList.add(e);
|
|
44
|
+
}), [
|
|
45
|
+
"box-border",
|
|
46
|
+
"m-0",
|
|
47
|
+
"p-0",
|
|
48
|
+
"border-0",
|
|
49
|
+
"align-baseline",
|
|
50
|
+
"block"
|
|
51
|
+
].forEach((e) => {
|
|
52
|
+
this.classList.contains(e) || this.classList.add(e);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
customElements.get("mint-card") || customElements.define("mint-card", e);
|
|
57
|
+
//#endregion
|
|
58
|
+
export { e as t };
|
package/dist/card.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./card-C1AqNkxK.cjs`);module.exports=e.t;
|
package/dist/card.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MintCard as default } from './mintui-elements'
|
package/dist/card.js
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import "./icon-D8dpuFVm.js";
|
|
2
|
+
//#region src/components/checkbox/Checkbox.js
|
|
3
|
+
var e = class extends HTMLElement {
|
|
4
|
+
static get observedAttributes() {
|
|
5
|
+
return [
|
|
6
|
+
"checked",
|
|
7
|
+
"disabled",
|
|
8
|
+
"label",
|
|
9
|
+
"info",
|
|
10
|
+
"id",
|
|
11
|
+
"name",
|
|
12
|
+
"value"
|
|
13
|
+
];
|
|
14
|
+
}
|
|
15
|
+
constructor() {
|
|
16
|
+
super(), this._checkbox = null, this._checked = !1, this._clickHandler = null;
|
|
17
|
+
}
|
|
18
|
+
connectedCallback() {
|
|
19
|
+
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "inline-flex", "items-start", "gap-2");
|
|
20
|
+
let e = this.getAttribute("checked");
|
|
21
|
+
this._checked = e !== null && e !== "false", this.render();
|
|
22
|
+
}
|
|
23
|
+
disconnectedCallback() {
|
|
24
|
+
this.removeEventListeners();
|
|
25
|
+
}
|
|
26
|
+
attributeChangedCallback(e, t, n) {
|
|
27
|
+
e === "checked" && (this._checked = n !== null && n !== "false", this._checkbox && (this._checkbox.checked = this._checked)), t !== n && (this.render(), e === "checked" && this._checkbox && this.updateVisualState());
|
|
28
|
+
}
|
|
29
|
+
get checked() {
|
|
30
|
+
return this._checked;
|
|
31
|
+
}
|
|
32
|
+
set checked(e) {
|
|
33
|
+
e ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this._checked = !!e, this._checkbox && (this._checkbox.checked = this._checked), this.updateVisualState();
|
|
34
|
+
}
|
|
35
|
+
isDisabled() {
|
|
36
|
+
return this.hasAttribute("disabled");
|
|
37
|
+
}
|
|
38
|
+
getLabel() {
|
|
39
|
+
return this.getAttribute("label") || "";
|
|
40
|
+
}
|
|
41
|
+
getInfo() {
|
|
42
|
+
return this.getAttribute("info") || "";
|
|
43
|
+
}
|
|
44
|
+
getId() {
|
|
45
|
+
return this.getAttribute("id") || "";
|
|
46
|
+
}
|
|
47
|
+
getName() {
|
|
48
|
+
return this.getAttribute("name") || "";
|
|
49
|
+
}
|
|
50
|
+
getValue() {
|
|
51
|
+
return this.getAttribute("value") || "";
|
|
52
|
+
}
|
|
53
|
+
getCheckboxClasses() {
|
|
54
|
+
let e = [
|
|
55
|
+
"relative",
|
|
56
|
+
"inline-flex",
|
|
57
|
+
"items-center",
|
|
58
|
+
"justify-center",
|
|
59
|
+
"flex-shrink-0",
|
|
60
|
+
"w-5",
|
|
61
|
+
"h-5",
|
|
62
|
+
"rounded",
|
|
63
|
+
"border-2",
|
|
64
|
+
"transition-all",
|
|
65
|
+
"duration-200",
|
|
66
|
+
"outline-none",
|
|
67
|
+
"focus:outline-none",
|
|
68
|
+
"focus-visible:ring-2",
|
|
69
|
+
"focus-visible:ring-offset-2",
|
|
70
|
+
"focus-visible:ring-slate-500",
|
|
71
|
+
"dark:focus-visible:ring-slate-400",
|
|
72
|
+
"cursor-pointer",
|
|
73
|
+
"disabled:opacity-50",
|
|
74
|
+
"disabled:cursor-not-allowed"
|
|
75
|
+
], t = this._checked ? [
|
|
76
|
+
"bg-slate-800",
|
|
77
|
+
"dark:bg-slate-600",
|
|
78
|
+
"border-slate-800",
|
|
79
|
+
"dark:border-slate-600"
|
|
80
|
+
] : [
|
|
81
|
+
"bg-white",
|
|
82
|
+
"dark:bg-gray-700",
|
|
83
|
+
"border-gray-300",
|
|
84
|
+
"dark:border-gray-500"
|
|
85
|
+
];
|
|
86
|
+
return [...e, ...t].join(" ");
|
|
87
|
+
}
|
|
88
|
+
render() {
|
|
89
|
+
let e = this.getLabel(), t = this.getInfo(), n = this.isDisabled(), r = this.querySelector(".mint-checkbox-wrapper");
|
|
90
|
+
r || (r = document.createElement("div"), r.className = "mint-checkbox-wrapper", this.insertBefore(r, this.firstChild)), this._checkbox ? this._checkbox.parentElement !== r && r.appendChild(this._checkbox) : (this._checkbox = document.createElement("input"), this._checkbox.type = "checkbox", r.appendChild(this._checkbox), this.setupEventListeners()), this._checkbox.className = "absolute inset-0 w-full h-full opacity-0 cursor-pointer", this._checkbox.style.cssText = "position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 10; pointer-events: auto; margin: 0; padding: 0;", this._checkbox.checked = this._checked, this._checkbox.disabled = n, this._changeHandler || this.setupEventListeners();
|
|
91
|
+
let i = this.getId();
|
|
92
|
+
i ? this._checkbox.id = i : this._checkbox.removeAttribute("id");
|
|
93
|
+
let a = this.getName();
|
|
94
|
+
a ? this._checkbox.name = a : this._checkbox.removeAttribute("name");
|
|
95
|
+
let o = this.getValue();
|
|
96
|
+
o ? this._checkbox.value = o : this._checkbox.removeAttribute("value"), e ? this._checkbox.setAttribute("aria-label", e) : this._checkbox.removeAttribute("aria-label"), r.className = `mint-checkbox-wrapper ${this.getCheckboxClasses()}`, r.style.pointerEvents = "none", this._checkbox.style.pointerEvents = "auto";
|
|
97
|
+
let s = r.querySelector("mint-icon");
|
|
98
|
+
s || (s = document.createElement("mint-icon"), s.setAttribute("name", "check"), s.className = "w-3.5 h-3.5 text-white pointer-events-none absolute inset-0 m-auto", s.style.transition = "opacity 200ms ease-out, transform 200ms ease-out", s.style.zIndex = "1", r.appendChild(s)), this.updateVisualState();
|
|
99
|
+
let c = this.querySelector(".mint-checkbox-label-container");
|
|
100
|
+
if (e || t) {
|
|
101
|
+
c || (c = document.createElement("div"), c.className = "mint-checkbox-label-container flex flex-col gap-0.5 flex-1", this.appendChild(c));
|
|
102
|
+
let r = c.querySelector(".mint-checkbox-label");
|
|
103
|
+
e ? (r || (r = document.createElement("span"), r.className = "mint-checkbox-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none", c.insertBefore(r, c.firstChild)), r.textContent = e, n ? r.classList.add("opacity-50") : r.classList.remove("opacity-50")) : r && r.remove();
|
|
104
|
+
let i = c.querySelector(".mint-checkbox-info");
|
|
105
|
+
if (t ? (i || (i = document.createElement("span"), i.className = "mint-checkbox-info text-xs text-gray-500 dark:text-gray-400 cursor-pointer select-none", c.appendChild(i)), i.textContent = t, n ? i.classList.add("opacity-50") : i.classList.remove("opacity-50")) : i && i.remove(), n) c.style.cursor = "default", c._clickHandler && (c.removeEventListener("click", c._clickHandler), c._clickHandler = null);
|
|
106
|
+
else {
|
|
107
|
+
c.style.cursor = "pointer";
|
|
108
|
+
let e = c._clickHandler;
|
|
109
|
+
e && c.removeEventListener("click", e), c._clickHandler = (e) => {
|
|
110
|
+
this._checkbox && (e.target === this._checkbox || this._checkbox.contains(e.target) || e.composedPath().includes(this._checkbox)) || this.toggle();
|
|
111
|
+
}, c.addEventListener("click", c._clickHandler);
|
|
112
|
+
}
|
|
113
|
+
} else c && c.remove();
|
|
114
|
+
}
|
|
115
|
+
setupEventListeners() {
|
|
116
|
+
this.removeEventListeners(), this._checkbox && (this._changeHandler = (e) => {
|
|
117
|
+
e.stopPropagation(), this._checked = this._checkbox.checked, this._checked ? this.hasAttribute("checked") || this.setAttribute("checked", "") : this.hasAttribute("checked") && this.removeAttribute("checked"), this.updateVisualState();
|
|
118
|
+
let t = new CustomEvent("change", {
|
|
119
|
+
detail: {
|
|
120
|
+
checked: this._checked,
|
|
121
|
+
value: this.getValue()
|
|
122
|
+
},
|
|
123
|
+
bubbles: !0,
|
|
124
|
+
cancelable: !0
|
|
125
|
+
});
|
|
126
|
+
this.dispatchEvent(t);
|
|
127
|
+
}, this._checkbox.addEventListener("change", this._changeHandler), this._mousedownHandler = (e) => {
|
|
128
|
+
e.stopPropagation();
|
|
129
|
+
let t = this.querySelector(".mint-checkbox-wrapper");
|
|
130
|
+
t && !this.isDisabled() && (t.classList.add("mint-checkbox-active"), this._checked ? (t.style.backgroundColor = "rgb(15 23 42)", t.style.boxShadow = "inset 0 2px 4px rgba(0, 0, 0, 0.3)") : (t.style.backgroundColor = "rgb(243 244 246)", t.style.boxShadow = "inset 0 2px 4px rgba(0, 0, 0, 0.1)"), document.documentElement.classList.contains("dark") && (this._checked ? t.style.backgroundColor = "rgb(51 65 85)" : t.style.backgroundColor = "rgb(31 41 55)"));
|
|
131
|
+
}, this._mouseupHandler = (e) => {
|
|
132
|
+
e.stopPropagation();
|
|
133
|
+
let t = this.querySelector(".mint-checkbox-wrapper");
|
|
134
|
+
t && (t.classList.remove("mint-checkbox-active"), t.style.backgroundColor = "", t.style.boxShadow = "");
|
|
135
|
+
}, this._mouseleaveHandler = (e) => {
|
|
136
|
+
let t = this.querySelector(".mint-checkbox-wrapper");
|
|
137
|
+
t && (t.classList.remove("mint-checkbox-active"), t.style.backgroundColor = "", t.style.boxShadow = "");
|
|
138
|
+
}, this._checkbox.addEventListener("mousedown", this._mousedownHandler), this._checkbox.addEventListener("mouseup", this._mouseupHandler), this._checkbox.addEventListener("mouseleave", this._mouseleaveHandler), this._touchstartHandler = (e) => {
|
|
139
|
+
e.stopPropagation();
|
|
140
|
+
let t = this.querySelector(".mint-checkbox-wrapper");
|
|
141
|
+
t && !this.isDisabled() && (t.classList.add("mint-checkbox-active"), this._checked ? (t.style.backgroundColor = "rgb(15 23 42)", t.style.boxShadow = "inset 0 2px 4px rgba(0, 0, 0, 0.3)") : (t.style.backgroundColor = "rgb(243 244 246)", t.style.boxShadow = "inset 0 2px 4px rgba(0, 0, 0, 0.1)"), document.documentElement.classList.contains("dark") && (this._checked ? t.style.backgroundColor = "rgb(51 65 85)" : t.style.backgroundColor = "rgb(31 41 55)"));
|
|
142
|
+
}, this._touchendHandler = (e) => {
|
|
143
|
+
e.stopPropagation();
|
|
144
|
+
let t = this.querySelector(".mint-checkbox-wrapper");
|
|
145
|
+
t && (t.classList.remove("mint-checkbox-active"), t.style.backgroundColor = "", t.style.boxShadow = "");
|
|
146
|
+
}, this._checkbox.addEventListener("touchstart", this._touchstartHandler), this._checkbox.addEventListener("touchend", this._touchendHandler));
|
|
147
|
+
}
|
|
148
|
+
removeEventListeners() {
|
|
149
|
+
this._checkbox && (this._changeHandler &&= (this._checkbox.removeEventListener("change", this._changeHandler), null), this._mousedownHandler &&= (this._checkbox.removeEventListener("mousedown", this._mousedownHandler), null), this._mouseupHandler &&= (this._checkbox.removeEventListener("mouseup", this._mouseupHandler), null), this._mouseleaveHandler &&= (this._checkbox.removeEventListener("mouseleave", this._mouseleaveHandler), null), this._touchstartHandler &&= (this._checkbox.removeEventListener("touchstart", this._touchstartHandler), null), this._touchendHandler &&= (this._checkbox.removeEventListener("touchend", this._touchendHandler), null));
|
|
150
|
+
}
|
|
151
|
+
updateVisualState() {
|
|
152
|
+
let e = this.querySelector(".mint-checkbox-wrapper"), t = e?.querySelector("mint-icon");
|
|
153
|
+
t && (t.style.opacity = this._checked ? "1" : "0", t.style.transform = this._checked ? "scale(1)" : "scale(0.8)"), e && (e.className = `mint-checkbox-wrapper ${this.getCheckboxClasses()}`, e.classList.contains("mint-checkbox-active") || (e.style.backgroundColor = "", e.style.boxShadow = ""));
|
|
154
|
+
}
|
|
155
|
+
toggle() {
|
|
156
|
+
if (this._checkbox && !this.isDisabled()) {
|
|
157
|
+
this._checkbox.checked = !this._checked, this._checked = this._checkbox.checked, this._checked ? this.hasAttribute("checked") || this.setAttribute("checked", "") : this.hasAttribute("checked") && this.removeAttribute("checked"), this.updateVisualState();
|
|
158
|
+
let e = new CustomEvent("change", {
|
|
159
|
+
detail: { checked: this._checked },
|
|
160
|
+
bubbles: !0,
|
|
161
|
+
cancelable: !0
|
|
162
|
+
});
|
|
163
|
+
this.dispatchEvent(e);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
customElements.get("mint-checkbox") || customElements.define("mint-checkbox", e);
|
|
168
|
+
//#endregion
|
|
169
|
+
export { e as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`./icon-Dut5ZPmM.cjs`);var e=class extends HTMLElement{static get observedAttributes(){return[`checked`,`disabled`,`label`,`info`,`id`,`name`,`value`]}constructor(){super(),this._checkbox=null,this._checked=!1,this._clickHandler=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`inline-flex`,`items-start`,`gap-2`);let e=this.getAttribute(`checked`);this._checked=e!==null&&e!==`false`,this.render()}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(e,t,n){e===`checked`&&(this._checked=n!==null&&n!==`false`,this._checkbox&&(this._checkbox.checked=this._checked)),t!==n&&(this.render(),e===`checked`&&this._checkbox&&this.updateVisualState())}get checked(){return this._checked}set checked(e){e?this.setAttribute(`checked`,``):this.removeAttribute(`checked`),this._checked=!!e,this._checkbox&&(this._checkbox.checked=this._checked),this.updateVisualState()}isDisabled(){return this.hasAttribute(`disabled`)}getLabel(){return this.getAttribute(`label`)||``}getInfo(){return this.getAttribute(`info`)||``}getId(){return this.getAttribute(`id`)||``}getName(){return this.getAttribute(`name`)||``}getValue(){return this.getAttribute(`value`)||``}getCheckboxClasses(){let e=[`relative`,`inline-flex`,`items-center`,`justify-center`,`flex-shrink-0`,`w-5`,`h-5`,`rounded`,`border-2`,`transition-all`,`duration-200`,`outline-none`,`focus:outline-none`,`focus-visible:ring-2`,`focus-visible:ring-offset-2`,`focus-visible:ring-slate-500`,`dark:focus-visible:ring-slate-400`,`cursor-pointer`,`disabled:opacity-50`,`disabled:cursor-not-allowed`],t=this._checked?[`bg-slate-800`,`dark:bg-slate-600`,`border-slate-800`,`dark:border-slate-600`]:[`bg-white`,`dark:bg-gray-700`,`border-gray-300`,`dark:border-gray-500`];return[...e,...t].join(` `)}render(){let e=this.getLabel(),t=this.getInfo(),n=this.isDisabled(),r=this.querySelector(`.mint-checkbox-wrapper`);r||(r=document.createElement(`div`),r.className=`mint-checkbox-wrapper`,this.insertBefore(r,this.firstChild)),this._checkbox?this._checkbox.parentElement!==r&&r.appendChild(this._checkbox):(this._checkbox=document.createElement(`input`),this._checkbox.type=`checkbox`,r.appendChild(this._checkbox),this.setupEventListeners()),this._checkbox.className=`absolute inset-0 w-full h-full opacity-0 cursor-pointer`,this._checkbox.style.cssText=`position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 10; pointer-events: auto; margin: 0; padding: 0;`,this._checkbox.checked=this._checked,this._checkbox.disabled=n,this._changeHandler||this.setupEventListeners();let i=this.getId();i?this._checkbox.id=i:this._checkbox.removeAttribute(`id`);let a=this.getName();a?this._checkbox.name=a:this._checkbox.removeAttribute(`name`);let o=this.getValue();o?this._checkbox.value=o:this._checkbox.removeAttribute(`value`),e?this._checkbox.setAttribute(`aria-label`,e):this._checkbox.removeAttribute(`aria-label`),r.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`,r.style.pointerEvents=`none`,this._checkbox.style.pointerEvents=`auto`;let s=r.querySelector(`mint-icon`);s||(s=document.createElement(`mint-icon`),s.setAttribute(`name`,`check`),s.className=`w-3.5 h-3.5 text-white pointer-events-none absolute inset-0 m-auto`,s.style.transition=`opacity 200ms ease-out, transform 200ms ease-out`,s.style.zIndex=`1`,r.appendChild(s)),this.updateVisualState();let c=this.querySelector(`.mint-checkbox-label-container`);if(e||t){c||(c=document.createElement(`div`),c.className=`mint-checkbox-label-container flex flex-col gap-0.5 flex-1`,this.appendChild(c));let r=c.querySelector(`.mint-checkbox-label`);e?(r||(r=document.createElement(`span`),r.className=`mint-checkbox-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none`,c.insertBefore(r,c.firstChild)),r.textContent=e,n?r.classList.add(`opacity-50`):r.classList.remove(`opacity-50`)):r&&r.remove();let i=c.querySelector(`.mint-checkbox-info`);if(t?(i||(i=document.createElement(`span`),i.className=`mint-checkbox-info text-xs text-gray-500 dark:text-gray-400 cursor-pointer select-none`,c.appendChild(i)),i.textContent=t,n?i.classList.add(`opacity-50`):i.classList.remove(`opacity-50`)):i&&i.remove(),n)c.style.cursor=`default`,c._clickHandler&&(c.removeEventListener(`click`,c._clickHandler),c._clickHandler=null);else{c.style.cursor=`pointer`;let e=c._clickHandler;e&&c.removeEventListener(`click`,e),c._clickHandler=e=>{this._checkbox&&(e.target===this._checkbox||this._checkbox.contains(e.target)||e.composedPath().includes(this._checkbox))||this.toggle()},c.addEventListener(`click`,c._clickHandler)}}else c&&c.remove()}setupEventListeners(){this.removeEventListeners(),this._checkbox&&(this._changeHandler=e=>{e.stopPropagation(),this._checked=this._checkbox.checked,this._checked?this.hasAttribute(`checked`)||this.setAttribute(`checked`,``):this.hasAttribute(`checked`)&&this.removeAttribute(`checked`),this.updateVisualState();let t=new CustomEvent(`change`,{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0});this.dispatchEvent(t)},this._checkbox.addEventListener(`change`,this._changeHandler),this._mousedownHandler=e=>{e.stopPropagation();let t=this.querySelector(`.mint-checkbox-wrapper`);t&&!this.isDisabled()&&(t.classList.add(`mint-checkbox-active`),this._checked?(t.style.backgroundColor=`rgb(15 23 42)`,t.style.boxShadow=`inset 0 2px 4px rgba(0, 0, 0, 0.3)`):(t.style.backgroundColor=`rgb(243 244 246)`,t.style.boxShadow=`inset 0 2px 4px rgba(0, 0, 0, 0.1)`),document.documentElement.classList.contains(`dark`)&&(this._checked?t.style.backgroundColor=`rgb(51 65 85)`:t.style.backgroundColor=`rgb(31 41 55)`))},this._mouseupHandler=e=>{e.stopPropagation();let t=this.querySelector(`.mint-checkbox-wrapper`);t&&(t.classList.remove(`mint-checkbox-active`),t.style.backgroundColor=``,t.style.boxShadow=``)},this._mouseleaveHandler=e=>{let t=this.querySelector(`.mint-checkbox-wrapper`);t&&(t.classList.remove(`mint-checkbox-active`),t.style.backgroundColor=``,t.style.boxShadow=``)},this._checkbox.addEventListener(`mousedown`,this._mousedownHandler),this._checkbox.addEventListener(`mouseup`,this._mouseupHandler),this._checkbox.addEventListener(`mouseleave`,this._mouseleaveHandler),this._touchstartHandler=e=>{e.stopPropagation();let t=this.querySelector(`.mint-checkbox-wrapper`);t&&!this.isDisabled()&&(t.classList.add(`mint-checkbox-active`),this._checked?(t.style.backgroundColor=`rgb(15 23 42)`,t.style.boxShadow=`inset 0 2px 4px rgba(0, 0, 0, 0.3)`):(t.style.backgroundColor=`rgb(243 244 246)`,t.style.boxShadow=`inset 0 2px 4px rgba(0, 0, 0, 0.1)`),document.documentElement.classList.contains(`dark`)&&(this._checked?t.style.backgroundColor=`rgb(51 65 85)`:t.style.backgroundColor=`rgb(31 41 55)`))},this._touchendHandler=e=>{e.stopPropagation();let t=this.querySelector(`.mint-checkbox-wrapper`);t&&(t.classList.remove(`mint-checkbox-active`),t.style.backgroundColor=``,t.style.boxShadow=``)},this._checkbox.addEventListener(`touchstart`,this._touchstartHandler),this._checkbox.addEventListener(`touchend`,this._touchendHandler))}removeEventListeners(){this._checkbox&&(this._changeHandler&&=(this._checkbox.removeEventListener(`change`,this._changeHandler),null),this._mousedownHandler&&=(this._checkbox.removeEventListener(`mousedown`,this._mousedownHandler),null),this._mouseupHandler&&=(this._checkbox.removeEventListener(`mouseup`,this._mouseupHandler),null),this._mouseleaveHandler&&=(this._checkbox.removeEventListener(`mouseleave`,this._mouseleaveHandler),null),this._touchstartHandler&&=(this._checkbox.removeEventListener(`touchstart`,this._touchstartHandler),null),this._touchendHandler&&=(this._checkbox.removeEventListener(`touchend`,this._touchendHandler),null))}updateVisualState(){let e=this.querySelector(`.mint-checkbox-wrapper`),t=e?.querySelector(`mint-icon`);t&&(t.style.opacity=this._checked?`1`:`0`,t.style.transform=this._checked?`scale(1)`:`scale(0.8)`),e&&(e.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`,e.classList.contains(`mint-checkbox-active`)||(e.style.backgroundColor=``,e.style.boxShadow=``))}toggle(){if(this._checkbox&&!this.isDisabled()){this._checkbox.checked=!this._checked,this._checked=this._checkbox.checked,this._checked?this.hasAttribute(`checked`)||this.setAttribute(`checked`,``):this.hasAttribute(`checked`)&&this.removeAttribute(`checked`),this.updateVisualState();let e=new CustomEvent(`change`,{detail:{checked:this._checked},bubbles:!0,cancelable:!0});this.dispatchEvent(e)}}};customElements.get(`mint-checkbox`)||customElements.define(`mint-checkbox`,e),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`./checkbox-DgwXHIbu.cjs`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MintCheckbox as default } from './mintui-elements'
|
package/dist/checkbox.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./checkbox-Bkgxfl0k.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=class extends HTMLElement{static get observedAttributes(){return[`checked`,`disabled`,`label`,`info`,`id`,`name`,`value`]}constructor(){super(),this._radio=null,this._checked=!1}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`inline-flex`,`items-start`,`gap-2`);let e=this.getAttribute(`checked`);this._checked=e!==null&&e!==`false`,this.render()}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(e,t,n){e===`checked`&&(this._checked=n!==null&&n!==`false`,this._radio&&(this._radio.checked=this._checked)),t!==n&&(this.render(),e===`checked`&&this._radio&&this.updateVisualState())}get checked(){return this._checked}set checked(e){e?this.setAttribute(`checked`,``):this.removeAttribute(`checked`),this._checked=!!e,this._radio&&(this._radio.checked=this._checked),this.updateVisualState()}isDisabled(){return this.hasAttribute(`disabled`)}getLabel(){return this.getAttribute(`label`)||``}getInfo(){return this.getAttribute(`info`)||``}getId(){return this.getAttribute(`id`)||``}getName(){return this.getAttribute(`name`)||``}getValue(){return this.getAttribute(`value`)||``}getChoiceClasses(){let e=[`relative`,`inline-flex`,`items-center`,`justify-center`,`flex-shrink-0`,`w-5`,`h-5`,`rounded-full`,`border-2`,`transition-all`,`duration-200`,`outline-none`,`focus:outline-none`,`focus-visible:ring-2`,`focus-visible:ring-offset-2`,`focus-visible:ring-slate-500`,`dark:focus-visible:ring-slate-400`,`cursor-pointer`,`disabled:opacity-50`,`disabled:cursor-not-allowed`],t=this._checked?[`bg-slate-800`,`dark:bg-slate-600`,`border-slate-800`,`dark:border-slate-600`]:[`bg-white`,`dark:bg-gray-700`,`border-gray-300`,`dark:border-gray-500`];return[...e,...t].join(` `)}render(){let e=this.getLabel(),t=this.getInfo(),n=this.isDisabled(),r=this.querySelector(`.mint-choice-wrapper`);r||(r=document.createElement(`div`),r.className=`mint-choice-wrapper`,this.insertBefore(r,this.firstChild)),this._radio?this._radio.parentElement!==r&&r.appendChild(this._radio):(this._radio=document.createElement(`input`),this._radio.type=`radio`,r.appendChild(this._radio),this.setupEventListeners()),this._radio.className=`absolute inset-0 w-full h-full opacity-0 cursor-pointer`,this._radio.style.cssText=`position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 10; pointer-events: auto; margin: 0; padding: 0;`,this._radio.checked=this._checked,this._radio.disabled=n,this._changeHandler||this.setupEventListeners();let i=this.getId();i?this._radio.id=i:this._radio.removeAttribute(`id`);let a=this.getName();a?this._radio.name=a:this._radio.removeAttribute(`name`);let o=this.getValue();o?this._radio.value=o:this._radio.removeAttribute(`value`),e?this._radio.setAttribute(`aria-label`,e):this._radio.removeAttribute(`aria-label`),r.className=`mint-choice-wrapper ${this.getChoiceClasses()}`,r.style.pointerEvents=`none`,this._radio.style.pointerEvents=`auto`;let s=r.querySelector(`.mint-choice-indicator`);s||(s=document.createElement(`div`),s.className=`mint-choice-indicator w-2.5 h-2.5 rounded-full bg-white pointer-events-none absolute inset-0 m-auto`,s.style.transition=`opacity 200ms ease-out, transform 200ms ease-out`,s.style.zIndex=`1`,r.appendChild(s)),s.style.opacity=this._checked?`1`:`0`,s.style.transform=this._checked?`scale(1)`:`scale(0.8)`,this.updateVisualState();let c=this.querySelector(`.mint-choice-label-container`);if(e||t){c||(c=document.createElement(`div`),c.className=`mint-choice-label-container flex flex-col gap-0.5 flex-1`,this.appendChild(c));let r=c.querySelector(`.mint-choice-label`);e?(r||(r=document.createElement(`span`),r.className=`mint-choice-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none`,c.insertBefore(r,c.firstChild)),r.textContent=e,n?r.classList.add(`opacity-50`):r.classList.remove(`opacity-50`)):r&&r.remove();let i=c.querySelector(`.mint-choice-info`);if(t?(i||(i=document.createElement(`span`),i.className=`mint-choice-info text-xs text-gray-500 dark:text-gray-400 cursor-pointer select-none`,c.appendChild(i)),i.textContent=t,n?i.classList.add(`opacity-50`):i.classList.remove(`opacity-50`)):i&&i.remove(),n)c.style.cursor=`default`,c._clickHandler&&(c.removeEventListener(`click`,c._clickHandler),c._clickHandler=null);else{c.style.cursor=`pointer`;let e=c._clickHandler;e&&c.removeEventListener(`click`,e),c._clickHandler=e=>{this._radio&&(e.target===this._radio||this._radio.contains(e.target)||e.composedPath().includes(this._radio))||this.select()},c.addEventListener(`click`,c._clickHandler)}}else c&&c.remove()}setupEventListeners(){this.removeEventListeners(),this._radio&&(this._changeHandler=e=>{e.stopPropagation();let t=this._checked;if(this._checked=this._radio.checked,this._checked?this.hasAttribute(`checked`)||this.setAttribute(`checked`,``):this.hasAttribute(`checked`)&&this.removeAttribute(`checked`),this.updateVisualState(),this._checked){let e=this._radio.name;e&&document.querySelectorAll(`input[type="radio"][name="${e}"]`).forEach(e=>{if(e!==this._radio){let t=e.closest(`mint-choice`);t&&t.updateVisualState&&(t._checked=e.checked,e.checked?t.hasAttribute(`checked`)||t.setAttribute(`checked`,``):t.hasAttribute(`checked`)&&t.removeAttribute(`checked`),t.updateVisualState())}})}if(t!==this._checked){let e=new CustomEvent(`change`,{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0});this.dispatchEvent(e)}},this._radio.addEventListener(`change`,this._changeHandler),this._groupChangeHandler=e=>{e.target!==this._radio&&e.target.type===`radio`&&e.target.name===this._radio.name&&e.target.checked&&setTimeout(()=>{this._radio&&this._radio.checked!==this._checked&&(this._checked=this._radio.checked,this._checked?this.hasAttribute(`checked`)||this.setAttribute(`checked`,``):this.hasAttribute(`checked`)&&this.removeAttribute(`checked`),this.updateVisualState())},0)},document.addEventListener(`change`,this._groupChangeHandler,!0),this._clickHandler=e=>{let t=this._radio.name;t&&document.querySelectorAll(`input[type="radio"][name="${t}"]`).forEach(e=>{if(e!==this._radio){let t=e.closest(`mint-choice`);t&&t.updateVisualState&&(t._checked=e.checked,e.checked?t.hasAttribute(`checked`)||t.setAttribute(`checked`,``):t.hasAttribute(`checked`)&&t.removeAttribute(`checked`),t.updateVisualState())}}),requestAnimationFrame(()=>{this._checked=this._radio.checked,this.updateVisualState()})},this._radio.addEventListener(`click`,this._clickHandler),this._mousedownHandler=e=>{e.stopPropagation();let t=this.querySelector(`.mint-choice-wrapper`);t&&!this.isDisabled()&&(t.classList.add(`mint-choice-active`),this._checked?(t.style.backgroundColor=`rgb(15 23 42)`,t.style.boxShadow=`inset 0 2px 4px rgba(0, 0, 0, 0.3)`):(t.style.backgroundColor=`rgb(243 244 246)`,t.style.boxShadow=`inset 0 2px 4px rgba(0, 0, 0, 0.1)`),document.documentElement.classList.contains(`dark`)&&(this._checked?t.style.backgroundColor=`rgb(51 65 85)`:t.style.backgroundColor=`rgb(31 41 55)`))},this._mouseupHandler=e=>{e.stopPropagation();let t=this.querySelector(`.mint-choice-wrapper`);t&&(t.classList.remove(`mint-choice-active`),t.style.backgroundColor=``,t.style.boxShadow=``)},this._mouseleaveHandler=e=>{let t=this.querySelector(`.mint-choice-wrapper`);t&&(t.classList.remove(`mint-choice-active`),t.style.backgroundColor=``,t.style.boxShadow=``)},this._radio.addEventListener(`mousedown`,this._mousedownHandler),this._radio.addEventListener(`mouseup`,this._mouseupHandler),this._radio.addEventListener(`mouseleave`,this._mouseleaveHandler),this._touchstartHandler=e=>{e.stopPropagation();let t=this.querySelector(`.mint-choice-wrapper`);t&&!this.isDisabled()&&(t.classList.add(`mint-choice-active`),this._checked?(t.style.backgroundColor=`rgb(15 23 42)`,t.style.boxShadow=`inset 0 2px 4px rgba(0, 0, 0, 0.3)`):(t.style.backgroundColor=`rgb(243 244 246)`,t.style.boxShadow=`inset 0 2px 4px rgba(0, 0, 0, 0.1)`),document.documentElement.classList.contains(`dark`)&&(this._checked?t.style.backgroundColor=`rgb(51 65 85)`:t.style.backgroundColor=`rgb(31 41 55)`))},this._touchendHandler=e=>{e.stopPropagation();let t=this.querySelector(`.mint-choice-wrapper`);t&&(t.classList.remove(`mint-choice-active`),t.style.backgroundColor=``,t.style.boxShadow=``)},this._radio.addEventListener(`touchstart`,this._touchstartHandler),this._radio.addEventListener(`touchend`,this._touchendHandler))}removeEventListeners(){this._radio&&(this._changeHandler&&=(this._radio.removeEventListener(`change`,this._changeHandler),null),this._groupChangeHandler&&=(document.removeEventListener(`change`,this._groupChangeHandler),null),this._clickHandler&&=(this._radio.removeEventListener(`click`,this._clickHandler),null),this._mousedownHandler&&=(this._radio.removeEventListener(`mousedown`,this._mousedownHandler),null),this._mouseupHandler&&=(this._radio.removeEventListener(`mouseup`,this._mouseupHandler),null),this._mouseleaveHandler&&=(this._radio.removeEventListener(`mouseleave`,this._mouseleaveHandler),null),this._touchstartHandler&&=(this._radio.removeEventListener(`touchstart`,this._touchstartHandler),null),this._touchendHandler&&=(this._radio.removeEventListener(`touchend`,this._touchendHandler),null))}updateVisualState(){let e=this.querySelector(`.mint-choice-wrapper`),t=e?.querySelector(`.mint-choice-indicator`);t&&(t.style.opacity=this._checked?`1`:`0`,t.style.transform=this._checked?`scale(1)`:`scale(0.8)`),e&&(e.className=`mint-choice-wrapper ${this.getChoiceClasses()}`,e.classList.contains(`mint-choice-active`)||(e.style.backgroundColor=``,e.style.boxShadow=``))}select(){if(this._radio&&!this.isDisabled()){this._radio.checked=!0,this._radio.dispatchEvent(new Event(`change`,{bubbles:!0})),this._checked=!0,this.hasAttribute(`checked`)||this.setAttribute(`checked`,``);let e=this._radio.name;e&&document.querySelectorAll(`input[type="radio"][name="${e}"]`).forEach(e=>{if(e!==this._radio){let t=e.closest(`mint-choice`);t&&t.updateVisualState&&(t._checked=e.checked,e.checked?t.hasAttribute(`checked`)||t.setAttribute(`checked`,``):t.hasAttribute(`checked`)&&t.removeAttribute(`checked`),t.updateVisualState())}}),this.updateVisualState();let t=new CustomEvent(`change`,{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0});this.dispatchEvent(t)}}};customElements.get(`mint-choice`)||customElements.define(`mint-choice`,e),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
//#region src/components/choice/Choice.js
|
|
2
|
+
var e = class extends HTMLElement {
|
|
3
|
+
static get observedAttributes() {
|
|
4
|
+
return [
|
|
5
|
+
"checked",
|
|
6
|
+
"disabled",
|
|
7
|
+
"label",
|
|
8
|
+
"info",
|
|
9
|
+
"id",
|
|
10
|
+
"name",
|
|
11
|
+
"value"
|
|
12
|
+
];
|
|
13
|
+
}
|
|
14
|
+
constructor() {
|
|
15
|
+
super(), this._radio = null, this._checked = !1;
|
|
16
|
+
}
|
|
17
|
+
connectedCallback() {
|
|
18
|
+
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "inline-flex", "items-start", "gap-2");
|
|
19
|
+
let e = this.getAttribute("checked");
|
|
20
|
+
this._checked = e !== null && e !== "false", this.render();
|
|
21
|
+
}
|
|
22
|
+
disconnectedCallback() {
|
|
23
|
+
this.removeEventListeners();
|
|
24
|
+
}
|
|
25
|
+
attributeChangedCallback(e, t, n) {
|
|
26
|
+
e === "checked" && (this._checked = n !== null && n !== "false", this._radio && (this._radio.checked = this._checked)), t !== n && (this.render(), e === "checked" && this._radio && this.updateVisualState());
|
|
27
|
+
}
|
|
28
|
+
get checked() {
|
|
29
|
+
return this._checked;
|
|
30
|
+
}
|
|
31
|
+
set checked(e) {
|
|
32
|
+
e ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this._checked = !!e, this._radio && (this._radio.checked = this._checked), this.updateVisualState();
|
|
33
|
+
}
|
|
34
|
+
isDisabled() {
|
|
35
|
+
return this.hasAttribute("disabled");
|
|
36
|
+
}
|
|
37
|
+
getLabel() {
|
|
38
|
+
return this.getAttribute("label") || "";
|
|
39
|
+
}
|
|
40
|
+
getInfo() {
|
|
41
|
+
return this.getAttribute("info") || "";
|
|
42
|
+
}
|
|
43
|
+
getId() {
|
|
44
|
+
return this.getAttribute("id") || "";
|
|
45
|
+
}
|
|
46
|
+
getName() {
|
|
47
|
+
return this.getAttribute("name") || "";
|
|
48
|
+
}
|
|
49
|
+
getValue() {
|
|
50
|
+
return this.getAttribute("value") || "";
|
|
51
|
+
}
|
|
52
|
+
getChoiceClasses() {
|
|
53
|
+
let e = [
|
|
54
|
+
"relative",
|
|
55
|
+
"inline-flex",
|
|
56
|
+
"items-center",
|
|
57
|
+
"justify-center",
|
|
58
|
+
"flex-shrink-0",
|
|
59
|
+
"w-5",
|
|
60
|
+
"h-5",
|
|
61
|
+
"rounded-full",
|
|
62
|
+
"border-2",
|
|
63
|
+
"transition-all",
|
|
64
|
+
"duration-200",
|
|
65
|
+
"outline-none",
|
|
66
|
+
"focus:outline-none",
|
|
67
|
+
"focus-visible:ring-2",
|
|
68
|
+
"focus-visible:ring-offset-2",
|
|
69
|
+
"focus-visible:ring-slate-500",
|
|
70
|
+
"dark:focus-visible:ring-slate-400",
|
|
71
|
+
"cursor-pointer",
|
|
72
|
+
"disabled:opacity-50",
|
|
73
|
+
"disabled:cursor-not-allowed"
|
|
74
|
+
], t = this._checked ? [
|
|
75
|
+
"bg-slate-800",
|
|
76
|
+
"dark:bg-slate-600",
|
|
77
|
+
"border-slate-800",
|
|
78
|
+
"dark:border-slate-600"
|
|
79
|
+
] : [
|
|
80
|
+
"bg-white",
|
|
81
|
+
"dark:bg-gray-700",
|
|
82
|
+
"border-gray-300",
|
|
83
|
+
"dark:border-gray-500"
|
|
84
|
+
];
|
|
85
|
+
return [...e, ...t].join(" ");
|
|
86
|
+
}
|
|
87
|
+
render() {
|
|
88
|
+
let e = this.getLabel(), t = this.getInfo(), n = this.isDisabled(), r = this.querySelector(".mint-choice-wrapper");
|
|
89
|
+
r || (r = document.createElement("div"), r.className = "mint-choice-wrapper", this.insertBefore(r, this.firstChild)), this._radio ? this._radio.parentElement !== r && r.appendChild(this._radio) : (this._radio = document.createElement("input"), this._radio.type = "radio", r.appendChild(this._radio), this.setupEventListeners()), this._radio.className = "absolute inset-0 w-full h-full opacity-0 cursor-pointer", this._radio.style.cssText = "position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 10; pointer-events: auto; margin: 0; padding: 0;", this._radio.checked = this._checked, this._radio.disabled = n, this._changeHandler || this.setupEventListeners();
|
|
90
|
+
let i = this.getId();
|
|
91
|
+
i ? this._radio.id = i : this._radio.removeAttribute("id");
|
|
92
|
+
let a = this.getName();
|
|
93
|
+
a ? this._radio.name = a : this._radio.removeAttribute("name");
|
|
94
|
+
let o = this.getValue();
|
|
95
|
+
o ? this._radio.value = o : this._radio.removeAttribute("value"), e ? this._radio.setAttribute("aria-label", e) : this._radio.removeAttribute("aria-label"), r.className = `mint-choice-wrapper ${this.getChoiceClasses()}`, r.style.pointerEvents = "none", this._radio.style.pointerEvents = "auto";
|
|
96
|
+
let s = r.querySelector(".mint-choice-indicator");
|
|
97
|
+
s || (s = document.createElement("div"), s.className = "mint-choice-indicator w-2.5 h-2.5 rounded-full bg-white pointer-events-none absolute inset-0 m-auto", s.style.transition = "opacity 200ms ease-out, transform 200ms ease-out", s.style.zIndex = "1", r.appendChild(s)), s.style.opacity = this._checked ? "1" : "0", s.style.transform = this._checked ? "scale(1)" : "scale(0.8)", this.updateVisualState();
|
|
98
|
+
let c = this.querySelector(".mint-choice-label-container");
|
|
99
|
+
if (e || t) {
|
|
100
|
+
c || (c = document.createElement("div"), c.className = "mint-choice-label-container flex flex-col gap-0.5 flex-1", this.appendChild(c));
|
|
101
|
+
let r = c.querySelector(".mint-choice-label");
|
|
102
|
+
e ? (r || (r = document.createElement("span"), r.className = "mint-choice-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none", c.insertBefore(r, c.firstChild)), r.textContent = e, n ? r.classList.add("opacity-50") : r.classList.remove("opacity-50")) : r && r.remove();
|
|
103
|
+
let i = c.querySelector(".mint-choice-info");
|
|
104
|
+
if (t ? (i || (i = document.createElement("span"), i.className = "mint-choice-info text-xs text-gray-500 dark:text-gray-400 cursor-pointer select-none", c.appendChild(i)), i.textContent = t, n ? i.classList.add("opacity-50") : i.classList.remove("opacity-50")) : i && i.remove(), n) c.style.cursor = "default", c._clickHandler && (c.removeEventListener("click", c._clickHandler), c._clickHandler = null);
|
|
105
|
+
else {
|
|
106
|
+
c.style.cursor = "pointer";
|
|
107
|
+
let e = c._clickHandler;
|
|
108
|
+
e && c.removeEventListener("click", e), c._clickHandler = (e) => {
|
|
109
|
+
this._radio && (e.target === this._radio || this._radio.contains(e.target) || e.composedPath().includes(this._radio)) || this.select();
|
|
110
|
+
}, c.addEventListener("click", c._clickHandler);
|
|
111
|
+
}
|
|
112
|
+
} else c && c.remove();
|
|
113
|
+
}
|
|
114
|
+
setupEventListeners() {
|
|
115
|
+
this.removeEventListeners(), this._radio && (this._changeHandler = (e) => {
|
|
116
|
+
e.stopPropagation();
|
|
117
|
+
let t = this._checked;
|
|
118
|
+
if (this._checked = this._radio.checked, this._checked ? this.hasAttribute("checked") || this.setAttribute("checked", "") : this.hasAttribute("checked") && this.removeAttribute("checked"), this.updateVisualState(), this._checked) {
|
|
119
|
+
let e = this._radio.name;
|
|
120
|
+
e && document.querySelectorAll(`input[type="radio"][name="${e}"]`).forEach((e) => {
|
|
121
|
+
if (e !== this._radio) {
|
|
122
|
+
let t = e.closest("mint-choice");
|
|
123
|
+
t && t.updateVisualState && (t._checked = e.checked, e.checked ? t.hasAttribute("checked") || t.setAttribute("checked", "") : t.hasAttribute("checked") && t.removeAttribute("checked"), t.updateVisualState());
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
if (t !== this._checked) {
|
|
128
|
+
let e = new CustomEvent("change", {
|
|
129
|
+
detail: {
|
|
130
|
+
checked: this._checked,
|
|
131
|
+
value: this.getValue()
|
|
132
|
+
},
|
|
133
|
+
bubbles: !0,
|
|
134
|
+
cancelable: !0
|
|
135
|
+
});
|
|
136
|
+
this.dispatchEvent(e);
|
|
137
|
+
}
|
|
138
|
+
}, this._radio.addEventListener("change", this._changeHandler), this._groupChangeHandler = (e) => {
|
|
139
|
+
e.target !== this._radio && e.target.type === "radio" && e.target.name === this._radio.name && e.target.checked && setTimeout(() => {
|
|
140
|
+
this._radio && this._radio.checked !== this._checked && (this._checked = this._radio.checked, this._checked ? this.hasAttribute("checked") || this.setAttribute("checked", "") : this.hasAttribute("checked") && this.removeAttribute("checked"), this.updateVisualState());
|
|
141
|
+
}, 0);
|
|
142
|
+
}, document.addEventListener("change", this._groupChangeHandler, !0), this._clickHandler = (e) => {
|
|
143
|
+
let t = this._radio.name;
|
|
144
|
+
t && document.querySelectorAll(`input[type="radio"][name="${t}"]`).forEach((e) => {
|
|
145
|
+
if (e !== this._radio) {
|
|
146
|
+
let t = e.closest("mint-choice");
|
|
147
|
+
t && t.updateVisualState && (t._checked = e.checked, e.checked ? t.hasAttribute("checked") || t.setAttribute("checked", "") : t.hasAttribute("checked") && t.removeAttribute("checked"), t.updateVisualState());
|
|
148
|
+
}
|
|
149
|
+
}), requestAnimationFrame(() => {
|
|
150
|
+
this._checked = this._radio.checked, this.updateVisualState();
|
|
151
|
+
});
|
|
152
|
+
}, this._radio.addEventListener("click", this._clickHandler), this._mousedownHandler = (e) => {
|
|
153
|
+
e.stopPropagation();
|
|
154
|
+
let t = this.querySelector(".mint-choice-wrapper");
|
|
155
|
+
t && !this.isDisabled() && (t.classList.add("mint-choice-active"), this._checked ? (t.style.backgroundColor = "rgb(15 23 42)", t.style.boxShadow = "inset 0 2px 4px rgba(0, 0, 0, 0.3)") : (t.style.backgroundColor = "rgb(243 244 246)", t.style.boxShadow = "inset 0 2px 4px rgba(0, 0, 0, 0.1)"), document.documentElement.classList.contains("dark") && (this._checked ? t.style.backgroundColor = "rgb(51 65 85)" : t.style.backgroundColor = "rgb(31 41 55)"));
|
|
156
|
+
}, this._mouseupHandler = (e) => {
|
|
157
|
+
e.stopPropagation();
|
|
158
|
+
let t = this.querySelector(".mint-choice-wrapper");
|
|
159
|
+
t && (t.classList.remove("mint-choice-active"), t.style.backgroundColor = "", t.style.boxShadow = "");
|
|
160
|
+
}, this._mouseleaveHandler = (e) => {
|
|
161
|
+
let t = this.querySelector(".mint-choice-wrapper");
|
|
162
|
+
t && (t.classList.remove("mint-choice-active"), t.style.backgroundColor = "", t.style.boxShadow = "");
|
|
163
|
+
}, this._radio.addEventListener("mousedown", this._mousedownHandler), this._radio.addEventListener("mouseup", this._mouseupHandler), this._radio.addEventListener("mouseleave", this._mouseleaveHandler), this._touchstartHandler = (e) => {
|
|
164
|
+
e.stopPropagation();
|
|
165
|
+
let t = this.querySelector(".mint-choice-wrapper");
|
|
166
|
+
t && !this.isDisabled() && (t.classList.add("mint-choice-active"), this._checked ? (t.style.backgroundColor = "rgb(15 23 42)", t.style.boxShadow = "inset 0 2px 4px rgba(0, 0, 0, 0.3)") : (t.style.backgroundColor = "rgb(243 244 246)", t.style.boxShadow = "inset 0 2px 4px rgba(0, 0, 0, 0.1)"), document.documentElement.classList.contains("dark") && (this._checked ? t.style.backgroundColor = "rgb(51 65 85)" : t.style.backgroundColor = "rgb(31 41 55)"));
|
|
167
|
+
}, this._touchendHandler = (e) => {
|
|
168
|
+
e.stopPropagation();
|
|
169
|
+
let t = this.querySelector(".mint-choice-wrapper");
|
|
170
|
+
t && (t.classList.remove("mint-choice-active"), t.style.backgroundColor = "", t.style.boxShadow = "");
|
|
171
|
+
}, this._radio.addEventListener("touchstart", this._touchstartHandler), this._radio.addEventListener("touchend", this._touchendHandler));
|
|
172
|
+
}
|
|
173
|
+
removeEventListeners() {
|
|
174
|
+
this._radio && (this._changeHandler &&= (this._radio.removeEventListener("change", this._changeHandler), null), this._groupChangeHandler &&= (document.removeEventListener("change", this._groupChangeHandler), null), this._clickHandler &&= (this._radio.removeEventListener("click", this._clickHandler), null), this._mousedownHandler &&= (this._radio.removeEventListener("mousedown", this._mousedownHandler), null), this._mouseupHandler &&= (this._radio.removeEventListener("mouseup", this._mouseupHandler), null), this._mouseleaveHandler &&= (this._radio.removeEventListener("mouseleave", this._mouseleaveHandler), null), this._touchstartHandler &&= (this._radio.removeEventListener("touchstart", this._touchstartHandler), null), this._touchendHandler &&= (this._radio.removeEventListener("touchend", this._touchendHandler), null));
|
|
175
|
+
}
|
|
176
|
+
updateVisualState() {
|
|
177
|
+
let e = this.querySelector(".mint-choice-wrapper"), t = e?.querySelector(".mint-choice-indicator");
|
|
178
|
+
t && (t.style.opacity = this._checked ? "1" : "0", t.style.transform = this._checked ? "scale(1)" : "scale(0.8)"), e && (e.className = `mint-choice-wrapper ${this.getChoiceClasses()}`, e.classList.contains("mint-choice-active") || (e.style.backgroundColor = "", e.style.boxShadow = ""));
|
|
179
|
+
}
|
|
180
|
+
select() {
|
|
181
|
+
if (this._radio && !this.isDisabled()) {
|
|
182
|
+
this._radio.checked = !0, this._radio.dispatchEvent(new Event("change", { bubbles: !0 })), this._checked = !0, this.hasAttribute("checked") || this.setAttribute("checked", "");
|
|
183
|
+
let e = this._radio.name;
|
|
184
|
+
e && document.querySelectorAll(`input[type="radio"][name="${e}"]`).forEach((e) => {
|
|
185
|
+
if (e !== this._radio) {
|
|
186
|
+
let t = e.closest("mint-choice");
|
|
187
|
+
t && t.updateVisualState && (t._checked = e.checked, e.checked ? t.hasAttribute("checked") || t.setAttribute("checked", "") : t.hasAttribute("checked") && t.removeAttribute("checked"), t.updateVisualState());
|
|
188
|
+
}
|
|
189
|
+
}), this.updateVisualState();
|
|
190
|
+
let t = new CustomEvent("change", {
|
|
191
|
+
detail: {
|
|
192
|
+
checked: this._checked,
|
|
193
|
+
value: this.getValue()
|
|
194
|
+
},
|
|
195
|
+
bubbles: !0,
|
|
196
|
+
cancelable: !0
|
|
197
|
+
});
|
|
198
|
+
this.dispatchEvent(t);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
customElements.get("mint-choice") || customElements.define("mint-choice", e);
|
|
203
|
+
//#endregion
|
|
204
|
+
export { e as t };
|
package/dist/choice.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`./choice-BAk8Jd5E.cjs`);
|
package/dist/choice.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MintChoice as default } from './mintui-elements'
|
package/dist/choice.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./choice-Cs16XiRh.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=class extends HTMLElement{static get observedAttributes(){return[`columns`,`sm`,`md`,`lg`,`xl`,`gap`]}constructor(){super()}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`block`),this.render()}attributeChangedCallback(e,t,n){t!==n&&this.render()}getColumns(){return this.getAttribute(`columns`)||`1`}getSm(){return this.getAttribute(`sm`)||null}getMd(){return this.getAttribute(`md`)||null}getLg(){return this.getAttribute(`lg`)||null}getXl(){return this.getAttribute(`xl`)||null}getGap(){return`3`}getGridClasses(){let e=[`grid`],t=this.getColumns();e.push(`grid-cols-${t}`);let n=this.getSm();n&&e.push(`sm:grid-cols-${n}`);let r=this.getMd();r&&e.push(`md:grid-cols-${r}`);let i=this.getLg();i&&e.push(`lg:grid-cols-${i}`);let a=this.getXl();a&&e.push(`xl:grid-cols-${a}`);let o=this.getGap();return e.push(`gap-${o}`),e}render(){Array.from(this.classList).filter(e=>e.startsWith(`grid-cols-`)||e.startsWith(`sm:grid-cols-`)||e.startsWith(`md:grid-cols-`)||e.startsWith(`lg:grid-cols-`)||e.startsWith(`xl:grid-cols-`)||e.startsWith(`gap-`)).forEach(e=>this.classList.remove(e)),this.classList.contains(`grid`)||this.classList.add(`grid`),this.getGridClasses().forEach(e=>{e&&e!==`grid`&&this.classList.add(e)})}};customElements.get(`mint-grid`)||customElements.define(`mint-grid`,e),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
|