@dashadmin/dash-modal 1.3.16 → 1.3.19

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.
@@ -0,0 +1 @@
1
+ import{Fragment as n,jsx as o,jsxs as i}from"react/jsx-runtime";import{Button as f,Dialog as R,DialogActions as $,DialogContent as _,DialogTitle as F,IconButton as H}from"@mui/material";import{useEffect as D,useState as W}from"react";import z from"@mui/icons-material/Info";import L from"@mui/icons-material/CheckCircle";import j from"@mui/icons-material/Error";import q from"@mui/icons-material/Close";import G from"./assets/modalError.mp3";import J from"./assets/success.mp3";import K from"./assets/modalInfo.mp3";import"./styles/modal.less";import{useTranslate as Q}from"react-admin";const U=s=>{const{children:t,variant:e}=s;switch(e){case"success":return i(n,{children:[o("div",{className:`dash-modal-img dash-modal-img-${e}`,children:o(L,{})}),t&&o("div",{className:"dash-modal-title",children:t})]});case"danger":return i(n,{children:[o("div",{className:`dash-modal-img dash-modal-img-${e}`,children:o(j,{})}),t&&o("div",{className:"dash-modal-title",children:t})]});case"info":case"default":return i(n,{children:[o("div",{className:`dash-modal-img dash-modal-img-${e}`,children:o(z,{})}),t&&o("div",{className:"dash-modal-title",children:t})]});default:return t?o("div",{className:"dash-modal-title",children:t}):o(n,{})}},V=s=>{const t=Q(),{variant:e="default",onClose:p,onCancel:h,onConfirm:g,open:c=!1,confirmText:N=t("dash.action.continue"),cancelText:C=t("dash.action.cancel"),closeText:d=null,title:b,content:w=null,className:v,showCloseButton:I=!0,showCancelButton:y=void 0,showConfirmButton:B=!0,dialogActions:k,sound:m=!0,children:x,...A}=s,S=typeof y=="boolean"?y:!!C,[r,l]=W(c);D(()=>{l(c)},[c]);const T=a=>{l(!1),h&&h()},u=(a,X)=>{l(!1),p&&p()},P=a=>{l(!1),g&&g()},E=()=>{try{if(m){const a=new Audio(J);a.load(),a.play()}}catch(a){console.error(a)}},M=()=>{try{if(m){const a=new Audio(K);a.load(),a.play()}}catch(a){console.error(a)}},O=()=>{try{if(m){const a=new Audio(G);a.load(),a.play()}}catch(a){console.error(a)}};return D(()=>{if(r===!0&&e==="danger"){O();return}if(r===!0&&e==="success"){E();return}if(r===!0){M();return}},[r,e]),i(R,{...A,onClose:u,className:`${v?v+" ":""}dash-modal-${e}`,open:r,children:[i(F,{id:"alert-dialog-title",children:[o(U,{variant:e}),I&&!d&&o(H,{"aria-label":"close",size:"small",onClick:a=>u(a,"backdropClick"),sx:{position:"absolute",right:5,top:20,color:"white",bgcolor:"error.main","&:hover":{bgcolor:"error.dark"},borderRadius:"50%",padding:"8px"},children:o(q,{})})]}),i(_,{children:[o("div",{className:"dash-modal-title",children:o("h3",{children:b})}),x||w]}),i($,{children:[k||o(n,{}),S?o(f,{variant:"contained",className:"btn-width-md",color:"primary",onClick:T,children:C}):o(n,{}),B===!0?o(f,{variant:"contained",className:"btn-width-md",color:"primary",onClick:P,autoFocus:!0,children:N}):o(n,{}),I===!0&&d?o(f,{variant:"contained",className:"btn-width-md",color:"primary",onClick:a=>u(a,"backdropClick"),children:d}):o(n,{})]})]})};var go=V;export{go as default};
@@ -0,0 +1 @@
1
+ import{Fragment as m,jsx as r}from"react/jsx-runtime";import{useState as l}from"react";import n from"./DASHModal";const s={title:"@app/atom/Dialog",component:n},i=o=>{const[t,a]=l(!!o?.open),e=()=>{a(!t)};return r(m,{children:r(n,{...o,open:t,onCancel:()=>e(),onConfirm:()=>e()})})},c={title:{control:!1},confirmText:{type:"string"},cancelText:{type:"string"},children:{type:"string"},onConfirm:{control:!1},onCancel:{control:!1}},p=i.bind({});p.argTypes=c,p.args={title:"T\xEDtulo",open:!0};var M=s;export{p as DASHModalBasic,M as default};
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,261 @@
1
+
2
+ .dash-modal{
3
+ &-default{
4
+ .MuiDialog-paper{
5
+ background: var(--component-bg, #FFFFFF);
6
+ box-shadow: var(--component-shadow, 0px 9px 28px 8px rgba(0, 0, 0, 0.05), 0px 6px 16px rgba(0, 0, 0, 0.08), 0px 3px 6px -4px rgba(0, 0, 0, 0.12));
7
+ > .MuiTypography-root.MuiDialogTitle-root{
8
+ font-family: 'Montserrat';
9
+ font-style: normal;
10
+ font-weight: 700;
11
+ font-size: 16px;
12
+ line-height: 24px;
13
+ color: var(--heading-color, #262626);
14
+ padding: 16px 24px;
15
+ }
16
+ > .MuiDialogContent-root{
17
+ padding: 24px;
18
+ border: 1px solid var(--component-border-split, #F0F0F0);
19
+ border-left: unset;
20
+ border-right: unset;
21
+
22
+ font-family: 'Montserrat';
23
+ font-style: normal;
24
+ font-weight: 400;
25
+ font-size: 14px;
26
+ line-height: 22px;
27
+ color: var(--text-color, #262626);
28
+ }
29
+ > .MuiDialogActions-root{
30
+ padding: 10px 16px;
31
+ }
32
+ }
33
+ }
34
+ &-info, &-success, &-danger{
35
+ .MuiDialog-paper{
36
+ padding-top: 39px;
37
+ background: transparent;
38
+ box-shadow: unset;
39
+ > .MuiTypography-root.MuiDialogTitle-root{
40
+ height: 115px;
41
+ background: var(--primary-color, #9A65E0);
42
+ border-radius: 8px;
43
+ padding: 0 0 30px;
44
+ .dash-modal-img{
45
+ position: relative;
46
+ width: 138.55px;
47
+ height: 124px;
48
+ margin: -39px auto 0;
49
+ svg{
50
+ width: 100%;
51
+ height: 100%;
52
+ object-fit: contain;
53
+ *{
54
+ pointer-events: none;
55
+ }
56
+ }
57
+ }
58
+
59
+ .dash-modal-img {
60
+ svg{
61
+ fill: var(--highlight-color);
62
+ }
63
+ &-info {
64
+ svg{
65
+ fill: var(--alert-info-bg);
66
+ }
67
+ }
68
+ &-success {
69
+ svg{
70
+ fill: var(--alert-success-bg);
71
+ }
72
+ }
73
+ &-danger {
74
+ svg{
75
+ fill: var(--alert-error-bg);
76
+ }
77
+
78
+ }
79
+
80
+ }
81
+ }
82
+ > .MuiDialogContent-root{
83
+ margin-top: -20px;
84
+ padding: 32px 32px 0;
85
+ border: unset;
86
+ background: var(--component-bg, #FFFFFF);
87
+ border-top-left-radius: 8px;
88
+ border-top-right-radius: 8px;
89
+
90
+ font-family: 'Montserrat';
91
+ font-style: normal;
92
+ font-weight: 400;
93
+ font-size: 16px;
94
+ line-height: 32px;
95
+ text-align: center;
96
+ color: var(--text-color, #262626);
97
+ }
98
+ > .MuiDialogActions-root{
99
+ padding: 10px 16px;
100
+ background: var(--component-bg, #FFFFFF);
101
+ border-bottom-left-radius: 8px;
102
+ border-bottom-right-radius: 8px;
103
+ }
104
+ }
105
+ }
106
+ &-info{
107
+ .MuiDialog-paper{
108
+ > .MuiTypography-root.MuiDialogTitle-root{
109
+ background: linear-gradient(93.81deg, var(--primary-color) 3%, var(--primary-contrast) 100%);
110
+ }
111
+ }
112
+ }
113
+ &-success{
114
+ .MuiDialog-paper{
115
+ > .MuiTypography-root.MuiDialogTitle-root{
116
+ background: var(--btn-success-bg, #58BE34);
117
+ }
118
+ }
119
+ }
120
+ &-danger{
121
+ .MuiDialog-paper{
122
+ > .MuiTypography-root.MuiDialogTitle-root{
123
+ background: var(--btn-danger-bg, #ED483D);
124
+ }
125
+ }
126
+ }
127
+ }
128
+
129
+
130
+ /*
131
+
132
+ .dash-modal{
133
+ &-default{
134
+ .MuiDialog-paper{
135
+ background: var(--component-bg);
136
+ box-shadow: var(--component-shadow);
137
+ > .MuiTypography-root.MuiDialogTitle-root{
138
+ font-family: 'Montserrat';
139
+ font-style: normal;
140
+ font-weight: 700;
141
+ font-size: 16px;
142
+ line-height: 24px;
143
+ color: var(--heading-color);
144
+ padding: 16px 24px;
145
+ }
146
+ > .MuiDialogContent-root{
147
+ padding: 24px;
148
+ border: 1px solid var(--component-border-split);
149
+ border-left: unset;
150
+ border-right: unset;
151
+
152
+ font-family: 'Montserrat';
153
+ font-style: normal;
154
+ font-weight: 400;
155
+ font-size: 14px;
156
+ line-height: 22px;
157
+ color: var(--text-color);
158
+ }
159
+ > .MuiDialogActions-root{
160
+ padding: 10px 16px;
161
+ }
162
+ }
163
+ }
164
+ &-info, &-success, &-danger{
165
+ .MuiDialog-paper{
166
+ padding-top: 39px;
167
+ background: transparent;
168
+ box-shadow: unset;
169
+ > .MuiTypography-root.MuiDialogTitle-root{
170
+ height: 115px;
171
+ background: var(--primary-color);
172
+ border-radius: 8px;
173
+ padding: 0 0 30px;
174
+ .dash-modal-img{
175
+ position: relative;
176
+ width: 138.55px;
177
+ height: 124px;
178
+ margin: -39px auto 0;
179
+ svg{
180
+ width: 100%;
181
+ height: 100%;
182
+ object-fit: contain;
183
+ *{
184
+ pointer-events: none;
185
+ }
186
+ }
187
+ }
188
+
189
+ .dash-modal-img {
190
+ svg{
191
+ fill: var(--highlight-color);
192
+ }
193
+ &-info {
194
+ svg{
195
+ fill: var(--alert-info-bg);
196
+ }
197
+ }
198
+ &-success {
199
+ svg{
200
+ fill: var(--alert-success-bg);
201
+ }
202
+ }
203
+ &-danger {
204
+ svg{
205
+ fill: var(--alert-error-bg);
206
+ }
207
+
208
+ }
209
+
210
+ }
211
+
212
+
213
+ }
214
+ > .MuiDialogContent-root{
215
+ margin-top: -20px;
216
+ padding: 32px 32px 0;
217
+ border: unset;
218
+ background: var(--component-bg);
219
+ border-top-left-radius: 8px;
220
+ border-top-right-radius: 8px;
221
+
222
+ font-family: 'Montserrat';
223
+ font-style: normal;
224
+ font-weight: 400;
225
+ font-size: 16px;
226
+ line-height: 32px;
227
+ text-align: center;
228
+ color: var(--text-color);
229
+ }
230
+ > .MuiDialogActions-root{
231
+ padding: 10px 16px;
232
+ background: var(--component-bg);
233
+ border-bottom-left-radius: 8px;
234
+ border-bottom-right-radius: 8px;
235
+ }
236
+ }
237
+ }
238
+ &-info{
239
+ .MuiDialog-paper{
240
+ > .MuiTypography-root.MuiDialogTitle-root{
241
+ background: linear-gradient(93.81deg, var(--primary-color) 2.98%, var(--primary-contrast) 102.49%);
242
+ }
243
+ }
244
+ }
245
+ &-success{
246
+ .MuiDialog-paper{
247
+ > .MuiTypography-root.MuiDialogTitle-root{
248
+ background: var(--btn-success-bg);
249
+ }
250
+ }
251
+ }
252
+ &-danger{
253
+ .MuiDialog-paper{
254
+ > .MuiTypography-root.MuiDialogTitle-root{
255
+ background: var(--btn-danger-bg);
256
+ }
257
+ }
258
+ }
259
+ }
260
+
261
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dashadmin/dash-modal",
3
- "version": "1.3.16",
3
+ "version": "1.3.19",
4
4
  "private": false,
5
5
  "main": "src/index.tsx",
6
6
  "type": "module",
@@ -9,10 +9,12 @@
9
9
  "import": "./src/index.tsx",
10
10
  "require": "./src/index.tsx"
11
11
  },
12
- "./src/*": "./src/*",
12
+ "./src/*": {
13
+ "import": "./src/*"
14
+ },
13
15
  "./index.less": {
14
16
  "import": "./src/styles/index.less",
15
- "require": "./src/styles7index.less"
17
+ "require": "./src/styles/index.less"
16
18
  },
17
19
  "./error.mp3": {
18
20
  "import": "./src/assets/error.mp3",
@@ -34,7 +36,7 @@
34
36
  "lint:fix": "pnpm prettier --write .",
35
37
  "check-updates": "pnpm npm-check-updates",
36
38
  "updates-packages": "pnpm npm-check-updates -u",
37
- "build": "vite build"
39
+ "build": "rm -rf dist && node ../dash-build/compile.mjs && vite build"
38
40
  },
39
41
  "browserslist": {
40
42
  "production": [
@@ -135,6 +137,21 @@
135
137
  "exports": {
136
138
  ".": {
137
139
  "import": "./dist/index.js"
140
+ },
141
+ "./src/*": {
142
+ "import": "./dist/*.js"
143
+ },
144
+ "./index.less": {
145
+ "import": "./dist/styles/index.less"
146
+ },
147
+ "./error.mp3": {
148
+ "import": "./dist/assets/error.mp3"
149
+ },
150
+ "./modalError.mp3": {
151
+ "import": "./dist/assets/modalError.mp3"
152
+ },
153
+ "./success.mp3": {
154
+ "import": "./dist/assets/success.mp3"
138
155
  }
139
156
  }
140
157
  },