adata-ui 2.1.40-beta.18 → 2.1.40-beta.19
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/.playground/app.vue +102 -0
- package/assets/styles/index.scss +67 -5
- package/components/elements/a-select-row/ASelectRowV2.vue +214 -0
- package/components/elements/a-select-row/index.vue +3 -5
- package/components/elements/accordion/AAccordion.vue +5 -3
- package/components/elements/accordion/AAccordionGroup/AAccordionGroup.vue +3 -3
- package/components/elements/alert/AAlert.vue +34 -47
- package/components/elements/bg-block/ABgBlock.vue +1 -1
- package/components/elements/button/AButton.vue +3 -3
- package/components/elements/button/AButtonV2.vue +133 -0
- package/components/elements/button-login/index.vue +6 -10
- package/components/elements/chip-wrapper/AChipWrapper.vue +1 -1
- package/components/elements/chips/AChips.vue +2 -2
- package/components/elements/companies/AOurClients.vue +3 -1
- package/components/elements/curve-block-v2/ACurveBlockV2.vue +85 -0
- package/components/elements/digit-badge/ADigitBadge.vue +24 -22
- package/components/elements/feature-description/AFeatureDescription.vue +1 -1
- package/components/elements/leave-note/ALeaveNote.vue +39 -18
- package/components/elements/pagination/APagination.vue +7 -7
- package/components/elements/segmented/ASegmentedV2.vue +151 -0
- package/components/elements/select/ASelect.vue +4 -4
- package/components/elements/select/ASelectMobile.vue +2 -2
- package/components/elements/select/ASelectV2.vue +588 -0
- package/components/elements/select/ui/select-button.vue +1 -1
- package/components/elements/show-more/AShowMoreV2.vue +26 -0
- package/components/elements/slider/ASlider.vue +174 -0
- package/components/elements/slider/ASliderItem.vue +31 -0
- package/components/elements/slider/types.ts +21 -0
- package/components/elements/star-rating/AStarRating.vue +12 -4
- package/components/elements/status-badge/AStatusBadge.vue +91 -44
- package/components/elements/step-slider/AStepSliderColCard.vue +232 -0
- package/components/elements/step-slider/AStepSliderColNumber.vue +178 -0
- package/components/elements/table/ATable.vue +1 -1
- package/components/elements/table/table.config.ts +2 -2
- package/components/elements/tree-select/ATreeSelect.vue +97 -113
- package/components/elements/tree-select/TreeService.ts +142 -207
- package/components/elements/tree-select/components/ATreeSelectNode.vue +104 -0
- package/components/elements/tree-select/types.ts +40 -11
- package/components/elements/tree-select/utils.ts +30 -0
- package/components/elements/tree-select-modal/ATreeSelectModal.vue +217 -0
- package/components/features/color-mode/AColorMode.client.vue +74 -32
- package/components/features/dropdown/ADropdownV2.vue +140 -0
- package/components/features/lang-switcher/lang-switcher.vue +125 -40
- package/components/features/payment/banner/BasicPlusLimitBanner.vue +3 -3
- package/components/features/payment/banner/PaymentBanner.vue +3 -3
- package/components/features/payment/banner/UpSellBanner.vue +3 -3
- package/components/features/payment/process/PaymentKaspiQrSidePanel.vue +45 -27
- package/components/features/payment/process/PaymentKaspiRedirectSidePanel.vue +34 -23
- package/components/features/payment/process/PaymentMethodSidePanel.vue +66 -49
- package/components/features/payment/process/PaymentProcess.vue +6 -6
- package/components/features/payment/process/PaymentTopUpSidePanel.vue +49 -63
- package/components/features/pk-mobile-services/APkMobileServices.vue +6 -28
- package/components/features//321/201hange-version/AChangeVersion.vue +2 -2
- package/components/forms/checkbox/ACheckbox.vue +1 -1
- package/components/forms/checkbox/ACheckboxV2.vue +229 -0
- package/components/forms/feedback-form/FeedbackForm.vue +8 -8
- package/components/forms/feedback-form/FeedbackFormV2.vue +182 -0
- package/components/forms/input/AInputV2.vue +542 -0
- package/components/forms/input/date/AInputDate.vue +2 -2
- package/components/forms/input/password/AInputPassword.vue +8 -2
- package/components/forms/input/standard/AInputStandard.vue +3 -3
- package/components/forms/input/textarea/ATextarea.vue +2 -2
- package/components/forms/input/textarea/ATextareaV2.vue +248 -0
- package/components/forms/toggle/AToggle.vue +2 -3
- package/components/forms/toggle/AToggleV2.vue +71 -0
- package/components/modals/AnotherDeviceModal.vue +22 -18
- package/components/modals/ApplicationAcceptedModal.vue +12 -15
- package/components/modals/ConnectingTariffModal.vue +13 -20
- package/components/modals/ContactsMobileModel.vue +1 -1
- package/components/modals/ContentNavigationModal.vue +77 -333
- package/components/modals/Insufficient-funds-modal.vue +18 -33
- package/components/modals/LimitReachedModal.vue +17 -14
- package/components/modals/NoAccessModal.vue +9 -11
- package/components/modals/PaymentMethodModal.vue +1 -1
- package/components/modals/ReportBugConfirmModal.vue +12 -10
- package/components/modals/ReportBugModal.vue +46 -38
- package/components/modals/Resend.vue +9 -10
- package/components/modals/SubmitApplicationModal.vue +27 -24
- package/components/modals/id/IdBanner.vue +3 -3
- package/components/modals/id/IdConfirmAccountOtpModal.vue +4 -9
- package/components/modals/id/IdLoginModal.vue +3 -8
- package/components/modals/id/IdModals.vue +23 -10
- package/components/modals/id/IdRecoveryModal.vue +1 -1
- package/components/modals/id/IdTwoFactorModal.vue +3 -8
- package/components/navigation/bottom-navigation/ABottomNavigation.vue +1 -1
- package/components/navigation/breadcrumbs/ABreadcrumbs.vue +106 -45
- package/components/navigation/breadcrumbs/types.ts +3 -0
- package/components/navigation/footer/AFooter.vue +39 -40
- package/components/navigation/footer/ui/a-footer-accordion.vue +9 -9
- package/components/navigation/header/AHeader.vue +68 -51
- package/components/navigation/header/AlmatyContacts.vue +78 -78
- package/components/navigation/header/CardGallery.vue +9 -7
- package/components/navigation/header/ContactMenu.vue +26 -92
- package/components/navigation/header/HeaderLink.vue +181 -213
- package/components/navigation/header/HeaderUsage.vue +139 -0
- package/components/navigation/header/ListItem.vue +2 -2
- package/components/navigation/header/NavCard.vue +1 -1
- package/components/navigation/header/NavList.vue +33 -92
- package/components/navigation/header/NotificationsMenu.vue +2 -3
- package/components/navigation/header/ProductMenu.vue +81 -127
- package/components/navigation/header/ProfileMenu.vue +122 -151
- package/components/navigation/header/SystemNotification.vue +108 -0
- package/components/navigation/mobile-navigation/AMobileNavigation.vue +23 -15
- package/components/navigation/pill-tabs/APillTabs.vue +2 -2
- package/components/navigation/pill-tabs/APillTabsV2.vue +226 -0
- package/components/overlays/drawer/ADrawerV2.vue +335 -0
- package/components/overlays/modal/AModal.vue +4 -4
- package/components/overlays/modal/AModalV2.vue +397 -0
- package/components/overlays/side-panel/ASidePanel.vue +10 -7
- package/components/overlays/sideover/ASlideover.vue +6 -6
- package/components/overlays/tooltip/ATooltip.vue +1 -1
- package/components/overlays/tooltip/ATooltipV2.vue +223 -0
- package/components/overlays/tooltip/types.ts +26 -0
- package/components/overlays/tooltip/useTooltipTrigger.ts +101 -0
- package/components/transitions/ATransitionHeight.vue +1 -1
- package/composables/useAccessTokenCookie.ts +25 -0
- package/composables/useActiveNavigation.ts +84 -0
- package/composables/useChipOverflow.ts +92 -0
- package/composables/useHeaderNavigationLinks.ts +140 -98
- package/icons/archive.vue +16 -0
- package/icons/arrow/arrow-left-right.vue +8 -0
- package/icons/arrow/arrow-right.vue +14 -0
- package/icons/arrow/arrows-in.vue +11 -0
- package/icons/arrow/arrows-out.vue +11 -0
- package/icons/arrow/arrows-resize-in.vue +38 -0
- package/icons/arrow/arrows-resize-out.vue +17 -0
- package/icons/bill.vue +3 -0
- package/icons/bot.vue +52 -0
- package/icons/briefcase.vue +14 -0
- package/icons/building.vue +9 -0
- package/icons/car-side.vue +16 -0
- package/icons/cart.vue +15 -0
- package/icons/chart-no-axes-column.vue +3 -0
- package/icons/clock-time.vue +24 -0
- package/icons/cloud/cloud-upload.vue +3 -0
- package/icons/code.vue +9 -0
- package/icons/compare-outlined.vue +8 -0
- package/icons/dots-horizontal.vue +31 -0
- package/icons/download-line.vue +13 -0
- package/icons/download-rounded.vue +15 -0
- package/icons/egov.vue +41 -0
- package/icons/elicense.vue +38 -0
- package/icons/favourite-bookmark-outline.vue +17 -0
- package/icons/file/file-check-corner.vue +3 -0
- package/icons/file/file-spreadsheet.vue +3 -0
- package/icons/file-pen.vue +31 -0
- package/icons/file-stack.vue +31 -0
- package/icons/file-types/excel.vue +131 -0
- package/icons/file-types/html.vue +13 -0
- package/icons/file-types/jpeg.vue +16 -0
- package/icons/file-types/pdf.vue +11 -0
- package/icons/file-types/png.vue +11 -0
- package/icons/file-types/rar.vue +11 -0
- package/icons/file-types/word.vue +50 -0
- package/icons/file-types/zip.vue +11 -0
- package/icons/gauge.vue +17 -0
- package/icons/git-compare.vue +38 -0
- package/icons/git-fork.vue +3 -0
- package/icons/graduation-cap.vue +31 -0
- package/icons/graph-loading.vue +34 -0
- package/icons/headset.vue +6 -0
- package/icons/help-question-circle.vue +26 -0
- package/icons/in-row-type.vue +46 -0
- package/icons/in-table-type.vue +29 -0
- package/icons/landmark.vue +3 -0
- package/icons/layers.vue +3 -0
- package/icons/letter/letter-a.vue +6 -0
- package/icons/letter/letter-b.vue +6 -0
- package/icons/letter/letter-c.vue +6 -0
- package/icons/letter/letter-d.vue +6 -0
- package/icons/letter/letter-e.vue +6 -0
- package/icons/link-url.vue +3 -0
- package/icons/list-tree.vue +3 -0
- package/icons/mail-question-mark.vue +8 -0
- package/icons/message/message-square.vue +3 -0
- package/icons/message-dotted.vue +30 -0
- package/icons/network.vue +3 -0
- package/icons/newspaper.vue +3 -0
- package/icons/notification-error.vue +17 -0
- package/icons/person.vue +22 -0
- package/icons/phone-call.vue +6 -0
- package/icons/phone-reversed.vue +3 -0
- package/icons/route.vue +7 -0
- package/icons/scan-search.vue +3 -0
- package/icons/settings.vue +26 -0
- package/icons/shield-alert.vue +31 -0
- package/icons/shield-verified.vue +14 -0
- package/icons/socials/facebook-color.vue +16 -0
- package/icons/socials/globe-color.vue +16 -0
- package/icons/socials/instagram-color.vue +46 -0
- package/icons/socials/linkedin-color.vue +14 -0
- package/icons/socials/telegram-color.vue +16 -0
- package/icons/socials/tiktok-color.vue +14 -0
- package/icons/socials/vk-color.vue +16 -0
- package/icons/socials/youtube-color.vue +16 -0
- package/icons/sparkles.vue +3 -0
- package/icons/sun.vue +13 -3
- package/icons/users-round.vue +3 -0
- package/icons/view-eye-open.vue +13 -0
- package/icons/workflow.vue +3 -0
- package/icons/zap.vue +3 -0
- package/lang/en.ts +49 -5
- package/lang/kk.ts +50 -6
- package/lang/ru.ts +51 -7
- package/package.json +1 -1
- package/plugins/toast.client.ts +38 -55
- package/shared/constans/pages.ts +8 -2
- package/tailwind.config.ts +147 -116
- package/utils/twMerge.ts +34 -0
- package/components/elements/tree-select/components/tree-select-nodes.vue +0 -91
- package/components/navigation/header/TopHeader.vue +0 -196
|
@@ -0,0 +1,542 @@
|
|
|
1
|
+
<script generic="T, K extends keyof T" lang="ts" setup>
|
|
2
|
+
import type { Component } from 'vue'
|
|
3
|
+
import { autoUpdate, flip, size as floatingSize, offset, shift, useFloating } from '@floating-ui/vue'
|
|
4
|
+
import { onClickOutside } from '@vueuse/core'
|
|
5
|
+
import { MaskInput } from 'maska'
|
|
6
|
+
|
|
7
|
+
defineOptions({ inheritAttrs: false })
|
|
8
|
+
|
|
9
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
10
|
+
type: 'text',
|
|
11
|
+
required: false,
|
|
12
|
+
disabled: false,
|
|
13
|
+
readonly: false,
|
|
14
|
+
clearable: false,
|
|
15
|
+
size: 'sm',
|
|
16
|
+
error: undefined,
|
|
17
|
+
placeholder: '',
|
|
18
|
+
autocomplete: 'off',
|
|
19
|
+
loading: false,
|
|
20
|
+
variant: 'default',
|
|
21
|
+
mask: undefined,
|
|
22
|
+
autocompleteList: () => [] as T[],
|
|
23
|
+
autocompleteKey: undefined,
|
|
24
|
+
autocompleteOption: undefined,
|
|
25
|
+
autocompleteFn: undefined,
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
const emit = defineEmits<{
|
|
29
|
+
(e: 'clear'): void
|
|
30
|
+
(e: 'focus', ev: FocusEvent): void
|
|
31
|
+
(e: 'blur', ev: FocusEvent): void
|
|
32
|
+
(e: 'keydown', ev: KeyboardEvent): void
|
|
33
|
+
(e: 'enter', value: string | AutocompleteValue): void
|
|
34
|
+
(e: 'selectOption', value: AutocompleteValue): void
|
|
35
|
+
(e: 'updateValue', value: string | number): void
|
|
36
|
+
}>()
|
|
37
|
+
|
|
38
|
+
interface Props {
|
|
39
|
+
label?: string
|
|
40
|
+
type?: 'text' | 'search' | 'email' | 'password' | 'tel' | 'url' | 'number'
|
|
41
|
+
placeholder?: string
|
|
42
|
+
required?: boolean
|
|
43
|
+
disabled?: boolean
|
|
44
|
+
readonly?: boolean
|
|
45
|
+
clearable?: boolean
|
|
46
|
+
size?: 'sm' | 'md'
|
|
47
|
+
error?: string | string[]
|
|
48
|
+
startIcon?: Component
|
|
49
|
+
endIcon?: Component
|
|
50
|
+
loading?: boolean
|
|
51
|
+
variant?: 'default' | 'gray' | 'blue'
|
|
52
|
+
mask?: string
|
|
53
|
+
inputId?: string
|
|
54
|
+
autocomplete?: string
|
|
55
|
+
autocompleteList?: T[]
|
|
56
|
+
autocompleteKey?: K
|
|
57
|
+
autocompleteOption?: K
|
|
58
|
+
autocompleteFn?: (item: T) => string
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
type AutocompleteValue = T | T[keyof T]
|
|
62
|
+
|
|
63
|
+
function customTrim(input: string | number | null | undefined): string | number {
|
|
64
|
+
if (input == null) return ''
|
|
65
|
+
if (typeof input !== 'string') return input
|
|
66
|
+
if (input === ' ' || /\d/.test(input)) return input.trim()
|
|
67
|
+
return input
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const [modelValue, modelModifiers] = defineModel<string | number | AutocompleteValue>({
|
|
71
|
+
default: '',
|
|
72
|
+
set(value) {
|
|
73
|
+
if (modelModifiers['custom-trim']) return customTrim(value as string)
|
|
74
|
+
return value
|
|
75
|
+
},
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
const inputRef = ref<HTMLInputElement | null>(null)
|
|
79
|
+
const isFocused = ref(false)
|
|
80
|
+
|
|
81
|
+
let maskInput: MaskInput | null = null
|
|
82
|
+
onMounted(() => {
|
|
83
|
+
if (props.mask && inputRef.value) {
|
|
84
|
+
maskInput = new MaskInput(inputRef.value, { mask: props.mask })
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
onUnmounted(() => {
|
|
88
|
+
maskInput?.destroy()
|
|
89
|
+
maskInput = null
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
const internalId = useId()
|
|
93
|
+
const inputId = computed(() => props.inputId ?? `input-v2-${internalId}`)
|
|
94
|
+
|
|
95
|
+
const hasValue = computed(() => modelValue.value != null && modelValue.value !== '')
|
|
96
|
+
const hasError = computed(() => Array.isArray(props.error) ? props.error.length > 0 : !!props.error)
|
|
97
|
+
const isLabelFloated = computed(() => hasValue.value || isFocused.value)
|
|
98
|
+
|
|
99
|
+
const hasAutocomplete = computed(() => props.autocompleteList && props.autocompleteList.length > 0)
|
|
100
|
+
const isDropdownOpen = computed(() => hasAutocomplete.value && isFocused.value)
|
|
101
|
+
const currentItemIndex = ref(-1)
|
|
102
|
+
|
|
103
|
+
const fieldRef = ref<HTMLElement | null>(null)
|
|
104
|
+
const floatingRef = ref<HTMLElement | null>(null)
|
|
105
|
+
const { x, y, strategy, update } = useFloating(fieldRef, floatingRef, {
|
|
106
|
+
placement: 'bottom-start',
|
|
107
|
+
strategy: 'absolute',
|
|
108
|
+
middleware: [
|
|
109
|
+
offset(6),
|
|
110
|
+
flip({ fallbackPlacements: ['top-start'] }),
|
|
111
|
+
shift({ padding: 8 }),
|
|
112
|
+
floatingSize({
|
|
113
|
+
apply({ availableHeight, elements, rects }) {
|
|
114
|
+
const el = elements.floating as HTMLElement
|
|
115
|
+
el.style.width = `${rects.reference.width}px`
|
|
116
|
+
el.style.maxHeight = `${Math.min(availableHeight, 320)}px`
|
|
117
|
+
},
|
|
118
|
+
}),
|
|
119
|
+
],
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
let cleanup: (() => void) | null = null
|
|
123
|
+
watch(isDropdownOpen, (open) => {
|
|
124
|
+
if (open && fieldRef.value && floatingRef.value) {
|
|
125
|
+
cleanup = autoUpdate(fieldRef.value, floatingRef.value, update)
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
cleanup?.()
|
|
129
|
+
cleanup = null
|
|
130
|
+
currentItemIndex.value = -1
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
onUnmounted(() => cleanup?.())
|
|
134
|
+
|
|
135
|
+
const wrapperRef = ref<HTMLDivElement | null>(null)
|
|
136
|
+
onClickOutside(wrapperRef, () => {
|
|
137
|
+
if (isFocused.value) inputRef.value?.blur()
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
function resolveSelectedValue(item: T): AutocompleteValue {
|
|
141
|
+
if (props.autocompleteFn) return props.autocompleteFn(item) as AutocompleteValue
|
|
142
|
+
if (props.autocompleteKey) return item[props.autocompleteKey] as AutocompleteValue
|
|
143
|
+
return item
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function applyCurrentItem() {
|
|
147
|
+
const item = props.autocompleteList[currentItemIndex.value]
|
|
148
|
+
if (item == null) return
|
|
149
|
+
modelValue.value = resolveSelectedValue(item)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function onSelectOption(item: T) {
|
|
153
|
+
const value = resolveSelectedValue(item)
|
|
154
|
+
modelValue.value = value
|
|
155
|
+
emit('selectOption', value)
|
|
156
|
+
inputRef.value?.blur()
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const isTouchScrolling = ref(false)
|
|
160
|
+
function onTouchEndOption(item: T) {
|
|
161
|
+
if (!isTouchScrolling.value) onSelectOption(item)
|
|
162
|
+
isTouchScrolling.value = false
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function onInput(ev: Event) {
|
|
166
|
+
const value = (ev.target as HTMLInputElement).value
|
|
167
|
+
modelValue.value = value
|
|
168
|
+
emit('updateValue', value)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function onFocus(ev: FocusEvent) {
|
|
172
|
+
isFocused.value = true
|
|
173
|
+
emit('focus', ev)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function onBlur(ev: FocusEvent) {
|
|
177
|
+
isFocused.value = false
|
|
178
|
+
emit('blur', ev)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const autocompleteListEl = ref<HTMLUListElement | null>(null)
|
|
182
|
+
function scrollIntoView(idx: number) {
|
|
183
|
+
const container = autocompleteListEl.value
|
|
184
|
+
if (!container) return
|
|
185
|
+
const item = container.children[idx] as HTMLElement | undefined
|
|
186
|
+
if (!item) return
|
|
187
|
+
const itemTop = item.offsetTop
|
|
188
|
+
const itemBottom = itemTop + item.clientHeight
|
|
189
|
+
if (itemTop < container.scrollTop) container.scrollTop = itemTop
|
|
190
|
+
else if (itemBottom > container.scrollTop + container.clientHeight)
|
|
191
|
+
container.scrollTop = itemBottom - container.clientHeight
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function onKeydown(ev: KeyboardEvent) {
|
|
195
|
+
emit('keydown', ev)
|
|
196
|
+
|
|
197
|
+
if (hasAutocomplete.value) {
|
|
198
|
+
const last = props.autocompleteList.length - 1
|
|
199
|
+
if (ev.key === 'ArrowDown' && currentItemIndex.value < last) {
|
|
200
|
+
ev.preventDefault()
|
|
201
|
+
currentItemIndex.value++
|
|
202
|
+
applyCurrentItem()
|
|
203
|
+
nextTick(() => scrollIntoView(currentItemIndex.value))
|
|
204
|
+
return
|
|
205
|
+
}
|
|
206
|
+
if (ev.key === 'ArrowUp' && currentItemIndex.value > 0) {
|
|
207
|
+
ev.preventDefault()
|
|
208
|
+
currentItemIndex.value--
|
|
209
|
+
applyCurrentItem()
|
|
210
|
+
nextTick(() => scrollIntoView(currentItemIndex.value))
|
|
211
|
+
return
|
|
212
|
+
}
|
|
213
|
+
if (ev.key === 'Enter') {
|
|
214
|
+
if (currentItemIndex.value !== -1) {
|
|
215
|
+
applyCurrentItem()
|
|
216
|
+
emit('enter', props.autocompleteList[currentItemIndex.value])
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
emit('enter', (ev.target as HTMLInputElement).value)
|
|
220
|
+
}
|
|
221
|
+
inputRef.value?.blur()
|
|
222
|
+
return
|
|
223
|
+
}
|
|
224
|
+
if (ev.key === 'Escape') {
|
|
225
|
+
inputRef.value?.blur()
|
|
226
|
+
return
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (ev.key === 'Enter') emit('enter', (ev.target as HTMLInputElement).value)
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function onClear() {
|
|
234
|
+
modelValue.value = ''
|
|
235
|
+
emit('clear')
|
|
236
|
+
emit('updateValue', '')
|
|
237
|
+
inputRef.value?.focus()
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function focus() {
|
|
241
|
+
inputRef.value?.focus()
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function blur() {
|
|
245
|
+
inputRef.value?.blur()
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function onFieldMousedown(ev: MouseEvent) {
|
|
249
|
+
if (ev.target === inputRef.value) return
|
|
250
|
+
ev.preventDefault()
|
|
251
|
+
inputRef.value?.focus()
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
defineExpose({ focus, blur, inputRef })
|
|
255
|
+
|
|
256
|
+
const layoutClass = computed(() => {
|
|
257
|
+
if (!props.label) {
|
|
258
|
+
return props.size === 'md' ? 'h-10 py-1.5' : 'h-9 py-1.5'
|
|
259
|
+
}
|
|
260
|
+
return props.size === 'md' ? 'h-10 pt-4 pb-0.5' : 'h-9 pt-3 pb-0.5'
|
|
261
|
+
})
|
|
262
|
+
|
|
263
|
+
const iconOffsetClass = computed(() => {
|
|
264
|
+
if (!props.label) return ''
|
|
265
|
+
return props.size === 'md' ? '-translate-y-[7px]' : '-translate-y-[5px]'
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
const showClearButton = computed(() =>
|
|
269
|
+
props.clearable && hasValue.value && !props.disabled && !props.readonly && !props.loading,
|
|
270
|
+
)
|
|
271
|
+
|
|
272
|
+
const errorMessages = computed(() => {
|
|
273
|
+
if (!props.error) return [] as string[]
|
|
274
|
+
return Array.isArray(props.error) ? props.error : [props.error]
|
|
275
|
+
})
|
|
276
|
+
|
|
277
|
+
const attrs = useAttrs()
|
|
278
|
+
const wrapperAttrs = computed(() => ({ class: attrs.class, style: attrs.style }))
|
|
279
|
+
const inputAttrs = computed(() => {
|
|
280
|
+
const { class: _c, style: _s, ...rest } = attrs as Record<string, unknown>
|
|
281
|
+
return rest
|
|
282
|
+
})
|
|
283
|
+
|
|
284
|
+
const fieldClass = computed(() => {
|
|
285
|
+
if (props.disabled) {
|
|
286
|
+
return 'border-gray-200 bg-gray-100/70 dark:border-gray-700 dark:bg-white/[0.03]'
|
|
287
|
+
}
|
|
288
|
+
if (props.variant === 'gray') {
|
|
289
|
+
return 'border-transparent bg-gray-50 dark:border-transparent dark:bg-white/[0.04]'
|
|
290
|
+
}
|
|
291
|
+
if (props.variant === 'blue') {
|
|
292
|
+
return 'border-blue-200 bg-blue-50 dark:border-blue-900/50 dark:bg-blue-900/20'
|
|
293
|
+
}
|
|
294
|
+
return 'border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-900'
|
|
295
|
+
})
|
|
296
|
+
|
|
297
|
+
function rowDisplay(item: T): unknown {
|
|
298
|
+
if (props.autocompleteOption) return item[props.autocompleteOption]
|
|
299
|
+
return item
|
|
300
|
+
}
|
|
301
|
+
</script>
|
|
302
|
+
|
|
303
|
+
<template>
|
|
304
|
+
<div
|
|
305
|
+
ref="wrapperRef"
|
|
306
|
+
class="input-v2 relative w-full text-body-md"
|
|
307
|
+
v-bind="wrapperAttrs"
|
|
308
|
+
>
|
|
309
|
+
<div
|
|
310
|
+
ref="fieldRef"
|
|
311
|
+
class="input-v2__field text-deepblue-900 relative flex w-full cursor-text items-center gap-2 rounded-[10px] border border-solid transition-colors duration-200 focus-within:border-blue-600 focus-within:ring-2 focus-within:ring-blue-600/20 hover:border-blue-500 dark:text-gray-200 dark:focus-within:border-blue-400 dark:focus-within:ring-blue-400/20 dark:hover:border-blue-400"
|
|
312
|
+
:class="[
|
|
313
|
+
layoutClass,
|
|
314
|
+
fieldClass,
|
|
315
|
+
startIcon ? 'pl-3' : 'pl-4',
|
|
316
|
+
clearable || endIcon || loading || $slots.endButton ? 'pr-3' : 'pr-4',
|
|
317
|
+
{ 'input-v2__field--error': hasError, 'input-v2__field--disabled': disabled },
|
|
318
|
+
]"
|
|
319
|
+
@mousedown="onFieldMousedown"
|
|
320
|
+
>
|
|
321
|
+
<label
|
|
322
|
+
v-if="label"
|
|
323
|
+
:for="inputId"
|
|
324
|
+
class="input-v2__label pointer-events-none absolute top-1/2 max-w-[calc(100%-32px)] truncate text-gray-500 dark:text-gray-400"
|
|
325
|
+
:data-size="size"
|
|
326
|
+
:class="[
|
|
327
|
+
startIcon ? 'left-9' : 'left-4',
|
|
328
|
+
{ 'input-v2__label--floated': isLabelFloated },
|
|
329
|
+
]"
|
|
330
|
+
>
|
|
331
|
+
{{ label }}<span v-if="required" class="text-red-500 dark:text-red-400"> *</span>
|
|
332
|
+
</label>
|
|
333
|
+
|
|
334
|
+
<component
|
|
335
|
+
:is="startIcon"
|
|
336
|
+
v-if="startIcon"
|
|
337
|
+
class="size-4 shrink-0 text-gray-400 dark:text-gray-500"
|
|
338
|
+
:class="iconOffsetClass"
|
|
339
|
+
/>
|
|
340
|
+
|
|
341
|
+
<input
|
|
342
|
+
:id="inputId"
|
|
343
|
+
ref="inputRef"
|
|
344
|
+
:type="type"
|
|
345
|
+
:value="modelValue ?? ''"
|
|
346
|
+
:placeholder="(isLabelFloated || !label) ? placeholder : ''"
|
|
347
|
+
:disabled="disabled"
|
|
348
|
+
:readonly="readonly"
|
|
349
|
+
:autocomplete="autocomplete"
|
|
350
|
+
:tabindex="disabled ? -1 : 0"
|
|
351
|
+
class="input-v2__input text-deepblue-900 w-full min-w-0 bg-transparent leading-tight outline-none placeholder:text-gray-500 disabled:cursor-not-allowed dark:text-gray-200 dark:placeholder:text-gray-400"
|
|
352
|
+
v-bind="inputAttrs"
|
|
353
|
+
@input="onInput"
|
|
354
|
+
@focus="onFocus"
|
|
355
|
+
@blur="onBlur"
|
|
356
|
+
@keydown="onKeydown"
|
|
357
|
+
>
|
|
358
|
+
|
|
359
|
+
<a-icon-loader-circle
|
|
360
|
+
v-if="loading"
|
|
361
|
+
class="size-4 shrink-0 animate-spin text-gray-400 dark:text-gray-500"
|
|
362
|
+
:class="iconOffsetClass"
|
|
363
|
+
/>
|
|
364
|
+
|
|
365
|
+
<button
|
|
366
|
+
v-else-if="showClearButton"
|
|
367
|
+
type="button"
|
|
368
|
+
tabindex="-1"
|
|
369
|
+
class="flex shrink-0 items-center justify-center rounded-full p-0.5 transition-colors hover:bg-gray-100 dark:hover:bg-white/[0.08] dark:hover:text-gray-300"
|
|
370
|
+
:class="iconOffsetClass"
|
|
371
|
+
@mousedown.prevent
|
|
372
|
+
@click.stop="onClear"
|
|
373
|
+
>
|
|
374
|
+
<a-icon-x-mark class="!m-0 size-3.5" />
|
|
375
|
+
</button>
|
|
376
|
+
|
|
377
|
+
<component
|
|
378
|
+
:is="endIcon"
|
|
379
|
+
v-else-if="endIcon"
|
|
380
|
+
class="size-4 shrink-0 text-gray-400 dark:text-gray-500"
|
|
381
|
+
:class="iconOffsetClass"
|
|
382
|
+
/>
|
|
383
|
+
|
|
384
|
+
<slot name="endButton" />
|
|
385
|
+
</div>
|
|
386
|
+
|
|
387
|
+
<transition
|
|
388
|
+
enter-active-class="input-v2__dropdown-enter-active"
|
|
389
|
+
enter-from-class="input-v2__dropdown-enter-from"
|
|
390
|
+
enter-to-class="input-v2__dropdown-enter-to"
|
|
391
|
+
leave-active-class="input-v2__dropdown-leave-active"
|
|
392
|
+
leave-from-class="input-v2__dropdown-leave-from"
|
|
393
|
+
leave-to-class="input-v2__dropdown-leave-to"
|
|
394
|
+
>
|
|
395
|
+
<div
|
|
396
|
+
v-if="isDropdownOpen"
|
|
397
|
+
ref="floatingRef"
|
|
398
|
+
class="input-v2__dropdown z-[10000] flex flex-col gap-2 rounded-lg border border-gray-200 bg-white p-1.5 shadow-lg shadow-gray-900/10 dark:border-gray-700 dark:bg-gray-900 dark:shadow-black/30"
|
|
399
|
+
:style="{
|
|
400
|
+
position: strategy,
|
|
401
|
+
left: x != null ? `${x}px` : '',
|
|
402
|
+
top: y != null ? `${y}px` : '',
|
|
403
|
+
}"
|
|
404
|
+
>
|
|
405
|
+
<ul ref="autocompleteListEl" class="input-v2__list flex flex-col">
|
|
406
|
+
<li
|
|
407
|
+
v-for="(item, idx) in autocompleteList"
|
|
408
|
+
:key="idx"
|
|
409
|
+
class="cursor-pointer rounded-md px-3 py-2 text-body-md transition-colors duration-100 hover:bg-gray-50 dark:hover:bg-gray-800/60"
|
|
410
|
+
:class="{ 'input-v2__option--active': currentItemIndex === idx }"
|
|
411
|
+
@mousedown.prevent="onSelectOption(item)"
|
|
412
|
+
@touchend.prevent="onTouchEndOption(item)"
|
|
413
|
+
@touchmove="isTouchScrolling = true"
|
|
414
|
+
>
|
|
415
|
+
<slot name="autocomplete-option" :item="item">
|
|
416
|
+
{{ rowDisplay(item) }}
|
|
417
|
+
</slot>
|
|
418
|
+
</li>
|
|
419
|
+
</ul>
|
|
420
|
+
|
|
421
|
+
<slot name="autocomplete-buttons" :value="modelValue" />
|
|
422
|
+
</div>
|
|
423
|
+
</transition>
|
|
424
|
+
|
|
425
|
+
<transition
|
|
426
|
+
enter-active-class="input-v2__error-enter-active"
|
|
427
|
+
enter-from-class="input-v2__error-enter-from"
|
|
428
|
+
enter-to-class="input-v2__error-enter-to"
|
|
429
|
+
leave-active-class="input-v2__error-leave-active"
|
|
430
|
+
leave-from-class="input-v2__error-leave-from"
|
|
431
|
+
leave-to-class="input-v2__error-leave-to"
|
|
432
|
+
>
|
|
433
|
+
<p v-if="hasError" class="mt-1 flex flex-col text-body-sm text-red-500 dark:text-red-400">
|
|
434
|
+
<span v-for="(err, idx) in errorMessages" :key="idx">{{ err }}</span>
|
|
435
|
+
</p>
|
|
436
|
+
</transition>
|
|
437
|
+
</div>
|
|
438
|
+
</template>
|
|
439
|
+
|
|
440
|
+
<style scoped>
|
|
441
|
+
.input-v2__field--error {
|
|
442
|
+
border-color: theme('colors.red.500');
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
.input-v2__field--disabled {
|
|
446
|
+
pointer-events: none;
|
|
447
|
+
cursor: not-allowed;
|
|
448
|
+
opacity: 0.7;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
.input-v2__field--disabled .input-v2__input {
|
|
452
|
+
cursor: not-allowed;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
.input-v2__label {
|
|
456
|
+
font-size: 14px;
|
|
457
|
+
line-height: 1.3;
|
|
458
|
+
transform: translateY(-50%);
|
|
459
|
+
transition:
|
|
460
|
+
transform 300ms cubic-bezier(0.22, 1, 0.36, 1),
|
|
461
|
+
font-size 300ms cubic-bezier(0.22, 1, 0.36, 1),
|
|
462
|
+
color 300ms ease-out;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
.input-v2__label--floated {
|
|
466
|
+
font-size: 10px;
|
|
467
|
+
transform: translateY(-17px);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
.input-v2__label--floated[data-size="sm"] {
|
|
471
|
+
transform: translateY(-14px);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
.input-v2__dropdown-enter-active,
|
|
475
|
+
.input-v2__dropdown-leave-active {
|
|
476
|
+
transition:
|
|
477
|
+
opacity 180ms cubic-bezier(0.22, 1, 0.36, 1),
|
|
478
|
+
transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
.input-v2__dropdown-enter-from,
|
|
482
|
+
.input-v2__dropdown-leave-to {
|
|
483
|
+
opacity: 0;
|
|
484
|
+
transform: translateY(-4px);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
.input-v2__dropdown-enter-to,
|
|
488
|
+
.input-v2__dropdown-leave-from {
|
|
489
|
+
opacity: 1;
|
|
490
|
+
transform: translateY(0);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
.input-v2__list {
|
|
494
|
+
max-height: 250px;
|
|
495
|
+
overflow-y: auto;
|
|
496
|
+
overflow-x: hidden;
|
|
497
|
+
scrollbar-width: none;
|
|
498
|
+
-ms-overflow-style: none;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
.input-v2__list::-webkit-scrollbar {
|
|
502
|
+
width: 0;
|
|
503
|
+
height: 0;
|
|
504
|
+
display: none;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
.input-v2__option--active {
|
|
508
|
+
background-color: theme('colors.blue.50');
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
:is(.dark) .input-v2__option--active {
|
|
512
|
+
background-color: rgb(30 64 175 / 0.18);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
.input-v2__error-enter-active {
|
|
516
|
+
transition: transform 0.3s, opacity 0.3s;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
.input-v2__error-enter-from {
|
|
520
|
+
opacity: 0;
|
|
521
|
+
transform: translateY(-4px);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
.input-v2__error-leave-active {
|
|
525
|
+
transition: transform 0.2s, opacity 0.2s;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
.input-v2__error-leave-to {
|
|
529
|
+
opacity: 0;
|
|
530
|
+
transform: translateY(-4px);
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
@media (prefers-reduced-motion: reduce) {
|
|
534
|
+
.input-v2__label,
|
|
535
|
+
.input-v2__dropdown-enter-active,
|
|
536
|
+
.input-v2__dropdown-leave-active,
|
|
537
|
+
.input-v2__error-enter-active,
|
|
538
|
+
.input-v2__error-leave-active {
|
|
539
|
+
transition: none;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
</style>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { twJoin, twMerge } from 'tailwind-merge'
|
|
3
2
|
import ACalendar from "#adata-ui/components/elements/calendar/ACalendar.vue";
|
|
3
|
+
import { twJoin, twMerge } from '#adata-ui/utils/twMerge'
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
interface Props {
|
|
@@ -48,7 +48,7 @@ const uiConfig = {
|
|
|
48
48
|
"input-wrapper": {
|
|
49
49
|
base: 'relative inline-block w-full text-sm sm:min-w-full'
|
|
50
50
|
},
|
|
51
|
-
base: 'w-full border-0 rounded-
|
|
51
|
+
base: 'w-full border-0 rounded-sm text-deepblue-900 dark:text-gray-200 hover:outline hover:outline-1 hover:outline-blue-700 hover:dark:outline-blue-500 focus:outline focus:outline-blue-700 focus:dark:outline-blue-500 mt-0',
|
|
52
52
|
size: {
|
|
53
53
|
sm: 'h-8 px-4 py-1.5 sm',
|
|
54
54
|
md: 'h-10 px-4 pb-1.5 pt-[18px] md'
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import AInputStandard from "#adata-ui/components/forms/input/standard/AInputStandard.vue";
|
|
3
3
|
|
|
4
|
-
|
|
5
4
|
interface Props {
|
|
6
5
|
disabled?: boolean
|
|
7
6
|
label?: string
|
|
8
7
|
size?: 'sm' | 'md'
|
|
9
8
|
error?: string
|
|
10
9
|
required?: boolean
|
|
10
|
+
iconEyeTestId?: string
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
const props = withDefaults(defineProps<Props>(), {
|
|
@@ -19,19 +19,25 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
19
19
|
})
|
|
20
20
|
|
|
21
21
|
const isOpened = ref<boolean>(false)
|
|
22
|
+
|
|
23
|
+
const inputProps = computed(() => {
|
|
24
|
+
const { iconEyeTestId, ...rest } = props
|
|
25
|
+
return rest
|
|
26
|
+
})
|
|
22
27
|
</script>
|
|
23
28
|
|
|
24
29
|
<template>
|
|
25
30
|
<a-input-standard
|
|
26
31
|
v-bind="$attrs"
|
|
27
32
|
:type="isOpened ? 'text' : 'password'"
|
|
28
|
-
v-bind.prop="
|
|
33
|
+
v-bind.prop="inputProps"
|
|
29
34
|
>
|
|
30
35
|
<template #endButton>
|
|
31
36
|
<button
|
|
32
37
|
class="absolute top-1/2 right-4 text-gray-500 fill-gray-500 pointer-events-click text-2xl transform translate-y-[-50%] hover:opacity-80 disabled:pointer-events-none"
|
|
33
38
|
:disabled="disabled"
|
|
34
39
|
type="button"
|
|
40
|
+
:data-test-id="iconEyeTestId"
|
|
35
41
|
@click="isOpened = !isOpened"
|
|
36
42
|
>
|
|
37
43
|
<a-icon-eye-closed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script generic="T, K extends keyof T" lang="ts" setup>
|
|
2
|
-
import {twMerge, twJoin} from 'tailwind-merge'
|
|
3
2
|
import AAlert from '#adata-ui/components/elements/alert/AAlert.vue'
|
|
3
|
+
import {twJoin, twMerge} from '#adata-ui/utils/twMerge'
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
6
6
|
disabled?: boolean
|
|
@@ -44,11 +44,11 @@ const {t} = useI18n()
|
|
|
44
44
|
const uiConfig = {
|
|
45
45
|
wrapper: 'transition duration-500 w-full',
|
|
46
46
|
'input-wrapper': {
|
|
47
|
-
base: 'relative inline-block w-full text-
|
|
47
|
+
base: 'relative inline-block w-full text-body-md sm:min-w-full',
|
|
48
48
|
readonly: 'pointer-events-none user-select-none',
|
|
49
49
|
disabled: 'pointer-events-none user-select-none opacity-40'
|
|
50
50
|
},
|
|
51
|
-
base: 'w-full border-0 rounded-
|
|
51
|
+
base: 'w-full border-0 rounded-sm text-deepblue-900 dark:text-gray-200 hover:outline outline-offset-[-1px] hover:outline-1 hover:outline-blue-700 hover:dark:outline-blue-500 focus:outline focus:outline-blue-700 focus:dark:outline-blue-500 mt-0',
|
|
52
52
|
size: {
|
|
53
53
|
sm: 'h-8 px-4 py-1.5 sm',
|
|
54
54
|
md: 'h-10 px-4 pb-1.5 pt-[18px] md',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { twMerge, twJoin } from 'tailwind-merge'
|
|
3
2
|
import AAlert from '#adata-ui/components/elements/alert/AAlert.vue'
|
|
3
|
+
import { twJoin, twMerge } from '#adata-ui/utils/twMerge'
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
6
6
|
disabled?: boolean
|
|
@@ -38,7 +38,7 @@ const uiConfig = {
|
|
|
38
38
|
disabled: 'pointer-events-none user-select-none opacity-40',
|
|
39
39
|
color: 'bg-deepblue-900/5 dark:bg-gray-200/5'
|
|
40
40
|
},
|
|
41
|
-
base: 'w-full border-0 rounded-
|
|
41
|
+
base: 'w-full border-0 rounded-sm text-deepblue-900 dark:text-gray-200 outline-none mt-0',
|
|
42
42
|
size: {
|
|
43
43
|
sm: 'h-8 px-4 py-1.5 sm',
|
|
44
44
|
md: 'h-10 px-4 pb-1.5 pt-[8px] md'
|