@react-spectrum/steplist 3.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,0CAA0C;ACZ1C;;;;;;;;;;CAUC;;;ACVD;;;;;;;;;;CAUC;AAKM,MAAM,4CAAkB,CAAA,GAAA,YAAI,EAAE,aAAa,CAAyB;;;ACf3E;;;;;;;;;;CAUC;;;;AEVD,4BAAiB;IAAG,aAAa,CAAC,WAAW,CAAC;IAC5C,gBAAgB,CAAC,eAAe,CAAC;IACjC,WAAW,CAAC,SAAS,CAAC;IACtB,YAAY,CAAC,SAAS,CAAC;AACzB;;;IDFA,2CAAe;IACb,SAAS,CAAA,GAAA,gEAAG;AACd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AEJA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AA5BA,4CAA4B,CAAC,cAAc,CAAC;AAC5C,4CAA+B,CAAC,iBAAiB,CAAC;AAClD,4CAAmC,CAAC,qBAAqB,CAAC;AAC1D,4CAAiC,CAAC,mBAAmB,CAAC;AACtD,4CAAgC,CAAC,kBAAkB,CAAC;AACpD,4CAAkC,CAAC,oBAAoB,CAAC;AACxD,4CAA+B,CAAC,iBAAiB,CAAC;AAClD,4CAAgC,CAAC,kBAAkB,CAAC;AACpD,4CAAgC,CAAC,kBAAkB,CAAC;AACpD,4CAA0B,CAAC,Y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U,CAAC;","sources":["packages/@react-spectrum/steplist/src/index.ts","packages/@react-spectrum/steplist/src/StepList.tsx","packages/@react-spectrum/steplist/src/StepListContext.ts","packages/@react-spectrum/steplist/src/StepListItem.tsx","packages/@react-spectrum/steplist/intl/index.js","packages/@react-spectrum/steplist/intl/en-US.json","packages/@adobe/spectrum-css-temp/components/steplist/vars.css"],"sourcesContent":["/*\n * Copyright 2023 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/// <reference types=\"css-module-types\" />\n\nexport {StepList} from './StepList';\nexport {Item} from '@react-stately/collections';\nexport type {SpectrumStepListProps} from './StepList';\n","/*\n * Copyright 2023 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaStepListProps, useStepList} from '@react-aria/steplist';\nimport {classNames, useDOMRef, useStyleProps} from '@react-spectrum/utils';\nimport {DOMRef, Orientation, StyleProps} from '@react-types/shared';\nimport React, {ReactElement} from 'react';\nimport {StepListContext} from './StepListContext';\nimport {StepListItem} from './StepListItem';\nimport styles from '@adobe/spectrum-css-temp/components/steplist/vars.css';\nimport {useProviderProps} from '@react-spectrum/provider';\nimport {useStepListState} from '@react-stately/steplist';\n\nexport interface SpectrumStepListProps<T> extends AriaStepListProps<T>, StyleProps {\n /**\n * Whether the step list should be displayed with a emphasized style.\n * @default false\n */\n isEmphasized?: boolean,\n /**\n * The orientation of the step list.\n * @default 'horizontal'\n */\n orientation?: Orientation,\n /**\n * The size of the step list.\n * @default 'M'\n */\n size?: 'S' | 'M' | 'L' | 'XL'\n}\n\nfunction StepList<T extends object>(props: SpectrumStepListProps<T>, ref: DOMRef<HTMLOListElement>) {\n const {size = 'M', orientation = 'horizontal'} = props;\n props = useProviderProps(props);\n let {styleProps} = useStyleProps(props);\n let domRef = useDOMRef(ref);\n\n let state = useStepListState(props);\n let {listProps} = useStepList(props, state, domRef);\n\n const {isDisabled, isEmphasized, isReadOnly} = props;\n\n return (\n <ol\n {...listProps}\n {...styleProps}\n ref={domRef}\n className={classNames(styles, 'spectrum-Steplist', styleProps.className, {\n 'spectrum-Steplist--interactive': !isReadOnly && !isDisabled,\n 'spectrum-Steplist--small': size === 'S',\n 'spectrum-Steplist--medium': size === 'M',\n 'spectrum-Steplist--large': size === 'L',\n 'spectrum-Steplist--xlarge': size === 'XL',\n 'spectrum-Steplist--vertical': orientation === 'vertical'\n })}>\n <StepListContext.Provider value={state}>\n {[...state.collection].map((item) => (\n <StepListItem\n key={item.key}\n isDisabled={isDisabled}\n isEmphasized={isEmphasized}\n isReadOnly={isReadOnly}\n item={item} />\n )\n )}\n </StepListContext.Provider>\n </ol>\n );\n}\n\nconst _StepList = React.forwardRef(StepList) as <T>(props: SpectrumStepListProps<T> & {ref?: DOMRef<HTMLOListElement>}) => ReactElement;\nexport {_StepList as StepList};\n","/*\n * Copyright 202 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport React from 'react';\nimport {StepListState} from '@react-stately/steplist';\n\nexport const StepListContext = React.createContext<StepListState<unknown>>(null);\n","/*\n * Copyright 2023 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport ChevronRightMedium from '@spectrum-icons/ui/ChevronRightMedium';\nimport {classNames} from '@react-spectrum/utils';\nimport {FocusRing} from '@react-aria/focus';\nimport intlMessages from '../intl';\nimport {mergeProps} from '@react-aria/utils';\nimport {Node} from '@react-types/shared';\nimport React, {useContext, useRef} from 'react';\nimport {StepListContext} from './StepListContext';\nimport styles from '@adobe/spectrum-css-temp/components/steplist/vars.css';\nimport {useHover} from '@react-aria/interactions';\nimport {useLocale, useLocalizedStringFormatter, useNumberFormatter} from '@react-aria/i18n';\nimport {useStepListItem} from '@react-aria/steplist';\nimport {VisuallyHidden} from '@react-aria/visually-hidden';\n\ninterface SpectrumStepListItemProps<T> {\n item: Node<T>,\n isDisabled?: boolean,\n isEmphasized?: boolean,\n isReadOnly?: boolean\n}\n\nexport function StepListItem<T>(props: SpectrumStepListItemProps<T>) {\n let {\n isDisabled,\n isEmphasized,\n item\n } = props;\n let {key} = item;\n\n let ref = useRef();\n let {direction} = useLocale();\n let state = useContext(StepListContext);\n const isCompleted = state.isCompleted(key);\n const isItemDisabled = isDisabled || state.disabledKeys.has(key);\n let {stepProps, stepStateProps} = useStepListItem({...props, key}, state, ref);\n\n let {hoverProps, isHovered} = useHover(props);\n const isSelected = state.selectedKey === key;\n\n let stepStateText = '';\n const stringFormatter = useLocalizedStringFormatter(intlMessages);\n const numberFormatter = useNumberFormatter();\n\n if (isSelected) {\n stepStateText = stringFormatter.format('current');\n } else if (isCompleted) {\n stepStateText = stringFormatter.format('completed');\n } else {\n stepStateText = stringFormatter.format('notCompleted');\n }\n\n return (\n <li\n key={key}\n className={\n classNames(\n styles,\n 'spectrum-Steplist-item'\n )\n }>\n <FocusRing within focusRingClass={classNames(styles, 'focus-ring')}>\n <a\n aria-labelledby={`step-marker-${key} step-label-${key}`}\n ref={ref}\n {...mergeProps(hoverProps, stepProps)}\n className={classNames(\n styles,\n 'spectrum-Steplist-link',\n {\n 'is-selected': isSelected && !isItemDisabled,\n 'is-disabled': isItemDisabled,\n 'is-hovered': isHovered,\n 'is-emphasized': isEmphasized && isSelected,\n 'is-completed': isCompleted\n }\n )}>\n <VisuallyHidden {...stepStateProps}>{stepStateText}</VisuallyHidden>\n <span id={`step-marker-${key}`} aria-hidden=\"true\" className={classNames(styles, 'spectrum-Steplist-marker')}>{numberFormatter.format((item.index || 0) + 1)}</span>\n <span id={`step-label-${key}`} aria-hidden=\"true\" className={classNames(styles, 'spectrum-Steplist-label')}>\n {item.rendered}\n </span>\n </a>\n </FocusRing>\n <span\n className={classNames(\n styles,\n 'spectrum-Steplist-segment', {\n 'is-completed': isCompleted\n })} >\n <ChevronRightMedium\n UNSAFE_className={classNames(styles, 'spectrum-Steplist-chevron', {\n 'is-reversed': direction === 'rtl'\n })} />\n </span>\n </li>\n );\n}\n","import enUS from './en-US.json';\n\nexport default {\n 'en-US': enUS\n};\n","{\n \"completed\": \"Completed: \",\n \"notCompleted\": \"Not completed: \",\n \"current\": \"Current: \",\n \"steplist\": \"Step List\"\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n@import './index.css';\n@import './skin.css';\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -0,0 +1,26 @@
1
+ import { AriaStepListProps } from "@react-aria/steplist";
2
+ import { DOMRef, Orientation, StyleProps } from "@react-types/shared";
3
+ import { ReactElement } from "react";
4
+ export interface SpectrumStepListProps<T> extends AriaStepListProps<T>, StyleProps {
5
+ /**
6
+ * Whether the step list should be displayed with a emphasized style.
7
+ * @default false
8
+ */
9
+ isEmphasized?: boolean;
10
+ /**
11
+ * The orientation of the step list.
12
+ * @default 'horizontal'
13
+ */
14
+ orientation?: Orientation;
15
+ /**
16
+ * The size of the step list.
17
+ * @default 'M'
18
+ */
19
+ size?: 'S' | 'M' | 'L' | 'XL';
20
+ }
21
+ export const StepList: <T>(props: SpectrumStepListProps<T> & {
22
+ ref?: DOMRef<HTMLOListElement>;
23
+ }) => ReactElement;
24
+ export { Item } from '@react-stately/collections';
25
+
26
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;AGsBA,uCAAuC,CAAC,CAAE,SAAQ,kBAAkB,CAAC,CAAC,EAAE,UAAU;IAChF;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;;OAGG;IACH,IAAI,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,CAAA;CAC9B;AAyCD,OAAA,MAAM;UAAuF,OAAO,gBAAgB,CAAC;MAAM,YAAY,CAAC;AChExI,OAAO,EAAC,IAAI,EAAC,MAAM,4BAA4B,CAAC","sources":["packages/@react-spectrum/steplist/src/packages/@react-spectrum/steplist/src/StepListContext.ts","packages/@react-spectrum/steplist/src/packages/@react-spectrum/steplist/intl/index.js","packages/@react-spectrum/steplist/src/packages/@react-spectrum/steplist/src/StepListItem.tsx","packages/@react-spectrum/steplist/src/packages/@react-spectrum/steplist/src/StepList.tsx","packages/@react-spectrum/steplist/src/packages/@react-spectrum/steplist/src/index.ts","packages/@react-spectrum/steplist/src/index.ts"],"sourcesContent":[null,null,null,null,null,"/*\n * Copyright 2023 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/// <reference types=\"css-module-types\" />\n\nexport {StepList} from './StepList';\nexport {Item} from '@react-stately/collections';\nexport type {SpectrumStepListProps} from './StepList';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@react-spectrum/steplist",
3
+ "version": "3.0.0-alpha.0",
4
+ "description": "Spectrum UI components in React",
5
+ "license": "Apache-2.0",
6
+ "main": "dist/main.js",
7
+ "module": "dist/module.js",
8
+ "exports": {
9
+ "types": "./dist/types.d.ts",
10
+ "import": "./dist/import.mjs",
11
+ "require": "./dist/main.js"
12
+ },
13
+ "types": "dist/types.d.ts",
14
+ "source": "src/index.ts",
15
+ "files": [
16
+ "dist",
17
+ "src"
18
+ ],
19
+ "sideEffects": [
20
+ "*.css"
21
+ ],
22
+ "targets": {
23
+ "main": {
24
+ "includeNodeModules": [
25
+ "@adobe/spectrum-css-temp"
26
+ ]
27
+ },
28
+ "module": {
29
+ "includeNodeModules": [
30
+ "@adobe/spectrum-css-temp"
31
+ ]
32
+ }
33
+ },
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/adobe/react-spectrum"
37
+ },
38
+ "dependencies": {
39
+ "@react-aria/focus": "^3.15.0",
40
+ "@react-aria/i18n": "^3.9.0",
41
+ "@react-aria/interactions": "^3.20.0",
42
+ "@react-aria/steplist": "3.0.0-alpha.0",
43
+ "@react-aria/utils": "^3.22.0",
44
+ "@react-aria/visually-hidden": "^3.8.7",
45
+ "@react-spectrum/utils": "^3.11.2",
46
+ "@react-stately/collections": "^3.10.3",
47
+ "@react-stately/steplist": "3.0.0-alpha.0",
48
+ "@react-types/shared": "^3.22.0",
49
+ "@spectrum-icons/ui": "^3.6.2",
50
+ "@swc/helpers": "^0.5.0"
51
+ },
52
+ "devDependencies": {
53
+ "@adobe/spectrum-css-temp": "^3.0.0-alpha.1"
54
+ },
55
+ "peerDependencies": {
56
+ "@react-spectrum/provider": "^3.0.0",
57
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0",
58
+ "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
59
+ },
60
+ "publishConfig": {
61
+ "access": "public"
62
+ },
63
+ "gitHead": "9ce2f674eab2cc8912800d3162dcf00a1ce94274"
64
+ }
@@ -0,0 +1,81 @@
1
+ /*
2
+ * Copyright 2023 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+
13
+ import {AriaStepListProps, useStepList} from '@react-aria/steplist';
14
+ import {classNames, useDOMRef, useStyleProps} from '@react-spectrum/utils';
15
+ import {DOMRef, Orientation, StyleProps} from '@react-types/shared';
16
+ import React, {ReactElement} from 'react';
17
+ import {StepListContext} from './StepListContext';
18
+ import {StepListItem} from './StepListItem';
19
+ import styles from '@adobe/spectrum-css-temp/components/steplist/vars.css';
20
+ import {useProviderProps} from '@react-spectrum/provider';
21
+ import {useStepListState} from '@react-stately/steplist';
22
+
23
+ export interface SpectrumStepListProps<T> extends AriaStepListProps<T>, StyleProps {
24
+ /**
25
+ * Whether the step list should be displayed with a emphasized style.
26
+ * @default false
27
+ */
28
+ isEmphasized?: boolean,
29
+ /**
30
+ * The orientation of the step list.
31
+ * @default 'horizontal'
32
+ */
33
+ orientation?: Orientation,
34
+ /**
35
+ * The size of the step list.
36
+ * @default 'M'
37
+ */
38
+ size?: 'S' | 'M' | 'L' | 'XL'
39
+ }
40
+
41
+ function StepList<T extends object>(props: SpectrumStepListProps<T>, ref: DOMRef<HTMLOListElement>) {
42
+ const {size = 'M', orientation = 'horizontal'} = props;
43
+ props = useProviderProps(props);
44
+ let {styleProps} = useStyleProps(props);
45
+ let domRef = useDOMRef(ref);
46
+
47
+ let state = useStepListState(props);
48
+ let {listProps} = useStepList(props, state, domRef);
49
+
50
+ const {isDisabled, isEmphasized, isReadOnly} = props;
51
+
52
+ return (
53
+ <ol
54
+ {...listProps}
55
+ {...styleProps}
56
+ ref={domRef}
57
+ className={classNames(styles, 'spectrum-Steplist', styleProps.className, {
58
+ 'spectrum-Steplist--interactive': !isReadOnly && !isDisabled,
59
+ 'spectrum-Steplist--small': size === 'S',
60
+ 'spectrum-Steplist--medium': size === 'M',
61
+ 'spectrum-Steplist--large': size === 'L',
62
+ 'spectrum-Steplist--xlarge': size === 'XL',
63
+ 'spectrum-Steplist--vertical': orientation === 'vertical'
64
+ })}>
65
+ <StepListContext.Provider value={state}>
66
+ {[...state.collection].map((item) => (
67
+ <StepListItem
68
+ key={item.key}
69
+ isDisabled={isDisabled}
70
+ isEmphasized={isEmphasized}
71
+ isReadOnly={isReadOnly}
72
+ item={item} />
73
+ )
74
+ )}
75
+ </StepListContext.Provider>
76
+ </ol>
77
+ );
78
+ }
79
+
80
+ const _StepList = React.forwardRef(StepList) as <T>(props: SpectrumStepListProps<T> & {ref?: DOMRef<HTMLOListElement>}) => ReactElement;
81
+ export {_StepList as StepList};
@@ -0,0 +1,16 @@
1
+ /*
2
+ * Copyright 202 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+
13
+ import React from 'react';
14
+ import {StepListState} from '@react-stately/steplist';
15
+
16
+ export const StepListContext = React.createContext<StepListState<unknown>>(null);
@@ -0,0 +1,108 @@
1
+ /*
2
+ * Copyright 2023 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ import ChevronRightMedium from '@spectrum-icons/ui/ChevronRightMedium';
13
+ import {classNames} from '@react-spectrum/utils';
14
+ import {FocusRing} from '@react-aria/focus';
15
+ import intlMessages from '../intl';
16
+ import {mergeProps} from '@react-aria/utils';
17
+ import {Node} from '@react-types/shared';
18
+ import React, {useContext, useRef} from 'react';
19
+ import {StepListContext} from './StepListContext';
20
+ import styles from '@adobe/spectrum-css-temp/components/steplist/vars.css';
21
+ import {useHover} from '@react-aria/interactions';
22
+ import {useLocale, useLocalizedStringFormatter, useNumberFormatter} from '@react-aria/i18n';
23
+ import {useStepListItem} from '@react-aria/steplist';
24
+ import {VisuallyHidden} from '@react-aria/visually-hidden';
25
+
26
+ interface SpectrumStepListItemProps<T> {
27
+ item: Node<T>,
28
+ isDisabled?: boolean,
29
+ isEmphasized?: boolean,
30
+ isReadOnly?: boolean
31
+ }
32
+
33
+ export function StepListItem<T>(props: SpectrumStepListItemProps<T>) {
34
+ let {
35
+ isDisabled,
36
+ isEmphasized,
37
+ item
38
+ } = props;
39
+ let {key} = item;
40
+
41
+ let ref = useRef();
42
+ let {direction} = useLocale();
43
+ let state = useContext(StepListContext);
44
+ const isCompleted = state.isCompleted(key);
45
+ const isItemDisabled = isDisabled || state.disabledKeys.has(key);
46
+ let {stepProps, stepStateProps} = useStepListItem({...props, key}, state, ref);
47
+
48
+ let {hoverProps, isHovered} = useHover(props);
49
+ const isSelected = state.selectedKey === key;
50
+
51
+ let stepStateText = '';
52
+ const stringFormatter = useLocalizedStringFormatter(intlMessages);
53
+ const numberFormatter = useNumberFormatter();
54
+
55
+ if (isSelected) {
56
+ stepStateText = stringFormatter.format('current');
57
+ } else if (isCompleted) {
58
+ stepStateText = stringFormatter.format('completed');
59
+ } else {
60
+ stepStateText = stringFormatter.format('notCompleted');
61
+ }
62
+
63
+ return (
64
+ <li
65
+ key={key}
66
+ className={
67
+ classNames(
68
+ styles,
69
+ 'spectrum-Steplist-item'
70
+ )
71
+ }>
72
+ <FocusRing within focusRingClass={classNames(styles, 'focus-ring')}>
73
+ <a
74
+ aria-labelledby={`step-marker-${key} step-label-${key}`}
75
+ ref={ref}
76
+ {...mergeProps(hoverProps, stepProps)}
77
+ className={classNames(
78
+ styles,
79
+ 'spectrum-Steplist-link',
80
+ {
81
+ 'is-selected': isSelected && !isItemDisabled,
82
+ 'is-disabled': isItemDisabled,
83
+ 'is-hovered': isHovered,
84
+ 'is-emphasized': isEmphasized && isSelected,
85
+ 'is-completed': isCompleted
86
+ }
87
+ )}>
88
+ <VisuallyHidden {...stepStateProps}>{stepStateText}</VisuallyHidden>
89
+ <span id={`step-marker-${key}`} aria-hidden="true" className={classNames(styles, 'spectrum-Steplist-marker')}>{numberFormatter.format((item.index || 0) + 1)}</span>
90
+ <span id={`step-label-${key}`} aria-hidden="true" className={classNames(styles, 'spectrum-Steplist-label')}>
91
+ {item.rendered}
92
+ </span>
93
+ </a>
94
+ </FocusRing>
95
+ <span
96
+ className={classNames(
97
+ styles,
98
+ 'spectrum-Steplist-segment', {
99
+ 'is-completed': isCompleted
100
+ })} >
101
+ <ChevronRightMedium
102
+ UNSAFE_className={classNames(styles, 'spectrum-Steplist-chevron', {
103
+ 'is-reversed': direction === 'rtl'
104
+ })} />
105
+ </span>
106
+ </li>
107
+ );
108
+ }
package/src/index.ts ADDED
@@ -0,0 +1,17 @@
1
+ /*
2
+ * Copyright 2023 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+
13
+ /// <reference types="css-module-types" />
14
+
15
+ export {StepList} from './StepList';
16
+ export {Item} from '@react-stately/collections';
17
+ export type {SpectrumStepListProps} from './StepList';