@dataloop-ai/components 0.13.19 → 0.14.4
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/.nvmrc +1 -0
- package/README.md +3 -1
- package/package.json +19 -17
- package/src/assets/globals.scss +38 -3
- package/src/assets/grid.scss +9 -0
- package/src/components/DlAccordion/DlAccordion.vue +4 -4
- package/src/components/DlAlert.vue +6 -6
- package/src/components/DlChart/BrushThumb.vue +83 -0
- package/src/components/DlChart/DlBarChart.vue +545 -0
- package/src/components/DlChart/DlBrush.vue +475 -0
- package/src/components/DlChart/DlChartLabels.vue +279 -0
- package/src/components/DlChart/DlChartLegend.vue +141 -0
- package/src/components/DlChart/DlColumnChart.vue +555 -0
- package/src/components/DlChart/DlLineChart.vue +644 -0
- package/src/components/DlChart/DlScrollBar.vue +147 -0
- package/src/components/DlChart/Doughnut/DlDoughnutChart.vue +448 -0
- package/src/components/DlChart/Doughnut/DlDoughnutChartLegend.vue +281 -0
- package/src/components/DlChart/Doughnut/DlDoughnutChartWidget.vue +64 -0
- package/src/components/DlChart/Doughnut/types/TDoughnutChartAnimation.ts +4 -0
- package/src/components/DlChart/Doughnut/types/TDoughnutChartData.ts +16 -0
- package/src/components/DlChart/Doughnut/types/TDoughnutChartOptions.ts +11 -0
- package/src/components/DlChart/Doughnut/types/TDoughnutChartProps.ts +8 -0
- package/src/components/DlChart/Doughnut/types/TDoughnutWithOriginalColor.ts +13 -0
- package/src/components/DlChart/chart.ts +122 -0
- package/src/components/DlChart/index.ts +36 -0
- package/src/components/DlChart/props.ts +348 -0
- package/src/components/DlChart/typedCharts.ts +88 -0
- package/src/components/DlChart/types.ts +63 -0
- package/src/components/DlChart/utils.ts +153 -0
- package/src/components/DlChip/DlChip.vue +40 -13
- package/src/components/DlCounters.vue +31 -7
- package/src/components/DlDatePicker/DlCalendar.vue +22 -10
- package/src/components/DlDatePicker/DlDatePicker.vue +8 -5
- package/src/components/DlDateTimeRange/types.ts +2 -2
- package/src/components/DlDropdownButton.vue +5 -3
- package/src/components/DlMenu/DlMenu.vue +4 -2
- package/src/components/DlPagination/RowsSelector.vue +15 -2
- package/src/components/DlPopup/DlPopup.vue +0 -1
- package/src/components/DlRange/DlRange.vue +3 -2
- package/src/components/DlSearch.vue +1 -1
- package/src/components/DlSelect/DlSelect.vue +3 -2
- package/src/components/DlSlider/sliderStyles.scss +4 -0
- package/src/components/DlSlider/useSlider.ts +39 -12
- package/src/components/DlSmartSearch/DlSuggestionsDropdown.vue +1 -1
- package/src/components/DlSpinner.vue +259 -0
- package/src/components/DlTable/DlTable.vue +4 -1
- package/src/components/DlTable/hooks/tablePagination.ts +8 -2
- package/src/components/DlTextArea.vue +9 -0
- package/src/components/DlTextInput.vue +4 -2
- package/src/components/DlThemeProvider.vue +22 -13
- package/src/components/DlToastMessage/api/useToast.ts +23 -0
- package/src/components/DlToastMessage/components/ToastComponent.vue +279 -0
- package/src/components/DlToastMessage/index.ts +5 -0
- package/src/components/DlToastMessage/types.ts +4 -0
- package/src/components/DlToastMessage/utils/config.ts +17 -0
- package/src/components/DlToastMessage/utils/render.ts +56 -0
- package/src/components/DlTypography.vue +1 -1
- package/src/components/DlWidget/DlGrid.vue +33 -0
- package/src/components/DlWidget/DlGridRow.vue +32 -0
- package/src/components/DlWidget/DlWidget.vue +202 -11
- package/src/components/DlWidget/index.ts +2 -2
- package/src/components/DlWidget/utils.ts +26 -19
- package/src/components/index.ts +8 -3
- package/src/demo/BarChartDemo.vue +77 -0
- package/src/demo/ColumnChartDemo.vue +230 -0
- package/src/demo/DlButtonDemo.vue +1 -1
- package/src/demo/DlChartDoughnutDemo.vue +229 -0
- package/src/demo/DlChipDemo.vue +42 -18
- package/src/demo/DlDialogBoxDemo.vue +4 -4
- package/src/demo/DlDropdownButtonDemo.vue +1 -1
- package/src/demo/DlLineChartDemo.vue +375 -0
- package/src/demo/DlMenuDemo.vue +1 -1
- package/src/demo/DlOptionGroupDemo.vue +1 -1
- package/src/demo/DlSelectDemo.vue +1 -1
- package/src/demo/DlSpinnerDemo.vue +20 -0
- package/src/demo/DlTableDemo.vue +13 -94
- package/src/demo/DlToastMessageDemo.vue +143 -0
- package/src/demo/DlWidgetDemo.vue +105 -143
- package/src/demo/index.ts +20 -2
- package/src/hooks/use-theme.ts +19 -0
- package/src/utils/abbreviate-to-string.ts +14 -0
- package/src/utils/colors.ts +47 -0
- package/src/utils/getRootStyles.ts +1 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/position-engine.ts +11 -2
- package/src/utils/swapNodes.ts +30 -0
- package/src/utils/update-key.ts +90 -0
- package/tsconfig.json +0 -1
- package/vite.config.ts +17 -0
- package/Dockerfile +0 -12
- package/jest.config.js +0 -16
- package/jest.setup.js +0 -59
- package/src/components/DlWidget/DlWidgetGrid.vue +0 -360
- package/storybook.js +0 -8
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div style="width: 950px; padding-top: 20px">
|
|
3
|
+
<div class="flex">
|
|
4
|
+
<div>
|
|
5
|
+
<dl-text-area
|
|
6
|
+
v-model="message"
|
|
7
|
+
title="Message"
|
|
8
|
+
/>
|
|
9
|
+
<dl-text-input
|
|
10
|
+
v-model="duration"
|
|
11
|
+
type="number"
|
|
12
|
+
title="Duration seconds"
|
|
13
|
+
/>
|
|
14
|
+
<dl-text-input
|
|
15
|
+
v-model="classItem"
|
|
16
|
+
title="Custom class for toast item"
|
|
17
|
+
/>
|
|
18
|
+
</div>
|
|
19
|
+
<div class="flex">
|
|
20
|
+
<div>
|
|
21
|
+
Type
|
|
22
|
+
<dl-radio
|
|
23
|
+
v-model="type"
|
|
24
|
+
value="success"
|
|
25
|
+
label="Success"
|
|
26
|
+
/>
|
|
27
|
+
<dl-radio
|
|
28
|
+
v-model="type"
|
|
29
|
+
value="warning"
|
|
30
|
+
label="Warning"
|
|
31
|
+
/>
|
|
32
|
+
<dl-radio
|
|
33
|
+
v-model="type"
|
|
34
|
+
value="error"
|
|
35
|
+
label="Error"
|
|
36
|
+
/>
|
|
37
|
+
<dl-radio
|
|
38
|
+
v-model="type"
|
|
39
|
+
value="info"
|
|
40
|
+
label="Info"
|
|
41
|
+
/>
|
|
42
|
+
</div>
|
|
43
|
+
<div>
|
|
44
|
+
Position
|
|
45
|
+
<dl-radio
|
|
46
|
+
v-model="position"
|
|
47
|
+
value="bottom"
|
|
48
|
+
label="Bottom"
|
|
49
|
+
/>
|
|
50
|
+
<dl-radio
|
|
51
|
+
v-model="position"
|
|
52
|
+
value="bottom-left"
|
|
53
|
+
label="Bottom left"
|
|
54
|
+
/>
|
|
55
|
+
<dl-radio
|
|
56
|
+
v-model="position"
|
|
57
|
+
value="bottom-right"
|
|
58
|
+
label="Bottom right"
|
|
59
|
+
/>
|
|
60
|
+
<dl-radio
|
|
61
|
+
v-model="position"
|
|
62
|
+
value="top"
|
|
63
|
+
label="Top"
|
|
64
|
+
/>
|
|
65
|
+
<dl-radio
|
|
66
|
+
v-model="position"
|
|
67
|
+
value="top-left"
|
|
68
|
+
label="Top left"
|
|
69
|
+
/>
|
|
70
|
+
<dl-radio
|
|
71
|
+
v-model="position"
|
|
72
|
+
value="top-right"
|
|
73
|
+
label="Top right"
|
|
74
|
+
/>
|
|
75
|
+
</div>
|
|
76
|
+
<div>
|
|
77
|
+
<dl-switch
|
|
78
|
+
v-model="closable"
|
|
79
|
+
left-label="Closable"
|
|
80
|
+
/>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
<dl-button @click="showToastMessage">
|
|
85
|
+
Show Toast Message
|
|
86
|
+
</dl-button>
|
|
87
|
+
</div>
|
|
88
|
+
</template>
|
|
89
|
+
|
|
90
|
+
<script lang="ts">
|
|
91
|
+
import { DlButton } from '../components'
|
|
92
|
+
import { DlToast } from '../components/DlToastMessage'
|
|
93
|
+
import { defineComponent, ref } from 'vue-demi'
|
|
94
|
+
import DlTextInput from '../components/DlTextInput.vue'
|
|
95
|
+
import DlRadio from '../components/DlRadio.vue'
|
|
96
|
+
import DlTextArea from '../components/DlTextArea.vue'
|
|
97
|
+
import DlSwitch from '../components/DlSwitch.vue'
|
|
98
|
+
export default defineComponent({
|
|
99
|
+
name: 'DlToast',
|
|
100
|
+
components: {
|
|
101
|
+
DlSwitch,
|
|
102
|
+
DlTextArea,
|
|
103
|
+
DlRadio,
|
|
104
|
+
DlTextInput,
|
|
105
|
+
DlButton
|
|
106
|
+
},
|
|
107
|
+
setup() {
|
|
108
|
+
const message = ref(
|
|
109
|
+
'This is a sample message with a <a href="https://google.com/">link</a>'
|
|
110
|
+
)
|
|
111
|
+
const duration = ref(10)
|
|
112
|
+
const type = ref('success')
|
|
113
|
+
const position = ref('bottom')
|
|
114
|
+
const closable = ref(true)
|
|
115
|
+
const classItem = ref('demo-toast')
|
|
116
|
+
function showToastMessage() {
|
|
117
|
+
DlToast.open({
|
|
118
|
+
message: message.value,
|
|
119
|
+
position: position.value,
|
|
120
|
+
type: type.value,
|
|
121
|
+
duration: duration.value,
|
|
122
|
+
classItem: classItem.value,
|
|
123
|
+
closable: closable.value
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
showToastMessage,
|
|
128
|
+
message,
|
|
129
|
+
duration,
|
|
130
|
+
type,
|
|
131
|
+
position,
|
|
132
|
+
classItem,
|
|
133
|
+
closable
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
</script>
|
|
138
|
+
|
|
139
|
+
<style scoped>
|
|
140
|
+
.flex {
|
|
141
|
+
display: flex;
|
|
142
|
+
}
|
|
143
|
+
</style>
|
|
@@ -1,157 +1,119 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { defineComponent
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import DlDialogBox from '../components/DlDialogBox/DlDialogBox.vue'
|
|
8
|
-
import DlDialogBoxHeader from '../components/DlDialogBox/DlDialogBoxHeader.vue'
|
|
9
|
-
import DlDialogBoxFooter from '../components/DlDialogBox/DlDialogBoxFooter.vue'
|
|
10
|
-
import DlChip from '../components/DlChip/DlChip.vue'
|
|
2
|
+
import { defineComponent } from 'vue-demi'
|
|
3
|
+
import DlBarChart from '../components/DlChart/DlBarChart.vue'
|
|
4
|
+
import DlGrid from '../components/DlWidget/DlGrid.vue'
|
|
5
|
+
import DlGridRow from '../components/DlWidget/DlGridRow.vue'
|
|
6
|
+
import DlWidget from '../components/DlWidget/DlWidget.vue'
|
|
11
7
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
DlChip
|
|
20
|
-
},
|
|
21
|
-
setup() {
|
|
22
|
-
const isEditable = ref(false)
|
|
23
|
-
const addDialog = ref(false)
|
|
24
|
-
const handleEditMode = () => (isEditable.value = !isEditable.value)
|
|
25
|
-
|
|
26
|
-
const widgetLibrary = ref([
|
|
27
|
-
{
|
|
28
|
-
title: 'Widget 1',
|
|
29
|
-
subTitle: 'first widget',
|
|
30
|
-
content: BadgeDemo,
|
|
31
|
-
description:
|
|
32
|
-
'Lorem ipsum dolor sit amet consectetur. Ultricies odio sagittis bibendum tristique congue pretium ac massa proin. Leo blandit commodo sit nibh sem. dfsdfdsfsdf dfsdfsdfsdfsd'
|
|
33
|
-
}
|
|
34
|
-
] as Widget[])
|
|
35
|
-
|
|
36
|
-
const widgets = ref([
|
|
37
|
-
[
|
|
38
|
-
{
|
|
39
|
-
title: 'Widget 8',
|
|
40
|
-
subTitle: 'eighth widget',
|
|
41
|
-
content: `Do I contradict myself?
|
|
42
|
-
Very well then I contradict myself,
|
|
43
|
-
(I am large, I contain multitudes.)
|
|
44
|
-
I concentrate toward them that are nigh, I wait on the door-slab.
|
|
45
|
-
Who has done his day's work? who will soonest be through with his supper?
|
|
46
|
-
Who wishes to walk with me?`,
|
|
47
|
-
description:
|
|
48
|
-
'Lorem dolor sit amet consectetur. Ultricies odio sagittis bibendum tristique congue pretium ac massa proin. Leo blandit commodo sit nibh sem. dfsdfdsfsdf dfsdfsdfsdfsd'
|
|
49
|
-
}
|
|
50
|
-
],
|
|
51
|
-
[
|
|
52
|
-
{
|
|
53
|
-
title: 'Widget 2',
|
|
54
|
-
subTitle: 'second widget',
|
|
55
|
-
content: `“Later she remembered all the hours of the afternoon as happy -- one of those uneventful times that seem at the moment only a link between past and future pleasure, but turn out to have been the pleasure itself.”`,
|
|
56
|
-
description:
|
|
57
|
-
'Lorem ipsum dolor sit amet consectetur. Ultricies odio sagittis bibendum tristique congue pretium ac massa proin. Leo blandit commodo sit nibh sem. dfsdfdsfsdf dfsdfsdfsdfsd'
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
title: 'Widget 3',
|
|
61
|
-
subTitle: 'third widget',
|
|
62
|
-
content: `The Bat that flits at close of Eve
|
|
63
|
-
Has left the Brain that wont Believe
|
|
64
|
-
The Owl that calls upon the Night
|
|
65
|
-
Speaks the Unbelievers fright`,
|
|
66
|
-
description:
|
|
67
|
-
'Lorem ipsum dolor sit amet consectetur. Ultricies odio sagittis bibendum tristique congue pretium ac massa proin. Leo blandit commodo sit nibh sem. dfsdfdsfsdf dfsdfsdfsdfsd'
|
|
68
|
-
}
|
|
69
|
-
],
|
|
70
|
-
[
|
|
71
|
-
{
|
|
72
|
-
title: 'Widget 4',
|
|
73
|
-
subTitle: 'fourth widget',
|
|
74
|
-
content: `That motley drama—oh, be sure
|
|
75
|
-
It shall not be forgot!
|
|
76
|
-
With its Phantom chased for evermore
|
|
77
|
-
By a crowd that seize it not,`,
|
|
78
|
-
description:
|
|
79
|
-
'Lorem ipsum dolor sit amet consectetur. Ultricies odio sagittis bibendum tristique congue pretium ac massa proin. Leo blandit commodo sit nibh sem. dfsdfdsfsdf dfsdfsdfsdfsd'
|
|
80
|
-
}
|
|
81
|
-
]
|
|
82
|
-
] as Widget[][])
|
|
8
|
+
const labelsFn = () => {
|
|
9
|
+
const a = []
|
|
10
|
+
for (let i = 0; i < 20; i++) {
|
|
11
|
+
a.push(`${i}`)
|
|
12
|
+
}
|
|
13
|
+
return a
|
|
14
|
+
}
|
|
83
15
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
16
|
+
const dataFn = () => {
|
|
17
|
+
const a = []
|
|
18
|
+
for (let i = 1; i <= 20; i++) {
|
|
19
|
+
a.push(i)
|
|
20
|
+
}
|
|
21
|
+
return a
|
|
22
|
+
}
|
|
88
23
|
|
|
89
|
-
|
|
90
|
-
|
|
24
|
+
const data = {
|
|
25
|
+
labels: labelsFn(),
|
|
26
|
+
datasets: [
|
|
27
|
+
{
|
|
28
|
+
label: 'Data One',
|
|
29
|
+
backgroundColor: '--dl-color-secondary',
|
|
30
|
+
borderRadius: 4,
|
|
31
|
+
data: dataFn()
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
label: 'Data Two',
|
|
35
|
+
backgroundColor: '--dl-color-warning',
|
|
36
|
+
borderRadius: 4,
|
|
37
|
+
data: dataFn()
|
|
91
38
|
}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
92
41
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
42
|
+
export default defineComponent({
|
|
43
|
+
components: {
|
|
44
|
+
DlGrid,
|
|
45
|
+
DlWidget,
|
|
46
|
+
DlBarChart,
|
|
47
|
+
DlGridRow
|
|
48
|
+
},
|
|
49
|
+
setup() {
|
|
50
|
+
return { data }
|
|
102
51
|
}
|
|
103
52
|
})
|
|
104
53
|
</script>
|
|
105
54
|
|
|
106
55
|
<template>
|
|
107
|
-
<div
|
|
108
|
-
<
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
56
|
+
<div>
|
|
57
|
+
<dl-grid gap="20px">
|
|
58
|
+
<dl-grid-row>
|
|
59
|
+
<dl-widget>
|
|
60
|
+
<template #header>
|
|
61
|
+
<span>Widget 1</span>
|
|
62
|
+
<span style="font-size: 12px; color: gray">Subtitle</span>
|
|
63
|
+
</template>
|
|
64
|
+
<template #menu>
|
|
65
|
+
<div>
|
|
66
|
+
Menu
|
|
67
|
+
<div />
|
|
68
|
+
</div>
|
|
69
|
+
</template>
|
|
70
|
+
<template #content>
|
|
71
|
+
<dl-bar-chart
|
|
72
|
+
:legend-props="legendProps"
|
|
73
|
+
:data="data"
|
|
74
|
+
:options="options"
|
|
75
|
+
:items-in-view="8"
|
|
76
|
+
/>
|
|
77
|
+
</template>
|
|
78
|
+
<template #description>
|
|
79
|
+
<span>Lorem ipsum dolor sit amet consectetur adipisicing
|
|
80
|
+
elit. Libero eligendi dolore, similique possimus
|
|
81
|
+
veritatis in vitae quia praesentium fuga quibusdam
|
|
82
|
+
autem. Doloremque tenetur repudiandae a cupiditate
|
|
83
|
+
modi dicta eveniet veritatis?</span>
|
|
84
|
+
</template>
|
|
85
|
+
</dl-widget>
|
|
86
|
+
</dl-grid-row>
|
|
87
|
+
|
|
88
|
+
<dl-grid-row gap="20px">
|
|
89
|
+
<dl-widget>
|
|
90
|
+
<template #header>
|
|
91
|
+
<span>Widget 2</span>
|
|
92
|
+
</template>
|
|
93
|
+
<template #content>
|
|
94
|
+
<dl-bar-chart
|
|
95
|
+
:legend-props="legendProps"
|
|
96
|
+
:data="data"
|
|
97
|
+
:options="options"
|
|
98
|
+
:items-in-view="6"
|
|
99
|
+
/>
|
|
100
|
+
</template>
|
|
101
|
+
</dl-widget>
|
|
125
102
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
style="cursor: pointer"
|
|
142
|
-
@click="addWidget(widget)"
|
|
143
|
-
>
|
|
144
|
-
{{ widget.title }}
|
|
145
|
-
</dl-chip>
|
|
146
|
-
</div>
|
|
147
|
-
</template>
|
|
148
|
-
<template #footer>
|
|
149
|
-
<dl-dialog-box-footer>
|
|
150
|
-
<dl-button @click="addDialog = false">
|
|
151
|
-
Close
|
|
152
|
-
</dl-button>
|
|
153
|
-
</dl-dialog-box-footer>
|
|
154
|
-
</template>
|
|
155
|
-
</dl-dialog-box>
|
|
103
|
+
<dl-widget>
|
|
104
|
+
<template #header>
|
|
105
|
+
<span>Widget 3</span>
|
|
106
|
+
</template>
|
|
107
|
+
<template #content>
|
|
108
|
+
<dl-bar-chart
|
|
109
|
+
:legend-props="legendProps"
|
|
110
|
+
:data="data"
|
|
111
|
+
:options="options"
|
|
112
|
+
:items-in-view="6"
|
|
113
|
+
/>
|
|
114
|
+
</template>
|
|
115
|
+
</dl-widget>
|
|
116
|
+
</dl-grid-row>
|
|
117
|
+
</dl-grid>
|
|
156
118
|
</div>
|
|
157
119
|
</template>
|
package/src/demo/index.ts
CHANGED
|
@@ -40,7 +40,13 @@ import DlTrendDemo from './DlTrendDemo.vue'
|
|
|
40
40
|
import DlWidgetDemo from './DlWidgetDemo.vue'
|
|
41
41
|
import DlRadioDemo from './DlRadioDemo.vue'
|
|
42
42
|
import DlTextHolderDemo from './DlTextHolderDemo.vue'
|
|
43
|
+
import DlColumnChartDemo from './ColumnChartDemo.vue'
|
|
44
|
+
import DlBarChartDemo from './BarChartDemo.vue'
|
|
43
45
|
import DlSwitchDemo from './DlSwitchDemo.vue'
|
|
46
|
+
import DlToastMessageDemo from './DlToastMessageDemo.vue'
|
|
47
|
+
import DlChartDoughnutDemo from './DlChartDoughnutDemo.vue'
|
|
48
|
+
import DlLineChartDemo from './DlLineChartDemo.vue'
|
|
49
|
+
import DlSpinner from './DlSpinnerDemo.vue'
|
|
44
50
|
|
|
45
51
|
export {
|
|
46
52
|
AvatarDemo,
|
|
@@ -85,7 +91,13 @@ export {
|
|
|
85
91
|
DlWidgetDemo,
|
|
86
92
|
DlRadioDemo,
|
|
87
93
|
DlTextHolderDemo,
|
|
88
|
-
|
|
94
|
+
DlToastMessageDemo,
|
|
95
|
+
DlColumnChartDemo,
|
|
96
|
+
DlSwitchDemo,
|
|
97
|
+
DlChartDoughnutDemo,
|
|
98
|
+
DlBarChartDemo,
|
|
99
|
+
DlLineChartDemo,
|
|
100
|
+
DlSpinner
|
|
89
101
|
}
|
|
90
102
|
|
|
91
103
|
export const demoState = {
|
|
@@ -94,11 +106,15 @@ export const demoState = {
|
|
|
94
106
|
avatar: AvatarDemo,
|
|
95
107
|
badge: DlBadgeDemo,
|
|
96
108
|
button: DlButtonDemo,
|
|
109
|
+
column_chart: DlColumnChartDemo,
|
|
110
|
+
bar_chart: DlBarChartDemo,
|
|
111
|
+
line_chart: DlLineChartDemo,
|
|
97
112
|
checkbox: DlCheckboxDemo,
|
|
98
113
|
chip: DlChipDemo,
|
|
99
114
|
color_picker: DlColorPickerDemo,
|
|
100
115
|
counter: DlCounterDemo,
|
|
101
116
|
dialog_box: DlDialogBoxDemo,
|
|
117
|
+
doughnut_chart: DlChartDoughnutDemo,
|
|
102
118
|
dropdown_button: DropdownButtonDemo,
|
|
103
119
|
icon: DlIconDemo,
|
|
104
120
|
link: DlLinkDemo,
|
|
@@ -131,5 +147,7 @@ export const demoState = {
|
|
|
131
147
|
widget: DlWidgetDemo,
|
|
132
148
|
radio: DlRadioDemo,
|
|
133
149
|
switch: DlSwitchDemo,
|
|
134
|
-
smart_search: DlSmartSearchDemo
|
|
150
|
+
smart_search: DlSmartSearchDemo,
|
|
151
|
+
toast_message: DlToastMessageDemo,
|
|
152
|
+
spinner: DlSpinner
|
|
135
153
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getRootStyles } from '../utils/getRootStyles'
|
|
2
|
+
import { inject, watch, reactive } from 'vue-demi'
|
|
3
|
+
|
|
4
|
+
export const useThemeVariables = () => {
|
|
5
|
+
const isDark = inject('theme')
|
|
6
|
+
|
|
7
|
+
const variables = reactive(getRootStyles())
|
|
8
|
+
|
|
9
|
+
watch(
|
|
10
|
+
() => isDark,
|
|
11
|
+
() => {
|
|
12
|
+
Object.assign(variables, getRootStyles())
|
|
13
|
+
},
|
|
14
|
+
{ deep: true }
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
if (variables) return { variables }
|
|
18
|
+
return
|
|
19
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function abbreviateToString(value: number): string {
|
|
2
|
+
const suffixes = ['', 'k', 'm', 'b', 't']
|
|
3
|
+
const suffixNum = Math.floor(('' + value).length / 3)
|
|
4
|
+
const shortValue = parseFloat(
|
|
5
|
+
(suffixNum !== 0
|
|
6
|
+
? value / Math.pow(1000, suffixNum)
|
|
7
|
+
: value
|
|
8
|
+
).toPrecision(2)
|
|
9
|
+
)
|
|
10
|
+
if (shortValue % 1 !== 0) {
|
|
11
|
+
shortValue.toFixed(1)
|
|
12
|
+
}
|
|
13
|
+
return shortValue + suffixes[suffixNum]
|
|
14
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export const hexToRgbA = (hex: string, opacity = 1) => {
|
|
2
|
+
try {
|
|
3
|
+
const r = parseInt(hex.slice(1, 3), 16)
|
|
4
|
+
const g = parseInt(hex.slice(3, 5), 16)
|
|
5
|
+
const b = parseInt(hex.slice(5, 7), 16)
|
|
6
|
+
|
|
7
|
+
if (opacity) {
|
|
8
|
+
return 'rgba(' + r + ', ' + g + ', ' + b + ', ' + opacity + ')'
|
|
9
|
+
} else {
|
|
10
|
+
return 'rgb(' + r + ', ' + g + ', ' + b + ')'
|
|
11
|
+
}
|
|
12
|
+
} catch {
|
|
13
|
+
return hex
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const revertRGBAOpacity = (oldRGBA: string) =>
|
|
18
|
+
oldRGBA.replace(/[^,]+(?=\))/, '1')
|
|
19
|
+
|
|
20
|
+
export const rgba2hex = (rgba: string) => {
|
|
21
|
+
let a: string | number
|
|
22
|
+
const rgb = rgba
|
|
23
|
+
.replace(/\s/g, '')
|
|
24
|
+
.match(/^rgba?\((\d+),(\d+),(\d+),?([^,\s)]+)?/i)
|
|
25
|
+
const alpha = ((rgb && rgb[4]) || '').trim()
|
|
26
|
+
let hex
|
|
27
|
+
|
|
28
|
+
if (rgb) {
|
|
29
|
+
hex =
|
|
30
|
+
((rgb[1] as any) | (1 << 8)).toString(16).slice(1) +
|
|
31
|
+
((rgb[2] as any) | (1 << 8)).toString(16).slice(1) +
|
|
32
|
+
((rgb[3] as any) | (1 << 8)).toString(16).slice(1)
|
|
33
|
+
} else {
|
|
34
|
+
return rgba
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (alpha !== '') {
|
|
38
|
+
a = alpha
|
|
39
|
+
} else {
|
|
40
|
+
a = 0o1
|
|
41
|
+
}
|
|
42
|
+
// multiply before convert to HEX
|
|
43
|
+
a = (((a as number) * 255) | (1 << 8)).toString(16).slice(1)
|
|
44
|
+
hex = hex + a
|
|
45
|
+
|
|
46
|
+
return `#${hex}`
|
|
47
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -126,7 +126,8 @@ interface PositionConfig {
|
|
|
126
126
|
maxHeight?: string
|
|
127
127
|
maxWidth?: string
|
|
128
128
|
absoluteOffset?: any
|
|
129
|
-
|
|
129
|
+
fitContent?: boolean // fit the size to the content
|
|
130
|
+
fitContainer?: boolean // fit the size to the container
|
|
130
131
|
cover?: boolean
|
|
131
132
|
}
|
|
132
133
|
|
|
@@ -194,13 +195,21 @@ export function setPosition(cfg: PositionConfig) {
|
|
|
194
195
|
visibility: 'visible'
|
|
195
196
|
}
|
|
196
197
|
|
|
197
|
-
if (
|
|
198
|
+
if (
|
|
199
|
+
cfg.fitContainer === true ||
|
|
200
|
+
cfg.cover === true ||
|
|
201
|
+
cfg.fitContent === true
|
|
202
|
+
) {
|
|
198
203
|
elStyle.minWidth = cfg.maxWidth || anchorProps.width + 'px'
|
|
199
204
|
elStyle.maxWidth = cfg.maxWidth || anchorProps.width + 'px'
|
|
200
205
|
|
|
201
206
|
if (cfg.cover === true) {
|
|
202
207
|
elStyle.minHeight = anchorProps.height + 'px'
|
|
203
208
|
}
|
|
209
|
+
|
|
210
|
+
if (cfg.fitContent === true) {
|
|
211
|
+
elStyle.maxWidth = cfg.el.offsetWidth + 'px'
|
|
212
|
+
}
|
|
204
213
|
}
|
|
205
214
|
|
|
206
215
|
Object.assign(cfg.el!.style, elStyle)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export function swapNodes({ source, target }: NodeSwap) {
|
|
2
|
+
const p1 = source.parentNode
|
|
3
|
+
const p2 = target.parentNode
|
|
4
|
+
let i1
|
|
5
|
+
let i2
|
|
6
|
+
|
|
7
|
+
if (!p1 || !p2 || p1.isEqualNode(target) || p2.isEqualNode(source)) return
|
|
8
|
+
|
|
9
|
+
for (var i = 0; i < p1.children.length; i++) {
|
|
10
|
+
if (p1.children[i].isEqualNode(source)) {
|
|
11
|
+
i1 = i
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
for (var i = 0; i < p2.children.length; i++) {
|
|
15
|
+
if (p2.children[i].isEqualNode(target)) {
|
|
16
|
+
i2 = i
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (p1.isEqualNode(p2) && i1 < i2) {
|
|
21
|
+
i2++
|
|
22
|
+
}
|
|
23
|
+
p1.insertBefore(target, p1.children[i1])
|
|
24
|
+
p2.insertBefore(source, p2.children[i2])
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface NodeSwap {
|
|
28
|
+
source: HTMLElement
|
|
29
|
+
target: HTMLElement
|
|
30
|
+
}
|