@nuralyui/popconfirm 0.0.4 → 0.0.5

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.
Files changed (3) hide show
  1. package/bundle.js +249 -2
  2. package/bundle.js.gz +0 -0
  3. package/package.json +1 -1
package/bundle.js CHANGED
@@ -1,6 +1,253 @@
1
- import{css as o,LitElement as r,html as t}from"lit";import{property as n,state as i,customElement as e}from"lit/decorators.js";import{classMap as c}from"lit/directives/class-map.js";import{NuralyUIBaseMixin as a}from"@nuralyui/common/mixins";const l=o`:host{display:inline-block}.popconfirm-content{display:flex;flex-direction:column;gap:12px;padding:12px 16px;min-width:200px;max-width:400px}.popconfirm-message{display:flex;gap:8px;align-items:flex-start}.popconfirm-icon{flex-shrink:0;font-size:16px;line-height:1.5;margin-top:2px}.popconfirm-icon--warning{color:var(--nuraly-color-warning)}.popconfirm-icon--question{color:var(--nuraly-color-info)}.popconfirm-icon--info{color:var(--nuraly-color-info)}.popconfirm-icon--error{color:var(--nuraly-color-error)}.popconfirm-icon--success{color:var(--nuraly-color-success)}.popconfirm-icon--custom{color:var(--nuraly-popconfirm-icon-color,var(--nuraly-color-text))}.popconfirm-text{flex:1;display:flex;flex-direction:column;gap:4px}.popconfirm-title{color:var(--nuraly-color-text);font-size:var(--nuraly-font-size-base);font-weight:600;line-height:1.5;margin:0}.popconfirm-description{color:var(--nuraly-color-text-secondary);font-size:var(--nuraly-font-size-sm);line-height:1.5;margin:0}.popconfirm-buttons{display:flex;gap:8px;justify-content:flex-end;align-items:center}.popconfirm-button{padding:4px 15px;font-size:var(--nuraly-font-size-sm);border-radius:var(--nuraly-border-radius);border:1px solid transparent;cursor:pointer;transition:all .2s;font-weight:400;line-height:1.5;white-space:nowrap;user-select:none}.popconfirm-button:focus-visible{outline:2px solid var(--nuraly-color-primary);outline-offset:2px}.popconfirm-button--cancel{background:var(--nuraly-button-default-background);color:var(--nuraly-button-default-text-color);border-color:var(--nuraly-button-default-border-color)}.popconfirm-button--cancel:hover:not(:disabled){background:var(--nuraly-button-default-hover-background);color:var(--nuraly-button-default-hover-text-color);border-color:var(--nuraly-button-default-hover-border-color)}.popconfirm-button--ok-primary{background:var(--nuraly-button-primary-background);color:var(--nuraly-button-primary-text-color);border-color:var(--nuraly-button-primary-border-color)}.popconfirm-button--ok-primary:hover:not(:disabled){background:var(--nuraly-button-primary-hover-background);color:var(--nuraly-button-primary-hover-text-color);border-color:var(--nuraly-button-primary-hover-border-color)}.popconfirm-button--ok-danger{background:var(--nuraly-button-danger-background);color:var(--nuraly-button-danger-text-color);border-color:var(--nuraly-button-danger-border-color)}.popconfirm-button--ok-danger:hover:not(:disabled){background:var(--nuraly-button-danger-hover-background);color:var(--nuraly-button-danger-hover-text-color);border-color:var(--nuraly-button-danger-hover-border-color)}.popconfirm-button--ok-secondary{background:var(--nuraly-button-secondary-background);color:var(--nuraly-button-secondary-text-color);border-color:var(--nuraly-button-secondary-border-color)}.popconfirm-button--ok-secondary:hover:not(:disabled){background:var(--nuraly-button-secondary-hover-background);color:var(--nuraly-button-secondary-hover-text-color);border-color:var(--nuraly-button-secondary-hover-border-color)}.popconfirm-button--ok-default{background:var(--nuraly-button-default-background);color:var(--nuraly-button-default-text-color);border-color:var(--nuraly-button-default-border-color)}.popconfirm-button--ok-default:hover:not(:disabled){background:var(--nuraly-button-default-hover-background);color:var(--nuraly-button-default-hover-text-color);border-color:var(--nuraly-button-default-hover-border-color)}.popconfirm-button:disabled{opacity:.5;cursor:not-allowed}.popconfirm-button--loading{position:relative;pointer-events:none}.popconfirm-button--loading::before{content:'';position:absolute;left:50%;top:50%;width:14px;height:14px;margin-left:-7px;margin-top:-7px;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:popconfirm-spin .6s linear infinite}.popconfirm-button--loading>*{visibility:hidden}@keyframes popconfirm-spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}:host([dir=rtl]) .popconfirm-message{direction:rtl}:host([dir=rtl]) .popconfirm-buttons{flex-direction:row-reverse}`
1
+ import{css as o,LitElement as r,html as t}from"lit";import{property as n,state as i,customElement as e}from"lit/decorators.js";import{classMap as c}from"lit/directives/class-map.js";import{NuralyUIBaseMixin as a}from"@nuralyui/common/mixins";const l=o`
2
+ :host {
3
+ display: inline-block;
4
+ }
5
+
6
+ .popconfirm-content {
7
+ display: flex;
8
+ flex-direction: column;
9
+ gap: 12px;
10
+ padding: 12px 16px;
11
+ min-width: 200px;
12
+ max-width: 400px;
13
+ }
14
+
15
+ .popconfirm-message {
16
+ display: flex;
17
+ gap: 8px;
18
+ align-items: flex-start;
19
+ }
20
+
21
+ .popconfirm-icon {
22
+ flex-shrink: 0;
23
+ font-size: 16px;
24
+ line-height: 1.5;
25
+ margin-top: 2px;
26
+ }
27
+
28
+ .popconfirm-icon--warning {
29
+ color: var(--nuraly-color-warning);
30
+ }
31
+
32
+ .popconfirm-icon--question {
33
+ color: var(--nuraly-color-info);
34
+ }
35
+
36
+ .popconfirm-icon--info {
37
+ color: var(--nuraly-color-info);
38
+ }
39
+
40
+ .popconfirm-icon--error {
41
+ color: var(--nuraly-color-error);
42
+ }
43
+
44
+ .popconfirm-icon--success {
45
+ color: var(--nuraly-color-success);
46
+ }
47
+
48
+ .popconfirm-icon--custom {
49
+ color: var(--nuraly-popconfirm-icon-color, var(--nuraly-color-text));
50
+ }
51
+
52
+ .popconfirm-text {
53
+ flex: 1;
54
+ display: flex;
55
+ flex-direction: column;
56
+ gap: 4px;
57
+ }
58
+
59
+ .popconfirm-title {
60
+ color: var(--nuraly-color-text);
61
+ font-size: var(--nuraly-font-size-base);
62
+ font-weight: 600;
63
+ line-height: 1.5;
64
+ margin: 0;
65
+ }
66
+
67
+ .popconfirm-description {
68
+ color: var(--nuraly-color-text-secondary);
69
+ font-size: var(--nuraly-font-size-sm);
70
+ line-height: 1.5;
71
+ margin: 0;
72
+ }
73
+
74
+ .popconfirm-buttons {
75
+ display: flex;
76
+ gap: 8px;
77
+ justify-content: flex-end;
78
+ align-items: center;
79
+ }
80
+
81
+ .popconfirm-button {
82
+ padding: 4px 15px;
83
+ font-size: var(--nuraly-font-size-sm);
84
+ border-radius: var(--nuraly-border-radius);
85
+ border: 1px solid transparent;
86
+ cursor: pointer;
87
+ transition: all 0.2s;
88
+ font-weight: 400;
89
+ line-height: 1.5;
90
+ white-space: nowrap;
91
+ user-select: none;
92
+ }
93
+
94
+ .popconfirm-button:focus-visible {
95
+ outline: 2px solid var(--nuraly-color-primary);
96
+ outline-offset: 2px;
97
+ }
98
+
99
+ .popconfirm-button--cancel {
100
+ background: var(--nuraly-button-default-background);
101
+ color: var(--nuraly-button-default-text-color);
102
+ border-color: var(--nuraly-button-default-border-color);
103
+ }
104
+
105
+ .popconfirm-button--cancel:hover:not(:disabled) {
106
+ background: var(--nuraly-button-default-hover-background);
107
+ color: var(--nuraly-button-default-hover-text-color);
108
+ border-color: var(--nuraly-button-default-hover-border-color);
109
+ }
110
+
111
+ .popconfirm-button--ok-primary {
112
+ background: var(--nuraly-button-primary-background);
113
+ color: var(--nuraly-button-primary-text-color);
114
+ border-color: var(--nuraly-button-primary-border-color);
115
+ }
116
+
117
+ .popconfirm-button--ok-primary:hover:not(:disabled) {
118
+ background: var(--nuraly-button-primary-hover-background);
119
+ color: var(--nuraly-button-primary-hover-text-color);
120
+ border-color: var(--nuraly-button-primary-hover-border-color);
121
+ }
122
+
123
+ .popconfirm-button--ok-danger {
124
+ background: var(--nuraly-button-danger-background);
125
+ color: var(--nuraly-button-danger-text-color);
126
+ border-color: var(--nuraly-button-danger-border-color);
127
+ }
128
+
129
+ .popconfirm-button--ok-danger:hover:not(:disabled) {
130
+ background: var(--nuraly-button-danger-hover-background);
131
+ color: var(--nuraly-button-danger-hover-text-color);
132
+ border-color: var(--nuraly-button-danger-hover-border-color);
133
+ }
134
+
135
+ .popconfirm-button--ok-secondary {
136
+ background: var(--nuraly-button-secondary-background);
137
+ color: var(--nuraly-button-secondary-text-color);
138
+ border-color: var(--nuraly-button-secondary-border-color);
139
+ }
140
+
141
+ .popconfirm-button--ok-secondary:hover:not(:disabled) {
142
+ background: var(--nuraly-button-secondary-hover-background);
143
+ color: var(--nuraly-button-secondary-hover-text-color);
144
+ border-color: var(--nuraly-button-secondary-hover-border-color);
145
+ }
146
+
147
+ .popconfirm-button--ok-default {
148
+ background: var(--nuraly-button-default-background);
149
+ color: var(--nuraly-button-default-text-color);
150
+ border-color: var(--nuraly-button-default-border-color);
151
+ }
152
+
153
+ .popconfirm-button--ok-default:hover:not(:disabled) {
154
+ background: var(--nuraly-button-default-hover-background);
155
+ color: var(--nuraly-button-default-hover-text-color);
156
+ border-color: var(--nuraly-button-default-hover-border-color);
157
+ }
158
+
159
+ .popconfirm-button:disabled {
160
+ opacity: 0.5;
161
+ cursor: not-allowed;
162
+ }
163
+
164
+ .popconfirm-button--loading {
165
+ position: relative;
166
+ pointer-events: none;
167
+ }
168
+
169
+ .popconfirm-button--loading::before {
170
+ content: '';
171
+ position: absolute;
172
+ left: 50%;
173
+ top: 50%;
174
+ width: 14px;
175
+ height: 14px;
176
+ margin-left: -7px;
177
+ margin-top: -7px;
178
+ border: 2px solid currentColor;
179
+ border-right-color: transparent;
180
+ border-radius: 50%;
181
+ animation: popconfirm-spin 0.6s linear infinite;
182
+ }
183
+
184
+ .popconfirm-button--loading > * {
185
+ visibility: hidden;
186
+ }
187
+
188
+ @keyframes popconfirm-spin {
189
+ 0% {
190
+ transform: rotate(0deg);
191
+ }
192
+ 100% {
193
+ transform: rotate(360deg);
194
+ }
195
+ }
196
+
197
+ /* RTL Support */
198
+ :host([dir='rtl']) .popconfirm-message {
199
+ direction: rtl;
200
+ }
201
+
202
+ :host([dir='rtl']) .popconfirm-buttons {
203
+ flex-direction: row-reverse;
204
+ }
205
+ `
2
206
  /**
3
207
  * @license
4
208
  * Copyright 2023 Nuraly, Laabidi Aymen
5
209
  * SPDX-License-Identifier: MIT
6
- */;var s=function(o,r,t,n){for(var i,e=arguments.length,c=e<3?r:null===n?n=Object.getOwnPropertyDescriptor(r,t):n,a=o.length-1;a>=0;a--)(i=o[a])&&(c=(e<3?i(c):e>3?i(r,t,c):i(r,t))||c);return e>3&&c&&Object.defineProperty(r,t,c),c},p=function(o,r,t,n){return new(t||(t=Promise))((function(i,e){function c(o){try{l(n.next(o))}catch(o){e(o)}}function a(o){try{l(n.throw(o))}catch(o){e(o)}}function l(o){var r;o.done?i(o.value):(r=o.value,r instanceof t?r:new t((function(o){o(r)}))).then(c,a)}l((n=n.apply(o,r||[])).next())}))};let u=class extends(a(r)){constructor(){super(...arguments),this.requiredComponents=["nr-dropdown","nr-icon"],this.title="",this.description="",this.okText="OK",this.cancelText="Cancel",this.okType="primary",this.showCancel=!0,this.icon="exclamation-circle",this.iconColor="",this.placement="top",this.trigger="click",this.disabled=!1,this.arrow=!0,this.open=!1,this.okLoading=!1,this.handleConfirm=o=>p(this,void 0,void 0,(function*(){o.stopPropagation();const r=new CustomEvent("nr-confirm",{bubbles:!0,composed:!0,cancelable:!0,detail:{originalEvent:o}});if(this.dispatchEvent(r)&&!r.defaultPrevented){const r=this.onConfirm;if(r&&"function"==typeof r){const t=r(o);if(t&&"function"==typeof t.then){this.okLoading=!0;try{yield t,this.closePopconfirm()}catch(o){console.error("Confirmation failed:",o)}finally{this.okLoading=!1}return}}this.closePopconfirm()}})),this.handleCancel=o=>{o.stopPropagation(),this.dispatchEvent(new CustomEvent("nr-cancel",{bubbles:!0,composed:!0,detail:{originalEvent:o}})),this.closePopconfirm()},this.handleOpenChange=o=>{this.open=o.detail.open,this.dispatchEvent(new CustomEvent("nr-open-change",{bubbles:!0,composed:!0,detail:{open:this.open}}))}}get dropdownElement(){var o;return null===(o=this.shadowRoot)||void 0===o?void 0:o.querySelector("nr-dropdown")}closePopconfirm(){this.open=!1,this.dropdownElement&&(this.dropdownElement.open=!1)}getIconColor(){return this.iconColor?this.iconColor:""}getIconClass(){const o={"exclamation-circle":"warning","question-circle":"question","info-circle":"info","close-circle":"error","check-circle":"success"};return this.iconColor?"custom":o[this.icon]||"warning"}renderContent(){const o=this.getIconClass(),r=this.getIconColor(),n=`ok-${this.okType}`;return t`<div class="popconfirm-content"><div class="popconfirm-message"><div class="popconfirm-icon popconfirm-icon--${o}" style="${r?`color: ${r}`:""}"><nr-icon name="${this.icon}"></nr-icon></div><div class="popconfirm-text">${this.title?t`<div class="popconfirm-title">${this.title}</div>`:""} ${this.description?t`<div class="popconfirm-description">${this.description}</div>`:""}</div></div><div class="popconfirm-buttons">${this.showCancel?t`<button class="popconfirm-button popconfirm-button--cancel" @click="${this.handleCancel}" type="button">${this.cancelText}</button>`:""} <button class="${c({"popconfirm-button":!0,[`popconfirm-button--${n}`]:!0,"popconfirm-button--loading":this.okLoading})}" @click="${this.handleConfirm}" ?disabled="${this.okLoading}" type="button">${this.okText}</button></div></div>`}render(){return t`<nr-dropdown .open="${this.open}" .placement="${this.placement}" .trigger="${this.trigger}" ?disabled="${this.disabled}" ?arrow="${this.arrow}" @nr-dropdown-open="${this.handleOpenChange}" @nr-dropdown-close="${this.handleOpenChange}"><slot name="trigger" slot="trigger"></slot><div slot="content">${this.renderContent()}</div></nr-dropdown>`}};u.styles=l,s([n({type:String})],u.prototype,"title",void 0),s([n({type:String})],u.prototype,"description",void 0),s([n({type:String,attribute:"ok-text"})],u.prototype,"okText",void 0),s([n({type:String,attribute:"cancel-text"})],u.prototype,"cancelText",void 0),s([n({type:String,attribute:"ok-type"})],u.prototype,"okType",void 0),s([n({type:Boolean,attribute:"show-cancel"})],u.prototype,"showCancel",void 0),s([n({type:String})],u.prototype,"icon",void 0),s([n({type:String,attribute:"icon-color"})],u.prototype,"iconColor",void 0),s([n({type:String})],u.prototype,"placement",void 0),s([n({type:String})],u.prototype,"trigger",void 0),s([n({type:Boolean})],u.prototype,"disabled",void 0),s([n({type:Boolean})],u.prototype,"arrow",void 0),s([n({type:Boolean,reflect:!0})],u.prototype,"open",void 0),s([i()],u.prototype,"okLoading",void 0),u=s([e("nr-popconfirm")],u);export{u as NrPopconfirmElement};
210
+ */;var s=function(o,r,t,n){for(var i,e=arguments.length,c=e<3?r:null===n?n=Object.getOwnPropertyDescriptor(r,t):n,a=o.length-1;a>=0;a--)(i=o[a])&&(c=(e<3?i(c):e>3?i(r,t,c):i(r,t))||c);return e>3&&c&&Object.defineProperty(r,t,c),c},p=function(o,r,t,n){return new(t||(t=Promise))((function(i,e){function c(o){try{l(n.next(o))}catch(o){e(o)}}function a(o){try{l(n.throw(o))}catch(o){e(o)}}function l(o){var r;o.done?i(o.value):(r=o.value,r instanceof t?r:new t((function(o){o(r)}))).then(c,a)}l((n=n.apply(o,r||[])).next())}))};let u=class extends(a(r)){constructor(){super(...arguments),this.requiredComponents=["nr-dropdown","nr-icon"],this.title="",this.description="",this.okText="OK",this.cancelText="Cancel",this.okType="primary",this.showCancel=!0,this.icon="exclamation-circle",this.iconColor="",this.placement="top",this.trigger="click",this.disabled=!1,this.arrow=!0,this.open=!1,this.okLoading=!1,this.handleConfirm=o=>p(this,void 0,void 0,(function*(){o.stopPropagation();const r=new CustomEvent("nr-confirm",{bubbles:!0,composed:!0,cancelable:!0,detail:{originalEvent:o}});if(this.dispatchEvent(r)&&!r.defaultPrevented){const r=this.onConfirm;if(r&&"function"==typeof r){const t=r(o);if(t&&"function"==typeof t.then){this.okLoading=!0;try{yield t,this.closePopconfirm()}catch(o){console.error("Confirmation failed:",o)}finally{this.okLoading=!1}return}}this.closePopconfirm()}})),this.handleCancel=o=>{o.stopPropagation(),this.dispatchEvent(new CustomEvent("nr-cancel",{bubbles:!0,composed:!0,detail:{originalEvent:o}})),this.closePopconfirm()},this.handleOpenChange=o=>{this.open=o.detail.open,this.dispatchEvent(new CustomEvent("nr-open-change",{bubbles:!0,composed:!0,detail:{open:this.open}}))}}get dropdownElement(){var o;return null===(o=this.shadowRoot)||void 0===o?void 0:o.querySelector("nr-dropdown")}closePopconfirm(){this.open=!1,this.dropdownElement&&(this.dropdownElement.open=!1)}getIconColor(){return this.iconColor?this.iconColor:""}getIconClass(){const o={"exclamation-circle":"warning","question-circle":"question","info-circle":"info","close-circle":"error","check-circle":"success"};return this.iconColor?"custom":o[this.icon]||"warning"}renderContent(){const o=this.getIconClass(),r=this.getIconColor(),n=`ok-${this.okType}`;return t`
211
+ <div class="popconfirm-content">
212
+ <div class="popconfirm-message">
213
+ <div
214
+ class="popconfirm-icon popconfirm-icon--${o}"
215
+ style=${r?`color: ${r}`:""}>
216
+ <nr-icon name=${this.icon}></nr-icon>
217
+ </div>
218
+ <div class="popconfirm-text">
219
+ ${this.title?t`<div class="popconfirm-title">${this.title}</div>`:""}
220
+ ${this.description?t`<div class="popconfirm-description">${this.description}</div>`:""}
221
+ </div>
222
+ </div>
223
+ <div class="popconfirm-buttons">
224
+ ${this.showCancel?t`
225
+ <button
226
+ class="popconfirm-button popconfirm-button--cancel"
227
+ @click=${this.handleCancel}
228
+ type="button">
229
+ ${this.cancelText}
230
+ </button>
231
+ `:""}
232
+ <button
233
+ class=${c({"popconfirm-button":!0,[`popconfirm-button--${n}`]:!0,"popconfirm-button--loading":this.okLoading})}
234
+ @click=${this.handleConfirm}
235
+ ?disabled=${this.okLoading}
236
+ type="button">
237
+ ${this.okText}
238
+ </button>
239
+ </div>
240
+ </div>
241
+ `}render(){return t`
242
+ <nr-dropdown
243
+ .open=${this.open}
244
+ .placement=${this.placement}
245
+ .trigger=${this.trigger}
246
+ ?disabled=${this.disabled}
247
+ ?arrow=${this.arrow}
248
+ @nr-dropdown-open=${this.handleOpenChange}
249
+ @nr-dropdown-close=${this.handleOpenChange}>
250
+ <slot name="trigger" slot="trigger"></slot>
251
+ <div slot="content">${this.renderContent()}</div>
252
+ </nr-dropdown>
253
+ `}};u.styles=l,s([n({type:String})],u.prototype,"title",void 0),s([n({type:String})],u.prototype,"description",void 0),s([n({type:String,attribute:"ok-text"})],u.prototype,"okText",void 0),s([n({type:String,attribute:"cancel-text"})],u.prototype,"cancelText",void 0),s([n({type:String,attribute:"ok-type"})],u.prototype,"okType",void 0),s([n({type:Boolean,attribute:"show-cancel"})],u.prototype,"showCancel",void 0),s([n({type:String})],u.prototype,"icon",void 0),s([n({type:String,attribute:"icon-color"})],u.prototype,"iconColor",void 0),s([n({type:String})],u.prototype,"placement",void 0),s([n({type:String})],u.prototype,"trigger",void 0),s([n({type:Boolean})],u.prototype,"disabled",void 0),s([n({type:Boolean})],u.prototype,"arrow",void 0),s([n({type:Boolean,reflect:!0})],u.prototype,"open",void 0),s([i()],u.prototype,"okLoading",void 0),u=s([e("nr-popconfirm")],u);export{u as NrPopconfirmElement};
package/bundle.js.gz CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuralyui/popconfirm",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "NuralyUI Popconfirm Component - A pop-up confirmation dialog",
5
5
  "author": "Nuraly, Laabidi Aymen",
6
6
  "license": "MIT",