@atlaskit/progress-indicator 9.0.4 → 9.1.2
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 +32 -0
- package/codemods/{9.0.0-import-rename.ts → 9.0.0-import-rename.tsx} +9 -9
- 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 +69 -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 +50 -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 +52 -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 +29 -11
- package/types/package.json +7 -0
- package/dist/cjs/components/Dots.js +0 -197
- package/dist/cjs/styled/Dots.js +0 -174
- 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 -151
- package/dist/types/components/Dots.d.ts +0 -51
- package/dist/types/styled/Dots.d.ts +0 -12
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
-
|
|
5
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports.default = exports.ProgressDotsWithoutAnalytics = void 0;
|
|
11
|
-
|
|
12
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
-
|
|
16
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
-
|
|
18
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
19
|
-
|
|
20
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
21
|
-
|
|
22
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
23
|
-
|
|
24
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
25
|
-
|
|
26
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
27
|
-
|
|
28
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
29
|
-
|
|
30
|
-
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
31
|
-
|
|
32
|
-
var _Dots = require("../styled/Dots");
|
|
33
|
-
|
|
34
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
35
|
-
|
|
36
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
37
|
-
|
|
38
|
-
var packageName = "@atlaskit/progress-indicator";
|
|
39
|
-
var packageVersion = "9.0.4";
|
|
40
|
-
|
|
41
|
-
var ProgressDots = /*#__PURE__*/function (_Component) {
|
|
42
|
-
(0, _inherits2.default)(ProgressDots, _Component);
|
|
43
|
-
|
|
44
|
-
var _super = _createSuper(ProgressDots);
|
|
45
|
-
|
|
46
|
-
function ProgressDots() {
|
|
47
|
-
var _this;
|
|
48
|
-
|
|
49
|
-
(0, _classCallCheck2.default)(this, ProgressDots);
|
|
50
|
-
|
|
51
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
52
|
-
args[_key] = arguments[_key];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
56
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "tablist", {
|
|
57
|
-
children: []
|
|
58
|
-
});
|
|
59
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleKeyDown", function (event) {
|
|
60
|
-
var _this$props = _this.props,
|
|
61
|
-
onSelect = _this$props.onSelect,
|
|
62
|
-
selectedIndex = _this$props.selectedIndex,
|
|
63
|
-
values = _this$props.values;
|
|
64
|
-
var indicators = Array.from(_this.tablist.children); // bail if the target isn't an indicator
|
|
65
|
-
|
|
66
|
-
if (!indicators.includes(event.target)) {
|
|
67
|
-
return;
|
|
68
|
-
} // bail if not valid arrow key
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
var isLeft = event.key === 'ArrowLeft';
|
|
72
|
-
var isRight = event.key === 'ArrowRight';
|
|
73
|
-
|
|
74
|
-
if (!isLeft && !isRight) {
|
|
75
|
-
return;
|
|
76
|
-
} // bail if at either end of the values
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
var isAlpha = isLeft && selectedIndex === 0;
|
|
80
|
-
var isOmega = isRight && selectedIndex === values.length - 1;
|
|
81
|
-
|
|
82
|
-
if (isAlpha || isOmega) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
var index = isLeft ? selectedIndex - 1 : selectedIndex + 1; // call the consumer's select method and focus the applicable indicator
|
|
87
|
-
|
|
88
|
-
if (onSelect) {
|
|
89
|
-
onSelect({
|
|
90
|
-
event: event,
|
|
91
|
-
index: index
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (typeof indicators[index].focus === 'function') {
|
|
96
|
-
indicators[index].focus();
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
return _this;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
(0, _createClass2.default)(ProgressDots, [{
|
|
103
|
-
key: "componentDidMount",
|
|
104
|
-
value: function componentDidMount() {
|
|
105
|
-
if (this.props.onSelect) {
|
|
106
|
-
document.addEventListener('keydown', this.handleKeyDown, false);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}, {
|
|
110
|
-
key: "componentWillUnmount",
|
|
111
|
-
value: function componentWillUnmount() {
|
|
112
|
-
if (this.props.onSelect) {
|
|
113
|
-
document.removeEventListener('keydown', this.handleKeyDown);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}, {
|
|
117
|
-
key: "render",
|
|
118
|
-
value: function render() {
|
|
119
|
-
var _this2 = this;
|
|
120
|
-
|
|
121
|
-
// NOTE: `spacing` is a reserved HTML attribute and will be added to the
|
|
122
|
-
// element, replaced with `gutter`.
|
|
123
|
-
var _this$props2 = this.props,
|
|
124
|
-
appearance = _this$props2.appearance,
|
|
125
|
-
ariaControls = _this$props2.ariaControls,
|
|
126
|
-
ariaLabel = _this$props2.ariaLabel,
|
|
127
|
-
onSelect = _this$props2.onSelect,
|
|
128
|
-
selectedIndex = _this$props2.selectedIndex,
|
|
129
|
-
size = _this$props2.size,
|
|
130
|
-
gutter = _this$props2.spacing,
|
|
131
|
-
values = _this$props2.values;
|
|
132
|
-
return /*#__PURE__*/_react.default.createElement(_Dots.Container, {
|
|
133
|
-
innerRef: function innerRef(r) {
|
|
134
|
-
_this2.tablist = r;
|
|
135
|
-
},
|
|
136
|
-
role: "tablist"
|
|
137
|
-
}, values.map(function (val, index) {
|
|
138
|
-
var selected = selectedIndex === index;
|
|
139
|
-
var common = {
|
|
140
|
-
appearance: appearance,
|
|
141
|
-
key: index,
|
|
142
|
-
selected: selected,
|
|
143
|
-
size: size,
|
|
144
|
-
gutter: gutter
|
|
145
|
-
};
|
|
146
|
-
var tabId = "".concat(ariaLabel).concat(index);
|
|
147
|
-
var panelId = "".concat(ariaControls).concat(index);
|
|
148
|
-
return onSelect ? /*#__PURE__*/_react.default.createElement(_Dots.IndicatorButton, (0, _extends2.default)({}, common, {
|
|
149
|
-
"aria-controls": panelId,
|
|
150
|
-
"aria-label": tabId,
|
|
151
|
-
"aria-selected": selected,
|
|
152
|
-
id: tabId,
|
|
153
|
-
onClick: function onClick(event) {
|
|
154
|
-
return onSelect({
|
|
155
|
-
event: event,
|
|
156
|
-
index: index
|
|
157
|
-
});
|
|
158
|
-
},
|
|
159
|
-
role: "tab",
|
|
160
|
-
tabIndex: selected ? 0 : -1,
|
|
161
|
-
type: "button"
|
|
162
|
-
})) : /*#__PURE__*/_react.default.createElement(_Dots.IndicatorDiv, (0, _extends2.default)({}, common, {
|
|
163
|
-
role: "presentation"
|
|
164
|
-
}));
|
|
165
|
-
}));
|
|
166
|
-
}
|
|
167
|
-
}]);
|
|
168
|
-
return ProgressDots;
|
|
169
|
-
}(_react.Component);
|
|
170
|
-
|
|
171
|
-
exports.ProgressDotsWithoutAnalytics = ProgressDots;
|
|
172
|
-
(0, _defineProperty2.default)(ProgressDots, "defaultProps", {
|
|
173
|
-
appearance: 'default',
|
|
174
|
-
ariaControls: 'panel',
|
|
175
|
-
ariaLabel: 'tab',
|
|
176
|
-
size: 'default',
|
|
177
|
-
spacing: 'comfortable'
|
|
178
|
-
});
|
|
179
|
-
var createAndFireEventOnAtlaskit = (0, _analyticsNext.createAndFireEvent)('atlaskit');
|
|
180
|
-
|
|
181
|
-
var _default = (0, _analyticsNext.withAnalyticsContext)({
|
|
182
|
-
componentName: 'progressIndicator',
|
|
183
|
-
packageName: packageName,
|
|
184
|
-
packageVersion: packageVersion
|
|
185
|
-
})((0, _analyticsNext.withAnalyticsEvents)({
|
|
186
|
-
onSelect: createAndFireEventOnAtlaskit({
|
|
187
|
-
action: 'selected',
|
|
188
|
-
actionSubject: 'progressIndicator',
|
|
189
|
-
attributes: {
|
|
190
|
-
componentName: 'progressIndicator',
|
|
191
|
-
packageName: packageName,
|
|
192
|
-
packageVersion: packageVersion
|
|
193
|
-
}
|
|
194
|
-
})
|
|
195
|
-
})(ProgressDots));
|
|
196
|
-
|
|
197
|
-
exports.default = _default;
|
package/dist/cjs/styled/Dots.js
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
-
|
|
5
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports.IndicatorDiv = exports.IndicatorButton = exports.Container = void 0;
|
|
11
|
-
|
|
12
|
-
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
13
|
-
|
|
14
|
-
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
15
|
-
|
|
16
|
-
var colors = _interopRequireWildcard(require("@atlaskit/theme/colors"));
|
|
17
|
-
|
|
18
|
-
var _components = require("@atlaskit/theme/components");
|
|
19
|
-
|
|
20
|
-
function _templateObject6() {
|
|
21
|
-
var data = (0, _taggedTemplateLiteral2.default)(["\n ", ";\n"]);
|
|
22
|
-
|
|
23
|
-
_templateObject6 = function _templateObject6() {
|
|
24
|
-
return data;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
return data;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function _templateObject5() {
|
|
31
|
-
var data = (0, _taggedTemplateLiteral2.default)(["\n &:focus {\n box-shadow: 0 0 0 2px ", ";\n }\n "]);
|
|
32
|
-
|
|
33
|
-
_templateObject5 = function _templateObject5() {
|
|
34
|
-
return data;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
return data;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function _templateObject4() {
|
|
41
|
-
var data = (0, _taggedTemplateLiteral2.default)(["\n ", " border: 0;\n cursor: pointer;\n outline: 0;\n padding: 0;\n\n ", ";\n"]);
|
|
42
|
-
|
|
43
|
-
_templateObject4 = function _templateObject4() {
|
|
44
|
-
return data;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
return data;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function _templateObject3() {
|
|
51
|
-
var data = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n justify-content: center;\n"]);
|
|
52
|
-
|
|
53
|
-
_templateObject3 = function _templateObject3() {
|
|
54
|
-
return data;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
return data;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function _templateObject2() {
|
|
61
|
-
var data = (0, _taggedTemplateLiteral2.default)(["\n ", " background-color: ", ";\n border-radius: 50%;\n"]);
|
|
62
|
-
|
|
63
|
-
_templateObject2 = function _templateObject2() {
|
|
64
|
-
return data;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
return data;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function _templateObject() {
|
|
71
|
-
var data = (0, _taggedTemplateLiteral2.default)(["\n height: ", "px;\n margin-left: ", "px;\n margin-right: ", "px;\n position: relative;\n width: ", "px;\n\n &::before {\n content: '';\n display: block;\n height: ", "px;\n left: -", "px;\n position: absolute;\n top: -", "px;\n width: ", "px;\n }\n "]);
|
|
72
|
-
|
|
73
|
-
_templateObject = function _templateObject() {
|
|
74
|
-
return data;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
return data;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
var colorMap = {
|
|
81
|
-
default: (0, _components.themed)({
|
|
82
|
-
light: colors.N50,
|
|
83
|
-
dark: colors.DN70
|
|
84
|
-
}),
|
|
85
|
-
help: (0, _components.themed)({
|
|
86
|
-
light: colors.P75,
|
|
87
|
-
dark: colors.DN70
|
|
88
|
-
}),
|
|
89
|
-
inverted: (0, _components.themed)({
|
|
90
|
-
light: 'rgba(255, 255, 255, 0.4)',
|
|
91
|
-
dark: colors.DN300A
|
|
92
|
-
}),
|
|
93
|
-
primary: (0, _components.themed)({
|
|
94
|
-
light: colors.B75,
|
|
95
|
-
dark: colors.DN70
|
|
96
|
-
})
|
|
97
|
-
};
|
|
98
|
-
var selectedColorMap = {
|
|
99
|
-
default: (0, _components.themed)({
|
|
100
|
-
light: colors.N900,
|
|
101
|
-
dark: colors.DN600
|
|
102
|
-
}),
|
|
103
|
-
help: (0, _components.themed)({
|
|
104
|
-
light: colors.P400,
|
|
105
|
-
dark: colors.P300
|
|
106
|
-
}),
|
|
107
|
-
inverted: (0, _components.themed)({
|
|
108
|
-
light: colors.N0,
|
|
109
|
-
dark: colors.DN30
|
|
110
|
-
}),
|
|
111
|
-
primary: (0, _components.themed)({
|
|
112
|
-
light: colors.B400,
|
|
113
|
-
dark: colors.B100
|
|
114
|
-
})
|
|
115
|
-
};
|
|
116
|
-
var outlineColorMap = {
|
|
117
|
-
default: (0, _components.themed)({
|
|
118
|
-
light: colors.B75,
|
|
119
|
-
dark: colors.B200
|
|
120
|
-
}),
|
|
121
|
-
help: (0, _components.themed)({
|
|
122
|
-
light: colors.P75,
|
|
123
|
-
dark: colors.P75
|
|
124
|
-
}),
|
|
125
|
-
inverted: (0, _components.themed)({
|
|
126
|
-
light: colors.B200,
|
|
127
|
-
dark: colors.B75
|
|
128
|
-
}),
|
|
129
|
-
primary: (0, _components.themed)({
|
|
130
|
-
light: colors.B75,
|
|
131
|
-
dark: colors.B75
|
|
132
|
-
})
|
|
133
|
-
};
|
|
134
|
-
var sizes = {
|
|
135
|
-
small: 4,
|
|
136
|
-
default: 8,
|
|
137
|
-
large: 12
|
|
138
|
-
};
|
|
139
|
-
var spacingDivision = {
|
|
140
|
-
comfortable: 2,
|
|
141
|
-
cozy: 4,
|
|
142
|
-
compact: 8
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
var getDimensions = function getDimensions(_ref) {
|
|
146
|
-
var gutter = _ref.gutter,
|
|
147
|
-
size = _ref.size;
|
|
148
|
-
var val = sizes[size];
|
|
149
|
-
var margin = val / spacingDivision[gutter];
|
|
150
|
-
var hitslop = val + margin * 2;
|
|
151
|
-
return (0, _styledComponents.css)(_templateObject(), val, margin, margin, val, hitslop, margin, margin, hitslop);
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
var getColor = function getColor(_ref2) {
|
|
155
|
-
var appearance = _ref2.appearance,
|
|
156
|
-
selected = _ref2.selected;
|
|
157
|
-
return selected ? selectedColorMap[appearance] : colorMap[appearance];
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
var commonRules = (0, _styledComponents.css)(_templateObject2(), getDimensions, getColor);
|
|
161
|
-
|
|
162
|
-
var Container = _styledComponents.default.div(_templateObject3());
|
|
163
|
-
|
|
164
|
-
exports.Container = Container;
|
|
165
|
-
|
|
166
|
-
var IndicatorButton = _styledComponents.default.button(_templateObject4(), commonRules, function (p) {
|
|
167
|
-
return p.selected ? (0, _styledComponents.css)(_templateObject5(), outlineColorMap[p.appearance]) : null;
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
exports.IndicatorButton = IndicatorButton;
|
|
171
|
-
|
|
172
|
-
var IndicatorDiv = _styledComponents.default.div(_templateObject6(), commonRules);
|
|
173
|
-
|
|
174
|
-
exports.IndicatorDiv = IndicatorDiv;
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
import React, { Component } from 'react';
|
|
4
|
-
import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
5
|
-
import { Container, IndicatorButton, IndicatorDiv } from '../styled/Dots';
|
|
6
|
-
const packageName = "@atlaskit/progress-indicator";
|
|
7
|
-
const packageVersion = "9.0.4";
|
|
8
|
-
|
|
9
|
-
class ProgressDots extends Component {
|
|
10
|
-
constructor(...args) {
|
|
11
|
-
super(...args);
|
|
12
|
-
|
|
13
|
-
_defineProperty(this, "tablist", {
|
|
14
|
-
children: []
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
_defineProperty(this, "handleKeyDown", event => {
|
|
18
|
-
const {
|
|
19
|
-
onSelect,
|
|
20
|
-
selectedIndex,
|
|
21
|
-
values
|
|
22
|
-
} = this.props;
|
|
23
|
-
const indicators = Array.from(this.tablist.children); // bail if the target isn't an indicator
|
|
24
|
-
|
|
25
|
-
if (!indicators.includes(event.target)) {
|
|
26
|
-
return;
|
|
27
|
-
} // bail if not valid arrow key
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const isLeft = event.key === 'ArrowLeft';
|
|
31
|
-
const isRight = event.key === 'ArrowRight';
|
|
32
|
-
|
|
33
|
-
if (!isLeft && !isRight) {
|
|
34
|
-
return;
|
|
35
|
-
} // bail if at either end of the values
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const isAlpha = isLeft && selectedIndex === 0;
|
|
39
|
-
const isOmega = isRight && selectedIndex === values.length - 1;
|
|
40
|
-
|
|
41
|
-
if (isAlpha || isOmega) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const index = isLeft ? selectedIndex - 1 : selectedIndex + 1; // call the consumer's select method and focus the applicable indicator
|
|
46
|
-
|
|
47
|
-
if (onSelect) {
|
|
48
|
-
onSelect({
|
|
49
|
-
event: event,
|
|
50
|
-
index
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (typeof indicators[index].focus === 'function') {
|
|
55
|
-
indicators[index].focus();
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
componentDidMount() {
|
|
61
|
-
if (this.props.onSelect) {
|
|
62
|
-
document.addEventListener('keydown', this.handleKeyDown, false);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
componentWillUnmount() {
|
|
67
|
-
if (this.props.onSelect) {
|
|
68
|
-
document.removeEventListener('keydown', this.handleKeyDown);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
render() {
|
|
73
|
-
// NOTE: `spacing` is a reserved HTML attribute and will be added to the
|
|
74
|
-
// element, replaced with `gutter`.
|
|
75
|
-
const {
|
|
76
|
-
appearance,
|
|
77
|
-
ariaControls,
|
|
78
|
-
ariaLabel,
|
|
79
|
-
onSelect,
|
|
80
|
-
selectedIndex,
|
|
81
|
-
size,
|
|
82
|
-
spacing: gutter,
|
|
83
|
-
values
|
|
84
|
-
} = this.props;
|
|
85
|
-
return /*#__PURE__*/React.createElement(Container, {
|
|
86
|
-
innerRef: r => {
|
|
87
|
-
this.tablist = r;
|
|
88
|
-
},
|
|
89
|
-
role: "tablist"
|
|
90
|
-
}, values.map((val, index) => {
|
|
91
|
-
const selected = selectedIndex === index;
|
|
92
|
-
const common = {
|
|
93
|
-
appearance: appearance,
|
|
94
|
-
key: index,
|
|
95
|
-
selected,
|
|
96
|
-
size: size,
|
|
97
|
-
gutter: gutter
|
|
98
|
-
};
|
|
99
|
-
const tabId = `${ariaLabel}${index}`;
|
|
100
|
-
const panelId = `${ariaControls}${index}`;
|
|
101
|
-
return onSelect ? /*#__PURE__*/React.createElement(IndicatorButton, _extends({}, common, {
|
|
102
|
-
"aria-controls": panelId,
|
|
103
|
-
"aria-label": tabId,
|
|
104
|
-
"aria-selected": selected,
|
|
105
|
-
id: tabId,
|
|
106
|
-
onClick: event => onSelect({
|
|
107
|
-
event,
|
|
108
|
-
index
|
|
109
|
-
}),
|
|
110
|
-
role: "tab",
|
|
111
|
-
tabIndex: selected ? 0 : -1,
|
|
112
|
-
type: "button"
|
|
113
|
-
})) : /*#__PURE__*/React.createElement(IndicatorDiv, _extends({}, common, {
|
|
114
|
-
role: "presentation"
|
|
115
|
-
}));
|
|
116
|
-
}));
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
_defineProperty(ProgressDots, "defaultProps", {
|
|
122
|
-
appearance: 'default',
|
|
123
|
-
ariaControls: 'panel',
|
|
124
|
-
ariaLabel: 'tab',
|
|
125
|
-
size: 'default',
|
|
126
|
-
spacing: 'comfortable'
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
export { ProgressDots as ProgressDotsWithoutAnalytics };
|
|
130
|
-
const createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
|
|
131
|
-
export default withAnalyticsContext({
|
|
132
|
-
componentName: 'progressIndicator',
|
|
133
|
-
packageName,
|
|
134
|
-
packageVersion
|
|
135
|
-
})(withAnalyticsEvents({
|
|
136
|
-
onSelect: createAndFireEventOnAtlaskit({
|
|
137
|
-
action: 'selected',
|
|
138
|
-
actionSubject: 'progressIndicator',
|
|
139
|
-
attributes: {
|
|
140
|
-
componentName: 'progressIndicator',
|
|
141
|
-
packageName,
|
|
142
|
-
packageVersion
|
|
143
|
-
}
|
|
144
|
-
})
|
|
145
|
-
})(ProgressDots));
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import styled, { css } from 'styled-components';
|
|
2
|
-
import * as colors from '@atlaskit/theme/colors';
|
|
3
|
-
import { themed } from '@atlaskit/theme/components';
|
|
4
|
-
const colorMap = {
|
|
5
|
-
default: themed({
|
|
6
|
-
light: colors.N50,
|
|
7
|
-
dark: colors.DN70
|
|
8
|
-
}),
|
|
9
|
-
help: themed({
|
|
10
|
-
light: colors.P75,
|
|
11
|
-
dark: colors.DN70
|
|
12
|
-
}),
|
|
13
|
-
inverted: themed({
|
|
14
|
-
light: 'rgba(255, 255, 255, 0.4)',
|
|
15
|
-
dark: colors.DN300A
|
|
16
|
-
}),
|
|
17
|
-
primary: themed({
|
|
18
|
-
light: colors.B75,
|
|
19
|
-
dark: colors.DN70
|
|
20
|
-
})
|
|
21
|
-
};
|
|
22
|
-
const selectedColorMap = {
|
|
23
|
-
default: themed({
|
|
24
|
-
light: colors.N900,
|
|
25
|
-
dark: colors.DN600
|
|
26
|
-
}),
|
|
27
|
-
help: themed({
|
|
28
|
-
light: colors.P400,
|
|
29
|
-
dark: colors.P300
|
|
30
|
-
}),
|
|
31
|
-
inverted: themed({
|
|
32
|
-
light: colors.N0,
|
|
33
|
-
dark: colors.DN30
|
|
34
|
-
}),
|
|
35
|
-
primary: themed({
|
|
36
|
-
light: colors.B400,
|
|
37
|
-
dark: colors.B100
|
|
38
|
-
})
|
|
39
|
-
};
|
|
40
|
-
const outlineColorMap = {
|
|
41
|
-
default: themed({
|
|
42
|
-
light: colors.B75,
|
|
43
|
-
dark: colors.B200
|
|
44
|
-
}),
|
|
45
|
-
help: themed({
|
|
46
|
-
light: colors.P75,
|
|
47
|
-
dark: colors.P75
|
|
48
|
-
}),
|
|
49
|
-
inverted: themed({
|
|
50
|
-
light: colors.B200,
|
|
51
|
-
dark: colors.B75
|
|
52
|
-
}),
|
|
53
|
-
primary: themed({
|
|
54
|
-
light: colors.B75,
|
|
55
|
-
dark: colors.B75
|
|
56
|
-
})
|
|
57
|
-
};
|
|
58
|
-
const sizes = {
|
|
59
|
-
small: 4,
|
|
60
|
-
default: 8,
|
|
61
|
-
large: 12
|
|
62
|
-
};
|
|
63
|
-
const spacingDivision = {
|
|
64
|
-
comfortable: 2,
|
|
65
|
-
cozy: 4,
|
|
66
|
-
compact: 8
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const getDimensions = ({
|
|
70
|
-
gutter,
|
|
71
|
-
size
|
|
72
|
-
}) => {
|
|
73
|
-
const val = sizes[size];
|
|
74
|
-
const margin = val / spacingDivision[gutter];
|
|
75
|
-
const hitslop = val + margin * 2;
|
|
76
|
-
return css`
|
|
77
|
-
height: ${val}px;
|
|
78
|
-
margin-left: ${margin}px;
|
|
79
|
-
margin-right: ${margin}px;
|
|
80
|
-
position: relative;
|
|
81
|
-
width: ${val}px;
|
|
82
|
-
|
|
83
|
-
&::before {
|
|
84
|
-
content: '';
|
|
85
|
-
display: block;
|
|
86
|
-
height: ${hitslop}px;
|
|
87
|
-
left: -${margin}px;
|
|
88
|
-
position: absolute;
|
|
89
|
-
top: -${margin}px;
|
|
90
|
-
width: ${hitslop}px;
|
|
91
|
-
}
|
|
92
|
-
`;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const getColor = ({
|
|
96
|
-
appearance,
|
|
97
|
-
selected
|
|
98
|
-
}) => selected ? selectedColorMap[appearance] : colorMap[appearance];
|
|
99
|
-
|
|
100
|
-
const commonRules = css`
|
|
101
|
-
${getDimensions} background-color: ${getColor};
|
|
102
|
-
border-radius: 50%;
|
|
103
|
-
`;
|
|
104
|
-
export const Container = styled.div`
|
|
105
|
-
display: flex;
|
|
106
|
-
justify-content: center;
|
|
107
|
-
`;
|
|
108
|
-
export const IndicatorButton = styled.button`
|
|
109
|
-
${commonRules} border: 0;
|
|
110
|
-
cursor: pointer;
|
|
111
|
-
outline: 0;
|
|
112
|
-
padding: 0;
|
|
113
|
-
|
|
114
|
-
${p => p.selected ? css`
|
|
115
|
-
&:focus {
|
|
116
|
-
box-shadow: 0 0 0 2px ${outlineColorMap[p.appearance]};
|
|
117
|
-
}
|
|
118
|
-
` : null};
|
|
119
|
-
`;
|
|
120
|
-
export const IndicatorDiv = styled.div`
|
|
121
|
-
${commonRules};
|
|
122
|
-
`;
|