@atlaskit/progress-indicator 9.0.5 → 9.2.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.
- package/CHANGELOG.md +40 -0
- package/codemods/{9.0.0-import-rename.ts → 9.0.0-import-rename.tsx} +0 -0
- package/codemods/__tests__/{9.0.0-import-rename.ts → 9.0.0-import-rename.tsx} +0 -0
- package/dist/cjs/components/appearances.js +54 -0
- package/dist/cjs/components/constants.js +22 -0
- package/dist/cjs/components/indicator.js +70 -0
- package/dist/cjs/components/progress-dots.js +164 -0
- package/dist/cjs/components/types.js +5 -0
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/types.js +5 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/appearances.js +40 -0
- package/dist/es2019/components/constants.js +12 -0
- package/dist/es2019/components/indicator.js +51 -0
- package/dist/es2019/components/progress-dots.js +135 -0
- package/dist/es2019/components/types.js +1 -0
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/types.js +1 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/appearances.js +42 -0
- package/dist/esm/components/constants.js +12 -0
- package/dist/esm/components/indicator.js +53 -0
- package/dist/esm/components/progress-dots.js +140 -0
- package/dist/esm/components/types.js +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/types.js +1 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/components/appearances.d.ts +2 -0
- package/dist/types/components/constants.d.ts +12 -0
- package/dist/types/components/indicator.d.ts +14 -0
- package/dist/types/components/progress-dots.d.ts +10 -0
- package/dist/types/components/types.d.ts +3 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/types.d.ts +44 -0
- package/package.json +28 -10
- package/types/package.json +7 -0
- package/dist/cjs/components/Dots.js +0 -201
- package/dist/cjs/styled/Dots.js +0 -120
- package/dist/es2019/components/Dots.js +0 -145
- package/dist/es2019/styled/Dots.js +0 -122
- package/dist/esm/components/Dots.js +0 -178
- package/dist/esm/styled/Dots.js +0 -93
- package/dist/types/components/Dots.d.ts +0 -51
- package/dist/types/styled/Dots.d.ts +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# @atlaskit/progress-indicator
|
|
2
2
|
|
|
3
|
+
## 9.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`303e4bf4aa5`](https://bitbucket.org/atlassian/atlassian-frontend/commits/303e4bf4aa5) - [ux] Instrumented progress-indicator with the new theming package, `@atlaskit/tokens`.
|
|
8
|
+
|
|
9
|
+
New tokens will be visible only in applications configured to use the new Tokens API (currently in alpha).
|
|
10
|
+
These changes are intended to be interoperable with the legacy theme implementation. Legacy dark mode users should expect no visual or breaking changes.
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [`58884c2f6c1`](https://bitbucket.org/atlassian/atlassian-frontend/commits/58884c2f6c1) - Internal code change turning on a new linting rule.
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
17
|
+
## 9.1.2
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- [`2b2290121eb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2b2290121eb) - Raised the minimum version carat range of focus ring to latest.
|
|
22
|
+
|
|
23
|
+
## 9.1.1
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- [`7d89d624097`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7d89d624097) - Fix for focus being incorrectly retained when indicators were not interactive.
|
|
28
|
+
|
|
29
|
+
## 9.1.0
|
|
30
|
+
|
|
31
|
+
### Minor Changes
|
|
32
|
+
|
|
33
|
+
- [`947ba5b11f0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/947ba5b11f0) - The component has undergone an internal refactor. The following changes need to be called out:
|
|
34
|
+
|
|
35
|
+
- `styled-components` has been removed from the package in favour of `@emotion/core`.
|
|
36
|
+
- The component now supports a `testId` prop in line with other Design System components. This can be used for automated testing.
|
|
37
|
+
- Focus ring colors have been normalised to be the same across all appearance types of the component.
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- Updated dependencies
|
|
42
|
+
|
|
3
43
|
## 9.0.5
|
|
4
44
|
|
|
5
45
|
### Patch Changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getBgColor = void 0;
|
|
7
|
+
|
|
8
|
+
var _colors = require("@atlaskit/theme/colors");
|
|
9
|
+
|
|
10
|
+
var _components = require("@atlaskit/theme/components");
|
|
11
|
+
|
|
12
|
+
// TODO Token usages are not consistent for dots https://product-fabric.atlassian.net/browse/DSP-3180
|
|
13
|
+
var colorMap = {
|
|
14
|
+
default: (0, _components.themed)({
|
|
15
|
+
light: "var(--ds-background-neutral, ".concat(_colors.N50, ")"),
|
|
16
|
+
dark: "var(--ds-background-neutral, ".concat(_colors.DN70, ")")
|
|
17
|
+
}),
|
|
18
|
+
help: (0, _components.themed)({
|
|
19
|
+
light: "var(--ds-background-neutral, ".concat(_colors.P75, ")"),
|
|
20
|
+
dark: "var(--ds-background-neutral, ".concat(_colors.DN70, ")")
|
|
21
|
+
}),
|
|
22
|
+
inverted: (0, _components.themed)({
|
|
23
|
+
light: "var(--ds-icon-subtle, rgba(255, 255, 255, 0.4))",
|
|
24
|
+
dark: "var(--ds-icon-subtle, ".concat(_colors.DN300A, ")")
|
|
25
|
+
}),
|
|
26
|
+
primary: (0, _components.themed)({
|
|
27
|
+
light: "var(--ds-background-neutral, ".concat(_colors.B75, ")"),
|
|
28
|
+
dark: "var(--ds-background-neutral, ".concat(_colors.DN70, ")")
|
|
29
|
+
})
|
|
30
|
+
};
|
|
31
|
+
var selectedColorMap = {
|
|
32
|
+
default: (0, _components.themed)({
|
|
33
|
+
light: "var(--ds-icon, ".concat(_colors.N900, ")"),
|
|
34
|
+
dark: "var(--ds-icon, ".concat(_colors.DN600, ")")
|
|
35
|
+
}),
|
|
36
|
+
help: (0, _components.themed)({
|
|
37
|
+
light: "var(--ds-icon-discovery, ".concat(_colors.P400, ")"),
|
|
38
|
+
dark: "var(--ds-icon-discovery, ".concat(_colors.P300, ")")
|
|
39
|
+
}),
|
|
40
|
+
inverted: (0, _components.themed)({
|
|
41
|
+
light: "var(--ds-icon-inverse, ".concat(_colors.N0, ")"),
|
|
42
|
+
dark: "var(--ds-icon-inverse, ".concat(_colors.DN30, ")")
|
|
43
|
+
}),
|
|
44
|
+
primary: (0, _components.themed)({
|
|
45
|
+
light: "var(--ds-icon-brand, ".concat(_colors.B400, ")"),
|
|
46
|
+
dark: "var(--ds-icon-brand, ".concat(_colors.B100, ")")
|
|
47
|
+
})
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
var getBgColor = function getBgColor(appearance, isSelected) {
|
|
51
|
+
return isSelected ? selectedColorMap[appearance] : colorMap[appearance];
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
exports.getBgColor = getBgColor;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.varDotsSize = exports.varDotsMargin = exports.spacingDivision = exports.sizes = void 0;
|
|
7
|
+
var sizes = {
|
|
8
|
+
small: 4,
|
|
9
|
+
default: 8,
|
|
10
|
+
large: 12
|
|
11
|
+
};
|
|
12
|
+
exports.sizes = sizes;
|
|
13
|
+
var spacingDivision = {
|
|
14
|
+
comfortable: 1,
|
|
15
|
+
cozy: 2,
|
|
16
|
+
compact: 4
|
|
17
|
+
};
|
|
18
|
+
exports.spacingDivision = spacingDivision;
|
|
19
|
+
var varDotsSize = '--ds-dots-size';
|
|
20
|
+
exports.varDotsSize = varDotsSize;
|
|
21
|
+
var varDotsMargin = '--ds-dots-margin';
|
|
22
|
+
exports.varDotsMargin = varDotsMargin;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.PresentationalIndicator = exports.ButtonIndicator = void 0;
|
|
9
|
+
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
|
|
12
|
+
var _core = require("@emotion/core");
|
|
13
|
+
|
|
14
|
+
var _focusRing = _interopRequireDefault(require("@atlaskit/focus-ring"));
|
|
15
|
+
|
|
16
|
+
var _constants = require("./constants");
|
|
17
|
+
|
|
18
|
+
/** @jsx jsx */
|
|
19
|
+
var commonStyles = (0, _core.css)({
|
|
20
|
+
width: "var(".concat(_constants.varDotsSize, ")"),
|
|
21
|
+
height: "var(".concat(_constants.varDotsSize, ")"),
|
|
22
|
+
position: 'relative',
|
|
23
|
+
borderRadius: '50%',
|
|
24
|
+
'&::before': {
|
|
25
|
+
display: 'block',
|
|
26
|
+
width: "calc(var(".concat(_constants.varDotsSize, ") + var(").concat(_constants.varDotsMargin, "))"),
|
|
27
|
+
height: "calc(var(".concat(_constants.varDotsSize, ") + var(").concat(_constants.varDotsMargin, "))"),
|
|
28
|
+
position: 'absolute',
|
|
29
|
+
top: "calc(-1 * var(".concat(_constants.varDotsMargin, ") / 2)"),
|
|
30
|
+
left: "calc(-1 * var(".concat(_constants.varDotsMargin, ") / 2)"),
|
|
31
|
+
content: '""'
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
var buttonStyles = (0, _core.css)({
|
|
35
|
+
padding: 0,
|
|
36
|
+
border: 0,
|
|
37
|
+
cursor: 'pointer',
|
|
38
|
+
outline: 0
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* __Presentational indicator__
|
|
42
|
+
*
|
|
43
|
+
* A presentational indicator with no interactivity
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
var PresentationalIndicator = function PresentationalIndicator(props // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
47
|
+
) {
|
|
48
|
+
return (0, _core.jsx)("div", (0, _extends2.default)({}, props, {
|
|
49
|
+
css: commonStyles,
|
|
50
|
+
role: "presentation"
|
|
51
|
+
}));
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* __Button indicator__
|
|
55
|
+
*
|
|
56
|
+
* An interactive indicator.
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
exports.PresentationalIndicator = PresentationalIndicator;
|
|
61
|
+
|
|
62
|
+
var ButtonIndicator = function ButtonIndicator(props) {
|
|
63
|
+
return (0, _core.jsx)(_focusRing.default, null, (0, _core.jsx)("button", (0, _extends2.default)({}, props, {
|
|
64
|
+
role: "tab",
|
|
65
|
+
type: "button",
|
|
66
|
+
css: [commonStyles, buttonStyles]
|
|
67
|
+
})));
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
exports.ButtonIndicator = ButtonIndicator;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.default = void 0;
|
|
11
|
+
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
|
|
16
|
+
var _core = require("@emotion/core");
|
|
17
|
+
|
|
18
|
+
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
19
|
+
|
|
20
|
+
var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
|
|
21
|
+
|
|
22
|
+
var _components = require("@atlaskit/theme/components");
|
|
23
|
+
|
|
24
|
+
var _appearances = require("./appearances");
|
|
25
|
+
|
|
26
|
+
var _constants = require("./constants");
|
|
27
|
+
|
|
28
|
+
var _indicator = require("./indicator");
|
|
29
|
+
|
|
30
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
|
+
|
|
32
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
+
|
|
34
|
+
/** @jsx jsx */
|
|
35
|
+
var packageName = "@atlaskit/progress-indicator";
|
|
36
|
+
var packageVersion = "9.2.0";
|
|
37
|
+
var containerStyles = (0, _core.css)({
|
|
38
|
+
display: 'flex',
|
|
39
|
+
justifyContent: 'center',
|
|
40
|
+
gap: "var(".concat(_constants.varDotsMargin, ")")
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* __ProgressDots__
|
|
44
|
+
*
|
|
45
|
+
* A progress indicator shows the user where they are along the steps of a journey.
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
var ProgressDots = function ProgressDots(_ref) {
|
|
49
|
+
var _ref2;
|
|
50
|
+
|
|
51
|
+
var _ref$appearance = _ref.appearance,
|
|
52
|
+
appearance = _ref$appearance === void 0 ? 'default' : _ref$appearance,
|
|
53
|
+
_ref$ariaControls = _ref.ariaControls,
|
|
54
|
+
ariaControls = _ref$ariaControls === void 0 ? 'panel' : _ref$ariaControls,
|
|
55
|
+
_ref$ariaLabel = _ref.ariaLabel,
|
|
56
|
+
ariaLabel = _ref$ariaLabel === void 0 ? 'tab' : _ref$ariaLabel,
|
|
57
|
+
_ref$size = _ref.size,
|
|
58
|
+
size = _ref$size === void 0 ? 'default' : _ref$size,
|
|
59
|
+
_ref$spacing = _ref.spacing,
|
|
60
|
+
gutter = _ref$spacing === void 0 ? 'comfortable' : _ref$spacing,
|
|
61
|
+
selectedIndex = _ref.selectedIndex,
|
|
62
|
+
testId = _ref.testId,
|
|
63
|
+
values = _ref.values,
|
|
64
|
+
onSelect = _ref.onSelect;
|
|
65
|
+
var tablistRef = (0, _react.useRef)(null);
|
|
66
|
+
var onSelectWithAnalytics = (0, _analyticsNext.usePlatformLeafEventHandler)({
|
|
67
|
+
fn: onSelect || _noop.default,
|
|
68
|
+
action: 'selected',
|
|
69
|
+
componentName: 'progressIndicator',
|
|
70
|
+
packageName: packageName,
|
|
71
|
+
packageVersion: packageVersion
|
|
72
|
+
});
|
|
73
|
+
var handleKeyDown = (0, _react.useCallback)(function (event) {
|
|
74
|
+
var indicators = Array.from(tablistRef.current.children); // bail if the target isn't an indicator
|
|
75
|
+
|
|
76
|
+
if (!indicators.includes(event.target)) {
|
|
77
|
+
return;
|
|
78
|
+
} // bail if not valid arrow key
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
var isLeft = event.key === 'ArrowLeft';
|
|
82
|
+
var isRight = event.key === 'ArrowRight';
|
|
83
|
+
|
|
84
|
+
if (!isLeft && !isRight) {
|
|
85
|
+
return;
|
|
86
|
+
} // bail if at either end of the values
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
var isAlpha = isLeft && selectedIndex === 0;
|
|
90
|
+
var isOmega = isRight && selectedIndex === values.length - 1;
|
|
91
|
+
|
|
92
|
+
if (isAlpha || isOmega) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
var index = isLeft ? selectedIndex - 1 : selectedIndex + 1; // call the consumer's select method and focus the applicable indicator
|
|
97
|
+
|
|
98
|
+
if (onSelect) {
|
|
99
|
+
onSelectWithAnalytics({
|
|
100
|
+
event: event,
|
|
101
|
+
index: index
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (typeof indicators[index].focus === 'function') {
|
|
106
|
+
indicators[index].focus();
|
|
107
|
+
}
|
|
108
|
+
}, [onSelectWithAnalytics, selectedIndex, values, onSelect]);
|
|
109
|
+
(0, _react.useEffect)(function () {
|
|
110
|
+
if (onSelect) {
|
|
111
|
+
document.addEventListener('keydown', handleKeyDown, false);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return function () {
|
|
115
|
+
if (onSelect) {
|
|
116
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}, [onSelect, handleKeyDown]);
|
|
120
|
+
var theme = (0, _components.useGlobalTheme)();
|
|
121
|
+
return (0, _core.jsx)("div", {
|
|
122
|
+
"data-testid": testId,
|
|
123
|
+
css: containerStyles,
|
|
124
|
+
style: (_ref2 = {}, (0, _defineProperty2.default)(_ref2, _constants.varDotsSize, "".concat(_constants.sizes[size], "px")), (0, _defineProperty2.default)(_ref2, _constants.varDotsMargin, "".concat(_constants.sizes[size] / _constants.spacingDivision[gutter], "px")), _ref2),
|
|
125
|
+
ref: function ref(r) {
|
|
126
|
+
tablistRef.current = r;
|
|
127
|
+
},
|
|
128
|
+
role: "tablist"
|
|
129
|
+
}, values.map(function (_, index) {
|
|
130
|
+
var isSelected = selectedIndex === index;
|
|
131
|
+
var tabId = "".concat(ariaLabel).concat(index);
|
|
132
|
+
var panelId = "".concat(ariaControls).concat(index);
|
|
133
|
+
var backgroundColor = (0, _appearances.getBgColor)(appearance, isSelected)({
|
|
134
|
+
theme: theme
|
|
135
|
+
});
|
|
136
|
+
return onSelect ? (0, _core.jsx)(_indicator.ButtonIndicator, {
|
|
137
|
+
key: index,
|
|
138
|
+
style: {
|
|
139
|
+
backgroundColor: backgroundColor
|
|
140
|
+
},
|
|
141
|
+
"aria-controls": panelId,
|
|
142
|
+
"aria-label": tabId,
|
|
143
|
+
"aria-selected": isSelected,
|
|
144
|
+
id: tabId,
|
|
145
|
+
onClick: function onClick(event) {
|
|
146
|
+
return onSelectWithAnalytics({
|
|
147
|
+
event: event,
|
|
148
|
+
index: index
|
|
149
|
+
});
|
|
150
|
+
},
|
|
151
|
+
tabIndex: isSelected ? 0 : -1,
|
|
152
|
+
"data-testid": testId && "".concat(testId, "-ind-").concat(index)
|
|
153
|
+
}) : (0, _core.jsx)(_indicator.PresentationalIndicator, {
|
|
154
|
+
"data-testid": testId && "".concat(testId, "-ind-").concat(index),
|
|
155
|
+
key: index,
|
|
156
|
+
style: {
|
|
157
|
+
backgroundColor: backgroundColor
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}));
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
var _default = ProgressDots;
|
|
164
|
+
exports.default = _default;
|
package/dist/cjs/index.js
CHANGED
|
@@ -8,8 +8,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
Object.defineProperty(exports, "ProgressIndicator", {
|
|
9
9
|
enumerable: true,
|
|
10
10
|
get: function get() {
|
|
11
|
-
return
|
|
11
|
+
return _progressDots.default;
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _progressDots = _interopRequireDefault(require("./components/progress-dots"));
|
package/dist/cjs/version.json
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { B100, B400, B75, DN30, DN300A, DN600, DN70, N0, N50, N900, P300, P400, P75 } from '@atlaskit/theme/colors';
|
|
2
|
+
import { themed } from '@atlaskit/theme/components';
|
|
3
|
+
// TODO Token usages are not consistent for dots https://product-fabric.atlassian.net/browse/DSP-3180
|
|
4
|
+
const colorMap = {
|
|
5
|
+
default: themed({
|
|
6
|
+
light: `var(--ds-background-neutral, ${N50})`,
|
|
7
|
+
dark: `var(--ds-background-neutral, ${DN70})`
|
|
8
|
+
}),
|
|
9
|
+
help: themed({
|
|
10
|
+
light: `var(--ds-background-neutral, ${P75})`,
|
|
11
|
+
dark: `var(--ds-background-neutral, ${DN70})`
|
|
12
|
+
}),
|
|
13
|
+
inverted: themed({
|
|
14
|
+
light: "var(--ds-icon-subtle, rgba(255, 255, 255, 0.4))",
|
|
15
|
+
dark: `var(--ds-icon-subtle, ${DN300A})`
|
|
16
|
+
}),
|
|
17
|
+
primary: themed({
|
|
18
|
+
light: `var(--ds-background-neutral, ${B75})`,
|
|
19
|
+
dark: `var(--ds-background-neutral, ${DN70})`
|
|
20
|
+
})
|
|
21
|
+
};
|
|
22
|
+
const selectedColorMap = {
|
|
23
|
+
default: themed({
|
|
24
|
+
light: `var(--ds-icon, ${N900})`,
|
|
25
|
+
dark: `var(--ds-icon, ${DN600})`
|
|
26
|
+
}),
|
|
27
|
+
help: themed({
|
|
28
|
+
light: `var(--ds-icon-discovery, ${P400})`,
|
|
29
|
+
dark: `var(--ds-icon-discovery, ${P300})`
|
|
30
|
+
}),
|
|
31
|
+
inverted: themed({
|
|
32
|
+
light: `var(--ds-icon-inverse, ${N0})`,
|
|
33
|
+
dark: `var(--ds-icon-inverse, ${DN30})`
|
|
34
|
+
}),
|
|
35
|
+
primary: themed({
|
|
36
|
+
light: `var(--ds-icon-brand, ${B400})`,
|
|
37
|
+
dark: `var(--ds-icon-brand, ${B100})`
|
|
38
|
+
})
|
|
39
|
+
};
|
|
40
|
+
export const getBgColor = (appearance, isSelected) => isSelected ? selectedColorMap[appearance] : colorMap[appearance];
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import { css, jsx } from '@emotion/core';
|
|
5
|
+
import FocusRing from '@atlaskit/focus-ring';
|
|
6
|
+
import { varDotsMargin, varDotsSize } from './constants';
|
|
7
|
+
const commonStyles = css({
|
|
8
|
+
width: `var(${varDotsSize})`,
|
|
9
|
+
height: `var(${varDotsSize})`,
|
|
10
|
+
position: 'relative',
|
|
11
|
+
borderRadius: '50%',
|
|
12
|
+
'&::before': {
|
|
13
|
+
display: 'block',
|
|
14
|
+
width: `calc(var(${varDotsSize}) + var(${varDotsMargin}))`,
|
|
15
|
+
height: `calc(var(${varDotsSize}) + var(${varDotsMargin}))`,
|
|
16
|
+
position: 'absolute',
|
|
17
|
+
top: `calc(-1 * var(${varDotsMargin}) / 2)`,
|
|
18
|
+
left: `calc(-1 * var(${varDotsMargin}) / 2)`,
|
|
19
|
+
content: '""'
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const buttonStyles = css({
|
|
23
|
+
padding: 0,
|
|
24
|
+
border: 0,
|
|
25
|
+
cursor: 'pointer',
|
|
26
|
+
outline: 0
|
|
27
|
+
});
|
|
28
|
+
/**
|
|
29
|
+
* __Presentational indicator__
|
|
30
|
+
*
|
|
31
|
+
* A presentational indicator with no interactivity
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
export const PresentationalIndicator = (props // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
35
|
+
) => jsx("div", _extends({}, props, {
|
|
36
|
+
css: commonStyles,
|
|
37
|
+
role: "presentation"
|
|
38
|
+
}));
|
|
39
|
+
/**
|
|
40
|
+
* __Button indicator__
|
|
41
|
+
*
|
|
42
|
+
* An interactive indicator.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
export const ButtonIndicator = props => {
|
|
46
|
+
return jsx(FocusRing, null, jsx("button", _extends({}, props, {
|
|
47
|
+
role: "tab",
|
|
48
|
+
type: "button",
|
|
49
|
+
css: [commonStyles, buttonStyles]
|
|
50
|
+
})));
|
|
51
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import React, { useCallback, useEffect, useRef } from 'react';
|
|
3
|
+
import { css, jsx } from '@emotion/core';
|
|
4
|
+
import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
|
|
5
|
+
import noop from '@atlaskit/ds-lib/noop';
|
|
6
|
+
import { useGlobalTheme } from '@atlaskit/theme/components';
|
|
7
|
+
import { getBgColor } from './appearances';
|
|
8
|
+
import { sizes, spacingDivision, varDotsMargin, varDotsSize } from './constants';
|
|
9
|
+
import { ButtonIndicator, PresentationalIndicator } from './indicator';
|
|
10
|
+
const packageName = "@atlaskit/progress-indicator";
|
|
11
|
+
const packageVersion = "9.2.0";
|
|
12
|
+
const containerStyles = css({
|
|
13
|
+
display: 'flex',
|
|
14
|
+
justifyContent: 'center',
|
|
15
|
+
gap: `var(${varDotsMargin})`
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* __ProgressDots__
|
|
19
|
+
*
|
|
20
|
+
* A progress indicator shows the user where they are along the steps of a journey.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const ProgressDots = ({
|
|
24
|
+
appearance = 'default',
|
|
25
|
+
ariaControls = 'panel',
|
|
26
|
+
ariaLabel = 'tab',
|
|
27
|
+
size = 'default',
|
|
28
|
+
// NOTE: `spacing` is a reserved HTML attribute and will be added to the
|
|
29
|
+
// element, replaced with `gutter`.
|
|
30
|
+
spacing: gutter = 'comfortable',
|
|
31
|
+
selectedIndex,
|
|
32
|
+
testId,
|
|
33
|
+
values,
|
|
34
|
+
onSelect
|
|
35
|
+
}) => {
|
|
36
|
+
const tablistRef = useRef(null);
|
|
37
|
+
const onSelectWithAnalytics = usePlatformLeafEventHandler({
|
|
38
|
+
fn: onSelect || noop,
|
|
39
|
+
action: 'selected',
|
|
40
|
+
componentName: 'progressIndicator',
|
|
41
|
+
packageName,
|
|
42
|
+
packageVersion
|
|
43
|
+
});
|
|
44
|
+
const handleKeyDown = useCallback(event => {
|
|
45
|
+
const indicators = Array.from(tablistRef.current.children); // bail if the target isn't an indicator
|
|
46
|
+
|
|
47
|
+
if (!indicators.includes(event.target)) {
|
|
48
|
+
return;
|
|
49
|
+
} // bail if not valid arrow key
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
const isLeft = event.key === 'ArrowLeft';
|
|
53
|
+
const isRight = event.key === 'ArrowRight';
|
|
54
|
+
|
|
55
|
+
if (!isLeft && !isRight) {
|
|
56
|
+
return;
|
|
57
|
+
} // bail if at either end of the values
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
const isAlpha = isLeft && selectedIndex === 0;
|
|
61
|
+
const isOmega = isRight && selectedIndex === values.length - 1;
|
|
62
|
+
|
|
63
|
+
if (isAlpha || isOmega) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const index = isLeft ? selectedIndex - 1 : selectedIndex + 1; // call the consumer's select method and focus the applicable indicator
|
|
68
|
+
|
|
69
|
+
if (onSelect) {
|
|
70
|
+
onSelectWithAnalytics({
|
|
71
|
+
event: event,
|
|
72
|
+
index
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (typeof indicators[index].focus === 'function') {
|
|
77
|
+
indicators[index].focus();
|
|
78
|
+
}
|
|
79
|
+
}, [onSelectWithAnalytics, selectedIndex, values, onSelect]);
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (onSelect) {
|
|
82
|
+
document.addEventListener('keydown', handleKeyDown, false);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return () => {
|
|
86
|
+
if (onSelect) {
|
|
87
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}, [onSelect, handleKeyDown]);
|
|
91
|
+
const theme = useGlobalTheme();
|
|
92
|
+
return jsx("div", {
|
|
93
|
+
"data-testid": testId,
|
|
94
|
+
css: containerStyles,
|
|
95
|
+
style: {
|
|
96
|
+
[varDotsSize]: `${sizes[size]}px`,
|
|
97
|
+
[varDotsMargin]: `${sizes[size] / spacingDivision[gutter]}px`
|
|
98
|
+
},
|
|
99
|
+
ref: r => {
|
|
100
|
+
tablistRef.current = r;
|
|
101
|
+
},
|
|
102
|
+
role: "tablist"
|
|
103
|
+
}, values.map((_, index) => {
|
|
104
|
+
const isSelected = selectedIndex === index;
|
|
105
|
+
const tabId = `${ariaLabel}${index}`;
|
|
106
|
+
const panelId = `${ariaControls}${index}`;
|
|
107
|
+
const backgroundColor = getBgColor(appearance, isSelected)({
|
|
108
|
+
theme
|
|
109
|
+
});
|
|
110
|
+
return onSelect ? jsx(ButtonIndicator, {
|
|
111
|
+
key: index,
|
|
112
|
+
style: {
|
|
113
|
+
backgroundColor
|
|
114
|
+
},
|
|
115
|
+
"aria-controls": panelId,
|
|
116
|
+
"aria-label": tabId,
|
|
117
|
+
"aria-selected": isSelected,
|
|
118
|
+
id: tabId,
|
|
119
|
+
onClick: event => onSelectWithAnalytics({
|
|
120
|
+
event,
|
|
121
|
+
index
|
|
122
|
+
}),
|
|
123
|
+
tabIndex: isSelected ? 0 : -1,
|
|
124
|
+
"data-testid": testId && `${testId}-ind-${index}`
|
|
125
|
+
}) : jsx(PresentationalIndicator, {
|
|
126
|
+
"data-testid": testId && `${testId}-ind-${index}`,
|
|
127
|
+
key: index,
|
|
128
|
+
style: {
|
|
129
|
+
backgroundColor
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}));
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export default ProgressDots;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/es2019/index.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
// having a single named export will avoid consumers having to update their
|
|
3
3
|
// imports when there's a feature release.
|
|
4
4
|
// eslint-disable-next-line import/prefer-default-export
|
|
5
|
-
export { default as ProgressIndicator } from './components/
|
|
5
|
+
export { default as ProgressIndicator } from './components/progress-dots';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/es2019/version.json
CHANGED