@spothero/ui 15.0.0 → 15.1.1

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 (94) hide show
  1. package/package.json +2 -3
  2. package/styles/v2/components/FormControl/FormControl.jsx +20 -2
  3. package/styles/v2/components/Radio/Radio.jsx +50 -0
  4. package/styles/v2/components/Radio/Radio.stories.js +155 -0
  5. package/styles/v2/components/Radio/RadioGroup.jsx +69 -0
  6. package/styles/v2/components/Radio/styles/index.js +52 -0
  7. package/styles/v2/components/index.js +1 -0
  8. package/styles/v2/components/styles.js +1 -0
  9. package/v2/index.js +1 -1
  10. package/v2/index.js.map +1 -1
  11. package/styles/Alert/Alert.jsx +0 -45
  12. package/styles/Alert/Alert.spec.js +0 -85
  13. package/styles/AutoSuggestInput/AutoSuggestInput.jsx +0 -429
  14. package/styles/AutoSuggestInput/AutoSuggestInput.spec.js +0 -132
  15. package/styles/AutoSuggestInput/AutoSuggestItem.jsx +0 -61
  16. package/styles/AutoSuggestInput/AutoSuggestList.jsx +0 -85
  17. package/styles/Badge/Badge.jsx +0 -24
  18. package/styles/Badge/Badge.spec.js +0 -43
  19. package/styles/Chart/Chart.jsx +0 -185
  20. package/styles/Chart/Chart.spec.js +0 -369
  21. package/styles/Checkbox/Checkbox.jsx +0 -159
  22. package/styles/Checkbox/Checkbox.spec.js +0 -142
  23. package/styles/DateTime/DatePicker.jsx +0 -281
  24. package/styles/DateTime/DatePicker.spec.js +0 -186
  25. package/styles/DateTime/DatePickerCalendar.jsx +0 -170
  26. package/styles/DateTime/DatePickerCalendarNavigation.jsx +0 -44
  27. package/styles/DateTime/DatePickerCalendarWithRange.jsx +0 -218
  28. package/styles/DateTime/DateTimePicker.jsx +0 -266
  29. package/styles/DateTime/DateTimePicker.spec.js +0 -60
  30. package/styles/DateTime/DateTimeRangePicker.jsx +0 -629
  31. package/styles/DateTime/DateTimeRangePicker.spec.js +0 -425
  32. package/styles/DateTime/TimePicker.jsx +0 -158
  33. package/styles/DateTime/TimePicker.spec.js +0 -148
  34. package/styles/DateTime/date-time-assertions.js +0 -89
  35. package/styles/DateTime/index.js +0 -6
  36. package/styles/ErrorBoundary/ErrorBoundary.jsx +0 -76
  37. package/styles/ErrorBoundary/ErrorBoundary.spec.js +0 -72
  38. package/styles/Flyout/Flyout.jsx +0 -147
  39. package/styles/Flyout/Flyout.spec.js +0 -117
  40. package/styles/Form/Form.jsx +0 -151
  41. package/styles/Form/Form.spec.js +0 -148
  42. package/styles/Form/FormElementError.jsx +0 -18
  43. package/styles/Form/FormGroup.jsx +0 -32
  44. package/styles/Form/FormGroupError.jsx +0 -24
  45. package/styles/Form/index.js +0 -4
  46. package/styles/GooglePlacesSearchInput/GooglePlacesSearchInput.jsx +0 -215
  47. package/styles/GooglePlacesSearchInput/GooglePlacesSearchInput.spec.js +0 -213
  48. package/styles/GooglePlacesSearchInput/PoweredByGoogle.jsx +0 -43
  49. package/styles/GooglePlacesSearchInput/index.js +0 -2
  50. package/styles/HorizontalRule/HorizontalRule.jsx +0 -36
  51. package/styles/HorizontalRule/HorizontalRule.spec.js +0 -94
  52. package/styles/Label/Label.jsx +0 -22
  53. package/styles/Label/Label.spec.js +0 -11
  54. package/styles/Notification/Notification.jsx +0 -117
  55. package/styles/Notification/Notification.spec.js +0 -154
  56. package/styles/Notification/NotificationContainer.jsx +0 -90
  57. package/styles/Notification/NotificationPropTypes.js +0 -20
  58. package/styles/Notification/index.js +0 -2
  59. package/styles/PasswordControl/PasswordControl.jsx +0 -197
  60. package/styles/PasswordControl/PasswordControl.spec.js +0 -236
  61. package/styles/Portal/Portal.jsx +0 -65
  62. package/styles/Portal/Portal.spec.js +0 -45
  63. package/styles/PulseLoader/PulseLoader.jsx +0 -71
  64. package/styles/PulseLoader/PulseLoader.spec.js +0 -63
  65. package/styles/Radio/Radio.jsx +0 -114
  66. package/styles/Radio/Radio.spec.js +0 -128
  67. package/styles/Radio/RadioGroup.jsx +0 -105
  68. package/styles/RenderInBody/RenderInBody.jsx +0 -56
  69. package/styles/RenderInBody/RenderInBody.spec.js +0 -24
  70. package/styles/Select/Select.jsx +0 -251
  71. package/styles/Select/Select.spec.js +0 -254
  72. package/styles/Select/SelectItemPropTypes.js +0 -19
  73. package/styles/Select/index.js +0 -2
  74. package/styles/SelectControlled/SelectControlled.jsx +0 -250
  75. package/styles/SelectControlled/SelectControlled.spec.js +0 -290
  76. package/styles/SelectControlled/index.js +0 -1
  77. package/styles/Sprite/Sprite.jsx +0 -16
  78. package/styles/Sprite/Sprite.spec.js +0 -11
  79. package/styles/Tabs/Tab.jsx +0 -38
  80. package/styles/Tabs/TabContent.jsx +0 -46
  81. package/styles/Tabs/TabNavigation.jsx +0 -64
  82. package/styles/Tabs/TabPanel.jsx +0 -30
  83. package/styles/Tabs/Tabs.jsx +0 -87
  84. package/styles/Tabs/Tabs.spec.js +0 -201
  85. package/styles/Tabs/index.js +0 -5
  86. package/styles/TextArea/TextArea.jsx +0 -137
  87. package/styles/TextArea/TextArea.spec.js +0 -111
  88. package/styles/TextInput/TextInput.jsx +0 -159
  89. package/styles/TextInput/TextInput.spec.js +0 -263
  90. package/styles/TextInput/TextInputPropTypes.js +0 -88
  91. package/styles/TextInput/index.js +0 -2
  92. package/styles/Tooltip/Tooltip.jsx +0 -230
  93. package/styles/Tooltip/Tooltip.spec.js +0 -170
  94. /package/styles/{Radio → v2/components/Radio}/index.js +0 -0
@@ -1,154 +0,0 @@
1
- import includes from 'lodash/includes';
2
-
3
- const animationTimeout = 400;
4
-
5
- describe('<Notification />', () => {
6
- context('Display', () => {
7
- context('Default', () => {
8
- const msg = 'This is a notification.';
9
-
10
- it('Renders correctly', () => {
11
- cy.visitStory('v1/Notification/Display', 'Default', {
12
- onBeforeLoad: contentWindow => {
13
- contentWindow.onNotificationHidden = evt => {
14
- // eslint-disable-next-line no-console
15
- console.log('notification hidden');
16
- };
17
-
18
- cy.stub(contentWindow, 'onNotificationHidden').as(
19
- 'onNotificationHidden'
20
- );
21
- },
22
- })
23
- .get('.Button')
24
- .click()
25
- .wait(animationTimeout)
26
- .get('.Notification')
27
- .should('have.class', 'Notification-showing')
28
- .should('have.class', 'Notification-custom')
29
- .get('.Notification-content')
30
- .contains(msg)
31
- .get('@onNotificationHidden')
32
- .should('be.calledWithMatch', value => {
33
- return includes(value, msg);
34
- });
35
- });
36
- });
37
-
38
- context('No Close Button', () => {
39
- it('Does not render a close button', () => {
40
- cy.visitStory('v1/Notification/Display', 'NoClose')
41
- .get('.Button')
42
- .click()
43
- .wait(animationTimeout)
44
- .get('.Notification-hide')
45
- .should('not.exist');
46
- });
47
- });
48
-
49
- context('Auto-Close Disabled', () => {
50
- it('Does not auto close', () => {
51
- cy.visitStory('v1/Notification/Display', 'NoAutoClose')
52
- .get('.Button')
53
- .click()
54
- .wait(1500)
55
- .get('.Notification')
56
- .should('exist')
57
- .get('.Notification-hide')
58
- .click()
59
- .wait(animationTimeout)
60
- .get('.Notification')
61
- .should('not.exist');
62
- });
63
- });
64
-
65
- context('Show Duration', () => {
66
- it('Closes after the specified duration', () => {
67
- cy.visitStory('v1/Notification/Display', 'Duration')
68
- .get('.Button')
69
- .click()
70
- .wait(500)
71
- .get('.NotificationContainer')
72
- .children()
73
- .should('not.exist');
74
- });
75
- });
76
-
77
- context('Queue', () => {
78
- it('Shows all notifications in the queue properly', () => {
79
- cy.visitStory('v1/Notification/Display', 'Queue', {
80
- onBeforeLoad: contentWindow => {
81
- contentWindow.onQueueEmpty = evt => {
82
- // eslint-disable-next-line no-console
83
- console.log('notification queue empty');
84
- };
85
-
86
- cy.stub(contentWindow, 'onQueueEmpty').as(
87
- 'onQueueEmpty'
88
- );
89
- },
90
- })
91
- .get('.Button-primary')
92
- .click()
93
- .get('.Button-primary')
94
- .click()
95
- .get('.Button-primary')
96
- .click()
97
- .get('.Button-primary')
98
- .click()
99
- .get('.Notification-info')
100
- .get('.Notification-success')
101
- .get('.Notification-error')
102
- .get('.Notification-warning')
103
- .get('@onQueueEmpty')
104
- .should('be.called');
105
- });
106
- });
107
- });
108
-
109
- context('Types', () => {
110
- context('Info', () => {
111
- it('Has the proper info type applied', () => {
112
- cy.visitStory('v1/Notification/Types', 'Info')
113
- .get('.Button')
114
- .click()
115
- .wait(animationTimeout)
116
- .get('.Notification-info')
117
- .should('have.class', 'Notification-showing');
118
- });
119
- });
120
-
121
- context('Success', () => {
122
- it('Has the proper success type applied', () => {
123
- cy.visitStory('v1/Notification/Types', 'Success')
124
- .get('.Button')
125
- .click()
126
- .wait(animationTimeout)
127
- .get('.Notification-success')
128
- .should('have.class', 'Notification-showing');
129
- });
130
- });
131
-
132
- context('Error', () => {
133
- it('Has the proper error type applied', () => {
134
- cy.visitStory('v1/Notification/Types', 'Error')
135
- .get('.Button')
136
- .click()
137
- .wait(animationTimeout)
138
- .get('.Notification-error')
139
- .should('have.class', 'Notification-showing');
140
- });
141
- });
142
-
143
- context('Warning', () => {
144
- it('Has the proper warning type applied', () => {
145
- cy.visitStory('v1/Notification/Types', 'Warning')
146
- .get('.Button')
147
- .click()
148
- .wait(animationTimeout)
149
- .get('.Notification-warning')
150
- .should('have.class', 'Notification-showing');
151
- });
152
- });
153
- });
154
- });
@@ -1,90 +0,0 @@
1
- import find from 'lodash/find';
2
- import React, {Component} from 'react';
3
- import PropTypes from 'prop-types';
4
- import classNames from 'classnames';
5
- import Notification from './Notification';
6
- import NotificationPropTypes from './NotificationPropTypes';
7
-
8
- export default class NotificationContainer extends Component {
9
- static propTypes = {
10
- /** Additional class(es) to add to the component. */
11
- className: PropTypes.string,
12
- /** A notification to queue up for display. */
13
- notification: PropTypes.shape({...NotificationPropTypes}),
14
- /** A function to execute when the notification queue is empty. Use this to clear your local state of any associated notification data. */
15
- onQueueEmpty: PropTypes.func,
16
- };
17
- state = {
18
- currentNotification: this.props.notification,
19
- };
20
-
21
- constructor(props) {
22
- super(props);
23
-
24
- const {notification} = props;
25
-
26
- this._notificationQueue = [];
27
-
28
- if (notification) {
29
- this._notificationQueue.push(notification);
30
- }
31
- }
32
-
33
- componentDidUpdate(prevProps, prevState) {
34
- const {notification, onQueueEmpty} = this.props;
35
-
36
- this._checkQueue();
37
-
38
- if (
39
- prevState.currentNotification &&
40
- !this.state.currentNotification &&
41
- !this._notificationQueue.length &&
42
- onQueueEmpty
43
- ) {
44
- onQueueEmpty();
45
- } else if (
46
- notification &&
47
- !find(this._notificationQueue, {id: notification.id}) // eslint-disable-line react/prop-types
48
- ) {
49
- // eslint-disable-line react/prop-types
50
- this._notificationQueue.push(notification);
51
- this._checkQueue();
52
- }
53
- }
54
-
55
- _onRemove = () => {
56
- this._notificationQueue.shift();
57
-
58
- // clear the state first so that it causes a re-render and the queue can be re-checked
59
- this.setState({
60
- currentNotification: null,
61
- });
62
- };
63
-
64
- _checkQueue() {
65
- if (this.state.currentNotification || !this._notificationQueue.length) {
66
- return;
67
- }
68
-
69
- this.setState({
70
- currentNotification: this._notificationQueue[0],
71
- });
72
- }
73
-
74
- render() {
75
- const {className} = this.props;
76
- const {currentNotification} = this.state;
77
- const classes = classNames('NotificationContainer', className);
78
-
79
- return (
80
- <div className={classes}>
81
- {currentNotification && (
82
- <Notification
83
- onRemove={this._onRemove}
84
- {...currentNotification}
85
- />
86
- )}
87
- </div>
88
- );
89
- }
90
- }
@@ -1,20 +0,0 @@
1
- import PropTypes from 'prop-types';
2
-
3
- export default {
4
- /** Additional class(es) to add to the component. */
5
- className: PropTypes.string,
6
- /** A unique ID to identify the notification with. The suggested way to create this is to use <a href="https://www.npmjs.com/package/uuid#quickstart---commonjs-recommended" target="_blank">uuid</a>. */
7
- id: PropTypes.string.isRequired,
8
- /** The message body of the notification. */
9
- message: PropTypes.node.isRequired,
10
- /** Determines the characteristics of the notification. */
11
- type: PropTypes.oneOf(['info', 'success', 'error', 'warning']),
12
- /** Whether to display the close button. */
13
- showClose: PropTypes.bool,
14
- /** The time (in milliseconds) that the notification stays open for. */
15
- duration: PropTypes.number,
16
- /** Whether the notification should close itself without having to click the close button after the specified duration. */
17
- autoClose: PropTypes.bool,
18
- /** A function to execute after the notification has been hidden. Will receive the notification's props. */
19
- onHidden: PropTypes.func,
20
- };
@@ -1,2 +0,0 @@
1
- export {default as NotificationContainer} from './NotificationContainer';
2
- export {default as NotificationPropTypes} from './NotificationPropTypes';
@@ -1,197 +0,0 @@
1
- import React, {Component} from 'react';
2
- import PropTypes from 'prop-types';
3
- import classNames from 'classnames';
4
- import Checkbox from '../Checkbox/Checkbox';
5
- import FormElementError from '../Form/FormElementError';
6
- import Label from '../Label/Label';
7
- import TextButton from 'v1/components/TextButton/TextButton';
8
- import TextInput from '../TextInput/TextInput';
9
-
10
- export default class PasswordControl extends Component {
11
- static propTypes = {
12
- /** Additional class(es) to add to the component. */
13
- className: PropTypes.string,
14
- /** A unique ID which is used to identify the show password Checkbox for accessibility purposes on the client as well as the server. */
15
- showCheckboxId: PropTypes.string,
16
- /** Whether to show the Forgot Password button. */
17
- showForgotPassword: PropTypes.bool,
18
- /** A custom label (typically a Label component) to display above the input. */
19
- label: PropTypes.element,
20
- /** Text to display in the field before a user starts to type in the input. */
21
- placeholder: PropTypes.string,
22
- /** Whether to show the placeholder copy or not. */
23
- showPlaceholder: PropTypes.bool,
24
- /** Whether this field is required during validation. */
25
- required: PropTypes.bool,
26
- /** The error to show when required validation fails. */
27
- requiredError: PropTypes.string,
28
- /** A custom help element to place below the input. */
29
- helpNode: PropTypes.node,
30
- /** Specifies the minimum number of characters allowed if a minimum password length is desired. */
31
- minLength: PropTypes.number,
32
- /** Function to execute when the iForgot Password button is clicked. */
33
- onForgotPasswordClick: PropTypes.func,
34
- /**
35
- * Function to execute when the input is focused.
36
- *
37
- * @param {SyntheticEvent} evt - The React `SyntheticEvent`.
38
- */
39
- onFocus: PropTypes.func,
40
- /**
41
- * Function to execute when the element is marked as invalid by a validation check.
42
- *
43
- * @param {ValidityState} validationState - ValidityState object for more fine grained control over error handling in a parent component if desired.
44
- */
45
- onInvalid: PropTypes.func,
46
- };
47
- static defaultProps = {
48
- showCheckboxId: 'PasswordControl-show-password',
49
- showForgotPassword: true,
50
- required: true,
51
- requiredError: 'Please enter your password.',
52
- };
53
- state = {
54
- showPassword: false,
55
- isValid: true,
56
- };
57
-
58
- constructor(props) {
59
- super(props);
60
-
61
- const {requiredError, minLength} = props;
62
-
63
- this._pattern = minLength ? `.{${minLength},}` : null;
64
-
65
- if (minLength) {
66
- this._error = (
67
- <FormElementError>
68
- Please enter at least {minLength} characters.
69
- </FormElementError>
70
- );
71
- } else {
72
- this._error = <FormElementError>{requiredError}</FormElementError>;
73
- }
74
-
75
- this._generateKey();
76
- }
77
-
78
- _onPasswordFocus = () => {
79
- const {onFocus} = this.props;
80
-
81
- if (onFocus) {
82
- onFocus();
83
- }
84
- };
85
-
86
- _onPasswordChange = evt => {
87
- this.setState({
88
- value: evt.target.value,
89
- isValid: true,
90
- });
91
- };
92
-
93
- _onInvalid = validationState => {
94
- const {onInvalid} = this.props;
95
-
96
- this.setState({
97
- isValid: validationState.valid,
98
- });
99
-
100
- if (onInvalid) {
101
- onInvalid(validationState);
102
- }
103
- };
104
-
105
- _onToggleShowPasswordChange = () => {
106
- this._generateKey();
107
- this.setState((prevState, props) => {
108
- return {
109
- showPassword: !prevState.showPassword,
110
- };
111
- });
112
- };
113
-
114
- _generateKey() {
115
- this._key = `password-${Date.now()}`;
116
- }
117
-
118
- /**
119
- * Provides the form data as an object for submission.
120
- *
121
- * @public
122
- * @returns {Object} - The form data to submit.
123
- */
124
- submit() {
125
- const value = this._input.node.value;
126
-
127
- return value ? {password: value} : null;
128
- }
129
-
130
- render() {
131
- const {
132
- className,
133
- showCheckboxId,
134
- showForgotPassword,
135
- label,
136
- placeholder,
137
- showPlaceholder,
138
- helpNode,
139
- required,
140
- onForgotPasswordClick,
141
- } = this.props;
142
- const {value, showPassword, isValid} = this.state;
143
- const classes = classNames(
144
- 'PasswordControl',
145
- 'FormElement',
146
- {'FormElement-contains-error': !isValid},
147
- className
148
- );
149
-
150
- return (
151
- <div className={classes}>
152
- {label}
153
- <div className="PasswordControl-input">
154
- <TextInput
155
- key={this._key}
156
- ref={node => {
157
- this._input = node;
158
- }}
159
- name="password"
160
- type={showPassword ? 'text' : 'password'}
161
- required={required}
162
- pattern={this._pattern}
163
- defaultValue={value}
164
- placeholder={
165
- showPlaceholder && placeholder ? placeholder : ''
166
- }
167
- onChange={this._onPasswordChange}
168
- onInvalid={this._onInvalid}
169
- onFocus={this._onPasswordFocus}
170
- />
171
- <div className="PasswordControl-show">
172
- <Checkbox
173
- id={showCheckboxId}
174
- label={<Label>Show</Label>}
175
- onChange={this._onToggleShowPasswordChange}
176
- />
177
- <TextButton onClick={this._onToggleShowPasswordChange}>
178
- {showPassword ? 'Hide' : 'Show'}
179
- </TextButton>
180
- </div>
181
- </div>
182
- {helpNode && (
183
- <div className="FormElement-help-text">{helpNode}</div>
184
- )}
185
- {!isValid && this._error}
186
- {showForgotPassword && (
187
- <TextButton
188
- className="PasswordControl-forgot"
189
- onClick={onForgotPasswordClick}
190
- >
191
- Forgot Password?
192
- </TextButton>
193
- )}
194
- </div>
195
- );
196
- }
197
- }