@pingux/astro 2.18.1-alpha.0 → 2.18.1-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,55 +6,18 @@ _Object$defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports["default"] = void 0;
9
- var _reverse = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/reverse"));
10
- var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
11
- var _splice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/splice"));
12
- var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
13
- var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
14
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
15
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
10
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
16
11
  var _react = _interopRequireDefault(require("react"));
17
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
18
- var _buttonAttributes = require("../../components/Button/buttonAttributes");
19
13
  var _index = require("../../index");
20
14
  var _react2 = require("@emotion/react");
21
- var _excluded = ["saveButtonProps", "cancelButtonProps", "refreshButtonProps", "isJustifiedRight", "children"];
22
- var SaveButton = function SaveButton(props) {
23
- return (0, _react2.jsx)(_index.Button, (0, _extends2["default"])({
24
- variant: "primary",
25
- "data-id": "save-button"
26
- }, props), props.text);
27
- };
28
- var CancelButton = function CancelButton(props) {
29
- return (0, _react2.jsx)(_index.Button, (0, _extends2["default"])({
30
- variant: "link",
31
- "data-id": "cancel-button"
32
- }, props), props.text);
33
- };
34
- var RefreshButton = function RefreshButton(props) {
35
- return (0, _react2.jsx)(_index.Button, (0, _extends2["default"])({
36
- "data-id": "refresh-button"
37
- }, props), props.text);
38
- };
15
+ var _excluded = ["align", "children"];
39
16
  var ButtonBar = function ButtonBar(props) {
40
- var _context2;
41
- var saveButtonProps = props.saveButtonProps,
42
- cancelButtonProps = props.cancelButtonProps,
43
- refreshButtonProps = props.refreshButtonProps,
44
- isJustifiedRight = props.isJustifiedRight,
17
+ var _props$align = props.align,
18
+ align = _props$align === void 0 ? 'left' : _props$align,
45
19
  children = props.children,
46
20
  others = (0, _objectWithoutProperties2["default"])(props, _excluded);
47
- var ButtonArray = [(0, _react2.jsx)(SaveButton, saveButtonProps), (0, _react2.jsx)(CancelButton, cancelButtonProps)];
48
- var Content = function Content() {
49
- var _context;
50
- var content = isJustifiedRight ? (0, _reverse["default"])(_context = (0, _slice["default"])(ButtonArray).call(ButtonArray)).call(_context) : ButtonArray;
51
- if (refreshButtonProps) {
52
- (0, _splice["default"])(content).call(content, 1, 0, (0, _react2.jsx)(RefreshButton, refreshButtonProps));
53
- }
54
- return (0, _react2.jsx)(_react["default"].Fragment, null, (0, _map["default"])(content).call(content, function (child) {
55
- return child;
56
- }));
57
- };
58
21
  return (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
59
22
  isRow: true,
60
23
  gap: "md",
@@ -62,24 +25,12 @@ var ButtonBar = function ButtonBar(props) {
62
25
  bg: 'white',
63
26
  px: 'lg',
64
27
  py: 'md',
65
- justifyContent: isJustifiedRight ? 'right' : 'left'
28
+ justifyContent: align === 'right' ? 'right' : 'left'
66
29
  }
67
- }, others), children ? (0, _concat["default"])(_context2 = []).call(_context2, children) : (0, _react2.jsx)(Content, null));
30
+ }, others), children);
68
31
  };
69
32
  ButtonBar.propTypes = {
70
- saveButtonProps: _propTypes["default"].shape(_buttonAttributes.buttonPropTypes),
71
- cancelButtonProps: _propTypes["default"].shape(_buttonAttributes.buttonPropTypes),
72
- refreshButtonProps: _propTypes["default"].shape(_buttonAttributes.buttonPropTypes),
73
- isJustifiedRight: _propTypes["default"].bool
74
- };
75
- SaveButton.propTypes = {
76
- text: _propTypes["default"].string
77
- };
78
- CancelButton.propTypes = {
79
- text: _propTypes["default"].string
80
- };
81
- RefreshButton.propTypes = {
82
- text: _propTypes["default"].string
33
+ align: _propTypes["default"].oneOf(['left', 'right'])
83
34
  };
84
35
  var _default = ButtonBar;
85
36
  exports["default"] = _default;
@@ -6,8 +6,4 @@ import { Meta } from '@storybook/addon-docs';
6
6
 
7
7
  This is a composed component that renders children in a simplified, organized and consistent manner.
8
8
 
9
- The default children are controlled by three prop objects, **saveButtonProps**, **cancelButtonProps**, and **refreshButtonProps**. The SaveButton and the CancelButton will render by default. The RefreshButton will only render if **refreshButtonProps** are supplied.
10
-
11
- The **isJustifiedRight** prop will reverse the order of the children, and justify them to the right.
12
-
13
- Supplying the ButtonBar with children using default React syntax will override the default render and render the custom children.
9
+ If the **align** prop is set to right it will justify the children to the right. Default is left justification.
@@ -5,8 +5,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
5
5
  _Object$defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports["default"] = exports.WithRefreshButton = exports.WithChildren = exports.JustifiedRight = exports.Default = void 0;
9
- var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
8
+ exports["default"] = exports.RightAligned = exports.Default = void 0;
10
9
  var _react = _interopRequireDefault(require("react"));
11
10
  var _storybookDocsLayout = _interopRequireDefault(require("../../../.storybook/storybookDocsLayout"));
12
11
  var _ = require("../..");
@@ -24,77 +23,47 @@ var _default = {
24
23
  return (0, _react2.jsx)(_react["default"].Fragment, null, (0, _react2.jsx)(_ButtonBar["default"], null), (0, _react2.jsx)(_storybookDocsLayout["default"], null));
25
24
  }
26
25
  }
26
+ },
27
+ argTypes: {
28
+ align: {
29
+ control: {
30
+ type: 'text'
31
+ }
32
+ }
27
33
  }
28
34
  };
29
35
  exports["default"] = _default;
30
36
  var Default = function Default(args) {
31
- return (0, _react2.jsx)(_.ButtonBar, (0, _extends2["default"])({
32
- saveButtonProps: {
33
- key: 'save button',
34
- text: 'Save',
35
- onPress: function onPress() {
36
- return alert('Save button pressed');
37
- }
38
- },
39
- cancelButtonProps: {
40
- key: 'cancel button',
41
- text: 'Cancel',
42
- onPress: function onPress() {
43
- return alert('Cancel button pressed');
44
- }
37
+ return (0, _react2.jsx)(_.ButtonBar, args, (0, _react2.jsx)(_.Button, {
38
+ variant: "primary",
39
+ "data-id": "save-button",
40
+ onPress: function onPress() {
41
+ return alert('Save button pressed');
45
42
  }
46
- }, args));
47
- };
48
- exports.Default = Default;
49
- var WithRefreshButton = function WithRefreshButton(args) {
50
- return (0, _react2.jsx)(_.ButtonBar, (0, _extends2["default"])({
51
- saveButtonProps: {
52
- key: 'save button',
53
- text: 'Save',
54
- onPress: function onPress() {
55
- return alert('Save button pressed');
56
- }
57
- },
58
- cancelButtonProps: {
59
- key: 'cancel button',
60
- text: 'Cancel',
61
- onPress: function onPress() {
62
- return alert('Cancel button pressed');
63
- }
64
- },
65
- refreshButtonProps: {
66
- key: 'refresh button',
67
- text: 'Refresh',
68
- onPress: function onPress() {
69
- return alert('Refresh button pressed');
70
- }
43
+ }, "Save"), (0, _react2.jsx)(_.Button, {
44
+ variant: "link",
45
+ "data-id": "cancel-button",
46
+ onPress: function onPress() {
47
+ return alert('Cancel button pressed');
71
48
  }
72
- }, args));
49
+ }, "Cancel"));
73
50
  };
74
- exports.WithRefreshButton = WithRefreshButton;
75
- var JustifiedRight = function JustifiedRight() {
51
+ exports.Default = Default;
52
+ var RightAligned = function RightAligned() {
76
53
  return (0, _react2.jsx)(_.ButtonBar, {
77
- saveButtonProps: {
78
- key: 'next button',
79
- text: 'Next',
80
- onPress: function onPress() {
81
- return alert('Save button pressed');
82
- }
83
- },
84
- cancelButtonProps: {
85
- key: 'cancel button',
86
- text: 'Cancel',
87
- onPress: function onPress() {
88
- return alert('Cancel button pressed');
89
- }
90
- },
91
- isJustifiedRight: true
92
- });
93
- };
94
- exports.JustifiedRight = JustifiedRight;
95
- var WithChildren = function WithChildren(args) {
96
- return (0, _react2.jsx)(_.ButtonBar, args, (0, _react2.jsx)(_.Button, null, "Custom Button!"), (0, _react2.jsx)(_.Button, {
97
- variant: "link"
98
- }, "Custom Link!"));
54
+ align: "right"
55
+ }, (0, _react2.jsx)(_.Button, {
56
+ variant: "primary",
57
+ "data-id": "next-button",
58
+ onPress: function onPress() {
59
+ return alert('Next button pressed');
60
+ }
61
+ }, "Next"), (0, _react2.jsx)(_.Button, {
62
+ variant: "link",
63
+ "data-id": "cancel-button",
64
+ onPress: function onPress() {
65
+ return alert('Cancel button pressed');
66
+ }
67
+ }, "Cancel"));
99
68
  };
100
- exports.WithChildren = WithChildren;
69
+ exports.RightAligned = RightAligned;
@@ -8,35 +8,24 @@ var _testAxe = _interopRequireDefault(require("../../utils/testUtils/testAxe"));
8
8
  var _testWrapper = require("../../utils/testUtils/testWrapper");
9
9
  var _react2 = require("@emotion/react");
10
10
  var testId = 'test-ButtonBar';
11
- var saveButtonProps = {
12
- key: 'save button',
13
- text: 'Save',
14
- onPress: function onPress() {
15
- return alert('Save button pressed');
16
- }
17
- };
18
- var cancelButtonProps = {
19
- key: 'cancel button',
20
- text: 'Cancel',
21
- onPress: function onPress() {
22
- return alert('Cancel button pressed');
23
- }
24
- };
25
- var refreshButtonProps = {
26
- key: 'refresh button',
27
- text: 'Refresh',
28
- onPress: function onPress() {
29
- return alert('Refresh button pressed');
30
- }
31
- };
32
11
  var defaultProps = {
33
- 'data-testid': testId,
34
- saveButtonProps: saveButtonProps,
35
- cancelButtonProps: cancelButtonProps
12
+ 'data-testid': testId
36
13
  };
37
14
  var getComponent = function getComponent() {
38
15
  var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
39
- return (0, _testWrapper.render)((0, _react2.jsx)(_.ButtonBar, (0, _extends2["default"])({}, defaultProps, props)));
16
+ return (0, _testWrapper.render)((0, _react2.jsx)(_.ButtonBar, (0, _extends2["default"])({}, defaultProps, props), (0, _react2.jsx)(_.Button, {
17
+ variant: "primary",
18
+ "data-id": "save-button",
19
+ onPress: function onPress() {
20
+ return alert('Save button pressed');
21
+ }
22
+ }, "Save"), (0, _react2.jsx)(_.Button, {
23
+ variant: "link",
24
+ "data-id": "cancel-button",
25
+ onPress: function onPress() {
26
+ return alert('Cancel button pressed');
27
+ }
28
+ }, "Cancel")));
40
29
  };
41
30
  var getComponentCustomChildren = function getComponentCustomChildren() {
42
31
  var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -55,22 +44,11 @@ test('ButtonBar does render', function () {
55
44
  var element = _testWrapper.screen.getByTestId(testId);
56
45
  expect(element).toBeInTheDocument();
57
46
  });
58
- test('renders save and cancel buttons', function () {
47
+ test('renders child save and cancel buttons', function () {
59
48
  getComponent();
60
- var saveButton = _testWrapper.screen.getByText(saveButtonProps.text);
49
+ var saveButton = _testWrapper.screen.getByText('Save');
61
50
  expect(saveButton).toBeInTheDocument();
62
- var cancelButton = _testWrapper.screen.getByText(cancelButtonProps.text);
63
- expect(cancelButton).toBeInTheDocument();
64
- });
65
- test('renders all three buttons', function () {
66
- getComponent({
67
- refreshButtonProps: refreshButtonProps
68
- });
69
- var saveButton = _testWrapper.screen.getByText(saveButtonProps.text);
70
- expect(saveButton).toBeInTheDocument();
71
- var refreshButton = _testWrapper.screen.getByText(refreshButtonProps.text);
72
- expect(refreshButton).toBeInTheDocument();
73
- var cancelButton = _testWrapper.screen.getByText(cancelButtonProps.text);
51
+ var cancelButton = _testWrapper.screen.getByText('Cancel');
74
52
  expect(cancelButton).toBeInTheDocument();
75
53
  });
76
54
  test('renders custom children', function () {
@@ -85,10 +63,29 @@ test('renders custom text', function () {
85
63
  var firstText = _testWrapper.screen.getByText('custom text');
86
64
  expect(firstText).toBeInTheDocument();
87
65
  });
88
- test('isJustifiedRight reverses order of button', function () {
66
+ test('justify-content right when align prop set to right', function () {
89
67
  getComponent({
90
- isJustifiedRight: true
68
+ align: 'right'
91
69
  });
92
- var buttons = _testWrapper.screen.getAllByRole('button');
93
- expect(buttons[0]).toHaveAttribute('data-id', 'cancel-button');
70
+ var element = _testWrapper.screen.getByTestId(testId);
71
+ expect(element).toHaveStyleRule('justify-content', 'right');
72
+ });
73
+ test('justify-content left when align prop is set to left', function () {
74
+ getComponent({
75
+ align: 'left'
76
+ });
77
+ var element = _testWrapper.screen.getByTestId(testId);
78
+ expect(element).toHaveStyleRule('justify-content', 'left');
79
+ });
80
+ test('justify-content left when align prop is excluded', function () {
81
+ getComponent();
82
+ var element = _testWrapper.screen.getByTestId(testId);
83
+ expect(element).toHaveStyleRule('justify-content', 'left');
84
+ });
85
+ test('an error is thrown when align has invalid prop value', function () {
86
+ expect(function () {
87
+ return getComponent({
88
+ align: 'rihgt'
89
+ });
90
+ }).toThrow('Failed prop type');
94
91
  });