@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,355 @@
|
|
|
1
|
+
import { Ref, ref } from 'vue-demi'
|
|
2
|
+
import { splitByQuotes } from '../utils/splitByQuotes'
|
|
3
|
+
|
|
4
|
+
export type Schema = {
|
|
5
|
+
[key: string]:
|
|
6
|
+
| string
|
|
7
|
+
| number
|
|
8
|
+
| boolean
|
|
9
|
+
| (number | boolean | string)[]
|
|
10
|
+
| Schema
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type Alias = {
|
|
14
|
+
alias: string
|
|
15
|
+
key: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type Operators = {
|
|
19
|
+
[key: string]: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export enum Logical {
|
|
23
|
+
AND = 'AND',
|
|
24
|
+
OR = 'OR'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const operators: Operators = {
|
|
28
|
+
$eq: '=', // all types
|
|
29
|
+
$neq: '!=', // all types
|
|
30
|
+
$gt: '>', // number, date, datetime, time
|
|
31
|
+
$gte: '>=', // number, date, datetime, time
|
|
32
|
+
$lt: '<', // number, date, datetime, time
|
|
33
|
+
$lte: '<=', // number, date, datetime, time
|
|
34
|
+
$in: 'IN', // all types
|
|
35
|
+
$nin: 'NOT-IN' // all types
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type OperatorToDataTypeMap = {
|
|
39
|
+
[key: string]: string[]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const operatorToDataTypeMap: OperatorToDataTypeMap = {
|
|
43
|
+
$eq: [],
|
|
44
|
+
$neq: [],
|
|
45
|
+
$gt: ['number', 'date', 'datetime', 'time'],
|
|
46
|
+
$gte: ['number', 'date', 'datetime', 'time'],
|
|
47
|
+
$lt: ['number', 'date', 'datetime', 'time'],
|
|
48
|
+
$lte: ['number', 'date', 'datetime', 'time'],
|
|
49
|
+
$in: [],
|
|
50
|
+
$nin: []
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
type Suggestion = string
|
|
54
|
+
|
|
55
|
+
type Expression = {
|
|
56
|
+
field: string | null
|
|
57
|
+
operator: string | null
|
|
58
|
+
value: string | null
|
|
59
|
+
keyword: string | null
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const space = ' '
|
|
63
|
+
const dateIntervalSuggestionString = '(From (dd/mm/yyyy) To (dd/mm/yyyy))'
|
|
64
|
+
|
|
65
|
+
let localSuggestions: Suggestion[] = []
|
|
66
|
+
|
|
67
|
+
export const dateIntervalPattern = new RegExp(
|
|
68
|
+
/\((from\s?\(\d{2}\/\d{2}\/\d{4}\)\s?to\s?\(\d{2}\/\d{2}\/\d{4}\))\)|\((from\s?\(dd\/mm\/yyyy\)\s?to\s?\(dd\/mm\/yyyy\))\)/,
|
|
69
|
+
'gi'
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
export const useSuggestions = (schema: Schema, aliases: Alias[]) => {
|
|
73
|
+
const initialSuggestions = aliases.map((alias) => alias.alias)
|
|
74
|
+
const suggestions: Ref<Suggestion[]> = ref(initialSuggestions)
|
|
75
|
+
const error: Ref<string | null> = ref(null)
|
|
76
|
+
|
|
77
|
+
const findSuggestions = (input: string) => {
|
|
78
|
+
localSuggestions = initialSuggestions
|
|
79
|
+
|
|
80
|
+
const words = splitByQuotes(input, space)
|
|
81
|
+
const expressions = mapWordsToExpressions(words)
|
|
82
|
+
|
|
83
|
+
expressions.forEach(
|
|
84
|
+
({ field, operator, value, keyword }: Expression) => {
|
|
85
|
+
let matchedField: Suggestion | null = null
|
|
86
|
+
let matchedOperator: Suggestion | null = null
|
|
87
|
+
let matchedKeyword: Suggestion | null = null
|
|
88
|
+
|
|
89
|
+
if (!field) return
|
|
90
|
+
|
|
91
|
+
localSuggestions = getMatches(localSuggestions, field)
|
|
92
|
+
matchedField = getMatch(localSuggestions, field)
|
|
93
|
+
|
|
94
|
+
if (!matchedField && isNextCharSpace(input, field)) {
|
|
95
|
+
localSuggestions = []
|
|
96
|
+
return
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (!matchedField || !isNextCharSpace(input, matchedField)) {
|
|
100
|
+
return
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const alias = getAliasObjByAlias(aliases, matchedField)
|
|
104
|
+
if (!alias) return
|
|
105
|
+
const dataType = getDataTypeByAliasKey(schema, alias.key)
|
|
106
|
+
if (!dataType) {
|
|
107
|
+
localSuggestions = []
|
|
108
|
+
return
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const ops: string[] = Array.isArray(dataType)
|
|
112
|
+
? getGenericOperators()
|
|
113
|
+
: getOperatorByDataType(dataType)
|
|
114
|
+
|
|
115
|
+
localSuggestions = getOperators(ops)
|
|
116
|
+
|
|
117
|
+
if (!operator) return
|
|
118
|
+
|
|
119
|
+
localSuggestions = getMatches(localSuggestions, operator)
|
|
120
|
+
matchedOperator = getMatch(localSuggestions, operator)
|
|
121
|
+
|
|
122
|
+
if (!matchedOperator && isNextCharSpace(input, operator)) {
|
|
123
|
+
localSuggestions = []
|
|
124
|
+
return
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (
|
|
128
|
+
!matchedOperator ||
|
|
129
|
+
!isNextCharSpace(input, matchedOperator)
|
|
130
|
+
) {
|
|
131
|
+
return
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (Array.isArray(dataType)) {
|
|
135
|
+
localSuggestions = dataType
|
|
136
|
+
|
|
137
|
+
if (!value) return
|
|
138
|
+
|
|
139
|
+
localSuggestions = getMatches(localSuggestions, value)
|
|
140
|
+
} else if (
|
|
141
|
+
dataType === 'datetime' ||
|
|
142
|
+
dataType === 'date' ||
|
|
143
|
+
dataType === 'time'
|
|
144
|
+
) {
|
|
145
|
+
localSuggestions = [dateIntervalSuggestionString]
|
|
146
|
+
|
|
147
|
+
if (!value) return
|
|
148
|
+
|
|
149
|
+
localSuggestions = getMatches(localSuggestions, value)
|
|
150
|
+
} else {
|
|
151
|
+
localSuggestions = []
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (!value || !isNextCharSpace(input, value)) {
|
|
155
|
+
return
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
localSuggestions = [Logical.AND, Logical.OR]
|
|
159
|
+
|
|
160
|
+
if (!keyword) return
|
|
161
|
+
|
|
162
|
+
localSuggestions = getMatches(localSuggestions, keyword)
|
|
163
|
+
matchedKeyword = getMatch(localSuggestions, keyword)
|
|
164
|
+
|
|
165
|
+
if (!matchedKeyword || !isNextCharSpace(input, matchedKeyword))
|
|
166
|
+
return
|
|
167
|
+
|
|
168
|
+
localSuggestions = initialSuggestions
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
error.value = input.length
|
|
173
|
+
? getError(schema, aliases, expressions)
|
|
174
|
+
: null
|
|
175
|
+
|
|
176
|
+
suggestions.value = localSuggestions
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return { suggestions, findSuggestions, error }
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const errors = {
|
|
183
|
+
INVALID_EXPRESSION: 'Invalid Expression',
|
|
184
|
+
INVALID_VALUE: (field: string) => `Invalid value for "${field}" field`
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const getError = (
|
|
188
|
+
schema: Schema,
|
|
189
|
+
aliases: Alias[],
|
|
190
|
+
expressions: Expression[]
|
|
191
|
+
): string | null => {
|
|
192
|
+
const hasErrorInStructure = expressions
|
|
193
|
+
.flatMap((exp) => Object.values(exp))
|
|
194
|
+
.some((el, index, arr) => {
|
|
195
|
+
const isLastValue = index === arr.length - 1
|
|
196
|
+
return (isLastValue && el) || (!isLastValue && !el)
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
if (hasErrorInStructure) {
|
|
200
|
+
return errors.INVALID_EXPRESSION
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return expressions
|
|
204
|
+
.filter(({ field, value }) => field !== null && value !== null)
|
|
205
|
+
.reduce<string | null>((acc, { field, value, operator }, _, arr) => {
|
|
206
|
+
const valid = isValidByDataType(
|
|
207
|
+
value,
|
|
208
|
+
getDataTypeByAliasKey(
|
|
209
|
+
schema,
|
|
210
|
+
getAliasObjByAlias(aliases, field)!.key
|
|
211
|
+
),
|
|
212
|
+
operator
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
if (!valid) {
|
|
216
|
+
arr.splice(1)
|
|
217
|
+
return (acc = errors.INVALID_VALUE(field))
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return (acc = null)
|
|
221
|
+
}, null)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const isValidByDataType = (
|
|
225
|
+
str: string,
|
|
226
|
+
dataType: string | string[],
|
|
227
|
+
operator: string // TODO: use operator
|
|
228
|
+
): boolean => {
|
|
229
|
+
if (Array.isArray(dataType)) {
|
|
230
|
+
return !!getValueMatch(dataType, str)
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
switch (dataType) {
|
|
234
|
+
case 'number':
|
|
235
|
+
return isValidNumber(str)
|
|
236
|
+
case 'boolean':
|
|
237
|
+
return isValidBoolean(str)
|
|
238
|
+
case 'string':
|
|
239
|
+
return isValidString(str)
|
|
240
|
+
case 'date':
|
|
241
|
+
case 'datetime':
|
|
242
|
+
case 'time':
|
|
243
|
+
return isValidDateIntervalPattern(str)
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const isValidDateIntervalPattern = (str: string) => {
|
|
248
|
+
return !!str.match(dateIntervalPattern)
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const isValidNumber = (str: string) => {
|
|
252
|
+
return !isNaN(Number(str))
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const isValidBoolean = (str: string) => {
|
|
256
|
+
return true.toString() === str || false.toString() === str
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const isValidString = (str: string) => {
|
|
260
|
+
return !!str.match(
|
|
261
|
+
/^('[A-Za-z0-9._~()'!*:@,;+?-]*')|("[A-Za-z0-9._~()'!*:@,;+?-]*")$/
|
|
262
|
+
)
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const getOperatorByDataType = (dataType: string) => {
|
|
266
|
+
return Object.keys(operatorToDataTypeMap).filter((key) => {
|
|
267
|
+
const value = operatorToDataTypeMap[key]
|
|
268
|
+
return value.length === 0 || value.includes(dataType)
|
|
269
|
+
})
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const getOperators = (op: string[]) => op.map((o) => operators[o])
|
|
273
|
+
|
|
274
|
+
const mapWordsToExpression = (words: string[]): Expression => {
|
|
275
|
+
return {
|
|
276
|
+
field: words[0] ?? null,
|
|
277
|
+
operator: words[1] ?? null,
|
|
278
|
+
value: words[2] ?? null,
|
|
279
|
+
keyword: words[3] ?? null
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const getDataTypeByAliasKey = (
|
|
284
|
+
schema: Schema,
|
|
285
|
+
key: string
|
|
286
|
+
): string | string[] | null => {
|
|
287
|
+
const nestedKey = key.split('.')
|
|
288
|
+
|
|
289
|
+
if (nestedKey.length === 1) {
|
|
290
|
+
return (schema[nestedKey[0]] as string | string[]) ?? null
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
let value = schema[nestedKey[0]] as Schema
|
|
294
|
+
for (let i = 1; i < nestedKey.length; i++) {
|
|
295
|
+
const nextKey = nestedKey[i]
|
|
296
|
+
value = (value[nextKey] as Schema) ?? null
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return value as unknown as string | string[] | null
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const getAliasObjByAlias = (aliases: Alias[], alias: string): Alias | null => {
|
|
303
|
+
return aliases.find((el) => el.alias === alias)
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const getGenericOperators = () => {
|
|
307
|
+
return Object.keys(operatorToDataTypeMap).filter(
|
|
308
|
+
(key) => operatorToDataTypeMap[key].length === 0
|
|
309
|
+
)
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
const mapWordsToExpressions = (words: string[]): Expression[] => {
|
|
313
|
+
const _words = words.slice()
|
|
314
|
+
const expressions = [mapWordsToExpression(_words.splice(0, 4))]
|
|
315
|
+
|
|
316
|
+
while (_words.length) {
|
|
317
|
+
expressions.push(mapWordsToExpression(_words.splice(0, 4)))
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
return expressions
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const insensitive = (str: string): string => str.toLowerCase()
|
|
324
|
+
|
|
325
|
+
const getMatch = (strArr: string[], str: string) =>
|
|
326
|
+
strArr.find((val) => insensitive(val) === insensitive(str)) ?? null
|
|
327
|
+
|
|
328
|
+
const getValueMatch = (strArr: string[], str: string | number | boolean) => {
|
|
329
|
+
return (
|
|
330
|
+
strArr.find((val) =>
|
|
331
|
+
val.toString().charAt(0) === '"' && typeof str === 'string'
|
|
332
|
+
? insensitive(val.replaceAll('"', '')) === insensitive(str)
|
|
333
|
+
: val.toString() === str.toString()
|
|
334
|
+
) ?? null
|
|
335
|
+
)
|
|
336
|
+
}
|
|
337
|
+
const getMatches = (strArr: string[], str: string | number | boolean) =>
|
|
338
|
+
strArr.filter((val) =>
|
|
339
|
+
insensitive(val.toString()).includes(insensitive(str.toString()))
|
|
340
|
+
)
|
|
341
|
+
|
|
342
|
+
const isNextCharSpace = (input: string, str: string) => {
|
|
343
|
+
const insensitiveInput = insensitive(input)
|
|
344
|
+
|
|
345
|
+
return (
|
|
346
|
+
(insensitiveInput.lastIndexOf(insensitive(str)) > -1 &&
|
|
347
|
+
insensitiveInput[
|
|
348
|
+
insensitiveInput.lastIndexOf(insensitive(str)) + str.length
|
|
349
|
+
] === space) ||
|
|
350
|
+
matchStringEnd(input, str)
|
|
351
|
+
)
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const matchStringEnd = (input: string, str: string) =>
|
|
355
|
+
input.lastIndexOf(str + '" ') > -1 || input.lastIndexOf(str + "' ") > -1
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { nextTick, onBeforeUnmount } from 'vue-demi'
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Usage:
|
|
5
|
+
* registerTick(fn)
|
|
6
|
+
* registerTick(fn)
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export default function () {
|
|
10
|
+
let tickFn: Function | undefined
|
|
11
|
+
|
|
12
|
+
onBeforeUnmount(() => {
|
|
13
|
+
tickFn = void 0
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
registerTick(fn: Function) {
|
|
18
|
+
tickFn = fn
|
|
19
|
+
|
|
20
|
+
nextTick(() => {
|
|
21
|
+
if (tickFn === fn) {
|
|
22
|
+
tickFn()
|
|
23
|
+
tickFn = void 0
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
removeTick() {
|
|
29
|
+
tickFn = void 0
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { onBeforeUnmount } from 'vue-demi'
|
|
2
|
+
|
|
3
|
+
export default function () {
|
|
4
|
+
let timer: number
|
|
5
|
+
|
|
6
|
+
onBeforeUnmount(() => {
|
|
7
|
+
clearTimeout(timer)
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
registerTimeout(fn: Function, delay: number) {
|
|
12
|
+
clearTimeout(timer)
|
|
13
|
+
timer = setTimeout(fn, delay)
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
removeTimeout() {
|
|
17
|
+
clearTimeout(timer)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ref, computed, watch, nextTick, Ref } from 'vue-demi'
|
|
2
|
+
|
|
3
|
+
export const useTransitionProps = {
|
|
4
|
+
transitionDuration: {
|
|
5
|
+
type: Number,
|
|
6
|
+
default: 300
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default function (
|
|
11
|
+
props: {
|
|
12
|
+
transitionDuration: number
|
|
13
|
+
},
|
|
14
|
+
showing: Ref<boolean>
|
|
15
|
+
) {
|
|
16
|
+
const transitionState = ref(showing.value)
|
|
17
|
+
|
|
18
|
+
watch(showing, (val) => {
|
|
19
|
+
nextTick(() => {
|
|
20
|
+
transitionState.value = val
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
// return transition
|
|
25
|
+
return {
|
|
26
|
+
transitionStyle: computed(() => {
|
|
27
|
+
return {
|
|
28
|
+
'--dl-transition-duration': `${props.transitionDuration}ms`
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { reactive, onMounted, onUnmounted } from 'vue-demi'
|
|
2
|
+
|
|
3
|
+
const useWindowSize = () => {
|
|
4
|
+
const sizes = reactive({
|
|
5
|
+
width: window.innerWidth,
|
|
6
|
+
height: window.innerHeight
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
const onResize = () => {
|
|
10
|
+
sizes.width = window.innerWidth
|
|
11
|
+
sizes.height = window.innerHeight
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
onMounted(() => {
|
|
15
|
+
window.addEventListener('resize', onResize)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
onUnmounted(() => {
|
|
19
|
+
window.removeEventListener('resize', onResize)
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
return sizes
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default useWindowSize
|
package/src/index.ts
ADDED
package/src/main.ts
ADDED
package/src/models.ts
ADDED
package/src/types.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './components/DlOptionGroup/OptionGroup.types'
|
|
2
|
+
export * from './components/DlStepper/interfaces'
|
|
3
|
+
export * from './components/DlTable/types'
|
|
4
|
+
export * from './components/DlTabs/types'
|
|
5
|
+
export * from './components/DlTimePicker/types'
|
|
6
|
+
export * from './components/DlWidget/types'
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const calculateWidth = (height: number) => Math.round(height * (25 / 12))
|
|
2
|
+
|
|
3
|
+
export const calculateBorderRadius = (height: number) => height * 0.5
|
|
4
|
+
|
|
5
|
+
export const calculateMargin = (height: number) => Math.round(height / 12)
|
|
6
|
+
|
|
7
|
+
export const calculateCircleRadius = (height: number) =>
|
|
8
|
+
height - calculateMargin(height) * 2
|
|
9
|
+
|
|
10
|
+
export const calculateActiveMarginLeft = (height: number) =>
|
|
11
|
+
calculateWidth(height) -
|
|
12
|
+
calculateMargin(height) -
|
|
13
|
+
calculateCircleRadius(height)
|
|
14
|
+
|
|
15
|
+
export const hasOverflowing = (ref: any) =>
|
|
16
|
+
ref?.offsetHeight < ref?.scrollHeight ||
|
|
17
|
+
ref?.offsetWidth < ref?.scrollWidth ||
|
|
18
|
+
false
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { listenOpts } from './events'
|
|
2
|
+
import { Ref } from 'vue-demi'
|
|
3
|
+
import { portalList } from './portal'
|
|
4
|
+
|
|
5
|
+
export interface ClickOutsideEvent extends MouseEvent {
|
|
6
|
+
dlClickOutside?: boolean
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface TouchOutsideEvent extends TouchEvent {
|
|
10
|
+
dlClickOutside?: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type ClickOutsideProps = {
|
|
14
|
+
anchorEl: Ref<HTMLElement | Element | null>
|
|
15
|
+
innerRef: Ref<HTMLElement | null>
|
|
16
|
+
onClickOutside: Function
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let timer: number
|
|
20
|
+
|
|
21
|
+
const { notPassiveCapture } = listenOpts
|
|
22
|
+
const registeredList: ClickOutsideProps[] = []
|
|
23
|
+
|
|
24
|
+
function globalHandler(evt: ClickOutsideEvent | TouchOutsideEvent) {
|
|
25
|
+
clearTimeout(timer)
|
|
26
|
+
|
|
27
|
+
const target = evt.target as HTMLElement
|
|
28
|
+
|
|
29
|
+
if (
|
|
30
|
+
target === void 0 ||
|
|
31
|
+
target.nodeType === 8 ||
|
|
32
|
+
target.classList.contains('no-pointer-events') === true
|
|
33
|
+
) {
|
|
34
|
+
return
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// check last portal vm if it's
|
|
38
|
+
// a DlDialog and not in seamless mode
|
|
39
|
+
let portalIndex = portalList.length - 1
|
|
40
|
+
|
|
41
|
+
while (portalIndex >= 0) {
|
|
42
|
+
const proxy = (portalList[portalIndex] as any).$
|
|
43
|
+
|
|
44
|
+
if (proxy?.type?.name !== 'DlDialog') {
|
|
45
|
+
break
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (proxy?.props?.seamless !== true) {
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
portalIndex--
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
for (let i = registeredList.length - 1; i >= 0; i--) {
|
|
56
|
+
const state = registeredList[i]
|
|
57
|
+
|
|
58
|
+
if (
|
|
59
|
+
(state.anchorEl.value === null ||
|
|
60
|
+
state.anchorEl.value.contains(target) === false) &&
|
|
61
|
+
(target === document.body ||
|
|
62
|
+
(state.innerRef.value !== null &&
|
|
63
|
+
state.innerRef.value.contains(target) === false))
|
|
64
|
+
) {
|
|
65
|
+
// mark the event as being processed by clickOutside
|
|
66
|
+
// used to prevent refocus after menu close
|
|
67
|
+
evt.dlClickOutside = true
|
|
68
|
+
state.onClickOutside(evt)
|
|
69
|
+
} else {
|
|
70
|
+
return
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function addClickOutside(clickOutsideProps: ClickOutsideProps) {
|
|
76
|
+
registeredList.push(clickOutsideProps)
|
|
77
|
+
|
|
78
|
+
if (registeredList.length === 1) {
|
|
79
|
+
document.addEventListener('mousedown', globalHandler, notPassiveCapture)
|
|
80
|
+
document.addEventListener(
|
|
81
|
+
'touchstart',
|
|
82
|
+
globalHandler,
|
|
83
|
+
notPassiveCapture
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function removeClickOutside(clickOutsideProps: ClickOutsideProps) {
|
|
89
|
+
const index = registeredList.findIndex((h) => h === clickOutsideProps)
|
|
90
|
+
|
|
91
|
+
if (index > -1) {
|
|
92
|
+
registeredList.splice(index, 1)
|
|
93
|
+
|
|
94
|
+
if (registeredList.length === 0) {
|
|
95
|
+
clearTimeout(timer)
|
|
96
|
+
document.removeEventListener(
|
|
97
|
+
'mousedown',
|
|
98
|
+
globalHandler,
|
|
99
|
+
notPassiveCapture
|
|
100
|
+
)
|
|
101
|
+
document.removeEventListener(
|
|
102
|
+
'touchstart',
|
|
103
|
+
globalHandler,
|
|
104
|
+
notPassiveCapture
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const parseName = (string: string) => string.split('_').join(' ')
|