@nova-design-system/nova-react 3.14.0 → 3.16.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-acda1bf5-BuORVmQv.js → collapse.animation-6e0b08df-AHWzNGm_.js} +4 -1
- package/dist/cjs/{constants-d0f19e7b-s0SCO_vi.js → constants-69bafca2-DpB_ghPF.js} +9 -0
- package/dist/cjs/{fade.animation-eb454088-Bma0SpTf.js → fade.animation-9b939939-DV--bM4S.js} +2 -2
- package/dist/cjs/{index-CKAZvszR.js → index-7K7BV1CP.js} +4676 -1345
- package/dist/cjs/index.js +10 -2
- package/dist/cjs/{nv-accordion-item.entry-CjBcmF8t.js → nv-accordion-item.entry-C-9tYw-c.js} +6 -5
- package/dist/cjs/{nv-accordion.entry-CRk2Wvt3.js → nv-accordion.entry-BA3mTIdj.js} +7 -6
- package/dist/cjs/{nv-alert.entry-D5qB5xZg.js → nv-alert.entry-Bic-YGW1.js} +13 -12
- package/dist/cjs/nv-avatar.entry-C-yd0YlD.js +68 -0
- package/dist/cjs/{nv-badge_2.entry-BDuX1qOQ.js → nv-badge_2.entry-B_8yvNXL.js} +11 -10
- package/dist/cjs/{nv-breadcrumb.entry-BE9U6AF_.js → nv-breadcrumb.entry-BCTbG942.js} +3 -2
- package/dist/cjs/{nv-breadcrumbs.entry-DJXqtmMR.js → nv-breadcrumbs.entry-C9B5Baf7.js} +2 -1
- package/dist/cjs/nv-button.entry-DgX8Bwmq.js +165 -0
- package/dist/cjs/{nv-buttongroup.entry-C0Zc2lOi.js → nv-buttongroup.entry-CKhZN_Yf.js} +2 -1
- package/dist/cjs/{nv-calendar.entry-NbVLStMN.js → nv-calendar.entry-E6Pk83WA.js} +8 -7
- package/dist/cjs/{nv-col.entry-ahFf8a1Z.js → nv-col.entry-CkZpukX9.js} +2 -1
- package/dist/cjs/{nv-datagrid.entry-C-MJXEdi.js → nv-datagrid.entry-RsfP7vbC.js} +183 -15
- package/dist/cjs/{nv-datagridcolumn.entry-CxU7soW7.js → nv-datagridcolumn.entry-D4VrDWo9.js} +2 -1
- package/dist/cjs/{nv-dialog.entry-WlnaC-w2.js → nv-dialog.entry-BhtWpYHl.js} +34 -30
- package/dist/cjs/{nv-dialogfooter_2.entry-CEWmTnJc.js → nv-dialogfooter_2.entry-BXLYmzYl.js} +6 -5
- package/dist/cjs/{nv-fieldcheckbox.entry-BYhFVrYb.js → nv-fieldcheckbox.entry-D96Nm6DZ.js} +3 -2
- package/dist/cjs/{nv-fielddate.entry-DVVnRiOT.js → nv-fielddate.entry-ty37R9jF.js} +52 -26
- package/dist/cjs/{nv-fielddaterange.entry-Cb4X5Q-C.js → nv-fielddaterange.entry-BSIRu_mq.js} +69 -42
- package/dist/cjs/{nv-fielddropdown.entry-D2PKGkpx.js → nv-fielddropdown.entry-CUzvIoZZ.js} +34 -7
- package/dist/cjs/{nv-fielddropdownitem.entry-BqgMRnIc.js → nv-fielddropdownitem.entry-D-GTxLNk.js} +2 -1
- package/dist/cjs/{nv-fieldmultiselect.entry-Dzw4c9wO.js → nv-fieldmultiselect.entry-DFY2bf6s.js} +188 -156
- package/dist/cjs/{nv-fieldnumber.entry-Cm5g6tw7.js → nv-fieldnumber.entry-CILclJ7Q.js} +3 -2
- package/dist/cjs/{nv-fieldpassword.entry-BMI5M4RR.js → nv-fieldpassword.entry-CdR-NM8e.js} +3 -2
- package/dist/cjs/{nv-fieldradio.entry-BrCJvkMR.js → nv-fieldradio.entry-lC4scIvU.js} +3 -2
- package/dist/cjs/{nv-fieldselect.entry-Cz76Y4Fb.js → nv-fieldselect.entry-CYu6870F.js} +3 -2
- package/dist/cjs/{nv-fieldslider.entry-C2ynnMK8.js → nv-fieldslider.entry-DOuJAR6P.js} +3 -2
- package/dist/cjs/{nv-fieldtext.entry-B6ciu2fU.js → nv-fieldtext.entry-BFLUiPa4.js} +3 -2
- package/dist/cjs/{nv-fieldtextarea.entry-BL_gMvTp.js → nv-fieldtextarea.entry-BeI0k97G.js} +3 -2
- package/dist/cjs/{nv-fieldtime.entry-Be5fujXA.js → nv-fieldtime.entry-C28EAKki.js} +82 -68
- package/dist/cjs/nv-icon.entry-BXgjUpe_.js +80 -0
- package/dist/cjs/{nv-iconbutton_2.entry-Dlk96yHi.js → nv-iconbutton_2.entry-CpIkxrp9.js} +3 -2
- package/dist/cjs/{nv-menu.entry-CDn1Tk9J.js → nv-menu.entry-as-NOsF-.js} +25 -9
- package/dist/cjs/{nv-menuitem.entry-DIkQnha9.js → nv-menuitem.entry-D8KAh6nr.js} +2 -1
- package/dist/cjs/nv-notification.entry-C-_jV-DL.js +262 -0
- package/dist/cjs/nv-notificationcontainer.entry-CMn42loT.js +41 -0
- package/dist/cjs/{nv-popover.entry-Bz9ZWGlN.js → nv-popover.entry--BhEBSir.js} +72 -65
- package/dist/cjs/{nv-row.entry-iJGXINmZ.js → nv-row.entry-BxhcK9aY.js} +3 -2
- package/dist/cjs/{nv-stack.entry-CifEjR2g.js → nv-stack.entry-C3DF9jJZ.js} +3 -2
- package/dist/cjs/nv-table.entry-pfEGt2KH.js +245 -0
- package/dist/cjs/nv-toggle.entry-ChpqtQtn.js +80 -0
- package/dist/cjs/{nv-togglebutton.entry-X4eLeP-C.js → nv-togglebutton.entry-DE7CKmeN.js} +3 -2
- package/dist/cjs/{nv-togglebuttongroup.entry-BYO58vql.js → nv-togglebuttongroup.entry-BJPjdmHD.js} +3 -2
- package/dist/cjs/{nv-tooltip.entry-DaxjQSt1.js → nv-tooltip.entry-D9-Fga6C.js} +3 -2
- package/dist/components/NvDatatable.js +45 -0
- package/dist/generated/components.js +10 -10
- package/dist/generated/components.server.js +9 -17
- package/dist/index.js +2 -0
- package/dist/providers/NotificationProvider.js +83 -0
- package/dist/types/components/NvDatatable.d.ts +25 -0
- package/dist/types/generated/components.d.ts +5 -12
- package/dist/types/generated/components.server.d.ts +5 -12
- package/dist/types/index.d.ts +2 -0
- package/dist/types/providers/NotificationProvider.d.ts +36 -0
- package/package.json +7 -3
- package/dist/cjs/dom.utils-ac71e0ef-CmIwRr6O.js +0 -168
- package/dist/cjs/nv-avatar.entry-CuNYdZl_.js +0 -67
- package/dist/cjs/nv-button.entry-CF5IDcG3.js +0 -164
- package/dist/cjs/nv-icon.entry-C-wbfOy3.js +0 -79
- package/dist/cjs/nv-notification.entry-BiwnZCkF.js +0 -178
- package/dist/cjs/nv-table.entry-Dxg0j3fe.js +0 -338
- package/dist/cjs/nv-tablecolumn.entry--29MFEe9.js +0 -18
- package/dist/cjs/nv-toggle.entry-D0eQoEqf.js +0 -79
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React, { type ComponentProps } from 'react';
|
|
2
|
+
declare const NvDatatable: {
|
|
3
|
+
<T extends NvDatatableRow = NvDatatableRow>({ columns, rows, ...htmlProps }: NvDatatableProps<T>): React.JSX.Element;
|
|
4
|
+
displayName: string;
|
|
5
|
+
};
|
|
6
|
+
export { NvDatatable };
|
|
7
|
+
export type NvDatatableProps<T> = {
|
|
8
|
+
columns: Array<NvDatatableColumn<T>>;
|
|
9
|
+
rows: Array<T>;
|
|
10
|
+
} & Pick<ComponentProps<'div'>, 'className' | 'style'>;
|
|
11
|
+
export interface NvDatatableColumn<T> {
|
|
12
|
+
field: keyof T;
|
|
13
|
+
headerName?: string;
|
|
14
|
+
width?: number;
|
|
15
|
+
resizable?: boolean;
|
|
16
|
+
hidden?: boolean;
|
|
17
|
+
renderCell?: (params: NvTableRenderCellParams<T, T[keyof T]>) => React.ReactNode;
|
|
18
|
+
}
|
|
19
|
+
export type NvDatatableRow = Record<string, string | number | boolean | null | undefined | typeof Date>;
|
|
20
|
+
export interface NvTableRenderCellParams<T, V> {
|
|
21
|
+
value: V;
|
|
22
|
+
row: T;
|
|
23
|
+
field: keyof T;
|
|
24
|
+
rowIndex: number;
|
|
25
|
+
}
|
|
@@ -36,20 +36,18 @@ import { NvLoader as NvLoaderElement } from "@nova-design-system/nova-webcompone
|
|
|
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
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";
|
|
39
40
|
import { NvPopover as NvPopoverElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-popover.js";
|
|
40
41
|
import { NvRow as NvRowElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-row.js";
|
|
41
42
|
import { NvStack as NvStackElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-stack.js";
|
|
42
43
|
import { NvTable as NvTableElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-table.js";
|
|
43
|
-
import { NvTablecolumn as NvTablecolumnElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-tablecolumn.js";
|
|
44
44
|
import { NvToggle as NvToggleElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-toggle.js";
|
|
45
45
|
import { NvTogglebutton as NvTogglebuttonElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-togglebutton.js";
|
|
46
46
|
import { NvTogglebuttongroup as NvTogglebuttongroupElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-togglebuttongroup.js";
|
|
47
47
|
import { NvTooltip as NvTooltipElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-tooltip.js";
|
|
48
48
|
import type { EventName, StencilReactComponent } from '@stencil/react-output-target/runtime';
|
|
49
49
|
export type NvAccordionEvents = {
|
|
50
|
-
|
|
51
|
-
openIndexes: number[];
|
|
52
|
-
}>>;
|
|
50
|
+
onOpenIndexesChanged: EventName<CustomEvent<number[]>>;
|
|
53
51
|
};
|
|
54
52
|
export declare const NvAccordion: StencilReactComponent<NvAccordionElement, NvAccordionEvents>;
|
|
55
53
|
export type NvAccordionItemEvents = {
|
|
@@ -210,6 +208,8 @@ export type NvNotificationEvents = {
|
|
|
210
208
|
onHiddenChanged: EventName<CustomEvent<boolean>>;
|
|
211
209
|
};
|
|
212
210
|
export declare const NvNotification: StencilReactComponent<NvNotificationElement, NvNotificationEvents>;
|
|
211
|
+
export type NvNotificationcontainerEvents = NonNullable<unknown>;
|
|
212
|
+
export declare const NvNotificationcontainer: StencilReactComponent<NvNotificationcontainerElement, NvNotificationcontainerEvents>;
|
|
213
213
|
export type NvPopoverEvents = {
|
|
214
214
|
onOpenChanged: EventName<CustomEvent<boolean>>;
|
|
215
215
|
};
|
|
@@ -218,15 +218,8 @@ export type NvRowEvents = NonNullable<unknown>;
|
|
|
218
218
|
export declare const NvRow: StencilReactComponent<NvRowElement, NvRowEvents>;
|
|
219
219
|
export type NvStackEvents = NonNullable<unknown>;
|
|
220
220
|
export declare const NvStack: StencilReactComponent<NvStackElement, NvStackEvents>;
|
|
221
|
-
export type NvTableEvents =
|
|
222
|
-
onAction: EventName<CustomEvent<{
|
|
223
|
-
keyAction: string;
|
|
224
|
-
details: any;
|
|
225
|
-
}>>;
|
|
226
|
-
};
|
|
221
|
+
export type NvTableEvents = NonNullable<unknown>;
|
|
227
222
|
export declare const NvTable: StencilReactComponent<NvTableElement, NvTableEvents>;
|
|
228
|
-
export type NvTablecolumnEvents = NonNullable<unknown>;
|
|
229
|
-
export declare const NvTablecolumn: StencilReactComponent<NvTablecolumnElement, NvTablecolumnEvents>;
|
|
230
223
|
export type NvToggleEvents = {
|
|
231
224
|
onCheckedChanged: EventName<CustomEvent<boolean>>;
|
|
232
225
|
};
|
|
@@ -36,11 +36,11 @@ import { NvLoader as NvLoaderElement } from "@nova-design-system/nova-webcompone
|
|
|
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
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";
|
|
39
40
|
import { NvPopover as NvPopoverElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-popover.js";
|
|
40
41
|
import { NvRow as NvRowElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-row.js";
|
|
41
42
|
import { NvStack as NvStackElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-stack.js";
|
|
42
43
|
import { NvTable as NvTableElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-table.js";
|
|
43
|
-
import { NvTablecolumn as NvTablecolumnElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-tablecolumn.js";
|
|
44
44
|
import { NvToggle as NvToggleElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-toggle.js";
|
|
45
45
|
import { NvTogglebutton as NvTogglebuttonElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-togglebutton.js";
|
|
46
46
|
import { NvTogglebuttongroup as NvTogglebuttongroupElement } from "@nova-design-system/nova-webcomponents/dist/components/nv-togglebuttongroup.js";
|
|
@@ -49,9 +49,7 @@ import type { EventName, StencilReactComponent } from '@stencil/react-output-tar
|
|
|
49
49
|
import { type SerializeShadowRootOptions } from '@stencil/react-output-target/ssr';
|
|
50
50
|
export declare const serializeShadowRoot: SerializeShadowRootOptions;
|
|
51
51
|
export type NvAccordionEvents = {
|
|
52
|
-
|
|
53
|
-
openIndexes: number[];
|
|
54
|
-
}>>;
|
|
52
|
+
onOpenIndexesChanged: EventName<CustomEvent<number[]>>;
|
|
55
53
|
};
|
|
56
54
|
export declare const NvAccordion: StencilReactComponent<NvAccordionElement, NvAccordionEvents>;
|
|
57
55
|
export type NvAccordionItemEvents = {
|
|
@@ -212,6 +210,8 @@ export type NvNotificationEvents = {
|
|
|
212
210
|
onHiddenChanged: EventName<CustomEvent<boolean>>;
|
|
213
211
|
};
|
|
214
212
|
export declare const NvNotification: StencilReactComponent<NvNotificationElement, NvNotificationEvents>;
|
|
213
|
+
export type NvNotificationcontainerEvents = NonNullable<unknown>;
|
|
214
|
+
export declare const NvNotificationcontainer: StencilReactComponent<NvNotificationcontainerElement, NvNotificationcontainerEvents>;
|
|
215
215
|
export type NvPopoverEvents = {
|
|
216
216
|
onOpenChanged: EventName<CustomEvent<boolean>>;
|
|
217
217
|
};
|
|
@@ -220,15 +220,8 @@ export type NvRowEvents = NonNullable<unknown>;
|
|
|
220
220
|
export declare const NvRow: StencilReactComponent<NvRowElement, NvRowEvents>;
|
|
221
221
|
export type NvStackEvents = NonNullable<unknown>;
|
|
222
222
|
export declare const NvStack: StencilReactComponent<NvStackElement, NvStackEvents>;
|
|
223
|
-
export type NvTableEvents =
|
|
224
|
-
onAction: EventName<CustomEvent<{
|
|
225
|
-
keyAction: string;
|
|
226
|
-
details: any;
|
|
227
|
-
}>>;
|
|
228
|
-
};
|
|
223
|
+
export type NvTableEvents = NonNullable<unknown>;
|
|
229
224
|
export declare const NvTable: StencilReactComponent<NvTableElement, NvTableEvents>;
|
|
230
|
-
export type NvTablecolumnEvents = NonNullable<unknown>;
|
|
231
|
-
export declare const NvTablecolumn: StencilReactComponent<NvTablecolumnElement, NvTablecolumnEvents>;
|
|
232
225
|
export type NvToggleEvents = {
|
|
233
226
|
onCheckedChanged: EventName<CustomEvent<boolean>>;
|
|
234
227
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
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';
|
|
5
|
+
export * from './components/NvDatatable';
|
|
@@ -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.16.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,14 +27,18 @@
|
|
|
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
|
-
"clean": "rimraf dist lib/generated",
|
|
36
|
+
"clean": "rimraf dist lib/generated lib/stories/generated",
|
|
34
37
|
"typecheck": "tsc --emitDeclarationOnly false --noEmit"
|
|
35
38
|
},
|
|
36
39
|
"dependencies": {
|
|
37
|
-
"@nova-design-system/nova-webcomponents": "*"
|
|
40
|
+
"@nova-design-system/nova-webcomponents": "*",
|
|
41
|
+
"@tanstack/react-table": "8.21.3"
|
|
38
42
|
},
|
|
39
43
|
"devDependencies": {
|
|
40
44
|
"react": "^18.3.1",
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
|
-
/**
|
|
5
|
-
* All properties that should be excluded from the deep copy of an HTML element.
|
|
6
|
-
*/
|
|
7
|
-
const excludedProps = new Set([
|
|
8
|
-
// Text and content-related properties
|
|
9
|
-
'textContent',
|
|
10
|
-
'innerText',
|
|
11
|
-
'outerText',
|
|
12
|
-
'innerHTML',
|
|
13
|
-
'outerHTML',
|
|
14
|
-
'text',
|
|
15
|
-
// Form element properties
|
|
16
|
-
'value',
|
|
17
|
-
'defaultValue',
|
|
18
|
-
'checked',
|
|
19
|
-
'defaultChecked',
|
|
20
|
-
'selectionStart',
|
|
21
|
-
'selectionEnd',
|
|
22
|
-
'selectionDirection',
|
|
23
|
-
'form',
|
|
24
|
-
'willValidate',
|
|
25
|
-
'validity',
|
|
26
|
-
'validationMessage',
|
|
27
|
-
'labels',
|
|
28
|
-
'list',
|
|
29
|
-
'maxLength',
|
|
30
|
-
'minLength',
|
|
31
|
-
'valueAsDate',
|
|
32
|
-
'valueAsNumber',
|
|
33
|
-
// Editability and namespaces
|
|
34
|
-
'contentEditable',
|
|
35
|
-
'isContentEditable',
|
|
36
|
-
'namespaceURI',
|
|
37
|
-
// Child-related properties (handled recursively)
|
|
38
|
-
'attributes',
|
|
39
|
-
'children',
|
|
40
|
-
'childNodes',
|
|
41
|
-
'firstChild',
|
|
42
|
-
'lastChild',
|
|
43
|
-
// Blazor-related properties
|
|
44
|
-
'origin',
|
|
45
|
-
'dataset',
|
|
46
|
-
'attributeStyleMap',
|
|
47
|
-
'prefix',
|
|
48
|
-
'localName',
|
|
49
|
-
'tagName',
|
|
50
|
-
'shadowRoot',
|
|
51
|
-
'assignedSlot',
|
|
52
|
-
'scrollWidth',
|
|
53
|
-
'scrollHeight',
|
|
54
|
-
'clientTop',
|
|
55
|
-
'clientLeft',
|
|
56
|
-
'clientWidth',
|
|
57
|
-
'clientHeight',
|
|
58
|
-
'firstElementChild',
|
|
59
|
-
'lastElementChild',
|
|
60
|
-
'childElementCount',
|
|
61
|
-
'previousElementSibling',
|
|
62
|
-
'nextElementSibling',
|
|
63
|
-
'currentCSSZoom',
|
|
64
|
-
'nodeType',
|
|
65
|
-
'nodeName',
|
|
66
|
-
'baseURI',
|
|
67
|
-
'isConnected',
|
|
68
|
-
'ownerDocument',
|
|
69
|
-
'parentNode',
|
|
70
|
-
'parentElement',
|
|
71
|
-
'previousSibling',
|
|
72
|
-
'nextSibling',
|
|
73
|
-
'ELEMENT_NODE',
|
|
74
|
-
'ATTRIBUTE_NODE',
|
|
75
|
-
'TEXT_NODE',
|
|
76
|
-
'CDATA_SECTION_NODE',
|
|
77
|
-
'ENTITY_REFERENCE_NODE',
|
|
78
|
-
'ENTITY_NODE',
|
|
79
|
-
'PROCESSING_INSTRUCTION_NODE',
|
|
80
|
-
'COMMENT_NODE',
|
|
81
|
-
'DOCUMENT_NODE',
|
|
82
|
-
'DOCUMENT_TYPE_NODE',
|
|
83
|
-
'DOCUMENT_FRAGMENT_NODE',
|
|
84
|
-
'NOTATION_NODE',
|
|
85
|
-
'DOCUMENT_POSITION_DISCONNECTED',
|
|
86
|
-
'DOCUMENT_POSITION_PRECEDING',
|
|
87
|
-
'DOCUMENT_POSITION_FOLLOWING',
|
|
88
|
-
'DOCUMENT_POSITION_CONTAINS',
|
|
89
|
-
'DOCUMENT_POSITION_CONTAINED_BY',
|
|
90
|
-
'DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC',
|
|
91
|
-
]);
|
|
92
|
-
/**
|
|
93
|
-
* Deep copy an HTML element with all its attributes, properties, and child nodes.
|
|
94
|
-
* This method is useful for creating a clone of an element that can be safely modified without affecting the original.
|
|
95
|
-
* @param {HTMLElement} element - The HTML element to copy.
|
|
96
|
-
* @returns {HTMLElement} - A deep copy of the HTML element.
|
|
97
|
-
* @example const copy = deepCopyElement(document.getElementById('myElement'));
|
|
98
|
-
*/
|
|
99
|
-
function deepCopyElement(element) {
|
|
100
|
-
const copy = document.createElement(element.tagName);
|
|
101
|
-
// ✅ Copy attributes
|
|
102
|
-
Array.from(element.attributes).forEach(attr => {
|
|
103
|
-
copy.setAttribute(attr.name, attr.value);
|
|
104
|
-
});
|
|
105
|
-
// ✅ Dynamically extract relevant properties
|
|
106
|
-
const properties = new Set();
|
|
107
|
-
// Collect only own enumerable properties
|
|
108
|
-
Object.keys(element).forEach(key => properties.add(key));
|
|
109
|
-
// Collect inherited properties from prototypes (HTMLElement -> Element -> Node)
|
|
110
|
-
let proto = Object.getPrototypeOf(element);
|
|
111
|
-
while (proto && proto !== HTMLElement.prototype) {
|
|
112
|
-
Object.keys(proto).forEach(key => properties.add(key));
|
|
113
|
-
proto = Object.getPrototypeOf(proto);
|
|
114
|
-
}
|
|
115
|
-
// ✅ Filter and copy only non-function properties (methods are excluded) and non-event listeners
|
|
116
|
-
properties.forEach(prop => {
|
|
117
|
-
if (typeof element[prop] !== 'function' && // Ignore methods
|
|
118
|
-
!prop.startsWith('on') && // Ignore event listeners (onclick, oninput, etc.)
|
|
119
|
-
!excludedProps.has(prop) // 🚨 Prevent text duplication and irrelevant props
|
|
120
|
-
) {
|
|
121
|
-
try {
|
|
122
|
-
copy[prop] = element[prop];
|
|
123
|
-
}
|
|
124
|
-
catch (error) {
|
|
125
|
-
console.warn(`Could not copy property ${prop}:`, error.message);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
// ✅ Copy dataset separately
|
|
130
|
-
Object.assign(copy.dataset, element.dataset);
|
|
131
|
-
// ✅ Handle form elements specifically
|
|
132
|
-
if (element instanceof HTMLInputElement) {
|
|
133
|
-
copy.value = element.value;
|
|
134
|
-
copy.checked = element.checked;
|
|
135
|
-
copy.defaultValue = element.defaultValue;
|
|
136
|
-
copy.defaultChecked = element.defaultChecked;
|
|
137
|
-
copy.selectionStart = element.selectionStart;
|
|
138
|
-
copy.selectionEnd = element.selectionEnd;
|
|
139
|
-
copy.selectionDirection = element.selectionDirection;
|
|
140
|
-
}
|
|
141
|
-
else if (element instanceof HTMLTextAreaElement) {
|
|
142
|
-
copy.value = element.value;
|
|
143
|
-
copy.defaultValue = element.defaultValue;
|
|
144
|
-
copy.selectionStart = element.selectionStart;
|
|
145
|
-
copy.selectionEnd = element.selectionEnd;
|
|
146
|
-
copy.selectionDirection =
|
|
147
|
-
element.selectionDirection;
|
|
148
|
-
}
|
|
149
|
-
else if (element instanceof HTMLSelectElement) {
|
|
150
|
-
copy.value = element.value;
|
|
151
|
-
copy.selectedIndex = element.selectedIndex;
|
|
152
|
-
}
|
|
153
|
-
// ✅ Recursively copy child nodes (prevent duplicates)
|
|
154
|
-
element.childNodes.forEach(child => {
|
|
155
|
-
let childCopy;
|
|
156
|
-
if (child.nodeType === Node.ELEMENT_NODE) {
|
|
157
|
-
childCopy = deepCopyElement(child);
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
childCopy = child.cloneNode(true);
|
|
161
|
-
}
|
|
162
|
-
copy.appendChild(childCopy);
|
|
163
|
-
});
|
|
164
|
-
return copy;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
exports.deepCopyElement = deepCopyElement;
|
|
168
|
-
exports.excludedProps = excludedProps;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var index = require('./index-CKAZvszR.js');
|
|
4
|
-
var clsx297c1ffe = require('./clsx-297c1ffe-BtxeOLZW.js');
|
|
5
|
-
var constantsD0f19e7b = require('./constants-d0f19e7b-s0SCO_vi.js');
|
|
6
|
-
require('react');
|
|
7
|
-
|
|
8
|
-
const nvAvatarCss = "nv-avatar{align-items:center !important;background-color:var(--components-avatar-background-1);border-radius:var(--radius-rounded-full) !important;display:flex !important;flex-shrink:0 !important;font-family:\"TT Norms Pro\", sans-serif;font-style:normal;font-weight:var(--font-weight-medium-emphasis);justify-content:center !important;leading-trim:both;line-height:1 !important;text-align:center;text-edge:cap;text-transform:uppercase}nv-avatar.avatar-color-1{background-color:var(--components-avatar-background-1);color:var(--components-avatar-content-1)}nv-avatar.avatar-color-2{background-color:var(--components-avatar-background-2);color:var(--components-avatar-content-2)}nv-avatar.avatar-color-3{background-color:var(--components-avatar-background-3);color:var(--components-avatar-content-3)}nv-avatar.avatar-color-4{background-color:var(--components-avatar-background-4);color:var(--components-avatar-content-4)}nv-avatar.avatar-color-5{background-color:var(--components-avatar-background-5);color:var(--components-avatar-content-5)}nv-avatar.avatar-color-6{background-color:var(--components-avatar-background-6);color:var(--components-avatar-content-6)}nv-avatar.avatar-color-7{background-color:var(--components-avatar-background-7);color:var(--components-avatar-content-7)}nv-avatar.avatar-color-8{background-color:var(--components-avatar-background-8);color:var(--components-avatar-content-8)}nv-avatar.avatar-color-9{background-color:var(--components-avatar-background-9);color:var(--components-avatar-content-9)}nv-avatar.avatar-color-10{background-color:var(--components-avatar-background-10);color:var(--components-avatar-content-10)}nv-avatar img{height:100%;width:100%;object-fit:cover;object-position:center;border-radius:50%}nv-avatar.avatar-xs{width:var(--avatar-xs-size);height:var(--avatar-xs-size);font-size:var(--avatar-xs-font-size);line-height:var(--avatar-xs-font-size)}nv-avatar.avatar-xs nv-icon>svg{width:var(--spacing-3);height:var(--spacing-3);stroke-width:1.2px}nv-avatar.avatar-sm{width:var(--avatar-sm-size);height:var(--avatar-sm-size);font-size:var(--avatar-sm-font-size);line-height:var(--avatar-sm-font-size)}nv-avatar.avatar-sm nv-icon>svg{width:var(--spacing-4);height:var(--spacing-4);stroke-width:1.5px}nv-avatar.avatar-md{width:var(--avatar-md-size);height:var(--avatar-md-size);font-size:var(--avatar-md-font-size);line-height:var(--avatar-md-font-size)}nv-avatar.avatar-md nv-icon>svg{width:var(--spacing-5);height:var(--spacing-5);stroke-width:1.6px}nv-avatar.avatar-lg{width:var(--avatar-lg-size);height:var(--avatar-lg-size);font-size:var(--avatar-lg-font-size);line-height:var(--avatar-lg-font-size)}nv-avatar.avatar-lg nv-icon>svg{width:var(--spacing-6);height:var(--spacing-6);stroke-width:1.8px}nv-avatar.avatar-xl{width:var(--avatar-xl-size);height:var(--avatar-xl-size);font-size:var(--avatar-xl-font-size);line-height:var(--avatar-xl-font-size)}nv-avatar.avatar-xl nv-icon>svg{width:var(--spacing-7);height:var(--spacing-7);stroke-width:1.9px}";
|
|
9
|
-
const NvAvatarStyle0 = nvAvatarCss;
|
|
10
|
-
|
|
11
|
-
const NvAvatar = class {
|
|
12
|
-
constructor(hostRef) {
|
|
13
|
-
index.registerInstance(this, hostRef);
|
|
14
|
-
/**
|
|
15
|
-
* Define the size of the avatar. You can use t-shirt sizes.
|
|
16
|
-
*/
|
|
17
|
-
this.size = 'md';
|
|
18
|
-
/**
|
|
19
|
-
* You can apply different colors on the Avatar.
|
|
20
|
-
* Use a string number between 1 and 10.
|
|
21
|
-
*/
|
|
22
|
-
this.color = '1';
|
|
23
|
-
}
|
|
24
|
-
componentWillRender() {
|
|
25
|
-
if (this.xsmall) {
|
|
26
|
-
this.size = constantsD0f19e7b.SemanticSizes.ExtraSmall;
|
|
27
|
-
}
|
|
28
|
-
if (this.small) {
|
|
29
|
-
this.size = constantsD0f19e7b.SemanticSizes.Small;
|
|
30
|
-
}
|
|
31
|
-
if (this.medium) {
|
|
32
|
-
this.size = constantsD0f19e7b.SemanticSizes.Medium;
|
|
33
|
-
}
|
|
34
|
-
if (this.large) {
|
|
35
|
-
this.size = constantsD0f19e7b.SemanticSizes.Large;
|
|
36
|
-
}
|
|
37
|
-
if (this.xlarge) {
|
|
38
|
-
this.size = constantsD0f19e7b.SemanticSizes.ExtraLarge;
|
|
39
|
-
}
|
|
40
|
-
if (this.text) {
|
|
41
|
-
this.initials = this.text;
|
|
42
|
-
}
|
|
43
|
-
if (this.url) {
|
|
44
|
-
this.src = this.url;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
//#endregion PROPERTIES
|
|
48
|
-
/****************************************************************************/
|
|
49
|
-
//#region METHODS
|
|
50
|
-
/**
|
|
51
|
-
* Makes sure the initials are trimmed to 2 letters.
|
|
52
|
-
* @param {string} initials - The initials to be trimmed.
|
|
53
|
-
* @returns {string} The trimmed initials.
|
|
54
|
-
*/
|
|
55
|
-
trimInitials(initials) {
|
|
56
|
-
return initials.trim().substring(0, 2);
|
|
57
|
-
}
|
|
58
|
-
//#endregion METHODS
|
|
59
|
-
/****************************************************************************/
|
|
60
|
-
//#region RENDER
|
|
61
|
-
render() {
|
|
62
|
-
return (index.h(index.Host, { key: '127d470eb9121f611f9e18f029ab9ef15a4a49df', class: clsx297c1ffe.clsx(`avatar-${this.size}`, `avatar-color-${this.color}`), "aria-label": this.alt }, this.src ? (index.h("img", { src: this.src, alt: this.alt })) : this.initials ? (this.trimInitials(this.initials)) : (index.h("slot", { name: "icon" }, index.h("nv-icon", { name: "user" })))));
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
NvAvatar.style = NvAvatarStyle0;
|
|
66
|
-
|
|
67
|
-
exports.nv_avatar = NvAvatar;
|