@dataloop-ai/components 0.13.0
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/.eslintrc.js +154 -0
- package/.prettierrc.json +7 -0
- package/Dockerfile +12 -0
- package/LICENSE +201 -0
- package/README.md +43 -0
- package/favicon.ico +0 -0
- package/index.html +13 -0
- package/index.ts +1 -0
- package/jest.config.js +16 -0
- package/jest.setup.js +59 -0
- package/models.ts +1 -0
- package/package.json +109 -0
- package/src/App.vue +201 -0
- package/src/assets/globals.scss +253 -0
- package/src/assets/globalsKeys.ts +28 -0
- package/src/components/DlAccordion/AccordionHeader.vue +148 -0
- package/src/components/DlAccordion/DlAccordion.vue +108 -0
- package/src/components/DlAccordion/index.ts +2 -0
- package/src/components/DlAlert.vue +227 -0
- package/src/components/DlAvatar.vue +99 -0
- package/src/components/DlBadge.vue +127 -0
- package/src/components/DlButton/DlButton.vue +370 -0
- package/src/components/DlButton/index.ts +4 -0
- package/src/components/DlButton/utils.ts +169 -0
- package/src/components/DlButtonGroup.vue +122 -0
- package/src/components/DlCheckbox.vue +298 -0
- package/src/components/DlChip/DlChip.vue +244 -0
- package/src/components/DlChip/index.ts +4 -0
- package/src/components/DlChip/utils.ts +100 -0
- package/src/components/DlColorPicker/DlAlpha.vue +142 -0
- package/src/components/DlColorPicker/DlBox.vue +75 -0
- package/src/components/DlColorPicker/DlColorPicker.vue +306 -0
- package/src/components/DlColorPicker/DlColors.vue +139 -0
- package/src/components/DlColorPicker/DlHue.vue +135 -0
- package/src/components/DlColorPicker/DlPreview.vue +61 -0
- package/src/components/DlColorPicker/DlSaturation.vue +152 -0
- package/src/components/DlColorPicker/constants.ts +16 -0
- package/src/components/DlColorPicker/index.ts +20 -0
- package/src/components/DlColorPicker/types.ts +11 -0
- package/src/components/DlColorPicker/utils.ts +128 -0
- package/src/components/DlCounters.vue +173 -0
- package/src/components/DlDatePicker/DlCalendar.vue +332 -0
- package/src/components/DlDatePicker/DlDatePicker.vue +315 -0
- package/src/components/DlDatePicker/DlMonthCalendar.vue +282 -0
- package/src/components/DlDatePicker/classes/Calendar.ts +110 -0
- package/src/components/DlDatePicker/classes/CalendarDate.ts +12 -0
- package/src/components/DlDatePicker/classes/CustomDate.ts +218 -0
- package/src/components/DlDatePicker/index.ts +3 -0
- package/src/components/DlDatePicker/isInRange.ts +44 -0
- package/src/components/DlDatePicker/types.ts +4 -0
- package/src/components/DlDatePicker/utils.ts +39 -0
- package/src/components/DlDateTimeRange/DlCardSidebar.vue +109 -0
- package/src/components/DlDateTimeRange/DlDateInput.vue +105 -0
- package/src/components/DlDateTimeRange/DlDateTimeRange.vue +468 -0
- package/src/components/DlDateTimeRange/index.ts +3 -0
- package/src/components/DlDateTimeRange/types.ts +42 -0
- package/src/components/DlDialogBox/DlDialogBox.vue +196 -0
- package/src/components/DlDialogBox/DlDialogBoxFooter.vue +22 -0
- package/src/components/DlDialogBox/DlDialogBoxHeader.vue +75 -0
- package/src/components/DlDialogBox/index.ts +5 -0
- package/src/components/DlDropdownButton.vue +463 -0
- package/src/components/DlIcon.vue +147 -0
- package/src/components/DlInfoErrorMessage.vue +91 -0
- package/src/components/DlItem/DlItem.vue +35 -0
- package/src/components/DlItem/index.ts +2 -0
- package/src/components/DlItemSection.vue +88 -0
- package/src/components/DlLink/DlLink.vue +76 -0
- package/src/components/DlLink/index.ts +4 -0
- package/src/components/DlLink/utils.ts +4 -0
- package/src/components/DlList.vue +61 -0
- package/src/components/DlListItem/DlListItem.vue +205 -0
- package/src/components/DlListItem/index.ts +3 -0
- package/src/components/DlListItem/utils.ts +14 -0
- package/src/components/DlMenu/DlMenu.vue +438 -0
- package/src/components/DlMenu/index.ts +3 -0
- package/src/components/DlMenu/utils.ts +138 -0
- package/src/components/DlOptionGroup/DlOptionGroup.vue +201 -0
- package/src/components/DlOptionGroup/MenuItemWrapper.vue +48 -0
- package/src/components/DlOptionGroup/OptionGroup.types.ts +36 -0
- package/src/components/DlOptionGroup/SimpleWrapper.vue +28 -0
- package/src/components/DlOptionGroup/index.ts +4 -0
- package/src/components/DlOptionGroup/utils.ts +40 -0
- package/src/components/DlPagination/DlPagination.vue +184 -0
- package/src/components/DlPagination/PageNavigation.vue +350 -0
- package/src/components/DlPagination/PaginationLegend.vue +41 -0
- package/src/components/DlPagination/QuickNavigation.vue +146 -0
- package/src/components/DlPagination/RowsSelector.vue +74 -0
- package/src/components/DlPagination/index.ts +3 -0
- package/src/components/DlPanelContainer/DlPanel.vue +213 -0
- package/src/components/DlPanelContainer/DlPanelContainer.vue +527 -0
- package/src/components/DlPanelContainer/index.ts +4 -0
- package/src/components/DlPopup/DlPopup.vue +478 -0
- package/src/components/DlPopup/DraggableUpper.vue +64 -0
- package/src/components/DlPopup/PopupHeader.vue +129 -0
- package/src/components/DlPopup/index.ts +1 -0
- package/src/components/DlProgressBar.vue +159 -0
- package/src/components/DlProgressChart.vue +299 -0
- package/src/components/DlRadio.vue +218 -0
- package/src/components/DlRange/DlRange.vue +439 -0
- package/src/components/DlRange/utils.ts +209 -0
- package/src/components/DlSearch.vue +155 -0
- package/src/components/DlSelect/DlSelect.vue +992 -0
- package/src/components/DlSelect/SelectOption.vue +261 -0
- package/src/components/DlSelect/index.ts +4 -0
- package/src/components/DlSelect/utils.ts +43 -0
- package/src/components/DlSkeleton.vue +72 -0
- package/src/components/DlSlider/DlSlider.vue +243 -0
- package/src/components/DlSlider/components/DlSliderBase.vue +380 -0
- package/src/components/DlSlider/components/DlSliderInput.vue +123 -0
- package/src/components/DlSlider/components/index.ts +4 -0
- package/src/components/DlSlider/index.ts +3 -0
- package/src/components/DlSlider/sliderStyles.scss +109 -0
- package/src/components/DlSlider/useSlider.ts +277 -0
- package/src/components/DlSlider/utils.ts +7 -0
- package/src/components/DlSmartSearch/DlJsonEditor.vue +309 -0
- package/src/components/DlSmartSearch/DlSmartSearch.vue +333 -0
- package/src/components/DlSmartSearch/DlSmartSearchInput.vue +741 -0
- package/src/components/DlSmartSearch/DlSuggestionsDropdown.vue +73 -0
- package/src/components/DlSmartSearch/highlightSyntax.ts +169 -0
- package/src/components/DlSmartSearch/index.ts +4 -0
- package/src/components/DlSmartSearch/types.ts +36 -0
- package/src/components/DlSmartSearch/utils.ts +45 -0
- package/src/components/DlStepper/DlStepper.vue +196 -0
- package/src/components/DlStepper/DlStepperContainer.vue +55 -0
- package/src/components/DlStepper/DlStepperContent.vue +101 -0
- package/src/components/DlStepper/DlStepperFooter.vue +133 -0
- package/src/components/DlStepper/DlStepperHeader.vue +49 -0
- package/src/components/DlStepper/DlStepperSidebar.vue +167 -0
- package/src/components/DlStepper/Step.ts +101 -0
- package/src/components/DlStepper/Stepper.ts +107 -0
- package/src/components/DlStepper/index.ts +7 -0
- package/src/components/DlStepper/interfaces.ts +11 -0
- package/src/components/DlSwitch.vue +280 -0
- package/src/components/DlTabPanels/DlTabPanel.vue +22 -0
- package/src/components/DlTabPanels/DlTabPanels.vue +41 -0
- package/src/components/DlTabPanels/index.ts +4 -0
- package/src/components/DlTabPanels/utils.ts +19 -0
- package/src/components/DlTable/DlTable.vue +1264 -0
- package/src/components/DlTable/DlTd.vue +109 -0
- package/src/components/DlTable/DlTh.vue +126 -0
- package/src/components/DlTable/DlTr.vue +44 -0
- package/src/components/DlTable/ResizableManager.ts +233 -0
- package/src/components/DlTable/dl-table-styles.scss +466 -0
- package/src/components/DlTable/hooks/tableActions.ts +64 -0
- package/src/components/DlTable/hooks/tableColumnSelection.ts +112 -0
- package/src/components/DlTable/hooks/tableFilter.ts +42 -0
- package/src/components/DlTable/hooks/tablePagination.ts +197 -0
- package/src/components/DlTable/hooks/tableRowExpand.ts +55 -0
- package/src/components/DlTable/hooks/tableRowSelection.ts +106 -0
- package/src/components/DlTable/hooks/tableSort.ts +125 -0
- package/src/components/DlTable/index.ts +6 -0
- package/src/components/DlTable/types.ts +96 -0
- package/src/components/DlTabs/DlTab.vue +146 -0
- package/src/components/DlTabs/DlTabs.vue +192 -0
- package/src/components/DlTabs/TabsWrapper.vue +104 -0
- package/src/components/DlTabs/index.ts +4 -0
- package/src/components/DlTabs/types.ts +8 -0
- package/src/components/DlTextArea.vue +151 -0
- package/src/components/DlTextHolder.vue +65 -0
- package/src/components/DlTextInput.vue +753 -0
- package/src/components/DlThemeProvider.vue +41 -0
- package/src/components/DlTimePicker/DlTimeCounter.vue +81 -0
- package/src/components/DlTimePicker/DlTimePicker.vue +151 -0
- package/src/components/DlTimePicker/DlTimePickerInput.vue +311 -0
- package/src/components/DlTimePicker/index.ts +3 -0
- package/src/components/DlTimePicker/types.ts +4 -0
- package/src/components/DlTooltip.vue +456 -0
- package/src/components/DlTrend.vue +97 -0
- package/src/components/DlTypography.vue +87 -0
- package/src/components/DlVirtualScroll/DlVirtualScroll.vue +290 -0
- package/src/components/DlVirtualScroll/index.ts +3 -0
- package/src/components/DlVirtualScroll/useVirtualScroll.ts +833 -0
- package/src/components/DlWidget/DlWidget.vue +50 -0
- package/src/components/DlWidget/DlWidgetGrid.vue +360 -0
- package/src/components/DlWidget/index.ts +4 -0
- package/src/components/DlWidget/types.ts +6 -0
- package/src/components/DlWidget/utils.ts +30 -0
- package/src/components/index.ts +118 -0
- package/src/demo/DlAccordionDemo.vue +60 -0
- package/src/demo/DlAlertDemo.vue +54 -0
- package/src/demo/DlAvatarDemo.vue +43 -0
- package/src/demo/DlBadgeDemo.vue +65 -0
- package/src/demo/DlButtonDemo.vue +266 -0
- package/src/demo/DlCheckboxDemo.vue +50 -0
- package/src/demo/DlChipDemo.vue +181 -0
- package/src/demo/DlColorPickerDemo.vue +43 -0
- package/src/demo/DlCounterDemo.vue +53 -0
- package/src/demo/DlDateTimeRangeDemo.vue +217 -0
- package/src/demo/DlDialogBoxDemo.vue +175 -0
- package/src/demo/DlDropdownButtonDemo.vue +260 -0
- package/src/demo/DlIconDemo.vue +47 -0
- package/src/demo/DlLinkDemo.vue +23 -0
- package/src/demo/DlListDemo.vue +177 -0
- package/src/demo/DlMenuDemo.vue +524 -0
- package/src/demo/DlOptionGroupDemo.vue +79 -0
- package/src/demo/DlPaginationDemo.vue +44 -0
- package/src/demo/DlPanelContainerDemo.vue +221 -0
- package/src/demo/DlPopupDemo.vue +58 -0
- package/src/demo/DlProgressBarDemo.vue +22 -0
- package/src/demo/DlProgressChartDemo.vue +71 -0
- package/src/demo/DlRadioDemo.vue +35 -0
- package/src/demo/DlRangeDemo.vue +44 -0
- package/src/demo/DlSearchDemo.vue +27 -0
- package/src/demo/DlSelectDemo.vue +355 -0
- package/src/demo/DlSkeletonDemo.vue +20 -0
- package/src/demo/DlSliderDemo.vue +47 -0
- package/src/demo/DlStepperDemo/CenteredStepperInDialogBox.vue +260 -0
- package/src/demo/DlStepperDemo/SimpleStepper.vue +202 -0
- package/src/demo/DlStepperDemo/StepperInDialogBox.vue +261 -0
- package/src/demo/DlStepperDemo/index.ts +5 -0
- package/src/demo/DlStepperDemo/steps/AssignmentsStep.vue +97 -0
- package/src/demo/DlStepperDemo/steps/DataStep.vue +158 -0
- package/src/demo/DlStepperDemo/steps/GeneralStep.vue +106 -0
- package/src/demo/DlStepperDemo/steps/InstructionStep.vue +176 -0
- package/src/demo/DlStepperDemo/steps/QualityStep.vue +65 -0
- package/src/demo/DlSwitchDemo.vue +49 -0
- package/src/demo/DlTableDemo.vue +475 -0
- package/src/demo/DlTabsDemo.vue +67 -0
- package/src/demo/DlTdDemo.vue +19 -0
- package/src/demo/DlTextAreaDemo.vue +37 -0
- package/src/demo/DlTextHolderDemo.vue +42 -0
- package/src/demo/DlTextInputDemo.vue +89 -0
- package/src/demo/DlThDemo.vue +32 -0
- package/src/demo/DlTooltipDemo.vue +60 -0
- package/src/demo/DlTrDemo.vue +18 -0
- package/src/demo/DlTrendDemo.vue +25 -0
- package/src/demo/DlTypographyDemo.vue +93 -0
- package/src/demo/DlWidgetDemo.vue +157 -0
- package/src/demo/SmartSearchDemo/DlSmartSearchDemo.vue +202 -0
- package/src/demo/SmartSearchDemo/schema.ts +44 -0
- package/src/demo/index.ts +141 -0
- package/src/directives/TouchPan.ts +525 -0
- package/src/env.d.ts +8 -0
- package/src/hooks/use-anchor.ts +223 -0
- package/src/hooks/use-model-toggle.ts +181 -0
- package/src/hooks/use-portal.ts +104 -0
- package/src/hooks/use-scroll-target.ts +53 -0
- package/src/hooks/use-size-observer.ts +24 -0
- package/src/hooks/use-suggestions.ts +355 -0
- package/src/hooks/use-tick.ts +32 -0
- package/src/hooks/use-timeout.ts +20 -0
- package/src/hooks/use-transition.ts +32 -0
- package/src/hooks/use-window-size.ts +25 -0
- package/src/hooks/useForm.ts +12 -0
- package/src/index.ts +7 -0
- package/src/main.ts +4 -0
- package/src/models.ts +4 -0
- package/src/types.ts +6 -0
- package/src/utils/calcs.ts +18 -0
- package/src/utils/click-outside.ts +108 -0
- package/src/utils/component-name-parser.ts +1 -0
- package/src/utils/css-color-names.ts +150 -0
- package/src/utils/dom.ts +55 -0
- package/src/utils/draggable-table.ts +416 -0
- package/src/utils/escape-key.ts +54 -0
- package/src/utils/events.ts +67 -0
- package/src/utils/focus-manager.ts +33 -0
- package/src/utils/focusout.ts +29 -0
- package/src/utils/format.ts +3 -0
- package/src/utils/getColor.ts +17 -0
- package/src/utils/getLighterGradient.ts +36 -0
- package/src/utils/getRootStyles.ts +52 -0
- package/src/utils/global-config.ts +6 -0
- package/src/utils/global-nodes.ts +42 -0
- package/src/utils/includes.ts +3 -0
- package/src/utils/index.ts +29 -0
- package/src/utils/inject-object-prop.ts +21 -0
- package/src/utils/input-sizes.ts +7 -0
- package/src/utils/is-ellipsis-active.ts +3 -0
- package/src/utils/is-in-viewport.ts +13 -0
- package/src/utils/is.ts +15 -0
- package/src/utils/key-composition.ts +17 -0
- package/src/utils/keyCodes.ts +12 -0
- package/src/utils/logger/ConsoleLogger.ts +65 -0
- package/src/utils/logger/ILogger.ts +8 -0
- package/src/utils/logger/index.ts +8 -0
- package/src/utils/nav-keys-constants.ts +1 -0
- package/src/utils/portal.ts +55 -0
- package/src/utils/position-engine.ts +381 -0
- package/src/utils/render.ts +36 -0
- package/src/utils/ripple.ts +7 -0
- package/src/utils/scroll.ts +73 -0
- package/src/utils/selection.ts +15 -0
- package/src/utils/sort.ts +7 -0
- package/src/utils/splitByQuotes.ts +32 -0
- package/src/utils/string.ts +6 -0
- package/src/utils/teleport.ts +14 -0
- package/src/utils/theme.ts +2 -0
- package/src/utils/vm.ts +16 -0
- package/storybook.js +8 -0
- package/tsconfig.json +44 -0
- package/tsconfig.node.json +8 -0
- package/types.ts +1 -0
- package/vite.config.ts +13 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:id="uuid"
|
|
4
|
+
class="dl-progress-wrapper"
|
|
5
|
+
:style="`width: ${width};`"
|
|
6
|
+
>
|
|
7
|
+
<p
|
|
8
|
+
v-if="label"
|
|
9
|
+
data-test-id="progress-label"
|
|
10
|
+
align="left"
|
|
11
|
+
class="dl-progress-bar-label"
|
|
12
|
+
>
|
|
13
|
+
{{ label }}
|
|
14
|
+
</p>
|
|
15
|
+
<div class="progress-container">
|
|
16
|
+
<span
|
|
17
|
+
role="progressbar"
|
|
18
|
+
class="dl-progress-bar"
|
|
19
|
+
:aria-valuenow="indeterminate ? undefined : computedValue"
|
|
20
|
+
:aria-valuemin="indeterminate ? undefined : 0"
|
|
21
|
+
:aria-valuemax="indeterminate ? undefined : 100"
|
|
22
|
+
>
|
|
23
|
+
<span
|
|
24
|
+
:style="cssVars"
|
|
25
|
+
:class="{
|
|
26
|
+
indeterminate,
|
|
27
|
+
'dl-progress-bar-indicator': true
|
|
28
|
+
}"
|
|
29
|
+
/>
|
|
30
|
+
</span>
|
|
31
|
+
<p
|
|
32
|
+
v-if="showValue && !indeterminate"
|
|
33
|
+
class="dl-progress-bar-label"
|
|
34
|
+
>
|
|
35
|
+
{{ computedValue }}{{ showPercentage ? '%' : '' }}
|
|
36
|
+
</p>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
</template>
|
|
40
|
+
|
|
41
|
+
<script lang="ts">
|
|
42
|
+
import { v4 } from 'uuid'
|
|
43
|
+
import { defineComponent } from 'vue-demi'
|
|
44
|
+
import { getColor } from '../utils'
|
|
45
|
+
|
|
46
|
+
export default defineComponent({
|
|
47
|
+
name: 'DlProgressBar',
|
|
48
|
+
props: {
|
|
49
|
+
color: {
|
|
50
|
+
type: String,
|
|
51
|
+
default: 'dl-color-secondary'
|
|
52
|
+
},
|
|
53
|
+
label: {
|
|
54
|
+
type: String,
|
|
55
|
+
default: null
|
|
56
|
+
},
|
|
57
|
+
showValue: {
|
|
58
|
+
type: Boolean,
|
|
59
|
+
required: false,
|
|
60
|
+
default: false
|
|
61
|
+
},
|
|
62
|
+
showPercentage: {
|
|
63
|
+
type: Boolean,
|
|
64
|
+
default: false
|
|
65
|
+
},
|
|
66
|
+
value: {
|
|
67
|
+
type: Number,
|
|
68
|
+
default: 0,
|
|
69
|
+
validator: (value: number) => value >= 0 && value <= 1
|
|
70
|
+
},
|
|
71
|
+
indeterminate: {
|
|
72
|
+
type: Boolean,
|
|
73
|
+
default: false
|
|
74
|
+
},
|
|
75
|
+
width: {
|
|
76
|
+
type: String,
|
|
77
|
+
default: '100%'
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
data() {
|
|
81
|
+
return {
|
|
82
|
+
uuid: `dl-progress-bar-${v4()}`
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
computed: {
|
|
86
|
+
computedValue(): number {
|
|
87
|
+
return Number((this.value * 100).toFixed(2).replace(/[.,]00$/, ''))
|
|
88
|
+
},
|
|
89
|
+
cssVars(): Record<string, string> {
|
|
90
|
+
return {
|
|
91
|
+
'--dl-progress-bar-width': `${this.computedValue}%`,
|
|
92
|
+
'--dl-progress-bar-bg': getColor(this.color)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
</script>
|
|
98
|
+
|
|
99
|
+
<style scoped>
|
|
100
|
+
.dl-progress-bar-label {
|
|
101
|
+
margin: 0;
|
|
102
|
+
font-size: var(--dl-font-size-body);
|
|
103
|
+
line-height: 1;
|
|
104
|
+
color: var(--dl-color-darker);
|
|
105
|
+
}
|
|
106
|
+
.dl-progress-bar {
|
|
107
|
+
overflow: hidden;
|
|
108
|
+
width: 100%;
|
|
109
|
+
height: 4px;
|
|
110
|
+
border-radius: 2px;
|
|
111
|
+
background-color: var(--dl-color-separator);
|
|
112
|
+
margin: 6px 0;
|
|
113
|
+
}
|
|
114
|
+
.dl-progress-bar-indicator {
|
|
115
|
+
transition: width 0.5s;
|
|
116
|
+
display: block;
|
|
117
|
+
height: 4px;
|
|
118
|
+
border-radius: 2px;
|
|
119
|
+
background-color: var(--dl-progress-bar-bg);
|
|
120
|
+
width: var(--dl-progress-bar-width);
|
|
121
|
+
}
|
|
122
|
+
.progress-container {
|
|
123
|
+
display: flex;
|
|
124
|
+
column-gap: 10px;
|
|
125
|
+
align-items: center;
|
|
126
|
+
}
|
|
127
|
+
.indeterminate {
|
|
128
|
+
animation: indeterminate-loading;
|
|
129
|
+
animation-duration: 3s;
|
|
130
|
+
animation-iteration-count: infinite;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
@keyframes indeterminate-loading {
|
|
134
|
+
0% {
|
|
135
|
+
width: 0%;
|
|
136
|
+
margin-left: 0%;
|
|
137
|
+
}
|
|
138
|
+
25% {
|
|
139
|
+
width: 60%;
|
|
140
|
+
margin-left: 25%;
|
|
141
|
+
}
|
|
142
|
+
50% {
|
|
143
|
+
width: 30%;
|
|
144
|
+
margin-left: 100%;
|
|
145
|
+
}
|
|
146
|
+
50.1% {
|
|
147
|
+
width: 0%;
|
|
148
|
+
margin-left: 0%;
|
|
149
|
+
}
|
|
150
|
+
75% {
|
|
151
|
+
width: 70%;
|
|
152
|
+
margin-left: 30%;
|
|
153
|
+
}
|
|
154
|
+
100% {
|
|
155
|
+
width: 10%;
|
|
156
|
+
margin-left: 100%;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
</style>
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:id="uuid"
|
|
4
|
+
ref="rootRef"
|
|
5
|
+
class="root"
|
|
6
|
+
:style="rootStyle"
|
|
7
|
+
>
|
|
8
|
+
<div class="progress-bar">
|
|
9
|
+
<div
|
|
10
|
+
v-for="item in progressBarItems"
|
|
11
|
+
:key="item.index"
|
|
12
|
+
:style="getBarItemStyles(item)"
|
|
13
|
+
>
|
|
14
|
+
<dl-tooltip
|
|
15
|
+
anchor="center middle"
|
|
16
|
+
self="bottom middle"
|
|
17
|
+
>
|
|
18
|
+
{{ item.tooltipText }}
|
|
19
|
+
</dl-tooltip>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
<div class="legend">
|
|
23
|
+
<div
|
|
24
|
+
v-for="item in progressBarItems"
|
|
25
|
+
:key="item.index"
|
|
26
|
+
class="item"
|
|
27
|
+
:style="legendItemStyle"
|
|
28
|
+
>
|
|
29
|
+
<dl-tooltip v-if="isOverflowing[item.index]">
|
|
30
|
+
{{ item.name }}
|
|
31
|
+
</dl-tooltip>
|
|
32
|
+
<span
|
|
33
|
+
class="circle"
|
|
34
|
+
:style="{ backgroundColor: item.color }"
|
|
35
|
+
/>
|
|
36
|
+
<div
|
|
37
|
+
v-if="isVue2"
|
|
38
|
+
ref="textRef"
|
|
39
|
+
:data-index="item.index"
|
|
40
|
+
class="text"
|
|
41
|
+
:class="{ ellipsis: isOverflowing[item.index] }"
|
|
42
|
+
>
|
|
43
|
+
{{ item.name }}
|
|
44
|
+
</div>
|
|
45
|
+
<div
|
|
46
|
+
v-else
|
|
47
|
+
:ref="
|
|
48
|
+
(el) => {
|
|
49
|
+
textRef[item.index] = el
|
|
50
|
+
}
|
|
51
|
+
"
|
|
52
|
+
:data-index="item.index"
|
|
53
|
+
class="text"
|
|
54
|
+
:class="{ ellipsis: isOverflowing[item.index] }"
|
|
55
|
+
>
|
|
56
|
+
{{ item.name }}
|
|
57
|
+
</div>
|
|
58
|
+
<span :style="counterStyle">
|
|
59
|
+
<dl-link
|
|
60
|
+
v-if="item.link"
|
|
61
|
+
open-in-new-tab
|
|
62
|
+
:href="item.link"
|
|
63
|
+
:size="12"
|
|
64
|
+
color="color"
|
|
65
|
+
data-test="counter-link"
|
|
66
|
+
>({{ item.value }})</dl-link><span
|
|
67
|
+
v-else
|
|
68
|
+
data-test="counter-text"
|
|
69
|
+
>({{ item.value }})</span>
|
|
70
|
+
</span>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</template>
|
|
75
|
+
|
|
76
|
+
<script lang="ts">
|
|
77
|
+
import { v4 } from 'uuid'
|
|
78
|
+
import { defineComponent, isVue2 } from 'vue-demi'
|
|
79
|
+
import { getColor } from '../utils'
|
|
80
|
+
import { isEllipsisActive } from '../utils/is-ellipsis-active'
|
|
81
|
+
import DlLink from './DlLink/DlLink.vue'
|
|
82
|
+
import DlTooltip from './DlTooltip.vue'
|
|
83
|
+
|
|
84
|
+
type ProgressChartOption = {
|
|
85
|
+
name: string
|
|
86
|
+
value: number
|
|
87
|
+
color: string
|
|
88
|
+
link?: string
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function getPercentage(value: number, total: number): number {
|
|
92
|
+
return (value * 100) / total
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export default defineComponent({
|
|
96
|
+
name: 'DlProgressChart',
|
|
97
|
+
components: { DlLink, DlTooltip },
|
|
98
|
+
props: {
|
|
99
|
+
options: {
|
|
100
|
+
type: Array,
|
|
101
|
+
default: null,
|
|
102
|
+
required: true,
|
|
103
|
+
validator: (val: ProgressChartOption[]) =>
|
|
104
|
+
Array.isArray(val) &&
|
|
105
|
+
val.every(
|
|
106
|
+
(el) =>
|
|
107
|
+
typeof el === 'object' &&
|
|
108
|
+
el !== null &&
|
|
109
|
+
!Array.isArray(el) &&
|
|
110
|
+
typeof el.name === 'string' &&
|
|
111
|
+
typeof el.value === 'number' &&
|
|
112
|
+
typeof el.color === 'string'
|
|
113
|
+
)
|
|
114
|
+
},
|
|
115
|
+
width: {
|
|
116
|
+
type: String,
|
|
117
|
+
default: '100%'
|
|
118
|
+
},
|
|
119
|
+
textColor: {
|
|
120
|
+
type: String,
|
|
121
|
+
default: 'dl-color-darker'
|
|
122
|
+
},
|
|
123
|
+
counterColor: {
|
|
124
|
+
type: String,
|
|
125
|
+
default: 'dl-color-secondary'
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
data(): {
|
|
129
|
+
uuid: string
|
|
130
|
+
isOverflowing: boolean[]
|
|
131
|
+
textRef: HTMLDivElement[]
|
|
132
|
+
resizeObserver: ResizeObserver | null
|
|
133
|
+
} {
|
|
134
|
+
return {
|
|
135
|
+
uuid: `dl-progress-chart-${v4()}`,
|
|
136
|
+
isOverflowing: [],
|
|
137
|
+
textRef: [],
|
|
138
|
+
resizeObserver: null
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
computed: {
|
|
142
|
+
progressBarItems() {
|
|
143
|
+
const options = this.options as ProgressChartOption[]
|
|
144
|
+
const total = options.reduce(
|
|
145
|
+
(sum, option) => (sum += option.value),
|
|
146
|
+
0
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
return options.map((option, index) => {
|
|
150
|
+
const percentage = getPercentage(option.value, total).toFixed(2)
|
|
151
|
+
|
|
152
|
+
return {
|
|
153
|
+
...option,
|
|
154
|
+
index,
|
|
155
|
+
percentage,
|
|
156
|
+
tooltipText: `${option.name}\n${percentage}% (${option.value}/${total})`
|
|
157
|
+
}
|
|
158
|
+
})
|
|
159
|
+
},
|
|
160
|
+
rootStyle(): Record<string, any> {
|
|
161
|
+
return {
|
|
162
|
+
width: this.width
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
counterStyle(): Record<string, any> {
|
|
166
|
+
const color = getColor(this.counterColor, 'dl-color-secondary')
|
|
167
|
+
|
|
168
|
+
return {
|
|
169
|
+
'--color': color,
|
|
170
|
+
color,
|
|
171
|
+
paddingLeft: '5px'
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
isVue2(): boolean {
|
|
175
|
+
return isVue2
|
|
176
|
+
},
|
|
177
|
+
legendItemWidth(): number {
|
|
178
|
+
const width =
|
|
179
|
+
(this.$refs['rootRef'] as HTMLDivElement)?.offsetWidth ?? 0
|
|
180
|
+
const length = this.progressBarItems.length ?? 0
|
|
181
|
+
return width / length
|
|
182
|
+
},
|
|
183
|
+
legendItemStyle(): Record<string, any> {
|
|
184
|
+
return {
|
|
185
|
+
width: `calc(${this.legendItemWidth} - 10px)`, // padding-right: 10px
|
|
186
|
+
color: getColor(this.textColor, 'dl-color-darker')
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
mounted() {
|
|
191
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
|
192
|
+
const tempArr = [...this.isOverflowing]
|
|
193
|
+
|
|
194
|
+
for (const entry of entries) {
|
|
195
|
+
const index = parseInt(
|
|
196
|
+
(entry.target as HTMLDivElement).dataset.index ?? '0'
|
|
197
|
+
)
|
|
198
|
+
tempArr[index] = isEllipsisActive(entry.target)
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
this.isOverflowing = tempArr
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
const elements = isVue2
|
|
205
|
+
? (this.$refs['textRef'] as HTMLDivElement[])
|
|
206
|
+
: this.textRef
|
|
207
|
+
|
|
208
|
+
for (const el of elements) {
|
|
209
|
+
this.resizeObserver.observe(el)
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
beforeUnmount() {
|
|
213
|
+
this.resizeObserver.disconnect()
|
|
214
|
+
this.resizeObserver = null
|
|
215
|
+
},
|
|
216
|
+
methods: {
|
|
217
|
+
getBarItemStyles(item: any): any {
|
|
218
|
+
return {
|
|
219
|
+
flexGrow: item.percentage,
|
|
220
|
+
flexShrink: item.percentage,
|
|
221
|
+
backgroundColor: item.color
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
|
|
226
|
+
template: 'dl-progress-chart'
|
|
227
|
+
})
|
|
228
|
+
</script>
|
|
229
|
+
|
|
230
|
+
<style scoped lang="scss">
|
|
231
|
+
.root {
|
|
232
|
+
display: flex;
|
|
233
|
+
flex-direction: column;
|
|
234
|
+
margin: 20px 0;
|
|
235
|
+
|
|
236
|
+
& > div {
|
|
237
|
+
display: flex;
|
|
238
|
+
flex-direction: row;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.progress-bar {
|
|
242
|
+
height: 10px;
|
|
243
|
+
width: 100%;
|
|
244
|
+
|
|
245
|
+
:first-child {
|
|
246
|
+
border-top-left-radius: 5px;
|
|
247
|
+
border-bottom-left-radius: 5px;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
:last-child {
|
|
251
|
+
border-top-right-radius: 5px;
|
|
252
|
+
border-bottom-right-radius: 5px;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.legend {
|
|
257
|
+
margin: 10px 0 20px 0;
|
|
258
|
+
font-size: var(--dl-font-size-body);
|
|
259
|
+
justify-content: space-evenly;
|
|
260
|
+
|
|
261
|
+
& .item {
|
|
262
|
+
display: flex;
|
|
263
|
+
align-items: center;
|
|
264
|
+
padding-right: 10px;
|
|
265
|
+
justify-content: center;
|
|
266
|
+
|
|
267
|
+
.circle {
|
|
268
|
+
min-width: 8px;
|
|
269
|
+
height: 8px;
|
|
270
|
+
border-radius: 50%;
|
|
271
|
+
margin-right: 5px;
|
|
272
|
+
box-sizing: border-box;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.text {
|
|
276
|
+
overflow: hidden;
|
|
277
|
+
white-space: nowrap;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.ellipsis {
|
|
281
|
+
text-overflow: ellipsis;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.text::first-letter {
|
|
285
|
+
text-transform: capitalize;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.item {
|
|
292
|
+
@for $n from 1 through 100 {
|
|
293
|
+
&:first-child:nth-last-child(#{$n}),
|
|
294
|
+
&:first-child:nth-last-child(#{$n}) ~ & {
|
|
295
|
+
width: calc(100% / #{$n} - 10px);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
</style>
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:id="uuid"
|
|
4
|
+
:class="identifierClass"
|
|
5
|
+
class="container-wrapper"
|
|
6
|
+
>
|
|
7
|
+
<label
|
|
8
|
+
:for="computedId"
|
|
9
|
+
class="container"
|
|
10
|
+
:class="{ disabled: disabled }"
|
|
11
|
+
:tabindex="tabindex"
|
|
12
|
+
:style="cssContainerVars"
|
|
13
|
+
@click="onClick"
|
|
14
|
+
@keydown="onKeydown"
|
|
15
|
+
@keyup="onKeyup"
|
|
16
|
+
>
|
|
17
|
+
<span class="radio-wrapper">
|
|
18
|
+
<input
|
|
19
|
+
:id="computedId"
|
|
20
|
+
:value="value"
|
|
21
|
+
:checked="isChecked"
|
|
22
|
+
type="radio"
|
|
23
|
+
tabindex="-1"
|
|
24
|
+
:disabled="disabled"
|
|
25
|
+
>
|
|
26
|
+
<svg
|
|
27
|
+
class="radio-border"
|
|
28
|
+
:style="cssSvgVars"
|
|
29
|
+
>
|
|
30
|
+
<path
|
|
31
|
+
d="M6 0C4.4087 0 2.8826 0.632144 1.75739 1.75736C0.632167 2.88258 0 4.4087 0 6C0 7.5913 0.632167 9.11742 1.75739 10.2426C2.8826 11.3679 4.4087 12 6 12C7.5913 12 9.11743 11.3679 10.2426 10.2426C11.3679 9.11742 12 7.5913 12 6C12 4.4087 11.3679 2.88258 10.2426 1.75736C9.11743 0.632144 7.5913 0 6 0ZM6 10.846C4.71476 10.846 3.48217 10.3354 2.57336 9.42664C1.66456 8.51784 1.15402 7.28524 1.15402 6C1.15402 5.36361 1.27935 4.73346 1.52289 4.14552C1.76642 3.55757 2.12337 3.02336 2.57336 2.57336C3.02336 2.12337 3.55759 1.76641 4.14554 1.52288C4.73348 1.27935 5.36361 1.154 6 1.154C6.63639 1.154 7.26655 1.27935 7.85449 1.52288C8.44244 1.76641 8.97667 2.12337 9.42667 2.57336C9.87666 3.02336 10.2336 3.55757 10.4771 4.14552C10.7207 4.73346 10.846 5.36361 10.846 6C10.846 7.28524 10.3355 8.51784 9.42667 9.42664C8.51787 10.3354 7.28524 10.846 6 10.846Z"
|
|
32
|
+
/>
|
|
33
|
+
</svg>
|
|
34
|
+
<svg
|
|
35
|
+
class="radio-check"
|
|
36
|
+
:style="cssSvgVars"
|
|
37
|
+
>
|
|
38
|
+
<path
|
|
39
|
+
d="M6 9C7.65685 9 9 7.65685 9 6C9 4.34315 7.65685 3 6 3C4.34315 3 3 4.34315 3 6C3 7.65685 4.34315 9 6 9Z"
|
|
40
|
+
/>
|
|
41
|
+
</svg>
|
|
42
|
+
</span>
|
|
43
|
+
<span
|
|
44
|
+
v-if="hasLabel"
|
|
45
|
+
class="radio-label"
|
|
46
|
+
:for="computedId"
|
|
47
|
+
>
|
|
48
|
+
<slot>
|
|
49
|
+
{{ label }}
|
|
50
|
+
</slot>
|
|
51
|
+
</span>
|
|
52
|
+
</label>
|
|
53
|
+
<div
|
|
54
|
+
v-if="subLabel"
|
|
55
|
+
:style="subLabelStyle"
|
|
56
|
+
class="sub-text"
|
|
57
|
+
>
|
|
58
|
+
<span> {{ subLabel }}</span>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
</template>
|
|
62
|
+
|
|
63
|
+
<script lang="ts">
|
|
64
|
+
import { defineComponent } from 'vue-demi'
|
|
65
|
+
import { stopAndPrevent } from '../utils'
|
|
66
|
+
import { v4 } from 'uuid'
|
|
67
|
+
import { getColor } from '../utils'
|
|
68
|
+
|
|
69
|
+
export default defineComponent({
|
|
70
|
+
name: 'DlRadio',
|
|
71
|
+
model: {
|
|
72
|
+
prop: 'modelValue',
|
|
73
|
+
event: 'update:model-value'
|
|
74
|
+
},
|
|
75
|
+
props: {
|
|
76
|
+
color: { type: String, default: null },
|
|
77
|
+
disabled: { type: Boolean, default: false },
|
|
78
|
+
id: { type: [String, Number], default: null },
|
|
79
|
+
label: { type: String, default: null },
|
|
80
|
+
padding: { type: String, default: '5px' },
|
|
81
|
+
modelValue: { type: [String, Number], required: true },
|
|
82
|
+
value: { type: [String, Number], required: true },
|
|
83
|
+
tabindex: { type: String, default: '0' },
|
|
84
|
+
subLabel: { type: String, default: '' },
|
|
85
|
+
subLabelSize: { type: String, default: '10px' }
|
|
86
|
+
},
|
|
87
|
+
emits: ['update:model-value'],
|
|
88
|
+
data() {
|
|
89
|
+
return {
|
|
90
|
+
uuid: `dl-radio-${v4()}`
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
computed: {
|
|
94
|
+
identifierClass(): string {
|
|
95
|
+
return `dl-radio-${this.label ?? ''}`.replaceAll(' ', '-')
|
|
96
|
+
},
|
|
97
|
+
computedId(): string {
|
|
98
|
+
return `${this.$props.id || v4()}`
|
|
99
|
+
},
|
|
100
|
+
hasLabel(): boolean {
|
|
101
|
+
return !!this.$props.label || !!this.$slots.default
|
|
102
|
+
},
|
|
103
|
+
isChecked(): boolean {
|
|
104
|
+
return this.$props.modelValue === this.$props.value
|
|
105
|
+
},
|
|
106
|
+
cssSvgVars(): Record<string, string | number> {
|
|
107
|
+
return {
|
|
108
|
+
'--dl-radio-color': this.getCurrentColor(),
|
|
109
|
+
'--dl-check-dot-scale': this.isChecked ? 1 : 0
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
cssContainerVars(): Record<string, string> {
|
|
113
|
+
return {
|
|
114
|
+
'--dl-radio-padding': this.padding
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
subLabelStyle(): Record<string, string> {
|
|
118
|
+
return {
|
|
119
|
+
'font-size': this.subLabelSize
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
methods: {
|
|
124
|
+
getCurrentColor() {
|
|
125
|
+
if (this.disabled) {
|
|
126
|
+
return 'var(--dl-color-disabled)'
|
|
127
|
+
}
|
|
128
|
+
if (this.isChecked) {
|
|
129
|
+
return getColor(this.color, 'dl-color-secondary')
|
|
130
|
+
}
|
|
131
|
+
return 'var(--dl-color-separator)'
|
|
132
|
+
},
|
|
133
|
+
onClick(e: Event) {
|
|
134
|
+
if (e) {
|
|
135
|
+
stopAndPrevent(e)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (!this.$props.disabled) {
|
|
139
|
+
this.$emit('update:model-value', this.$props.value, e)
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
onKeydown(e: KeyboardEvent) {
|
|
143
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
144
|
+
stopAndPrevent(e)
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
onKeyup(e: KeyboardEvent) {
|
|
148
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
149
|
+
this.onClick(e as Event)
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
template: 'dl-radio'
|
|
154
|
+
})
|
|
155
|
+
</script>
|
|
156
|
+
|
|
157
|
+
<style scoped lang="scss">
|
|
158
|
+
.container {
|
|
159
|
+
cursor: pointer;
|
|
160
|
+
display: inline-flex;
|
|
161
|
+
max-width: max-content;
|
|
162
|
+
gap: 10px;
|
|
163
|
+
align-items: center;
|
|
164
|
+
padding: var(--dl-radio-padding);
|
|
165
|
+
user-select: none;
|
|
166
|
+
}
|
|
167
|
+
.container.disabled {
|
|
168
|
+
cursor: not-allowed;
|
|
169
|
+
color: var(--dl-color-disabled);
|
|
170
|
+
& * {
|
|
171
|
+
pointer-events: none;
|
|
172
|
+
color: var(--dl-color-disabled);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
.radio-wrapper {
|
|
176
|
+
display: flex;
|
|
177
|
+
position: relative;
|
|
178
|
+
width: 12px;
|
|
179
|
+
height: 12px;
|
|
180
|
+
& svg {
|
|
181
|
+
transition: all 150ms cubic-bezier(0, 0, 0.2, 1) 0ms;
|
|
182
|
+
overflow: visible;
|
|
183
|
+
fill: var(--dl-radio-color);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
input {
|
|
187
|
+
position: absolute;
|
|
188
|
+
opacity: 0;
|
|
189
|
+
margin: 0;
|
|
190
|
+
width: 100%;
|
|
191
|
+
height: 100%;
|
|
192
|
+
}
|
|
193
|
+
.radio-label {
|
|
194
|
+
font-size: var(--dl-font-size-body);
|
|
195
|
+
color: var(--dl-color-darker);
|
|
196
|
+
}
|
|
197
|
+
.radio-border {
|
|
198
|
+
position: absolute;
|
|
199
|
+
width: 100%;
|
|
200
|
+
height: 100%;
|
|
201
|
+
}
|
|
202
|
+
.radio-check {
|
|
203
|
+
transition: transform 150ms cubic-bezier(0, 0, 0.2, 1) 0ms;
|
|
204
|
+
transform: scale(var(--dl-check-dot-scale));
|
|
205
|
+
width: 100%;
|
|
206
|
+
height: 100%;
|
|
207
|
+
}
|
|
208
|
+
.label-wrapper {
|
|
209
|
+
display: flex;
|
|
210
|
+
flex-direction: column;
|
|
211
|
+
}
|
|
212
|
+
.sub-text {
|
|
213
|
+
margin-left: 6%;
|
|
214
|
+
width: 80%;
|
|
215
|
+
color: var(--dl-color-medium);
|
|
216
|
+
word-break: break-all;
|
|
217
|
+
}
|
|
218
|
+
</style>
|