@pingux/astro 2.204.0-alpha.0 → 2.205.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ import { StepStatus } from './Stepper.constants';
2
+ interface LineProps {
3
+ className?: string;
4
+ status?: StepStatus;
5
+ }
6
+ declare const Line: ({ className, status, }: LineProps) => import("react/jsx-runtime").JSX.Element;
7
+ export default Line;
@@ -6,9 +6,7 @@ _Object$defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports["default"] = void 0;
9
- var _values = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/values"));
10
9
  var _react = _interopRequireDefault(require("react"));
11
- var _propTypes = _interopRequireDefault(require("prop-types"));
12
10
  var _hooks = require("../../hooks");
13
11
  var _Box = _interopRequireDefault(require("../Box"));
14
12
  var _Stepper = require("./Stepper.constants");
@@ -29,7 +27,4 @@ var Line = function Line(_ref) {
29
27
  className: classNames
30
28
  });
31
29
  };
32
- Line.propTypes = {
33
- status: _propTypes["default"].oneOf((0, _values["default"])(_Stepper.stepStatuses))
34
- };
35
30
  var _default = exports["default"] = Line;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { StepStatus } from './Stepper.constants';
3
+ interface StepProps {
4
+ status?: StepStatus;
5
+ value?: number;
6
+ className?: string;
7
+ orientation?: 'vertical' | 'horizontal';
8
+ }
9
+ declare const Step: React.ForwardRefExoticComponent<StepProps & React.RefAttributes<HTMLElement>>;
10
+ export default Step;
@@ -9,12 +9,10 @@ _Object$defineProperty(exports, "__esModule", {
9
9
  value: true
10
10
  });
11
11
  exports["default"] = void 0;
12
- var _values = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/values"));
13
12
  var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
14
13
  var _react = _interopRequireWildcard(require("react"));
15
14
  var _CheckBoldIcon = _interopRequireDefault(require("@pingux/mdi-react/CheckBoldIcon"));
16
15
  var _interactions = require("@react-aria/interactions");
17
- var _propTypes = _interopRequireDefault(require("prop-types"));
18
16
  var _index = require("../../index");
19
17
  var _orientation = _interopRequireDefault(require("../../utils/devUtils/constants/orientation"));
20
18
  var _Stepper = require("./Stepper.constants");
@@ -23,11 +21,13 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof _WeakMap) var
23
21
  var COMPLETED = _Stepper.stepStatuses.COMPLETED,
24
22
  INACTIVE = _Stepper.stepStatuses.INACTIVE;
25
23
  var Step = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
26
- var status = props.status,
27
- value = props.value,
24
+ var _props$status = props.status,
25
+ status = _props$status === void 0 ? INACTIVE : _props$status,
26
+ _props$value = props.value,
27
+ value = _props$value === void 0 ? 0 : _props$value,
28
28
  className = props.className,
29
29
  orientation = props.orientation;
30
- var _useHover = (0, _interactions.useHover)(props),
30
+ var _useHover = (0, _interactions.useHover)({}),
31
31
  hoverProps = _useHover.hoverProps,
32
32
  isHovered = _useHover.isHovered;
33
33
  var stepValue = orientation !== _orientation["default"].VERTICAL && value;
@@ -45,13 +45,5 @@ var Step = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
45
45
  }
46
46
  }) : stepValue);
47
47
  });
48
- Step.propTypes = {
49
- status: _propTypes["default"].oneOf((0, _values["default"])(_Stepper.stepStatuses)),
50
- value: _propTypes["default"].number,
51
- orientation: _propTypes["default"].oneOf([_orientation["default"].VERTICAL, _orientation["default"].HORIZONTAL])
52
- };
53
- Step.defaultProps = {
54
- status: INACTIVE,
55
- value: 0
56
- };
48
+ Step.displayName = 'Step';
57
49
  var _default = exports["default"] = Step;
@@ -0,0 +1,6 @@
1
+ export declare const stepStatuses: {
2
+ readonly ACTIVE: "active";
3
+ readonly COMPLETED: "completed";
4
+ readonly INACTIVE: "inactive";
5
+ };
6
+ export type StepStatus = typeof stepStatuses[keyof typeof stepStatuses];
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { StepperProps } from '../../types';
3
+ declare const Stepper: React.ForwardRefExoticComponent<StepperProps & React.RefAttributes<HTMLElement>>;
4
+ export default Stepper;
@@ -23,11 +23,11 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/he
23
23
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
24
24
  var _react = _interopRequireWildcard(require("react"));
25
25
  var _list = require("@react-stately/list");
26
- var _propTypes = _interopRequireDefault(require("prop-types"));
27
26
  var _ = require("../..");
28
27
  var _hooks = require("../../hooks");
29
28
  var _orientation = _interopRequireDefault(require("../../utils/devUtils/constants/orientation"));
30
29
  var _isValidPositiveInt = _interopRequireDefault(require("../../utils/devUtils/props/isValidPositiveInt"));
30
+ var _Tab = _interopRequireDefault(require("../Tab"));
31
31
  var _Line = _interopRequireDefault(require("./Line"));
32
32
  var _Stepper = require("./Stepper.constants");
33
33
  var _Stepper2 = require("./Stepper.styles");
@@ -49,6 +49,15 @@ var Stepper = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
49
49
  orientation = props.orientation,
50
50
  className = props.className,
51
51
  others = (0, _objectWithoutProperties2["default"])(props, _excluded);
52
+ var stepperRef = (0, _hooks.useLocalOrForwardRef)(ref);
53
+ if (process.env.NODE_ENV !== 'production' && props.activeStep !== undefined) {
54
+ var validationError = (0, _isValidPositiveInt["default"])({
55
+ activeStep: props.activeStep
56
+ }, 'activeStep', 'Stepper');
57
+ if (validationError) {
58
+ console.error(validationError.message);
59
+ }
60
+ }
52
61
  var state = (0, _list.useSingleSelectListState)(props);
53
62
  var getStatus = function getStatus(i) {
54
63
  if (i === activeStep) {
@@ -61,7 +70,7 @@ var Stepper = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
61
70
  };
62
71
  var onStepChangeHandler = function onStepChangeHandler(key) {
63
72
  if (onStepChange) {
64
- onStepChange(+key);
73
+ onStepChange(Number(key));
65
74
  }
66
75
  };
67
76
  var _useStatusClasses = (0, _hooks.useStatusClasses)(className, {
@@ -107,7 +116,8 @@ var Stepper = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
107
116
 
108
117
  /* istanbul ignore next */
109
118
  var textValue = item && item.value && item.value.label || item.textValue || stepIndex.toString();
110
- var container = (0, _react2.jsx)(_.Tab, {
119
+ var TabItem = _Tab["default"];
120
+ var container = (0, _react2.jsx)(TabItem, {
111
121
  key: stepIndex,
112
122
  variant: "stepper.tab",
113
123
  tabLineProps: {
@@ -122,13 +132,13 @@ var Stepper = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
122
132
  content: item.rendered,
123
133
  separator: !isFirst && orientation === _orientation["default"].HORIZONTAL && !isFirst && line,
124
134
  tooltipTriggerProps: tooltipProps,
125
- sx: i !== steps.length - 1 && orientation === _orientation["default"].VERTICAL && _Stepper2.verticalLine
135
+ sx: i !== steps.length - 1 && orientation === _orientation["default"].VERTICAL ? _Stepper2.verticalLine : undefined
126
136
  });
127
137
  isFirst = isFirst && !container;
128
138
  return container;
129
139
  });
130
140
  return (0, _react2.jsx)(_.Tabs, (0, _extends2["default"])({
131
- ref: ref,
141
+ ref: stepperRef,
132
142
  variant: "stepper.wrapper",
133
143
  tabListProps: _objectSpread({
134
144
  variant: 'stepper.tabs',
@@ -140,30 +150,6 @@ var Stepper = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
140
150
  orientation: orientation
141
151
  }, others), render);
142
152
  });
143
- Stepper.propTypes = {
144
- /**
145
- * *For performance reasons,
146
- use this prop instead of Array.map when iteratively rendering Items*.
147
- * For use with [dynamic collections](https://react-spectrum.adobe.com/react-stately/collections.html#dynamic-collections).
148
- */
149
- items: _propTypes["default"].arrayOf(_propTypes["default"].shape({
150
- /** The primary option for the tooltip label. */
151
- label: _propTypes["default"].string,
152
- children: _propTypes["default"].node,
153
- name: _propTypes["default"].string
154
- })),
155
- /** The number of the current step (using one-based indexing) */
156
- activeStep: _isValidPositiveInt["default"],
157
- /**
158
- * Handler that is called when the current step changes
159
- * `(index: number) => void`
160
- */
161
- onStepChange: _propTypes["default"].func,
162
- /** A props object that is subsequently spread into the rendered tablist. */
163
- tabListProps: _propTypes["default"].shape({}),
164
- tooltipProps: _propTypes["default"].shape({}),
165
- orientation: _propTypes["default"].oneOf(['vertical', 'horizontal'])
166
- };
167
153
  Stepper.displayName = 'Stepper';
168
154
  Stepper.defaultProps = {
169
155
  orientation: 'horizontal'
@@ -16,7 +16,7 @@ var _CreationOutlineIcon = _interopRequireDefault(require("@pingux/mdi-react/Cre
16
16
  var _storybookDocsLayout = _interopRequireDefault(require("../../../.storybook/storybookDocsLayout"));
17
17
  var _hooks = require("../../hooks");
18
18
  var _index = require("../../index");
19
- var _figmaLinks = require("../../utils/designUtils/figmaLinks.ts");
19
+ var _figmaLinks = require("../../utils/designUtils/figmaLinks");
20
20
  var _Stepper = _interopRequireDefault(require("./Stepper.mdx"));
21
21
  var _react2 = require("@emotion/react");
22
22
  function _interopRequireWildcard(e, t) { if ("function" == typeof _WeakMap) var r = new _WeakMap(), n = new _WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = _Object$defineProperty) && _Object$getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
@@ -248,7 +248,7 @@ var Panel = exports.Panel = function Panel() {
248
248
  var _useOverlayPanelState = (0, _hooks.useOverlayPanelState)(),
249
249
  state = _useOverlayPanelState.state,
250
250
  onClose = _useOverlayPanelState.onClose;
251
- var triggerRef = _react.useRef < HTMLButtonElement > null;
251
+ var triggerRef = (0, _react.useRef)(null);
252
252
  var onCloseHandler = function onCloseHandler() {
253
253
  return onClose(state, triggerRef);
254
254
  };
@@ -0,0 +1,257 @@
1
+ export declare const verticalLine: {
2
+ '&:before': {
3
+ position: string;
4
+ content: string;
5
+ borderLeft: string;
6
+ borderLeftColor: string;
7
+ left: string;
8
+ top: string;
9
+ height: string;
10
+ };
11
+ };
12
+ declare const _default: {
13
+ wrapper: {
14
+ width: string;
15
+ };
16
+ tabs: {
17
+ outline: string;
18
+ borderBottom: string;
19
+ mb: string;
20
+ justifyContent: string;
21
+ '&.is-horizontal': {
22
+ width: string;
23
+ };
24
+ '&.is-vertical': {
25
+ minWidth: string;
26
+ borderRight: string;
27
+ };
28
+ };
29
+ tab: {
30
+ '&.is-horizontal': {
31
+ mb: number;
32
+ mr: number;
33
+ outline: string;
34
+ '&.is-focused': {
35
+ outline: string;
36
+ outlineColor: string;
37
+ outlineOffset: string;
38
+ borderRadius: string;
39
+ };
40
+ '&:not(:first-of-type)': {
41
+ flex: number;
42
+ maxWidth: number;
43
+ };
44
+ };
45
+ '&.is-vertical': {
46
+ position: string;
47
+ height: string;
48
+ width: string;
49
+ py: string;
50
+ px: string;
51
+ ':focus-visible:not(.is-focused)': {
52
+ outline: string;
53
+ };
54
+ };
55
+ };
56
+ tabLabel: {
57
+ mb: number;
58
+ };
59
+ outerWrapper: {
60
+ alignItems: string;
61
+ };
62
+ step: {
63
+ active: {
64
+ '&.is-horizontal': {
65
+ display: string;
66
+ justifyContent: string;
67
+ alignItems: string;
68
+ width: number;
69
+ height: number;
70
+ minWidth: number;
71
+ minHeight: number;
72
+ borderWidth: number;
73
+ borderStyle: string;
74
+ borderRadius: string;
75
+ fontSize: string;
76
+ fontWeight: number;
77
+ cursor: string;
78
+ fontFamily: string;
79
+ '&[aria-expanded="true"]': {
80
+ backgroundColor: string;
81
+ borderColor: string;
82
+ color: string;
83
+ };
84
+ backgroundColor: string;
85
+ borderColor: string;
86
+ color: string;
87
+ };
88
+ '&.is-vertical': {
89
+ backgroundColor: string;
90
+ border: string;
91
+ borderColor: string;
92
+ width: number;
93
+ height: number;
94
+ minWidth: number;
95
+ minHeight: number;
96
+ display: string;
97
+ justifyContent: string;
98
+ alignItems: string;
99
+ borderWidth: number;
100
+ borderStyle: string;
101
+ borderRadius: string;
102
+ fontSize: string;
103
+ fontWeight: number;
104
+ cursor: string;
105
+ fontFamily: string;
106
+ '&[aria-expanded="true"]': {
107
+ backgroundColor: string;
108
+ borderColor: string;
109
+ color: string;
110
+ };
111
+ };
112
+ };
113
+ completed: {
114
+ '&.is-horizontal': {
115
+ display: string;
116
+ justifyContent: string;
117
+ alignItems: string;
118
+ width: number;
119
+ height: number;
120
+ minWidth: number;
121
+ minHeight: number;
122
+ borderWidth: number;
123
+ borderStyle: string;
124
+ borderRadius: string;
125
+ fontSize: string;
126
+ fontWeight: number;
127
+ cursor: string;
128
+ fontFamily: string;
129
+ '&[aria-expanded="true"]': {
130
+ backgroundColor: string;
131
+ borderColor: string;
132
+ color: string;
133
+ };
134
+ backgroundColor: string;
135
+ borderColor: string;
136
+ color: string;
137
+ };
138
+ '&.is-vertical': {
139
+ width: number;
140
+ height: number;
141
+ minWidth: number;
142
+ minHeight: number;
143
+ display: string;
144
+ justifyContent: string;
145
+ alignItems: string;
146
+ borderWidth: number;
147
+ borderStyle: string;
148
+ borderRadius: string;
149
+ fontSize: string;
150
+ fontWeight: number;
151
+ cursor: string;
152
+ fontFamily: string;
153
+ '&[aria-expanded="true"]': {
154
+ backgroundColor: string;
155
+ borderColor: string;
156
+ color: string;
157
+ };
158
+ backgroundColor: string;
159
+ borderColor: string;
160
+ };
161
+ };
162
+ inactive: {
163
+ '&.is-horizontal': {
164
+ display: string;
165
+ justifyContent: string;
166
+ alignItems: string;
167
+ width: number;
168
+ height: number;
169
+ minWidth: number;
170
+ minHeight: number;
171
+ borderWidth: number;
172
+ borderStyle: string;
173
+ borderRadius: string;
174
+ fontSize: string;
175
+ fontWeight: number;
176
+ cursor: string;
177
+ fontFamily: string;
178
+ '&[aria-expanded="true"]': {
179
+ backgroundColor: string;
180
+ borderColor: string;
181
+ color: string;
182
+ };
183
+ backgroundColor: string;
184
+ borderColor: string;
185
+ color: string;
186
+ };
187
+ '&.is-vertical': {
188
+ backgroundColor: string;
189
+ border: string;
190
+ width: number;
191
+ height: number;
192
+ minWidth: number;
193
+ minHeight: number;
194
+ display: string;
195
+ justifyContent: string;
196
+ alignItems: string;
197
+ borderWidth: number;
198
+ borderStyle: string;
199
+ borderRadius: string;
200
+ fontSize: string;
201
+ fontWeight: number;
202
+ cursor: string;
203
+ fontFamily: string;
204
+ '&[aria-expanded="true"]': {
205
+ backgroundColor: string;
206
+ borderColor: string;
207
+ color: string;
208
+ };
209
+ };
210
+ };
211
+ default: {
212
+ display: string;
213
+ justifyContent: string;
214
+ alignItems: string;
215
+ width: number;
216
+ height: number;
217
+ minWidth: number;
218
+ minHeight: number;
219
+ borderWidth: number;
220
+ borderStyle: string;
221
+ borderRadius: string;
222
+ fontSize: string;
223
+ fontWeight: number;
224
+ cursor: string;
225
+ fontFamily: string;
226
+ '&[aria-expanded="true"]': {
227
+ backgroundColor: string;
228
+ borderColor: string;
229
+ color: string;
230
+ };
231
+ backgroundColor: string;
232
+ borderColor: string;
233
+ color: string;
234
+ };
235
+ };
236
+ line: {
237
+ alignSelf: string;
238
+ width: string;
239
+ maxWidth: string;
240
+ borderBottomWidth: number;
241
+ borderBottomStyle: string;
242
+ borderBottomColor: string;
243
+ '&.is-inactive': {
244
+ borderBottomStyle: string;
245
+ borderBottomColor: string;
246
+ };
247
+ '&.is-default': {
248
+ width: number;
249
+ height: string;
250
+ maxHeight: string;
251
+ borderRightWidth: number;
252
+ borderRightStyle: string;
253
+ borderRightColor: string;
254
+ };
255
+ };
256
+ };
257
+ export default _default;
@@ -61,34 +61,31 @@ var defaultProps = {
61
61
  activeStep: 1,
62
62
  items: steps
63
63
  };
64
+
65
+ // StepperProps.children is ReactNode (from BoxProps), but Stepper also accepts a render-prop
66
+ // function via react-stately's collection mechanism. We cast to silence the assignability error.
67
+ var stepperChildren = function stepperChildren(_ref) {
68
+ var name = _ref.name,
69
+ children = _ref.children;
70
+ return (0, _react2.jsx)(_reactStately.Item, {
71
+ key: name || children,
72
+ textValue: name || children
73
+ }, (0, _react2.jsx)(_Text["default"], null, children));
74
+ };
64
75
  var getComponent = function getComponent() {
65
76
  var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
66
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
67
- _ref$renderFn = _ref.renderFn,
68
- renderFn = _ref$renderFn === void 0 ? _testWrapper.render : _ref$renderFn;
77
+ var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
78
+ _ref2$renderFn = _ref2.renderFn,
79
+ renderFn = _ref2$renderFn === void 0 ? _testWrapper.render : _ref2$renderFn;
69
80
  return renderFn((0, _react2.jsx)(_react2.CacheProvider, {
70
81
  value: emotionCache
71
- }, (0, _react2.jsx)(_Stepper["default"], (0, _extends2["default"])({}, defaultProps, props), function (_ref2) {
72
- var name = _ref2.name,
73
- children = _ref2.children;
74
- return (0, _react2.jsx)(_reactStately.Item, {
75
- key: name || children,
76
- textValue: name || children
77
- }, (0, _react2.jsx)(_Text["default"], null, children));
78
- })));
82
+ }, (0, _react2.jsx)(_Stepper["default"], (0, _extends2["default"])({}, defaultProps, props), stepperChildren)));
79
83
  };
80
84
 
81
85
  // Needs to be added to each components test file
82
86
  (0, _universalComponentTest.universalComponentTests)({
83
87
  renderComponent: function renderComponent(props) {
84
- return (0, _react2.jsx)(_Stepper["default"], (0, _extends2["default"])({}, defaultProps, props), function (_ref3) {
85
- var name = _ref3.name,
86
- children = _ref3.children;
87
- return (0, _react2.jsx)(_reactStately.Item, {
88
- key: name || children,
89
- textValue: name || children
90
- }, (0, _react2.jsx)(_Text["default"], null, children));
91
- });
88
+ return (0, _react2.jsx)(_Stepper["default"], (0, _extends2["default"])({}, defaultProps, props), stepperChildren);
92
89
  }
93
90
  });
94
91
  test('renders Stepper component in the default state', function () {
@@ -162,8 +159,9 @@ test('tooltip renders expected content based on props', /*#__PURE__*/(0, _asyncT
162
159
  _testWrapper.fireEvent.mouseMove(tab0);
163
160
  _testWrapper.fireEvent.mouseEnter(tab0);
164
161
  (0, _setTimeout2["default"])(function () {
162
+ var _steps$0$label;
165
163
  expect(_testWrapper.screen.queryByRole('tooltip')).toBeInTheDocument();
166
- expect(_testWrapper.screen.queryByRole('tooltip')).toHaveTextContent(steps[0].label);
164
+ expect(_testWrapper.screen.queryByRole('tooltip')).toHaveTextContent((_steps$0$label = steps[0].label) !== null && _steps$0$label !== void 0 ? _steps$0$label : '');
167
165
  }, 0);
168
166
 
169
167
  // Should render textValue
@@ -0,0 +1,2 @@
1
+ export { default as Step } from './Step';
2
+ export { default } from './Stepper';
@@ -0,0 +1,33 @@
1
+ import { ReactNode } from 'react';
2
+ import { TestingAttributes } from './shared/test';
3
+ import { ValidPositiveInteger } from './shared/validPositiveInteger';
4
+ import { BoxProps } from './box';
5
+ export interface StepperItemProps {
6
+ /** The primary option for the tooltip label. */
7
+ label?: string;
8
+ children?: ReactNode;
9
+ name?: string;
10
+ /** Whether the step is required. */
11
+ isRequired?: boolean;
12
+ }
13
+ export interface StepperProps extends BoxProps, TestingAttributes {
14
+ /**
15
+ * *For performance reasons,
16
+ * use this prop instead of Array.map when iteratively rendering Items*.
17
+ * For use with [dynamic collections](https://react-spectrum.adobe.com/react-stately/collections.html#dynamic-collections).
18
+ */
19
+ items?: Array<StepperItemProps>;
20
+ /** The number of the current step (using one-based indexing) */
21
+ activeStep?: ValidPositiveInteger;
22
+ /**
23
+ * Handler that is called when the current step changes.
24
+ * `(index: number) => void`
25
+ */
26
+ onStepChange?: (index: number) => void;
27
+ /** A props object that is subsequently spread into the rendered tablist. */
28
+ tabListProps?: Record<string, unknown>;
29
+ /** A props object that is subsequently spread into the rendered tooltip. */
30
+ tooltipProps?: Record<string, unknown>;
31
+ /** The orientation of the stepper. */
32
+ orientation?: 'vertical' | 'horizontal';
33
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
+ _Object$defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
@@ -52,6 +52,7 @@ export * from './separator';
52
52
  export * from './ServerErrorBoundary';
53
53
  export * from './shared';
54
54
  export * from './skeleton';
55
+ export * from './Stepper';
55
56
  export * from './switchField';
56
57
  export * from './tab';
57
58
  export * from './table';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context0, _context1, _context10, _context11, _context12, _context13, _context14, _context15, _context16, _context17, _context18, _context19, _context20, _context21, _context22, _context23, _context24, _context25, _context26, _context27, _context28, _context29, _context30, _context31, _context32, _context33, _context34, _context35, _context36, _context37, _context38, _context39, _context40, _context41, _context42, _context43, _context44, _context45, _context46, _context47, _context48, _context49, _context50, _context51, _context52, _context53, _context54, _context55, _context56, _context57, _context58, _context59, _context60;
3
+ var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context0, _context1, _context10, _context11, _context12, _context13, _context14, _context15, _context16, _context17, _context18, _context19, _context20, _context21, _context22, _context23, _context24, _context25, _context26, _context27, _context28, _context29, _context30, _context31, _context32, _context33, _context34, _context35, _context36, _context37, _context38, _context39, _context40, _context41, _context42, _context43, _context44, _context45, _context46, _context47, _context48, _context49, _context50, _context51, _context52, _context53, _context54, _context55, _context56, _context57, _context58, _context59, _context60, _context61;
4
4
  var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
5
5
  var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
6
6
  var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
@@ -601,8 +601,19 @@ _forEachInstanceProperty(_context52 = _Object$keys(_skeleton)).call(_context52,
601
601
  }
602
602
  });
603
603
  });
604
+ var _Stepper = require("./Stepper");
605
+ _forEachInstanceProperty(_context53 = _Object$keys(_Stepper)).call(_context53, function (key) {
606
+ if (key === "default" || key === "__esModule") return;
607
+ if (key in exports && exports[key] === _Stepper[key]) return;
608
+ _Object$defineProperty(exports, key, {
609
+ enumerable: true,
610
+ get: function get() {
611
+ return _Stepper[key];
612
+ }
613
+ });
614
+ });
604
615
  var _switchField = require("./switchField");
605
- _forEachInstanceProperty(_context53 = _Object$keys(_switchField)).call(_context53, function (key) {
616
+ _forEachInstanceProperty(_context54 = _Object$keys(_switchField)).call(_context54, function (key) {
606
617
  if (key === "default" || key === "__esModule") return;
607
618
  if (key in exports && exports[key] === _switchField[key]) return;
608
619
  _Object$defineProperty(exports, key, {
@@ -613,7 +624,7 @@ _forEachInstanceProperty(_context53 = _Object$keys(_switchField)).call(_context5
613
624
  });
614
625
  });
615
626
  var _tab = require("./tab");
616
- _forEachInstanceProperty(_context54 = _Object$keys(_tab)).call(_context54, function (key) {
627
+ _forEachInstanceProperty(_context55 = _Object$keys(_tab)).call(_context55, function (key) {
617
628
  if (key === "default" || key === "__esModule") return;
618
629
  if (key in exports && exports[key] === _tab[key]) return;
619
630
  _Object$defineProperty(exports, key, {
@@ -624,7 +635,7 @@ _forEachInstanceProperty(_context54 = _Object$keys(_tab)).call(_context54, funct
624
635
  });
625
636
  });
626
637
  var _table = require("./table");
627
- _forEachInstanceProperty(_context55 = _Object$keys(_table)).call(_context55, function (key) {
638
+ _forEachInstanceProperty(_context56 = _Object$keys(_table)).call(_context56, function (key) {
628
639
  if (key === "default" || key === "__esModule") return;
629
640
  if (key in exports && exports[key] === _table[key]) return;
630
641
  _Object$defineProperty(exports, key, {
@@ -635,7 +646,7 @@ _forEachInstanceProperty(_context55 = _Object$keys(_table)).call(_context55, fun
635
646
  });
636
647
  });
637
648
  var _tabs = require("./tabs");
638
- _forEachInstanceProperty(_context56 = _Object$keys(_tabs)).call(_context56, function (key) {
649
+ _forEachInstanceProperty(_context57 = _Object$keys(_tabs)).call(_context57, function (key) {
639
650
  if (key === "default" || key === "__esModule") return;
640
651
  if (key in exports && exports[key] === _tabs[key]) return;
641
652
  _Object$defineProperty(exports, key, {
@@ -646,7 +657,7 @@ _forEachInstanceProperty(_context56 = _Object$keys(_tabs)).call(_context56, func
646
657
  });
647
658
  });
648
659
  var _text = require("./text");
649
- _forEachInstanceProperty(_context57 = _Object$keys(_text)).call(_context57, function (key) {
660
+ _forEachInstanceProperty(_context58 = _Object$keys(_text)).call(_context58, function (key) {
650
661
  if (key === "default" || key === "__esModule") return;
651
662
  if (key in exports && exports[key] === _text[key]) return;
652
663
  _Object$defineProperty(exports, key, {
@@ -657,7 +668,7 @@ _forEachInstanceProperty(_context57 = _Object$keys(_text)).call(_context57, func
657
668
  });
658
669
  });
659
670
  var _textField = require("./textField");
660
- _forEachInstanceProperty(_context58 = _Object$keys(_textField)).call(_context58, function (key) {
671
+ _forEachInstanceProperty(_context59 = _Object$keys(_textField)).call(_context59, function (key) {
661
672
  if (key === "default" || key === "__esModule") return;
662
673
  if (key in exports && exports[key] === _textField[key]) return;
663
674
  _Object$defineProperty(exports, key, {
@@ -668,7 +679,7 @@ _forEachInstanceProperty(_context58 = _Object$keys(_textField)).call(_context58,
668
679
  });
669
680
  });
670
681
  var _timefield = require("./timefield");
671
- _forEachInstanceProperty(_context59 = _Object$keys(_timefield)).call(_context59, function (key) {
682
+ _forEachInstanceProperty(_context60 = _Object$keys(_timefield)).call(_context60, function (key) {
672
683
  if (key === "default" || key === "__esModule") return;
673
684
  if (key in exports && exports[key] === _timefield[key]) return;
674
685
  _Object$defineProperty(exports, key, {
@@ -679,7 +690,7 @@ _forEachInstanceProperty(_context59 = _Object$keys(_timefield)).call(_context59,
679
690
  });
680
691
  });
681
692
  var _tooltipTrigger = require("./tooltipTrigger");
682
- _forEachInstanceProperty(_context60 = _Object$keys(_tooltipTrigger)).call(_context60, function (key) {
693
+ _forEachInstanceProperty(_context61 = _Object$keys(_tooltipTrigger)).call(_context61, function (key) {
683
694
  if (key === "default" || key === "__esModule") return;
684
695
  if (key in exports && exports[key] === _tooltipTrigger[key]) return;
685
696
  _Object$defineProperty(exports, key, {
@@ -1,4 +1,4 @@
1
- import { Dispatch, ReactNode, SetStateAction } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  import { AriaTabListProps } from '@react-aria/tabs';
3
3
  import { TabListState } from '@react-stately/tabs';
4
4
  import type { CollectionChildren } from '@react-types/shared';
@@ -21,7 +21,7 @@ export interface TabsProps extends StyleProps, TestingAttributes, OrientationPro
21
21
  /** Whether the entire tablist is disabled. */
22
22
  isDisabled?: boolean;
23
23
  /** Handler that is called when the selected tab has changed. */
24
- onSelectionChange?: Dispatch<SetStateAction<string | undefined>>;
24
+ onSelectionChange?: (key: string) => void;
25
25
  /** A props object that is subsequently spread into the rendered tablist. */
26
26
  tabListProps?: object;
27
27
  /** Props object that is spread directly into all of the tab panel wrapper elements. */
@@ -0,0 +1,2 @@
1
+ declare const isValidPositiveInt: (props: Record<string, unknown>, propName: string, componentName: string) => null | Error;
2
+ export default isValidPositiveInt;
@@ -20,7 +20,8 @@ var validatePositiveInteger = function validatePositiveInteger() {
20
20
  var isPositiveInteger = isWithinRange(1, Infinity);
21
21
  if (props[propName] && !isPositiveInteger(props[propName])) {
22
22
  var _context, _context2;
23
- return new Error((0, _concat["default"])(_context = (0, _concat["default"])(_context2 = "Expected a positive integer for ".concat(propName, " in ")).call(_context2, componentName, ", but instead received `")).call(_context, props[propName], "`."));
23
+ var received = props[propName];
24
+ return new Error((0, _concat["default"])(_context = (0, _concat["default"])(_context2 = "Expected a positive integer for ".concat(propName, " in ")).call(_context2, componentName, ", but instead received `")).call(_context, received, "`."));
24
25
  }
25
26
  // Everything is fine
26
27
  return null;
@@ -1,7 +1,5 @@
1
- import _Object$values from "@babel/runtime-corejs3/core-js-stable/object/values";
2
1
  /* istanbul ignore file */
3
2
  import React from 'react';
4
- import PropTypes from 'prop-types';
5
3
  import { useStatusClasses } from '../../hooks';
6
4
  import Box from '../Box';
7
5
  import { stepStatuses } from './Stepper.constants';
@@ -20,7 +18,4 @@ var Line = function Line(_ref) {
20
18
  className: classNames
21
19
  });
22
20
  };
23
- Line.propTypes = {
24
- status: PropTypes.oneOf(_Object$values(stepStatuses))
25
- };
26
21
  export default Line;
@@ -1,9 +1,7 @@
1
1
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
- import _Object$values from "@babel/runtime-corejs3/core-js-stable/object/values";
3
2
  import React, { forwardRef } from 'react';
4
3
  import CheckBoldIcon from '@pingux/mdi-react/CheckBoldIcon';
5
4
  import { useHover } from '@react-aria/interactions';
6
- import PropTypes from 'prop-types';
7
5
  import { Box, Icon } from '../../index';
8
6
  import ORIENTATION from '../../utils/devUtils/constants/orientation';
9
7
  import { stepStatuses } from './Stepper.constants';
@@ -11,11 +9,13 @@ import { jsx as ___EmotionJSX } from "@emotion/react";
11
9
  var COMPLETED = stepStatuses.COMPLETED,
12
10
  INACTIVE = stepStatuses.INACTIVE;
13
11
  var Step = /*#__PURE__*/forwardRef(function (props, ref) {
14
- var status = props.status,
15
- value = props.value,
12
+ var _props$status = props.status,
13
+ status = _props$status === void 0 ? INACTIVE : _props$status,
14
+ _props$value = props.value,
15
+ value = _props$value === void 0 ? 0 : _props$value,
16
16
  className = props.className,
17
17
  orientation = props.orientation;
18
- var _useHover = useHover(props),
18
+ var _useHover = useHover({}),
19
19
  hoverProps = _useHover.hoverProps,
20
20
  isHovered = _useHover.isHovered;
21
21
  var stepValue = orientation !== ORIENTATION.VERTICAL && value;
@@ -33,13 +33,5 @@ var Step = /*#__PURE__*/forwardRef(function (props, ref) {
33
33
  }
34
34
  }) : stepValue);
35
35
  });
36
- Step.propTypes = {
37
- status: PropTypes.oneOf(_Object$values(stepStatuses)),
38
- value: PropTypes.number,
39
- orientation: PropTypes.oneOf([ORIENTATION.VERTICAL, ORIENTATION.HORIZONTAL])
40
- };
41
- Step.defaultProps = {
42
- status: INACTIVE,
43
- value: 0
44
- };
36
+ Step.displayName = 'Step';
45
37
  export default Step;
@@ -18,11 +18,11 @@ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object
18
18
  /* istanbul ignore file */
19
19
  import React, { forwardRef } from 'react';
20
20
  import { useSingleSelectListState } from '@react-stately/list';
21
- import PropTypes from 'prop-types';
22
- import { Box, Step, Tab, Tabs, Text } from '../..';
23
- import { useStatusClasses } from '../../hooks';
21
+ import { Box, Step, Tabs, Text } from '../..';
22
+ import { useLocalOrForwardRef, useStatusClasses } from '../../hooks';
24
23
  import ORIENTATION from '../../utils/devUtils/constants/orientation';
25
24
  import isValidPositiveInt from '../../utils/devUtils/props/isValidPositiveInt';
25
+ import Tab from '../Tab';
26
26
  import Line from './Line';
27
27
  import { stepStatuses } from './Stepper.constants';
28
28
  import { verticalLine } from './Stepper.styles';
@@ -39,6 +39,15 @@ var Stepper = /*#__PURE__*/forwardRef(function (props, ref) {
39
39
  orientation = props.orientation,
40
40
  className = props.className,
41
41
  others = _objectWithoutProperties(props, _excluded);
42
+ var stepperRef = useLocalOrForwardRef(ref);
43
+ if (process.env.NODE_ENV !== 'production' && props.activeStep !== undefined) {
44
+ var validationError = isValidPositiveInt({
45
+ activeStep: props.activeStep
46
+ }, 'activeStep', 'Stepper');
47
+ if (validationError) {
48
+ console.error(validationError.message);
49
+ }
50
+ }
42
51
  var state = useSingleSelectListState(props);
43
52
  var getStatus = function getStatus(i) {
44
53
  if (i === activeStep) {
@@ -51,7 +60,7 @@ var Stepper = /*#__PURE__*/forwardRef(function (props, ref) {
51
60
  };
52
61
  var onStepChangeHandler = function onStepChangeHandler(key) {
53
62
  if (onStepChange) {
54
- onStepChange(+key);
63
+ onStepChange(Number(key));
55
64
  }
56
65
  };
57
66
  var _useStatusClasses = useStatusClasses(className, {
@@ -97,7 +106,8 @@ var Stepper = /*#__PURE__*/forwardRef(function (props, ref) {
97
106
 
98
107
  /* istanbul ignore next */
99
108
  var textValue = item && item.value && item.value.label || item.textValue || stepIndex.toString();
100
- var container = ___EmotionJSX(Tab, {
109
+ var TabItem = Tab;
110
+ var container = ___EmotionJSX(TabItem, {
101
111
  key: stepIndex,
102
112
  variant: "stepper.tab",
103
113
  tabLineProps: {
@@ -112,13 +122,13 @@ var Stepper = /*#__PURE__*/forwardRef(function (props, ref) {
112
122
  content: item.rendered,
113
123
  separator: !isFirst && orientation === ORIENTATION.HORIZONTAL && !isFirst && line,
114
124
  tooltipTriggerProps: tooltipProps,
115
- sx: i !== steps.length - 1 && orientation === ORIENTATION.VERTICAL && verticalLine
125
+ sx: i !== steps.length - 1 && orientation === ORIENTATION.VERTICAL ? verticalLine : undefined
116
126
  });
117
127
  isFirst = isFirst && !container;
118
128
  return container;
119
129
  });
120
130
  return ___EmotionJSX(Tabs, _extends({
121
- ref: ref,
131
+ ref: stepperRef,
122
132
  variant: "stepper.wrapper",
123
133
  tabListProps: _objectSpread({
124
134
  variant: 'stepper.tabs',
@@ -130,30 +140,6 @@ var Stepper = /*#__PURE__*/forwardRef(function (props, ref) {
130
140
  orientation: orientation
131
141
  }, others), render);
132
142
  });
133
- Stepper.propTypes = {
134
- /**
135
- * *For performance reasons,
136
- use this prop instead of Array.map when iteratively rendering Items*.
137
- * For use with [dynamic collections](https://react-spectrum.adobe.com/react-stately/collections.html#dynamic-collections).
138
- */
139
- items: PropTypes.arrayOf(PropTypes.shape({
140
- /** The primary option for the tooltip label. */
141
- label: PropTypes.string,
142
- children: PropTypes.node,
143
- name: PropTypes.string
144
- })),
145
- /** The number of the current step (using one-based indexing) */
146
- activeStep: isValidPositiveInt,
147
- /**
148
- * Handler that is called when the current step changes
149
- * `(index: number) => void`
150
- */
151
- onStepChange: PropTypes.func,
152
- /** A props object that is subsequently spread into the rendered tablist. */
153
- tabListProps: PropTypes.shape({}),
154
- tooltipProps: PropTypes.shape({}),
155
- orientation: PropTypes.oneOf(['vertical', 'horizontal'])
156
- };
157
143
  Stepper.displayName = 'Stepper';
158
144
  Stepper.defaultProps = {
159
145
  orientation: 'horizontal'
@@ -5,7 +5,7 @@ import CreationOutlineIcon from '@pingux/mdi-react/CreationOutlineIcon';
5
5
  import DocsLayout from '../../../.storybook/storybookDocsLayout';
6
6
  import { useOverlayPanelState } from '../../hooks';
7
7
  import { Box, Button, Item, OverlayPanel, OverlayProvider, PanelHeader, PanelHeaderCloseButton, Stepper, Text } from '../../index';
8
- import { FIGMA_LINKS } from '../../utils/designUtils/figmaLinks.ts';
8
+ import { FIGMA_LINKS } from '../../utils/designUtils/figmaLinks';
9
9
  import StepperReadme from './Stepper.mdx';
10
10
  import { jsx as ___EmotionJSX } from "@emotion/react";
11
11
  export default {
@@ -236,7 +236,7 @@ export var Panel = function Panel() {
236
236
  var _useOverlayPanelState = useOverlayPanelState(),
237
237
  state = _useOverlayPanelState.state,
238
238
  onClose = _useOverlayPanelState.onClose;
239
- var triggerRef = useRef < HTMLButtonElement > null;
239
+ var triggerRef = useRef(null);
240
240
  var onCloseHandler = function onCloseHandler() {
241
241
  return onClose(state, triggerRef);
242
242
  };
@@ -61,34 +61,31 @@ var defaultProps = {
61
61
  activeStep: 1,
62
62
  items: steps
63
63
  };
64
+
65
+ // StepperProps.children is ReactNode (from BoxProps), but Stepper also accepts a render-prop
66
+ // function via react-stately's collection mechanism. We cast to silence the assignability error.
67
+ var stepperChildren = function stepperChildren(_ref) {
68
+ var name = _ref.name,
69
+ children = _ref.children;
70
+ return ___EmotionJSX(Item, {
71
+ key: name || children,
72
+ textValue: name || children
73
+ }, ___EmotionJSX(Text, null, children));
74
+ };
64
75
  var getComponent = function getComponent() {
65
76
  var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
66
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
67
- _ref$renderFn = _ref.renderFn,
68
- renderFn = _ref$renderFn === void 0 ? render : _ref$renderFn;
77
+ var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
78
+ _ref2$renderFn = _ref2.renderFn,
79
+ renderFn = _ref2$renderFn === void 0 ? render : _ref2$renderFn;
69
80
  return renderFn(___EmotionJSX(CacheProvider, {
70
81
  value: emotionCache
71
- }, ___EmotionJSX(Stepper, _extends({}, defaultProps, props), function (_ref2) {
72
- var name = _ref2.name,
73
- children = _ref2.children;
74
- return ___EmotionJSX(Item, {
75
- key: name || children,
76
- textValue: name || children
77
- }, ___EmotionJSX(Text, null, children));
78
- })));
82
+ }, ___EmotionJSX(Stepper, _extends({}, defaultProps, props), stepperChildren)));
79
83
  };
80
84
 
81
85
  // Needs to be added to each components test file
82
86
  universalComponentTests({
83
87
  renderComponent: function renderComponent(props) {
84
- return ___EmotionJSX(Stepper, _extends({}, defaultProps, props), function (_ref3) {
85
- var name = _ref3.name,
86
- children = _ref3.children;
87
- return ___EmotionJSX(Item, {
88
- key: name || children,
89
- textValue: name || children
90
- }, ___EmotionJSX(Text, null, children));
91
- });
88
+ return ___EmotionJSX(Stepper, _extends({}, defaultProps, props), stepperChildren);
92
89
  }
93
90
  });
94
91
  test('renders Stepper component in the default state', function () {
@@ -162,8 +159,9 @@ test('tooltip renders expected content based on props', /*#__PURE__*/_asyncToGen
162
159
  fireEvent.mouseMove(tab0);
163
160
  fireEvent.mouseEnter(tab0);
164
161
  _setTimeout(function () {
162
+ var _steps$0$label;
165
163
  expect(screen.queryByRole('tooltip')).toBeInTheDocument();
166
- expect(screen.queryByRole('tooltip')).toHaveTextContent(steps[0].label);
164
+ expect(screen.queryByRole('tooltip')).toHaveTextContent((_steps$0$label = steps[0].label) !== null && _steps$0$label !== void 0 ? _steps$0$label : '');
167
165
  }, 0);
168
166
 
169
167
  // Should render textValue
@@ -0,0 +1 @@
1
+ export {};
@@ -52,6 +52,7 @@ export * from './separator';
52
52
  export * from './ServerErrorBoundary';
53
53
  export * from './shared';
54
54
  export * from './skeleton';
55
+ export * from './Stepper';
55
56
  export * from './switchField';
56
57
  export * from './tab';
57
58
  export * from './table';
@@ -12,7 +12,8 @@ var validatePositiveInteger = function validatePositiveInteger() {
12
12
  var isPositiveInteger = isWithinRange(1, Infinity);
13
13
  if (props[propName] && !isPositiveInteger(props[propName])) {
14
14
  var _context, _context2;
15
- return new Error(_concatInstanceProperty(_context = _concatInstanceProperty(_context2 = "Expected a positive integer for ".concat(propName, " in ")).call(_context2, componentName, ", but instead received `")).call(_context, props[propName], "`."));
15
+ var received = props[propName];
16
+ return new Error(_concatInstanceProperty(_context = _concatInstanceProperty(_context2 = "Expected a positive integer for ".concat(propName, " in ")).call(_context2, componentName, ", but instead received `")).call(_context, received, "`."));
16
17
  }
17
18
  // Everything is fine
18
19
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "2.204.0-alpha.0",
3
+ "version": "2.205.0-alpha.0",
4
4
  "description": "React component library for Ping Identity's design system",
5
5
  "repository": {
6
6
  "type": "git",