shoelace/src/components/select/select.ts

590 wiersze
19 KiB
TypeScript
Czysty Zwykły widok Historia

import { html, LitElement } from 'lit';
2021-05-27 21:00:43 +00:00
import { customElement, property, query, state } from 'lit/decorators.js';
2021-09-29 12:40:26 +00:00
import { classMap } from 'lit/directives/class-map.js';
2022-03-24 11:48:03 +00:00
import '~/components/dropdown/dropdown';
import type SlDropdown from '~/components/dropdown/dropdown';
import '~/components/icon-button/icon-button';
import type SlIconButton from '~/components/icon-button/icon-button';
import '~/components/icon/icon';
import type SlMenuItem from '~/components/menu-item/menu-item';
import '~/components/menu/menu';
import type SlMenu from '~/components/menu/menu';
import type { MenuSelectEventDetail } from '~/components/menu/menu';
import '~/components/tag/tag';
import { emit } from '~/internal/event';
import { FormSubmitController } from '~/internal/form';
import { getTextContent, HasSlotController } from '~/internal/slot';
import { watch } from '~/internal/watch';
2021-07-10 00:45:44 +00:00
import styles from './select.styles';
2022-03-02 22:20:40 +00:00
import type { TemplateResult } from 'lit';
2020-07-15 21:30:37 +00:00
/**
2020-07-17 10:09:10 +00:00
* @since 2.0
2020-07-15 21:30:37 +00:00
* @status stable
*
2021-02-26 14:09:13 +00:00
* @dependency sl-dropdown
* @dependency sl-icon
* @dependency sl-icon-button
* @dependency sl-menu
* @dependency sl-tag
*
2021-06-25 20:25:46 +00:00
* @slot - The select's options in the form of menu items.
2021-08-16 21:05:28 +00:00
* @slot prefix - Used to prepend an icon or similar element to the select.
* @slot suffix - Used to append an icon or similar element to the select.
2021-11-19 13:36:59 +00:00
* @slot clear-icon - An icon to use in lieu of the default clear icon.
2021-06-25 20:25:46 +00:00
* @slot label - The select's label. Alternatively, you can use the label prop.
* @slot help-text - Help text that describes how to use the select.
2020-07-15 21:30:37 +00:00
*
2021-06-25 20:25:46 +00:00
* @event sl-clear - Emitted when the clear button is activated.
* @event sl-change - Emitted when the control's value changes.
* @event sl-focus - Emitted when the control gains focus.
2021-07-08 21:23:47 +00:00
* @event sl-blur - Emitted when the control loses focus.
*
2022-03-18 21:33:23 +00:00
* @csspart form-control - The form control that wraps the label, input, and help-text.
* @csspart form-control-label - The label's wrapper.
* @csspart form-control-input - The select's wrapper.
* @csspart form-control-help-text - The help text's wrapper.
2022-03-09 20:54:18 +00:00
* @csspart base - The component's internal wrapper.
2021-09-25 02:28:14 +00:00
* @csspart clear-button - The clear button.
2021-09-24 12:48:01 +00:00
* @csspart control - The container that holds the prefix, label, and suffix.
2022-02-03 13:31:52 +00:00
* @csspart display-label - The label that displays the current selection. Not available when used with `multiple`.
2021-06-25 20:25:46 +00:00
* @csspart icon - The select's icon.
* @csspart prefix - The select's prefix.
* @csspart suffix - The select's suffix.
2022-02-03 13:31:52 +00:00
* @csspart menu - The select menu, an `<sl-menu>` element.
* @csspart tag - The multi select option, an `<sl-tag>` element.
2022-03-09 20:54:18 +00:00
* @csspart tag__base - The tag's `base` part.
* @csspart tag__content - The tag's `content` part.
* @csspart tag__remove-button - The tag's `remove-button` part.
2022-01-01 01:39:16 +00:00
* @csspart tags - The container in which multi select options are rendered.
2020-07-15 21:30:37 +00:00
*/
2021-03-18 13:04:23 +00:00
@customElement('sl-select')
2021-03-09 00:14:32 +00:00
export default class SlSelect extends LitElement {
2021-07-10 00:45:44 +00:00
static styles = styles;
2021-03-06 17:01:39 +00:00
@query('.select') dropdown: SlDropdown;
2021-09-24 12:48:01 +00:00
@query('.select__control') control: SlDropdown;
2021-03-06 17:01:39 +00:00
@query('.select__hidden-select') input: HTMLInputElement;
@query('.select__menu') menu: SlMenu;
// @ts-expect-error -- Controller is currently unused
private readonly formSubmitController = new FormSubmitController(this);
private readonly hasSlotController = new HasSlotController(this, 'help-text', 'label');
2021-02-26 14:09:13 +00:00
private resizeObserver: ResizeObserver;
@state() private hasFocus = false;
@state() private isOpen = false;
@state() private displayLabel = '';
@state() private displayTags: TemplateResult[] = [];
2021-03-06 17:01:39 +00:00
2022-01-01 01:39:16 +00:00
/** Enables multi select. With this enabled, value will be an array. */
2021-07-01 00:04:46 +00:00
@property({ type: Boolean, reflect: true }) multiple = false;
2020-07-15 21:30:37 +00:00
/**
* The maximum number of tags to show when `multiple` is true. After the maximum, "+n" will be shown to indicate the
* number of additional items that are selected. Set to -1 to remove the limit.
*/
2021-07-01 00:04:46 +00:00
@property({ attribute: 'max-tags-visible', type: Number }) maxTagsVisible = 3;
2020-07-15 21:30:37 +00:00
2021-02-26 14:09:13 +00:00
/** Disables the select control. */
2021-07-01 00:04:46 +00:00
@property({ type: Boolean, reflect: true }) disabled = false;
2020-07-15 21:30:37 +00:00
/** The select's name. */
2021-07-01 00:04:46 +00:00
@property() name = '';
2020-07-15 21:30:37 +00:00
/** The select's placeholder text. */
2021-07-01 00:04:46 +00:00
@property() placeholder = '';
2020-07-15 21:30:37 +00:00
/** The select's size. */
2021-03-06 17:01:39 +00:00
@property() size: 'small' | 'medium' | 'large' = 'medium';
2020-07-15 21:30:37 +00:00
2020-08-25 21:07:28 +00:00
/**
* Enable this option to prevent the panel from being clipped when the component is placed inside a container with
* `overflow: auto|scroll`.
*/
2021-07-01 00:04:46 +00:00
@property({ type: Boolean }) hoist = false;
2020-08-25 21:07:28 +00:00
2020-07-15 21:30:37 +00:00
/** The value of the control. This will be a string or an array depending on `multiple`. */
@property() value: string | string[] = '';
2021-03-06 20:18:54 +00:00
2021-09-25 02:28:14 +00:00
/** Draws a filled select. */
@property({ type: Boolean, reflect: true }) filled = false;
2021-02-26 14:09:13 +00:00
/** Draws a pill-style select with rounded edges. */
2021-07-01 00:04:46 +00:00
@property({ type: Boolean, reflect: true }) pill = false;
2020-07-15 21:30:37 +00:00
2020-12-23 20:47:13 +00:00
/** The select's label. Alternatively, you can use the label slot. */
@property() label = '';
2021-03-06 20:18:54 +00:00
/**
2022-02-21 14:13:33 +00:00
* The preferred placement of the select's menu. Note that the actual placement may vary as needed to keep the panel
* inside of the viewport.
*/
@property() placement: 'top' | 'bottom' = 'bottom';
2020-12-23 20:47:13 +00:00
/** The select's help text. Alternatively, you can use the help-text slot. */
@property({ attribute: 'help-text' }) helpText = '';
2021-03-06 20:18:54 +00:00
2020-08-25 13:30:28 +00:00
/** The select's required attribute. */
2021-07-01 00:04:46 +00:00
@property({ type: Boolean, reflect: true }) required = false;
2020-08-25 13:30:28 +00:00
2021-02-26 14:09:13 +00:00
/** Adds a clear button when the select is populated. */
2021-07-01 00:04:46 +00:00
@property({ type: Boolean }) clearable = false;
/** This will be true when the control is in an invalid state. Validity is determined by the `required` prop. */
2021-07-01 00:04:46 +00:00
@property({ type: Boolean, reflect: true }) invalid = false;
2021-03-06 17:01:39 +00:00
connectedCallback() {
super.connectedCallback();
this.handleMenuSlotChange = this.handleMenuSlotChange.bind(this);
this.resizeObserver = new ResizeObserver(() => this.resizeMenu());
2021-06-02 12:47:55 +00:00
this.updateComplete.then(() => {
2021-06-02 12:47:55 +00:00
this.resizeObserver.observe(this);
this.syncItemsFromValue();
});
2020-07-15 21:30:37 +00:00
}
2021-06-16 12:42:02 +00:00
firstUpdated() {
this.invalid = !this.input.checkValidity();
}
2021-03-06 17:01:39 +00:00
disconnectedCallback() {
super.disconnectedCallback();
2021-06-02 12:47:55 +00:00
this.resizeObserver.unobserve(this);
2020-12-23 20:47:13 +00:00
}
/** Checks for validity and shows the browser's validation message if the control is invalid. */
2021-02-26 14:09:13 +00:00
reportValidity() {
return this.input.reportValidity();
}
/** Sets a custom validation message. If `message` is not empty, the field will be considered invalid. */
2021-02-26 14:09:13 +00:00
setCustomValidity(message: string) {
this.input.setCustomValidity(message);
this.invalid = !this.input.checkValidity();
}
2021-02-26 14:09:13 +00:00
getItemLabel(item: SlMenuItem) {
const slot = item.shadowRoot!.querySelector<HTMLSlotElement>('slot:not([name])');
2020-07-15 21:30:37 +00:00
return getTextContent(slot);
}
getItems() {
2022-03-08 22:34:17 +00:00
return [...this.querySelectorAll<SlMenuItem>('sl-menu-item')];
2020-07-15 21:30:37 +00:00
}
getValueAsArray() {
2021-06-04 12:56:35 +00:00
// Single selects use '' as an empty selection value, so convert this to [] for an empty multi select
if (this.multiple && this.value === '') {
return [];
}
2020-07-15 21:30:37 +00:00
return Array.isArray(this.value) ? this.value : [this.value];
}
2021-12-17 14:15:47 +00:00
/** Sets focus on the control. */
focus(options?: FocusOptions) {
2021-12-17 14:27:23 +00:00
this.control.focus(options);
}
/** Removes focus from the control. */
blur() {
this.control.blur();
2021-12-17 14:15:47 +00:00
}
2020-12-11 22:09:10 +00:00
handleBlur() {
2021-06-05 16:29:57 +00:00
// Don't blur if the control is open. We'll move focus back once it closes.
if (!this.isOpen) {
this.hasFocus = false;
emit(this, 'sl-blur');
2021-06-05 16:29:57 +00:00
}
2020-07-15 21:30:37 +00:00
}
2020-12-11 22:09:10 +00:00
handleClearClick(event: MouseEvent) {
event.stopPropagation();
this.value = this.multiple ? [] : '';
emit(this, 'sl-clear');
this.syncItemsFromValue();
}
@watch('disabled', { waitUntilFirstUpdate: true })
2021-03-06 19:39:48 +00:00
handleDisabledChange() {
if (this.disabled && this.isOpen) {
this.dropdown.hide();
2021-03-06 19:39:48 +00:00
}
2021-06-25 23:22:05 +00:00
// Disabled form controls are always valid, so we need to recheck validity when the state changes
this.input.disabled = this.disabled;
this.invalid = !this.input.checkValidity();
2021-03-06 19:39:48 +00:00
}
handleFocus() {
2021-06-05 16:29:57 +00:00
if (!this.hasFocus) {
this.hasFocus = true;
emit(this, 'sl-focus');
2021-06-05 16:29:57 +00:00
}
2021-03-06 19:39:48 +00:00
}
2020-10-22 17:42:37 +00:00
handleKeyDown(event: KeyboardEvent) {
2020-12-11 22:09:10 +00:00
const target = event.target as HTMLElement;
2020-10-22 17:42:37 +00:00
const items = this.getItems();
const firstItem = items[0];
const lastItem = items[items.length - 1];
2020-12-11 22:09:10 +00:00
// Ignore key presses on tags
if (target.tagName.toLowerCase() === 'sl-tag') {
return;
}
// Tabbing out of the control closes it
if (event.key === 'Tab') {
if (this.isOpen) {
this.dropdown.hide();
2020-12-11 22:09:10 +00:00
}
return;
}
2020-10-22 17:42:37 +00:00
2020-12-11 22:09:10 +00:00
// Up/down opens the menu
2020-10-22 17:42:37 +00:00
if (['ArrowDown', 'ArrowUp'].includes(event.key)) {
event.preventDefault();
// Show the menu if it's not already open
if (!this.isOpen) {
this.dropdown.show();
2020-10-22 17:42:37 +00:00
}
// Focus on a menu item
2022-01-19 14:37:07 +00:00
if (event.key === 'ArrowDown') {
2021-07-08 21:23:47 +00:00
this.menu.setCurrentItem(firstItem);
firstItem.focus();
2020-10-22 17:42:37 +00:00
return;
}
2022-01-19 14:37:07 +00:00
if (event.key === 'ArrowUp') {
2021-07-08 21:23:47 +00:00
this.menu.setCurrentItem(lastItem);
lastItem.focus();
2020-10-22 17:42:37 +00:00
return;
}
}
2020-08-29 15:26:14 +00:00
// don't open the menu when a CTRL/Command key is pressed
if (event.ctrlKey || event.metaKey) {
return;
}
2021-06-10 13:33:02 +00:00
// All other "printable" keys open the menu and initiate type to select
if (!this.isOpen && event.key.length === 1) {
2020-12-11 22:09:10 +00:00
event.stopPropagation();
event.preventDefault();
this.dropdown.show();
2022-03-04 15:12:05 +00:00
this.menu.typeToSelect(event);
2020-12-11 22:09:10 +00:00
}
2020-07-15 21:30:37 +00:00
}
handleLabelClick() {
2021-12-17 14:15:47 +00:00
this.focus();
2020-07-15 21:30:37 +00:00
}
handleMenuSelect(event: CustomEvent<MenuSelectEventDetail>) {
2020-07-15 21:30:37 +00:00
const item = event.detail.item;
if (this.multiple) {
this.value = this.value.includes(item.value)
2020-07-15 21:30:37 +00:00
? (this.value as []).filter(v => v !== item.value)
: [...this.value, item.value];
} else {
this.value = item.value;
}
this.syncItemsFromValue();
}
2021-05-27 20:29:10 +00:00
handleMenuShow() {
2020-07-15 21:30:37 +00:00
this.resizeMenu();
this.isOpen = true;
}
handleMenuHide() {
this.isOpen = false;
2021-06-05 16:29:57 +00:00
// Restore focus on the box after the menu is hidden
2021-09-24 12:48:01 +00:00
this.control.focus();
2020-07-15 21:30:37 +00:00
}
@watch('multiple')
2021-03-06 19:39:48 +00:00
handleMultipleChange() {
// Cast to array | string based on `this.multiple`
const value = this.getValueAsArray();
this.value = this.multiple ? value : value[0] ?? '';
2021-03-06 19:39:48 +00:00
this.syncItemsFromValue();
}
async handleMenuSlotChange() {
// Wait for items to render before gathering labels otherwise the slot won't exist
const items = this.getItems();
2021-07-26 12:20:18 +00:00
// Check for duplicate values in menu items
const values: string[] = [];
items.forEach(item => {
2021-07-26 12:20:18 +00:00
if (values.includes(item.value)) {
console.error(`Duplicate value found in <sl-select> menu item: '${item.value}'`, item);
}
values.push(item.value);
});
await Promise.all(items.map(item => item.render)).then(() => this.syncItemsFromValue());
2020-07-15 21:30:37 +00:00
}
2020-12-11 22:09:10 +00:00
handleTagInteraction(event: KeyboardEvent | MouseEvent) {
2020-08-27 12:20:36 +00:00
// Don't toggle the menu when a tag's clear button is activated
const path = event.composedPath();
2021-02-26 14:09:13 +00:00
const clearButton = path.find((el: SlIconButton) => {
2020-08-27 12:20:36 +00:00
if (el instanceof HTMLElement) {
const element = el as HTMLElement;
2021-10-07 13:52:23 +00:00
return element.classList.contains('tag__remove');
2020-08-27 12:20:36 +00:00
}
2021-02-26 14:09:13 +00:00
return false;
2020-08-27 12:20:36 +00:00
});
2022-01-19 14:37:07 +00:00
if (clearButton) {
2020-08-27 12:20:36 +00:00
event.stopPropagation();
}
}
2021-06-15 13:26:35 +00:00
@watch('value', { waitUntilFirstUpdate: true })
2021-06-16 12:42:02 +00:00
async handleValueChange() {
2021-03-06 19:39:48 +00:00
this.syncItemsFromValue();
2021-06-16 12:42:02 +00:00
await this.updateComplete;
this.invalid = !this.input.checkValidity();
emit(this, 'sl-change');
2021-03-06 19:39:48 +00:00
}
2020-07-15 21:30:37 +00:00
resizeMenu() {
this.menu.style.width = `${this.control.clientWidth}px`;
2021-03-06 17:01:39 +00:00
this.dropdown.reposition();
2020-07-15 21:30:37 +00:00
}
syncItemsFromValue() {
const items = this.getItems();
const value = this.getValueAsArray();
// Sync checked states
items.map(item => (item.checked = value.includes(item.value)));
2021-03-22 17:14:32 +00:00
// Sync display label and tags
2020-07-15 21:30:37 +00:00
if (this.multiple) {
const checkedItems = items.filter(item => value.includes(item.value));
2020-07-15 21:30:37 +00:00
this.displayLabel = checkedItems.length > 0 ? this.getItemLabel(checkedItems[0]) : '';
2021-02-26 14:09:13 +00:00
this.displayTags = checkedItems.map((item: SlMenuItem) => {
return html`
2020-07-15 21:30:37 +00:00
<sl-tag
2022-02-19 17:47:13 +00:00
part="tag"
2022-03-09 20:54:18 +00:00
exportparts="
base:tag__base,
content:tag__content,
remove-button:tag__remove-button
"
2021-12-13 22:38:40 +00:00
variant="neutral"
2021-02-26 14:09:13 +00:00
size=${this.size}
2021-03-15 12:03:32 +00:00
?pill=${this.pill}
2021-10-07 13:52:23 +00:00
removable
2021-03-06 17:01:39 +00:00
@click=${this.handleTagInteraction}
@keydown=${this.handleTagInteraction}
2021-10-07 13:52:23 +00:00
@sl-remove=${(event: CustomEvent) => {
event.stopPropagation();
2020-12-11 22:09:10 +00:00
if (!this.disabled) {
item.checked = false;
this.syncValueFromItems();
}
2020-07-15 21:30:37 +00:00
}}
>
2021-02-26 14:09:13 +00:00
${this.getItemLabel(item)}
2020-07-15 21:30:37 +00:00
</sl-tag>
2021-02-26 14:09:13 +00:00
`;
2020-07-15 21:30:37 +00:00
});
if (this.maxTagsVisible > 0 && this.displayTags.length > this.maxTagsVisible) {
const total = this.displayTags.length;
2020-12-11 22:09:10 +00:00
this.displayLabel = '';
2020-07-15 21:30:37 +00:00
this.displayTags = this.displayTags.slice(0, this.maxTagsVisible);
2021-02-26 14:09:13 +00:00
this.displayTags.push(html`
2022-03-09 20:54:18 +00:00
<sl-tag
part="tag"
exportparts="
base:tag__base,
content:tag__content,
remove-button:tag__remove-button
"
variant="neutral"
size=${this.size}
>
+${total - this.maxTagsVisible}
</sl-tag>
2021-02-26 14:09:13 +00:00
`);
2020-07-15 21:30:37 +00:00
}
} else {
const checkedItem = items.find(item => item.value === value[0]);
2021-03-22 17:14:32 +00:00
2022-01-19 14:37:07 +00:00
this.displayLabel = checkedItem ? this.getItemLabel(checkedItem) : '';
2020-07-15 21:30:37 +00:00
this.displayTags = [];
}
}
syncValueFromItems() {
const items = this.getItems();
const checkedItems = items.filter(item => item.checked);
const checkedValues = checkedItems.map(item => item.value);
if (this.multiple) {
this.value = (this.value as []).filter(val => checkedValues.includes(val));
} else {
this.value = checkedValues.length > 0 ? checkedValues[0] : '';
}
}
render() {
const hasLabelSlot = this.hasSlotController.test('label');
const hasHelpTextSlot = this.hasSlotController.test('help-text');
const hasSelection = this.multiple ? this.value.length > 0 : this.value !== '';
2022-03-08 22:34:17 +00:00
const hasLabel = this.label ? true : !!hasLabelSlot;
const hasHelpText = this.helpText ? true : !!hasHelpTextSlot;
return html`
<div
part="form-control"
class=${classMap({
'form-control': true,
'form-control--small': this.size === 'small',
'form-control--medium': this.size === 'medium',
'form-control--large': this.size === 'large',
'form-control--has-label': hasLabel,
'form-control--has-help-text': hasHelpText
})}
>
<label
2022-03-18 21:33:23 +00:00
part="form-control-label"
2022-03-08 22:34:17 +00:00
class="form-control__label"
for="input"
aria-hidden=${hasLabel ? 'false' : 'true'}
@click=${this.handleLabelClick}
2020-07-15 21:30:37 +00:00
>
2022-03-08 22:34:17 +00:00
<slot name="label">${this.label}</slot>
</label>
2022-03-18 21:33:23 +00:00
<div part="form-control-input" class="form-control-input">
2022-03-08 22:34:17 +00:00
<sl-dropdown
part="base"
.hoist=${this.hoist}
.placement=${this.placement}
.stayOpenOnSelect=${this.multiple}
.containingElement=${this as HTMLElement}
?disabled=${this.disabled}
class=${classMap({
select: true,
'select--open': this.isOpen,
'select--empty': this.value.length === 0,
'select--focused': this.hasFocus,
'select--clearable': this.clearable,
'select--disabled': this.disabled,
'select--multiple': this.multiple,
'select--standard': !this.filled,
'select--filled': this.filled,
'select--has-tags': this.multiple && this.displayTags.length > 0,
'select--placeholder-visible': this.displayLabel === '',
'select--small': this.size === 'small',
'select--medium': this.size === 'medium',
'select--large': this.size === 'large',
'select--pill': this.pill,
'select--invalid': this.invalid
})}
@sl-show=${this.handleMenuShow}
@sl-hide=${this.handleMenuHide}
2020-07-15 21:30:37 +00:00
>
2022-03-08 22:34:17 +00:00
<div
part="control"
slot="trigger"
id="input"
class="select__control"
role="combobox"
aria-describedby="help-text"
aria-haspopup="true"
2022-03-16 21:38:58 +00:00
aria-disabled=${this.disabled ? 'true' : 'false'}
2022-03-08 22:34:17 +00:00
aria-expanded=${this.isOpen ? 'true' : 'false'}
aria-controls="menu"
tabindex=${this.disabled ? '-1' : '0'}
@blur=${this.handleBlur}
@focus=${this.handleFocus}
@keydown=${this.handleKeyDown}
>
<span part="prefix" class="select__prefix">
<slot name="prefix"></slot>
</span>
<div part="display-label" class="select__label">
${this.displayTags.length > 0
? html` <span part="tags" class="select__tags"> ${this.displayTags} </span> `
: this.displayLabel.length > 0
? this.displayLabel
: this.placeholder}
</div>
${this.clearable && hasSelection
? html`
<button part="clear-button" class="select__clear" @click=${this.handleClearClick} tabindex="-1">
<slot name="clear-icon">
<sl-icon name="x-circle-fill" library="system"></sl-icon>
</slot>
</button>
`
: ''}
<span part="suffix" class="select__suffix">
<slot name="suffix"></slot>
</span>
<span part="icon" class="select__icon" aria-hidden="true">
<sl-icon name="chevron-down" library="system"></sl-icon>
</span>
<!-- The hidden input tricks the browser's built-in validation so it works as expected. We use an input
instead of a select because, otherwise, iOS will show a list of options during validation. The focus
handler is used to move focus to the primary control when it's marked invalid. -->
<input
class="select__hidden-select"
aria-hidden="true"
?required=${this.required}
.value=${hasSelection ? '1' : ''}
tabindex="-1"
@focus=${() => this.control.focus()}
/>
2020-12-11 22:09:10 +00:00
</div>
2022-03-08 22:34:17 +00:00
<sl-menu part="menu" id="menu" class="select__menu" @sl-select=${this.handleMenuSelect}>
<slot @slotchange=${this.handleMenuSlotChange}></slot>
</sl-menu>
</sl-dropdown>
</div>
<div
2022-03-18 21:33:23 +00:00
part="form-control-help-text"
2022-03-08 22:34:17 +00:00
id="help-text"
class="form-control__help-text"
aria-hidden=${hasHelpText ? 'false' : 'true'}
>
<slot name="help-text">${this.helpText}</slot>
</div>
</div>
`;
2020-07-15 21:30:37 +00:00
}
}
2021-03-12 14:09:08 +00:00
declare global {
interface HTMLElementTagNameMap {
'sl-select': SlSelect;
}
}