@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
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var index = require('./index-CKAZvszR.js');
|
|
4
|
-
var constantsD0f19e7b = require('./constants-d0f19e7b-s0SCO_vi.js');
|
|
5
|
-
var collapse_animationAcda1bf5 = require('./collapse.animation-acda1bf5-BuORVmQv.js');
|
|
6
|
-
var fade_animationEb454088 = require('./fade.animation-eb454088-Bma0SpTf.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
|
-
|
|
12
|
-
const useSlide = (node, { duration } = { duration: 200 }) => {
|
|
13
|
-
const nodeStyler = fade_animationEb454088.index(node);
|
|
14
|
-
/**
|
|
15
|
-
* Will animate the translateX to 100%, sliding the element to the right.
|
|
16
|
-
*/
|
|
17
|
-
function slideOut() {
|
|
18
|
-
return new Promise(resolve => {
|
|
19
|
-
styleValueTypes_esF5d10b79.animate({
|
|
20
|
-
from: { x: 0 },
|
|
21
|
-
to: { x: 100 },
|
|
22
|
-
ease: styleValueTypes_esF5d10b79.easeOut,
|
|
23
|
-
duration,
|
|
24
|
-
onUpdate(latest) {
|
|
25
|
-
nodeStyler.set({ transform: `translateX(${latest.x}%)` });
|
|
26
|
-
},
|
|
27
|
-
onComplete() {
|
|
28
|
-
resolve();
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Applies the slideOut styles without animating, useful when initial state
|
|
35
|
-
* is slid out.
|
|
36
|
-
*/
|
|
37
|
-
function setSlideOut() {
|
|
38
|
-
node.style.transform = 'translateX(100%)';
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Applies the slideIn styles without animating, useful when initial state
|
|
42
|
-
* is slid in.
|
|
43
|
-
*/
|
|
44
|
-
function setSlideIn() {
|
|
45
|
-
node.style.transform = '';
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Will animate the translateX from 100% to 0%, sliding the element in from the right.
|
|
49
|
-
*/
|
|
50
|
-
function slideIn() {
|
|
51
|
-
return new Promise(resolve => {
|
|
52
|
-
styleValueTypes_esF5d10b79.animate({
|
|
53
|
-
from: { x: 100 },
|
|
54
|
-
to: { x: 0 },
|
|
55
|
-
duration,
|
|
56
|
-
onUpdate(latest) {
|
|
57
|
-
nodeStyler.set({ transform: `translateX(${latest.x}%)` });
|
|
58
|
-
},
|
|
59
|
-
onComplete() {
|
|
60
|
-
resolve();
|
|
61
|
-
node.style.removeProperty('transform');
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
return {
|
|
67
|
-
slideIn,
|
|
68
|
-
slideOut,
|
|
69
|
-
setSlideOut,
|
|
70
|
-
setSlideIn,
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
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]>nv-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]>nv-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]>nv-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]>nv-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]>nv-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]>nv-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)}";
|
|
75
|
-
const NvNotificationStyle0 = nvNotificationCss;
|
|
76
|
-
|
|
77
|
-
const NvNotification = class {
|
|
78
|
-
constructor(hostRef) {
|
|
79
|
-
index.registerInstance(this, hostRef);
|
|
80
|
-
this.hiddenChanged = index.createEvent(this, "hiddenChanged");
|
|
81
|
-
/****************************************************************************/
|
|
82
|
-
//#region PROPERTIES
|
|
83
|
-
/**
|
|
84
|
-
* Set a unique ID for the notification. Used for aria attributes and managing
|
|
85
|
-
* multiple notifications.
|
|
86
|
-
*/
|
|
87
|
-
this.uid = v4A79185f4.v4();
|
|
88
|
-
/**
|
|
89
|
-
* Specifies the notification type which determines the color and default icon.
|
|
90
|
-
*/
|
|
91
|
-
this.feedback = 'information';
|
|
92
|
-
/**
|
|
93
|
-
* Adjusts the emphasis to make the notification more or less visually
|
|
94
|
-
* prominent to users. Use this to draw attention to important actions or
|
|
95
|
-
* reduce focus on less critical ones
|
|
96
|
-
*/
|
|
97
|
-
this.emphasis = 'medium';
|
|
98
|
-
/**
|
|
99
|
-
* Allows the notification to be dismissed via a close button (x). The
|
|
100
|
-
* notification is not dismissible unless explicitly enabled.
|
|
101
|
-
*/
|
|
102
|
-
this.dismissible = false;
|
|
103
|
-
/**
|
|
104
|
-
* Controls the visibility of the notification.
|
|
105
|
-
*/
|
|
106
|
-
this.hidden = false; // eslint-disable-line @stencil-community/reserved-member-names
|
|
107
|
-
//#endregion EVENTS
|
|
108
|
-
/****************************************************************************/
|
|
109
|
-
//#region INTERNAL
|
|
110
|
-
this.iconByFeedback = {
|
|
111
|
-
[constantsD0f19e7b.FeedbackColors.Warning]: 'alert-circle',
|
|
112
|
-
[constantsD0f19e7b.FeedbackColors.Information]: 'info-circle',
|
|
113
|
-
[constantsD0f19e7b.FeedbackColors.Success]: 'circle-check',
|
|
114
|
-
[constantsD0f19e7b.FeedbackColors.Error]: 'alert-triangle',
|
|
115
|
-
[constantsD0f19e7b.FeedbackColors.Neutral]: 'help',
|
|
116
|
-
};
|
|
117
|
-
this.roleByFeedback = {
|
|
118
|
-
[constantsD0f19e7b.FeedbackColors.Error]: 'alert',
|
|
119
|
-
[constantsD0f19e7b.FeedbackColors.Warning]: 'alert',
|
|
120
|
-
[constantsD0f19e7b.FeedbackColors.Information]: 'status',
|
|
121
|
-
[constantsD0f19e7b.FeedbackColors.Success]: 'status',
|
|
122
|
-
[constantsD0f19e7b.FeedbackColors.Neutral]: 'status',
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
//#endregion PROPERTIES
|
|
126
|
-
/****************************************************************************/
|
|
127
|
-
//#region METHODS
|
|
128
|
-
async dismiss() {
|
|
129
|
-
await this.dismissAnimation();
|
|
130
|
-
}
|
|
131
|
-
getDefaultIcon() {
|
|
132
|
-
var _a;
|
|
133
|
-
return (_a = this.iconByFeedback[this.feedback]) !== null && _a !== void 0 ? _a : 'info-circle';
|
|
134
|
-
}
|
|
135
|
-
getAriaRole() {
|
|
136
|
-
var _a;
|
|
137
|
-
return (_a = this.roleByFeedback[this.feedback]) !== null && _a !== void 0 ? _a : 'status';
|
|
138
|
-
}
|
|
139
|
-
getAriaLive() {
|
|
140
|
-
return this.getAriaRole() === 'alert' ? 'assertive' : 'polite';
|
|
141
|
-
}
|
|
142
|
-
getHeadingId() {
|
|
143
|
-
return this.heading ? `nv-notification-${this.uid}-heading` : null;
|
|
144
|
-
}
|
|
145
|
-
getMessageId() {
|
|
146
|
-
return this.message ? `nv-notification-${this.uid}-message` : null;
|
|
147
|
-
}
|
|
148
|
-
async dismissAnimation() {
|
|
149
|
-
const { fadeOut } = fade_animationEb454088.useFade(this.container, { duration: 300 });
|
|
150
|
-
const { slideOut } = useSlide(this.container, { duration: 800 });
|
|
151
|
-
const { collapse } = collapse_animationAcda1bf5.useCollapse(this.el, {
|
|
152
|
-
duration: 800,
|
|
153
|
-
overflow: 'visible',
|
|
154
|
-
});
|
|
155
|
-
await timeline_animation79215cd4.parallel(fadeOut, slideOut, collapse).start();
|
|
156
|
-
this.hidden = true;
|
|
157
|
-
this.hiddenChanged.emit(true);
|
|
158
|
-
}
|
|
159
|
-
//#endregion INTERNAL
|
|
160
|
-
/****************************************************************************/
|
|
161
|
-
//#region LIFECYCLE
|
|
162
|
-
componentWillLoad() {
|
|
163
|
-
this.headingSlot = this.el.querySelector('[slot="heading"]');
|
|
164
|
-
this.messageSlot = this.el.querySelector('[slot="content"]');
|
|
165
|
-
this.actionsSlot = this.el.querySelector('[slot="actions"]');
|
|
166
|
-
}
|
|
167
|
-
//#endregion LIFECYCLE
|
|
168
|
-
/****************************************************************************/
|
|
169
|
-
//#region RENDER
|
|
170
|
-
render() {
|
|
171
|
-
var _a, _b, _c;
|
|
172
|
-
return (index.h(index.Host, { key: '9146cea4ed72801aadf2fb4b7e44895038c98437', 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: 'beed9ae5f6fac1b0c6d103dd75a41e0aede84041', "data-scope": "container", ref: el => (this.container = el) }, this.dismissible && (index.h("button", { key: '8e17f33867c2563de719dc1b0f0e2d4ae39ad1a6', "data-scope": "dismiss", type: "button", onClick: this.dismiss.bind(this) }, index.h("nv-icon", { key: 'cb8850135bb2383e33a16671569547611b55e434', name: "x", size: "sm" }))), index.h("nv-icon", { key: 'f5f58e1c3a94d854841271eb12af047322b2f0b4', name: (_c = this.icon) !== null && _c !== void 0 ? _c : this.getDefaultIcon(), size: "md" }), index.h("div", { key: '9c6f6bb0315cd25260d483472a24832031ce45da', "data-scope": "content" }, (this.heading || this.headingSlot) && (index.h("p", { key: '1013d6b6790f75682a1db0e43293b61e614f1c07', id: this.getHeadingId(), "data-scope": "heading" }, index.h("slot", { key: '844a7bccf6f365d4e59dfdec9b3c9096cbeda798', name: "heading" }, this.heading))), (this.message || this.messageSlot) && (index.h("p", { key: '6688e9dc927f6164ce60f27b84fdbeb257296504', id: this.getMessageId(), "data-scope": "message" }, index.h("slot", { key: 'f0c0790faa40411970575240a081f0f0bf0e9aff', name: "content" }, this.message))), this.actionsSlot && (index.h("div", { key: '0ba946edf5b3a8410da3b375e589613a2674fd15', "data-scope": "actions" }, index.h("slot", { key: '0360ab92db66957f0290569c39307ced2be5922d', name: "actions" })))))));
|
|
173
|
-
}
|
|
174
|
-
get el() { return index.getElement(this); }
|
|
175
|
-
};
|
|
176
|
-
NvNotification.style = NvNotificationStyle0;
|
|
177
|
-
|
|
178
|
-
exports.nv_notification = NvNotification;
|
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var index = require('./index-CKAZvszR.js');
|
|
4
|
-
var dom_utilsAc71e0ef = require('./dom.utils-ac71e0ef-CmIwRr6O.js');
|
|
5
|
-
require('react');
|
|
6
|
-
|
|
7
|
-
const nvTableCss = "nv-table{display:block}nv-table .hidden{display:none}nv-table table{border-collapse:collapse;border-color:inherit;text-indent:0;width:100%}nv-table th{text-align:left;border-bottom:1px solid var(--components-datagrid-header-border);height:var(--spacing-12);padding:var(--spacing-3) var(--spacing-4);font-size:var(--font-size-md);font-weight:700;color:var(--components-datagrid-header-text)}nv-table td{border-bottom:1px solid var(--components-datagrid-body-border);height:var(--spacing-12);max-height:var(--spacing-14);padding:var(--spacing-2) var(--spacing-4);font-size:var(--font-size-md);font-weight:400;color:var(--components-datagrid-body-text);white-space:nowrap;text-overflow:ellipsis}nv-table tbody>tr:hover{background:var(--color-interaction-container-neutral-background-hover)}";
|
|
8
|
-
const NvTableStyle0 = nvTableCss;
|
|
9
|
-
|
|
10
|
-
const NvTable = class {
|
|
11
|
-
constructor(hostRef) {
|
|
12
|
-
index.registerInstance(this, hostRef);
|
|
13
|
-
this.action = index.createEvent(this, "action");
|
|
14
|
-
this.templateCache = new Map();
|
|
15
|
-
this.headerTemplateCache = new Map();
|
|
16
|
-
/****************************************************************************/
|
|
17
|
-
//#region STATES
|
|
18
|
-
this.parsedColumns = [];
|
|
19
|
-
this.parsedData = [];
|
|
20
|
-
this.table = null;
|
|
21
|
-
//#endregion STATES
|
|
22
|
-
/****************************************************************************/
|
|
23
|
-
//#region PROPERTIES
|
|
24
|
-
/**
|
|
25
|
-
* Data to be displayed in the table
|
|
26
|
-
*/
|
|
27
|
-
this.data = [];
|
|
28
|
-
/**
|
|
29
|
-
* Configuration of the columns of the table
|
|
30
|
-
*/
|
|
31
|
-
this.columnsConfig = [];
|
|
32
|
-
/**
|
|
33
|
-
* Fallback value to be displayed when data is not available
|
|
34
|
-
*/
|
|
35
|
-
this.fallbackValue = 'N/A';
|
|
36
|
-
/**
|
|
37
|
-
* Message to be displayed when no data is available
|
|
38
|
-
*/
|
|
39
|
-
this.noDataMessage = 'No data available';
|
|
40
|
-
/**
|
|
41
|
-
* The message to display when there are no columns or data available.
|
|
42
|
-
* @default 'No data or columns available to display.'
|
|
43
|
-
*/
|
|
44
|
-
this.noColumnsNoDataMessage = 'No data or columns available to display.';
|
|
45
|
-
}
|
|
46
|
-
//#endregion PROPERTIES
|
|
47
|
-
/****************************************************************************/
|
|
48
|
-
//#region METHODS
|
|
49
|
-
/**
|
|
50
|
-
* Caches templates for cells and headers upfront to improve performance.
|
|
51
|
-
*/
|
|
52
|
-
cacheTemplates() {
|
|
53
|
-
const columns = Array.from(this.el.querySelectorAll('nv-tablecolumn'));
|
|
54
|
-
columns.forEach((col) => {
|
|
55
|
-
const key = col.name;
|
|
56
|
-
const cellSlot = col.querySelector('[slot="cell"]');
|
|
57
|
-
if (cellSlot) {
|
|
58
|
-
const element = dom_utilsAc71e0ef.deepCopyElement(cellSlot);
|
|
59
|
-
this.templateCache.set(key, element);
|
|
60
|
-
}
|
|
61
|
-
const headerSlot = col.querySelector('[slot="header"]');
|
|
62
|
-
if (headerSlot) {
|
|
63
|
-
const element = dom_utilsAc71e0ef.deepCopyElement(headerSlot);
|
|
64
|
-
this.headerTemplateCache.set(key, element);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
const header = col.header;
|
|
68
|
-
if (header) {
|
|
69
|
-
const headerDiv = document.createElement('div');
|
|
70
|
-
headerDiv.textContent = header;
|
|
71
|
-
this.headerTemplateCache.set(key, headerDiv);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
parseDataAndColumns() {
|
|
77
|
-
if (this.dataJson) {
|
|
78
|
-
this.parseJsonData(this.dataJson);
|
|
79
|
-
}
|
|
80
|
-
else if (this.data && this.data.length > 0) {
|
|
81
|
-
this.parseDataArray(this.data, this.parsedData);
|
|
82
|
-
}
|
|
83
|
-
if (this.columnsConfigJson) {
|
|
84
|
-
this.parseJsonColumns(this.columnsConfigJson, this.parsedColumns);
|
|
85
|
-
}
|
|
86
|
-
else if (this.columnsConfig && this.columnsConfig.length > 0) {
|
|
87
|
-
this.parseColumnsArray(this.columnsConfig, this.parsedColumns);
|
|
88
|
-
}
|
|
89
|
-
else if (this.headerTemplateCache.size > 0) {
|
|
90
|
-
const headerKeys = Array.from(this.headerTemplateCache.keys());
|
|
91
|
-
const arrayColumnsConfig = headerKeys.map(key => (Object.assign({}, { name: key, header: key ? key.charAt(0).toUpperCase() + key.slice(1) : '' })));
|
|
92
|
-
this.parseColumnsArray(arrayColumnsConfig, this.parsedColumns);
|
|
93
|
-
}
|
|
94
|
-
else if (this.parsedData.length > 0) {
|
|
95
|
-
const firstRow = this.parsedData[0];
|
|
96
|
-
const arrayColumnsConfig = Object.keys(firstRow).map(key => ({
|
|
97
|
-
name: key,
|
|
98
|
-
header: key.charAt(0).toUpperCase() + key.slice(1),
|
|
99
|
-
}));
|
|
100
|
-
this.parseColumnsArray(arrayColumnsConfig, this.parsedColumns);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
deepEqual(a, b) {
|
|
104
|
-
return JSON.stringify(a) === JSON.stringify(b);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Parses the data array and sets the state accordingly
|
|
108
|
-
* @param {any[]} newValue - New value of the data array
|
|
109
|
-
* @param {any[]} oldValue - Old value of the data array
|
|
110
|
-
* @returns {void}
|
|
111
|
-
*/
|
|
112
|
-
parseDataArray(newValue, oldValue) {
|
|
113
|
-
// Ensure both are arrays for proper comparison
|
|
114
|
-
const safeNewValue = Array.isArray(newValue) ? newValue : [];
|
|
115
|
-
const safeOldValue = Array.isArray(oldValue) ? oldValue : [];
|
|
116
|
-
if (this.deepEqual(safeNewValue, safeOldValue)) {
|
|
117
|
-
return; // Deep comparison
|
|
118
|
-
}
|
|
119
|
-
this.parsedData = Array.isArray(newValue) ? newValue : [];
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Parses the columns array and sets the state accordingly
|
|
123
|
-
* @param {ColumnConfig[]} newValue - New value of the columns array
|
|
124
|
-
* @param {ColumnConfig[]} oldValue - Old value of the columns array
|
|
125
|
-
* @returns {void}
|
|
126
|
-
*/
|
|
127
|
-
parseColumnsArray(newValue, oldValue) {
|
|
128
|
-
// Ensure both are arrays for proper comparison
|
|
129
|
-
const safeNewValue = Array.isArray(newValue) ? newValue : [];
|
|
130
|
-
const safeOldValue = Array.isArray(oldValue) ? oldValue : [];
|
|
131
|
-
// Use a proper deep comparison function (e.g., Lodash's isEqual)
|
|
132
|
-
if (this.deepEqual(safeNewValue, safeOldValue)) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
// Assign only after confirming changes
|
|
136
|
-
this.parsedColumns = safeNewValue;
|
|
137
|
-
}
|
|
138
|
-
initializeTable() {
|
|
139
|
-
// Clear the previous table instance (if any)
|
|
140
|
-
this.table = null;
|
|
141
|
-
if (this.parsedColumns.length > 0) {
|
|
142
|
-
this.table = {
|
|
143
|
-
columns: this.parsedColumns,
|
|
144
|
-
data: this.getTableData(),
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
this.table = null;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
getTableData() {
|
|
152
|
-
if (this.parsedData &&
|
|
153
|
-
Array.isArray(this.parsedData) &&
|
|
154
|
-
this.parsedData.length > 0) {
|
|
155
|
-
return [...this.parsedData];
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
return [];
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
// Helper function to get nested property value
|
|
162
|
-
replaceKeyWithValue(obj, path) {
|
|
163
|
-
var _a;
|
|
164
|
-
return ((_a = path
|
|
165
|
-
.split('.')
|
|
166
|
-
.reduce((acc, key) => (acc && acc[key] !== undefined ? acc[key] : undefined), obj)) !== null && _a !== void 0 ? _a : this.fallbackValue);
|
|
167
|
-
}
|
|
168
|
-
renderTemplate(template, row) {
|
|
169
|
-
if (!template) {
|
|
170
|
-
return null;
|
|
171
|
-
}
|
|
172
|
-
// Handle <template> elements correctly
|
|
173
|
-
const templateContent = template instanceof HTMLTemplateElement ? template.content : template;
|
|
174
|
-
const element = dom_utilsAc71e0ef.deepCopyElement(templateContent);
|
|
175
|
-
// Replace placeholders in text content, attributes, and properties
|
|
176
|
-
element.querySelectorAll('*').forEach(el => {
|
|
177
|
-
// Replace placeholders in text content
|
|
178
|
-
this.replacePlaceholdersTextContent(el, row);
|
|
179
|
-
// Replace placeholders in attributes
|
|
180
|
-
this.replacePlaceholdersAttributes(el, row);
|
|
181
|
-
// Replace placeholders in properties
|
|
182
|
-
this.replacePlaceholdersProperties(el, row);
|
|
183
|
-
});
|
|
184
|
-
// Handle `data-bind-event`
|
|
185
|
-
element.querySelectorAll('[data-bind-event]').forEach(el => {
|
|
186
|
-
const bindEvent = el.getAttribute('data-bind-event') || '';
|
|
187
|
-
const splitted = bindEvent.split(':');
|
|
188
|
-
if (!bindEvent.includes(':') || splitted.length < 2) {
|
|
189
|
-
console.warn('Invalid data-bind-event format:', bindEvent);
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
const eventType = splitted[0];
|
|
193
|
-
const keyAction = splitted[1];
|
|
194
|
-
const details = splitted.length > 2 ? splitted[2] : null;
|
|
195
|
-
el.addEventListener(eventType, () => {
|
|
196
|
-
var _a;
|
|
197
|
-
const keys = (_a = details === null || details === void 0 ? void 0 : details.split(',')) !== null && _a !== void 0 ? _a : [];
|
|
198
|
-
// Convert keys into a single object instead of an array of objects
|
|
199
|
-
const keyValue = keys.reduce((acc, key) => {
|
|
200
|
-
acc[key] = row === null || row === void 0 ? void 0 : row[key];
|
|
201
|
-
return acc;
|
|
202
|
-
}, {});
|
|
203
|
-
const action = { keyAction, details: keyValue };
|
|
204
|
-
this.action.emit(action);
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
// Ensure Web Components are properly connected
|
|
208
|
-
setTimeout(() => {
|
|
209
|
-
element.querySelectorAll('*').forEach(child => {
|
|
210
|
-
if (typeof child.connectedCallback === 'function') {
|
|
211
|
-
child.connectedCallback();
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
}, 0);
|
|
215
|
-
return (index.h("div", { ref: el => {
|
|
216
|
-
if (el) {
|
|
217
|
-
el.innerHTML = ''; // Remove existing content
|
|
218
|
-
el.appendChild(element); // Append new element
|
|
219
|
-
}
|
|
220
|
-
} }));
|
|
221
|
-
}
|
|
222
|
-
replacePlaceholdersTextContent(element, row) {
|
|
223
|
-
// ✅ Replace placeholders in text content
|
|
224
|
-
element.childNodes.forEach(node => {
|
|
225
|
-
if (node.nodeType === Node.TEXT_NODE) {
|
|
226
|
-
node.textContent = node.textContent.replace(/__([\w.]+)__/g, (_, key) => this.replaceKeyWithValue(row, key));
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
replacePlaceholdersAttributes(element, row) {
|
|
231
|
-
// ✅ Replace placeholders in attributes
|
|
232
|
-
Array.from(element.attributes).forEach(attr => {
|
|
233
|
-
if (attr.value.includes('__')) {
|
|
234
|
-
attr.value = attr.value.replace(/__([\w.]+)__/g, (_, key) => this.replaceKeyWithValue(row, key));
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
replacePlaceholdersProperties(element, row) {
|
|
239
|
-
// ✅ Dynamically extract relevant properties
|
|
240
|
-
const properties = new Set();
|
|
241
|
-
// Collect only own enumerable properties
|
|
242
|
-
Object.keys(element).forEach(key => properties.add(key));
|
|
243
|
-
// Collect inherited properties from prototypes (HTMLElement -> Element -> Node)
|
|
244
|
-
let proto = Object.getPrototypeOf(element);
|
|
245
|
-
while (proto && proto !== HTMLElement.prototype) {
|
|
246
|
-
Object.keys(proto).forEach(key => properties.add(key));
|
|
247
|
-
proto = Object.getPrototypeOf(proto);
|
|
248
|
-
}
|
|
249
|
-
// ✅ Filter and copy only non-function properties and exclude irrelevant ones
|
|
250
|
-
properties.forEach(prop => {
|
|
251
|
-
if (typeof element[prop] !== 'function' && // Ignore methods
|
|
252
|
-
!prop.startsWith('on') && // Ignore event listeners (onclick, oninput, etc.)
|
|
253
|
-
!dom_utilsAc71e0ef.excludedProps.has(prop) // 🚨 Prevent text duplication and irrelevant props
|
|
254
|
-
) {
|
|
255
|
-
try {
|
|
256
|
-
const value = element[prop];
|
|
257
|
-
// ✅ Replace placeholders only if the value is a string
|
|
258
|
-
if (typeof value === 'string' && value.includes('__')) {
|
|
259
|
-
element[prop] = value.replace(/__([\w.]+)__/g, (_, key) => this.replaceKeyWithValue(row, key)); // ✅ TypeScript safe
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
catch (error) {
|
|
263
|
-
console.warn(`Could not assign property ${prop}:`, error.message);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
//#endregion METHODS
|
|
269
|
-
/****************************************************************************/
|
|
270
|
-
//#region WATCHERS
|
|
271
|
-
parseColumns(newValue, oldValue) {
|
|
272
|
-
this.parseColumnsArray(newValue, oldValue);
|
|
273
|
-
}
|
|
274
|
-
parseJsonColumns(newValue, oldValue) {
|
|
275
|
-
try {
|
|
276
|
-
const newItems = newValue ? JSON.parse(newValue) : [];
|
|
277
|
-
this.parseColumnsArray(newItems, oldValue);
|
|
278
|
-
}
|
|
279
|
-
catch (e) {
|
|
280
|
-
console.error('Invalid JSON format for columnsConfigJson:', e.message);
|
|
281
|
-
this.parsedColumns = [];
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
parseData(newValue, oldValue) {
|
|
285
|
-
this.parseDataArray(newValue, oldValue);
|
|
286
|
-
}
|
|
287
|
-
parseJsonData(newValue) {
|
|
288
|
-
try {
|
|
289
|
-
const newItems = newValue ? JSON.parse(newValue) : [];
|
|
290
|
-
this.parseDataArray(newItems, this.parsedData);
|
|
291
|
-
}
|
|
292
|
-
catch (e) {
|
|
293
|
-
console.error('Invalid JSON format for dataJson:', e.message);
|
|
294
|
-
this.parsedData = [];
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
handleParsedChange() {
|
|
298
|
-
this.initializeTable();
|
|
299
|
-
}
|
|
300
|
-
//#endregion WATCHERS
|
|
301
|
-
/****************************************************************************/
|
|
302
|
-
//#region LIFECYCLE
|
|
303
|
-
componentWillLoad() {
|
|
304
|
-
this.cacheTemplates();
|
|
305
|
-
this.parseDataAndColumns();
|
|
306
|
-
}
|
|
307
|
-
//#endregion EVENTS
|
|
308
|
-
/****************************************************************************/
|
|
309
|
-
//#region RENDER
|
|
310
|
-
render() {
|
|
311
|
-
const headerGroups = !this.table || this.table === undefined || this.parsedColumns.length === 0
|
|
312
|
-
? []
|
|
313
|
-
: this.table.columns;
|
|
314
|
-
const rows = !this.table || this.table === undefined || this.parsedData.length === 0
|
|
315
|
-
? []
|
|
316
|
-
: this.table.data;
|
|
317
|
-
return (index.h(index.Host, { key: 'ea0b3237145fbc199d356010f1e001797afc52d6' }, index.h("div", { key: 'd3bf41bad48e549d1799b2c8e55a308a7d767973', class: "hidden" }, index.h("slot", { key: '8263220ebd266240b16228b67f8d215d7d56afd7' })), index.h("slot", { key: '36d43d6870cf9a6021521579c0507afd1fe85081', name: "before" }), this.parsedColumns.length === 0 && this.parsedData.length === 0 ? (index.h("div", { class: "no-data" }, this.noColumnsNoDataMessage)) : (index.h("table", { class: "table" }, this.parsedColumns.length > 0 && headerGroups.length > 0 && (index.h("thead", { class: "table-header" }, index.h("tr", null, headerGroups &&
|
|
318
|
-
headerGroups.map(col => {
|
|
319
|
-
return (index.h("th", { key: col.name }, this.renderTemplate(this.headerTemplateCache.get(col.name), {}) || col.header));
|
|
320
|
-
})))), index.h("tbody", { class: "table-body" }, !rows || rows.length === 0 ? (index.h("tr", null, index.h("td", { colSpan: headerGroups.length || 12, class: "no-data" }, this.noDataMessage))) : (rows.map(row => (index.h("tr", { key: JSON.stringify(row) }, headerGroups.map(col => {
|
|
321
|
-
var _a;
|
|
322
|
-
return (index.h("td", null, this.renderTemplate(this.templateCache.get(col.name), row) ||
|
|
323
|
-
((_a = row[col.name]) !== null && _a !== void 0 ? _a : this.fallbackValue)));
|
|
324
|
-
})))))))), index.h("slot", { key: '233b61e9099f58ca0eeeb7d0f7fdc7bd71bc9065', name: "after" })));
|
|
325
|
-
}
|
|
326
|
-
get el() { return index.getElement(this); }
|
|
327
|
-
static get watchers() { return {
|
|
328
|
-
"columnsConfig": ["parseColumns"],
|
|
329
|
-
"columnsConfigJson": ["parseJsonColumns"],
|
|
330
|
-
"data": ["parseData"],
|
|
331
|
-
"dataJson": ["parseJsonData"],
|
|
332
|
-
"parsedColumns": ["handleParsedChange"],
|
|
333
|
-
"parsedData": ["handleParsedChange"]
|
|
334
|
-
}; }
|
|
335
|
-
};
|
|
336
|
-
NvTable.style = NvTableStyle0;
|
|
337
|
-
|
|
338
|
-
exports.nv_table = NvTable;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var index = require('./index-CKAZvszR.js');
|
|
4
|
-
require('react');
|
|
5
|
-
|
|
6
|
-
const NvTablecolumn = class {
|
|
7
|
-
constructor(hostRef) {
|
|
8
|
-
index.registerInstance(this, hostRef);
|
|
9
|
-
}
|
|
10
|
-
//#endregion PROPERTIES
|
|
11
|
-
/****************************************************************************/
|
|
12
|
-
//#region RENDER
|
|
13
|
-
render() {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
exports.nv_tablecolumn = NvTablecolumn;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var index = require('./index-CKAZvszR.js');
|
|
4
|
-
var clsx297c1ffe = require('./clsx-297c1ffe-BtxeOLZW.js');
|
|
5
|
-
var v4A79185f4 = require('./v4-a79185f4-2n0dOd_Y.js');
|
|
6
|
-
require('react');
|
|
7
|
-
|
|
8
|
-
const nvToggleCss = "nv-toggle{display:inline-flex;align-items:flex-start;gap:var(--form-gap-x);position:relative}nv-toggle:not([disabled],[readonly]) input,nv-toggle:not([disabled],[readonly]) label{cursor:pointer}nv-toggle.label-placement-before{flex-direction:row-reverse}nv-toggle[disabled]{opacity:0.5}nv-toggle label{align-self:stretch;color:var(--components-form-text-label-default);font-family:\"TT Norms Pro\", sans-serif;font-size:var(--form-label-font-size);font-style:normal;font-weight:500;line-height:var(--form-label-line-height)}nv-toggle label.visually-hidden{position:absolute;padding:0;border:0;overflow:hidden;white-space:nowrap;width:1px;height:1px;margin:-1px;clip:rect(0, 0, 0, 0)}nv-toggle .input-container{position:relative;color:var(--components-form-shape-foreground-default)}nv-toggle .input-container:has(input[type=checkbox]:disabled:not([readonly])){color:var(--components-form-shape-foreground-disabled)}nv-toggle .input-container input[type=checkbox]{appearance:none;position:relative;display:flex;width:var(--form-toggle-width);height:var(--form-toggle-height);flex-direction:column;align-items:flex-start;border-radius:var(--form-toggle-radius);border-width:var(--form-toggle-border-width);border-style:solid;border-color:var(--components-toggle-border-default);background:var(--components-toggle-background-default)}nv-toggle .input-container input[type=checkbox]::after{content:\"\";display:block;width:var(--form-toggle-switch-dot-default);height:var(--form-toggle-switch-dot-default);background-color:var(--components-toggle-shape-default);border-radius:var(--radius-rounded-full);position:absolute;top:50%;left:25%;transform:translate(-50%, -50%)}nv-toggle .input-container input[type=checkbox]:hover{border-color:var(--components-toggle-border-hover)}nv-toggle .input-container input[type=checkbox]:hover::after{background-color:var(--components-toggle-shape-hover)}nv-toggle .input-container input[type=checkbox]:focus{border-color:var(--components-toggle-border-default)}nv-toggle .input-container input[type=checkbox]:focus::after{background-color:var(--components-toggle-shape-default)}nv-toggle .input-container input[type=checkbox]:focus,nv-toggle .input-container input[type=checkbox]:focus-within{outline:none}nv-toggle .input-container input[type=checkbox]:focus-visible,nv-toggle .input-container input[type=checkbox]:has(:focus-visible){outline:calc(var(--focus-outline-stroke) * 1) solid var(--color-focus-brand);outline-offset:calc(var(--focus-outline-offset) * 1)}nv-toggle .input-container input[type=checkbox]:checked{background:var(--components-toggle-background-default-checked);border-color:var(--components-toggle-border-default-checked)}nv-toggle .input-container input[type=checkbox]:checked::after{content:\"\";display:block;width:var(--form-toggle-switch-dot-default);height:var(--form-toggle-switch-dot-default);background-color:var(--components-toggle-shape-default-checked);border-radius:var(--radius-rounded-full);position:absolute;top:50%;left:75%;transform:translate(-50%, -50%)}nv-toggle .input-container input[type=checkbox]:checked:focus{background:var(--components-toggle-background-default-checked);border-color:var(--components-toggle-border-default-checked)}nv-toggle .input-container input[type=checkbox]:disabled:not([readonly]){box-shadow:unset;background:var(--components-toggle-background-disabled);border-color:var(--components-toggle-border-default)}nv-toggle .input-container input[type=checkbox]:disabled:not([readonly]):checked{background:var(--components-toggle-background-disabled-checked);border-color:var(--components-toggle-border-disabled-checked)}nv-toggle .input-container input[type=checkbox]:disabled:not([readonly]):checked::after{background-color:var(--components-toggle-shape-disabled-checked)}nv-toggle .description{align-self:stretch;color:var(--components-form-text-description-default);font-family:\"TT Norms Pro\", sans-serif;font-size:var(--form-description-font-size);font-style:normal;font-weight:450;line-height:var(--form-description-line-height)}nv-toggle .text-container{display:flex;flex-direction:column;align-items:flex-start;flex:1 0 0}";
|
|
9
|
-
const NvToggleStyle0 = nvToggleCss;
|
|
10
|
-
|
|
11
|
-
const NvToggle = class {
|
|
12
|
-
constructor(hostRef) {
|
|
13
|
-
index.registerInstance(this, hostRef);
|
|
14
|
-
this.checkedChanged = index.createEvent(this, "checkedChanged");
|
|
15
|
-
/****************************************************************************/
|
|
16
|
-
//#region PROPERTIES
|
|
17
|
-
/**
|
|
18
|
-
* Sets the ID for the radio button’s input element and the for attribute of
|
|
19
|
-
* the associated label. If no ID is provided, a random one will be
|
|
20
|
-
* automatically generated to ensure unique identification, facilitating
|
|
21
|
-
* proper label association and accessibility.
|
|
22
|
-
*/
|
|
23
|
-
this.inputId = v4A79185f4.v4();
|
|
24
|
-
/**
|
|
25
|
-
* Hides the label visually while still keeping it available for screen
|
|
26
|
-
* readers.
|
|
27
|
-
*/
|
|
28
|
-
this.hideLabel = false;
|
|
29
|
-
/** Indicates whether the toggle is checked or not. */
|
|
30
|
-
this.checked = false;
|
|
31
|
-
/** Disables the toggle, preventing user interaction. */
|
|
32
|
-
this.disabled = false;
|
|
33
|
-
/**
|
|
34
|
-
* Sets the toggle to read-only, preventing user changes but still allowing
|
|
35
|
-
* focus and selection of text.
|
|
36
|
-
*/
|
|
37
|
-
this.readonly = false;
|
|
38
|
-
}
|
|
39
|
-
//#endregion EVENTS
|
|
40
|
-
/****************************************************************************/
|
|
41
|
-
//#region WATCHERS
|
|
42
|
-
/**
|
|
43
|
-
* Watches for changes to the checked state and emits the new value.
|
|
44
|
-
* @param {boolean} checked - The new value of the checked state.
|
|
45
|
-
*/
|
|
46
|
-
onCheckedChanged(checked) {
|
|
47
|
-
this.checkedChanged.emit(checked);
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Listens for the change event on the toggle input element and updates the checked state.
|
|
51
|
-
* the checked state of the host elements.
|
|
52
|
-
* @param {Event} event - The change event.
|
|
53
|
-
*/
|
|
54
|
-
handleChange(event) {
|
|
55
|
-
const target = event.target;
|
|
56
|
-
if (target.type === 'checkbox' && target.id === this.inputId) {
|
|
57
|
-
if (this.readonly || this.disabled) {
|
|
58
|
-
event.preventDefault();
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
this.checked = target.checked;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
//#endregion WATCHERS
|
|
65
|
-
/****************************************************************************/
|
|
66
|
-
//#region RENDER
|
|
67
|
-
render() {
|
|
68
|
-
return (index.h(index.Host, { key: 'db161d2edfcf7f83381b6431c8bc70a22c04fbf3', class: clsx297c1ffe.clsx(this.labelPlacement === 'before' && 'label-placement-before') }, index.h("div", { key: '086d6c429b4b7bcaa23093b13d30cf6ba21912f8', class: "input-container" }, index.h("input", { key: 'e83f407f2c3643c245198131a7991545b73dde78', type: "checkbox", id: this.inputId, name: this.name, autocomplete: "off", value: this.value, checked: Boolean(this.checked), disabled: this.disabled || this.readonly, readonly: this.readonly })), index.h("div", { key: 'eb5af410d1c643c70a4364948bf8fad9d54e74df', class: "text-container" }, (this.label || this.el.querySelector('[slot="label"]')) && (index.h("label", { key: '54793fd81258bee7676801f23da4f5fb554242bf', htmlFor: this.inputId, class: clsx297c1ffe.clsx(this.hideLabel && 'visually-hidden') }, index.h("slot", { key: '6af650d9677d1eb0f8cfa77cbcd6318f2d6f8aaf', name: "label" }, this.label))), (this.description ||
|
|
69
|
-
this.el.querySelector('[slot="description"]')) && (index.h("div", { key: '2c157429288779ad6cc18d4e318e64830a657c54', class: "description" }, index.h("slot", { key: 'fcfae2a0d7cdcc76d4b23c4b376c8e2496e11bb5', name: "description" }, this.description))))));
|
|
70
|
-
}
|
|
71
|
-
static get formAssociated() { return true; }
|
|
72
|
-
get el() { return index.getElement(this); }
|
|
73
|
-
static get watchers() { return {
|
|
74
|
-
"checked": ["onCheckedChanged"]
|
|
75
|
-
}; }
|
|
76
|
-
};
|
|
77
|
-
NvToggle.style = NvToggleStyle0;
|
|
78
|
-
|
|
79
|
-
exports.nv_toggle = NvToggle;
|