@nova-design-system/nova-react 3.12.0 → 3.14.0-beta.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/README.md +27 -58
- package/dist/cjs/collapse.animation-6e0b08df-AHWzNGm_.js +217 -0
- package/dist/cjs/{constants-a857c476-Cj2b-su0.js → constants-69bafca2-DpB_ghPF.js} +14 -0
- package/dist/cjs/fade.animation-9b939939-DV--bM4S.js +724 -0
- package/dist/cjs/{index-jBgPO7HC.js → index-CJDePE8Z.js} +2322 -1657
- package/dist/cjs/index.js +14 -1
- package/dist/cjs/{nv-accordion-item.entry-BUb_Apy8.js → nv-accordion-item.entry-Begcz9SZ.js} +75 -40
- package/dist/cjs/nv-accordion.entry-DQAkheHY.js +179 -0
- package/dist/cjs/{nv-alert.entry-nzJu8E5h.js → nv-alert.entry-CEzR0iu0.js} +21 -20
- package/dist/cjs/{nv-avatar.entry-BPp1d-QO.js → nv-avatar.entry-B-u7r30l.js} +8 -7
- package/dist/cjs/{nv-badge_2.entry-Bk56p4jv.js → nv-badge_2.entry-0vhTS5D7.js} +15 -14
- package/dist/cjs/{nv-breadcrumb.entry-DB3zR7FC.js → nv-breadcrumb.entry-BkWs1x-W.js} +2 -1
- package/dist/cjs/{nv-breadcrumbs.entry-CoGgEsro.js → nv-breadcrumbs.entry-DglL-1Ed.js} +2 -1
- package/dist/cjs/{nv-button.entry-psZ3_t6i.js → nv-button.entry-BbT0aeQI.js} +8 -7
- package/dist/cjs/{nv-buttongroup.entry-cNenBx1F.js → nv-buttongroup.entry-wlJma4qm.js} +2 -1
- package/dist/cjs/{nv-calendar.entry-nkrORr_V.js → nv-calendar.entry-wIPDRk0B.js} +21 -16
- package/dist/cjs/{nv-col.entry-D4mInxLU.js → nv-col.entry-Btsenp2c.js} +2 -1
- package/dist/cjs/{nv-datagrid.entry-D50O7eyc.js → nv-datagrid.entry-Dae8YlRu.js} +7 -6
- package/dist/cjs/{nv-datagridcolumn.entry-BuGX-3ev.js → nv-datagridcolumn.entry-D918Vo_U.js} +2 -1
- package/dist/cjs/{nv-dialog.entry-yiZIq-TV.js → nv-dialog.entry--cGTlgDZ.js} +4 -3
- package/dist/cjs/{nv-dialogfooter_2.entry-C9ykJQK6.js → nv-dialogfooter_2.entry-CXYjGHc5.js} +11 -7
- package/dist/cjs/{nv-fieldcheckbox.entry-CCRvvFJ3.js → nv-fieldcheckbox.entry-9b_kDQGz.js} +3 -2
- package/dist/cjs/{nv-fielddate.entry-C4k6k980.js → nv-fielddate.entry-CRRTthds.js} +2 -1
- package/dist/cjs/{nv-fielddaterange.entry-BhfV2KCd.js → nv-fielddaterange.entry-BAVePsLs.js} +2 -1
- package/dist/cjs/{nv-fielddropdown.entry-Xkkvl_gb.js → nv-fielddropdown.entry-Dy8sZyze.js} +2 -1
- package/dist/cjs/{nv-fielddropdownitem.entry-Ckwq6k6r.js → nv-fielddropdownitem.entry-CuPocgsF.js} +2 -1
- package/dist/cjs/{nv-fieldmultiselect.entry-D4PgRSFv.js → nv-fieldmultiselect.entry-HWSDowQH.js} +2 -31
- package/dist/cjs/{nv-fieldnumber.entry-BEnJ81XX.js → nv-fieldnumber.entry-fObgOYJX.js} +3 -2
- package/dist/cjs/{nv-fieldpassword.entry-elzveqP8.js → nv-fieldpassword.entry-BRhKH_Mb.js} +2 -1
- package/dist/cjs/{nv-fieldradio.entry-xJpdsXGo.js → nv-fieldradio.entry-D74Mlgjc.js} +2 -1
- package/dist/cjs/{nv-fieldselect.entry-DVyO7LMD.js → nv-fieldselect.entry-BS81ItZs.js} +2 -1
- package/dist/cjs/{nv-fieldslider.entry-O4TFO-Rl.js → nv-fieldslider.entry-xyqrZxYj.js} +26 -17
- package/dist/cjs/{nv-fieldtext.entry-p-9GEp1g.js → nv-fieldtext.entry-BVUKbv4b.js} +2 -1
- package/dist/cjs/{nv-fieldtextarea.entry-Cvik8cci.js → nv-fieldtextarea.entry-B7hb1so-.js} +2 -1
- package/dist/cjs/{nv-fieldtime.entry-mnsDon9M.js → nv-fieldtime.entry-DvCbKaOO.js} +61 -60
- package/dist/cjs/nv-icon.entry-DP715dyH.js +80 -0
- package/dist/cjs/{nv-iconbutton_2.entry-M5EY3-1s.js → nv-iconbutton_2.entry-FpzwxZe_.js} +2 -1
- package/dist/cjs/{nv-menu.entry-D7bORqXp.js → nv-menu.entry-ryMNpTHW.js} +2 -1
- package/dist/cjs/{nv-menuitem.entry-CaN6qNoB.js → nv-menuitem.entry-SQBrWIYf.js} +2 -1
- package/dist/cjs/nv-notification.entry-DnCew-lG.js +262 -0
- package/dist/cjs/nv-notificationcontainer.entry-Dwlv9s1v.js +41 -0
- package/dist/cjs/{nv-popover.entry-DGeXSyhZ.js → nv-popover.entry-DOu6rhco.js} +10 -9
- package/dist/cjs/{nv-row.entry-B17DsCjM.js → nv-row.entry-Tx_yvWTJ.js} +3 -2
- package/dist/cjs/{nv-stack.entry-Dv3YU4nJ.js → nv-stack.entry-Cn0JrM2N.js} +3 -2
- package/dist/cjs/{nv-table.entry-BILyG-43.js → nv-table.entry-D-uKGKnp.js} +4 -3
- package/dist/cjs/{nv-tablecolumn.entry-II6Z_gdO.js → nv-tablecolumn.entry-BsJzXKCk.js} +2 -1
- package/dist/cjs/{nv-toggle.entry-5Wmww2Cd.js → nv-toggle.entry-DuDRh-Ww.js} +4 -3
- package/dist/cjs/{nv-togglebutton.entry-Dnmfrj0O.js → nv-togglebutton.entry-DAlky3tO.js} +3 -2
- package/dist/cjs/{nv-togglebuttongroup.entry-C9mplQcb.js → nv-togglebuttongroup.entry-DTadjqMQ.js} +3 -2
- package/dist/cjs/{nv-tooltip.entry-CcUQrjAv.js → nv-tooltip.entry-BWzlP6gC.js} +3 -2
- package/dist/cjs/{stylefire.es-74da334a-y0piPjlz.js → style-value-types.es-f5d10b79-D0QCM8OB.js} +50 -694
- package/dist/cjs/{timeline.animation-adf35ecb-CE6Dsdxr.js → timeline.animation-79215cd4-KteJaZPb.js} +19 -0
- package/dist/generated/components.js +16 -0
- package/dist/generated/components.server.js +25 -1
- package/dist/index.js +1 -0
- package/dist/providers/NotificationProvider.js +83 -0
- package/dist/types/generated/components.d.ts +8 -0
- package/dist/types/generated/components.server.d.ts +8 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/providers/NotificationProvider.d.ts +36 -0
- package/package.json +4 -1
- package/dist/cjs/collapse.animation-16e3af45-CChx_tQJ.js +0 -84
- package/dist/cjs/fade.animation-71e8e34c-BAw_TYsB.js +0 -68
- package/dist/cjs/nv-accordion.entry-hi3M0POV.js +0 -164
- package/dist/cjs/nv-icon.entry-CrgnozDL.js +0 -79
package/dist/cjs/{timeline.animation-adf35ecb-CE6Dsdxr.js → timeline.animation-79215cd4-KteJaZPb.js}
RENAMED
|
@@ -19,5 +19,24 @@ const timeline = (...animations) => ({
|
|
|
19
19
|
return animations.reduce((promise, animation) => promise.then(() => animation()), Promise.resolve());
|
|
20
20
|
},
|
|
21
21
|
});
|
|
22
|
+
/**
|
|
23
|
+
* Will execute a series of animation promises in parallel.
|
|
24
|
+
* This is useful for running multiple animations simultaneously.
|
|
25
|
+
*
|
|
26
|
+
* @param {Array<() => Promise<void>>} animations - The array of animation functions.
|
|
27
|
+
* @returns {Object} - An object with a `start` method to begin the parallel animations.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* const { fadeOut } = useFade(this.ref);
|
|
31
|
+
* const { slideOut } = useSlide(this.containerRef);
|
|
32
|
+
*
|
|
33
|
+
* parallel(fadeOut, slideOut).start();
|
|
34
|
+
*/
|
|
35
|
+
const parallel = (...animations) => ({
|
|
36
|
+
start: () => {
|
|
37
|
+
return Promise.all(animations.map(animation => animation()));
|
|
38
|
+
},
|
|
39
|
+
});
|
|
22
40
|
|
|
41
|
+
exports.parallel = parallel;
|
|
23
42
|
exports.timeline = timeline;
|
|
@@ -35,6 +35,8 @@ import { NvIconbutton as NvIconbuttonElement, defineCustomElement as defineNvIco
|
|
|
35
35
|
import { NvLoader as NvLoaderElement, defineCustomElement as defineNvLoader } from "@nova-design-system/nova-webcomponents/dist/components/nv-loader.js";
|
|
36
36
|
import { NvMenu as NvMenuElement, defineCustomElement as defineNvMenu } from "@nova-design-system/nova-webcomponents/dist/components/nv-menu.js";
|
|
37
37
|
import { NvMenuitem as NvMenuitemElement, defineCustomElement as defineNvMenuitem } from "@nova-design-system/nova-webcomponents/dist/components/nv-menuitem.js";
|
|
38
|
+
import { NvNotification as NvNotificationElement, defineCustomElement as defineNvNotification } from "@nova-design-system/nova-webcomponents/dist/components/nv-notification.js";
|
|
39
|
+
import { NvNotificationcontainer as NvNotificationcontainerElement, defineCustomElement as defineNvNotificationcontainer } from "@nova-design-system/nova-webcomponents/dist/components/nv-notificationcontainer.js";
|
|
38
40
|
import { NvPopover as NvPopoverElement, defineCustomElement as defineNvPopover } from "@nova-design-system/nova-webcomponents/dist/components/nv-popover.js";
|
|
39
41
|
import { NvRow as NvRowElement, defineCustomElement as defineNvRow } from "@nova-design-system/nova-webcomponents/dist/components/nv-row.js";
|
|
40
42
|
import { NvStack as NvStackElement, defineCustomElement as defineNvStack } from "@nova-design-system/nova-webcomponents/dist/components/nv-stack.js";
|
|
@@ -326,6 +328,20 @@ export const NvMenuitem = createComponent({
|
|
|
326
328
|
events: { onMenuitemSelected: 'menuitemSelected' },
|
|
327
329
|
defineCustomElement: defineNvMenuitem
|
|
328
330
|
});
|
|
331
|
+
export const NvNotification = createComponent({
|
|
332
|
+
tagName: 'nv-notification',
|
|
333
|
+
elementClass: NvNotificationElement,
|
|
334
|
+
react: React,
|
|
335
|
+
events: { onHiddenChanged: 'hiddenChanged' },
|
|
336
|
+
defineCustomElement: defineNvNotification
|
|
337
|
+
});
|
|
338
|
+
export const NvNotificationcontainer = createComponent({
|
|
339
|
+
tagName: 'nv-notificationcontainer',
|
|
340
|
+
elementClass: NvNotificationcontainerElement,
|
|
341
|
+
react: React,
|
|
342
|
+
events: {},
|
|
343
|
+
defineCustomElement: defineNvNotificationcontainer
|
|
344
|
+
});
|
|
329
345
|
export const NvPopover = createComponent({
|
|
330
346
|
tagName: 'nv-popover',
|
|
331
347
|
elementClass: NvPopoverElement,
|
|
@@ -128,7 +128,9 @@ export const NvCalendar = createComponent({
|
|
|
128
128
|
shortcutsPlacement: 'shortcuts-placement',
|
|
129
129
|
selectionType: 'selection-type',
|
|
130
130
|
showActions: 'show-actions',
|
|
131
|
-
showWeekNumbers: 'show-week-numbers'
|
|
131
|
+
showWeekNumbers: 'show-week-numbers',
|
|
132
|
+
cancelLabel: 'cancel-label',
|
|
133
|
+
primaryLabel: 'primary-label'
|
|
132
134
|
},
|
|
133
135
|
hydrateModule: import('@nova-design-system/nova-webcomponents/hydrate'),
|
|
134
136
|
serializeShadowRoot
|
|
@@ -646,6 +648,28 @@ export const NvMenuitem = createComponent({
|
|
|
646
648
|
hydrateModule: import('@nova-design-system/nova-webcomponents/hydrate'),
|
|
647
649
|
serializeShadowRoot
|
|
648
650
|
});
|
|
651
|
+
export const NvNotification = createComponent({
|
|
652
|
+
tagName: 'nv-notification',
|
|
653
|
+
properties: {
|
|
654
|
+
uid: 'uid',
|
|
655
|
+
feedback: 'feedback',
|
|
656
|
+
emphasis: 'emphasis',
|
|
657
|
+
heading: 'heading',
|
|
658
|
+
message: 'message',
|
|
659
|
+
icon: 'icon',
|
|
660
|
+
dismissible: 'dismissible',
|
|
661
|
+
hidden: 'hidden',
|
|
662
|
+
initiallyHidden: 'initially-hidden'
|
|
663
|
+
},
|
|
664
|
+
hydrateModule: import('@nova-design-system/nova-webcomponents/hydrate'),
|
|
665
|
+
serializeShadowRoot
|
|
666
|
+
});
|
|
667
|
+
export const NvNotificationcontainer = createComponent({
|
|
668
|
+
tagName: 'nv-notificationcontainer',
|
|
669
|
+
properties: { position: 'position' },
|
|
670
|
+
hydrateModule: import('@nova-design-system/nova-webcomponents/hydrate'),
|
|
671
|
+
serializeShadowRoot
|
|
672
|
+
});
|
|
649
673
|
export const NvPopover = createComponent({
|
|
650
674
|
tagName: 'nv-popover',
|
|
651
675
|
properties: {
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export * from './generated/components';
|
|
2
2
|
export * from '@nova-design-system/nova-webcomponents/constants';
|
|
3
3
|
export { defineCustomElements } from '@nova-design-system/nova-webcomponents/loader';
|
|
4
|
+
export { useNotifications, NotificationProvider, } from './providers/NotificationProvider';
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
};
|
|
@@ -35,6 +35,8 @@ import { NvIconbutton as NvIconbuttonElement } from "@nova-design-system/nova-we
|
|
|
35
35
|
import { NvLoader as NvLoaderElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-loader.js";
|
|
36
36
|
import { NvMenu as NvMenuElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-menu.js";
|
|
37
37
|
import { NvMenuitem as NvMenuitemElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-menuitem.js";
|
|
38
|
+
import { NvNotification as NvNotificationElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-notification.js";
|
|
39
|
+
import { NvNotificationcontainer as NvNotificationcontainerElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-notificationcontainer.js";
|
|
38
40
|
import { NvPopover as NvPopoverElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-popover.js";
|
|
39
41
|
import { NvRow as NvRowElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-row.js";
|
|
40
42
|
import { NvStack as NvStackElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-stack.js";
|
|
@@ -205,6 +207,12 @@ export type NvMenuitemEvents = {
|
|
|
205
207
|
}>>;
|
|
206
208
|
};
|
|
207
209
|
export declare const NvMenuitem: StencilReactComponent<NvMenuitemElement, NvMenuitemEvents>;
|
|
210
|
+
export type NvNotificationEvents = {
|
|
211
|
+
onHiddenChanged: EventName<CustomEvent<boolean>>;
|
|
212
|
+
};
|
|
213
|
+
export declare const NvNotification: StencilReactComponent<NvNotificationElement, NvNotificationEvents>;
|
|
214
|
+
export type NvNotificationcontainerEvents = NonNullable<unknown>;
|
|
215
|
+
export declare const NvNotificationcontainer: StencilReactComponent<NvNotificationcontainerElement, NvNotificationcontainerEvents>;
|
|
208
216
|
export type NvPopoverEvents = {
|
|
209
217
|
onOpenChanged: EventName<CustomEvent<boolean>>;
|
|
210
218
|
};
|
|
@@ -35,6 +35,8 @@ import { NvIconbutton as NvIconbuttonElement } from "@nova-design-system/nova-we
|
|
|
35
35
|
import { NvLoader as NvLoaderElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-loader.js";
|
|
36
36
|
import { NvMenu as NvMenuElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-menu.js";
|
|
37
37
|
import { NvMenuitem as NvMenuitemElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-menuitem.js";
|
|
38
|
+
import { NvNotification as NvNotificationElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-notification.js";
|
|
39
|
+
import { NvNotificationcontainer as NvNotificationcontainerElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-notificationcontainer.js";
|
|
38
40
|
import { NvPopover as NvPopoverElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-popover.js";
|
|
39
41
|
import { NvRow as NvRowElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-row.js";
|
|
40
42
|
import { NvStack as NvStackElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-stack.js";
|
|
@@ -207,6 +209,12 @@ export type NvMenuitemEvents = {
|
|
|
207
209
|
}>>;
|
|
208
210
|
};
|
|
209
211
|
export declare const NvMenuitem: StencilReactComponent<NvMenuitemElement, NvMenuitemEvents>;
|
|
212
|
+
export type NvNotificationEvents = {
|
|
213
|
+
onHiddenChanged: EventName<CustomEvent<boolean>>;
|
|
214
|
+
};
|
|
215
|
+
export declare const NvNotification: StencilReactComponent<NvNotificationElement, NvNotificationEvents>;
|
|
216
|
+
export type NvNotificationcontainerEvents = NonNullable<unknown>;
|
|
217
|
+
export declare const NvNotificationcontainer: StencilReactComponent<NvNotificationcontainerElement, NvNotificationcontainerEvents>;
|
|
210
218
|
export type NvPopoverEvents = {
|
|
211
219
|
onOpenChanged: EventName<CustomEvent<boolean>>;
|
|
212
220
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export * from './generated/components';
|
|
2
2
|
export * from '@nova-design-system/nova-webcomponents/constants';
|
|
3
3
|
export { defineCustomElements } from '@nova-design-system/nova-webcomponents/loader';
|
|
4
|
+
export { useNotifications, NotificationProvider, type NotificationOptions, type NotificationContextValue, type NotificationProviderProps, type Notification, } from './providers/NotificationProvider';
|
|
@@ -0,0 +1,36 @@
|
|
|
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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nova-design-system/nova-react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.14.0-beta.0",
|
|
4
4
|
"description": "Nova is a design system created by Elia Group to empower creators to efficiently build solutions that people love to use.",
|
|
5
5
|
"author": "Elia Group",
|
|
6
6
|
"homepage": "https://nova.eliagroup.io",
|
|
@@ -27,7 +27,10 @@
|
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build": "npm run build:cjs && npm run tsc",
|
|
29
29
|
"build:cjs": "rollup -c",
|
|
30
|
+
"build:watch": "npm run build:cjs:watch & npm run tsc:watch",
|
|
31
|
+
"build:cjs:watch": "rollup -c --watch",
|
|
30
32
|
"tsc": "tsc -p . --outDir ./dist --declarationDir ./dist/types --declaration true",
|
|
33
|
+
"tsc:watch": "tsc -p . --outDir ./dist --declarationDir ./dist/types --declaration true --watch",
|
|
31
34
|
"storybook": "storybook dev -p 6006",
|
|
32
35
|
"storybook.build": "storybook build -o ../../storybook-static/react",
|
|
33
36
|
"clean": "rimraf dist lib/generated",
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var stylefire_es74da334a = require('./stylefire.es-74da334a-y0piPjlz.js');
|
|
4
|
-
|
|
5
|
-
const useCollapse = (node, { duration } = { duration: 200 }) => {
|
|
6
|
-
const nodeStyler = stylefire_es74da334a.index(node);
|
|
7
|
-
/**
|
|
8
|
-
* Will set the overflow to hidden, and animate the max height to 0. Make sure
|
|
9
|
-
* the element has no border or y padding set, otherwise the animation will
|
|
10
|
-
* not work as expected.
|
|
11
|
-
*/
|
|
12
|
-
function collapse() {
|
|
13
|
-
return new Promise(resolve => {
|
|
14
|
-
const height = node.getBoundingClientRect().height;
|
|
15
|
-
nodeStyler.set({ overflow: 'hidden' });
|
|
16
|
-
stylefire_es74da334a.animate({
|
|
17
|
-
from: height,
|
|
18
|
-
to: 0,
|
|
19
|
-
duration,
|
|
20
|
-
onUpdate: value => {
|
|
21
|
-
nodeStyler.set({
|
|
22
|
-
maxHeight: value,
|
|
23
|
-
});
|
|
24
|
-
},
|
|
25
|
-
onComplete: () => {
|
|
26
|
-
resolve();
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Apply the collapsed styles without animating, useful when initial state
|
|
33
|
-
* is collapsed.
|
|
34
|
-
*/
|
|
35
|
-
function setCollapsed() {
|
|
36
|
-
node.style.maxHeight = '0';
|
|
37
|
-
node.style.overflow = 'hidden';
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Apply the expanded styles without animating, useful when initial state
|
|
41
|
-
* is expanded.
|
|
42
|
-
*/
|
|
43
|
-
function setExpanded() {
|
|
44
|
-
node.style.maxHeight = '';
|
|
45
|
-
node.style.overflow = '';
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Will set the overflow to hidden, and animate the max height to the value
|
|
49
|
-
* of the scrollHeight. Make sure the element has no border or y padding set,
|
|
50
|
-
* otherwise the animation will not work as expected. Once complete, the
|
|
51
|
-
* max-height and overflow style properties will be removed.
|
|
52
|
-
*/
|
|
53
|
-
function expand() {
|
|
54
|
-
return new Promise(resolve => {
|
|
55
|
-
const scrollHeight = node.scrollHeight;
|
|
56
|
-
nodeStyler.set({
|
|
57
|
-
overflow: 'hidden',
|
|
58
|
-
});
|
|
59
|
-
stylefire_es74da334a.animate({
|
|
60
|
-
from: 0,
|
|
61
|
-
to: scrollHeight,
|
|
62
|
-
duration,
|
|
63
|
-
onUpdate: value => {
|
|
64
|
-
nodeStyler.set({
|
|
65
|
-
maxHeight: value,
|
|
66
|
-
});
|
|
67
|
-
},
|
|
68
|
-
onComplete: () => {
|
|
69
|
-
node.style.removeProperty('max-height');
|
|
70
|
-
node.style.removeProperty('overflow');
|
|
71
|
-
resolve();
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
return {
|
|
77
|
-
collapse,
|
|
78
|
-
expand,
|
|
79
|
-
setCollapsed,
|
|
80
|
-
setExpanded,
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
exports.useCollapse = useCollapse;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var stylefire_es74da334a = require('./stylefire.es-74da334a-y0piPjlz.js');
|
|
4
|
-
|
|
5
|
-
const useFade = (node, { duration } = { duration: 200 }) => {
|
|
6
|
-
const nodeStyler = stylefire_es74da334a.index(node);
|
|
7
|
-
/**
|
|
8
|
-
* Will animate the opacity to 1, and removes the opacity style attribute once
|
|
9
|
-
* complete.
|
|
10
|
-
*/
|
|
11
|
-
function fadeIn() {
|
|
12
|
-
return new Promise(resolve => {
|
|
13
|
-
stylefire_es74da334a.animate({
|
|
14
|
-
from: { opacity: 0 },
|
|
15
|
-
to: { opacity: 1 },
|
|
16
|
-
duration,
|
|
17
|
-
onUpdate(latest) {
|
|
18
|
-
nodeStyler.set({ opacity: latest.opacity });
|
|
19
|
-
},
|
|
20
|
-
onComplete() {
|
|
21
|
-
resolve();
|
|
22
|
-
node.style.removeProperty('opacity');
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Applies the fadeOut styles without animating, useful when initial state
|
|
29
|
-
* is hidden.
|
|
30
|
-
*/
|
|
31
|
-
function setFadeOut() {
|
|
32
|
-
node.style.opacity = '0';
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Applies the fadeIn styles without animating, useful when initial state
|
|
36
|
-
* is visible.
|
|
37
|
-
*/
|
|
38
|
-
function setFadeIn() {
|
|
39
|
-
node.style.opacity = '1';
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Will animate the opacity to 0, once complete, the opacity style attribute
|
|
43
|
-
* will stay on the element.
|
|
44
|
-
*/
|
|
45
|
-
function fadeOut() {
|
|
46
|
-
return new Promise(resolve => {
|
|
47
|
-
stylefire_es74da334a.animate({
|
|
48
|
-
from: { opacity: 1 },
|
|
49
|
-
to: { opacity: 0 },
|
|
50
|
-
duration,
|
|
51
|
-
onUpdate(latest) {
|
|
52
|
-
nodeStyler.set({ opacity: latest.opacity });
|
|
53
|
-
},
|
|
54
|
-
onComplete() {
|
|
55
|
-
resolve();
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
fadeIn,
|
|
62
|
-
fadeOut,
|
|
63
|
-
setFadeOut,
|
|
64
|
-
setFadeIn,
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
exports.useFade = useFade;
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var index = require('./index-jBgPO7HC.js');
|
|
4
|
-
require('react');
|
|
5
|
-
|
|
6
|
-
const nvAccordionCss = "nv-accordion{display:block;border:var(--spacing-px) solid var(--color-content-low-border);border-radius:var(--radius-rounded-lg)}nv-accordion .nv-accordion__footer{padding:var(--spacing-3);background:var(--color-level-05-background);border-radius:0 0 var(--radius-rounded-lg) var(--radius-rounded-lg);margin-top:calc(var(--spacing-px) * -1);border-top:var(--spacing-px) solid var(--color-content-low-border)}nv-accordion .nv-accordion__footer:empty{display:none}";
|
|
7
|
-
const NvAccordionStyle0 = nvAccordionCss;
|
|
8
|
-
|
|
9
|
-
const NvAccordion = class {
|
|
10
|
-
constructor(hostRef) {
|
|
11
|
-
index.registerInstance(this, hostRef);
|
|
12
|
-
this.openChanged = index.createEvent(this, "openChanged");
|
|
13
|
-
/****************************************************************************/
|
|
14
|
-
//#region PROPERTIES
|
|
15
|
-
/**
|
|
16
|
-
* Data to display as a list of items (title, subtitle, content).
|
|
17
|
-
*/
|
|
18
|
-
this.data = [];
|
|
19
|
-
/**
|
|
20
|
-
* Expansion mode: 'accordion' (single open) or 'multi' (multiple open)
|
|
21
|
-
*/
|
|
22
|
-
this.mode = 'accordion';
|
|
23
|
-
//#endregion PROPERTIES
|
|
24
|
-
/****************************************************************************/
|
|
25
|
-
//#region STATE
|
|
26
|
-
/**
|
|
27
|
-
* Internal index of open items (not exposed)
|
|
28
|
-
*/
|
|
29
|
-
this.internalOpenIndexes = [];
|
|
30
|
-
}
|
|
31
|
-
//#endregion EVENTS
|
|
32
|
-
/****************************************************************************/
|
|
33
|
-
//#region METHODS
|
|
34
|
-
/**
|
|
35
|
-
* Opens an item by its index (Public API)
|
|
36
|
-
* @param {number} index Index of the item to open
|
|
37
|
-
*/
|
|
38
|
-
async open(index) {
|
|
39
|
-
this.toggleItem(index, true);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Closes an item by its index (Public API)
|
|
43
|
-
* @param {number} index Index of the item to close
|
|
44
|
-
*/
|
|
45
|
-
async close(index) {
|
|
46
|
-
this.toggleItem(index, false);
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Toggles an item's state (internal)
|
|
50
|
-
* @param {number} index Item index
|
|
51
|
-
* @param {boolean} [forceOpen] Force open (true) or close (false)
|
|
52
|
-
*/
|
|
53
|
-
toggleItem(index, forceOpen) {
|
|
54
|
-
let openIndexes = this.openIndexes !== undefined
|
|
55
|
-
? [...this.openIndexes]
|
|
56
|
-
: [...(this.internalOpenIndexes || [])];
|
|
57
|
-
const isOpen = openIndexes.includes(index);
|
|
58
|
-
if (this.mode === 'accordion') {
|
|
59
|
-
openIndexes = forceOpen === false || isOpen ? [] : [index];
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
if (forceOpen === false) {
|
|
63
|
-
openIndexes = openIndexes.filter(i => i !== index);
|
|
64
|
-
}
|
|
65
|
-
else if (!isOpen) {
|
|
66
|
-
openIndexes.push(index);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
this.internalOpenIndexes = openIndexes;
|
|
70
|
-
this.openChanged.emit({ openIndexes });
|
|
71
|
-
if (this.openIndexes !== undefined) {
|
|
72
|
-
this.openIndexes =
|
|
73
|
-
this.mode === 'accordion'
|
|
74
|
-
? [openIndexes[0]].filter(x => x !== undefined)
|
|
75
|
-
: [...openIndexes];
|
|
76
|
-
}
|
|
77
|
-
// Update child elements state - for both data and slot usage
|
|
78
|
-
this.updateChildrenState();
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Updates the open state of child elements based on internalOpenIndexes
|
|
82
|
-
*/
|
|
83
|
-
async updateChildrenState() {
|
|
84
|
-
// Force a re-render by updating the state
|
|
85
|
-
this.internalOpenIndexes = [...(this.internalOpenIndexes || [])];
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Listens to itemToggle events from nv-accordion-item elements
|
|
89
|
-
* @param {CustomEvent<boolean>} event Event emitted by nv-accordion-item
|
|
90
|
-
*/
|
|
91
|
-
onItemToggle(event) {
|
|
92
|
-
// Find the index of the item that emitted the event
|
|
93
|
-
const items = Array.from(this.el.querySelectorAll('nv-accordion-item'));
|
|
94
|
-
const targetItem = event.target;
|
|
95
|
-
const index = items.indexOf(targetItem);
|
|
96
|
-
if (index !== -1) {
|
|
97
|
-
// If the event comes from an item that is opening, handle accordion mode
|
|
98
|
-
if (event.detail === true) {
|
|
99
|
-
if (this.mode === 'accordion') {
|
|
100
|
-
// Close all other items
|
|
101
|
-
items.forEach((item, i) => {
|
|
102
|
-
if (i !== index && item.open) {
|
|
103
|
-
item.open = false;
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
this.internalOpenIndexes = [index];
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
// Add index to internalOpenIndexes if not already present
|
|
110
|
-
if (!this.internalOpenIndexes.includes(index)) {
|
|
111
|
-
this.internalOpenIndexes = [...this.internalOpenIndexes, index];
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
// If the item is closing, remove it from internalOpenIndexes
|
|
117
|
-
this.internalOpenIndexes = this.internalOpenIndexes.filter(i => i !== index);
|
|
118
|
-
}
|
|
119
|
-
// Emit openChanged event
|
|
120
|
-
this.openChanged.emit({ openIndexes: this.internalOpenIndexes });
|
|
121
|
-
if (this.openIndexes !== undefined) {
|
|
122
|
-
this.openIndexes =
|
|
123
|
-
this.mode === 'accordion'
|
|
124
|
-
? [this.internalOpenIndexes[0]].filter(x => x !== undefined)
|
|
125
|
-
: [...this.internalOpenIndexes];
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
//#endregion METHODS
|
|
130
|
-
/****************************************************************************/
|
|
131
|
-
//#region WATCHERS
|
|
132
|
-
//#endregion WATCHERS
|
|
133
|
-
/****************************************************************************/
|
|
134
|
-
//#region LIFECYCLE
|
|
135
|
-
componentWillLoad() {
|
|
136
|
-
if (this.openIndexes !== undefined) {
|
|
137
|
-
this.internalOpenIndexes = [...this.openIndexes];
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
componentDidLoad() {
|
|
141
|
-
// If using direct child elements, initialize their state
|
|
142
|
-
if (!this.data || this.data.length === 0) {
|
|
143
|
-
this.updateChildrenState();
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
componentWillUpdate() {
|
|
147
|
-
if (this.openIndexes !== undefined) {
|
|
148
|
-
this.internalOpenIndexes = [...this.openIndexes];
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
//#endregion LIFECYCLE
|
|
152
|
-
/****************************************************************************/
|
|
153
|
-
//#region RENDER
|
|
154
|
-
render() {
|
|
155
|
-
return (index.h(index.Host, { key: 'a6cb21b274024a00e60e0d0db780f25fab6e5bc2', role: "list", class: "nv-accordion" }, this.data && this.data.length > 0 ? (this.data.map((item, i) => {
|
|
156
|
-
var _a;
|
|
157
|
-
return (index.h("nv-accordion-item", { key: (_a = item.id) !== null && _a !== void 0 ? _a : i, itemTitle: item.title, disabled: item.disabled, open: (this.internalOpenIndexes || []).includes(i) }, item.subtitle ? (index.h("div", { slot: "header" }, index.h("div", { class: "nv-accordion-item__header-content" }, index.h("span", { class: "nv-accordion-item__title" }, item.title), index.h("span", { class: "nv-accordion-item__subtitle" }, item.subtitle)))) : null, index.h("div", { slot: "content" }, item.content), item.footer && index.h("div", { slot: "footer" }, item.footer)));
|
|
158
|
-
})) : (index.h("slot", null))));
|
|
159
|
-
}
|
|
160
|
-
get el() { return index.getElement(this); }
|
|
161
|
-
};
|
|
162
|
-
NvAccordion.style = NvAccordionStyle0;
|
|
163
|
-
|
|
164
|
-
exports.nv_accordion = NvAccordion;
|