@nuralyui/popconfirm 0.0.1

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/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './popconfirm.component.js';
2
+ export * from './popconfirm.types.js';
3
+ //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/popconfirm/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC"}
package/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './popconfirm.component.js';
2
+ export * from './popconfirm.types.js';
3
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/popconfirm/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC","sourcesContent":["export * from './popconfirm.component.js';\nexport * from './popconfirm.types.js';\n"]}
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@nuralyui/popconfirm",
3
+ "version": "0.0.1",
4
+ "description": "NuralyUI Popconfirm Component - A pop-up confirmation dialog",
5
+ "author": "Nuraly, Laabidi Aymen",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "main": "./index.js",
9
+ "module": "./index.js",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./index.js"
13
+ },
14
+ "./bundle": {
15
+ "import": "./bundle.js"
16
+ }
17
+ },
18
+ "keywords": [
19
+ "web-components",
20
+ "lit-element",
21
+ "popconfirm",
22
+ "confirmation",
23
+ "dialog",
24
+ "ui",
25
+ "nuralyui"
26
+ ],
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "https://github.com/NuralyUI/NuralyUI.git"
30
+ }
31
+ }
@@ -0,0 +1,162 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Nuraly, Laabidi Aymen
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ import { LitElement } from 'lit';
7
+ import { PopconfirmPlacement, PopconfirmTrigger, PopconfirmButtonType, PopconfirmIcon } from './popconfirm.types.js';
8
+ import '../dropdown/index.js';
9
+ import '../icon/index.js';
10
+ declare const NrPopconfirmElement_base: (new (...args: any[]) => import("../../shared/dependency-mixin.js").DependencyAware) & (new (...args: any[]) => import("../../shared/theme-mixin.js").ThemeAware) & (new (...args: any[]) => import("../../shared/event-handler-mixin.js").EventHandlerCapable) & typeof LitElement;
11
+ /**
12
+ * # Popconfirm Component
13
+ *
14
+ * A pop-up confirmation dialog triggered by user interaction. It provides a simple and
15
+ * compact way to ask for user confirmation before performing an action.
16
+ *
17
+ * ## Features
18
+ * - Customizable title and description
19
+ * - Configurable OK and Cancel buttons
20
+ * - Multiple placement options (12 positions)
21
+ * - Custom icons with predefined options
22
+ * - Async confirmation support
23
+ * - Multiple trigger modes (click, hover, focus)
24
+ * - Theme-aware styling
25
+ * - Keyboard accessibility
26
+ *
27
+ * ## Usage
28
+ * ```html
29
+ * <!-- Basic popconfirm -->
30
+ * <nr-popconfirm
31
+ * title="Are you sure delete this task?"
32
+ * ok-text="Yes"
33
+ * cancel-text="No">
34
+ * <button slot="trigger">Delete</button>
35
+ * </nr-popconfirm>
36
+ *
37
+ * <!-- With description -->
38
+ * <nr-popconfirm
39
+ * title="Delete the task"
40
+ * description="Are you sure you want to delete this task? This action cannot be undone."
41
+ * ok-type="danger">
42
+ * <button slot="trigger">Delete</button>
43
+ * </nr-popconfirm>
44
+ *
45
+ * <!-- Custom icon -->
46
+ * <nr-popconfirm
47
+ * title="Change status?"
48
+ * icon="question-circle"
49
+ * icon-color="#1890ff">
50
+ * <button slot="trigger">Change Status</button>
51
+ * </nr-popconfirm>
52
+ * ```
53
+ *
54
+ * @element nr-popconfirm
55
+ * @fires nr-confirm - Fired when user confirms the action
56
+ * @fires nr-cancel - Fired when user cancels the action
57
+ * @fires nr-open-change - Fired when popconfirm visibility changes
58
+ *
59
+ * @slot trigger - Element that triggers the popconfirm
60
+ *
61
+ * @cssproperty --nuraly-popconfirm-icon-color - Custom icon color
62
+ */
63
+ export declare class NrPopconfirmElement extends NrPopconfirmElement_base {
64
+ static styles: import("lit").CSSResult;
65
+ requiredComponents: string[];
66
+ /**
67
+ * Title of the confirmation box
68
+ */
69
+ title: string;
70
+ /**
71
+ * Description of the confirmation box (optional)
72
+ */
73
+ description: string;
74
+ /**
75
+ * Text of the OK button
76
+ */
77
+ okText: string;
78
+ /**
79
+ * Text of the Cancel button
80
+ */
81
+ cancelText: string;
82
+ /**
83
+ * Button type of the OK button
84
+ */
85
+ okType: PopconfirmButtonType;
86
+ /**
87
+ * Show cancel button
88
+ */
89
+ showCancel: boolean;
90
+ /**
91
+ * Icon name for the confirmation box
92
+ */
93
+ icon: PopconfirmIcon;
94
+ /**
95
+ * Custom icon color
96
+ */
97
+ iconColor: string;
98
+ /**
99
+ * Placement of the popconfirm
100
+ */
101
+ placement: PopconfirmPlacement;
102
+ /**
103
+ * Trigger mode
104
+ */
105
+ trigger: PopconfirmTrigger;
106
+ /**
107
+ * Whether the popconfirm is disabled
108
+ */
109
+ disabled: boolean;
110
+ /**
111
+ * Whether to show arrow
112
+ */
113
+ arrow: boolean;
114
+ /**
115
+ * Whether the popconfirm is open
116
+ */
117
+ open: boolean;
118
+ /**
119
+ * Loading state for OK button (for async operations)
120
+ */
121
+ private okLoading;
122
+ /**
123
+ * Reference to the dropdown element
124
+ */
125
+ private get dropdownElement();
126
+ /**
127
+ * Handle confirm button click
128
+ */
129
+ private handleConfirm;
130
+ /**
131
+ * Handle cancel button click
132
+ */
133
+ private handleCancel;
134
+ /**
135
+ * Close the popconfirm
136
+ */
137
+ private closePopconfirm;
138
+ /**
139
+ * Handle dropdown open/close events
140
+ */
141
+ private handleOpenChange;
142
+ /**
143
+ * Get icon color based on icon type
144
+ */
145
+ private getIconColor;
146
+ /**
147
+ * Get icon class based on icon type
148
+ */
149
+ private getIconClass;
150
+ /**
151
+ * Render the popconfirm content
152
+ */
153
+ private renderContent;
154
+ render(): import("lit").TemplateResult<1>;
155
+ }
156
+ declare global {
157
+ interface HTMLElementTagNameMap {
158
+ 'nr-popconfirm': NrPopconfirmElement;
159
+ }
160
+ }
161
+ export {};
162
+ //# sourceMappingURL=popconfirm.component.d.ts.map
@@ -0,0 +1 @@
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;AAKvC,OAAO,EACH,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,cAAc,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,sBAAsB,CAAC;AAC9B,OAAO,kBAAkB,CAAC;;AAE1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,qBACa,mBAAoB,SAAQ,wBAA6B;IACpE,OAAgB,MAAM,0BAAU;IAEvB,kBAAkB,WAA8B;IAEzD;;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,KAAK,eAAe,GAE1B;IAED;;OAEG;IACH,OAAO,CAAC,aAAa,CAiCnB;IAEF;;OAEG;IACH,OAAO,CAAC,YAAY,CAYlB;IAEF;;OAEG;IACH,OAAO,CAAC,eAAe;IAOvB;;OAEG;IACH,OAAO,CAAC,gBAAgB,CAStB;IAEF;;OAEG;IACH,OAAO,CAAC,YAAY;IASpB;;OAEG;IACH,OAAO,CAAC,YAAY;IAgBpB;;OAEG;IACH,OAAO,CAAC,aAAa;IA+CZ,MAAM;CAehB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,eAAe,EAAE,mBAAmB,CAAC;KACtC;CACF"}
@@ -0,0 +1,353 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Nuraly, Laabidi Aymen
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
7
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
8
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
9
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ import { html, LitElement } from 'lit';
22
+ import { customElement, property, state } from 'lit/decorators.js';
23
+ import { classMap } from 'lit/directives/class-map.js';
24
+ import { styles } from './popconfirm.style.js';
25
+ import { NuralyUIBaseMixin } from '../../shared/base-mixin.js';
26
+ import '../dropdown/index.js';
27
+ import '../icon/index.js';
28
+ /**
29
+ * # Popconfirm Component
30
+ *
31
+ * A pop-up confirmation dialog triggered by user interaction. It provides a simple and
32
+ * compact way to ask for user confirmation before performing an action.
33
+ *
34
+ * ## Features
35
+ * - Customizable title and description
36
+ * - Configurable OK and Cancel buttons
37
+ * - Multiple placement options (12 positions)
38
+ * - Custom icons with predefined options
39
+ * - Async confirmation support
40
+ * - Multiple trigger modes (click, hover, focus)
41
+ * - Theme-aware styling
42
+ * - Keyboard accessibility
43
+ *
44
+ * ## Usage
45
+ * ```html
46
+ * <!-- Basic popconfirm -->
47
+ * <nr-popconfirm
48
+ * title="Are you sure delete this task?"
49
+ * ok-text="Yes"
50
+ * cancel-text="No">
51
+ * <button slot="trigger">Delete</button>
52
+ * </nr-popconfirm>
53
+ *
54
+ * <!-- With description -->
55
+ * <nr-popconfirm
56
+ * title="Delete the task"
57
+ * description="Are you sure you want to delete this task? This action cannot be undone."
58
+ * ok-type="danger">
59
+ * <button slot="trigger">Delete</button>
60
+ * </nr-popconfirm>
61
+ *
62
+ * <!-- Custom icon -->
63
+ * <nr-popconfirm
64
+ * title="Change status?"
65
+ * icon="question-circle"
66
+ * icon-color="#1890ff">
67
+ * <button slot="trigger">Change Status</button>
68
+ * </nr-popconfirm>
69
+ * ```
70
+ *
71
+ * @element nr-popconfirm
72
+ * @fires nr-confirm - Fired when user confirms the action
73
+ * @fires nr-cancel - Fired when user cancels the action
74
+ * @fires nr-open-change - Fired when popconfirm visibility changes
75
+ *
76
+ * @slot trigger - Element that triggers the popconfirm
77
+ *
78
+ * @cssproperty --nuraly-popconfirm-icon-color - Custom icon color
79
+ */
80
+ let NrPopconfirmElement = class NrPopconfirmElement extends NuralyUIBaseMixin(LitElement) {
81
+ constructor() {
82
+ super(...arguments);
83
+ this.requiredComponents = ['nr-dropdown', 'nr-icon'];
84
+ /**
85
+ * Title of the confirmation box
86
+ */
87
+ this.title = '';
88
+ /**
89
+ * Description of the confirmation box (optional)
90
+ */
91
+ this.description = '';
92
+ /**
93
+ * Text of the OK button
94
+ */
95
+ this.okText = 'OK';
96
+ /**
97
+ * Text of the Cancel button
98
+ */
99
+ this.cancelText = 'Cancel';
100
+ /**
101
+ * Button type of the OK button
102
+ */
103
+ this.okType = "primary" /* PopconfirmButtonType.Primary */;
104
+ /**
105
+ * Show cancel button
106
+ */
107
+ this.showCancel = true;
108
+ /**
109
+ * Icon name for the confirmation box
110
+ */
111
+ this.icon = "exclamation-circle" /* PopconfirmIcon.Warning */;
112
+ /**
113
+ * Custom icon color
114
+ */
115
+ this.iconColor = '';
116
+ /**
117
+ * Placement of the popconfirm
118
+ */
119
+ this.placement = "top" /* PopconfirmPlacement.Top */;
120
+ /**
121
+ * Trigger mode
122
+ */
123
+ this.trigger = "click" /* PopconfirmTrigger.Click */;
124
+ /**
125
+ * Whether the popconfirm is disabled
126
+ */
127
+ this.disabled = false;
128
+ /**
129
+ * Whether to show arrow
130
+ */
131
+ this.arrow = true;
132
+ /**
133
+ * Whether the popconfirm is open
134
+ */
135
+ this.open = false;
136
+ /**
137
+ * Loading state for OK button (for async operations)
138
+ */
139
+ this.okLoading = false;
140
+ /**
141
+ * Handle confirm button click
142
+ */
143
+ this.handleConfirm = (e) => __awaiter(this, void 0, void 0, function* () {
144
+ e.stopPropagation();
145
+ const confirmEvent = new CustomEvent('nr-confirm', {
146
+ bubbles: true,
147
+ composed: true,
148
+ cancelable: true,
149
+ detail: { originalEvent: e },
150
+ });
151
+ const dispatched = this.dispatchEvent(confirmEvent);
152
+ // If event is not prevented, close the popconfirm
153
+ if (dispatched && !confirmEvent.defaultPrevented) {
154
+ // Check if the event handler returns a promise
155
+ const handler = this.onConfirm;
156
+ if (handler && typeof handler === 'function') {
157
+ const result = handler(e);
158
+ if (result && typeof result.then === 'function') {
159
+ this.okLoading = true;
160
+ try {
161
+ yield result;
162
+ this.closePopconfirm();
163
+ }
164
+ catch (error) {
165
+ console.error('Confirmation failed:', error);
166
+ }
167
+ finally {
168
+ this.okLoading = false;
169
+ }
170
+ return;
171
+ }
172
+ }
173
+ this.closePopconfirm();
174
+ }
175
+ });
176
+ /**
177
+ * Handle cancel button click
178
+ */
179
+ this.handleCancel = (e) => {
180
+ e.stopPropagation();
181
+ this.dispatchEvent(new CustomEvent('nr-cancel', {
182
+ bubbles: true,
183
+ composed: true,
184
+ detail: { originalEvent: e },
185
+ }));
186
+ this.closePopconfirm();
187
+ };
188
+ /**
189
+ * Handle dropdown open/close events
190
+ */
191
+ this.handleOpenChange = (e) => {
192
+ this.open = e.detail.open;
193
+ this.dispatchEvent(new CustomEvent('nr-open-change', {
194
+ bubbles: true,
195
+ composed: true,
196
+ detail: { open: this.open },
197
+ }));
198
+ };
199
+ }
200
+ /**
201
+ * Reference to the dropdown element
202
+ */
203
+ get dropdownElement() {
204
+ var _a;
205
+ return (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('nr-dropdown');
206
+ }
207
+ /**
208
+ * Close the popconfirm
209
+ */
210
+ closePopconfirm() {
211
+ this.open = false;
212
+ if (this.dropdownElement) {
213
+ this.dropdownElement.open = false;
214
+ }
215
+ }
216
+ /**
217
+ * Get icon color based on icon type
218
+ */
219
+ getIconColor() {
220
+ if (this.iconColor) {
221
+ return this.iconColor;
222
+ }
223
+ // Return empty string to use CSS class colors
224
+ return '';
225
+ }
226
+ /**
227
+ * Get icon class based on icon type
228
+ */
229
+ getIconClass() {
230
+ const iconColorMap = {
231
+ ["exclamation-circle" /* PopconfirmIcon.Warning */]: 'warning',
232
+ ["question-circle" /* PopconfirmIcon.Question */]: 'question',
233
+ ["info-circle" /* PopconfirmIcon.Info */]: 'info',
234
+ ["close-circle" /* PopconfirmIcon.Error */]: 'error',
235
+ ["check-circle" /* PopconfirmIcon.Success */]: 'success',
236
+ };
237
+ if (this.iconColor) {
238
+ return 'custom';
239
+ }
240
+ return iconColorMap[this.icon] || 'warning';
241
+ }
242
+ /**
243
+ * Render the popconfirm content
244
+ */
245
+ renderContent() {
246
+ const iconClass = this.getIconClass();
247
+ const iconColor = this.getIconColor();
248
+ const okButtonClass = `ok-${this.okType}`;
249
+ return html `
250
+ <div class="popconfirm-content">
251
+ <div class="popconfirm-message">
252
+ <div
253
+ class="popconfirm-icon popconfirm-icon--${iconClass}"
254
+ style=${iconColor ? `color: ${iconColor}` : ''}>
255
+ <nr-icon name=${this.icon}></nr-icon>
256
+ </div>
257
+ <div class="popconfirm-text">
258
+ ${this.title ? html `<div class="popconfirm-title">${this.title}</div>` : ''}
259
+ ${this.description
260
+ ? html `<div class="popconfirm-description">${this.description}</div>`
261
+ : ''}
262
+ </div>
263
+ </div>
264
+ <div class="popconfirm-buttons">
265
+ ${this.showCancel
266
+ ? html `
267
+ <button
268
+ class="popconfirm-button popconfirm-button--cancel"
269
+ @click=${this.handleCancel}
270
+ type="button">
271
+ ${this.cancelText}
272
+ </button>
273
+ `
274
+ : ''}
275
+ <button
276
+ class=${classMap({
277
+ 'popconfirm-button': true,
278
+ [`popconfirm-button--${okButtonClass}`]: true,
279
+ 'popconfirm-button--loading': this.okLoading,
280
+ })}
281
+ @click=${this.handleConfirm}
282
+ ?disabled=${this.okLoading}
283
+ type="button">
284
+ ${this.okText}
285
+ </button>
286
+ </div>
287
+ </div>
288
+ `;
289
+ }
290
+ render() {
291
+ return html `
292
+ <nr-dropdown
293
+ .open=${this.open}
294
+ .placement=${this.placement}
295
+ .trigger=${this.trigger}
296
+ ?disabled=${this.disabled}
297
+ ?arrow=${this.arrow}
298
+ @nr-dropdown-open=${this.handleOpenChange}
299
+ @nr-dropdown-close=${this.handleOpenChange}>
300
+ <slot name="trigger" slot="trigger"></slot>
301
+ <div slot="content">${this.renderContent()}</div>
302
+ </nr-dropdown>
303
+ `;
304
+ }
305
+ };
306
+ NrPopconfirmElement.styles = styles;
307
+ __decorate([
308
+ property({ type: String })
309
+ ], NrPopconfirmElement.prototype, "title", void 0);
310
+ __decorate([
311
+ property({ type: String })
312
+ ], NrPopconfirmElement.prototype, "description", void 0);
313
+ __decorate([
314
+ property({ type: String, attribute: 'ok-text' })
315
+ ], NrPopconfirmElement.prototype, "okText", void 0);
316
+ __decorate([
317
+ property({ type: String, attribute: 'cancel-text' })
318
+ ], NrPopconfirmElement.prototype, "cancelText", void 0);
319
+ __decorate([
320
+ property({ type: String, attribute: 'ok-type' })
321
+ ], NrPopconfirmElement.prototype, "okType", void 0);
322
+ __decorate([
323
+ property({ type: Boolean, attribute: 'show-cancel' })
324
+ ], NrPopconfirmElement.prototype, "showCancel", void 0);
325
+ __decorate([
326
+ property({ type: String })
327
+ ], NrPopconfirmElement.prototype, "icon", void 0);
328
+ __decorate([
329
+ property({ type: String, attribute: 'icon-color' })
330
+ ], NrPopconfirmElement.prototype, "iconColor", void 0);
331
+ __decorate([
332
+ property({ type: String })
333
+ ], NrPopconfirmElement.prototype, "placement", void 0);
334
+ __decorate([
335
+ property({ type: String })
336
+ ], NrPopconfirmElement.prototype, "trigger", void 0);
337
+ __decorate([
338
+ property({ type: Boolean })
339
+ ], NrPopconfirmElement.prototype, "disabled", void 0);
340
+ __decorate([
341
+ property({ type: Boolean })
342
+ ], NrPopconfirmElement.prototype, "arrow", void 0);
343
+ __decorate([
344
+ property({ type: Boolean, reflect: true })
345
+ ], NrPopconfirmElement.prototype, "open", void 0);
346
+ __decorate([
347
+ state()
348
+ ], NrPopconfirmElement.prototype, "okLoading", void 0);
349
+ NrPopconfirmElement = __decorate([
350
+ customElement('nr-popconfirm')
351
+ ], NrPopconfirmElement);
352
+ export { NrPopconfirmElement };
353
+ //# sourceMappingURL=popconfirm.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popconfirm.component.js","sourceRoot":"","sources":["../../../src/components/popcon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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 '../../shared/base-mixin.js';\nimport {\n PopconfirmPlacement,\n PopconfirmTrigger,\n PopconfirmButtonType,\n PopconfirmIcon,\n} from './popconfirm.types.js';\nimport '../dropdown/index.js';\nimport '../icon/index.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"]}
@@ -0,0 +1,2 @@
1
+ export declare const styles: import("lit").CSSResult;
2
+ //# sourceMappingURL=popconfirm.style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popconfirm.style.d.ts","sourceRoot":"","sources":["../../../src/components/popconfirm/popconfirm.style.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,yBA4MlB,CAAC"}