@nova-design-system/nova-react 3.14.0-beta.0 → 3.14.0
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/dist/cjs/{collapse.animation-6e0b08df-AHWzNGm_.js → collapse.animation-acda1bf5-BuORVmQv.js} +1 -4
- package/dist/cjs/{constants-69bafca2-DpB_ghPF.js → constants-d0f19e7b-s0SCO_vi.js} +0 -9
- package/dist/cjs/{fade.animation-9b939939-DV--bM4S.js → fade.animation-eb454088-Bma0SpTf.js} +2 -2
- package/dist/cjs/{index-CJDePE8Z.js → index-CKAZvszR.js} +328 -584
- package/dist/cjs/index.js +1 -9
- package/dist/cjs/{nv-accordion-item.entry-Begcz9SZ.js → nv-accordion-item.entry-CjBcmF8t.js} +4 -5
- package/dist/cjs/{nv-accordion.entry-DQAkheHY.js → nv-accordion.entry-CRk2Wvt3.js} +1 -2
- package/dist/cjs/{nv-alert.entry-CEzR0iu0.js → nv-alert.entry-D5qB5xZg.js} +11 -12
- package/dist/cjs/{nv-avatar.entry-B-u7r30l.js → nv-avatar.entry-CuNYdZl_.js} +7 -8
- package/dist/cjs/{nv-badge_2.entry-0vhTS5D7.js → nv-badge_2.entry-BDuX1qOQ.js} +10 -11
- package/dist/cjs/{nv-breadcrumb.entry-BkWs1x-W.js → nv-breadcrumb.entry-BE9U6AF_.js} +1 -2
- package/dist/cjs/{nv-breadcrumbs.entry-DglL-1Ed.js → nv-breadcrumbs.entry-DJXqtmMR.js} +1 -2
- package/dist/cjs/{nv-button.entry-BbT0aeQI.js → nv-button.entry-CF5IDcG3.js} +7 -8
- package/dist/cjs/{nv-buttongroup.entry-wlJma4qm.js → nv-buttongroup.entry-C0Zc2lOi.js} +1 -2
- package/dist/cjs/{nv-calendar.entry-wIPDRk0B.js → nv-calendar.entry-NbVLStMN.js} +7 -8
- package/dist/cjs/{nv-col.entry-Btsenp2c.js → nv-col.entry-ahFf8a1Z.js} +1 -2
- package/dist/cjs/{nv-datagrid.entry-Dae8YlRu.js → nv-datagrid.entry-C-MJXEdi.js} +6 -7
- package/dist/cjs/{nv-datagridcolumn.entry-D918Vo_U.js → nv-datagridcolumn.entry-CxU7soW7.js} +1 -2
- package/dist/cjs/{nv-dialog.entry--cGTlgDZ.js → nv-dialog.entry-WlnaC-w2.js} +3 -4
- package/dist/cjs/{nv-dialogfooter_2.entry-CXYjGHc5.js → nv-dialogfooter_2.entry-CEWmTnJc.js} +4 -5
- package/dist/cjs/{nv-fieldcheckbox.entry-9b_kDQGz.js → nv-fieldcheckbox.entry-BYhFVrYb.js} +2 -3
- package/dist/cjs/{nv-fielddate.entry-CRRTthds.js → nv-fielddate.entry-DVVnRiOT.js} +1 -2
- package/dist/cjs/{nv-fielddaterange.entry-BAVePsLs.js → nv-fielddaterange.entry-Cb4X5Q-C.js} +1 -2
- package/dist/cjs/{nv-fielddropdown.entry-Dy8sZyze.js → nv-fielddropdown.entry-D2PKGkpx.js} +1 -2
- package/dist/cjs/{nv-fielddropdownitem.entry-CuPocgsF.js → nv-fielddropdownitem.entry-BqgMRnIc.js} +1 -2
- package/dist/cjs/{nv-fieldmultiselect.entry-HWSDowQH.js → nv-fieldmultiselect.entry-Dzw4c9wO.js} +1 -2
- package/dist/cjs/{nv-fieldnumber.entry-fObgOYJX.js → nv-fieldnumber.entry-Cm5g6tw7.js} +1 -2
- package/dist/cjs/{nv-fieldpassword.entry-BRhKH_Mb.js → nv-fieldpassword.entry-BMI5M4RR.js} +1 -2
- package/dist/cjs/{nv-fieldradio.entry-D74Mlgjc.js → nv-fieldradio.entry-BrCJvkMR.js} +1 -2
- package/dist/cjs/{nv-fieldselect.entry-BS81ItZs.js → nv-fieldselect.entry-Cz76Y4Fb.js} +1 -2
- package/dist/cjs/{nv-fieldslider.entry-xyqrZxYj.js → nv-fieldslider.entry-C2ynnMK8.js} +1 -2
- package/dist/cjs/{nv-fieldtext.entry-BVUKbv4b.js → nv-fieldtext.entry-B6ciu2fU.js} +1 -2
- package/dist/cjs/{nv-fieldtextarea.entry-B7hb1so-.js → nv-fieldtextarea.entry-BL_gMvTp.js} +1 -2
- package/dist/cjs/{nv-fieldtime.entry-DvCbKaOO.js → nv-fieldtime.entry-Be5fujXA.js} +60 -61
- package/dist/cjs/{nv-icon.entry-DP715dyH.js → nv-icon.entry-C-wbfOy3.js} +8 -9
- package/dist/cjs/{nv-iconbutton_2.entry-FpzwxZe_.js → nv-iconbutton_2.entry-Dlk96yHi.js} +1 -2
- package/dist/cjs/{nv-menu.entry-ryMNpTHW.js → nv-menu.entry-CDn1Tk9J.js} +1 -2
- package/dist/cjs/{nv-menuitem.entry-SQBrWIYf.js → nv-menuitem.entry-DIkQnha9.js} +1 -2
- package/dist/cjs/nv-notification.entry-BiwnZCkF.js +178 -0
- package/dist/cjs/{nv-popover.entry-DOu6rhco.js → nv-popover.entry-Bz9ZWGlN.js} +6 -7
- package/dist/cjs/{nv-row.entry-Tx_yvWTJ.js → nv-row.entry-iJGXINmZ.js} +2 -3
- package/dist/cjs/{nv-stack.entry-Cn0JrM2N.js → nv-stack.entry-CifEjR2g.js} +2 -3
- package/dist/cjs/{nv-table.entry-D-uKGKnp.js → nv-table.entry-Dxg0j3fe.js} +3 -4
- package/dist/cjs/{nv-tablecolumn.entry-BsJzXKCk.js → nv-tablecolumn.entry--29MFEe9.js} +1 -2
- package/dist/cjs/{nv-toggle.entry-DuDRh-Ww.js → nv-toggle.entry-D0eQoEqf.js} +4 -5
- package/dist/cjs/{nv-togglebutton.entry-DAlky3tO.js → nv-togglebutton.entry-X4eLeP-C.js} +2 -3
- package/dist/cjs/{nv-togglebuttongroup.entry-DTadjqMQ.js → nv-togglebuttongroup.entry-BYO58vql.js} +2 -3
- package/dist/cjs/{nv-tooltip.entry-BWzlP6gC.js → nv-tooltip.entry-DaxjQSt1.js} +2 -3
- package/dist/generated/components.js +0 -8
- package/dist/generated/components.server.js +1 -8
- package/dist/index.js +0 -1
- package/dist/types/generated/components.d.ts +0 -3
- package/dist/types/generated/components.server.d.ts +0 -3
- package/dist/types/index.d.ts +0 -1
- package/package.json +1 -4
- package/dist/cjs/nv-notification.entry-DnCew-lG.js +0 -262
- package/dist/cjs/nv-notificationcontainer.entry-Dwlv9s1v.js +0 -41
- package/dist/providers/NotificationProvider.js +0 -83
- package/dist/types/providers/NotificationProvider.d.ts +0 -36
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var index = require('./index-CJDePE8Z.js');
|
|
4
|
-
var constants69bafca2 = require('./constants-69bafca2-DpB_ghPF.js');
|
|
5
|
-
var collapse_animation6e0b08df = require('./collapse.animation-6e0b08df-AHWzNGm_.js');
|
|
6
|
-
var fade_animation9b939939 = require('./fade.animation-9b939939-DV--bM4S.js');
|
|
7
|
-
var styleValueTypes_esF5d10b79 = require('./style-value-types.es-f5d10b79-D0QCM8OB.js');
|
|
8
|
-
var timeline_animation79215cd4 = require('./timeline.animation-79215cd4-KteJaZPb.js');
|
|
9
|
-
var v4A79185f4 = require('./v4-a79185f4-2n0dOd_Y.js');
|
|
10
|
-
require('react');
|
|
11
|
-
require('react-dom');
|
|
12
|
-
|
|
13
|
-
const useSlide = (node, { duration } = { duration: 200 }) => {
|
|
14
|
-
const nodeStyler = fade_animation9b939939.index(node);
|
|
15
|
-
/**
|
|
16
|
-
* Will animate the translateX property.
|
|
17
|
-
*
|
|
18
|
-
* @param {object} options - The options for the animation.
|
|
19
|
-
* @param {number} options.from - The starting value for the translateX property.
|
|
20
|
-
* @param {number} options.to - The ending value for the translateX property.
|
|
21
|
-
* @returns {Promise<void>} - A promise that resolves when the animation is
|
|
22
|
-
* complete.
|
|
23
|
-
*/
|
|
24
|
-
const slideX = (options = { from: 0, to: 100 }) => () => {
|
|
25
|
-
return new Promise(resolve => {
|
|
26
|
-
styleValueTypes_esF5d10b79.animate({
|
|
27
|
-
from: { x: options.from },
|
|
28
|
-
to: { x: options.to },
|
|
29
|
-
ease: styleValueTypes_esF5d10b79.easeOut,
|
|
30
|
-
duration,
|
|
31
|
-
onUpdate(latest) {
|
|
32
|
-
nodeStyler.set({ transform: `translateX(${latest.x}%)` });
|
|
33
|
-
},
|
|
34
|
-
onComplete() {
|
|
35
|
-
resolve();
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Will animate the translateY property.
|
|
42
|
-
*
|
|
43
|
-
* @param {object} options - The options for the animation.
|
|
44
|
-
* @param {number} options.from - The starting value for the translateY property.
|
|
45
|
-
* @param {number} options.to - The ending value for the translateY property.
|
|
46
|
-
* @returns {Promise<void>} - A promise that resolves when the animation is
|
|
47
|
-
* complete.
|
|
48
|
-
*/
|
|
49
|
-
const slideY = (options = { from: 0, to: 100 }) => () => {
|
|
50
|
-
return new Promise(resolve => {
|
|
51
|
-
styleValueTypes_esF5d10b79.animate({
|
|
52
|
-
from: { y: options.from },
|
|
53
|
-
to: { y: options.to },
|
|
54
|
-
ease: styleValueTypes_esF5d10b79.easeOut,
|
|
55
|
-
duration,
|
|
56
|
-
onUpdate(latest) {
|
|
57
|
-
nodeStyler.set({ transform: `translateY(${latest.y}%)` });
|
|
58
|
-
},
|
|
59
|
-
onComplete() {
|
|
60
|
-
resolve();
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Applies the slideX styles without animating, useful when initial state
|
|
67
|
-
* is slid out.
|
|
68
|
-
*
|
|
69
|
-
* @param {number} amount - The amount to translate the element by.
|
|
70
|
-
* @returns {function} - A function that applies the slideX styles.
|
|
71
|
-
*/
|
|
72
|
-
const setSlideX = (amount = 100) => nodeStyler.set({ transform: `translateX(${amount}%)` });
|
|
73
|
-
/**
|
|
74
|
-
* Applies the slideY styles without animating, useful when initial state
|
|
75
|
-
* is slid out.
|
|
76
|
-
*
|
|
77
|
-
* @param {number} amount - The amount to translate the element by.
|
|
78
|
-
* @returns {function} - A function that applies the slideY styles.
|
|
79
|
-
*/
|
|
80
|
-
const setSlideY = (amount = 100) => nodeStyler.set({ transform: `translateY(${amount}%)` });
|
|
81
|
-
/**
|
|
82
|
-
* Applies the slideIn styles without animating, useful when initial state
|
|
83
|
-
* is slid in.
|
|
84
|
-
*/
|
|
85
|
-
function setSlideReset() {
|
|
86
|
-
nodeStyler.set({ transform: `translateX(${0}%) translateY(${0}%)` });
|
|
87
|
-
}
|
|
88
|
-
return {
|
|
89
|
-
slideX,
|
|
90
|
-
slideY,
|
|
91
|
-
setSlideX,
|
|
92
|
-
setSlideY,
|
|
93
|
-
setSlideReset,
|
|
94
|
-
};
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const nvNotificationCss = "nv-notification{display:block}nv-notification [data-scope=container]{display:flex;position:relative;max-width:512px;width:100%;padding:var(--notification-padding);align-items:flex-start;gap:var(--notification-gap-x);border-radius:var(--notification-radius);border-style:solid;box-shadow:0 var(--shadow-y-axis-lg-1, 4px) var(--shadow-blur-lg-1, 6px) var(--shadow-spread-lg-1, -2px) var(--shadow-color-opacity-1, rgba(14, 14, 14, 0.06)), 0 var(--shadow-y-axis-lg-2, 10px) var(--shadow-blur-lg-2, 15px) var(--shadow-spread-lg-2, -3px) var(--shadow-color-opacity-2, rgba(14, 14, 14, 0.1))}nv-notification [data-scope=container] [data-scope=icon]{flex-shrink:0}nv-notification [data-scope=container] [data-scope=dismiss]{padding:var(--button-sm-icon-button-padding, 8px);justify-content:center;align-items:center;gap:var(--button-sm-gap, 6px);display:flex;position:absolute;right:8px;top:8px;border-radius:var(--button-sm-border-radius, 4px);background:var(--components-button-lower-background, rgba(255, 255, 255, 0));color:var(--components-button-lower-icon)}nv-notification [data-scope=container] [data-scope=content]{display:flex;padding-right:var(--notification-padding-right);flex-direction:column;align-items:flex-start;gap:var(--notification-gap-y);flex:1 0 0}nv-notification [data-scope=container] [data-scope=content] [data-scope=heading]{display:flex;align-items:flex-start;gap:var(--notification-gap-x);align-self:stretch;color:var(--components-notification-content-title);font-size:var(--notification-title-font-size);font-style:normal;font-weight:500;line-height:20px;}nv-notification [data-scope=container] [data-scope=content] [data-scope=message]{display:flex;flex-direction:column;align-items:flex-start;gap:var(--notification-gap-y);align-self:stretch;color:var(--components-notification-content-description);font-variant-numeric:lining-nums tabular-nums slashed-zero;font-size:var(--font-size-sm, 14px);font-style:normal;font-weight:400;line-height:var(--line-height-sm, 20px)}nv-notification [data-scope=container] [data-scope=content] [data-scope=actions]{display:flex;padding:var(--spacing-2, 8px) 0;padding-bottom:0px;align-items:flex-start;gap:var(--notification-gap-x);align-self:stretch;margin-left:calc(-1 * var(--button-sm-padding-x))}nv-notification[feedback=information] [data-scope=container]{background-color:var(--components-notification-information-background);border-color:var(--components-notification-information-border)}nv-notification[feedback=information] [data-scope=container] [data-scope=icon]{color:var(--components-notification-information-icon)}nv-notification[feedback=information]>[data-scope=close]:focus,nv-notification[feedback=information]>[data-scope=close]:focus-within{outline:none}nv-notification[feedback=information]>[data-scope=close]:focus-visible,nv-notification[feedback=information]>[data-scope=close]:has(:focus-visible){outline:calc(var(--focus-outline-stroke) * 1) solid var(--components-notification-information-border);outline-offset:calc(var(--focus-outline-offset) * 1)}nv-notification[feedback=warning] [data-scope=container]{background-color:var(--components-notification-warning-background);border-color:var(--components-notification-warning-border)}nv-notification[feedback=warning] [data-scope=container] [data-scope=icon]{color:var(--components-notification-warning-icon)}nv-notification[feedback=warning]>[data-scope=close]:focus,nv-notification[feedback=warning]>[data-scope=close]:focus-within{outline:none}nv-notification[feedback=warning]>[data-scope=close]:focus-visible,nv-notification[feedback=warning]>[data-scope=close]:has(:focus-visible){outline:calc(var(--focus-outline-stroke) * 1) solid var(--components-notification-warning-border);outline-offset:calc(var(--focus-outline-offset) * 1)}nv-notification[feedback=error] [data-scope=container]{background-color:var(--components-notification-error-background);border-color:var(--components-notification-error-border)}nv-notification[feedback=error] [data-scope=container] [data-scope=icon]{color:var(--components-notification-error-icon)}nv-notification[feedback=error]>[data-scope=close]:focus,nv-notification[feedback=error]>[data-scope=close]:focus-within{outline:none}nv-notification[feedback=error]>[data-scope=close]:focus-visible,nv-notification[feedback=error]>[data-scope=close]:has(:focus-visible){outline:calc(var(--focus-outline-stroke) * 1) solid var(--components-notification-error-border);outline-offset:calc(var(--focus-outline-offset) * 1)}nv-notification[feedback=success] [data-scope=container]{background-color:var(--components-notification-success-background);border-color:var(--components-notification-success-border)}nv-notification[feedback=success] [data-scope=container] [data-scope=icon]{color:var(--components-notification-success-icon)}nv-notification[feedback=success]>[data-scope=close]:focus,nv-notification[feedback=success]>[data-scope=close]:focus-within{outline:none}nv-notification[feedback=success]>[data-scope=close]:focus-visible,nv-notification[feedback=success]>[data-scope=close]:has(:focus-visible){outline:calc(var(--focus-outline-stroke) * 1) solid var(--components-notification-success-border);outline-offset:calc(var(--focus-outline-offset) * 1)}nv-notification[feedback=neutral] [data-scope=container]{background-color:var(--components-notification-neutral-background);border-color:var(--components-notification-neutral-border)}nv-notification[feedback=neutral] [data-scope=container] [data-scope=icon]{color:var(--components-notification-neutral-icon)}nv-notification[feedback=neutral]>[data-scope=close]:focus,nv-notification[feedback=neutral]>[data-scope=close]:focus-within{outline:none}nv-notification[feedback=neutral]>[data-scope=close]:focus-visible,nv-notification[feedback=neutral]>[data-scope=close]:has(:focus-visible){outline:calc(var(--focus-outline-stroke) * 1) solid var(--components-notification-neutral-border);outline-offset:calc(var(--focus-outline-offset) * 1)}nv-notification[emphasis=high] [data-scope=container]{border-width:1px;border-left-width:var(--notification-border-width-high-emphasis);padding-left:calc(var(--notification-padding) - var(--notification-border-width-high-emphasis) + 1px)}nv-notification[emphasis=medium] [data-scope=container]{border-width:var(--notification-border-width-low-emphasis);border-color:var(--color-content-low-border, #E3E3E3)}";
|
|
98
|
-
const NvNotificationStyle0 = nvNotificationCss;
|
|
99
|
-
|
|
100
|
-
const NvNotification = class {
|
|
101
|
-
constructor(hostRef) {
|
|
102
|
-
index.registerInstance(this, hostRef);
|
|
103
|
-
this.hiddenChanged = index.createEvent(this, "hiddenChanged");
|
|
104
|
-
/****************************************************************************/
|
|
105
|
-
//#region PROPERTIES
|
|
106
|
-
/**
|
|
107
|
-
* Set a unique ID for the notification. Used for aria attributes and managing
|
|
108
|
-
* multiple notifications.
|
|
109
|
-
*/
|
|
110
|
-
this.uid = v4A79185f4.v4();
|
|
111
|
-
/**
|
|
112
|
-
* Specifies the notification type which determines the color and default icon.
|
|
113
|
-
*/
|
|
114
|
-
this.feedback = 'information';
|
|
115
|
-
/**
|
|
116
|
-
* Adjusts the emphasis to make the notification more or less visually
|
|
117
|
-
* prominent to users. Use this to draw attention to important actions or
|
|
118
|
-
* reduce focus on less critical ones
|
|
119
|
-
*/
|
|
120
|
-
this.emphasis = 'medium';
|
|
121
|
-
/**
|
|
122
|
-
* Allows the notification to be dismissed via a close button (x). The
|
|
123
|
-
* notification is not dismissible unless explicitly enabled.
|
|
124
|
-
*/
|
|
125
|
-
this.dismissible = false;
|
|
126
|
-
/**
|
|
127
|
-
* Controls the visibility of the notification.
|
|
128
|
-
*/
|
|
129
|
-
this.hidden = false; // eslint-disable-line @stencil-community/reserved-member-names
|
|
130
|
-
/**
|
|
131
|
-
* When true, the notification will be hidden initially, but internal changes
|
|
132
|
-
* will not be in a controlled state. Good for animating the notification in.
|
|
133
|
-
*/
|
|
134
|
-
this.initiallyHidden = false;
|
|
135
|
-
//#endregion EVENTS
|
|
136
|
-
/****************************************************************************/
|
|
137
|
-
//#region INTERNAL
|
|
138
|
-
this.iconByFeedback = {
|
|
139
|
-
[constants69bafca2.FeedbackColors.Warning]: 'alert-circle',
|
|
140
|
-
[constants69bafca2.FeedbackColors.Information]: 'info-circle',
|
|
141
|
-
[constants69bafca2.FeedbackColors.Success]: 'circle-check',
|
|
142
|
-
[constants69bafca2.FeedbackColors.Error]: 'alert-triangle',
|
|
143
|
-
[constants69bafca2.FeedbackColors.Neutral]: 'help',
|
|
144
|
-
};
|
|
145
|
-
this.roleByFeedback = {
|
|
146
|
-
[constants69bafca2.FeedbackColors.Error]: 'alert',
|
|
147
|
-
[constants69bafca2.FeedbackColors.Warning]: 'alert',
|
|
148
|
-
[constants69bafca2.FeedbackColors.Information]: 'status',
|
|
149
|
-
[constants69bafca2.FeedbackColors.Success]: 'status',
|
|
150
|
-
[constants69bafca2.FeedbackColors.Neutral]: 'status',
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
//#endregion PROPERTIES
|
|
154
|
-
/****************************************************************************/
|
|
155
|
-
//#region METHODS
|
|
156
|
-
/**
|
|
157
|
-
* Dismisses the notification with an animation, after the animation is
|
|
158
|
-
* complete, the hiddenChanged event will be emitted with the value of true,
|
|
159
|
-
* and the hidden prop will be set to true.
|
|
160
|
-
*/
|
|
161
|
-
async dismiss() {
|
|
162
|
-
await this.dismissAnimation();
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Sets the hidden prop to false, and shows the notification with an
|
|
166
|
-
* animation, after the animation is complete, the hiddenChanged event will be
|
|
167
|
-
* emitted with the value of false.
|
|
168
|
-
*/
|
|
169
|
-
async show() {
|
|
170
|
-
await this.showAnimation();
|
|
171
|
-
}
|
|
172
|
-
getDefaultIcon() {
|
|
173
|
-
var _a;
|
|
174
|
-
return (_a = this.iconByFeedback[this.feedback]) !== null && _a !== void 0 ? _a : 'info-circle';
|
|
175
|
-
}
|
|
176
|
-
getAriaRole() {
|
|
177
|
-
var _a;
|
|
178
|
-
return (_a = this.roleByFeedback[this.feedback]) !== null && _a !== void 0 ? _a : 'status';
|
|
179
|
-
}
|
|
180
|
-
getAriaLive() {
|
|
181
|
-
return this.getAriaRole() === 'alert' ? 'assertive' : 'polite';
|
|
182
|
-
}
|
|
183
|
-
getHeadingId() {
|
|
184
|
-
return this.heading ? `nv-notification-${this.uid}-heading` : null;
|
|
185
|
-
}
|
|
186
|
-
getMessageId() {
|
|
187
|
-
return this.message ? `nv-notification-${this.uid}-message` : null;
|
|
188
|
-
}
|
|
189
|
-
async showAnimation() {
|
|
190
|
-
this.hidden = false;
|
|
191
|
-
const { setFadeIn } = fade_animation9b939939.useFade(this.container);
|
|
192
|
-
const { expand } = collapse_animation6e0b08df.useCollapse(this.el, {
|
|
193
|
-
duration: 300,
|
|
194
|
-
overflow: 'visible',
|
|
195
|
-
});
|
|
196
|
-
const { slideY, setSlideY } = useSlide(this.container, {
|
|
197
|
-
duration: 300,
|
|
198
|
-
});
|
|
199
|
-
setSlideY(-100);
|
|
200
|
-
setFadeIn();
|
|
201
|
-
await timeline_animation79215cd4.parallel(slideY({ from: -100, to: 0 }), expand).start();
|
|
202
|
-
this.hiddenChanged.emit(false);
|
|
203
|
-
}
|
|
204
|
-
getSlideDestination(pos) {
|
|
205
|
-
switch (pos) {
|
|
206
|
-
case constants69bafca2.NotificationPosition.TopRight:
|
|
207
|
-
case constants69bafca2.NotificationPosition.BottomRight:
|
|
208
|
-
return { axis: 'x', to: 100 }; // right
|
|
209
|
-
case constants69bafca2.NotificationPosition.TopLeft:
|
|
210
|
-
case constants69bafca2.NotificationPosition.BottomLeft:
|
|
211
|
-
return { axis: 'x', to: -100 }; // left
|
|
212
|
-
case constants69bafca2.NotificationPosition.TopCenter:
|
|
213
|
-
return { axis: 'y', to: -100 }; // up
|
|
214
|
-
case constants69bafca2.NotificationPosition.BottomCenter:
|
|
215
|
-
return { axis: 'y', to: 100 }; // down
|
|
216
|
-
default:
|
|
217
|
-
return { axis: 'x', to: 100 }; // fallback
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
async dismissAnimation() {
|
|
221
|
-
var _a;
|
|
222
|
-
const position = (_a = this.el
|
|
223
|
-
.closest('nv-notificationcontainer')) === null || _a === void 0 ? void 0 : _a.getAttribute('position');
|
|
224
|
-
const destination = this.getSlideDestination(position);
|
|
225
|
-
const { fadeOut } = fade_animation9b939939.useFade(this.container, { duration: 300 });
|
|
226
|
-
const { slideX, slideY, setSlideReset } = useSlide(this.container, {
|
|
227
|
-
duration: 500,
|
|
228
|
-
});
|
|
229
|
-
const { collapse } = collapse_animation6e0b08df.useCollapse(this.el, {
|
|
230
|
-
duration: 500,
|
|
231
|
-
overflow: 'visible',
|
|
232
|
-
});
|
|
233
|
-
const slide = destination.axis === 'x'
|
|
234
|
-
? slideX({ from: 0, to: destination.to })
|
|
235
|
-
: slideY({ from: 0, to: destination.to });
|
|
236
|
-
setSlideReset();
|
|
237
|
-
await timeline_animation79215cd4.parallel(fadeOut, slide, collapse).start();
|
|
238
|
-
this.hidden = true;
|
|
239
|
-
this.hiddenChanged.emit(true);
|
|
240
|
-
}
|
|
241
|
-
//#endregion INTERNAL
|
|
242
|
-
/****************************************************************************/
|
|
243
|
-
//#region LIFECYCLE
|
|
244
|
-
componentWillLoad() {
|
|
245
|
-
this.headingSlot = this.el.querySelector('[slot="heading"]');
|
|
246
|
-
this.messageSlot = this.el.querySelector('[slot="content"]');
|
|
247
|
-
this.actionsSlot = this.el.querySelector('[slot="actions"]');
|
|
248
|
-
if (this.initiallyHidden)
|
|
249
|
-
this.hidden = true;
|
|
250
|
-
}
|
|
251
|
-
//#endregion LIFECYCLE
|
|
252
|
-
/****************************************************************************/
|
|
253
|
-
//#region RENDER
|
|
254
|
-
render() {
|
|
255
|
-
var _a, _b, _c;
|
|
256
|
-
return (index.h(index.Host, { key: '6e0b8abd9cbcb62b0b133db77520aa5aaa4173c9', role: this.getAriaRole(), "aria-live": this.getAriaLive(), "aria-atomic": true, "aria-labelledby": (_a = this.getHeadingId()) !== null && _a !== void 0 ? _a : null, "aria-describedby": (_b = this.getMessageId()) !== null && _b !== void 0 ? _b : null, tabindex: "-1" }, index.h("div", { key: '41b2ad35bf5220333e132d61f8843d1136cb1f40', "data-scope": "container", ref: el => (this.container = el) }, this.dismissible && (index.h("button", { key: '63116f239f7108ae945845c247c712827d8ae8a6', "data-scope": "dismiss", type: "button", onClick: this.dismiss.bind(this) }, index.h("nv-icon", { key: 'dc19bf166c6d2eccd3d40384d43206457f0d03f0', name: "x", size: "sm" }))), index.h("nv-icon", { key: 'e673ac1cc78300bc3425018a0cdfc4b90c679796', name: (_c = this.icon) !== null && _c !== void 0 ? _c : this.getDefaultIcon(), size: "md", "data-scope": "icon" }), index.h("div", { key: '95cb6ec06d89cda8e5170f9ff0f863b6b0b7e32d', "data-scope": "content" }, (this.heading || this.headingSlot) && (index.h("p", { key: 'ed654c0271d2ff8538295d8f7bf58a9754abb4c9', id: this.getHeadingId(), "data-scope": "heading" }, index.h("slot", { key: '00cc14a709059b9caf2117174ef7fcc310f5965f', name: "heading" }, this.heading))), (this.message || this.messageSlot) && (index.h("p", { key: 'c7c0bcbc2b54fdfdf8280af6a377929bf17fd688', id: this.getMessageId(), "data-scope": "message" }, index.h("slot", { key: '946db5aeb667b67f52f51adbb1b8f600325f937e', name: "content" }, this.message))), this.actionsSlot && (index.h("div", { key: 'd94560b658507a515a1360057121e933b95e6fe6', "data-scope": "actions" }, index.h("slot", { key: 'db185d3924c7d1fbeb30578992f2375e92a0d4bc', name: "actions" })))))));
|
|
257
|
-
}
|
|
258
|
-
get el() { return index.getElement(this); }
|
|
259
|
-
};
|
|
260
|
-
NvNotification.style = NvNotificationStyle0;
|
|
261
|
-
|
|
262
|
-
exports.nv_notification = NvNotification;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var index = require('./index-CJDePE8Z.js');
|
|
4
|
-
require('react');
|
|
5
|
-
require('react-dom');
|
|
6
|
-
|
|
7
|
-
const nvNotificationcontainerCss = "nv-notificationcontainer{position:fixed;display:flex;flex-direction:column;padding:var(--spacing-2);padding-top:0;z-index:9999;pointer-events:none;width:100%;max-width:512px}nv-notificationcontainer.position-top-right{top:0;right:0}nv-notificationcontainer.position-top-right nv-notification{margin-top:var(--spacing-2)}nv-notificationcontainer.position-top-left{top:0;left:0}nv-notificationcontainer.position-top-left nv-notification{margin-bottom:var(--spacing-2)}nv-notificationcontainer.position-top-center{top:0;left:50%;transform:translateX(-50%)}nv-notificationcontainer.position-top-center nv-notification{margin-bottom:var(--spacing-2)}nv-notificationcontainer.position-bottom-right{bottom:0;right:0;flex-direction:column-reverse}nv-notificationcontainer.position-bottom-right nv-notification{margin-top:var(--spacing-2)}nv-notificationcontainer.position-bottom-left{bottom:0;left:0;flex-direction:column-reverse}nv-notificationcontainer.position-bottom-left nv-notification{margin-top:var(--spacing-2)}nv-notificationcontainer.position-bottom-center{bottom:0;left:50%;transform:translateX(-50%);flex-direction:column-reverse}nv-notificationcontainer.position-bottom-center nv-notification{margin-top:var(--spacing-2)}nv-notificationcontainer>*{pointer-events:auto}";
|
|
8
|
-
const NvNotificationcontainerStyle0 = nvNotificationcontainerCss;
|
|
9
|
-
|
|
10
|
-
const NvNotificationContainer = class {
|
|
11
|
-
constructor(hostRef) {
|
|
12
|
-
index.registerInstance(this, hostRef);
|
|
13
|
-
/****************************************************************************/
|
|
14
|
-
//#region PROPERTIES
|
|
15
|
-
/**
|
|
16
|
-
* Position of the notification container on the screen.
|
|
17
|
-
*/
|
|
18
|
-
this.position = 'top-right';
|
|
19
|
-
}
|
|
20
|
-
//#endregion PROPERTIES
|
|
21
|
-
/****************************************************************************/
|
|
22
|
-
//#region METHODS
|
|
23
|
-
//#endregion METHODS
|
|
24
|
-
/****************************************************************************/
|
|
25
|
-
//#region WATCHERS
|
|
26
|
-
//#endregion WATCHERS
|
|
27
|
-
/****************************************************************************/
|
|
28
|
-
//#region LIFECYCLE
|
|
29
|
-
//#endregion LIFECYCLE
|
|
30
|
-
/****************************************************************************/
|
|
31
|
-
//#region EVENTS
|
|
32
|
-
//#endregion EVENTS
|
|
33
|
-
/****************************************************************************/
|
|
34
|
-
//#region RENDER
|
|
35
|
-
render() {
|
|
36
|
-
return (index.h(index.Host, { key: 'db4005459b926bcfef55e76f61bff0b5635f2872', class: `position-${this.position}` }, index.h("slot", { key: '518909541ca3e9e82168436a43d5362c414c0ec3' })));
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
NvNotificationContainer.style = NvNotificationcontainerStyle0;
|
|
40
|
-
|
|
41
|
-
exports.nv_notificationcontainer = NvNotificationContainer;
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import React, { createContext, useContext, useState, useCallback, createRef, useEffect, useRef, } from 'react';
|
|
2
|
-
import { createPortal } from 'react-dom';
|
|
3
|
-
import { NvNotificationcontainer, NvNotification, NvButton, } from '../generated/components';
|
|
4
|
-
const NotificationContext = createContext(null);
|
|
5
|
-
const DEFAULT_POSITION = 'top-right';
|
|
6
|
-
const DEFAULT_MAX_NOTIFICATIONS = 50;
|
|
7
|
-
const generateId = () => {
|
|
8
|
-
return `notification-${Date.now()}-${Math.random()
|
|
9
|
-
.toString(36)
|
|
10
|
-
.substr(2, 9)}`;
|
|
11
|
-
};
|
|
12
|
-
export const NotificationProvider = ({ children, position = DEFAULT_POSITION, maxNotifications = DEFAULT_MAX_NOTIFICATIONS, className, }) => {
|
|
13
|
-
const [notifications, setNotifications] = useState([]);
|
|
14
|
-
const notificationsRef = useRef([]);
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
notificationsRef.current = notifications;
|
|
17
|
-
}, [notifications]);
|
|
18
|
-
const show = useCallback((options) => {
|
|
19
|
-
const id = options.id || generateId();
|
|
20
|
-
const ref = createRef();
|
|
21
|
-
const notification = {
|
|
22
|
-
id,
|
|
23
|
-
heading: options.heading,
|
|
24
|
-
message: options.message,
|
|
25
|
-
dismissible: options.dismissible ?? true,
|
|
26
|
-
emphasis: options.emphasis ?? 'medium',
|
|
27
|
-
feedback: options.feedback ?? 'information',
|
|
28
|
-
icon: options.icon,
|
|
29
|
-
actions: options.actions ?? [],
|
|
30
|
-
actionSlot: options.actionSlot,
|
|
31
|
-
createdAt: Date.now(),
|
|
32
|
-
ref,
|
|
33
|
-
};
|
|
34
|
-
setNotifications((prev) => {
|
|
35
|
-
const newNotifications = [notification, ...prev];
|
|
36
|
-
if (newNotifications.length > maxNotifications) {
|
|
37
|
-
return newNotifications.slice(0, maxNotifications);
|
|
38
|
-
}
|
|
39
|
-
return newNotifications;
|
|
40
|
-
});
|
|
41
|
-
setTimeout(() => {
|
|
42
|
-
notification.ref.current?.show();
|
|
43
|
-
}, 0);
|
|
44
|
-
return id;
|
|
45
|
-
}, [maxNotifications]);
|
|
46
|
-
const dismiss = useCallback((id) => {
|
|
47
|
-
const n = notificationsRef.current.find((item) => item.id === id);
|
|
48
|
-
n?.ref.current?.dismiss();
|
|
49
|
-
}, []);
|
|
50
|
-
const remove = useCallback((id) => {
|
|
51
|
-
setNotifications((prev) => prev.filter((notification) => notification.id !== id));
|
|
52
|
-
}, []);
|
|
53
|
-
const removeAll = useCallback(() => {
|
|
54
|
-
setNotifications([]);
|
|
55
|
-
}, []);
|
|
56
|
-
const handleNotificationClose = useCallback((id) => {
|
|
57
|
-
remove(id);
|
|
58
|
-
}, [remove]);
|
|
59
|
-
const contextValue = {
|
|
60
|
-
notifications,
|
|
61
|
-
show,
|
|
62
|
-
dismiss,
|
|
63
|
-
remove,
|
|
64
|
-
removeAll,
|
|
65
|
-
};
|
|
66
|
-
return (React.createElement(NotificationContext.Provider, { value: contextValue },
|
|
67
|
-
children,
|
|
68
|
-
createPortal(React.createElement(NvNotificationcontainer, { position: position, className: className, "data-testid": "notification-container" }, notifications.map((notification) => (React.createElement(NvNotification, { key: notification.id, heading: notification.heading, message: notification.message, dismissible: notification.dismissible, emphasis: notification.emphasis, feedback: notification.feedback, icon: notification.icon, onHiddenChanged: (event) => {
|
|
69
|
-
if (event.detail) {
|
|
70
|
-
handleNotificationClose(notification.id);
|
|
71
|
-
}
|
|
72
|
-
}, initiallyHidden: true, ref: notification.ref }, (Boolean(notification.actionSlot) ||
|
|
73
|
-
Boolean(notification.actions.length)) && (React.createElement("div", { slot: "actions" },
|
|
74
|
-
notification.actions.map((action) => (React.createElement(NvButton, { key: action.label, emphasis: "low", size: "md", onClick: action.onClick }, action.label))),
|
|
75
|
-
notification.actionSlot)))))), document.body)));
|
|
76
|
-
};
|
|
77
|
-
export const useNotifications = () => {
|
|
78
|
-
const context = useContext(NotificationContext);
|
|
79
|
-
if (!context) {
|
|
80
|
-
throw new Error('useNotifications must be used within a NotificationProvider');
|
|
81
|
-
}
|
|
82
|
-
return context;
|
|
83
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from 'react';
|
|
2
|
-
import { type NotificationPosition, type NotificationEmphasis, FeedbackColors } from '../index';
|
|
3
|
-
export interface NotificationAction {
|
|
4
|
-
label: string;
|
|
5
|
-
onClick: () => void;
|
|
6
|
-
}
|
|
7
|
-
export interface NotificationOptions {
|
|
8
|
-
id?: string;
|
|
9
|
-
heading?: string;
|
|
10
|
-
message?: string;
|
|
11
|
-
dismissible?: boolean;
|
|
12
|
-
emphasis?: `${NotificationEmphasis}`;
|
|
13
|
-
feedback?: `${FeedbackColors}`;
|
|
14
|
-
icon?: string;
|
|
15
|
-
actions?: NotificationAction[];
|
|
16
|
-
actionSlot?: React.ReactElement;
|
|
17
|
-
}
|
|
18
|
-
export interface Notification extends NotificationOptions {
|
|
19
|
-
createdAt: number;
|
|
20
|
-
ref: React.RefObject<HTMLNvNotificationElement>;
|
|
21
|
-
}
|
|
22
|
-
export interface NotificationContextValue {
|
|
23
|
-
notifications: Notification[];
|
|
24
|
-
show: (options: NotificationOptions) => string;
|
|
25
|
-
dismiss: (id: string) => void;
|
|
26
|
-
remove: (id: string) => void;
|
|
27
|
-
removeAll: () => void;
|
|
28
|
-
}
|
|
29
|
-
export interface NotificationProviderProps {
|
|
30
|
-
children: ReactNode;
|
|
31
|
-
position?: `${NotificationPosition}`;
|
|
32
|
-
maxNotifications?: number;
|
|
33
|
-
className?: string;
|
|
34
|
-
}
|
|
35
|
-
export declare const NotificationProvider: React.FC<NotificationProviderProps>;
|
|
36
|
-
export declare const useNotifications: () => NotificationContextValue;
|