@api-client/ui 0.0.2 → 0.0.4
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/demo/amf/api-annotation.html +1 -0
- package/demo/amf/api-channel.html +1 -0
- package/demo/amf/api-console.html +1 -0
- package/demo/amf/api-documentation-document.html +1 -0
- package/demo/amf/api-documentation.html +1 -0
- package/demo/amf/api-editor.html +1 -0
- package/demo/amf/api-navigation.html +1 -0
- package/demo/amf/api-operation.html +1 -0
- package/demo/amf/api-payload.html +1 -0
- package/demo/amf/api-request.html +1 -0
- package/demo/amf/api-resource.html +1 -0
- package/demo/amf/api-schema-documentation.html +1 -0
- package/demo/amf/api-security-documentation.html +1 -0
- package/demo/amf/api-server-picker.html +1 -0
- package/demo/amf/api-summary.html +1 -0
- package/demo/amf/bare-components.html +2 -0
- package/demo/amf/index.html +2 -0
- package/demo/amf/oauth-authorize.html +2 -0
- package/demo/amf/request-editor.html +1 -0
- package/demo/elements/authorization/api-key.html +1 -0
- package/demo/elements/authorization/basic.html +1 -0
- package/demo/elements/authorization/bearer.html +1 -0
- package/demo/elements/authorization/cc.html +1 -0
- package/demo/elements/authorization/index.html +2 -0
- package/demo/elements/authorization/ntlm.html +1 -0
- package/demo/elements/authorization/oauth-authorize.html +2 -2
- package/demo/elements/authorization/oauth-error.html +2 -0
- package/demo/elements/authorization/oauth-popup.html +2 -0
- package/demo/elements/authorization/oauth2.html +1 -0
- package/demo/elements/authorization/oidc.html +1 -0
- package/demo/elements/authorization/redirect.html +3 -1
- package/demo/elements/context-menu/basic.html +2 -1
- package/demo/elements/context-menu/custom-data.html +2 -1
- package/demo/elements/context-menu/enabled-state.html +2 -1
- package/demo/elements/context-menu/icons.html +2 -1
- package/demo/elements/context-menu/index.html +2 -0
- package/demo/elements/context-menu/nested.html +2 -1
- package/demo/elements/context-menu/no-execute.html +2 -1
- package/demo/elements/context-menu/radio-menu.html +2 -1
- package/demo/elements/context-menu/separators.html +2 -1
- package/demo/elements/environment/environment-editor.html +1 -0
- package/demo/elements/environment/index.html +1 -0
- package/demo/elements/environment/server-editor.html +1 -1
- package/demo/elements/environment/variables-editor.html +1 -1
- package/demo/elements/har/har-viewer.html +1 -0
- package/demo/elements/highlight/index.html +1 -0
- package/demo/elements/highlight/marked-highlight.html +1 -0
- package/demo/elements/highlight/prism-highlight.html +1 -0
- package/demo/elements/http/body-editor.html +1 -0
- package/demo/elements/http/headers.html +1 -0
- package/demo/elements/http/http-assertions.html +1 -0
- package/demo/elements/http/request-editor.html +1 -0
- package/demo/elements/http/request-log.html +1 -0
- package/demo/elements/http/url-editing.html +1 -0
- package/demo/elements/icons/index.html +1 -0
- package/demo/elements/project/project-run-report.html +1 -0
- package/demo/elements/project/request-editor.html +1 -0
- package/demo/elements/ui/buttons/api-button.html +2 -1
- package/demo/elements/ui/buttons/api-icon-button.html +2 -1
- package/demo/elements/ui/buttons/segmented-buttons.html +2 -1
- package/demo/elements/ui/chip/api-chip.html +2 -1
- package/demo/elements/ui/collapse/ui-collapse.html +2 -1
- package/demo/elements/ui/dialog/ui-dialog.html +2 -1
- package/demo/elements/ui/inputs/api-checkbox.html +2 -1
- package/demo/elements/ui/inputs/api-input.html +2 -1
- package/demo/elements/ui/inputs/api-radio.html +2 -1
- package/demo/elements/ui/inputs/api-switch.html +2 -1
- package/demo/elements/ui/list/dropdown-list.html +2 -1
- package/demo/elements/ui/list/list.html +2 -1
- package/demo/elements/ui/notification/snack.html +2 -1
- package/demo/elements/ui/progress/ui-progress.html +2 -1
- package/demo/elements/ui/tabs/tabs.html +2 -1
- package/demo/pages/api-client/authenticate.html +1 -0
- package/demo/pages/api-client/config.html +1 -0
- package/demo/pages/api-client/main.html +1 -0
- package/demo/pages/api-client/telemetry.html +1 -0
- package/demo/pages/http-project/main.html +1 -0
- package/demo/pages/schema-design/main.html +1 -0
- package/dist/pages/ApplicationScreen.d.ts +0 -4
- package/dist/pages/ApplicationScreen.d.ts.map +1 -1
- package/dist/pages/ApplicationScreen.js +12 -18
- package/dist/pages/ApplicationScreen.js.map +1 -1
- package/dist/pages/demo/DemoPage.d.ts.map +1 -1
- package/dist/pages/demo/DemoPage.js +12 -11
- package/dist/pages/demo/DemoPage.js.map +1 -1
- package/dist/ui/dialog/UiDialog.d.ts +1 -1
- package/dist/ui/dialog/UiDialog.d.ts.map +1 -1
- package/dist/ui/dialog/UiDialog.js +5 -3
- package/dist/ui/dialog/UiDialog.js.map +1 -1
- package/package.json +1 -1
- package/src/pages/ApplicationScreen.ts +12 -19
- package/src/pages/demo/DemoPage.ts +12 -11
- package/src/styles/m3/theme.css +81 -0
- package/src/ui/dialog/UiDialog.ts +6 -4
- package/test/ui/dialog/UiDialog.test.ts +236 -0
- package/web-test-runner.config.mjs +3 -5
- package/demo/themes/default.css +0 -0
- package/demo/themes/m3/theme.dark.css +0 -40
- package/demo/themes/m3/theme.light.css +0 -40
- package/demo/themes/m3/tokens.css +0 -291
- package/src/styles/m3/theme.dark.css +0 -40
- package/src/styles/m3/theme.light.css +0 -40
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiDialog.js","sourceRoot":"","sources":["../../../src/ui/dialog/UiDialog.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAkC,MAAM,KAAK,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACtG,OAAO,EAAa,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE7D,OAAO,8BAA8B,CAAA;AAerC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,SAAS;IAC7C,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KjC;IAAhB,KAAK,CAAC,QAAQ,CAAC;wCAAqC;AAE5C;IAAR,KAAK,EAAE;yCAA2B;AAE1B;IAAR,KAAK,EAAE;0CAA4B;AAE3B;IAAR,KAAK,EAAE;2CAA6B;AAEmB;IAAvD,qBAAqB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCAA0C;AAE3C;IAArD,kBAAkB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCAA2C;AAEtC;IAAzD,qBAAqB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;yCAA4C","sourcesContent":["import { html, nothing, PropertyValues, TemplateResult } from \"lit\";\nimport { property, query, queryAssignedElements, queryAssignedNodes, state } from \"lit/decorators.js\";\nimport { ClassInfo, classMap } from \"lit/directives/class-map.js\";\nimport { UiElement } from \"../UiElement.js\";\nimport { isDisabled, setDisabled } from \"../lib/disabled.js\";\nimport UiButton from \"../button/UiButton.js\";\nimport '../../define/ui/ui-button.js'\n\nexport interface UiDialogClosingReason {\n /**\n * Whether the dialog was cancelled by either activating the `dismiss` button\n * or by pressing escape.\n */\n cancelled: boolean;\n /**\n * This is used in cases when the dialog has more complex purpose.\n * This is the value expected from the dialog.\n */\n value?: unknown;\n}\n\n/**\n * Styled dialog using a native `<dialog>` element under the hood.\n * Note, since native dialog renders in the top layer it is not necessary \n * to place the dialog in the `<body>`.\n * \n * ## Using buttons\n * \n * The dialog automatically recognizes buttons with values `confirm` and `dismiss` \n * to close the dialog and dispatch the `close` event. The event has additional \n * closing reason detail.\n * \n * ```javascript\n * <ui-button value=\"dismiss\">Cancel</ui-button> \n * <ui-button value=\"confirm\">Take action</ui-button> \n * ```\n * \n * ```javascript\n * <button value=\"dismiss\">Cancel</button> \n * <button value=\"confirm\">Take action</button> \n * ```\n * \n * The detail object of the `close` event has the following properties:\n * - cancelled - Whether the dialog was cancelled by either activating the `dismiss` button or by pressing escape.\n * \n * The `close` event is only dispatched when the user interact with the dialog. Imperative control of the \n * dialog won't trigger the close button. \n * \n * ## Full example\n * \n * ```javascript\n * <ui-dialog modal>\n * <ui-icon slot=\"icon\" icon=\"delete\"></ui-icon>\n * \n * <span slot=\"title\">Delete photos?</span>\n * <p>This action will permanently remove the selected pictures from your account.</p>\n * \n * <ui-button slot=\"button\" value=\"dismiss\" type=\"text\">Cancel</ui-button>\n * <ui-button slot=\"button\" value=\"confirm\" type=\"text\">Confirm</ui-button>\n * </ui-dialog>\n * ```\n * \n * @slot - The slot for the content of the dialog.\n * @slot icon - The slot to place the dialog icon\n * @slot title - The slot to place the dialog title. Do not put elements here, just the text.\n * @slot button - The slot to place the dialog buttons. Use the `confirm` or `dismiss` buttons to automatically close the dialog.\n * @fires close - A non-bubbling, non-cancellable event with the `UiDialogClosingReason` as the detail.\n */\nexport default class UiDialog extends UiElement {\n get disabled(): boolean {\n return isDisabled(this);\n }\n\n /**\n * When set, the button is a disabled state.\n * @attribute\n */\n @property({ reflect: true, type: Boolean })\n set disabled(value: boolean) {\n const old = isDisabled(this);\n setDisabled(this, value);\n this.requestUpdate('disabled', old);\n }\n\n /**\n * Opens the dialog as modal when toggling dialog's open state.\n * @attribute\n */\n @property({ type: Boolean }) modal = false;\n\n /**\n * Toggles visibility of the dialog.\n * Note, the dialog is opened asynchronously after the update is performed.\n * @attribute\n */\n @property({ type: Boolean }) open = false;\n\n /**\n * Imperative access to create a dismiss button.\n * When set this will render a dismiss button at the end of the buttons line, before the `confirmLabel` button.\n * @attribute\n */\n @property({ type: String }) dismissLabel?: string;\n\n /**\n * Imperative access to create a confirm button.\n * When set this will render a confirm button at the end of the buttons line, after the `dismissLabel` button.\n * @attribute\n */\n @property({ type: String }) confirmLabel?: string;\n\n /**\n * A reference to the underlying dialog element.\n */\n @query('dialog') readonly dialog!: HTMLDialogElement;\n\n @state() protected hasIcon = false;\n\n @state() protected hasTitle = false;\n\n @state() protected hasButton = false;\n\n @queryAssignedElements({ flatten: true, slot: 'icon' }) protected readonly icons!: HTMLElement[];\n\n @queryAssignedNodes({ flatten: true, slot: 'title' }) protected readonly titles!: HTMLElement[];\n\n @queryAssignedElements({ flatten: true, slot: 'button' }) protected readonly buttons!: HTMLElement[];\n\n /**\n * To be set by a child class when closing the dialog.\n * This is passed to the close event.\n */\n protected dialogValue?: unknown;\n\n constructor() {\n super();\n\n this.addEventListener('click', this.handleClick);\n this.addEventListener('keydown', this.handleKeyDown);\n }\n\n override handleClick(e: MouseEvent): void {\n super.handleClick(e);\n const path = e.composedPath();\n const { buttons } = this;\n const button = path.find(i => buttons.includes(i as HTMLElement)) as HTMLButtonElement | UiButton | undefined;\n if (!button) {\n return;\n }\n const { value ='' } = button;\n this.handleInteraction(value as 'dismiss' | 'confirm');\n }\n\n override handleKeyDown(e: KeyboardEvent): void {\n super.handleKeyDown(e);\n if (e.key === 'Escape') {\n this.handleInteraction('dismiss');\n }\n }\n\n protected override updated(changedProperties: PropertyValues<this>): void {\n if (changedProperties.has('open')) {\n this.controlVisibility();\n }\n super.updated(changedProperties);\n }\n\n protected controlVisibility(): void {\n const { dialog, modal, open } = this;\n if (!dialog) {\n return;\n }\n if (open) {\n if (modal) {\n dialog.showModal();\n } else {\n dialog.show();\n }\n } else {\n dialog.close();\n }\n }\n\n protected handleSlotChange(): void {\n this.hasIcon = !!this.icons.length;\n this.hasTitle = !!this.titles.length;\n this.hasButton = !!this.buttons.length;\n }\n\n protected handleInteraction(value: 'dismiss' | 'confirm'): void {\n if (!['dismiss', 'confirm'].includes(value)) {\n return;\n }\n this.open = false;\n const detail: UiDialogClosingReason = {\n cancelled: value === 'dismiss',\n }\n if (this.dialogValue !== undefined) {\n detail.value = this.dialogValue;\n }\n this.dispatchEvent(new CustomEvent<UiDialogClosingReason>('close', {\n composed: true,\n detail,\n }));\n }\n\n protected handleDialogClose(): void {\n if (!this.open) {\n return;\n }\n this.open = false;\n this.handleInteraction('dismiss');\n }\n\n protected handleDismiss(): void {\n this.handleInteraction('dismiss');\n }\n\n protected handleConfirm(): void {\n this.handleInteraction('confirm');\n }\n\n override render(): TemplateResult {\n return html`\n <dialog @close=\"${this.handleDialogClose}\">\n ${this.renderIcon()}\n ${this.renderTitle()}\n ${this.renderBody()}\n ${this.renderButtons()}\n </dialog>\n `;\n }\n\n protected renderIcon(): TemplateResult {\n const classes: ClassInfo = {\n icon: true,\n 'with-icon': this.hasIcon,\n };\n return html`\n <div class=\"${classMap(classes)}\" part=\"icon\"><slot name=\"icon\" @slotchange=\"${this.handleSlotChange}\"></slot></div>\n `;\n }\n\n protected renderTitle(): TemplateResult {\n const classes: ClassInfo = {\n title: true,\n 'with-title': this.hasTitle,\n };\n return html`\n <div class=\"${classMap(classes)}\" part=\"title\"><slot name=\"title\" @slotchange=\"${this.handleSlotChange}\"></slot></div>\n `;\n }\n\n protected renderBody(): TemplateResult {\n return html`\n <div class=\"content\"><slot></slot></div>\n `;\n }\n\n protected renderButtons(): TemplateResult {\n const classes: ClassInfo = {\n buttons: true,\n 'with-buttons': this.hasButton || !!this.confirmLabel || !!this.dismissLabel,\n };\n return html`\n <div class=\"${classMap(classes)}\" part=\"button\">\n <slot name=\"button\" @slotchange=\"${this.handleSlotChange}\"></slot>\n ${this.renderDismissButton()}\n </div>\n `;\n }\n\n protected renderDismissButton(): TemplateResult | typeof nothing {\n const { dismissLabel } = this;\n if (!dismissLabel) {\n return nothing;\n }\n return html`\n <ui-button value=\"dismiss\" type=\"text\" class=\"internal-button\" @click=\"${this.handleDismiss}\">${dismissLabel}</ui-button>\n `;\n }\n\n protected renderConfirmButton(): TemplateResult | typeof nothing {\n const { confirmLabel } = this;\n if (!confirmLabel) {\n return nothing;\n }\n return html`\n <ui-button value=\"confirm\" type=\"text\" class=\"internal-button\" @click=\"${this.handleConfirm}\">${confirmLabel}</ui-button>\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UiDialog.js","sourceRoot":"","sources":["../../../src/ui/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AC+D,IAAI,CAAC,aAAa,KAAK,YAAY;KAC5G,CAAC;IACJ,CAAC;IAES,mBAAmB;QAC3B,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;QAC9B,IAAI,CAAC,YAAY,EAAE;YACjB,OAAO,OAAO,CAAC;SAChB;QACD,OAAO,IAAI,CAAA;8EAC+D,IAAI,CAAC,aAAa,KAAK,YAAY;KAC5G,CAAC;IACJ,CAAC;CACF;AAvNC;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCAK1C;AAM4B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uCAAe;AAOd;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sCAAc;AAOd;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAuB;AAOtB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAuB;AAKjC;IAAhB,KAAK,CAAC,QAAQ,CAAC;wCAAqC;AAE5C;IAAR,KAAK,EAAE;yCAA2B;AAE1B;IAAR,KAAK,EAAE;0CAA4B;AAE3B;IAAR,KAAK,EAAE;2CAA6B;AAEmB;IAAvD,qBAAqB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCAA0C;AAE3C;IAArD,kBAAkB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCAA2C;AAEtC;IAAzD,qBAAqB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;yCAA4C","sourcesContent":["import { html, nothing, PropertyValues, TemplateResult } from \"lit\";\nimport { property, query, queryAssignedElements, queryAssignedNodes, state } from \"lit/decorators.js\";\nimport { ClassInfo, classMap } from \"lit/directives/class-map.js\";\nimport { UiElement } from \"../UiElement.js\";\nimport { isDisabled, setDisabled } from \"../lib/disabled.js\";\nimport UiButton from \"../button/UiButton.js\";\nimport '../../define/ui/ui-button.js'\n\nexport interface UiDialogClosingReason {\n /**\n * Whether the dialog was cancelled by either activating the `dismiss` button\n * or by pressing escape.\n */\n cancelled: boolean;\n /**\n * This is used in cases when the dialog has more complex purpose.\n * This is the value expected from the dialog.\n */\n value?: unknown;\n}\n\n/**\n * Styled dialog using a native `<dialog>` element under the hood.\n * Note, since native dialog renders in the top layer it is not necessary \n * to place the dialog in the `<body>`.\n * \n * ## Using buttons\n * \n * The dialog automatically recognizes buttons with values `confirm` and `dismiss` \n * to close the dialog and dispatch the `close` event. The event has additional \n * closing reason detail.\n * \n * ```javascript\n * <ui-button value=\"dismiss\">Cancel</ui-button> \n * <ui-button value=\"confirm\">Take action</ui-button> \n * ```\n * \n * ```javascript\n * <button value=\"dismiss\">Cancel</button> \n * <button value=\"confirm\">Take action</button> \n * ```\n * \n * The detail object of the `close` event has the following properties:\n * - cancelled - Whether the dialog was cancelled by either activating the `dismiss` button or by pressing escape.\n * \n * The `close` event is only dispatched when the user interact with the dialog. Imperative control of the \n * dialog won't trigger the close button. \n * \n * ## Full example\n * \n * ```javascript\n * <ui-dialog modal>\n * <ui-icon slot=\"icon\" icon=\"delete\"></ui-icon>\n * \n * <span slot=\"title\">Delete photos?</span>\n * <p>This action will permanently remove the selected pictures from your account.</p>\n * \n * <ui-button slot=\"button\" value=\"dismiss\" type=\"text\">Cancel</ui-button>\n * <ui-button slot=\"button\" value=\"confirm\" type=\"text\">Confirm</ui-button>\n * </ui-dialog>\n * ```\n * \n * @slot - The slot for the content of the dialog.\n * @slot icon - The slot to place the dialog icon\n * @slot title - The slot to place the dialog title. Do not put elements here, just the text.\n * @slot button - The slot to place the dialog buttons. Use the `confirm` or `dismiss` buttons to automatically close the dialog.\n * @fires close - A non-bubbling, non-cancellable event with the `UiDialogClosingReason` as the detail.\n */\nexport default class UiDialog extends UiElement {\n get disabled(): boolean {\n return isDisabled(this);\n }\n\n /**\n * When set, the button is a disabled state.\n * @attribute\n */\n @property({ reflect: true, type: Boolean })\n set disabled(value: boolean) {\n const old = isDisabled(this);\n setDisabled(this, value);\n this.requestUpdate('disabled', old);\n }\n\n /**\n * Opens the dialog as modal when toggling dialog's open state.\n * @attribute\n */\n @property({ type: Boolean }) modal = false;\n\n /**\n * Toggles visibility of the dialog.\n * Note, the dialog is opened asynchronously after the update is performed.\n * @attribute\n */\n @property({ type: Boolean }) open = false;\n\n /**\n * Imperative access to create a dismiss button.\n * When set this will render a dismiss button at the end of the buttons line, before the `confirmLabel` button.\n * @attribute\n */\n @property({ type: String }) dismissLabel?: string;\n\n /**\n * Imperative access to create a confirm button.\n * When set this will render a confirm button at the end of the buttons line, after the `dismissLabel` button.\n * @attribute\n */\n @property({ type: String }) confirmLabel?: string;\n\n /**\n * A reference to the underlying dialog element.\n */\n @query('dialog') readonly dialog!: HTMLDialogElement;\n\n @state() protected hasIcon = false;\n\n @state() protected hasTitle = false;\n\n @state() protected hasButton = false;\n\n @queryAssignedElements({ flatten: true, slot: 'icon' }) protected readonly icons!: HTMLElement[];\n\n @queryAssignedNodes({ flatten: true, slot: 'title' }) protected readonly titles!: HTMLElement[];\n\n @queryAssignedElements({ flatten: true, slot: 'button' }) protected readonly buttons!: HTMLElement[];\n\n /**\n * To be set by a child class when closing the dialog.\n * This is passed to the close event.\n */\n dialogValue?: unknown;\n\n constructor() {\n super();\n\n this.addEventListener('click', this.handleClick);\n this.addEventListener('keydown', this.handleKeyDown);\n }\n\n override handleClick(e: MouseEvent): void {\n super.handleClick(e);\n const path = e.composedPath();\n const { buttons } = this;\n const button = path.find(i => buttons.includes(i as HTMLElement)) as HTMLButtonElement | UiButton | undefined;\n if (!button) {\n return;\n }\n const { value ='' } = button;\n this.handleInteraction(value as 'dismiss' | 'confirm');\n }\n\n override handleKeyDown(e: KeyboardEvent): void {\n super.handleKeyDown(e);\n if (e.key === 'Escape') {\n this.handleInteraction('dismiss');\n }\n }\n\n protected override updated(changedProperties: PropertyValues<this>): void {\n if (changedProperties.has('open')) {\n this.controlVisibility();\n }\n super.updated(changedProperties);\n }\n\n protected controlVisibility(): void {\n const { dialog, modal, open } = this;\n if (!dialog) {\n return;\n }\n if (open) {\n if (modal) {\n dialog.showModal();\n } else {\n dialog.show();\n }\n } else {\n dialog.close();\n }\n }\n\n protected handleSlotChange(): void {\n const { icons, titles, buttons } = this;\n this.hasIcon = !!icons && !!icons.length;\n this.hasTitle = !!titles && !!titles.length;\n this.hasButton = !!buttons && !!buttons.length;\n }\n\n protected handleInteraction(value: 'dismiss' | 'confirm'): void {\n if (!['dismiss', 'confirm'].includes(value)) {\n return;\n }\n this.open = false;\n const detail: UiDialogClosingReason = {\n cancelled: value === 'dismiss',\n }\n if (this.dialogValue !== undefined) {\n detail.value = this.dialogValue;\n }\n this.dispatchEvent(new CustomEvent<UiDialogClosingReason>('close', {\n composed: true,\n detail,\n }));\n }\n\n protected handleDialogClose(): void {\n if (!this.open) {\n return;\n }\n this.open = false;\n this.handleInteraction('dismiss');\n }\n\n protected handleDismiss(): void {\n this.handleInteraction('dismiss');\n }\n\n protected handleConfirm(): void {\n this.handleInteraction('confirm');\n }\n\n override render(): TemplateResult {\n return html`\n <dialog @close=\"${this.handleDialogClose}\">\n ${this.renderIcon()}\n ${this.renderTitle()}\n ${this.renderBody()}\n ${this.renderButtons()}\n </dialog>\n `;\n }\n\n protected renderIcon(): TemplateResult {\n const classes: ClassInfo = {\n icon: true,\n 'with-icon': this.hasIcon,\n };\n return html`\n <div class=\"${classMap(classes)}\" part=\"icon\"><slot name=\"icon\" @slotchange=\"${this.handleSlotChange}\"></slot></div>\n `;\n }\n\n protected renderTitle(): TemplateResult {\n const classes: ClassInfo = {\n title: true,\n 'with-title': this.hasTitle,\n };\n return html`\n <div class=\"${classMap(classes)}\" part=\"title\"><slot name=\"title\" @slotchange=\"${this.handleSlotChange}\"></slot></div>\n `;\n }\n\n protected renderBody(): TemplateResult {\n return html`\n <div class=\"content\"><slot></slot></div>\n `;\n }\n\n protected renderButtons(): TemplateResult {\n const classes: ClassInfo = {\n buttons: true,\n 'with-buttons': this.hasButton || !!this.confirmLabel || !!this.dismissLabel,\n };\n return html`\n <div class=\"${classMap(classes)}\" part=\"button\">\n <slot name=\"button\" @slotchange=\"${this.handleSlotChange}\"></slot>\n ${this.renderDismissButton()}\n ${this.renderConfirmButton()}\n </div>\n `;\n }\n\n protected renderDismissButton(): TemplateResult | typeof nothing {\n const { dismissLabel } = this;\n if (!dismissLabel) {\n return nothing;\n }\n return html`\n <ui-button value=\"dismiss\" type=\"text\" class=\"internal-button\" @click=\"${this.handleDismiss}\">${dismissLabel}</ui-button>\n `;\n }\n\n protected renderConfirmButton(): TemplateResult | typeof nothing {\n const { confirmLabel } = this;\n if (!confirmLabel) {\n return nothing;\n }\n return html`\n <ui-button value=\"confirm\" type=\"text\" class=\"internal-button\" @click=\"${this.handleConfirm}\">${confirmLabel}</ui-button>\n `;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -116,11 +116,6 @@ export abstract class ApplicationScreen extends RouteMixin(RenderableMixin(Event
|
|
|
116
116
|
*/
|
|
117
117
|
systemTheme: 'light' | 'dark' = 'light';
|
|
118
118
|
|
|
119
|
-
/**
|
|
120
|
-
* The root location where theme files are located.
|
|
121
|
-
*/
|
|
122
|
-
themesRoot = '/src/styles/m3';
|
|
123
|
-
|
|
124
119
|
/**
|
|
125
120
|
* The theme to use as selected by the user.
|
|
126
121
|
* Default to system default.
|
|
@@ -201,21 +196,19 @@ export abstract class ApplicationScreen extends RouteMixin(RenderableMixin(Event
|
|
|
201
196
|
}
|
|
202
197
|
|
|
203
198
|
protected activateTheme(type: 'light' | 'dark'): void {
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
if (existing.href.includes(file)) {
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
existing.parentElement?.removeChild(existing);
|
|
199
|
+
const root = document.querySelector('html');
|
|
200
|
+
if (!root) {
|
|
201
|
+
return;
|
|
211
202
|
}
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
203
|
+
const { classList } = root;
|
|
204
|
+
// clear all themes
|
|
205
|
+
classList.forEach((value) => {
|
|
206
|
+
if (value.startsWith('theme-')) {
|
|
207
|
+
classList.remove(value);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
const name = `theme-${type}`;
|
|
211
|
+
classList.add(name);
|
|
219
212
|
}
|
|
220
213
|
|
|
221
214
|
async isPlatformSupported(): Promise<boolean> {
|
|
@@ -76,18 +76,19 @@ export abstract class DemoPage extends RouteMixin(RenderableMixin(EventTarget))
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
protected activateTheme(type: 'light' | 'dark'): void {
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
existing.parentElement?.removeChild(existing);
|
|
79
|
+
const root = document.querySelector('html');
|
|
80
|
+
if (!root) {
|
|
81
|
+
return;
|
|
83
82
|
}
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
83
|
+
const { classList } = root;
|
|
84
|
+
// clear all themes
|
|
85
|
+
classList.forEach((value) => {
|
|
86
|
+
if (value.startsWith('theme-')) {
|
|
87
|
+
classList.remove(value);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
const name = `theme-${type}`;
|
|
91
|
+
classList.add(name);
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
/**
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
html.theme-light {
|
|
2
|
+
--md-sys-color-primary: var(--md-sys-color-primary-light);
|
|
3
|
+
--md-sys-color-on-primary: var(--md-sys-color-on-primary-light);
|
|
4
|
+
--md-sys-color-primary-container: var(--md-sys-color-primary-container-light);
|
|
5
|
+
--md-sys-color-on-primary-container: var(--md-sys-color-on-primary-container-light);
|
|
6
|
+
--md-sys-color-secondary: var(--md-sys-color-secondary-light);
|
|
7
|
+
--md-sys-color-on-secondary: var(--md-sys-color-on-secondary-light);
|
|
8
|
+
--md-sys-color-secondary-container: var(--md-sys-color-secondary-container-light);
|
|
9
|
+
--md-sys-color-on-secondary-container: var(--md-sys-color-on-secondary-container-light);
|
|
10
|
+
--md-sys-color-tertiary: var(--md-sys-color-tertiary-light);
|
|
11
|
+
--md-sys-color-on-tertiary: var(--md-sys-color-on-tertiary-light);
|
|
12
|
+
--md-sys-color-tertiary-container: var(--md-sys-color-tertiary-container-light);
|
|
13
|
+
--md-sys-color-on-tertiary-container: var(--md-sys-color-on-tertiary-container-light);
|
|
14
|
+
--md-sys-color-error: var(--md-sys-color-error-light);
|
|
15
|
+
--md-sys-color-on-error: var(--md-sys-color-on-error-light);
|
|
16
|
+
--md-sys-color-error-container: var(--md-sys-color-error-container-light);
|
|
17
|
+
--md-sys-color-on-error-container: var(--md-sys-color-on-error-container-light);
|
|
18
|
+
--md-sys-color-outline: var(--md-sys-color-outline-light);
|
|
19
|
+
--md-sys-color-background: var(--md-sys-color-background-light);
|
|
20
|
+
--md-sys-color-on-background: var(--md-sys-color-on-background-light);
|
|
21
|
+
--md-sys-color-surface: var(--md-sys-color-surface-light);
|
|
22
|
+
--md-sys-color-on-surface: var(--md-sys-color-on-surface-light);
|
|
23
|
+
--md-sys-color-surface-variant: var(--md-sys-color-surface-variant-light);
|
|
24
|
+
--md-sys-color-on-surface-variant: var(--md-sys-color-on-surface-variant-light);
|
|
25
|
+
--md-sys-color-inverse-surface: var(--md-sys-color-inverse-surface-light);
|
|
26
|
+
--md-sys-color-inverse-on-surface: var(--md-sys-color-inverse-on-surface-light);
|
|
27
|
+
--md-sys-color-inverse-primary: var(--md-sys-color-inverse-primary-light);
|
|
28
|
+
--md-sys-color-shadow: var(--md-sys-color-shadow-light);
|
|
29
|
+
--md-sys-color-surface-tint: var(--md-sys-color-surface-tint-light);
|
|
30
|
+
--md-sys-color-outline-variant: var(--md-sys-color-outline-variant-light);
|
|
31
|
+
--md-sys-color-scrim: var(--md-sys-color-scrim-light);
|
|
32
|
+
|
|
33
|
+
/* CUSTOM */
|
|
34
|
+
--md-sys-elevation-0: none;
|
|
35
|
+
--md-sys-elevation-1: var(--md-sys-elevation-1-light);
|
|
36
|
+
--md-sys-elevation-2: var(--md-sys-elevation-2-light);
|
|
37
|
+
--md-sys-elevation-3: var(--md-sys-elevation-3-light);
|
|
38
|
+
--md-sys-elevation-4: var(--md-sys-elevation-4-light);
|
|
39
|
+
--md-sys-elevation-5: var(--md-sys-elevation-5-light);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
html.theme-dark {
|
|
43
|
+
--md-sys-color-primary: var(--md-sys-color-primary-dark);
|
|
44
|
+
--md-sys-color-on-primary: var(--md-sys-color-on-primary-dark);
|
|
45
|
+
--md-sys-color-primary-container: var(--md-sys-color-primary-container-dark);
|
|
46
|
+
--md-sys-color-on-primary-container: var(--md-sys-color-on-primary-container-dark);
|
|
47
|
+
--md-sys-color-secondary: var(--md-sys-color-secondary-dark);
|
|
48
|
+
--md-sys-color-on-secondary: var(--md-sys-color-on-secondary-dark);
|
|
49
|
+
--md-sys-color-secondary-container: var(--md-sys-color-secondary-container-dark);
|
|
50
|
+
--md-sys-color-on-secondary-container: var(--md-sys-color-on-secondary-container-dark);
|
|
51
|
+
--md-sys-color-tertiary: var(--md-sys-color-tertiary-dark);
|
|
52
|
+
--md-sys-color-on-tertiary: var(--md-sys-color-on-tertiary-dark);
|
|
53
|
+
--md-sys-color-tertiary-container: var(--md-sys-color-tertiary-container-dark);
|
|
54
|
+
--md-sys-color-on-tertiary-container: var(--md-sys-color-on-tertiary-container-dark);
|
|
55
|
+
--md-sys-color-error: var(--md-sys-color-error-dark);
|
|
56
|
+
--md-sys-color-on-error: var(--md-sys-color-on-error-dark);
|
|
57
|
+
--md-sys-color-error-container: var(--md-sys-color-error-container-dark);
|
|
58
|
+
--md-sys-color-on-error-container: var(--md-sys-color-on-error-container-dark);
|
|
59
|
+
--md-sys-color-outline: var(--md-sys-color-outline-dark);
|
|
60
|
+
--md-sys-color-background: var(--md-sys-color-background-dark);
|
|
61
|
+
--md-sys-color-on-background: var(--md-sys-color-on-background-dark);
|
|
62
|
+
--md-sys-color-surface: var(--md-sys-color-surface-dark);
|
|
63
|
+
--md-sys-color-on-surface: var(--md-sys-color-on-surface-dark);
|
|
64
|
+
--md-sys-color-surface-variant: var(--md-sys-color-surface-variant-dark);
|
|
65
|
+
--md-sys-color-on-surface-variant: var(--md-sys-color-on-surface-variant-dark);
|
|
66
|
+
--md-sys-color-inverse-surface: var(--md-sys-color-inverse-surface-dark);
|
|
67
|
+
--md-sys-color-inverse-on-surface: var(--md-sys-color-inverse-on-surface-dark);
|
|
68
|
+
--md-sys-color-inverse-primary: var(--md-sys-color-inverse-primary-dark);
|
|
69
|
+
--md-sys-color-shadow: var(--md-sys-color-shadow-dark);
|
|
70
|
+
--md-sys-color-surface-tint: var(--md-sys-color-surface-tint-dark);
|
|
71
|
+
--md-sys-color-outline-variant: var(--md-sys-color-outline-variant-dark);
|
|
72
|
+
--md-sys-color-scrim: var(--md-sys-color-scrim-dark);
|
|
73
|
+
|
|
74
|
+
/* CUSTOM */
|
|
75
|
+
--md-sys-elevation-0: none;
|
|
76
|
+
--md-sys-elevation-1: var(--md-sys-elevation-1-dark);
|
|
77
|
+
--md-sys-elevation-2: var(--md-sys-elevation-2-dark);
|
|
78
|
+
--md-sys-elevation-3: var(--md-sys-elevation-3-dark);
|
|
79
|
+
--md-sys-elevation-4: var(--md-sys-elevation-4-dark);
|
|
80
|
+
--md-sys-elevation-5: var(--md-sys-elevation-5-dark);
|
|
81
|
+
}
|
|
@@ -130,7 +130,7 @@ export default class UiDialog extends UiElement {
|
|
|
130
130
|
* To be set by a child class when closing the dialog.
|
|
131
131
|
* This is passed to the close event.
|
|
132
132
|
*/
|
|
133
|
-
|
|
133
|
+
dialogValue?: unknown;
|
|
134
134
|
|
|
135
135
|
constructor() {
|
|
136
136
|
super();
|
|
@@ -182,9 +182,10 @@ export default class UiDialog extends UiElement {
|
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
protected handleSlotChange(): void {
|
|
185
|
-
|
|
186
|
-
this.
|
|
187
|
-
this.
|
|
185
|
+
const { icons, titles, buttons } = this;
|
|
186
|
+
this.hasIcon = !!icons && !!icons.length;
|
|
187
|
+
this.hasTitle = !!titles && !!titles.length;
|
|
188
|
+
this.hasButton = !!buttons && !!buttons.length;
|
|
188
189
|
}
|
|
189
190
|
|
|
190
191
|
protected handleInteraction(value: 'dismiss' | 'confirm'): void {
|
|
@@ -266,6 +267,7 @@ export default class UiDialog extends UiElement {
|
|
|
266
267
|
<div class="${classMap(classes)}" part="button">
|
|
267
268
|
<slot name="button" @slotchange="${this.handleSlotChange}"></slot>
|
|
268
269
|
${this.renderDismissButton()}
|
|
270
|
+
${this.renderConfirmButton()}
|
|
269
271
|
</div>
|
|
270
272
|
`;
|
|
271
273
|
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { assert, fixture, html } from '@open-wc/testing';
|
|
2
|
+
import sinon from 'sinon';
|
|
3
|
+
import UiDialog, { UiDialogClosingReason } from '../../../src/ui/dialog/UiDialog.js';
|
|
4
|
+
import { UiMock } from '../../helpers/UiMock.js';
|
|
5
|
+
import UiButton from '../../../src/ui/button/UiButton.js';
|
|
6
|
+
import '../../../src/define/ui/ui-dialog.js';
|
|
7
|
+
import '../../../src/define/ui/ui-icon.js';
|
|
8
|
+
|
|
9
|
+
describe('UI', () => {
|
|
10
|
+
describe('Dialog', () => {
|
|
11
|
+
async function basicFixture(): Promise<UiDialog> {
|
|
12
|
+
return fixture(html`
|
|
13
|
+
<ui-dialog>
|
|
14
|
+
Content
|
|
15
|
+
</ui-dialog>`
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async function modalFixture(): Promise<UiDialog> {
|
|
20
|
+
return fixture(html`
|
|
21
|
+
<ui-dialog modal>
|
|
22
|
+
Content
|
|
23
|
+
</ui-dialog>`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function iconFixture(): Promise<UiDialog> {
|
|
27
|
+
return fixture(html`
|
|
28
|
+
<ui-dialog>
|
|
29
|
+
<ui-icon slot="icon" icon="deleteOutline"></ui-icon>
|
|
30
|
+
Content
|
|
31
|
+
</ui-dialog>`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function titleFixture(): Promise<UiDialog> {
|
|
35
|
+
return fixture(html`
|
|
36
|
+
<ui-dialog>
|
|
37
|
+
<span slot="title">The title</span>
|
|
38
|
+
Content
|
|
39
|
+
</ui-dialog>`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function buttonFixture(): Promise<UiDialog> {
|
|
43
|
+
return fixture(html`
|
|
44
|
+
<ui-dialog>
|
|
45
|
+
Content
|
|
46
|
+
<ui-button slot="button" type="text">Learn more</ui-button>
|
|
47
|
+
<ui-button slot="button" value="dismiss" type="text">Cancel</ui-button>
|
|
48
|
+
<ui-button slot="button" value="confirm" type="text">Accept</ui-button>
|
|
49
|
+
</ui-dialog>`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
describe('open/close', () => {
|
|
53
|
+
it('opens the native dialog via the "open" attribute', async () => {
|
|
54
|
+
const element = await basicFixture();
|
|
55
|
+
assert.isFalse(element.dialog.open, 'native dialog is closed initially');
|
|
56
|
+
|
|
57
|
+
element.open = true;
|
|
58
|
+
await element.updateComplete;
|
|
59
|
+
assert.isTrue(element.dialog.open, 'native dialog is opened');
|
|
60
|
+
|
|
61
|
+
element.open = false;
|
|
62
|
+
await element.updateComplete;
|
|
63
|
+
assert.isFalse(element.dialog.open, 'native dialog is closed again');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('closes the dialog via the Escape button', async () => {
|
|
67
|
+
const element = await buttonFixture();
|
|
68
|
+
// the dialog requires a focusable element
|
|
69
|
+
const button = element.querySelector('ui-button')!;
|
|
70
|
+
button.focus();
|
|
71
|
+
await UiMock.keyPress(element, 'Escape', { key: 'Escape' });
|
|
72
|
+
assert.equal(element.open, false);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('closes the dialog via the dismiss slotted button', async () => {
|
|
76
|
+
const element = await buttonFixture();
|
|
77
|
+
const button = element.querySelector('ui-button[value="dismiss"]') as UiButton;
|
|
78
|
+
button.click();
|
|
79
|
+
assert.equal(element.open, false);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('closes the dialog via the confirm slotted button', async () => {
|
|
83
|
+
const element = await buttonFixture();
|
|
84
|
+
const button = element.querySelector('ui-button[value="confirm"]') as UiButton;
|
|
85
|
+
button.click();
|
|
86
|
+
assert.equal(element.open, false);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('closes the dialog via the dismissLabel button', async () => {
|
|
90
|
+
const element = await basicFixture();
|
|
91
|
+
element.dismissLabel = 'Close';
|
|
92
|
+
await element.updateComplete;
|
|
93
|
+
const button = element.shadowRoot!.querySelector('.internal-button[value="dismiss"]') as UiButton;
|
|
94
|
+
button.click();
|
|
95
|
+
assert.equal(element.open, false);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('closes the dialog via the confirmLabel button', async () => {
|
|
99
|
+
const element = await basicFixture();
|
|
100
|
+
element.confirmLabel = 'Close';
|
|
101
|
+
await element.updateComplete;
|
|
102
|
+
const button = element.shadowRoot!.querySelector('.internal-button[value="confirm"]') as UiButton;
|
|
103
|
+
button.click();
|
|
104
|
+
assert.equal(element.open, false);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('dispatches the close event with cancelled = true', async () => {
|
|
108
|
+
const element = await buttonFixture();
|
|
109
|
+
const spy = sinon.spy();
|
|
110
|
+
element.addEventListener('close', spy);
|
|
111
|
+
const button = element.querySelector('ui-button[value="dismiss"]') as UiButton;
|
|
112
|
+
button.click();
|
|
113
|
+
assert.isTrue(spy.calledOnce, 'the event was dispatched');
|
|
114
|
+
const event = spy.args[0][0] as CustomEvent<UiDialogClosingReason>;
|
|
115
|
+
assert.isTrue(event.detail.cancelled, 'the cancelled flag is set');
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('dispatches the close event with cancelled = true', async () => {
|
|
119
|
+
const element = await buttonFixture();
|
|
120
|
+
const spy = sinon.spy();
|
|
121
|
+
element.addEventListener('close', spy);
|
|
122
|
+
const button = element.querySelector('ui-button[value="confirm"]') as UiButton;
|
|
123
|
+
button.click();
|
|
124
|
+
assert.isTrue(spy.calledOnce, 'the event was dispatched');
|
|
125
|
+
const event = spy.args[0][0] as CustomEvent<UiDialogClosingReason>;
|
|
126
|
+
assert.isFalse(event.detail.cancelled, 'the cancelled flag is not set');
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('dispatches the dialogValue', async () => {
|
|
130
|
+
const element = await buttonFixture();
|
|
131
|
+
element.dialogValue = 'test';
|
|
132
|
+
const spy = sinon.spy();
|
|
133
|
+
element.addEventListener('close', spy);
|
|
134
|
+
const button = element.querySelector('ui-button[value="confirm"]') as UiButton;
|
|
135
|
+
button.click();
|
|
136
|
+
assert.isTrue(spy.calledOnce, 'the event was dispatched');
|
|
137
|
+
const event = spy.args[0][0] as CustomEvent<UiDialogClosingReason>;
|
|
138
|
+
assert.equal(event.detail.value, 'test', 'has the value');
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
describe('modal dialog', () => {
|
|
143
|
+
it('opens the dialog as modal', async () => {
|
|
144
|
+
const element = await modalFixture();
|
|
145
|
+
const spy = sinon.spy(element.dialog, 'showModal');
|
|
146
|
+
element.open = true;
|
|
147
|
+
await element.updateComplete;
|
|
148
|
+
assert.isTrue(spy.calledOnce);
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
describe('icon', () => {
|
|
153
|
+
it('renders the icon slot', async () => {
|
|
154
|
+
const element = await basicFixture();
|
|
155
|
+
const slot = element.shadowRoot!.querySelector('slot[name="icon"]') as HTMLSlotElement;
|
|
156
|
+
assert.ok(slot, 'has the slot');
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('does not render padding around the icon slot', async () => {
|
|
160
|
+
const element = await basicFixture();
|
|
161
|
+
const container = element.shadowRoot!.querySelector('.icon') as HTMLElement;
|
|
162
|
+
assert.isFalse(container.classList.contains('with-icon'), 'has no with-icon class');
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('renders padding around the icon slot with an icon', async () => {
|
|
166
|
+
const element = await iconFixture();
|
|
167
|
+
const container = element.shadowRoot!.querySelector('.icon') as HTMLElement;
|
|
168
|
+
assert.isTrue(container.classList.contains('with-icon'), 'has the with-icon class');
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
describe('title', () => {
|
|
173
|
+
it('renders the title slot', async () => {
|
|
174
|
+
const element = await basicFixture();
|
|
175
|
+
const slot = element.shadowRoot!.querySelector('slot[name="title"]') as HTMLSlotElement;
|
|
176
|
+
assert.ok(slot, 'has the slot');
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('does not render padding around the title slot', async () => {
|
|
180
|
+
const element = await basicFixture();
|
|
181
|
+
const container = element.shadowRoot!.querySelector('.title') as HTMLElement;
|
|
182
|
+
assert.isFalse(container.classList.contains('with-title'), 'has no with-title class');
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('renders padding around the title slot with a title', async () => {
|
|
186
|
+
const element = await titleFixture();
|
|
187
|
+
const container = element.shadowRoot!.querySelector('.title') as HTMLElement;
|
|
188
|
+
assert.isTrue(container.classList.contains('with-title'), 'has the with-title class');
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
describe('buttons', () => {
|
|
193
|
+
it('renders the button slot', async () => {
|
|
194
|
+
const element = await basicFixture();
|
|
195
|
+
const slot = element.shadowRoot!.querySelector('slot[name="button"]') as HTMLSlotElement;
|
|
196
|
+
assert.ok(slot, 'has the slot');
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('does not render padding around the buttons slot', async () => {
|
|
200
|
+
const element = await basicFixture();
|
|
201
|
+
const container = element.shadowRoot!.querySelector('.buttons') as HTMLElement;
|
|
202
|
+
assert.isFalse(container.classList.contains('with-buttons'), 'has no with-buttons class');
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it('renders the confirm button', async () => {
|
|
206
|
+
const element = await basicFixture();
|
|
207
|
+
element.confirmLabel = 'OK label';
|
|
208
|
+
await element.updateComplete;
|
|
209
|
+
const container = element.shadowRoot!.querySelector('.buttons') as HTMLElement;
|
|
210
|
+
assert.isTrue(container.classList.contains('with-buttons'), 'has the with-buttons class');
|
|
211
|
+
const button = element.shadowRoot!.querySelector('.internal-button') as UiButton;
|
|
212
|
+
assert.ok(button, 'has the button');
|
|
213
|
+
assert.equal(button.value, 'confirm');
|
|
214
|
+
assert.equal(button.textContent!.trim(), 'OK label');
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it('renders the dismiss button', async () => {
|
|
218
|
+
const element = await basicFixture();
|
|
219
|
+
element.dismissLabel = 'Cancel label';
|
|
220
|
+
await element.updateComplete;
|
|
221
|
+
const container = element.shadowRoot!.querySelector('.buttons') as HTMLElement;
|
|
222
|
+
assert.isTrue(container.classList.contains('with-buttons'), 'has the with-buttons class');
|
|
223
|
+
const button = element.shadowRoot!.querySelector('.internal-button') as UiButton;
|
|
224
|
+
assert.ok(button, 'has the button');
|
|
225
|
+
assert.equal(button.value, 'dismiss');
|
|
226
|
+
assert.equal(button.textContent!.trim(), 'Cancel label');
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it('renders the slotted buttons', async () => {
|
|
230
|
+
const element = await buttonFixture();
|
|
231
|
+
const container = element.shadowRoot!.querySelector('.buttons') as HTMLElement;
|
|
232
|
+
assert.isTrue(container.classList.contains('with-buttons'), 'has the with-buttons class');
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
});
|
|
@@ -11,9 +11,7 @@ const filteredLogs = ['Running in dev mode', 'lit-html is in dev mode'];
|
|
|
11
11
|
|
|
12
12
|
export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
|
|
13
13
|
/** Test files to run */
|
|
14
|
-
files: [
|
|
15
|
-
"test/**/**/*.test.ts",
|
|
16
|
-
],
|
|
14
|
+
files: ["test/**/**/*.test.ts"],
|
|
17
15
|
|
|
18
16
|
/** Resolve bare module imports */
|
|
19
17
|
nodeResolve: {
|
|
@@ -88,12 +86,12 @@ export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
|
|
|
88
86
|
// See documentation for all available options
|
|
89
87
|
|
|
90
88
|
testRunnerHtml: (testFramework) =>
|
|
91
|
-
`<html>
|
|
89
|
+
`<html class="theme-light">
|
|
92
90
|
<head>
|
|
93
91
|
<link rel="stylesheet" href="/test/visualization/lib/test-styles.css" />
|
|
94
92
|
<!-- m3 styles -->
|
|
95
93
|
<link rel="stylesheet" href="/src/styles/m3/tokens.css" data-theme="tokens" />
|
|
96
|
-
<link rel="stylesheet" href="/src/styles/m3/theme.
|
|
94
|
+
<link rel="stylesheet" href="/src/styles/m3/theme.css" data-theme="light" />
|
|
97
95
|
</head>
|
|
98
96
|
<body>
|
|
99
97
|
<script type="module" src="${testFramework}"></script>
|
package/demo/themes/default.css
DELETED
|
File without changes
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
:root {
|
|
2
|
-
--md-sys-color-primary: var(--md-sys-color-primary-dark);
|
|
3
|
-
--md-sys-color-on-primary: var(--md-sys-color-on-primary-dark);
|
|
4
|
-
--md-sys-color-primary-container: var(--md-sys-color-primary-container-dark);
|
|
5
|
-
--md-sys-color-on-primary-container: var(--md-sys-color-on-primary-container-dark);
|
|
6
|
-
--md-sys-color-secondary: var(--md-sys-color-secondary-dark);
|
|
7
|
-
--md-sys-color-on-secondary: var(--md-sys-color-on-secondary-dark);
|
|
8
|
-
--md-sys-color-secondary-container: var(--md-sys-color-secondary-container-dark);
|
|
9
|
-
--md-sys-color-on-secondary-container: var(--md-sys-color-on-secondary-container-dark);
|
|
10
|
-
--md-sys-color-tertiary: var(--md-sys-color-tertiary-dark);
|
|
11
|
-
--md-sys-color-on-tertiary: var(--md-sys-color-on-tertiary-dark);
|
|
12
|
-
--md-sys-color-tertiary-container: var(--md-sys-color-tertiary-container-dark);
|
|
13
|
-
--md-sys-color-on-tertiary-container: var(--md-sys-color-on-tertiary-container-dark);
|
|
14
|
-
--md-sys-color-error: var(--md-sys-color-error-dark);
|
|
15
|
-
--md-sys-color-on-error: var(--md-sys-color-on-error-dark);
|
|
16
|
-
--md-sys-color-error-container: var(--md-sys-color-error-container-dark);
|
|
17
|
-
--md-sys-color-on-error-container: var(--md-sys-color-on-error-container-dark);
|
|
18
|
-
--md-sys-color-outline: var(--md-sys-color-outline-dark);
|
|
19
|
-
--md-sys-color-background: var(--md-sys-color-background-dark);
|
|
20
|
-
--md-sys-color-on-background: var(--md-sys-color-on-background-dark);
|
|
21
|
-
--md-sys-color-surface: var(--md-sys-color-surface-dark);
|
|
22
|
-
--md-sys-color-on-surface: var(--md-sys-color-on-surface-dark);
|
|
23
|
-
--md-sys-color-surface-variant: var(--md-sys-color-surface-variant-dark);
|
|
24
|
-
--md-sys-color-on-surface-variant: var(--md-sys-color-on-surface-variant-dark);
|
|
25
|
-
--md-sys-color-inverse-surface: var(--md-sys-color-inverse-surface-dark);
|
|
26
|
-
--md-sys-color-inverse-on-surface: var(--md-sys-color-inverse-on-surface-dark);
|
|
27
|
-
--md-sys-color-inverse-primary: var(--md-sys-color-inverse-primary-dark);
|
|
28
|
-
--md-sys-color-shadow: var(--md-sys-color-shadow-dark);
|
|
29
|
-
--md-sys-color-surface-tint: var(--md-sys-color-surface-tint-dark);
|
|
30
|
-
--md-sys-color-outline-variant: var(--md-sys-color-outline-variant-dark);
|
|
31
|
-
--md-sys-color-scrim: var(--md-sys-color-scrim-dark);
|
|
32
|
-
|
|
33
|
-
/* CUSTOM */
|
|
34
|
-
--md-sys-elevation-0: none;
|
|
35
|
-
--md-sys-elevation-1: var(--md-sys-elevation-1-dark);
|
|
36
|
-
--md-sys-elevation-2: var(--md-sys-elevation-2-dark);
|
|
37
|
-
--md-sys-elevation-3: var(--md-sys-elevation-3-dark);
|
|
38
|
-
--md-sys-elevation-4: var(--md-sys-elevation-4-dark);
|
|
39
|
-
--md-sys-elevation-5: var(--md-sys-elevation-5-dark);
|
|
40
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
:root {
|
|
2
|
-
--md-sys-color-primary: var(--md-sys-color-primary-light);
|
|
3
|
-
--md-sys-color-on-primary: var(--md-sys-color-on-primary-light);
|
|
4
|
-
--md-sys-color-primary-container: var(--md-sys-color-primary-container-light);
|
|
5
|
-
--md-sys-color-on-primary-container: var(--md-sys-color-on-primary-container-light);
|
|
6
|
-
--md-sys-color-secondary: var(--md-sys-color-secondary-light);
|
|
7
|
-
--md-sys-color-on-secondary: var(--md-sys-color-on-secondary-light);
|
|
8
|
-
--md-sys-color-secondary-container: var(--md-sys-color-secondary-container-light);
|
|
9
|
-
--md-sys-color-on-secondary-container: var(--md-sys-color-on-secondary-container-light);
|
|
10
|
-
--md-sys-color-tertiary: var(--md-sys-color-tertiary-light);
|
|
11
|
-
--md-sys-color-on-tertiary: var(--md-sys-color-on-tertiary-light);
|
|
12
|
-
--md-sys-color-tertiary-container: var(--md-sys-color-tertiary-container-light);
|
|
13
|
-
--md-sys-color-on-tertiary-container: var(--md-sys-color-on-tertiary-container-light);
|
|
14
|
-
--md-sys-color-error: var(--md-sys-color-error-light);
|
|
15
|
-
--md-sys-color-on-error: var(--md-sys-color-on-error-light);
|
|
16
|
-
--md-sys-color-error-container: var(--md-sys-color-error-container-light);
|
|
17
|
-
--md-sys-color-on-error-container: var(--md-sys-color-on-error-container-light);
|
|
18
|
-
--md-sys-color-outline: var(--md-sys-color-outline-light);
|
|
19
|
-
--md-sys-color-background: var(--md-sys-color-background-light);
|
|
20
|
-
--md-sys-color-on-background: var(--md-sys-color-on-background-light);
|
|
21
|
-
--md-sys-color-surface: var(--md-sys-color-surface-light);
|
|
22
|
-
--md-sys-color-on-surface: var(--md-sys-color-on-surface-light);
|
|
23
|
-
--md-sys-color-surface-variant: var(--md-sys-color-surface-variant-light);
|
|
24
|
-
--md-sys-color-on-surface-variant: var(--md-sys-color-on-surface-variant-light);
|
|
25
|
-
--md-sys-color-inverse-surface: var(--md-sys-color-inverse-surface-light);
|
|
26
|
-
--md-sys-color-inverse-on-surface: var(--md-sys-color-inverse-on-surface-light);
|
|
27
|
-
--md-sys-color-inverse-primary: var(--md-sys-color-inverse-primary-light);
|
|
28
|
-
--md-sys-color-shadow: var(--md-sys-color-shadow-light);
|
|
29
|
-
--md-sys-color-surface-tint: var(--md-sys-color-surface-tint-light);
|
|
30
|
-
--md-sys-color-outline-variant: var(--md-sys-color-outline-variant-light);
|
|
31
|
-
--md-sys-color-scrim: var(--md-sys-color-scrim-light);
|
|
32
|
-
|
|
33
|
-
/* CUSTOM */
|
|
34
|
-
--md-sys-elevation-0: none;
|
|
35
|
-
--md-sys-elevation-1: var(--md-sys-elevation-1-light);
|
|
36
|
-
--md-sys-elevation-2: var(--md-sys-elevation-2-light);
|
|
37
|
-
--md-sys-elevation-3: var(--md-sys-elevation-3-light);
|
|
38
|
-
--md-sys-elevation-4: var(--md-sys-elevation-4-light);
|
|
39
|
-
--md-sys-elevation-5: var(--md-sys-elevation-5-light);
|
|
40
|
-
}
|