@dataloop-ai/components 0.16.58 → 0.16.61
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/package.json +1 -1
- package/src/assets/constants.scss +1 -1
- package/src/assets/globals.scss +18 -16
- package/src/components/basic/DlKpi/DlKpi.vue +4 -3
- package/src/components/compound/DlToast/api/useToast.ts +40 -3
- package/src/components/compound/DlToast/components/ToastComponent.vue +82 -13
- package/src/components/compound/DlToast/utils/render.ts +2 -2
- package/src/components/essential/DlProgressBar/DlProgressBar.vue +8 -3
- package/src/demos/DlAlertDemo.vue +7 -0
- package/src/demos/DlToastDemo.vue +1 -1
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Constants
|
|
3
3
|
--dl-color-alert-success: #38D079;
|
|
4
4
|
--dl-color-alert-success-background: #E1FFF0;
|
|
5
|
-
--dl-color-alert-warn:
|
|
5
|
+
--dl-color-alert-warn: #FFDA3A;
|
|
6
6
|
--dl-color-alert-warn-background: #FFF7D6;
|
|
7
7
|
--dl-color-alert-error: #FF3434;
|
|
8
8
|
--dl-color-alert-error-background: #FFEAEA ;
|
package/src/assets/globals.scss
CHANGED
|
@@ -155,22 +155,25 @@ body {
|
|
|
155
155
|
--dl-color-panel-background: #FFFFFF;
|
|
156
156
|
--dl-color-side-panel: #18195C;
|
|
157
157
|
--dl-color-shadow: #FFFFFF;
|
|
158
|
-
--dl-color-negative: #FF3434;
|
|
159
|
-
--dl-color-negative-background: #FFEAEA;
|
|
160
|
-
--dl-color-warning: #FFDA3A;
|
|
161
|
-
--dl-color-warning-background: #FFF7D6;
|
|
162
|
-
--dl-color-positive: #039E49;
|
|
163
|
-
--dl-color-positive-background: #E1FFF0;
|
|
164
|
-
--dl-color-info-background: #F3F9FF;
|
|
165
158
|
--dl-color-icon-default: #171723;
|
|
166
159
|
--dl-color-fill-secondary: #FBF8F8;
|
|
167
160
|
--dl-color-fill-third: #FBFBFB;
|
|
168
161
|
--dl-color-link: #20ABFA;
|
|
169
|
-
--dl-color-info: #4E81B3;
|
|
170
162
|
--dl-color-cell-background: #FFFAE2;
|
|
171
163
|
--q-color-positive: #38D079;
|
|
172
164
|
--q-color-warning: #E1B75B;
|
|
173
165
|
|
|
166
|
+
// alert colors
|
|
167
|
+
--dl-color-negative: var(--dl-color-alert-error);
|
|
168
|
+
--dl-color-negative-background: var(--dl-color-alert-error-background);
|
|
169
|
+
--dl-color-warning: var(--dl-color-alert-warn);
|
|
170
|
+
--dl-color-warning-background: var(--dl-color-alert-warn-background);
|
|
171
|
+
--dl-color-positive: var(--dl-color-alert-success);
|
|
172
|
+
--dl-color-positive-background: var(--dl-color-alert-success-background);
|
|
173
|
+
--dl-color-info: var(--dl-color-alert-info);
|
|
174
|
+
--dl-color-info-background: var(--dl-color-alert-info-background);
|
|
175
|
+
|
|
176
|
+
|
|
174
177
|
--dl-color-chart-brush: #EEF1FF;
|
|
175
178
|
|
|
176
179
|
--dl-date-picker-shadow: 0px 3px 6px #101e7326;
|
|
@@ -205,22 +208,21 @@ body {
|
|
|
205
208
|
--dl-color-panel-background: #30363D;
|
|
206
209
|
--dl-color-side-panel: #2A343E;
|
|
207
210
|
--dl-color-shadow: #30363D;
|
|
208
|
-
--dl-color-negative: #FF3434;
|
|
209
|
-
--dl-color-negative-background: #734145;
|
|
210
|
-
--dl-color-warning: #FFDA3A;
|
|
211
|
-
--dl-color-warning-background: #7B7241;
|
|
212
|
-
--dl-color-positive: #00DE93;
|
|
213
|
-
--dl-color-positive-background: #3A644E;
|
|
214
|
-
--dl-color-info-background: #2F3C4B;
|
|
215
211
|
--dl-color-icon-default: #ffffffbf;
|
|
216
212
|
--dl-color-fill-secondary: #FFFFFF1A;
|
|
217
213
|
--dl-color-fill-third: #9E9E9E1A;
|
|
218
214
|
--dl-color-link: #53B2E8;
|
|
219
|
-
--dl-color-info: #92CDF2;
|
|
220
215
|
--dl-color-cell-background: #FFFAE2;
|
|
221
216
|
--q-color-positive: #A1E5B6;
|
|
222
217
|
--q-color-warning: #F8D29A;
|
|
223
218
|
|
|
219
|
+
// alert colors
|
|
220
|
+
--dl-color-negative-background: #734145;
|
|
221
|
+
--dl-color-warning-background: #7B7241;
|
|
222
|
+
--dl-color-positive-background: #3A644E;
|
|
223
|
+
--dl-color-info-background: #4B5A6B;
|
|
224
|
+
--dl-color-info: #92CDF2;
|
|
225
|
+
|
|
224
226
|
--dl-color-chart-brush: #475077;
|
|
225
227
|
|
|
226
228
|
--dl-date-picker-shadow: 0px 3px 6px #292e3580;
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
>
|
|
44
44
|
<dl-progress-bar
|
|
45
45
|
color="dl-color-darker"
|
|
46
|
+
height="5px"
|
|
46
47
|
:value="progressValue(progress)"
|
|
47
48
|
:show-value="true"
|
|
48
49
|
:show-percentage="true"
|
|
@@ -151,13 +152,13 @@ export default defineComponent({
|
|
|
151
152
|
)
|
|
152
153
|
|
|
153
154
|
const formatCounter = (counter: DlKpiCounterType) => {
|
|
154
|
-
if (
|
|
155
|
+
if (counter === null) {
|
|
155
156
|
return emptyString
|
|
156
157
|
}
|
|
157
158
|
if (typeof counter === 'number') {
|
|
158
159
|
return formatNumberCounter(counter)
|
|
159
160
|
}
|
|
160
|
-
if (
|
|
161
|
+
if (counter.value === null || counter.value === undefined) {
|
|
161
162
|
return emptyString
|
|
162
163
|
}
|
|
163
164
|
if (typeof counter.value === 'number') {
|
|
@@ -197,7 +198,7 @@ export default defineComponent({
|
|
|
197
198
|
}
|
|
198
199
|
|
|
199
200
|
const formatNumberCounter = (amount: number, format = '') => {
|
|
200
|
-
if (
|
|
201
|
+
if (isNaN(amount)) {
|
|
201
202
|
return emptyString
|
|
202
203
|
}
|
|
203
204
|
if (amount === 0) {
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
import { isVue3 } from 'vue-demi'
|
|
1
2
|
import toastComponent from '../components/ToastComponent.vue'
|
|
2
3
|
import { createComponent } from '../utils/render'
|
|
4
|
+
import { v4 } from 'uuid'
|
|
5
|
+
|
|
6
|
+
const state: { prevToastId: any; toasts: { [key: string]: any } } = {
|
|
7
|
+
prevToastId: null,
|
|
8
|
+
toasts: {}
|
|
9
|
+
}
|
|
3
10
|
|
|
4
11
|
export const useToast = (globalProps = {}) => {
|
|
5
12
|
return {
|
|
@@ -8,16 +15,46 @@ export const useToast = (globalProps = {}) => {
|
|
|
8
15
|
if (typeof options === 'string') message = options
|
|
9
16
|
|
|
10
17
|
const defaultProps = {
|
|
11
|
-
message
|
|
18
|
+
message,
|
|
19
|
+
identifier: v4()
|
|
12
20
|
}
|
|
13
21
|
|
|
14
22
|
const propsData = Object.assign(
|
|
15
23
|
{},
|
|
16
24
|
defaultProps,
|
|
17
25
|
globalProps,
|
|
18
|
-
options
|
|
26
|
+
options,
|
|
27
|
+
{
|
|
28
|
+
remove: () => {
|
|
29
|
+
delete state.toasts[defaultProps.identifier]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
if (state.prevToastId && state.toasts[state.prevToastId]) {
|
|
35
|
+
const toast = state.toasts[state.prevToastId]
|
|
36
|
+
const props = isVue3 ? toast.props : toast.$children[0]
|
|
37
|
+
const similar =
|
|
38
|
+
propsData.message === props.message &&
|
|
39
|
+
propsData.type === props.type
|
|
40
|
+
if (similar) {
|
|
41
|
+
if (isVue3) {
|
|
42
|
+
toast.proxy.updateCount(toast.proxy.count + 1)
|
|
43
|
+
} else {
|
|
44
|
+
toast.$children[0].updateCount(
|
|
45
|
+
toast.$children[0].count + 1
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
return
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
state.prevToastId = defaultProps.identifier
|
|
53
|
+
state.toasts[defaultProps.identifier] = createComponent(
|
|
54
|
+
toastComponent,
|
|
55
|
+
propsData,
|
|
56
|
+
document.body
|
|
19
57
|
)
|
|
20
|
-
createComponent(toastComponent, propsData, document.body)
|
|
21
58
|
}
|
|
22
59
|
}
|
|
23
60
|
}
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
>
|
|
6
6
|
<div
|
|
7
7
|
v-show="isActive"
|
|
8
|
-
id="DlToastContainer"
|
|
8
|
+
:id="`DlToastContainer-${uuid}`"
|
|
9
9
|
ref="root"
|
|
10
|
-
class="toast-item"
|
|
10
|
+
class="toast-item DlToastContainer"
|
|
11
11
|
:class="[
|
|
12
12
|
`toast-item--${type}`,
|
|
13
13
|
`toast-item--${position}`,
|
|
@@ -21,12 +21,35 @@
|
|
|
21
21
|
:closable="closable"
|
|
22
22
|
:dark-mode="false"
|
|
23
23
|
close-button-position="center"
|
|
24
|
+
style="position: relative"
|
|
24
25
|
@update:model-value="closeToast"
|
|
25
26
|
>
|
|
26
27
|
<span
|
|
27
28
|
class="toast-message"
|
|
28
29
|
data-test="message-text"
|
|
29
30
|
/>
|
|
31
|
+
<dl-badge
|
|
32
|
+
v-if="count"
|
|
33
|
+
with-border
|
|
34
|
+
floating
|
|
35
|
+
align="top"
|
|
36
|
+
:color="badgeColor"
|
|
37
|
+
:text-color="
|
|
38
|
+
type === 'warning'
|
|
39
|
+
? 'var(--dl-color-alert-text)'
|
|
40
|
+
: 'var(--dl-color-text-buttons)'
|
|
41
|
+
"
|
|
42
|
+
style="
|
|
43
|
+
display: grid;
|
|
44
|
+
text-align: center;
|
|
45
|
+
width: fit-content;
|
|
46
|
+
padding: 3px;
|
|
47
|
+
min-width: 1em;
|
|
48
|
+
top: -5px;
|
|
49
|
+
"
|
|
50
|
+
>
|
|
51
|
+
{{ count + 1 }}
|
|
52
|
+
</dl-badge>
|
|
30
53
|
</dl-alert>
|
|
31
54
|
</div>
|
|
32
55
|
</transition>
|
|
@@ -40,14 +63,15 @@ import {
|
|
|
40
63
|
onMounted,
|
|
41
64
|
ref
|
|
42
65
|
} from 'vue-demi'
|
|
43
|
-
import { DlAlert } from '../../../
|
|
66
|
+
import { DlAlert, DlBadge } from '../../../'
|
|
44
67
|
import { Positions, Types } from '../utils/config'
|
|
45
68
|
import { removeElement } from '../utils/render'
|
|
46
69
|
import { Animation } from '../types'
|
|
70
|
+
import { v4 } from 'uuid'
|
|
47
71
|
|
|
48
72
|
export default defineComponent({
|
|
49
73
|
name: 'ToastComponent',
|
|
50
|
-
components: { DlAlert },
|
|
74
|
+
components: { DlAlert, DlBadge },
|
|
51
75
|
props: {
|
|
52
76
|
message: {
|
|
53
77
|
type: String,
|
|
@@ -88,16 +112,22 @@ export default defineComponent({
|
|
|
88
112
|
default: 5
|
|
89
113
|
}
|
|
90
114
|
},
|
|
91
|
-
|
|
115
|
+
emits: ['removed'],
|
|
116
|
+
setup(props: any, { emit }) {
|
|
117
|
+
const uuid = v4()
|
|
92
118
|
const { position, duration, message, collapseCount } = props
|
|
93
119
|
const root = ref(null)
|
|
120
|
+
const count = ref(0)
|
|
94
121
|
let parentTop: HTMLElement = null
|
|
95
122
|
let parentBottom: HTMLElement = null
|
|
96
123
|
const toastParentPosition = ref(null)
|
|
97
124
|
const isActive = ref(false)
|
|
98
125
|
function closeToastMessage(): void {
|
|
99
126
|
isActive.value = false
|
|
100
|
-
setTimeout(() =>
|
|
127
|
+
setTimeout(() => {
|
|
128
|
+
emit('removed')
|
|
129
|
+
removeElement(root.value)
|
|
130
|
+
}, 200)
|
|
101
131
|
}
|
|
102
132
|
onBeforeMount(() => {
|
|
103
133
|
setupContainer()
|
|
@@ -157,6 +187,19 @@ export default defineComponent({
|
|
|
157
187
|
showNotice()
|
|
158
188
|
})
|
|
159
189
|
|
|
190
|
+
const timeoutId = ref(null)
|
|
191
|
+
|
|
192
|
+
const setHideTimeout = () => {
|
|
193
|
+
if (timeoutId.value) {
|
|
194
|
+
clearTimeout(timeoutId.value)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
timeoutId.value = setTimeout(() => {
|
|
198
|
+
closeToastMessage()
|
|
199
|
+
timeoutId.value = null
|
|
200
|
+
}, duration * 1000)
|
|
201
|
+
}
|
|
202
|
+
|
|
160
203
|
function showNotice(): void {
|
|
161
204
|
const parent = correctParent.value
|
|
162
205
|
const container = root.value.closest('.dl-toast-container--pending')
|
|
@@ -165,24 +208,50 @@ export default defineComponent({
|
|
|
165
208
|
container?.remove()
|
|
166
209
|
isActive.value = true
|
|
167
210
|
if (duration) {
|
|
168
|
-
|
|
169
|
-
closeToastMessage()
|
|
170
|
-
}, duration * 1000)
|
|
211
|
+
setHideTimeout()
|
|
171
212
|
}
|
|
172
213
|
if (collapseCount && collapseCount < parent.childNodes.length) {
|
|
173
|
-
setTimeout(() =>
|
|
214
|
+
setTimeout(() => {
|
|
215
|
+
emit('removed')
|
|
216
|
+
removeElement(parent.lastElementChild)
|
|
217
|
+
}, 200)
|
|
174
218
|
}
|
|
175
219
|
}
|
|
176
220
|
function closeToast(val: boolean) {
|
|
177
|
-
if (!val)
|
|
221
|
+
if (!val) {
|
|
222
|
+
emit('removed')
|
|
223
|
+
removeElement(root.value)
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const updateCount = (val: number) => {
|
|
228
|
+
count.value = val
|
|
229
|
+
setHideTimeout()
|
|
178
230
|
}
|
|
179
231
|
|
|
232
|
+
const badgeColor = computed(() => {
|
|
233
|
+
switch (props.type) {
|
|
234
|
+
case Types.success:
|
|
235
|
+
return 'var(--dl-color-alert-success)'
|
|
236
|
+
case Types.warning:
|
|
237
|
+
return 'var(--dl-color-alert-warn)'
|
|
238
|
+
case Types.error:
|
|
239
|
+
return 'var(--dl-color-alert-error)'
|
|
240
|
+
case Types.info:
|
|
241
|
+
return 'var(--dl-color-alert-info)'
|
|
242
|
+
}
|
|
243
|
+
})
|
|
244
|
+
|
|
180
245
|
return {
|
|
246
|
+
uuid,
|
|
181
247
|
root,
|
|
182
248
|
transition,
|
|
183
249
|
isActive,
|
|
184
250
|
closeToast,
|
|
185
|
-
correctParent
|
|
251
|
+
correctParent,
|
|
252
|
+
updateCount,
|
|
253
|
+
count,
|
|
254
|
+
badgeColor
|
|
186
255
|
}
|
|
187
256
|
}
|
|
188
257
|
})
|
|
@@ -304,7 +373,7 @@ export default defineComponent({
|
|
|
304
373
|
}
|
|
305
374
|
}
|
|
306
375
|
|
|
307
|
-
|
|
376
|
+
.DlToastContainer {
|
|
308
377
|
--dl-color-negative: var(--dl-color-alert-error);
|
|
309
378
|
--dl-color-negative-background: var(--dl-color-alert-error-background);
|
|
310
379
|
--dl-color-warning: var(--dl-color-alert-warn);
|
|
@@ -30,7 +30,7 @@ if (VueDemi.isVue3) {
|
|
|
30
30
|
const container = document.createElement('div')
|
|
31
31
|
container.classList.add('dl-toast-container--pending')
|
|
32
32
|
parentContainer.appendChild(container)
|
|
33
|
-
renderVue2Component(
|
|
33
|
+
return renderVue2Component(
|
|
34
34
|
ToastComponent,
|
|
35
35
|
props,
|
|
36
36
|
'.dl-toast-container--pending'
|
|
@@ -53,7 +53,7 @@ function renderVue2Component(
|
|
|
53
53
|
props: Object,
|
|
54
54
|
container: string
|
|
55
55
|
) {
|
|
56
|
-
new VueDemi.Vue2({
|
|
56
|
+
return new VueDemi.Vue2({
|
|
57
57
|
render: (h: (arg0: Object, arg1: { props: Object }) => any) =>
|
|
58
58
|
h(component, { props })
|
|
59
59
|
}).$mount(container)
|
|
@@ -85,6 +85,10 @@ export default defineComponent({
|
|
|
85
85
|
type: String,
|
|
86
86
|
default: '100%'
|
|
87
87
|
},
|
|
88
|
+
height: {
|
|
89
|
+
type: String,
|
|
90
|
+
default: '4px'
|
|
91
|
+
},
|
|
88
92
|
summary: {
|
|
89
93
|
type: String,
|
|
90
94
|
default: ''
|
|
@@ -102,6 +106,7 @@ export default defineComponent({
|
|
|
102
106
|
cssVars(): Record<string, string> {
|
|
103
107
|
return {
|
|
104
108
|
'--dl-progress-bar-width': `${this.computedValue}%`,
|
|
109
|
+
'--dl-progress-bar-height': `${this.height}`,
|
|
105
110
|
'--dl-progress-bar-bg': getColor(this.color)
|
|
106
111
|
}
|
|
107
112
|
}
|
|
@@ -109,7 +114,7 @@ export default defineComponent({
|
|
|
109
114
|
})
|
|
110
115
|
</script>
|
|
111
116
|
|
|
112
|
-
<style scoped>
|
|
117
|
+
<style scoped lang="scss">
|
|
113
118
|
.dl-progress-bar-label {
|
|
114
119
|
margin: 0;
|
|
115
120
|
font-size: var(--dl-font-size-body);
|
|
@@ -119,7 +124,7 @@ export default defineComponent({
|
|
|
119
124
|
.dl-progress-bar {
|
|
120
125
|
overflow: hidden;
|
|
121
126
|
width: 100%;
|
|
122
|
-
height:
|
|
127
|
+
height: var(--dl-progress-bar-height);
|
|
123
128
|
border-radius: 2px;
|
|
124
129
|
background-color: var(--dl-color-separator);
|
|
125
130
|
margin: 6px 0;
|
|
@@ -127,7 +132,7 @@ export default defineComponent({
|
|
|
127
132
|
.dl-progress-bar-indicator {
|
|
128
133
|
transition: width 0.5s;
|
|
129
134
|
display: block;
|
|
130
|
-
height:
|
|
135
|
+
height: var(--dl-progress-bar-height);
|
|
131
136
|
border-radius: 2px;
|
|
132
137
|
background-color: var(--dl-progress-bar-bg);
|
|
133
138
|
width: var(--dl-progress-bar-width);
|
|
@@ -39,6 +39,13 @@
|
|
|
39
39
|
>
|
|
40
40
|
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
|
|
41
41
|
</DlAlert>
|
|
42
|
+
<DlAlert
|
|
43
|
+
type="success"
|
|
44
|
+
text="Text: Lorem ipsum dolor sit amet, consectetur adipisicing elit. "
|
|
45
|
+
:closable="true"
|
|
46
|
+
>
|
|
47
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
|
|
48
|
+
</DlAlert>
|
|
42
49
|
</div>
|
|
43
50
|
</template>
|
|
44
51
|
|
|
@@ -132,7 +132,7 @@ export default defineComponent({
|
|
|
132
132
|
message: message.value,
|
|
133
133
|
position: position.value,
|
|
134
134
|
type: type.value,
|
|
135
|
-
duration: duration.value,
|
|
135
|
+
duration: Number(duration.value) || 1000,
|
|
136
136
|
classItem: classItem.value,
|
|
137
137
|
closable: closable.value,
|
|
138
138
|
width: width.value,
|