funda-ui 4.7.103 → 4.7.107

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 (55) hide show
  1. package/Chatbox/index.js +8 -3
  2. package/Checkbox/index.js +10 -1
  3. package/Date/index.js +12 -2
  4. package/Input/index.js +6 -1
  5. package/LiveSearch/index.js +5 -0
  6. package/MultipleCheckboxes/index.js +27 -1
  7. package/NumberInput/index.js +6 -1
  8. package/Radio/index.js +22 -1
  9. package/RangeSlider/index.js +6 -1
  10. package/Stepper/index.css +7 -8
  11. package/Stepper/index.d.ts +1 -1
  12. package/Stepper/index.js +7 -1
  13. package/TagInput/index.js +10 -1
  14. package/Textarea/index.js +6 -1
  15. package/Toast/index.css +23 -75
  16. package/Toast/index.d.ts +3 -34
  17. package/Toast/index.js +652 -175
  18. package/lib/cjs/Chatbox/index.js +8 -3
  19. package/lib/cjs/Checkbox/index.js +10 -1
  20. package/lib/cjs/Date/index.js +12 -2
  21. package/lib/cjs/Input/index.js +6 -1
  22. package/lib/cjs/LiveSearch/index.js +5 -0
  23. package/lib/cjs/MultipleCheckboxes/index.js +27 -1
  24. package/lib/cjs/NumberInput/index.js +6 -1
  25. package/lib/cjs/Radio/index.js +22 -1
  26. package/lib/cjs/RangeSlider/index.js +6 -1
  27. package/lib/cjs/Stepper/index.d.ts +1 -1
  28. package/lib/cjs/Stepper/index.js +7 -1
  29. package/lib/cjs/TagInput/index.js +10 -1
  30. package/lib/cjs/Textarea/index.js +6 -1
  31. package/lib/cjs/Toast/index.d.ts +3 -34
  32. package/lib/cjs/Toast/index.js +652 -175
  33. package/lib/css/Stepper/index.css +7 -8
  34. package/lib/css/Toast/index.css +23 -75
  35. package/lib/esm/Chatbox/index.tsx +2 -2
  36. package/lib/esm/Checkbox/index.tsx +12 -1
  37. package/lib/esm/Date/index.tsx +8 -1
  38. package/lib/esm/Input/index.tsx +8 -1
  39. package/lib/esm/LiveSearch/index.tsx +7 -0
  40. package/lib/esm/MultipleCheckboxes/index.tsx +19 -1
  41. package/lib/esm/NumberInput/index.tsx +8 -1
  42. package/lib/esm/Radio/index.tsx +17 -1
  43. package/lib/esm/Stepper/index.scss +7 -8
  44. package/lib/esm/Stepper/index.tsx +2 -2
  45. package/lib/esm/TagInput/index.tsx +8 -1
  46. package/lib/esm/Textarea/index.tsx +8 -1
  47. package/lib/esm/Toast/Item.tsx +52 -11
  48. package/lib/esm/Toast/Toast.tsx +391 -0
  49. package/lib/esm/Toast/ToastContext.tsx +104 -0
  50. package/lib/esm/Toast/__toast.vanilla.js +422 -0
  51. package/lib/esm/Toast/index.scss +24 -96
  52. package/lib/esm/Toast/index.tsx +3 -374
  53. package/lib/esm/Toast/types.ts +60 -0
  54. package/lib/esm/Toast/useToast.tsx +72 -0
  55. package/package.json +1 -1
@@ -29,8 +29,7 @@
29
29
  }
30
30
  .stepper-container .stepper-header {
31
31
  display: flex;
32
- align-items: center;
33
- margin-bottom: 1.5rem;
32
+ align-items: flex-start;
34
33
  flex-wrap: nowrap;
35
34
  position: relative;
36
35
  /* background line */
@@ -38,18 +37,18 @@
38
37
  .stepper-container .stepper-header::before {
39
38
  content: "";
40
39
  position: absolute;
41
- top: calc(50% - 0.875rem); /* Subtract the height of the title */
40
+ top: 16px; /* Subtract the height of the title */
42
41
  left: 14px;
43
42
  right: 0;
44
43
  height: 2px;
45
44
  background-color: var(--stepper-line-default);
46
45
  z-index: 1;
47
- width: calc(100% - var(--stepper-indicator-offset) / 2);
46
+ width: calc(100% - 32px);
48
47
  }
49
48
  .stepper-container .stepper-header::after {
50
49
  content: "";
51
50
  position: absolute;
52
- top: calc(50% - 0.875rem); /* Subtract the height of the title */
51
+ top: 16px; /* Subtract the height of the title */
53
52
  left: 14px;
54
53
  height: 2px;
55
54
  background-color: var(--stepper-line-complete);
@@ -59,7 +58,7 @@
59
58
  }
60
59
  .stepper-container .stepper-header::after {
61
60
  width: var(--stepper-progress-width, 0%);
62
- max-width: calc(100% - var(--stepper-indicator-offset) / 2);
61
+ max-width: calc(100% - 32px);
63
62
  }
64
63
  .stepper-container .step-item {
65
64
  flex: none;
@@ -174,7 +173,7 @@
174
173
  top: 20px;
175
174
  left: 24px;
176
175
  width: 2px;
177
- height: calc(100% - var(--stepper-indicator-offset));
176
+ height: calc(100% - 32px);
178
177
  background-color: var(--stepper-line-default);
179
178
  z-index: 1;
180
179
  }
@@ -191,7 +190,7 @@
191
190
  }
192
191
  .stepper-container.stepper-container--vertical::after {
193
192
  height: var(--stepper-progress-height, 0%);
194
- max-height: calc(100% - var(--stepper-indicator-offset));
193
+ max-height: calc(100% - 32px);
195
194
  }
196
195
  .stepper-container.stepper-container--vertical .vertical-step-row {
197
196
  display: flex;
@@ -9,8 +9,8 @@
9
9
  --toasts-offset-bothsides: 15px;
10
10
  --toasts-container-gap: 0.5rem;
11
11
  --toasts-container-width: 350px;
12
- --toasts-progress-height: 5px;
13
- --toasts-progress-bg: rgba(255,255,255,.6);
12
+ --toasts-progress-height: 3px;
13
+ --toasts-progress-bg: rgba(228, 228, 228, 0.6);
14
14
  width: var(--toasts-container-width);
15
15
  position: fixed;
16
16
  left: 50%;
@@ -72,34 +72,28 @@
72
72
  }
73
73
  .toasts__wrapper .toast-container {
74
74
  margin-bottom: var(--toasts-container-gap);
75
+ /* Use clip-path instead of opacity to achieve a fade effect, avoiding the problem of transparency overlay */
76
+ clip-path: inset(0 0 0 0);
77
+ transform: translateY(0);
78
+ /* Rendering of 3D transformations */
79
+ backface-visibility: hidden;
80
+ transform-style: preserve-3d;
81
+ /* init animation */
82
+ /* enter animation */
83
+ /* exit animation */
84
+ }
85
+ .toasts__wrapper .toast-container.animate-ready {
86
+ pointer-events: none;
87
+ clip-path: inset(0 0 100% 0);
88
+ transform: translateY(10px);
75
89
  }
76
- .toasts__wrapper .toast-container.auto-anim-switch--initfirst {
77
- transform: translateY(-20px);
78
- opacity: 0;
90
+ .toasts__wrapper .toast-container.animate-in {
91
+ clip-path: inset(0 0 0 0);
92
+ transform: translateY(0);
79
93
  }
80
- .toasts__wrapper .toast-container.auto-anim-switch--first {
81
- animation-name: toast-anim-show-first;
82
- animation-duration: 0.3s;
83
- animation-timing-function: linear;
84
- animation-delay: 0;
85
- animation-iteration-count: 1;
86
- animation-fill-mode: forwards;
87
- }
88
- .toasts__wrapper .toast-container.auto-anim-switch:not(.only-one) {
89
- animation-name: toast-anim-hide;
90
- animation-duration: 0.3s;
91
- animation-timing-function: linear;
92
- animation-delay: 0;
93
- animation-iteration-count: 1;
94
- animation-fill-mode: forwards;
95
- }
96
- .toasts__wrapper .toast-container.only-one.auto-anim-switch {
97
- animation-name: toast-anim-hide--onlyone;
98
- animation-duration: 0.3s;
99
- animation-timing-function: linear;
100
- animation-delay: 0;
101
- animation-iteration-count: 1;
102
- animation-fill-mode: forwards;
94
+ .toasts__wrapper .toast-container.hide-start {
95
+ clip-path: inset(0 0 100% 0);
96
+ transform: translateY(-10px);
103
97
  }
104
98
  .toasts__wrapper.toasts__wrapper--cascading .toast-container {
105
99
  margin-bottom: 0;
@@ -120,6 +114,7 @@
120
114
  .toasts__wrapper .toast-progress .progress-bar {
121
115
  background: var(--toasts-progress-bg);
122
116
  width: 100%;
117
+ height: 100%;
123
118
  transition: all 0.1s;
124
119
  }
125
120
 
@@ -152,50 +147,3 @@
152
147
  .toast-container.hide-end {
153
148
  display: none;
154
149
  }
155
-
156
- @keyframes toast-anim-initfirst {
157
- 0% {
158
- transform: translateY(-20px);
159
- opacity: 1;
160
- }
161
- 100% {
162
- transform: translateY(20px);
163
- opacity: 0;
164
- }
165
- }
166
- @keyframes toast-anim-show-first {
167
- 0% {
168
- transform: translateY(-20px);
169
- opacity: 0;
170
- }
171
- 100% {
172
- transform: translateY(0);
173
- opacity: 1;
174
- }
175
- }
176
- @keyframes toast-anim-hide {
177
- 0% {
178
- transform: translateY(-100%);
179
- opacity: 1;
180
- }
181
- 100% {
182
- transform: translateY(10px);
183
- opacity: 0;
184
- /* prevent auto-close's item */
185
- display: block;
186
- }
187
- }
188
- @keyframes toast-anim-hide--onlyone {
189
- 0% {
190
- transform: translateY(-100%);
191
- opacity: 1;
192
- /* prevent auto-close's item */
193
- display: block;
194
- }
195
- 100% {
196
- transform: translateY(10px);
197
- opacity: 0;
198
- /* prevent auto-close's item */
199
- display: block;
200
- }
201
- }
@@ -1496,8 +1496,8 @@ const Chatbox = (props: ChatboxProps) => {
1496
1496
  }
1497
1497
 
1498
1498
  }}
1499
- onChange={(e) => {
1500
- args().onInputChange?.(inputContentRef.current, e.target.value);
1499
+ onChange={(e: React.MouseEvent, el: any, value: string) => {
1500
+ args().onInputChange?.(inputContentRef.current, value);
1501
1501
  }}
1502
1502
  onFocus={() => {
1503
1503
  setFocused(true);
@@ -67,16 +67,27 @@ const Checkbox = forwardRef((props: CheckboxProps, externalRef: any) => {
67
67
  control: () => {
68
68
  return valRef.current;
69
69
  },
70
+ getLatestVal: () => {
71
+ return val;
72
+ },
70
73
  clear: (cb?: any) => {
71
74
  setVal(false);
72
75
  cb?.();
76
+
77
+ if (typeof (onChange) === 'function') {
78
+ onChange(null, false);
79
+ }
73
80
  },
74
81
  set: (value: string, cb?: any) => {
75
82
  setVal(value);
76
83
  cb?.();
84
+
85
+ if (typeof (onChange) === 'function') {
86
+ onChange(null, value);
87
+ }
77
88
  }
78
89
  }),
79
- [contentRef],
90
+ [contentRef, val],
80
91
  );
81
92
 
82
93
 
@@ -342,9 +342,14 @@ const Date = forwardRef((props: DateProps, externalRef: any) => {
342
342
  control: () => {
343
343
  return getAllSplittingInputs();
344
344
  },
345
+ getLatestVal: () => {
346
+ return !dateDefaultValueExist ? `` : valueResConverter(changedVal);
347
+ },
345
348
  clear: (cb?: any) => {
346
349
  clearAll();
347
350
  cb?.();
351
+
352
+ onChange?.(inputRef.current, '', false, getAllSplittingInputs());
348
353
  },
349
354
  blur: (cb?: any) => {
350
355
  getAllSplittingInputs().forEach((el: any) => {
@@ -364,9 +369,11 @@ const Date = forwardRef((props: DateProps, externalRef: any) => {
364
369
  initValue(curTargetVal);
365
370
 
366
371
  cb?.();
372
+
373
+ onChange?.(inputRef.current, value, isValidDate(value), getAllSplittingInputs());
367
374
  }
368
375
  }),
369
- [contentRef],
376
+ [contentRef, dateDefaultValueExist, changedVal],
370
377
  );
371
378
 
372
379
 
@@ -308,13 +308,20 @@ const Input = forwardRef((props: InputProps, externalRef: any) => {
308
308
  control: () => {
309
309
  return valRef.current;
310
310
  },
311
+ getLatestVal: () => {
312
+ return changedVal || '';
313
+ },
311
314
  clear: (cb?: any) => {
312
315
  setChangedVal('');
313
316
  cb?.();
317
+
318
+ onChange?.(null, onComposition, valRef.current, '');
314
319
  },
315
320
  set: (value: string, cb?: any) => {
316
321
  setChangedVal(`${value}`);
317
322
  cb?.();
323
+
324
+ onChange?.(null, onComposition, valRef.current, `${value}`);
318
325
  },
319
326
  aiPredictReset: () => {
320
327
  setTimeout(() => { // Avoid conflicts with other asynchronous states, resulting in invalid clearing
@@ -322,7 +329,7 @@ const Input = forwardRef((props: InputProps, externalRef: any) => {
322
329
  }, 0);
323
330
  },
324
331
  }),
325
- [contentRef],
332
+ [contentRef, onComposition, changedVal],
326
333
  );
327
334
 
328
335
  const propExist = (p: any) => {
@@ -196,13 +196,20 @@ const LiveSearch = forwardRef((props: LiveSearchProps, externalRef: any) => {
196
196
  control: () => {
197
197
  return inputRef.current;
198
198
  },
199
+ getLatestVal: () => {
200
+ return changedVal || '';
201
+ },
199
202
  clear: (cb?: any) => {
200
203
  setChangedVal('');
201
204
  cb?.();
205
+
206
+ onChange?.(inputRef.current, [], '', listRef.current);
202
207
  },
203
208
  set: (value: string, cb?: any) => {
204
209
  setChangedVal(`${value}`);
205
210
  cb?.();
211
+
212
+ onChange?.(inputRef.current, [], '', listRef.current);
206
213
  }
207
214
  }),
208
215
  [contentRef],
@@ -150,16 +150,34 @@ const MultipleCheckboxes = forwardRef((props: MultipleCheckboxesProps, externalR
150
150
  control: () => {
151
151
  return getAllControls();
152
152
  },
153
+ getLatestVal: () => {
154
+ return VALUE_BY_BRACKETS ? convertArrToValByBrackets(valRes(selectedItems)) : valRes(selectedItems).join(',');
155
+ },
153
156
  clear: (cb?: any) => {
154
157
  initDefaultValue('', dataInit);
155
158
  cb?.();
159
+
160
+ onChange?.(null, null, '', null, null, null, null);
156
161
  },
157
162
  set: (value: any, cb?: any) => {
158
163
  initDefaultValue(value, dataInit);
159
164
  cb?.();
165
+
166
+ if (Array.isArray(value)) {
167
+ const _resDataCollection = value;
168
+ const _value = value.map((k: any) => k.value);
169
+ const _valueStr = VALUE_BY_BRACKETS ? value.map((k: any) => `[${k.value}]`).join('') : value.map((k: any) => k.value).join(',');
170
+ const _label = value.map((k: any) => k.label);
171
+ const _labelStr = VALUE_BY_BRACKETS ? value.map((k: any) => `[${k.label}]`).join('') : value.map((k: any) => k.label).join(',');
172
+
173
+ onChange?.(null, _value, _valueStr, _label, _labelStr, null, _resDataCollection);
174
+ } else {
175
+ onChange?.(null, null, value, null, null, null, null);
176
+ }
177
+
160
178
  }
161
179
  }),
162
- [dataInit, contentRef],
180
+ [dataInit, contentRef, selectedItems],
163
181
  );
164
182
 
165
183
 
@@ -105,13 +105,20 @@ const NumberInput = forwardRef((props: NumberInputProps, externalRef: any) => {
105
105
  control: () => {
106
106
  return valRef.current;
107
107
  },
108
+ getLatestVal: () => {
109
+ return changedVal || '';
110
+ },
108
111
  clear: (cb?: any) => {
109
112
  setChangedVal('');
110
113
  cb?.();
114
+
115
+ onChange?.(null, valRef.current, Number(''));
111
116
  },
112
117
  set: (value: string, cb?: any) => {
113
118
  setChangedVal(`${value}`);
114
119
  cb?.();
120
+
121
+ onChange?.(null, valRef.current, Number(formatValue(`${value}`)));
115
122
  },
116
123
  increment: (cb?: any) => {
117
124
  handleIncrement(null);
@@ -123,7 +130,7 @@ const NumberInput = forwardRef((props: NumberInputProps, externalRef: any) => {
123
130
  }
124
131
 
125
132
  }),
126
- [contentRef],
133
+ [contentRef, changedVal],
127
134
  );
128
135
 
129
136
  const propExist = (p: any) => {
@@ -162,16 +162,32 @@ const Radio = forwardRef((props: RadioProps, externalRef: any) => {
162
162
  control: () => {
163
163
  return getAllControls();
164
164
  },
165
+ getLatestVal: () => {
166
+ return controlValue || '';
167
+ },
165
168
  clear: (cb?: any) => {
166
169
  setControlValue('');
167
170
  cb?.();
171
+
172
+ if (typeof (onChange) === 'function') {
173
+ const curData: Record<string, unknown> = optionsFlat(dataInit).find((v: any) => v.value == value);
174
+ const currentIndex: number = optionsFlat(dataInit).findIndex((v: any) => v.value == value);
175
+ onChange(null, '', null, null);
176
+ }
177
+
168
178
  },
169
179
  set: (value: string, cb?: any) => {
170
180
  setControlValue(`${value}`);
171
181
  cb?.();
182
+
183
+ if (typeof (onChange) === 'function') {
184
+ const curData: Record<string, unknown> = optionsFlat(dataInit).find((v: any) => v.value == value);
185
+ const currentIndex: number = optionsFlat(dataInit).findIndex((v: any) => v.value == value);
186
+ onChange(null, `${value}`, curData, currentIndex);
187
+ }
172
188
  }
173
189
  }),
174
- [dataInit, contentRef],
190
+ [dataInit, contentRef, controlValue],
175
191
  );
176
192
 
177
193
 
@@ -28,8 +28,7 @@
28
28
  /* Navigation Header (only horizontal) */
29
29
  .stepper-header {
30
30
  display: flex;
31
- align-items: center;
32
- margin-bottom: 1.5rem;
31
+ align-items: flex-start;
33
32
  flex-wrap: nowrap;
34
33
  position: relative;
35
34
 
@@ -37,19 +36,19 @@
37
36
  &::before {
38
37
  content: '';
39
38
  position: absolute;
40
- top: calc(50% - 0.875rem); /* Subtract the height of the title */
39
+ top: 16px; /* Subtract the height of the title */
41
40
  left: 14px;
42
41
  right: 0;
43
42
  height: 2px;
44
43
  background-color: var(--stepper-line-default);
45
44
  z-index: 1;
46
- width: calc(100% - calc(var(--stepper-indicator-offset)/2));
45
+ width: calc(100% - 32px);
47
46
  }
48
47
 
49
48
  &::after {
50
49
  content: '';
51
50
  position: absolute;
52
- top: calc(50% - 0.875rem); /* Subtract the height of the title */
51
+ top: 16px; /* Subtract the height of the title */
53
52
  left: 14px;
54
53
  height: 2px;
55
54
  background-color: var(--stepper-line-complete);
@@ -60,7 +59,7 @@
60
59
 
61
60
  &::after {
62
61
  width: var(--stepper-progress-width, 0%);
63
- max-width: calc(100% - calc(var(--stepper-indicator-offset)/2));
62
+ max-width: calc(100% - 32px);
64
63
  }
65
64
  }
66
65
 
@@ -215,7 +214,7 @@
215
214
  top: 20px;
216
215
  left: 24px;
217
216
  width: 2px;
218
- height: calc(100% - calc(var(--stepper-indicator-offset)));
217
+ height: calc(100% - 32px);
219
218
  background-color: var(--stepper-line-default);
220
219
  z-index: 1;
221
220
  }
@@ -234,7 +233,7 @@
234
233
 
235
234
  &::after {
236
235
  height: var(--stepper-progress-height, 0%);
237
- max-height: calc(100% - calc(var(--stepper-indicator-offset)));
236
+ max-height: calc(100% - 32px);
238
237
  }
239
238
 
240
239
 
@@ -4,7 +4,7 @@ import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
4
4
 
5
5
 
6
6
  interface StepperPanelProps {
7
- header: React.ReactNode;
7
+ header?: React.ReactNode;
8
8
  children?: React.ReactNode;
9
9
  style?: React.CSSProperties;
10
10
  }
@@ -29,7 +29,7 @@ interface StepperRef {
29
29
 
30
30
  const StepperPanel: React.FC<StepperPanelProps> = (props) => {
31
31
  const {
32
- header,
32
+ header = <><svg width="1rem" height="1rem"><rect fill="none"/></svg></>,
33
33
  children,
34
34
  style
35
35
  } = props;
@@ -102,16 +102,23 @@ const TagInput = forwardRef((props: TagInputProps, externalRef: any) => {
102
102
  control: () => {
103
103
  return valRef.current;
104
104
  },
105
+ getLatestVal: () => {
106
+ return VALUE_BY_BRACKETS ? convertArrToValByBrackets(items.map((item: any) => item.content)) : items.map((item: any) => item.content).join(',');
107
+ },
105
108
  clear: (cb?: any) => {
106
109
  initDefaultValue('');
107
110
  cb?.();
111
+
112
+ onChange?.(inputRef.current, items, '');
108
113
  },
109
114
  set: (value: string, cb?: any) => {
110
115
  initDefaultValue(`${value}`);
111
116
  cb?.();
117
+
118
+ onChange?.(inputRef.current, items, `${value}`);
112
119
  }
113
120
  }),
114
- [contentRef],
121
+ [contentRef, items],
115
122
  );
116
123
 
117
124
 
@@ -297,13 +297,20 @@ const Textarea = forwardRef((props: TextareaProps, externalRef: any) => {
297
297
  control: () => {
298
298
  return valRef.current;
299
299
  },
300
+ getLatestVal: () => {
301
+ return changedVal || '';
302
+ },
300
303
  clear: (cb?: any) => {
301
304
  setChangedVal('');
302
305
  cb?.();
306
+
307
+ onChange?.(null, valRef.current, '');
303
308
  },
304
309
  set: (value: string, cb?: any) => {
305
310
  setChangedVal(`${value}`);
306
311
  cb?.();
312
+
313
+ onChange?.(null, valRef.current, `${value}`);
307
314
  },
308
315
  resetHeight: () => {
309
316
  reset();
@@ -314,7 +321,7 @@ const Textarea = forwardRef((props: TextareaProps, externalRef: any) => {
314
321
  }, 0);
315
322
  },
316
323
  }),
317
- [contentRef, reset]
324
+ [contentRef, reset, changedVal]
318
325
  );
319
326
 
320
327
  const propExist = (p: any) => {
@@ -1,13 +1,20 @@
1
1
  import React, { useRef, forwardRef } from 'react';
2
2
 
3
+ import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
4
+
5
+
3
6
  export interface ItemProps extends React.ComponentPropsWithoutRef<any> {
4
- onlyOne?: boolean;
7
+ depth: number;
5
8
  index: number;
9
+ isNew: boolean;
10
+ uniqueID: string;
11
+
12
+ //
13
+ onlyOne?: boolean;
6
14
  title?: string | React.ReactNode | boolean;
7
15
  note?: string | React.ReactNode | boolean;
8
16
  theme?: string | undefined;
9
17
  message?: string | React.ReactNode;
10
- depth: number;
11
18
  schemeBody?: string;
12
19
  schemeHeader?: string;
13
20
  closeBtnColor?: string;
@@ -24,13 +31,17 @@ export interface ItemProps extends React.ComponentPropsWithoutRef<any> {
24
31
  const Item = forwardRef((props: ItemProps, externalRef: any) => {
25
32
 
26
33
  const {
27
- onlyOne,
34
+ depth,
28
35
  index,
36
+ isNew,
37
+ uniqueID,
38
+
39
+ //
40
+ onlyOne,
29
41
  title,
30
42
  note,
31
43
  theme,
32
44
  message,
33
- depth,
34
45
  lock,
35
46
  cascading,
36
47
  schemeBody,
@@ -43,16 +54,25 @@ const Item = forwardRef((props: ItemProps, externalRef: any) => {
43
54
  evClose
44
55
  } = props;
45
56
 
46
-
57
+
47
58
  const containerRef = useRef<HTMLDivElement>(null);
59
+ const hideTitle: boolean = (title === '' || title === false) && (note === '' || note === false);
48
60
 
49
61
  return (
50
62
  <>
51
63
 
52
64
  <div
53
65
  ref={containerRef}
54
- className={`toast-container ${onlyOne ? 'only-one' : ''}`}
66
+ id={`toast-${uniqueID}`}
67
+ data-toast-id={uniqueID}
68
+ data-new={isNew}
55
69
  data-index={index}
70
+ className={combinedCls(
71
+ 'toast-container',
72
+ {
73
+ 'only-one': onlyOne
74
+ }
75
+ )}
56
76
  style={cascading ? {
57
77
  transform: `perspective(100px) translateZ(-${2 * index}px) translateY(${35 * index}px)`,
58
78
  zIndex: depth
@@ -64,9 +84,20 @@ const Item = forwardRef((props: ItemProps, externalRef: any) => {
64
84
  >
65
85
 
66
86
  {/* Bootstrap toast */}
67
- <div className={`toast fade show ${schemeBody ? schemeBody : ''} ${theme ? `bg-${theme}` : ''}`} role="alert">
68
- {(title === '' || title === false) && (note === '' || note === false) ? null : <>
69
- <div className={`toast-header ${schemeHeader ? schemeHeader : ''}`}>
87
+ <div
88
+ className={combinedCls(
89
+ `toast fade show ${theme ? `bg-${theme}` : ''}`,
90
+ clsWrite(schemeBody, '')
91
+ )}
92
+ role="alert"
93
+ >
94
+ {hideTitle ? null : <>
95
+ <div
96
+ className={combinedCls(
97
+ 'toast-header',
98
+ clsWrite(schemeHeader, '')
99
+ )}
100
+ >
70
101
  <strong className="me-auto">{title === '' || title === false ? '' : <>{title}</>}</strong>
71
102
  <small className="text-muted">{note === '' || note === false ? '' : <>{note}</>}</small>
72
103
  {!lock ? <>{!closeDisabled ? <button
@@ -88,7 +119,7 @@ const Item = forwardRef((props: ItemProps, externalRef: any) => {
88
119
  <div className="toast-body">
89
120
  {message}
90
121
 
91
- {(title === '' || title === false) && (note === '' || note === false) ? <>
122
+ {hideTitle ? <>
92
123
  {!closeDisabled ? <button
93
124
  data-close="1"
94
125
  data-index={index}
@@ -105,7 +136,17 @@ const Item = forwardRef((props: ItemProps, externalRef: any) => {
105
136
 
106
137
 
107
138
  {/* PROGRESS */}
108
- <div ref={externalRef} data-progress-index={index} className={`progress active toast-progress ${autoCloseTime === false ? 'd-none' : ''}`} role="progressbar">
139
+ <div
140
+ ref={externalRef}
141
+ data-progress-index={index}
142
+ className={combinedCls(
143
+ 'progress active toast-progress',
144
+ {
145
+ 'd-none': autoCloseTime === false
146
+ }
147
+ )}
148
+ role="progressbar"
149
+ >
109
150
  <div className="progress-bar"></div>
110
151
  </div>
111
152
  {/* /PROGRESS */}