@spothero/ui 15.1.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 (85) hide show
  1. package/package.json +2 -3
  2. package/styles/Alert/Alert.jsx +0 -45
  3. package/styles/Alert/Alert.spec.js +0 -85
  4. package/styles/AutoSuggestInput/AutoSuggestInput.jsx +0 -429
  5. package/styles/AutoSuggestInput/AutoSuggestInput.spec.js +0 -132
  6. package/styles/AutoSuggestInput/AutoSuggestItem.jsx +0 -61
  7. package/styles/AutoSuggestInput/AutoSuggestList.jsx +0 -85
  8. package/styles/Badge/Badge.jsx +0 -24
  9. package/styles/Badge/Badge.spec.js +0 -43
  10. package/styles/Chart/Chart.jsx +0 -185
  11. package/styles/Chart/Chart.spec.js +0 -369
  12. package/styles/Checkbox/Checkbox.jsx +0 -159
  13. package/styles/Checkbox/Checkbox.spec.js +0 -142
  14. package/styles/DateTime/DatePicker.jsx +0 -281
  15. package/styles/DateTime/DatePicker.spec.js +0 -186
  16. package/styles/DateTime/DatePickerCalendar.jsx +0 -170
  17. package/styles/DateTime/DatePickerCalendarNavigation.jsx +0 -44
  18. package/styles/DateTime/DatePickerCalendarWithRange.jsx +0 -218
  19. package/styles/DateTime/DateTimePicker.jsx +0 -266
  20. package/styles/DateTime/DateTimePicker.spec.js +0 -60
  21. package/styles/DateTime/DateTimeRangePicker.jsx +0 -629
  22. package/styles/DateTime/DateTimeRangePicker.spec.js +0 -425
  23. package/styles/DateTime/TimePicker.jsx +0 -158
  24. package/styles/DateTime/TimePicker.spec.js +0 -148
  25. package/styles/DateTime/date-time-assertions.js +0 -89
  26. package/styles/DateTime/index.js +0 -6
  27. package/styles/ErrorBoundary/ErrorBoundary.jsx +0 -76
  28. package/styles/ErrorBoundary/ErrorBoundary.spec.js +0 -72
  29. package/styles/Flyout/Flyout.jsx +0 -147
  30. package/styles/Flyout/Flyout.spec.js +0 -117
  31. package/styles/Form/Form.jsx +0 -151
  32. package/styles/Form/Form.spec.js +0 -148
  33. package/styles/Form/FormElementError.jsx +0 -18
  34. package/styles/Form/FormGroup.jsx +0 -32
  35. package/styles/Form/FormGroupError.jsx +0 -24
  36. package/styles/Form/index.js +0 -4
  37. package/styles/GooglePlacesSearchInput/GooglePlacesSearchInput.jsx +0 -215
  38. package/styles/GooglePlacesSearchInput/GooglePlacesSearchInput.spec.js +0 -213
  39. package/styles/GooglePlacesSearchInput/PoweredByGoogle.jsx +0 -43
  40. package/styles/GooglePlacesSearchInput/index.js +0 -2
  41. package/styles/HorizontalRule/HorizontalRule.jsx +0 -36
  42. package/styles/HorizontalRule/HorizontalRule.spec.js +0 -94
  43. package/styles/Label/Label.jsx +0 -22
  44. package/styles/Label/Label.spec.js +0 -11
  45. package/styles/Notification/Notification.jsx +0 -117
  46. package/styles/Notification/Notification.spec.js +0 -154
  47. package/styles/Notification/NotificationContainer.jsx +0 -90
  48. package/styles/Notification/NotificationPropTypes.js +0 -20
  49. package/styles/Notification/index.js +0 -2
  50. package/styles/PasswordControl/PasswordControl.jsx +0 -197
  51. package/styles/PasswordControl/PasswordControl.spec.js +0 -236
  52. package/styles/Portal/Portal.jsx +0 -65
  53. package/styles/Portal/Portal.spec.js +0 -45
  54. package/styles/PulseLoader/PulseLoader.jsx +0 -71
  55. package/styles/PulseLoader/PulseLoader.spec.js +0 -63
  56. package/styles/Radio/Radio.jsx +0 -114
  57. package/styles/Radio/Radio.spec.js +0 -128
  58. package/styles/Radio/RadioGroup.jsx +0 -105
  59. package/styles/Radio/index.js +0 -2
  60. package/styles/RenderInBody/RenderInBody.jsx +0 -56
  61. package/styles/RenderInBody/RenderInBody.spec.js +0 -24
  62. package/styles/Select/Select.jsx +0 -251
  63. package/styles/Select/Select.spec.js +0 -254
  64. package/styles/Select/SelectItemPropTypes.js +0 -19
  65. package/styles/Select/index.js +0 -2
  66. package/styles/SelectControlled/SelectControlled.jsx +0 -250
  67. package/styles/SelectControlled/SelectControlled.spec.js +0 -290
  68. package/styles/SelectControlled/index.js +0 -1
  69. package/styles/Sprite/Sprite.jsx +0 -16
  70. package/styles/Sprite/Sprite.spec.js +0 -11
  71. package/styles/Tabs/Tab.jsx +0 -38
  72. package/styles/Tabs/TabContent.jsx +0 -46
  73. package/styles/Tabs/TabNavigation.jsx +0 -64
  74. package/styles/Tabs/TabPanel.jsx +0 -30
  75. package/styles/Tabs/Tabs.jsx +0 -87
  76. package/styles/Tabs/Tabs.spec.js +0 -201
  77. package/styles/Tabs/index.js +0 -5
  78. package/styles/TextArea/TextArea.jsx +0 -137
  79. package/styles/TextArea/TextArea.spec.js +0 -111
  80. package/styles/TextInput/TextInput.jsx +0 -159
  81. package/styles/TextInput/TextInput.spec.js +0 -263
  82. package/styles/TextInput/TextInputPropTypes.js +0 -88
  83. package/styles/TextInput/index.js +0 -2
  84. package/styles/Tooltip/Tooltip.jsx +0 -230
  85. package/styles/Tooltip/Tooltip.spec.js +0 -170
@@ -1,132 +0,0 @@
1
- describe('<AutoSuggestInput />', () => {
2
- context('Display', () => {
3
- context('Usage', () => {
4
- beforeEach(() => {
5
- cy.visitStory('v1/AutoSuggestInput/Display', 'Default', {
6
- onBeforeLoad: contentWindow => {
7
- contentWindow.onSuggestSelected = suggestion => {
8
- console.log('selected suggestion:', suggestion); // eslint-disable-line no-console
9
- };
10
-
11
- contentWindow.onAutoSuggestClear = () => {
12
- console.log('cleared input'); // eslint-disable-line no-console
13
- };
14
-
15
- cy.stub(contentWindow, 'onSuggestSelected').as(
16
- 'suggestSelected'
17
- );
18
-
19
- cy.stub(contentWindow, 'onAutoSuggestClear').as(
20
- 'suggestCleared'
21
- );
22
- },
23
- })
24
- .get('.AutoSuggestInput')
25
- .as('asInput')
26
- .fillTextInput({alias: 'asInput', text: 'Ite'});
27
- });
28
-
29
- it('Shows the suggestions list', () => {
30
- cy.get('.AutoSuggestInput-suggestions').should(
31
- 'not.have.class',
32
- 'AutoSuggestInput-suggestions-hidden'
33
- );
34
- });
35
-
36
- it('Populates the input with the selected item', () => {
37
- cy.get('.AutoSuggestInput-item')
38
- .eq(2)
39
- .click()
40
- .confirmTextInput({alias: 'asInput', value: 'Item 3'});
41
- });
42
-
43
- it('Clears input when clear is clicked', () => {
44
- cy.get('.AutoSuggestInput-clear')
45
- .click()
46
- .confirmTextInput({alias: 'asInput', value: ''})
47
- .get('@suggestCleared')
48
- .should('be.called');
49
- });
50
-
51
- it('Works with keyboard selection', () => {
52
- cy.get('@asInput')
53
- .find('input')
54
- .click()
55
- .type('{downarrow}', {delay: 0})
56
- .type('{downarrow}', {delay: 0})
57
- .type('{enter}', {delay: 0})
58
- .confirmTextInput({alias: 'asInput', value: 'Item 2'});
59
- });
60
-
61
- it('Scrolls list using keyboard', () => {
62
- const typeMultiple = (value, count) =>
63
- new Array(count).fill(value).join('');
64
-
65
- cy.get('@asInput').find('input').click();
66
-
67
- cy.get('.AutoSuggestInput-item')
68
- .eq(14)
69
- .should('not.be.visible');
70
-
71
- cy.get('@asInput')
72
- .find('input')
73
- .click()
74
- .type(typeMultiple('{downarrow}', 15), {delay: 0})
75
- .should('be.visible');
76
-
77
- cy.get('.AutoSuggestInput-item').eq(0).should('not.be.visible');
78
-
79
- cy.get('@asInput')
80
- .find('input')
81
- .click()
82
- .type(typeMultiple('{uparrow}', 14), {delay: 0})
83
- .should('be.visible');
84
-
85
- cy.get('.AutoSuggestInput-item')
86
- .eq(19)
87
- .should('not.be.visible');
88
-
89
- cy.get('@asInput')
90
- .find('input')
91
- .click()
92
- .type('{uparrow}', {delay: 0});
93
-
94
- cy.get('.AutoSuggestInput-item').eq(19).should('be.visible');
95
- });
96
-
97
- it('Fires `onSuggestionSelect` properly', () => {
98
- cy.get('.AutoSuggestInput-item')
99
- .eq(2)
100
- .click()
101
- .get('@suggestSelected')
102
- .should('be.calledWith', {
103
- label: 'Item 3',
104
- id: 3,
105
- });
106
- });
107
- });
108
-
109
- context('Auto Activate', () => {
110
- it('Highlight the first item when suggestions are activated', () => {
111
- cy.visitStory('v1/AutoSuggestInput/Display', 'AutoActivate')
112
- .get('.AutoSuggestInput')
113
- .as('asInput')
114
- .fillTextInput({alias: 'asInput', text: 'Item 4'})
115
- .get('.AutoSuggestInput-item')
116
- .eq(0)
117
- .should('have.class', 'AutoSuggestInput-item-active');
118
- });
119
- });
120
-
121
- context('Custom Footer', () => {
122
- it('Has a custom footer when one is defined', () => {
123
- cy.visitStory('v1/AutoSuggestInput/Display', 'Footer')
124
- .get('.AutoSuggestInput')
125
- .as('asInput')
126
- .fillTextInput({alias: 'asInput', text: 'I'})
127
- .get('.AutoSuggestInput-custom-footer')
128
- .should('contain.text', 'This is a custom footer.');
129
- });
130
- });
131
- });
132
- });
@@ -1,61 +0,0 @@
1
- import React, {PureComponent} from 'react';
2
- import PropTypes from 'prop-types';
3
- import classnames from 'classnames';
4
-
5
- export default class AutoSuggestItem extends PureComponent {
6
- static propTypes = {
7
- /** Additional class(es) to add to the component. */
8
- className: PropTypes.string,
9
- /** Whether or not the suggestion item is active. */
10
- active: PropTypes.bool,
11
- /** The suggestion data object. */
12
- suggestion: PropTypes.shape({
13
- label: PropTypes.oneOfType([PropTypes.string, PropTypes.element])
14
- .isRequired,
15
- id: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
16
- .isRequired,
17
- }).isRequired,
18
- /** Optional function to execute when a suggestion is selected. */
19
- onSuggestionSelect: PropTypes.func,
20
- /** Optional function to execute for suggestion list item's mousedown event. */
21
- onSuggestionMouseDown: PropTypes.func,
22
- /** Optional function to execute for suggestion list item's mouseout event. */
23
- onSuggestionMouseOut: PropTypes.func,
24
- };
25
-
26
- _onClick = evt => {
27
- evt.preventDefault();
28
-
29
- const {suggestion, onSuggestionSelect} = this.props;
30
-
31
- if (onSuggestionSelect) {
32
- onSuggestionSelect(suggestion);
33
- }
34
- };
35
-
36
- render() {
37
- const {
38
- active,
39
- className,
40
- suggestion,
41
- onSuggestionMouseDown,
42
- onSuggestionMouseOut,
43
- } = this.props;
44
- const classes = classnames(
45
- 'AutoSuggestInput-item',
46
- {'AutoSuggestInput-item-active': active},
47
- className
48
- );
49
-
50
- return (
51
- <li
52
- className={classes}
53
- onClick={this._onClick}
54
- onMouseDown={onSuggestionMouseDown}
55
- onMouseOut={onSuggestionMouseOut}
56
- >
57
- {suggestion.label}
58
- </li>
59
- );
60
- }
61
- }
@@ -1,85 +0,0 @@
1
- import React, {PureComponent} from 'react';
2
- import PropTypes from 'prop-types';
3
- import classnames from 'classnames';
4
- import AutoSuggestItem from './AutoSuggestItem';
5
-
6
- class AutoSuggestList extends PureComponent {
7
- static propTypes = {
8
- /** Whether or not the suggestion list should be hidden */
9
- hidden: PropTypes.bool,
10
- /** An array of suggestion objects. */
11
- suggestions: PropTypes.arrayOf(
12
- PropTypes.shape({
13
- label: PropTypes.oneOfType([
14
- PropTypes.string,
15
- PropTypes.element,
16
- ]).isRequired,
17
- id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
18
- })
19
- ),
20
- /** The suggestion object which is currently active. */
21
- activeSuggestion: PropTypes.object,
22
- /** A custom element to display at the bottom of the suggestion list */
23
- suggestionBoxFooter: PropTypes.element.isRequired,
24
- /** Function to execute when a suggestion is selected. */
25
- onSuggestionSelect: PropTypes.func.isRequired,
26
- /** Optional function to execute for suggestion list item's mousedown event. */
27
- onSuggestionMouseDown: PropTypes.func,
28
- /** Optional function to execute for suggestion list item's mouseout event. */
29
- onSuggestionMouseOut: PropTypes.func,
30
- /** Optional ref of underlying <ul> */
31
- forwardRef: PropTypes.node,
32
- };
33
- static defaultProps = {
34
- hidden: true,
35
- suggestions: [],
36
- };
37
-
38
- _onSuggestionSelect = suggestion => {
39
- this.props.onSuggestionSelect({
40
- suggestion,
41
- });
42
- };
43
-
44
- render() {
45
- const {
46
- hidden,
47
- suggestions,
48
- activeSuggestion,
49
- suggestionBoxFooter,
50
- onSuggestionMouseDown,
51
- onSuggestionMouseOut,
52
- forwardRef,
53
- } = this.props;
54
- const classes = classnames('AutoSuggestInput-suggestions', {
55
- 'AutoSuggestInput-suggestions-hidden': hidden,
56
- });
57
-
58
- return (
59
- <ul className={classes} ref={forwardRef}>
60
- {suggestions.map(suggestion => {
61
- const {id, className} = suggestion;
62
- const active =
63
- activeSuggestion && id === activeSuggestion.id;
64
-
65
- return (
66
- <AutoSuggestItem
67
- key={id}
68
- className={className}
69
- suggestion={suggestion}
70
- active={active}
71
- onSuggestionSelect={this._onSuggestionSelect}
72
- onSuggestionMouseDown={onSuggestionMouseDown}
73
- onSuggestionMouseOut={onSuggestionMouseOut}
74
- />
75
- );
76
- })}
77
- {suggestionBoxFooter}
78
- </ul>
79
- );
80
- }
81
- }
82
-
83
- export default React.forwardRef((props, ref) => (
84
- <AutoSuggestList forwardRef={ref} {...props} />
85
- ));
@@ -1,24 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import classNames from 'classnames';
4
-
5
- const Badge = ({className, color, children}) => {
6
- const classes = classNames('Badge', `Badge-${color}`, className);
7
-
8
- return <span className={classes}>{children}</span>;
9
- };
10
-
11
- Badge.propTypes = {
12
- /** Additional class(es) to add to the component. */
13
- className: PropTypes.string,
14
- /** The node (typically a string) to put in the badge. */
15
- children: PropTypes.node.isRequired,
16
- /** The color of the badge. */
17
- color: PropTypes.oneOf(['default', 'danger', 'warning', 'success', 'info']),
18
- };
19
-
20
- Badge.defaultProps = {
21
- color: 'default',
22
- };
23
-
24
- export default Badge;
@@ -1,43 +0,0 @@
1
- describe('<Badge />', () => {
2
- context('Colors', () => {
3
- context('Default', () => {
4
- it('Has default styles', () => {
5
- cy.visitStory('v1/Badge/Colors', 'Default')
6
- .get('.Badge')
7
- .should('have.class', 'Badge-default');
8
- });
9
- });
10
-
11
- context('Danger', () => {
12
- it('Has danger styles', () => {
13
- cy.visitStory('v1/Badge/Colors', 'Danger')
14
- .get('.Badge')
15
- .should('have.class', 'Badge-danger');
16
- });
17
- });
18
-
19
- context('Info', () => {
20
- it('Has info styles', () => {
21
- cy.visitStory('v1/Badge/Colors', 'Info')
22
- .get('.Badge')
23
- .should('have.class', 'Badge-info');
24
- });
25
- });
26
-
27
- context('Success', () => {
28
- it('Has success styles', () => {
29
- cy.visitStory('v1/Badge/Colors', 'Success')
30
- .get('.Badge')
31
- .should('have.class', 'Badge-success');
32
- });
33
- });
34
-
35
- context('Warning', () => {
36
- it('Has warning styles', () => {
37
- cy.visitStory('v1/Badge/Colors', 'Warning')
38
- .get('.Badge')
39
- .should('have.class', 'Badge-warning');
40
- });
41
- });
42
- });
43
- });
@@ -1,185 +0,0 @@
1
- import forEach from 'lodash/forEach';
2
- import isEqual from 'lodash/isEqual';
3
- import React, {Component} from 'react';
4
- import PropTypes from 'prop-types';
5
- import classNames from 'classnames';
6
- import Chartist from 'chartist';
7
- import DOMUtils from '@spothero/utils/dom';
8
-
9
- export default class Chart extends Component {
10
- static propTypes = {
11
- /** Additional class(es) to add to the component. */
12
- className: PropTypes.string,
13
- /** The type of chart to draw. */
14
- type: PropTypes.oneOf(['Line', 'Bar', 'Pie', 'Donut']).isRequired,
15
- /**
16
- * The aspect ratio of the chart container.
17
- *
18
- * @see See the aspect ratio information <a href="https://gionkunz.github.io/chartist-js/getting-started.html#as-simple-as-it-can-get" target="_blank">here</a>. The value should not include the leading `ct-`.
19
- */
20
- aspectRatio: PropTypes.string,
21
- /**
22
- * The data to display on the chart.
23
- *
24
- * @see See the <a href="https://gionkunz.github.io/chartist-js/api-documentation.html" target="_blank">Chartist documentation</a> for details.
25
- */
26
- data: PropTypes.object.isRequired,
27
- /**
28
- * The options for the chart.
29
- *
30
- * @see See the <a href="https://gionkunz.github.io/chartist-js/api-documentation.html" target="_blank">Chartist documentation</a> for details.
31
- */
32
- options: PropTypes.object,
33
- /**
34
- * The responsive options to apply to chart.
35
- *
36
- * @see See the <a href="https://gionkunz.github.io/chartist-js/api-documentation.html" target="_blank">Chartist documentation</a> for details.
37
- */
38
- responsiveOptions: PropTypes.array,
39
- /** An array containing the events to listen for and their respective handler functions. */
40
- events: PropTypes.arrayOf(
41
- PropTypes.shape({
42
- event: PropTypes.oneOf([
43
- 'draw',
44
- 'optionsChanged',
45
- 'data',
46
- 'animationBegin',
47
- 'animationEnd',
48
- 'created',
49
- ]).isRequired,
50
- handler: PropTypes.func.isRequired,
51
- })
52
- ),
53
- /**
54
- * Setting this will show a legend. If passed as an object it will set configuration options on the legend.
55
- *
56
- * @see For possible options, see <a href="https://github.com/CodeYellowBV/chartist-plugin-legend" target="_blank">chartist-plugin-legend</a>.
57
- */
58
- legend: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]),
59
- /**
60
- * Setting this will show a tooltip when hovering over a point. If passed as an object it will set configuration options on the tooltip.
61
- *
62
- * @see For possible options, see <a href="https://github.com/Globegitter/chartist-plugin-tooltip" target="_blank">chartist-plugin-tooltip</a>.
63
- */
64
- tooltip: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]),
65
- };
66
- static defaultProps = {
67
- aspectRatio: 'double-octave',
68
- };
69
-
70
- constructor(props) {
71
- super(props);
72
-
73
- if (window) {
74
- const {type, options, legend, tooltip} = props;
75
- const plugins = [];
76
- const isDonut = type === 'Donut';
77
-
78
- this._chartType = isDonut ? 'Pie' : type;
79
- this._options = {...options};
80
-
81
- if (isDonut) {
82
- this._options.donut = true;
83
- }
84
-
85
- if (legend) {
86
- plugins.push(Chartist.plugins.legend(legend));
87
- }
88
-
89
- if (tooltip) {
90
- plugins.push(Chartist.plugins.tooltip(tooltip));
91
- }
92
-
93
- if (this._options.plugins) {
94
- this._options.plugins.concat(plugins);
95
- } else {
96
- this._options.plugins = plugins;
97
- }
98
-
99
- this._previousOptions = this._options;
100
- }
101
- }
102
-
103
- componentDidMount() {
104
- if (window) {
105
- const {data, responsiveOptions, events} = this.props;
106
-
107
- this._chartist = new Chartist[this._chartType](
108
- this._chart,
109
- data,
110
- this._options,
111
- responsiveOptions
112
- );
113
-
114
- if (events) {
115
- forEach(events, ({event, handler}) => {
116
- this._chartist.on(event, handler);
117
- });
118
- }
119
- }
120
- }
121
-
122
- componentDidUpdate(prevProps, prevState, snapshot) {
123
- const {data, options, responsiveOptions} = this.props;
124
-
125
- this._options = {
126
- ...this._options,
127
- ...options,
128
- };
129
-
130
- if (window && !isEqual(this._previousOptions, this._options)) {
131
- this._chartist.update(data, this._options, responsiveOptions);
132
-
133
- this._previousOptions = this._options;
134
- }
135
- }
136
-
137
- componentWillUnmount() {
138
- if (window) {
139
- const {tooltip, events} = this.props;
140
-
141
- if (tooltip && tooltip.appendToBody) {
142
- DOMUtils.remove('.chartist-tooltip');
143
- }
144
-
145
- forEach(events, ({event, handler}) => {
146
- this._chartist.off(event, handler);
147
- });
148
-
149
- this._chartist.detach();
150
- }
151
- }
152
-
153
- /**
154
- * Getter for the chartist event emitter.
155
- *
156
- * @public
157
- * @returns {Object} - The event emitter.
158
- */
159
- get eventEmitter() {
160
- return this._chartist.eventEmitter;
161
- }
162
-
163
- render() {
164
- if (!window) {
165
- return null;
166
- }
167
-
168
- const {className, aspectRatio} = this.props;
169
- const classes = classNames(
170
- 'Chart',
171
- 'ct-chart',
172
- `ct-${aspectRatio}`,
173
- className
174
- );
175
-
176
- return (
177
- <div
178
- ref={node => {
179
- this._chart = node;
180
- }}
181
- className={classes}
182
- />
183
- );
184
- }
185
- }