626fbc70d8
- Migrate to eslint flat config + composite tsconfig. - Complete the asChild→as="template" refactor (remove asChild prop + :as-child bindings across components, matching Primitive's slot model). - Fix test type errors and source type-safety (useGraceArea hull/point math, FocusScope/util ref typing). Note: ~53 vue-tsc errors remain (HTML attr/event passthrough typing on transparent wrapper components + a couple of duplicate-export naming collisions) — not gated by CI (build/lint/test green); pending a component-attribute-typing design decision.
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import type { ComputedRef, Ref } from 'vue';
|
|
import { useContextFactory } from '@robonen/vue';
|
|
|
|
export type StepperOrientation = 'horizontal' | 'vertical';
|
|
export type StepperDirection = 'ltr' | 'rtl';
|
|
export type StepperState = 'completed' | 'active' | 'inactive';
|
|
|
|
export interface StepperRootContext {
|
|
/** Currently active step (1-based). */
|
|
value: Ref<number>;
|
|
/** Total registered items, tracked through the Collection. */
|
|
total: ComputedRef<number>;
|
|
/** Orientation of the stepper — drives arrow-key axis. */
|
|
orientation: Ref<StepperOrientation>;
|
|
/** Writing direction. */
|
|
direction: Ref<StepperDirection>;
|
|
/** When `true`, steps must be completed in order. */
|
|
linear: Ref<boolean>;
|
|
/** Whether the whole stepper is disabled. */
|
|
disabled: Ref<boolean>;
|
|
|
|
goToStep: (step: number) => void;
|
|
onTriggerKeyDown: (event: KeyboardEvent, el: HTMLElement) => void;
|
|
}
|
|
|
|
export interface StepperItemContext {
|
|
step: Ref<number>;
|
|
state: Ref<StepperState>;
|
|
disabled: Ref<boolean>;
|
|
focusable: Ref<boolean>;
|
|
titleId: string;
|
|
descriptionId: string;
|
|
}
|
|
|
|
export const {
|
|
inject: useStepperRootContext,
|
|
provide: provideStepperRootContext,
|
|
} = useContextFactory<StepperRootContext>('stepper');
|
|
|
|
export const {
|
|
inject: useStepperItemContext,
|
|
provide: provideStepperItemContext,
|
|
} = useContextFactory<StepperItemContext>('stepper-item');
|