@universal-material/web 3.3.11 → 3.3.12
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/custom-elements.json +5104 -5104
- package/package.json +1 -1
- package/typeahead/typeahead.d.ts.map +1 -1
- package/typeahead/typeahead.js +3 -0
- package/typeahead/typeahead.js.map +1 -1
- package/vscode.html-custom-data.json +193 -193
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeahead.d.ts","sourceRoot":"","sources":["../../src/typeahead/typeahead.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,kBAAkB,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAI3D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAKzC,OAAO,iBAAiB,CAAC;AACzB,OAAO,sBAAsB,CAAC;AAC9B,OAAO,gBAAgB,CAAC;AAExB,MAAM,WAAW,IAAI;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,GAAG,CAAC;CACZ;AAED,qBACa,WAAY,SAAQ,UAAU;;IACzC,MAAM,CAAC,QAAQ,CAAC,cAAc,QAAQ;IAEtC,OAAgB,MAAM,0BAAU;IAKhC,OAAO,CAAC,MAAM,CAOE;IASP,OAAO,CAAC,OAAO,CAAS;IAEjC;;OAEG;IACM,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IAE1E;;OAEG;IACH,SAAS,EAAE,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAC,GAAG,SAAS,CAAC;IAEhD;;;;OAIG;IACH,QAAQ,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,MAAM,CAAC,GAA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AS,EAMrC;IAEgB,KAAK,EAAG,MAAM,CAAC;IACP,SAAS,EAAG,UAAU,CAAC,UAAU,CAAC,CAAC;IAE5D,IAAI,UAAU,IAAI,UAAU,EAAE,CAE7B;;IAOQ,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAgBhF,iBAAiB;IAWjB,oBAAoB;cAuGV,MAAM,IAAI,kBAAkB;IAwG/C,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,aAAa;IAoBrB,OAAO,CAAC,YAAY;CAOrB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,WAAW,CAAC;KAC5B;CACF"}
|
package/typeahead/typeahead.js
CHANGED
|
@@ -307,6 +307,9 @@ let UmTypeahead = class UmTypeahead extends LitElement {
|
|
|
307
307
|
if (this.target.tagName === 'U-CHIP-FIELD') {
|
|
308
308
|
return this.target.input;
|
|
309
309
|
}
|
|
310
|
+
if (this.target.tagName === 'U-SEARCH') {
|
|
311
|
+
return this.target.input;
|
|
312
|
+
}
|
|
310
313
|
if (this.target.tagName === 'U-TEXT-FIELD') {
|
|
311
314
|
return this.target.container;
|
|
312
315
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeahead.js","sourceRoot":"","sources":["../../src/typeahead/typeahead.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAsB,UAAU,EAAE,MAAM,KAAK,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAIpF,OAAO,EAAE,6BAA6B,EAAE,MAAM,0DAA0D,CAAC;AACzG,OAAO,EAAE,aAAa,EAAE,MAAM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AAE,SAAS,EAAE,WAAW,EAAE,CAAC;2CAGnD;AAUgB;IAAhB,KAAK,CAAC,QAAQ,CAAC;0CAAgB;AACP;IAAxB,QAAQ,CAAC,aAAa,CAAC;8CAAoC;AArIjD,WAAW;IADvB,aAAa,CAAC,aAAa,CAAC;GAChB,WAAW,CA6ZvB","sourcesContent":["import { html, HTMLTemplateResult, LitElement } from 'lit';\nimport { unsafeHTML } from 'lit-html/directives/unsafe-html.js';\nimport { customElement, property, query, queryAll, state } from 'lit/decorators.js';\n\nimport { UmMenuItem } from '../menu/menu-item.js';\nimport { UmMenu } from '../menu/menu.js';\nimport { MenuFieldNavigationController } from '../shared/menu-field/menu-field-navigation-controller.js';\nimport { normalizeText } from '../shared/normalize-text.js';\nimport { styles } from './typeahead.styles.js';\n\nimport '../menu/menu.js';\nimport '../menu/menu-item.js';\nimport './highlight.js';\n\nexport interface Data {\n label: string;\n value: any;\n}\n\n@customElement('u-typeahead')\nexport class UmTypeahead extends LitElement {\n static readonly formAssociated = true;\n\n static override styles = styles;\n\n #targetId: string | undefined;\n\n #connected = false;\n private target:\n | (HTMLElement & {\n autocomplete: 'on' | 'off' | string | null;\n input?: HTMLInputElement;\n container?: HTMLElement;\n value: string;\n })\n | null = null;\n #documentMutationObserver: MutationObserver | null = null;\n readonly #navigationController = new MenuFieldNavigationController(this);\n #termNormalized = '';\n #debounceTimeout: number | null = null;\n #value: any;\n readonly #elementInternals: ElementInternals;\n\n // @ts-ignore\n @state() private results: Data[];\n\n /**\n * The datasource of the typeahead. Accepts an `Array` or a `Promise<[]>`.\n */\n @state() source: (any[] | ((term: string) => Promise<any[]>)) | undefined;\n\n /**\n * A function return a string based on a result from the `source`. Useful when the source results are objects.\n */\n formatter: ((value: any) => string) | undefined;\n\n /**\n * A string representing an HTML to be rendered inside the menu item. If set, it will replace the `u-highlight`.\n *\n * _Note:_ Subject to signature change\n */\n template: ((term: string, value: any) => string) | undefined;\n\n /**\n * The time in milliseconds before triggering an update in the results.\n */\n @property({ type: Number, reflect: true }) debounce = 300;\n\n /**\n * The number of suggestions to show\n */\n @property({ type: Number, reflect: true }) limit = 10;\n\n /**\n * How many characters must be typed before show suggestions\n *\n * _Note:_ Not used when the source is a `Promise`\n */\n @property({ type: Number, reflect: true }) minLength = 2;\n\n /**\n * Whether the menu will be show when the target get focus.\n *\n * _Note:_ The `minLength` will still be applied\n */\n @property({ type: Boolean, attribute: 'open-on-focus', reflect: true })\n openOnFocus = false;\n\n /**\n * If `true`, model values will not be restricted only to items selected from the menu.\n */\n @property({ type: Boolean, reflect: true }) editable = false;\n\n /**\n * The value for the `autocomplete` attribute for the target element.\n */\n @property({ reflect: true }) autocomplete: 'on' | 'off' | string = 'off';\n\n /**\n * The value for the `spellcheck` attribute for the target element.\n */\n @property({ reflect: true }) override spellcheck = false;\n\n get form(): HTMLFormElement | null {\n return this.#elementInternals.form;\n }\n\n /**\n * Gets or sets the current value of the typeahead.\n */\n get value(): any {\n return this.#value;\n }\n\n set value(value: any) {\n this.#value = value;\n this.#elementInternals.setFormValue(value);\n\n if (this.#connected) {\n this.#setValueOnTarget();\n }\n }\n\n override focus() {\n this.target?.focus();\n }\n\n clear() {\n if (!this.target) {\n return;\n }\n\n this.#termNormalized = '';\n this.setTargetValue('');\n }\n\n /**\n * The id of the target element to attach the typeahead.\n */\n @property({ reflect: true, attribute: 'target-id' })\n get targetId(): string | undefined {\n return this.#targetId;\n }\n\n set targetId(value: string | undefined) {\n this.#targetId = value;\n\n if (this.#connected) {\n this.#attach();\n }\n }\n\n @query('u-menu') _menu!: UmMenu;\n @queryAll('u-menu-item') menuItems!: NodeListOf<UmMenuItem>;\n\n get _menuItems(): UmMenuItem[] {\n return Array.from(this.menuItems);\n }\n\n constructor() {\n super();\n this.#elementInternals = this.attachInternals();\n }\n\n override attributeChangedCallback(name: string, _old: string | null, value: string | null) {\n super.attributeChangedCallback(name, _old, value);\n\n if (!this.target) {\n return;\n }\n\n if (name === 'autocomplete') {\n this.target.autocomplete = value;\n }\n\n if (name === 'spellcheck') {\n this.target.spellcheck = value === 'true';\n }\n }\n\n override connectedCallback() {\n super.connectedCallback();\n this.#connected = true;\n this.#attach();\n this.#documentMutationObserver = new MutationObserver(() => this.#attach());\n this.#documentMutationObserver.observe(document, {\n attributes: true,\n childList: true,\n });\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.#connected = false;\n this.#detach();\n this.#documentMutationObserver!.disconnect();\n this.#documentMutationObserver = null;\n }\n\n #attach() {\n if (!this.targetId) {\n this.#detach();\n return;\n }\n\n const newTarget = document.getElementById(this.targetId) as HTMLInputElement;\n\n if (newTarget === this.target) {\n return;\n }\n\n this.#detach();\n\n if (!newTarget) {\n return;\n }\n\n // @ts-ignore\n this.target = newTarget;\n newTarget.role = 'combobox';\n newTarget.autocomplete = this.autocomplete as any;\n newTarget.spellcheck = this.spellcheck;\n newTarget.autocapitalize = 'off';\n\n newTarget.addEventListener('click', this.#handleClick);\n newTarget.addEventListener('input', this.#handleInput);\n this.#navigationController.attach(newTarget);\n newTarget.addEventListener('focus', this.#handleFocus);\n\n if (this.value) {\n this.#setValueOnTarget();\n }\n }\n\n #detach() {\n this.target?.removeEventListener('click', this.#handleClick);\n this.target?.removeEventListener('input', this.#handleInput);\n this.#navigationController.detach();\n this.target?.removeEventListener('focus', this.#handleFocus);\n }\n\n #handleItemMouseDown(e: Event) {\n e.preventDefault();\n }\n\n #handleClick(e: Event) {\n e.stopPropagation();\n }\n\n readonly #handleFocus = async () => {\n if (this.openOnFocus) {\n await this.#updateResults();\n }\n };\n\n readonly #handleInput = () => {\n if (this.#debounceTimeout) {\n clearTimeout(this.#debounceTimeout);\n }\n\n this.#setValueAndDispatchEvents(this.editable ? this.getTargetValue() : null, true);\n\n this.#debounceTimeout = setTimeout(async () => await this.#updateResults(true), this.debounce);\n };\n\n #getItemClickHandler(data: Data) {\n return () => {\n const selectedEvent = new CustomEvent('selected', {\n cancelable: true,\n detail: data.value,\n });\n\n this.dispatchEvent(selectedEvent);\n\n if (selectedEvent.defaultPrevented) {\n return;\n }\n\n this.#setValueAndDispatchEvents(data.value);\n };\n }\n\n #setValueAndDispatchEvents(value: any, direct = false) {\n if (!direct) {\n this.value = value;\n } else {\n this.#value = value;\n this.#elementInternals.setFormValue(value);\n }\n\n this.dispatchEvent(new InputEvent('input', { bubbles: true, composed: true }));\n this.dispatchEvent(new Event('change', { bubbles: true }));\n }\n\n protected override render(): HTMLTemplateResult {\n if (!this.results?.length) {\n return html``;\n }\n\n setTimeout(() => {\n this._menu.anchorElement = this.getMenuAnchor();\n this._menu.open = true;\n this.#navigationController.focusMenu(this._menuItems[0], 0);\n });\n\n return html`\n <u-menu manualFocus manualClose anchor-corner=\"auto-start\">\n ${this.results.map(result => {\n const content = this.template\n ? unsafeHTML(this.template(this.#termNormalized, result.value))\n : html`\n <u-highlight .term=${this.#termNormalized} .result=${result.label}></u-highlight>\n `;\n\n return html`\n <u-menu-item\n @mousedown=${this.#handleItemMouseDown}\n @click=${this.#getItemClickHandler(result)}\n tabindex=\"-1\">\n ${content}\n </u-menu-item>\n `;\n })}\n </u-menu>\n `;\n }\n\n async #updateResults(lazy = false) {\n const term = this.getTargetValue();\n\n const termNormalized = normalizeText(term).toLowerCase();\n\n if (lazy && termNormalized === this.#termNormalized && this._menu?.open === true) {\n return;\n }\n\n this.#termNormalized = termNormalized;\n\n if (termNormalized.length < this.minLength) {\n this.results = [];\n return;\n }\n\n this.results = await this.#getData();\n this.results = this.results.slice(0, this.limit || this.results.length);\n }\n\n async #getData(): Promise<Data[]> {\n if (!this.source) {\n return [];\n }\n\n let values: any[];\n\n let filter = false;\n\n if (this.source instanceof Array) {\n values = this.source;\n filter = true;\n } else {\n const source = this.source as (term: string) => Promise<any[]>;\n values = await source(this.#termNormalized);\n }\n\n const result = values.map(source => ({\n label: this.formatter ? this.formatter(source) : source.toString(),\n value: source,\n }));\n\n if (!filter) {\n return result;\n }\n\n return result.filter(t => normalizeText(t.label).toLowerCase()\n .includes(this.#termNormalized));\n }\n\n #setValueOnTarget() {\n if (!this.target) {\n return;\n }\n\n const textValue = this.getTextValue();\n this.#termNormalized = normalizeText(textValue)?.toLowerCase();\n\n if (this.target.tagName === 'U-TEXT-FIELD') {\n this.target.value = textValue;\n return;\n }\n\n if (this.target.input) {\n this.target.input.value = textValue;\n return;\n }\n\n this.target.value = textValue;\n }\n\n private getTargetValue(): string {\n return this.target!.input?.value ?? this.target!.value;\n }\n\n private setTargetValue(value: string): void {\n const targetInput = this.target?.input ?? this.target;\n\n if (targetInput) {\n targetInput.value = value;\n }\n }\n\n private getMenuAnchor() {\n if (!this.target) {\n return null;\n }\n\n if (this.target.tagName === 'U-CHIP-FIELD') {\n return this.target.input;\n }\n\n if (this.target.tagName === 'U-TEXT-FIELD') {\n return this.target.container;\n }\n\n return this.target;\n }\n\n private getTextValue(): string {\n if (!this.value) {\n return '';\n }\n\n return this.formatter ? this.formatter(this.value) : this.value;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'u-typeahead': UmTypeahead;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"typeahead.js","sourceRoot":"","sources":["../../src/typeahead/typeahead.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAsB,UAAU,EAAE,MAAM,KAAK,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAIpF,OAAO,EAAE,6BAA6B,EAAE,MAAM,0DAA0D,CAAC;AACzG,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,OAAO,iBAAiB,CAAC;AACzB,OAAO,sBAAsB,CAAC;AAC9B,OAAO,gBAAgB,CAAC;AAQjB,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,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C,QAAQ,CAAC;0CAAgB;AACP;IAAxB,QAAQ,CAAC,aAAa,CAAC;8CAAoC;AArIjD,WAAW;IADvB,aAAa,CAAC,aAAa,CAAC;GAChB,WAAW,CAiavB","sourcesContent":["import { html, HTMLTemplateResult, LitElement } from 'lit';\nimport { unsafeHTML } from 'lit-html/directives/unsafe-html.js';\nimport { customElement, property, query, queryAll, state } from 'lit/decorators.js';\n\nimport { UmMenuItem } from '../menu/menu-item.js';\nimport { UmMenu } from '../menu/menu.js';\nimport { MenuFieldNavigationController } from '../shared/menu-field/menu-field-navigation-controller.js';\nimport { normalizeText } from '../shared/normalize-text.js';\nimport { styles } from './typeahead.styles.js';\n\nimport '../menu/menu.js';\nimport '../menu/menu-item.js';\nimport './highlight.js';\n\nexport interface Data {\n label: string;\n value: any;\n}\n\n@customElement('u-typeahead')\nexport class UmTypeahead extends LitElement {\n static readonly formAssociated = true;\n\n static override styles = styles;\n\n #targetId: string | undefined;\n\n #connected = false;\n private target:\n | (HTMLElement & {\n autocomplete: 'on' | 'off' | string | null;\n input?: HTMLInputElement;\n container?: HTMLElement;\n value: string;\n })\n | null = null;\n #documentMutationObserver: MutationObserver | null = null;\n readonly #navigationController = new MenuFieldNavigationController(this);\n #termNormalized = '';\n #debounceTimeout: number | null = null;\n #value: any;\n readonly #elementInternals: ElementInternals;\n\n // @ts-ignore\n @state() private results: Data[];\n\n /**\n * The datasource of the typeahead. Accepts an `Array` or a `Promise<[]>`.\n */\n @state() source: (any[] | ((term: string) => Promise<any[]>)) | undefined;\n\n /**\n * A function return a string based on a result from the `source`. Useful when the source results are objects.\n */\n formatter: ((value: any) => string) | undefined;\n\n /**\n * A string representing an HTML to be rendered inside the menu item. If set, it will replace the `u-highlight`.\n *\n * _Note:_ Subject to signature change\n */\n template: ((term: string, value: any) => string) | undefined;\n\n /**\n * The time in milliseconds before triggering an update in the results.\n */\n @property({ type: Number, reflect: true }) debounce = 300;\n\n /**\n * The number of suggestions to show\n */\n @property({ type: Number, reflect: true }) limit = 10;\n\n /**\n * How many characters must be typed before show suggestions\n *\n * _Note:_ Not used when the source is a `Promise`\n */\n @property({ type: Number, reflect: true }) minLength = 2;\n\n /**\n * Whether the menu will be show when the target get focus.\n *\n * _Note:_ The `minLength` will still be applied\n */\n @property({ type: Boolean, attribute: 'open-on-focus', reflect: true })\n openOnFocus = false;\n\n /**\n * If `true`, model values will not be restricted only to items selected from the menu.\n */\n @property({ type: Boolean, reflect: true }) editable = false;\n\n /**\n * The value for the `autocomplete` attribute for the target element.\n */\n @property({ reflect: true }) autocomplete: 'on' | 'off' | string = 'off';\n\n /**\n * The value for the `spellcheck` attribute for the target element.\n */\n @property({ reflect: true }) override spellcheck = false;\n\n get form(): HTMLFormElement | null {\n return this.#elementInternals.form;\n }\n\n /**\n * Gets or sets the current value of the typeahead.\n */\n get value(): any {\n return this.#value;\n }\n\n set value(value: any) {\n this.#value = value;\n this.#elementInternals.setFormValue(value);\n\n if (this.#connected) {\n this.#setValueOnTarget();\n }\n }\n\n override focus() {\n this.target?.focus();\n }\n\n clear() {\n if (!this.target) {\n return;\n }\n\n this.#termNormalized = '';\n this.setTargetValue('');\n }\n\n /**\n * The id of the target element to attach the typeahead.\n */\n @property({ reflect: true, attribute: 'target-id' })\n get targetId(): string | undefined {\n return this.#targetId;\n }\n\n set targetId(value: string | undefined) {\n this.#targetId = value;\n\n if (this.#connected) {\n this.#attach();\n }\n }\n\n @query('u-menu') _menu!: UmMenu;\n @queryAll('u-menu-item') menuItems!: NodeListOf<UmMenuItem>;\n\n get _menuItems(): UmMenuItem[] {\n return Array.from(this.menuItems);\n }\n\n constructor() {\n super();\n this.#elementInternals = this.attachInternals();\n }\n\n override attributeChangedCallback(name: string, _old: string | null, value: string | null) {\n super.attributeChangedCallback(name, _old, value);\n\n if (!this.target) {\n return;\n }\n\n if (name === 'autocomplete') {\n this.target.autocomplete = value;\n }\n\n if (name === 'spellcheck') {\n this.target.spellcheck = value === 'true';\n }\n }\n\n override connectedCallback() {\n super.connectedCallback();\n this.#connected = true;\n this.#attach();\n this.#documentMutationObserver = new MutationObserver(() => this.#attach());\n this.#documentMutationObserver.observe(document, {\n attributes: true,\n childList: true,\n });\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.#connected = false;\n this.#detach();\n this.#documentMutationObserver!.disconnect();\n this.#documentMutationObserver = null;\n }\n\n #attach() {\n if (!this.targetId) {\n this.#detach();\n return;\n }\n\n const newTarget = document.getElementById(this.targetId) as HTMLInputElement;\n\n if (newTarget === this.target) {\n return;\n }\n\n this.#detach();\n\n if (!newTarget) {\n return;\n }\n\n // @ts-ignore\n this.target = newTarget;\n newTarget.role = 'combobox';\n newTarget.autocomplete = this.autocomplete as any;\n newTarget.spellcheck = this.spellcheck;\n newTarget.autocapitalize = 'off';\n\n newTarget.addEventListener('click', this.#handleClick);\n newTarget.addEventListener('input', this.#handleInput);\n this.#navigationController.attach(newTarget);\n newTarget.addEventListener('focus', this.#handleFocus);\n\n if (this.value) {\n this.#setValueOnTarget();\n }\n }\n\n #detach() {\n this.target?.removeEventListener('click', this.#handleClick);\n this.target?.removeEventListener('input', this.#handleInput);\n this.#navigationController.detach();\n this.target?.removeEventListener('focus', this.#handleFocus);\n }\n\n #handleItemMouseDown(e: Event) {\n e.preventDefault();\n }\n\n #handleClick(e: Event) {\n e.stopPropagation();\n }\n\n readonly #handleFocus = async () => {\n if (this.openOnFocus) {\n await this.#updateResults();\n }\n };\n\n readonly #handleInput = () => {\n if (this.#debounceTimeout) {\n clearTimeout(this.#debounceTimeout);\n }\n\n this.#setValueAndDispatchEvents(this.editable ? this.getTargetValue() : null, true);\n\n this.#debounceTimeout = setTimeout(async () => await this.#updateResults(true), this.debounce);\n };\n\n #getItemClickHandler(data: Data) {\n return () => {\n const selectedEvent = new CustomEvent('selected', {\n cancelable: true,\n detail: data.value,\n });\n\n this.dispatchEvent(selectedEvent);\n\n if (selectedEvent.defaultPrevented) {\n return;\n }\n\n this.#setValueAndDispatchEvents(data.value);\n };\n }\n\n #setValueAndDispatchEvents(value: any, direct = false) {\n if (!direct) {\n this.value = value;\n } else {\n this.#value = value;\n this.#elementInternals.setFormValue(value);\n }\n\n this.dispatchEvent(new InputEvent('input', { bubbles: true, composed: true }));\n this.dispatchEvent(new Event('change', { bubbles: true }));\n }\n\n protected override render(): HTMLTemplateResult {\n if (!this.results?.length) {\n return html``;\n }\n\n setTimeout(() => {\n this._menu.anchorElement = this.getMenuAnchor();\n this._menu.open = true;\n this.#navigationController.focusMenu(this._menuItems[0], 0);\n });\n\n return html`\n <u-menu manualFocus manualClose anchor-corner=\"auto-start\">\n ${this.results.map(result => {\n const content = this.template\n ? unsafeHTML(this.template(this.#termNormalized, result.value))\n : html`\n <u-highlight .term=${this.#termNormalized} .result=${result.label}></u-highlight>\n `;\n\n return html`\n <u-menu-item\n @mousedown=${this.#handleItemMouseDown}\n @click=${this.#getItemClickHandler(result)}\n tabindex=\"-1\">\n ${content}\n </u-menu-item>\n `;\n })}\n </u-menu>\n `;\n }\n\n async #updateResults(lazy = false) {\n const term = this.getTargetValue();\n\n const termNormalized = normalizeText(term).toLowerCase();\n\n if (lazy && termNormalized === this.#termNormalized && this._menu?.open === true) {\n return;\n }\n\n this.#termNormalized = termNormalized;\n\n if (termNormalized.length < this.minLength) {\n this.results = [];\n return;\n }\n\n this.results = await this.#getData();\n this.results = this.results.slice(0, this.limit || this.results.length);\n }\n\n async #getData(): Promise<Data[]> {\n if (!this.source) {\n return [];\n }\n\n let values: any[];\n\n let filter = false;\n\n if (this.source instanceof Array) {\n values = this.source;\n filter = true;\n } else {\n const source = this.source as (term: string) => Promise<any[]>;\n values = await source(this.#termNormalized);\n }\n\n const result = values.map(source => ({\n label: this.formatter ? this.formatter(source) : source.toString(),\n value: source,\n }));\n\n if (!filter) {\n return result;\n }\n\n return result.filter(t => normalizeText(t.label).toLowerCase()\n .includes(this.#termNormalized));\n }\n\n #setValueOnTarget() {\n if (!this.target) {\n return;\n }\n\n const textValue = this.getTextValue();\n this.#termNormalized = normalizeText(textValue)?.toLowerCase();\n\n if (this.target.tagName === 'U-TEXT-FIELD') {\n this.target.value = textValue;\n return;\n }\n\n if (this.target.input) {\n this.target.input.value = textValue;\n return;\n }\n\n this.target.value = textValue;\n }\n\n private getTargetValue(): string {\n return this.target!.input?.value ?? this.target!.value;\n }\n\n private setTargetValue(value: string): void {\n const targetInput = this.target?.input ?? this.target;\n\n if (targetInput) {\n targetInput.value = value;\n }\n }\n\n private getMenuAnchor() {\n if (!this.target) {\n return null;\n }\n\n if (this.target.tagName === 'U-CHIP-FIELD') {\n return this.target.input;\n }\n\n if (this.target.tagName === 'U-SEARCH') {\n return this.target.input;\n }\n\n if (this.target.tagName === 'U-TEXT-FIELD') {\n return this.target.container;\n }\n\n return this.target;\n }\n\n private getTextValue(): string {\n if (!this.value) {\n return '';\n }\n\n return this.formatter ? this.formatter(this.value) : this.value;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'u-typeahead': UmTypeahead;\n }\n}\n"]}
|
|
@@ -77,6 +77,84 @@
|
|
|
77
77
|
],
|
|
78
78
|
"references": []
|
|
79
79
|
},
|
|
80
|
+
{
|
|
81
|
+
"name": "u-button-field",
|
|
82
|
+
"description": "\n---\n",
|
|
83
|
+
"attributes": [
|
|
84
|
+
{
|
|
85
|
+
"name": "value",
|
|
86
|
+
"values": []
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"name": "placeholder",
|
|
90
|
+
"values": []
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"name": "variant",
|
|
94
|
+
"values": [
|
|
95
|
+
{
|
|
96
|
+
"name": "filled"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"name": "outlined"
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"name": "label",
|
|
105
|
+
"description": "The floating label for the field",
|
|
106
|
+
"values": []
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"name": "counter",
|
|
110
|
+
"values": []
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"name": "hide-counter",
|
|
114
|
+
"values": []
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"name": "supporting-text",
|
|
118
|
+
"description": "Supporting text conveys additional information about the field, such as how it will be used",
|
|
119
|
+
"values": []
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"name": "error-text",
|
|
123
|
+
"description": "For text fields that validate their content (such as passwords), replace supporting text with error text when applicable.\nIf `errorText` is not an empty string, changing the property `invalid` to `true` will show the `errorText` instead of `supportingText`",
|
|
124
|
+
"values": []
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"name": "empty",
|
|
128
|
+
"description": "Whether the field is empty or not. This changes the behavior of the floating label when the field is not focused.",
|
|
129
|
+
"values": []
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"name": "disabled",
|
|
133
|
+
"values": []
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"name": "invalid",
|
|
137
|
+
"description": "Get or sets where or not the field is in a visually invalid state.",
|
|
138
|
+
"values": []
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"name": "has-leading-icon",
|
|
142
|
+
"description": "Whether the field has a leading icon or not\n\n_Note:_ Readonly",
|
|
143
|
+
"values": []
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"name": "has-trailing-icon",
|
|
147
|
+
"description": "Whether the field has a trailing icon or not\n\n_Note:_ Readonly",
|
|
148
|
+
"values": []
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"name": "has-error-text",
|
|
152
|
+
"description": "Whether the field has an error text or not\n\n_Note:_ Readonly",
|
|
153
|
+
"values": []
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
"references": []
|
|
157
|
+
},
|
|
80
158
|
{
|
|
81
159
|
"name": "u-button-set",
|
|
82
160
|
"description": "\n---\n",
|
|
@@ -492,79 +570,45 @@
|
|
|
492
570
|
"references": []
|
|
493
571
|
},
|
|
494
572
|
{
|
|
495
|
-
"name": "u-
|
|
573
|
+
"name": "u-card-content",
|
|
496
574
|
"description": "\n---\n",
|
|
497
575
|
"attributes": [
|
|
498
576
|
{
|
|
499
|
-
"name": "
|
|
577
|
+
"name": "has-content",
|
|
500
578
|
"values": []
|
|
501
|
-
}
|
|
579
|
+
}
|
|
580
|
+
],
|
|
581
|
+
"references": []
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
"name": "u-card-media",
|
|
585
|
+
"description": "\n---\n",
|
|
586
|
+
"attributes": [
|
|
502
587
|
{
|
|
503
|
-
"name": "
|
|
588
|
+
"name": "wide",
|
|
504
589
|
"values": []
|
|
505
|
-
}
|
|
590
|
+
}
|
|
591
|
+
],
|
|
592
|
+
"references": []
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
"name": "u-card",
|
|
596
|
+
"description": "\n---\n",
|
|
597
|
+
"attributes": [
|
|
506
598
|
{
|
|
507
599
|
"name": "variant",
|
|
600
|
+
"description": "The Card variant to render.",
|
|
508
601
|
"values": [
|
|
509
602
|
{
|
|
510
603
|
"name": "filled"
|
|
511
604
|
},
|
|
605
|
+
{
|
|
606
|
+
"name": "elevated"
|
|
607
|
+
},
|
|
512
608
|
{
|
|
513
609
|
"name": "outlined"
|
|
514
610
|
}
|
|
515
611
|
]
|
|
516
|
-
},
|
|
517
|
-
{
|
|
518
|
-
"name": "label",
|
|
519
|
-
"description": "The floating label for the field",
|
|
520
|
-
"values": []
|
|
521
|
-
},
|
|
522
|
-
{
|
|
523
|
-
"name": "counter",
|
|
524
|
-
"values": []
|
|
525
|
-
},
|
|
526
|
-
{
|
|
527
|
-
"name": "hide-counter",
|
|
528
|
-
"values": []
|
|
529
|
-
},
|
|
530
|
-
{
|
|
531
|
-
"name": "supporting-text",
|
|
532
|
-
"description": "Supporting text conveys additional information about the field, such as how it will be used",
|
|
533
|
-
"values": []
|
|
534
|
-
},
|
|
535
|
-
{
|
|
536
|
-
"name": "error-text",
|
|
537
|
-
"description": "For text fields that validate their content (such as passwords), replace supporting text with error text when applicable.\nIf `errorText` is not an empty string, changing the property `invalid` to `true` will show the `errorText` instead of `supportingText`",
|
|
538
|
-
"values": []
|
|
539
|
-
},
|
|
540
|
-
{
|
|
541
|
-
"name": "empty",
|
|
542
|
-
"description": "Whether the field is empty or not. This changes the behavior of the floating label when the field is not focused.",
|
|
543
|
-
"values": []
|
|
544
|
-
},
|
|
545
|
-
{
|
|
546
|
-
"name": "disabled",
|
|
547
|
-
"values": []
|
|
548
|
-
},
|
|
549
|
-
{
|
|
550
|
-
"name": "invalid",
|
|
551
|
-
"description": "Get or sets where or not the field is in a visually invalid state.",
|
|
552
|
-
"values": []
|
|
553
|
-
},
|
|
554
|
-
{
|
|
555
|
-
"name": "has-leading-icon",
|
|
556
|
-
"description": "Whether the field has a leading icon or not\n\n_Note:_ Readonly",
|
|
557
|
-
"values": []
|
|
558
|
-
},
|
|
559
|
-
{
|
|
560
|
-
"name": "has-trailing-icon",
|
|
561
|
-
"description": "Whether the field has a trailing icon or not\n\n_Note:_ Readonly",
|
|
562
|
-
"values": []
|
|
563
|
-
},
|
|
564
|
-
{
|
|
565
|
-
"name": "has-error-text",
|
|
566
|
-
"description": "Whether the field has an error text or not\n\n_Note:_ Readonly",
|
|
567
|
-
"values": []
|
|
568
612
|
}
|
|
569
613
|
],
|
|
570
614
|
"references": []
|
|
@@ -637,50 +681,6 @@
|
|
|
637
681
|
],
|
|
638
682
|
"references": []
|
|
639
683
|
},
|
|
640
|
-
{
|
|
641
|
-
"name": "u-card-content",
|
|
642
|
-
"description": "\n---\n",
|
|
643
|
-
"attributes": [
|
|
644
|
-
{
|
|
645
|
-
"name": "has-content",
|
|
646
|
-
"values": []
|
|
647
|
-
}
|
|
648
|
-
],
|
|
649
|
-
"references": []
|
|
650
|
-
},
|
|
651
|
-
{
|
|
652
|
-
"name": "u-card-media",
|
|
653
|
-
"description": "\n---\n",
|
|
654
|
-
"attributes": [
|
|
655
|
-
{
|
|
656
|
-
"name": "wide",
|
|
657
|
-
"values": []
|
|
658
|
-
}
|
|
659
|
-
],
|
|
660
|
-
"references": []
|
|
661
|
-
},
|
|
662
|
-
{
|
|
663
|
-
"name": "u-card",
|
|
664
|
-
"description": "\n---\n",
|
|
665
|
-
"attributes": [
|
|
666
|
-
{
|
|
667
|
-
"name": "variant",
|
|
668
|
-
"description": "The Card variant to render.",
|
|
669
|
-
"values": [
|
|
670
|
-
{
|
|
671
|
-
"name": "filled"
|
|
672
|
-
},
|
|
673
|
-
{
|
|
674
|
-
"name": "elevated"
|
|
675
|
-
},
|
|
676
|
-
{
|
|
677
|
-
"name": "outlined"
|
|
678
|
-
}
|
|
679
|
-
]
|
|
680
|
-
}
|
|
681
|
-
],
|
|
682
|
-
"references": []
|
|
683
|
-
},
|
|
684
684
|
{
|
|
685
685
|
"name": "u-chip-field",
|
|
686
686
|
"description": "\n---\n\n\n### **Events:**\n - **change**",
|
|
@@ -1164,27 +1164,6 @@
|
|
|
1164
1164
|
],
|
|
1165
1165
|
"references": []
|
|
1166
1166
|
},
|
|
1167
|
-
{
|
|
1168
|
-
"name": "u-overflow-menu-item",
|
|
1169
|
-
"description": "\n---\n",
|
|
1170
|
-
"attributes": [
|
|
1171
|
-
{
|
|
1172
|
-
"name": "label",
|
|
1173
|
-
"values": []
|
|
1174
|
-
},
|
|
1175
|
-
{
|
|
1176
|
-
"name": "priority",
|
|
1177
|
-
"values": []
|
|
1178
|
-
}
|
|
1179
|
-
],
|
|
1180
|
-
"references": []
|
|
1181
|
-
},
|
|
1182
|
-
{
|
|
1183
|
-
"name": "u-overflow-menu",
|
|
1184
|
-
"description": "\n---\n",
|
|
1185
|
-
"attributes": [],
|
|
1186
|
-
"references": []
|
|
1187
|
-
},
|
|
1188
1167
|
{
|
|
1189
1168
|
"name": "u-circular-progress",
|
|
1190
1169
|
"description": "\n---\n",
|
|
@@ -1275,6 +1254,27 @@
|
|
|
1275
1254
|
],
|
|
1276
1255
|
"references": []
|
|
1277
1256
|
},
|
|
1257
|
+
{
|
|
1258
|
+
"name": "u-overflow-menu-item",
|
|
1259
|
+
"description": "\n---\n",
|
|
1260
|
+
"attributes": [
|
|
1261
|
+
{
|
|
1262
|
+
"name": "label",
|
|
1263
|
+
"values": []
|
|
1264
|
+
},
|
|
1265
|
+
{
|
|
1266
|
+
"name": "priority",
|
|
1267
|
+
"values": []
|
|
1268
|
+
}
|
|
1269
|
+
],
|
|
1270
|
+
"references": []
|
|
1271
|
+
},
|
|
1272
|
+
{
|
|
1273
|
+
"name": "u-overflow-menu",
|
|
1274
|
+
"description": "\n---\n",
|
|
1275
|
+
"attributes": [],
|
|
1276
|
+
"references": []
|
|
1277
|
+
},
|
|
1278
1278
|
{
|
|
1279
1279
|
"name": "u-ripple",
|
|
1280
1280
|
"description": "\n---\n",
|
|
@@ -1757,77 +1757,6 @@
|
|
|
1757
1757
|
],
|
|
1758
1758
|
"references": []
|
|
1759
1759
|
},
|
|
1760
|
-
{
|
|
1761
|
-
"name": "u-highlight",
|
|
1762
|
-
"description": "\n---\n",
|
|
1763
|
-
"attributes": [
|
|
1764
|
-
{
|
|
1765
|
-
"name": "result",
|
|
1766
|
-
"description": "The result text to display. If the term is found inside this text, it's highlighted",
|
|
1767
|
-
"values": []
|
|
1768
|
-
},
|
|
1769
|
-
{
|
|
1770
|
-
"name": "term",
|
|
1771
|
-
"description": "The searched term",
|
|
1772
|
-
"values": []
|
|
1773
|
-
}
|
|
1774
|
-
],
|
|
1775
|
-
"references": []
|
|
1776
|
-
},
|
|
1777
|
-
{
|
|
1778
|
-
"name": "u-typeahead",
|
|
1779
|
-
"description": "\n---\n\n\n### **Events:**\n - **input**\n- **change**",
|
|
1780
|
-
"attributes": [
|
|
1781
|
-
{
|
|
1782
|
-
"name": "debounce",
|
|
1783
|
-
"description": "The time in milliseconds before triggering an update in the results.",
|
|
1784
|
-
"values": []
|
|
1785
|
-
},
|
|
1786
|
-
{
|
|
1787
|
-
"name": "limit",
|
|
1788
|
-
"description": "The number of suggestions to show",
|
|
1789
|
-
"values": []
|
|
1790
|
-
},
|
|
1791
|
-
{
|
|
1792
|
-
"name": "minLength",
|
|
1793
|
-
"description": "How many characters must be typed before show suggestions\n\n_Note:_ Not used when the source is a `Promise`",
|
|
1794
|
-
"values": []
|
|
1795
|
-
},
|
|
1796
|
-
{
|
|
1797
|
-
"name": "open-on-focus",
|
|
1798
|
-
"description": "Whether the menu will be show when the target get focus.\n\n_Note:_ The `minLength` will still be applied",
|
|
1799
|
-
"values": []
|
|
1800
|
-
},
|
|
1801
|
-
{
|
|
1802
|
-
"name": "editable",
|
|
1803
|
-
"description": "If `true`, model values will not be restricted only to items selected from the menu.",
|
|
1804
|
-
"values": []
|
|
1805
|
-
},
|
|
1806
|
-
{
|
|
1807
|
-
"name": "autocomplete",
|
|
1808
|
-
"description": "The value for the `autocomplete` attribute for the target element.",
|
|
1809
|
-
"values": [
|
|
1810
|
-
{
|
|
1811
|
-
"name": "on"
|
|
1812
|
-
},
|
|
1813
|
-
{
|
|
1814
|
-
"name": "off"
|
|
1815
|
-
}
|
|
1816
|
-
]
|
|
1817
|
-
},
|
|
1818
|
-
{
|
|
1819
|
-
"name": "spellcheck",
|
|
1820
|
-
"description": "The value for the `spellcheck` attribute for the target element.",
|
|
1821
|
-
"values": []
|
|
1822
|
-
},
|
|
1823
|
-
{
|
|
1824
|
-
"name": "target-id",
|
|
1825
|
-
"description": "The id of the target element to attach the typeahead.",
|
|
1826
|
-
"values": []
|
|
1827
|
-
}
|
|
1828
|
-
],
|
|
1829
|
-
"references": []
|
|
1830
|
-
},
|
|
1831
1760
|
{
|
|
1832
1761
|
"name": "u-text-field",
|
|
1833
1762
|
"description": "\n---\n",
|
|
@@ -1944,6 +1873,77 @@
|
|
|
1944
1873
|
}
|
|
1945
1874
|
],
|
|
1946
1875
|
"references": []
|
|
1876
|
+
},
|
|
1877
|
+
{
|
|
1878
|
+
"name": "u-highlight",
|
|
1879
|
+
"description": "\n---\n",
|
|
1880
|
+
"attributes": [
|
|
1881
|
+
{
|
|
1882
|
+
"name": "result",
|
|
1883
|
+
"description": "The result text to display. If the term is found inside this text, it's highlighted",
|
|
1884
|
+
"values": []
|
|
1885
|
+
},
|
|
1886
|
+
{
|
|
1887
|
+
"name": "term",
|
|
1888
|
+
"description": "The searched term",
|
|
1889
|
+
"values": []
|
|
1890
|
+
}
|
|
1891
|
+
],
|
|
1892
|
+
"references": []
|
|
1893
|
+
},
|
|
1894
|
+
{
|
|
1895
|
+
"name": "u-typeahead",
|
|
1896
|
+
"description": "\n---\n\n\n### **Events:**\n - **input**\n- **change**",
|
|
1897
|
+
"attributes": [
|
|
1898
|
+
{
|
|
1899
|
+
"name": "debounce",
|
|
1900
|
+
"description": "The time in milliseconds before triggering an update in the results.",
|
|
1901
|
+
"values": []
|
|
1902
|
+
},
|
|
1903
|
+
{
|
|
1904
|
+
"name": "limit",
|
|
1905
|
+
"description": "The number of suggestions to show",
|
|
1906
|
+
"values": []
|
|
1907
|
+
},
|
|
1908
|
+
{
|
|
1909
|
+
"name": "minLength",
|
|
1910
|
+
"description": "How many characters must be typed before show suggestions\n\n_Note:_ Not used when the source is a `Promise`",
|
|
1911
|
+
"values": []
|
|
1912
|
+
},
|
|
1913
|
+
{
|
|
1914
|
+
"name": "open-on-focus",
|
|
1915
|
+
"description": "Whether the menu will be show when the target get focus.\n\n_Note:_ The `minLength` will still be applied",
|
|
1916
|
+
"values": []
|
|
1917
|
+
},
|
|
1918
|
+
{
|
|
1919
|
+
"name": "editable",
|
|
1920
|
+
"description": "If `true`, model values will not be restricted only to items selected from the menu.",
|
|
1921
|
+
"values": []
|
|
1922
|
+
},
|
|
1923
|
+
{
|
|
1924
|
+
"name": "autocomplete",
|
|
1925
|
+
"description": "The value for the `autocomplete` attribute for the target element.",
|
|
1926
|
+
"values": [
|
|
1927
|
+
{
|
|
1928
|
+
"name": "on"
|
|
1929
|
+
},
|
|
1930
|
+
{
|
|
1931
|
+
"name": "off"
|
|
1932
|
+
}
|
|
1933
|
+
]
|
|
1934
|
+
},
|
|
1935
|
+
{
|
|
1936
|
+
"name": "spellcheck",
|
|
1937
|
+
"description": "The value for the `spellcheck` attribute for the target element.",
|
|
1938
|
+
"values": []
|
|
1939
|
+
},
|
|
1940
|
+
{
|
|
1941
|
+
"name": "target-id",
|
|
1942
|
+
"description": "The id of the target element to attach the typeahead.",
|
|
1943
|
+
"values": []
|
|
1944
|
+
}
|
|
1945
|
+
],
|
|
1946
|
+
"references": []
|
|
1947
1947
|
}
|
|
1948
1948
|
]
|
|
1949
1949
|
}
|