@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.
Files changed (44) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/codemods/{9.0.0-import-rename.ts → 9.0.0-import-rename.tsx} +0 -0
  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 +70 -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 +51 -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 +53 -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 +28 -10
  36. package/types/package.json +7 -0
  37. package/dist/cjs/components/Dots.js +0 -201
  38. package/dist/cjs/styled/Dots.js +0 -120
  39. package/dist/es2019/components/Dots.js +0 -145
  40. package/dist/es2019/styled/Dots.js +0 -122
  41. package/dist/esm/components/Dots.js +0 -178
  42. package/dist/esm/styled/Dots.js +0 -93
  43. package/dist/types/components/Dots.d.ts +0 -51
  44. package/dist/types/styled/Dots.d.ts +0 -12
@@ -0,0 +1,42 @@
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
+ var colorMap = {
5
+ default: themed({
6
+ light: "var(--ds-background-neutral, ".concat(N50, ")"),
7
+ dark: "var(--ds-background-neutral, ".concat(DN70, ")")
8
+ }),
9
+ help: themed({
10
+ light: "var(--ds-background-neutral, ".concat(P75, ")"),
11
+ dark: "var(--ds-background-neutral, ".concat(DN70, ")")
12
+ }),
13
+ inverted: themed({
14
+ light: "var(--ds-icon-subtle, rgba(255, 255, 255, 0.4))",
15
+ dark: "var(--ds-icon-subtle, ".concat(DN300A, ")")
16
+ }),
17
+ primary: themed({
18
+ light: "var(--ds-background-neutral, ".concat(B75, ")"),
19
+ dark: "var(--ds-background-neutral, ".concat(DN70, ")")
20
+ })
21
+ };
22
+ var selectedColorMap = {
23
+ default: themed({
24
+ light: "var(--ds-icon, ".concat(N900, ")"),
25
+ dark: "var(--ds-icon, ".concat(DN600, ")")
26
+ }),
27
+ help: themed({
28
+ light: "var(--ds-icon-discovery, ".concat(P400, ")"),
29
+ dark: "var(--ds-icon-discovery, ".concat(P300, ")")
30
+ }),
31
+ inverted: themed({
32
+ light: "var(--ds-icon-inverse, ".concat(N0, ")"),
33
+ dark: "var(--ds-icon-inverse, ".concat(DN30, ")")
34
+ }),
35
+ primary: themed({
36
+ light: "var(--ds-icon-brand, ".concat(B400, ")"),
37
+ dark: "var(--ds-icon-brand, ".concat(B100, ")")
38
+ })
39
+ };
40
+ export var getBgColor = function getBgColor(appearance, isSelected) {
41
+ return isSelected ? selectedColorMap[appearance] : colorMap[appearance];
42
+ };
@@ -0,0 +1,12 @@
1
+ export var sizes = {
2
+ small: 4,
3
+ default: 8,
4
+ large: 12
5
+ };
6
+ export var spacingDivision = {
7
+ comfortable: 1,
8
+ cozy: 2,
9
+ compact: 4
10
+ };
11
+ export var varDotsSize = '--ds-dots-size';
12
+ export var varDotsMargin = '--ds-dots-margin';
@@ -0,0 +1,53 @@
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
+ var commonStyles = css({
8
+ width: "var(".concat(varDotsSize, ")"),
9
+ height: "var(".concat(varDotsSize, ")"),
10
+ position: 'relative',
11
+ borderRadius: '50%',
12
+ '&::before': {
13
+ display: 'block',
14
+ width: "calc(var(".concat(varDotsSize, ") + var(").concat(varDotsMargin, "))"),
15
+ height: "calc(var(".concat(varDotsSize, ") + var(").concat(varDotsMargin, "))"),
16
+ position: 'absolute',
17
+ top: "calc(-1 * var(".concat(varDotsMargin, ") / 2)"),
18
+ left: "calc(-1 * var(".concat(varDotsMargin, ") / 2)"),
19
+ content: '""'
20
+ }
21
+ });
22
+ var 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 var PresentationalIndicator = function PresentationalIndicator(props // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
35
+ ) {
36
+ return jsx("div", _extends({}, props, {
37
+ css: commonStyles,
38
+ role: "presentation"
39
+ }));
40
+ };
41
+ /**
42
+ * __Button indicator__
43
+ *
44
+ * An interactive indicator.
45
+ */
46
+
47
+ export var ButtonIndicator = function ButtonIndicator(props) {
48
+ return jsx(FocusRing, null, jsx("button", _extends({}, props, {
49
+ role: "tab",
50
+ type: "button",
51
+ css: [commonStyles, buttonStyles]
52
+ })));
53
+ };
@@ -0,0 +1,140 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ /** @jsx jsx */
4
+ import React, { useCallback, useEffect, useRef } from 'react';
5
+ import { css, jsx } from '@emotion/core';
6
+ import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
7
+ import noop from '@atlaskit/ds-lib/noop';
8
+ import { useGlobalTheme } from '@atlaskit/theme/components';
9
+ import { getBgColor } from './appearances';
10
+ import { sizes, spacingDivision, varDotsMargin, varDotsSize } from './constants';
11
+ import { ButtonIndicator, PresentationalIndicator } from './indicator';
12
+ var packageName = "@atlaskit/progress-indicator";
13
+ var packageVersion = "9.2.0";
14
+ var containerStyles = css({
15
+ display: 'flex',
16
+ justifyContent: 'center',
17
+ gap: "var(".concat(varDotsMargin, ")")
18
+ });
19
+ /**
20
+ * __ProgressDots__
21
+ *
22
+ * A progress indicator shows the user where they are along the steps of a journey.
23
+ */
24
+
25
+ var ProgressDots = function ProgressDots(_ref) {
26
+ var _ref2;
27
+
28
+ var _ref$appearance = _ref.appearance,
29
+ appearance = _ref$appearance === void 0 ? 'default' : _ref$appearance,
30
+ _ref$ariaControls = _ref.ariaControls,
31
+ ariaControls = _ref$ariaControls === void 0 ? 'panel' : _ref$ariaControls,
32
+ _ref$ariaLabel = _ref.ariaLabel,
33
+ ariaLabel = _ref$ariaLabel === void 0 ? 'tab' : _ref$ariaLabel,
34
+ _ref$size = _ref.size,
35
+ size = _ref$size === void 0 ? 'default' : _ref$size,
36
+ _ref$spacing = _ref.spacing,
37
+ gutter = _ref$spacing === void 0 ? 'comfortable' : _ref$spacing,
38
+ selectedIndex = _ref.selectedIndex,
39
+ testId = _ref.testId,
40
+ values = _ref.values,
41
+ onSelect = _ref.onSelect;
42
+ var tablistRef = useRef(null);
43
+ var onSelectWithAnalytics = usePlatformLeafEventHandler({
44
+ fn: onSelect || noop,
45
+ action: 'selected',
46
+ componentName: 'progressIndicator',
47
+ packageName: packageName,
48
+ packageVersion: packageVersion
49
+ });
50
+ var handleKeyDown = useCallback(function (event) {
51
+ var indicators = Array.from(tablistRef.current.children); // bail if the target isn't an indicator
52
+
53
+ if (!indicators.includes(event.target)) {
54
+ return;
55
+ } // bail if not valid arrow key
56
+
57
+
58
+ var isLeft = event.key === 'ArrowLeft';
59
+ var isRight = event.key === 'ArrowRight';
60
+
61
+ if (!isLeft && !isRight) {
62
+ return;
63
+ } // bail if at either end of the values
64
+
65
+
66
+ var isAlpha = isLeft && selectedIndex === 0;
67
+ var isOmega = isRight && selectedIndex === values.length - 1;
68
+
69
+ if (isAlpha || isOmega) {
70
+ return;
71
+ }
72
+
73
+ var index = isLeft ? selectedIndex - 1 : selectedIndex + 1; // call the consumer's select method and focus the applicable indicator
74
+
75
+ if (onSelect) {
76
+ onSelectWithAnalytics({
77
+ event: event,
78
+ index: index
79
+ });
80
+ }
81
+
82
+ if (typeof indicators[index].focus === 'function') {
83
+ indicators[index].focus();
84
+ }
85
+ }, [onSelectWithAnalytics, selectedIndex, values, onSelect]);
86
+ useEffect(function () {
87
+ if (onSelect) {
88
+ document.addEventListener('keydown', handleKeyDown, false);
89
+ }
90
+
91
+ return function () {
92
+ if (onSelect) {
93
+ document.removeEventListener('keydown', handleKeyDown);
94
+ }
95
+ };
96
+ }, [onSelect, handleKeyDown]);
97
+ var theme = useGlobalTheme();
98
+ return jsx("div", {
99
+ "data-testid": testId,
100
+ css: containerStyles,
101
+ style: (_ref2 = {}, _defineProperty(_ref2, varDotsSize, "".concat(sizes[size], "px")), _defineProperty(_ref2, varDotsMargin, "".concat(sizes[size] / spacingDivision[gutter], "px")), _ref2),
102
+ ref: function ref(r) {
103
+ tablistRef.current = r;
104
+ },
105
+ role: "tablist"
106
+ }, values.map(function (_, index) {
107
+ var isSelected = selectedIndex === index;
108
+ var tabId = "".concat(ariaLabel).concat(index);
109
+ var panelId = "".concat(ariaControls).concat(index);
110
+ var backgroundColor = getBgColor(appearance, isSelected)({
111
+ theme: theme
112
+ });
113
+ return onSelect ? jsx(ButtonIndicator, {
114
+ key: index,
115
+ style: {
116
+ backgroundColor: backgroundColor
117
+ },
118
+ "aria-controls": panelId,
119
+ "aria-label": tabId,
120
+ "aria-selected": isSelected,
121
+ id: tabId,
122
+ onClick: function onClick(event) {
123
+ return onSelectWithAnalytics({
124
+ event: event,
125
+ index: index
126
+ });
127
+ },
128
+ tabIndex: isSelected ? 0 : -1,
129
+ "data-testid": testId && "".concat(testId, "-ind-").concat(index)
130
+ }) : jsx(PresentationalIndicator, {
131
+ "data-testid": testId && "".concat(testId, "-ind-").concat(index),
132
+ key: index,
133
+ style: {
134
+ backgroundColor: backgroundColor
135
+ }
136
+ });
137
+ }));
138
+ };
139
+
140
+ export default ProgressDots;
@@ -0,0 +1 @@
1
+ export {};
package/dist/esm/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/Dots';
5
+ export { default as ProgressIndicator } from './components/progress-dots';
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/progress-indicator",
3
- "version": "9.0.5",
3
+ "version": "9.2.0",
4
4
  "sideEffects": false
5
5
  }
@@ -0,0 +1,2 @@
1
+ import type { DotsAppearance } from './types';
2
+ export declare const getBgColor: (appearance: DotsAppearance, isSelected: boolean) => import("@atlaskit/theme").ThemedValue<"var(--ds-background-neutral)"> | import("@atlaskit/theme").ThemedValue<"var(--ds-icon-subtle)"> | import("@atlaskit/theme").ThemedValue<"var(--ds-icon)"> | import("@atlaskit/theme").ThemedValue<"var(--ds-icon-discovery)"> | import("@atlaskit/theme").ThemedValue<"var(--ds-icon-inverse)"> | import("@atlaskit/theme").ThemedValue<"var(--ds-icon-brand)">;
@@ -0,0 +1,12 @@
1
+ export declare const sizes: {
2
+ small: number;
3
+ default: number;
4
+ large: number;
5
+ };
6
+ export declare const spacingDivision: {
7
+ comfortable: number;
8
+ cozy: number;
9
+ compact: number;
10
+ };
11
+ export declare const varDotsSize = "--ds-dots-size";
12
+ export declare const varDotsMargin = "--ds-dots-margin";
@@ -0,0 +1,14 @@
1
+ /** @jsx jsx */
2
+ import type { HTMLAttributes } from 'react';
3
+ /**
4
+ * __Presentational indicator__
5
+ *
6
+ * A presentational indicator with no interactivity
7
+ */
8
+ export declare const PresentationalIndicator: (props: HTMLAttributes<HTMLDivElement>) => JSX.Element;
9
+ /**
10
+ * __Button indicator__
11
+ *
12
+ * An interactive indicator.
13
+ */
14
+ export declare const ButtonIndicator: (props: HTMLAttributes<HTMLButtonElement>) => JSX.Element;
@@ -0,0 +1,10 @@
1
+ /** @jsx jsx */
2
+ import { FC } from 'react';
3
+ import type { ProgressDotsProps } from '../types';
4
+ /**
5
+ * __ProgressDots__
6
+ *
7
+ * A progress indicator shows the user where they are along the steps of a journey.
8
+ */
9
+ declare const ProgressDots: FC<ProgressDotsProps>;
10
+ export default ProgressDots;
@@ -0,0 +1,3 @@
1
+ export declare type DotsAppearance = 'default' | 'help' | 'inverted' | 'primary';
2
+ export declare type Spacing = 'comfortable' | 'cozy' | 'compact';
3
+ export declare type Size = 'small' | 'default' | 'large';
@@ -1 +1,2 @@
1
- export { default as ProgressIndicator } from './components/Dots';
1
+ export { default as ProgressIndicator } from './components/progress-dots';
2
+ export type { ProgressDotsProps } from './types';
@@ -0,0 +1,44 @@
1
+ /// <reference types="react" />
2
+ import type { UIAnalyticsEvent } from '@atlaskit/analytics-next';
3
+ import type { DotsAppearance, Size, Spacing } from './components/types';
4
+ export interface ProgressDotsProps {
5
+ /**
6
+ * The color of the indicators
7
+ */
8
+ appearance?: DotsAppearance;
9
+ /**
10
+ * The aria-controls text applied to each indicator, appended by the index
11
+ */
12
+ ariaControls?: string;
13
+ /**
14
+ * The aria-label text applied to each indicator, appended by the index
15
+ */
16
+ ariaLabel?: string;
17
+ /**
18
+ * Function called when an indicator is selected
19
+ */
20
+ onSelect?: (eventData: {
21
+ event: React.MouseEvent<HTMLButtonElement>;
22
+ index: number;
23
+ }, analyticsEvent: UIAnalyticsEvent) => void;
24
+ /**
25
+ * Which indicator is currently selected
26
+ */
27
+ selectedIndex: number;
28
+ /**
29
+ * Corresponds to the width & height of each indicator
30
+ */
31
+ size?: Size;
32
+ /**
33
+ * How much of a gutter is desired between indicators
34
+ */
35
+ spacing?: Spacing;
36
+ /**
37
+ * A hook for automated tests.
38
+ */
39
+ testId?: string;
40
+ /**
41
+ * An array of values mapped over to create the indicators
42
+ */
43
+ values: any[];
44
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/progress-indicator",
3
- "version": "9.0.5",
3
+ "version": "9.2.0",
4
4
  "description": "A progress indicator shows the user where they are along the steps of a journey.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -13,11 +13,9 @@
13
13
  "module:es2019": "dist/es2019/index.js",
14
14
  "types": "dist/types/index.d.ts",
15
15
  "sideEffects": false,
16
- "atlaskit:src": "src/index.ts",
16
+ "atlaskit:src": "src/index.tsx",
17
17
  "atlassian": {
18
18
  "team": "Design System Team",
19
- "deprecatedAutoEntryPoints": true,
20
- "inPublicMirror": true,
21
19
  "releaseModel": "scheduled",
22
20
  "website": {
23
21
  "name": "Progress indicator"
@@ -25,32 +23,52 @@
25
23
  },
26
24
  "dependencies": {
27
25
  "@atlaskit/analytics-next": "^8.0.0",
28
- "@atlaskit/theme": "^11.3.0",
29
- "@babel/runtime": "^7.0.0"
26
+ "@atlaskit/ds-lib": "^1.4.0",
27
+ "@atlaskit/focus-ring": "^1.0.0",
28
+ "@atlaskit/theme": "^12.1.0",
29
+ "@atlaskit/tokens": "^0.6.0",
30
+ "@babel/runtime": "^7.0.0",
31
+ "@emotion/core": "^10.0.9"
30
32
  },
31
33
  "peerDependencies": {
32
- "react": "^16.8.0",
33
- "styled-components": "^3.2.6"
34
+ "react": "^16.8.0"
34
35
  },
35
36
  "devDependencies": {
36
- "@atlaskit/build-utils": "*",
37
- "@atlaskit/button": "^15.1.0",
37
+ "@atlaskit/button": "^16.0.0",
38
38
  "@atlaskit/docs": "*",
39
+ "@atlaskit/section-message": "^6.0.0",
39
40
  "@atlaskit/ssr": "*",
40
41
  "@atlaskit/visual-regression": "*",
41
42
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
43
+ "@testing-library/react": "^8.0.1",
42
44
  "@types/jscodeshift": "^0.11.0",
43
45
  "enzyme": "^3.10.0",
44
46
  "jscodeshift": "^0.13.0",
45
47
  "react-dom": "^16.8.0",
46
48
  "react-lorem-component": "^0.13.0",
49
+ "styled-components": "^3.2.6",
47
50
  "typescript": "3.9.6"
48
51
  },
49
52
  "techstack": {
50
53
  "@atlassian/frontend": {
51
54
  "import-structure": "atlassian-conventions"
55
+ },
56
+ "@repo/internal": {
57
+ "ui-components": "lite-mode",
58
+ "design-system": "v1",
59
+ "styling": [
60
+ "static",
61
+ "emotion"
62
+ ],
63
+ "analytics": "analytics-next",
64
+ "theming": "tokens",
65
+ "deprecation": "no-deprecated-imports"
52
66
  }
53
67
  },
68
+ "af:exports": {
69
+ "./types": "./src/types.tsx",
70
+ ".": "./src/index.tsx"
71
+ },
54
72
  "homepage": "https://atlassian.design/components/progress-indicator/",
55
73
  "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
56
74
  }
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "@atlaskit/progress-indicator/types",
3
+ "main": "../dist/cjs/types.js",
4
+ "module": "../dist/esm/types.js",
5
+ "module:es2019": "../dist/es2019/types.js",
6
+ "types": "../dist/types/types.d.ts"
7
+ }
@@ -1,201 +0,0 @@
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 = 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 _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); }
35
-
36
- 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; }
37
-
38
- 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); }; }
39
-
40
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
41
-
42
- var packageName = "@atlaskit/progress-indicator";
43
- var packageVersion = "9.0.5";
44
-
45
- var ProgressDots = /*#__PURE__*/function (_Component) {
46
- (0, _inherits2.default)(ProgressDots, _Component);
47
-
48
- var _super = _createSuper(ProgressDots);
49
-
50
- function ProgressDots() {
51
- var _this;
52
-
53
- (0, _classCallCheck2.default)(this, ProgressDots);
54
-
55
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
56
- args[_key] = arguments[_key];
57
- }
58
-
59
- _this = _super.call.apply(_super, [this].concat(args));
60
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "tablist", {
61
- children: []
62
- });
63
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleKeyDown", function (event) {
64
- var _this$props = _this.props,
65
- onSelect = _this$props.onSelect,
66
- selectedIndex = _this$props.selectedIndex,
67
- values = _this$props.values;
68
- var indicators = Array.from(_this.tablist.children); // bail if the target isn't an indicator
69
-
70
- if (!indicators.includes(event.target)) {
71
- return;
72
- } // bail if not valid arrow key
73
-
74
-
75
- var isLeft = event.key === 'ArrowLeft';
76
- var isRight = event.key === 'ArrowRight';
77
-
78
- if (!isLeft && !isRight) {
79
- return;
80
- } // bail if at either end of the values
81
-
82
-
83
- var isAlpha = isLeft && selectedIndex === 0;
84
- var isOmega = isRight && selectedIndex === values.length - 1;
85
-
86
- if (isAlpha || isOmega) {
87
- return;
88
- }
89
-
90
- var index = isLeft ? selectedIndex - 1 : selectedIndex + 1; // call the consumer's select method and focus the applicable indicator
91
-
92
- if (onSelect) {
93
- onSelect({
94
- event: event,
95
- index: index
96
- });
97
- }
98
-
99
- if (typeof indicators[index].focus === 'function') {
100
- indicators[index].focus();
101
- }
102
- });
103
- return _this;
104
- }
105
-
106
- (0, _createClass2.default)(ProgressDots, [{
107
- key: "componentDidMount",
108
- value: function componentDidMount() {
109
- if (this.props.onSelect) {
110
- document.addEventListener('keydown', this.handleKeyDown, false);
111
- }
112
- }
113
- }, {
114
- key: "componentWillUnmount",
115
- value: function componentWillUnmount() {
116
- if (this.props.onSelect) {
117
- document.removeEventListener('keydown', this.handleKeyDown);
118
- }
119
- }
120
- }, {
121
- key: "render",
122
- value: function render() {
123
- var _this2 = this;
124
-
125
- // NOTE: `spacing` is a reserved HTML attribute and will be added to the
126
- // element, replaced with `gutter`.
127
- var _this$props2 = this.props,
128
- appearance = _this$props2.appearance,
129
- ariaControls = _this$props2.ariaControls,
130
- ariaLabel = _this$props2.ariaLabel,
131
- onSelect = _this$props2.onSelect,
132
- selectedIndex = _this$props2.selectedIndex,
133
- size = _this$props2.size,
134
- gutter = _this$props2.spacing,
135
- values = _this$props2.values;
136
- return /*#__PURE__*/_react.default.createElement(_Dots.Container, {
137
- innerRef: function innerRef(r) {
138
- _this2.tablist = r;
139
- },
140
- role: "tablist"
141
- }, values.map(function (val, index) {
142
- var selected = selectedIndex === index;
143
- var common = {
144
- appearance: appearance,
145
- key: index,
146
- selected: selected,
147
- size: size,
148
- gutter: gutter
149
- };
150
- var tabId = "".concat(ariaLabel).concat(index);
151
- var panelId = "".concat(ariaControls).concat(index);
152
- return onSelect ? /*#__PURE__*/_react.default.createElement(_Dots.IndicatorButton, (0, _extends2.default)({}, common, {
153
- "aria-controls": panelId,
154
- "aria-label": tabId,
155
- "aria-selected": selected,
156
- id: tabId,
157
- onClick: function onClick(event) {
158
- return onSelect({
159
- event: event,
160
- index: index
161
- });
162
- },
163
- role: "tab",
164
- tabIndex: selected ? 0 : -1,
165
- type: "button"
166
- })) : /*#__PURE__*/_react.default.createElement(_Dots.IndicatorDiv, (0, _extends2.default)({}, common, {
167
- role: "presentation"
168
- }));
169
- }));
170
- }
171
- }]);
172
- return ProgressDots;
173
- }(_react.Component);
174
-
175
- exports.ProgressDotsWithoutAnalytics = ProgressDots;
176
- (0, _defineProperty2.default)(ProgressDots, "defaultProps", {
177
- appearance: 'default',
178
- ariaControls: 'panel',
179
- ariaLabel: 'tab',
180
- size: 'default',
181
- spacing: 'comfortable'
182
- });
183
- var createAndFireEventOnAtlaskit = (0, _analyticsNext.createAndFireEvent)('atlaskit');
184
-
185
- var _default = (0, _analyticsNext.withAnalyticsContext)({
186
- componentName: 'progressIndicator',
187
- packageName: packageName,
188
- packageVersion: packageVersion
189
- })((0, _analyticsNext.withAnalyticsEvents)({
190
- onSelect: createAndFireEventOnAtlaskit({
191
- action: 'selected',
192
- actionSubject: 'progressIndicator',
193
- attributes: {
194
- componentName: 'progressIndicator',
195
- packageName: packageName,
196
- packageVersion: packageVersion
197
- }
198
- })
199
- })(ProgressDots));
200
-
201
- exports.default = _default;