@dxtmisha/constructor 0.23.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/LICENSE +21 -0
- package/README.md +136 -0
- package/package.json +124 -0
- package/src/classes/CaptionInclude.ts +71 -0
- package/src/classes/DescriptionInclude.ts +70 -0
- package/src/classes/EnabledInclude.ts +56 -0
- package/src/classes/EventClickInclude.ts +138 -0
- package/src/classes/LabelHighlightInclude.ts +90 -0
- package/src/classes/LabelInclude.ts +171 -0
- package/src/classes/LabelNumberInclude.ts +70 -0
- package/src/classes/ModelInclude.ts +49 -0
- package/src/classes/PrefixInclude.ts +71 -0
- package/src/classes/SuffixInclude.ts +71 -0
- package/src/classes/field/FieldAttributesInclude.ts +100 -0
- package/src/classes/field/FieldChangeInclude.ts +52 -0
- package/src/classes/field/FieldCodeInclude.ts +69 -0
- package/src/classes/field/FieldElementInclude.ts +97 -0
- package/src/classes/field/FieldInputCheckInclude.ts +128 -0
- package/src/classes/field/FieldMatchInclude.ts +101 -0
- package/src/classes/field/FieldPatternInclude.ts +42 -0
- package/src/classes/field/FieldTypeInclude.ts +42 -0
- package/src/classes/field/FieldValidationInclude.ts +196 -0
- package/src/classes/field/FieldValueInclude.ts +318 -0
- package/src/classes/field/FieldVisibilityInclude.ts +21 -0
- package/src/constructors/Badge/Badge.ts +73 -0
- package/src/constructors/Badge/BadgeDesign.tsx +127 -0
- package/src/constructors/Badge/BadgeInclude.ts +78 -0
- package/src/constructors/Badge/basicTypes.ts +15 -0
- package/src/constructors/Badge/index.ts +5 -0
- package/src/constructors/Badge/properties.json +36 -0
- package/src/constructors/Badge/props.ts +43 -0
- package/src/constructors/Badge/style.scss +83 -0
- package/src/constructors/Badge/types.ts +47 -0
- package/src/constructors/Bars/Bars.ts +188 -0
- package/src/constructors/Bars/BarsAction.ts +57 -0
- package/src/constructors/Bars/BarsDesign.tsx +229 -0
- package/src/constructors/Bars/BarsInclude.ts +116 -0
- package/src/constructors/Bars/basicTypes.ts +40 -0
- package/src/constructors/Bars/index.ts +6 -0
- package/src/constructors/Bars/properties.json +6 -0
- package/src/constructors/Bars/props.ts +63 -0
- package/src/constructors/Bars/style.scss +18 -0
- package/src/constructors/Bars/types.ts +58 -0
- package/src/constructors/Button/Button.ts +88 -0
- package/src/constructors/Button/ButtonDesign.tsx +136 -0
- package/src/constructors/Button/ButtonInclude.ts +80 -0
- package/src/constructors/Button/basicTypes.ts +12 -0
- package/src/constructors/Button/index.ts +5 -0
- package/src/constructors/Button/properties.json +84 -0
- package/src/constructors/Button/props.ts +55 -0
- package/src/constructors/Button/style.scss +96 -0
- package/src/constructors/Button/types.ts +56 -0
- package/src/constructors/Cell/Cell.ts +127 -0
- package/src/constructors/Cell/CellDesign.tsx +203 -0
- package/src/constructors/Cell/basicTypes.ts +6 -0
- package/src/constructors/Cell/index.ts +5 -0
- package/src/constructors/Cell/properties.json +52 -0
- package/src/constructors/Cell/props.ts +61 -0
- package/src/constructors/Cell/style.scss +80 -0
- package/src/constructors/Cell/types.ts +68 -0
- package/src/constructors/Chip/Chip.ts +33 -0
- package/src/constructors/Chip/ChipDesign.tsx +26 -0
- package/src/constructors/Chip/basicTypes.ts +0 -0
- package/src/constructors/Chip/index.ts +4 -0
- package/src/constructors/Chip/properties.json +3 -0
- package/src/constructors/Chip/props.ts +44 -0
- package/src/constructors/Chip/style.scss +6 -0
- package/src/constructors/Chip/types.ts +53 -0
- package/src/constructors/Field/Field.ts +147 -0
- package/src/constructors/Field/FieldDesign.tsx +372 -0
- package/src/constructors/Field/FieldIcons.ts +99 -0
- package/src/constructors/Field/FieldInclude.ts +72 -0
- package/src/constructors/Field/FieldSize.ts +93 -0
- package/src/constructors/Field/basicTypes.ts +90 -0
- package/src/constructors/Field/index.ts +5 -0
- package/src/constructors/Field/properties.json +86 -0
- package/src/constructors/Field/props.ts +88 -0
- package/src/constructors/Field/style.scss +556 -0
- package/src/constructors/Field/types.ts +78 -0
- package/src/constructors/FieldCounter/FieldCounter.ts +75 -0
- package/src/constructors/FieldCounter/FieldCounterDesign.tsx +122 -0
- package/src/constructors/FieldCounter/FieldCounterInclude.ts +98 -0
- package/src/constructors/FieldCounter/basicTypes.ts +25 -0
- package/src/constructors/FieldCounter/index.ts +6 -0
- package/src/constructors/FieldCounter/properties.json +3 -0
- package/src/constructors/FieldCounter/props.ts +32 -0
- package/src/constructors/FieldCounter/style.scss +4 -0
- package/src/constructors/FieldCounter/types.ts +42 -0
- package/src/constructors/FieldLabel/FieldLabel.ts +93 -0
- package/src/constructors/FieldLabel/FieldLabelDesign.tsx +156 -0
- package/src/constructors/FieldLabel/FieldLabelInclude.ts +91 -0
- package/src/constructors/FieldLabel/basicTypes.ts +34 -0
- package/src/constructors/FieldLabel/index.ts +6 -0
- package/src/constructors/FieldLabel/properties.json +4 -0
- package/src/constructors/FieldLabel/props.ts +40 -0
- package/src/constructors/FieldLabel/style.scss +10 -0
- package/src/constructors/FieldLabel/types.ts +49 -0
- package/src/constructors/FieldMessage/FieldMessage.ts +79 -0
- package/src/constructors/FieldMessage/FieldMessageDesign.tsx +159 -0
- package/src/constructors/FieldMessage/FieldMessageInclude.ts +105 -0
- package/src/constructors/FieldMessage/FieldMessageMessage.ts +54 -0
- package/src/constructors/FieldMessage/basicTypes.ts +27 -0
- package/src/constructors/FieldMessage/index.ts +6 -0
- package/src/constructors/FieldMessage/properties.json +9 -0
- package/src/constructors/FieldMessage/props.ts +40 -0
- package/src/constructors/FieldMessage/style.scss +13 -0
- package/src/constructors/FieldMessage/types.ts +49 -0
- package/src/constructors/Icon/Icon.ts +105 -0
- package/src/constructors/Icon/IconDesign.tsx +157 -0
- package/src/constructors/Icon/IconInclude.ts +64 -0
- package/src/constructors/Icon/IconLiteInclude.ts +121 -0
- package/src/constructors/Icon/IconTrailingInclude.ts +106 -0
- package/src/constructors/Icon/basicTypes.ts +50 -0
- package/src/constructors/Icon/index.ts +8 -0
- package/src/constructors/Icon/properties.json +25 -0
- package/src/constructors/Icon/props.ts +54 -0
- package/src/constructors/Icon/style.scss +106 -0
- package/src/constructors/Icon/types.ts +46 -0
- package/src/constructors/Image/Image.ts +184 -0
- package/src/constructors/Image/ImageAdaptiveGroup.ts +230 -0
- package/src/constructors/Image/ImageAdaptiveItem.ts +295 -0
- package/src/constructors/Image/ImageBackground.ts +127 -0
- package/src/constructors/Image/ImageCalculation.ts +184 -0
- package/src/constructors/Image/ImageCalculationList.ts +61 -0
- package/src/constructors/Image/ImageCoordinator.ts +104 -0
- package/src/constructors/Image/ImageData.ts +99 -0
- package/src/constructors/Image/ImageDesign.tsx +137 -0
- package/src/constructors/Image/ImageFile.ts +137 -0
- package/src/constructors/Image/ImageInclude.ts +53 -0
- package/src/constructors/Image/ImagePdf.ts +44 -0
- package/src/constructors/Image/ImagePosition.ts +49 -0
- package/src/constructors/Image/ImageType.ts +83 -0
- package/src/constructors/Image/basicTypes.ts +70 -0
- package/src/constructors/Image/index.ts +5 -0
- package/src/constructors/Image/properties.json +17 -0
- package/src/constructors/Image/props.ts +66 -0
- package/src/constructors/Image/style.scss +77 -0
- package/src/constructors/Image/types.ts +49 -0
- package/src/constructors/List/List.ts +267 -0
- package/src/constructors/List/ListControl.ts +194 -0
- package/src/constructors/List/ListDesign.tsx +382 -0
- package/src/constructors/List/ListFocus.ts +196 -0
- package/src/constructors/List/ListGo.ts +283 -0
- package/src/constructors/List/ListSearch.ts +113 -0
- package/src/constructors/List/basicTypes.ts +3 -0
- package/src/constructors/List/index.ts +5 -0
- package/src/constructors/List/properties.json +16 -0
- package/src/constructors/List/props.ts +76 -0
- package/src/constructors/List/style.scss +36 -0
- package/src/constructors/List/types.ts +66 -0
- package/src/constructors/ListGroup/ListGroup.ts +53 -0
- package/src/constructors/ListGroup/ListGroupDesign.tsx +180 -0
- package/src/constructors/ListGroup/ListGroupOpen.ts +56 -0
- package/src/constructors/ListGroup/basicTypes.ts +3 -0
- package/src/constructors/ListGroup/index.ts +5 -0
- package/src/constructors/ListGroup/properties.json +15 -0
- package/src/constructors/ListGroup/props.ts +30 -0
- package/src/constructors/ListGroup/style.scss +18 -0
- package/src/constructors/ListGroup/types.ts +51 -0
- package/src/constructors/ListItem/ListItem.ts +115 -0
- package/src/constructors/ListItem/ListItemDesign.tsx +196 -0
- package/src/constructors/ListItem/basicTypes.ts +3 -0
- package/src/constructors/ListItem/index.ts +5 -0
- package/src/constructors/ListItem/properties.json +52 -0
- package/src/constructors/ListItem/props.ts +78 -0
- package/src/constructors/ListItem/style.scss +152 -0
- package/src/constructors/ListItem/types.ts +78 -0
- package/src/constructors/ListMenu/ListMenu.ts +52 -0
- package/src/constructors/ListMenu/ListMenuDesign.tsx +127 -0
- package/src/constructors/ListMenu/basicTypes.ts +3 -0
- package/src/constructors/ListMenu/index.ts +5 -0
- package/src/constructors/ListMenu/properties.json +19 -0
- package/src/constructors/ListMenu/props.ts +34 -0
- package/src/constructors/ListMenu/style.scss +5 -0
- package/src/constructors/ListMenu/types.ts +54 -0
- package/src/constructors/Mask/Mask.ts +321 -0
- package/src/constructors/Mask/MaskBuffer.ts +89 -0
- package/src/constructors/Mask/MaskCharacter.ts +192 -0
- package/src/constructors/Mask/MaskCharacterLength.ts +40 -0
- package/src/constructors/Mask/MaskData.ts +287 -0
- package/src/constructors/Mask/MaskDate.ts +157 -0
- package/src/constructors/Mask/MaskDesign.tsx +217 -0
- package/src/constructors/Mask/MaskEmit.ts +140 -0
- package/src/constructors/Mask/MaskEvent.ts +347 -0
- package/src/constructors/Mask/MaskFocus.ts +49 -0
- package/src/constructors/Mask/MaskFormat.ts +216 -0
- package/src/constructors/Mask/MaskItem.ts +218 -0
- package/src/constructors/Mask/MaskMatch.ts +73 -0
- package/src/constructors/Mask/MaskPattern.ts +123 -0
- package/src/constructors/Mask/MaskRight.ts +43 -0
- package/src/constructors/Mask/MaskRubber.ts +156 -0
- package/src/constructors/Mask/MaskRubberItem.ts +96 -0
- package/src/constructors/Mask/MaskRubberTransition.ts +50 -0
- package/src/constructors/Mask/MaskSelection.ts +208 -0
- package/src/constructors/Mask/MaskSpecial.ts +179 -0
- package/src/constructors/Mask/MaskType.ts +103 -0
- package/src/constructors/Mask/MaskValidation.ts +102 -0
- package/src/constructors/Mask/MaskValue.ts +225 -0
- package/src/constructors/Mask/MaskValueBasic.ts +87 -0
- package/src/constructors/Mask/MaskView.ts +169 -0
- package/src/constructors/Mask/basicTypes.ts +49 -0
- package/src/constructors/Mask/index.ts +5 -0
- package/src/constructors/Mask/properties.json +29 -0
- package/src/constructors/Mask/props.ts +70 -0
- package/src/constructors/Mask/style.scss +104 -0
- package/src/constructors/Mask/types.ts +71 -0
- package/src/constructors/Menu/Menu.ts +179 -0
- package/src/constructors/Menu/MenuDesign.tsx +244 -0
- package/src/constructors/Menu/MenuInclude.ts +110 -0
- package/src/constructors/Menu/MenuRequest.ts +101 -0
- package/src/constructors/Menu/MenuSearch.ts +49 -0
- package/src/constructors/Menu/MenuValue.ts +73 -0
- package/src/constructors/Menu/MenuWindow.ts +89 -0
- package/src/constructors/Menu/basicTypes.ts +41 -0
- package/src/constructors/Menu/index.ts +6 -0
- package/src/constructors/Menu/properties.json +17 -0
- package/src/constructors/Menu/props.ts +79 -0
- package/src/constructors/Menu/style.scss +17 -0
- package/src/constructors/Menu/types.ts +79 -0
- package/src/constructors/MotionTransform/MotionTransform.ts +87 -0
- package/src/constructors/MotionTransform/MotionTransformClassesInclude.ts +38 -0
- package/src/constructors/MotionTransform/MotionTransformDesign.tsx +242 -0
- package/src/constructors/MotionTransform/MotionTransformElement.ts +220 -0
- package/src/constructors/MotionTransform/MotionTransformEvent.ts +118 -0
- package/src/constructors/MotionTransform/MotionTransformGo.ts +47 -0
- package/src/constructors/MotionTransform/MotionTransformInclude.ts +123 -0
- package/src/constructors/MotionTransform/MotionTransformSize.ts +97 -0
- package/src/constructors/MotionTransform/MotionTransformState.ts +250 -0
- package/src/constructors/MotionTransform/basicTypes.ts +121 -0
- package/src/constructors/MotionTransform/index.ts +7 -0
- package/src/constructors/MotionTransform/properties.json +35 -0
- package/src/constructors/MotionTransform/props.ts +50 -0
- package/src/constructors/MotionTransform/style.scss +180 -0
- package/src/constructors/MotionTransform/types.ts +86 -0
- package/src/constructors/Progress/Progress.ts +184 -0
- package/src/constructors/Progress/ProgressDesign.tsx +175 -0
- package/src/constructors/Progress/ProgressInclude.ts +67 -0
- package/src/constructors/Progress/basicTypes.ts +12 -0
- package/src/constructors/Progress/index.ts +6 -0
- package/src/constructors/Progress/properties.json +47 -0
- package/src/constructors/Progress/props.ts +54 -0
- package/src/constructors/Progress/style.scss +374 -0
- package/src/constructors/Progress/types.ts +43 -0
- package/src/constructors/Ripple/Ripple.ts +46 -0
- package/src/constructors/Ripple/RippleDesign.tsx +112 -0
- package/src/constructors/Ripple/RippleInclude.ts +39 -0
- package/src/constructors/Ripple/RippleItem.ts +62 -0
- package/src/constructors/Ripple/basicTypes.ts +3 -0
- package/src/constructors/Ripple/index.ts +6 -0
- package/src/constructors/Ripple/properties.json +9 -0
- package/src/constructors/Ripple/props.ts +28 -0
- package/src/constructors/Ripple/style.scss +62 -0
- package/src/constructors/Ripple/types.ts +41 -0
- package/src/constructors/Scrollbar/Scrollbar.ts +66 -0
- package/src/constructors/Scrollbar/ScrollbarBorder.ts +243 -0
- package/src/constructors/Scrollbar/ScrollbarDesign.tsx +126 -0
- package/src/constructors/Scrollbar/ScrollbarInclude.ts +80 -0
- package/src/constructors/Scrollbar/basicTypes.ts +42 -0
- package/src/constructors/Scrollbar/index.ts +5 -0
- package/src/constructors/Scrollbar/properties.json +33 -0
- package/src/constructors/Scrollbar/props.ts +37 -0
- package/src/constructors/Scrollbar/style.scss +117 -0
- package/src/constructors/Scrollbar/types.ts +52 -0
- package/src/constructors/Skeleton/Skeleton.ts +86 -0
- package/src/constructors/Skeleton/SkeletonDesign.tsx +117 -0
- package/src/constructors/Skeleton/SkeletonInclude.ts +61 -0
- package/src/constructors/Skeleton/basicTypes.ts +16 -0
- package/src/constructors/Skeleton/const.ts +1 -0
- package/src/constructors/Skeleton/index.ts +6 -0
- package/src/constructors/Skeleton/properties.json +24 -0
- package/src/constructors/Skeleton/props.ts +28 -0
- package/src/constructors/Skeleton/style.scss +112 -0
- package/src/constructors/Skeleton/types.ts +46 -0
- package/src/constructors/Window/Window.ts +212 -0
- package/src/constructors/Window/WindowClasses.ts +180 -0
- package/src/constructors/Window/WindowClassesInclude.ts +39 -0
- package/src/constructors/Window/WindowClient.ts +93 -0
- package/src/constructors/Window/WindowCoordinates.ts +257 -0
- package/src/constructors/Window/WindowDesign.tsx +278 -0
- package/src/constructors/Window/WindowElement.ts +84 -0
- package/src/constructors/Window/WindowEmit.ts +52 -0
- package/src/constructors/Window/WindowEvent.ts +157 -0
- package/src/constructors/Window/WindowFlash.ts +70 -0
- package/src/constructors/Window/WindowHook.ts +110 -0
- package/src/constructors/Window/WindowInclude.ts +134 -0
- package/src/constructors/Window/WindowOpen.ts +292 -0
- package/src/constructors/Window/WindowOrigin.ts +85 -0
- package/src/constructors/Window/WindowPersistent.ts +89 -0
- package/src/constructors/Window/WindowPosition.ts +358 -0
- package/src/constructors/Window/WindowStatic.ts +102 -0
- package/src/constructors/Window/WindowStatus.ts +138 -0
- package/src/constructors/Window/WindowStyles.ts +78 -0
- package/src/constructors/Window/WindowVerification.ts +287 -0
- package/src/constructors/Window/basicTypes.ts +186 -0
- package/src/constructors/Window/index.ts +7 -0
- package/src/constructors/Window/properties.json +236 -0
- package/src/constructors/Window/props.ts +88 -0
- package/src/constructors/Window/style.scss +262 -0
- package/src/constructors/Window/types.ts +124 -0
- package/src/functions/getClassTegAStatic.ts +8 -0
- package/src/library.ts +36 -0
- package/src/types/captionTypes.ts +15 -0
- package/src/types/descriptionTypes.ts +15 -0
- package/src/types/enabledTypes.ts +9 -0
- package/src/types/eventClickTypes.ts +51 -0
- package/src/types/fieldTypes.ts +282 -0
- package/src/types/labelTypes.ts +30 -0
- package/src/types/modelTypes.ts +23 -0
- package/src/types/prefixTypes.ts +15 -0
- package/src/types/suffixTypes.ts +15 -0
- package/src/vite-env.d.ts +1 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { computed, type Ref, ref } from 'vue'
|
|
2
|
+
import {
|
|
3
|
+
goScroll,
|
|
4
|
+
type ListDataItem,
|
|
5
|
+
type ListSelectedItem
|
|
6
|
+
} from '@dxtmisha/functional'
|
|
7
|
+
import type { ListProps } from './props'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Class for working with element focus.
|
|
11
|
+
*
|
|
12
|
+
* Класс для работы с фокусировкой элемента.
|
|
13
|
+
*/
|
|
14
|
+
export class ListFocus {
|
|
15
|
+
readonly item = ref<ListDataItem>()
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Constructor
|
|
19
|
+
* @param props input data/ входные данные
|
|
20
|
+
* @param element input element/ элемент ввода
|
|
21
|
+
* @param listId unique list identifier/ уникальный идентификатор списка
|
|
22
|
+
*/
|
|
23
|
+
constructor(
|
|
24
|
+
protected readonly props: ListProps,
|
|
25
|
+
protected readonly element: Ref<HTMLElement | undefined>,
|
|
26
|
+
protected readonly listId: number
|
|
27
|
+
) {
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Returns the value of the selected element/ Возвращает значение выбранного элемента */
|
|
31
|
+
readonly focus = computed<ListSelectedItem | undefined>(() => this.item.value?.index ?? this.props.focus)
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Returns the selected element.
|
|
35
|
+
*
|
|
36
|
+
* Возвращает выбранный элемент.
|
|
37
|
+
* @param index element index/ индекс элемента
|
|
38
|
+
*/
|
|
39
|
+
isElement(index?: string): boolean {
|
|
40
|
+
return Boolean(this.getElement(index))
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Checks if the element is an item.
|
|
45
|
+
*
|
|
46
|
+
* Проверяет, является ли элемент элементом.
|
|
47
|
+
*/
|
|
48
|
+
isItem(): boolean {
|
|
49
|
+
return this.item.value?.type === 'item'
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Checks if the element is a group.
|
|
54
|
+
*
|
|
55
|
+
* Проверяет, является ли элемент группой.
|
|
56
|
+
*/
|
|
57
|
+
isGroup(): boolean {
|
|
58
|
+
return this.item.value?.type === 'group'
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Checks if the element is a menu.
|
|
63
|
+
*
|
|
64
|
+
* Проверяет, является ли элемент меню.
|
|
65
|
+
*/
|
|
66
|
+
isMenu(): boolean {
|
|
67
|
+
return this.item.value?.type === 'menu'
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Checks if the group or menu is open.
|
|
72
|
+
*
|
|
73
|
+
* Проверяет, открыта ли группа или меню.
|
|
74
|
+
*/
|
|
75
|
+
isOpen(): boolean {
|
|
76
|
+
const element = this.getElement()
|
|
77
|
+
|
|
78
|
+
if (
|
|
79
|
+
element
|
|
80
|
+
&& (this.isGroup() || this.isMenu())
|
|
81
|
+
) {
|
|
82
|
+
return element.dataset.status === 'open'
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return false
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Returns the selected element.
|
|
90
|
+
*
|
|
91
|
+
* Возвращает выбранный элемент.
|
|
92
|
+
*/
|
|
93
|
+
get(): ListDataItem | undefined {
|
|
94
|
+
return this.item.value
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Returns the selector for the desired element by its index.
|
|
99
|
+
*
|
|
100
|
+
* Возвращает селектор нужного элемента по его индексу.
|
|
101
|
+
* @param index element index/ индекс элемента
|
|
102
|
+
*/
|
|
103
|
+
getSelector(index?: string): string {
|
|
104
|
+
return `[data-list-id="${this.listId}"][data-value="${index ?? this.item.value?.index}"]`
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Returns the HTML element of the selected item.
|
|
109
|
+
*
|
|
110
|
+
* Возвращает HTML элемент выбранного элемента.
|
|
111
|
+
* @param index element index/ индекс элемента
|
|
112
|
+
*/
|
|
113
|
+
getElement(index?: string): HTMLDivElement | undefined {
|
|
114
|
+
return document.querySelector<HTMLDivElement>(this.getSelector(index)) ?? undefined
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Changes the selected element.
|
|
119
|
+
*
|
|
120
|
+
* Изменяет выбранный элемент.
|
|
121
|
+
* @param item new value/ новое значение
|
|
122
|
+
*/
|
|
123
|
+
set(item: ListDataItem | undefined): this {
|
|
124
|
+
if (this.item.value !== item) {
|
|
125
|
+
this.item.value = item
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return this
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Resets the selected element.
|
|
133
|
+
*
|
|
134
|
+
* Сбрасывает выбранный элемент.
|
|
135
|
+
*/
|
|
136
|
+
reset(): this {
|
|
137
|
+
this.set(undefined)
|
|
138
|
+
return this
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Performs a click on the selected element.
|
|
143
|
+
*
|
|
144
|
+
* Выполняет клик на выбранном элементе.
|
|
145
|
+
*/
|
|
146
|
+
click() {
|
|
147
|
+
this.getElement()?.click()
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Moves to the value in focus.
|
|
152
|
+
*
|
|
153
|
+
* Перемещает к значению в фокусе.
|
|
154
|
+
*/
|
|
155
|
+
toElementFocus(): boolean {
|
|
156
|
+
if (this.item.value) {
|
|
157
|
+
const element = this.getElement()
|
|
158
|
+
|
|
159
|
+
if (element) {
|
|
160
|
+
this.toElement(element)
|
|
161
|
+
|
|
162
|
+
return true
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return false
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Scrolls to the desired element by its index.
|
|
171
|
+
*
|
|
172
|
+
* Скроллирует к нужному элементу по его индексу.
|
|
173
|
+
* @param index element index/ индекс элемента
|
|
174
|
+
*/
|
|
175
|
+
toElementSelected(index: string): this {
|
|
176
|
+
this.toElement(this.getElement(index))
|
|
177
|
+
return this
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Scrolls to the desired element.
|
|
182
|
+
*
|
|
183
|
+
* Скроллирует к нужному элементу.
|
|
184
|
+
* @param element the element to scroll to/ элемент, до которого надо проскроллить
|
|
185
|
+
*/
|
|
186
|
+
protected toElement(element?: HTMLElement) {
|
|
187
|
+
const selector = '*[data-window-body]'
|
|
188
|
+
|
|
189
|
+
if (
|
|
190
|
+
element
|
|
191
|
+
&& element.closest(selector)
|
|
192
|
+
) {
|
|
193
|
+
goScroll(selector, element)
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ConstrEmit,
|
|
3
|
+
isSelected,
|
|
4
|
+
ListData
|
|
5
|
+
} from '@dxtmisha/functional'
|
|
6
|
+
|
|
7
|
+
import { ListFocus } from './ListFocus'
|
|
8
|
+
|
|
9
|
+
import type { ListProps } from './props'
|
|
10
|
+
import type { ListEmits } from './types'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Class for working with element focus.
|
|
14
|
+
*
|
|
15
|
+
* Класс для работы с фокусировкой элемента.
|
|
16
|
+
*/
|
|
17
|
+
export class ListGo {
|
|
18
|
+
protected index: number = -1
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Constructor
|
|
22
|
+
* @param props input data/ входные данные
|
|
23
|
+
* @param focus object of the class for working with focus/ объект класса для работы с фокусировкой
|
|
24
|
+
* @param data object of the class for working with the list/ объект класса для работы со списком
|
|
25
|
+
* @param emits the function is called when an event is triggered/ функция вызывается, когда срабатывает событие
|
|
26
|
+
*/
|
|
27
|
+
constructor(
|
|
28
|
+
protected readonly props: ListProps,
|
|
29
|
+
protected readonly focus: ListFocus,
|
|
30
|
+
protected readonly data: ListData,
|
|
31
|
+
protected readonly emits?: ConstrEmit<ListEmits>
|
|
32
|
+
) {
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Changing the index in focus by the number in the array.
|
|
37
|
+
*
|
|
38
|
+
* Изменение значения в фокусе по номеру в массиве.
|
|
39
|
+
* @param index number in the array/ номер в массиве
|
|
40
|
+
*/
|
|
41
|
+
set(index: number): boolean {
|
|
42
|
+
if (this.index !== index) {
|
|
43
|
+
if (index < 0) {
|
|
44
|
+
this.reset()
|
|
45
|
+
} else {
|
|
46
|
+
this.setByIndex(index)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
this.focus.toElementFocus()
|
|
50
|
+
return true
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return false
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Changes the selected element.
|
|
58
|
+
*
|
|
59
|
+
* Изменяет выбранный элемент.
|
|
60
|
+
* @param value new value/ новое значение
|
|
61
|
+
*/
|
|
62
|
+
preparation(value: any) {
|
|
63
|
+
const map = this.data.map.value
|
|
64
|
+
const index = map.findIndex(item => isSelected(item.index, value))
|
|
65
|
+
|
|
66
|
+
this.reset()
|
|
67
|
+
|
|
68
|
+
if (index) {
|
|
69
|
+
this.index = index
|
|
70
|
+
|
|
71
|
+
if (map?.[index]) {
|
|
72
|
+
this.focus.toElementSelected(map[index].index)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Scrolls the element to the selected element
|
|
79
|
+
*
|
|
80
|
+
* Прокрутить элемент до выбранного элемента
|
|
81
|
+
*/
|
|
82
|
+
preparationBySelected() {
|
|
83
|
+
if (this.props.selected) {
|
|
84
|
+
requestAnimationFrame(() => this.preparation(this.props.selected))
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Moves the selected value back.
|
|
90
|
+
*
|
|
91
|
+
* Перемещает выбранное значение назад.
|
|
92
|
+
*/
|
|
93
|
+
previous() {
|
|
94
|
+
if (this.isFirstByParent()) {
|
|
95
|
+
return
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
this.setByIndex(this.index - 1)
|
|
99
|
+
|
|
100
|
+
if (!this.focus.toElementFocus()) {
|
|
101
|
+
this.previous()
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Moves the selected value forward.
|
|
107
|
+
*
|
|
108
|
+
* Перемещает выбранное значение вперед.
|
|
109
|
+
*/
|
|
110
|
+
next() {
|
|
111
|
+
if (this.isLastByParent()) {
|
|
112
|
+
return
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
this.setByIndex(this.index + 1)
|
|
116
|
+
|
|
117
|
+
if (!this.focus.toElementFocus()) {
|
|
118
|
+
this.next()
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Reset all records to the initial state.
|
|
124
|
+
*
|
|
125
|
+
* Сброс всех записей до начального состояния.
|
|
126
|
+
*/
|
|
127
|
+
reset() {
|
|
128
|
+
this.index = -1
|
|
129
|
+
this.focus.reset()
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Opens the window if the element is in it.
|
|
134
|
+
*
|
|
135
|
+
* Открывает окно, если элемент в нем.
|
|
136
|
+
*/
|
|
137
|
+
open(): void {
|
|
138
|
+
if (
|
|
139
|
+
this.focus.isGroup()
|
|
140
|
+
|| this.focus.isMenu()
|
|
141
|
+
) {
|
|
142
|
+
this.focus.click()
|
|
143
|
+
this.nextByType()
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Closes the window if the element is in it.
|
|
149
|
+
*
|
|
150
|
+
* Закрывает окно, если элемент в нем.
|
|
151
|
+
*/
|
|
152
|
+
close(): void {
|
|
153
|
+
const item = this.getMainItem()
|
|
154
|
+
|
|
155
|
+
if (item) {
|
|
156
|
+
item.click()
|
|
157
|
+
|
|
158
|
+
const focus = this.data.getItemByIndex(item.dataset.value)
|
|
159
|
+
|
|
160
|
+
if (focus) {
|
|
161
|
+
this.set(focus.key)
|
|
162
|
+
this.focus.set(focus.item)
|
|
163
|
+
}
|
|
164
|
+
} else {
|
|
165
|
+
this.emits?.('close')
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Stops the event.
|
|
171
|
+
*
|
|
172
|
+
* Останавливает событие.
|
|
173
|
+
*/
|
|
174
|
+
stop() {
|
|
175
|
+
this.focus.reset()
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Checks if the next element is in the same window.
|
|
180
|
+
*
|
|
181
|
+
* Проверяет, находится ли следующий элемент в том же окне.
|
|
182
|
+
*/
|
|
183
|
+
protected isFirstByParent(): boolean {
|
|
184
|
+
const parent = this.focus.item.value?.parent
|
|
185
|
+
|
|
186
|
+
if (
|
|
187
|
+
parent
|
|
188
|
+
&& this.focus.isElement()
|
|
189
|
+
) {
|
|
190
|
+
return this.data.getFirstItemByParent(parent)?.index === this.focus.item.value?.index
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return false
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Checks if the next element is in the same window.
|
|
198
|
+
*
|
|
199
|
+
* Проверяет, находится ли следующий элемент в том же окне.
|
|
200
|
+
*/
|
|
201
|
+
protected isLastByParent(): boolean {
|
|
202
|
+
const parent = this.focus.item.value?.parent
|
|
203
|
+
|
|
204
|
+
if (
|
|
205
|
+
parent
|
|
206
|
+
&& this.focus.isElement()
|
|
207
|
+
) {
|
|
208
|
+
return this.data.getLastItemByParent(parent)?.index === this.focus.item.value?.index
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return false
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Checks if the element is in a window.
|
|
216
|
+
*
|
|
217
|
+
* Проверяет, находится ли элемент в окне.
|
|
218
|
+
*/
|
|
219
|
+
protected getMainItem(): HTMLDivElement | undefined {
|
|
220
|
+
const parent = this.focus.item.value?.parent
|
|
221
|
+
|
|
222
|
+
if (
|
|
223
|
+
parent
|
|
224
|
+
&& !this.focus.isOpen()
|
|
225
|
+
) {
|
|
226
|
+
return this.focus.getElement(parent)
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return undefined
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Changing the index in focus by the number in the array.
|
|
234
|
+
*
|
|
235
|
+
* Изменение значения в фокусе по номеру в массиве.
|
|
236
|
+
* @param index number in the array/ номер в массиве
|
|
237
|
+
*/
|
|
238
|
+
protected setByIndex(index: number): void {
|
|
239
|
+
const length = this.data.getLengthByMap()
|
|
240
|
+
|
|
241
|
+
if (index >= length) {
|
|
242
|
+
this.index = 0
|
|
243
|
+
} else if (index < 0) {
|
|
244
|
+
this.index = length - 1
|
|
245
|
+
} else {
|
|
246
|
+
this.index = index
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const item = this.data.map.value[this.index]
|
|
250
|
+
|
|
251
|
+
if (
|
|
252
|
+
item
|
|
253
|
+
&& (
|
|
254
|
+
item.type === 'item'
|
|
255
|
+
|| item.type === 'group'
|
|
256
|
+
|| item.type === 'menu'
|
|
257
|
+
)
|
|
258
|
+
) {
|
|
259
|
+
this.focus.set(item)
|
|
260
|
+
} else {
|
|
261
|
+
this.focus.reset()
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Moves the selected value forward by type.
|
|
267
|
+
*
|
|
268
|
+
* Перемещает выбранное значение вперед по типу.
|
|
269
|
+
*/
|
|
270
|
+
protected nextByType(): void {
|
|
271
|
+
this.setByIndex(this.index + 1)
|
|
272
|
+
|
|
273
|
+
if (
|
|
274
|
+
this.focus.isItem()
|
|
275
|
+
|| this.focus.isGroup()
|
|
276
|
+
|| this.focus.isMenu()
|
|
277
|
+
) {
|
|
278
|
+
return
|
|
279
|
+
} else {
|
|
280
|
+
this.nextByType()
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { computed, ref } from 'vue'
|
|
2
|
+
import { isFilled } from '@dxtmisha/functional'
|
|
3
|
+
|
|
4
|
+
import type { ListProps } from './props'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Class for working with search.
|
|
8
|
+
*
|
|
9
|
+
* Класс для работы с поиском.
|
|
10
|
+
*/
|
|
11
|
+
export class ListSearch {
|
|
12
|
+
readonly item = ref<string>()
|
|
13
|
+
|
|
14
|
+
protected timeout?: any
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Constructor
|
|
18
|
+
* @param props input data/ входные данные
|
|
19
|
+
*/
|
|
20
|
+
constructor(
|
|
21
|
+
protected readonly props: ListProps
|
|
22
|
+
) {
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Current search string/ Текущая строка поиска */
|
|
26
|
+
readonly highlight = computed<string | undefined>(() => this.item.value ?? this.props.highlight)
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Adds a new character to the search.
|
|
30
|
+
*
|
|
31
|
+
* Добавляет новый символ к поиску.
|
|
32
|
+
* @param char new character/ новый символ
|
|
33
|
+
*/
|
|
34
|
+
add(char: string) {
|
|
35
|
+
this.addChar(char)
|
|
36
|
+
.makeReset()
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Sets the search string.
|
|
41
|
+
*
|
|
42
|
+
* Устанавливает строку поиска.
|
|
43
|
+
* @param value new value/ новое значение
|
|
44
|
+
*/
|
|
45
|
+
set(value?: string) {
|
|
46
|
+
const data = this.getValue(value)
|
|
47
|
+
|
|
48
|
+
if (this.item.value !== data) {
|
|
49
|
+
this.item.value = data
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Resets the search string.
|
|
55
|
+
*
|
|
56
|
+
* Сбрасывает строку поиска.
|
|
57
|
+
*/
|
|
58
|
+
reset(): this {
|
|
59
|
+
this.set()
|
|
60
|
+
return this
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Returns a processed value.
|
|
65
|
+
*
|
|
66
|
+
* Возвращает обработанное значение.
|
|
67
|
+
* @param value source value/ исходное значение
|
|
68
|
+
*/
|
|
69
|
+
protected getValue(value?: string): string | undefined {
|
|
70
|
+
if (isFilled(value)) {
|
|
71
|
+
return value.trim()
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return undefined
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Appends a character to the search string.
|
|
79
|
+
*
|
|
80
|
+
* Добавляет символ к строке поиска.
|
|
81
|
+
* @param char new character/ новый символ
|
|
82
|
+
*/
|
|
83
|
+
protected addChar(char: string): this {
|
|
84
|
+
if (
|
|
85
|
+
this.item.value
|
|
86
|
+
&& this.timeout
|
|
87
|
+
) {
|
|
88
|
+
this.item.value += char
|
|
89
|
+
} else {
|
|
90
|
+
this.item.value = char
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return this
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Schedules reset to the initial state after a delay.
|
|
98
|
+
*
|
|
99
|
+
* Планирует сброс к исходному состоянию после задержки.
|
|
100
|
+
*/
|
|
101
|
+
protected makeReset(): this {
|
|
102
|
+
if (this.timeout) {
|
|
103
|
+
clearTimeout(this.timeout)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
this.timeout = setTimeout(
|
|
107
|
+
() => (this.timeout = undefined),
|
|
108
|
+
2000
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
return this
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ConstrBind,
|
|
3
|
+
ListRecord,
|
|
4
|
+
ListSelectedItem,
|
|
5
|
+
ListSelectedList
|
|
6
|
+
} from '@dxtmisha/functional'
|
|
7
|
+
import type { IconPropsBasic, IconValue } from '../Icon'
|
|
8
|
+
import type { ListItemPropsBasic } from '../ListItem'
|
|
9
|
+
|
|
10
|
+
interface ListPropsToken {
|
|
11
|
+
// :type [!] System label / Системная метка
|
|
12
|
+
axis?: 'x' | 'y'
|
|
13
|
+
divider?: boolean
|
|
14
|
+
// :type [!] System label / Системная метка
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ListPropsBasic<
|
|
18
|
+
Icon extends IconPropsBasic = IconPropsBasic,
|
|
19
|
+
ListItem extends ListItemPropsBasic = ListItemPropsBasic
|
|
20
|
+
> {
|
|
21
|
+
// Status
|
|
22
|
+
focus?: ListSelectedItem
|
|
23
|
+
selected?: ListSelectedList
|
|
24
|
+
disabled?: boolean
|
|
25
|
+
lite?: boolean
|
|
26
|
+
|
|
27
|
+
// Value
|
|
28
|
+
list?: ListRecord<ListItem>
|
|
29
|
+
liteThreshold?: number
|
|
30
|
+
highlight?: string
|
|
31
|
+
highlightLengthStart?: number
|
|
32
|
+
|
|
33
|
+
keyLabel?: string
|
|
34
|
+
keyValue?: string
|
|
35
|
+
|
|
36
|
+
// Style
|
|
37
|
+
tag?: 'div' | 'button' | 'a' | 'span' | string
|
|
38
|
+
|
|
39
|
+
axis?: 'x' | 'y'
|
|
40
|
+
divider?: boolean
|
|
41
|
+
|
|
42
|
+
itemAttrs?: ConstrBind<ListItem>
|
|
43
|
+
itemManagementAttrs?: ConstrBind<ListItem>
|
|
44
|
+
itemGroupAttrs?: ConstrBind<ListItem>
|
|
45
|
+
itemMenuAttrs?: ConstrBind<ListItem>
|
|
46
|
+
|
|
47
|
+
iconArrowDown?: IconValue<Icon>
|
|
48
|
+
iconArrowRight?: IconValue<Icon>
|
|
49
|
+
|
|
50
|
+
// Technical
|
|
51
|
+
control?: boolean
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Type describing incoming properties.
|
|
56
|
+
*
|
|
57
|
+
* Тип, описывающий входящие свойства.
|
|
58
|
+
*/
|
|
59
|
+
export interface ListProps extends ListPropsBasic, ListPropsToken {
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Default value for property.
|
|
64
|
+
*
|
|
65
|
+
* Значение по умолчанию для свойства.
|
|
66
|
+
*/
|
|
67
|
+
export const defaultsList = {
|
|
68
|
+
keyLabel: 'label',
|
|
69
|
+
keyValue: 'value',
|
|
70
|
+
tag: 'div',
|
|
71
|
+
...{
|
|
72
|
+
// :default [!] System label / Системная метка
|
|
73
|
+
axis: 'y'
|
|
74
|
+
// :default [!] System label / Системная метка
|
|
75
|
+
}
|
|
76
|
+
}
|