@umbraco-ui/uui 2.0.0-alpha.1 → 2.0.0-rc.1
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 +45 -8
- package/dist/components/avatar/avatar.element.js +1 -0
- package/dist/components/avatar/avatar.element.js.map +1 -1
- package/dist/components/boolean-input/boolean-input.element.js +7 -1
- package/dist/components/boolean-input/boolean-input.element.js.map +1 -1
- package/dist/components/button/button.element.d.ts +0 -1
- package/dist/components/button/button.element.js +64 -18
- package/dist/components/button/button.element.js.map +1 -1
- package/dist/components/card-block-type/card-block-type.element.js +13 -4
- package/dist/components/card-block-type/card-block-type.element.js.map +1 -1
- package/dist/components/card-content-node/card-content-node.element.js +2 -2
- package/dist/components/card-content-node/card-content-node.element.js.map +1 -1
- package/dist/components/card-media/card-media.element.js +10 -3
- package/dist/components/card-media/card-media.element.js.map +1 -1
- package/dist/components/card-user/card-user.element.js +2 -2
- package/dist/components/card-user/card-user.element.js.map +1 -1
- package/dist/components/checkbox/checkbox.element.js +3 -6
- package/dist/components/checkbox/checkbox.element.js.map +1 -1
- package/dist/components/color-slider/color-slider.element.js +13 -3
- package/dist/components/color-slider/color-slider.element.js.map +1 -1
- package/dist/components/color-swatch/color-swatch.element.js +33 -1
- package/dist/components/color-swatch/color-swatch.element.js.map +1 -1
- package/dist/components/combobox/combobox.element.d.ts +9 -0
- package/dist/components/combobox/combobox.element.js +127 -15
- package/dist/components/combobox/combobox.element.js.map +1 -1
- package/dist/components/combobox-list/combobox-list-option.element.d.ts +1 -0
- package/dist/components/combobox-list/combobox-list-option.element.js +49 -10
- package/dist/components/combobox-list/combobox-list-option.element.js.map +1 -1
- package/dist/components/combobox-list/combobox-list.element.d.ts +14 -0
- package/dist/components/combobox-list/combobox-list.element.js +74 -25
- package/dist/components/combobox-list/combobox-list.element.js.map +1 -1
- package/dist/components/file-dropzone/file-dropzone.element.d.ts +2 -8
- package/dist/components/file-dropzone/file-dropzone.element.js +14 -25
- package/dist/components/file-dropzone/file-dropzone.element.js.map +1 -1
- package/dist/components/icon-registry-essential/UUIIconRegistryEssential.js +1 -1
- package/dist/components/icon-registry-essential/icon-registry-essential.js +33 -0
- package/dist/components/icon-registry-essential/icon-registry-essential.js.map +1 -1
- package/dist/components/index.d.ts +81 -0
- package/dist/components/input/input.element.js +33 -3
- package/dist/components/input/input.element.js.map +1 -1
- package/dist/components/input-file/input-file.element.js +33 -1
- package/dist/components/input-file/input-file.element.js.map +1 -1
- package/dist/components/input-lock/input-lock.element.js +33 -4
- package/dist/components/input-lock/input-lock.element.js.map +1 -1
- package/dist/components/input-password/input-password.element.js +33 -3
- package/dist/components/input-password/input-password.element.js.map +1 -1
- package/dist/components/keyboard-shortcut/key.element.js +7 -1
- package/dist/components/keyboard-shortcut/key.element.js.map +1 -1
- package/dist/components/loader/loader.element.js +19 -2
- package/dist/components/loader/loader.element.js.map +1 -1
- package/dist/components/modal/modal.js +7 -1
- package/dist/components/modal/modal.js.map +1 -1
- package/dist/components/pagination/pagination.element.d.ts +2 -0
- package/dist/components/pagination/pagination.element.js +26 -20
- package/dist/components/pagination/pagination.element.js.map +1 -1
- package/dist/components/progress-bar/progress-bar.element.js +6 -5
- package/dist/components/progress-bar/progress-bar.element.js.map +1 -1
- package/dist/components/responsive-container/responsive-container.element.js +36 -14
- package/dist/components/responsive-container/responsive-container.element.js.map +1 -1
- package/dist/components/scroll-container/scroll-container.element.js +4 -4
- package/dist/components/scroll-container/scroll-container.element.js.map +1 -1
- package/dist/components/symbol-expand/symbol-expand.element.js +1 -1
- package/dist/components/symbol-expand/symbol-expand.element.js.map +1 -1
- package/dist/components/symbol-file-thumbnail/symbol-file-thumbnail.element.js +34 -1
- package/dist/components/symbol-file-thumbnail/symbol-file-thumbnail.element.js.map +1 -1
- package/dist/components/table/table-head.element.js +4 -0
- package/dist/components/table/table-head.element.js.map +1 -1
- package/dist/components/table/table.element.js +5 -1
- package/dist/components/table/table.element.js.map +1 -1
- package/dist/components/tag/tag.element.js +4 -3
- package/dist/components/tag/tag.element.js.map +1 -1
- package/dist/components/toast-notification/toast-notification.element.js +34 -2
- package/dist/components/toast-notification/toast-notification.element.js.map +1 -1
- package/dist/components/toggle/toggle.element.js +38 -3
- package/dist/components/toggle/toggle.element.js.map +1 -1
- package/dist/index.d.ts +1 -81
- package/dist/internal/mixins/LabelMixin.js +14 -1
- package/dist/internal/mixins/LabelMixin.js.map +1 -1
- package/dist/internal/mixins/SelectOnlyMixin.d.ts +1 -1
- package/dist/internal/mixins/SelectOnlyMixin.js.map +1 -1
- package/dist/package.json.js +1 -1
- package/dist/themes/dark.css +1 -1
- package/dist/themes/high-contrast.css +1 -1
- package/dist/themes/light.css +1 -1
- package/package.json +26 -26
- package/vscode.html-custom-data.json +33 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.element.js","sources":["../../../src/components/input/input.element.ts"],"sourcesContent":["import {\n UUIFormControlWithBasicsMixin,\n LabelMixin,\n} from '../../internal/mixins/index.js';\nimport { css, html, LitElement } from 'lit';\nimport { property, query } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nimport { UUIInputEvent } from './UUIInputEvent.js';\n\nexport type InputType =\n | 'text'\n | 'tel'\n | 'url'\n | 'email'\n | 'password'\n | 'search'\n | 'month'\n | 'week'\n | 'time'\n | 'date'\n | 'datetime-local'\n | 'number'\n | 'color';\n\nexport type InputMode =\n | 'text'\n | 'none'\n | 'decimal'\n | 'numeric'\n | 'tel'\n | 'search'\n | 'email'\n | 'url';\n\n/**\n * Custom element wrapping the native input element.This is a formAssociated element, meaning it can participate in a native HTMLForm. A name:value pair will be submitted.\n * @element uui-input\n * @slot prepend - for components to render to the left of the input.\n * @slot append - for components to render to the right of the input.\n * @property {boolean} spellcheck - get/set native spellcheck attribute\n * @attribute spellcheck - native spellcheck attribute\n * @property {string} value - get/set the value of the input\n * @attribute value - get/set the value of the input\n * @property {string} name - get/set the name of the input\n * @attribute name - get/set the name of the input\n * @fires UUIInputEvent#change on change\n * @fires InputEvent#input on input\n * @fires KeyboardEvent#keyup on keyup\n * @cssprop --uui-input-height - Height of the element\n * @cssprop --uui-input-background-color - Background color of the element\n * @cssprop --uui-input-background-color-disabled - Background color when disabled\n * @cssprop --uui-input-background-color-readonly - Background color when readonly\n * @cssprop --uui-input-border-width - Border width\n * @cssprop --uui-input-border-radius - Border radius\n * @cssprop --uui-input-border-color - Border color\n * @cssprop --uui-input-border-color-hover - Border color on hover\n * @cssprop --uui-input-border-color-focus - Border color on focus\n * @cssprop --uui-input-border-color-disabled - Border color when disabled\n * @cssprop --uui-input-border-color-readonly - Border color when readonly\n */\nexport class UUIInputElement extends UUIFormControlWithBasicsMixin(\n LabelMixin('', LitElement),\n '',\n) {\n /**\n * This is a static class field indicating that the element is can be used inside a native form and participate in its events. It may require a polyfill, check support here https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/attachInternals. Read more about form controls here https://web.dev/more-capable-form-controls/\n * @type {boolean}\n */\n static readonly formAssociated = true;\n\n /**\n * Sets the min value of the input.\n * Examples: the first date the user may pick in date and datetime-local, or the min numeric value the user can pick in a number input.\n * @type {number | string}\n * @attr\n * @default undefined\n */\n @property()\n min?: number | string;\n\n /**\n * Sets the minimum length of the value of the input.\n * @type {number}\n * @attr\n * @default undefined\n */\n @property({ type: Number })\n minlength?: number;\n\n /**\n * Minlength validation message.\n * @attr minlength-message\n * @default\n */\n @property({ attribute: 'minlength-message' })\n minlengthMessage: string | ((charsLeft: number) => string) = charsLeft =>\n `${charsLeft} characters left`;\n\n /**\n * Sets the max value of the input.\n * Examples: the last date the user may pick in date and datetime-local, or the max numeric value the user can pick in a number input.\n * @type {number | string}\n * @attr\n * @default undefined\n */\n @property()\n max?: number | string;\n\n /**\n * Sets the maximum length of the value of the input.\n * @type {number}\n * @attr\n * @default undefined\n */\n @property({ type: Number })\n maxlength?: number;\n\n /**\n * Maxlength validation message.\n * @attr maxlength-message\n * @default\n */\n @property({ attribute: 'maxlength-message' })\n maxlengthMessage: string | ((max: number, current: number) => string) = (\n max,\n current,\n ) => `Maximum ${max} characters, ${current - max} too many.`;\n\n /**\n * Specifies the interval between legal numbers of the input\n * @type {number}\n * @attr\n * @default undefined\n */\n @property({ type: Number })\n step?: number;\n\n /**\n * Disables the input.\n * @type {boolean}\n * @attr\n * @default false\n */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n /**\n * Sets the input to readonly mode, meaning value cannot be changed but still able to read and select its content.\n * @type {boolean}\n * @attr\n * @default false\n */\n @property({ type: Boolean, reflect: true })\n readonly = false;\n\n /**\n * Defines the input placeholder.\n * @type {string}\n * @attr\n * @default ''\n */\n @property()\n placeholder = '';\n\n /**\n * Defines the input autocomplete.\n * @type {string}\n * @attr\n * @default undefined\n */\n @property()\n autocomplete?: string;\n\n /**\n * Sets the input width to fit the value or placeholder if empty\n * @type {boolean}\n * @attr auto-width\n */\n @property({ type: Boolean, reflect: true, attribute: 'auto-width' })\n autoWidth = false;\n\n /**\n * This property specifies the type of input that will be rendered.\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types|MDN} for further information\n * @type {'text' | 'tel' | 'url' | 'email' | 'password' | 'date' | 'month' | 'week' | 'time' | 'datetime-local' | 'number' | 'color'}\n * @attr\n * @default text\n */\n @property({ type: String })\n get type(): InputType {\n return this._type;\n }\n set type(value: InputType) {\n this._type = value;\n }\n\n /**\n * The inputmode global attribute is an enumerated attribute that hints at the type of data that might be entered by the user while editing the element or its contents. This allows a browser to display an appropriate virtual keyboard.\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode|MDN} for further information\n * @type {'text' | 'none' | 'decimal' | 'number' | 'tel' | 'search' | 'email' | 'url'}\n * @attr\n * @default text\n */\n @property({ attribute: 'inputmode' })\n inputMode: InputMode = 'text';\n\n /**\n * Validates the input based on the Regex pattern\n * @type {string}\n * @attr\n */\n @property({ type: String })\n pattern?: string;\n\n /**\n * Set the input tabindex, set this to `-1` to avoid tabbing into the input.\n * @type {number}\n * @attr\n */\n @property({ type: Number, reflect: false, attribute: 'tabindex' })\n tabIndex: number = 0;\n\n @query('#input')\n readonly _input!: HTMLInputElement;\n\n private _type: InputType = 'text';\n\n constructor() {\n super();\n\n this.addEventListener('keydown', this.#onKeyDown);\n\n this.addValidator(\n 'tooShort',\n () => {\n const label = this.minlengthMessage;\n if (typeof label === 'function') {\n return label(\n this.minlength ? this.minlength - String(this.value).length : 0,\n );\n }\n return label;\n },\n () => !!this.minlength && String(this.value).length < this.minlength,\n );\n this.addValidator(\n 'tooLong',\n () => {\n const label = this.maxlengthMessage;\n if (typeof label === 'function') {\n return label(this.maxlength ?? 0, String(this.value).length);\n }\n return label;\n },\n () => !!this.maxlength && String(this.value).length > this.maxlength,\n );\n\n this.updateComplete.then(() => {\n this.addFormControlElement(this._input);\n });\n }\n\n #onKeyDown(e: KeyboardEvent): void {\n if (this.type !== 'color' && e.key == 'Enter') {\n this.submit();\n }\n }\n\n /**\n * Removes focus from the input.\n */\n async blur() {\n await this.updateComplete;\n this._input.blur();\n }\n\n /**\n * This method enables <label for=\"...\"> to focus the input\n */\n async focus() {\n await this.updateComplete;\n this._input.focus();\n }\n\n /**\n * Selects all the text in the input.\n */\n async select() {\n await this.updateComplete;\n this._input.select();\n }\n\n protected getFormElement(): HTMLElement {\n return this.shadowRoot?.querySelector('input') as HTMLElement;\n }\n\n protected onInput(e: Event) {\n e.stopPropagation();\n this.value = (e.target as HTMLInputElement).value;\n\n this.dispatchEvent(new UUIInputEvent(UUIInputEvent.INPUT));\n }\n\n protected onChange(e: Event) {\n e.stopPropagation();\n this.pristine = false;\n\n this.dispatchEvent(new UUIInputEvent(UUIInputEvent.CHANGE));\n }\n\n protected renderPrepend() {\n return html`<slot name=\"prepend\"></slot>`;\n }\n\n protected renderAppend() {\n return html`<slot name=\"append\"></slot>`;\n }\n\n render() {\n return html`\n ${this.renderPrepend()}\n ${this.autoWidth ? this.renderInputWithAutoWidth() : this.renderInput()}\n ${this.renderAppend()}\n `;\n }\n\n private renderInputWithAutoWidth() {\n return html`<div id=\"autoWidth\">\n ${this.renderInput()}${this.renderAutoWidthBackground()}\n </div>`;\n }\n\n renderInput() {\n return html`<input\n id=\"input\"\n size=${ifDefined(this.autoWidth ? '1' : undefined)}\n .type=${this.type}\n .value=${this.value as string}\n .name=${this.name}\n pattern=${ifDefined(this.pattern)}\n min=${ifDefined(this.min)}\n max=${ifDefined(this.max)}\n step=${ifDefined(this.step)}\n spellcheck=${this.spellcheck}\n autocomplete=${ifDefined(this.autocomplete as any)}\n placeholder=${ifDefined(this.placeholder)}\n aria-label=${ifDefined(this.label)}\n inputmode=${ifDefined(this.inputMode)}\n ?disabled=${this.disabled}\n ?autofocus=${this.autofocus}\n ?required=${this.required}\n ?readonly=${this.readonly}\n tabindex=${ifDefined(this.tabIndex)}\n @input=${this.onInput}\n @change=${this.onChange} />`;\n }\n\n private renderAutoWidthBackground() {\n return html` <div id=\"auto\" aria-hidden=\"true\">${this.renderText()}</div>`;\n }\n\n private renderText() {\n return html`${(this.value as string).length > 0\n ? this.value\n : this.placeholder}`;\n }\n\n static override readonly styles = [\n css`\n :host {\n position: relative;\n display: inline-flex;\n align-items: stretch;\n height: var(--uui-input-height, var(--uui-size-11));\n text-align: left;\n color: var(--uui-color-text);\n color-scheme: var(--uui-color-scheme, normal);\n box-sizing: border-box;\n background-color: var(\n --uui-input-background-color,\n var(--uui-color-surface)\n );\n border: var(--uui-input-border-width, 1px) solid\n var(--uui-input-border-color, var(--uui-color-border));\n border-radius: var(--uui-input-border-radius, var(--uui-border-radius));\n min-width: 0;\n\n --uui-input-padding: 1px var(--uui-size-space-3);\n --uui-button-height: 100%;\n --uui-button-border-radius: var(\n --uui-input-border-radius,\n var(--uui-border-radius)\n );\n --auto-width-text-margin-right: 0;\n --auto-width-text-margin-left: 0;\n }\n\n #autoWidth {\n position: relative;\n display: flex;\n flex-direction: column;\n align-items: stretch;\n justify-content: center;\n flex-grow: 1;\n flex-shrink: 1;\n min-width: 0;\n }\n\n #auto {\n border: 0 1px solid transparent;\n visibility: hidden;\n white-space: pre;\n z-index: -1;\n height: 0px;\n padding: 0 var(--uui-size-space-3);\n margin: 0 var(--auto-width-text-margin-right) 0\n var(--auto-width-text-margin-left);\n }\n\n :host(:hover) {\n border-color: var(\n --uui-input-border-color-hover,\n var(--uui-color-border-standalone)\n );\n }\n /* TODO: Fix so we dont get double outline when there is focus on things in the slot. */\n :host(:focus-within) {\n border-color: var(\n --uui-input-border-color-focus,\n var(--uui-color-border-emphasis)\n );\n outline: 2px solid var(--uui-color-focus);\n }\n :host(:focus) {\n border-color: var(\n --uui-input-border-color-focus,\n var(--uui-color-border-emphasis)\n );\n }\n :host([disabled]) {\n background-color: var(\n --uui-input-background-color-disabled,\n var(--uui-color-disabled)\n );\n border-color: var(\n --uui-input-border-color-disabled,\n var(--uui-color-disabled)\n );\n\n color: var(--uui-color-disabled-contrast);\n }\n :host([disabled]) input {\n -webkit-text-fill-color: var(\n --uui-color-disabled-contrast\n ); /* required on Safari and IOS */\n }\n :host([readonly]) {\n background-color: var(\n --uui-input-background-color-readonly,\n var(--uui-color-disabled)\n );\n border-color: var(\n --uui-input-border-color-readonly,\n var(--uui-color-disabled-standalone)\n );\n }\n\n :host(:not([pristine]):invalid),\n /* polyfill support */\n :host(:not([pristine])[internals-invalid]) {\n border-color: var(--uui-color-invalid);\n }\n\n input {\n font-family: inherit;\n padding: var(--uui-input-padding);\n font-size: inherit;\n color: inherit;\n border-radius: var(--uui-border-radius);\n box-sizing: border-box;\n border: none;\n background: none;\n min-width: 0;\n flex-grow: 1;\n flex-shrink: 1;\n height: inherit;\n text-align: inherit;\n outline: none;\n text-overflow: ellipsis;\n }\n\n input[type='password']::-ms-reveal {\n display: none;\n }\n\n /* TODO: make sure color looks good, or remove it as an option as we want to provide color-picker component */\n input[type='color'] {\n width: 30px;\n padding: 0;\n border: none;\n }\n\n slot[name='prepend'],\n slot[name='append'] {\n display: flex;\n align-items: center;\n line-height: 1;\n height: 100%;\n min-width: 0;\n }\n\n ::slotted(uui-input),\n ::slotted(uui-input-lock) {\n height: 100%;\n --uui-input-border-width: 0;\n }\n `,\n ];\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA6DO,MAAM,mBAAN,MAAM,yBAAwB;AAAA,EACnC,WAAW,IAAI,UAAU;AAAA,EACzB;AACF,EAAE;AAAA,EAoKA,cAAc;AACZ,UAAA;AAxKG;AAmCL,SAAA,mBAA6D,CAAA,cAC3D,GAAG,SAAS;AA2Bd,SAAA,mBAAwE,CACtE,KACA,YACG,WAAW,GAAG,gBAAgB,UAAU,GAAG;AAkBhD,SAAA,WAAW;AASX,SAAA,WAAW;AASX,SAAA,cAAc;AAiBd,SAAA,YAAY;AAyBZ,SAAA,YAAuB;AAgBvB,SAAA,WAAmB;AAKnB,SAAQ,QAAmB;AAKzB,SAAK,iBAAiB,WAAW,sBAAK,yCAAU;AAEhD,SAAK;AAAA,MACH;AAAA,MACA,MAAM;AACJ,cAAM,QAAQ,KAAK;AACnB,YAAI,OAAO,UAAU,YAAY;AAC/B,iBAAO;AAAA,YACL,KAAK,YAAY,KAAK,YAAY,OAAO,KAAK,KAAK,EAAE,SAAS;AAAA,UAAA;AAAA,QAElE;AACA,eAAO;AAAA,MACT;AAAA,MACA,MAAM,CAAC,CAAC,KAAK,aAAa,OAAO,KAAK,KAAK,EAAE,SAAS,KAAK;AAAA,IAAA;AAE7D,SAAK;AAAA,MACH;AAAA,MACA,MAAM;AACJ,cAAM,QAAQ,KAAK;AACnB,YAAI,OAAO,UAAU,YAAY;AAC/B,iBAAO,MAAM,KAAK,aAAa,GAAG,OAAO,KAAK,KAAK,EAAE,MAAM;AAAA,QAC7D;AACA,eAAO;AAAA,MACT;AAAA,MACA,MAAM,CAAC,CAAC,KAAK,aAAa,OAAO,KAAK,KAAK,EAAE,SAAS,KAAK;AAAA,IAAA;AAG7D,SAAK,eAAe,KA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CAAA;AASA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,SAAS,SAAS,MAAM;AAAA,GAnF/B,gBAoFX,WAAA,YAAA,CAAA;AASA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,SAAS,SAAS,MAAM;AAAA,GA5F/B,gBA6FX,WAAA,YAAA,CAAA;AASA,gBAAA;AAAA,EADC,SAAA;AAAS,GArGC,gBAsGX,WAAA,eAAA,CAAA;AASA,gBAAA;AAAA,EADC,SAAA;AAAS,GA9GC,gBA+GX,WAAA,gBAAA,CAAA;AAQA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,SAAS,SAAS,MAAM,WAAW,cAAc;AAAA,GAtHxD,gBAuHX,WAAA,aAAA,CAAA;AAUI,gBAAA;AAAA,EADH,SAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAhIf,gBAiIP,WAAA,QAAA,CAAA;AAeJ,gBAAA;AAAA,EADC,SAAS,EAAE,WAAW,YAAA,CAAa;AAAA,GA/IzB,gBAgJX,WAAA,aAAA,CAAA;AAQA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAvJf,gBAwJX,WAAA,WAAA,CAAA;AAQA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,QAAQ,SAAS,OAAO,WAAW,YAAY;AAAA,GA/JtD,gBAgKX,WAAA,YAAA,CAAA;AAGS,gBAAA;AAAA,EADR,MAAM,QAAQ;AAAA,GAlKJ,gBAmKF,WAAA,UAAA,CAAA;"}
|
|
1
|
+
{"version":3,"file":"input.element.js","sources":["../../../src/components/input/input.element.ts"],"sourcesContent":["import {\n UUIFormControlWithBasicsMixin,\n LabelMixin,\n} from '../../internal/mixins/index.js';\nimport { css, html, LitElement } from 'lit';\nimport { property, query } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nimport { UUIInputEvent } from './UUIInputEvent.js';\n\nexport type InputType =\n | 'text'\n | 'tel'\n | 'url'\n | 'email'\n | 'password'\n | 'search'\n | 'month'\n | 'week'\n | 'time'\n | 'date'\n | 'datetime-local'\n | 'number'\n | 'color';\n\nexport type InputMode =\n | 'text'\n | 'none'\n | 'decimal'\n | 'numeric'\n | 'tel'\n | 'search'\n | 'email'\n | 'url';\n\n/**\n * Custom element wrapping the native input element.This is a formAssociated element, meaning it can participate in a native HTMLForm. A name:value pair will be submitted.\n * @element uui-input\n * @slot prepend - for components to render to the left of the input.\n * @slot append - for components to render to the right of the input.\n * @property {boolean} spellcheck - get/set native spellcheck attribute\n * @attribute spellcheck - native spellcheck attribute\n * @property {string} value - get/set the value of the input\n * @attribute value - get/set the value of the input\n * @property {string} name - get/set the name of the input\n * @attribute name - get/set the name of the input\n * @fires UUIInputEvent#change on change\n * @fires InputEvent#input on input\n * @fires KeyboardEvent#keyup on keyup\n * @cssprop --uui-input-height - Height of the element\n * @cssprop --uui-input-background-color - Background color of the element\n * @cssprop --uui-input-background-color-disabled - Background color when disabled\n * @cssprop --uui-input-background-color-readonly - Background color when readonly\n * @cssprop --uui-input-border-width - Border width\n * @cssprop --uui-input-border-radius - Border radius\n * @cssprop --uui-input-border-color - Border color\n * @cssprop --uui-input-border-color-hover - Border color on hover\n * @cssprop --uui-input-border-color-focus - Border color on focus\n * @cssprop --uui-input-border-color-disabled - Border color when disabled\n * @cssprop --uui-input-border-color-readonly - Border color when readonly\n */\nexport class UUIInputElement extends UUIFormControlWithBasicsMixin(\n LabelMixin('', LitElement),\n '',\n) {\n /**\n * This is a static class field indicating that the element is can be used inside a native form and participate in its events. It may require a polyfill, check support here https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/attachInternals. Read more about form controls here https://web.dev/more-capable-form-controls/\n * @type {boolean}\n */\n static readonly formAssociated = true;\n\n /**\n * Sets the min value of the input.\n * Examples: the first date the user may pick in date and datetime-local, or the min numeric value the user can pick in a number input.\n * @type {number | string}\n * @attr\n * @default undefined\n */\n @property()\n min?: number | string;\n\n /**\n * Sets the minimum length of the value of the input.\n * @type {number}\n * @attr\n * @default undefined\n */\n @property({ type: Number })\n minlength?: number;\n\n /**\n * Minlength validation message.\n * @attr minlength-message\n * @default\n */\n @property({ attribute: 'minlength-message' })\n minlengthMessage: string | ((charsLeft: number) => string) = charsLeft =>\n `${charsLeft} characters left`;\n\n /**\n * Sets the max value of the input.\n * Examples: the last date the user may pick in date and datetime-local, or the max numeric value the user can pick in a number input.\n * @type {number | string}\n * @attr\n * @default undefined\n */\n @property()\n max?: number | string;\n\n /**\n * Sets the maximum length of the value of the input.\n * @type {number}\n * @attr\n * @default undefined\n */\n @property({ type: Number })\n maxlength?: number;\n\n /**\n * Maxlength validation message.\n * @attr maxlength-message\n * @default\n */\n @property({ attribute: 'maxlength-message' })\n maxlengthMessage: string | ((max: number, current: number) => string) = (\n max,\n current,\n ) => `Maximum ${max} characters, ${current - max} too many.`;\n\n /**\n * Specifies the interval between legal numbers of the input\n * @type {number}\n * @attr\n * @default undefined\n */\n @property({ type: Number })\n step?: number;\n\n /**\n * Disables the input.\n * @type {boolean}\n * @attr\n * @default false\n */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n /**\n * Sets the input to readonly mode, meaning value cannot be changed but still able to read and select its content.\n * @type {boolean}\n * @attr\n * @default false\n */\n @property({ type: Boolean, reflect: true })\n readonly = false;\n\n /**\n * Defines the input placeholder.\n * @type {string}\n * @attr\n * @default ''\n */\n @property()\n placeholder = '';\n\n /**\n * Defines the input autocomplete.\n * @type {string}\n * @attr\n * @default undefined\n */\n @property()\n autocomplete?: string;\n\n /**\n * Sets the input width to fit the value or placeholder if empty\n * @type {boolean}\n * @attr auto-width\n */\n @property({ type: Boolean, reflect: true, attribute: 'auto-width' })\n autoWidth = false;\n\n /**\n * This property specifies the type of input that will be rendered.\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types|MDN} for further information\n * @type {'text' | 'tel' | 'url' | 'email' | 'password' | 'date' | 'month' | 'week' | 'time' | 'datetime-local' | 'number' | 'color'}\n * @attr\n * @default text\n */\n @property({ type: String })\n get type(): InputType {\n return this._type;\n }\n set type(value: InputType) {\n this._type = value;\n }\n\n /**\n * The inputmode global attribute is an enumerated attribute that hints at the type of data that might be entered by the user while editing the element or its contents. This allows a browser to display an appropriate virtual keyboard.\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode|MDN} for further information\n * @type {'text' | 'none' | 'decimal' | 'number' | 'tel' | 'search' | 'email' | 'url'}\n * @attr\n * @default text\n */\n @property({ attribute: 'inputmode' })\n inputMode: InputMode = 'text';\n\n /**\n * Validates the input based on the Regex pattern\n * @type {string}\n * @attr\n */\n @property({ type: String })\n pattern?: string;\n\n /**\n * Set the input tabindex, set this to `-1` to avoid tabbing into the input.\n * @type {number}\n * @attr\n */\n @property({ type: Number, reflect: false, attribute: 'tabindex' })\n tabIndex: number = 0;\n\n @query('#input')\n readonly _input!: HTMLInputElement;\n\n private _type: InputType = 'text';\n\n constructor() {\n super();\n\n this.addEventListener('keydown', this.#onKeyDown);\n\n this.addValidator(\n 'tooShort',\n () => {\n const label = this.minlengthMessage;\n if (typeof label === 'function') {\n return label(\n this.minlength ? this.minlength - String(this.value).length : 0,\n );\n }\n return label;\n },\n () => !!this.minlength && String(this.value).length < this.minlength,\n );\n this.addValidator(\n 'tooLong',\n () => {\n const label = this.maxlengthMessage;\n if (typeof label === 'function') {\n return label(this.maxlength ?? 0, String(this.value).length);\n }\n return label;\n },\n () => !!this.maxlength && String(this.value).length > this.maxlength,\n );\n\n this.updateComplete.then(() => {\n this.addFormControlElement(this._input);\n });\n }\n\n #onKeyDown(e: KeyboardEvent): void {\n if (this.type !== 'color' && e.key == 'Enter') {\n this.submit();\n }\n }\n\n /**\n * Removes focus from the input.\n */\n async blur() {\n await this.updateComplete;\n this._input.blur();\n }\n\n /**\n * This method enables <label for=\"...\"> to focus the input\n */\n async focus() {\n await this.updateComplete;\n this._input.focus();\n }\n\n /**\n * Selects all the text in the input.\n */\n async select() {\n await this.updateComplete;\n this._input.select();\n }\n\n protected getFormElement(): HTMLElement {\n return this.shadowRoot?.querySelector('input') as HTMLElement;\n }\n\n protected onInput(e: Event) {\n e.stopPropagation();\n this.value = (e.target as HTMLInputElement).value;\n\n this.dispatchEvent(new UUIInputEvent(UUIInputEvent.INPUT));\n }\n\n protected onChange(e: Event) {\n e.stopPropagation();\n this.pristine = false;\n\n this.dispatchEvent(new UUIInputEvent(UUIInputEvent.CHANGE));\n }\n\n protected renderPrepend() {\n return html`<slot name=\"prepend\"></slot>`;\n }\n\n protected renderAppend() {\n return html`<slot name=\"append\"></slot>`;\n }\n\n render() {\n return html`\n ${this.renderPrepend()}\n <div id=\"inner\">\n <slot></slot>\n ${this.autoWidth ? this.renderInputWithAutoWidth() : this.renderInput()}\n </div>\n ${this.renderAppend()}\n `;\n }\n\n private renderInputWithAutoWidth() {\n return html`<div id=\"autoWidth\">\n ${this.renderInput()}${this.renderAutoWidthBackground()}\n </div>`;\n }\n\n renderInput() {\n return html`<input\n id=\"input\"\n size=${ifDefined(this.autoWidth ? '1' : undefined)}\n .type=${this.type}\n .value=${this.value as string}\n .name=${this.name}\n pattern=${ifDefined(this.pattern)}\n min=${ifDefined(this.min)}\n max=${ifDefined(this.max)}\n step=${ifDefined(this.step)}\n spellcheck=${this.spellcheck}\n autocomplete=${ifDefined(this.autocomplete as any)}\n placeholder=${ifDefined(this.placeholder)}\n aria-label=${ifDefined(\n this.getAttribute('aria-label') || this.label || undefined,\n )}\n aria-labelledby=${ifDefined(\n this.getAttribute('aria-labelledby') || undefined,\n )}\n inputmode=${ifDefined(this.inputMode)}\n ?disabled=${this.disabled}\n ?autofocus=${this.autofocus}\n ?required=${this.required}\n ?readonly=${this.readonly}\n tabindex=${ifDefined(this.tabIndex)}\n @input=${this.onInput}\n @change=${this.onChange} />`;\n }\n\n private renderAutoWidthBackground() {\n return html` <div id=\"auto\" aria-hidden=\"true\">${this.renderText()}</div>`;\n }\n\n private renderText() {\n return html`${(this.value as string).length > 0\n ? this.value\n : this.placeholder}`;\n }\n\n static override readonly styles = [\n css`\n :host {\n position: relative;\n display: inline-flex;\n align-items: stretch;\n height: var(--uui-input-height, var(--uui-size-11));\n text-align: left;\n color: var(--uui-color-text);\n color-scheme: var(--uui-color-scheme, normal);\n box-sizing: border-box;\n background-color: var(\n --uui-input-background-color,\n var(--uui-color-surface)\n );\n border: var(--uui-input-border-width, 1px) solid\n var(--uui-input-border-color, var(--uui-color-border));\n border-radius: var(--uui-input-border-radius, var(--uui-border-radius));\n min-width: 0;\n\n --uui-input-padding: 1px var(--uui-size-space-3) 3px\n var(--uui-size-space-3);\n --uui-button-height: 100%;\n --uui-button-border-radius: var(\n --uui-input-border-radius,\n var(--uui-border-radius)\n );\n --auto-width-text-margin-right: 0;\n --auto-width-text-margin-left: 0;\n }\n\n #autoWidth {\n position: relative;\n display: flex;\n flex-direction: column;\n align-items: stretch;\n justify-content: center;\n flex-grow: 1;\n flex-shrink: 1;\n min-width: 0;\n }\n\n #auto {\n border: 0 1px solid transparent;\n visibility: hidden;\n white-space: pre;\n z-index: -1;\n height: 0px;\n padding: 0 var(--uui-size-space-3);\n margin: 0 var(--auto-width-text-margin-right) 0\n var(--auto-width-text-margin-left);\n }\n\n :host(:hover) {\n border-color: var(\n --uui-input-border-color-hover,\n var(--uui-color-border-standalone)\n );\n }\n /* TODO: Fix so we dont get double outline when there is focus on things in the slot. */\n :host(:focus-within) {\n border-color: var(\n --uui-input-border-color-focus,\n var(--uui-color-border-emphasis)\n );\n outline: 2px solid var(--uui-color-focus);\n }\n :host(:focus) {\n border-color: var(\n --uui-input-border-color-focus,\n var(--uui-color-border-emphasis)\n );\n }\n :host([disabled]) {\n background-color: var(\n --uui-input-background-color-disabled,\n var(--uui-color-disabled)\n );\n border-color: var(\n --uui-input-border-color-disabled,\n var(--uui-color-disabled)\n );\n\n color: var(--uui-color-disabled-contrast);\n }\n :host([disabled]) input {\n -webkit-text-fill-color: var(\n --uui-color-disabled-contrast\n ); /* required on Safari and IOS */\n }\n :host([readonly]) {\n background-color: var(\n --uui-input-background-color-readonly,\n var(--uui-color-disabled)\n );\n border-color: var(\n --uui-input-border-color-readonly,\n var(--uui-color-disabled-standalone)\n );\n }\n\n :host(:not([pristine]):invalid),\n /* polyfill support */\n :host(:not([pristine])[internals-invalid]) {\n border-color: var(--uui-color-invalid);\n }\n\n input {\n font-family: inherit;\n padding: var(--uui-input-padding);\n font-size: inherit;\n color: inherit;\n border-radius: var(--uui-border-radius);\n box-sizing: border-box;\n border: none;\n background: none;\n min-width: 0;\n flex-grow: 1;\n flex-shrink: 1;\n height: inherit;\n text-align: inherit;\n outline: none;\n text-overflow: ellipsis;\n line-height: 1;\n flex: 1 1 auto;\n min-width: 60px;\n }\n\n input[type='password']::-ms-reveal {\n display: none;\n }\n\n /* TODO: make sure color looks good, or remove it as an option as we want to provide color-picker component */\n input[type='color'] {\n width: 30px;\n padding: 0;\n border: none;\n }\n\n slot[name='prepend'],\n slot[name='append'] {\n display: flex;\n align-items: center;\n line-height: 1;\n height: 100%;\n min-width: 0;\n }\n\n uui-input,\n uui-input-lock,\n ::slotted(uui-input),\n ::slotted(uui-input-lock) {\n height: 100%;\n --uui-input-border-width: 0;\n }\n\n uui-button,\n ::slotted(uui-button) {\n height: 100%;\n --uui-button-border-width: 0;\n }\n\n #inner {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 4px;\n flex: 1 1 auto;\n min-width: 0;\n padding: 2px;\n }\n `,\n ];\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA6DO,MAAM,mBAAN,MAAM,yBAAwB;AAAA,EACnC,WAAW,IAAI,UAAU;AAAA,EACzB;AACF,EAAE;AAAA,EAoKA,cAAc;AACZ,UAAA;AAxKG;AAmCL,SAAA,mBAA6D,CAAA,cAC3D,GAAG,SAAS;AA2Bd,SAAA,mBAAwE,CACtE,KACA,YACG,WAAW,GAAG,gBAAgB,UAAU,GAAG;AAkBhD,SAAA,WAAW;AASX,SAA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AA,CAAA;AASA,gBAAA;AAAA,EADC,SAAA;AAAS,GArGC,gBAsGX,WAAA,eAAA,CAAA;AASA,gBAAA;AAAA,EADC,SAAA;AAAS,GA9GC,gBA+GX,WAAA,gBAAA,CAAA;AAQA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,SAAS,SAAS,MAAM,WAAW,cAAc;AAAA,GAtHxD,gBAuHX,WAAA,aAAA,CAAA;AAUI,gBAAA;AAAA,EADH,SAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAhIf,gBAiIP,WAAA,QAAA,CAAA;AAeJ,gBAAA;AAAA,EADC,SAAS,EAAE,WAAW,YAAA,CAAa;AAAA,GA/IzB,gBAgJX,WAAA,aAAA,CAAA;AAQA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAvJf,gBAwJX,WAAA,WAAA,CAAA;AAQA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,QAAQ,SAAS,OAAO,WAAW,YAAY;AAAA,GA/JtD,gBAgKX,WAAA,YAAA,CAAA;AAGS,gBAAA;AAAA,EADR,MAAM,QAAQ;AAAA,GAlKJ,gBAmKF,WAAA,UAAA,CAAA;"}
|
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
import { query, property, state } from "lit/decorators.js";
|
|
2
2
|
import { LitElement, html, nothing, css } from "lit";
|
|
3
|
+
import "../icon-registry-essential/svgs/iconAdd.js";
|
|
4
|
+
import "../icon-registry-essential/svgs/iconAlert.js";
|
|
5
|
+
import "../icon-registry-essential/svgs/iconAttachment.js";
|
|
6
|
+
import "../icon-registry-essential/svgs/iconCalendar.js";
|
|
7
|
+
import "../icon-registry-essential/svgs/iconCheck.js";
|
|
8
|
+
import "../icon-registry-essential/svgs/iconClipboard.js";
|
|
9
|
+
import "../icon-registry-essential/svgs/iconCode.js";
|
|
10
|
+
import "../icon-registry-essential/svgs/iconColorPicker.js";
|
|
11
|
+
import "../icon-registry-essential/svgs/iconCopy.js";
|
|
12
|
+
import { iconDelete } from "../icon-registry-essential/svgs/iconDelete.js";
|
|
13
|
+
import "../icon-registry-essential/svgs/iconDocument.js";
|
|
14
|
+
import "../icon-registry-essential/svgs/iconDownload.js";
|
|
15
|
+
import "../icon-registry-essential/svgs/iconDrag.js";
|
|
16
|
+
import "../icon-registry-essential/svgs/iconEdit.js";
|
|
17
|
+
import "../icon-registry-essential/svgs/iconFavorite.js";
|
|
18
|
+
import "../icon-registry-essential/svgs/iconFolder.js";
|
|
19
|
+
import "../icon-registry-essential/svgs/iconForbidden.js";
|
|
20
|
+
import "../icon-registry-essential/svgs/iconInfo.js";
|
|
21
|
+
import "../icon-registry-essential/svgs/iconLink.js";
|
|
22
|
+
import "../icon-registry-essential/svgs/iconLock.js";
|
|
23
|
+
import "../icon-registry-essential/svgs/iconPause.js";
|
|
24
|
+
import "../icon-registry-essential/svgs/iconPicture.js";
|
|
25
|
+
import "../icon-registry-essential/svgs/iconPlay.js";
|
|
26
|
+
import "../icon-registry-essential/svgs/iconRemove.js";
|
|
27
|
+
import "../icon-registry-essential/svgs/iconSearch.js";
|
|
28
|
+
import "../icon-registry-essential/svgs/iconSee.js";
|
|
29
|
+
import "../icon-registry-essential/svgs/iconSettings.js";
|
|
30
|
+
import "../icon-registry-essential/svgs/iconSubtract.js";
|
|
31
|
+
import "../icon-registry-essential/svgs/iconSync.js";
|
|
32
|
+
import "../icon-registry-essential/svgs/iconUnlock.js";
|
|
33
|
+
import "../icon-registry-essential/svgs/iconUnsee.js";
|
|
34
|
+
import "../icon-registry-essential/svgs/iconWand.js";
|
|
35
|
+
import "../icon-registry-essential/svgs/iconWrong.js";
|
|
3
36
|
import { repeat } from "lit/directives/repeat.js";
|
|
4
37
|
import "../file-preview/file-preview.js";
|
|
5
38
|
import "../action-bar/action-bar.js";
|
|
@@ -7,7 +40,6 @@ import "../button/button.js";
|
|
|
7
40
|
import "../icon/icon.js";
|
|
8
41
|
import "../file-dropzone/file-dropzone.js";
|
|
9
42
|
import { UUIFormControlWithBasicsMixin } from "../../internal/mixins/FormControlWithBasicsMixin.js";
|
|
10
|
-
import { iconDelete } from "../icon-registry-essential/svgs/iconDelete.js";
|
|
11
43
|
var __defProp = Object.defineProperty;
|
|
12
44
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
13
45
|
var result = void 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-file.element.js","sources":["../../../src/components/input-file/input-file.element.ts"],"sourcesContent":["import { property, query, state } from 'lit/decorators.js';\nimport { css, html, LitElement, nothing } from 'lit';\nimport type { UUIFileDropzoneElement } from '../file-dropzone/file-dropzone.js';\nimport { UUIFormControlWithBasicsMixin } from '../../internal/mixins/index.js';\nimport { iconDelete } from '../icon-registry-essential/svgs/index.js';\nimport { repeat } from 'lit/directives/repeat.js';\n\nimport '../file-preview/file-preview.js';\nimport '../action-bar/action-bar.js';\nimport '../button/button.js';\nimport '../icon/icon.js';\nimport '../file-dropzone/file-dropzone.js';\n\n// TODO: Missing change event, when files are changed.\n/**\n * @element uui-input-file\n * @description - A form associated file input that supports multiple files.\n * @extends UUIFormControlMixin\n */\nexport class UUIInputFileElement extends UUIFormControlWithBasicsMixin(\n LitElement,\n) {\n @query('#dropzone')\n private readonly _dropzone!: UUIFileDropzoneElement;\n\n @query('#dropzone')\n private readonly _dropZone: UUIFileDropzoneElement | undefined;\n\n /**\n * Accepted filetypes. Will allow all types if empty.\n * @type {string}\n * @attr\n * @default false\n */\n @property({ type: String })\n public accept: string = '';\n\n /**\n * Allows for multiple files to be selected.\n * @type {boolean}\n * @attr\n * @default false\n */\n @property({ type: Boolean })\n public multiple: boolean = false;\n\n get value() {\n return super.value;\n }\n set value(newValue) {\n super.value = newValue;\n\n if (newValue instanceof FormData) {\n const data = (\n this.multiple ? newValue.getAll(this.name) : [newValue.get(this.name)]\n ) as Array<File>;\n this._updateFileWrappers(data);\n return;\n }\n\n if (newValue instanceof File) {\n this._updateFileWrappers([newValue]);\n }\n }\n\n @state()\n private _files: File[] = [];\n\n constructor() {\n super();\n this.addEventListener('dragenter', () => this._setShowDropzone(true));\n this.addEventListener('dragleave', () => this._setShowDropzone(false));\n this.addEventListener('drop', () => this._setShowDropzone(false));\n }\n\n protected getFormElement(): HTMLElement {\n return this._dropZone! as HTMLElement;\n }\n\n /**\n * Removes focus from the input.\n */\n async blur() {\n await this.updateComplete;\n this._dropzone.blur();\n }\n\n /**\n * This method enables <label for=\"...\"> to focus the input\n */\n async focus() {\n await this.updateComplete;\n this._dropzone.focus();\n }\n\n async click() {\n await this.updateComplete;\n this._dropzone.browse();\n }\n\n private _handleClick(e: Event) {\n e.stopImmediatePropagation();\n this._dropzone.browse();\n }\n\n private readonly _updateFileWrappers = (data: Array<File>) => {\n let newFileWrappers: Array<File> = [];\n\n for (const file of data) {\n if (this.multiple) {\n newFileWrappers.push(file);\n } else {\n newFileWrappers = [file];\n }\n }\n\n this._files = newFileWrappers;\n };\n\n private async _handleFilesChange(event: CustomEvent) {\n const entries = event.detail.files as (File | FileSystemFileEntry)[];\n const files = entries.filter(\n entry => entry instanceof File || entry.isFile,\n );\n // TODO: implement folder preview + remove folder including children\n\n if (!this.multiple) {\n const entry = files[0];\n const isFile = entry instanceof File;\n const file = isFile ? entry : await this._getFile(entry);\n\n if (this.value instanceof File) {\n this.value = file;\n return;\n }\n\n if (this.value instanceof FormData) {\n this.value.delete(this.name);\n this.value.append(this.name, file);\n this._updateFileWrappers([file]);\n return;\n }\n }\n\n let newValue = this.value;\n\n if (files.length > 0 && !(this.value instanceof FormData)) {\n newValue = new FormData();\n }\n\n if (newValue instanceof FormData) {\n for (const entry of files) {\n const isFile = entry instanceof File;\n newValue.append(this.name, isFile ? entry : await this._getFile(entry));\n }\n }\n\n this.value = newValue;\n }\n\n private async _getFile(fileEntry: FileSystemFileEntry): Promise<File> {\n return await new Promise<File>((resolve, reject) =>\n fileEntry.file(resolve, reject),\n );\n }\n\n private _removeFile(index: number) {\n const fileToRemove = this._files[index];\n\n if (this.value instanceof FormData) {\n const files = this.value.getAll(this.name) as Array<File>;\n const filteredFiles = files.filter(file => file !== fileToRemove);\n\n if (filteredFiles.length === 0) {\n this.value = '';\n } else {\n this.value.delete(this.name);\n\n for (const file of filteredFiles) {\n this.value.append(this.name, file);\n }\n }\n\n this._updateFileWrappers(filteredFiles);\n }\n\n if (this.value instanceof File) {\n this.value = '';\n this._updateFileWrappers([]);\n }\n }\n\n private _setShowDropzone(show: boolean) {\n if (show) {\n this._dropZone!.style.display = 'flex';\n } else {\n this._dropZone!.style.display = 'none';\n }\n }\n\n private _renderFileItem(file: File, index: number) {\n return html`<uui-file-preview .file=\"${file}\">\n <uui-action-bar slot=\"actions\">\n <uui-button\n @click=${() => this._removeFile(index)}\n color=\"danger\"\n label=${`Delete ${file.name}`}>\n <uui-icon name=\"delete\" .fallback=${iconDelete.strings[0]}></uui-icon>\n </uui-button>\n </uui-action-bar>\n </uui-file-preview>`;\n }\n\n private _renderFiles() {\n return html`${repeat(\n this._files,\n (file: File) => file.name + file.size,\n (file: File, index: number) => this._renderFileItem(file, index),\n )}`;\n }\n\n render() {\n return html`\n <uui-file-dropzone\n id=\"dropzone\"\n ?multiple=${this.multiple}\n .accept=${this.accept}\n @change=${this._handleFilesChange}\n label=\"Drop files here\"></uui-file-dropzone>\n <div id=\"files\">\n ${this._renderFiles()}\n ${this._files.length === 0 || this.multiple\n ? html`<uui-button\n @click=${this._handleClick}\n id=\"add-button\"\n look=\"placeholder\"\n label=\"Add\"></uui-button>`\n : nothing}\n </div>\n `;\n }\n\n static override readonly styles = [\n css`\n :host {\n width: 100%;\n height: 100%;\n position: relative;\n display: flex;\n box-sizing: border-box;\n border: 1px solid var(--uui-color-border);\n }\n\n #input {\n position: absolute;\n width: 0px;\n height: 0px;\n opacity: 0;\n display: none;\n }\n\n #files {\n display: grid;\n box-sizing: border-box;\n justify-items: center;\n width: 100%;\n grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));\n grid-auto-rows: min-content;\n gap: 16px;\n padding: 16px;\n overflow: auto;\n max-height: 100%;\n }\n\n #dropzone {\n display: none;\n position: absolute;\n inset: 0px;\n z-index: 10;\n justify-content: center;\n align-items: center;\n }\n\n #add-button {\n width: 150px;\n height: 150px;\n display: flex;\n padding: 16px;\n box-sizing: border-box;\n justify-content: center;\n align-items: stretch;\n }\n `,\n ];\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAmBO,MAAM,uBAAN,MAAM,6BAA4B;AAAA,EACvC;AACF,EAAE;AAAA,EA+CA,cAAc;AACZ,UAAA;AAlCF,SAAO,SAAiB;AASxB,SAAO,WAAoB;AAsB3B,SAAQ,SAAiB,CAAA;AAuCzB,SAAiB,sBAAsB,CAAC,SAAsB;AAC5D,UAAI,kBAA+B,CAAA;AAEnC,iBAAW,QAAQ,MAAM;AACvB,YAAI,KAAK,UAAU;AACjB,0BAAgB,KAAK,IAAI;AAAA,QAC3B,OAAO;AACL,4BAAkB,CAAC,IAAI;AAAA,QACzB;AAAA,MACF;AAEA,WAAK,SAAS;AAAA,IAChB;AA/CE,SAAK,iBAAiB,aAAa,MAAM,KAAK,iBAAiB,IAAI,CAAC;AACpE,SAAK,iBAAiB,aAAa,MAAM,KAAK,iBAAiB,KAAK,CAAC;AACrE,SAAK,iBAAiB,QAAQ,MAAM,KAAK,iBAAiB,KAAK,CAAC;AAAA,EAClE;AAAA,EA3BA,IAAI,QAAQ;AACV,WAAO,MAAM;AAAA,EACf;AAAA,EACA,IAAI,MAAM,UAAU;AAClB,UAAM,QAAQ;AAEd,QAAI,oBAAoB,UAAU;AAChC,YAAM,OACJ,KAAK,WAAW,SAAS,OAAO,KAAK,IAAI,IAAI,CAAC,SAAS,IAAI,KAAK,IAAI,CAAC;AAEvE,WAAK,oBAAoB,IAAI;AAC7B;AAAA,IACF;AAEA,QAAI,oBAAoB,MAAM;AAC5B,WAAK,oBAAoB,CAAC,QAAQ,CAAC;AAAA,IACrC;AAAA,EACF;AAAA,EAYU,iBAA8B;AACtC,WAAO,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AAAA,EAEA,SAAS;AACP,WAAO;AAAA;AAAA;AAAA,oBAGS,KAAK,QAAQ;AAAA,kBACf,KAAK,MAAM;AAAA,kBACX,KAAK,kBAAkB;AAAA;AAAA;AAAA,UAG/B,KAAK,cAAc;AAAA,UACnB,KAAK,OAAO,WAAW,KAAK,KAAK,WAC/B;AAAA,uBACW,KAAK,YAAY;AAAA;AAAA;AAAA,2CAI5B,OAAO;AAAA;AAAA;AAAA,EAGjB;AAsDF;AApDE,qBAAyB,SAAS;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAhOG,IAAM,sBAAN;AAIY,gBAAA;AAAA,EADhB,MAAM,WAAW;AAAA,GAHP,oBAIM,WAAA,WAAA;AAGA,gBAAA;AAAA,EADhB,MAAM,WAAW;AAAA,GANP,oBAOM,WAAA,WAAA;AASV,gBAAA;AAAA,EADN,SAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAff,oBAgBJ,WAAA,QAAA;AASA,gBAAA;AAAA,EADN,SAAS,EAAE,MAAM,QAAA,CAAS;AAAA,GAxBhB,oBAyBJ,WAAA,UAAA;AAsBC,gBAAA;AAAA,EADP,MAAA;AAAM,GA9CI,oBA+CH,WAAA,QAAA;"}
|
|
1
|
+
{"version":3,"file":"input-file.element.js","sources":["../../../src/components/input-file/input-file.element.ts"],"sourcesContent":["import { property, query, state } from 'lit/decorators.js';\nimport { css, html, LitElement, nothing } from 'lit';\nimport type { UUIFileDropzoneElement } from '../file-dropzone/file-dropzone.js';\nimport { UUIFormControlWithBasicsMixin } from '../../internal/mixins/index.js';\nimport { iconDelete } from '../icon-registry-essential/svgs/index.js';\nimport { repeat } from 'lit/directives/repeat.js';\n\nimport '../file-preview/file-preview.js';\nimport '../action-bar/action-bar.js';\nimport '../button/button.js';\nimport '../icon/icon.js';\nimport '../file-dropzone/file-dropzone.js';\n\n// TODO: Missing change event, when files are changed.\n/**\n * @element uui-input-file\n * @description - A form associated file input that supports multiple files.\n * @extends UUIFormControlMixin\n */\nexport class UUIInputFileElement extends UUIFormControlWithBasicsMixin(\n LitElement,\n) {\n @query('#dropzone')\n private readonly _dropzone!: UUIFileDropzoneElement;\n\n @query('#dropzone')\n private readonly _dropZone: UUIFileDropzoneElement | undefined;\n\n /**\n * Accepted filetypes. Will allow all types if empty.\n * @type {string}\n * @attr\n * @default false\n */\n @property({ type: String })\n public accept: string = '';\n\n /**\n * Allows for multiple files to be selected.\n * @type {boolean}\n * @attr\n * @default false\n */\n @property({ type: Boolean })\n public multiple: boolean = false;\n\n get value() {\n return super.value;\n }\n set value(newValue) {\n super.value = newValue;\n\n if (newValue instanceof FormData) {\n const data = (\n this.multiple ? newValue.getAll(this.name) : [newValue.get(this.name)]\n ) as Array<File>;\n this._updateFileWrappers(data);\n return;\n }\n\n if (newValue instanceof File) {\n this._updateFileWrappers([newValue]);\n }\n }\n\n @state()\n private _files: File[] = [];\n\n constructor() {\n super();\n this.addEventListener('dragenter', () => this._setShowDropzone(true));\n this.addEventListener('dragleave', () => this._setShowDropzone(false));\n this.addEventListener('drop', () => this._setShowDropzone(false));\n }\n\n protected getFormElement(): HTMLElement {\n return this._dropZone! as HTMLElement;\n }\n\n /**\n * Removes focus from the input.\n */\n async blur() {\n await this.updateComplete;\n this._dropzone.blur();\n }\n\n /**\n * This method enables <label for=\"...\"> to focus the input\n */\n async focus() {\n await this.updateComplete;\n this._dropzone.focus();\n }\n\n async click() {\n await this.updateComplete;\n this._dropzone.browse();\n }\n\n private _handleClick(e: Event) {\n e.stopImmediatePropagation();\n this._dropzone.browse();\n }\n\n private readonly _updateFileWrappers = (data: Array<File>) => {\n let newFileWrappers: Array<File> = [];\n\n for (const file of data) {\n if (this.multiple) {\n newFileWrappers.push(file);\n } else {\n newFileWrappers = [file];\n }\n }\n\n this._files = newFileWrappers;\n };\n\n private async _handleFilesChange(event: CustomEvent) {\n const entries = event.detail.files as (File | FileSystemFileEntry)[];\n const files = entries.filter(\n entry => entry instanceof File || entry.isFile,\n );\n // TODO: implement folder preview + remove folder including children\n\n if (!this.multiple) {\n const entry = files[0];\n const isFile = entry instanceof File;\n const file = isFile ? entry : await this._getFile(entry);\n\n if (this.value instanceof File) {\n this.value = file;\n return;\n }\n\n if (this.value instanceof FormData) {\n this.value.delete(this.name);\n this.value.append(this.name, file);\n this._updateFileWrappers([file]);\n return;\n }\n }\n\n let newValue = this.value;\n\n if (files.length > 0 && !(this.value instanceof FormData)) {\n newValue = new FormData();\n }\n\n if (newValue instanceof FormData) {\n for (const entry of files) {\n const isFile = entry instanceof File;\n newValue.append(this.name, isFile ? entry : await this._getFile(entry));\n }\n }\n\n this.value = newValue;\n }\n\n private async _getFile(fileEntry: FileSystemFileEntry): Promise<File> {\n return await new Promise<File>((resolve, reject) =>\n fileEntry.file(resolve, reject),\n );\n }\n\n private _removeFile(index: number) {\n const fileToRemove = this._files[index];\n\n if (this.value instanceof FormData) {\n const files = this.value.getAll(this.name) as Array<File>;\n const filteredFiles = files.filter(file => file !== fileToRemove);\n\n if (filteredFiles.length === 0) {\n this.value = '';\n } else {\n this.value.delete(this.name);\n\n for (const file of filteredFiles) {\n this.value.append(this.name, file);\n }\n }\n\n this._updateFileWrappers(filteredFiles);\n }\n\n if (this.value instanceof File) {\n this.value = '';\n this._updateFileWrappers([]);\n }\n }\n\n private _setShowDropzone(show: boolean) {\n if (show) {\n this._dropZone!.style.display = 'flex';\n } else {\n this._dropZone!.style.display = 'none';\n }\n }\n\n private _renderFileItem(file: File, index: number) {\n return html`<uui-file-preview .file=\"${file}\">\n <uui-action-bar slot=\"actions\">\n <uui-button\n @click=${() => this._removeFile(index)}\n color=\"danger\"\n label=${`Delete ${file.name}`}>\n <uui-icon name=\"delete\" .fallback=${iconDelete.strings[0]}></uui-icon>\n </uui-button>\n </uui-action-bar>\n </uui-file-preview>`;\n }\n\n private _renderFiles() {\n return html`${repeat(\n this._files,\n (file: File) => file.name + file.size,\n (file: File, index: number) => this._renderFileItem(file, index),\n )}`;\n }\n\n render() {\n return html`\n <uui-file-dropzone\n id=\"dropzone\"\n ?multiple=${this.multiple}\n .accept=${this.accept}\n @change=${this._handleFilesChange}\n label=\"Drop files here\"></uui-file-dropzone>\n <div id=\"files\">\n ${this._renderFiles()}\n ${this._files.length === 0 || this.multiple\n ? html`<uui-button\n @click=${this._handleClick}\n id=\"add-button\"\n look=\"placeholder\"\n label=\"Add\"></uui-button>`\n : nothing}\n </div>\n `;\n }\n\n static override readonly styles = [\n css`\n :host {\n width: 100%;\n height: 100%;\n position: relative;\n display: flex;\n box-sizing: border-box;\n border: 1px solid var(--uui-color-border);\n }\n\n #input {\n position: absolute;\n width: 0px;\n height: 0px;\n opacity: 0;\n display: none;\n }\n\n #files {\n display: grid;\n box-sizing: border-box;\n justify-items: center;\n width: 100%;\n grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));\n grid-auto-rows: min-content;\n gap: 16px;\n padding: 16px;\n overflow: auto;\n max-height: 100%;\n }\n\n #dropzone {\n display: none;\n position: absolute;\n inset: 0px;\n z-index: 10;\n justify-content: center;\n align-items: center;\n }\n\n #add-button {\n width: 150px;\n height: 150px;\n display: flex;\n padding: 16px;\n box-sizing: border-box;\n justify-content: center;\n align-items: stretch;\n }\n `,\n ];\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBO,MAAM,uBAAN,MAAM,6BAA4B;AAAA,EACvC;AACF,EAAE;AAAA,EA+CA,cAAc;AACZ,UAAA;AAlCF,SAAO,SAAiB;AASxB,SAAO,WAAoB;AAsB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AA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAhOG,IAAM,sBAAN;AAIY,gBAAA;AAAA,EADhB,MAAM,WAAW;AAAA,GAHP,oBAIM,WAAA,WAAA;AAGA,gBAAA;AAAA,EADhB,MAAM,WAAW;AAAA,GANP,oBAOM,WAAA,WAAA;AASV,gBAAA;AAAA,EADN,SAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAff,oBAgBJ,WAAA,QAAA;AASA,gBAAA;AAAA,EADN,SAAS,EAAE,MAAM,QAAA,CAAS;AAAA,GAxBhB,oBAyBJ,WAAA,UAAA;AAsBC,gBAAA;AAAA,EADP,MAAA;AAAM,GA9CI,oBA+CH,WAAA,QAAA;"}
|
|
@@ -8,13 +8,44 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
8
8
|
var _locked;
|
|
9
9
|
import { html, css } from "lit";
|
|
10
10
|
import "../input/input.js";
|
|
11
|
+
import "../icon-registry-essential/svgs/iconAdd.js";
|
|
12
|
+
import "../icon-registry-essential/svgs/iconAlert.js";
|
|
13
|
+
import "../icon-registry-essential/svgs/iconAttachment.js";
|
|
14
|
+
import "../icon-registry-essential/svgs/iconCalendar.js";
|
|
15
|
+
import "../icon-registry-essential/svgs/iconCheck.js";
|
|
16
|
+
import "../icon-registry-essential/svgs/iconClipboard.js";
|
|
17
|
+
import "../icon-registry-essential/svgs/iconCode.js";
|
|
18
|
+
import "../icon-registry-essential/svgs/iconColorPicker.js";
|
|
19
|
+
import "../icon-registry-essential/svgs/iconCopy.js";
|
|
20
|
+
import "../icon-registry-essential/svgs/iconDelete.js";
|
|
21
|
+
import "../icon-registry-essential/svgs/iconDocument.js";
|
|
22
|
+
import "../icon-registry-essential/svgs/iconDownload.js";
|
|
23
|
+
import "../icon-registry-essential/svgs/iconDrag.js";
|
|
24
|
+
import "../icon-registry-essential/svgs/iconEdit.js";
|
|
25
|
+
import "../icon-registry-essential/svgs/iconFavorite.js";
|
|
26
|
+
import "../icon-registry-essential/svgs/iconFolder.js";
|
|
27
|
+
import "../icon-registry-essential/svgs/iconForbidden.js";
|
|
28
|
+
import "../icon-registry-essential/svgs/iconInfo.js";
|
|
29
|
+
import "../icon-registry-essential/svgs/iconLink.js";
|
|
30
|
+
import { iconLock } from "../icon-registry-essential/svgs/iconLock.js";
|
|
31
|
+
import "../icon-registry-essential/svgs/iconPause.js";
|
|
32
|
+
import "../icon-registry-essential/svgs/iconPicture.js";
|
|
33
|
+
import "../icon-registry-essential/svgs/iconPlay.js";
|
|
34
|
+
import "../icon-registry-essential/svgs/iconRemove.js";
|
|
35
|
+
import "../icon-registry-essential/svgs/iconSearch.js";
|
|
36
|
+
import "../icon-registry-essential/svgs/iconSee.js";
|
|
37
|
+
import "../icon-registry-essential/svgs/iconSettings.js";
|
|
38
|
+
import "../icon-registry-essential/svgs/iconSubtract.js";
|
|
39
|
+
import "../icon-registry-essential/svgs/iconSync.js";
|
|
40
|
+
import { iconUnlock } from "../icon-registry-essential/svgs/iconUnlock.js";
|
|
41
|
+
import "../icon-registry-essential/svgs/iconUnsee.js";
|
|
42
|
+
import "../icon-registry-essential/svgs/iconWand.js";
|
|
43
|
+
import "../icon-registry-essential/svgs/iconWrong.js";
|
|
11
44
|
import { property } from "lit/decorators.js";
|
|
12
45
|
import { UUIInputLockEvent } from "./UUIInputLockEvent.js";
|
|
13
46
|
import "../icon/icon.js";
|
|
14
47
|
import "../button/button.js";
|
|
15
48
|
import { UUIInputElement } from "../input/input.element.js";
|
|
16
|
-
import { iconLock } from "../icon-registry-essential/svgs/iconLock.js";
|
|
17
|
-
import { iconUnlock } from "../icon-registry-essential/svgs/iconUnlock.js";
|
|
18
49
|
var __defProp = Object.defineProperty;
|
|
19
50
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
20
51
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
@@ -72,8 +103,6 @@ _UUIInputLockElement.styles = [
|
|
|
72
103
|
...UUIInputElement.styles,
|
|
73
104
|
css`
|
|
74
105
|
#lock {
|
|
75
|
-
height: 100%;
|
|
76
|
-
|
|
77
106
|
--uui-input-padding: 1px var(--uui-size-space-1);
|
|
78
107
|
--uui-button-padding-left-factor: 0.75;
|
|
79
108
|
--uui-button-padding-right-factor: 0.75;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-lock.element.js","sources":["../../../src/components/input-lock/input-lock.element.ts"],"sourcesContent":["import { css, html } from 'lit';\nimport { UUIInputElement } from '../input/input.js';\nimport { iconLock, iconUnlock } from '../icon-registry-essential/svgs/index.js';\nimport { property } from 'lit/decorators.js';\nimport { UUIInputLockEvent } from './UUIInputLockEvent.js';\n\nimport '../icon/icon.js';\nimport '../button/button.js';\n\n/**\n * @element uui-input-lock\n * @extends uui-input\n */\nexport class UUIInputLockElement extends UUIInputElement {\n /**\n * Determine the inputs locked state.\n * @type {boolean}\n * @attr\n * @default true\n */\n @property({ type: Boolean, reflect: true })\n public set locked(lock: boolean) {\n this.#locked = lock;\n this.readonly = lock;\n this.tabIndex = lock ? -1 : 0;\n }\n public get locked(): boolean {\n return this.#locked;\n }\n #locked: boolean = true;\n\n /**\n * Define the label for the unlock button.\n * @type {string}\n * @attr\n * @default true\n */\n @property({ type: String, reflect: false, attribute: 'unlock-label' })\n public unlockLabel: string = 'Unlock input';\n\n /**\n * Define the label for the lock button.\n * @type {string}\n * @attr\n * @default true\n */\n @property({ type: String, reflect: false, attribute: 'lock-label' })\n public lockLabel: string = 'Lock input';\n\n constructor() {\n super();\n this.readonly = true;\n this.tabIndex = -1;\n }\n\n _onLockToggle() {\n this.locked = !this.locked;\n this.pristine = false;\n this.dispatchEvent(new UUIInputLockEvent(UUIInputLockEvent.LOCK_CHANGE));\n if (!this.locked) {\n this._input?.focus();\n }\n }\n\n renderIcon() {\n return this.locked === true\n ? html`<uui-icon name=\"lock\" .fallback=${iconLock.strings[0]}></uui-icon>`\n : html`<uui-icon\n name=\"unlock\"\n .fallback=${iconUnlock.strings[0]}></uui-icon>`;\n }\n\n renderPrepend() {\n return html`<uui-button\n .disabled=${this.disabled}\n @click=${this._onLockToggle}\n compact\n id=\"lock\"\n label=\"${this.locked ? this.unlockLabel : this.lockLabel}\">\n ${this.renderIcon()}\n </uui-button>`;\n }\n\n static override readonly styles = [\n ...UUIInputElement.styles,\n css`\n #lock {\n
|
|
1
|
+
{"version":3,"file":"input-lock.element.js","sources":["../../../src/components/input-lock/input-lock.element.ts"],"sourcesContent":["import { css, html } from 'lit';\nimport { UUIInputElement } from '../input/input.js';\nimport { iconLock, iconUnlock } from '../icon-registry-essential/svgs/index.js';\nimport { property } from 'lit/decorators.js';\nimport { UUIInputLockEvent } from './UUIInputLockEvent.js';\n\nimport '../icon/icon.js';\nimport '../button/button.js';\n\n/**\n * @element uui-input-lock\n * @extends uui-input\n */\nexport class UUIInputLockElement extends UUIInputElement {\n /**\n * Determine the inputs locked state.\n * @type {boolean}\n * @attr\n * @default true\n */\n @property({ type: Boolean, reflect: true })\n public set locked(lock: boolean) {\n this.#locked = lock;\n this.readonly = lock;\n this.tabIndex = lock ? -1 : 0;\n }\n public get locked(): boolean {\n return this.#locked;\n }\n #locked: boolean = true;\n\n /**\n * Define the label for the unlock button.\n * @type {string}\n * @attr\n * @default true\n */\n @property({ type: String, reflect: false, attribute: 'unlock-label' })\n public unlockLabel: string = 'Unlock input';\n\n /**\n * Define the label for the lock button.\n * @type {string}\n * @attr\n * @default true\n */\n @property({ type: String, reflect: false, attribute: 'lock-label' })\n public lockLabel: string = 'Lock input';\n\n constructor() {\n super();\n this.readonly = true;\n this.tabIndex = -1;\n }\n\n _onLockToggle() {\n this.locked = !this.locked;\n this.pristine = false;\n this.dispatchEvent(new UUIInputLockEvent(UUIInputLockEvent.LOCK_CHANGE));\n if (!this.locked) {\n this._input?.focus();\n }\n }\n\n renderIcon() {\n return this.locked === true\n ? html`<uui-icon name=\"lock\" .fallback=${iconLock.strings[0]}></uui-icon>`\n : html`<uui-icon\n name=\"unlock\"\n .fallback=${iconUnlock.strings[0]}></uui-icon>`;\n }\n\n renderPrepend() {\n return html`<uui-button\n .disabled=${this.disabled}\n @click=${this._onLockToggle}\n compact\n id=\"lock\"\n label=\"${this.locked ? this.unlockLabel : this.lockLabel}\">\n ${this.renderIcon()}\n </uui-button>`;\n }\n\n static override readonly styles = [\n ...UUIInputElement.styles,\n css`\n #lock {\n --uui-input-padding: 1px var(--uui-size-space-1);\n --uui-button-padding-left-factor: 0.75;\n --uui-button-padding-right-factor: 0.75;\n font-size: 12px;\n }\n\n :host([locked]) #input {\n cursor: not-allowed;\n opacity: 0.55;\n }\n `,\n ];\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaO,MAAM,uBAAN,MAAM,6BAA4B,gBAAgB;AAAA,EAoCvD,cAAc;AACZ,UAAA;AArBF;AAAA,uBAAA,SAAmB;AASnB,SAAO,cAAsB;AAS7B,SAAO,YAAoB;AAIzB,SAAK,WAAW;AAChB,SAAK,WAAW;AAAA,EAClB;AAAA,EAhCA,IAAW,OAAO,MAAe;AAC/B,uBAAK,SAAU;AACf,SAAK,WAAW;AAChB,SAAK,WAAW,OAAO,KAAK;AAAA,EAC9B;AAAA,EACA,IAAW,SAAkB;AAC3B,WAAO,mBAAK;AAAA,EACd;AAAA,EA2BA,gBAAgB;AACd,SAAK,SAAS,CAAC,KAAK;AACpB,SAAK,WAAW;AAChB,SAAK,cAAc,IAAI,kBAAkB,kBAAkB,WAAW,CAAC;AACvE,QAAI,CAAC,KAAK,QAAQ;AAChB,WAAK,QAAQ,MAAA;AAAA,IACf;AAAA,EACF;AAAA,EAEA,aAAa;AACX,WAAO,KAAK,WAAW,OACnB,uCAAuC,SAAS,QAAQ,CAAC,CAAC,iBAC1D;AAAA;AAAA,sBAEc,WAAW,QAAQ,CAAC,CAAC;AAAA,EACzC;AAAA,EAEA,gBAAgB;AACd,WAAO;AAAA,kBACO,KAAK,QAAQ;AAAA,eAChB,KAAK,aAAa;AAAA;AAAA;AAAA,eAGlB,KAAK,SAAS,KAAK,cAAc,KAAK,SAAS;AAAA,QACtD,KAAK,YAAY;AAAA;AAAA,EAEvB;AAkBF;AAtEE;AAsDA,qBAAyB,SAAS;AAAA,EAChC,GAAG,gBAAgB;AAAA,EACnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAxEG,IAAM,sBAAN;AAQM,gBAAA;AAAA,EADV,SAAS,EAAE,MAAM,SAAS,SAAS,MAAM;AAAA,GAP/B,oBAQA,WAAA,UAAA,CAAA;AAiBJ,gBAAA;AAAA,EADN,SAAS,EAAE,MAAM,QAAQ,SAAS,OAAO,WAAW,gBAAgB;AAAA,GAxB1D,oBAyBJ,WAAA,eAAA,CAAA;AASA,gBAAA;AAAA,EADN,SAAS,EAAE,MAAM,QAAQ,SAAS,OAAO,WAAW,cAAc;AAAA,GAjCxD,oBAkCJ,WAAA,aAAA,CAAA;"}
|
|
@@ -1,11 +1,42 @@
|
|
|
1
|
+
import "../icon-registry-essential/svgs/iconAdd.js";
|
|
2
|
+
import "../icon-registry-essential/svgs/iconAlert.js";
|
|
3
|
+
import "../icon-registry-essential/svgs/iconAttachment.js";
|
|
4
|
+
import "../icon-registry-essential/svgs/iconCalendar.js";
|
|
5
|
+
import "../icon-registry-essential/svgs/iconCheck.js";
|
|
6
|
+
import "../icon-registry-essential/svgs/iconClipboard.js";
|
|
7
|
+
import "../icon-registry-essential/svgs/iconCode.js";
|
|
8
|
+
import "../icon-registry-essential/svgs/iconColorPicker.js";
|
|
9
|
+
import "../icon-registry-essential/svgs/iconCopy.js";
|
|
10
|
+
import "../icon-registry-essential/svgs/iconDelete.js";
|
|
11
|
+
import "../icon-registry-essential/svgs/iconDocument.js";
|
|
12
|
+
import "../icon-registry-essential/svgs/iconDownload.js";
|
|
13
|
+
import "../icon-registry-essential/svgs/iconDrag.js";
|
|
14
|
+
import "../icon-registry-essential/svgs/iconEdit.js";
|
|
15
|
+
import "../icon-registry-essential/svgs/iconFavorite.js";
|
|
16
|
+
import "../icon-registry-essential/svgs/iconFolder.js";
|
|
17
|
+
import "../icon-registry-essential/svgs/iconForbidden.js";
|
|
18
|
+
import "../icon-registry-essential/svgs/iconInfo.js";
|
|
19
|
+
import "../icon-registry-essential/svgs/iconLink.js";
|
|
20
|
+
import "../icon-registry-essential/svgs/iconLock.js";
|
|
21
|
+
import "../icon-registry-essential/svgs/iconPause.js";
|
|
22
|
+
import "../icon-registry-essential/svgs/iconPicture.js";
|
|
23
|
+
import "../icon-registry-essential/svgs/iconPlay.js";
|
|
24
|
+
import "../icon-registry-essential/svgs/iconRemove.js";
|
|
25
|
+
import "../icon-registry-essential/svgs/iconSearch.js";
|
|
26
|
+
import { iconSee } from "../icon-registry-essential/svgs/iconSee.js";
|
|
27
|
+
import "../icon-registry-essential/svgs/iconSettings.js";
|
|
28
|
+
import "../icon-registry-essential/svgs/iconSubtract.js";
|
|
29
|
+
import "../icon-registry-essential/svgs/iconSync.js";
|
|
30
|
+
import "../icon-registry-essential/svgs/iconUnlock.js";
|
|
31
|
+
import { iconUnsee } from "../icon-registry-essential/svgs/iconUnsee.js";
|
|
32
|
+
import "../icon-registry-essential/svgs/iconWand.js";
|
|
33
|
+
import "../icon-registry-essential/svgs/iconWrong.js";
|
|
1
34
|
import "../input/input.js";
|
|
2
35
|
import { html, css } from "lit";
|
|
3
36
|
import { state, property } from "lit/decorators.js";
|
|
4
37
|
import "../icon/icon.js";
|
|
5
38
|
import "../button/button.js";
|
|
6
39
|
import { UUIInputElement } from "../input/input.element.js";
|
|
7
|
-
import { iconSee } from "../icon-registry-essential/svgs/iconSee.js";
|
|
8
|
-
import { iconUnsee } from "../icon-registry-essential/svgs/iconUnsee.js";
|
|
9
40
|
var __defProp = Object.defineProperty;
|
|
10
41
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
42
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
@@ -60,7 +91,6 @@ _UUIInputPasswordElement.styles = [
|
|
|
60
91
|
...UUIInputElement.styles,
|
|
61
92
|
css`
|
|
62
93
|
#eye {
|
|
63
|
-
height: 100%;
|
|
64
94
|
margin-left: -6px;
|
|
65
95
|
}
|
|
66
96
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-password.element.js","sources":["../../../src/components/input-password/input-password.element.ts"],"sourcesContent":["import { iconSee, iconUnsee } from '../icon-registry-essential/svgs/index.js';\nimport type { InputType } from '../input/input.js';\nimport { UUIInputElement } from '../input/input.js';\nimport { css, html } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport '../icon/icon.js';\nimport '../button/button.js';\n\n/**\n * @element uui-input-password\n * @extends uui-input\n */\nexport class UUIInputPasswordElement extends UUIInputElement {\n @state()\n private passwordType: InputType = 'password';\n\n // this overrides the inherited type property, and moves the input's type handling to the passwordType state.\n @property()\n get type() {\n return this.passwordType;\n }\n set type(newValue) {\n this.passwordType = newValue;\n }\n\n _onPasswordToggle() {\n if (this.passwordType === 'password') {\n this.passwordType = 'text';\n } else {\n this.passwordType = 'password';\n }\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n\n if (!this.hasAttribute('spellcheck')) {\n this.spellcheck = false;\n }\n }\n\n renderIcon() {\n return this.passwordType === 'password'\n ? html`<uui-icon name=\"see\" .fallback=${iconSee.strings[0]}></uui-icon>`\n : html`<uui-icon\n name=\"unsee\"\n .fallback=${iconUnsee.strings[0]}></uui-icon>`;\n }\n\n renderAppend() {\n return html`<uui-button\n .disabled=${this.disabled}\n @click=${this._onPasswordToggle}\n compact\n label=\"${this.passwordType === 'password'\n ? 'Show password'\n : 'Hide password'}\"\n id=\"eye\">\n ${this.renderIcon()}\n </uui-button>`;\n }\n\n static override readonly styles = [\n ...UUIInputElement.styles,\n css`\n #eye {\n
|
|
1
|
+
{"version":3,"file":"input-password.element.js","sources":["../../../src/components/input-password/input-password.element.ts"],"sourcesContent":["import { iconSee, iconUnsee } from '../icon-registry-essential/svgs/index.js';\nimport type { InputType } from '../input/input.js';\nimport { UUIInputElement } from '../input/input.js';\nimport { css, html } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport '../icon/icon.js';\nimport '../button/button.js';\n\n/**\n * @element uui-input-password\n * @extends uui-input\n */\nexport class UUIInputPasswordElement extends UUIInputElement {\n @state()\n private passwordType: InputType = 'password';\n\n // this overrides the inherited type property, and moves the input's type handling to the passwordType state.\n @property()\n get type() {\n return this.passwordType;\n }\n set type(newValue) {\n this.passwordType = newValue;\n }\n\n _onPasswordToggle() {\n if (this.passwordType === 'password') {\n this.passwordType = 'text';\n } else {\n this.passwordType = 'password';\n }\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n\n if (!this.hasAttribute('spellcheck')) {\n this.spellcheck = false;\n }\n }\n\n renderIcon() {\n return this.passwordType === 'password'\n ? html`<uui-icon name=\"see\" .fallback=${iconSee.strings[0]}></uui-icon>`\n : html`<uui-icon\n name=\"unsee\"\n .fallback=${iconUnsee.strings[0]}></uui-icon>`;\n }\n\n renderAppend() {\n return html`<uui-button\n .disabled=${this.disabled}\n @click=${this._onPasswordToggle}\n compact\n label=\"${this.passwordType === 'password'\n ? 'Show password'\n : 'Hide password'}\"\n id=\"eye\">\n ${this.renderIcon()}\n </uui-button>`;\n }\n\n static override readonly styles = [\n ...UUIInputElement.styles,\n css`\n #eye {\n margin-left: -6px;\n }\n\n #clear:hover {\n color: black;\n }\n `,\n ];\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaO,MAAM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
|
+
line-height: 1;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
height: 2em;
|
|
15
|
+
|
|
10
16
|
background: var(--uui-color-surface);
|
|
11
17
|
border: 1px solid var(--uui-color-border);
|
|
12
18
|
font-family: inherit;
|
|
@@ -14,7 +20,7 @@ _UUIKeyElement.styles = [
|
|
|
14
20
|
color: var(--uui-color-text);
|
|
15
21
|
border-radius: var(--uui-border-radius);
|
|
16
22
|
margin: 0px 5px;
|
|
17
|
-
padding:
|
|
23
|
+
padding: 0px 6px;
|
|
18
24
|
box-sizing: border-box;
|
|
19
25
|
user-select: none;
|
|
20
26
|
text-transform: lowercase;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key.element.js","sources":["../../../src/components/keyboard-shortcut/key.element.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit';\n\n/**\n * A visual representation of a key on you keyboard. use inside `<uui-keyboard-shortcut></uui-keyboard-shortcut>`\n * @element uui-key\n * @slot - for the key name. Anything you put in here will be lowercase.\n */\nexport class UUIKeyElement extends LitElement {\n render() {\n return html`<slot></slot>`;\n }\n\n static override readonly styles = [\n css`\n :host {\n background: var(--uui-color-surface);\n border: 1px solid var(--uui-color-border);\n font-family: inherit;\n font-size: var(--uui-type-small-size);\n color: var(--uui-color-text);\n border-radius: var(--uui-border-radius);\n margin: 0px 5px;\n padding:
|
|
1
|
+
{"version":3,"file":"key.element.js","sources":["../../../src/components/keyboard-shortcut/key.element.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit';\n\n/**\n * A visual representation of a key on you keyboard. use inside `<uui-keyboard-shortcut></uui-keyboard-shortcut>`\n * @element uui-key\n * @slot - for the key name. Anything you put in here will be lowercase.\n */\nexport class UUIKeyElement extends LitElement {\n render() {\n return html`<slot></slot>`;\n }\n\n static override readonly styles = [\n css`\n :host {\n display: inline-flex;\n line-height: 1;\n justify-content: center;\n flex-direction: column;\n height: 2em;\n\n background: var(--uui-color-surface);\n border: 1px solid var(--uui-color-border);\n font-family: inherit;\n font-size: var(--uui-type-small-size);\n color: var(--uui-color-text);\n border-radius: var(--uui-border-radius);\n margin: 0px 5px;\n padding: 0px 6px;\n box-sizing: border-box;\n user-select: none;\n text-transform: lowercase;\n }\n `,\n ];\n}\n"],"names":[],"mappings":";AAOO,MAAM,iBAAN,MAAM,uBAAsB,WAAW;AAAA,EAC5C,SAAS;AACP,WAAO;AAAA,EACT;AAyBF;AAvBE,eAAyB,SAAS;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AANG,IAAM,gBAAN;"}
|
|
@@ -19,11 +19,14 @@ _UUILoaderElement.styles = [
|
|
|
19
19
|
width: var(--uui-size-2);
|
|
20
20
|
height: var(--uui-size-2);
|
|
21
21
|
border: 1px solid currentColor;
|
|
22
|
+
box-shadow: 0 0 0 0.33px currentColor;
|
|
22
23
|
border-radius: 100%;
|
|
24
|
+
opacity: 0;
|
|
23
25
|
animation: loaderAnimation 1.2s infinite;
|
|
24
26
|
transition:
|
|
25
|
-
transform 60ms cubic-bezier(0.
|
|
26
|
-
|
|
27
|
+
transform 60ms cubic-bezier(0.175, 0.885, 0.32, 1.275),
|
|
28
|
+
opacity 60ms cubic-bezier(0.175, 0.885, 0.32, 1.275),
|
|
29
|
+
filter 60ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
div:nth-child(1n) {
|
|
@@ -42,14 +45,28 @@ _UUILoaderElement.styles = [
|
|
|
42
45
|
0% {
|
|
43
46
|
transform: scale(0.33);
|
|
44
47
|
background-color: currentColor;
|
|
48
|
+
filter: blur(1.5px);
|
|
49
|
+
opacity: 0.25;
|
|
50
|
+
}
|
|
51
|
+
33% {
|
|
52
|
+
transform: scale(1);
|
|
53
|
+
background-color: transparent;
|
|
54
|
+
filter: blur(0px);
|
|
55
|
+
|
|
56
|
+
opacity: 1;
|
|
45
57
|
}
|
|
46
58
|
50% {
|
|
47
59
|
transform: scale(1);
|
|
48
60
|
background-color: transparent;
|
|
61
|
+
filter: blur(0px);
|
|
62
|
+
|
|
63
|
+
opacity: 0.9;
|
|
49
64
|
}
|
|
50
65
|
100% {
|
|
51
66
|
transform: scale(0.33);
|
|
52
67
|
background-color: currentColor;
|
|
68
|
+
filter: blur(1.5px);
|
|
69
|
+
opacity: 0.25;
|
|
53
70
|
}
|
|
54
71
|
}
|
|
55
72
|
`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.element.js","sources":["../../../src/components/loader/loader.element.ts"],"sourcesContent":["import { LitElement, html, css } from 'lit';\n/**\n * A basic loader.\n * @element uui-loader\n */\nexport class UUILoaderElement extends LitElement {\n render() {\n return html`\n <div></div>\n <div></div>\n <div></div>\n `;\n }\n\n static override readonly styles = [\n css`\n :host {\n color: var(--uui-color-default);\n }\n\n div {\n display: inline-block;\n width: var(--uui-size-2);\n height: var(--uui-size-2);\n border: 1px solid currentColor;\n border-radius: 100%;\n animation: loaderAnimation 1.2s infinite;\n transition:\n transform 60ms cubic-bezier(0.
|
|
1
|
+
{"version":3,"file":"loader.element.js","sources":["../../../src/components/loader/loader.element.ts"],"sourcesContent":["import { LitElement, html, css } from 'lit';\n/**\n * A basic loader.\n * @element uui-loader\n */\nexport class UUILoaderElement extends LitElement {\n render() {\n return html`\n <div></div>\n <div></div>\n <div></div>\n `;\n }\n\n static override readonly styles = [\n css`\n :host {\n color: var(--uui-color-default);\n }\n\n div {\n display: inline-block;\n width: var(--uui-size-2);\n height: var(--uui-size-2);\n border: 1px solid currentColor;\n box-shadow: 0 0 0 0.33px currentColor;\n border-radius: 100%;\n opacity: 0;\n animation: loaderAnimation 1.2s infinite;\n transition:\n transform 60ms cubic-bezier(0.175, 0.885, 0.32, 1.275),\n opacity 60ms cubic-bezier(0.175, 0.885, 0.32, 1.275),\n filter 60ms cubic-bezier(0.175, 0.885, 0.32, 1.275);\n }\n\n div:nth-child(1n) {\n animation-delay: 0s;\n }\n\n div:nth-child(2n) {\n animation-delay: 0.15s;\n }\n\n div:nth-child(3n) {\n animation-delay: 0.3s;\n }\n\n @keyframes loaderAnimation {\n 0% {\n transform: scale(0.33);\n background-color: currentColor;\n filter: blur(1.5px);\n opacity: 0.25;\n }\n 33% {\n transform: scale(1);\n background-color: transparent;\n filter: blur(0px);\n\n opacity: 1;\n }\n 50% {\n transform: scale(1);\n background-color: transparent;\n filter: blur(0px);\n\n opacity: 0.9;\n }\n 100% {\n transform: scale(0.33);\n background-color: currentColor;\n filter: blur(1.5px);\n opacity: 0.25;\n }\n }\n `,\n ];\n}\n"],"names":[],"mappings":";AAKO,MAAM,oBAAN,MAAM,0BAAyB,WAAW;AAAA,EAC/C,SAAS;AACP,WAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKT;AAiEF;AA/DE,kBAAyB,SAAS;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAVG,IAAM,mBAAN;"}
|
|
@@ -2,12 +2,18 @@ import { defineElement } from "../../internal/registration/index.js";
|
|
|
2
2
|
import { UUIModalDialogElement } from "./modal-dialog.element.js";
|
|
3
3
|
import { UUIModalSidebarElement } from "./modal-sidebar.element.js";
|
|
4
4
|
import { UUIModalContainerElement } from "./modal-container.js";
|
|
5
|
+
import { UUIModalCloseEndEvent, UUIModalCloseEvent, UUIModalElement, UUIModalOpenEvent, UUIModalElement as UUIModalElement2 } from "./modal.element.js";
|
|
5
6
|
defineElement("uui-modal-dialog", UUIModalDialogElement);
|
|
6
7
|
defineElement("uui-modal-sidebar", UUIModalSidebarElement);
|
|
7
8
|
defineElement("uui-modal-container", UUIModalContainerElement);
|
|
8
9
|
export {
|
|
10
|
+
UUIModalCloseEndEvent,
|
|
11
|
+
UUIModalCloseEvent,
|
|
9
12
|
UUIModalContainerElement,
|
|
10
13
|
UUIModalDialogElement,
|
|
11
|
-
|
|
14
|
+
UUIModalElement,
|
|
15
|
+
UUIModalOpenEvent,
|
|
16
|
+
UUIModalSidebarElement,
|
|
17
|
+
UUIModalElement2 as default
|
|
12
18
|
};
|
|
13
19
|
//# sourceMappingURL=modal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.js","sources":["../../../src/components/modal/modal.ts"],"sourcesContent":["import { defineElement } from '../../internal/registration/index.js';\nimport { UUIModalDialogElement } from './modal-dialog.element.js';\nimport { UUIModalSidebarElement } from './modal-sidebar.element.js';\nimport { UUIModalContainerElement } from './modal-container.js';\n\ndefineElement('uui-modal-dialog', UUIModalDialogElement);\ndefineElement('uui-modal-sidebar', UUIModalSidebarElement);\ndefineElement('uui-modal-container', UUIModalContainerElement);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uui-modal-dialog': UUIModalDialogElement;\n 'uui-modal-sidebar': UUIModalSidebarElement;\n 'uui-modal-container': UUIModalContainerElement;\n }\n}\n\nexport * from './modal-dialog.element.js';\nexport * from './modal-sidebar.element.js';\nexport * from './modal.element.js';\nexport * from './modal-container.js';\nexport { UUIModalElement as default } from './modal.element.js';\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"modal.js","sources":["../../../src/components/modal/modal.ts"],"sourcesContent":["import { defineElement } from '../../internal/registration/index.js';\nimport { UUIModalDialogElement } from './modal-dialog.element.js';\nimport { UUIModalSidebarElement } from './modal-sidebar.element.js';\nimport { UUIModalContainerElement } from './modal-container.js';\n\ndefineElement('uui-modal-dialog', UUIModalDialogElement);\ndefineElement('uui-modal-sidebar', UUIModalSidebarElement);\ndefineElement('uui-modal-container', UUIModalContainerElement);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uui-modal-dialog': UUIModalDialogElement;\n 'uui-modal-sidebar': UUIModalSidebarElement;\n 'uui-modal-container': UUIModalContainerElement;\n }\n}\n\nexport * from './modal-dialog.element.js';\nexport * from './modal-sidebar.element.js';\nexport * from './modal.element.js';\nexport * from './modal-container.js';\nexport { UUIModalElement as default } from './modal.element.js';\n"],"names":[],"mappings":";;;;;AAKA,cAAc,oBAAoB,qBAAqB;AACvD,cAAc,qBAAqB,sBAAsB;AACzD,cAAc,uBAAuB,wBAAwB;"}
|
|
@@ -96,6 +96,8 @@ export declare class UUIPaginationElement extends LitElement {
|
|
|
96
96
|
protected renderLast(): import("lit-html").TemplateResult<1>;
|
|
97
97
|
protected renderDots(): import("lit-html").TemplateResult<1>;
|
|
98
98
|
protected renderPage(page: number): import("lit-html").TemplateResult<1>;
|
|
99
|
+
protected renderLeftDots(): import("lit-html").TemplateResult<1>;
|
|
100
|
+
protected renderRightDots(): import("lit-html").TemplateResult<1>;
|
|
99
101
|
protected renderNavigationLeft(): import("lit-html").TemplateResult<1>;
|
|
100
102
|
protected renderNavigationRight(): import("lit-html").TemplateResult<1>;
|
|
101
103
|
render(): import("lit-html").TemplateResult<1>;
|
|
@@ -68,7 +68,7 @@ const _UUIPaginationElement = class _UUIPaginationElement extends LitElement {
|
|
|
68
68
|
);
|
|
69
69
|
const rangeBaseWidth = containerWidth - navButtonsWidth;
|
|
70
70
|
const range = rangeBaseWidth / PAGE_BUTTON_MAX_WIDTH / 2;
|
|
71
|
-
this._range = Math.max(
|
|
71
|
+
this._range = Math.max(0, Math.floor(range));
|
|
72
72
|
this._visiblePages = this._generateVisiblePages(this.current);
|
|
73
73
|
}
|
|
74
74
|
_generateVisiblePages(current) {
|
|
@@ -148,9 +148,7 @@ const _UUIPaginationElement = class _UUIPaginationElement extends LitElement {
|
|
|
148
148
|
renderFirst() {
|
|
149
149
|
return html`<uui-button
|
|
150
150
|
compact
|
|
151
|
-
look="outline"
|
|
152
151
|
class="nav"
|
|
153
|
-
role="listitem"
|
|
154
152
|
label=${this.firstLabel}
|
|
155
153
|
?disabled=${this._current === 1}
|
|
156
154
|
@click=${() => this.goToPage(1)}></uui-button>`;
|
|
@@ -158,9 +156,7 @@ const _UUIPaginationElement = class _UUIPaginationElement extends LitElement {
|
|
|
158
156
|
renderPrevious() {
|
|
159
157
|
return html`<uui-button
|
|
160
158
|
compact
|
|
161
|
-
look="outline"
|
|
162
159
|
class="nav"
|
|
163
|
-
role="listitem"
|
|
164
160
|
label=${this.previousLabel}
|
|
165
161
|
?disabled=${this._current === 1}
|
|
166
162
|
@click=${this.goToPreviousPage}></uui-button>`;
|
|
@@ -168,8 +164,6 @@ const _UUIPaginationElement = class _UUIPaginationElement extends LitElement {
|
|
|
168
164
|
renderNext() {
|
|
169
165
|
return html`<uui-button
|
|
170
166
|
compact
|
|
171
|
-
look="outline"
|
|
172
|
-
role="listitem"
|
|
173
167
|
class="nav"
|
|
174
168
|
label=${this.nextLabel}
|
|
175
169
|
?disabled=${this._current === this.total}
|
|
@@ -179,8 +173,6 @@ const _UUIPaginationElement = class _UUIPaginationElement extends LitElement {
|
|
|
179
173
|
return html`
|
|
180
174
|
<uui-button
|
|
181
175
|
compact
|
|
182
|
-
look="outline"
|
|
183
|
-
role="listitem"
|
|
184
176
|
class="nav"
|
|
185
177
|
label=${this.lastLabel}
|
|
186
178
|
?disabled=${this.total === this._current}
|
|
@@ -196,7 +188,7 @@ const _UUIPaginationElement = class _UUIPaginationElement extends LitElement {
|
|
|
196
188
|
class="dots"
|
|
197
189
|
label="More pages"
|
|
198
190
|
>...</uui-button
|
|
199
|
-
|
|
191
|
+
>`;
|
|
200
192
|
}
|
|
201
193
|
renderPage(page) {
|
|
202
194
|
return html`<uui-button
|
|
@@ -214,38 +206,50 @@ const _UUIPaginationElement = class _UUIPaginationElement extends LitElement {
|
|
|
214
206
|
${page}
|
|
215
207
|
</uui-button>`;
|
|
216
208
|
}
|
|
209
|
+
renderLeftDots() {
|
|
210
|
+
return html` ${this._visiblePages.includes(1) ? "" : this.renderDots()}`;
|
|
211
|
+
}
|
|
212
|
+
renderRightDots() {
|
|
213
|
+
return html`${this._visiblePages.includes(this.total) ? "" : this.renderDots()}`;
|
|
214
|
+
}
|
|
217
215
|
renderNavigationLeft() {
|
|
218
|
-
return html` ${this.renderFirst()} ${this.renderPrevious()}
|
|
219
|
-
${this._visiblePages.includes(1) ? "" : this.renderDots()}`;
|
|
216
|
+
return html` ${this.renderFirst()} ${this.renderPrevious()}`;
|
|
220
217
|
}
|
|
221
218
|
renderNavigationRight() {
|
|
222
|
-
return html
|
|
223
|
-
${this.renderNext()} ${this.renderLast()}`;
|
|
219
|
+
return html` ${this.renderNext()} ${this.renderLast()}`;
|
|
224
220
|
}
|
|
225
221
|
render() {
|
|
226
|
-
return html
|
|
222
|
+
return html`
|
|
227
223
|
${this.renderNavigationLeft()}
|
|
228
|
-
|
|
224
|
+
<uui-button-group role="list" id="pages">
|
|
225
|
+
${this.renderLeftDots()}
|
|
226
|
+
${this._visiblePages.map(
|
|
229
227
|
(page) => this.renderPage(page)
|
|
230
228
|
)}
|
|
229
|
+
${this.renderRightDots()}
|
|
230
|
+
</uui-button-group>
|
|
231
231
|
${this.renderNavigationRight()}
|
|
232
|
-
</uui-button-group>
|
|
233
232
|
`;
|
|
234
233
|
}
|
|
235
234
|
};
|
|
236
235
|
_UUIPaginationElement.styles = [
|
|
237
236
|
css`
|
|
238
|
-
|
|
237
|
+
:host {
|
|
238
|
+
display: inline-flex;
|
|
239
239
|
width: 100%;
|
|
240
|
+
gap: 1px;
|
|
241
|
+
}
|
|
242
|
+
uui-button-group {
|
|
243
|
+
flex-grow: 1;
|
|
240
244
|
}
|
|
241
245
|
|
|
242
|
-
uui-button {
|
|
246
|
+
uui-button-group uui-button {
|
|
243
247
|
--uui-button-border-color: var(--uui-color-border-standalone);
|
|
244
248
|
--uui-button-border-color-hover: var(--uui-color-interactive-emphasis);
|
|
245
249
|
--uui-button-border-color-disabled: var(--uui-color-border-standalone);
|
|
246
250
|
}
|
|
247
251
|
|
|
248
|
-
uui-button:hover {
|
|
252
|
+
uui-button-group uui-button:hover {
|
|
249
253
|
z-index: 1;
|
|
250
254
|
}
|
|
251
255
|
|
|
@@ -263,6 +267,8 @@ _UUIPaginationElement.styles = [
|
|
|
263
267
|
|
|
264
268
|
.dots {
|
|
265
269
|
pointer-events: none;
|
|
270
|
+
min-width: 36px;
|
|
271
|
+
max-width: 72px;
|
|
266
272
|
}
|
|
267
273
|
|
|
268
274
|
.active {
|