{"version":3,"names":["CSS","buttonLoader","content","contentSlotted","icon","iconStart","iconEnd","loadingIn","loadingOut","iconStartEmpty","iconEndEmpty","buttonPadding","buttonPaddingShrunk","buttonCss","CalciteButtonStyle0","Button","this","mutationObserver","createObserver","updateHasContent","resizeObserver","setTooltipText","handleClick","type","href","submitForm","resetForm","contentEl","tooltipText","offsetWidth","scrollWidth","el","innerText","setChildEl","childEl","observe","handleGlobalAttributesChanged","forceUpdate","onMessagesChange","connectedCallback","connectLocalized","connectMessages","setupTextContentObserver","connectLabel","formEl","findAssociatedForm","disconnectedCallback","disconnect","disconnectLabel","disconnectLocalized","disconnectMessages","componentWillLoad","setUpLoadableComponent","isBrowser","setUpMessages","componentDidLoad","setComponentLoaded","componentDidRender","updateHostInteraction","render","childElType","Tag","loaderNode","loading","h","class","inline","label","messages","scale","noStartEndIcons","iconStartEl","key","flipRtl","iconFlipRtl","getIconScale","iconEndEl","ref","InteractiveContainer","disabled","toAriaBoolean","ariaExpanded","getLabelText","hasContent","download","name","onClick","rel","tabIndex","target","title","setFocus","componentFocusable","focus","effectiveLocaleChange","updateMessages","effectiveLocale","slottedContent","textContent","trim","length","childNodes","nodeName","childList","subtree","onLabelClick"],"sources":["src/components/button/resources.ts","src/components/button/button.scss?tag=calcite-button&encapsulation=shadow","src/components/button/button.tsx"],"sourcesContent":["export const CSS = {\n buttonLoader: \"calcite-button--loader\",\n content: \"content\",\n contentSlotted: \"content--slotted\",\n icon: \"icon\",\n iconStart: \"icon--start\",\n iconEnd: \"icon--end\",\n loadingIn: \"loading-in\",\n loadingOut: \"loading-out\",\n iconStartEmpty: \"icon-start-empty\",\n iconEndEmpty: \"icon-end-empty\",\n buttonPadding: \"button-padding\",\n buttonPaddingShrunk: \"button-padding--shrunk\",\n};\n",":host {\n @apply inline-block w-auto align-middle;\n}\n\n// fab variants\n:host([round]) {\n border-radius: 50px;\n & a,\n & button {\n border-radius: 50px;\n }\n}\n\n// focus styles\n:host button,\n:host a {\n @apply focus-base;\n &:focus {\n @apply focus-outset;\n }\n}\n// button base\n:host button,\n:host a {\n --calcite-button-content-margin-internal: theme(\"margin.2\");\n --calcite-button-padding-x-internal: 7px;\n --calcite-button-padding-y-internal: 3px;\n padding-block: var(--calcite-button-padding-y-internal);\n padding-inline: var(--calcite-button-padding-x-internal);\n @apply font-inherit\n relative\n box-border\n flex\n h-full\n w-full\n cursor-pointer\n select-none\n appearance-none\n items-center\n justify-center\n rounded-none\n border-none\n text-center\n font-normal\n no-underline;\n // include transition from focus\n transition:\n color var(--calcite-animation-timing) ease-in-out,\n background-color var(--calcite-animation-timing) ease-in-out,\n box-shadow var(--calcite-animation-timing) ease-in-out,\n outline-color var(--calcite-internal-animation-timing-fast) ease-in-out;\n &:hover {\n @apply no-underline;\n }\n & span {\n @apply truncate;\n }\n}\n\n.content {\n margin-inline: var(--calcite-button-content-margin-internal);\n}\n\n.icon-start-empty {\n .content {\n margin-inline-start: unset;\n }\n}\n.icon-end-empty {\n .content {\n margin-inline-end: unset;\n }\n}\n\n:host([scale=\"m\"]) {\n button,\n a {\n --calcite-button-content-margin-internal: theme(\"margin.3\");\n }\n}\n:host([scale=\"l\"]) {\n button,\n a {\n --calcite-button-content-margin-internal: theme(\"margin.4\");\n }\n}\n\n// button width\n:host([width=\"auto\"]) {\n @apply w-auto;\n}\n\n:host([width=\"half\"]) {\n @apply w-2/4;\n}\n\n:host([width=\"full\"]) {\n @apply w-full;\n}\n\n// alignment\n:host([alignment=\"center\"]:not([width=\"auto\"])) {\n a,\n button {\n @apply justify-center;\n }\n}\n:host([alignment=\"start\"]:not([width=\"auto\"])) {\n a,\n button {\n @apply justify-start;\n }\n}\n:host([alignment=\"end\"]:not([width=\"auto\"])) {\n a,\n button {\n @apply justify-end;\n }\n}\n:host([alignment*=\"space-between\"]:not([width=\"auto\"])) {\n a,\n button {\n @apply justify-between;\n }\n}\n:host([alignment=\"icon-start-space-between\"]:not([width=\"auto\"])) {\n .icon--start {\n margin-inline-end: auto;\n }\n a,\n button {\n text-align: unset;\n }\n}\n:host([alignment=\"icon-end-space-between\"]:not([width=\"auto\"])) {\n .icon--end {\n margin-inline-start: auto;\n }\n a,\n button {\n text-align: unset;\n }\n}\n\n// only two icons\n:host([alignment=\"center\"]) {\n a:not(.content--slotted),\n button:not(.content--slotted) {\n .icon--start + .icon--end {\n margin-inline-start: var(--calcite-button-content-margin-internal);\n }\n }\n}\n\n.icon {\n @apply relative\n m-0\n inline-flex\n font-normal;\n line-height: inherit;\n}\n\n@include disabled();\n\n@keyframes loader-in {\n 0% {\n inline-size: 0;\n opacity: 0;\n transform: scale(0.5);\n }\n 100% {\n inline-size: 1em;\n opacity: 1;\n transform: scale(1);\n }\n}\n@keyframes loader-out {\n 0% {\n inline-size: 1em;\n opacity: 1;\n transform: scale(1);\n }\n 100% {\n inline-size: 0;\n opacity: 0;\n transform: scale(0.5);\n }\n}\n\n.calcite-button--loader {\n @apply flex;\n calcite-loader {\n @apply m-0;\n }\n}\n\n:host([loading]) {\n // center loading spinner when button has text\n button.content--slotted,\n a.content--slotted {\n .calcite-button--loader calcite-loader {\n margin-inline-end: var(--calcite-button-content-margin-internal);\n }\n }\n // hide icons when loading with no text\n button:not(.content--slotted),\n a:not(.content--slotted) {\n .icon--start,\n .icon--end {\n @apply hidden;\n }\n }\n}\n\n// button styles\n:host([appearance]) {\n button,\n a {\n @apply border-color-transparent\n border\n border-solid;\n }\n}\n\n:host([kind=\"brand\"]) {\n button,\n a {\n @apply text-color-inverse bg-brand;\n &:hover,\n &:focus {\n @apply bg-brand-hover;\n }\n &:active {\n @apply bg-brand-press;\n }\n calcite-loader {\n @apply text-color-inverse;\n }\n }\n}\n:host([kind=\"danger\"]) {\n button,\n a {\n @apply text-color-inverse bg-danger;\n &:hover,\n &:focus {\n @apply bg-danger-hover;\n }\n &:active {\n @apply bg-danger-press;\n }\n calcite-loader {\n @apply text-color-inverse;\n }\n }\n}\n:host([kind=\"neutral\"]) {\n button,\n a {\n @apply text-color-1 bg-foreground-3;\n &:hover,\n &:focus {\n @apply bg-foreground-2;\n }\n &:active {\n @apply bg-foreground-1;\n }\n calcite-loader {\n @apply text-color-1;\n }\n }\n}\n:host([kind=\"inverse\"]) {\n button,\n a {\n @apply text-color-inverse;\n background-color: var(--calcite-color-inverse);\n &:hover,\n &:focus {\n background-color: var(--calcite-color-inverse-hover);\n }\n &:active {\n background-color: var(--calcite-color-inverse-press);\n }\n calcite-loader {\n @apply text-color-inverse;\n }\n }\n}\n// outline\n:host([appearance=\"outline-fill\"]) {\n button,\n a {\n @apply bg-foreground-1 border border-solid;\n box-shadow: inset 0 0 0 1px transparent;\n }\n}\n:host([appearance=\"outline-fill\"][kind=\"brand\"]) {\n button,\n a {\n @apply border-color-brand bg-foreground-1;\n color: theme(\"colors.brand\");\n &:hover {\n @apply border-color-brand-hover;\n color: theme(\"colors.brand-hover\");\n box-shadow: inset 0 0 0 1px var(--calcite-color-brand-hover);\n }\n &:focus {\n @apply border-color-brand;\n color: theme(\"colors.brand\");\n box-shadow: inset 0 0 0 2px var(--calcite-color-brand);\n }\n &:active {\n @apply border-color-brand-press;\n color: theme(\"colors.brand-press\");\n box-shadow: inset 0 0 0 2px var(--calcite-color-brand-press);\n }\n calcite-loader {\n color: theme(\"colors.brand\");\n }\n }\n}\n:host([appearance=\"outline-fill\"][kind=\"danger\"]) {\n button,\n a {\n @apply border-color-danger bg-foreground-1;\n color: theme(\"colors.danger\");\n &:hover {\n @apply border-color-danger-hover;\n color: theme(\"colors.danger-hover\");\n box-shadow: inset 0 0 0 1px var(--calcite-color-status-danger-hover);\n }\n &:focus {\n @apply border-color-danger;\n color: theme(\"colors.danger\");\n box-shadow: inset 0 0 0 2px var(--calcite-color-status-danger);\n }\n &:active {\n @apply border-color-danger-press;\n color: theme(\"colors.danger-press\");\n box-shadow: inset 0 0 0 2px var(--calcite-color-status-danger-press);\n }\n calcite-loader {\n color: theme(\"colors.danger\");\n }\n }\n}\n:host([appearance=\"outline-fill\"][kind=\"neutral\"]) {\n button,\n a {\n @apply text-color-1 bg-foreground-1;\n border-color: theme(\"borderColor.color.1\");\n &:hover {\n box-shadow: inset 0 0 0 1px var(--calcite-color-foreground-3);\n }\n &:focus {\n box-shadow: inset 0 0 0 2px var(--calcite-color-foreground-3);\n }\n &:active {\n box-shadow: inset 0 0 0 2px var(--calcite-color-foreground-3);\n }\n calcite-loader {\n @apply text-color-1;\n }\n }\n}\n:host([appearance=\"outline-fill\"][kind=\"inverse\"]) {\n button,\n a {\n @apply text-color-1 bg-foreground-1;\n border-color: var(--calcite-color-inverse);\n &:hover {\n border-color: var(--calcite-color-inverse-hover);\n box-shadow: inset 0 0 0 1px var(--calcite-color-inverse-hover);\n }\n &:focus {\n border-color: var(--calcite-color-inverse);\n box-shadow: inset 0 0 0 2px var(--calcite-color-inverse);\n }\n &:active {\n border-color: var(--calcite-color-inverse-press);\n box-shadow: inset 0 0 0 2px var(--calcite-color-inverse-press);\n }\n calcite-loader {\n @apply text-color-1;\n }\n }\n}\n:host([appearance=\"outline\"]) {\n button,\n a {\n @apply border border-solid bg-transparent;\n box-shadow: inset 0 0 0 1px transparent;\n }\n}\n:host([appearance=\"outline\"][kind=\"brand\"]) {\n button,\n a {\n @apply border-color-brand bg-transparent;\n color: theme(\"colors.brand\");\n &:hover {\n @apply border-color-brand-hover;\n color: theme(\"colors.brand-hover\");\n box-shadow: inset 0 0 0 1px var(--calcite-color-brand-hover);\n }\n &:focus {\n @apply border-color-brand;\n color: theme(\"colors.brand\");\n box-shadow: inset 0 0 0 2px var(--calcite-color-brand);\n }\n &:active {\n @apply border-color-brand-press;\n color: theme(\"colors.brand-press\");\n box-shadow: inset 0 0 0 2px var(--calcite-color-brand-press);\n }\n calcite-loader {\n color: theme(\"colors.brand\");\n }\n }\n}\n:host([appearance=\"outline\"][kind=\"danger\"]) {\n button,\n a {\n @apply border-color-danger bg-transparent;\n color: theme(\"colors.danger\");\n &:hover {\n @apply border-color-danger-hover;\n color: theme(\"colors.danger-hover\");\n box-shadow: inset 0 0 0 1px var(--calcite-color-status-danger-hover);\n }\n &:focus {\n @apply border-color-danger;\n color: theme(\"colors.danger\");\n box-shadow: inset 0 0 0 2px var(--calcite-color-status-danger);\n }\n &:active {\n @apply border-color-danger-press;\n color: theme(\"colors.danger-press\");\n box-shadow: inset 0 0 0 2px var(--calcite-color-status-danger-press);\n }\n calcite-loader {\n color: theme(\"colors.danger\");\n }\n }\n}\n:host([appearance=\"outline\"][kind=\"neutral\"]) {\n button,\n a {\n @apply text-color-1 bg-transparent;\n border-color: theme(\"borderColor.color.1\");\n &:hover {\n box-shadow: inset 0 0 0 1px var(--calcite-color-foreground-3);\n }\n &:focus {\n box-shadow: inset 0 0 0 2px var(--calcite-color-foreground-3);\n }\n &:active {\n box-shadow: inset 0 0 0 2px var(--calcite-color-foreground-3);\n }\n calcite-loader {\n @apply text-color-1;\n }\n }\n}\n:host([appearance=\"outline\"][kind=\"inverse\"]) {\n button,\n a {\n @apply text-color-1 bg-transparent;\n border-color: var(--calcite-color-inverse);\n &:hover {\n border-color: var(--calcite-color-inverse-hover);\n box-shadow: inset 0 0 0 1px var(--calcite-color-inverse-hover);\n }\n &:focus {\n border-color: var(--calcite-color-inverse);\n box-shadow: inset 0 0 0 2px var(--calcite-color-inverse);\n }\n &:active {\n border-color: var(--calcite-color-inverse-press);\n box-shadow: inset 0 0 0 2px var(--calcite-color-inverse-press);\n }\n calcite-loader {\n @apply text-color-1;\n }\n }\n}\n\n:host([appearance=\"outline-fill\"][split-child=\"primary\"]) button,\n:host([appearance=\"outline\"][split-child=\"primary\"]) button {\n border-inline-end-width: 0;\n border-inline-start-width: theme(\"borderWidth.DEFAULT\");\n}\n\n:host([appearance=\"outline-fill\"][split-child=\"secondary\"]) button,\n:host([appearance=\"outline\"][split-child=\"secondary\"]) button {\n border-inline-start-width: 0;\n border-inline-end-width: theme(\"borderWidth.DEFAULT\");\n}\n\n// transparent\n:host([appearance=\"transparent\"]:not(.enable-editing-button)) {\n button,\n a {\n @apply bg-transparent;\n &:hover,\n &:focus {\n background-color: var(--calcite-color-transparent-hover);\n }\n &:active {\n background-color: var(--calcite-color-transparent-press);\n }\n }\n}\n:host([appearance=\"transparent\"][kind=\"brand\"]) {\n button,\n a {\n color: theme(\"colors.brand\");\n &:hover {\n color: theme(\"colors.brand-hover\");\n }\n &:focus {\n color: theme(\"colors.brand\");\n }\n &:active {\n color: theme(\"colors.brand-press\");\n }\n calcite-loader {\n color: theme(\"colors.brand\");\n }\n }\n}\n\n:host([appearance=\"transparent\"][kind=\"danger\"]) {\n button,\n a {\n color: theme(\"colors.danger\");\n &:hover {\n color: theme(\"colors.danger-hover\");\n }\n &:focus {\n color: theme(\"colors.danger\");\n }\n &:active {\n color: theme(\"colors.danger-press\");\n }\n calcite-loader {\n color: theme(\"colors.danger\");\n }\n }\n}\n\n:host([appearance=\"transparent\"][kind=\"neutral\"]:not(.cancel-editing-button)) {\n button,\n a,\n calcite-loader {\n @apply text-color-1;\n }\n}\n\n:host([appearance=\"transparent\"][kind=\"neutral\"].cancel-editing-button) {\n button {\n @apply text-color-3\n border-t-color-input\n border-b-color-input\n border-t\n border-b;\n border-block-style: solid;\n\n &:not(.content--slotted) {\n --calcite-button-padding-y-internal: 0;\n }\n\n &:hover {\n @apply text-color-1;\n }\n }\n}\n\n:host([appearance=\"transparent\"][kind=\"neutral\"].enable-editing-button) {\n button {\n @apply bg-transparent;\n }\n}\n\n:host(.confirm-changes-button),\n:host(.cancel-editing-button),\n:host(.enable-editing-button) {\n button {\n &:focus {\n outline-offset: -2px; // ensure focus outlines work in Safari\n }\n }\n}\n\n:host([appearance=\"transparent\"][kind=\"inverse\"]) {\n button,\n a,\n calcite-loader {\n @apply text-color-inverse;\n }\n}\n\n// generate button scales (scenario: text exists)\n:host([scale=\"s\"]) button.content--slotted,\n:host([scale=\"s\"]) a.content--slotted {\n @apply text-n2h;\n}\n\n// accommodate for transparent buttons not having borders\n:host([scale=\"s\"][appearance=\"transparent\"]) button.content--slotted,\n:host([scale=\"s\"][appearance=\"transparent\"]) a.content--slotted {\n --calcite-button-padding-x-internal: theme(\"padding.2\");\n}\n\n:host([scale=\"s\"]) button,\n:host([scale=\"s\"]) a {\n --calcite-button-padding-y-internal: 3px;\n}\n\n:host([scale=\"m\"]) button.content--slotted,\n:host([scale=\"m\"]) a.content--slotted {\n --calcite-button-padding-x-internal: 11px;\n @apply text-n1h;\n}\n\n:host([scale=\"m\"]) button,\n:host([scale=\"m\"]) a {\n --calcite-button-padding-y-internal: 7px;\n}\n// accommodate for transparent buttons not having borders\n:host([scale=\"m\"][appearance=\"transparent\"]) button.content--slotted,\n:host([scale=\"m\"][appearance=\"transparent\"]) a.content--slotted {\n --calcite-button-padding-x-internal: theme(\"padding.3\");\n}\n\n:host([scale=\"l\"]) button.content--slotted,\n:host([scale=\"l\"]) a.content--slotted {\n --calcite-button-padding-x-internal: 15px;\n @apply text-0h;\n}\n\n:host([scale=\"l\"]) {\n .button-padding {\n --calcite-button-padding-x-internal: theme(\"padding.4\");\n --calcite-button-padding-y-internal: 11px;\n }\n //shrink the padding if an icon is present to preserve the height\n .button-padding--shrunk {\n --calcite-button-padding-y-internal: 9px;\n }\n}\n\n// generate fab scales (scenario: 1 icon, ie., should be square)\n:host([scale=\"s\"]) button:not(.content--slotted),\n:host([scale=\"s\"]) a:not(.content--slotted) {\n --calcite-button-padding-x-internal: theme(\"padding[0.5]\");\n --calcite-button-padding-y-internal: 3px;\n @apply text-0h w-6;\n min-block-size: theme(\"height.6\");\n}\n\n:host([scale=\"m\"]) button:not(.content--slotted),\n:host([scale=\"m\"]) a:not(.content--slotted) {\n --calcite-button-padding-x-internal: theme(\"padding[0.5]\");\n --calcite-button-padding-y-internal: 7px;\n @apply text-0h w-8;\n min-block-size: theme(\"height.8\");\n}\n:host([scale=\"l\"]) button:not(.content--slotted),\n:host([scale=\"l\"]) a:not(.content--slotted) {\n --calcite-button-padding-x-internal: theme(\"padding[0.5]\");\n --calcite-button-padding-y-internal: 9px;\n @apply text-0h w-11;\n min-block-size: theme(\"height.11\");\n}\n\n:host(:is([scale=\"s\"], [scale=\"m\"], [scale=\"l\"])[width=\"full\"]) {\n a,\n button {\n &:not(.content--slotted) {\n inline-size: var(--calcite-container-size-content-fluid);\n }\n }\n}\n\n// accommodate for transparent buttons not having borders\n:host([scale=\"l\"][appearance=\"transparent\"]) button:not(.content--slotted),\n:host([scale=\"l\"][appearance=\"transparent\"]) a:not(.content--slotted) {\n --calcite-button-padding-y-internal: theme(\"padding[2.5]\");\n}\n\n// generate fab scales (scenario: 2 icons, ie., should not be square)\n:host([scale=\"s\"][icon-start][icon-end]) button:not(.content--slotted),\n:host([scale=\"s\"][icon-start][icon-end]) a:not(.content--slotted) {\n --calcite-button-padding-x-internal: 23px;\n @apply text-0h h-6;\n}\n// accommodate for transparent buttons not having borders\n:host([scale=\"s\"][icon-start][icon-end][appearance=\"transparent\"]) button:not(.content--slotted),\n:host([scale=\"s\"][icon-start][icon-end][appearance=\"transparent\"]) a:not(.content--slotted) {\n --calcite-button-padding-x-internal: theme(\"padding.6\");\n}\n:host([scale=\"m\"][icon-start][icon-end]) button:not(.content--slotted),\n:host([scale=\"m\"][icon-start][icon-end]) a:not(.content--slotted) {\n --calcite-button-padding-x-internal: theme(\"padding.8\");\n @apply text-0h h-8;\n}\n// accommodate for transparent buttons not having borders\n:host([scale=\"m\"][icon-start][icon-end][appearance=\"transparent\"]) button:not(.content--slotted),\n:host([scale=\"m\"][icon-start][icon-end][appearance=\"transparent\"]) a:not(.content--slotted) {\n --calcite-button-padding-x-internal: 33px;\n}\n:host([scale=\"l\"][icon-start][icon-end]) button:not(.content--slotted),\n:host([scale=\"l\"][icon-start][icon-end]) a:not(.content--slotted) {\n --calcite-button-padding-x-internal: 43px;\n @apply text-0h h-11;\n // add space between when only 2 icons\n .icon--start + .icon--end {\n margin-inline-start: theme(\"margin.4\");\n }\n}\n// accommodate for transparent buttons not having borders\n:host([scale=\"l\"][icon-start][icon-end][appearance=\"transparent\"]) button:not(.content--slotted),\n:host([scale=\"l\"][icon-start][icon-end][appearance=\"transparent\"]) a:not(.content--slotted) {\n --calcite-button-padding-x-internal: theme(\"padding.11\");\n}\n\n@include base-component();\n","import {\n Component,\n Element,\n forceUpdate,\n h,\n Method,\n Prop,\n State,\n VNode,\n Watch,\n} from \"@stencil/core\";\nimport { findAssociatedForm, FormOwner, resetForm, submitForm } from \"../../utils/form\";\nimport {\n InteractiveComponent,\n InteractiveContainer,\n updateHostInteraction,\n} from \"../../utils/interactive\";\nimport { connectLabel, disconnectLabel, getLabelText, LabelableComponent } from \"../../utils/label\";\nimport {\n componentFocusable,\n LoadableComponent,\n setComponentLoaded,\n setUpLoadableComponent,\n} from \"../../utils/loadable\";\nimport { connectLocalized, disconnectLocalized, LocalizedComponent } from \"../../utils/locale\";\nimport { createObserver } from \"../../utils/observers\";\nimport { getIconScale } from \"../../utils/component\";\nimport {\n connectMessages,\n disconnectMessages,\n setUpMessages,\n T9nComponent,\n updateMessages,\n} from \"../../utils/t9n\";\nimport { Appearance, FlipContext, Kind, Scale, Width } from \"../interfaces\";\nimport { IconNameOrString } from \"../icon/interfaces\";\nimport { isBrowser } from \"../../utils/browser\";\nimport { toAriaBoolean } from \"../../utils/dom\";\nimport { ButtonMessages } from \"./assets/button/t9n\";\nimport { ButtonAlignment } from \"./interfaces\";\nimport { CSS } from \"./resources\";\n\n/** Passing a 'href' will render an anchor link, instead of a button. Role will be set to link, or button, depending on this. */\n/** It is the consumers responsibility to add aria information, rel, target, for links, and any button attributes for form submission */\n\n/** @slot - A slot for adding text. */\n@Component({\n tag: \"calcite-button\",\n styleUrl: \"button.scss\",\n shadow: true,\n assetsDirs: [\"assets\"],\n})\nexport class Button\n implements\n LabelableComponent,\n InteractiveComponent,\n FormOwner,\n LoadableComponent,\n LocalizedComponent,\n T9nComponent\n{\n //--------------------------------------------------------------------------\n //\n // Global attributes\n //\n //--------------------------------------------------------------------------\n\n @Watch(\"aria-expanded\")\n handleGlobalAttributesChanged(): void {\n forceUpdate(this);\n }\n\n // --------------------------------------------------------------------------\n //\n // Properties\n //\n //--------------------------------------------------------------------------\n\n /** Specifies the alignment of the component's elements. */\n @Prop({ reflect: true }) alignment: ButtonAlignment = \"center\";\n\n /** Specifies the appearance style of the component. */\n @Prop({ reflect: true }) appearance: Extract<\n \"outline\" | \"outline-fill\" | \"solid\" | \"transparent\",\n Appearance\n > = \"solid\";\n\n /** Accessible name for the component. */\n @Prop() label: string;\n\n /** Specifies the kind of the component, which will apply to the border and background if applicable. */\n @Prop({ reflect: true }) kind: Extract<\"brand\" | \"danger\" | \"inverse\" | \"neutral\", Kind> =\n \"brand\";\n\n /** When `true`, interaction is prevented and the component is displayed with lower opacity. */\n @Prop({ reflect: true }) disabled = false;\n\n /**\n * The `id` of the form that will be associated with the component.\n *\n * When not set, the component will be associated with its ancestor form element, if any.\n */\n @Prop({ reflect: true })\n form: string;\n\n /**\n * Prompts the user to save the linked URL instead of navigating to it. Can be used with or without a value:\n * Without a value, the browser will suggest a filename/extension\n * See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-download.\n */\n @Prop({ reflect: true }) download: string | boolean = false;\n\n /**\n * Specifies the URL of the linked resource, which can be set as an absolute or relative path.\n */\n @Prop({ reflect: true }) href: string;\n\n /** Specifies an icon to display at the end of the component. */\n @Prop({ reflect: true }) iconEnd: IconNameOrString;\n\n /** Displays the `iconStart` and/or `iconEnd` as flipped when the element direction is right-to-left (`\"rtl\"`). */\n @Prop({ reflect: true }) iconFlipRtl: FlipContext;\n\n /** Specifies an icon to display at the start of the component. */\n @Prop({ reflect: true }) iconStart: IconNameOrString;\n\n /**\n * When `true`, a busy indicator is displayed and interaction is disabled.\n */\n @Prop({ reflect: true }) loading = false;\n\n /** Specifies the name of the component on form submission. */\n @Prop({ reflect: true }) name?: string;\n\n /**\n * Defines the relationship between the `href` value and the current document.\n *\n * @mdn [rel](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel)\n */\n @Prop({ reflect: true }) rel: string;\n\n /** When `true`, adds a round style to the component. */\n @Prop({ reflect: true }) round = false;\n\n /** Specifies the size of the component. */\n @Prop({ reflect: true }) scale: Scale = \"m\";\n\n /** Specifies if the component is a child of a `calcite-split-button`. */\n @Prop({ reflect: true }) splitChild: \"primary\" | \"secondary\" | false = false;\n\n /**\n * Specifies where to open the linked document defined in the `href` property.\n *\n * @mdn [target](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-target)\n */\n @Prop({ reflect: true }) target: string;\n\n /**\n * Specifies the default behavior of the component.\n *\n * @mdn [type](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type)\n */\n @Prop({ reflect: true }) type = \"button\";\n\n /** Specifies the width of the component. */\n @Prop({ reflect: true }) width: Width = \"auto\";\n\n /**\n * Made into a prop for testing purposes only\n *\n * @internal\n */\n // eslint-disable-next-line @stencil-community/strict-mutable -- updated by t9n module\n @Prop({ mutable: true }) messages: ButtonMessages;\n\n /**\n * Use this property to override individual strings used by the component.\n */\n // eslint-disable-next-line @stencil-community/strict-mutable -- updated by t9n module\n @Prop({ mutable: true }) messageOverrides: Partial;\n\n @Watch(\"messageOverrides\")\n onMessagesChange(): void {\n /** referred in t9n util */\n }\n\n //--------------------------------------------------------------------------\n //\n // Lifecycle\n //\n //--------------------------------------------------------------------------\n\n async connectedCallback(): Promise {\n connectLocalized(this);\n connectMessages(this);\n this.setupTextContentObserver();\n connectLabel(this);\n this.formEl = findAssociatedForm(this);\n }\n\n disconnectedCallback(): void {\n this.mutationObserver?.disconnect();\n disconnectLabel(this);\n disconnectLocalized(this);\n disconnectMessages(this);\n this.resizeObserver?.disconnect();\n this.formEl = null;\n }\n\n async componentWillLoad(): Promise {\n setUpLoadableComponent(this);\n if (isBrowser()) {\n this.updateHasContent();\n await setUpMessages(this);\n }\n }\n\n componentDidLoad(): void {\n setComponentLoaded(this);\n this.setTooltipText();\n }\n\n componentDidRender(): void {\n updateHostInteraction(this);\n }\n\n render(): VNode {\n const childElType = this.href ? \"a\" : \"button\";\n const Tag = childElType;\n const loaderNode = this.loading ? (\n
\n \n
\n ) : null;\n const noStartEndIcons = !this.iconStart && !this.iconEnd;\n\n const iconStartEl = (\n \n );\n\n const iconEndEl = (\n \n );\n\n const contentEl = (\n (this.contentEl = el)}>\n \n \n );\n\n return (\n \n \n {loaderNode}\n {this.iconStart ? iconStartEl : null}\n {this.hasContent ? contentEl : null}\n {this.iconEnd ? iconEndEl : null}\n \n \n );\n }\n\n //--------------------------------------------------------------------------\n //\n // Public Methods\n //\n //--------------------------------------------------------------------------\n\n /** Sets focus on the component. */\n @Method()\n async setFocus(): Promise {\n await componentFocusable(this);\n\n this.childEl?.focus();\n }\n\n //--------------------------------------------------------------------------\n //\n // Private State/Props\n //\n //--------------------------------------------------------------------------\n\n @Element() el: HTMLCalciteButtonElement;\n\n formEl: HTMLFormElement;\n\n labelEl: HTMLCalciteLabelElement;\n\n /** watches for changing text content */\n private mutationObserver = createObserver(\"mutation\", () => this.updateHasContent());\n\n /** the rendered child element */\n private childEl?: HTMLElement;\n\n /** determine if there is slotted content for styling purposes */\n @State() private hasContent = false;\n\n @State() effectiveLocale = \"\";\n\n @Watch(\"effectiveLocale\")\n effectiveLocaleChange(): void {\n updateMessages(this, this.effectiveLocale);\n }\n\n @State() defaultMessages: ButtonMessages;\n\n private updateHasContent() {\n const slottedContent = this.el.textContent.trim().length > 0 || this.el.childNodes.length > 0;\n this.hasContent =\n this.el.childNodes.length === 1 && this.el.childNodes[0]?.nodeName === \"#text\"\n ? this.el.textContent?.trim().length > 0\n : slottedContent;\n }\n\n private setupTextContentObserver() {\n this.mutationObserver?.observe(this.el, { childList: true, subtree: true });\n }\n\n /** keeps track of the tooltipText */\n @State() tooltipText: string;\n\n /** keep track of the rendered contentEl */\n private contentEl: HTMLSpanElement;\n\n resizeObserver = createObserver(\"resize\", () => this.setTooltipText());\n\n //--------------------------------------------------------------------------\n //\n // Private Methods\n //\n //--------------------------------------------------------------------------\n\n onLabelClick(): void {\n this.handleClick();\n this.setFocus();\n }\n\n // act on a requested or nearby form based on type\n private handleClick = (): void => {\n const { type } = this;\n\n if (this.href) {\n return;\n }\n\n // this.type refers to type attribute, not child element type\n if (type === \"submit\") {\n submitForm(this);\n } else if (type === \"reset\") {\n resetForm(this);\n }\n };\n\n private setTooltipText = (): void => {\n const { contentEl } = this;\n if (contentEl) {\n this.tooltipText =\n contentEl.offsetWidth < contentEl.scrollWidth ? this.el.innerText || null : null;\n }\n };\n\n private setChildEl = (el: HTMLElement): void => {\n this.childEl = el;\n\n if (el) {\n this.resizeObserver?.observe(el);\n }\n };\n}\n"],"mappings":";;;;;4iBAAO,MAAMA,EAAM,CACjBC,aAAc,yBACdC,QAAS,UACTC,eAAgB,mBAChBC,KAAM,OACNC,UAAW,cACXC,QAAS,YACTC,UAAW,aACXC,WAAY,cACZC,eAAgB,mBAChBC,aAAc,iBACdC,cAAe,iBACfC,oBAAqB,0BCZvB,MAAMC,EAAY,wguBAClB,MAAAC,EAAeD,E,MCmDFE,EAAM,M,yBAyRTC,KAAAC,iBAAmBC,EAAe,YAAY,IAAMF,KAAKG,qBAmCjEH,KAAAI,eAAiBF,EAAe,UAAU,IAAMF,KAAKK,mBAc7CL,KAAAM,YAAc,KACpB,MAAMC,KAAEA,GAASP,KAEjB,GAAIA,KAAKQ,KAAM,CACb,M,CAIF,GAAID,IAAS,SAAU,CACrBE,EAAWT,K,MACN,GAAIO,IAAS,QAAS,CAC3BG,EAAUV,K,GAINA,KAAAK,eAAiB,KACvB,MAAMM,UAAEA,GAAcX,KACtB,GAAIW,EAAW,CACbX,KAAKY,YACHD,EAAUE,YAAcF,EAAUG,YAAcd,KAAKe,GAAGC,WAAa,KAAO,I,GAI1EhB,KAAAiB,WAAcF,IACpBf,KAAKkB,QAAUH,EAEf,GAAIA,EAAI,CACNf,KAAKI,gBAAgBe,QAAQJ,E,kBA1UqB,S,gBAMlD,Q,+BAOF,Q,cAGkC,M,kCAekB,M,4GAmBnB,M,kDAaF,M,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