@felleslosninger/minid-elements 0.0.100 → 0.0.102
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.map +1 -1
- package/dist/components/alert.js +3 -4
- package/dist/components/alert.js.map +1 -1
- package/dist/components/button.component.d.ts +3 -2
- package/dist/components/button.component.d.ts.map +1 -1
- package/dist/components/button.js +12 -5
- package/dist/components/button.js.map +1 -1
- package/dist/components/combobox.component.d.ts +2 -2
- package/dist/components/combobox.component.d.ts.map +1 -1
- package/dist/components/combobox.js +1 -1
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/dropdown.component.d.ts +47 -3
- package/dist/components/dropdown.component.d.ts.map +1 -1
- package/dist/components/dropdown.js +262 -29
- package/dist/components/dropdown.js.map +1 -1
- package/dist/components/link.js +1 -1
- package/dist/components/link.js.map +1 -1
- package/dist/components/menu-item.component.d.ts +3 -0
- package/dist/components/menu-item.component.d.ts.map +1 -1
- package/dist/components/menu-item.js +20 -2
- package/dist/components/menu-item.js.map +1 -1
- package/dist/components/menu.component.d.ts +1 -1
- package/dist/components/menu.component.d.ts.map +1 -1
- package/dist/components/menu.js +4 -4
- package/dist/components/menu.js.map +1 -1
- package/dist/components/phone-input.js +1 -1
- package/dist/components/phone-input.js.map +1 -1
- package/dist/components/popup.component.d.ts +0 -1
- package/dist/components/popup.component.d.ts.map +1 -1
- package/dist/components/popup.js +1 -14
- package/dist/components/popup.js.map +1 -1
- package/dist/components/step-indicator.component.d.ts +14 -0
- package/dist/components/step-indicator.component.d.ts.map +1 -0
- package/dist/components/step-indicator.js +58 -0
- package/dist/components/step-indicator.js.map +1 -0
- package/dist/events/events.d.ts +2 -0
- package/dist/events/events.d.ts.map +1 -0
- package/dist/events/mid-select.d.ts +10 -0
- package/dist/events/mid-select.d.ts.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/mixins/tailwind.mixin.js +2 -2
- package/package.json +9 -6
|
@@ -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 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,SAA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AAA,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 })}\"\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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AAA,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;"}
|
|
@@ -166,7 +166,6 @@ export declare class MinidPopup extends MinidPopup_base {
|
|
|
166
166
|
/** Forces the popup to recalculate and reposition itself. */
|
|
167
167
|
reposition(): void;
|
|
168
168
|
private updateHoverBridge;
|
|
169
|
-
private handleAnchorClick;
|
|
170
169
|
render(): import('lit-html').TemplateResult<1>;
|
|
171
170
|
}
|
|
172
171
|
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;IACxD,OAAO,CAAC,QAAQ,CAAyC;IACzD,OAAO,CAAC,OAAO,CAAC,CAAgC;IAEhD;;OAEG;IAEH,KAAK,EAAG,WAAW,CAAC;I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;IAEH,cAAc,EAAE,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAY;IAEjE;;;OAGG;IAEH,YAAY,SAAM;IAElB;;;OAGG;IAEH,IAAI,UAAS;IAEb;;;;OAIG;IAeH,sBAAsB,SAAM;IAE5B;;;;OAIG;IAEH,oBAAoB,EAAE,UAAU,GAAG,SAAS,CAAc;IAE1D;;;;OAIG;IAEH,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,EAAE,CAAC;IAEnC;;OAEG;IAEH,WAAW,SAAK;IAEhB;;OAEG;IAEH,KAAK,UAAS;IAEd;;;;OAIG;IAEH,aAAa,CAAC,EAAE,OAAO,GAAG,OAAO,EAAE,CAAC;IAEpC;;OAEG;IAEH,YAAY,SAAK;IAEjB,yGAAyG;IACnE,QAAQ,CAAC,EAC3C,YAAY,GACZ,UAAU,GACV,MAAM,CAAC;IAEX;;OAEG;IAEH,IAAI,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,MAAM;CAgCP"}
|
package/dist/components/popup.js
CHANGED
|
@@ -422,22 +422,9 @@ let MinidPopup = class extends styled(LitElement, styles) {
|
|
|
422
422
|
requestAnimationFrame(() => this.updateHoverBridge());
|
|
423
423
|
this.dispatchEvent(new Event("mid-reposition"));
|
|
424
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
|
-
}
|
|
434
425
|
render() {
|
|
435
426
|
return html`
|
|
436
|
-
<slot
|
|
437
|
-
name="anchor"
|
|
438
|
-
@slotchange=${this.handleAnchorChange}
|
|
439
|
-
@click=${this.handleAnchorClick}
|
|
440
|
-
></slot>
|
|
427
|
+
<slot name="anchor" @slotchange=${this.handleAnchorChange}></slot>
|
|
441
428
|
|
|
442
429
|
<span
|
|
443
430
|
part="hover-bridge"
|
|
@@ -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 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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,QAAS,CAAA;AAAA,GA9IhB,WA+IX,WAAA,SAAA,CAAA;AAQA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,OAAQ,CAAA;AAAA,GAtJf,WAuJX,WAAA,iBAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,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 render() {\n return html`\n <slot name=\"anchor\" @slotchange=${this.handleAnchorChange}></slot>\n\n <span\n part=\"hover-bridge\"\n class=${classMap({\n 'popup-hover-bridge': true,\n 'popup-hover-bridge--visible': this.hoverBridge && this.active,\n })}\n ></span>\n\n <div\n part=\"popup\"\n class=${classMap({\n popup: true,\n 'popup--active': this.active,\n 'popup--fixed': this.strategy === 'fixed',\n 'popup--has-arrow': this.arrow,\n })}\n >\n <slot></slot>\n ${this.arrow\n ? html`<div\n part=\"arrow\"\n class=\"popup__arrow\"\n role=\"presentation\"\n ></div>`\n : ''}\n </div>\n `;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAuCA,SAAS,iBAAiB,GAAiC;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;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AA,GAxI1C,WAyIX,WAAA,eAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,QAAS,CAAA;AAAA,GA9IhB,WA+IX,WAAA,SAAA,CAAA;AAQA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,OAAQ,CAAA;AAAA,GAtJf,WAuJX,WAAA,iBAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,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;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
declare global {
|
|
3
|
+
interface HTMLElementTagNameMap {
|
|
4
|
+
'mid-step-indicator': MinidStepIndicator;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
declare const MinidStepIndicator_base: typeof LitElement;
|
|
8
|
+
export declare class MinidStepIndicator extends MinidStepIndicator_base {
|
|
9
|
+
steps: number;
|
|
10
|
+
current: number;
|
|
11
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=step-indicator.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-indicator.component.d.ts","sourceRoot":"","sources":["../../src/components/step-indicator.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,MAAM,KAAK,CAAC;AAK5C,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,oBAAoB,EAAE,kBAAkB,CAAC;KAC1C;CACF;;AAWD,qBACa,kBAAmB,SAAQ,uBAA0B;IAEhE,KAAK,SAAK;IAGV,OAAO,SAAK;IAEH,MAAM;CAgBhB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { css, LitElement, html } from "lit";
|
|
2
|
+
import { styled } from "../mixins/tailwind.mixin.js";
|
|
3
|
+
import { property, customElement } from "lit/decorators.js";
|
|
4
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
8
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
9
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
10
|
+
if (decorator = decorators[i])
|
|
11
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
12
|
+
if (kind && result) __defProp(target, key, result);
|
|
13
|
+
return result;
|
|
14
|
+
};
|
|
15
|
+
const styles = [
|
|
16
|
+
css`
|
|
17
|
+
:host {
|
|
18
|
+
display: flex;
|
|
19
|
+
justify-content: center;
|
|
20
|
+
}
|
|
21
|
+
`
|
|
22
|
+
];
|
|
23
|
+
let MinidStepIndicator = class extends styled(LitElement, styles) {
|
|
24
|
+
constructor() {
|
|
25
|
+
super(...arguments);
|
|
26
|
+
this.steps = 0;
|
|
27
|
+
this.current = 0;
|
|
28
|
+
}
|
|
29
|
+
render() {
|
|
30
|
+
return html`
|
|
31
|
+
<ul class="flex space-x-2">
|
|
32
|
+
${Array.from({ length: this.steps }).map((_, index) => {
|
|
33
|
+
const step = index + 1;
|
|
34
|
+
return html`<li
|
|
35
|
+
class="${classMap({
|
|
36
|
+
"bg-accent-surface-active": step < this.current,
|
|
37
|
+
"bg-accent-base": step === this.current,
|
|
38
|
+
"bg-accent": step > this.current
|
|
39
|
+
})} border-accent rounded-full border p-1.5"
|
|
40
|
+
></li>`;
|
|
41
|
+
})}
|
|
42
|
+
</ul>
|
|
43
|
+
`;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
__decorateClass([
|
|
47
|
+
property({ type: Number })
|
|
48
|
+
], MinidStepIndicator.prototype, "steps", 2);
|
|
49
|
+
__decorateClass([
|
|
50
|
+
property({ type: Number })
|
|
51
|
+
], MinidStepIndicator.prototype, "current", 2);
|
|
52
|
+
MinidStepIndicator = __decorateClass([
|
|
53
|
+
customElement("mid-step-indicator")
|
|
54
|
+
], MinidStepIndicator);
|
|
55
|
+
export {
|
|
56
|
+
MinidStepIndicator
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=step-indicator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-indicator.js","sources":["../../src/components/step-indicator.component.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { styled } from '../mixins/tailwind.mixin';\nimport { customElement, property } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-step-indicator': MinidStepIndicator;\n }\n}\n\nconst styles = [\n css`\n :host {\n display: flex;\n justify-content: center;\n }\n `,\n];\n\n@customElement('mid-step-indicator')\nexport class MinidStepIndicator extends styled(LitElement, styles) {\n @property({ type: Number })\n steps = 0;\n\n @property({ type: Number })\n current = 0;\n\n override render() {\n return html`\n <ul class=\"flex space-x-2\">\n ${Array.from({ length: this.steps }).map((_, index) => {\n const step = index + 1;\n return html`<li\n class=\"${classMap({\n 'bg-accent-surface-active': step < this.current,\n 'bg-accent-base': step === this.current,\n 'bg-accent': step > this.current,\n })} border-accent rounded-full border p-1.5\"\n ></li>`;\n })}\n </ul>\n `;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAWA,MAAM,SAAS;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAMF;AAGO,IAAM,qBAAN,cAAiC,OAAO,YAAY,MAAM,EAAE;AAAA,EAA5D,cAAA;AAAA,UAAA,GAAA,SAAA;AAEG,SAAA,QAAA;AAGE,SAAA,UAAA;AAAA,EAAA;AAAA,EAED,SAAS;AACT,WAAA;AAAA;AAAA,UAED,MAAM,KAAK,EAAE,QAAQ,KAAK,MAAO,CAAA,EAAE,IAAI,CAAC,GAAG,UAAU;AACrD,YAAM,OAAO,QAAQ;AACd,aAAA;AAAA,qBACI,SAAS;AAAA,QAChB,4BAA4B,OAAO,KAAK;AAAA,QACxC,kBAAkB,SAAS,KAAK;AAAA,QAChC,aAAa,OAAO,KAAK;AAAA,MAAA,CAC1B,CAAC;AAAA;AAAA,IAAA,CAEL,CAAC;AAAA;AAAA;AAAA,EAAA;AAIV;AArBE,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,OAAQ,CAAA;AAAA,GADf,mBAEX,WAAA,SAAA,CAAA;AAGA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,OAAQ,CAAA;AAAA,GAJf,mBAKX,WAAA,WAAA,CAAA;AALW,qBAAN,gBAAA;AAAA,EADN,cAAc,oBAAoB;AAAA,GACtB,kBAAA;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/events/events.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MinidMenuItem } from '../components/menu-item.component';
|
|
2
|
+
export type MidSelectEvent = CustomEvent<{
|
|
3
|
+
item: MinidMenuItem;
|
|
4
|
+
}>;
|
|
5
|
+
declare global {
|
|
6
|
+
interface GlobalEventHandlersEventMap {
|
|
7
|
+
'mid-select': MidSelectEvent;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=mid-select.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mid-select.d.ts","sourceRoot":"","sources":["../../src/events/mid-select.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAEvE,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC,CAAC;AAElE,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,2BAA2B;QACnC,YAAY,EAAE,cAAc,CAAC;KAC9B;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { MinidCheckbox } from './components/checkbox.component.ts';
|
|
|
4
4
|
export { MinidCodeInput } from './components/code-input.component.ts';
|
|
5
5
|
export { MinidCombobox } from './components/combobox.component.ts';
|
|
6
6
|
export { MinidCountdown } from './components/countdown.component.ts';
|
|
7
|
+
export { MinidDialog } from './components/dialog.component.ts';
|
|
7
8
|
export { MinidDropdown } from './components/dropdown.component.ts';
|
|
8
9
|
export { MinidHeading } from './components/heading.component.ts';
|
|
9
10
|
export { MinidHelptext } from './components/helptext.component.ts';
|
|
@@ -12,13 +13,14 @@ export { MinidLabel } from './components/label.component.ts';
|
|
|
12
13
|
export { MinidLink } from './components/link.component.ts';
|
|
13
14
|
export { MinidMenu } from './components/menu.component.ts';
|
|
14
15
|
export { MinidMenuItem } from './components/menu-item.component.ts';
|
|
15
|
-
export { MinidDialog } from './components/dialog.component.ts';
|
|
16
16
|
export { MinidParagraph } from './components/paragraph.component.ts';
|
|
17
17
|
export { MinidPhoneInput } from './components/phone-input.component.ts';
|
|
18
18
|
export { MinidPopup } from './components/popup.component.ts';
|
|
19
19
|
export { MinidQrCode } from './components/qr-code.component.ts';
|
|
20
20
|
export { MinidSearch } from './components/search.component.ts';
|
|
21
21
|
export { MinidSpinner } from './components/spinner.component.ts';
|
|
22
|
+
export { MinidStepIndicator } from './components/step-indicator.component.ts';
|
|
22
23
|
export { MinidTextfield } from './components/textfield.component.ts';
|
|
23
24
|
export { MinidTooltip } from './components/tooltip.component.ts';
|
|
25
|
+
export * from './events/events.ts';
|
|
24
26
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,E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C9E,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEjE,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { MinidCheckbox } from "./components/checkbox.js";
|
|
|
4
4
|
import { MinidCodeInput } from "./components/code-input.js";
|
|
5
5
|
import { MinidCombobox } from "./components/combobox.js";
|
|
6
6
|
import { MinidCountdown } from "./components/countdown.js";
|
|
7
|
+
import { MinidDialog } from "./components/dialog.js";
|
|
7
8
|
import { MinidDropdown } from "./components/dropdown.js";
|
|
8
9
|
import { MinidHeading } from "./components/heading.js";
|
|
9
10
|
import { MinidHelptext } from "./components/helptext.js";
|
|
@@ -12,13 +13,13 @@ import { MinidLabel } from "./components/label.js";
|
|
|
12
13
|
import { MinidLink } from "./components/link.js";
|
|
13
14
|
import { MinidMenu } from "./components/menu.js";
|
|
14
15
|
import { MinidMenuItem } from "./components/menu-item.js";
|
|
15
|
-
import { MinidDialog } from "./components/dialog.js";
|
|
16
16
|
import { MinidParagraph } from "./components/paragraph.js";
|
|
17
17
|
import { MinidPhoneInput } from "./components/phone-input.js";
|
|
18
18
|
import { MinidPopup } from "./components/popup.js";
|
|
19
19
|
import { MinidQrCode } from "./components/qr-code.js";
|
|
20
20
|
import { MinidSearch } from "./components/search.js";
|
|
21
21
|
import { MinidSpinner } from "./components/spinner.js";
|
|
22
|
+
import { MinidStepIndicator } from "./components/step-indicator.js";
|
|
22
23
|
import { MinidTextfield } from "./components/textfield.js";
|
|
23
24
|
import { MinidTooltip } from "./components/tooltip.js";
|
|
24
25
|
export {
|
|
@@ -43,6 +44,7 @@ export {
|
|
|
43
44
|
MinidQrCode,
|
|
44
45
|
MinidSearch,
|
|
45
46
|
MinidSpinner,
|
|
47
|
+
MinidStepIndicator,
|
|
46
48
|
MinidTextfield,
|
|
47
49
|
MinidTooltip
|
|
48
50
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
|