@pingux/astro 2.7.1 → 2.8.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,41 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
5
+ _Object$defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.stringOrStringArray = exports.funcArg = exports.docArgTypes = exports.booleanArg = void 0;
9
+ var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
10
+ var _context;
11
+ var docArgTypes = {
12
+ bool: 'boolean',
13
+ node: 'node',
14
+ string: 'string',
15
+ stringArray: 'string[]',
16
+ text: 'text',
17
+ func: 'func',
18
+ object: 'object'
19
+ };
20
+ exports.docArgTypes = docArgTypes;
21
+ var stringOrStringArray = (0, _concat["default"])(_context = "".concat(docArgTypes.string, " | ")).call(_context, docArgTypes.stringArray);
22
+ exports.stringOrStringArray = stringOrStringArray;
23
+ var booleanArg = {
24
+ control: {
25
+ type: docArgTypes.bool
26
+ },
27
+ defaultValue: false,
28
+ type: {
29
+ summary: docArgTypes.bool
30
+ }
31
+ };
32
+ exports.booleanArg = booleanArg;
33
+ var funcArg = {
34
+ control: {
35
+ type: null
36
+ },
37
+ type: {
38
+ summary: docArgTypes.func
39
+ }
40
+ };
41
+ exports.funcArg = funcArg;
@@ -15,10 +15,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
15
15
  import React, { forwardRef, useImperativeHandle, useRef } from 'react';
16
16
  import { mergeProps, useButton, useFocusRing } from 'react-aria';
17
17
  import { Pressable, useHover, usePress } from '@react-aria/interactions';
18
- import PropTypes from 'prop-types';
19
18
  import { Button as ThemeUIButton } from 'theme-ui';
20
19
  import { useAriaLabelWarning, usePropWarning, useStatusClasses } from '../../hooks';
21
20
  import Loader from '../Loader';
21
+ import { buttonPropTypes } from './buttonAttributes';
22
22
  import { jsx as ___EmotionJSX } from "@emotion/react";
23
23
  var Button = /*#__PURE__*/forwardRef(function (props, ref) {
24
24
  var className = props.className,
@@ -90,60 +90,7 @@ var Button = /*#__PURE__*/forwardRef(function (props, ref) {
90
90
  }
91
91
  })));
92
92
  });
93
- Button.propTypes = {
94
- /** Defines a string value that labels the current element. */
95
- 'aria-label': PropTypes.string,
96
- /** Whether the button is disabled. */
97
- isDisabled: PropTypes.bool,
98
- /** Shows loader instead of children */
99
- isLoading: PropTypes.bool,
100
- /**
101
- * Handler that is called when a hover interaction starts.
102
- * (e: HoverEvent) => void
103
- */
104
- onHoverStart: PropTypes.func,
105
- /**
106
- * Handler that is called when a hover interaction ends.
107
- * (e: HoverEvent) => void
108
- */
109
- onHoverEnd: PropTypes.func,
110
- /**
111
- * Handler that is called when the hover state changes.
112
- * (isHovering: boolean) => void
113
- */
114
- onHoverChange: PropTypes.func,
115
- /**
116
- * Handler that is called when the press is released over the target.
117
- * (e: PressEvent) => void
118
- */
119
- onPress: PropTypes.func,
120
- /**
121
- * Handler that is called when a press interaction starts.
122
- * (e: PressEvent) => void
123
- */
124
- onPressStart: PropTypes.func,
125
- /**
126
- * Handler that is called when a press interaction ends, either over the target or when the
127
- * pointer leaves the target.
128
- * (e: PressEvent) => void
129
- */
130
- onPressEnd: PropTypes.func,
131
- /**
132
- * Handler that is called when the press state changes.
133
- * (isPressed: boolean) => void
134
- */
135
- onPressChange: PropTypes.func,
136
- /**
137
- * Handler that is called when a press is released over the target, regardless of whether it
138
- * started on the target or not.
139
- * (e: PressEvent) => void
140
- */
141
- onPressUp: PropTypes.func,
142
- /** The styling variation of the button. */
143
- variant: PropTypes.string,
144
- /** The focus variation of the button. */
145
- tabIndex: PropTypes.number
146
- };
93
+ Button.propTypes = buttonPropTypes;
147
94
  Button.defaultProps = {
148
95
  isDisabled: false,
149
96
  variant: 'default'
@@ -1,6 +1,17 @@
1
+ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
2
+ import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
3
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
4
+ import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
5
+ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
6
+ import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
7
+ import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
8
+ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
1
9
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
10
  import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
11
+ import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
3
12
  var _excluded = ["isConfigured"];
13
+ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
14
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
4
15
  import React from 'react';
5
16
  import AddCircleIcon from '@pingux/mdi-react/AddCircleIcon';
6
17
  import CreateIcon from '@pingux/mdi-react/CreateIcon';
@@ -9,43 +20,14 @@ import { withDesign } from 'storybook-addon-designs';
9
20
  import DocsLayout from '../../../.storybook/storybookDocsLayout';
10
21
  import { Box, Button, Icon, SearchField, Text } from '../../index';
11
22
  import { FIGMA_LINKS } from '../../utils/designUtils/figmaLinks.js';
12
- import { buttonVariants } from '../../utils/devUtils/constants/variants';
13
23
  import ButtonReadme from './Button.mdx';
14
-
15
- // removing the iconButton variants from this story.
24
+ import { buttonArgTypes } from './buttonAttributes';
16
25
  import { jsx as ___EmotionJSX } from "@emotion/react";
17
- var variants = buttonVariants;
18
- delete variants.ICON;
19
- delete variants.ICON_BUTTON;
20
- delete variants.INVERTED;
21
-
22
- // add designer approved variants for devs to use here
23
- var variantOptions = ['critical', 'default', 'inline', 'inlinePrimary', 'link', 'primary'];
24
26
  export default {
25
27
  title: 'Components/Button',
26
28
  component: Button,
27
29
  decorators: [withDesign],
28
- argTypes: {
29
- variant: {
30
- control: {
31
- type: 'select',
32
- options: variantOptions
33
- },
34
- defaultValue: 'default'
35
- },
36
- children: {
37
- description: 'Button text.',
38
- defaultValue: 'Button Text',
39
- table: {
40
- type: {
41
- summary: 'string'
42
- }
43
- },
44
- control: {
45
- type: 'text'
46
- }
47
- }
48
- },
30
+ argTypes: _objectSpread({}, buttonArgTypes),
49
31
  parameters: {
50
32
  docs: {
51
33
  source: {
@@ -0,0 +1,101 @@
1
+ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
2
+ import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
3
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
4
+ import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
5
+ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
6
+ import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
7
+ import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
8
+ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
9
+ import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
10
+ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
11
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
12
+ import PropTypes from 'prop-types';
13
+ import { descriptions as ariaDescriptions } from '../../utils/docUtils/ariaAttributes';
14
+ import { booleanArg, funcArg } from '../../utils/docUtils/docArgTypes';
15
+ import { onHoverArgTypes } from '../../utils/docUtils/hoverProps';
16
+
17
+ // add designer approved variants for devs to use here
18
+ var variantOptions = ['critical', 'default', 'inline', 'inlinePrimary', 'link', 'primary'];
19
+ var descriptions = {
20
+ isDisabled: 'Whether the button is disabled.',
21
+ isLoading: 'Shows loader instead of children',
22
+ onHoverStart: 'Handler that is called when a hover interaction starts. (e: HoverEvent) => void',
23
+ onHoverEnd: 'Handler that is called when the hover state changes. (isHovering: boolean) => void',
24
+ onHoverChange: 'Handler that is called when the press is released over the target. (e: PressEvent) => void',
25
+ onPress: 'Handler that is called when the press is released over the target. (e: PressEvent) => void',
26
+ onPressChange: 'Handler that is called when the press state changes. (isPressed: boolean) => void',
27
+ onPressEnd: 'Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target. (e: PressEvent) => void',
28
+ onPressStart: 'Handler that is called when a press interaction starts. (e: PressEvent) => void',
29
+ onPressUp: 'Handler that is called when a press is released over the target, regardless of whether it started on the target or not. (e: PressEvent) => void',
30
+ variant: 'The styling variation of the button.',
31
+ tabIndex: 'The focus variation of button',
32
+ children: 'Button text.'
33
+ };
34
+ export var buttonArgTypes = _objectSpread(_objectSpread({
35
+ variant: {
36
+ control: {
37
+ type: 'select',
38
+ options: variantOptions
39
+ },
40
+ defaultValue: 'default',
41
+ description: descriptions.variant
42
+ },
43
+ children: {
44
+ defaultValue: 'Button Text',
45
+ table: {
46
+ type: {
47
+ summary: 'string'
48
+ }
49
+ },
50
+ control: {
51
+ type: 'text'
52
+ },
53
+ description: descriptions.children
54
+ },
55
+ onPress: _objectSpread({
56
+ description: descriptions.onPress
57
+ }, funcArg),
58
+ onPressStart: _objectSpread({
59
+ description: descriptions.onPressStart
60
+ }, funcArg),
61
+ onPressEnd: _objectSpread({
62
+ description: descriptions.onPressEnd
63
+ }, funcArg),
64
+ onPressChange: _objectSpread({
65
+ description: descriptions.onPressChange
66
+ }, funcArg),
67
+ onPressUp: _objectSpread({
68
+ description: descriptions.onPressUp
69
+ }, funcArg)
70
+ }, onHoverArgTypes), {}, {
71
+ isLoading: _objectSpread(_objectSpread({}, booleanArg), {}, {
72
+ description: descriptions.isLoading
73
+ }),
74
+ isDisabled: _objectSpread(_objectSpread({}, booleanArg), {}, {
75
+ description: descriptions.isDisabled
76
+ }),
77
+ tabIndex: {
78
+ description: descriptions.tabIndex
79
+ },
80
+ 'aria-label': {
81
+ control: {
82
+ type: 'text'
83
+ },
84
+ description: ariaDescriptions.ariaLabel
85
+ }
86
+ });
87
+ export var buttonPropTypes = {
88
+ 'aria-label': PropTypes.string,
89
+ isDisabled: PropTypes.bool,
90
+ isLoading: PropTypes.bool,
91
+ onHoverStart: PropTypes.func,
92
+ onHoverEnd: PropTypes.func,
93
+ onHoverChange: PropTypes.func,
94
+ onPress: PropTypes.func,
95
+ onPressStart: PropTypes.func,
96
+ onPressEnd: PropTypes.func,
97
+ onPressChange: PropTypes.func,
98
+ onPressUp: PropTypes.func,
99
+ variant: PropTypes.string,
100
+ tabIndex: PropTypes.number
101
+ };
@@ -124,7 +124,7 @@ test('should be able to select dates', function () {
124
124
  userEvent.click(dateButtons[4]);
125
125
  expect(dateButtons[4]).toHaveClass('is-selected');
126
126
  });
127
- test('should be able to navigate and select shown previous month dates', function () {
127
+ test('should be able to navigate to previous month dates without selection', function () {
128
128
  var _context3;
129
129
  getComponent({
130
130
  defaultValue: '2022-08-10'
@@ -135,10 +135,10 @@ test('should be able to navigate and select shown previous month dates', functio
135
135
  var previousDate = disabledGridCells[0];
136
136
  expect(within(previousDate).getByText(31)).toHaveAttribute('aria-label', 'Sunday, July 31, 2022');
137
137
  userEvent.click(previousDate);
138
- var selectedDate = screen.queryByText(31);
139
- expect(selectedDate).toHaveAttribute('aria-label', 'Sunday, July 31, 2022 selected');
138
+ var selectedMonth = screen.queryByRole('grid');
139
+ expect(selectedMonth).toHaveAttribute('aria-label', 'July 2022');
140
140
  });
141
- test('should be able to navigate and select shown next month dates', function () {
141
+ test('should be able to navigate to next month dates without selection', function () {
142
142
  var _context4;
143
143
  getComponent({
144
144
  defaultValue: '2022-08-10'
@@ -149,8 +149,8 @@ test('should be able to navigate and select shown next month dates', function ()
149
149
  var NextDate = disabledGridCells[34];
150
150
  expect(within(NextDate).getByText(3)).toHaveAttribute('aria-label', 'Saturday, September 3, 2022');
151
151
  userEvent.click(NextDate);
152
- var selectedDate = screen.queryByText(3);
153
- expect(selectedDate).toHaveAttribute('aria-label', 'Saturday, September 3, 2022 selected');
152
+ var selectedMonth = screen.queryByRole('grid');
153
+ expect(selectedMonth).toHaveAttribute('aria-label', 'September 2022');
154
154
  });
155
155
  test('allows users to open calendar item with enter / space key', function () {
156
156
  getComponent({
@@ -37,8 +37,8 @@ var CalendarCell = /*#__PURE__*/forwardRef(function (props, ref) {
37
37
  formattedDate = _useCalendarCell.formattedDate,
38
38
  isDisabled = _useCalendarCell.isDisabled;
39
39
  var focusPreviousPage = state.focusPreviousPage,
40
- setValue = state.setValue,
41
- focusNextPage = state.focusNextPage;
40
+ focusNextPage = state.focusNextPage,
41
+ setFocused = state.setFocused;
42
42
 
43
43
  /**
44
44
  * Function handles the navigation and adds focus to previous or next month dates
@@ -48,13 +48,13 @@ var CalendarCell = /*#__PURE__*/forwardRef(function (props, ref) {
48
48
  var handleDisableClick = useCallback(function () {
49
49
  var _cellRef$current, _cellRef$current2;
50
50
  if ((_cellRef$current = cellRef.current) !== null && _cellRef$current !== void 0 && _cellRef$current.hidden && !state.isDisabled && formattedDate > 20) {
51
+ setFocused(undefined);
51
52
  focusPreviousPage();
52
- setValue(date);
53
53
  } else if ((_cellRef$current2 = cellRef.current) !== null && _cellRef$current2 !== void 0 && _cellRef$current2.hidden && !state.isDisabled && formattedDate < 15) {
54
+ setFocused(undefined);
54
55
  focusNextPage();
55
- setValue(date);
56
56
  }
57
- }, [date, focusNextPage, focusPreviousPage, formattedDate, setValue, state]);
57
+ }, [date, focusNextPage, focusPreviousPage, formattedDate, state, setFocused]);
58
58
  var _useHover = useHover({}),
59
59
  hoverProps = _useHover.hoverProps,
60
60
  isHovered = _useHover.isHovered;
@@ -103,6 +103,7 @@ CalendarCell.propTypes = {
103
103
  focusPreviousPage: PropTypes.func,
104
104
  setValue: PropTypes.func,
105
105
  focusNextPage: PropTypes.func,
106
+ setFocused: PropTypes.func,
106
107
  setFocusedDate: PropTypes.func,
107
108
  isDisabled: PropTypes.bool
108
109
  }),
@@ -0,0 +1,76 @@
1
+ import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
2
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
3
+ var _excluded = ["saveButtonProps", "cancelButtonProps", "refreshButtonProps", "isJustifiedRight", "children"];
4
+ import _reverseInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reverse";
5
+ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
6
+ import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/splice";
7
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
8
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
9
+ import React from 'react';
10
+ import PropTypes from 'prop-types';
11
+ import { buttonPropTypes } from '../../components/Button/buttonAttributes';
12
+ import { Box, Button } from '../../index';
13
+ import { jsx as ___EmotionJSX } from "@emotion/react";
14
+ var SaveButton = function SaveButton(props) {
15
+ return ___EmotionJSX(Button, _extends({
16
+ variant: "primary",
17
+ "data-id": "save-button"
18
+ }, props), props.text);
19
+ };
20
+ var CancelButton = function CancelButton(props) {
21
+ return ___EmotionJSX(Button, _extends({
22
+ variant: "link",
23
+ "data-id": "cancel-button"
24
+ }, props), props.text);
25
+ };
26
+ var RefreshButton = function RefreshButton(props) {
27
+ return ___EmotionJSX(Button, _extends({
28
+ "data-id": "refresh-button"
29
+ }, props), props.text);
30
+ };
31
+ var SaveBar = function SaveBar(props) {
32
+ var _context2;
33
+ var saveButtonProps = props.saveButtonProps,
34
+ cancelButtonProps = props.cancelButtonProps,
35
+ refreshButtonProps = props.refreshButtonProps,
36
+ isJustifiedRight = props.isJustifiedRight,
37
+ children = props.children,
38
+ others = _objectWithoutProperties(props, _excluded);
39
+ var ButtonArray = [___EmotionJSX(SaveButton, saveButtonProps), ___EmotionJSX(CancelButton, cancelButtonProps)];
40
+ var Content = function Content() {
41
+ var _context;
42
+ var content = isJustifiedRight ? _reverseInstanceProperty(_context = _sliceInstanceProperty(ButtonArray).call(ButtonArray)).call(_context) : ButtonArray;
43
+ if (refreshButtonProps) {
44
+ _spliceInstanceProperty(content).call(content, 1, 0, ___EmotionJSX(RefreshButton, refreshButtonProps));
45
+ }
46
+ return ___EmotionJSX(React.Fragment, null, _mapInstanceProperty(content).call(content, function (child) {
47
+ return child;
48
+ }));
49
+ };
50
+ return ___EmotionJSX(Box, _extends({
51
+ isRow: true,
52
+ gap: "md",
53
+ sx: {
54
+ bg: 'white',
55
+ px: 'lg',
56
+ py: 'md',
57
+ justifyContent: isJustifiedRight ? 'right' : 'left'
58
+ }
59
+ }, others), children ? _concatInstanceProperty(_context2 = []).call(_context2, children) : ___EmotionJSX(Content, null));
60
+ };
61
+ SaveBar.propTypes = {
62
+ saveButtonProps: PropTypes.shape(buttonPropTypes),
63
+ cancelButtonProps: PropTypes.shape(buttonPropTypes),
64
+ refreshButtonProps: PropTypes.shape(buttonPropTypes),
65
+ isJustifiedRight: PropTypes.bool
66
+ };
67
+ SaveButton.propTypes = {
68
+ text: PropTypes.string
69
+ };
70
+ CancelButton.propTypes = {
71
+ text: PropTypes.string
72
+ };
73
+ RefreshButton.propTypes = {
74
+ text: PropTypes.string
75
+ };
76
+ export default SaveBar;
@@ -0,0 +1,88 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
+ import React from 'react';
3
+ import DocsLayout from '../../../.storybook/storybookDocsLayout';
4
+ import { Button } from '../../index';
5
+ import SaveBar from './SaveBar';
6
+ import SaveBarReadme from './SaveBar.mdx';
7
+ import { jsx as ___EmotionJSX } from "@emotion/react";
8
+ export default {
9
+ title: 'Experimental/SaveBar',
10
+ component: SaveBar,
11
+ parameters: {
12
+ docs: {
13
+ source: {
14
+ type: 'code'
15
+ },
16
+ page: function page() {
17
+ return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(SaveBarReadme, null), ___EmotionJSX(DocsLayout, null));
18
+ }
19
+ }
20
+ }
21
+ };
22
+ export var Default = function Default(args) {
23
+ return ___EmotionJSX(SaveBar, _extends({
24
+ saveButtonProps: {
25
+ key: 'save button',
26
+ text: 'Save',
27
+ onPress: function onPress() {
28
+ return alert('Save button pressed');
29
+ }
30
+ },
31
+ cancelButtonProps: {
32
+ key: 'cancel button',
33
+ text: 'Cancel',
34
+ onPress: function onPress() {
35
+ return alert('Cancel button pressed');
36
+ }
37
+ }
38
+ }, args));
39
+ };
40
+ export var WithRefreshButton = function WithRefreshButton(args) {
41
+ return ___EmotionJSX(SaveBar, _extends({
42
+ saveButtonProps: {
43
+ key: 'save button',
44
+ text: 'Save',
45
+ onPress: function onPress() {
46
+ return alert('Save button pressed');
47
+ }
48
+ },
49
+ cancelButtonProps: {
50
+ key: 'cancel button',
51
+ text: 'Cancel',
52
+ onPress: function onPress() {
53
+ return alert('Cancel button pressed');
54
+ }
55
+ },
56
+ refreshButtonProps: {
57
+ key: 'refresh button',
58
+ text: 'Refresh',
59
+ onPress: function onPress() {
60
+ return alert('Refresh button pressed');
61
+ }
62
+ }
63
+ }, args));
64
+ };
65
+ export var JustifiedRight = function JustifiedRight() {
66
+ return ___EmotionJSX(SaveBar, {
67
+ saveButtonProps: {
68
+ key: 'next button',
69
+ text: 'Next',
70
+ onPress: function onPress() {
71
+ return alert('Save button pressed');
72
+ }
73
+ },
74
+ cancelButtonProps: {
75
+ key: 'cancel button',
76
+ text: 'Cancel',
77
+ onPress: function onPress() {
78
+ return alert('Cancel button pressed');
79
+ }
80
+ },
81
+ isJustifiedRight: true
82
+ });
83
+ };
84
+ export var WithChildren = function WithChildren(args) {
85
+ return ___EmotionJSX(SaveBar, args, ___EmotionJSX(Button, null, "Custom Button!"), ___EmotionJSX(Button, {
86
+ variant: "link"
87
+ }, "Custom Link!"));
88
+ };
@@ -0,0 +1,91 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
+ import React from 'react';
3
+ import axeTest from '../../utils/testUtils/testAxe';
4
+ import { render, screen } from '../../utils/testUtils/testWrapper';
5
+ import SaveBar from '.';
6
+ import { jsx as ___EmotionJSX } from "@emotion/react";
7
+ var testId = 'test-SaveBar';
8
+ var saveButtonProps = {
9
+ key: 'save button',
10
+ text: 'Save',
11
+ onPress: function onPress() {
12
+ return alert('Save button pressed');
13
+ }
14
+ };
15
+ var cancelButtonProps = {
16
+ key: 'cancel button',
17
+ text: 'Cancel',
18
+ onPress: function onPress() {
19
+ return alert('Cancel button pressed');
20
+ }
21
+ };
22
+ var refreshButtonProps = {
23
+ key: 'refresh button',
24
+ text: 'Refresh',
25
+ onPress: function onPress() {
26
+ return alert('Refresh button pressed');
27
+ }
28
+ };
29
+ var defaultProps = {
30
+ 'data-testid': testId,
31
+ saveButtonProps: saveButtonProps,
32
+ cancelButtonProps: cancelButtonProps
33
+ };
34
+ var getComponent = function getComponent() {
35
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
36
+ return render(___EmotionJSX(SaveBar, _extends({}, defaultProps, props)));
37
+ };
38
+ var getComponentCustomChildren = function getComponentCustomChildren() {
39
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
40
+ return render(___EmotionJSX(SaveBar, _extends({}, defaultProps, props), ___EmotionJSX("button", null, "custom text"), ___EmotionJSX("button", null, "Also custom text")));
41
+ };
42
+ var getComponentTextChildren = function getComponentTextChildren() {
43
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
44
+ return render(___EmotionJSX(SaveBar, props, "custom text"));
45
+ };
46
+ axeTest(getComponent);
47
+ afterEach(function () {
48
+ jest.resetAllMocks();
49
+ });
50
+ test('SaveBar does render', function () {
51
+ getComponent({});
52
+ var element = screen.getByTestId(testId);
53
+ expect(element).toBeInTheDocument();
54
+ });
55
+ test('renders save and cancel buttons', function () {
56
+ getComponent();
57
+ var saveButton = screen.getByText(saveButtonProps.text);
58
+ expect(saveButton).toBeInTheDocument();
59
+ var cancelButton = screen.getByText(cancelButtonProps.text);
60
+ expect(cancelButton).toBeInTheDocument();
61
+ });
62
+ test('renders all three buttons', function () {
63
+ getComponent({
64
+ refreshButtonProps: refreshButtonProps
65
+ });
66
+ var saveButton = screen.getByText(saveButtonProps.text);
67
+ expect(saveButton).toBeInTheDocument();
68
+ var refreshButton = screen.getByText(refreshButtonProps.text);
69
+ expect(refreshButton).toBeInTheDocument();
70
+ var cancelButton = screen.getByText(cancelButtonProps.text);
71
+ expect(cancelButton).toBeInTheDocument();
72
+ });
73
+ test('renders custom children', function () {
74
+ getComponentCustomChildren();
75
+ var firstButton = screen.getByText('custom text');
76
+ var secondButton = screen.getByText('Also custom text');
77
+ expect(firstButton).toBeInTheDocument();
78
+ expect(secondButton).toBeInTheDocument();
79
+ });
80
+ test('renders custom text', function () {
81
+ getComponentTextChildren();
82
+ var firstText = screen.getByText('custom text');
83
+ expect(firstText).toBeInTheDocument();
84
+ });
85
+ test('isJustifiedRight reverses order of button', function () {
86
+ getComponent({
87
+ isJustifiedRight: true
88
+ });
89
+ var buttons = screen.getAllByRole('button');
90
+ expect(buttons[0]).toHaveAttribute('data-id', 'cancel-button');
91
+ });
@@ -0,0 +1 @@
1
+ export { default } from './SaveBar';
@@ -14,7 +14,7 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (
14
14
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
15
15
  import omit from 'lodash/omit';
16
16
  import PropTypes from 'prop-types';
17
- var descriptions = {
17
+ export var descriptions = {
18
18
  ariaControls: 'Identifies the element (or elements) whose contents or presence are controlled by the current element.',
19
19
  ariaDescribedby: 'Identifies the element (or elements) that describes the object.',
20
20
  ariaDetails: 'Identifies the element (or elements) that provide a detailed, extended description for the object.',
@@ -0,0 +1,29 @@
1
+ var _context;
2
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
3
+ export var docArgTypes = {
4
+ bool: 'boolean',
5
+ node: 'node',
6
+ string: 'string',
7
+ stringArray: 'string[]',
8
+ text: 'text',
9
+ func: 'func',
10
+ object: 'object'
11
+ };
12
+ export var stringOrStringArray = _concatInstanceProperty(_context = "".concat(docArgTypes.string, " | ")).call(_context, docArgTypes.stringArray);
13
+ export var booleanArg = {
14
+ control: {
15
+ type: docArgTypes.bool
16
+ },
17
+ defaultValue: false,
18
+ type: {
19
+ summary: docArgTypes.bool
20
+ }
21
+ };
22
+ export var funcArg = {
23
+ control: {
24
+ type: null
25
+ },
26
+ type: {
27
+ summary: docArgTypes.func
28
+ }
29
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "2.7.1",
3
+ "version": "2.8.0-alpha.0",
4
4
  "description": "PingUX themeable React component library",
5
5
  "repository": {
6
6
  "type": "git",