Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/@react-aria/steplist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"@react-aria/utils": "^3.20.0",
"@react-stately/steplist": "3.0.0-alpha.1",
"@react-types/shared": "^3.21.0",
"@react-types/steplist": "^3.0.0-alpha.1",
"@swc/helpers": "^0.5.0"
},
"peerDependencies": {
Expand Down
9 changes: 6 additions & 3 deletions packages/@react-aria/steplist/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/

export * from './useStepList';
export * from './useStepListItem';
export {useStepList} from './useStepList';
export {useStepListItem} from './useStepListItem';

export type {AriaStepListProps, StepListAria} from './useStepList';
export type {AriaStepListItemProps, StepListItemAria} from './useStepListItem';
10 changes: 6 additions & 4 deletions packages/@react-aria/steplist/src/useStepList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,22 @@
* governing permissions and limitations under the License.
*/

import {AriaLabelingProps, DOMProps} from '@react-types/shared';
import {filterDOMProps, mergeProps} from '@react-aria/utils';
import {HTMLAttributes, RefObject} from 'react';
// @ts-ignore
import intlMessages from '../intl/*.json';
import {SpectrumStepListProps} from '@react-types/steplist';
import {StepListState} from '@react-stately/steplist';
import {StepListProps, StepListState} from '@react-stately/steplist';
import {useLocalizedStringFormatter} from '@react-aria/i18n';
import {useSelectableList} from '@react-aria/selection';

interface StepListAria {
export interface AriaStepListProps<T> extends StepListProps<T>, AriaLabelingProps, DOMProps {}

export interface StepListAria {
listProps: HTMLAttributes<HTMLElement>
}

export function useStepList<T>(props: SpectrumStepListProps<T>, state: StepListState<T>, ref: RefObject<HTMLOListElement>): StepListAria {
export function useStepList<T>(props: AriaStepListProps<T>, state: StepListState<T>, ref: RefObject<HTMLOListElement>): StepListAria {
let {
'aria-label': ariaLabel
} = props;
Expand Down
4 changes: 2 additions & 2 deletions packages/@react-aria/steplist/src/useStepListItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import {Key} from '@react-types/shared';
import {StepListState} from '@react-stately/steplist';
import {useSelectableItem} from '@react-aria/selection';

interface AriaStepListItemProps {
export interface AriaStepListItemProps {
key: Key
}

interface StepListItemAria {
export interface StepListItemAria {
/** Props for the step link element. */
stepProps: HTMLAttributes<HTMLElement>,
/** Props for the visually hidden element indicating the step state. */
Expand Down
1 change: 0 additions & 1 deletion packages/@react-spectrum/steplist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"@react-stately/collections": "^3.10.2",
"@react-stately/steplist": "^3.0.0-alpha.1",
"@react-types/shared": "^3.20.0",
"@react-types/steplist": "^3.0.0-alpha.1",
"@spectrum-icons/ui": "^3.5.5",
"@swc/helpers": "^0.5.0"
},
Expand Down
23 changes: 20 additions & 3 deletions packages/@react-spectrum/steplist/src/StepList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,34 @@
* governing permissions and limitations under the License.
*/

import {AriaStepListProps, useStepList} from '@react-aria/steplist';
import {classNames, useDOMRef, useStyleProps} from '@react-spectrum/utils';
import {DOMRef} from '@react-types/shared';
import {DOMRef, Orientation, StyleProps} from '@react-types/shared';
import React, {ReactElement} from 'react';
import {SpectrumStepListProps} from '@react-types/steplist';
import {StepListContext} from './StepListContext';
import {StepListItem} from './StepListItem';
import styles from '@adobe/spectrum-css-temp/components/steplist/vars.css';
import {useProviderProps} from '@react-spectrum/provider';
import {useStepList} from '@react-aria/steplist';
import {useStepListState} from '@react-stately/steplist';

export interface SpectrumStepListProps<T> extends AriaStepListProps<T>, StyleProps {
/**
* Whether the step list should be displayed with a emphasized style.
* @default false
*/
isEmphasized?: boolean,
/**
* The orientation of the step list.
* @default 'horizontal'
*/
orientation?: Orientation,
/**
* The size of the step list.
* @default 'M'
*/
size?: 'S' | 'M' | 'L' | 'XL'
}

function StepList<T extends object>(props: SpectrumStepListProps<T>, ref: DOMRef<HTMLOListElement>) {
const {size = 'M', orientation = 'horizontal'} = props;
props = useProviderProps(props);
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-spectrum/steplist/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

export {StepList} from './StepList';
export {Item} from '@react-stately/collections';
export type {SpectrumStepListProps} from '@react-types/steplist';
export type {SpectrumStepListProps} from './StepList';
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import {Item} from '@react-stately/collections';
import {Key} from '@react-types/shared';
import {Picker} from '@react-spectrum/picker';
import React, {useCallback, useMemo, useState} from 'react';
import {SpectrumStepListProps} from '@react-types/steplist';
import {StepList} from '../';
import {SpectrumStepListProps, StepList} from '../';
import {View} from '@react-spectrum/view';

const options = [{
Expand Down
1 change: 0 additions & 1 deletion packages/@react-stately/steplist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"@react-stately/list": "^3.9.2",
"@react-stately/utils": "^3.7.0",
"@react-types/shared": "^3.20.0",
"@react-types/steplist": "^3.0.0-alpha.1",
"@swc/helpers": "^0.5.0"
},
"peerDependencies": {
Expand Down
5 changes: 3 additions & 2 deletions packages/@react-stately/steplist/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/

export * from './useStepListState';
export {useStepListState} from './useStepListState';
export type {StepListProps, StepListState} from './useStepListState';
18 changes: 15 additions & 3 deletions packages/@react-stately/steplist/src/useStepListState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,32 @@
* governing permissions and limitations under the License.
*/

import {AriaStepListProps} from '@react-types/steplist';
import {Collection, Key, Node} from '@react-types/shared';
import {Collection, CollectionBase, Key, Node, SingleSelection} from '@react-types/shared';
import {SingleSelectListState, useSingleSelectListState} from '@react-stately/list';
import {useCallback, useEffect, useMemo} from 'react';
import {useControlledState} from '@react-stately/utils';

export interface StepListProps<T> extends CollectionBase<T>, SingleSelection {
/** The key of the last completed step (controlled). */
lastCompletedStep?: Key,
/** The key of the initially last completed step (uncontrolled). */
defaultLastCompletedStep?: Key,
/** Callback for when the last completed step changes. */
onLastCompletedStepChange?: (key: Key) => void,
/** Whether the step list is disabled. Steps will not be focusable or interactive. */
isDisabled?: boolean,
/** Whether the step list is read only. Steps will be focusable but non-interactive. */
isReadOnly?: boolean
}

export interface StepListState<T> extends SingleSelectListState<T> {
readonly lastCompletedStep?: Key,
setLastCompletedStep(key: Key): void,
isCompleted(key: Key): boolean,
isSelectable(key: Key): boolean
}

export function useStepListState<T extends object>(props: AriaStepListProps<T>): StepListState<T> {
export function useStepListState<T extends object>(props: StepListProps<T>): StepListState<T> {
let state = useSingleSelectListState<T>(props);

let [lastCompletedStep, setLastCompletedStep] = useControlledState<Key>(props.lastCompletedStep, props.defaultLastCompletedStep, props.onLastCompletedStepChange);
Expand Down
3 changes: 0 additions & 3 deletions packages/@react-types/steplist/README.md

This file was deleted.

20 changes: 0 additions & 20 deletions packages/@react-types/steplist/package.json

This file was deleted.

54 changes: 0 additions & 54 deletions packages/@react-types/steplist/src/index.d.ts

This file was deleted.