@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,370 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:id="uuid"
|
|
4
|
+
class="dl-button-container"
|
|
5
|
+
style="pointer-events: none"
|
|
6
|
+
>
|
|
7
|
+
<button
|
|
8
|
+
v-if="hasContent || hasIcon"
|
|
9
|
+
:tabindex="tabIndex"
|
|
10
|
+
:aria-disabled="disabled ? 'true' : 'false'"
|
|
11
|
+
:disabled="disabled"
|
|
12
|
+
:style="cssButtonVars"
|
|
13
|
+
style="pointer-events: auto"
|
|
14
|
+
class="dl-button"
|
|
15
|
+
@click="onClick"
|
|
16
|
+
@mousedown="onMouseDown"
|
|
17
|
+
>
|
|
18
|
+
<dl-tooltip
|
|
19
|
+
v-if="!tooltip && overflow && isOverflowing && hasLabel"
|
|
20
|
+
>
|
|
21
|
+
{{ btnLabel }}
|
|
22
|
+
</dl-tooltip>
|
|
23
|
+
<span class="dl-btn-content dl-anchor--skip">
|
|
24
|
+
<dl-icon
|
|
25
|
+
v-if="hasIcon"
|
|
26
|
+
:size="iconSizePX"
|
|
27
|
+
:color="iconColor || textColor"
|
|
28
|
+
:class="{ 'dl-btn-icon': hasContent }"
|
|
29
|
+
:icon="icon"
|
|
30
|
+
:style="cssButtonVars"
|
|
31
|
+
/>
|
|
32
|
+
<span
|
|
33
|
+
v-if="hasLabel"
|
|
34
|
+
ref="btnLabelRef"
|
|
35
|
+
class="dl-btn-label"
|
|
36
|
+
:class="{ 'dl-button-no-wrap': noWrap }"
|
|
37
|
+
>
|
|
38
|
+
{{ btnLabel }}
|
|
39
|
+
</span>
|
|
40
|
+
<slot />
|
|
41
|
+
</span>
|
|
42
|
+
</button>
|
|
43
|
+
<dl-tooltip
|
|
44
|
+
v-if="tooltip"
|
|
45
|
+
style="pointer-events: auto"
|
|
46
|
+
>
|
|
47
|
+
{{ tooltip }}
|
|
48
|
+
</dl-tooltip>
|
|
49
|
+
</div>
|
|
50
|
+
</template>
|
|
51
|
+
|
|
52
|
+
<script lang="ts">
|
|
53
|
+
import DlIcon from '../DlIcon.vue'
|
|
54
|
+
import DlTooltip from '../DlTooltip.vue'
|
|
55
|
+
import {
|
|
56
|
+
setPadding,
|
|
57
|
+
setFontSize,
|
|
58
|
+
setTextColor,
|
|
59
|
+
setBgColor,
|
|
60
|
+
setBorder,
|
|
61
|
+
setColorOnHover,
|
|
62
|
+
setBorderOnHover,
|
|
63
|
+
setBgOnHover,
|
|
64
|
+
setIconSize,
|
|
65
|
+
setIconPadding,
|
|
66
|
+
setMaxHeight
|
|
67
|
+
} from './utils'
|
|
68
|
+
import type { ButtonSizes } from './utils'
|
|
69
|
+
import { textTransform } from '../../utils/string'
|
|
70
|
+
import { defineComponent, PropType, ref } from 'vue-demi'
|
|
71
|
+
import { colorNames } from '../../utils/css-color-names'
|
|
72
|
+
import { useSizeObserver } from '../../hooks/use-size-observer'
|
|
73
|
+
import { v4 } from 'uuid'
|
|
74
|
+
|
|
75
|
+
export enum ButtonState {
|
|
76
|
+
Active = 'ACTIVE',
|
|
77
|
+
Hover = 'HOVER',
|
|
78
|
+
Pressed = 'PRESSED',
|
|
79
|
+
Disabled = 'DISABLED'
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export enum ButtonPart {
|
|
83
|
+
Text = 'TEXT',
|
|
84
|
+
Background = 'BACKGROUND',
|
|
85
|
+
Border = 'BORDER'
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export type ButtonColors = Record<ButtonState, Record<ButtonPart, string>>
|
|
89
|
+
|
|
90
|
+
export default defineComponent({
|
|
91
|
+
name: 'DlButton',
|
|
92
|
+
components: {
|
|
93
|
+
DlIcon,
|
|
94
|
+
DlTooltip
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
props: {
|
|
98
|
+
disabled: Boolean,
|
|
99
|
+
color: {
|
|
100
|
+
type: String! as PropType<keyof typeof colorNames>,
|
|
101
|
+
default: ''
|
|
102
|
+
},
|
|
103
|
+
dense: { type: Boolean, default: false },
|
|
104
|
+
label: { type: String, default: '' },
|
|
105
|
+
textColor: { type: String!, default: '' },
|
|
106
|
+
colorsObject: {
|
|
107
|
+
type: Object as PropType<ButtonColors>,
|
|
108
|
+
default: null
|
|
109
|
+
},
|
|
110
|
+
iconColor: { type: String!, default: '' },
|
|
111
|
+
padding: { type: String, default: '' },
|
|
112
|
+
size: { type: String! as PropType<ButtonSizes>, default: 'm' },
|
|
113
|
+
filled: { type: Boolean, default: true },
|
|
114
|
+
round: { type: Boolean, default: false },
|
|
115
|
+
fluid: Boolean,
|
|
116
|
+
flat: Boolean,
|
|
117
|
+
uppercase: Boolean,
|
|
118
|
+
outlined: Boolean,
|
|
119
|
+
noWrap: Boolean,
|
|
120
|
+
icon: { type: String, default: '' },
|
|
121
|
+
overflow: { type: Boolean, default: false, required: false },
|
|
122
|
+
tooltip: { type: String, default: null, required: false }
|
|
123
|
+
},
|
|
124
|
+
emits: ['click', 'mousedown'],
|
|
125
|
+
setup() {
|
|
126
|
+
const btnLabelRef = ref(null)
|
|
127
|
+
const { hasEllipsis } = useSizeObserver(btnLabelRef)
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
uuid: `dl-button-${v4()}`,
|
|
131
|
+
btnLabelRef,
|
|
132
|
+
isOverflowing: hasEllipsis
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
computed: {
|
|
136
|
+
isActionable(): boolean {
|
|
137
|
+
return this.disabled !== true
|
|
138
|
+
},
|
|
139
|
+
tabIndex(): number {
|
|
140
|
+
return this.isActionable ? 0 : -1
|
|
141
|
+
},
|
|
142
|
+
iconSizePX(): string {
|
|
143
|
+
return setIconSize(this.$props.size)
|
|
144
|
+
},
|
|
145
|
+
hasLabel(): boolean {
|
|
146
|
+
return (
|
|
147
|
+
this.label !== void 0 &&
|
|
148
|
+
this.label !== null &&
|
|
149
|
+
this.label !== ''
|
|
150
|
+
)
|
|
151
|
+
},
|
|
152
|
+
btnLabel(): string {
|
|
153
|
+
return textTransform(this.label)
|
|
154
|
+
},
|
|
155
|
+
hasIcon(): boolean {
|
|
156
|
+
return typeof this.icon === 'string' && this.icon !== ''
|
|
157
|
+
},
|
|
158
|
+
hasContent(): boolean {
|
|
159
|
+
return !!this.$slots.default || this.hasLabel
|
|
160
|
+
},
|
|
161
|
+
cssButtonVars(): Record<string, string> {
|
|
162
|
+
let colors: Record<string, string> = {}
|
|
163
|
+
|
|
164
|
+
if (this.colorsObject) {
|
|
165
|
+
if (this.disabled) {
|
|
166
|
+
colors = {
|
|
167
|
+
'--dl-button-text-color':
|
|
168
|
+
this.colorsObject.DISABLED.TEXT,
|
|
169
|
+
'--dl-button-bg': this.colorsObject.DISABLED.BACKGROUND,
|
|
170
|
+
'--dl-button-border': this.colorsObject.DISABLED.BORDER,
|
|
171
|
+
'--dl-button-text-color-hover':
|
|
172
|
+
this.colorsObject.DISABLED.TEXT,
|
|
173
|
+
'--dl-button-bg-hover':
|
|
174
|
+
this.colorsObject.DISABLED.BACKGROUND,
|
|
175
|
+
'--dl-button-border-hover':
|
|
176
|
+
this.colorsObject.DISABLED.BORDER,
|
|
177
|
+
'--dl-button-text-color-pressed':
|
|
178
|
+
this.colorsObject.DISABLED.TEXT,
|
|
179
|
+
'--dl-button-bg-pressed':
|
|
180
|
+
this.colorsObject.DISABLED.BACKGROUND,
|
|
181
|
+
'--dl-button-border-pressed':
|
|
182
|
+
this.colorsObject.DISABLED.BORDER
|
|
183
|
+
}
|
|
184
|
+
} else {
|
|
185
|
+
colors = {
|
|
186
|
+
'--dl-button-text-color': this.colorsObject.ACTIVE.TEXT,
|
|
187
|
+
'--dl-button-bg': this.colorsObject.ACTIVE.BACKGROUND,
|
|
188
|
+
'--dl-button-border': this.colorsObject.ACTIVE.BORDER,
|
|
189
|
+
'--dl-button-text-color-hover':
|
|
190
|
+
this.colorsObject.HOVER.TEXT,
|
|
191
|
+
'--dl-button-bg-hover':
|
|
192
|
+
this.colorsObject.HOVER.BACKGROUND,
|
|
193
|
+
'--dl-button-border-hover':
|
|
194
|
+
this.colorsObject.HOVER.BORDER,
|
|
195
|
+
'--dl-button-text-color-pressed':
|
|
196
|
+
this.colorsObject.PRESSED.TEXT,
|
|
197
|
+
'--dl-button-bg-pressed':
|
|
198
|
+
this.colorsObject.PRESSED.BACKGROUND,
|
|
199
|
+
'--dl-button-border-pressed':
|
|
200
|
+
this.colorsObject.PRESSED.BORDER
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
} else {
|
|
204
|
+
colors = {
|
|
205
|
+
'--dl-button-text-color': setTextColor({
|
|
206
|
+
disabled: this.disabled,
|
|
207
|
+
outlined: this.outlined,
|
|
208
|
+
flat: this.flat,
|
|
209
|
+
color: this.color,
|
|
210
|
+
filled: this.filled,
|
|
211
|
+
textColor: this.textColor
|
|
212
|
+
}),
|
|
213
|
+
'--dl-button-bg': setBgColor({
|
|
214
|
+
disabled: this.disabled,
|
|
215
|
+
outlined: this.outlined,
|
|
216
|
+
flat: this.flat,
|
|
217
|
+
color: this.color
|
|
218
|
+
}),
|
|
219
|
+
'--dl-button-border': setBorder({
|
|
220
|
+
disabled: this.disabled,
|
|
221
|
+
flat: this.flat,
|
|
222
|
+
color: this.color
|
|
223
|
+
}),
|
|
224
|
+
'--dl-button-text-color-hover': setColorOnHover({
|
|
225
|
+
disabled: this.disabled,
|
|
226
|
+
outlined: this.outlined,
|
|
227
|
+
flat: this.flat,
|
|
228
|
+
color: this.textColor
|
|
229
|
+
}),
|
|
230
|
+
'--dl-button-border-hover': setBorderOnHover({
|
|
231
|
+
disabled: this.disabled,
|
|
232
|
+
flat: this.flat,
|
|
233
|
+
color: this.color
|
|
234
|
+
}),
|
|
235
|
+
'--dl-button-bg-hover': setBgOnHover({
|
|
236
|
+
disabled: this.disabled,
|
|
237
|
+
outlined: this.outlined,
|
|
238
|
+
flat: this.flat,
|
|
239
|
+
filled: this.filled,
|
|
240
|
+
color: this.color
|
|
241
|
+
}),
|
|
242
|
+
'--dl-button-text-color-pressed':
|
|
243
|
+
'var(--dl-button-text-color)',
|
|
244
|
+
'--dl-button-bg-pressed': 'var(--dl-button-bg)',
|
|
245
|
+
'--dl-button-border-pressed': 'var(--dl-button-border)'
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return {
|
|
250
|
+
'--dl-button-padding': this.dense
|
|
251
|
+
? '0'
|
|
252
|
+
: this.padding
|
|
253
|
+
? this.padding
|
|
254
|
+
: this.hasIcon && !this.hasContent
|
|
255
|
+
? setIconPadding(this.size)
|
|
256
|
+
: setPadding(this.size),
|
|
257
|
+
'--dl-button-font-size': setFontSize(this.size),
|
|
258
|
+
'--dl-button-text-transform': this.uppercase
|
|
259
|
+
? 'uppercase'
|
|
260
|
+
: 'none',
|
|
261
|
+
'--dl-button-cursor': this.isActionable
|
|
262
|
+
? 'pointer'
|
|
263
|
+
: 'not-allowed',
|
|
264
|
+
|
|
265
|
+
'--dl-button-width': '100%',
|
|
266
|
+
'--dl-button-border-radius':
|
|
267
|
+
!this.hasContent && this.hasIcon && this.round
|
|
268
|
+
? '50%'
|
|
269
|
+
: '2px',
|
|
270
|
+
'--dl-button-max-height': this.padding
|
|
271
|
+
? '100%'
|
|
272
|
+
: setMaxHeight(this.size),
|
|
273
|
+
...colors
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
methods: {
|
|
278
|
+
onClick(e: Event) {
|
|
279
|
+
if (this.isActionable) {
|
|
280
|
+
if (!e) {
|
|
281
|
+
if (e.defaultPrevented === true) {
|
|
282
|
+
return
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
this.$emit('click', e)
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
onMouseDown(e: Event) {
|
|
290
|
+
if (this.isActionable) {
|
|
291
|
+
if (e !== void 0) {
|
|
292
|
+
if (e.defaultPrevented === true) {
|
|
293
|
+
return
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
this.$emit('mousedown', e)
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
})
|
|
302
|
+
</script>
|
|
303
|
+
|
|
304
|
+
<style scoped lang="scss">
|
|
305
|
+
.dl-button-no-wrap {
|
|
306
|
+
white-space: nowrap;
|
|
307
|
+
overflow: hidden;
|
|
308
|
+
text-overflow: ellipsis;
|
|
309
|
+
}
|
|
310
|
+
.dl-button {
|
|
311
|
+
padding: var(--dl-button-padding);
|
|
312
|
+
border-radius: var(--dl-button-border-radius);
|
|
313
|
+
text-transform: var(--dl-button-text-transform);
|
|
314
|
+
font-family: 'Roboto', sans-serif;
|
|
315
|
+
font-size: var(--dl-button-font-size);
|
|
316
|
+
cursor: var(--dl-button-cursor);
|
|
317
|
+
color: var(--dl-button-text-color);
|
|
318
|
+
background-color: var(--dl-button-bg);
|
|
319
|
+
border: 1px solid var(--dl-button-border);
|
|
320
|
+
width: var(--dl-button-width);
|
|
321
|
+
max-height: var(--dl-button-max-height);
|
|
322
|
+
height: auto;
|
|
323
|
+
display: inline-flex;
|
|
324
|
+
flex-direction: column;
|
|
325
|
+
align-items: stretch;
|
|
326
|
+
position: relative;
|
|
327
|
+
vertical-align: middle;
|
|
328
|
+
transition: all ease-in 0.15s;
|
|
329
|
+
justify-content: center;
|
|
330
|
+
&:active {
|
|
331
|
+
transition: all ease-in 0.15s;
|
|
332
|
+
color: var(--dl-button-text-color-pressed) !important;
|
|
333
|
+
background-color: var(--dl-button-bg-pressed) !important;
|
|
334
|
+
border-color: var(--dl-button-border-pressed) !important;
|
|
335
|
+
& > span > i {
|
|
336
|
+
transition: all ease-in 0.15s;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
&:hover:enabled:not(:active) {
|
|
340
|
+
color: var(--dl-button-text-color-hover);
|
|
341
|
+
background-color: var(--dl-button-bg-hover);
|
|
342
|
+
border-color: var(--dl-button-border-hover);
|
|
343
|
+
& .dl-btn-label {
|
|
344
|
+
transition: all ease-in 0.15s;
|
|
345
|
+
color: var(--dl-button-color-hover);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
.dl-btn-content {
|
|
350
|
+
display: flex;
|
|
351
|
+
text-align: center;
|
|
352
|
+
align-items: center;
|
|
353
|
+
justify-content: center;
|
|
354
|
+
padding: 0;
|
|
355
|
+
flex: 10000 1 0%;
|
|
356
|
+
flex-wrap: nowrap;
|
|
357
|
+
line-height: 1;
|
|
358
|
+
z-index: 0;
|
|
359
|
+
user-select: none !important;
|
|
360
|
+
min-width: 1.5em;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
.dl-btn-icon {
|
|
364
|
+
margin-right: 7px;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
.dl-button-container {
|
|
368
|
+
display: inline-block;
|
|
369
|
+
}
|
|
370
|
+
</style>
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { getColor } from '../../utils'
|
|
2
|
+
import { getLighterGradient } from '../../utils/getLighterGradient'
|
|
3
|
+
|
|
4
|
+
export type ButtonSizes = 's' | 'm' | 'l' | 'xl'
|
|
5
|
+
|
|
6
|
+
const paddings = {
|
|
7
|
+
s: '7px 16px',
|
|
8
|
+
m: '9px 16px',
|
|
9
|
+
l: '10px 16px',
|
|
10
|
+
xl: '12px 16px'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const iconPaddings = {
|
|
14
|
+
s: '6px',
|
|
15
|
+
m: '8px',
|
|
16
|
+
l: '10px',
|
|
17
|
+
xl: '12px'
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const iconSizes = {
|
|
21
|
+
s: '12px',
|
|
22
|
+
m: '16px',
|
|
23
|
+
l: '18px',
|
|
24
|
+
xl: '20px'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const maxHeights = {
|
|
28
|
+
s: '28px',
|
|
29
|
+
m: '34px',
|
|
30
|
+
l: 'auto',
|
|
31
|
+
xl: 'auto'
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const fontSizes = {
|
|
35
|
+
s: '12px',
|
|
36
|
+
m: '14px',
|
|
37
|
+
l: '16px',
|
|
38
|
+
xl: '18px'
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface ButtonProps {
|
|
42
|
+
disabled: boolean
|
|
43
|
+
outlined: boolean
|
|
44
|
+
flat: boolean
|
|
45
|
+
filled: boolean
|
|
46
|
+
color: string
|
|
47
|
+
textColor: string
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const setIconSize = (size: ButtonSizes) => iconSizes[size] || size
|
|
51
|
+
|
|
52
|
+
export const setPadding = (size: ButtonSizes) => paddings[size]
|
|
53
|
+
|
|
54
|
+
export const setIconPadding = (size: ButtonSizes) => iconPaddings[size]
|
|
55
|
+
|
|
56
|
+
export const setFontSize = (size: ButtonSizes) => fontSizes[size]
|
|
57
|
+
|
|
58
|
+
export const setMaxHeight = (size: ButtonSizes) => maxHeights[size]
|
|
59
|
+
|
|
60
|
+
export const setTextColor = ({
|
|
61
|
+
disabled,
|
|
62
|
+
outlined,
|
|
63
|
+
flat,
|
|
64
|
+
color,
|
|
65
|
+
filled,
|
|
66
|
+
textColor
|
|
67
|
+
}: ButtonProps): string => {
|
|
68
|
+
if (disabled) {
|
|
69
|
+
return getColor('', 'dl-color-disabled')
|
|
70
|
+
}
|
|
71
|
+
if (outlined) {
|
|
72
|
+
return getColor(textColor, 'dl-color-secondary')
|
|
73
|
+
}
|
|
74
|
+
if (flat) {
|
|
75
|
+
if (color === 'secondary') {
|
|
76
|
+
return getColor(textColor, 'dl-color-darker')
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return getColor(textColor, 'dl-color-secondary')
|
|
80
|
+
}
|
|
81
|
+
if (filled) {
|
|
82
|
+
return getColor(textColor, 'dl-color-text-buttons')
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return getColor(textColor, 'dl-color-text-buttons')
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export const setBgColor = ({
|
|
89
|
+
disabled,
|
|
90
|
+
flat,
|
|
91
|
+
outlined,
|
|
92
|
+
color = ''
|
|
93
|
+
}: Partial<ButtonProps>) => {
|
|
94
|
+
if (disabled || flat || outlined) {
|
|
95
|
+
return 'var(--dl-color-transparent)'
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return getColor(color, 'dl-color-secondary')
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export const setBorder = ({
|
|
102
|
+
disabled,
|
|
103
|
+
flat,
|
|
104
|
+
color = ''
|
|
105
|
+
}: Partial<ButtonProps>) => {
|
|
106
|
+
if (disabled) {
|
|
107
|
+
return flat
|
|
108
|
+
? 'var(--dl-color-transparent)'
|
|
109
|
+
: 'var(--dl-color-separator)'
|
|
110
|
+
}
|
|
111
|
+
if (flat) {
|
|
112
|
+
return 'var(--dl-color-transparent)'
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return getColor(color, 'dl-color-secondary')
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export const setColorOnHover = ({
|
|
119
|
+
disabled,
|
|
120
|
+
flat,
|
|
121
|
+
outlined,
|
|
122
|
+
color
|
|
123
|
+
}: Partial<ButtonProps>) => {
|
|
124
|
+
if (color) return getLighterGradient(color)
|
|
125
|
+
if (disabled) {
|
|
126
|
+
return flat ? 'var(--dl-color-transparent)' : 'var(--dl-color-disabled)'
|
|
127
|
+
}
|
|
128
|
+
if (outlined || flat) {
|
|
129
|
+
return 'var(--dl-color-hover)'
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return 'var(--dl-color-white)'
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export const setBorderOnHover = ({
|
|
136
|
+
disabled,
|
|
137
|
+
flat,
|
|
138
|
+
color
|
|
139
|
+
}: Partial<ButtonProps>) => {
|
|
140
|
+
if (disabled) {
|
|
141
|
+
return 'var(--dl-color-separator)'
|
|
142
|
+
}
|
|
143
|
+
if (flat) {
|
|
144
|
+
return 'var(--dl-color-transparent)'
|
|
145
|
+
}
|
|
146
|
+
if (color) {
|
|
147
|
+
return getLighterGradient(color)
|
|
148
|
+
}
|
|
149
|
+
return 'var(--dl-color-hover)'
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export const setBgOnHover = ({
|
|
153
|
+
disabled,
|
|
154
|
+
flat,
|
|
155
|
+
outlined,
|
|
156
|
+
filled,
|
|
157
|
+
color
|
|
158
|
+
}: Partial<ButtonProps>) => {
|
|
159
|
+
if (color) return getLighterGradient(color)
|
|
160
|
+
|
|
161
|
+
if (disabled || flat || outlined) {
|
|
162
|
+
return 'var(--dl-color-transparent)'
|
|
163
|
+
}
|
|
164
|
+
if (filled) {
|
|
165
|
+
return 'var(--dl-color-hover)'
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return 'var(--dl-color-panel-background)'
|
|
169
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:id="uuid"
|
|
4
|
+
:class="classes"
|
|
5
|
+
>
|
|
6
|
+
<slot />
|
|
7
|
+
</div>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script lang="ts">
|
|
11
|
+
import { v4 } from 'uuid'
|
|
12
|
+
import { defineComponent } from 'vue-demi'
|
|
13
|
+
|
|
14
|
+
const classes = ['outlined', 'flat', 'stretch']
|
|
15
|
+
|
|
16
|
+
export default defineComponent({
|
|
17
|
+
name: 'DlButtonGroup',
|
|
18
|
+
props: {
|
|
19
|
+
outlined: Boolean,
|
|
20
|
+
flat: Boolean,
|
|
21
|
+
stretch: Boolean,
|
|
22
|
+
spread: Boolean
|
|
23
|
+
},
|
|
24
|
+
data() {
|
|
25
|
+
return {
|
|
26
|
+
uuid: `dl-button-group-${v4()}`
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
computed: {
|
|
30
|
+
classes(): string {
|
|
31
|
+
const cls = classes
|
|
32
|
+
// @ts-ignore wtf is this ?
|
|
33
|
+
.filter((t) => this[t] === true)
|
|
34
|
+
.map((t) => `dl-btn-group--${t}`)
|
|
35
|
+
.join(' ')
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
`dl-btn-group row no-wrap${cls.length > 0 ? ' ' + cls : ''}` +
|
|
39
|
+
(this.spread ? ' dl-btn-group--spread' : ' inline')
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<style lang="scss">
|
|
47
|
+
.dl-btn-group {
|
|
48
|
+
border-radius: 2px;
|
|
49
|
+
vertical-align: middle;
|
|
50
|
+
|
|
51
|
+
> .dl-button {
|
|
52
|
+
border-radius: inherit;
|
|
53
|
+
align-self: stretch;
|
|
54
|
+
|
|
55
|
+
&:before {
|
|
56
|
+
box-shadow: none;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
> .dl-btn-group {
|
|
60
|
+
box-shadow: none;
|
|
61
|
+
|
|
62
|
+
&:first-child {
|
|
63
|
+
> .dl-button:first-child {
|
|
64
|
+
border-top-left-radius: inherit;
|
|
65
|
+
border-bottom-left-radius: inherit;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
&:last-child {
|
|
69
|
+
> .dl-button:last-child {
|
|
70
|
+
border-top-right-radius: inherit;
|
|
71
|
+
border-bottom-right-radius: inherit;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
> .dl-btn-group:not(:first-child) > .dl-button:first-child:before {
|
|
76
|
+
border-left: 0;
|
|
77
|
+
}
|
|
78
|
+
> .dl-btn-group:not(:last-child) > .dl-button:last-child:before {
|
|
79
|
+
border-right: 0;
|
|
80
|
+
}
|
|
81
|
+
> .dl-button:not(:last-child) {
|
|
82
|
+
border-top-right-radius: 0;
|
|
83
|
+
border-bottom-right-radius: 0;
|
|
84
|
+
}
|
|
85
|
+
> .dl-button:not(:first-child) {
|
|
86
|
+
border-top-left-radius: 0;
|
|
87
|
+
border-bottom-left-radius: 0;
|
|
88
|
+
}
|
|
89
|
+
> .dl-button.dl-button--standard:before {
|
|
90
|
+
z-index: -1;
|
|
91
|
+
}
|
|
92
|
+
&--flat,
|
|
93
|
+
&--outlined,
|
|
94
|
+
&--outlined {
|
|
95
|
+
> .dl-separator {
|
|
96
|
+
display: none;
|
|
97
|
+
}
|
|
98
|
+
> .dl-button + .dl-button:before {
|
|
99
|
+
border-left: 0;
|
|
100
|
+
}
|
|
101
|
+
> .dl-button:not(:last-child):before {
|
|
102
|
+
border-right: 0;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
&--stretch {
|
|
106
|
+
align-self: stretch;
|
|
107
|
+
border-radius: 0;
|
|
108
|
+
}
|
|
109
|
+
&--spread {
|
|
110
|
+
> .dl-btn-group {
|
|
111
|
+
display: flex !important;
|
|
112
|
+
}
|
|
113
|
+
> .dl-button,
|
|
114
|
+
> .dl-btn-group > .dl-button:not(.dl-btn-dropdown__arrow-container) {
|
|
115
|
+
width: auto;
|
|
116
|
+
min-width: 0;
|
|
117
|
+
max-width: 100%;
|
|
118
|
+
flex: 10000 1 0%;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
</style>
|