From 03b15c0bec94d0ee7ab3e53896763ebf95e4d360 Mon Sep 17 00:00:00 2001 From: Jared Scott Date: Mon, 2 Sep 2024 14:53:30 +0800 Subject: [PATCH] feat: #6870 Add typing to steps.d.ts Do not implement child props at the moment --- components/lib/steps/Steps.js | 2 +- components/lib/steps/steps.d.ts | 52 ++++++++++++++++++++++++++++++--- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/components/lib/steps/Steps.js b/components/lib/steps/Steps.js index 612630824e..ce829341c3 100644 --- a/components/lib/steps/Steps.js +++ b/components/lib/steps/Steps.js @@ -33,7 +33,7 @@ export const Steps = React.memo( const getStepPT = (step, key, index) => { const stepMetaData = { - props: step.props, + // props: step.props, parent: metaData, context: { index, diff --git a/components/lib/steps/steps.d.ts b/components/lib/steps/steps.d.ts index 940514f4a5..7dff8ceb3a 100644 --- a/components/lib/steps/steps.d.ts +++ b/components/lib/steps/steps.d.ts @@ -14,6 +14,50 @@ import { PassThroughOptions } from '../passthrough'; import { PassThroughType } from '../utils/utils'; export declare type StepsPassThroughType = PassThroughType; +export declare type StepPassThroughType = PassThroughType; + +/** + * Custom passthrough(pt) option method. + */ +export interface StepPassThroughMethodOptions { + // props: StepsProps; + parent: StepsThroughMethodOptions; + context: StepContext; +} + +/** + * Defines current inline context in Steps component. + */ +export interface StepContext { + /** + * Step index. + */ + index: number; + /** + * Total number of steps + */ + count: number; + /** + * Is this the first step? + * @defaultValue false + */ + first: boolean; + /** + * Is this the last step? + * @defaultValue false + */ + last: boolean; + /** + * Is this step currently selected. + * @defaultValue false + */ + selected: boolean; + /** + * Is this step currently disabled. + * @defaultValue false + */ + disabled: boolean; +} /** * Custom passthrough(pt) option method. @@ -42,19 +86,19 @@ export interface StepsPassThroughOptions { /** * Uses to pass attributes to the action's DOM element. */ - action?: StepsPassThroughType>; + action?: StepPassThroughType>; /** * Uses to pass attributes to the step's DOM element. */ - step?: StepsPassThroughType>; + step?: StepPassThroughType>; /** * Uses to pass attributes to the label's DOM element. */ - label?: StepsPassThroughType>; + label?: StepPassThroughType>; /** * Uses to pass attributes to the icon's DOM element. */ - icon?: StepsPassThroughType | React.HTMLAttributes>; + icon?: StepPassThroughType | React.HTMLAttributes>; /** * Used to manage all lifecycle hooks * @see {@link ComponentHooks}