@felleslosninger/minid-elements 0.0.118 → 0.0.120
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/components/alert.js.map +1 -1
- package/dist/components/button.js.map +1 -1
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/code-input-old.js.map +1 -1
- package/dist/components/code-input.js.map +1 -1
- package/dist/components/combobox.component.d.ts +1 -1
- package/dist/components/combobox.component.d.ts.map +1 -1
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/countdown.js.map +1 -1
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/dropdown.component.d.ts +6 -0
- package/dist/components/dropdown.component.d.ts.map +1 -1
- package/dist/components/dropdown.js.map +1 -1
- package/dist/components/heading.js.map +1 -1
- package/dist/components/helptext.js.map +1 -1
- package/dist/components/icon/icon.js.map +1 -1
- package/dist/components/label.js.map +1 -1
- package/dist/components/link.js.map +1 -1
- package/dist/components/menu-item.js.map +1 -1
- package/dist/components/menu.component.d.ts.map +1 -1
- package/dist/components/menu.js +0 -7
- package/dist/components/menu.js.map +1 -1
- package/dist/components/paragraph.js.map +1 -1
- package/dist/components/phone-input.js.map +1 -1
- package/dist/components/popup.js.map +1 -1
- package/dist/components/qr-code.js.map +1 -1
- package/dist/components/radio-button.js.map +1 -1
- package/dist/components/radio-group.js.map +1 -1
- package/dist/components/radio.js.map +1 -1
- package/dist/components/search.js.map +1 -1
- package/dist/components/spinner.js.map +1 -1
- package/dist/components/step-indicator.js.map +1 -1
- package/dist/components/textfield.component.d.ts +12 -0
- package/dist/components/textfield.component.d.ts.map +1 -1
- package/dist/components/textfield.js +19 -0
- package/dist/components/textfield.js.map +1 -1
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/validation-message.js.map +1 -1
- package/dist/internal/animate.js.map +1 -1
- package/dist/internal/debounce.js.map +1 -1
- package/dist/internal/event.js.map +1 -1
- package/dist/internal/scroll.js.map +1 -1
- package/dist/internal/slot.js.map +1 -1
- package/dist/internal/string-converter.js.map +1 -1
- package/dist/internal/tabbable.js.map +1 -1
- package/dist/internal/watch.js.map +1 -1
- package/dist/mixins/form-control.mixin.js.map +1 -1
- package/dist/mixins/form-controller.mixin.js.map +1 -1
- package/dist/mixins/tailwind.mixin.d.ts.map +1 -1
- package/dist/mixins/tailwind.mixin.js.map +1 -1
- package/dist/mixins/validators.js.map +1 -1
- package/dist/utilities/animation-registry.js.map +1 -1
- package/dist/utilities/web-otp-api.js.map +1 -1
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popup.js","sources":["../../src/components/popup.component.ts"],"sourcesContent":["/*\n\nCopyright (c) 2020 A Beautiful Site, LLC\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n*/\n\nimport {\n arrow,\n autoUpdate,\n computePosition,\n flip,\n offset,\n platform,\n shift,\n size,\n} from '@floating-ui/dom';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { css, html, LitElement } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { styled } from '../mixins/tailwind.mixin';\nimport { offsetParent } from 'composed-offset-position';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-popup': MinidPopup;\n }\n}\n\nexport interface VirtualElement {\n getBoundingClientRect: () => DOMRect;\n contextElement?: Element;\n}\n\nfunction isVirtualElement(e: unknown): e is VirtualElement {\n return (\n e !== null &&\n typeof e === 'object' &&\n 'getBoundingClientRect' in e &&\n ('contextElement' in e ? e instanceof Element : true)\n );\n}\n\nconst styles = [\n css`\n :host {\n --arrow-color: white;\n --arrow-border-color: transparent;\n --arrow-size: 6px;\n\n /*\n These properties are computed to account for the arrow's dimensions after being rotated 45º. The constant\n 0.7071 is derived from sin(45), which is the diagonal size of the arrow's container after rotating.\n */\n --arrow-size-diagonal: calc(var(--arrow-size) * 0.7071);\n --arrow-padding-offset: calc(\n var(--arrow-size-diagonal) - var(--arrow-size)\n );\n\n display: contents;\n }\n\n .popup {\n position: absolute;\n isolation: isolate;\n max-width: var(--auto-size-available-width, none);\n max-height: var(--auto-size-available-height, none);\n z-index: 900;\n }\n\n .popup--fixed {\n position: fixed;\n }\n\n .popup:not(.popup--active) {\n display: none;\n }\n\n .popup__arrow {\n position: absolute;\n width: calc(var(--arrow-size-diagonal) * 2);\n height: calc(var(--arrow-size-diagonal) * 2);\n border: 1px solid var(--arrow-border-color);\n border-left-color: transparent;\n border-top-color: transparent;\n rotate: 45deg;\n background: var(--arrow-color);\n z-index: 901;\n }\n\n /* Hover bridge */\n .popup-hover-bridge:not(.popup-hover-bridge--visible) {\n display: none;\n }\n\n .popup-hover-bridge {\n position: fixed;\n z-index: calc(900 - 1);\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n clip-path: polygon(\n var(--hover-bridge-top-left-x, 0) var(--hover-bridge-top-left-y, 0),\n var(--hover-bridge-top-right-x, 0) var(--hover-bridge-top-right-y, 0),\n var(--hover-bridge-bottom-right-x, 0)\n var(--hover-bridge-bottom-right-y, 0),\n var(--hover-bridge-bottom-left-x, 0)\n var(--hover-bridge-bottom-left-y, 0)\n );\n }\n\n :host([data-current-placement^='top']) .popup {\n transform-origin: bottom;\n }\n\n :host([data-current-placement^='bottom']) .popup {\n transform-origin: top;\n }\n\n :host([data-current-placement^='left']) .popup {\n transform-origin: right;\n }\n\n :host([data-current-placement^='right']) .popup {\n transform-origin: left;\n }\n\n :host([data-current-placement^='top']) .popup__arrow {\n transform: rotate(0deg);\n }\n\n :host([data-current-placement^='bottom']) .popup__arrow {\n transform: rotate(180deg);\n }\n\n :host([data-current-placement^='left']) .popup__arrow {\n transform: rotate(-90deg);\n }\n\n :host([data-current-placement^='right']) .popup__arrow {\n transform: rotate(90deg);\n }\n `,\n];\n\n/**\n * @summary Popup is a utility that lets you declaratively anchor \"popup\" containers to another element.\n * @documentation https://shoelace.style/components/popup\n * @status stable\n * @since 2.0\n *\n * @event mid-reposition - Emitted when the popup is repositioned. This event can fire a lot, so avoid putting expensive\n * operations in your listener or consider debouncing it.\n *\n * @slot - The popup's content.\n * @slot anchor - The element the popup will be anchored to. If the anchor lives outside of the popup, you can use the\n * `anchor` attribute or property instead.\n *\n * @csspart arrow - The arrow's container. Avoid setting `top|bottom|left|right` properties, as these values are\n * assigned dynamically as the popup moves. This is most useful for applying a background color to match the popup, and\n * maybe a border or box shadow.\n * @csspart popup - The popup's container. Useful for setting a background color, box shadow, etc.\n * @csspart hover-bridge - The hover bridge element. Only available when the `hover-bridge` option is enabled.\n *\n * @cssproperty [--arrow-size=6px] - The size of the arrow. Note that an arrow won't be shown unless the `arrow`\n * attribute is used.\n * @cssproperty [--arrow-color=white] - The color of the arrow.\n * @cssproperty [--arrow-border-color=transparent] - The color for the arrow border\n * @cssproperty [--auto-size-available-width] - A read-only custom property that determines the amount of width the\n * popup can be before overflowing. Useful for positioning child elements that need to overflow. This property is only\n * available when using `auto-size`.\n * @cssproperty [--auto-size-available-height] - A read-only custom property that determines the amount of height the\n * popup can be before overflowing. Useful for positioning child elements that need to overflow. This property is only\n * available when using `auto-size`.\n */\n\n@customElement('mid-popup')\nexport class MinidPopup extends styled(LitElement, styles) {\n private anchorEl: Element | VirtualElement | null = null;\n private cleanup?: ReturnType<typeof autoUpdate>;\n\n /**\n * A reference to the internal popup container. Useful for animating and styling the popup with JavaScript.\n */\n @query('.popup')\n popup!: HTMLElement;\n\n @query('.popup__arrow')\n private arrowEl!: HTMLElement;\n\n /**\n * The element the popup will be anchored to. If the anchor lives outside of the popup, you can provide the anchor\n * element `id`, a DOM element reference, or a `VirtualElement`. If the anchor lives inside the popup, use the\n * `anchor` slot instead.\n */\n @property()\n anchor: Element | string | VirtualElement = '';\n\n /**\n * Activates the positioning logic and shows the popup. When this attribute is removed, the positioning logic is torn\n * down and the popup will be hidden.\n */\n @property({ type: Boolean, reflect: true })\n active = false;\n\n /**\n * The preferred placement of the popup. Note that the actual placement will vary as configured to keep the\n * panel inside of the viewport.\n */\n @property({ reflect: true })\n placement:\n | 'top'\n | 'top-start'\n | 'top-end'\n | 'bottom'\n | 'bottom-start'\n | 'bottom-end'\n | 'right'\n | 'right-start'\n | 'right-end'\n | 'left'\n | 'left-start'\n | 'left-end' = 'top';\n\n /**\n * Determines how the popup is positioned. The `absolute` strategy works well in most cases, but if overflow is\n * clipped, using a `fixed` position strategy can often workaround it.\n */\n @property({ reflect: true })\n strategy: 'absolute' | 'fixed' = 'absolute';\n\n /**\n * The distance in pixels from which to offset the panel away from its anchor.\n */\n @property({ type: Number })\n distance = 0;\n\n /**\n * The distance in pixels from which to offset the panel along its anchor.\n */\n @property({ type: Number })\n skidding = 0;\n\n /**\n * Attaches an arrow to the popup. The arrow's size and color can be customized using the `--arrow-size` and\n * `--arrow-color` custom properties. For additional customizations, you can also target the arrow using\n * `::part(arrow)` in your stylesheet.\n */\n @property({ type: Boolean })\n arrow = false;\n\n /**\n * The placement of the arrow. The default is `anchor`, which will align the arrow as close to the center of the\n * anchor as possible, considering available space and `arrow-padding`. A value of `start`, `end`, or `center` will\n * align the arrow to the start, end, or center of the popover instead.\n */\n @property({ attribute: 'arrow-placement' })\n arrowPlacement: 'start' | 'end' | 'center' | 'anchor' = 'anchor';\n\n /**\n * The amount of padding between the arrow and the edges of the popup. If the popup has a border-radius, for example,\n * this will prevent it from overflowing the corners.\n */\n @property({ attribute: 'arrow-padding', type: Number })\n arrowPadding = 10;\n\n /**\n * When set, placement of the popup will flip to the opposite site to keep it in view. You can use\n * `flipFallbackPlacements` to further configure how the fallback placement is determined.\n */\n @property({ type: Boolean })\n flip = false;\n\n /**\n * If the preferred placement doesn't fit, popup will be tested in these fallback placements until one fits. Must be a\n * string of any number of placements separated by a space, e.g. \"top bottom left\". If no placement fits, the flip\n * fallback strategy will be used instead.\n */\n @property({\n attribute: 'flip-fallback-placements',\n converter: {\n fromAttribute: (value: string) => {\n return value\n .split(' ')\n .map((p) => p.trim())\n .filter((p) => p !== '');\n },\n toAttribute: (value: []) => {\n return value.join(' ');\n },\n },\n })\n flipFallbackPlacements = '';\n\n /**\n * When neither the preferred placement nor the fallback placements fit, this value will be used to determine whether\n * the popup should be positioned using the best available fit based on available space or as it was initially\n * preferred.\n */\n @property({ attribute: 'flip-fallback-strategy' })\n flipFallbackStrategy: 'best-fit' | 'initial' = 'best-fit';\n\n /**\n * The flip boundary describes clipping element(s) that overflow will be checked relative to when flipping. By\n * default, the boundary includes overflow ancestors that will cause the element to be clipped. If needed, you can\n * change the boundary by passing a reference to one or more elements to this property.\n */\n @property({ type: Object })\n flipBoundary?: Element | Element[];\n\n /**\n * The amount of padding, in pixels, to exceed before the flip behavior will occur.\n */\n @property({ attribute: 'flip-padding', type: Number })\n flipPadding = 0;\n\n /**\n * Moves the popup along the axis to keep it in view when clipped.\n */\n @property({ type: Boolean })\n shift = false;\n\n /**\n * The shift boundary describes clipping element(s) that overflow will be checked relative to when shifting. By\n * default, the boundary includes overflow ancestors that will cause the element to be clipped. If needed, you can\n * change the boundary by passing a reference to one or more elements to this property.\n */\n @property({ type: Object })\n shiftBoundary?: Element | Element[];\n\n /**\n * The amount of padding, in pixels, to exceed before the shift behavior will occur.\n */\n @property({ attribute: 'shift-padding', type: Number })\n shiftPadding = 0;\n\n /** When set, this will cause the popup to automatically resize itself to prevent it from overflowing. */\n @property({ attribute: 'auto-size' }) autoSize?:\n | 'horizontal'\n | 'vertical'\n | 'both';\n\n /**\n * Syncs the popup's width or height to that of the anchor element.\n */\n @property()\n sync?: 'width' | 'height' | 'both';\n\n /**\n * The auto-size boundary describes clipping element(s) that overflow will be checked relative to when resizing. By\n * default, the boundary includes overflow ancestors that will cause the element to be clipped. If needed, you can\n * change the boundary by passing a reference to one or more elements to this property.\n */\n @property({ type: Object })\n autoSizeBoundary?: Element | Element[];\n\n /**\n * The amount of padding, in pixels, to exceed before the auto-size behavior will occur.\n */\n @property({ attribute: 'auto-size-padding', type: Number }) autoSizePadding =\n 0;\n\n /**\n * When a gap exists between the anchor and the popup element, this option will add a \"hover bridge\" that fills the\n * gap using an invisible element. This makes listening for events such as `mouseenter` and `mouseleave` more sane\n * because the pointer never technically leaves the element. The hover bridge will only be drawn when the popover is\n * active.\n */\n @property({ attribute: 'hover-bridge', type: Boolean }) hoverBridge = false;\n\n async connectedCallback() {\n super.connectedCallback();\n\n // Start the positioner after the first update\n await this.updateComplete;\n this.start();\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.stop();\n }\n\n async updated(changedProps: Map<string, unknown>) {\n super.updated(changedProps);\n\n // Start or stop the positioner when active changes\n if (changedProps.has('active')) {\n if (this.active) {\n this.start();\n } else {\n this.stop();\n }\n }\n\n // Update the anchor when anchor changes\n if (changedProps.has('anchor')) {\n this.handleAnchorChange();\n }\n\n // All other properties will trigger a reposition when active\n if (this.active) {\n await this.updateComplete;\n this.reposition();\n }\n }\n\n private async handleAnchorChange() {\n await this.stop();\n\n if (this.anchor && typeof this.anchor === 'string') {\n // Locate the anchor by id\n const root = this.getRootNode() as Document | ShadowRoot;\n this.anchorEl = root.getElementById(this.anchor);\n } else if (\n this.anchor instanceof Element ||\n isVirtualElement(this.anchor)\n ) {\n // Use the anchor's reference\n this.anchorEl = this.anchor;\n } else {\n // Look for a slotted anchor\n this.anchorEl = this.querySelector<HTMLElement>('[slot=\"anchor\"]');\n }\n\n // If the anchor is a <slot>, we'll use the first assigned element as the target since slots use `display: contents`\n // and positioning can't be calculated on them\n if (this.anchorEl instanceof HTMLSlotElement) {\n this.anchorEl = this.anchorEl.assignedElements({\n flatten: true,\n })[0] as HTMLElement;\n }\n\n // If the anchor is valid, start it up\n if (this.anchorEl && this.active) {\n this.start();\n }\n }\n\n private start() {\n // We can't start the positioner without an anchor\n if (!this.anchorEl) {\n return;\n }\n\n this.cleanup = autoUpdate(this.anchorEl, this.popup, () => {\n this.reposition();\n });\n }\n\n private async stop(): Promise<void> {\n return new Promise((resolve) => {\n if (this.cleanup) {\n this.cleanup();\n this.cleanup = undefined;\n this.removeAttribute('data-current-placement');\n this.style.removeProperty('--auto-size-available-width');\n this.style.removeProperty('--auto-size-available-height');\n requestAnimationFrame(() => resolve());\n } else {\n resolve();\n }\n });\n }\n\n /** Forces the popup to recalculate and reposition itself. */\n reposition() {\n // Nothing to do if the popup is inactive or the anchor doesn't exist\n if (!this.active || !this.anchorEl) {\n return;\n }\n\n //\n // NOTE: Floating UI middlewares are order dependent: https://floating-ui.com/docs/middleware\n //\n const middleware = [\n // The offset middleware goes first\n offset({ mainAxis: this.distance, crossAxis: this.skidding }),\n ];\n\n // First we sync width/height\n if (this.sync) {\n middleware.push(\n size({\n apply: ({ rects }) => {\n const syncWidth = this.sync === 'width' || this.sync === 'both';\n const syncHeight = this.sync === 'height' || this.sync === 'both';\n this.popup.style.width = syncWidth\n ? `${rects.reference.width}px`\n : '';\n this.popup.style.height = syncHeight\n ? `${rects.reference.height}px`\n : '';\n },\n })\n );\n } else {\n // Cleanup styles if we're not matching width/height\n this.popup.style.width = '';\n this.popup.style.height = '';\n }\n\n // Then we flip\n if (this.flip) {\n middleware.push(\n flip({\n boundary: this.flipBoundary,\n // @ts-expect-error - We're converting a string attribute to an array here\n fallbackPlacements: this.flipFallbackPlacements,\n fallbackStrategy:\n this.flipFallbackStrategy === 'best-fit'\n ? 'bestFit'\n : 'initialPlacement',\n padding: this.flipPadding,\n })\n );\n }\n\n // Then we shift\n if (this.shift) {\n middleware.push(\n shift({\n boundary: this.shiftBoundary,\n padding: this.shiftPadding,\n })\n );\n }\n\n // Now we adjust the size as needed\n if (this.autoSize) {\n middleware.push(\n size({\n boundary: this.autoSizeBoundary,\n padding: this.autoSizePadding,\n apply: ({ availableWidth, availableHeight }) => {\n if (this.autoSize === 'vertical' || this.autoSize === 'both') {\n this.style.setProperty(\n '--auto-size-available-height',\n `${availableHeight}px`\n );\n } else {\n this.style.removeProperty('--auto-size-available-height');\n }\n\n if (this.autoSize === 'horizontal' || this.autoSize === 'both') {\n this.style.setProperty(\n '--auto-size-available-width',\n `${availableWidth}px`\n );\n } else {\n this.style.removeProperty('--auto-size-available-width');\n }\n },\n })\n );\n } else {\n // Cleanup styles if we're no longer using auto-size\n this.style.removeProperty('--auto-size-available-width');\n this.style.removeProperty('--auto-size-available-height');\n }\n\n // Finally, we add an arrow\n if (this.arrow) {\n middleware.push(\n arrow({\n element: this.arrowEl,\n padding: this.arrowPadding,\n })\n );\n }\n\n //\n // Use custom positioning logic if the strategy is absolute. Otherwise, fall back to the default logic.\n //\n // More info: https://github.com/shoelace-style/shoelace/issues/1135\n //\n const getOffsetParent =\n this.strategy === 'absolute'\n ? (element: Element) => platform.getOffsetParent(element, offsetParent)\n : platform.getOffsetParent;\n\n computePosition(this.anchorEl, this.popup, {\n placement: this.placement,\n middleware,\n strategy: this.strategy,\n platform: {\n ...platform,\n getOffsetParent,\n },\n }).then(({ x, y, middlewareData, placement }) => {\n //\n // Even though we have our own localization utility, it uses different heuristics to determine RTL. Because of\n // that, we'll use the same approach that Floating UI uses.\n //\n // Source: https://github.com/floating-ui/floating-ui/blob/cb3b6ab07f95275730d3e6e46c702f8d4908b55c/packages/dom/src/utils/getDocumentRect.ts#L31\n //\n const isRtl = this.matches(':dir(rtl)');\n const staticSide = {\n top: 'bottom',\n right: 'left',\n bottom: 'top',\n left: 'right',\n }[placement.split('-')[0]]!;\n\n this.setAttribute('data-current-placement', placement);\n\n Object.assign(this.popup.style, {\n left: `${x}px`,\n top: `${y}px`,\n });\n\n if (this.arrow) {\n const arrowX = middlewareData.arrow!.x;\n const arrowY = middlewareData.arrow!.y;\n let top = '';\n let right = '';\n let bottom = '';\n let left = '';\n\n if (this.arrowPlacement === 'start') {\n // Start\n const value =\n typeof arrowX === 'number'\n ? `calc(${this.arrowPadding}px - var(--arrow-padding-offset))`\n : '';\n top =\n typeof arrowY === 'number'\n ? `calc(${this.arrowPadding}px - var(--arrow-padding-offset))`\n : '';\n right = isRtl ? value : '';\n left = isRtl ? '' : value;\n } else if (this.arrowPlacement === 'end') {\n // End\n const value =\n typeof arrowX === 'number'\n ? `calc(${this.arrowPadding}px - var(--arrow-padding-offset))`\n : '';\n right = isRtl ? '' : value;\n left = isRtl ? value : '';\n bottom =\n typeof arrowY === 'number'\n ? `calc(${this.arrowPadding}px - var(--arrow-padding-offset))`\n : '';\n } else if (this.arrowPlacement === 'center') {\n // Center\n left =\n typeof arrowX === 'number'\n ? `calc(50% - var(--arrow-size-diagonal))`\n : '';\n top =\n typeof arrowY === 'number'\n ? `calc(50% - var(--arrow-size-diagonal))`\n : '';\n } else {\n // Anchor (default)\n left = typeof arrowX === 'number' ? `${arrowX}px` : '';\n top = typeof arrowY === 'number' ? `${arrowY}px` : '';\n }\n\n Object.assign(this.arrowEl.style, {\n top,\n right,\n bottom,\n left,\n [staticSide]: 'calc(var(--arrow-size-diagonal) * -1)',\n });\n }\n });\n\n // Wait until the new position is drawn before updating the hover bridge, otherwise it can get out of sync\n requestAnimationFrame(() => this.updateHoverBridge());\n\n this.dispatchEvent(new Event('mid-reposition'));\n }\n\n private updateHoverBridge = () => {\n if (this.hoverBridge && this.anchorEl) {\n const anchorRect = this.anchorEl.getBoundingClientRect();\n const popupRect = this.popup.getBoundingClientRect();\n const isVertical =\n this.placement.includes('top') || this.placement.includes('bottom');\n let topLeftX = 0;\n let topLeftY = 0;\n let topRightX = 0;\n let topRightY = 0;\n let bottomLeftX = 0;\n let bottomLeftY = 0;\n let bottomRightX = 0;\n let bottomRightY = 0;\n\n if (isVertical) {\n if (anchorRect.top < popupRect.top) {\n // Anchor is above\n topLeftX = anchorRect.left;\n topLeftY = anchorRect.bottom;\n topRightX = anchorRect.right;\n topRightY = anchorRect.bottom;\n\n bottomLeftX = popupRect.left;\n bottomLeftY = popupRect.top;\n bottomRightX = popupRect.right;\n bottomRightY = popupRect.top;\n } else {\n // Anchor is below\n topLeftX = popupRect.left;\n topLeftY = popupRect.bottom;\n topRightX = popupRect.right;\n topRightY = popupRect.bottom;\n\n bottomLeftX = anchorRect.left;\n bottomLeftY = anchorRect.top;\n bottomRightX = anchorRect.right;\n bottomRightY = anchorRect.top;\n }\n } else {\n if (anchorRect.left < popupRect.left) {\n // Anchor is on the left\n topLeftX = anchorRect.right;\n topLeftY = anchorRect.top;\n topRightX = popupRect.left;\n topRightY = popupRect.top;\n\n bottomLeftX = anchorRect.right;\n bottomLeftY = anchorRect.bottom;\n bottomRightX = popupRect.left;\n bottomRightY = popupRect.bottom;\n } else {\n // Anchor is on the right\n topLeftX = popupRect.right;\n topLeftY = popupRect.top;\n topRightX = anchorRect.left;\n topRightY = anchorRect.top;\n\n bottomLeftX = popupRect.right;\n bottomLeftY = popupRect.bottom;\n bottomRightX = anchorRect.left;\n bottomRightY = anchorRect.bottom;\n }\n }\n\n this.style.setProperty('--hover-bridge-top-left-x', `${topLeftX}px`);\n this.style.setProperty('--hover-bridge-top-left-y', `${topLeftY}px`);\n this.style.setProperty('--hover-bridge-top-right-x', `${topRightX}px`);\n this.style.setProperty('--hover-bridge-top-right-y', `${topRightY}px`);\n this.style.setProperty(\n '--hover-bridge-bottom-left-x',\n `${bottomLeftX}px`\n );\n this.style.setProperty(\n '--hover-bridge-bottom-left-y',\n `${bottomLeftY}px`\n );\n this.style.setProperty(\n '--hover-bridge-bottom-right-x',\n `${bottomRightX}px`\n );\n this.style.setProperty(\n '--hover-bridge-bottom-right-y',\n `${bottomRightY}px`\n );\n }\n };\n\n render() {\n return html`\n <slot name=\"anchor\" @slotchange=${this.handleAnchorChange}></slot>\n\n <span\n part=\"hover-bridge\"\n class=${classMap({\n 'popup-hover-bridge': true,\n 'popup-hover-bridge--visible': this.hoverBridge && this.active,\n })}\n ></span>\n\n <div\n part=\"popup\"\n class=${classMap({\n popup: true,\n 'popup--active': this.active,\n 'popup--fixed': this.strategy === 'fixed',\n 'popup--has-arrow': this.arrow,\n })}\n >\n <slot></slot>\n ${this.arrow\n ? html`<div\n part=\"arrow\"\n class=\"popup__arrow\"\n role=\"presentation\"\n ></div>`\n : ''}\n </div>\n `;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAuCA,SAAS,iBAAiB,GAAiC;AACzD,SACE,MAAM,QACN,OAAO,MAAM,YACb,2BAA2B,MAC1B,oBAAoB,IAAI,aAAa,UAAU;AAEpD;AAEA,MAAM,SAAS;AAAA,EACb;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;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,MAAM,OAAA,CAAQ;AAAA,GAhLf,WAiLX,WAAA,oBAAA,CAAA;AAK4D,gBAAA;AAAA,EAA3D,SAAS,EAAE,WAAW,qBAAqB,MAAM,QAAQ;AAAA,GAtL/C,WAsLiD,WAAA,mBAAA,CAAA;AASJ,gBAAA;AAAA,EAAvD,SAAS,EAAE,WAAW,gBAAgB,MAAM,SAAS;AAAA,GA/L3C,WA+L6C,WAAA,eAAA,CAAA;AA/L7C,aAAN,gBAAA;AAAA,EADN,cAAc,WAAW;AAAA,GACb,UAAA;"}
|
|
1
|
+
{"version":3,"file":"popup.js","sources":["../../src/components/popup.component.ts"],"sourcesContent":["/*\n\nCopyright (c) 2020 A Beautiful Site, LLC\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n*/\n\nimport {\n arrow,\n autoUpdate,\n computePosition,\n flip,\n offset,\n platform,\n shift,\n size,\n} from '@floating-ui/dom';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { css, html, LitElement } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { styled } from '../mixins/tailwind.mixin';\nimport { offsetParent } from 'composed-offset-position';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-popup': MinidPopup;\n }\n}\n\nexport interface VirtualElement {\n getBoundingClientRect: () => DOMRect;\n contextElement?: Element;\n}\n\nfunction isVirtualElement(e: unknown): e is VirtualElement {\n return (\n e !== null &&\n typeof e === 'object' &&\n 'getBoundingClientRect' in e &&\n ('contextElement' in e ? e instanceof Element : true)\n );\n}\n\nconst styles = [\n css`\n :host {\n --arrow-color: white;\n --arrow-border-color: transparent;\n --arrow-size: 6px;\n\n /*\n These properties are computed to account for the arrow's dimensions after being rotated 45º. The constant\n 0.7071 is derived from sin(45), which is the diagonal size of the arrow's container after rotating.\n */\n --arrow-size-diagonal: calc(var(--arrow-size) * 0.7071);\n --arrow-padding-offset: calc(\n var(--arrow-size-diagonal) - var(--arrow-size)\n );\n\n display: contents;\n }\n\n .popup {\n position: absolute;\n isolation: isolate;\n max-width: var(--auto-size-available-width, none);\n max-height: var(--auto-size-available-height, none);\n z-index: 900;\n }\n\n .popup--fixed {\n position: fixed;\n }\n\n .popup:not(.popup--active) {\n display: none;\n }\n\n .popup__arrow {\n position: absolute;\n width: calc(var(--arrow-size-diagonal) * 2);\n height: calc(var(--arrow-size-diagonal) * 2);\n border: 1px solid var(--arrow-border-color);\n border-left-color: transparent;\n border-top-color: transparent;\n rotate: 45deg;\n background: var(--arrow-color);\n z-index: 901;\n }\n\n /* Hover bridge */\n .popup-hover-bridge:not(.popup-hover-bridge--visible) {\n display: none;\n }\n\n .popup-hover-bridge {\n position: fixed;\n z-index: calc(900 - 1);\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n clip-path: polygon(\n var(--hover-bridge-top-left-x, 0) var(--hover-bridge-top-left-y, 0),\n var(--hover-bridge-top-right-x, 0) var(--hover-bridge-top-right-y, 0),\n var(--hover-bridge-bottom-right-x, 0)\n var(--hover-bridge-bottom-right-y, 0),\n var(--hover-bridge-bottom-left-x, 0)\n var(--hover-bridge-bottom-left-y, 0)\n );\n }\n\n :host([data-current-placement^='top']) .popup {\n transform-origin: bottom;\n }\n\n :host([data-current-placement^='bottom']) .popup {\n transform-origin: top;\n }\n\n :host([data-current-placement^='left']) .popup {\n transform-origin: right;\n }\n\n :host([data-current-placement^='right']) .popup {\n transform-origin: left;\n }\n\n :host([data-current-placement^='top']) .popup__arrow {\n transform: rotate(0deg);\n }\n\n :host([data-current-placement^='bottom']) .popup__arrow {\n transform: rotate(180deg);\n }\n\n :host([data-current-placement^='left']) .popup__arrow {\n transform: rotate(-90deg);\n }\n\n :host([data-current-placement^='right']) .popup__arrow {\n transform: rotate(90deg);\n }\n `,\n];\n\n/**\n * @summary Popup is a utility that lets you declaratively anchor \"popup\" containers to another element.\n * @documentation https://shoelace.style/components/popup\n * @status stable\n * @since 2.0\n *\n * @event mid-reposition - Emitted when the popup is repositioned. This event can fire a lot, so avoid putting expensive\n * operations in your listener or consider debouncing it.\n *\n * @slot - The popup's content.\n * @slot anchor - The element the popup will be anchored to. If the anchor lives outside of the popup, you can use the\n * `anchor` attribute or property instead.\n *\n * @csspart arrow - The arrow's container. Avoid setting `top|bottom|left|right` properties, as these values are\n * assigned dynamically as the popup moves. This is most useful for applying a background color to match the popup, and\n * maybe a border or box shadow.\n * @csspart popup - The popup's container. Useful for setting a background color, box shadow, etc.\n * @csspart hover-bridge - The hover bridge element. Only available when the `hover-bridge` option is enabled.\n *\n * @cssproperty [--arrow-size=6px] - The size of the arrow. Note that an arrow won't be shown unless the `arrow`\n * attribute is used.\n * @cssproperty [--arrow-color=white] - The color of the arrow.\n * @cssproperty [--arrow-border-color=transparent] - The color for the arrow border\n * @cssproperty [--auto-size-available-width] - A read-only custom property that determines the amount of width the\n * popup can be before overflowing. Useful for positioning child elements that need to overflow. This property is only\n * available when using `auto-size`.\n * @cssproperty [--auto-size-available-height] - A read-only custom property that determines the amount of height the\n * popup can be before overflowing. Useful for positioning child elements that need to overflow. This property is only\n * available when using `auto-size`.\n */\n\n@customElement('mid-popup')\nexport class MinidPopup extends styled(LitElement, styles) {\n private anchorEl: Element | VirtualElement | null = null;\n private cleanup?: ReturnType<typeof autoUpdate>;\n\n /**\n * A reference to the internal popup container. Useful for animating and styling the popup with JavaScript.\n */\n @query('.popup')\n popup!: HTMLElement;\n\n @query('.popup__arrow')\n private arrowEl!: HTMLElement;\n\n /**\n * The element the popup will be anchored to. If the anchor lives outside of the popup, you can provide the anchor\n * element `id`, a DOM element reference, or a `VirtualElement`. If the anchor lives inside the popup, use the\n * `anchor` slot instead.\n */\n @property()\n anchor: Element | string | VirtualElement = '';\n\n /**\n * Activates the positioning logic and shows the popup. When this attribute is removed, the positioning logic is torn\n * down and the popup will be hidden.\n */\n @property({ type: Boolean, reflect: true })\n active = false;\n\n /**\n * The preferred placement of the popup. Note that the actual placement will vary as configured to keep the\n * panel inside of the viewport.\n */\n @property({ reflect: true })\n placement:\n | 'top'\n | 'top-start'\n | 'top-end'\n | 'bottom'\n | 'bottom-start'\n | 'bottom-end'\n | 'right'\n | 'right-start'\n | 'right-end'\n | 'left'\n | 'left-start'\n | 'left-end' = 'top';\n\n /**\n * Determines how the popup is positioned. The `absolute` strategy works well in most cases, but if overflow is\n * clipped, using a `fixed` position strategy can often workaround it.\n */\n @property({ reflect: true })\n strategy: 'absolute' | 'fixed' = 'absolute';\n\n /**\n * The distance in pixels from which to offset the panel away from its anchor.\n */\n @property({ type: Number })\n distance = 0;\n\n /**\n * The distance in pixels from which to offset the panel along its anchor.\n */\n @property({ type: Number })\n skidding = 0;\n\n /**\n * Attaches an arrow to the popup. The arrow's size and color can be customized using the `--arrow-size` and\n * `--arrow-color` custom properties. For additional customizations, you can also target the arrow using\n * `::part(arrow)` in your stylesheet.\n */\n @property({ type: Boolean })\n arrow = false;\n\n /**\n * The placement of the arrow. The default is `anchor`, which will align the arrow as close to the center of the\n * anchor as possible, considering available space and `arrow-padding`. A value of `start`, `end`, or `center` will\n * align the arrow to the start, end, or center of the popover instead.\n */\n @property({ attribute: 'arrow-placement' })\n arrowPlacement: 'start' | 'end' | 'center' | 'anchor' = 'anchor';\n\n /**\n * The amount of padding between the arrow and the edges of the popup. If the popup has a border-radius, for example,\n * this will prevent it from overflowing the corners.\n */\n @property({ attribute: 'arrow-padding', type: Number })\n arrowPadding = 10;\n\n /**\n * When set, placement of the popup will flip to the opposite site to keep it in view. You can use\n * `flipFallbackPlacements` to further configure how the fallback placement is determined.\n */\n @property({ type: Boolean })\n flip = false;\n\n /**\n * If the preferred placement doesn't fit, popup will be tested in these fallback placements until one fits. Must be a\n * string of any number of placements separated by a space, e.g. \"top bottom left\". If no placement fits, the flip\n * fallback strategy will be used instead.\n */\n @property({\n attribute: 'flip-fallback-placements',\n converter: {\n fromAttribute: (value: string) => {\n return value\n .split(' ')\n .map((p) => p.trim())\n .filter((p) => p !== '');\n },\n toAttribute: (value: []) => {\n return value.join(' ');\n },\n },\n })\n flipFallbackPlacements = '';\n\n /**\n * When neither the preferred placement nor the fallback placements fit, this value will be used to determine whether\n * the popup should be positioned using the best available fit based on available space or as it was initially\n * preferred.\n */\n @property({ attribute: 'flip-fallback-strategy' })\n flipFallbackStrategy: 'best-fit' | 'initial' = 'best-fit';\n\n /**\n * The flip boundary describes clipping element(s) that overflow will be checked relative to when flipping. By\n * default, the boundary includes overflow ancestors that will cause the element to be clipped. If needed, you can\n * change the boundary by passing a reference to one or more elements to this property.\n */\n @property({ type: Object })\n flipBoundary?: Element | Element[];\n\n /**\n * The amount of padding, in pixels, to exceed before the flip behavior will occur.\n */\n @property({ attribute: 'flip-padding', type: Number })\n flipPadding = 0;\n\n /**\n * Moves the popup along the axis to keep it in view when clipped.\n */\n @property({ type: Boolean })\n shift = false;\n\n /**\n * The shift boundary describes clipping element(s) that overflow will be checked relative to when shifting. By\n * default, the boundary includes overflow ancestors that will cause the element to be clipped. If needed, you can\n * change the boundary by passing a reference to one or more elements to this property.\n */\n @property({ type: Object })\n shiftBoundary?: Element | Element[];\n\n /**\n * The amount of padding, in pixels, to exceed before the shift behavior will occur.\n */\n @property({ attribute: 'shift-padding', type: Number })\n shiftPadding = 0;\n\n /** When set, this will cause the popup to automatically resize itself to prevent it from overflowing. */\n @property({ attribute: 'auto-size' }) autoSize?:\n | 'horizontal'\n | 'vertical'\n | 'both';\n\n /**\n * Syncs the popup's width or height to that of the anchor element.\n */\n @property()\n sync?: 'width' | 'height' | 'both';\n\n /**\n * The auto-size boundary describes clipping element(s) that overflow will be checked relative to when resizing. By\n * default, the boundary includes overflow ancestors that will cause the element to be clipped. If needed, you can\n * change the boundary by passing a reference to one or more elements to this property.\n */\n @property({ type: Object })\n autoSizeBoundary?: Element | Element[];\n\n /**\n * The amount of padding, in pixels, to exceed before the auto-size behavior will occur.\n */\n @property({ attribute: 'auto-size-padding', type: Number }) autoSizePadding =\n 0;\n\n /**\n * When a gap exists between the anchor and the popup element, this option will add a \"hover bridge\" that fills the\n * gap using an invisible element. This makes listening for events such as `mouseenter` and `mouseleave` more sane\n * because the pointer never technically leaves the element. The hover bridge will only be drawn when the popover is\n * active.\n */\n @property({ attribute: 'hover-bridge', type: Boolean }) hoverBridge = false;\n\n async connectedCallback() {\n super.connectedCallback();\n\n // Start the positioner after the first update\n await this.updateComplete;\n this.start();\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.stop();\n }\n\n async updated(changedProps: Map<string, unknown>) {\n super.updated(changedProps);\n\n // Start or stop the positioner when active changes\n if (changedProps.has('active')) {\n if (this.active) {\n this.start();\n } else {\n this.stop();\n }\n }\n\n // Update the anchor when anchor changes\n if (changedProps.has('anchor')) {\n this.handleAnchorChange();\n }\n\n // All other properties will trigger a reposition when active\n if (this.active) {\n await this.updateComplete;\n this.reposition();\n }\n }\n\n private async handleAnchorChange() {\n await this.stop();\n\n if (this.anchor && typeof this.anchor === 'string') {\n // Locate the anchor by id\n const root = this.getRootNode() as Document | ShadowRoot;\n this.anchorEl = root.getElementById(this.anchor);\n } else if (\n this.anchor instanceof Element ||\n isVirtualElement(this.anchor)\n ) {\n // Use the anchor's reference\n this.anchorEl = this.anchor;\n } else {\n // Look for a slotted anchor\n this.anchorEl = this.querySelector<HTMLElement>('[slot=\"anchor\"]');\n }\n\n // If the anchor is a <slot>, we'll use the first assigned element as the target since slots use `display: contents`\n // and positioning can't be calculated on them\n if (this.anchorEl instanceof HTMLSlotElement) {\n this.anchorEl = this.anchorEl.assignedElements({\n flatten: true,\n })[0] as HTMLElement;\n }\n\n // If the anchor is valid, start it up\n if (this.anchorEl && this.active) {\n this.start();\n }\n }\n\n private start() {\n // We can't start the positioner without an anchor\n if (!this.anchorEl) {\n return;\n }\n\n this.cleanup = autoUpdate(this.anchorEl, this.popup, () => {\n this.reposition();\n });\n }\n\n private async stop(): Promise<void> {\n return new Promise((resolve) => {\n if (this.cleanup) {\n this.cleanup();\n this.cleanup = undefined;\n this.removeAttribute('data-current-placement');\n this.style.removeProperty('--auto-size-available-width');\n this.style.removeProperty('--auto-size-available-height');\n requestAnimationFrame(() => resolve());\n } else {\n resolve();\n }\n });\n }\n\n /** Forces the popup to recalculate and reposition itself. */\n reposition() {\n // Nothing to do if the popup is inactive or the anchor doesn't exist\n if (!this.active || !this.anchorEl) {\n return;\n }\n\n //\n // NOTE: Floating UI middlewares are order dependent: https://floating-ui.com/docs/middleware\n //\n const middleware = [\n // The offset middleware goes first\n offset({ mainAxis: this.distance, crossAxis: this.skidding }),\n ];\n\n // First we sync width/height\n if (this.sync) {\n middleware.push(\n size({\n apply: ({ rects }) => {\n const syncWidth = this.sync === 'width' || this.sync === 'both';\n const syncHeight = this.sync === 'height' || this.sync === 'both';\n this.popup.style.width = syncWidth\n ? `${rects.reference.width}px`\n : '';\n this.popup.style.height = syncHeight\n ? `${rects.reference.height}px`\n : '';\n },\n })\n );\n } else {\n // Cleanup styles if we're not matching width/height\n this.popup.style.width = '';\n this.popup.style.height = '';\n }\n\n // Then we flip\n if (this.flip) {\n middleware.push(\n flip({\n boundary: this.flipBoundary,\n // @ts-expect-error - We're converting a string attribute to an array here\n fallbackPlacements: this.flipFallbackPlacements,\n fallbackStrategy:\n this.flipFallbackStrategy === 'best-fit'\n ? 'bestFit'\n : 'initialPlacement',\n padding: this.flipPadding,\n })\n );\n }\n\n // Then we shift\n if (this.shift) {\n middleware.push(\n shift({\n boundary: this.shiftBoundary,\n padding: this.shiftPadding,\n })\n );\n }\n\n // Now we adjust the size as needed\n if (this.autoSize) {\n middleware.push(\n size({\n boundary: this.autoSizeBoundary,\n padding: this.autoSizePadding,\n apply: ({ availableWidth, availableHeight }) => {\n if (this.autoSize === 'vertical' || this.autoSize === 'both') {\n this.style.setProperty(\n '--auto-size-available-height',\n `${availableHeight}px`\n );\n } else {\n this.style.removeProperty('--auto-size-available-height');\n }\n\n if (this.autoSize === 'horizontal' || this.autoSize === 'both') {\n this.style.setProperty(\n '--auto-size-available-width',\n `${availableWidth}px`\n );\n } else {\n this.style.removeProperty('--auto-size-available-width');\n }\n },\n })\n );\n } else {\n // Cleanup styles if we're no longer using auto-size\n this.style.removeProperty('--auto-size-available-width');\n this.style.removeProperty('--auto-size-available-height');\n }\n\n // Finally, we add an arrow\n if (this.arrow) {\n middleware.push(\n arrow({\n element: this.arrowEl,\n padding: this.arrowPadding,\n })\n );\n }\n\n //\n // Use custom positioning logic if the strategy is absolute. Otherwise, fall back to the default logic.\n //\n // More info: https://github.com/shoelace-style/shoelace/issues/1135\n //\n const getOffsetParent =\n this.strategy === 'absolute'\n ? (element: Element) => platform.getOffsetParent(element, offsetParent)\n : platform.getOffsetParent;\n\n computePosition(this.anchorEl, this.popup, {\n placement: this.placement,\n middleware,\n strategy: this.strategy,\n platform: {\n ...platform,\n getOffsetParent,\n },\n }).then(({ x, y, middlewareData, placement }) => {\n //\n // Even though we have our own localization utility, it uses different heuristics to determine RTL. Because of\n // that, we'll use the same approach that Floating UI uses.\n //\n // Source: https://github.com/floating-ui/floating-ui/blob/cb3b6ab07f95275730d3e6e46c702f8d4908b55c/packages/dom/src/utils/getDocumentRect.ts#L31\n //\n const isRtl = this.matches(':dir(rtl)');\n const staticSide = {\n top: 'bottom',\n right: 'left',\n bottom: 'top',\n left: 'right',\n }[placement.split('-')[0]]!;\n\n this.setAttribute('data-current-placement', placement);\n\n Object.assign(this.popup.style, {\n left: `${x}px`,\n top: `${y}px`,\n });\n\n if (this.arrow) {\n const arrowX = middlewareData.arrow!.x;\n const arrowY = middlewareData.arrow!.y;\n let top = '';\n let right = '';\n let bottom = '';\n let left = '';\n\n if (this.arrowPlacement === 'start') {\n // Start\n const value =\n typeof arrowX === 'number'\n ? `calc(${this.arrowPadding}px - var(--arrow-padding-offset))`\n : '';\n top =\n typeof arrowY === 'number'\n ? `calc(${this.arrowPadding}px - var(--arrow-padding-offset))`\n : '';\n right = isRtl ? value : '';\n left = isRtl ? '' : value;\n } else if (this.arrowPlacement === 'end') {\n // End\n const value =\n typeof arrowX === 'number'\n ? `calc(${this.arrowPadding}px - var(--arrow-padding-offset))`\n : '';\n right = isRtl ? '' : value;\n left = isRtl ? value : '';\n bottom =\n typeof arrowY === 'number'\n ? `calc(${this.arrowPadding}px - var(--arrow-padding-offset))`\n : '';\n } else if (this.arrowPlacement === 'center') {\n // Center\n left =\n typeof arrowX === 'number'\n ? `calc(50% - var(--arrow-size-diagonal))`\n : '';\n top =\n typeof arrowY === 'number'\n ? `calc(50% - var(--arrow-size-diagonal))`\n : '';\n } else {\n // Anchor (default)\n left = typeof arrowX === 'number' ? `${arrowX}px` : '';\n top = typeof arrowY === 'number' ? `${arrowY}px` : '';\n }\n\n Object.assign(this.arrowEl.style, {\n top,\n right,\n bottom,\n left,\n [staticSide]: 'calc(var(--arrow-size-diagonal) * -1)',\n });\n }\n });\n\n // Wait until the new position is drawn before updating the hover bridge, otherwise it can get out of sync\n requestAnimationFrame(() => this.updateHoverBridge());\n\n this.dispatchEvent(new Event('mid-reposition'));\n }\n\n private updateHoverBridge = () => {\n if (this.hoverBridge && this.anchorEl) {\n const anchorRect = this.anchorEl.getBoundingClientRect();\n const popupRect = this.popup.getBoundingClientRect();\n const isVertical =\n this.placement.includes('top') || this.placement.includes('bottom');\n let topLeftX = 0;\n let topLeftY = 0;\n let topRightX = 0;\n let topRightY = 0;\n let bottomLeftX = 0;\n let bottomLeftY = 0;\n let bottomRightX = 0;\n let bottomRightY = 0;\n\n if (isVertical) {\n if (anchorRect.top < popupRect.top) {\n // Anchor is above\n topLeftX = anchorRect.left;\n topLeftY = anchorRect.bottom;\n topRightX = anchorRect.right;\n topRightY = anchorRect.bottom;\n\n bottomLeftX = popupRect.left;\n bottomLeftY = popupRect.top;\n bottomRightX = popupRect.right;\n bottomRightY = popupRect.top;\n } else {\n // Anchor is below\n topLeftX = popupRect.left;\n topLeftY = popupRect.bottom;\n topRightX = popupRect.right;\n topRightY = popupRect.bottom;\n\n bottomLeftX = anchorRect.left;\n bottomLeftY = anchorRect.top;\n bottomRightX = anchorRect.right;\n bottomRightY = anchorRect.top;\n }\n } else {\n if (anchorRect.left < popupRect.left) {\n // Anchor is on the left\n topLeftX = anchorRect.right;\n topLeftY = anchorRect.top;\n topRightX = popupRect.left;\n topRightY = popupRect.top;\n\n bottomLeftX = anchorRect.right;\n bottomLeftY = anchorRect.bottom;\n bottomRightX = popupRect.left;\n bottomRightY = popupRect.bottom;\n } else {\n // Anchor is on the right\n topLeftX = popupRect.right;\n topLeftY = popupRect.top;\n topRightX = anchorRect.left;\n topRightY = anchorRect.top;\n\n bottomLeftX = popupRect.right;\n bottomLeftY = popupRect.bottom;\n bottomRightX = anchorRect.left;\n bottomRightY = anchorRect.bottom;\n }\n }\n\n this.style.setProperty('--hover-bridge-top-left-x', `${topLeftX}px`);\n this.style.setProperty('--hover-bridge-top-left-y', `${topLeftY}px`);\n this.style.setProperty('--hover-bridge-top-right-x', `${topRightX}px`);\n this.style.setProperty('--hover-bridge-top-right-y', `${topRightY}px`);\n this.style.setProperty(\n '--hover-bridge-bottom-left-x',\n `${bottomLeftX}px`\n );\n this.style.setProperty(\n '--hover-bridge-bottom-left-y',\n `${bottomLeftY}px`\n );\n this.style.setProperty(\n '--hover-bridge-bottom-right-x',\n `${bottomRightX}px`\n );\n this.style.setProperty(\n '--hover-bridge-bottom-right-y',\n `${bottomRightY}px`\n );\n }\n };\n\n render() {\n return html`\n <slot name=\"anchor\" @slotchange=${this.handleAnchorChange}></slot>\n\n <span\n part=\"hover-bridge\"\n class=${classMap({\n 'popup-hover-bridge': true,\n 'popup-hover-bridge--visible': this.hoverBridge && this.active,\n })}\n ></span>\n\n <div\n part=\"popup\"\n class=${classMap({\n popup: true,\n 'popup--active': this.active,\n 'popup--fixed': this.strategy === 'fixed',\n 'popup--has-arrow': this.arrow,\n })}\n >\n <slot></slot>\n ${this.arrow\n ? html`<div\n part=\"arrow\"\n class=\"popup__arrow\"\n role=\"presentation\"\n ></div>`\n : ''}\n </div>\n `;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAuCA,SAAS,iBAAiB,GAAiC;AACzD,SACE,MAAM,QACN,OAAO,MAAM,YACb,2BAA2B,MAC1B,oBAAoB,IAAI,aAAa,UAAU;AAEpD;AAEA,MAAM,SAAS;AAAA,EACb;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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AAQ;AAAA,GAhLf,WAiLX,WAAA,oBAAA,CAAA;AAK4D,gBAAA;AAAA,EAA3D,SAAS,EAAE,WAAW,qBAAqB,MAAM,QAAQ;AAAA,GAtL/C,WAsLiD,WAAA,mBAAA,CAAA;AASJ,gBAAA;AAAA,EAAvD,SAAS,EAAE,WAAW,gBAAgB,MAAM,SAAS;AAAA,GA/L3C,WA+L6C,WAAA,eAAA,CAAA;AA/L7C,aAAN,gBAAA;AAAA,EADN,cAAc,WAAW;AAAA,GACb,UAAA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qr-code.js","sources":["../../src/components/qr-code.component.ts"],"sourcesContent":["import { html, LitElement } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { styled } from '../mixins/tailwind.mixin';\nimport QRCode from 'qrcode';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-qr-code': MinidQrCode;\n }\n}\n\n@customElement('mid-qr-code')\nexport class MinidQrCode extends styled(LitElement) {\n @query('#qr-code')\n private canvas!: HTMLCanvasElement;\n\n /**\n * Text to encode\n */\n @property()\n content = '';\n\n /**\n * The label for assistive devices to announce. If unspecified, the content will be used instead.\n */\n @property()\n label = '';\n\n /**\n * Scale factor. A value of 1 means 1px per modules (black dots).\n */\n @property({ type: Number })\n scale = 4;\n\n /**\n * Forces a specific width for the output image.\n * If width is too small to contain the qr symbol, this option will be ignored.\n * Takes precedence over scale.\n */\n @property({ type: Number })\n width?: number;\n\n /**\n * The color of the QR pattern. Needs to be in hex format\n */\n @property()\n fill = '#000';\n\n /**\n * The color of the background. Needs to be in hex format\n */\n @property()\n background = '#fff';\n\n @property({ type: Number })\n margin = 4;\n\n protected updated() {\n QRCode.toCanvas(this.canvas, this.content, {\n scale: this.scale,\n color: { dark: this.fill, light: this.background },\n margin: this.margin,\n width: this.width,\n });\n }\n\n override render() {\n return html`\n <canvas\n aria-label=\"${this.label.length ? this.label : this.content}\"\n role=\"img\"\n id=\"qr-code\"\n ></canvas>\n `;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAYO,IAAM,cAAN,cAA0B,OAAO,UAAU,EAAE;AAAA,EAA7C,cAAA;AAAA,UAAA,GAAA,SAAA;AAQL,SAAA,UAAU;AAMV,SAAA,QAAQ;AAMR,SAAA,QAAQ;AAcR,SAAA,OAAO;AAMP,SAAA,aAAa;AAGb,SAAA,SAAS;AAAA,EAAA;AAAA,EAEC,UAAU;AAClB,WAAO,SAAS,KAAK,QAAQ,KAAK,SAAS;AAAA,MACzC,OAAO,KAAK;AAAA,MACZ,OAAO,EAAE,MAAM,KAAK,MAAM,OAAO,KAAK,WAAA;AAAA,MACtC,QAAQ,KAAK;AAAA,MACb,OAAO,KAAK;AAAA,IAAA,CACb;AAAA,
|
|
1
|
+
{"version":3,"file":"qr-code.js","sources":["../../src/components/qr-code.component.ts"],"sourcesContent":["import { html, LitElement } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { styled } from '../mixins/tailwind.mixin';\nimport QRCode from 'qrcode';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-qr-code': MinidQrCode;\n }\n}\n\n@customElement('mid-qr-code')\nexport class MinidQrCode extends styled(LitElement) {\n @query('#qr-code')\n private canvas!: HTMLCanvasElement;\n\n /**\n * Text to encode\n */\n @property()\n content = '';\n\n /**\n * The label for assistive devices to announce. If unspecified, the content will be used instead.\n */\n @property()\n label = '';\n\n /**\n * Scale factor. A value of 1 means 1px per modules (black dots).\n */\n @property({ type: Number })\n scale = 4;\n\n /**\n * Forces a specific width for the output image.\n * If width is too small to contain the qr symbol, this option will be ignored.\n * Takes precedence over scale.\n */\n @property({ type: Number })\n width?: number;\n\n /**\n * The color of the QR pattern. Needs to be in hex format\n */\n @property()\n fill = '#000';\n\n /**\n * The color of the background. Needs to be in hex format\n */\n @property()\n background = '#fff';\n\n @property({ type: Number })\n margin = 4;\n\n protected updated() {\n QRCode.toCanvas(this.canvas, this.content, {\n scale: this.scale,\n color: { dark: this.fill, light: this.background },\n margin: this.margin,\n width: this.width,\n });\n }\n\n override render() {\n return html`\n <canvas\n aria-label=\"${this.label.length ? this.label : this.content}\"\n role=\"img\"\n id=\"qr-code\"\n ></canvas>\n `;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAYO,IAAM,cAAN,cAA0B,OAAO,UAAU,EAAE;AAAA,EAA7C,cAAA;AAAA,UAAA,GAAA,SAAA;AAQL,SAAA,UAAU;AAMV,SAAA,QAAQ;AAMR,SAAA,QAAQ;AAcR,SAAA,OAAO;AAMP,SAAA,aAAa;AAGb,SAAA,SAAS;AAAA,EAAA;AAAA,EAEC,UAAU;AAClB,WAAO,SAAS,KAAK,QAAQ,KAAK,SAAS;AAAA,MACzC,OAAO,KAAK;AAAA,MACZ,OAAO,EAAE,MAAM,KAAK,MAAM,OAAO,KAAK,WAAA;AAAA,MACtC,QAAQ,KAAK;AAAA,MACb,OAAO,KAAK;AAAA,IAAA,CACb;AAAA,EACH;AAAA,EAES,SAAS;AAChB,WAAO;AAAA;AAAA,sBAEW,KAAK,MAAM,SAAS,KAAK,QAAQ,KAAK,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKjE;AACF;AA7DU,gBAAA;AAAA,EADP,MAAM,UAAU;AAAA,GADN,YAEH,WAAA,UAAA,CAAA;AAMR,gBAAA;AAAA,EADC,SAAA;AAAS,GAPC,YAQX,WAAA,WAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAA;AAAS,GAbC,YAcX,WAAA,SAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAnBf,YAoBX,WAAA,SAAA,CAAA;AAQA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA3Bf,YA4BX,WAAA,SAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAA;AAAS,GAjCC,YAkCX,WAAA,QAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAA;AAAS,GAvCC,YAwCX,WAAA,cAAA,CAAA;AAGA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA1Cf,YA2CX,WAAA,UAAA,CAAA;AA3CW,cAAN,gBAAA;AAAA,EADN,cAAc,aAAa;AAAA,GACf,WAAA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio-button.js","sources":["../../src/components/radio-button.component.ts"],"sourcesContent":["import { html, LitElement } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { watch } from '../internal/watch';\nimport { styled } from '../mixins/tailwind.mixin';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-radio-button': MinidRadioButton;\n }\n}\n\n/**\n *\n * @slot -- The radio button's label.\n *\n * @event mid-blur - Emitted when the button loses focus.\n * @event mid-focus - Emitted when the button gains focus.\n *\n * @csspart button - Select the internal button element\n */\n@customElement('mid-radio-button')\nexport class MinidRadioButton extends styled(LitElement) {\n @query('.radio')\n element!: HTMLButtonElement;\n\n @property()\n name = 'option';\n\n /**\n * The radio button's checked state.\n */\n @property({ type: Boolean, reflect: true })\n checked = false;\n\n /**\n * The radio's value. When selected, the radio group will receive this value.\n */\n @property()\n value: string | null = null;\n\n /**\n * Disables the radio button.\n */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n /**\n * The radio button's size. When used inside a radio group, the size will be determined by the radio group's size so\n * this attribute can typically be omitted.\n */\n @property({ reflect: true })\n size: 'sm' | 'md' | 'lg' = 'md';\n\n private handleBlur() {\n this.dispatchEvent(\n new Event('mid-blur', { composed: true, bubbles: true })\n );\n }\n\n private handleFocus() {\n this.dispatchEvent(\n new Event('mid-focus', { composed: true, bubbles: true })\n );\n }\n\n private handleClick(event: MouseEvent) {\n if (this.disabled) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n\n this.checked = true;\n }\n\n @watch('disabled', { waitUntilFirstUpdate: true })\n handleDisabledChange() {\n this.setAttribute('aria-disabled', this.disabled ? 'true' : 'false');\n }\n\n /**\n * Sets focus on the radio button.\n */\n focus(options?: FocusOptions) {\n this.element.focus(options);\n }\n\n /**\n * Removes focus from the radio button.\n */\n blur() {\n this.element.blur();\n }\n\n override render() {\n return html`<button\n role=\"radio\"\n type=\"button\"\n part=\"button\"\n name=${this.name}\n value=${ifDefined(this.value ?? undefined)}\n class=\"${classMap({\n radio: true,\n 'whitespace-nowrap': true,\n 'fds-togglegroup__item': true,\n 'fds-btn': true,\n 'fds-focus': true,\n 'fds-btn--first': true,\n 'fds-btn--full-width': true,\n 'fds-btn--primary': this.checked,\n 'fds-btn--tertiary': !this.checked,\n 'fds-btn--sm': this.size === 'sm',\n 'fds-btn--md': this.size === 'md',\n 'fds-btn--lg': this.size === 'lg',\n })}\"\n aria-checked=${this.checked}\n ?disabled=${this.disabled}\n @blur=${this.handleBlur}\n @focus=${this.handleFocus}\n @click=${this.handleClick}\n >\n <slot></slot>\n </button> `;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAuBO,IAAM,mBAAN,cAA+B,OAAO,UAAU,EAAE;AAAA,EAAlD,cAAA;AAAA,UAAA,GAAA,SAAA;AAKL,SAAA,OAAO;AAMP,SAAA,UAAU;AAMV,SAAA,QAAuB;AAMvB,SAAA,WAAW;AAOX,SAAA,OAA2B;AAAA,EAAA;AAAA,EAEnB,aAAa;AACnB,SAAK;AAAA,MACH,IAAI,MAAM,YAAY,EAAE,UAAU,MAAM,SAAS,MAAM;AAAA,IAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"radio-button.js","sources":["../../src/components/radio-button.component.ts"],"sourcesContent":["import { html, LitElement } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { watch } from '../internal/watch';\nimport { styled } from '../mixins/tailwind.mixin';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-radio-button': MinidRadioButton;\n }\n}\n\n/**\n *\n * @slot -- The radio button's label.\n *\n * @event mid-blur - Emitted when the button loses focus.\n * @event mid-focus - Emitted when the button gains focus.\n *\n * @csspart button - Select the internal button element\n */\n@customElement('mid-radio-button')\nexport class MinidRadioButton extends styled(LitElement) {\n @query('.radio')\n element!: HTMLButtonElement;\n\n @property()\n name = 'option';\n\n /**\n * The radio button's checked state.\n */\n @property({ type: Boolean, reflect: true })\n checked = false;\n\n /**\n * The radio's value. When selected, the radio group will receive this value.\n */\n @property()\n value: string | null = null;\n\n /**\n * Disables the radio button.\n */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n /**\n * The radio button's size. When used inside a radio group, the size will be determined by the radio group's size so\n * this attribute can typically be omitted.\n */\n @property({ reflect: true })\n size: 'sm' | 'md' | 'lg' = 'md';\n\n private handleBlur() {\n this.dispatchEvent(\n new Event('mid-blur', { composed: true, bubbles: true })\n );\n }\n\n private handleFocus() {\n this.dispatchEvent(\n new Event('mid-focus', { composed: true, bubbles: true })\n );\n }\n\n private handleClick(event: MouseEvent) {\n if (this.disabled) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n\n this.checked = true;\n }\n\n @watch('disabled', { waitUntilFirstUpdate: true })\n handleDisabledChange() {\n this.setAttribute('aria-disabled', this.disabled ? 'true' : 'false');\n }\n\n /**\n * Sets focus on the radio button.\n */\n focus(options?: FocusOptions) {\n this.element.focus(options);\n }\n\n /**\n * Removes focus from the radio button.\n */\n blur() {\n this.element.blur();\n }\n\n override render() {\n return html`<button\n role=\"radio\"\n type=\"button\"\n part=\"button\"\n name=${this.name}\n value=${ifDefined(this.value ?? undefined)}\n class=\"${classMap({\n radio: true,\n 'whitespace-nowrap': true,\n 'fds-togglegroup__item': true,\n 'fds-btn': true,\n 'fds-focus': true,\n 'fds-btn--first': true,\n 'fds-btn--full-width': true,\n 'fds-btn--primary': this.checked,\n 'fds-btn--tertiary': !this.checked,\n 'fds-btn--sm': this.size === 'sm',\n 'fds-btn--md': this.size === 'md',\n 'fds-btn--lg': this.size === 'lg',\n })}\"\n aria-checked=${this.checked}\n ?disabled=${this.disabled}\n @blur=${this.handleBlur}\n @focus=${this.handleFocus}\n @click=${this.handleClick}\n >\n <slot></slot>\n </button> `;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAuBO,IAAM,mBAAN,cAA+B,OAAO,UAAU,EAAE;AAAA,EAAlD,cAAA;AAAA,UAAA,GAAA,SAAA;AAKL,SAAA,OAAO;AAMP,SAAA,UAAU;AAMV,SAAA,QAAuB;AAMvB,SAAA,WAAW;AAOX,SAAA,OAA2B;AAAA,EAAA;AAAA,EAEnB,aAAa;AACnB,SAAK;AAAA,MACH,IAAI,MAAM,YAAY,EAAE,UAAU,MAAM,SAAS,MAAM;AAAA,IAAA;AAAA,EAE3D;AAAA,EAEQ,cAAc;AACpB,SAAK;AAAA,MACH,IAAI,MAAM,aAAa,EAAE,UAAU,MAAM,SAAS,MAAM;AAAA,IAAA;AAAA,EAE5D;AAAA,EAEQ,YAAY,OAAmB;AACrC,QAAI,KAAK,UAAU;AACjB,YAAM,eAAA;AACN,YAAM,gBAAA;AACN;AAAA,IACF;AAEA,SAAK,UAAU;AAAA,EACjB;AAAA,EAGA,uBAAuB;AACrB,SAAK,aAAa,iBAAiB,KAAK,WAAW,SAAS,OAAO;AAAA,EACrE;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,SAAwB;AAC5B,SAAK,QAAQ,MAAM,OAAO;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO;AACL,SAAK,QAAQ,KAAA;AAAA,EACf;AAAA,EAES,SAAS;AAChB,WAAO;AAAA;AAAA;AAAA;AAAA,aAIE,KAAK,IAAI;AAAA,cACR,UAAU,KAAK,SAAS,MAAS,CAAC;AAAA,eACjC,SAAS;AAAA,MAChB,OAAO;AAAA,MACP,qBAAqB;AAAA,MACrB,yBAAyB;AAAA,MACzB,WAAW;AAAA,MACX,aAAa;AAAA,MACb,kBAAkB;AAAA,MAClB,uBAAuB;AAAA,MACvB,oBAAoB,KAAK;AAAA,MACzB,qBAAqB,CAAC,KAAK;AAAA,MAC3B,eAAe,KAAK,SAAS;AAAA,MAC7B,eAAe,KAAK,SAAS;AAAA,MAC7B,eAAe,KAAK,SAAS;AAAA,IAAA,CAC9B,CAAC;AAAA,qBACa,KAAK,OAAO;AAAA,kBACf,KAAK,QAAQ;AAAA,cACjB,KAAK,UAAU;AAAA,eACd,KAAK,WAAW;AAAA,eAChB,KAAK,WAAW;AAAA;AAAA;AAAA;AAAA,EAI7B;AACF;AArGE,gBAAA;AAAA,EADC,MAAM,QAAQ;AAAA,GADJ,iBAEX,WAAA,WAAA,CAAA;AAGA,gBAAA;AAAA,EADC,SAAA;AAAS,GAJC,iBAKX,WAAA,QAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,SAAS,SAAS,MAAM;AAAA,GAV/B,iBAWX,WAAA,WAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAA;AAAS,GAhBC,iBAiBX,WAAA,SAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,SAAS,SAAS,MAAM;AAAA,GAtB/B,iBAuBX,WAAA,YAAA,CAAA;AAOA,gBAAA;AAAA,EADC,SAAS,EAAE,SAAS,KAAA,CAAM;AAAA,GA7BhB,iBA8BX,WAAA,QAAA,CAAA;AAyBA,gBAAA;AAAA,EADC,MAAM,YAAY,EAAE,sBAAsB,MAAM;AAAA,GAtDtC,iBAuDX,WAAA,wBAAA,CAAA;AAvDW,mBAAN,gBAAA;AAAA,EADN,cAAc,kBAAkB;AAAA,GACpB,gBAAA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio-group.js","sources":["../../src/components/radio-group.component.ts"],"sourcesContent":["import { css, html, LitElement, type PropertyValues } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { styled } from '../mixins/tailwind.mixin';\nimport './label.component';\nimport { ConstraintsValidationMixin } from '../mixins/form-controller.mixin';\nimport { MinidRadioButton } from '../components/radio-button.component';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { watch } from '../internal/watch';\nimport { MinidRadio } from '../components/radio.component';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-radio-group': MinidRadioGroup;\n }\n}\n\nconst styles = [\n css`\n :host {\n display: block;\n }\n\n .fds-label {\n margin-bottom: 1rem;\n }\n `,\n];\n\n/**\n *\n * @slot -- The default slot where `<mid-radio>` or `<mid-radio-button>` elements are placed.\n *\n * @event mid-change - Emitted when the selected value changes\n * @event mid-input - Emitted when radio group recieves input\n *\n * @csspart form-control-label - Select the label element\n * @csspart form-control - Select the fieldset containing the radios\n * @csspart base - Select the container around the radios\n */\n@customElement('mid-radio-group')\nexport class MinidRadioGroup extends ConstraintsValidationMixin(\n styled(LitElement, styles)\n) {\n /**\n * The name of the radio group.\n */\n @property()\n name = 'option';\n\n /**\n * The current value of the radio group.\n */\n @property({ reflect: true })\n value: string | null = null;\n\n @property()\n label = '';\n\n @property()\n size: 'sm' | 'md' | 'lg' = 'md';\n\n @property({ type: Boolean })\n labelhidden = false;\n\n @property({ type: Boolean })\n disabled = false;\n\n @state()\n private hasButtonRadios = false;\n\n @state()\n defaultValue: string | null = null;\n\n protected firstUpdated(_changedProperties: PropertyValues): void {\n super.firstUpdated(_changedProperties);\n this.defaultValue = this.value;\n this.setFormValue(this.value);\n }\n\n protected formResetCallback() {\n this.value = this.defaultValue;\n this.setFormValue(this.value);\n this.updateCheckedRadio();\n }\n\n private async syncRadioElements() {\n const radios = this.getAllRadios();\n this.hasButtonRadios = radios.some(\n (radio) => radio.tagName.toLowerCase() === 'mid-radio-button'\n );\n\n await Promise.all(\n // Sync the checked state and size\n radios.map(async (radio) => {\n await radio.updateComplete;\n radio.checked = radio.value === this.value;\n radio.size = this.size;\n })\n );\n\n if (radios.length > 0 && !radios.some((radio) => radio.checked)) {\n if (this.hasButtonRadios) {\n const buttonRadio = radios[0].shadowRoot?.querySelector('button');\n if (buttonRadio) {\n buttonRadio.setAttribute('tabindex', '0');\n }\n } else {\n radios[0].element.setAttribute('tabindex', '0');\n }\n }\n }\n\n private syncRadios() {\n if (\n customElements.get('mid-radio') &&\n customElements.get('mid-radio-button')\n ) {\n this.syncRadioElements();\n return;\n }\n\n if (customElements.get('mid-radio')) {\n this.syncRadioElements();\n } else {\n customElements.whenDefined('mid-radio').then(() => this.syncRadios());\n }\n\n if (customElements.get('mid-radio-button')) {\n this.syncRadioElements();\n } else {\n // Rerun this handler when <mid-radio> or <mid-radio-button> is registered\n customElements\n .whenDefined('mid-radio-button')\n .then(() => this.syncRadios());\n }\n }\n\n private handleKeyDown(event: KeyboardEvent) {\n if (\n !['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', ' '].includes(\n event.key\n )\n ) {\n return;\n }\n\n const radios = this.getAllRadios().filter((radio) => !radio.disabled);\n const checkedRadio = radios.find((radio) => radio.checked) ?? radios[0];\n const incr =\n event.key === ' '\n ? 0\n : ['ArrowUp', 'ArrowLeft'].includes(event.key)\n ? -1\n : 1;\n const oldValue = this.value;\n let index = radios.indexOf(checkedRadio) + incr;\n\n if (index < 0) {\n index = radios.length - 1;\n }\n\n if (index > radios.length - 1) {\n index = 0;\n }\n\n this.getAllRadios().forEach((radio) => {\n radio.checked = false;\n\n if (!this.hasButtonRadios) {\n radio.element.setAttribute('tabindex', '-1');\n }\n });\n\n this.value = radios[index].value;\n radios[index].checked = true;\n this.setFormValue(this.value);\n\n if (!this.hasButtonRadios) {\n radios[index].element.setAttribute('tabindex', '0');\n radios[index].focus();\n } else {\n radios[index].shadowRoot!.querySelector('button')!.focus();\n }\n\n if (this.value !== oldValue) {\n this.dispatchEvent(\n new Event('mid-change', { bubbles: true, composed: true })\n );\n this.dispatchEvent(\n new Event('mid-input', { bubbles: true, composed: true })\n );\n }\n\n event.preventDefault();\n }\n\n private getAllRadios() {\n return Array.from(\n this.querySelectorAll<MinidRadioButton | MinidRadio>(\n 'mid-radio, mid-radio-button'\n )\n );\n }\n\n private updateCheckedRadio() {\n const radios = this.getAllRadios();\n radios.forEach((radio) => {\n radio.checked = radio.value === this.value;\n });\n }\n\n private handleLabelClick() {\n this.focus();\n }\n\n private handleRadioClick(event: MouseEvent) {\n const target = (event.target as HTMLElement).closest<\n MinidRadioButton | MinidRadio\n >('mid-radio, mid-radio-button')!;\n // const radios = this.getAllRadios();\n\n const oldValue = this.value;\n\n if (!target || target.disabled) {\n return;\n }\n\n this.value = target.value;\n this.setFormValue(this.value);\n\n this.updateCheckedRadio();\n\n if (this.value !== oldValue) {\n this.dispatchEvent(\n new Event('mid-change', { bubbles: true, composed: true })\n );\n this.dispatchEvent(\n new Event('mid-input', { bubbles: true, composed: true })\n );\n }\n }\n\n @watch('size', { waitUntilFirstUpdate: true })\n handleSizeChange() {\n this.syncRadios();\n }\n\n @watch('value')\n handleValueChange() {\n if (this.hasUpdated) {\n this.updateCheckedRadio();\n }\n }\n\n @watch('disabled')\n handleDisabledChange() {\n const radios = this.getAllRadios();\n const every = radios.every((radio) => radio.disabled);\n const some = radios.some((radio) => radio.disabled);\n radios.forEach((radio) => {\n if (every === some) {\n radio.disabled = this.disabled;\n } else if (this.disabled) {\n radio.disabled = true;\n }\n });\n }\n\n /**\n * Sets focus on the radio-group.\n */\n public focus(options?: FocusOptions) {\n const radios = this.getAllRadios();\n const checked = radios.find((radio) => radio.checked);\n const firstEnabledRadio = radios.find((radio) => !radio.disabled);\n\n const radioToFocus = checked || firstEnabledRadio;\n\n // Call focus for the checked radio\n // If no radio is checked, focus the first one that is not disabled\n if (radioToFocus) {\n radioToFocus.focus(options);\n }\n }\n\n override render() {\n return html`\n <label\n part=\"form-control-label\"\n id=\"label\"\n class=\"class=${classMap({\n 'fds-label': true,\n 'fds-label--spacing': true,\n 'fds-label--sm': this.size === 'sm',\n 'fds-label--md': this.size === 'md',\n 'fds-label--lg': this.size === 'lg',\n 'sr-only': this.labelhidden,\n })}\"\n @click=${this.handleLabelClick}\n >\n ${this.label}\n </label>\n <fieldset\n class=\"${classMap({\n 'fds-togglegroup': this.hasButtonRadios,\n })} flex\"\n part=\"form-control\"\n role=\"radiogroup\"\n aria-labelledby=\"label\"\n >\n <div\n class=\"${classMap({\n grid: true,\n 'gap-3': true,\n 'fds-togglegroup__content': this.hasButtonRadios,\n })}\"\n part=\"base\"\n role=\"presentation\"\n aria-label=${this.label}\n >\n <slot\n @slotchange=${this.syncRadios}\n @click=${this.handleRadioClick}\n @keydown=${this.handleKeyDown}\n ></slot>\n </div>\n </fieldset>\n `;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAgBA,MAAM,SAAS;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASF;AAcO,IAAM,kBAAN,cAA8B;AAAA,EACnC,OAAO,YAAY,MAAM;AAC3B,EAAE;AAAA,EAFK,cAAA;AAAA,UAAA,GAAA,SAAA;AAOL,SAAA,OAAO;AAMP,SAAA,QAAuB;AAGvB,SAAA,QAAQ;AAGR,SAAA,OAA2B;AAG3B,SAAA,cAAc;AAGd,SAAA,WAAW;AAGX,SAAQ,kBAAkB;AAG1B,SAAA,eAA8B;AAAA,EAAA;AAAA,EAEpB,aAAa,oBAA0C;AAC/D,UAAM,aAAa,kBAAkB;AACrC,SAAK,eAAe,KAAK;AACzB,SAAK,aAAa,KAAK,KAAK;AAAA,EAAA;AAAA,EAGpB,oBAAoB;AAC5B,SAAK,QAAQ,KAAK;AAClB,SAAK,aAAa,KAAK,KAAK;AAC5B,SAAK,mBAAA;AAAA,EAAmB;AAAA,EAG1B,MAAc,oBAAoB;AAChC,UAAM,SAAS,KAAK,aAAA;AACpB,SAAK,kBAAkB,OAAO;AAAA,MAC5B,CAAC,UAAU,MAAM,QAAQ,kBAAkB;AAAA,IAAA;AAG7C,UAAM,QAAQ;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AA;AAGR,gBAAA;AAAA,EADC,MAAA;AAAM,GA9BI,gBA+BX,WAAA,gBAAA,CAAA;AA4KA,gBAAA;AAAA,EADC,MAAM,QAAQ,EAAE,sBAAsB,MAAM;AAAA,GA1MlC,gBA2MX,WAAA,oBAAA,CAAA;AAKA,gBAAA;AAAA,EADC,MAAM,OAAO;AAAA,GA/MH,gBAgNX,WAAA,qBAAA,CAAA;AAOA,gBAAA;AAAA,EADC,MAAM,UAAU;AAAA,GAtNN,gBAuNX,WAAA,wBAAA,CAAA;AAvNW,kBAAN,gBAAA;AAAA,EADN,cAAc,iBAAiB;AAAA,GACnB,eAAA;"}
|
|
1
|
+
{"version":3,"file":"radio-group.js","sources":["../../src/components/radio-group.component.ts"],"sourcesContent":["import { css, html, LitElement, type PropertyValues } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { styled } from '../mixins/tailwind.mixin';\nimport './label.component';\nimport { ConstraintsValidationMixin } from '../mixins/form-controller.mixin';\nimport { MinidRadioButton } from '../components/radio-button.component';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { watch } from '../internal/watch';\nimport { MinidRadio } from '../components/radio.component';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-radio-group': MinidRadioGroup;\n }\n}\n\nconst styles = [\n css`\n :host {\n display: block;\n }\n\n .fds-label {\n margin-bottom: 1rem;\n }\n `,\n];\n\n/**\n *\n * @slot -- The default slot where `<mid-radio>` or `<mid-radio-button>` elements are placed.\n *\n * @event mid-change - Emitted when the selected value changes\n * @event mid-input - Emitted when radio group recieves input\n *\n * @csspart form-control-label - Select the label element\n * @csspart form-control - Select the fieldset containing the radios\n * @csspart base - Select the container around the radios\n */\n@customElement('mid-radio-group')\nexport class MinidRadioGroup extends ConstraintsValidationMixin(\n styled(LitElement, styles)\n) {\n /**\n * The name of the radio group.\n */\n @property()\n name = 'option';\n\n /**\n * The current value of the radio group.\n */\n @property({ reflect: true })\n value: string | null = null;\n\n @property()\n label = '';\n\n @property()\n size: 'sm' | 'md' | 'lg' = 'md';\n\n @property({ type: Boolean })\n labelhidden = false;\n\n @property({ type: Boolean })\n disabled = false;\n\n @state()\n private hasButtonRadios = false;\n\n @state()\n defaultValue: string | null = null;\n\n protected firstUpdated(_changedProperties: PropertyValues): void {\n super.firstUpdated(_changedProperties);\n this.defaultValue = this.value;\n this.setFormValue(this.value);\n }\n\n protected formResetCallback() {\n this.value = this.defaultValue;\n this.setFormValue(this.value);\n this.updateCheckedRadio();\n }\n\n private async syncRadioElements() {\n const radios = this.getAllRadios();\n this.hasButtonRadios = radios.some(\n (radio) => radio.tagName.toLowerCase() === 'mid-radio-button'\n );\n\n await Promise.all(\n // Sync the checked state and size\n radios.map(async (radio) => {\n await radio.updateComplete;\n radio.checked = radio.value === this.value;\n radio.size = this.size;\n })\n );\n\n if (radios.length > 0 && !radios.some((radio) => radio.checked)) {\n if (this.hasButtonRadios) {\n const buttonRadio = radios[0].shadowRoot?.querySelector('button');\n if (buttonRadio) {\n buttonRadio.setAttribute('tabindex', '0');\n }\n } else {\n radios[0].element.setAttribute('tabindex', '0');\n }\n }\n }\n\n private syncRadios() {\n if (\n customElements.get('mid-radio') &&\n customElements.get('mid-radio-button')\n ) {\n this.syncRadioElements();\n return;\n }\n\n if (customElements.get('mid-radio')) {\n this.syncRadioElements();\n } else {\n customElements.whenDefined('mid-radio').then(() => this.syncRadios());\n }\n\n if (customElements.get('mid-radio-button')) {\n this.syncRadioElements();\n } else {\n // Rerun this handler when <mid-radio> or <mid-radio-button> is registered\n customElements\n .whenDefined('mid-radio-button')\n .then(() => this.syncRadios());\n }\n }\n\n private handleKeyDown(event: KeyboardEvent) {\n if (\n !['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', ' '].includes(\n event.key\n )\n ) {\n return;\n }\n\n const radios = this.getAllRadios().filter((radio) => !radio.disabled);\n const checkedRadio = radios.find((radio) => radio.checked) ?? radios[0];\n const incr =\n event.key === ' '\n ? 0\n : ['ArrowUp', 'ArrowLeft'].includes(event.key)\n ? -1\n : 1;\n const oldValue = this.value;\n let index = radios.indexOf(checkedRadio) + incr;\n\n if (index < 0) {\n index = radios.length - 1;\n }\n\n if (index > radios.length - 1) {\n index = 0;\n }\n\n this.getAllRadios().forEach((radio) => {\n radio.checked = false;\n\n if (!this.hasButtonRadios) {\n radio.element.setAttribute('tabindex', '-1');\n }\n });\n\n this.value = radios[index].value;\n radios[index].checked = true;\n this.setFormValue(this.value);\n\n if (!this.hasButtonRadios) {\n radios[index].element.setAttribute('tabindex', '0');\n radios[index].focus();\n } else {\n radios[index].shadowRoot!.querySelector('button')!.focus();\n }\n\n if (this.value !== oldValue) {\n this.dispatchEvent(\n new Event('mid-change', { bubbles: true, composed: true })\n );\n this.dispatchEvent(\n new Event('mid-input', { bubbles: true, composed: true })\n );\n }\n\n event.preventDefault();\n }\n\n private getAllRadios() {\n return Array.from(\n this.querySelectorAll<MinidRadioButton | MinidRadio>(\n 'mid-radio, mid-radio-button'\n )\n );\n }\n\n private updateCheckedRadio() {\n const radios = this.getAllRadios();\n radios.forEach((radio) => {\n radio.checked = radio.value === this.value;\n });\n }\n\n private handleLabelClick() {\n this.focus();\n }\n\n private handleRadioClick(event: MouseEvent) {\n const target = (event.target as HTMLElement).closest<\n MinidRadioButton | MinidRadio\n >('mid-radio, mid-radio-button')!;\n // const radios = this.getAllRadios();\n\n const oldValue = this.value;\n\n if (!target || target.disabled) {\n return;\n }\n\n this.value = target.value;\n this.setFormValue(this.value);\n\n this.updateCheckedRadio();\n\n if (this.value !== oldValue) {\n this.dispatchEvent(\n new Event('mid-change', { bubbles: true, composed: true })\n );\n this.dispatchEvent(\n new Event('mid-input', { bubbles: true, composed: true })\n );\n }\n }\n\n @watch('size', { waitUntilFirstUpdate: true })\n handleSizeChange() {\n this.syncRadios();\n }\n\n @watch('value')\n handleValueChange() {\n if (this.hasUpdated) {\n this.updateCheckedRadio();\n }\n }\n\n @watch('disabled')\n handleDisabledChange() {\n const radios = this.getAllRadios();\n const every = radios.every((radio) => radio.disabled);\n const some = radios.some((radio) => radio.disabled);\n radios.forEach((radio) => {\n if (every === some) {\n radio.disabled = this.disabled;\n } else if (this.disabled) {\n radio.disabled = true;\n }\n });\n }\n\n /**\n * Sets focus on the radio-group.\n */\n public focus(options?: FocusOptions) {\n const radios = this.getAllRadios();\n const checked = radios.find((radio) => radio.checked);\n const firstEnabledRadio = radios.find((radio) => !radio.disabled);\n\n const radioToFocus = checked || firstEnabledRadio;\n\n // Call focus for the checked radio\n // If no radio is checked, focus the first one that is not disabled\n if (radioToFocus) {\n radioToFocus.focus(options);\n }\n }\n\n override render() {\n return html`\n <label\n part=\"form-control-label\"\n id=\"label\"\n class=\"class=${classMap({\n 'fds-label': true,\n 'fds-label--spacing': true,\n 'fds-label--sm': this.size === 'sm',\n 'fds-label--md': this.size === 'md',\n 'fds-label--lg': this.size === 'lg',\n 'sr-only': this.labelhidden,\n })}\"\n @click=${this.handleLabelClick}\n >\n ${this.label}\n </label>\n <fieldset\n class=\"${classMap({\n 'fds-togglegroup': this.hasButtonRadios,\n })} flex\"\n part=\"form-control\"\n role=\"radiogroup\"\n aria-labelledby=\"label\"\n >\n <div\n class=\"${classMap({\n grid: true,\n 'gap-3': true,\n 'fds-togglegroup__content': this.hasButtonRadios,\n })}\"\n part=\"base\"\n role=\"presentation\"\n aria-label=${this.label}\n >\n <slot\n @slotchange=${this.syncRadios}\n @click=${this.handleRadioClick}\n @keydown=${this.handleKeyDown}\n ></slot>\n </div>\n </fieldset>\n `;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAgBA,MAAM,SAAS;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASF;AAcO,IAAM,kBAAN,cAA8B;AAAA,EACnC,OAAO,YAAY,MAAM;AAC3B,EAAE;AAAA,EAFK,cAAA;AAAA,UAAA,GAAA,SAAA;AAOL,SAAA,OAAO;AAMP,SAAA,QAAuB;AAGvB,SAAA,QA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A;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,SAAS,KAAA,CAAM;AAAA,GAZhB,gBAaX,WAAA,SAAA,CAAA;AAGA,gBAAA;AAAA,EADC,SAAA;AAAS,GAfC,gBAgBX,WAAA,SAAA,CAAA;AAGA,gBAAA;AAAA,EADC,SAAA;AAAS,GAlBC,gBAmBX,WAAA,QAAA,CAAA;AAGA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,QAAA,CAAS;AAAA,GArBhB,gBAsBX,WAAA,eAAA,CAAA;AAGA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,QAAA,CAAS;AAAA,GAxBhB,gBAyBX,WAAA,YAAA,CAAA;AAGQ,gBAAA;AAAA,EADP,MAAA;AAAM,GA3BI,gBA4BH,WAAA,mBAAA,CAAA;AAGR,gBAAA;AAAA,EADC,MAAA;AAAM,GA9BI,gBA+BX,WAAA,gBAAA,CAAA;AA4KA,gBAAA;AAAA,EADC,MAAM,QAAQ,EAAE,sBAAsB,MAAM;AAAA,GA1MlC,gBA2MX,WAAA,oBAAA,CAAA;AAKA,gBAAA;AAAA,EADC,MAAM,OAAO;AAAA,GA/MH,gBAgNX,WAAA,qBAAA,CAAA;AAOA,gBAAA;AAAA,EADC,MAAM,UAAU;AAAA,GAtNN,gBAuNX,WAAA,wBAAA,CAAA;AAvNW,kBAAN,gBAAA;AAAA,EADN,cAAc,iBAAiB;AAAA,GACnB,eAAA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio.js","sources":["../../src/components/radio.component.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { live } from 'lit/directives/live.js';\nimport { watch } from '../internal/watch';\nimport { styled } from '../mixins/tailwind.mixin';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-radio': MinidRadio;\n }\n}\n\nconst styles = [\n css`\n :host {\n --color-checked: #0062ba;\n --color-border: #7a818c;\n\n color: white;\n padding: 0.25rem 0;\n display: grid;\n grid-template-columns: auto 1fr;\n gap: 0.5rem;\n cursor: pointer;\n font-weight: 400;\n }\n\n :host > * {\n cursor: pointer;\n }\n\n :host:has(input:focus-visible) {\n --fds-focus-border-width: 3px;\n box-shadow: 0 0 0 var(--fds-focus-border-width)\n var(--fds-semantic-border-focus-boxshadow);\n }\n\n :host:has(input:disabled),\n :host:has(input:disabled) > * {\n cursor: not-allowed;\n }\n\n :host:has(input:disabled) > * {\n opacity: 0.3;\n }\n\n .label {\n font-weight: 400;\n }\n\n .radio {\n -webkit-appearance: none;\n appearance: none;\n\n border-radius: 999px;\n display: grid;\n place-content: center;\n border: 2px solid var(--color-border);\n transform: translateY(-0.075em);\n }\n\n .radio:checked {\n border-color: var(--color-checked);\n background:\n radial-gradient(circle closest-side, currentcolor 45%, transparent 50%),\n var(--color-checked);\n }\n `,\n];\n\n/**\n *\n * @slot -- The radio's label\n *\n * @event mid-blur - Emitted when the control loses focus.\n * @event mid-focus - Emitted when the control gains focus.\n *\n * @csspart radio - Select the radio input element\n * @csspart label - Select the label element\n */\n@customElement('mid-radio')\nexport class MinidRadio extends styled(LitElement, styles) {\n @query('.radio')\n element!: HTMLInputElement;\n\n @property()\n name = 'option';\n\n /**\n * The radio button's checked state.\n */\n @property({ type: Boolean, reflect: true })\n checked = false;\n\n /**\n * The radio's value. When selected, the radio group will receive this value.\n */\n @property()\n value = '';\n\n /**\n * Disables the radio button.\n */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n /**\n * The radio button's size. When used inside a radio group, the size will be determined by the radio group's size so\n * this attribute can typically be omitted.\n */\n @property({ reflect: true })\n size: 'sm' | 'md' | 'lg' = 'md';\n\n constructor() {\n super();\n this.addEventListener('blur', this.handleBlur);\n this.addEventListener('click', this.handleClick);\n this.addEventListener('focus', this.handleFocus);\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.setAttribute('role', 'presentation');\n this.setAttribute('aria-disabled', this.disabled ? 'true' : 'false');\n\n this.classList.add('rounded');\n }\n\n private handleBlur() {\n this.classList.remove('shadow-focus-visible');\n this.dispatchEvent(\n new Event('mid-blur', { composed: true, bubbles: true })\n );\n }\n\n private handleFocus() {\n if (this.disabled) {\n return;\n }\n\n this.focus();\n this.dispatchEvent(\n new Event('mid-focus', { composed: true, bubbles: true })\n );\n }\n\n private handleClick(event: MouseEvent) {\n if (this.disabled) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n\n this.checked = true;\n }\n\n @watch('disabled', { waitUntilFirstUpdate: true })\n handleDisabledChange() {\n this.setAttribute('aria-disabled', this.disabled ? 'true' : 'false');\n }\n\n @watch('checked', { waitUntilFirstUpdate: true })\n handleCheckChange() {\n this.element.checked = this.checked;\n }\n\n /**\n * Sets focus on the radio button.\n */\n focus(options?: FocusOptions) {\n // this.classList.add('shadow-focus-visible');\n this.element.focus(options);\n }\n\n override render() {\n return html`\n <input\n type=\"radio\"\n part=\"radio\"\n name=\"${this.name}\"\n class=\"${classMap({\n radio: true,\n 'h-7': this.size === 'lg',\n 'w-7': this.size === 'lg',\n 'w-6': this.size === 'md',\n 'h-6': this.size === 'md',\n 'w-5': this.size === 'sm',\n 'h-5': this.size === 'sm',\n })} shadow-none\"\n ?checked=${live(this.checked)}\n ?disabled=${this.disabled}\n />\n <label\n part=\"label\"\n class=\"${classMap({\n label: true,\n 'fds-label': true,\n 'fds-label--sm': this.size === 'sm',\n 'fds-label--md': this.size === 'md',\n 'fds-label--lg': this.size === 'lg',\n })}\"\n >\n <slot></slot>\n </label>\n `;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAaA,MAAM,SAAS;AAAA,EACb;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;AAuDF;AAaO,IAAM,aAAN,cAAyB,OAAO,YAAY,MAAM,EAAE;AAAA,EAgCzD,cAAc;AACZ,UAAA;AA5BF,SAAA,OAAO;AAMP,SAAA,UAAU;AAMV,SAAA,QAAQ;AAMR,SAAA,WAAW;AAOX,SAAA,OAA2B;AAIzB,SAAK,iBAAiB,QAAQ,KAAK,UAAU;AAC7C,SAAK,iBAAiB,SAAS,KAAK,WAAW;AAC/C,SAAK,iBAAiB,SAAS,KAAK,WAAW;AAAA,
|
|
1
|
+
{"version":3,"file":"radio.js","sources":["../../src/components/radio.component.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { live } from 'lit/directives/live.js';\nimport { watch } from '../internal/watch';\nimport { styled } from '../mixins/tailwind.mixin';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-radio': MinidRadio;\n }\n}\n\nconst styles = [\n css`\n :host {\n --color-checked: #0062ba;\n --color-border: #7a818c;\n\n color: white;\n padding: 0.25rem 0;\n display: grid;\n grid-template-columns: auto 1fr;\n gap: 0.5rem;\n cursor: pointer;\n font-weight: 400;\n }\n\n :host > * {\n cursor: pointer;\n }\n\n :host:has(input:focus-visible) {\n --fds-focus-border-width: 3px;\n box-shadow: 0 0 0 var(--fds-focus-border-width)\n var(--fds-semantic-border-focus-boxshadow);\n }\n\n :host:has(input:disabled),\n :host:has(input:disabled) > * {\n cursor: not-allowed;\n }\n\n :host:has(input:disabled) > * {\n opacity: 0.3;\n }\n\n .label {\n font-weight: 400;\n }\n\n .radio {\n -webkit-appearance: none;\n appearance: none;\n\n border-radius: 999px;\n display: grid;\n place-content: center;\n border: 2px solid var(--color-border);\n transform: translateY(-0.075em);\n }\n\n .radio:checked {\n border-color: var(--color-checked);\n background:\n radial-gradient(circle closest-side, currentcolor 45%, transparent 50%),\n var(--color-checked);\n }\n `,\n];\n\n/**\n *\n * @slot -- The radio's label\n *\n * @event mid-blur - Emitted when the control loses focus.\n * @event mid-focus - Emitted when the control gains focus.\n *\n * @csspart radio - Select the radio input element\n * @csspart label - Select the label element\n */\n@customElement('mid-radio')\nexport class MinidRadio extends styled(LitElement, styles) {\n @query('.radio')\n element!: HTMLInputElement;\n\n @property()\n name = 'option';\n\n /**\n * The radio button's checked state.\n */\n @property({ type: Boolean, reflect: true })\n checked = false;\n\n /**\n * The radio's value. When selected, the radio group will receive this value.\n */\n @property()\n value = '';\n\n /**\n * Disables the radio button.\n */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n /**\n * The radio button's size. When used inside a radio group, the size will be determined by the radio group's size so\n * this attribute can typically be omitted.\n */\n @property({ reflect: true })\n size: 'sm' | 'md' | 'lg' = 'md';\n\n constructor() {\n super();\n this.addEventListener('blur', this.handleBlur);\n this.addEventListener('click', this.handleClick);\n this.addEventListener('focus', this.handleFocus);\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.setAttribute('role', 'presentation');\n this.setAttribute('aria-disabled', this.disabled ? 'true' : 'false');\n\n this.classList.add('rounded');\n }\n\n private handleBlur() {\n this.classList.remove('shadow-focus-visible');\n this.dispatchEvent(\n new Event('mid-blur', { composed: true, bubbles: true })\n );\n }\n\n private handleFocus() {\n if (this.disabled) {\n return;\n }\n\n this.focus();\n this.dispatchEvent(\n new Event('mid-focus', { composed: true, bubbles: true })\n );\n }\n\n private handleClick(event: MouseEvent) {\n if (this.disabled) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n\n this.checked = true;\n }\n\n @watch('disabled', { waitUntilFirstUpdate: true })\n handleDisabledChange() {\n this.setAttribute('aria-disabled', this.disabled ? 'true' : 'false');\n }\n\n @watch('checked', { waitUntilFirstUpdate: true })\n handleCheckChange() {\n this.element.checked = this.checked;\n }\n\n /**\n * Sets focus on the radio button.\n */\n focus(options?: FocusOptions) {\n // this.classList.add('shadow-focus-visible');\n this.element.focus(options);\n }\n\n override render() {\n return html`\n <input\n type=\"radio\"\n part=\"radio\"\n name=\"${this.name}\"\n class=\"${classMap({\n radio: true,\n 'h-7': this.size === 'lg',\n 'w-7': this.size === 'lg',\n 'w-6': this.size === 'md',\n 'h-6': this.size === 'md',\n 'w-5': this.size === 'sm',\n 'h-5': this.size === 'sm',\n })} shadow-none\"\n ?checked=${live(this.checked)}\n ?disabled=${this.disabled}\n />\n <label\n part=\"label\"\n class=\"${classMap({\n label: true,\n 'fds-label': true,\n 'fds-label--sm': this.size === 'sm',\n 'fds-label--md': this.size === 'md',\n 'fds-label--lg': this.size === 'lg',\n })}\"\n >\n <slot></slot>\n </label>\n `;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAaA,MAAM,SAAS;AAAA,EACb;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;AAuDF;AAaO,IAAM,aAAN,cAAyB,OAAO,YAAY,MAAM,EAAE;AAAA,EAgCzD,cAAc;AACZ,UAAA;AA5BF,SAAA,OAAO;AAMP,SAAA,UAAU;AAMV,SAAA,QAAQ;AAMR,SAAA,WAAW;AAOX,SAAA,OAA2B;AAIzB,SAAK,iBAAiB,QAAQ,KAAK,UAAU;AAC7C,SAAK,iBAAiB,SAAS,KAAK,WAAW;AAC/C,SAAK,iBAAiB,SAAS,KAAK,WAAW;AAAA,EACjD;AAAA,EAEA,o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AA;AAAA,iBAIhB,SAAS;AAAA,MAChB,OAAO;AAAA,MACP,aAAa;AAAA,MACb,iBAAiB,KAAK,SAAS;AAAA,MAC/B,iBAAiB,KAAK,SAAS;AAAA,MAC/B,iBAAiB,KAAK,SAAS;AAAA,IAAA,CAChC,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,EAKR;AACF;AA3HE,gBAAA;AAAA,EADC,MAAM,QAAQ;AAAA,GADJ,WAEX,WAAA,WAAA,CAAA;AAGA,gBAAA;AAAA,EADC,SAAA;AAAS,GAJC,WAKX,WAAA,QAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,SAAS,SAAS,MAAM;AAAA,GAV/B,WAWX,WAAA,WAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAA;AAAS,GAhBC,WAiBX,WAAA,SAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,SAAS,SAAS,MAAM;AAAA,GAtB/B,WAuBX,WAAA,YAAA,CAAA;AAOA,gBAAA;AAAA,EADC,SAAS,EAAE,SAAS,KAAA,CAAM;AAAA,GA7BhB,WA8BX,WAAA,QAAA,CAAA;AA8CA,gBAAA;AAAA,EADC,MAAM,YAAY,EAAE,sBAAsB,MAAM;AAAA,GA3EtC,WA4EX,WAAA,wBAAA,CAAA;AAKA,gBAAA;AAAA,EADC,MAAM,WAAW,EAAE,sBAAsB,MAAM;AAAA,GAhFrC,WAiFX,WAAA,qBAAA,CAAA;AAjFW,aAAN,gBAAA;AAAA,EADN,cAAc,WAAW;AAAA,GACb,UAAA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.js","sources":["../../src/components/search.component.ts"],"sourcesContent":["import { html, LitElement } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { styled } from '../mixins/tailwind.mixin';\nimport './textfield.component';\nimport './icon/icon.component';\nimport './button.component.ts';\nimport { live } from 'lit/directives/live.js';\nimport { MinidTextfield } from './textfield.component.ts';\nimport { debounce } from '../internal/debounce.ts';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-search': MinidSearch;\n }\n}\n\n/**\n * @event mid-change - Emitted when a change to the input value is comitted by the user\n * @event mid-input - Emitted when the input element recieves input\n * @event mid-clear - Emitted when the input value is cleared\n * @event mid-focus - Emitted when input element is focused\n * @event mid-blur - Emitted when focus moves away from input element\n */\n@customElement('mid-search')\nexport class MinidSearch extends styled(LitElement) {\n @query('mid-textfield')\n textField!: MinidTextfield;\n\n @property()\n size: 'sm' | 'md' | 'lg' = 'md';\n\n @property()\n label = '';\n\n @property()\n placeholder = '';\n\n @property()\n value = '';\n\n /**\n * Debounce the `mid-input` event by a number of milliseconds\n */\n @property({ type: Number, reflect: true })\n debounce = 0;\n\n private handleInput = () => {\n this.value = this.textField.value;\n this.dispatchEvent(\n new Event('mid-input', { composed: true, bubbles: true })\n );\n };\n\n focus() {\n this.textField.focus();\n }\n\n override render() {\n return html`\n <mid-textfield\n .value=${live(this.value)}\n type=\"search\"\n size=${this.size}\n label=${this.label}\n placeholder=${this.placeholder}\n @mid-input=${debounce(this.handleInput, this.debounce, {\n stopPropagation: true,\n })}\n clearable\n >\n <mid-icon\n slot=\"prefix\"\n class=\"size-6\"\n library=\"system\"\n name=\"magnifying-glass\"\n >\n </mid-icon>\n </mid-textfield>\n `;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAwBO,IAAM,cAAN,cAA0B,OAAO,UAAU,EAAE;AAAA,EAA7C,cAAA;AAAA,UAAA,GAAA,SAAA;AAKL,SAAA,OAA2B;AAG3B,SAAA,QAAQ;AAGR,SAAA,cAAc;AAGd,SAAA,QAAQ;AAMR,SAAA,WAAW;AAEX,SAAQ,cAAc,MAAM;AAC1B,WAAK,QAAQ,KAAK,UAAU;AAC5B,WAAK;AAAA,QACH,IAAI,MAAM,aAAa,EAAE,UAAU,MAAM,SAAS,MAAM;AAAA,MAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"search.js","sources":["../../src/components/search.component.ts"],"sourcesContent":["import { html, LitElement } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { styled } from '../mixins/tailwind.mixin';\nimport './textfield.component';\nimport './icon/icon.component';\nimport './button.component.ts';\nimport { live } from 'lit/directives/live.js';\nimport { MinidTextfield } from './textfield.component.ts';\nimport { debounce } from '../internal/debounce.ts';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-search': MinidSearch;\n }\n}\n\n/**\n * @event mid-change - Emitted when a change to the input value is comitted by the user\n * @event mid-input - Emitted when the input element recieves input\n * @event mid-clear - Emitted when the input value is cleared\n * @event mid-focus - Emitted when input element is focused\n * @event mid-blur - Emitted when focus moves away from input element\n */\n@customElement('mid-search')\nexport class MinidSearch extends styled(LitElement) {\n @query('mid-textfield')\n textField!: MinidTextfield;\n\n @property()\n size: 'sm' | 'md' | 'lg' = 'md';\n\n @property()\n label = '';\n\n @property()\n placeholder = '';\n\n @property()\n value = '';\n\n /**\n * Debounce the `mid-input` event by a number of milliseconds\n */\n @property({ type: Number, reflect: true })\n debounce = 0;\n\n private handleInput = () => {\n this.value = this.textField.value;\n this.dispatchEvent(\n new Event('mid-input', { composed: true, bubbles: true })\n );\n };\n\n focus() {\n this.textField.focus();\n }\n\n override render() {\n return html`\n <mid-textfield\n .value=${live(this.value)}\n type=\"search\"\n size=${this.size}\n label=${this.label}\n placeholder=${this.placeholder}\n @mid-input=${debounce(this.handleInput, this.debounce, {\n stopPropagation: true,\n })}\n clearable\n >\n <mid-icon\n slot=\"prefix\"\n class=\"size-6\"\n library=\"system\"\n name=\"magnifying-glass\"\n >\n </mid-icon>\n </mid-textfield>\n `;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAwBO,IAAM,cAAN,cAA0B,OAAO,UAAU,EAAE;AAAA,EAA7C,cAAA;AAAA,UAAA,GAAA,SAAA;AAKL,SAAA,OAA2B;AAG3B,SAAA,QAAQ;AAGR,SAAA,cAAc;AAGd,SAAA,QAAQ;AAMR,SAAA,WAAW;AAEX,SAAQ,cAAc,MAAM;AAC1B,WAAK,QAAQ,KAAK,UAAU;AAC5B,WAAK;AAAA,QACH,IAAI,MAAM,aAAa,EAAE,UAAU,MAAM,SAAS,MAAM;AAAA,MAAA;AAAA,IAE5D;AAAA,EAAA;AAAA,EAEA,QAAQ;AACN,SAAK,UAAU,MAAA;AAAA,EACjB;AAAA,EAES,SAAS;AAChB,WAAO;AAAA;AAAA,iBAEM,KAAK,KAAK,KAAK,CAAC;AAAA;AAAA,eAElB,KAAK,IAAI;AAAA,gBACR,KAAK,KAAK;AAAA,sBACJ,KAAK,WAAW;AAAA,qBACjB,SAAS,KAAK,aAAa,KAAK,UAAU;AAAA,MACrD,iBAAiB;AAAA,IAAA,CAClB,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYR;AACF;AAtDE,gBAAA;AAAA,EADC,MAAM,eAAe;AAAA,GADX,YAEX,WAAA,aAAA,CAAA;AAGA,gBAAA;AAAA,EADC,SAAA;AAAS,GAJC,YAKX,WAAA,QAAA,CAAA;AAGA,gBAAA;AAAA,EADC,SAAA;AAAS,GAPC,YAQX,WAAA,SAAA,CAAA;AAGA,gBAAA;AAAA,EADC,SAAA;AAAS,GAVC,YAWX,WAAA,eAAA,CAAA;AAGA,gBAAA;AAAA,EADC,SAAA;AAAS,GAbC,YAcX,WAAA,SAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,QAAQ,SAAS,MAAM;AAAA,GAnB9B,YAoBX,WAAA,YAAA,CAAA;AApBW,cAAN,gBAAA;AAAA,EADN,cAAc,YAAY;AAAA,GACd,WAAA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spinner.js","sources":["../../src/components/spinner.component.ts"],"sourcesContent":["import { customElement } from 'lit/decorators.js';\nimport { css, html, LitElement } from 'lit';\nimport { styled } from '../mixins/tailwind.mixin';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-spinner': MinidSpinner;\n }\n}\n\nconst styles = [\n css`\n :host {\n display: inline-flex;\n }\n `,\n];\n\n/**\n * Size and color can be adjusted with `font-size` and `color` css properties\n */\n@customElement('mid-spinner')\nexport class MinidSpinner extends styled(LitElement, styles) {\n override render() {\n return html`\n <svg\n class=\"animate-spin-slow\"\n width=\"1em\"\n height=\"1em\"\n viewBox=\"0 0 50 50\"\n >\n <circle\n opacity=\"0.2\"\n stroke=\"currentColor\"\n cx=\"25\"\n cy=\"25\"\n r=\"20\"\n fill=\"none\"\n stroke-width=\"5\"\n ></circle>\n <circle\n class=\"animate-dash\"\n cx=\"25\"\n cy=\"25\"\n r=\"20\"\n fill=\"none\"\n stroke-width=\"5\"\n stroke=\"currentColor\"\n ></circle>\n </svg>\n `;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAUA,MAAM,SAAS;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAKF;AAMO,IAAM,eAAN,cAA2B,OAAO,YAAY,MAAM,EAAE;AAAA,EAClD,SAAS;AAChB,WAAO;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,
|
|
1
|
+
{"version":3,"file":"spinner.js","sources":["../../src/components/spinner.component.ts"],"sourcesContent":["import { customElement } from 'lit/decorators.js';\nimport { css, html, LitElement } from 'lit';\nimport { styled } from '../mixins/tailwind.mixin';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-spinner': MinidSpinner;\n }\n}\n\nconst styles = [\n css`\n :host {\n display: inline-flex;\n }\n `,\n];\n\n/**\n * Size and color can be adjusted with `font-size` and `color` css properties\n */\n@customElement('mid-spinner')\nexport class MinidSpinner extends styled(LitElement, styles) {\n override render() {\n return html`\n <svg\n class=\"animate-spin-slow\"\n width=\"1em\"\n height=\"1em\"\n viewBox=\"0 0 50 50\"\n >\n <circle\n opacity=\"0.2\"\n stroke=\"currentColor\"\n cx=\"25\"\n cy=\"25\"\n r=\"20\"\n fill=\"none\"\n stroke-width=\"5\"\n ></circle>\n <circle\n class=\"animate-dash\"\n cx=\"25\"\n cy=\"25\"\n r=\"20\"\n fill=\"none\"\n stroke-width=\"5\"\n stroke=\"currentColor\"\n ></circle>\n </svg>\n `;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAUA,MAAM,SAAS;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAKF;AAMO,IAAM,eAAN,cAA2B,OAAO,YAAY,MAAM,EAAE;AAAA,EAClD,SAAS;AAChB,WAAO;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,EA2BT;AACF;AA9Ba,eAAN,gBAAA;AAAA,EADN,cAAc,aAAa;AAAA,GACf,YAAA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step-indicator.js","sources":["../../src/components/step-indicator.component.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { styled } from '../mixins/tailwind.mixin';\nimport { customElement, property } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-step-indicator': MinidStepIndicator;\n }\n}\n\nconst styles = [\n css`\n :host {\n display: flex;\n justify-content: center;\n }\n `,\n];\n\n@customElement('mid-step-indicator')\nexport class MinidStepIndicator extends styled(LitElement, styles) {\n @property({ type: Number })\n steps = 0;\n\n @property({ type: Number })\n current = 0;\n\n override render() {\n return html`\n <ol class=\"flex gap-8\">\n ${Array.from({ length: this.steps }).map((_, index) => {\n const step = index + 1;\n const isActive = step === this.current;\n const isCompleted = step < this.current;\n const isUpcoming = step > this.current;\n return html`<li\n aria-current=\"${ifDefined(isActive ? 'step' : undefined)}\"\n class=\"${classMap({\n 'after:bg-accent-base': isActive || isCompleted,\n 'border-accent-base': isActive || isCompleted,\n 'after:bg-neutral-surface-active': isUpcoming,\n 'border-neutral-surface-active': isUpcoming,\n 'bg-neutral-surface-active': isUpcoming,\n 'after:bg-transparent': step === 1,\n 'bg-neutral-surface': isCompleted,\n 'bg-accent-base': isActive,\n 'bg-accent': isUpcoming,\n })} relative rounded-full border-4 p-1.5 after:absolute after:-left-1 after:block after:h-1 after:w-8 after:-translate-x-full after:-translate-y-1/2\"\n ></li>`;\n })}\n </ol>\n `;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAYA,MAAM,SAAS;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAMF;AAGO,IAAM,qBAAN,cAAiC,OAAO,YAAY,MAAM,EAAE;AAAA,EAA5D,cAAA;AAAA,UAAA,GAAA,SAAA;AAEL,SAAA,QAAQ;AAGR,SAAA,UAAU;AAAA,EAAA;AAAA,EAED,SAAS;AAChB,WAAO;AAAA;AAAA,UAED,MAAM,KAAK,EAAE,QAAQ,KAAK,MAAA,CAAO,EAAE,IAAI,CAAC,GAAG,UAAU;AACrD,YAAM,OAAO,QAAQ;AACrB,YAAM,WAAW,SAAS,KAAK;AAC/B,YAAM,cAAc,OAAO,KAAK;AAChC,YAAM,aAAa,OAAO,KAAK;AAC/B,aAAO;AAAA,4BACW,UAAU,WAAW,SAAS,MAAS,CAAC;AAAA,qBAC/C,SAAS;AAAA,QAChB,wBAAwB,YAAY;AAAA,QACpC,sBAAsB,YAAY;AAAA,QAClC,mCAAmC;AAAA,QACnC,iCAAiC;AAAA,QACjC,6BAA6B;AAAA,QAC7B,wBAAwB,SAAS;AAAA,QACjC,sBAAsB;AAAA,QACtB,kBAAkB;AAAA,QAClB,aAAa;AAAA,MAAA,CACd,CAAC;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"step-indicator.js","sources":["../../src/components/step-indicator.component.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { styled } from '../mixins/tailwind.mixin';\nimport { customElement, property } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-step-indicator': MinidStepIndicator;\n }\n}\n\nconst styles = [\n css`\n :host {\n display: flex;\n justify-content: center;\n }\n `,\n];\n\n@customElement('mid-step-indicator')\nexport class MinidStepIndicator extends styled(LitElement, styles) {\n @property({ type: Number })\n steps = 0;\n\n @property({ type: Number })\n current = 0;\n\n override render() {\n return html`\n <ol class=\"flex gap-8\">\n ${Array.from({ length: this.steps }).map((_, index) => {\n const step = index + 1;\n const isActive = step === this.current;\n const isCompleted = step < this.current;\n const isUpcoming = step > this.current;\n return html`<li\n aria-current=\"${ifDefined(isActive ? 'step' : undefined)}\"\n class=\"${classMap({\n 'after:bg-accent-base': isActive || isCompleted,\n 'border-accent-base': isActive || isCompleted,\n 'after:bg-neutral-surface-active': isUpcoming,\n 'border-neutral-surface-active': isUpcoming,\n 'bg-neutral-surface-active': isUpcoming,\n 'after:bg-transparent': step === 1,\n 'bg-neutral-surface': isCompleted,\n 'bg-accent-base': isActive,\n 'bg-accent': isUpcoming,\n })} relative rounded-full border-4 p-1.5 after:absolute after:-left-1 after:block after:h-1 after:w-8 after:-translate-x-full after:-translate-y-1/2\"\n ></li>`;\n })}\n </ol>\n `;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAYA,MAAM,SAAS;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAMF;AAGO,IAAM,qBAAN,cAAiC,OAAO,YAAY,MAAM,EAAE;AAAA,EAA5D,cAAA;AAAA,UAAA,GAAA,SAAA;AAEL,SAAA,QAAQ;AAGR,SAAA,UAAU;AAAA,EAAA;AAAA,EAED,SAAS;AAChB,WAAO;AAAA;AAAA,UAED,MAAM,KAAK,EAAE,QAAQ,KAAK,MAAA,CAAO,EAAE,IAAI,CAAC,GAAG,UAAU;AACrD,YAAM,OAAO,QAAQ;AACrB,YAAM,WAAW,SAAS,KAAK;AAC/B,YAAM,cAAc,OAAO,KAAK;AAChC,YAAM,aAAa,OAAO,KAAK;AAC/B,aAAO;AAAA,4BACW,UAAU,WAAW,SAAS,MAAS,CAAC;AAAA,qBAC/C,SAAS;AAAA,QAChB,wBAAwB,YAAY;AAAA,QACpC,sBAAsB,YAAY;AAAA,QAClC,mCAAmC;AAAA,QACnC,iCAAiC;AAAA,QACjC,6BAA6B;AAAA,QAC7B,wBAAwB,SAAS;AAAA,QACjC,sBAAsB;AAAA,QACtB,kBAAkB;AAAA,QAClB,aAAa;AAAA,MAAA,CACd,CAAC;AAAA;AAAA,IAEN,CAAC,CAAC;AAAA;AAAA;AAAA,EAGR;AACF;AA/BE,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GADf,mBAEX,WAAA,SAAA,CAAA;AAGA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAJf,mBAKX,WAAA,WAAA,CAAA;AALW,qBAAN,gBAAA;AAAA,EADN,cAAc,oBAAoB;AAAA,GACtB,kBAAA;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
|
+
import { MaskType } from 'maska';
|
|
2
3
|
declare global {
|
|
3
4
|
interface HTMLElementTagNameMap {
|
|
4
5
|
'mid-textfield': MinidTextfield;
|
|
@@ -30,6 +31,7 @@ export declare class MinidTextfield extends MinidTextfield_base {
|
|
|
30
31
|
private readonly descriptionId;
|
|
31
32
|
private readonly validationId;
|
|
32
33
|
private readonly hasSlotControler;
|
|
34
|
+
private inputMask?;
|
|
33
35
|
private initialValue;
|
|
34
36
|
input: HTMLInputElement;
|
|
35
37
|
label: string;
|
|
@@ -94,10 +96,19 @@ export declare class MinidTextfield extends MinidTextfield_base {
|
|
|
94
96
|
* Visually hides `label` and `description` (still available for screen readers)
|
|
95
97
|
*/
|
|
96
98
|
hidelabel: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Modify input value based on mask e.g: `"##:##"` = 12:34.
|
|
101
|
+
* `#`: /[0-9]/
|
|
102
|
+
* `@`: /[a-zA-Z]/
|
|
103
|
+
* `*`: /[a-zA-Z0-9]/
|
|
104
|
+
* For more information go to https://beholdr.github.io/maska
|
|
105
|
+
*/
|
|
106
|
+
mask?: MaskType;
|
|
97
107
|
hasFocus: boolean;
|
|
98
108
|
static get formControlValidators(): import('../types/validator.type.ts').Validator[];
|
|
99
109
|
constructor();
|
|
100
110
|
connectedCallback(): void;
|
|
111
|
+
disconnectedCallback(): void;
|
|
101
112
|
private handleKeydown;
|
|
102
113
|
private handleBlur;
|
|
103
114
|
private handleChange;
|
|
@@ -109,6 +120,7 @@ export declare class MinidTextfield extends MinidTextfield_base {
|
|
|
109
120
|
resetFormControl(): void;
|
|
110
121
|
forceError(message?: string): void;
|
|
111
122
|
handleValueUpdate(): void;
|
|
123
|
+
handleMaskUpdate(): Promise<void>;
|
|
112
124
|
render(): import('lit-html').TemplateResult<1>;
|
|
113
125
|
}
|
|
114
126
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textfield.component.d.ts","sourceRoot":"","sources":["../../src/components/textfield.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAW,MAAM,KAAK,CAAC;AAgBrD,OAAO,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"textfield.component.d.ts","sourceRoot":"","sources":["../../src/components/textfield.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAW,MAAM,KAAK,CAAC;AAgBrD,OAAO,0BAA0B,CAAC;AAClC,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,OAAO,CAAC;AA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EjB;;OAEG;IAEH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IAEH,QAAQ,UAAS;IAEjB;;OAEG;IAEH,SAAS,UAAS;IAElB;;;;;;OAMG;IAEH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAGhB,QAAQ,UAAS;IAEjB,MAAM,KAAK,qBAAqB,qDAO/B;;IAUQ,iBAAiB,IAAI,IAAI;IAKlC,oBAAoB,IAAI,IAAI;IAI5B,OAAO,CAAC,aAAa;IAkBrB,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,WAAW;IAQnB,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,oBAAoB;IAI5B,OAAO,CAAC,gBAAgB;IAmBxB,KAAK;IAKL,gBAAgB;IAKhB,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAKlC,iBAAiB;IAKX,gBAAgB;IAUb,MAAM;CAiKhB"}
|
|
@@ -10,6 +10,7 @@ import { FormControlMixin } from "../mixins/form-control.mixin.js";
|
|
|
10
10
|
import { requiredValidator, maxLengthValidator, minLengthValidator, patternValidator } from "../mixins/validators.js";
|
|
11
11
|
import { watch } from "../internal/watch.js";
|
|
12
12
|
import "./icon/icon.js";
|
|
13
|
+
import { MaskInput } from "maska";
|
|
13
14
|
var __defProp = Object.defineProperty;
|
|
14
15
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
15
16
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
@@ -67,6 +68,9 @@ let MinidTextfield = class extends FormControlMixin(
|
|
|
67
68
|
super.connectedCallback();
|
|
68
69
|
this.initialValue = this.value;
|
|
69
70
|
}
|
|
71
|
+
disconnectedCallback() {
|
|
72
|
+
this.inputMask?.destroy();
|
|
73
|
+
}
|
|
70
74
|
handleKeydown(event) {
|
|
71
75
|
const hasModifier = event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;
|
|
72
76
|
if (event.key === "Enter" && !hasModifier) {
|
|
@@ -135,6 +139,15 @@ let MinidTextfield = class extends FormControlMixin(
|
|
|
135
139
|
handleValueUpdate() {
|
|
136
140
|
this.setValue(this.value);
|
|
137
141
|
}
|
|
142
|
+
async handleMaskUpdate() {
|
|
143
|
+
if (!this.mask) return;
|
|
144
|
+
await this.updateComplete;
|
|
145
|
+
this.inputMask?.destroy();
|
|
146
|
+
this.inputMask = new MaskInput(this.input, {
|
|
147
|
+
mask: this.mask,
|
|
148
|
+
eager: true
|
|
149
|
+
});
|
|
150
|
+
}
|
|
138
151
|
render() {
|
|
139
152
|
const lg = this.size === "lg";
|
|
140
153
|
const md = this.size === "md";
|
|
@@ -345,12 +358,18 @@ __decorateClass([
|
|
|
345
358
|
__decorateClass([
|
|
346
359
|
property({ type: Boolean })
|
|
347
360
|
], MinidTextfield.prototype, "hidelabel", 2);
|
|
361
|
+
__decorateClass([
|
|
362
|
+
property()
|
|
363
|
+
], MinidTextfield.prototype, "mask", 2);
|
|
348
364
|
__decorateClass([
|
|
349
365
|
state()
|
|
350
366
|
], MinidTextfield.prototype, "hasFocus", 2);
|
|
351
367
|
__decorateClass([
|
|
352
368
|
watch("value")
|
|
353
369
|
], MinidTextfield.prototype, "handleValueUpdate", 1);
|
|
370
|
+
__decorateClass([
|
|
371
|
+
watch("mask")
|
|
372
|
+
], MinidTextfield.prototype, "handleMaskUpdate", 1);
|
|
354
373
|
MinidTextfield = __decorateClass([
|
|
355
374
|
customElement("mid-textfield")
|
|
356
375
|
], MinidTextfield);
|