@felleslosninger/minid-elements 0.0.99 → 0.0.100
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.component.d.ts +2 -6
- package/dist/components/alert.component.d.ts.map +1 -1
- package/dist/components/alert.js +16 -55
- package/dist/components/alert.js.map +1 -1
- package/dist/components/checkbox.component.d.ts +46 -6
- package/dist/components/checkbox.component.d.ts.map +1 -1
- package/dist/components/checkbox.js +115 -87
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/code-input.component.d.ts +16 -15
- package/dist/components/code-input.component.d.ts.map +1 -1
- package/dist/components/code-input.js +105 -105
- package/dist/components/code-input.js.map +1 -1
- package/dist/components/combobox.component.d.ts +6 -9
- package/dist/components/combobox.component.d.ts.map +1 -1
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/dialog.js +2 -2
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/menu.js +1 -1
- package/dist/components/menu.js.map +1 -1
- package/dist/components/phone-input.component.d.ts +5 -3
- package/dist/components/phone-input.component.d.ts.map +1 -1
- package/dist/components/phone-input.js +22 -34
- package/dist/components/phone-input.js.map +1 -1
- package/dist/components/popup.component.d.ts +1 -1
- package/dist/components/popup.component.d.ts.map +1 -1
- package/dist/components/popup.js +10 -19
- package/dist/components/popup.js.map +1 -1
- package/dist/components/search.js +1 -1
- package/dist/components/search.js.map +1 -1
- package/dist/components/spinner.component.d.ts.map +1 -1
- package/dist/components/spinner.js +9 -1
- package/dist/components/spinner.js.map +1 -1
- package/dist/components/textfield.component.d.ts +1 -0
- package/dist/components/textfield.component.d.ts.map +1 -1
- package/dist/components/textfield.js +9 -7
- package/dist/components/textfield.js.map +1 -1
- package/dist/designsystemet-tailwind.css +1 -1
- package/dist/mixins/form-controller.mixin.d.ts.map +1 -1
- package/dist/mixins/form-controller.mixin.js +0 -3
- package/dist/mixins/form-controller.mixin.js.map +1 -1
- package/dist/mixins/tailwind.mixin.js +1 -1
- package/package.json +9 -8
package/dist/components/menu.js
CHANGED
|
@@ -187,7 +187,7 @@ let MinidMenu = class extends styled(LitElement, styles) {
|
|
|
187
187
|
render() {
|
|
188
188
|
return html`
|
|
189
189
|
<div
|
|
190
|
-
class="text-
|
|
190
|
+
class="text-neutral border-neutral-subtle rounded-md border shadow-md"
|
|
191
191
|
>
|
|
192
192
|
${!this.searchable ? nothing : html`<div
|
|
193
193
|
class="border-neutral-subtle flex items-center gap-2 border-b p-2"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu.js","sources":["../../src/components/menu.component.ts"],"sourcesContent":["import { css, html, LitElement, nothing } from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { styled } from '../mixins/tailwind.mixin.ts';\nimport { MinidMenuItem } from './menu-item.component';\nimport { scrollIntoView } from '../internal/scroll';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-menu': MinidMenu;\n }\n}\n\nconst styles = [\n css`\n :host {\n --max-height: none;\n --max-width: none;\n }\n `,\n];\n\n/**\n * @event {{ detail: { item: MidMenuItem } }} mid-select - Emitted when a menu item is selected.\n */\n@customElement('mid-menu')\nexport class MinidMenu extends styled(LitElement, styles) {\n @query('slot')\n defaultSlot!: HTMLSlotElement;\n\n @query('.filter-input')\n filterInput!: HTMLInputElement;\n\n @query('.item-list')\n itemList!: HTMLUListElement;\n\n /**\n * Adds an input element that filters selectable menu items\n */\n @property({ type: Boolean })\n searchable = false;\n\n /**\n * Wether the menu should be styled as a dropdown or a combobox\n */\n @property()\n variant: 'combobox' | 'dropdown' = 'dropdown';\n\n @state()\n emptyItemList = false;\n\n protected firstUpdated(): void {\n this.getAllItems().forEach((item) => {\n item.variant = this.variant;\n item.addEventListener('mouseenter', () => {\n this.setCurrentItem(item);\n });\n });\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.setAttribute('role', 'menu');\n }\n\n private handleClick(event: MouseEvent) {\n const menuItemTypes = ['menuitem', 'menuitemcheckbox'];\n\n const composedPath = event.composedPath();\n const target = composedPath.find((el) =>\n menuItemTypes.includes((el as HTMLElement)?.getAttribute?.('role') || '')\n );\n\n if (!target) return;\n\n const closestMenu = composedPath.find(\n (el) => (el as HTMLElement)?.getAttribute?.('role') === 'menu'\n );\n const clickHasSubmenu = closestMenu !== this;\n\n // Make sure we're the menu thats supposed to be handling the click event.\n if (clickHasSubmenu) {\n return;\n }\n\n // This isn't true. But we use it for TypeScript checks below.\n const item = target as MinidMenuItem;\n\n // if (item.type === 'checkbox') {\n // item.checked = !item.checked;\n // }\n\n this.dispatchEvent(\n new CustomEvent('mid-select', {\n bubbles: true,\n composed: true,\n detail: { item },\n })\n );\n }\n\n private handleFilterItems() {\n this.filter((item) =>\n item.innerText\n .toLowerCase()\n .includes(this.filterInput.value.toLowerCase())\n );\n\n const items = this.getAllSelectableItems();\n this.emptyItemList = items.length === 0;\n this.setCurrentItem(items[0]);\n }\n\n private scrollOptionIntoView(item: MinidMenuItem): void {\n scrollIntoView(item, this.itemList, 'vertical', 'auto');\n }\n\n private handleKeyDown(event: KeyboardEvent) {\n // Make a selection when pressing enter or space\n if (event.key === 'Enter' || event.key === ' ') {\n const item = this.getCurrentItem();\n event.preventDefault();\n event.stopPropagation();\n\n // Simulate a click to support @click handlers on menu items that also work with the keyboard\n item?.click();\n }\n\n // Move the selection when pressing down or up\n else if (['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(event.key)) {\n const items = this.getAllSelectableItems();\n const activeItem = this.getCurrentItem();\n let index = activeItem ? items.indexOf(activeItem) : 0;\n\n if (items.length > 0) {\n event.preventDefault();\n event.stopPropagation();\n\n if (event.key === 'ArrowDown') {\n index++;\n } else if (event.key === 'ArrowUp') {\n index--;\n } else if (event.key === 'Home') {\n index = 0;\n } else if (event.key === 'End') {\n index = items.length - 1;\n }\n\n if (index < 0) {\n index = items.length - 1;\n }\n if (index > items.length - 1) {\n index = 0;\n }\n\n this.setCurrentItem(items[index]);\n this.scrollOptionIntoView(items[index]);\n\n if (!this.searchable) {\n items[index].focus();\n }\n }\n }\n }\n\n private handleMouseDown(event: MouseEvent) {\n const target = event.target as HTMLElement;\n\n if (this.isMenuItem(target)) {\n this.setCurrentItem(target as MinidMenuItem);\n }\n }\n\n private handleSlotChange() {\n const items = this.getAllSelectableItems();\n\n // Reset the roving tab index when the slotted items change\n if (items.length > 0) {\n this.setCurrentItem(items[0]);\n }\n }\n\n private isMenuItem(item: HTMLElement) {\n return (\n item.tagName.toLowerCase() === 'mid-menu-item' ||\n ['menuitem', 'menuitemcheckbox', 'menuitemradio'].includes(\n item.getAttribute('role') ?? ''\n )\n );\n }\n\n /**\n * Pass a filter function to enable/disable menu items in the menu\n * @type {(item: MinidMenuItem) => boolean}\n */\n filter = (filterFn: (item: MinidMenuItem) => boolean) => {\n this.getAllItems().forEach((item) => {\n if (filterFn(item)) {\n item.removeAttribute('hidden');\n item.removeAttribute('inert');\n } else {\n item.setAttribute('inert', 'true');\n item.setAttribute('hidden', 'true');\n }\n });\n };\n\n clearFilter() {\n this.filterInput.value = '';\n this.itemList.scrollTop = 0;\n this.filterInput.dispatchEvent(new Event('input'));\n }\n\n /**\n * @internal Gets all slotted menu items, ignoring dividers, headers, and other elements.\n */\n getAllSelectableItems() {\n return [\n ...(this.defaultSlot.assignedElements({\n flatten: true,\n }) as MinidMenuItem[]),\n ].filter((el) => !(el.inert || !this.isMenuItem(el)));\n }\n\n getAllItems() {\n return [\n ...(this.defaultSlot.assignedElements({\n flatten: true,\n }) as MinidMenuItem[]),\n ].filter((el) => this.isMenuItem(el));\n }\n\n /**\n * @internal Gets the current menu item, which is the menu item that has `tabindex=\"0\"` within the roving tab index.\n * The menu item may or may not have focus, but for keyboard interaction purposes it's considered the \"active\" item.\n */\n getCurrentItem() {\n return this.getAllSelectableItems().find(\n (i) => i.getAttribute('tabindex') === '0'\n );\n }\n\n /**\n * @internal Sets the current menu item to the specified element. This sets `tabindex=\"0\"` on the target element and\n * `tabindex=\"-1\"` to all other items. This method must be called prior to setting focus on a menu item.\n */\n setCurrentItem(item: MinidMenuItem) {\n const items = this.getAllSelectableItems();\n\n // Update tab indexes\n items.forEach((i) => {\n i.setActive(i === item);\n i.setAttribute('tabindex', i === item ? '0' : '-1');\n });\n }\n\n focusSearchField() {\n if (this.searchable) {\n this.filterInput.focus();\n }\n }\n\n override render() {\n return html`\n <div\n class=\"text-body-md text-neutral border-neutral-subtle rounded-md border shadow-md\"\n >\n ${!this.searchable\n ? nothing\n : html`<div\n class=\"border-neutral-subtle flex items-center gap-2 border-b p-2\"\n >\n <mid-icon\n class=\"text-6\"\n slot=\"prefix\"\n library=\"system\"\n name=\"magnifying-glass\"\n >\n </mid-icon>\n <input\n @input=${this.handleFilterItems}\n @keydown=${this.handleKeyDown}\n class=\"filter-input border-neutral-subtle focus-visible:outline-focus-outer h-8 w-full rounded border px-2\"\n type=\"search\"\n />\n </div>`}\n <ul\n class=\"item-list max-h-(--max-height) max-w-(--max-width) overflow-y-auto px-2 py-3\"\n >\n <slot\n @slotchange=${this.handleSlotChange}\n @click=${this.handleClick}\n @keydown=${this.handleKeyDown}\n @mousedown=${this.handleMouseDown}\n ></slot>\n ${this.emptyItemList\n ? html`<div class=\"p-2\">Fant ingen treff</div>`\n : nothing}\n </ul>\n </div>\n `;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAYA,MAAM,SAAS;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAMF;AAMO,IAAM,YAAN,cAAwB,OAAO,YAAY,MAAM,EAAE;AAAA,EAAnD,cAAA;AAAA,UAAA,GAAA,SAAA;AAcQ,SAAA,aAAA;AAMsB,SAAA,UAAA;AAGnB,SAAA,gBAAA;AAkJhB,SAAA,SAAS,CAAC,aAA+C;AACvD,WAAK,YAAY,EAAE,QAAQ,CAAC,SAAS;AAC/B,YAAA,SAAS,IAAI,GAAG;AAClB,eAAK,gBAAgB,QAAQ;AAC7B,eAAK,gBAAgB,OAAO;AAAA,QAAA,OACvB;AACA,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C,KAAK,aACJ,UACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAWa,KAAK,iBAAiB;AAAA,2BACpB,KAAK,aAAa;AAAA;AAAA;AAAA;AAAA,mBAI1B;AAAA;AAAA;AAAA;AAAA;AAAA,0BAKO,KAAK,gBAAgB;AAAA,qBAC1B,KAAK,WAAW;AAAA,uBACd,KAAK,aAAa;AAAA,yBAChB,KAAK,eAAe;AAAA;AAAA,YAEjC,KAAK,gBACH,gDACA,OAAO;AAAA;AAAA;AAAA;AAAA,EAAA;AAKrB;AAlRE,gBAAA;AAAA,EADC,MAAM,MAAM;AAAA,GADF,UAEX,WAAA,eAAA,CAAA;AAGA,gBAAA;AAAA,EADC,MAAM,eAAe;AAAA,GAJX,UAKX,WAAA,eAAA,CAAA;AAGA,gBAAA;AAAA,EADC,MAAM,YAAY;AAAA,GAPR,UAQX,WAAA,YAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,QAAS,CAAA;AAAA,GAbhB,UAcX,WAAA,cAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS;AAAA,GAnBC,UAoBX,WAAA,WAAA,CAAA;AAGA,gBAAA;AAAA,EADC,MAAM;AAAA,GAtBI,UAuBX,WAAA,iBAAA,CAAA;AAvBW,YAAN,gBAAA;AAAA,EADN,cAAc,UAAU;AAAA,GACZ,SAAA;"}
|
|
1
|
+
{"version":3,"file":"menu.js","sources":["../../src/components/menu.component.ts"],"sourcesContent":["import { css, html, LitElement, nothing } from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { styled } from '../mixins/tailwind.mixin.ts';\nimport { MinidMenuItem } from './menu-item.component';\nimport { scrollIntoView } from '../internal/scroll';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-menu': MinidMenu;\n }\n}\n\nconst styles = [\n css`\n :host {\n --max-height: none;\n --max-width: none;\n }\n `,\n];\n\n/**\n * @event {{ detail: { item: MidMenuItem } }} mid-select - Emitted when a menu item is selected.\n */\n@customElement('mid-menu')\nexport class MinidMenu extends styled(LitElement, styles) {\n @query('slot')\n defaultSlot!: HTMLSlotElement;\n\n @query('.filter-input')\n filterInput!: HTMLInputElement;\n\n @query('.item-list')\n itemList!: HTMLUListElement;\n\n /**\n * Adds an input element that filters selectable menu items\n */\n @property({ type: Boolean })\n searchable = false;\n\n /**\n * Wether the menu should be styled as a dropdown or a combobox\n */\n @property()\n variant: 'combobox' | 'dropdown' = 'dropdown';\n\n @state()\n emptyItemList = false;\n\n protected firstUpdated(): void {\n this.getAllItems().forEach((item) => {\n item.variant = this.variant;\n item.addEventListener('mouseenter', () => {\n this.setCurrentItem(item);\n });\n });\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.setAttribute('role', 'menu');\n }\n\n private handleClick(event: MouseEvent) {\n const menuItemTypes = ['menuitem', 'menuitemcheckbox'];\n\n const composedPath = event.composedPath();\n const target = composedPath.find((el) =>\n menuItemTypes.includes((el as HTMLElement)?.getAttribute?.('role') || '')\n );\n\n if (!target) return;\n\n const closestMenu = composedPath.find(\n (el) => (el as HTMLElement)?.getAttribute?.('role') === 'menu'\n );\n const clickHasSubmenu = closestMenu !== this;\n\n // Make sure we're the menu thats supposed to be handling the click event.\n if (clickHasSubmenu) {\n return;\n }\n\n // This isn't true. But we use it for TypeScript checks below.\n const item = target as MinidMenuItem;\n\n // if (item.type === 'checkbox') {\n // item.checked = !item.checked;\n // }\n\n this.dispatchEvent(\n new CustomEvent('mid-select', {\n bubbles: true,\n composed: true,\n detail: { item },\n })\n );\n }\n\n private handleFilterItems() {\n this.filter((item) =>\n item.innerText\n .toLowerCase()\n .includes(this.filterInput.value.toLowerCase())\n );\n\n const items = this.getAllSelectableItems();\n this.emptyItemList = items.length === 0;\n this.setCurrentItem(items[0]);\n }\n\n private scrollOptionIntoView(item: MinidMenuItem): void {\n scrollIntoView(item, this.itemList, 'vertical', 'auto');\n }\n\n private handleKeyDown(event: KeyboardEvent) {\n // Make a selection when pressing enter or space\n if (event.key === 'Enter' || event.key === ' ') {\n const item = this.getCurrentItem();\n event.preventDefault();\n event.stopPropagation();\n\n // Simulate a click to support @click handlers on menu items that also work with the keyboard\n item?.click();\n }\n\n // Move the selection when pressing down or up\n else if (['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(event.key)) {\n const items = this.getAllSelectableItems();\n const activeItem = this.getCurrentItem();\n let index = activeItem ? items.indexOf(activeItem) : 0;\n\n if (items.length > 0) {\n event.preventDefault();\n event.stopPropagation();\n\n if (event.key === 'ArrowDown') {\n index++;\n } else if (event.key === 'ArrowUp') {\n index--;\n } else if (event.key === 'Home') {\n index = 0;\n } else if (event.key === 'End') {\n index = items.length - 1;\n }\n\n if (index < 0) {\n index = items.length - 1;\n }\n if (index > items.length - 1) {\n index = 0;\n }\n\n this.setCurrentItem(items[index]);\n this.scrollOptionIntoView(items[index]);\n\n if (!this.searchable) {\n items[index].focus();\n }\n }\n }\n }\n\n private handleMouseDown(event: MouseEvent) {\n const target = event.target as HTMLElement;\n\n if (this.isMenuItem(target)) {\n this.setCurrentItem(target as MinidMenuItem);\n }\n }\n\n private handleSlotChange() {\n const items = this.getAllSelectableItems();\n\n // Reset the roving tab index when the slotted items change\n if (items.length > 0) {\n this.setCurrentItem(items[0]);\n }\n }\n\n private isMenuItem(item: HTMLElement) {\n return (\n item.tagName.toLowerCase() === 'mid-menu-item' ||\n ['menuitem', 'menuitemcheckbox', 'menuitemradio'].includes(\n item.getAttribute('role') ?? ''\n )\n );\n }\n\n /**\n * Pass a filter function to enable/disable menu items in the menu\n * @type {(item: MinidMenuItem) => boolean}\n */\n filter = (filterFn: (item: MinidMenuItem) => boolean) => {\n this.getAllItems().forEach((item) => {\n if (filterFn(item)) {\n item.removeAttribute('hidden');\n item.removeAttribute('inert');\n } else {\n item.setAttribute('inert', 'true');\n item.setAttribute('hidden', 'true');\n }\n });\n };\n\n clearFilter() {\n this.filterInput.value = '';\n this.itemList.scrollTop = 0;\n this.filterInput.dispatchEvent(new Event('input'));\n }\n\n /**\n * @internal Gets all slotted menu items, ignoring dividers, headers, and other elements.\n */\n getAllSelectableItems() {\n return [\n ...(this.defaultSlot.assignedElements({\n flatten: true,\n }) as MinidMenuItem[]),\n ].filter((el) => !(el.inert || !this.isMenuItem(el)));\n }\n\n getAllItems() {\n return [\n ...(this.defaultSlot.assignedElements({\n flatten: true,\n }) as MinidMenuItem[]),\n ].filter((el) => this.isMenuItem(el));\n }\n\n /**\n * @internal Gets the current menu item, which is the menu item that has `tabindex=\"0\"` within the roving tab index.\n * The menu item may or may not have focus, but for keyboard interaction purposes it's considered the \"active\" item.\n */\n getCurrentItem() {\n return this.getAllSelectableItems().find(\n (i) => i.getAttribute('tabindex') === '0'\n );\n }\n\n /**\n * @internal Sets the current menu item to the specified element. This sets `tabindex=\"0\"` on the target element and\n * `tabindex=\"-1\"` to all other items. This method must be called prior to setting focus on a menu item.\n */\n setCurrentItem(item: MinidMenuItem) {\n const items = this.getAllSelectableItems();\n\n // Update tab indexes\n items.forEach((i) => {\n i.setActive(i === item);\n i.setAttribute('tabindex', i === item ? '0' : '-1');\n });\n }\n\n focusSearchField() {\n if (this.searchable) {\n this.filterInput.focus();\n }\n }\n\n override render() {\n return html`\n <div\n class=\"text-neutral border-neutral-subtle rounded-md border shadow-md\"\n >\n ${!this.searchable\n ? nothing\n : html`<div\n class=\"border-neutral-subtle flex items-center gap-2 border-b p-2\"\n >\n <mid-icon\n class=\"text-6\"\n slot=\"prefix\"\n library=\"system\"\n name=\"magnifying-glass\"\n >\n </mid-icon>\n <input\n @input=${this.handleFilterItems}\n @keydown=${this.handleKeyDown}\n class=\"filter-input border-neutral-subtle focus-visible:outline-focus-outer h-8 w-full rounded border px-2\"\n type=\"search\"\n />\n </div>`}\n <ul\n class=\"item-list max-h-(--max-height) max-w-(--max-width) overflow-y-auto px-2 py-3\"\n >\n <slot\n @slotchange=${this.handleSlotChange}\n @click=${this.handleClick}\n @keydown=${this.hand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A,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS;AAAA,GAnBC,UAoBX,WAAA,WAAA,CAAA;AAGA,gBAAA;AAAA,EADC,MAAM;AAAA,GAtBI,UAuBX,WAAA,iBAAA,CAAA;AAvBW,YAAN,gBAAA;AAAA,EADN,cAAc,UAAU;AAAA,GACZ,SAAA;"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
2
|
import { CountryCode } from 'libphonenumber-js';
|
|
3
|
-
import { HasSlotController } from '../internal/slot';
|
|
4
3
|
declare global {
|
|
5
4
|
interface HTMLElementTagNameMap {
|
|
6
5
|
'mid-phone-input': MinidPhoneInput;
|
|
@@ -21,8 +20,11 @@ declare const MinidPhoneInput_base: typeof LitElement & import('../types/mixin-c
|
|
|
21
20
|
* @part input - Select the phone number input
|
|
22
21
|
*/
|
|
23
22
|
export declare class MinidPhoneInput extends MinidPhoneInput_base {
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
private formatter;
|
|
24
|
+
private skipCountryUpdate;
|
|
25
|
+
private currentEvent;
|
|
26
|
+
private currentTemplate;
|
|
27
|
+
private hasSlotControler;
|
|
26
28
|
input: HTMLInputElement;
|
|
27
29
|
/**
|
|
28
30
|
* The value of the phone number in E.164 format. Example: `"+4799999999"`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phone-input.component.d.ts","sourceRoot":"","sources":["../../src/components/phone-input.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,MAAM,KAAK,CAAC;AAI5C,OAAO,EAIL,WAAW,EAEZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"phone-input.component.d.ts","sourceRoot":"","sources":["../../src/components/phone-input.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,MAAM,KAAK,CAAC;AAI5C,OAAO,EAIL,WAAW,EAEZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,uBAAuB,CAAC;AAW/B,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,iBAAiB,EAAE,eAAe,CAAC;KACpC;CACF;;AAUD;;;;;;;;;;;;GAYG;AACH,qBACa,eAAgB,SAAQ,oBAEpC;IACC,OAAO,CAAC,SAAS,CAAmB;IACpC,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,YAAY,CAAiB;IACrC,OAAO,CAAC,eAAe,CAAM;IAC7B,OAAO,CAAC,gBAAgB,CAAwC;IAGhE,KAAK,EAAG,gBAAgB,CAAC;IAEzB;;;OAGG;IAEH,KAAK,SAAM;IAEX;;OAEG;IAEH,cAAc,SAAM;IAEpB;;OAEG;IAEH,WAAW,SAAM;IAEjB;;;OAGG;IAEH,KAAK,SAAM;IAEX;;OAEG;IAEH,SAAS,UAAS;IAElB;;OAEG;IAEH,OAAO,CAAC,EAAE,WAAW,CAAC;IAGtB,QAAQ,UAAS;IAEjB,kBAAkB;IAMlB,oBAAoB,CAAC,KAAK,EAAE,aAAa;IAQzC,iBAAiB,IAAI,IAAI;IAkBzB,IAAI,aAAa,yCAEhB;IAED,IAAI,cAAc,0CAEjB;IAED,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,aAAa;IAerB,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,QAAQ;IAkBhB,OAAO,CAAC,mBAAmB,CAkBzB;IAEF,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,iBAAiB;IAUzB,KAAK;IAWL,mBAAmB;IAmBV,MAAM;CAiEhB"}
|
|
@@ -10,9 +10,6 @@ import { FormControllerMixin } from "../mixins/form-controller.mixin.js";
|
|
|
10
10
|
import { HasSlotController } from "../internal/slot.js";
|
|
11
11
|
var __defProp = Object.defineProperty;
|
|
12
12
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
-
var __typeError = (msg) => {
|
|
14
|
-
throw TypeError(msg);
|
|
15
|
-
};
|
|
16
13
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
17
14
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
18
15
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
@@ -21,11 +18,6 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
21
18
|
if (kind && result) __defProp(target, key, result);
|
|
22
19
|
return result;
|
|
23
20
|
};
|
|
24
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
25
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
26
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
27
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
|
|
28
|
-
var _formatter, _skipCountryUpdate, _currentEvent, _currentTemplate;
|
|
29
21
|
const styles = [
|
|
30
22
|
css`
|
|
31
23
|
:host {
|
|
@@ -38,10 +30,10 @@ let MinidPhoneInput = class extends FormControllerMixin(
|
|
|
38
30
|
) {
|
|
39
31
|
constructor() {
|
|
40
32
|
super(...arguments);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
this.formatter = new AsYouType();
|
|
34
|
+
this.skipCountryUpdate = false;
|
|
35
|
+
this.currentEvent = new Event("");
|
|
36
|
+
this.currentTemplate = "";
|
|
45
37
|
this.hasSlotControler = new HasSlotController(this, "label");
|
|
46
38
|
this.value = "";
|
|
47
39
|
this.nationalnumber = "";
|
|
@@ -50,15 +42,15 @@ let MinidPhoneInput = class extends FormControllerMixin(
|
|
|
50
42
|
this.hidelabel = false;
|
|
51
43
|
this.hasFocus = false;
|
|
52
44
|
this.valueChangeCallback = (value) => {
|
|
53
|
-
const country = value.length < 2 ? void 0 :
|
|
45
|
+
const country = value.length < 2 ? void 0 : this.formatter.getCountry() ?? this.country;
|
|
54
46
|
if (country !== this.country) {
|
|
55
47
|
this.country = country;
|
|
56
48
|
this.countrycode = this.country ? `+${getCountryCallingCode(this.country)}` : "+";
|
|
57
|
-
|
|
49
|
+
this.skipCountryUpdate = true;
|
|
58
50
|
}
|
|
59
51
|
this.value = value;
|
|
60
52
|
this.nationalnumber = this.removePhonePrefix(value);
|
|
61
|
-
this.dispatchEvent(
|
|
53
|
+
this.dispatchEvent(this.currentEvent);
|
|
62
54
|
this.setFormValue(this.value);
|
|
63
55
|
};
|
|
64
56
|
}
|
|
@@ -76,8 +68,8 @@ let MinidPhoneInput = class extends FormControllerMixin(
|
|
|
76
68
|
}
|
|
77
69
|
connectedCallback() {
|
|
78
70
|
super.connectedCallback();
|
|
79
|
-
|
|
80
|
-
this.country =
|
|
71
|
+
this.formatter.input(this.value);
|
|
72
|
+
this.country = this.formatter.getCountry() ?? this.country;
|
|
81
73
|
this.countrycode = this.country ? `+${getCountryCallingCode(this.country)}` : "+";
|
|
82
74
|
this.value = formatIncompletePhoneNumber(this.value);
|
|
83
75
|
this.value ??= this.countrycode;
|
|
@@ -87,10 +79,10 @@ let MinidPhoneInput = class extends FormControllerMixin(
|
|
|
87
79
|
}, 0);
|
|
88
80
|
}
|
|
89
81
|
get parseTemplate() {
|
|
90
|
-
return templateParser(
|
|
82
|
+
return templateParser(this.currentTemplate, parsePhoneNumberCharacter);
|
|
91
83
|
}
|
|
92
84
|
get formatTemplate() {
|
|
93
|
-
return templateFormatter(
|
|
85
|
+
return templateFormatter(this.currentTemplate);
|
|
94
86
|
}
|
|
95
87
|
handleBlur() {
|
|
96
88
|
this.hasFocus = false;
|
|
@@ -99,10 +91,10 @@ let MinidPhoneInput = class extends FormControllerMixin(
|
|
|
99
91
|
);
|
|
100
92
|
}
|
|
101
93
|
handleChange(event) {
|
|
102
|
-
|
|
94
|
+
this.currentEvent = new Event("mid-change", {
|
|
103
95
|
bubbles: true,
|
|
104
96
|
composed: true
|
|
105
|
-
})
|
|
97
|
+
});
|
|
106
98
|
this.setValue(event);
|
|
107
99
|
}
|
|
108
100
|
handleKeydown(event) {
|
|
@@ -119,19 +111,19 @@ let MinidPhoneInput = class extends FormControllerMixin(
|
|
|
119
111
|
);
|
|
120
112
|
}
|
|
121
113
|
handleInput(event) {
|
|
122
|
-
|
|
114
|
+
this.currentEvent = new Event("mid-input", {
|
|
123
115
|
composed: true,
|
|
124
116
|
bubbles: true
|
|
125
|
-
})
|
|
117
|
+
});
|
|
126
118
|
this.setValue(event);
|
|
127
119
|
}
|
|
128
120
|
setValue(event) {
|
|
129
|
-
|
|
121
|
+
this.formatter.reset();
|
|
130
122
|
if (!this.input.value.startsWith("+")) {
|
|
131
123
|
this.input.value = `+${this.input.value}`;
|
|
132
124
|
}
|
|
133
|
-
|
|
134
|
-
|
|
125
|
+
this.formatter.input(this.input.value);
|
|
126
|
+
this.currentTemplate = this.formatter.getTemplate();
|
|
135
127
|
onChange(
|
|
136
128
|
event,
|
|
137
129
|
this.input,
|
|
@@ -165,11 +157,11 @@ let MinidPhoneInput = class extends FormControllerMixin(
|
|
|
165
157
|
}, 0);
|
|
166
158
|
}
|
|
167
159
|
handleCountryChange() {
|
|
168
|
-
if (
|
|
169
|
-
|
|
160
|
+
if (this.skipCountryUpdate) {
|
|
161
|
+
this.skipCountryUpdate = false;
|
|
170
162
|
return;
|
|
171
163
|
}
|
|
172
|
-
|
|
164
|
+
this.formatter = new AsYouType(this.country);
|
|
173
165
|
this.nationalnumber = this.removePhonePrefix(this.input.value);
|
|
174
166
|
this.countrycode = this.country ? `+${getCountryCallingCode(this.country)}` : "+";
|
|
175
167
|
this.input.value = formatIncompletePhoneNumber(
|
|
@@ -224,7 +216,7 @@ let MinidPhoneInput = class extends FormControllerMixin(
|
|
|
224
216
|
|
|
225
217
|
<input
|
|
226
218
|
id="input"
|
|
227
|
-
class="border-neutral
|
|
219
|
+
class="border-neutral focus-visible:focus-ring grow rounded-r border px-3"
|
|
228
220
|
part="phone-number"
|
|
229
221
|
type="tel"
|
|
230
222
|
autocomplete="tel"
|
|
@@ -240,10 +232,6 @@ let MinidPhoneInput = class extends FormControllerMixin(
|
|
|
240
232
|
`;
|
|
241
233
|
}
|
|
242
234
|
};
|
|
243
|
-
_formatter = /* @__PURE__ */ new WeakMap();
|
|
244
|
-
_skipCountryUpdate = /* @__PURE__ */ new WeakMap();
|
|
245
|
-
_currentEvent = /* @__PURE__ */ new WeakMap();
|
|
246
|
-
_currentTemplate = /* @__PURE__ */ new WeakMap();
|
|
247
235
|
__decorateClass([
|
|
248
236
|
query("#input")
|
|
249
237
|
], MinidPhoneInput.prototype, "input", 2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phone-input.js","sources":["../../src/components/phone-input.component.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { styled } from '../mixins/tailwind.mixin';\nimport {\n AsYouType,\n formatIncompletePhoneNumber,\n getCountryCallingCode,\n CountryCode,\n parsePhoneNumberCharacter,\n} from 'libphonenumber-js';\nimport './icon/icon.component';\nimport {\n onChange,\n onKeyDown,\n templateFormatter,\n templateParser,\n} from 'input-format';\nimport { watch } from '../internal/watch';\nimport { FormControllerMixin } from '../mixins/form-controller.mixin';\nimport { HasSlotController } from '../internal/slot';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-phone-input': MinidPhoneInput;\n }\n}\n\nconst styles = [\n css`\n :host {\n display: block;\n }\n `,\n];\n\n/**\n * @event {Event} mid-country-click - Emitted when the country button is clicked\n * @event {Event} mid-change - Emitted when the value is modified by the user\n * @event {Event} mid-input - Emitted after a new user input\n * @event {Event} mid-blur - Emitted after focus is moved away from input\n * @event {Event} mid-focus - Emitted after input gains focus\n *\n * @part base - Select the container outside the country button and phone number input\n * @part field - Select the container around the label and the inputs\n * @part label - Select the label element\n * @part country-button - Select the country button\n * @part input - Select the phone number input\n */\n@customElement('mid-phone-input')\nexport class MinidPhoneInput extends FormControllerMixin(\n styled(LitElement, styles)\n) {\n #formatter = new AsYouType();\n #skipCountryUpdate = false; // avoids unwanted update loop\n #currentEvent = new Event(''); // the event to be emitted after value is set\n #currentTemplate = '';\n hasSlotControler = new HasSlotController(this, 'label');\n\n @query('#input')\n input!: HTMLInputElement;\n\n /**\n * The value of the phone number in E.164 format. Example: `\"+4799999999\"`\n *\n */\n @property({ reflect: true })\n value = '';\n\n /**\n * The phone number without the country code prefix. Example: `\"99999999\"`\n */\n @property({ reflect: true })\n nationalnumber = '';\n\n /**\n * The country code of the current phone number value. Example: `\"+47\"`\n */\n @property({ reflect: true })\n countrycode = '';\n\n /**\n * Label for the phone input.\n * Passed label will be encapsulated by a label element.\n */\n @property()\n label = '';\n\n /**\n * Hide label visually. Still available for screen readers\n */\n @property({ type: Boolean })\n hidelabel = false;\n\n /**\n * The country selected. A two letter ISO country code like: `\"NO\"`\n */\n @property({ reflect: true })\n country?: CountryCode;\n\n @state()\n hasFocus = false;\n\n handleCountryClick() {\n this.dispatchEvent(\n new CustomEvent('mid-country-click', { composed: true, bubbles: true })\n );\n }\n\n handleCountryKeyDown(event: KeyboardEvent) {\n if ([' ', 'Enter'].includes(event.key)) {\n this.dispatchEvent(\n new CustomEvent('mid-country-click', { composed: true, bubbles: true })\n );\n }\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n\n this.#formatter.input(this.value);\n this.country = this.#formatter.getCountry() ?? this.country;\n this.countrycode = this.country\n ? `+${getCountryCallingCode(this.country)}`\n : '+';\n\n this.value = formatIncompletePhoneNumber(this.value);\n this.value ??= this.countrycode;\n this.nationalnumber = this.removePhonePrefix(this.value);\n\n setTimeout(() => {\n this.input.value = `${this.countrycode}${this.nationalnumber}`;\n }, 0);\n }\n\n get parseTemplate() {\n return templateParser(this.#currentTemplate, parsePhoneNumberCharacter);\n }\n\n get formatTemplate() {\n return templateFormatter(this.#currentTemplate);\n }\n\n private handleBlur() {\n this.hasFocus = false;\n this.dispatchEvent(\n new Event('mid-blur', { bubbles: true, composed: true })\n );\n }\n\n private handleChange(event: Event) {\n // Event is dispatched after value is set\n this.#currentEvent = new Event('mid-change', {\n bubbles: true,\n composed: true,\n });\n\n this.setValue(event);\n }\n\n private handleKeydown(event: KeyboardEvent) {\n if (event.key === 'Backspace' && this.input.selectionStart === 1) {\n event.preventDefault();\n return;\n }\n\n onKeyDown(\n event,\n this.input,\n this.parseTemplate,\n this.formatTemplate,\n this.valueChangeCallback\n );\n }\n\n private handleInput(event: InputEvent) {\n // Event is dispatched after value is set\n this.#currentEvent = new Event('mid-input', {\n composed: true,\n bubbles: true,\n });\n this.setValue(event);\n }\n\n private setValue(event: Event) {\n this.#formatter.reset();\n\n if (!this.input.value.startsWith('+')) {\n this.input.value = `+${this.input.value}`;\n }\n this.#formatter.input(this.input.value);\n this.#currentTemplate = this.#formatter.getTemplate();\n\n onChange(\n event,\n this.input,\n this.parseTemplate,\n this.formatTemplate,\n this.valueChangeCallback\n );\n }\n\n private valueChangeCallback = (value: string) => {\n const country =\n value.length < 2\n ? undefined\n : (this.#formatter.getCountry() ?? this.country);\n\n if (country !== this.country) {\n this.country = country;\n this.countrycode = this.country\n ? `+${getCountryCallingCode(this.country)}`\n : '+';\n this.#skipCountryUpdate = true;\n }\n\n this.value = value;\n this.nationalnumber = this.removePhonePrefix(value);\n this.dispatchEvent(this.#currentEvent);\n this.setFormValue(this.value);\n };\n\n private handleFocus() {\n this.hasFocus = true;\n this.dispatchEvent(\n new Event('mid-focus', { composed: true, bubbles: true })\n );\n }\n\n private removePhonePrefix(value: string) {\n if (this.countrycode) {\n value = value.slice(this.countrycode.length);\n if (value[0] === ' ') {\n value = value.slice(1);\n }\n }\n return value;\n }\n\n focus() {\n this.input.focus();\n setTimeout(() => {\n this.input.setSelectionRange(\n (this.countrycode?.length ?? 0) + 1,\n this.input.value.length\n );\n }, 0);\n }\n\n @watch('country', { waitUntilFirstUpdate: true })\n handleCountryChange() {\n if (this.#skipCountryUpdate) {\n this.#skipCountryUpdate = false;\n return;\n }\n\n this.#formatter = new AsYouType(this.country);\n this.nationalnumber = this.removePhonePrefix(this.input.value);\n\n this.countrycode = this.country\n ? `+${getCountryCallingCode(this.country)}`\n : '+';\n this.input.value = formatIncompletePhoneNumber(\n `${this.countrycode}${this.nationalnumber}`\n );\n this.input.dispatchEvent(new Event('input', { bubbles: true }));\n this.input.dispatchEvent(new Event('change', { bubbles: true }));\n }\n\n override render() {\n const lg = false;\n const md = true;\n const sm = false;\n\n const hasLabelSlot = this.hasSlotControler.test('label');\n const hasLabel = !!this.label || !!hasLabelSlot;\n\n return html`\n <div\n part=\"field\"\n class=\"${classMap({\n 'text-body-sm': sm,\n 'text-body-md': md,\n 'text-body-lg': lg,\n })} grow\"\n >\n <label\n for=\"input\"\n class=\"${classMap({\n 'sr-only': this.hidelabel || !hasLabel,\n })} mb-2 inline-flex items-center gap-1 font-medium\"\n >\n <slot name=\"label\"> ${this.label} </slot>\n </label>\n <div part=\"base\" class=\"flex h-12\">\n <button\n part=\"country-button\"\n class=\"border-neutral focus-visible:focus-ring flex h-full items-center rounded-l border border-r-0 pl-3\"\n iconstyled\n variant=\"tertiary\"\n @click=${this.handleCountryClick}\n @keydown=${this.handleCountryKeyDown}\n >\n ${this.country\n ? html`\n <mid-icon\n class=\"h-4 w-6 overflow-hidden rounded\"\n library=\"country\"\n name=\"${this.country}\"\n ></mid-icon>\n `\n : html`<div\n class=\"bg-neutral-surface-active h-4 w-6 overflow-hidden rounded\"\n ></div>`}\n <mid-icon name=\"chevron-down\"></mid-icon>\n </button>\n\n <input\n id=\"input\"\n class=\"border-neutral p focus-visible:focus-ring grow rounded-r border px-3\"\n part=\"phone-number\"\n type=\"tel\"\n autocomplete=\"tel\"\n value=${this.value}\n @input=${this.handleInput}\n @focus=${this.handleFocus}\n @blur=${this.handleBlur}\n @keydown=${this.handleKeydown}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,uBACZ,KAAK,aAAa;AAAA,sBACnB,KAAK,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA,EAAA;AAMvC;AAzRE,aAAA,oBAAA,QAAA;AACA,qBAAA,oBAAA,QAAA;AACA,gBAAA,oBAAA,QAAA;AACA,mBAAA,oBAAA,QAAA;AAIA,gBAAA;AAAA,EADC,MAAM,QAAQ;AAAA,GATJ,gBAUX,WAAA,SAAA,CAAA;AAOA,gBAAA;AAAA,EADC,SAAS,EAAE,SAAS,KAAM,CAAA;AAAA,GAhBhB,gBAiBX,WAAA,SAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,SAAS,KAAM,CAAA;AAAA,GAtBhB,gBAuBX,WAAA,kBAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,SAAS,KAAM,CAAA;AAAA,GA5BhB,gBA6BX,WAAA,eAAA,CAAA;AAOA,gBAAA;AAAA,EADC,SAAS;AAAA,GAnCC,gBAoCX,WAAA,SAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,QAAS,CAAA;AAAA,GAzChB,gBA0CX,WAAA,aAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,SAAS,KAAM,CAAA;AAAA,GA/ChB,gBAgDX,WAAA,WAAA,CAAA;AAGA,gBAAA;AAAA,EADC,MAAM;AAAA,GAlDI,gBAmDX,WAAA,YAAA,CAAA;AAqJA,gBAAA;AAAA,EADC,MAAM,WAAW,EAAE,sBAAsB,KAAM,CAAA;AAAA,GAvMrC,gBAwMX,WAAA,uBAAA,CAAA;AAxMW,kBAAN,gBAAA;AAAA,EADN,cAAc,iBAAiB;AAAA,GACnB,eAAA;"}
|
|
1
|
+
{"version":3,"file":"phone-input.js","sources":["../../src/components/phone-input.component.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { styled } from '../mixins/tailwind.mixin';\nimport {\n AsYouType,\n formatIncompletePhoneNumber,\n getCountryCallingCode,\n CountryCode,\n parsePhoneNumberCharacter,\n} from 'libphonenumber-js';\nimport './icon/icon.component';\nimport {\n onChange,\n onKeyDown,\n templateFormatter,\n templateParser,\n} from 'input-format';\nimport { watch } from '../internal/watch';\nimport { FormControllerMixin } from '../mixins/form-controller.mixin';\nimport { HasSlotController } from '../internal/slot';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-phone-input': MinidPhoneInput;\n }\n}\n\nconst styles = [\n css`\n :host {\n display: block;\n }\n `,\n];\n\n/**\n * @event {Event} mid-country-click - Emitted when the country button is clicked\n * @event {Event} mid-change - Emitted when the value is modified by the user\n * @event {Event} mid-input - Emitted after a new user input\n * @event {Event} mid-blur - Emitted after focus is moved away from input\n * @event {Event} mid-focus - Emitted after input gains focus\n *\n * @part base - Select the container outside the country button and phone number input\n * @part field - Select the container around the label and the inputs\n * @part label - Select the label element\n * @part country-button - Select the country button\n * @part input - Select the phone number input\n */\n@customElement('mid-phone-input')\nexport class MinidPhoneInput extends FormControllerMixin(\n styled(LitElement, styles)\n) {\n private formatter = new AsYouType();\n private skipCountryUpdate = false; // avoids unwanted update loop\n private currentEvent = new Event(''); // the event to be emitted after value is set\n private currentTemplate = '';\n private hasSlotControler = new HasSlotController(this, 'label');\n\n @query('#input')\n input!: HTMLInputElement;\n\n /**\n * The value of the phone number in E.164 format. Example: `\"+4799999999\"`\n *\n */\n @property({ reflect: true })\n value = '';\n\n /**\n * The phone number without the country code prefix. Example: `\"99999999\"`\n */\n @property({ reflect: true })\n nationalnumber = '';\n\n /**\n * The country code of the current phone number value. Example: `\"+47\"`\n */\n @property({ reflect: true })\n countrycode = '';\n\n /**\n * Label for the phone input.\n * Passed label will be encapsulated by a label element.\n */\n @property()\n label = '';\n\n /**\n * Hide label visually. Still available for screen readers\n */\n @property({ type: Boolean })\n hidelabel = false;\n\n /**\n * The country selected. A two letter ISO country code like: `\"NO\"`\n */\n @property({ reflect: true })\n country?: CountryCode;\n\n @state()\n hasFocus = false;\n\n handleCountryClick() {\n this.dispatchEvent(\n new CustomEvent('mid-country-click', { composed: true, bubbles: true })\n );\n }\n\n handleCountryKeyDown(event: KeyboardEvent) {\n if ([' ', 'Enter'].includes(event.key)) {\n this.dispatchEvent(\n new CustomEvent('mid-country-click', { composed: true, bubbles: true })\n );\n }\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n\n this.formatter.input(this.value);\n this.country = this.formatter.getCountry() ?? this.country;\n this.countrycode = this.country\n ? `+${getCountryCallingCode(this.country)}`\n : '+';\n\n this.value = formatIncompletePhoneNumber(this.value);\n this.value ??= this.countrycode;\n this.nationalnumber = this.removePhonePrefix(this.value);\n\n setTimeout(() => {\n this.input.value = `${this.countrycode}${this.nationalnumber}`;\n }, 0);\n }\n\n get parseTemplate() {\n return templateParser(this.currentTemplate, parsePhoneNumberCharacter);\n }\n\n get formatTemplate() {\n return templateFormatter(this.currentTemplate);\n }\n\n private handleBlur() {\n this.hasFocus = false;\n this.dispatchEvent(\n new Event('mid-blur', { bubbles: true, composed: true })\n );\n }\n\n private handleChange(event: Event) {\n // Event is dispatched after value is set\n this.currentEvent = new Event('mid-change', {\n bubbles: true,\n composed: true,\n });\n\n this.setValue(event);\n }\n\n private handleKeydown(event: KeyboardEvent) {\n if (event.key === 'Backspace' && this.input.selectionStart === 1) {\n event.preventDefault();\n return;\n }\n\n onKeyDown(\n event,\n this.input,\n this.parseTemplate,\n this.formatTemplate,\n this.valueChangeCallback\n );\n }\n\n private handleInput(event: InputEvent) {\n // Event is dispatched after value is set\n this.currentEvent = new Event('mid-input', {\n composed: true,\n bubbles: true,\n });\n this.setValue(event);\n }\n\n private setValue(event: Event) {\n this.formatter.reset();\n\n if (!this.input.value.startsWith('+')) {\n this.input.value = `+${this.input.value}`;\n }\n this.formatter.input(this.input.value);\n this.currentTemplate = this.formatter.getTemplate();\n\n onChange(\n event,\n this.input,\n this.parseTemplate,\n this.formatTemplate,\n this.valueChangeCallback\n );\n }\n\n private valueChangeCallback = (value: string) => {\n const country =\n value.length < 2\n ? undefined\n : (this.formatter.getCountry() ?? this.country);\n\n if (country !== this.country) {\n this.country = country;\n this.countrycode = this.country\n ? `+${getCountryCallingCode(this.country)}`\n : '+';\n this.skipCountryUpdate = true;\n }\n\n this.value = value;\n this.nationalnumber = this.removePhonePrefix(value);\n this.dispatchEvent(this.currentEvent);\n this.setFormValue(this.value);\n };\n\n private handleFocus() {\n this.hasFocus = true;\n this.dispatchEvent(\n new Event('mid-focus', { composed: true, bubbles: true })\n );\n }\n\n private removePhonePrefix(value: string) {\n if (this.countrycode) {\n value = value.slice(this.countrycode.length);\n if (value[0] === ' ') {\n value = value.slice(1);\n }\n }\n return value;\n }\n\n focus() {\n this.input.focus();\n setTimeout(() => {\n this.input.setSelectionRange(\n (this.countrycode?.length ?? 0) + 1,\n this.input.value.length\n );\n }, 0);\n }\n\n @watch('country', { waitUntilFirstUpdate: true })\n handleCountryChange() {\n if (this.skipCountryUpdate) {\n this.skipCountryUpdate = false;\n return;\n }\n\n this.formatter = new AsYouType(this.country);\n this.nationalnumber = this.removePhonePrefix(this.input.value);\n\n this.countrycode = this.country\n ? `+${getCountryCallingCode(this.country)}`\n : '+';\n this.input.value = formatIncompletePhoneNumber(\n `${this.countrycode}${this.nationalnumber}`\n );\n this.input.dispatchEvent(new Event('input', { bubbles: true }));\n this.input.dispatchEvent(new Event('change', { bubbles: true }));\n }\n\n override render() {\n const lg = false;\n const md = true;\n const sm = false;\n\n const hasLabelSlot = this.hasSlotControler.test('label');\n const hasLabel = !!this.label || !!hasLabelSlot;\n\n return html`\n <div\n part=\"field\"\n class=\"${classMap({\n 'text-body-sm': sm,\n 'text-body-md': md,\n 'text-body-lg': lg,\n })} grow\"\n >\n <label\n for=\"input\"\n class=\"${classMap({\n 'sr-only': this.hidelabel || !hasLabel,\n })} mb-2 inline-flex items-center gap-1 font-medium\"\n >\n <slot name=\"label\"> ${this.label} </slot>\n </label>\n <div part=\"base\" class=\"flex h-12\">\n <button\n part=\"country-button\"\n class=\"border-neutral focus-visible:focus-ring flex h-full items-center rounded-l border border-r-0 pl-3\"\n iconstyled\n variant=\"tertiary\"\n @click=${this.handleCountryClick}\n @keydown=${this.handleCountryKeyDown}\n >\n ${this.country\n ? html`\n <mid-icon\n class=\"h-4 w-6 overflow-hidden rounded\"\n library=\"country\"\n name=\"${this.country}\"\n ></mid-icon>\n `\n : html`<div\n class=\"bg-neutral-surface-active h-4 w-6 overflow-hidden rounded\"\n ></div>`}\n <mid-icon name=\"chevron-down\"></mid-icon>\n </button>\n\n <input\n id=\"input\"\n class=\"border-neutral focus-visible:focus-ring grow rounded-r border px-3\"\n part=\"phone-number\"\n type=\"tel\"\n autocomplete=\"tel\"\n value=${this.value}\n @input=${this.handleInput}\n @focus=${this.handleFocus}\n @blur=${this.handleBlur}\n @keydown=${this.handleKeydown}\n @change=${this.handleChange}\n />\n </div>\n </div>\n `;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AA4BA,MAAM,SAAS;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAKF;AAgBO,IAAM,kBAAN,cAA8B;AAAA,EACnC,OAAO,YAAY,MAAM;AAC3B,EAAE;AAAA,EAFK,cAAA;AAAA,UAAA,GAAA,SAAA;AAGG,SAAA,YAAY,IAAI,UAAU;AAClC,SAAQ,oBAAoB;AACpB,SAAA,eAAe,IAAI,MAAM,EAAE;AACnC,SAAQ,kBAAkB;AAC1B,SAAQ,mBAAmB,IAAI,kBAAkB,MAAM,OAAO;AAUtD,SAAA,QAAA;AAMS,SAAA,iBAAA;AAMH,SAAA,cAAA;AAON,SAAA,QAAA;AAMI,SAAA,YAAA;AASD,SAAA,WAAA;AAqGH,SAAA,sBAAsB,CAAC,UAAkB;AACzC,YAAA,UACJ,MAAM,SAAS,IACX,SACC,KAAK,UAAU,gBAAgB,KAAK;AAEvC,UAAA,YAAY,KAAK,SAAS;AAC5B,aAAK,UAA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ACnB,eAAA;"}
|
|
@@ -40,7 +40,6 @@ declare const MinidPopup_base: typeof LitElement;
|
|
|
40
40
|
* available when using `auto-size`.
|
|
41
41
|
*/
|
|
42
42
|
export declare class MinidPopup extends MinidPopup_base {
|
|
43
|
-
#private;
|
|
44
43
|
private anchorEl;
|
|
45
44
|
private cleanup?;
|
|
46
45
|
/**
|
|
@@ -167,6 +166,7 @@ export declare class MinidPopup extends MinidPopup_base {
|
|
|
167
166
|
/** Forces the popup to recalculate and reposition itself. */
|
|
168
167
|
reposition(): void;
|
|
169
168
|
private updateHoverBridge;
|
|
169
|
+
private handleAnchorClick;
|
|
170
170
|
render(): import('lit-html').TemplateResult<1>;
|
|
171
171
|
}
|
|
172
172
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popup.component.d.ts","sourceRoot":"","sources":["../../src/components/popup.component.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAa,UAAU,EAAE,MAAM,KAAK,CAAC;AAK5C,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,UAAU,CAAC;KACzB;CACF;AAED,MAAM,WAAW,cAAc;IAC7B,qBAAqB,EAAE,MAAM,OAAO,CAAC;IACrC,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;;AAkHD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,qBACa,UAAW,SAAQ,eAA0B
|
|
1
|
+
{"version":3,"file":"popup.component.d.ts","sourceRoot":"","sources":["../../src/components/popup.component.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAa,UAAU,EAAE,MAAM,KAAK,CAAC;AAK5C,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,UAAU,CAAC;KACzB;CACF;AAED,MAAM,WAAW,cAAc;IAC7B,qBAAqB,EAAE,MAAM,OAAO,CAAC;IACrC,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;;AAkHD;;;;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,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;IAEnC;;;;OAIG;IAEH,gBAAgB,CAAC,EAAE,OAAO,GAAG,OAAO,EAAE,CAAC;IAEvC;;OAEG;IACyD,eAAe,SACvE;IAEJ;;;;;OAKG;IACqD,WAAW,UAAS;IAEtE,iBAAiB;IAQvB,oBAAoB;IAKd,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;YAwBlC,kBAAkB;IAgChC,OAAO,CAAC,KAAK;YAWC,IAAI;IAelB,6DAA6D;IAC7D,UAAU;IAiNV,OAAO,CAAC,iBAAiB,CAsFvB;IAEF,OAAO,CAAC,iBAAiB;IAWzB,MAAM;CAoCP"}
|
package/dist/components/popup.js
CHANGED
|
@@ -6,9 +6,6 @@ import { styled } from "../mixins/tailwind.mixin.js";
|
|
|
6
6
|
import { offsetParent } from "composed-offset-position";
|
|
7
7
|
var __defProp = Object.defineProperty;
|
|
8
8
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
-
var __typeError = (msg) => {
|
|
10
|
-
throw TypeError(msg);
|
|
11
|
-
};
|
|
12
9
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
13
10
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
14
11
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
@@ -17,10 +14,6 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
17
14
|
if (kind && result) __defProp(target, key, result);
|
|
18
15
|
return result;
|
|
19
16
|
};
|
|
20
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
21
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
22
|
-
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
23
|
-
var _MinidPopup_instances, handleAnchorClick_fn;
|
|
24
17
|
function isVirtualElement(e) {
|
|
25
18
|
return e !== null && typeof e === "object" && "getBoundingClientRect" in e && ("contextElement" in e ? e instanceof Element : true);
|
|
26
19
|
}
|
|
@@ -129,7 +122,6 @@ const styles = [
|
|
|
129
122
|
let MinidPopup = class extends styled(LitElement, styles) {
|
|
130
123
|
constructor() {
|
|
131
124
|
super(...arguments);
|
|
132
|
-
__privateAdd(this, _MinidPopup_instances);
|
|
133
125
|
this.anchorEl = null;
|
|
134
126
|
this.anchor = "";
|
|
135
127
|
this.active = false;
|
|
@@ -430,12 +422,21 @@ let MinidPopup = class extends styled(LitElement, styles) {
|
|
|
430
422
|
requestAnimationFrame(() => this.updateHoverBridge());
|
|
431
423
|
this.dispatchEvent(new Event("mid-reposition"));
|
|
432
424
|
}
|
|
425
|
+
handleAnchorClick() {
|
|
426
|
+
this.dispatchEvent(
|
|
427
|
+
new CustomEvent("mid-anchor-click", {
|
|
428
|
+
bubbles: true,
|
|
429
|
+
composed: true,
|
|
430
|
+
detail: { id: this.id }
|
|
431
|
+
})
|
|
432
|
+
);
|
|
433
|
+
}
|
|
433
434
|
render() {
|
|
434
435
|
return html`
|
|
435
436
|
<slot
|
|
436
437
|
name="anchor"
|
|
437
438
|
@slotchange=${this.handleAnchorChange}
|
|
438
|
-
@click=${
|
|
439
|
+
@click=${this.handleAnchorClick}
|
|
439
440
|
></slot>
|
|
440
441
|
|
|
441
442
|
<span
|
|
@@ -465,16 +466,6 @@ let MinidPopup = class extends styled(LitElement, styles) {
|
|
|
465
466
|
`;
|
|
466
467
|
}
|
|
467
468
|
};
|
|
468
|
-
_MinidPopup_instances = /* @__PURE__ */ new WeakSet();
|
|
469
|
-
handleAnchorClick_fn = function() {
|
|
470
|
-
this.dispatchEvent(
|
|
471
|
-
new CustomEvent("mid-anchor-click", {
|
|
472
|
-
bubbles: true,
|
|
473
|
-
composed: true,
|
|
474
|
-
detail: { id: this.id }
|
|
475
|
-
})
|
|
476
|
-
);
|
|
477
|
-
};
|
|
478
469
|
__decorateClass([
|
|
479
470
|
query(".popup")
|
|
480
471
|
], MinidPopup.prototype, "popup", 2);
|
|
@@ -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 #handleAnchorClick() {\n // to make sure clicking another element's anchor closes current element's dropdown menu\n this.dispatchEvent(\n new CustomEvent('mid-anchor-click', {\n bubbles: true,\n composed: true,\n detail: { id: this.id },\n })\n );\n }\n\n render() {\n return html`\n <slot\n name=\"anchor\"\n @slotchange=${this.handleAnchorChange}\n @click=${this.#handleAnchorClick}\n ></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":";;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,uBAAA;AAuCA,SAAS,iBAAiB,GAAiC;AAEvD,SAAA,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;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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S,EAAE,WAAW,iBAAiB,MAAM,OAAQ,CAAA;AAAA,GA5J3C,WA6JX,WAAA,gBAAA,CAAA;AAGsC,gBAAA;AAAA,EAArC,SAAS,EAAE,WAAW,YAAa,CAAA;AAAA,GAhKzB,WAgK2B,WAAA,YAAA,CAAA;AAStC,gBAAA;AAAA,EADC,SAAS;AAAA,GAxKC,WAyKX,WAAA,QAAA,CAAA;AAQA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,OAAQ,CAAA;AAAA,GAhLf,WAiLX,WAAA,oBAAA,CAAA;AAK4D,gBAAA;AAAA,EAA3D,SAAS,EAAE,WAAW,qBAAqB,MAAM,OAAQ,CAAA;AAAA,GAtL/C,WAsLiD,WAAA,mBAAA,CAAA;AASJ,gBAAA;AAAA,EAAvD,SAAS,EAAE,WAAW,gBAAgB,MAAM,QAAS,CAAA;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 private handleAnchorClick() {\n // to make sure clicking another element's anchor closes current element's dropdown menu\n this.dispatchEvent(\n new CustomEvent('mid-anchor-click', {\n bubbles: true,\n composed: true,\n detail: { id: this.id },\n })\n );\n }\n\n render() {\n return html`\n <slot\n name=\"anchor\"\n @slotchange=${this.handleAnchorChange}\n @click=${this.handleAnchorClick}\n ></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;AAEvD,SAAA,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;A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