diff --git a/packages/docs/components/Steps.md b/packages/docs/components/Steps.md index f931ea813..1f9d058bc 100644 --- a/packages/docs/components/Steps.md +++ b/packages/docs/components/Steps.md @@ -41,9 +41,11 @@ Breaking things down into multiple steps can improve the user experience by keep | Prop name | Description | Type | Values | Default | | ----------------- | ----------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | ------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| activateOnFocus | Set the step active on navigation focus | boolean | - | false | | animateInitially | Apply animation on the initial render | boolean | - |
From config:
steps: {
  animateInitially: false
}
| | animated | Step navigation is animated | boolean | - |
From config:
steps: {
  animated: true
}
| | animation | Transition animation name | [string, string, string, string] \| [string, string] | `[next`, `prev]`, `[right`, `left`, `down`, `up]` |
From config:
steps: {
  animation: [ "slide-next", "slide-prev", "slide-down", "slide-up",]
}
| +| ariaLabel | Accessibility aria-label to be passed to the tablist wrapper element | string | - |
From config:
steps: {
  ariaLabel: undefined
}
| | ariaNextLabel | Accessibility next button aria label | string | - |
From config:
steps: {
  ariaNextLabel: "Next"
}
| | ariaPreviousLabel | Accessibility previous button aria label | string | - |
From config:
steps: {
  ariaPreviousLabel: "Previous"
}
| | hasNavigation | Next and previous buttons below the component. You can use this property if you want to use your own custom navigation items. | boolean | - | true | @@ -91,7 +93,6 @@ Breaking things down into multiple steps can improve the user experience by keep | Prop name | Description | Type | Values | Default | | --------- | ---------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------- | -| ariaRole | Role attribute to be passed to the li wrapper for better accessibility | string | - |
From config:
steps: {
  ariaRole: "tab"
}
| | clickable | Item can be used directly to navigate.
If undefined, previous steps are clickable while the others are not | boolean | - | | | component | Component to be injected. | Component | - | | | content | Text content, unnecessary when default slot is used | string | - | | @@ -103,7 +104,6 @@ Breaking things down into multiple steps can improve the user experience by keep | override | Override existing theme classes completely | boolean | - | | | props | Props to be binded to the injected component | any | - | | | step | Step marker content (when there is no icon) | number \| string | - | | -| tag | Step item tag name | DynamicComponent | - |
From config:
steps: {
  itemTag: "button"
}
| | value | Item value (it will be used as v-model of wrapper component) - default is an uuid | string\|number\|object | - | | | variant | Default style for the step.
This will override parent type.
Could be used to set a completed step to "success" for example | string | - | | | visible | Show/hide item | boolean | - | true | diff --git a/packages/oruga/src/components/steps/StepItem.vue b/packages/oruga/src/components/steps/StepItem.vue index 1e1de36d4..730850f2c 100644 --- a/packages/oruga/src/components/steps/StepItem.vue +++ b/packages/oruga/src/components/steps/StepItem.vue @@ -29,8 +29,6 @@ const props = withDefaults(defineProps>(), { visible: true, icon: () => getDefault("steps.icon"), iconPack: () => getDefault("steps.iconPack"), - tag: () => getDefault("steps.itemTag", "button"), - ariaRole: () => getDefault("steps.ariaRole", "tab"), content: undefined, component: undefined, props: undefined, @@ -48,15 +46,14 @@ const itemValue = props.value ?? useId(); const slots = useSlots(); -// provided data is a computed ref to enjure reactivity +// provided data is a computed ref to ensure reactivity const providedData = computed>(() => ({ ...props, value: itemValue, $slots: slots, - navClasses: navItemClasses.value, stepClasses: stepClasses.value, - labelClasses: stepLabelClasses.value, iconClasses: stepIconClasses.value, + labelClasses: stepLabelClasses.value, isTransitioning: isTransitioning.value, activate, deactivate, @@ -118,45 +115,40 @@ function beforeLeave(): void { // --- Computed Component Classes --- -const navItemClasses = defineClasses( - ["navItemClass", "o-steps__nav-item"], +const stepClasses = defineClasses( + ["stepClass", "o-steps__step"], [ - "navItemVariantClass", - "o-steps__nav-item--", + "stepVariantClass", + "o-steps__step--", computed(() => parent.value?.variant || props.variant), computed(() => !!parent.value?.variant || !!props.variant), ], - ["navItemActiveClass", "o-steps__nav-item--active", null, isActive], + ["stepActiveClass", "o-steps__step--active", null, isActive], + ["stepClickableClass", "o-steps__step--clickable", null, isClickable], + [ + "stepDisabledClass", + "o-steps__step--disabled", + null, + computed(() => props.disabled), + ], [ - "navItemPreviousClass", - "o-steps__nav-item--previous", + "stepPreviousClass", + "o-steps__step--previous", null, computed(() => item.value.index < parent.value?.activeIndex), ], [ - "navItemNextClass", - "o-steps__nav-item--next", + "stepNextClass", + "o-steps__step--next", null, computed(() => item.value.index > parent.value?.activeIndex), ], -); - -const stepClasses = defineClasses( - ["stepClass", "o-steps__step"], [ "stepLabelPositionClass", - "o-steps__step-label-", + "o-steps__step--label-", computed(() => parent.value?.labelPosition), computed(() => !!parent.value?.labelPosition), ], - ["stepActiveClass", "o-steps__step--active", null, isActive], - ["stepClickableClass", "o-steps__step--clickable", null, isClickable], - [ - "stepDisabledClass", - "o-steps__step--disabled", - null, - computed(() => props.disabled), - ], ); const stepLabelClasses = defineClasses([ @@ -184,6 +176,8 @@ const panelClasses = defineClasses(["stepPanelClass", "o-steps__panel"]); data-oruga="steps-item" :data-id="`steps-${item.identifier}`" :class="panelClasses" + role="tabpanel" + :hidden="!isActive" :aria-labelledby="`tab-${item.identifier}`" aria-roledescription="item"> + :previous="{ disabled: !hasPrev, action: () => activateItem(-1) }" + :next="{ disabled: !hasNext, action: () => activateItem(1) }"> diff --git a/packages/oruga/src/components/steps/examples/base.vue b/packages/oruga/src/components/steps/examples/base.vue index d6f68a710..c2a53452a 100644 --- a/packages/oruga/src/components/steps/examples/base.vue +++ b/packages/oruga/src/components/steps/examples/base.vue @@ -19,11 +19,9 @@ const nextIcon = ref("chevron-right"); const showSocial = ref(false); const labelPosition = ref<"bottom" | "left" | "right">("bottom"); -const onProfileActivate = () => { - if (enableProfileActivateEvent.value) { - alert("Profile Activated"); - } -}; +function onProfileActivate(): void { + if (enableProfileActivateEvent.value) alert("Profile Activated"); +}