Skip to content

Commit 51a1be5

Browse files
kricsleozernonia
andauthored
feat(Progress): add getValueText for aria-valuetext (#1920)
Co-authored-by: zernonia <zernonia@gmail.com>
1 parent a43b99e commit 51a1be5

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

docs/content/meta/ProgressRoot.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,17 @@
1616
},
1717
{
1818
'name': 'getValueLabel',
19-
'description': '<p>A function to get the accessible label text representing the current value in a human-readable format.</p>\n<p>If not provided, the value label will be read as the numeric value as a percentage of the max value.</p>\n',
19+
'description': '<p>A function to get the accessible label text in a human-readable format.</p>\n<p>If not provided, the value label will be read as the numeric value as a percentage of the max value.</p>\n',
2020
'type': '((value: number | null, max: number) => string)',
2121
'required': false,
2222
'default': 'isNumber(value) ? `${Math.round((value / max) * DEFAULT_MAX)}%` : undefined'
2323
},
24+
{
25+
'name': 'getValueText',
26+
'description': '<p>A function to get the accessible value text representing the current value in a human-readable format.</p>\n',
27+
'type': '((value: number | null, max: number) => string)',
28+
'required': false
29+
},
2430
{
2531
'name': 'max',
2632
'description': '<p>The maximum progress value.</p>\n',
@@ -60,7 +66,7 @@
6066
<MethodsTable :data="[
6167
{
6268
'name': 'getValueLabel',
63-
'description': '<p>A function to get the accessible label text representing the current value in a human-readable format.</p>\n<p>If not provided, the value label will be read as the numeric value as a percentage of the max value.</p>\n',
69+
'description': '<p>A function to get the accessible label text in a human-readable format.</p>\n<p>If not provided, the value label will be read as the numeric value as a percentage of the max value.</p>\n',
6470
'type': '(value: number | null | undefined, max: number) => string | undefined'
6571
}
6672
]" />

packages/core/src/Progress/ProgressRoot.vue

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts">
2-
import type { PrimitiveProps } from '@/Primitive'
32
import type { ComputedRef, Ref } from 'vue'
3+
import type { PrimitiveProps } from '@/Primitive'
44
import { createContext, isNullish, useForwardExpose } from '@/shared'
55
66
export type ProgressRootEmits = {
@@ -16,11 +16,15 @@ export interface ProgressRootProps extends PrimitiveProps {
1616
/** The maximum progress value. */
1717
max?: number
1818
/**
19-
* A function to get the accessible label text representing the current value in a human-readable format.
19+
* A function to get the accessible label text in a human-readable format.
2020
*
2121
* If not provided, the value label will be read as the numeric value as a percentage of the max value.
2222
*/
2323
getValueLabel?: (value: number | null | undefined, max: number) => string | undefined
24+
/**
25+
* A function to get the accessible value text representing the current value in a human-readable format.
26+
*/
27+
getValueText?: (value: number | null | undefined, max: number) => string | undefined
2428
}
2529
2630
const DEFAULT_MAX = 100
@@ -69,9 +73,9 @@ function validateMax(max: number): number {
6973
</script>
7074

7175
<script setup lang="ts">
72-
import { Primitive } from '@/Primitive'
7376
import { useVModel } from '@vueuse/core'
7477
import { computed, nextTick, watch } from 'vue'
78+
import { Primitive } from '@/Primitive'
7579
7680
const props = withDefaults(defineProps<ProgressRootProps>(), {
7781
max: DEFAULT_MAX,
@@ -143,7 +147,7 @@ provideProgressRootContext({
143147
:aria-valuemax="max"
144148
:aria-valuemin="0"
145149
:aria-valuenow="isNumber(modelValue) ? modelValue : undefined"
146-
:aria-valuetext="getValueLabel(modelValue, max)"
150+
:aria-valuetext="getValueText?.(modelValue, max)"
147151
:aria-label="getValueLabel(modelValue, max)"
148152
role="progressbar"
149153
:data-state="progressState"

packages/core/src/TagsInput/TagsInputInput.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ export interface TagsInputInputProps extends PrimitiveProps {
1313
</script>
1414

1515
<script setup lang="ts">
16-
import { Primitive } from '@/Primitive'
1716
import { nextTick, onMounted, ref } from 'vue'
17+
import { Primitive } from '@/Primitive'
1818
import { injectTagsInputRootContext } from './TagsInputRoot.vue'
1919
2020
const props = withDefaults(defineProps<TagsInputInputProps>(), {

packages/core/src/Tree/TreeRoot.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ export const [injectTreeRootContext, provideTreeRootContext] = createContext<Tre
7676
</script>
7777

7878
<script setup lang="ts" generic="T extends Record<string, any>, U extends Record<string, any>, M extends boolean = false">
79-
import type { PrimitiveProps } from '@/Primitive'
8079
import type { EventHook } from '@vueuse/core'
8180
import type { Ref } from 'vue'
81+
import type { PrimitiveProps } from '@/Primitive'
82+
import { createEventHook, useVModel } from '@vueuse/core'
83+
import { computed, nextTick, ref, toRefs } from 'vue'
8284
import { Primitive } from '@/Primitive'
8385
import { RovingFocusGroup } from '@/RovingFocus'
8486
import { MAP_KEY_TO_FOCUS_INTENT } from '@/RovingFocus/utils'
85-
import { createEventHook, useVModel } from '@vueuse/core'
86-
import { computed, nextTick, ref, toRefs } from 'vue'
8787
8888
const props = withDefaults(defineProps<TreeRootProps<T, U, M>>(), {
8989
as: 'ul',

0 commit comments

Comments
 (0)