WlStepper

A step list and current panel with application-controlled transitions.
Components / Navigation v1.4.0

Appearance

Bind the current index and put each step’s fields in the panel slot. The application decides when Next is available and what a transition does.

Enter a workspace name to continue to Review.
Full example
<script setup lang="ts">
import { WlField, WlInput, type WlStepItem, WlStepper } from "legato-ui";
import { computed, ref } from "vue";

const props = { preview: {} as Record<string, unknown> };
const current = ref(0);
const name = ref("");
const canAdvance = computed(() => Boolean(name.value.trim()) && props.preview?.canGoNext !== false);
const forwardedPreview = computed(() => {
  const attributes = { ...props.preview };
  delete attributes.canGoNext;
  return attributes;
});
const items = computed<readonly WlStepItem[]>(() => [
  { key: "workspace", label: "Workspace" },
  { key: "review", label: "Review", disabled: current.value === 0 && !canAdvance.value }
]);
</script>

<template>
  <WlStepper
    v-model:current="current"
    :items="items"
    :can-go-next="canAdvance"
    clickable
    v-bind="forwardedPreview"
  >
    <template #default="{ index }">
      <WlField
        v-if="index === 0"
        v-slot="{ id, ariaDescribedby }"
        label="Workspace name"
        hint="Enter a workspace name to continue to Review."
        required
      >
        <WlInput
          :id="id"
          v-model="name"
          :aria-describedby="ariaDescribedby"
          required
        />
      </WlField>
      <p v-else class="wl-text-body">{{ name }}</p>
    </template>
  </WlStepper>
</template>

Behavior

Enter a workspace name to continue to Review.
Full example
<script setup lang="ts">
import { WlField, WlInput, type WlStepItem, WlStepper } from "legato-ui";
import { computed, ref } from "vue";

const props = { preview: {} as Record<string, unknown> };
const current = ref(0);
const name = ref("");
const canAdvance = computed(() => Boolean(name.value.trim()) && props.preview?.canGoNext !== false);
const forwardedPreview = computed(() => {
  const attributes = { ...props.preview };
  delete attributes.canGoNext;
  return attributes;
});
const items = computed<readonly WlStepItem[]>(() => [
  { key: "workspace", label: "Workspace" },
  { key: "review", label: "Review", disabled: current.value === 0 && !canAdvance.value }
]);
</script>

<template>
  <WlStepper
    v-model:current="current"
    :items="items"
    :can-go-next="canAdvance"
    clickable
    v-bind="forwardedPreview"
  >
    <template #default="{ index }">
      <WlField
        v-if="index === 0"
        v-slot="{ id, ariaDescribedby }"
        label="Workspace name"
        hint="Enter a workspace name to continue to Review."
        required
      >
        <WlInput
          :id="id"
          v-model="name"
          :aria-describedby="ariaDescribedby"
          required
        />
      </WlField>
      <p v-else class="wl-text-body">{{ name }}</p>
    </template>
  </WlStepper>
</template>

Custom step actions

Confirm access, review the setting, then save. The actions slot supplies the enabled Back and Next callbacks.

  1. Workspace accessCurrent step
  2. Review
Full example
<script setup lang="ts">
import { WlButton, WlCheckbox, type WlStepItem, WlStepper } from "legato-ui";
import { computed, ref } from "vue";

const current = ref(0);
const confirmed = ref(false);
const saved = ref(false);
const items = computed<readonly WlStepItem[]>(() => [
  { key: "access", label: "Workspace access" },
  { key: "review", label: "Review" }
]);
</script>

<template>
  <div class="wl-stack" data-space="sm">
    <WlStepper
      v-model:current="current"
      :items="items"
      :can-go-next="confirmed"
      orientation="vertical"
    >
      <template #default="{ index }">
        <WlCheckbox v-if="index === 0" v-model="confirmed">{{ "Allow the team to open this workspace" }}</WlCheckbox>
        <p v-else>{{ "The team can open the workspace after you save." }}</p>
      </template>
      <template #actions="{ canGoBack, canGoNext, back, next }">
        <WlButton v-if="canGoBack" @click="back">{{ "Edit access" }}</WlButton>
        <WlButton
          v-if="current === 0"
          variant="primary"
          :disabled="!canGoNext"
          @click="next"
        >
          {{ "Review access" }}
        </WlButton>
        <WlButton v-else variant="primary" @click="saved = true">{{ "Save" }}</WlButton>
      </template>
    </WlStepper>
    <output v-if="saved" aria-label="Changes saved">{{ "Changes saved" }}</output>
  </div>
</template>