@atlaskit/progress-indicator 9.0.3 → 9.1.1

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/codemods/{9.0.0-import-rename.ts → 9.0.0-import-rename.tsx} +9 -9
  3. package/codemods/__tests__/{9.0.0-import-rename.ts → 9.0.0-import-rename.tsx} +0 -0
  4. package/dist/cjs/components/appearances.js +54 -0
  5. package/dist/cjs/components/constants.js +22 -0
  6. package/dist/cjs/components/indicator.js +69 -0
  7. package/dist/cjs/components/progress-dots.js +164 -0
  8. package/dist/cjs/components/types.js +5 -0
  9. package/dist/cjs/index.js +2 -2
  10. package/dist/cjs/types.js +5 -0
  11. package/dist/cjs/version.json +1 -1
  12. package/dist/es2019/components/appearances.js +40 -0
  13. package/dist/es2019/components/constants.js +12 -0
  14. package/dist/es2019/components/indicator.js +50 -0
  15. package/dist/es2019/components/progress-dots.js +135 -0
  16. package/dist/es2019/components/types.js +1 -0
  17. package/dist/es2019/index.js +1 -1
  18. package/dist/es2019/types.js +1 -0
  19. package/dist/es2019/version.json +1 -1
  20. package/dist/esm/components/appearances.js +42 -0
  21. package/dist/esm/components/constants.js +12 -0
  22. package/dist/esm/components/indicator.js +52 -0
  23. package/dist/esm/components/progress-dots.js +140 -0
  24. package/dist/esm/components/types.js +1 -0
  25. package/dist/esm/index.js +1 -1
  26. package/dist/esm/types.js +1 -0
  27. package/dist/esm/version.json +1 -1
  28. package/dist/types/components/appearances.d.ts +2 -0
  29. package/dist/types/components/constants.d.ts +12 -0
  30. package/dist/types/components/indicator.d.ts +14 -0
  31. package/dist/types/components/progress-dots.d.ts +10 -0
  32. package/dist/types/components/types.d.ts +3 -0
  33. package/dist/types/index.d.ts +2 -1
  34. package/dist/types/types.d.ts +44 -0
  35. package/package.json +30 -12
  36. package/types/package.json +7 -0
  37. package/dist/cjs/components/Dots.js +0 -196
  38. package/dist/cjs/styled/Dots.js +0 -174
  39. package/dist/es2019/components/Dots.js +0 -144
  40. package/dist/es2019/styled/Dots.js +0 -122
  41. package/dist/esm/components/Dots.js +0 -177
  42. package/dist/esm/styled/Dots.js +0 -151
  43. package/dist/types/components/Dots.d.ts +0 -51
  44. package/dist/types/styled/Dots.d.ts +0 -12
@@ -1,177 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/createClass";
4
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
5
- import _inherits from "@babel/runtime/helpers/inherits";
6
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
-
10
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11
-
12
- 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; } }
13
-
14
- import React, { Component } from 'react';
15
- import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
16
- import { Container, IndicatorButton, IndicatorDiv } from '../styled/Dots';
17
- import { name as packageName, version as packageVersion } from '../version.json';
18
-
19
- var ProgressDots = /*#__PURE__*/function (_Component) {
20
- _inherits(ProgressDots, _Component);
21
-
22
- var _super = _createSuper(ProgressDots);
23
-
24
- function ProgressDots() {
25
- var _this;
26
-
27
- _classCallCheck(this, ProgressDots);
28
-
29
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
30
- args[_key] = arguments[_key];
31
- }
32
-
33
- _this = _super.call.apply(_super, [this].concat(args));
34
-
35
- _defineProperty(_assertThisInitialized(_this), "tablist", {
36
- children: []
37
- });
38
-
39
- _defineProperty(_assertThisInitialized(_this), "handleKeyDown", function (event) {
40
- var _this$props = _this.props,
41
- onSelect = _this$props.onSelect,
42
- selectedIndex = _this$props.selectedIndex,
43
- values = _this$props.values;
44
- var indicators = Array.from(_this.tablist.children); // bail if the target isn't an indicator
45
-
46
- if (!indicators.includes(event.target)) {
47
- return;
48
- } // bail if not valid arrow key
49
-
50
-
51
- var isLeft = event.key === 'ArrowLeft';
52
- var isRight = event.key === 'ArrowRight';
53
-
54
- if (!isLeft && !isRight) {
55
- return;
56
- } // bail if at either end of the values
57
-
58
-
59
- var isAlpha = isLeft && selectedIndex === 0;
60
- var isOmega = isRight && selectedIndex === values.length - 1;
61
-
62
- if (isAlpha || isOmega) {
63
- return;
64
- }
65
-
66
- var index = isLeft ? selectedIndex - 1 : selectedIndex + 1; // call the consumer's select method and focus the applicable indicator
67
-
68
- if (onSelect) {
69
- onSelect({
70
- event: event,
71
- index: index
72
- });
73
- }
74
-
75
- if (typeof indicators[index].focus === 'function') {
76
- indicators[index].focus();
77
- }
78
- });
79
-
80
- return _this;
81
- }
82
-
83
- _createClass(ProgressDots, [{
84
- key: "componentDidMount",
85
- value: function componentDidMount() {
86
- if (this.props.onSelect) {
87
- document.addEventListener('keydown', this.handleKeyDown, false);
88
- }
89
- }
90
- }, {
91
- key: "componentWillUnmount",
92
- value: function componentWillUnmount() {
93
- if (this.props.onSelect) {
94
- document.removeEventListener('keydown', this.handleKeyDown);
95
- }
96
- }
97
- }, {
98
- key: "render",
99
- value: function render() {
100
- var _this2 = this;
101
-
102
- // NOTE: `spacing` is a reserved HTML attribute and will be added to the
103
- // element, replaced with `gutter`.
104
- var _this$props2 = this.props,
105
- appearance = _this$props2.appearance,
106
- ariaControls = _this$props2.ariaControls,
107
- ariaLabel = _this$props2.ariaLabel,
108
- onSelect = _this$props2.onSelect,
109
- selectedIndex = _this$props2.selectedIndex,
110
- size = _this$props2.size,
111
- gutter = _this$props2.spacing,
112
- values = _this$props2.values;
113
- return /*#__PURE__*/React.createElement(Container, {
114
- innerRef: function innerRef(r) {
115
- _this2.tablist = r;
116
- },
117
- role: "tablist"
118
- }, values.map(function (val, index) {
119
- var selected = selectedIndex === index;
120
- var common = {
121
- appearance: appearance,
122
- key: index,
123
- selected: selected,
124
- size: size,
125
- gutter: gutter
126
- };
127
- var tabId = "".concat(ariaLabel).concat(index);
128
- var panelId = "".concat(ariaControls).concat(index);
129
- return onSelect ? /*#__PURE__*/React.createElement(IndicatorButton, _extends({}, common, {
130
- "aria-controls": panelId,
131
- "aria-label": tabId,
132
- "aria-selected": selected,
133
- id: tabId,
134
- onClick: function onClick(event) {
135
- return onSelect({
136
- event: event,
137
- index: index
138
- });
139
- },
140
- role: "tab",
141
- tabIndex: selected ? 0 : -1,
142
- type: "button"
143
- })) : /*#__PURE__*/React.createElement(IndicatorDiv, _extends({}, common, {
144
- role: "presentation"
145
- }));
146
- }));
147
- }
148
- }]);
149
-
150
- return ProgressDots;
151
- }(Component);
152
-
153
- _defineProperty(ProgressDots, "defaultProps", {
154
- appearance: 'default',
155
- ariaControls: 'panel',
156
- ariaLabel: 'tab',
157
- size: 'default',
158
- spacing: 'comfortable'
159
- });
160
-
161
- export { ProgressDots as ProgressDotsWithoutAnalytics };
162
- var createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
163
- export default withAnalyticsContext({
164
- componentName: 'progressIndicator',
165
- packageName: packageName,
166
- packageVersion: packageVersion
167
- })(withAnalyticsEvents({
168
- onSelect: createAndFireEventOnAtlaskit({
169
- action: 'selected',
170
- actionSubject: 'progressIndicator',
171
- attributes: {
172
- componentName: 'progressIndicator',
173
- packageName: packageName,
174
- packageVersion: packageVersion
175
- }
176
- })
177
- })(ProgressDots));
@@ -1,151 +0,0 @@
1
- import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
-
3
- function _templateObject6() {
4
- var data = _taggedTemplateLiteral(["\n ", ";\n"]);
5
-
6
- _templateObject6 = function _templateObject6() {
7
- return data;
8
- };
9
-
10
- return data;
11
- }
12
-
13
- function _templateObject5() {
14
- var data = _taggedTemplateLiteral(["\n &:focus {\n box-shadow: 0 0 0 2px ", ";\n }\n "]);
15
-
16
- _templateObject5 = function _templateObject5() {
17
- return data;
18
- };
19
-
20
- return data;
21
- }
22
-
23
- function _templateObject4() {
24
- var data = _taggedTemplateLiteral(["\n ", " border: 0;\n cursor: pointer;\n outline: 0;\n padding: 0;\n\n ", ";\n"]);
25
-
26
- _templateObject4 = function _templateObject4() {
27
- return data;
28
- };
29
-
30
- return data;
31
- }
32
-
33
- function _templateObject3() {
34
- var data = _taggedTemplateLiteral(["\n display: flex;\n justify-content: center;\n"]);
35
-
36
- _templateObject3 = function _templateObject3() {
37
- return data;
38
- };
39
-
40
- return data;
41
- }
42
-
43
- function _templateObject2() {
44
- var data = _taggedTemplateLiteral(["\n ", " background-color: ", ";\n border-radius: 50%;\n"]);
45
-
46
- _templateObject2 = function _templateObject2() {
47
- return data;
48
- };
49
-
50
- return data;
51
- }
52
-
53
- function _templateObject() {
54
- var data = _taggedTemplateLiteral(["\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 "]);
55
-
56
- _templateObject = function _templateObject() {
57
- return data;
58
- };
59
-
60
- return data;
61
- }
62
-
63
- import styled, { css } from 'styled-components';
64
- import * as colors from '@atlaskit/theme/colors';
65
- import { themed } from '@atlaskit/theme/components';
66
- var colorMap = {
67
- default: themed({
68
- light: colors.N50,
69
- dark: colors.DN70
70
- }),
71
- help: themed({
72
- light: colors.P75,
73
- dark: colors.DN70
74
- }),
75
- inverted: themed({
76
- light: 'rgba(255, 255, 255, 0.4)',
77
- dark: colors.DN300A
78
- }),
79
- primary: themed({
80
- light: colors.B75,
81
- dark: colors.DN70
82
- })
83
- };
84
- var selectedColorMap = {
85
- default: themed({
86
- light: colors.N900,
87
- dark: colors.DN600
88
- }),
89
- help: themed({
90
- light: colors.P400,
91
- dark: colors.P300
92
- }),
93
- inverted: themed({
94
- light: colors.N0,
95
- dark: colors.DN30
96
- }),
97
- primary: themed({
98
- light: colors.B400,
99
- dark: colors.B100
100
- })
101
- };
102
- var outlineColorMap = {
103
- default: themed({
104
- light: colors.B75,
105
- dark: colors.B200
106
- }),
107
- help: themed({
108
- light: colors.P75,
109
- dark: colors.P75
110
- }),
111
- inverted: themed({
112
- light: colors.B200,
113
- dark: colors.B75
114
- }),
115
- primary: themed({
116
- light: colors.B75,
117
- dark: colors.B75
118
- })
119
- };
120
- var sizes = {
121
- small: 4,
122
- default: 8,
123
- large: 12
124
- };
125
- var spacingDivision = {
126
- comfortable: 2,
127
- cozy: 4,
128
- compact: 8
129
- };
130
-
131
- var getDimensions = function getDimensions(_ref) {
132
- var gutter = _ref.gutter,
133
- size = _ref.size;
134
- var val = sizes[size];
135
- var margin = val / spacingDivision[gutter];
136
- var hitslop = val + margin * 2;
137
- return css(_templateObject(), val, margin, margin, val, hitslop, margin, margin, hitslop);
138
- };
139
-
140
- var getColor = function getColor(_ref2) {
141
- var appearance = _ref2.appearance,
142
- selected = _ref2.selected;
143
- return selected ? selectedColorMap[appearance] : colorMap[appearance];
144
- };
145
-
146
- var commonRules = css(_templateObject2(), getDimensions, getColor);
147
- export var Container = styled.div(_templateObject3());
148
- export var IndicatorButton = styled.button(_templateObject4(), commonRules, function (p) {
149
- return p.selected ? css(_templateObject5(), outlineColorMap[p.appearance]) : null;
150
- });
151
- export var IndicatorDiv = styled.div(_templateObject6(), commonRules);
@@ -1,51 +0,0 @@
1
- import React, { Component } from 'react';
2
- import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
3
- export declare type DotsAppearance = 'default' | 'help' | 'inverted' | 'primary';
4
- export declare type Spacing = 'comfortable' | 'cozy' | 'compact';
5
- export declare type Size = 'small' | 'default' | 'large';
6
- interface Props extends WithAnalyticsEventsProps {
7
- /** The color of the indicators */
8
- appearance?: DotsAppearance;
9
- /** The aria-controls text applied to each indicator, appended by the index */
10
- ariaControls?: string;
11
- /** The aria-label text applied to each indicator, appended by the index */
12
- ariaLabel?: string;
13
- /** Function called when an indicator is selected */
14
- onSelect?: (eventData: {
15
- event: React.MouseEvent<HTMLButtonElement>;
16
- index: number;
17
- }) => void;
18
- /** Which indicator is currently selected */
19
- selectedIndex: number;
20
- /** Corresponds to the width & height of each indicator */
21
- size?: Size;
22
- /** How much of a gutter is desired between indicators */
23
- spacing?: Spacing;
24
- /** An array of values mapped over to create the indicators */
25
- values: Array<any>;
26
- }
27
- declare class ProgressDots extends Component<Props, {}> {
28
- tablist: {
29
- children: HTMLElement[];
30
- };
31
- static defaultProps: {
32
- appearance: string;
33
- ariaControls: string;
34
- ariaLabel: string;
35
- size: string;
36
- spacing: string;
37
- };
38
- componentDidMount(): void;
39
- componentWillUnmount(): void;
40
- handleKeyDown: (event: KeyboardEvent) => void;
41
- render(): JSX.Element;
42
- }
43
- export { ProgressDots as ProgressDotsWithoutAnalytics };
44
- declare const _default: React.ForwardRefExoticComponent<Pick<Pick<Pick<Props, "size" | "appearance" | "ariaControls" | "ariaLabel" | "onSelect" | "selectedIndex" | "spacing" | "values">, "onSelect" | "selectedIndex" | "values"> & Partial<Pick<Pick<Props, "size" | "appearance" | "ariaControls" | "ariaLabel" | "onSelect" | "selectedIndex" | "spacing" | "values">, "size" | "appearance" | "ariaControls" | "ariaLabel" | "spacing">> & Partial<Pick<{
45
- appearance: string;
46
- ariaControls: string;
47
- ariaLabel: string;
48
- size: string;
49
- spacing: string;
50
- }, never>> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "size" | "appearance" | "ariaControls" | "ariaLabel" | "onSelect" | "selectedIndex" | "spacing" | "values" | "key" | "analyticsContext"> & React.RefAttributes<any>>;
51
- export default _default;
@@ -1,12 +0,0 @@
1
- /// <reference types="react" />
2
- import { DotsAppearance, Size, Spacing } from '../components/Dots';
3
- export declare const Container: import("styled-components").StyledComponentClass<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, any, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
4
- interface IndicatorButtonProps {
5
- selected: boolean;
6
- appearance: DotsAppearance;
7
- gutter: Spacing;
8
- size: Size;
9
- }
10
- export declare const IndicatorButton: import("styled-components").StyledComponentClass<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & IndicatorButtonProps, any, import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & IndicatorButtonProps>;
11
- export declare const IndicatorDiv: import("styled-components").StyledComponentClass<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & IndicatorButtonProps, any, import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & IndicatorButtonProps>;
12
- export {};