@francofantomius/material-components 0.1.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +80 -0
- package/README.md +550 -90
- package/custom-elements.json +21010 -2354
- package/dist/chunks/badge-G4EjcMoy.js +89 -0
- package/dist/chunks/badge-G4EjcMoy.js.map +1 -0
- package/dist/chunks/button-B4TSZ7Sl.js +250 -0
- package/dist/chunks/button-B4TSZ7Sl.js.map +1 -0
- package/dist/chunks/card-DVffdPpv.js +163 -0
- package/dist/chunks/card-DVffdPpv.js.map +1 -0
- package/dist/chunks/checkbox-BqlboAHd.js +194 -0
- package/dist/chunks/checkbox-BqlboAHd.js.map +1 -0
- package/dist/chunks/chip-CI1ZINnr.js +169 -0
- package/dist/chunks/chip-CI1ZINnr.js.map +1 -0
- package/dist/chunks/code-C5UFBkCh.js +1830 -0
- package/dist/chunks/code-C5UFBkCh.js.map +1 -0
- package/dist/chunks/decorate-DXuynaiA.js +39 -0
- package/dist/chunks/decorate-DXuynaiA.js.map +1 -0
- package/dist/chunks/dialog-DGVEE5m_.js +158 -0
- package/dist/chunks/dialog-DGVEE5m_.js.map +1 -0
- package/dist/chunks/divider-DNepwoZv.js +82 -0
- package/dist/chunks/divider-DNepwoZv.js.map +1 -0
- package/dist/chunks/fab-C9j3WBHE.js +150 -0
- package/dist/chunks/fab-C9j3WBHE.js.map +1 -0
- package/dist/chunks/focus-ring-CuiJuM-y.js +71 -0
- package/dist/chunks/focus-ring-CuiJuM-y.js.map +1 -0
- package/dist/chunks/{form-associated-fKbeX_2P.js → form-associated-Cty_ZaS9.js} +26 -27
- package/dist/chunks/form-associated-Cty_ZaS9.js.map +1 -0
- package/dist/chunks/icon-DrNqcNEL.js +62 -0
- package/dist/chunks/icon-DrNqcNEL.js.map +1 -0
- package/dist/chunks/icon-button-BdSc7eot.js +188 -0
- package/dist/chunks/icon-button-BdSc7eot.js.map +1 -0
- package/dist/chunks/list-D8olR7oZ.js +204 -0
- package/dist/chunks/list-D8olR7oZ.js.map +1 -0
- package/dist/chunks/navigation-drawer-CKl44Ef5.js +531 -0
- package/dist/chunks/navigation-drawer-CKl44Ef5.js.map +1 -0
- package/dist/chunks/player-C4ydiIpr.js +1582 -0
- package/dist/chunks/player-C4ydiIpr.js.map +1 -0
- package/dist/chunks/progress-LQmLMDjX.js +266 -0
- package/dist/chunks/progress-LQmLMDjX.js.map +1 -0
- package/dist/chunks/radio-Bily78NT.js +205 -0
- package/dist/chunks/radio-Bily78NT.js.map +1 -0
- package/dist/chunks/ripple-squbKHhj.js +135 -0
- package/dist/chunks/ripple-squbKHhj.js.map +1 -0
- package/dist/chunks/search-bar-TXnqJ-gd.js +698 -0
- package/dist/chunks/search-bar-TXnqJ-gd.js.map +1 -0
- package/dist/chunks/snackbar-Wsz3BzEY.js +161 -0
- package/dist/chunks/snackbar-Wsz3BzEY.js.map +1 -0
- package/dist/chunks/switch-DdukrvXb.js +190 -0
- package/dist/chunks/switch-DdukrvXb.js.map +1 -0
- package/dist/chunks/table-aRTYzDyE.js +773 -0
- package/dist/chunks/table-aRTYzDyE.js.map +1 -0
- package/dist/chunks/tabs-BfOtoeir.js +191 -0
- package/dist/chunks/tabs-BfOtoeir.js.map +1 -0
- package/dist/chunks/text-field-hN6-2HQy.js +338 -0
- package/dist/chunks/text-field-hN6-2HQy.js.map +1 -0
- package/dist/chunks/top-app-bar-Dgbp6CFv.js +228 -0
- package/dist/chunks/top-app-bar-Dgbp6CFv.js.map +1 -0
- package/dist/components/account-menu/account-menu.css.d.ts +3 -0
- package/dist/components/account-menu/account-menu.css.d.ts.map +1 -0
- package/dist/components/account-menu/account-menu.d.ts +111 -0
- package/dist/components/account-menu/account-menu.d.ts.map +1 -0
- package/dist/components/app-drawer/app-drawer.css.d.ts +3 -0
- package/dist/components/app-drawer/app-drawer.css.d.ts.map +1 -0
- package/dist/components/app-drawer/app-drawer.d.ts +173 -0
- package/dist/components/app-drawer/app-drawer.d.ts.map +1 -0
- package/dist/components/badge/badge.js +2 -91
- package/dist/components/button/button.js +2 -261
- package/dist/components/card/card.js +2 -167
- package/dist/components/checkbox/checkbox.css.d.ts.map +1 -1
- package/dist/components/checkbox/checkbox.js +2 -186
- package/dist/components/chip/chip.js +3 -172
- package/dist/components/code/code.css.d.ts +2 -0
- package/dist/components/code/code.css.d.ts.map +1 -0
- package/dist/components/code/code.d.ts +106 -0
- package/dist/components/code/code.d.ts.map +1 -0
- package/dist/components/code/code.js +5 -0
- package/dist/components/code/highlighter.d.ts +8 -0
- package/dist/components/code/highlighter.d.ts.map +1 -0
- package/dist/components/code/linter.d.ts +44 -0
- package/dist/components/code/linter.d.ts.map +1 -0
- package/dist/components/dialog/dialog.js +2 -165
- package/dist/components/divider/divider.js +2 -79
- package/dist/components/fab/fab.js +2 -153
- package/dist/components/icon/icon.js +2 -68
- package/dist/components/icon-button/icon-button.css.d.ts.map +1 -1
- package/dist/components/icon-button/icon-button.js +1 -189
- package/dist/components/list/list.css.d.ts.map +1 -1
- package/dist/components/list/list.d.ts.map +1 -1
- package/dist/components/list/list.js +3 -188
- package/dist/components/navigation-drawer/navigation-drawer.css.d.ts +3 -0
- package/dist/components/navigation-drawer/navigation-drawer.css.d.ts.map +1 -0
- package/dist/components/navigation-drawer/navigation-drawer.d.ts +76 -0
- package/dist/components/navigation-drawer/navigation-drawer.d.ts.map +1 -0
- package/dist/components/navigation-drawer/navigation-drawer.js +8 -0
- package/dist/components/player/player.css.d.ts +2 -0
- package/dist/components/player/player.css.d.ts.map +1 -0
- package/dist/components/player/player.d.ts +99 -0
- package/dist/components/player/player.d.ts.map +1 -0
- package/dist/components/player/player.js +7 -0
- package/dist/components/progress/progress.css.d.ts.map +1 -1
- package/dist/components/progress/progress.d.ts +2 -0
- package/dist/components/progress/progress.d.ts.map +1 -1
- package/dist/components/progress/progress.js +3 -181
- package/dist/components/radio/radio.css.d.ts.map +1 -1
- package/dist/components/radio/radio.js +3 -203
- package/dist/components/search-bar/search-bar.css.d.ts +2 -0
- package/dist/components/search-bar/search-bar.css.d.ts.map +1 -0
- package/dist/components/search-bar/search-bar.d.ts +81 -0
- package/dist/components/search-bar/search-bar.d.ts.map +1 -0
- package/dist/components/search-bar/search-bar.js +5 -0
- package/dist/components/snackbar/snackbar.js +2 -162
- package/dist/components/switch/switch.css.d.ts.map +1 -1
- package/dist/components/switch/switch.js +2 -169
- package/dist/components/table/table.css.d.ts +8 -0
- package/dist/components/table/table.css.d.ts.map +1 -0
- package/dist/components/table/table.d.ts +158 -0
- package/dist/components/table/table.d.ts.map +1 -0
- package/dist/components/table/table.js +13 -0
- package/dist/components/tabs/tabs.js +3 -198
- package/dist/components/text-field/text-field.css.d.ts.map +1 -1
- package/dist/components/text-field/text-field.d.ts +1 -1
- package/dist/components/text-field/text-field.d.ts.map +1 -1
- package/dist/components/text-field/text-field.js +2 -325
- package/dist/components/top-app-bar/top-app-bar.css.d.ts +2 -0
- package/dist/components/top-app-bar/top-app-bar.css.d.ts.map +1 -0
- package/dist/components/top-app-bar/top-app-bar.d.ts +29 -0
- package/dist/components/top-app-bar/top-app-bar.d.ts.map +1 -0
- package/dist/components/top-app-bar/top-app-bar.js +5 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2264 -58
- package/dist/index.js.map +1 -1
- package/dist/internal/focus-ring/focus-ring.d.ts.map +1 -1
- package/dist/internal/focus-ring/focus-ring.js +4 -0
- package/dist/internal/ripple/ripple.css.d.ts.map +1 -1
- package/dist/internal/ripple/ripple.d.ts +0 -3
- package/dist/internal/ripple/ripple.d.ts.map +1 -1
- package/dist/internal/ripple/ripple.js +2 -142
- package/dist/tokens/index.js +336 -11
- package/dist/tokens/index.js.map +1 -1
- package/package.json +118 -12
- package/dist/chunks/base-component-DQTjlEVL.js +0 -34
- package/dist/chunks/base-component-DQTjlEVL.js.map +0 -1
- package/dist/chunks/focus-ring-Dl-XoEKK.js +0 -71
- package/dist/chunks/focus-ring-Dl-XoEKK.js.map +0 -1
- package/dist/chunks/form-associated-fKbeX_2P.js.map +0 -1
- package/dist/chunks/theme.css-DV3DRha-.js +0 -263
- package/dist/chunks/theme.css-DV3DRha-.js.map +0 -1
- package/dist/components/badge/badge.js.map +0 -1
- package/dist/components/button/button.js.map +0 -1
- package/dist/components/card/card.js.map +0 -1
- package/dist/components/checkbox/checkbox.js.map +0 -1
- package/dist/components/chip/chip.js.map +0 -1
- package/dist/components/dialog/dialog.js.map +0 -1
- package/dist/components/divider/divider.js.map +0 -1
- package/dist/components/fab/fab.js.map +0 -1
- package/dist/components/icon/icon.js.map +0 -1
- package/dist/components/icon-button/icon-button.js.map +0 -1
- package/dist/components/list/list.js.map +0 -1
- package/dist/components/progress/progress.js.map +0 -1
- package/dist/components/radio/radio.js.map +0 -1
- package/dist/components/snackbar/snackbar.js.map +0 -1
- package/dist/components/switch/switch.js.map +0 -1
- package/dist/components/tabs/tabs.js.map +0 -1
- package/dist/components/text-field/text-field.js.map +0 -1
- package/dist/internal/ripple/ripple.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-bar-TXnqJ-gd.js","names":[],"sources":["../../src/components/search-bar/search-bar.css.ts","../../src/components/search-bar/search-bar.ts"],"sourcesContent":["import { css } from 'lit';\n\nexport const searchBarStyles = css`\n :host {\n display: block;\n box-sizing: border-box;\n position: relative;\n width: 100%;\n max-width: var(--md-search-bar-max-width, 100%);\n font-family: var(--md-sys-typescale-font-family, inherit);\n color: var(--md-sys-color-on-surface, #1D1B20);\n vertical-align: middle;\n }\n\n :host([disabled]) {\n pointer-events: none;\n opacity: 0.38;\n }\n\n .scrim {\n display: none;\n }\n\n /* Scrim when active in docked mode to catch outside clicks */\n :host([active]) .scrim {\n display: block;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n z-index: 40;\n background: transparent;\n }\n\n .search-container {\n position: relative;\n z-index: 1;\n display: flex;\n flex-direction: column;\n width: 100%;\n box-sizing: border-box;\n background-color: var(--md-search-bar-container-color, var(--md-sys-color-surface-container-high, #ECE6F0));\n border-radius: var(--md-sys-shape-corner-full, 28px);\n box-shadow: var(--md-sys-elevation-level1, 0px 1px 3px 1px rgba(0, 0, 0, 0.15));\n transition: box-shadow 200ms cubic-bezier(0.2, 0, 0, 1),\n border-radius 200ms cubic-bezier(0.2, 0, 0, 1),\n background-color 200ms cubic-bezier(0.2, 0, 0, 1);\n }\n\n .search-bar-header {\n display: flex;\n align-items: center;\n min-height: 56px;\n height: 56px;\n padding: 0 8px 0 16px;\n box-sizing: border-box;\n gap: 8px;\n }\n\n .leading-slot, .trailing-slot {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n }\n\n .icon-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 40px;\n height: 40px;\n border: none;\n background: transparent;\n border-radius: 50%;\n color: var(--md-sys-color-on-surface-variant, #49454F);\n cursor: pointer;\n padding: 0;\n outline: none;\n position: relative;\n transition: background-color 150ms ease;\n }\n\n .icon-btn:hover {\n background-color: rgba(73, 69, 79, 0.08);\n }\n\n .icon-btn:focus-visible {\n background-color: rgba(73, 69, 79, 0.12);\n }\n\n .input-wrapper {\n display: flex;\n flex: 1;\n min-width: 0;\n align-items: center;\n position: relative;\n }\n\n input {\n width: 100%;\n border: none;\n background: transparent;\n outline: none;\n font-family: inherit;\n font-size: var(--md-sys-typescale-body-large-size, 16px);\n line-height: var(--md-sys-typescale-body-large-line-height, 24px);\n color: var(--md-sys-color-on-surface, #1D1B20);\n padding: 0 4px;\n margin: 0;\n box-sizing: border-box;\n }\n\n input::placeholder {\n color: var(--md-sys-color-on-surface-variant, #49454F);\n opacity: 0.8;\n }\n\n /* Active Docked Mode */\n :host([active]) .search-container {\n z-index: 50;\n border-radius: var(--md-sys-shape-corner-extra-large, 28px 28px 16px 16px);\n box-shadow: var(--md-sys-elevation-level3, 0px 4px 8px 3px rgba(0, 0, 0, 0.15));\n }\n\n /* Divider when active */\n .divider {\n display: none;\n height: 1px;\n background-color: var(--md-sys-color-outline-variant, #CAC4D0);\n margin: 0 16px;\n }\n\n :host([active]) .divider {\n display: block;\n }\n\n /* Suggestions / Content Container */\n .suggestions-container {\n display: none;\n flex-direction: column;\n max-height: 360px;\n overflow-y: auto;\n padding: 8px 0;\n box-sizing: border-box;\n }\n\n :host([active]) .suggestions-container {\n display: flex;\n }\n\n .suggestion-item {\n display: flex;\n align-items: center;\n min-height: 48px;\n padding: 0 16px;\n gap: 16px;\n box-sizing: border-box;\n cursor: pointer;\n position: relative;\n user-select: none;\n color: var(--md-sys-color-on-surface, #1D1B20);\n transition: background-color 150ms ease;\n }\n\n .suggestion-item:hover,\n .suggestion-item.highlighted {\n background-color: rgba(73, 69, 79, 0.08);\n }\n\n .suggestion-item.selected {\n background-color: rgba(73, 69, 79, 0.12);\n }\n\n .suggestion-icon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n color: var(--md-sys-color-on-surface-variant, #49454F);\n flex-shrink: 0;\n }\n\n .suggestion-text {\n display: flex;\n flex-direction: column;\n flex: 1;\n min-width: 0;\n overflow: hidden;\n }\n\n .suggestion-label {\n font-size: var(--md-sys-typescale-body-large-size, 16px);\n line-height: 20px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n\n .suggestion-supporting {\n font-size: var(--md-sys-typescale-body-medium-size, 14px);\n line-height: 16px;\n color: var(--md-sys-color-on-surface-variant, #49454F);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n margin-top: 2px;\n }\n\n .suggestion-trailing {\n font-size: var(--md-sys-typescale-body-medium-size, 14px);\n color: var(--md-sys-color-on-surface-variant, #49454F);\n flex-shrink: 0;\n }\n\n .search-trigger-container {\n display: none;\n }\n\n /* Responsive Fullscreen / Mobile Collapsed Mode */\n @media (max-width: 768px) {\n :host([responsive]:not([active]):not([collapse-on-mobile=\"false\"])),\n :host([collapse-on-mobile]:not([active]):not([collapse-on-mobile=\"false\"])) {\n display: inline-flex;\n width: auto;\n max-width: none;\n vertical-align: middle;\n }\n\n :host([responsive]:not([active]):not([collapse-on-mobile=\"false\"])) .search-trigger-container,\n :host([collapse-on-mobile]:not([active]):not([collapse-on-mobile=\"false\"])) .search-trigger-container {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background-color: transparent;\n border-radius: 50%;\n box-shadow: none;\n cursor: pointer;\n user-select: none;\n outline: none;\n transition: background-color 200ms ease, box-shadow 200ms ease;\n -webkit-tap-highlight-color: transparent;\n }\n\n :host([responsive]:not([active]):not([collapse-on-mobile=\"false\"])) .search-trigger-container.has-trailing,\n :host([collapse-on-mobile]:not([active]):not([collapse-on-mobile=\"false\"])) .search-trigger-container.has-trailing {\n height: 48px;\n padding: 0 4px;\n gap: 2px;\n background-color: var(--md-search-bar-container-color, var(--md-sys-color-surface-container-high, #ECE6F0));\n border-radius: var(--md-sys-shape-corner-full, 28px);\n box-shadow: var(--md-sys-elevation-level1, 0px 1px 3px 1px rgba(0, 0, 0, 0.15));\n }\n\n :host([responsive]:not([active]):not([collapse-on-mobile=\"false\"])) .search-trigger-container.has-trailing:hover,\n :host([collapse-on-mobile]:not([active]):not([collapse-on-mobile=\"false\"])) .search-trigger-container.has-trailing:hover {\n box-shadow: var(--md-sys-elevation-level2, 0px 2px 6px 2px rgba(0, 0, 0, 0.15));\n }\n\n :host([responsive]:not([active]):not([collapse-on-mobile=\"false\"])) .search-trigger-container:focus-visible,\n :host([collapse-on-mobile]:not([active]):not([collapse-on-mobile=\"false\"])) .search-trigger-container:focus-visible {\n outline: 2px solid var(--md-sys-color-primary, #6750A4);\n outline-offset: 2px;\n }\n\n .trigger-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 40px;\n height: 40px;\n min-width: 40px;\n min-height: 40px;\n border-radius: 50%;\n border: none;\n background: transparent;\n color: var(--md-sys-color-on-surface-variant, #49454F);\n cursor: pointer;\n padding: 0;\n margin: 0;\n outline: none;\n position: relative;\n transition: background-color 150ms ease, color 150ms ease;\n -webkit-tap-highlight-color: transparent;\n }\n\n .trigger-btn:hover {\n background-color: rgba(73, 69, 79, 0.08);\n }\n\n .trigger-btn:focus-visible {\n background-color: rgba(73, 69, 79, 0.12);\n }\n\n .trigger-divider {\n width: 1px;\n height: 22px;\n background-color: var(--md-sys-color-outline-variant, #CAC4D0);\n margin: 0 2px;\n flex-shrink: 0;\n }\n\n :host([responsive]:not([active]):not([collapse-on-mobile=\"false\"])) .search-container,\n :host([collapse-on-mobile]:not([active]):not([collapse-on-mobile=\"false\"])) .search-container {\n display: none;\n }\n\n :host([responsive]:not([active]):not([collapse-on-mobile=\"false\"])) .scrim,\n :host([collapse-on-mobile]:not([active]):not([collapse-on-mobile=\"false\"])) .scrim {\n display: none;\n }\n\n :host([responsive][active]),\n :host([collapse-on-mobile][active]) {\n display: block;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100vw;\n height: 100vh;\n height: 100dvh;\n max-width: 100vw;\n margin: 0;\n padding: 0;\n z-index: 99999;\n }\n\n :host([responsive][active]) .search-trigger-container,\n :host([collapse-on-mobile][active]) .search-trigger-container {\n display: none;\n }\n\n :host([responsive][active]) .scrim,\n :host([collapse-on-mobile][active]) .scrim {\n display: none;\n }\n\n :host([responsive][active]) .search-container,\n :host([collapse-on-mobile][active]) .search-container {\n display: flex;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100vw;\n height: 100vh;\n height: 100dvh;\n max-width: 100vw;\n border-radius: 0;\n box-shadow: none;\n z-index: 99999;\n background-color: var(--md-search-bar-container-color, var(--md-sys-color-surface-container-high, #ECE6F0));\n }\n\n :host([responsive][active]) .suggestions-container,\n :host([collapse-on-mobile][active]) .suggestions-container {\n flex: 1;\n max-height: calc(100vh - 57px);\n max-height: calc(100dvh - 57px);\n }\n }\n\n /* Forced Fullscreen attribute */\n :host([fullscreen][active]) {\n display: block;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100vw;\n height: 100vh;\n height: 100dvh;\n max-width: 100vw;\n z-index: 99999;\n }\n\n :host([fullscreen][active]) .search-trigger-container {\n display: none;\n }\n\n :host([fullscreen][active]) .scrim {\n display: none;\n }\n\n :host([fullscreen][active]) .search-container {\n display: flex;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100vw;\n height: 100vh;\n height: 100dvh;\n max-width: 100vw;\n border-radius: 0;\n box-shadow: none;\n z-index: 99999;\n background-color: var(--md-search-bar-container-color, var(--md-sys-color-surface-container-high, #ECE6F0));\n }\n\n :host([fullscreen][active]) .suggestions-container {\n flex: 1;\n max-height: calc(100vh - 57px);\n max-height: calc(100dvh - 57px);\n }\n`;\n\n","import { html, nothing } from 'lit';\nimport { customElement, property, state, query } from 'lit/decorators.js';\nimport { MdFormAssociatedElement } from '../../internal/form-associated.js';\nimport '../icon/icon.js';\nimport { searchBarStyles } from './search-bar.css.js';\n\nexport interface SearchSuggestion {\n id?: string;\n label: string;\n value?: string;\n supportingText?: string;\n trailingSupportingText?: string;\n icon?: string;\n [key: string]: unknown;\n}\n\n@customElement('md-search-bar')\nexport class MdSearchBar extends MdFormAssociatedElement {\n static override styles = [MdFormAssociatedElement.styles, searchBarStyles];\n\n @property({ type: String })\n value = '';\n\n @property({ type: String })\n placeholder = 'Search';\n\n @property({ type: Boolean, reflect: true })\n active = false;\n\n @property({ type: Array })\n suggestions: Array<string | SearchSuggestion> = [];\n\n @property({ type: String, attribute: 'leading-icon' })\n leadingIcon = 'search';\n\n @property({ type: String, attribute: 'active-leading-icon' })\n activeLeadingIcon = 'arrow_back';\n\n @property({ type: String, attribute: 'trailing-icon' })\n trailingIcon = '';\n\n @property({ type: Boolean, attribute: 'show-back-button' })\n showBackButton = true;\n\n @property({ type: Boolean, attribute: 'show-clear-button' })\n showClearButton = true;\n\n @property({ type: Boolean, reflect: true })\n responsive = true;\n\n @property({ type: Boolean, attribute: 'collapse-on-mobile', reflect: true })\n collapseOnMobile = true;\n\n @property({ type: Boolean, reflect: true })\n fullscreen = false;\n\n @property({ type: Boolean, attribute: 'auto-deactivate-on-select' })\n autoDeactivateOnSelect = true;\n\n @state()\n private highlightedIndex = -1;\n\n @query('input')\n private inputElement?: HTMLInputElement;\n\n override connectedCallback() {\n super.connectedCallback();\n this.setFormValue(this.value);\n this.toggleAttribute('has-value', Boolean(this.value));\n this.toggleAttribute('active', this.active);\n this.toggleAttribute('collapse-on-mobile', this.collapseOnMobile);\n }\n\n override willUpdate(changedProperties: Map<string, unknown>) {\n super.willUpdate(changedProperties);\n if (changedProperties.has('value')) {\n this.setFormValue(this.value);\n this.toggleAttribute('has-value', Boolean(this.value));\n }\n if (changedProperties.has('active')) {\n this.toggleAttribute('active', this.active);\n if (!this.active) {\n this.highlightedIndex = -1;\n }\n }\n if (changedProperties.has('collapseOnMobile')) {\n this.toggleAttribute('collapse-on-mobile', this.collapseOnMobile);\n }\n }\n\n override formResetCallback() {\n this.value = '';\n this.setFormValue(null);\n this.toggleAttribute('has-value', false);\n this.highlightedIndex = -1;\n }\n\n /**\n * Focuses the search input field.\n */\n override focus() {\n this.inputElement?.focus();\n }\n\n /**\n * Opens / activates the search view.\n */\n show() {\n if (!this.active) {\n this.active = true;\n this.emitEvent('active-change', { active: true });\n }\n this.updateComplete.then(() => {\n this.inputElement?.focus();\n });\n }\n\n /**\n * Alias for show()\n */\n open() {\n this.show();\n }\n\n /**\n * Closes / deactivates the search view.\n */\n close() {\n if (this.active) {\n this.active = false;\n this.highlightedIndex = -1;\n this.emitEvent('active-change', { active: false });\n }\n }\n\n /**\n * Alias for close()\n */\n collapse() {\n this.close();\n }\n\n /**\n * Toggles the active state of the search bar.\n */\n toggle() {\n if (this.active) {\n this.close();\n } else {\n this.show();\n }\n }\n\n /**\n * Clears the current search input.\n */\n clear() {\n this.value = '';\n this.setFormValue('');\n this.toggleAttribute('has-value', false);\n this.highlightedIndex = -1;\n this.emitEvent('input', { value: '' });\n this.emitEvent('clear');\n this.inputElement?.focus();\n }\n\n private handleFocus = () => {\n if (!this.active) {\n this.active = true;\n this.emitEvent('active-change', { active: true });\n }\n };\n\n private handleInput = (event: Event) => {\n const target = event.target as HTMLInputElement;\n this.value = target.value;\n this.setFormValue(this.value);\n this.toggleAttribute('has-value', Boolean(this.value));\n this.highlightedIndex = -1;\n this.emitEvent('input', { value: this.value });\n };\n\n private handleChange = () => {\n this.emitEvent('change', { value: this.value });\n };\n\n private handleKeyDown = (event: KeyboardEvent) => {\n const count = this.suggestions.length;\n\n if (event.key === 'Escape') {\n event.preventDefault();\n this.close();\n this.inputElement?.blur();\n return;\n }\n\n if (event.key === 'ArrowDown') {\n if (!this.active) {\n this.show();\n return;\n }\n if (count > 0) {\n event.preventDefault();\n this.highlightedIndex = (this.highlightedIndex + 1) % count;\n }\n return;\n }\n\n if (event.key === 'ArrowUp') {\n if (count > 0 && this.active) {\n event.preventDefault();\n this.highlightedIndex = this.highlightedIndex <= 0 ? count - 1 : this.highlightedIndex - 1;\n }\n return;\n }\n\n if (event.key === 'Enter') {\n if (this.active && this.highlightedIndex >= 0 && this.highlightedIndex < count) {\n const item = this.suggestions[this.highlightedIndex];\n if (item !== undefined) {\n event.preventDefault();\n this.selectSuggestion(item, this.highlightedIndex);\n }\n } else {\n this.emitEvent('search', { value: this.value });\n }\n }\n };\n\n private handleTriggerClick = (event: MouseEvent) => {\n event.stopPropagation();\n this.show();\n };\n\n private handleTriggerKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n this.show();\n }\n };\n\n private handleTrailingTriggerClick = (event: MouseEvent) => {\n event.stopPropagation();\n const allowed = this.emitEvent('trailing-icon-click', { icon: this.trailingIcon });\n if (allowed) {\n this.show();\n }\n };\n\n private handleBackClick = (event: MouseEvent) => {\n event.stopPropagation();\n this.close();\n };\n\n private handleScrimClick = () => {\n this.close();\n };\n\n private handleClearClick = (event: MouseEvent) => {\n event.stopPropagation();\n this.clear();\n };\n\n private selectSuggestion(suggestion: string | SearchSuggestion, index: number) {\n const label = typeof suggestion === 'string' ? suggestion : suggestion.label;\n const value = typeof suggestion === 'string' ? suggestion : (suggestion.value ?? suggestion.label);\n\n this.value = value;\n this.setFormValue(this.value);\n this.toggleAttribute('has-value', Boolean(this.value));\n this.emitEvent('suggestion-select', { suggestion, label, value, index });\n this.emitEvent('search', { value: this.value, suggestion });\n\n if (this.autoDeactivateOnSelect) {\n this.close();\n }\n }\n\n private renderSuggestionItem(suggestion: string | SearchSuggestion, index: number) {\n const isString = typeof suggestion === 'string';\n const label = isString ? suggestion : suggestion.label;\n const supportingText = !isString ? suggestion.supportingText : undefined;\n const trailingSupportingText = !isString ? suggestion.trailingSupportingText : undefined;\n const iconName = !isString && suggestion.icon ? suggestion.icon : 'history';\n const isHighlighted = this.highlightedIndex === index;\n\n return html`\n <div\n class=\"suggestion-item ${isHighlighted ? 'highlighted' : ''}\"\n role=\"option\"\n aria-selected=${isHighlighted ? 'true' : 'false'}\n @click=${() => this.selectSuggestion(suggestion, index)}\n >\n <span class=\"suggestion-icon\">\n <md-icon name=${iconName}></md-icon>\n </span>\n <div class=\"suggestion-text\">\n <span class=\"suggestion-label\">${label}</span>\n ${supportingText ? html`<span class=\"suggestion-supporting\">${supportingText}</span>` : nothing}\n </div>\n ${trailingSupportingText ? html`<span class=\"suggestion-trailing\">${trailingSupportingText}</span>` : nothing}\n </div>\n `;\n }\n\n override render() {\n const showBack = this.active && this.showBackButton;\n const hasTrailing = Boolean(this.trailingIcon);\n\n return html`\n <div\n class=\"search-trigger-container ${hasTrailing ? 'has-trailing' : ''}\"\n role=\"button\"\n tabindex=\"0\"\n aria-label=${this.placeholder || 'Search'}\n title=${this.placeholder || 'Search'}\n ?disabled=${this.disabled}\n @click=${this.handleTriggerClick}\n @keydown=${this.handleTriggerKeyDown}\n >\n <button\n class=\"trigger-btn\"\n type=\"button\"\n aria-label=${this.placeholder || 'Search'}\n title=${this.placeholder || 'Search'}\n ?disabled=${this.disabled}\n @click=${this.handleTriggerClick}\n >\n <md-icon name=${this.leadingIcon || 'search'}></md-icon>\n </button>\n\n ${hasTrailing\n ? html`\n <div class=\"trigger-divider\" aria-hidden=\"true\"></div>\n <button\n class=\"trigger-btn trigger-trailing-btn\"\n type=\"button\"\n aria-label=${this.trailingIcon}\n title=${this.trailingIcon}\n ?disabled=${this.disabled}\n @click=${this.handleTrailingTriggerClick}\n >\n <md-icon name=${this.trailingIcon}></md-icon>\n </button>\n `\n : nothing}\n </div>\n\n <div class=\"scrim\" @click=${this.handleScrimClick}></div>\n\n <div class=\"search-container\" role=\"search\">\n <div class=\"search-bar-header\">\n <span class=\"leading-slot\">\n <slot name=\"leading-icon\">\n ${showBack\n ? html`\n <button\n class=\"icon-btn\"\n type=\"button\"\n aria-label=\"Back\"\n @click=${this.handleBackClick}\n >\n <md-icon name=${this.activeLeadingIcon}></md-icon>\n </button>\n `\n : html`\n <span class=\"icon-btn\" style=\"cursor: default;\">\n <md-icon name=${this.leadingIcon}></md-icon>\n </span>\n `}\n </slot>\n </span>\n\n <div class=\"input-wrapper\">\n <input\n type=\"search\"\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-expanded=${this.active ? 'true' : 'false'}\n aria-label=${this.placeholder}\n placeholder=${this.placeholder}\n .value=${this.value}\n ?disabled=${this.disabled}\n @input=${this.handleInput}\n @change=${this.handleChange}\n @keydown=${this.handleKeyDown}\n @focus=${this.handleFocus}\n @click=${this.handleFocus}\n />\n </div>\n\n <span class=\"trailing-slot\">\n ${this.showClearButton && this.value\n ? html`\n <button\n class=\"icon-btn clear-btn\"\n type=\"button\"\n aria-label=\"Clear search\"\n @click=${this.handleClearClick}\n >\n <md-icon name=\"close\"></md-icon>\n </button>\n `\n : nothing}\n\n <slot name=\"trailing-icon\">\n ${this.trailingIcon\n ? html`\n <span class=\"icon-btn\" style=\"cursor: default;\">\n <md-icon name=${this.trailingIcon}></md-icon>\n </span>\n `\n : nothing}\n </slot>\n </span>\n </div>\n\n <div class=\"divider\"></div>\n\n <div class=\"suggestions-container\" role=\"listbox\" aria-label=\"Suggestions\">\n <slot name=\"suggestions\">\n ${this.suggestions.map((item, idx) => this.renderSuggestionItem(item, idx))}\n </slot>\n <div class=\"extra-content\">\n <slot></slot>\n </div>\n </div>\n </div>\n `;\n }\n}\n\n@customElement('md-search')\nexport class MdSearch extends MdSearchBar {}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'md-search-bar': MdSearchBar;\n 'md-search': MdSearch;\n }\n}\n"],"mappings":";;;;;AAEA,IAAa,IAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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ement as l, property as s } from "lit/decorators.js";
|
|
5
|
+
var c = n`
|
|
6
|
+
:host {
|
|
7
|
+
display: block;
|
|
8
|
+
position: fixed;
|
|
9
|
+
bottom: 24px;
|
|
10
|
+
left: 50%;
|
|
11
|
+
transform: translateX(-50%) translateY(100px);
|
|
12
|
+
opacity: 0;
|
|
13
|
+
pointer-events: none;
|
|
14
|
+
z-index: 2000;
|
|
15
|
+
transition: transform 250ms cubic-bezier(0.2, 0, 0, 1),
|
|
16
|
+
opacity 250ms cubic-bezier(0.2, 0, 0, 1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
:host([open]) {
|
|
20
|
+
transform: translateX(-50%) translateY(0);
|
|
21
|
+
opacity: 1;
|
|
22
|
+
pointer-events: auto;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.snackbar {
|
|
26
|
+
display: flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
min-width: 288px;
|
|
29
|
+
max-width: 568px;
|
|
30
|
+
min-height: 48px;
|
|
31
|
+
padding: 8px 16px;
|
|
32
|
+
box-sizing: border-box;
|
|
33
|
+
border-radius: var(--md-sys-shape-corner-extra-small, 4px);
|
|
34
|
+
background-color: var(--md-sys-color-inverse-surface, #313033);
|
|
35
|
+
color: var(--md-sys-color-inverse-on-surface, #F4EFF4);
|
|
36
|
+
box-shadow: var(--md-sys-elevation-level3, 0px 1px 3px 0px rgba(0,0,0,0.30));
|
|
37
|
+
font-family: var(--md-sys-typescale-font-family, inherit);
|
|
38
|
+
font-size: var(--md-sys-typescale-body-medium-size, 14px);
|
|
39
|
+
line-height: 20px;
|
|
40
|
+
gap: 12px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.message {
|
|
44
|
+
flex: 1;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.actions {
|
|
48
|
+
display: flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
gap: 8px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.action-btn {
|
|
54
|
+
background: transparent;
|
|
55
|
+
border: none;
|
|
56
|
+
color: var(--md-sys-color-inverse-primary, #D0BCFF);
|
|
57
|
+
font-family: inherit;
|
|
58
|
+
font-size: var(--md-sys-typescale-label-large-size, 14px);
|
|
59
|
+
font-weight: 500;
|
|
60
|
+
cursor: pointer;
|
|
61
|
+
padding: 0 8px;
|
|
62
|
+
height: 36px;
|
|
63
|
+
border-radius: var(--md-sys-shape-corner-extra-small, 4px);
|
|
64
|
+
outline: none;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.action-btn:hover {
|
|
68
|
+
background-color: rgba(208, 188, 255, 0.08);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.close-btn {
|
|
72
|
+
display: inline-flex;
|
|
73
|
+
align-items: center;
|
|
74
|
+
justify-content: center;
|
|
75
|
+
background: transparent;
|
|
76
|
+
border: none;
|
|
77
|
+
color: var(--md-sys-color-inverse-on-surface, #F4EFF4);
|
|
78
|
+
cursor: pointer;
|
|
79
|
+
padding: 4px;
|
|
80
|
+
border-radius: 50%;
|
|
81
|
+
outline: none;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.close-btn:hover {
|
|
85
|
+
background-color: rgba(255, 255, 255, 0.08);
|
|
86
|
+
}
|
|
87
|
+
`, e = class extends r {
|
|
88
|
+
constructor(...i) {
|
|
89
|
+
super(...i), this.open = !1, this.message = "", this.actionText = "", this.closeable = !1, this.timeoutMs = 4e3, this.timerId = null, this.handleAction = () => {
|
|
90
|
+
this.emitEvent("action"), this.close();
|
|
91
|
+
}, this.handleClose = () => {
|
|
92
|
+
this.close();
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
static {
|
|
96
|
+
this.styles = [r.styles, c];
|
|
97
|
+
}
|
|
98
|
+
updated(i) {
|
|
99
|
+
super.updated(i), i.has("open") && (this.open ? this.startTimer() : this.clearTimer());
|
|
100
|
+
}
|
|
101
|
+
show() {
|
|
102
|
+
this.open = !0;
|
|
103
|
+
}
|
|
104
|
+
close() {
|
|
105
|
+
this.open = !1, this.emitEvent("close");
|
|
106
|
+
}
|
|
107
|
+
startTimer() {
|
|
108
|
+
this.clearTimer(), this.timeoutMs > 0 && (this.timerId = window.setTimeout(() => {
|
|
109
|
+
this.close();
|
|
110
|
+
}, this.timeoutMs));
|
|
111
|
+
}
|
|
112
|
+
clearTimer() {
|
|
113
|
+
this.timerId !== null && (clearTimeout(this.timerId), this.timerId = null);
|
|
114
|
+
}
|
|
115
|
+
render() {
|
|
116
|
+
return o`
|
|
117
|
+
<div class="snackbar" role="status" aria-live="polite">
|
|
118
|
+
<div class="message">
|
|
119
|
+
<slot>${this.message}</slot>
|
|
120
|
+
</div>
|
|
121
|
+
|
|
122
|
+
<div class="actions">
|
|
123
|
+
${this.actionText ? o`
|
|
124
|
+
<button class="action-btn" @click=${this.handleAction}>
|
|
125
|
+
${this.actionText}
|
|
126
|
+
</button>
|
|
127
|
+
` : a}
|
|
128
|
+
|
|
129
|
+
${this.closeable ? o`
|
|
130
|
+
<button class="close-btn" aria-label="Dismiss" @click=${this.handleClose}>
|
|
131
|
+
<md-icon name="close" size="18"></md-icon>
|
|
132
|
+
</button>
|
|
133
|
+
` : a}
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
`;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
t([s({
|
|
140
|
+
type: Boolean,
|
|
141
|
+
reflect: !0
|
|
142
|
+
})], e.prototype, "open", void 0);
|
|
143
|
+
t([s({ type: String })], e.prototype, "message", void 0);
|
|
144
|
+
t([s({
|
|
145
|
+
type: String,
|
|
146
|
+
attribute: "action-text"
|
|
147
|
+
})], e.prototype, "actionText", void 0);
|
|
148
|
+
t([s({
|
|
149
|
+
type: Boolean,
|
|
150
|
+
reflect: !0
|
|
151
|
+
})], e.prototype, "closeable", void 0);
|
|
152
|
+
t([s({
|
|
153
|
+
type: Number,
|
|
154
|
+
attribute: "timeout-ms"
|
|
155
|
+
})], e.prototype, "timeoutMs", void 0);
|
|
156
|
+
e = t([l("md-snackbar")], e);
|
|
157
|
+
export {
|
|
158
|
+
e as t
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
//# sourceMappingURL=snackbar-Wsz3BzEY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snackbar-Wsz3BzEY.js","names":[],"sources":["../../src/components/snackbar/snackbar.css.ts","../../src/components/snackbar/snackbar.ts"],"sourcesContent":["import { css } from 'lit';\n\nexport const snackbarStyles = css`\n :host {\n display: block;\n position: fixed;\n bottom: 24px;\n left: 50%;\n transform: translateX(-50%) translateY(100px);\n opacity: 0;\n pointer-events: none;\n z-index: 2000;\n transition: transform 250ms cubic-bezier(0.2, 0, 0, 1),\n opacity 250ms cubic-bezier(0.2, 0, 0, 1);\n }\n\n :host([open]) {\n transform: translateX(-50%) translateY(0);\n opacity: 1;\n pointer-events: auto;\n }\n\n .snackbar {\n display: flex;\n align-items: center;\n min-width: 288px;\n max-width: 568px;\n min-height: 48px;\n padding: 8px 16px;\n box-sizing: border-box;\n border-radius: var(--md-sys-shape-corner-extra-small, 4px);\n background-color: var(--md-sys-color-inverse-surface, #313033);\n color: var(--md-sys-color-inverse-on-surface, #F4EFF4);\n box-shadow: var(--md-sys-elevation-level3, 0px 1px 3px 0px rgba(0,0,0,0.30));\n font-family: var(--md-sys-typescale-font-family, inherit);\n font-size: var(--md-sys-typescale-body-medium-size, 14px);\n line-height: 20px;\n gap: 12px;\n }\n\n .message {\n flex: 1;\n }\n\n .actions {\n display: flex;\n align-items: center;\n gap: 8px;\n }\n\n .action-btn {\n background: transparent;\n border: none;\n color: var(--md-sys-color-inverse-primary, #D0BCFF);\n font-family: inherit;\n font-size: var(--md-sys-typescale-label-large-size, 14px);\n font-weight: 500;\n cursor: pointer;\n padding: 0 8px;\n height: 36px;\n border-radius: var(--md-sys-shape-corner-extra-small, 4px);\n outline: none;\n }\n\n .action-btn:hover {\n background-color: rgba(208, 188, 255, 0.08);\n }\n\n .close-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: transparent;\n border: none;\n color: var(--md-sys-color-inverse-on-surface, #F4EFF4);\n cursor: pointer;\n padding: 4px;\n border-radius: 50%;\n outline: none;\n }\n\n .close-btn:hover {\n background-color: rgba(255, 255, 255, 0.08);\n }\n`;\n\n","import { html, nothing } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { MdBaseElement } from '../../internal/base-component.js';\nimport '../icon/icon.js';\nimport { snackbarStyles } from './snackbar.css.js';\n\n@customElement('md-snackbar')\nexport class MdSnackbar extends MdBaseElement {\n static override styles = [MdBaseElement.styles, snackbarStyles];\n\n @property({ type: Boolean, reflect: true })\n open = false;\n\n @property({ type: String })\n message = '';\n\n @property({ type: String, attribute: 'action-text' })\n actionText = '';\n\n @property({ type: Boolean, reflect: true })\n closeable = false;\n\n @property({ type: Number, attribute: 'timeout-ms' })\n timeoutMs = 4000;\n\n private timerId: number | null = null;\n\n override updated(changedProperties: Map<string, unknown>) {\n super.updated(changedProperties);\n if (changedProperties.has('open')) {\n if (this.open) {\n this.startTimer();\n } else {\n this.clearTimer();\n }\n }\n }\n\n show() {\n this.open = true;\n }\n\n close() {\n this.open = false;\n this.emitEvent('close');\n }\n\n private startTimer() {\n this.clearTimer();\n if (this.timeoutMs > 0) {\n this.timerId = window.setTimeout(() => {\n this.close();\n }, this.timeoutMs);\n }\n }\n\n private clearTimer() {\n if (this.timerId !== null) {\n clearTimeout(this.timerId);\n this.timerId = null;\n }\n }\n\n private handleAction = () => {\n this.emitEvent('action');\n this.close();\n };\n\n private handleClose = () => {\n this.close();\n };\n\n override render() {\n return html`\n <div class=\"snackbar\" role=\"status\" aria-live=\"polite\">\n <div class=\"message\">\n <slot>${this.message}</slot>\n </div>\n\n <div class=\"actions\">\n ${this.actionText\n ? html`\n <button class=\"action-btn\" @click=${this.handleAction}>\n ${this.actionText}\n </button>\n `\n : nothing}\n\n ${this.closeable\n ? html`\n <button class=\"close-btn\" aria-label=\"Dismiss\" @click=${this.handleClose}>\n <md-icon name=\"close\" size=\"18\"></md-icon>\n </button>\n `\n : nothing}\n </div>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'md-snackbar': MdSnackbar;\n }\n}\n\n"],"mappings":";;;;AAEA,IAAa,IAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GCKjB,IAAN,cAAyB,EAAc;AAAA;iBAIrC,KAAA,OAAA,IAGG,KAAA,UAAA,IAGG,KAAA,aAAA,IAGD,KAAA,YAAA,IAGA,KAAA,YAAA,KAEqB,KAAA,UAAA,MAsCJ,KAAA,eAAA,MAAA;AAC3B,WAAK,UAAU,QAAQ,GACvB,KAAK,MAAM;AAAA,IACb,GAE4B,KAAA,cAAA,MAAA;AAC1B,WAAK,MAAM;AAAA,IACb;AAAA;;AA9DyB,SAAA,SAAA,CAAC,EAAc,QAAQ,CAAc;AAAA;EAmB9D,QAAiB,GAAyC;AACxD,UAAM,QAAQ,CAAiB,GAC3B,EAAkB,IAAI,MAAM,MAC1B,KAAK,OACP,KAAK,WAAW,IAEhB,KAAK,WAAW;AAAA,EAGtB;AAAA,EAEA,OAAO;AACL,SAAK,OAAO;AAAA,EACd;A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,190 @@
|
|
|
1
|
+
import { t as i } from "./decorate-DXuynaiA.js";
|
|
2
|
+
import { t as c } from "./form-associated-Cty_ZaS9.js";
|
|
3
|
+
import "./ripple-squbKHhj.js";
|
|
4
|
+
import "./focus-ring-CuiJuM-y.js";
|
|
5
|
+
import "./icon-DrNqcNEL.js";
|
|
6
|
+
import { css as l, html as o } from "lit";
|
|
7
|
+
import { customElement as n, property as r } from "lit/decorators.js";
|
|
8
|
+
var a = l`
|
|
9
|
+
:host {
|
|
10
|
+
display: inline-flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
vertical-align: middle;
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
outline: none;
|
|
15
|
+
-webkit-tap-highlight-color: transparent;
|
|
16
|
+
user-select: none;
|
|
17
|
+
gap: 12px;
|
|
18
|
+
font-family: var(--md-sys-typescale-font-family, inherit);
|
|
19
|
+
font-size: var(--md-sys-typescale-body-large-size, 16px);
|
|
20
|
+
color: var(--md-sys-color-on-surface, #1D1B20);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
:host([disabled]) {
|
|
24
|
+
cursor: not-allowed;
|
|
25
|
+
opacity: 0.38;
|
|
26
|
+
pointer-events: none;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.switch {
|
|
30
|
+
position: relative;
|
|
31
|
+
display: inline-flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
width: 52px;
|
|
34
|
+
height: 32px;
|
|
35
|
+
box-sizing: border-box;
|
|
36
|
+
border-radius: var(--md-sys-shape-corner-full, 9999px);
|
|
37
|
+
border: 2px solid var(--md-sys-color-outline, #79747E);
|
|
38
|
+
background-color: var(--md-sys-color-surface-container-highest, #E6E0E9);
|
|
39
|
+
transition: background-color 200ms cubic-bezier(0.2, 0, 0, 1),
|
|
40
|
+
border-color 200ms cubic-bezier(0.2, 0, 0, 1);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
:host([selected]) .switch {
|
|
44
|
+
background-color: var(--md-sys-color-primary, #6750A4);
|
|
45
|
+
border-color: var(--md-sys-color-primary, #6750A4);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
:host([disabled]) .switch {
|
|
49
|
+
background-color: var(--md-sys-color-surface-container-highest, #E6E0E9);
|
|
50
|
+
border-color: var(--md-sys-color-outline, #79747E);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
:host([disabled][selected]) .switch {
|
|
54
|
+
background-color: var(--md-sys-color-on-surface, #1D1B20);
|
|
55
|
+
border-color: transparent;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.thumb-container {
|
|
59
|
+
position: absolute;
|
|
60
|
+
top: 2px;
|
|
61
|
+
left: 2px;
|
|
62
|
+
width: 24px;
|
|
63
|
+
height: 24px;
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
justify-content: center;
|
|
67
|
+
transition: transform 200ms cubic-bezier(0.2, 0, 0, 1);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
:host([selected]) .thumb-container {
|
|
71
|
+
transform: translateX(20px);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.thumb {
|
|
75
|
+
position: relative;
|
|
76
|
+
width: 16px;
|
|
77
|
+
height: 16px;
|
|
78
|
+
flex-shrink: 0;
|
|
79
|
+
border-radius: 50%;
|
|
80
|
+
background-color: var(--md-sys-color-outline, #79747E);
|
|
81
|
+
display: flex;
|
|
82
|
+
align-items: center;
|
|
83
|
+
justify-content: center;
|
|
84
|
+
transition: width 200ms cubic-bezier(0.2, 0, 0, 1),
|
|
85
|
+
height 200ms cubic-bezier(0.2, 0, 0, 1),
|
|
86
|
+
background-color 200ms cubic-bezier(0.2, 0, 0, 1);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
:host([icons]) .thumb,
|
|
90
|
+
:host([selected]) .thumb {
|
|
91
|
+
width: 24px;
|
|
92
|
+
height: 24px;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
:host([selected]) .thumb {
|
|
96
|
+
background-color: var(--md-sys-color-on-primary, #FFFFFF);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
:host([disabled]) .thumb {
|
|
100
|
+
background-color: var(--md-sys-color-on-surface, #1D1B20);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
:host([disabled][selected]) .thumb {
|
|
104
|
+
background-color: var(--md-sys-color-surface, #FEF7FF);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.icon {
|
|
108
|
+
position: absolute;
|
|
109
|
+
inset: 0;
|
|
110
|
+
margin: auto;
|
|
111
|
+
display: inline-flex;
|
|
112
|
+
align-items: center;
|
|
113
|
+
justify-content: center;
|
|
114
|
+
font-size: 16px;
|
|
115
|
+
color: var(--md-sys-color-on-primary-container, #21005D);
|
|
116
|
+
opacity: 0;
|
|
117
|
+
transition: opacity 150ms ease;
|
|
118
|
+
pointer-events: none;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
:host([selected]) .icon.check {
|
|
122
|
+
opacity: 1;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
:host([icons]:not([selected])) .icon.cross {
|
|
126
|
+
opacity: 1;
|
|
127
|
+
color: var(--md-sys-color-surface-container-highest, #E6E0E9);
|
|
128
|
+
}
|
|
129
|
+
`, s = class extends c {
|
|
130
|
+
constructor(...e) {
|
|
131
|
+
super(...e), this.selected = !1, this.icons = !1, this.value = "on", this.handleClick = (t) => {
|
|
132
|
+
this.disabled || (t.preventDefault(), this.toggle());
|
|
133
|
+
}, this.handleKeyDown = (t) => {
|
|
134
|
+
this.disabled || (t.key === " " || t.key === "Enter") && (t.preventDefault(), this.toggle());
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
static {
|
|
138
|
+
this.styles = [c.styles, a];
|
|
139
|
+
}
|
|
140
|
+
connectedCallback() {
|
|
141
|
+
super.connectedCallback(), this.tabIndex = this.disabled ? -1 : 0, this.addEventListener("click", this.handleClick), this.addEventListener("keydown", this.handleKeyDown), this.updateFormValue();
|
|
142
|
+
}
|
|
143
|
+
disconnectedCallback() {
|
|
144
|
+
super.disconnectedCallback(), this.removeEventListener("click", this.handleClick), this.removeEventListener("keydown", this.handleKeyDown);
|
|
145
|
+
}
|
|
146
|
+
updated(e) {
|
|
147
|
+
super.updated(e), (e.has("selected") || e.has("value")) && this.updateFormValue();
|
|
148
|
+
}
|
|
149
|
+
formResetCallback() {
|
|
150
|
+
this.selected = !1, this.updateFormValue();
|
|
151
|
+
}
|
|
152
|
+
updateFormValue() {
|
|
153
|
+
this.setFormValue(this.selected ? this.value : null), this.required && !this.selected ? this.setValidity({ valueMissing: !0 }, "Please toggle this switch") : this.setValidity({});
|
|
154
|
+
}
|
|
155
|
+
toggle() {
|
|
156
|
+
this.selected = !this.selected, this.updateFormValue(), this.emitEvent("change", { selected: this.selected }), this.emitEvent("input", { selected: this.selected });
|
|
157
|
+
}
|
|
158
|
+
render() {
|
|
159
|
+
return o`
|
|
160
|
+
<div class="switch">
|
|
161
|
+
<div class="thumb-container">
|
|
162
|
+
<md-ripple ?disabled=${this.disabled} unbounded></md-ripple>
|
|
163
|
+
<md-focus-ring></md-focus-ring>
|
|
164
|
+
<div class="thumb">
|
|
165
|
+
${this.icons ? o`
|
|
166
|
+
<md-icon class="icon check" size="16">check</md-icon>
|
|
167
|
+
<md-icon class="icon cross" size="16">close</md-icon>
|
|
168
|
+
` : o`<slot name="icon"></slot>`}
|
|
169
|
+
</div>
|
|
170
|
+
</div>
|
|
171
|
+
</div>
|
|
172
|
+
<slot></slot>
|
|
173
|
+
`;
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
i([r({
|
|
177
|
+
type: Boolean,
|
|
178
|
+
reflect: !0
|
|
179
|
+
})], s.prototype, "selected", void 0);
|
|
180
|
+
i([r({
|
|
181
|
+
type: Boolean,
|
|
182
|
+
reflect: !0
|
|
183
|
+
})], s.prototype, "icons", void 0);
|
|
184
|
+
i([r({ type: String })], s.prototype, "value", void 0);
|
|
185
|
+
s = i([n("md-switch")], s);
|
|
186
|
+
export {
|
|
187
|
+
s as t
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
//# sourceMappingURL=switch-DdukrvXb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"switch-DdukrvXb.js","names":[],"sources":["../../src/components/switch/switch.css.ts","../../src/components/switch/switch.ts"],"sourcesContent":["import { css } from 'lit';\n\nexport const switchStyles = css`\n :host {\n display: inline-flex;\n align-items: center;\n vertical-align: middle;\n cursor: pointer;\n outline: none;\n -webkit-tap-highlight-color: transparent;\n user-select: none;\n gap: 12px;\n font-family: var(--md-sys-typescale-font-family, inherit);\n font-size: var(--md-sys-typescale-body-large-size, 16px);\n color: var(--md-sys-color-on-surface, #1D1B20);\n }\n\n :host([disabled]) {\n cursor: not-allowed;\n opacity: 0.38;\n pointer-events: none;\n }\n\n .switch {\n position: relative;\n display: inline-flex;\n align-items: center;\n width: 52px;\n height: 32px;\n box-sizing: border-box;\n border-radius: var(--md-sys-shape-corner-full, 9999px);\n border: 2px solid var(--md-sys-color-outline, #79747E);\n background-color: var(--md-sys-color-surface-container-highest, #E6E0E9);\n transition: background-color 200ms cubic-bezier(0.2, 0, 0, 1),\n border-color 200ms cubic-bezier(0.2, 0, 0, 1);\n }\n\n :host([selected]) .switch {\n background-color: var(--md-sys-color-primary, #6750A4);\n border-color: var(--md-sys-color-primary, #6750A4);\n }\n\n :host([disabled]) .switch {\n background-color: var(--md-sys-color-surface-container-highest, #E6E0E9);\n border-color: var(--md-sys-color-outline, #79747E);\n }\n\n :host([disabled][selected]) .switch {\n background-color: var(--md-sys-color-on-surface, #1D1B20);\n border-color: transparent;\n }\n\n .thumb-container {\n position: absolute;\n top: 2px;\n left: 2px;\n width: 24px;\n height: 24px;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: transform 200ms cubic-bezier(0.2, 0, 0, 1);\n }\n\n :host([selected]) .thumb-container {\n transform: translateX(20px);\n }\n\n .thumb {\n position: relative;\n width: 16px;\n height: 16px;\n flex-shrink: 0;\n border-radius: 50%;\n background-color: var(--md-sys-color-outline, #79747E);\n display: flex;\n align-items: center;\n justify-content: center;\n transition: width 200ms cubic-bezier(0.2, 0, 0, 1),\n height 200ms cubic-bezier(0.2, 0, 0, 1),\n background-color 200ms cubic-bezier(0.2, 0, 0, 1);\n }\n\n :host([icons]) .thumb,\n :host([selected]) .thumb {\n width: 24px;\n height: 24px;\n }\n\n :host([selected]) .thumb {\n background-color: var(--md-sys-color-on-primary, #FFFFFF);\n }\n\n :host([disabled]) .thumb {\n background-color: var(--md-sys-color-on-surface, #1D1B20);\n }\n\n :host([disabled][selected]) .thumb {\n background-color: var(--md-sys-color-surface, #FEF7FF);\n }\n\n .icon {\n position: absolute;\n inset: 0;\n margin: auto;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 16px;\n color: var(--md-sys-color-on-primary-container, #21005D);\n opacity: 0;\n transition: opacity 150ms ease;\n pointer-events: none;\n }\n\n :host([selected]) .icon.check {\n opacity: 1;\n }\n\n :host([icons]:not([selected])) .icon.cross {\n opacity: 1;\n color: var(--md-sys-color-surface-container-highest, #E6E0E9);\n }\n`;\n\n","import { html } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { MdBaseElement } from '../../internal/base-component.js';\nimport { MdFormAssociatedElement } from '../../internal/form-associated.js';\nimport '../../internal/ripple/ripple.js';\nimport '../../internal/focus-ring/focus-ring.js';\nimport '../icon/icon.js';\nimport { switchStyles } from './switch.css.js';\n\n@customElement('md-switch')\nexport class MdSwitch extends MdFormAssociatedElement {\n static override styles = [MdFormAssociatedElement.styles, switchStyles];\n\n @property({ type: Boolean, reflect: true })\n selected = false;\n\n @property({ type: Boolean, reflect: true })\n icons = false;\n\n @property({ type: String })\n value = 'on';\n\n override connectedCallback() {\n super.connectedCallback();\n this.tabIndex = this.disabled ? -1 : 0;\n this.addEventListener('click', this.handleClick);\n this.addEventListener('keydown', this.handleKeyDown);\n this.updateFormValue();\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.removeEventListener('click', this.handleClick);\n this.removeEventListener('keydown', this.handleKeyDown);\n }\n\n override updated(changedProperties: Map<string, unknown>) {\n super.updated(changedProperties);\n if (changedProperties.has('selected') || changedProperties.has('value')) {\n this.updateFormValue();\n }\n }\n\n override formResetCallback() {\n this.selected = false;\n this.updateFormValue();\n }\n\n private updateFormValue() {\n this.setFormValue(this.selected ? this.value : null);\n if (this.required && !this.selected) {\n this.setValidity({ valueMissing: true }, 'Please toggle this switch');\n } else {\n this.setValidity({});\n }\n }\n\n private handleClick = (event: MouseEvent) => {\n if (this.disabled) return;\n event.preventDefault();\n this.toggle();\n };\n\n private handleKeyDown = (event: KeyboardEvent) => {\n if (this.disabled) return;\n if (event.key === ' ' || event.key === 'Enter') {\n event.preventDefault();\n this.toggle();\n }\n };\n\n private toggle() {\n this.selected = !this.selected;\n this.updateFormValue();\n this.emitEvent('change', { selected: this.selected });\n this.emitEvent('input', { selected: this.selected });\n }\n\n override render() {\n return html`\n <div class=\"switch\">\n <div class=\"thumb-container\">\n <md-ripple ?disabled=${this.disabled} unbounded></md-ripple>\n <md-focus-ring></md-focus-ring>\n <div class=\"thumb\">\n ${this.icons\n ? html`\n <md-icon class=\"icon check\" size=\"16\">check</md-icon>\n <md-icon class=\"icon cross\" size=\"16\">close</md-icon>\n `\n : html`<slot name=\"icon\"></slot>`}\n </div>\n </div>\n </div>\n <slot></slot>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'md-switch': MdSwitch;\n }\n}\n"],"mappings":";;;;;;;AAEA,IAAa,IAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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