@nuralyui/popconfirm 0.0.5 → 0.0.6
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/bundle.js +1234 -23
- package/bundle.js.gz +0 -0
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/popconfirm-manager.component.d.ts +132 -0
- package/popconfirm-manager.component.d.ts.map +1 -0
- package/popconfirm-manager.component.js +376 -0
- package/popconfirm-manager.component.js.map +1 -0
- package/popconfirm-manager.style.d.ts +2 -0
- package/popconfirm-manager.style.d.ts.map +1 -0
- package/popconfirm-manager.style.js +137 -0
- package/popconfirm-manager.style.js.map +1 -0
- package/popconfirm.component.d.ts +24 -5
- package/popconfirm.component.d.ts.map +1 -1
- package/popconfirm.component.js +93 -35
- package/popconfirm.component.js.map +1 -1
- package/popconfirm.style.d.ts.map +1 -1
- package/popconfirm.style.js.map +1 -1
- package/popconfirm.types.d.ts +41 -0
- package/popconfirm.types.d.ts.map +1 -1
- package/popconfirm.types.js.map +1 -1
- package/react.d.ts.map +1 -1
- package/react.js.map +1 -1
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const popconfirmManagerStyles = css `
|
|
3
|
+
:host {
|
|
4
|
+
display: block;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.popconfirm-manager {
|
|
8
|
+
position: fixed;
|
|
9
|
+
top: 0;
|
|
10
|
+
left: 0;
|
|
11
|
+
width: 100%;
|
|
12
|
+
height: 100%;
|
|
13
|
+
pointer-events: none;
|
|
14
|
+
z-index: var(--nuraly-z-index-popconfirm, 10000);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.popconfirm-manager__item {
|
|
18
|
+
position: fixed;
|
|
19
|
+
pointer-events: auto;
|
|
20
|
+
background: var(--nuraly-color-dropdown-background, #ffffff);
|
|
21
|
+
border: 1px solid var(--nuraly-color-dropdown-border, #e0e0e0);
|
|
22
|
+
border-radius: var(--nuraly-border-radius-lg, 8px);
|
|
23
|
+
box-shadow: var(--nuraly-shadow-lg, 0 4px 16px rgba(0, 0, 0, 0.15));
|
|
24
|
+
min-width: 240px;
|
|
25
|
+
max-width: 320px;
|
|
26
|
+
animation: popconfirm-manager-fade-in 0.15s ease-out;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@keyframes popconfirm-manager-fade-in {
|
|
30
|
+
from {
|
|
31
|
+
opacity: 0;
|
|
32
|
+
transform: scale(0.95) translateY(-4px);
|
|
33
|
+
}
|
|
34
|
+
to {
|
|
35
|
+
opacity: 1;
|
|
36
|
+
transform: scale(1) translateY(0);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.popconfirm-manager__content {
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-direction: column;
|
|
43
|
+
gap: 12px;
|
|
44
|
+
padding: 12px 16px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.popconfirm-manager__message {
|
|
48
|
+
display: flex;
|
|
49
|
+
gap: 8px;
|
|
50
|
+
align-items: flex-start;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.popconfirm-manager__icon {
|
|
54
|
+
flex-shrink: 0;
|
|
55
|
+
font-size: 16px;
|
|
56
|
+
line-height: 1.5;
|
|
57
|
+
margin-top: 2px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.popconfirm-manager__icon--warning {
|
|
61
|
+
color: var(--nuraly-color-warning, #faad14);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.popconfirm-manager__icon--question {
|
|
65
|
+
color: var(--nuraly-color-info, #1890ff);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.popconfirm-manager__icon--info {
|
|
69
|
+
color: var(--nuraly-color-info, #1890ff);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.popconfirm-manager__icon--error {
|
|
73
|
+
color: var(--nuraly-color-error, #ff4d4f);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.popconfirm-manager__icon--success {
|
|
77
|
+
color: var(--nuraly-color-success, #52c41a);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.popconfirm-manager__icon--custom {
|
|
81
|
+
color: inherit;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.popconfirm-manager__text {
|
|
85
|
+
flex: 1;
|
|
86
|
+
display: flex;
|
|
87
|
+
flex-direction: column;
|
|
88
|
+
gap: 4px;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.popconfirm-manager__title {
|
|
92
|
+
color: var(--nuraly-color-text, #262626);
|
|
93
|
+
font-size: var(--nuraly-font-size-base, 14px);
|
|
94
|
+
font-weight: 600;
|
|
95
|
+
line-height: 1.5;
|
|
96
|
+
margin: 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.popconfirm-manager__description {
|
|
100
|
+
color: var(--nuraly-color-text-secondary, #666666);
|
|
101
|
+
font-size: var(--nuraly-font-size-sm, 12px);
|
|
102
|
+
line-height: 1.5;
|
|
103
|
+
margin: 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.popconfirm-manager__buttons {
|
|
107
|
+
display: flex;
|
|
108
|
+
gap: 8px;
|
|
109
|
+
justify-content: flex-end;
|
|
110
|
+
align-items: center;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* Arrow pointer towards cursor */
|
|
114
|
+
.popconfirm-manager__item::before {
|
|
115
|
+
content: '';
|
|
116
|
+
position: absolute;
|
|
117
|
+
left: 16px;
|
|
118
|
+
top: -6px;
|
|
119
|
+
width: 12px;
|
|
120
|
+
height: 12px;
|
|
121
|
+
background: var(--nuraly-color-dropdown-background, #ffffff);
|
|
122
|
+
border: 1px solid var(--nuraly-color-dropdown-border, #e0e0e0);
|
|
123
|
+
border-right: none;
|
|
124
|
+
border-bottom: none;
|
|
125
|
+
transform: rotate(45deg);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/* RTL Support */
|
|
129
|
+
:host([dir='rtl']) .popconfirm-manager__message {
|
|
130
|
+
direction: rtl;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
:host([dir='rtl']) .popconfirm-manager__buttons {
|
|
134
|
+
flex-direction: row-reverse;
|
|
135
|
+
}
|
|
136
|
+
`;
|
|
137
|
+
//# sourceMappingURL=popconfirm-manager.style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popconfirm-manager.style.js","sourceRoot":"","sources":["../../../../src/components/popconfirm/popconfirm-manager.style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsIzC,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const popconfirmManagerStyles = css`\n :host {\n display: block;\n }\n\n .popconfirm-manager {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n pointer-events: none;\n z-index: var(--nuraly-z-index-popconfirm, 10000);\n }\n\n .popconfirm-manager__item {\n position: fixed;\n pointer-events: auto;\n background: var(--nuraly-color-dropdown-background, #ffffff);\n border: 1px solid var(--nuraly-color-dropdown-border, #e0e0e0);\n border-radius: var(--nuraly-border-radius-lg, 8px);\n box-shadow: var(--nuraly-shadow-lg, 0 4px 16px rgba(0, 0, 0, 0.15));\n min-width: 240px;\n max-width: 320px;\n animation: popconfirm-manager-fade-in 0.15s ease-out;\n }\n\n @keyframes popconfirm-manager-fade-in {\n from {\n opacity: 0;\n transform: scale(0.95) translateY(-4px);\n }\n to {\n opacity: 1;\n transform: scale(1) translateY(0);\n }\n }\n\n .popconfirm-manager__content {\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 12px 16px;\n }\n\n .popconfirm-manager__message {\n display: flex;\n gap: 8px;\n align-items: flex-start;\n }\n\n .popconfirm-manager__icon {\n flex-shrink: 0;\n font-size: 16px;\n line-height: 1.5;\n margin-top: 2px;\n }\n\n .popconfirm-manager__icon--warning {\n color: var(--nuraly-color-warning, #faad14);\n }\n\n .popconfirm-manager__icon--question {\n color: var(--nuraly-color-info, #1890ff);\n }\n\n .popconfirm-manager__icon--info {\n color: var(--nuraly-color-info, #1890ff);\n }\n\n .popconfirm-manager__icon--error {\n color: var(--nuraly-color-error, #ff4d4f);\n }\n\n .popconfirm-manager__icon--success {\n color: var(--nuraly-color-success, #52c41a);\n }\n\n .popconfirm-manager__icon--custom {\n color: inherit;\n }\n\n .popconfirm-manager__text {\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .popconfirm-manager__title {\n color: var(--nuraly-color-text, #262626);\n font-size: var(--nuraly-font-size-base, 14px);\n font-weight: 600;\n line-height: 1.5;\n margin: 0;\n }\n\n .popconfirm-manager__description {\n color: var(--nuraly-color-text-secondary, #666666);\n font-size: var(--nuraly-font-size-sm, 12px);\n line-height: 1.5;\n margin: 0;\n }\n\n .popconfirm-manager__buttons {\n display: flex;\n gap: 8px;\n justify-content: flex-end;\n align-items: center;\n }\n\n /* Arrow pointer towards cursor */\n .popconfirm-manager__item::before {\n content: '';\n position: absolute;\n left: 16px;\n top: -6px;\n width: 12px;\n height: 12px;\n background: var(--nuraly-color-dropdown-background, #ffffff);\n border: 1px solid var(--nuraly-color-dropdown-border, #e0e0e0);\n border-right: none;\n border-bottom: none;\n transform: rotate(45deg);\n }\n\n /* RTL Support */\n :host([dir='rtl']) .popconfirm-manager__message {\n direction: rtl;\n }\n\n :host([dir='rtl']) .popconfirm-manager__buttons {\n flex-direction: row-reverse;\n }\n`;\n"]}
|
|
@@ -117,10 +117,33 @@ export declare class NrPopconfirmElement extends NrPopconfirmElement_base {
|
|
|
117
117
|
* Loading state for OK button (for async operations)
|
|
118
118
|
*/
|
|
119
119
|
private okLoading;
|
|
120
|
+
/**
|
|
121
|
+
* Bound event handlers for cleanup
|
|
122
|
+
*/
|
|
123
|
+
private _boundHandleOutsideClick;
|
|
124
|
+
private _boundHandleKeydown;
|
|
120
125
|
/**
|
|
121
126
|
* Reference to the dropdown element
|
|
122
127
|
*/
|
|
123
128
|
private get dropdownElement();
|
|
129
|
+
connectedCallback(): void;
|
|
130
|
+
disconnectedCallback(): void;
|
|
131
|
+
/**
|
|
132
|
+
* Handle trigger click to toggle popconfirm
|
|
133
|
+
*/
|
|
134
|
+
private handleTriggerClick;
|
|
135
|
+
/**
|
|
136
|
+
* Open the popconfirm
|
|
137
|
+
*/
|
|
138
|
+
private openPopconfirm;
|
|
139
|
+
/**
|
|
140
|
+
* Handle clicks outside the popconfirm to close it
|
|
141
|
+
*/
|
|
142
|
+
private handleOutsideClick;
|
|
143
|
+
/**
|
|
144
|
+
* Handle escape key to close popconfirm
|
|
145
|
+
*/
|
|
146
|
+
private handleKeydown;
|
|
124
147
|
/**
|
|
125
148
|
* Handle confirm button click
|
|
126
149
|
*/
|
|
@@ -133,10 +156,6 @@ export declare class NrPopconfirmElement extends NrPopconfirmElement_base {
|
|
|
133
156
|
* Close the popconfirm
|
|
134
157
|
*/
|
|
135
158
|
private closePopconfirm;
|
|
136
|
-
/**
|
|
137
|
-
* Handle dropdown open/close events
|
|
138
|
-
*/
|
|
139
|
-
private handleOpenChange;
|
|
140
159
|
/**
|
|
141
160
|
* Get icon color based on icon type
|
|
142
161
|
*/
|
|
@@ -149,7 +168,7 @@ export declare class NrPopconfirmElement extends NrPopconfirmElement_base {
|
|
|
149
168
|
* Render the popconfirm content
|
|
150
169
|
*/
|
|
151
170
|
private renderContent;
|
|
152
|
-
render(): import("lit").TemplateResult<1>;
|
|
171
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
153
172
|
}
|
|
154
173
|
declare global {
|
|
155
174
|
interface HTMLElementTagNameMap {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popconfirm.component.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"popconfirm.component.d.ts","sourceRoot":"","sources":["../../../../src/components/popconfirm/popconfirm.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAQ,UAAU,EAAE,MAAM,KAAK,CAAC;AAIvC,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,cAAc,EACf,MAAM,uBAAuB,CAAC;;AAG/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,qBACa,mBAAoB,SAAQ,wBAA6B;IACpE,OAAgB,MAAM,0BAAU;IAEvB,kBAAkB,WAAuD;IAElF;;OAEG;IACkC,KAAK,SAAM;IAEhD;;OAEG;IACyB,WAAW,SAAM;IAE7C;;OAEG;IAC+C,MAAM,SAAQ;IAEhE;;OAEG;IACmD,UAAU,SAAY;IAE5E;;OAEG;IAC+C,MAAM,EAAE,oBAAoB,CAC/C;IAE/B;;OAEG;IACoD,UAAU,UAAQ;IAEzE;;OAEG;IACyB,IAAI,iBAA0B;IAE1D;;OAEG;IACkD,SAAS,SAAM;IAEpE;;OAEG;IACyB,SAAS,EAAE,mBAAmB,CAA2B;IAErF;;OAEG;IACyB,OAAO,EAAE,iBAAiB,CAA2B;IAEjF;;OAEG;IAC0B,QAAQ,UAAS;IAE9C;;OAEG;IAC0B,KAAK,UAAQ;IAE1C;;OAEG;IACyC,IAAI,UAAS;IAEzD;;OAEG;IACM,OAAO,CAAC,SAAS,CAAS;IAEnC;;OAEG;IACH,OAAO,CAAC,wBAAwB,CAAqC;IACrE,OAAO,CAAC,mBAAmB,CAA6C;IAExE;;OAEG;IACH,OAAO,KAAK,eAAe,GAE1B;IAEQ,iBAAiB,IAAI,IAAI;IAQzB,oBAAoB,IAAI,IAAI;IAUrC;;OAEG;IACH,OAAO,CAAC,kBAAkB,CASxB;IAEF;;OAEG;IACH,OAAO,CAAC,cAAc;IActB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAQ1B;;OAEG;IACH,OAAO,CAAC,aAAa;IAMrB;;OAEG;IACH,OAAO,CAAC,aAAa,CAiCnB;IAEF;;OAEG;IACH,OAAO,CAAC,YAAY,CAYlB;IAEF;;OAEG;IACH,OAAO,CAAC,eAAe;IAcvB;;OAEG;IACH,OAAO,CAAC,YAAY;IASpB;;OAEG;IACH,OAAO,CAAC,YAAY;IAgBpB;;OAEG;IACH,OAAO,CAAC,aAAa;IA0CZ,MAAM;CAiBhB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,eAAe,EAAE,mBAAmB,CAAC;KACtC;CACF"}
|
package/popconfirm.component.js
CHANGED
|
@@ -20,7 +20,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
20
20
|
};
|
|
21
21
|
import { html, LitElement } from 'lit';
|
|
22
22
|
import { customElement, property, state } from 'lit/decorators.js';
|
|
23
|
-
import { classMap } from 'lit/directives/class-map.js';
|
|
24
23
|
import { styles } from './popconfirm.style.js';
|
|
25
24
|
import { NuralyUIBaseMixin } from '@nuralyui/common/mixins';
|
|
26
25
|
/**
|
|
@@ -78,7 +77,7 @@ import { NuralyUIBaseMixin } from '@nuralyui/common/mixins';
|
|
|
78
77
|
let NrPopconfirmElement = class NrPopconfirmElement extends NuralyUIBaseMixin(LitElement) {
|
|
79
78
|
constructor() {
|
|
80
79
|
super(...arguments);
|
|
81
|
-
this.requiredComponents = ['nr-dropdown', 'nr-icon'];
|
|
80
|
+
this.requiredComponents = ['nr-dropdown', 'nr-icon', 'nr-button', 'nr-label'];
|
|
82
81
|
/**
|
|
83
82
|
* Title of the confirmation box
|
|
84
83
|
*/
|
|
@@ -135,6 +134,25 @@ let NrPopconfirmElement = class NrPopconfirmElement extends NuralyUIBaseMixin(Li
|
|
|
135
134
|
* Loading state for OK button (for async operations)
|
|
136
135
|
*/
|
|
137
136
|
this.okLoading = false;
|
|
137
|
+
/**
|
|
138
|
+
* Bound event handlers for cleanup
|
|
139
|
+
*/
|
|
140
|
+
this._boundHandleOutsideClick = null;
|
|
141
|
+
this._boundHandleKeydown = null;
|
|
142
|
+
/**
|
|
143
|
+
* Handle trigger click to toggle popconfirm
|
|
144
|
+
*/
|
|
145
|
+
this.handleTriggerClick = (e) => {
|
|
146
|
+
if (this.disabled)
|
|
147
|
+
return;
|
|
148
|
+
e.stopPropagation();
|
|
149
|
+
if (this.open) {
|
|
150
|
+
this.closePopconfirm();
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
this.openPopconfirm();
|
|
154
|
+
}
|
|
155
|
+
};
|
|
138
156
|
/**
|
|
139
157
|
* Handle confirm button click
|
|
140
158
|
*/
|
|
@@ -183,17 +201,6 @@ let NrPopconfirmElement = class NrPopconfirmElement extends NuralyUIBaseMixin(Li
|
|
|
183
201
|
}));
|
|
184
202
|
this.closePopconfirm();
|
|
185
203
|
};
|
|
186
|
-
/**
|
|
187
|
-
* Handle dropdown open/close events
|
|
188
|
-
*/
|
|
189
|
-
this.handleOpenChange = (e) => {
|
|
190
|
-
this.open = e.detail.open;
|
|
191
|
-
this.dispatchEvent(new CustomEvent('nr-open-change', {
|
|
192
|
-
bubbles: true,
|
|
193
|
-
composed: true,
|
|
194
|
-
detail: { open: this.open },
|
|
195
|
-
}));
|
|
196
|
-
};
|
|
197
204
|
}
|
|
198
205
|
/**
|
|
199
206
|
* Reference to the dropdown element
|
|
@@ -202,14 +209,68 @@ let NrPopconfirmElement = class NrPopconfirmElement extends NuralyUIBaseMixin(Li
|
|
|
202
209
|
var _a;
|
|
203
210
|
return (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('nr-dropdown');
|
|
204
211
|
}
|
|
212
|
+
connectedCallback() {
|
|
213
|
+
super.connectedCallback();
|
|
214
|
+
this._boundHandleOutsideClick = this.handleOutsideClick.bind(this);
|
|
215
|
+
this._boundHandleKeydown = this.handleKeydown.bind(this);
|
|
216
|
+
document.addEventListener('click', this._boundHandleOutsideClick, true);
|
|
217
|
+
document.addEventListener('keydown', this._boundHandleKeydown);
|
|
218
|
+
}
|
|
219
|
+
disconnectedCallback() {
|
|
220
|
+
super.disconnectedCallback();
|
|
221
|
+
if (this._boundHandleOutsideClick) {
|
|
222
|
+
document.removeEventListener('click', this._boundHandleOutsideClick, true);
|
|
223
|
+
}
|
|
224
|
+
if (this._boundHandleKeydown) {
|
|
225
|
+
document.removeEventListener('keydown', this._boundHandleKeydown);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Open the popconfirm
|
|
230
|
+
*/
|
|
231
|
+
openPopconfirm() {
|
|
232
|
+
this.open = true;
|
|
233
|
+
if (this.dropdownElement) {
|
|
234
|
+
this.dropdownElement.show();
|
|
235
|
+
}
|
|
236
|
+
this.dispatchEvent(new CustomEvent('nr-open-change', {
|
|
237
|
+
bubbles: true,
|
|
238
|
+
composed: true,
|
|
239
|
+
detail: { open: true },
|
|
240
|
+
}));
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Handle clicks outside the popconfirm to close it
|
|
244
|
+
*/
|
|
245
|
+
handleOutsideClick(e) {
|
|
246
|
+
if (!this.open)
|
|
247
|
+
return;
|
|
248
|
+
const path = e.composedPath();
|
|
249
|
+
if (!path.includes(this)) {
|
|
250
|
+
this.closePopconfirm();
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Handle escape key to close popconfirm
|
|
255
|
+
*/
|
|
256
|
+
handleKeydown(e) {
|
|
257
|
+
if (e.key === 'Escape' && this.open) {
|
|
258
|
+
this.closePopconfirm();
|
|
259
|
+
}
|
|
260
|
+
}
|
|
205
261
|
/**
|
|
206
262
|
* Close the popconfirm
|
|
207
263
|
*/
|
|
208
264
|
closePopconfirm() {
|
|
209
265
|
this.open = false;
|
|
210
266
|
if (this.dropdownElement) {
|
|
211
|
-
this.dropdownElement.
|
|
267
|
+
this.dropdownElement.hide();
|
|
212
268
|
}
|
|
269
|
+
this.dispatchEvent(new CustomEvent('nr-open-change', {
|
|
270
|
+
bubbles: true,
|
|
271
|
+
composed: true,
|
|
272
|
+
detail: { open: false },
|
|
273
|
+
}));
|
|
213
274
|
}
|
|
214
275
|
/**
|
|
215
276
|
* Get icon color based on icon type
|
|
@@ -243,7 +304,6 @@ let NrPopconfirmElement = class NrPopconfirmElement extends NuralyUIBaseMixin(Li
|
|
|
243
304
|
renderContent() {
|
|
244
305
|
const iconClass = this.getIconClass();
|
|
245
306
|
const iconColor = this.getIconColor();
|
|
246
|
-
const okButtonClass = `ok-${this.okType}`;
|
|
247
307
|
return html `
|
|
248
308
|
<div class="popconfirm-content">
|
|
249
309
|
<div class="popconfirm-message">
|
|
@@ -253,34 +313,30 @@ let NrPopconfirmElement = class NrPopconfirmElement extends NuralyUIBaseMixin(Li
|
|
|
253
313
|
<nr-icon name=${this.icon}></nr-icon>
|
|
254
314
|
</div>
|
|
255
315
|
<div class="popconfirm-text">
|
|
256
|
-
${this.title ? html `<
|
|
316
|
+
${this.title ? html `<nr-label class="popconfirm-title" size="medium">${this.title}</nr-label>` : ''}
|
|
257
317
|
${this.description
|
|
258
|
-
? html `<
|
|
318
|
+
? html `<nr-label class="popconfirm-description" size="small" variant="secondary">${this.description}</nr-label>`
|
|
259
319
|
: ''}
|
|
260
320
|
</div>
|
|
261
321
|
</div>
|
|
262
322
|
<div class="popconfirm-buttons">
|
|
263
323
|
${this.showCancel
|
|
264
324
|
? html `
|
|
265
|
-
<button
|
|
266
|
-
|
|
267
|
-
@click=${this.handleCancel}
|
|
268
|
-
type="button">
|
|
325
|
+
<nr-button
|
|
326
|
+
size="small"
|
|
327
|
+
@click=${this.handleCancel}>
|
|
269
328
|
${this.cancelText}
|
|
270
|
-
</button>
|
|
329
|
+
</nr-button>
|
|
271
330
|
`
|
|
272
331
|
: ''}
|
|
273
|
-
<button
|
|
274
|
-
|
|
275
|
-
'
|
|
276
|
-
|
|
277
|
-
'popconfirm-button--loading': this.okLoading,
|
|
278
|
-
})}
|
|
279
|
-
@click=${this.handleConfirm}
|
|
332
|
+
<nr-button
|
|
333
|
+
size="small"
|
|
334
|
+
type=${this.okType === 'danger' ? 'danger' : this.okType === 'primary' ? 'primary' : 'default'}
|
|
335
|
+
?loading=${this.okLoading}
|
|
280
336
|
?disabled=${this.okLoading}
|
|
281
|
-
|
|
337
|
+
@click=${this.handleConfirm}>
|
|
282
338
|
${this.okText}
|
|
283
|
-
</button>
|
|
339
|
+
</nr-button>
|
|
284
340
|
</div>
|
|
285
341
|
</div>
|
|
286
342
|
`;
|
|
@@ -290,12 +346,14 @@ let NrPopconfirmElement = class NrPopconfirmElement extends NuralyUIBaseMixin(Li
|
|
|
290
346
|
<nr-dropdown
|
|
291
347
|
.open=${this.open}
|
|
292
348
|
.placement=${this.placement}
|
|
293
|
-
|
|
349
|
+
trigger="manual"
|
|
294
350
|
?disabled=${this.disabled}
|
|
295
351
|
?arrow=${this.arrow}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
<slot
|
|
352
|
+
.closeOnOutsideClick=${false}
|
|
353
|
+
.closeOnEscape=${false}>
|
|
354
|
+
<div slot="trigger" @click=${this.handleTriggerClick}>
|
|
355
|
+
<slot name="trigger"></slot>
|
|
356
|
+
</div>
|
|
299
357
|
<div slot="content">${this.renderContent()}</div>
|
|
300
358
|
</nr-dropdown>
|
|
301
359
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popconfirm.component.js","sourceRoot":"","sources":["../../../src/components/popconfirm/popconfirm.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;;;;;;;;;;;;;;;AAEH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,E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E,CAAC;wDAAkB;AAKK;IAAjD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;mDAAe;AAKV;IAArD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;uDAAuB;AAK1B;IAAjD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;mDAClB;AAKwB;IAAtD,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;uDAAmB;AAK7C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDAA+B;AAKL;IAApD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;sDAAgB;AAKxC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAA0D;AAKzD;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oDAAsD;AAKpD;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;qDAAkB;AAKjB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kDAAc;AAKE;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iDAAc;AAKhD;IAAR,KAAK,EAAE;sDAA2B;AA1ExB,mBAAmB;IAD/B,aAAa,CAAC,eAAe,CAAC;GAClB,mBAAmB,CAkQ/B;SAlQY,mBAAmB","sourcesContent":["/**\n * @license\n * Copyright 2023 Nuraly, Laabidi Aymen\n * SPDX-License-Identifier: MIT\n */\n\nimport { html, LitElement } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { styles } from './popconfirm.style.js';\nimport { NuralyUIBaseMixin } from '@nuralyui/common/mixins';\nimport {\n PopconfirmPlacement,\n PopconfirmTrigger,\n PopconfirmButtonType,\n PopconfirmIcon,\n} from './popconfirm.types.js';\n\n/**\n * # Popconfirm Component\n *\n * A pop-up confirmation dialog triggered by user interaction. It provides a simple and\n * compact way to ask for user confirmation before performing an action.\n *\n * ## Features\n * - Customizable title and description\n * - Configurable OK and Cancel buttons\n * - Multiple placement options (12 positions)\n * - Custom icons with predefined options\n * - Async confirmation support\n * - Multiple trigger modes (click, hover, focus)\n * - Theme-aware styling\n * - Keyboard accessibility\n *\n * ## Usage\n * ```html\n * <!-- Basic popconfirm -->\n * <nr-popconfirm\n * title=\"Are you sure delete this task?\"\n * ok-text=\"Yes\"\n * cancel-text=\"No\">\n * <button slot=\"trigger\">Delete</button>\n * </nr-popconfirm>\n *\n * <!-- With description -->\n * <nr-popconfirm\n * title=\"Delete the task\"\n * description=\"Are you sure you want to delete this task? This action cannot be undone.\"\n * ok-type=\"danger\">\n * <button slot=\"trigger\">Delete</button>\n * </nr-popconfirm>\n *\n * <!-- Custom icon -->\n * <nr-popconfirm\n * title=\"Change status?\"\n * icon=\"question-circle\"\n * icon-color=\"#1890ff\">\n * <button slot=\"trigger\">Change Status</button>\n * </nr-popconfirm>\n * ```\n *\n * @element nr-popconfirm\n * @fires nr-confirm - Fired when user confirms the action\n * @fires nr-cancel - Fired when user cancels the action\n * @fires nr-open-change - Fired when popconfirm visibility changes\n *\n * @slot trigger - Element that triggers the popconfirm\n *\n * @cssproperty --nuraly-popconfirm-icon-color - Custom icon color\n */\n@customElement('nr-popconfirm')\nexport class NrPopconfirmElement extends NuralyUIBaseMixin(LitElement) {\n static override styles = styles;\n\n override requiredComponents = ['nr-dropdown', 'nr-icon'];\n\n /**\n * Title of the confirmation box\n */\n @property({ type: String }) override title = '';\n\n /**\n * Description of the confirmation box (optional)\n */\n @property({ type: String }) description = '';\n\n /**\n * Text of the OK button\n */\n @property({ type: String, attribute: 'ok-text' }) okText = 'OK';\n\n /**\n * Text of the Cancel button\n */\n @property({ type: String, attribute: 'cancel-text' }) cancelText = 'Cancel';\n\n /**\n * Button type of the OK button\n */\n @property({ type: String, attribute: 'ok-type' }) okType: PopconfirmButtonType =\n PopconfirmButtonType.Primary;\n\n /**\n * Show cancel button\n */\n @property({ type: Boolean, attribute: 'show-cancel' }) showCancel = true;\n\n /**\n * Icon name for the confirmation box\n */\n @property({ type: String }) icon = PopconfirmIcon.Warning;\n\n /**\n * Custom icon color\n */\n @property({ type: String, attribute: 'icon-color' }) iconColor = '';\n\n /**\n * Placement of the popconfirm\n */\n @property({ type: String }) placement: PopconfirmPlacement = PopconfirmPlacement.Top;\n\n /**\n * Trigger mode\n */\n @property({ type: String }) trigger: PopconfirmTrigger = PopconfirmTrigger.Click;\n\n /**\n * Whether the popconfirm is disabled\n */\n @property({ type: Boolean }) disabled = false;\n\n /**\n * Whether to show arrow\n */\n @property({ type: Boolean }) arrow = true;\n\n /**\n * Whether the popconfirm is open\n */\n @property({ type: Boolean, reflect: true }) open = false;\n\n /**\n * Loading state for OK button (for async operations)\n */\n @state() private okLoading = false;\n\n /**\n * Reference to the dropdown element\n */\n private get dropdownElement(): any {\n return this.shadowRoot?.querySelector('nr-dropdown');\n }\n\n /**\n * Handle confirm button click\n */\n private handleConfirm = async (e: Event) => {\n e.stopPropagation();\n\n const confirmEvent = new CustomEvent('nr-confirm', {\n bubbles: true,\n composed: true,\n cancelable: true,\n detail: { originalEvent: e },\n });\n\n const dispatched = this.dispatchEvent(confirmEvent);\n\n // If event is not prevented, close the popconfirm\n if (dispatched && !confirmEvent.defaultPrevented) {\n // Check if the event handler returns a promise\n const handler = (this as any).onConfirm;\n if (handler && typeof handler === 'function') {\n const result = handler(e);\n if (result && typeof result.then === 'function') {\n this.okLoading = true;\n try {\n await result;\n this.closePopconfirm();\n } catch (error) {\n console.error('Confirmation failed:', error);\n } finally {\n this.okLoading = false;\n }\n return;\n }\n }\n this.closePopconfirm();\n }\n };\n\n /**\n * Handle cancel button click\n */\n private handleCancel = (e: Event) => {\n e.stopPropagation();\n\n this.dispatchEvent(\n new CustomEvent('nr-cancel', {\n bubbles: true,\n composed: true,\n detail: { originalEvent: e },\n })\n );\n\n this.closePopconfirm();\n };\n\n /**\n * Close the popconfirm\n */\n private closePopconfirm() {\n this.open = false;\n if (this.dropdownElement) {\n this.dropdownElement.open = false;\n }\n }\n\n /**\n * Handle dropdown open/close events\n */\n private handleOpenChange = (e: CustomEvent) => {\n this.open = e.detail.open;\n this.dispatchEvent(\n new CustomEvent('nr-open-change', {\n bubbles: true,\n composed: true,\n detail: { open: this.open },\n })\n );\n };\n\n /**\n * Get icon color based on icon type\n */\n private getIconColor(): string {\n if (this.iconColor) {\n return this.iconColor;\n }\n\n // Return empty string to use CSS class colors\n return '';\n }\n\n /**\n * Get icon class based on icon type\n */\n private getIconClass(): string {\n const iconColorMap: Record<string, string> = {\n [PopconfirmIcon.Warning]: 'warning',\n [PopconfirmIcon.Question]: 'question',\n [PopconfirmIcon.Info]: 'info',\n [PopconfirmIcon.Error]: 'error',\n [PopconfirmIcon.Success]: 'success',\n };\n\n if (this.iconColor) {\n return 'custom';\n }\n\n return iconColorMap[this.icon] || 'warning';\n }\n\n /**\n * Render the popconfirm content\n */\n private renderContent() {\n const iconClass = this.getIconClass();\n const iconColor = this.getIconColor();\n const okButtonClass = `ok-${this.okType}`;\n\n return html`\n <div class=\"popconfirm-content\">\n <div class=\"popconfirm-message\">\n <div\n class=\"popconfirm-icon popconfirm-icon--${iconClass}\"\n style=${iconColor ? `color: ${iconColor}` : ''}>\n <nr-icon name=${this.icon}></nr-icon>\n </div>\n <div class=\"popconfirm-text\">\n ${this.title ? html`<div class=\"popconfirm-title\">${this.title}</div>` : ''}\n ${this.description\n ? html`<div class=\"popconfirm-description\">${this.description}</div>`\n : ''}\n </div>\n </div>\n <div class=\"popconfirm-buttons\">\n ${this.showCancel\n ? html`\n <button\n class=\"popconfirm-button popconfirm-button--cancel\"\n @click=${this.handleCancel}\n type=\"button\">\n ${this.cancelText}\n </button>\n `\n : ''}\n <button\n class=${classMap({\n 'popconfirm-button': true,\n [`popconfirm-button--${okButtonClass}`]: true,\n 'popconfirm-button--loading': this.okLoading,\n })}\n @click=${this.handleConfirm}\n ?disabled=${this.okLoading}\n type=\"button\">\n ${this.okText}\n </button>\n </div>\n </div>\n `;\n }\n\n override render() {\n return html`\n <nr-dropdown\n .open=${this.open}\n .placement=${this.placement as any}\n .trigger=${this.trigger as any}\n ?disabled=${this.disabled}\n ?arrow=${this.arrow}\n @nr-dropdown-open=${this.handleOpenChange}\n @nr-dropdown-close=${this.handleOpenChange}>\n <slot name=\"trigger\" slot=\"trigger\"></slot>\n <div slot=\"content\">${this.renderContent()}</div>\n </nr-dropdown>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nr-popconfirm': NrPopconfirmElement;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"popconfirm.component.js","sourceRoot":"","sources":["../../../../src/components/popconfirm/popconfirm.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;;;;;;;;;;;;;;;AAEH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAS5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH,IAAa,mBAAmB,GAAhC,MAAa,mBAAoB,SAAQ,iBAAiB,CAAC,UAAU,CAAC;IAAtE;;QAGW,uBAAkB,GAAG,CAAC,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;QAElF;;WAEG;QACkC,UAAK,GAAG,EAA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AKK;IAAjD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;mDAAe;AAKV;IAArD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;uDAAuB;AAK1B;IAAjD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;mDAClB;AAKwB;IAAtD,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;uDAAmB;AAK7C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDAA+B;AAKL;IAApD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;sDAAgB;AAKxC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAA0D;AAKzD;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oDAAsD;AAKpD;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;qDAAkB;AAKjB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kDAAc;AAKE;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iDAAc;AAKhD;IAAR,KAAK,EAAE;sDAA2B;AA1ExB,mBAAmB;IAD/B,aAAa,CAAC,eAAe,CAAC;GAClB,mBAAmB,CAmU/B;SAnUY,mBAAmB","sourcesContent":["/**\n * @license\n * Copyright 2023 Nuraly, Laabidi Aymen\n * SPDX-License-Identifier: MIT\n */\n\nimport { html, LitElement } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { styles } from './popconfirm.style.js';\nimport { NuralyUIBaseMixin } from '@nuralyui/common/mixins';\nimport {\n PopconfirmPlacement,\n PopconfirmTrigger,\n PopconfirmButtonType,\n PopconfirmIcon,\n} from './popconfirm.types.js';\n\n\n/**\n * # Popconfirm Component\n *\n * A pop-up confirmation dialog triggered by user interaction. It provides a simple and\n * compact way to ask for user confirmation before performing an action.\n *\n * ## Features\n * - Customizable title and description\n * - Configurable OK and Cancel buttons\n * - Multiple placement options (12 positions)\n * - Custom icons with predefined options\n * - Async confirmation support\n * - Multiple trigger modes (click, hover, focus)\n * - Theme-aware styling\n * - Keyboard accessibility\n *\n * ## Usage\n * ```html\n * <!-- Basic popconfirm -->\n * <nr-popconfirm\n * title=\"Are you sure delete this task?\"\n * ok-text=\"Yes\"\n * cancel-text=\"No\">\n * <button slot=\"trigger\">Delete</button>\n * </nr-popconfirm>\n *\n * <!-- With description -->\n * <nr-popconfirm\n * title=\"Delete the task\"\n * description=\"Are you sure you want to delete this task? This action cannot be undone.\"\n * ok-type=\"danger\">\n * <button slot=\"trigger\">Delete</button>\n * </nr-popconfirm>\n *\n * <!-- Custom icon -->\n * <nr-popconfirm\n * title=\"Change status?\"\n * icon=\"question-circle\"\n * icon-color=\"#1890ff\">\n * <button slot=\"trigger\">Change Status</button>\n * </nr-popconfirm>\n * ```\n *\n * @element nr-popconfirm\n * @fires nr-confirm - Fired when user confirms the action\n * @fires nr-cancel - Fired when user cancels the action\n * @fires nr-open-change - Fired when popconfirm visibility changes\n *\n * @slot trigger - Element that triggers the popconfirm\n *\n * @cssproperty --nuraly-popconfirm-icon-color - Custom icon color\n */\n@customElement('nr-popconfirm')\nexport class NrPopconfirmElement extends NuralyUIBaseMixin(LitElement) {\n static override styles = styles;\n\n override requiredComponents = ['nr-dropdown', 'nr-icon', 'nr-button', 'nr-label'];\n\n /**\n * Title of the confirmation box\n */\n @property({ type: String }) override title = '';\n\n /**\n * Description of the confirmation box (optional)\n */\n @property({ type: String }) description = '';\n\n /**\n * Text of the OK button\n */\n @property({ type: String, attribute: 'ok-text' }) okText = 'OK';\n\n /**\n * Text of the Cancel button\n */\n @property({ type: String, attribute: 'cancel-text' }) cancelText = 'Cancel';\n\n /**\n * Button type of the OK button\n */\n @property({ type: String, attribute: 'ok-type' }) okType: PopconfirmButtonType =\n PopconfirmButtonType.Primary;\n\n /**\n * Show cancel button\n */\n @property({ type: Boolean, attribute: 'show-cancel' }) showCancel = true;\n\n /**\n * Icon name for the confirmation box\n */\n @property({ type: String }) icon = PopconfirmIcon.Warning;\n\n /**\n * Custom icon color\n */\n @property({ type: String, attribute: 'icon-color' }) iconColor = '';\n\n /**\n * Placement of the popconfirm\n */\n @property({ type: String }) placement: PopconfirmPlacement = PopconfirmPlacement.Top;\n\n /**\n * Trigger mode\n */\n @property({ type: String }) trigger: PopconfirmTrigger = PopconfirmTrigger.Click;\n\n /**\n * Whether the popconfirm is disabled\n */\n @property({ type: Boolean }) disabled = false;\n\n /**\n * Whether to show arrow\n */\n @property({ type: Boolean }) arrow = true;\n\n /**\n * Whether the popconfirm is open\n */\n @property({ type: Boolean, reflect: true }) open = false;\n\n /**\n * Loading state for OK button (for async operations)\n */\n @state() private okLoading = false;\n\n /**\n * Bound event handlers for cleanup\n */\n private _boundHandleOutsideClick: ((e: Event) => void) | null = null;\n private _boundHandleKeydown: ((e: KeyboardEvent) => void) | null = null;\n\n /**\n * Reference to the dropdown element\n */\n private get dropdownElement(): any {\n return this.shadowRoot?.querySelector('nr-dropdown');\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this._boundHandleOutsideClick = this.handleOutsideClick.bind(this);\n this._boundHandleKeydown = this.handleKeydown.bind(this);\n document.addEventListener('click', this._boundHandleOutsideClick, true);\n document.addEventListener('keydown', this._boundHandleKeydown);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n if (this._boundHandleOutsideClick) {\n document.removeEventListener('click', this._boundHandleOutsideClick, true);\n }\n if (this._boundHandleKeydown) {\n document.removeEventListener('keydown', this._boundHandleKeydown);\n }\n }\n\n /**\n * Handle trigger click to toggle popconfirm\n */\n private handleTriggerClick = (e: Event): void => {\n if (this.disabled) return;\n e.stopPropagation();\n\n if (this.open) {\n this.closePopconfirm();\n } else {\n this.openPopconfirm();\n }\n };\n\n /**\n * Open the popconfirm\n */\n private openPopconfirm(): void {\n this.open = true;\n if (this.dropdownElement) {\n this.dropdownElement.show();\n }\n this.dispatchEvent(\n new CustomEvent('nr-open-change', {\n bubbles: true,\n composed: true,\n detail: { open: true },\n })\n );\n }\n\n /**\n * Handle clicks outside the popconfirm to close it\n */\n private handleOutsideClick(e: Event): void {\n if (!this.open) return;\n const path = e.composedPath();\n if (!path.includes(this)) {\n this.closePopconfirm();\n }\n }\n\n /**\n * Handle escape key to close popconfirm\n */\n private handleKeydown(e: KeyboardEvent): void {\n if (e.key === 'Escape' && this.open) {\n this.closePopconfirm();\n }\n }\n\n /**\n * Handle confirm button click\n */\n private handleConfirm = async (e: Event) => {\n e.stopPropagation();\n\n const confirmEvent = new CustomEvent('nr-confirm', {\n bubbles: true,\n composed: true,\n cancelable: true,\n detail: { originalEvent: e },\n });\n\n const dispatched = this.dispatchEvent(confirmEvent);\n\n // If event is not prevented, close the popconfirm\n if (dispatched && !confirmEvent.defaultPrevented) {\n // Check if the event handler returns a promise\n const handler = (this as any).onConfirm;\n if (handler && typeof handler === 'function') {\n const result = handler(e);\n if (result && typeof result.then === 'function') {\n this.okLoading = true;\n try {\n await result;\n this.closePopconfirm();\n } catch (error) {\n console.error('Confirmation failed:', error);\n } finally {\n this.okLoading = false;\n }\n return;\n }\n }\n this.closePopconfirm();\n }\n };\n\n /**\n * Handle cancel button click\n */\n private handleCancel = (e: Event) => {\n e.stopPropagation();\n\n this.dispatchEvent(\n new CustomEvent('nr-cancel', {\n bubbles: true,\n composed: true,\n detail: { originalEvent: e },\n })\n );\n\n this.closePopconfirm();\n };\n\n /**\n * Close the popconfirm\n */\n private closePopconfirm() {\n this.open = false;\n if (this.dropdownElement) {\n this.dropdownElement.hide();\n }\n this.dispatchEvent(\n new CustomEvent('nr-open-change', {\n bubbles: true,\n composed: true,\n detail: { open: false },\n })\n );\n }\n\n /**\n * Get icon color based on icon type\n */\n private getIconColor(): string {\n if (this.iconColor) {\n return this.iconColor;\n }\n\n // Return empty string to use CSS class colors\n return '';\n }\n\n /**\n * Get icon class based on icon type\n */\n private getIconClass(): string {\n const iconColorMap: Record<string, string> = {\n [PopconfirmIcon.Warning]: 'warning',\n [PopconfirmIcon.Question]: 'question',\n [PopconfirmIcon.Info]: 'info',\n [PopconfirmIcon.Error]: 'error',\n [PopconfirmIcon.Success]: 'success',\n };\n\n if (this.iconColor) {\n return 'custom';\n }\n\n return iconColorMap[this.icon] || 'warning';\n }\n\n /**\n * Render the popconfirm content\n */\n private renderContent() {\n const iconClass = this.getIconClass();\n const iconColor = this.getIconColor();\n\n return html`\n <div class=\"popconfirm-content\">\n <div class=\"popconfirm-message\">\n <div\n class=\"popconfirm-icon popconfirm-icon--${iconClass}\"\n style=${iconColor ? `color: ${iconColor}` : ''}>\n <nr-icon name=${this.icon}></nr-icon>\n </div>\n <div class=\"popconfirm-text\">\n ${this.title ? html`<nr-label class=\"popconfirm-title\" size=\"medium\">${this.title}</nr-label>` : ''}\n ${this.description\n ? html`<nr-label class=\"popconfirm-description\" size=\"small\" variant=\"secondary\">${this.description}</nr-label>`\n : ''}\n </div>\n </div>\n <div class=\"popconfirm-buttons\">\n ${this.showCancel\n ? html`\n <nr-button\n size=\"small\"\n @click=${this.handleCancel}>\n ${this.cancelText}\n </nr-button>\n `\n : ''}\n <nr-button\n size=\"small\"\n type=${this.okType === 'danger' ? 'danger' : this.okType === 'primary' ? 'primary' : 'default'}\n ?loading=${this.okLoading}\n ?disabled=${this.okLoading}\n @click=${this.handleConfirm}>\n ${this.okText}\n </nr-button>\n </div>\n </div>\n `;\n }\n\n override render() {\n return html`\n <nr-dropdown\n .open=${this.open}\n .placement=${this.placement as any}\n trigger=\"manual\"\n ?disabled=${this.disabled}\n ?arrow=${this.arrow}\n .closeOnOutsideClick=${false}\n .closeOnEscape=${false}>\n <div slot=\"trigger\" @click=${this.handleTriggerClick}>\n <slot name=\"trigger\"></slot>\n </div>\n <div slot=\"content\">${this.renderContent()}</div>\n </nr-dropdown>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nr-popconfirm': NrPopconfirmElement;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popconfirm.style.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"popconfirm.style.d.ts","sourceRoot":"","sources":["../../../../src/components/popconfirm/popconfirm.style.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,yBA4MlB,CAAC"}
|
package/popconfirm.style.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popconfirm.style.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"popconfirm.style.js","sourceRoot":"","sources":["../../../../src/components/popconfirm/popconfirm.style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4MxB,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const styles = css`\n :host {\n display: inline-block;\n }\n\n .popconfirm-content {\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 12px 16px;\n min-width: 200px;\n max-width: 400px;\n }\n\n .popconfirm-message {\n display: flex;\n gap: 8px;\n align-items: flex-start;\n }\n\n .popconfirm-icon {\n flex-shrink: 0;\n font-size: 16px;\n line-height: 1.5;\n margin-top: 2px;\n }\n\n .popconfirm-icon--warning {\n color: var(--nuraly-color-warning);\n }\n\n .popconfirm-icon--question {\n color: var(--nuraly-color-info);\n }\n\n .popconfirm-icon--info {\n color: var(--nuraly-color-info);\n }\n\n .popconfirm-icon--error {\n color: var(--nuraly-color-error);\n }\n\n .popconfirm-icon--success {\n color: var(--nuraly-color-success);\n }\n\n .popconfirm-icon--custom {\n color: var(--nuraly-popconfirm-icon-color, var(--nuraly-color-text));\n }\n\n .popconfirm-text {\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .popconfirm-title {\n color: var(--nuraly-color-text);\n font-size: var(--nuraly-font-size-base);\n font-weight: 600;\n line-height: 1.5;\n margin: 0;\n }\n\n .popconfirm-description {\n color: var(--nuraly-color-text-secondary);\n font-size: var(--nuraly-font-size-sm);\n line-height: 1.5;\n margin: 0;\n }\n\n .popconfirm-buttons {\n display: flex;\n gap: 8px;\n justify-content: flex-end;\n align-items: center;\n }\n\n .popconfirm-button {\n padding: 4px 15px;\n font-size: var(--nuraly-font-size-sm);\n border-radius: var(--nuraly-border-radius);\n border: 1px solid transparent;\n cursor: pointer;\n transition: all 0.2s;\n font-weight: 400;\n line-height: 1.5;\n white-space: nowrap;\n user-select: none;\n }\n\n .popconfirm-button:focus-visible {\n outline: 2px solid var(--nuraly-color-primary);\n outline-offset: 2px;\n }\n\n .popconfirm-button--cancel {\n background: var(--nuraly-button-default-background);\n color: var(--nuraly-button-default-text-color);\n border-color: var(--nuraly-button-default-border-color);\n }\n\n .popconfirm-button--cancel:hover:not(:disabled) {\n background: var(--nuraly-button-default-hover-background);\n color: var(--nuraly-button-default-hover-text-color);\n border-color: var(--nuraly-button-default-hover-border-color);\n }\n\n .popconfirm-button--ok-primary {\n background: var(--nuraly-button-primary-background);\n color: var(--nuraly-button-primary-text-color);\n border-color: var(--nuraly-button-primary-border-color);\n }\n\n .popconfirm-button--ok-primary:hover:not(:disabled) {\n background: var(--nuraly-button-primary-hover-background);\n color: var(--nuraly-button-primary-hover-text-color);\n border-color: var(--nuraly-button-primary-hover-border-color);\n }\n\n .popconfirm-button--ok-danger {\n background: var(--nuraly-button-danger-background);\n color: var(--nuraly-button-danger-text-color);\n border-color: var(--nuraly-button-danger-border-color);\n }\n\n .popconfirm-button--ok-danger:hover:not(:disabled) {\n background: var(--nuraly-button-danger-hover-background);\n color: var(--nuraly-button-danger-hover-text-color);\n border-color: var(--nuraly-button-danger-hover-border-color);\n }\n\n .popconfirm-button--ok-secondary {\n background: var(--nuraly-button-secondary-background);\n color: var(--nuraly-button-secondary-text-color);\n border-color: var(--nuraly-button-secondary-border-color);\n }\n\n .popconfirm-button--ok-secondary:hover:not(:disabled) {\n background: var(--nuraly-button-secondary-hover-background);\n color: var(--nuraly-button-secondary-hover-text-color);\n border-color: var(--nuraly-button-secondary-hover-border-color);\n }\n\n .popconfirm-button--ok-default {\n background: var(--nuraly-button-default-background);\n color: var(--nuraly-button-default-text-color);\n border-color: var(--nuraly-button-default-border-color);\n }\n\n .popconfirm-button--ok-default:hover:not(:disabled) {\n background: var(--nuraly-button-default-hover-background);\n color: var(--nuraly-button-default-hover-text-color);\n border-color: var(--nuraly-button-default-hover-border-color);\n }\n\n .popconfirm-button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n .popconfirm-button--loading {\n position: relative;\n pointer-events: none;\n }\n\n .popconfirm-button--loading::before {\n content: '';\n position: absolute;\n left: 50%;\n top: 50%;\n width: 14px;\n height: 14px;\n margin-left: -7px;\n margin-top: -7px;\n border: 2px solid currentColor;\n border-right-color: transparent;\n border-radius: 50%;\n animation: popconfirm-spin 0.6s linear infinite;\n }\n\n .popconfirm-button--loading > * {\n visibility: hidden;\n }\n\n @keyframes popconfirm-spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n\n /* RTL Support */\n :host([dir='rtl']) .popconfirm-message {\n direction: rtl;\n }\n\n :host([dir='rtl']) .popconfirm-buttons {\n flex-direction: row-reverse;\n }\n`;\n"]}
|
package/popconfirm.types.d.ts
CHANGED
|
@@ -60,4 +60,45 @@ export interface PopconfirmConfig {
|
|
|
60
60
|
disabled?: boolean;
|
|
61
61
|
arrow?: boolean;
|
|
62
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Configuration for programmatic popconfirm at cursor position
|
|
65
|
+
*/
|
|
66
|
+
export interface PopconfirmShowConfig {
|
|
67
|
+
/** Title of the confirmation box */
|
|
68
|
+
title: string;
|
|
69
|
+
/** Description of the confirmation box (optional) */
|
|
70
|
+
description?: string;
|
|
71
|
+
/** Text of the OK button */
|
|
72
|
+
okText?: string;
|
|
73
|
+
/** Text of the Cancel button */
|
|
74
|
+
cancelText?: string;
|
|
75
|
+
/** Button type of the OK button */
|
|
76
|
+
okType?: PopconfirmButtonType;
|
|
77
|
+
/** Show cancel button */
|
|
78
|
+
showCancel?: boolean;
|
|
79
|
+
/** Icon name */
|
|
80
|
+
icon?: string;
|
|
81
|
+
/** Custom icon color */
|
|
82
|
+
iconColor?: string;
|
|
83
|
+
/** Callback when confirmed */
|
|
84
|
+
onConfirm?: () => void | Promise<void>;
|
|
85
|
+
/** Callback when cancelled */
|
|
86
|
+
onCancel?: () => void;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Position for cursor-based popconfirm
|
|
90
|
+
*/
|
|
91
|
+
export interface PopconfirmPosition {
|
|
92
|
+
x: number;
|
|
93
|
+
y: number;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Active popconfirm item
|
|
97
|
+
*/
|
|
98
|
+
export interface PopconfirmItem {
|
|
99
|
+
id: string;
|
|
100
|
+
config: PopconfirmShowConfig;
|
|
101
|
+
position: PopconfirmPosition;
|
|
102
|
+
loading?: boolean;
|
|
103
|
+
}
|
|
63
104
|
//# sourceMappingURL=popconfirm.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popconfirm.types.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"popconfirm.types.d.ts","sourceRoot":"","sources":["../../../../src/components/popconfirm/popconfirm.types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,0BAAkB,mBAAmB;IACnC,GAAG,QAAQ;IACX,QAAQ,cAAc;IACtB,MAAM,YAAY;IAClB,MAAM,WAAW;IACjB,WAAW,iBAAiB;IAC5B,SAAS,eAAe;IACxB,IAAI,SAAS;IACb,SAAS,eAAe;IACxB,OAAO,aAAa;IACpB,KAAK,UAAU;IACf,UAAU,gBAAgB;IAC1B,QAAQ,cAAc;CACvB;AAED;;GAEG;AACH,0BAAkB,iBAAiB;IACjC,KAAK,UAAU;IACf,KAAK,UAAU;IACf,KAAK,UAAU;CAChB;AAED;;GAEG;AACH,0BAAkB,oBAAoB;IACpC,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,0BAAkB,cAAc;IAC9B,OAAO,uBAAuB;IAC9B,QAAQ,oBAAoB;IAC5B,IAAI,gBAAgB;IACpB,KAAK,iBAAiB;IACtB,OAAO,iBAAiB;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,mBAAmB,CAAC;IAChC,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gCAAgC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mCAAmC;IACnC,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,yBAAyB;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gBAAgB;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wBAAwB;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8BAA8B;IAC9B,SAAS,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,8BAA8B;IAC9B,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,oBAAoB,CAAC;IAC7B,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
|
package/popconfirm.types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popconfirm.types.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"popconfirm.types.js","sourceRoot":"","sources":["../../../../src/components/popconfirm/popconfirm.types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Popconfirm placement options\n * Inherited from dropdown placement options\n */\nexport const enum PopconfirmPlacement {\n Top = 'top',\n TopStart = 'top-start',\n TopEnd = 'top-end',\n Bottom = 'bottom',\n BottomStart = 'bottom-start',\n BottomEnd = 'bottom-end',\n Left = 'left',\n LeftStart = 'left-start',\n LeftEnd = 'left-end',\n Right = 'right',\n RightStart = 'right-start',\n RightEnd = 'right-end',\n}\n\n/**\n * Popconfirm trigger mode\n */\nexport const enum PopconfirmTrigger {\n Click = 'click',\n Hover = 'hover',\n Focus = 'focus',\n}\n\n/**\n * Popconfirm button type\n */\nexport const enum PopconfirmButtonType {\n Primary = 'primary',\n Secondary = 'secondary',\n Danger = 'danger',\n Default = 'default',\n}\n\n/**\n * Predefined icons for popconfirm\n */\nexport const enum PopconfirmIcon {\n Warning = 'exclamation-circle',\n Question = 'question-circle',\n Info = 'info-circle',\n Error = 'close-circle',\n Success = 'check-circle',\n}\n\n/**\n * Popconfirm configuration\n */\nexport interface PopconfirmConfig {\n title: string;\n description?: string;\n okText?: string;\n cancelText?: string;\n okType?: PopconfirmButtonType;\n showCancel?: boolean;\n icon?: string;\n iconColor?: string;\n placement?: PopconfirmPlacement;\n trigger?: PopconfirmTrigger;\n disabled?: boolean;\n arrow?: boolean;\n}\n\n/**\n * Configuration for programmatic popconfirm at cursor position\n */\nexport interface PopconfirmShowConfig {\n /** Title of the confirmation box */\n title: string;\n /** Description of the confirmation box (optional) */\n description?: string;\n /** Text of the OK button */\n okText?: string;\n /** Text of the Cancel button */\n cancelText?: string;\n /** Button type of the OK button */\n okType?: PopconfirmButtonType;\n /** Show cancel button */\n showCancel?: boolean;\n /** Icon name */\n icon?: string;\n /** Custom icon color */\n iconColor?: string;\n /** Callback when confirmed */\n onConfirm?: () => void | Promise<void>;\n /** Callback when cancelled */\n onCancel?: () => void;\n}\n\n/**\n * Position for cursor-based popconfirm\n */\nexport interface PopconfirmPosition {\n x: number;\n y: number;\n}\n\n/**\n * Active popconfirm item\n */\nexport interface PopconfirmItem {\n id: string;\n config: PopconfirmShowConfig;\n position: PopconfirmPosition;\n loading?: boolean;\n}\n"]}
|
package/react.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../../../src/components/popconfirm/react.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,eAAO,MAAM,YAAY;;;;EASvB,CAAC"}
|
package/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"react.js","sourceRoot":"","sources":["../../../../src/components/popconfirm/react.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,MAAM,CAAC,MAAM,YAAY,GAAG,eAAe,CAAC;IAC1C,OAAO,EAAE,eAAe;IACxB,YAAY,EAAE,mBAAmB;IACjC,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE;QACN,SAAS,EAAE,YAAY;QACvB,QAAQ,EAAE,WAAW;QACrB,YAAY,EAAE,gBAAgB;KAC/B;CACF,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport { createComponent } from '@lit-labs/react';\nimport { NrPopconfirmElement } from './popconfirm.component.js';\n\nexport const NrPopconfirm = createComponent({\n tagName: 'nr-popconfirm',\n elementClass: NrPopconfirmElement,\n react: React,\n events: {\n onConfirm: 'nr-confirm',\n onCancel: 'nr-cancel',\n onOpenChange: 'nr-open-change',\n },\n});\n"]}
|