@pingux/astro 1.2.0-alpha.0 → 1.2.0-alpha.4

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 (37) hide show
  1. package/lib/cjs/components/Breadcrumbs/BreadcrumbItem.js +3 -0
  2. package/lib/cjs/components/Breadcrumbs/Breadcrumbs.js +24 -14
  3. package/lib/cjs/components/Breadcrumbs/Breadcrumbs.test.js +9 -0
  4. package/lib/cjs/components/CopyText/CopyButton.js +9 -2
  5. package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +338 -0
  6. package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.stories.js +295 -0
  7. package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.test.js +287 -0
  8. package/lib/cjs/components/EnvironmentBreadcrumb/index.js +18 -0
  9. package/lib/cjs/components/Messages/Messages.reducer.js +2 -1
  10. package/lib/cjs/components/Messages/Messages.stories.js +10 -10
  11. package/lib/cjs/components/Messages/Messages.test.js +15 -1
  12. package/lib/cjs/components/Messages/index.js +21 -2
  13. package/lib/cjs/components/MultivaluesField/MultivaluesField.js +3 -1
  14. package/lib/cjs/components/TextField/TextField.stories.js +79 -2
  15. package/lib/cjs/index.js +10 -0
  16. package/lib/cjs/styles/variants/boxes.js +13 -0
  17. package/lib/cjs/styles/variants/buttons.js +24 -1
  18. package/lib/cjs/styles/variants/text.js +9 -0
  19. package/lib/components/Breadcrumbs/BreadcrumbItem.js +4 -1
  20. package/lib/components/Breadcrumbs/Breadcrumbs.js +24 -15
  21. package/lib/components/Breadcrumbs/Breadcrumbs.test.js +9 -0
  22. package/lib/components/CopyText/CopyButton.js +7 -2
  23. package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +296 -0
  24. package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.stories.js +256 -0
  25. package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.test.js +246 -0
  26. package/lib/components/EnvironmentBreadcrumb/index.js +1 -0
  27. package/lib/components/Messages/Messages.reducer.js +1 -1
  28. package/lib/components/Messages/Messages.stories.js +1 -1
  29. package/lib/components/Messages/Messages.test.js +11 -1
  30. package/lib/components/Messages/index.js +2 -1
  31. package/lib/components/MultivaluesField/MultivaluesField.js +3 -1
  32. package/lib/components/TextField/TextField.stories.js +72 -0
  33. package/lib/index.js +1 -0
  34. package/lib/styles/variants/boxes.js +13 -0
  35. package/lib/styles/variants/buttons.js +24 -1
  36. package/lib/styles/variants/text.js +9 -0
  37. package/package.json +1 -1
@@ -26,7 +26,7 @@ var _testAxe = _interopRequireDefault(require("../../utils/testUtils/testAxe"));
26
26
 
27
27
  var _testWrapper = require("../../utils/testUtils/testWrapper");
28
28
 
29
- var _ = _interopRequireDefault(require("."));
29
+ var _ = _interopRequireWildcard(require("."));
30
30
 
31
31
  var _Button = _interopRequireDefault(require("../Button"));
32
32
 
@@ -211,4 +211,18 @@ describe('announcements', function () {
211
211
  expect(messages.childElementCount).toBe(1);
212
212
  expect(_liveAnnouncer.announce).toHaveBeenCalledWith('New message 1', 'polite');
213
213
  });
214
+ });
215
+ test('should render messages with messagesReducerStory', function () {
216
+ getComponent();
217
+
218
+ _.messagesReducerStory.actions.showSuccessMessage();
219
+
220
+ expect(_testWrapper.screen.getByTestId(testId)).toBeInTheDocument();
221
+ });
222
+ test('should render messages with multiMessagesReducerStory', function () {
223
+ getComponent();
224
+
225
+ _.multiMessagesReducerStory.actions.showSuccessMessage();
226
+
227
+ expect(_testWrapper.screen.getByTestId(testId)).toBeInTheDocument();
214
228
  });
@@ -14,7 +14,10 @@ _Object$defineProperty(exports, "__esModule", {
14
14
  value: true
15
15
  });
16
16
 
17
- var _exportNames = {};
17
+ var _exportNames = {
18
+ messagesReducerStory: true,
19
+ multiMessagesReducerStory: true
20
+ };
18
21
 
19
22
  _Object$defineProperty(exports, "default", {
20
23
  enumerable: true,
@@ -23,6 +26,20 @@ _Object$defineProperty(exports, "default", {
23
26
  }
24
27
  });
25
28
 
29
+ _Object$defineProperty(exports, "messagesReducerStory", {
30
+ enumerable: true,
31
+ get: function get() {
32
+ return _Messages2.messagesReducer;
33
+ }
34
+ });
35
+
36
+ _Object$defineProperty(exports, "multiMessagesReducerStory", {
37
+ enumerable: true,
38
+ get: function get() {
39
+ return _Messages2.multiMessagesReducer;
40
+ }
41
+ });
42
+
26
43
  var _Messages = _interopRequireDefault(require("./Messages"));
27
44
 
28
45
  var _utils = require("./utils");
@@ -37,4 +54,6 @@ _forEachInstanceProperty(_context = _Object$keys(_utils)).call(_context, functio
37
54
  return _utils[key];
38
55
  }
39
56
  });
40
- });
57
+ });
58
+
59
+ var _Messages2 = require("./Messages.reducer");
@@ -320,7 +320,9 @@ var MultivaluesField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
320
320
  height: '100%',
321
321
  m: 5,
322
322
  mr: 10,
323
- py: 2
323
+ ml: 0,
324
+ py: 3,
325
+ pr: 0
324
326
  },
325
327
  textProps: {
326
328
  sx: {
@@ -10,7 +10,7 @@ _Object$defineProperty(exports, "__esModule", {
10
10
  value: true
11
11
  });
12
12
 
13
- exports.MaxLength = exports.WithoutStatusIndicator = exports.WithHelpHint = exports.Warning = exports.Success = exports.Error = exports.DynamicRequired = exports.Required = exports.ReadOnly = exports.Disabled = exports.Password = exports.Controlled = exports.LeftLabel = exports.FloatLabel = exports.SmallVariant = exports.Default = exports["default"] = void 0;
13
+ exports.WithSlots = exports.MaxLength = exports.WithoutStatusIndicator = exports.WithHelpHint = exports.Warning = exports.Success = exports.Error = exports.DynamicRequired = exports.Required = exports.ReadOnly = exports.Disabled = exports.Password = exports.Controlled = exports.LeftLabel = exports.FloatLabel = exports.SmallVariant = exports.Default = exports["default"] = void 0;
14
14
 
15
15
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
16
16
 
@@ -32,6 +32,10 @@ var _statuses = _interopRequireDefault(require("../../utils/devUtils/constants/s
32
32
 
33
33
  var _Box = _interopRequireDefault(require("../Box"));
34
34
 
35
+ var _useCopyToClipboard = _interopRequireDefault(require("../../hooks/useCopyToClipboard"));
36
+
37
+ var _CopyButton = _interopRequireDefault(require("../CopyText/CopyButton"));
38
+
35
39
  var _react2 = require("@emotion/react");
36
40
 
37
41
  var _default = {
@@ -259,4 +263,77 @@ var MaxLength = function MaxLength() {
259
263
  });
260
264
  };
261
265
 
262
- exports.MaxLength = MaxLength;
266
+ exports.MaxLength = MaxLength;
267
+
268
+ var WithSlots = function WithSlots() {
269
+ var _useState5 = (0, _react.useState)("[{ 'type': 'work', 'streetAddress': 'San Antonio MI 47096' },{ 'type': 'home', 'streetAddress': 'Santa Rosa MN 98804' }]"),
270
+ _useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
271
+ addressesValue = _useState6[0],
272
+ setAddressesValue = _useState6[1];
273
+
274
+ var _useState7 = (0, _react.useState)("[{ 'status': 'inactive', 'subject': 'example@pingidentity.com' },{ 'status': 'active', 'subject': 'john@pingidentity.com' }]"),
275
+ _useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
276
+ jsonValue = _useState8[0],
277
+ setJsonValue = _useState8[1];
278
+
279
+ var copyAddressesToClipboard = (0, _useCopyToClipboard["default"])(addressesValue);
280
+ var copyJsonToClipboard = (0, _useCopyToClipboard["default"])(jsonValue);
281
+ var buttonSx = {
282
+ position: 'absolute',
283
+ right: 0,
284
+ top: '5px'
285
+ };
286
+ var containerSx = {
287
+ sx: {
288
+ '& input': {
289
+ paddingRight: '40px'
290
+ }
291
+ }
292
+ };
293
+ return (0, _react2.jsx)(_react["default"].Fragment, null, (0, _react2.jsx)(_["default"], {
294
+ label: "Multiple Addresses",
295
+ labelMode: "float",
296
+ onChange: function onChange(e) {
297
+ return setAddressesValue(e.target.value);
298
+ },
299
+ value: addressesValue,
300
+ containerProps: containerSx,
301
+ slots: {
302
+ inContainer: (0, _react2.jsx)(_CopyButton["default"], {
303
+ onPress: copyAddressesToClipboard,
304
+ sx: buttonSx,
305
+ iconProps: {
306
+ sx: {
307
+ path: {
308
+ fill: 'active'
309
+ }
310
+ }
311
+ }
312
+ })
313
+ },
314
+ mb: 30
315
+ }), (0, _react2.jsx)(_["default"], {
316
+ label: "Example JSON",
317
+ labelMode: "float",
318
+ onChange: function onChange(e) {
319
+ return setJsonValue(e.target.value);
320
+ },
321
+ value: jsonValue,
322
+ containerProps: containerSx,
323
+ slots: {
324
+ inContainer: (0, _react2.jsx)(_CopyButton["default"], {
325
+ onPress: copyJsonToClipboard,
326
+ sx: buttonSx,
327
+ iconProps: {
328
+ sx: {
329
+ path: {
330
+ fill: 'active'
331
+ }
332
+ }
333
+ }
334
+ })
335
+ }
336
+ }));
337
+ };
338
+
339
+ exports.WithSlots = WithSlots;
package/lib/cjs/index.js CHANGED
@@ -34,6 +34,7 @@ var _exportNames = {
34
34
  ComboBoxField: true,
35
35
  CopyText: true,
36
36
  ColorField: true,
37
+ EnvironmentBreadcrumb: true,
37
38
  FieldHelperText: true,
38
39
  FileInputField: true,
39
40
  HelpHint: true,
@@ -214,6 +215,13 @@ _Object$defineProperty(exports, "ColorField", {
214
215
  }
215
216
  });
216
217
 
218
+ _Object$defineProperty(exports, "EnvironmentBreadcrumb", {
219
+ enumerable: true,
220
+ get: function get() {
221
+ return _EnvironmentBreadcrumb["default"];
222
+ }
223
+ });
224
+
217
225
  _Object$defineProperty(exports, "FieldHelperText", {
218
226
  enumerable: true,
219
227
  get: function get() {
@@ -817,6 +825,8 @@ var _CopyText = _interopRequireDefault(require("./components/CopyText"));
817
825
 
818
826
  var _ColorField = _interopRequireDefault(require("./components/ColorField"));
819
827
 
828
+ var _EnvironmentBreadcrumb = _interopRequireDefault(require("./components/EnvironmentBreadcrumb"));
829
+
820
830
  var _FieldHelperText = _interopRequireWildcard(require("./components/FieldHelperText"));
821
831
 
822
832
  _forEachInstanceProperty(_context14 = _Object$keys(_FieldHelperText)).call(_context14, function (key) {
@@ -274,6 +274,18 @@ var datePicker = {
274
274
  }
275
275
  }
276
276
  };
277
+
278
+ var environmentChip = _objectSpread(_objectSpread({}, chip), {}, {
279
+ alignSelf: 'center',
280
+ height: '17px',
281
+ minWidth: 'fit-content',
282
+ ml: 8,
283
+ '& span': {
284
+ fontSize: 'xs',
285
+ lineHeight: 1
286
+ }
287
+ });
288
+
277
289
  var fileInputFieldWrapper = {
278
290
  display: 'flex',
279
291
  border: '1px dashed',
@@ -302,6 +314,7 @@ var _default = {
302
314
  chip: chip,
303
315
  copy: copy,
304
316
  datePicker: datePicker,
317
+ environmentChip: environmentChip,
305
318
  expandableRow: expandableRow,
306
319
  inputInContainerSlot: inputInContainerSlot,
307
320
  fileInputFieldWrapper: fileInputFieldWrapper,
@@ -376,7 +376,7 @@ var chipDeleteButton = {
376
376
  borderRadius: '50%',
377
377
  cursor: 'pointer',
378
378
  height: 14,
379
- ml: 'xs',
379
+ mx: '3px !important',
380
380
  p: 0,
381
381
  width: 14,
382
382
  '&.is-focused, &.is-hovered': {
@@ -485,6 +485,28 @@ var expandableRow = {
485
485
  }
486
486
  }
487
487
  };
488
+ var environmentBreadcrumb = {
489
+ current: _objectSpread(_objectSpread({}, text), {}, {
490
+ color: 'neutral.30',
491
+ fontSize: 'md',
492
+ fontWeight: 1,
493
+ '&.is-hovered, &.is-focused': {
494
+ color: 'active',
495
+ textDecoration: 'none',
496
+ boxShadow: 'none'
497
+ },
498
+ '&.is-pressed': {
499
+ color: 'accent.20',
500
+ textDecoration: 'none'
501
+ }
502
+ }),
503
+ selectItem: _objectSpread(_objectSpread({}, text), {}, {
504
+ color: 'neutral.10',
505
+ fontSize: 'md',
506
+ fontWeight: 0,
507
+ justifyContent: 'start'
508
+ })
509
+ };
488
510
  var fileInputField = {
489
511
  background: 'none',
490
512
  cursor: 'pointer',
@@ -551,6 +573,7 @@ var _default = {
551
573
  '&.is-pressed': _objectSpread({}, defaultActive),
552
574
  '&.is-focused': _objectSpread({}, defaultFocus)
553
575
  }),
576
+ environmentBreadcrumb: environmentBreadcrumb,
554
577
  expandableRow: expandableRow,
555
578
  fileInputField: fileInputField,
556
579
  iconButton: iconButton,
@@ -139,6 +139,14 @@ var expandableRow = {
139
139
  }
140
140
  }
141
141
  };
142
+
143
+ var environmentBreadcrumb = _objectSpread(_objectSpread({}, base), {}, {
144
+ fontSize: 'sm',
145
+ fontWeight: 3,
146
+ color: 'secondary',
147
+ textTransform: 'capitalize'
148
+ });
149
+
142
150
  var navBarSubtitle = {
143
151
  fontWeight: 3,
144
152
  fontSize: '11px',
@@ -175,6 +183,7 @@ var text = {
175
183
  textTransform: 'uppercase',
176
184
  fontFamily: 'standard'
177
185
  }),
186
+ environmentBreadcrumb: environmentBreadcrumb,
178
187
  fieldHelperText: fieldHelperText,
179
188
  inputValue: {
180
189
  fontWeight: 1,
@@ -14,7 +14,7 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (
14
14
 
15
15
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context2; _forEachInstanceProperty(_context2 = ownKeys(Object(source), true)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context3; _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
16
16
 
17
- import React, { forwardRef, useCallback, useImperativeHandle, useMemo, useRef } from 'react';
17
+ import React, { forwardRef, Fragment, useCallback, useImperativeHandle, useMemo, useRef } from 'react';
18
18
  import { useBreadcrumbItem } from '@react-aria/breadcrumbs';
19
19
  import PropTypes from 'prop-types';
20
20
  import { mergeProps } from '@react-aria/utils';
@@ -54,6 +54,9 @@ var BreadcrumbItem = /*#__PURE__*/forwardRef(function (props, ref) {
54
54
  case 'Text':
55
55
  return Text;
56
56
 
57
+ case 'Fragment':
58
+ return Fragment;
59
+
57
60
  default:
58
61
  return elementType;
59
62
  }
@@ -1,7 +1,9 @@
1
- import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
1
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
2
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
3
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
4
+ import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
3
5
  import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
4
- import React, { forwardRef, useRef, useImperativeHandle, Fragment } from 'react';
6
+ import React, { forwardRef, useRef, useImperativeHandle, Fragment, useCallback } from 'react';
5
7
  import { useBreadcrumbs } from '@react-aria/breadcrumbs';
6
8
  import PropTypes from 'prop-types';
7
9
  import { mergeProps } from '@react-aria/utils';
@@ -21,7 +23,12 @@ var Breadcrumbs = /*#__PURE__*/forwardRef(function (props, ref) {
21
23
  icon = props.icon,
22
24
  iconProps = props.iconProps,
23
25
  onAction = props.onAction,
24
- others = _objectWithoutProperties(props, ["children", "icon", "iconProps", "onAction"]);
26
+ others = _objectWithoutProperties(props, ["children", "icon", "iconProps", "onAction"]); // the following filters undefined values passed as a child
27
+
28
+
29
+ var filteredChildren = _Array$isArray(children) ? _filterInstanceProperty(children).call(children, function (child) {
30
+ return child;
31
+ }) : children;
25
32
 
26
33
  var _useBreadcrumbs = useBreadcrumbs(props),
27
34
  wrapperProps = _useBreadcrumbs.navProps;
@@ -33,26 +40,28 @@ var Breadcrumbs = /*#__PURE__*/forwardRef(function (props, ref) {
33
40
  useImperativeHandle(ref, function () {
34
41
  return breadcrumbsRef.current;
35
42
  });
36
- return ___EmotionJSX(Box, _extends({
37
- ref: breadcrumbsRef,
38
- display: "flex",
39
- flexDirection: "row",
40
- alignItems: "center",
41
- sx: {
42
- overflow: 'auto'
43
- }
44
- }, mergeProps(wrapperProps, others)), _mapInstanceProperty(children).call(children, function (child, idx) {
43
+ var createBreadcrumb = useCallback(function (child, idx) {
44
+ var isCurrentItem = _Array$isArray(filteredChildren) && filteredChildren.length > 1 ? idx === children.length - 1 : true;
45
45
  return ___EmotionJSX(Fragment, {
46
46
  key: "fragment-".concat(child.key)
47
47
  }, ___EmotionJSX(BreadcrumbItem, _extends({
48
48
  "data-id": child['data-id'],
49
- isCurrent: idx === children.length - 1,
49
+ isCurrent: isCurrentItem,
50
50
  onAction: onAction,
51
51
  actionKey: child.key
52
- }, child.props), child.props.children), icon && idx !== children.length - 1 && ___EmotionJSX(Icon, _extends({
52
+ }, child.props), child.props.children), icon && !isCurrentItem && ___EmotionJSX(Icon, _extends({
53
53
  icon: icon
54
54
  }, iconProps)));
55
- }));
55
+ }, [children.length, filteredChildren, icon, iconProps, onAction]);
56
+ return ___EmotionJSX(Box, _extends({
57
+ ref: breadcrumbsRef,
58
+ display: "flex",
59
+ flexDirection: "row",
60
+ alignItems: "center",
61
+ sx: {
62
+ overflow: 'auto'
63
+ }
64
+ }, mergeProps(wrapperProps, others)), _Array$isArray(filteredChildren) ? _mapInstanceProperty(filteredChildren).call(filteredChildren, createBreadcrumb) : createBreadcrumb(children));
56
65
  });
57
66
  Breadcrumbs.propTypes = {
58
67
  /** The icon to render in between each node. */
@@ -89,4 +89,13 @@ test('Item accepts a data-id and the data-id can be found in the DOM', function
89
89
  var item = screen.getByText(testItemsArr[0]);
90
90
  expect(item).toBeInTheDocument();
91
91
  expect(item).toHaveAttribute('data-id', testItemsArr[0]);
92
+ });
93
+ test('will render correctly with single child item', function () {
94
+ render(___EmotionJSX(Breadcrumbs, mergeProps(defaultProps), ___EmotionJSX(Item, {
95
+ key: testItemsArr[0],
96
+ "data-id": testItemsArr[0],
97
+ isCurrent: true
98
+ }, testItemsArr[0])));
99
+ expect(screen.getByTestId(testId)).toBeInTheDocument();
100
+ expect(screen.getByText(testItemsArr[0])).toBeInTheDocument();
92
101
  });
@@ -1,6 +1,8 @@
1
1
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
2
  import React, { forwardRef } from 'react';
3
3
  import ContentCopy from 'mdi-react/ContentCopyIcon';
4
+ import { omit } from 'lodash';
5
+ import PropTypes from 'prop-types';
4
6
  import Icon from '../Icon';
5
7
  import IconButton from '../IconButton';
6
8
  import { jsx as ___EmotionJSX } from "@emotion/react";
@@ -9,9 +11,12 @@ var CopyButton = /*#__PURE__*/forwardRef(function (props, ref) {
9
11
  ref: ref,
10
12
  "aria-label": "copy",
11
13
  variant: "buttons.copy"
12
- }, props), ___EmotionJSX(Icon, {
14
+ }, omit(props, 'iconProps')), ___EmotionJSX(Icon, _extends({
13
15
  icon: ContentCopy,
14
16
  size: 15
15
- }));
17
+ }, props === null || props === void 0 ? void 0 : props.iconProps)));
16
18
  });
19
+ CopyButton.propTypes = {
20
+ iconProps: PropTypes.shape({})
21
+ };
17
22
  export default CopyButton;