From 95b222b68ab88270164a61700223ab8cd64520f3 Mon Sep 17 00:00:00 2001 From: Maksim Nedoshev Date: Tue, 4 Apr 2023 20:17:47 +0300 Subject: [PATCH 01/30] feat(ui): expose aria labels as props (#3175) * feat(ui): expose aria labels as props * docs(select): description for aria label props * fix(counter): label translation --- packages/docs/locales/en.json | 5 ++++- .../modules/page-config/blocks/api/index.vue | 12 ++++++++++ .../src/components/va-backtop/VaBacktop.vue | 3 ++- .../va-breadcrumbs/VaBreadcrumbs.vue | 5 +++-- .../va-button-dropdown/VaButtonDropdown.vue | 5 ++++- .../src/components/va-carousel/VaCarousel.vue | 16 +++++++++----- packages/ui/src/components/va-chip/VaChip.vue | 4 +++- .../va-color-input/VaColorInput.vue | 3 ++- .../va-color-palette/VaColorPalette.vue | 6 +++-- .../src/components/va-counter/VaCounter.vue | 14 +++++++----- .../components/va-data-table/VaDataTable.vue | 5 ++++- .../components/VaDataTableThRow.vue | 11 ++++++---- .../components/va-date-input/VaDateInput.vue | 16 +++++++++----- .../VaDatePickerHeader/VaDatePickerHeader.vue | 10 ++++++--- .../src/components/va-dropdown/VaDropdown.vue | 7 +++--- .../va-file-upload/VaFileUpload.vue | 6 +++++ .../VaFileUploadGalleryItem.vue | 4 +++- .../VaFileUploadList/VaFileUploadList.vue | 18 ++++++++++++--- .../VaFileUploadListItem.vue | 4 +++- .../VaFileUploadSingleItem.vue | 3 ++- .../ui/src/components/va-input/VaInput.vue | 3 ++- .../ui/src/components/va-modal/VaModal.vue | 3 ++- .../components/va-pagination/VaPagination.vue | 22 +++++++++++++------ .../va-progress-bar/VaProgressBar.vue | 5 +++-- .../va-progress-circle/VaProgressCircle.vue | 5 +++-- .../ui/src/components/va-rating/VaRating.vue | 7 ++++-- .../ui/src/components/va-select/VaSelect.vue | 10 ++++++--- .../src/components/va-skeleton/VaSkeleton.vue | 6 +++-- .../ui/src/components/va-slider/VaSlider.vue | 7 ++++-- .../ui/src/components/va-split/VaSplit.vue | 4 +++- .../src/components/va-stepper/VaStepper.vue | 9 ++++---- .../ui/src/components/va-switch/VaSwitch.vue | 2 +- packages/ui/src/components/va-tabs/VaTabs.vue | 6 +++-- .../components/va-time-input/VaTimeInput.vue | 18 +++++++++------ .../ui/src/components/va-toast/VaToast.vue | 3 ++- packages/ui/src/composables/useTranslation.ts | 8 +++---- .../ui/src/services/i18n/config/default.ts | 9 ++++++++ 37 files changed, 200 insertions(+), 84 deletions(-) diff --git a/packages/docs/locales/en.json b/packages/docs/locales/en.json index c2c328a38e..3d28bdf225 100644 --- a/packages/docs/locales/en.json +++ b/packages/docs/locales/en.json @@ -875,7 +875,10 @@ "stickToEdges": "Dropdown will not be rendered outside of viewport. It will be moved in opposite direction.", "autocomplete": "Enables the autocomplete behaviour.", "highlightMatchedText": "Highlight chars in options that are match the input value (search or autocomplete).", - "minSearchChars": "Minimal amount of chars in input value to initiate search or autocomplete." + "minSearchChars": "Minimal amount of chars in input value to initiate search or autocomplete.", + "ariaLabel": "Set aria label. By default it `$t:selectOption` is value is selected and `$t:noSelectedOption` if value is empty.", + "ariaClearLabel": "Set aria label for clear button", + "ariaSearchLabel": "Set aria label for search input" }, "events": { "clear": "Emitted if select value has been cleared", diff --git a/packages/docs/modules/page-config/blocks/api/index.vue b/packages/docs/modules/page-config/blocks/api/index.vue index 2f3789c0b6..249bdc8d4c 100644 --- a/packages/docs/modules/page-config/blocks/api/index.vue +++ b/packages/docs/modules/page-config/blocks/api/index.vue @@ -81,6 +81,9 @@ const propsOptions = Object types: '`' + prop.types + '`', default: cleanDefaultValue(prop.default), })) + .sort((a, b) => { + return a.name.name.localeCompare(b.name.name) + }) const eventsOptions = Object .entries(withManual.events || {}) @@ -89,6 +92,9 @@ const eventsOptions = Object name: key, description: t(getTranslation('events', key)), })) + .sort((a, b) => { + return a.name.localeCompare(b.name) + }) const slotsOptions = Object .entries(withManual.slots || {}) @@ -96,6 +102,9 @@ const slotsOptions = Object name: key, description: t(getTranslation('slots', key)), })) + .sort((a, b) => { + return a.name.localeCompare(b.name) + }) const methodsOptions = Object .entries(withManual.methods || {}) @@ -103,6 +112,9 @@ const methodsOptions = Object name: key, description: t(getTranslation('methods', key)), })) + .sort((a, b) => { + return a.name.localeCompare(b.name) + }) const cssVariablesOptions = props.cssVariables.map(([name, value, comment]) => ({ name, value, /* comment */ // TODO: Enable comment when everywhere is used correct comments diff --git a/packages/ui/src/components/va-backtop/VaBacktop.vue b/packages/ui/src/components/va-backtop/VaBacktop.vue index 401f08571a..e33c0df6e9 100644 --- a/packages/ui/src/components/va-backtop/VaBacktop.vue +++ b/packages/ui/src/components/va-backtop/VaBacktop.vue @@ -3,7 +3,7 @@ v-if="visible" class="va-backtop" role="button" - :aria-label="t('backToTop')" + :aria-label="tp($props.ariaLabel)" :style="computedStyle" @click="scrollToTop" @keydown.enter.stop="scrollToTop" @@ -49,6 +49,7 @@ export default defineComponent({ default: 'bottom', validator: (value: string) => ['bottom', 'top'].includes(value), }, + ariaLabel: { type: String, default: '$t:backToTop' }, }, setup (props) { const targetScrollValue = ref(0) diff --git a/packages/ui/src/components/va-breadcrumbs/VaBreadcrumbs.vue b/packages/ui/src/components/va-breadcrumbs/VaBreadcrumbs.vue index 9d73ddaa5f..736de34d73 100644 --- a/packages/ui/src/components/va-breadcrumbs/VaBreadcrumbs.vue +++ b/packages/ui/src/components/va-breadcrumbs/VaBreadcrumbs.vue @@ -15,6 +15,7 @@ export default defineComponent({ color: { type: String, default: 'secondary' }, activeColor: { type: String, default: null }, separatorColor: { type: String, default: null }, + ariaLabel: { type: String, default: '$t:breadcrumbs' }, }, setup (props, { slots }) { const { alignComputed } = useAlign(props) @@ -108,13 +109,13 @@ export default defineComponent({ return children } - const { t } = useTranslation() + const { tp } = useTranslation() return () => h('div', { class: 'va-breadcrumbs', style: alignComputed.value, role: isAllChildLinks.value ? 'navigation' : undefined, - 'aria-label': isAllChildLinks.value ? t('breadcrumbs') : undefined, + 'aria-label': (isAllChildLinks.value ? tp(props.ariaLabel) : undefined), }, getChildren()) }, }) diff --git a/packages/ui/src/components/va-button-dropdown/VaButtonDropdown.vue b/packages/ui/src/components/va-button-dropdown/VaButtonDropdown.vue index 9b415e49ba..6a9201f119 100644 --- a/packages/ui/src/components/va-button-dropdown/VaButtonDropdown.vue +++ b/packages/ui/src/components/va-button-dropdown/VaButtonDropdown.vue @@ -8,6 +8,7 @@ >