@aquera/nile-elements 0.0.30 → 0.0.32
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/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/index.d.ts +2 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/index.js +2 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/index.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-button/nile-button.css.js +2 -2
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-button/nile-button.css.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-button-toggle/nile-button-toggle.css.js +12 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-button-toggle/nile-button-toggle.css.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-calendar/nile-calendar.js +1 -3
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-calendar/nile-calendar.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/extensionSetup.d.ts +33 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/extensionSetup.js +63 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/extensionSetup.js.map +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/index.d.ts +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/index.js +2 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/index.js.map +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.css.d.ts +12 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.css.js +42 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.css.js.map +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.d.ts +43 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.js +114 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.js.map +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-dialog/nile-dialog.js +0 -6
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-dialog/nile-dialog.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-error-message/nile-error-message.css.js +5 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-error-message/nile-error-message.css.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-error-message/nile-error-message.js +5 -2
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-error-message/nile-error-message.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-icon-button/nile-icon-button.d.ts +4 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-icon-button/nile-icon-button.js +16 -2
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-icon-button/nile-icon-button.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-input/nile-input.css.js +4 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-input/nile-input.css.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-input/nile-input.js +4 -4
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-input/nile-input.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-select/nile-select.d.ts +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-select/nile-select.js +9 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-select/nile-select.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.css.js +11 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.css.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.d.ts +11 -5
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.js +55 -7
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab/nile-tab.css.js +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab/nile-tab.css.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab/nile-tab.js +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab/nile-tab.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-textarea/nile-textarea.css.js +4 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-textarea/nile-textarea.css.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-textarea/nile-textarea.js +5 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-textarea/nile-textarea.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-toast/index.d.ts +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-toast/index.js +2 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-toast/index.js.map +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-toast/nile-toast.css.d.ts +12 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-toast/nile-toast.css.js +174 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-toast/nile-toast.css.js.map +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-toast/nile-toast.d.ts +88 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-toast/nile-toast.js +350 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-toast/nile-toast.js.map +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.iife.js +672 -351
- package/dist/nile-button/nile-button.css.cjs.js +1 -1
- package/dist/nile-button/nile-button.css.cjs.js.map +1 -1
- package/dist/nile-button/nile-button.css.esm.js +2 -2
- package/dist/nile-button-toggle/nile-button-toggle.css.cjs.js +1 -1
- package/dist/nile-button-toggle/nile-button-toggle.css.cjs.js.map +1 -1
- package/dist/nile-button-toggle/nile-button-toggle.css.esm.js +12 -0
- package/dist/nile-calendar/index.cjs.js +1 -1
- package/dist/nile-calendar/index.esm.js +1 -1
- package/dist/nile-calendar/nile-calendar.cjs.js +1 -1
- package/dist/nile-calendar/nile-calendar.cjs.js.map +1 -1
- package/dist/nile-calendar/nile-calendar.esm.js +4 -6
- package/dist/nile-calendar/timezones.cjs.js +1 -1
- package/dist/nile-calendar/timezones.cjs.js.map +1 -1
- package/dist/nile-calendar/timezones.esm.js +1 -1
- package/dist/nile-code-editor/extensionSetup.cjs.js +7 -0
- package/dist/nile-code-editor/extensionSetup.cjs.js.map +1 -0
- package/dist/nile-code-editor/extensionSetup.esm.js +1 -0
- package/dist/nile-code-editor/index.cjs.js +2 -0
- package/dist/nile-code-editor/index.cjs.js.map +1 -0
- package/dist/nile-code-editor/index.esm.js +1 -0
- package/dist/nile-code-editor/nile-code-editor.cjs.js +3 -0
- package/dist/nile-code-editor/nile-code-editor.cjs.js.map +1 -0
- package/dist/nile-code-editor/nile-code-editor.css.cjs.js +2 -0
- package/dist/nile-code-editor/nile-code-editor.css.cjs.js.map +1 -0
- package/dist/nile-code-editor/nile-code-editor.css.esm.js +30 -0
- package/dist/nile-code-editor/nile-code-editor.esm.js +9 -0
- package/dist/nile-dialog/nile-dialog.cjs.js.map +1 -1
- package/dist/nile-error-message/nile-error-message.cjs.js +1 -1
- package/dist/nile-error-message/nile-error-message.cjs.js.map +1 -1
- package/dist/nile-error-message/nile-error-message.css.cjs.js +1 -1
- package/dist/nile-error-message/nile-error-message.css.cjs.js.map +1 -1
- package/dist/nile-error-message/nile-error-message.css.esm.js +5 -0
- package/dist/nile-error-message/nile-error-message.esm.js +6 -4
- package/dist/nile-icon-button/nile-icon-button.cjs.js +1 -1
- package/dist/nile-icon-button/nile-icon-button.cjs.js.map +1 -1
- package/dist/nile-icon-button/nile-icon-button.esm.js +5 -2
- package/dist/nile-input/nile-input.cjs.js +1 -1
- package/dist/nile-input/nile-input.cjs.js.map +1 -1
- package/dist/nile-input/nile-input.css.cjs.js +1 -1
- package/dist/nile-input/nile-input.css.cjs.js.map +1 -1
- package/dist/nile-input/nile-input.css.esm.js +4 -0
- package/dist/nile-input/nile-input.esm.js +2 -2
- package/dist/nile-select/nile-select.cjs.js +1 -1
- package/dist/nile-select/nile-select.cjs.js.map +1 -1
- package/dist/nile-select/nile-select.esm.js +2 -2
- package/dist/nile-switcher/index.cjs.js +1 -1
- package/dist/nile-switcher/index.esm.js +1 -1
- package/dist/nile-switcher/nile-switcher.cjs.js +1 -1
- package/dist/nile-switcher/nile-switcher.cjs.js.map +1 -1
- package/dist/nile-switcher/nile-switcher.css.cjs.js +1 -1
- package/dist/nile-switcher/nile-switcher.css.cjs.js.map +1 -1
- package/dist/nile-switcher/nile-switcher.css.esm.js +13 -2
- package/dist/nile-switcher/nile-switcher.esm.js +38 -30
- package/dist/nile-tab/nile-tab.cjs.js +1 -1
- package/dist/nile-tab/nile-tab.cjs.js.map +1 -1
- package/dist/nile-tab/nile-tab.css.cjs.js +1 -1
- package/dist/nile-tab/nile-tab.css.cjs.js.map +1 -1
- package/dist/nile-tab/nile-tab.css.esm.js +1 -0
- package/dist/nile-tab/nile-tab.esm.js +1 -0
- package/dist/nile-textarea/nile-textarea.cjs.js +1 -1
- package/dist/nile-textarea/nile-textarea.cjs.js.map +1 -1
- package/dist/nile-textarea/nile-textarea.css.cjs.js +1 -1
- package/dist/nile-textarea/nile-textarea.css.cjs.js.map +1 -1
- package/dist/nile-textarea/nile-textarea.css.esm.js +4 -1
- package/dist/nile-textarea/nile-textarea.esm.js +3 -1
- package/dist/nile-toast/index.cjs.js +2 -0
- package/dist/nile-toast/index.cjs.js.map +1 -0
- package/dist/nile-toast/index.esm.js +1 -0
- package/dist/nile-toast/nile-toast.cjs.js +2 -0
- package/dist/nile-toast/nile-toast.cjs.js.map +1 -0
- package/dist/nile-toast/nile-toast.css.cjs.js +2 -0
- package/dist/nile-toast/nile-toast.css.cjs.js.map +1 -0
- package/dist/nile-toast/nile-toast.css.esm.js +162 -0
- package/dist/nile-toast/nile-toast.esm.js +74 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/nile-button/nile-button.css.js +2 -2
- package/dist/src/nile-button/nile-button.css.js.map +1 -1
- package/dist/src/nile-button-toggle/nile-button-toggle.css.js +12 -0
- package/dist/src/nile-button-toggle/nile-button-toggle.css.js.map +1 -1
- package/dist/src/nile-calendar/nile-calendar.js +1 -3
- package/dist/src/nile-calendar/nile-calendar.js.map +1 -1
- package/dist/src/nile-code-editor/extensionSetup.d.ts +33 -0
- package/dist/src/nile-code-editor/extensionSetup.js +63 -0
- package/dist/src/nile-code-editor/extensionSetup.js.map +1 -0
- package/dist/src/nile-code-editor/index.d.ts +1 -0
- package/dist/src/nile-code-editor/index.js +2 -0
- package/dist/src/nile-code-editor/index.js.map +1 -0
- package/dist/src/nile-code-editor/nile-code-editor.css.d.ts +12 -0
- package/dist/src/nile-code-editor/nile-code-editor.css.js +42 -0
- package/dist/src/nile-code-editor/nile-code-editor.css.js.map +1 -0
- package/dist/src/nile-code-editor/nile-code-editor.d.ts +43 -0
- package/dist/src/nile-code-editor/nile-code-editor.js +114 -0
- package/dist/src/nile-code-editor/nile-code-editor.js.map +1 -0
- package/dist/src/nile-dialog/nile-dialog.js +0 -6
- package/dist/src/nile-dialog/nile-dialog.js.map +1 -1
- package/dist/src/nile-error-message/nile-error-message.css.js +5 -0
- package/dist/src/nile-error-message/nile-error-message.css.js.map +1 -1
- package/dist/src/nile-error-message/nile-error-message.js +5 -2
- package/dist/src/nile-error-message/nile-error-message.js.map +1 -1
- package/dist/src/nile-icon-button/nile-icon-button.d.ts +4 -0
- package/dist/src/nile-icon-button/nile-icon-button.js +16 -2
- package/dist/src/nile-icon-button/nile-icon-button.js.map +1 -1
- package/dist/src/nile-input/nile-input.css.js +4 -0
- package/dist/src/nile-input/nile-input.css.js.map +1 -1
- package/dist/src/nile-input/nile-input.js +4 -4
- package/dist/src/nile-input/nile-input.js.map +1 -1
- package/dist/src/nile-select/nile-select.d.ts +1 -0
- package/dist/src/nile-select/nile-select.js +9 -0
- package/dist/src/nile-select/nile-select.js.map +1 -1
- package/dist/src/nile-switcher/nile-switcher.css.js +11 -0
- package/dist/src/nile-switcher/nile-switcher.css.js.map +1 -1
- package/dist/src/nile-switcher/nile-switcher.d.ts +11 -5
- package/dist/src/nile-switcher/nile-switcher.js +55 -7
- package/dist/src/nile-switcher/nile-switcher.js.map +1 -1
- package/dist/src/nile-tab/nile-tab.css.js +1 -0
- package/dist/src/nile-tab/nile-tab.css.js.map +1 -1
- package/dist/src/nile-tab/nile-tab.js +1 -0
- package/dist/src/nile-tab/nile-tab.js.map +1 -1
- package/dist/src/nile-textarea/nile-textarea.css.js +4 -1
- package/dist/src/nile-textarea/nile-textarea.css.js.map +1 -1
- package/dist/src/nile-textarea/nile-textarea.js +5 -0
- package/dist/src/nile-textarea/nile-textarea.js.map +1 -1
- package/dist/src/nile-toast/index.d.ts +1 -0
- package/dist/src/nile-toast/index.js +2 -0
- package/dist/src/nile-toast/index.js.map +1 -0
- package/dist/src/nile-toast/nile-toast.css.d.ts +12 -0
- package/dist/src/nile-toast/nile-toast.css.js +174 -0
- package/dist/src/nile-toast/nile-toast.css.js.map +1 -0
- package/dist/src/nile-toast/nile-toast.d.ts +88 -0
- package/dist/src/nile-toast/nile-toast.js +350 -0
- package/dist/src/nile-toast/nile-toast.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/index.ts +3 -1
- package/src/nile-button/nile-button.css.ts +2 -2
- package/src/nile-button-toggle/nile-button-toggle.css.ts +12 -0
- package/src/nile-calendar/nile-calendar.ts +1 -5
- package/src/nile-code-editor/extensionSetup.ts +125 -0
- package/src/nile-code-editor/index.ts +1 -0
- package/src/nile-code-editor/nile-code-editor.css.ts +44 -0
- package/src/nile-code-editor/nile-code-editor.ts +127 -0
- package/src/nile-dialog/nile-dialog.ts +0 -6
- package/src/nile-error-message/nile-error-message.css.ts +5 -0
- package/src/nile-error-message/nile-error-message.ts +6 -2
- package/src/nile-icon-button/nile-icon-button.ts +24 -5
- package/src/nile-input/nile-input.css.ts +4 -0
- package/src/nile-input/nile-input.ts +6 -6
- package/src/nile-select/nile-select.ts +9 -0
- package/src/nile-switcher/nile-switcher.css.ts +11 -0
- package/src/nile-switcher/nile-switcher.ts +70 -10
- package/src/nile-tab/nile-tab.css.ts +1 -0
- package/src/nile-tab/nile-tab.ts +1 -0
- package/src/nile-textarea/nile-textarea.css.ts +4 -1
- package/src/nile-textarea/nile-textarea.ts +6 -1
- package/src/nile-toast/index.ts +1 -0
- package/src/nile-toast/nile-toast.css.ts +176 -0
- package/src/nile-toast/nile-toast.ts +381 -0
@@ -0,0 +1,381 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright Aquera Inc 2023
|
3
|
+
*
|
4
|
+
* This source code is licensed under the BSD-3-Clause license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
|
8
|
+
import { LitElement, CSSResultArray, TemplateResult } from 'lit-element';
|
9
|
+
|
10
|
+
import '../nile-icon-button/nile-icon-button';
|
11
|
+
import { animateTo, stopAnimations } from '../internal/animate';
|
12
|
+
import { classMap } from 'lit/directives/class-map.js';
|
13
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
14
|
+
import {
|
15
|
+
getAnimation,
|
16
|
+
setDefaultAnimation,
|
17
|
+
} from '../utilities/animation-registry';
|
18
|
+
import { HasSlotController } from '../internal/slot';
|
19
|
+
import { html } from 'lit';
|
20
|
+
import { waitForEvent } from '../internal/event';
|
21
|
+
import { watch } from '../internal/watch';
|
22
|
+
import NileElement from '../internal/nile-element';
|
23
|
+
import { styles } from './nile-toast.css';
|
24
|
+
import type { CSSResultGroup } from 'lit';
|
25
|
+
|
26
|
+
const toastStack = Object.assign(document.createElement('div'), {
|
27
|
+
className: 'nile-toast-stack',
|
28
|
+
});
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Nile icon component.
|
32
|
+
*
|
33
|
+
* @tag nile-toast
|
34
|
+
*
|
35
|
+
* @dependency nile-icon-button
|
36
|
+
*
|
37
|
+
* @slot - The alert's main content.
|
38
|
+
* @slot icon - An icon to show in the alert. Works best with `<nile-icon>`.
|
39
|
+
*
|
40
|
+
* @event nile-show - Emitted when the alert opens.
|
41
|
+
* @event nile-after-show - Emitted after the alert opens and all animations are complete.
|
42
|
+
* @event nile-hide - Emitted when the alert closes.
|
43
|
+
* @event nile-after-hide - Emitted after the alert closes and all animations are complete.
|
44
|
+
*
|
45
|
+
* @csspart base - The component's base wrapper.
|
46
|
+
* @csspart icon - The container that wraps the optional icon.
|
47
|
+
* @csspart message - The container that wraps the alert's main content.
|
48
|
+
* @csspart close-button - The close button, an `<nile-icon-button>`.
|
49
|
+
* @csspart close-button__base - The close button's exported `base` part.
|
50
|
+
*
|
51
|
+
* @animation alert.show - The animation to use when showing the alert.
|
52
|
+
* @animation alert.hide - The animation to use when hiding the alert.
|
53
|
+
*/
|
54
|
+
|
55
|
+
@customElement('nile-toast')
|
56
|
+
export class NileToast extends NileElement {
|
57
|
+
static styles: CSSResultGroup = styles;
|
58
|
+
|
59
|
+
private autoHideTimeout: number;
|
60
|
+
private readonly hasSlotController = new HasSlotController(
|
61
|
+
this,
|
62
|
+
'icon',
|
63
|
+
'suffix'
|
64
|
+
);
|
65
|
+
|
66
|
+
@query('[part~="base"]') base: HTMLElement;
|
67
|
+
|
68
|
+
/**
|
69
|
+
* Indicates whether or not the alert is open. You can toggle this attribute to show and hide the alert, or you can
|
70
|
+
* use the `show()` and `hide()` methods and this attribute will reflect the alert's open state.
|
71
|
+
*/
|
72
|
+
@property({ type: Boolean, reflect: true }) open = false;
|
73
|
+
|
74
|
+
@property({ type: Boolean, reflect: true }) noIcon = false;
|
75
|
+
|
76
|
+
/** Enables a close button that allows the user to dismiss the alert. */
|
77
|
+
|
78
|
+
@property({ type: Boolean, reflect: true }) closable = false;
|
79
|
+
|
80
|
+
@property({ type: Boolean, reflect: true }) hasSlottedContent = false;
|
81
|
+
|
82
|
+
@property({ type: Boolean, reflect: true }) hasSlottedIcon = false;
|
83
|
+
|
84
|
+
@property({ type: String, reflect: true }) prefixImageUrl = '';
|
85
|
+
|
86
|
+
/** The alert's theme variant. */
|
87
|
+
@property({ reflect: true }) variant:
|
88
|
+
| 'success'
|
89
|
+
| 'info'
|
90
|
+
| 'warning'
|
91
|
+
| 'error' = 'success';
|
92
|
+
|
93
|
+
/**
|
94
|
+
* The length of time, in milliseconds, the alert will show before closing itself. If the user interacts with
|
95
|
+
* the alert before it closes (e.g. moves the mouse over it), the timer will restart. Defaults to `Infinity`, meaning
|
96
|
+
* the alert will not close on its own.
|
97
|
+
*/
|
98
|
+
@property({ type: Number }) duration = Infinity;
|
99
|
+
|
100
|
+
@property({ type: String }) title = '';
|
101
|
+
|
102
|
+
@property({ type: String }) content = '';
|
103
|
+
|
104
|
+
@property({ type: Array, reflect: true }) tags: any[] = [];
|
105
|
+
|
106
|
+
firstUpdated() {
|
107
|
+
this.base.hidden = !this.open;
|
108
|
+
}
|
109
|
+
|
110
|
+
private restartAutoHide() {
|
111
|
+
clearTimeout(this.autoHideTimeout);
|
112
|
+
if (this.open && this.duration < Infinity) {
|
113
|
+
this.autoHideTimeout = window.setTimeout(
|
114
|
+
() => this.hide(),
|
115
|
+
this.duration
|
116
|
+
);
|
117
|
+
}
|
118
|
+
}
|
119
|
+
|
120
|
+
private handleCloseClick() {
|
121
|
+
this.hide();
|
122
|
+
}
|
123
|
+
|
124
|
+
private handleMouseMove() {
|
125
|
+
this.restartAutoHide();
|
126
|
+
}
|
127
|
+
|
128
|
+
@watch('open', { waitUntilFirstUpdate: true })
|
129
|
+
async handleOpenChange() {
|
130
|
+
if (this.open) {
|
131
|
+
// Show
|
132
|
+
this.emit('nile-show');
|
133
|
+
|
134
|
+
if (this.duration < Infinity) {
|
135
|
+
this.restartAutoHide();
|
136
|
+
}
|
137
|
+
|
138
|
+
await stopAnimations(this.base);
|
139
|
+
this.base.hidden = false;
|
140
|
+
const { keyframes, options } = getAnimation(this, 'alert.show', {
|
141
|
+
dir: 'ltr',
|
142
|
+
});
|
143
|
+
await animateTo(this.base, keyframes, options);
|
144
|
+
|
145
|
+
this.emit('nile-after-show');
|
146
|
+
} else {
|
147
|
+
// Hide
|
148
|
+
this.emit('nile-hide');
|
149
|
+
|
150
|
+
clearTimeout(this.autoHideTimeout);
|
151
|
+
|
152
|
+
await stopAnimations(this.base);
|
153
|
+
const { keyframes, options } = getAnimation(this, 'alert.hide', {
|
154
|
+
dir: 'ltr',
|
155
|
+
});
|
156
|
+
await animateTo(this.base, keyframes, options);
|
157
|
+
this.base.hidden = true;
|
158
|
+
|
159
|
+
this.emit('nile-after-hide');
|
160
|
+
}
|
161
|
+
}
|
162
|
+
|
163
|
+
@watch('duration')
|
164
|
+
handleDurationChange() {
|
165
|
+
this.restartAutoHide();
|
166
|
+
}
|
167
|
+
|
168
|
+
/** Shows the alert. */
|
169
|
+
async show() {
|
170
|
+
if (this.open) {
|
171
|
+
return undefined;
|
172
|
+
}
|
173
|
+
|
174
|
+
this.open = true;
|
175
|
+
return waitForEvent(this, 'nile-after-show');
|
176
|
+
}
|
177
|
+
|
178
|
+
/** Hides the alert */
|
179
|
+
async hide() {
|
180
|
+
if (!this.open) {
|
181
|
+
return undefined;
|
182
|
+
}
|
183
|
+
|
184
|
+
this.open = false;
|
185
|
+
return waitForEvent(this, 'nile-after-hide');
|
186
|
+
}
|
187
|
+
|
188
|
+
getIconNameByVariant() {
|
189
|
+
switch (this.variant) {
|
190
|
+
case 'success':
|
191
|
+
return 'tick';
|
192
|
+
case 'info':
|
193
|
+
return 'helpsupport';
|
194
|
+
case 'warning':
|
195
|
+
return 'info-icon';
|
196
|
+
case 'error':
|
197
|
+
return 'cancel';
|
198
|
+
default:
|
199
|
+
return 'tick';
|
200
|
+
}
|
201
|
+
}
|
202
|
+
|
203
|
+
handleSlotChange(e: any) {
|
204
|
+
const slot = e.target;
|
205
|
+
const nodes = slot.assignedNodes({ flatten: true });
|
206
|
+
if (slot.name === 'message') {
|
207
|
+
const nodes = slot.assignedNodes({ flatten: true });
|
208
|
+
this.hasSlottedContent = nodes.length > 0;
|
209
|
+
}
|
210
|
+
|
211
|
+
if (slot.name === 'icon') {
|
212
|
+
const nodes = slot.assignedNodes({ flatten: true });
|
213
|
+
this.hasSlottedIcon = nodes.length > 0;
|
214
|
+
}
|
215
|
+
|
216
|
+
}
|
217
|
+
|
218
|
+
/**
|
219
|
+
* Displays the alert as a toast notification. This will move the alert out of its position in the DOM and, when
|
220
|
+
* dismissed, it will be removed from the DOM completely. By storing a reference to the alert, you can reuse it by
|
221
|
+
* calling this method again. The returned promise will resolve after the alert is hidden.
|
222
|
+
*/
|
223
|
+
async toast() {
|
224
|
+
return new Promise<void>(resolve => {
|
225
|
+
if (toastStack.parentElement === null) {
|
226
|
+
document.body.append(toastStack);
|
227
|
+
}
|
228
|
+
|
229
|
+
toastStack.appendChild(this);
|
230
|
+
|
231
|
+
// Wait for the toast stack to render
|
232
|
+
requestAnimationFrame(() => {
|
233
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- force a reflow for the initial transition
|
234
|
+
this.clientWidth;
|
235
|
+
this.show();
|
236
|
+
});
|
237
|
+
|
238
|
+
this.addEventListener(
|
239
|
+
'nile-after-hide',
|
240
|
+
() => {
|
241
|
+
toastStack.removeChild(this);
|
242
|
+
resolve();
|
243
|
+
|
244
|
+
// Remove the toast stack from the DOM when there are no more alerts
|
245
|
+
if (toastStack.querySelector('nile-alert') === null) {
|
246
|
+
toastStack.remove();
|
247
|
+
}
|
248
|
+
},
|
249
|
+
{ once: true }
|
250
|
+
);
|
251
|
+
});
|
252
|
+
}
|
253
|
+
|
254
|
+
private toastTags(content: string, imageUrl: string) {
|
255
|
+
return html`
|
256
|
+
<div class="alert__tag">
|
257
|
+
<img class="alert__tag-image" src="${imageUrl}" />
|
258
|
+
<span class="alert__tag-content"> ${content} </span>
|
259
|
+
</div>
|
260
|
+
`;
|
261
|
+
}
|
262
|
+
|
263
|
+
render() {
|
264
|
+
return html`
|
265
|
+
<div
|
266
|
+
part="base"
|
267
|
+
class=${classMap({
|
268
|
+
alert: true,
|
269
|
+
'alert--open': this.open,
|
270
|
+
'alert--closable': this.closable,
|
271
|
+
'alert--has-icon': this.hasSlotController.test('icon'),
|
272
|
+
'alert--success': this.variant === 'success',
|
273
|
+
'alert--info': this.variant === 'info',
|
274
|
+
'alert--warning': this.variant === 'warning',
|
275
|
+
'alert--error': this.variant === 'error',
|
276
|
+
})}
|
277
|
+
role="alert"
|
278
|
+
aria-hidden=${this.open ? 'false' : 'true'}
|
279
|
+
@mousemove=${this.handleMouseMove}
|
280
|
+
>
|
281
|
+
<slot name="icon" part="icon" ?hidden="${this.noIcon === true}">
|
282
|
+
${!this.prefixImageUrl
|
283
|
+
? html`
|
284
|
+
<div
|
285
|
+
class="alert__prefix-icon-container"
|
286
|
+
?hidden="${this.hasSlottedIcon ||
|
287
|
+
this.prefixImageUrl.length > 0}"
|
288
|
+
>
|
289
|
+
<nile-icon
|
290
|
+
name="${this.getIconNameByVariant()}"
|
291
|
+
size="15"
|
292
|
+
color="white"
|
293
|
+
></nile-icon>
|
294
|
+
</div>
|
295
|
+
`
|
296
|
+
: ``}
|
297
|
+
|
298
|
+
${this.prefixImageUrl
|
299
|
+
? html`
|
300
|
+
<img src="${this.prefixImageUrl}" class="alert__prefix-img" />
|
301
|
+
`
|
302
|
+
: ``}
|
303
|
+
</slot>
|
304
|
+
|
305
|
+
<slot
|
306
|
+
name="message"
|
307
|
+
part="message"
|
308
|
+
class="alert__message"
|
309
|
+
aria-live="polite"
|
310
|
+
@slotchange="${this.handleSlotChange}"
|
311
|
+
>
|
312
|
+
<div
|
313
|
+
?hidden="${this.hasSlottedContent && this.title === ''}"
|
314
|
+
class="alert__message--title"
|
315
|
+
>
|
316
|
+
${this.title}
|
317
|
+
</div>
|
318
|
+
<div
|
319
|
+
?hidden="${this.hasSlottedContent && this.content === ''}"
|
320
|
+
class="alert__message--content ${this.title === ''
|
321
|
+
? 'alert__message--content-only'
|
322
|
+
: ''}"
|
323
|
+
>
|
324
|
+
${this.content}
|
325
|
+
</div>
|
326
|
+
|
327
|
+
${this.tags?.length > 0
|
328
|
+
? html`
|
329
|
+
<div class="alert__tags">
|
330
|
+
${this.tags.map(
|
331
|
+
tag =>
|
332
|
+
html`<span
|
333
|
+
>${this.toastTags(tag.content, tag.imageUrl)}</span
|
334
|
+
>`
|
335
|
+
)}
|
336
|
+
</div>
|
337
|
+
`
|
338
|
+
: ``}
|
339
|
+
</slot>
|
340
|
+
|
341
|
+
${this.closable
|
342
|
+
? html`
|
343
|
+
<nile-icon-button
|
344
|
+
part="close-button"
|
345
|
+
exportparts="base:close-button__base"
|
346
|
+
class="alert__close-button"
|
347
|
+
name="close"
|
348
|
+
label="close"
|
349
|
+
size="14"
|
350
|
+
@click=${this.handleCloseClick}
|
351
|
+
></nile-icon-button>
|
352
|
+
`
|
353
|
+
: ''}
|
354
|
+
</div>
|
355
|
+
`;
|
356
|
+
}
|
357
|
+
}
|
358
|
+
|
359
|
+
setDefaultAnimation('alert.show', {
|
360
|
+
keyframes: [
|
361
|
+
{ opacity: 0, scale: 0.8 },
|
362
|
+
{ opacity: 1, scale: 1 },
|
363
|
+
],
|
364
|
+
options: { duration: 250, easing: 'ease' },
|
365
|
+
});
|
366
|
+
|
367
|
+
setDefaultAnimation('alert.hide', {
|
368
|
+
keyframes: [
|
369
|
+
{ opacity: 1, scale: 1 },
|
370
|
+
{ opacity: 0, scale: 0.8 },
|
371
|
+
],
|
372
|
+
options: { duration: 250, easing: 'ease' },
|
373
|
+
});
|
374
|
+
|
375
|
+
export default NileToast;
|
376
|
+
|
377
|
+
declare global {
|
378
|
+
interface HTMLElementTagNameMap {
|
379
|
+
'nile-toast': NileToast;
|
380
|
+
}
|
381
|
+
}
|