@spaced-out/ui-design-system 0.1.91 → 0.1.93-beta.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.
Files changed (43) hide show
  1. package/.cspell/custom-words.txt +41 -0
  2. package/CHANGELOG.md +24 -0
  3. package/lib/components/DateRangePicker/Calendar.js +75 -0
  4. package/lib/components/DateRangePicker/Calendar.js.flow +113 -0
  5. package/lib/components/DateRangePicker/Calendar.module.css +49 -0
  6. package/lib/components/DateRangePicker/DateRangePicker.js +120 -0
  7. package/lib/components/DateRangePicker/DateRangePicker.js.flow +173 -0
  8. package/lib/components/DateRangePicker/DateRangePicker.module.css +8 -0
  9. package/lib/components/DateRangePicker/DateRangeWrapper.js +175 -0
  10. package/lib/components/DateRangePicker/DateRangeWrapper.js.flow +282 -0
  11. package/lib/components/DateRangePicker/DateRangeWrapper.module.css +64 -0
  12. package/lib/components/DateRangePicker/Day.js +65 -0
  13. package/lib/components/DateRangePicker/Day.js.flow +80 -0
  14. package/lib/components/DateRangePicker/Day.module.css +91 -0
  15. package/lib/components/DateRangePicker/index.js +16 -0
  16. package/lib/components/DateRangePicker/index.js.flow +3 -0
  17. package/lib/components/DateRangePicker/timezones.js +262 -0
  18. package/lib/components/DateRangePicker/timezones.js.flow +256 -0
  19. package/lib/components/DateRangePicker/utils.js +218 -0
  20. package/lib/components/DateRangePicker/utils.js.flow +231 -0
  21. package/lib/components/Dropdown/Dropdown.js +7 -1
  22. package/lib/components/Dropdown/Dropdown.js.flow +7 -0
  23. package/lib/components/Dropdown/SimpleDropdown.js +3 -1
  24. package/lib/components/Dropdown/SimpleDropdown.js.flow +3 -0
  25. package/lib/components/Grid/Grid.js +4 -3
  26. package/lib/components/Grid/Grid.js.flow +6 -2
  27. package/lib/components/Grid/Grid.module.css +6 -0
  28. package/lib/components/SpiderChart/SpiderChart.js +1 -20
  29. package/lib/components/SpiderChart/SpiderChart.js.flow +0 -20
  30. package/lib/components/index.js +11 -0
  31. package/lib/components/index.js.flow +1 -0
  32. package/lib/types/charts.js.flow +1 -0
  33. package/lib/utils/charts/charts.js +3 -0
  34. package/lib/utils/charts/charts.js.flow +3 -0
  35. package/lib/utils/charts/columnChart.js +1 -0
  36. package/lib/utils/charts/columnChart.js.flow +1 -0
  37. package/lib/utils/charts/lineChart.js +1 -0
  38. package/lib/utils/charts/lineChart.js.flow +1 -0
  39. package/lib/utils/charts/spiderChart.js +3 -1
  40. package/lib/utils/charts/spiderChart.js.flow +4 -17
  41. package/lib/utils/charts/typography.js +2 -3
  42. package/lib/utils/charts/typography.js.flow +1 -3
  43. package/package.json +2 -1
@@ -0,0 +1,218 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.addTimeZone = exports.WEEKDAYS = exports.NAVIGATION_ACTION = exports.MONTHS = exports.MARKERS = void 0;
7
+ exports.formatIsoDate = formatIsoDate;
8
+ exports.isStartOfRange = exports.isStartDateEndDateSame = exports.isEndOfRange = exports.inDateRange = exports.getValidatedMonths = exports.getTimeZones = exports.getSubtractedDate = exports.getDaysInMonth = exports.getAvailableMonths = exports.getAddedDate = exports.generateAvailableYears = void 0;
9
+ exports.wrangleMoment = wrangleMoment;
10
+ var _formatISO = _interopRequireDefault(require("date-fns/formatISO"));
11
+ var _parseISO = _interopRequireDefault(require("date-fns/parseISO"));
12
+ var _lodash = _interopRequireDefault(require("lodash"));
13
+ var _moment = _interopRequireDefault(require("moment"));
14
+ var _timezones = require("./timezones");
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
+
17
+ // $FlowFixMe - strict types for date-fns
18
+
19
+ // $FlowFixMe - strict types for date-fns
20
+
21
+ // $FlowFixMe[untyped-import]
22
+
23
+ const NAVIGATION_ACTION = Object.freeze({
24
+ NEXT: 'next',
25
+ PREV: 'prev'
26
+ });
27
+ exports.NAVIGATION_ACTION = NAVIGATION_ACTION;
28
+ const MARKERS = Object.freeze({
29
+ DATE_RANGE_START: 'FIRST',
30
+ DATE_RANGE_END: 'SECOND'
31
+ });
32
+ exports.MARKERS = MARKERS;
33
+ const WEEKDAYS = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
34
+ exports.WEEKDAYS = WEEKDAYS;
35
+ const MONTHS = [{
36
+ key: '0',
37
+ label: 'Jan'
38
+ }, {
39
+ key: '1',
40
+ label: 'Feb'
41
+ }, {
42
+ key: '2',
43
+ label: 'Mar'
44
+ }, {
45
+ key: '3',
46
+ label: 'Apr'
47
+ }, {
48
+ key: '4',
49
+ label: 'May'
50
+ }, {
51
+ key: '5',
52
+ label: 'Jun'
53
+ }, {
54
+ key: '6',
55
+ label: 'Jul'
56
+ }, {
57
+ key: '7',
58
+ label: 'Aug'
59
+ }, {
60
+ key: '8',
61
+ label: 'Sep'
62
+ }, {
63
+ key: '9',
64
+ label: 'Oct'
65
+ }, {
66
+ key: '10',
67
+ label: 'Nov'
68
+ }, {
69
+ key: '11',
70
+ label: 'Dec'
71
+ }];
72
+ exports.MONTHS = MONTHS;
73
+ const getDaysInMonth = date => {
74
+ const startWeek = (0, _moment.default)(date).startOf('month').startOf('week');
75
+ const endWeek = (0, _moment.default)(date).endOf('month').endOf('week');
76
+ const days = [],
77
+ current = startWeek;
78
+ while (current.isBefore(endWeek)) {
79
+ days.push(current.clone().format('YYYY-MM-DD'));
80
+ current.add(1, 'd');
81
+ }
82
+ const daysInChunks = _lodash.default.chunk(days, 7);
83
+
84
+ // if total rows in calendar are 5 add one more week to the calendar
85
+ if (daysInChunks.length === 5) {
86
+ const nextWeek = getAddedDate(endWeek, WEEKDAYS.length, 'd');
87
+ const extraDays = [];
88
+ while (current.isSameOrBefore(nextWeek)) {
89
+ extraDays.push(current.clone().format('YYYY-MM-DD'));
90
+ current.add(1, 'd');
91
+ }
92
+ daysInChunks.push(extraDays);
93
+ }
94
+ return daysInChunks;
95
+ };
96
+ exports.getDaysInMonth = getDaysInMonth;
97
+ const isStartOfRange = (_ref, date) => {
98
+ let {
99
+ startDate
100
+ } = _ref;
101
+ return !!startDate && (0, _moment.default)(date).isSame(startDate, 'd');
102
+ };
103
+ exports.isStartOfRange = isStartOfRange;
104
+ const isEndOfRange = (_ref2, date) => {
105
+ let {
106
+ endDate
107
+ } = _ref2;
108
+ return !!endDate && (0, _moment.default)(date).isSame(endDate, 'd');
109
+ };
110
+ exports.isEndOfRange = isEndOfRange;
111
+ const inDateRange = (_ref3, date) => {
112
+ let {
113
+ startDate,
114
+ endDate
115
+ } = _ref3;
116
+ if (startDate && endDate) {
117
+ const momentDay = (0, _moment.default)(date);
118
+ const momentStartDate = (0, _moment.default)(startDate);
119
+ const momentEndDate = (0, _moment.default)(endDate);
120
+ return momentDay.isBetween(momentStartDate, momentEndDate) || momentDay.isSame(momentStartDate, 'd') || momentDay.isSame(momentEndDate, 'd');
121
+ }
122
+ return false;
123
+ };
124
+ exports.inDateRange = inDateRange;
125
+ const isStartDateEndDateSame = _ref4 => {
126
+ let {
127
+ startDate,
128
+ endDate
129
+ } = _ref4;
130
+ if (startDate && endDate) {
131
+ return (0, _moment.default)(startDate).isSame((0, _moment.default)(endDate), 'd');
132
+ }
133
+ return false;
134
+ };
135
+ exports.isStartDateEndDateSame = isStartDateEndDateSame;
136
+ const generateAvailableYears = (count, firstCalendarDate, secondCalendarDate, marker) => {
137
+ const startYear = (0, _moment.default)().year() - count + 1;
138
+ const firstCalendarYear = (0, _moment.default)(firstCalendarDate).year();
139
+ const secondCalendarYear = (0, _moment.default)(secondCalendarDate).year();
140
+ const isWithinRange = year => marker === MARKERS.DATE_RANGE_START ? year <= secondCalendarYear : year >= firstCalendarYear;
141
+ return Array.from({
142
+ length: count
143
+ }, (_, index) => {
144
+ const year = startYear + index;
145
+ return {
146
+ key: year.toString(),
147
+ label: year.toString(),
148
+ disabled: !isWithinRange(year)
149
+ };
150
+ }).filter(_ref5 => {
151
+ let {
152
+ disabled
153
+ } = _ref5;
154
+ return !disabled;
155
+ });
156
+ };
157
+ exports.generateAvailableYears = generateAvailableYears;
158
+ const getMonthAndYear = date => {
159
+ const momentDate = date ? (0, _moment.default)(date) : (0, _moment.default)();
160
+ return [momentDate.month(), momentDate.year()];
161
+ };
162
+ const getAvailableMonths = (Months, first, second, marker) => {
163
+ const [firstMonth, firstYear] = getMonthAndYear(first);
164
+ const [secondMonth, secondYear] = getMonthAndYear(second);
165
+ const [currentMonth, currentYear] = getMonthAndYear();
166
+ return Months.filter(month => {
167
+ const isSameYear = firstYear === secondYear;
168
+ const isMonthBeforeFirstMonth = month.key <= firstMonth;
169
+ const isMonthAfterCurrentMonth = currentYear === secondYear && month.key > currentMonth;
170
+ if (marker === MARKERS.DATE_RANGE_START) {
171
+ return !(isSameYear && month.key >= secondMonth);
172
+ } else {
173
+ return !(isSameYear && isMonthBeforeFirstMonth || isMonthAfterCurrentMonth);
174
+ }
175
+ });
176
+ };
177
+ exports.getAvailableMonths = getAvailableMonths;
178
+ const addTimeZone = (date, timeZone) => _moment.default.tz(date, timeZone).startOf('d').utc().toISOString();
179
+ exports.addTimeZone = addTimeZone;
180
+ const getSubtractedDate = (date, subtractCount, timeUnit) => formatIsoDate((0, _moment.default)(date).subtract(subtractCount, timeUnit));
181
+ exports.getSubtractedDate = getSubtractedDate;
182
+ const getAddedDate = (date, addCount, timeUnit) => formatIsoDate((0, _moment.default)(date).add(addCount, timeUnit));
183
+ exports.getAddedDate = getAddedDate;
184
+ function formatIsoDate(date) {
185
+ return (0, _formatISO.default)(wrangleMoment(date), {
186
+ representation: 'date'
187
+ });
188
+ }
189
+ function wrangleMoment(date) {
190
+ if (date instanceof Date) {
191
+ return date;
192
+ } else if (!date) {
193
+ return new Date();
194
+ }
195
+ return date instanceof _moment.default ? date.toDate() : (0, _parseISO.default)(date);
196
+ }
197
+ const getValidatedMonths = (_ref6, minDate, maxDate) => {
198
+ let {
199
+ startDate,
200
+ endDate
201
+ } = _ref6;
202
+ if (startDate && endDate) {
203
+ const newStart = _moment.default.max((0, _moment.default)(startDate), (0, _moment.default)(minDate)); // TODO Figure out the validated date
204
+ const newEnd = _moment.default.min((0, _moment.default)(endDate), (0, _moment.default)(maxDate));
205
+ return [formatIsoDate(newStart), newStart.isSame(newEnd, 'M') ? getAddedDate(newEnd, 1, 'M') : formatIsoDate(newEnd)];
206
+ } else {
207
+ return [startDate, endDate];
208
+ }
209
+ };
210
+ exports.getValidatedMonths = getValidatedMonths;
211
+ const getTimeZones = () => Object.keys(_timezones.TIMEZONES).reduce((menuOptions, key) => {
212
+ menuOptions.push({
213
+ key,
214
+ label: _timezones.TIMEZONES[key]
215
+ });
216
+ return menuOptions;
217
+ }, []);
218
+ exports.getTimeZones = getTimeZones;
@@ -0,0 +1,231 @@
1
+ // @flow strict
2
+
3
+ // $FlowFixMe - strict types for date-fns
4
+ import formatISO from 'date-fns/formatISO';
5
+ // $FlowFixMe - strict types for date-fns
6
+ import parseISO from 'date-fns/parseISO';
7
+ import lodash from 'lodash';
8
+ // $FlowFixMe[untyped-import]
9
+ import moment from 'moment';
10
+
11
+ import type {MenuOption} from '../Menu';
12
+
13
+ import {TIMEZONES} from './timezones';
14
+
15
+
16
+ export type TimeUnit = 'years' | 'months' | 'days' | 'd' | 'M' | 'y';
17
+
18
+ export type DateRange = {
19
+ startDate?: string,
20
+ endDate?: string,
21
+ };
22
+
23
+ export type DatePickerSelectedRange = {
24
+ startDate?: string,
25
+ endDate?: string,
26
+ startDateUTC?: string,
27
+ endDateUTC?: string,
28
+ timeZone?: string,
29
+ };
30
+
31
+ export const NAVIGATION_ACTION = Object.freeze({
32
+ NEXT: 'next',
33
+ PREV: 'prev',
34
+ });
35
+
36
+ export const MARKERS = Object.freeze({
37
+ DATE_RANGE_START: 'FIRST',
38
+ DATE_RANGE_END: 'SECOND',
39
+ });
40
+
41
+ export const WEEKDAYS = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
42
+
43
+ export const MONTHS = [
44
+ {key: '0', label: 'Jan'},
45
+ {key: '1', label: 'Feb'},
46
+ {key: '2', label: 'Mar'},
47
+ {key: '3', label: 'Apr'},
48
+ {key: '4', label: 'May'},
49
+ {key: '5', label: 'Jun'},
50
+ {key: '6', label: 'Jul'},
51
+ {key: '7', label: 'Aug'},
52
+ {key: '8', label: 'Sep'},
53
+ {key: '9', label: 'Oct'},
54
+ {key: '10', label: 'Nov'},
55
+ {key: '11', label: 'Dec'},
56
+ ];
57
+
58
+ export const getDaysInMonth = (date: string): Array<Array<string>> => {
59
+ const startWeek = moment(date).startOf('month').startOf('week');
60
+ const endWeek = moment(date).endOf('month').endOf('week');
61
+ const days = [],
62
+ current = startWeek;
63
+
64
+ while (current.isBefore(endWeek)) {
65
+ days.push(current.clone().format('YYYY-MM-DD'));
66
+ current.add(1, 'd');
67
+ }
68
+ const daysInChunks = lodash.chunk(days, 7);
69
+
70
+ // if total rows in calendar are 5 add one more week to the calendar
71
+ if (daysInChunks.length === 5) {
72
+ const nextWeek = getAddedDate(endWeek, WEEKDAYS.length, 'd');
73
+ const extraDays = [];
74
+ while (current.isSameOrBefore(nextWeek)) {
75
+ extraDays.push(current.clone().format('YYYY-MM-DD'));
76
+ current.add(1, 'd');
77
+ }
78
+ daysInChunks.push(extraDays);
79
+ }
80
+
81
+ return daysInChunks;
82
+ };
83
+
84
+ export const isStartOfRange = ({startDate}: DateRange, date: string): boolean =>
85
+ !!startDate && moment(date).isSame(startDate, 'd');
86
+
87
+ export const isEndOfRange = ({endDate}: DateRange, date: string): boolean =>
88
+ !!endDate && moment(date).isSame(endDate, 'd');
89
+
90
+ export const inDateRange = (
91
+ {startDate, endDate}: DateRange,
92
+ date: string,
93
+ ): boolean => {
94
+ if (startDate && endDate) {
95
+ const momentDay = moment(date);
96
+ const momentStartDate = moment(startDate);
97
+ const momentEndDate = moment(endDate);
98
+ return (
99
+ momentDay.isBetween(momentStartDate, momentEndDate) ||
100
+ momentDay.isSame(momentStartDate, 'd') ||
101
+ momentDay.isSame(momentEndDate, 'd')
102
+ );
103
+ }
104
+ return false;
105
+ };
106
+
107
+ export const isStartDateEndDateSame = ({
108
+ startDate,
109
+ endDate,
110
+ }: DateRange): boolean => {
111
+ if (startDate && endDate) {
112
+ return moment(startDate).isSame(moment(endDate), 'd');
113
+ }
114
+ return false;
115
+ };
116
+
117
+ export const generateAvailableYears = (
118
+ count: number,
119
+ firstCalendarDate: string,
120
+ secondCalendarDate: string,
121
+ marker: $Values<typeof MARKERS>,
122
+ ): Array<MenuOption> => {
123
+ const startYear = moment().year() - count + 1;
124
+ const firstCalendarYear = moment(firstCalendarDate).year();
125
+ const secondCalendarYear = moment(secondCalendarDate).year();
126
+
127
+ const isWithinRange = (year: number) =>
128
+ marker === MARKERS.DATE_RANGE_START
129
+ ? year <= secondCalendarYear
130
+ : year >= firstCalendarYear;
131
+
132
+ return Array.from({length: count}, (_, index) => {
133
+ const year = startYear + index;
134
+ return {
135
+ key: year.toString(),
136
+ label: year.toString(),
137
+ disabled: !isWithinRange(year),
138
+ };
139
+ }).filter(({disabled}) => !disabled);
140
+ };
141
+
142
+ const getMonthAndYear = (date) => {
143
+ const momentDate = date ? moment(date) : moment();
144
+ return [momentDate.month(), momentDate.year()];
145
+ };
146
+
147
+ export const getAvailableMonths = (
148
+ Months: Array<MenuOption>,
149
+ first: string,
150
+ second: string,
151
+ marker: $Values<typeof MARKERS>,
152
+ ): Array<MenuOption> => {
153
+ const [firstMonth, firstYear] = getMonthAndYear(first);
154
+ const [secondMonth, secondYear] = getMonthAndYear(second);
155
+ const [currentMonth, currentYear] = getMonthAndYear();
156
+
157
+ return Months.filter((month: MenuOption) => {
158
+ const isSameYear = firstYear === secondYear;
159
+ const isMonthBeforeFirstMonth = month.key <= firstMonth;
160
+ const isMonthAfterCurrentMonth =
161
+ currentYear === secondYear && month.key > currentMonth;
162
+
163
+ if (marker === MARKERS.DATE_RANGE_START) {
164
+ return !(isSameYear && month.key >= secondMonth);
165
+ } else {
166
+ return !(
167
+ (isSameYear && isMonthBeforeFirstMonth) ||
168
+ isMonthAfterCurrentMonth
169
+ );
170
+ }
171
+ });
172
+ };
173
+
174
+ export const addTimeZone = (date: string, timeZone: string): string =>
175
+ moment.tz(date, timeZone).startOf('d').utc().toISOString();
176
+
177
+ export const getSubtractedDate = (
178
+ date: string,
179
+ subtractCount: number,
180
+ timeUnit: TimeUnit,
181
+ ): string => formatIsoDate(moment(date).subtract(subtractCount, timeUnit));
182
+
183
+ export const getAddedDate = (
184
+ date: string,
185
+ addCount: number,
186
+ timeUnit: TimeUnit,
187
+ ): string => formatIsoDate(moment(date).add(addCount, timeUnit));
188
+
189
+ export function formatIsoDate(date?: string | Date): string {
190
+ return formatISO(wrangleMoment(date), {
191
+ representation: 'date',
192
+ });
193
+ }
194
+
195
+ export function wrangleMoment(date?: string | Date): Date {
196
+ if (date instanceof Date) {
197
+ return date;
198
+ } else if (!date) {
199
+ return new Date();
200
+ }
201
+ return date instanceof moment ? date.toDate() : parseISO(date);
202
+ }
203
+
204
+ export const getValidatedMonths = (
205
+ {startDate, endDate}: DateRange,
206
+ minDate: string,
207
+ maxDate: string,
208
+ ): Array<?string> => {
209
+ if (startDate && endDate) {
210
+ const newStart = moment.max(moment(startDate), moment(minDate)); // TODO Figure out the validated date
211
+ const newEnd = moment.min(moment(endDate), moment(maxDate));
212
+
213
+ return [
214
+ formatIsoDate(newStart),
215
+ newStart.isSame(newEnd, 'M')
216
+ ? getAddedDate(newEnd, 1, 'M')
217
+ : formatIsoDate(newEnd),
218
+ ];
219
+ } else {
220
+ return [startDate, endDate];
221
+ }
222
+ };
223
+
224
+ export const getTimeZones = (): Array<MenuOption> =>
225
+ Object.keys(TIMEZONES).reduce((menuOptions, key) => {
226
+ menuOptions.push({
227
+ key,
228
+ label: TIMEZONES[key],
229
+ });
230
+ return menuOptions;
231
+ }, []);
@@ -26,10 +26,12 @@ const Dropdown = /*#__PURE__*/React.forwardRef((_ref, ref) => {
26
26
  menu,
27
27
  onMenuOpen,
28
28
  onMenuClose,
29
+ scrollMenuToBottom = false,
29
30
  dropdownInputText = '',
30
31
  ...inputProps
31
32
  } = _ref;
32
33
  const dropdownRef = React.useRef();
34
+ const menuRef = React.useRef();
33
35
  const {
34
36
  x,
35
37
  y,
@@ -44,6 +46,9 @@ const Dropdown = /*#__PURE__*/React.forwardRef((_ref, ref) => {
44
46
  });
45
47
  const onMenuToggle = isOpen => {
46
48
  isOpen ? onMenuOpen && onMenuOpen() : onMenuClose && onMenuClose();
49
+ if (scrollMenuToBottom && menuRef.current && isOpen) {
50
+ menuRef.current.scrollTop = isOpen ? menuRef.current.scrollHeight : 0;
51
+ }
47
52
  };
48
53
  return /*#__PURE__*/React.createElement(_clickAway.ClickAway, {
49
54
  onChange: onMenuToggle
@@ -90,7 +95,8 @@ const Dropdown = /*#__PURE__*/React.forwardRef((_ref, ref) => {
90
95
  }
91
96
  },
92
97
  size: menu.size || size,
93
- onTabOut: clickAway
98
+ onTabOut: clickAway,
99
+ ref: menuRef
94
100
  }))));
95
101
  });
96
102
  });
@@ -32,6 +32,7 @@ export type DropdownProps = {
32
32
  onChange?: (option: MenuOption, ?SyntheticEvent<HTMLElement>) => mixed,
33
33
  onMenuOpen?: () => mixed,
34
34
  onMenuClose?: () => mixed,
35
+ scrollMenuToBottom?: boolean,
35
36
  dropdownInputText?: string,
36
37
  menu?: MenuProps,
37
38
  ...
@@ -50,12 +51,14 @@ export const Dropdown: React$AbstractComponent<
50
51
  menu,
51
52
  onMenuOpen,
52
53
  onMenuClose,
54
+ scrollMenuToBottom = false,
53
55
  dropdownInputText = '',
54
56
  ...inputProps
55
57
  }: DropdownProps,
56
58
  ref,
57
59
  ): React.Node => {
58
60
  const dropdownRef = React.useRef();
61
+ const menuRef = React.useRef();
59
62
  const {x, y, refs, strategy} = useFloating({
60
63
  open: true,
61
64
  strategy: 'absolute',
@@ -66,6 +69,9 @@ export const Dropdown: React$AbstractComponent<
66
69
 
67
70
  const onMenuToggle = (isOpen: boolean) => {
68
71
  isOpen ? onMenuOpen && onMenuOpen() : onMenuClose && onMenuClose();
72
+ if (scrollMenuToBottom && menuRef.current && isOpen) {
73
+ menuRef.current.scrollTop = isOpen ? menuRef.current.scrollHeight : 0;
74
+ }
69
75
  };
70
76
 
71
77
  return (
@@ -116,6 +122,7 @@ export const Dropdown: React$AbstractComponent<
116
122
  }}
117
123
  size={menu.size || size}
118
124
  onTabOut={clickAway}
125
+ ref={menuRef}
119
126
  />
120
127
  </div>
121
128
  )}
@@ -24,6 +24,7 @@ const SimpleDropdownBase = (props, ref) => {
24
24
  onMenuClose,
25
25
  resolveLabel,
26
26
  resolveSecondaryLabel,
27
+ isMenuFluid = true,
27
28
  ...inputProps
28
29
  } = props;
29
30
  const [dropdownInputText, setDropdownInputText] = React.useState('');
@@ -66,7 +67,8 @@ const SimpleDropdownBase = (props, ref) => {
66
67
  allowSearch,
67
68
  resolveLabel,
68
69
  resolveSecondaryLabel,
69
- size
70
+ size,
71
+ isFluid: isMenuFluid
70
72
  }
71
73
  }));
72
74
  };
@@ -33,6 +33,7 @@ export type SimpleDropdownProps = {
33
33
  optionsVariant?: MenuOptionsVariant,
34
34
  allowSearch?: boolean,
35
35
  selectedKeys?: Array<string>,
36
+ isMenuFluid?: boolean,
36
37
 
37
38
  // events
38
39
  onChange?: (option: MenuOption, ?SyntheticEvent<HTMLElement>) => mixed,
@@ -59,6 +60,7 @@ const SimpleDropdownBase = (props: SimpleDropdownProps, ref) => {
59
60
  onMenuClose,
60
61
  resolveLabel,
61
62
  resolveSecondaryLabel,
63
+ isMenuFluid = true,
62
64
  ...inputProps
63
65
  } = props;
64
66
 
@@ -121,6 +123,7 @@ const SimpleDropdownBase = (props: SimpleDropdownProps, ref) => {
121
123
  resolveLabel,
122
124
  resolveSecondaryLabel,
123
125
  size,
126
+ isFluid: isMenuFluid,
124
127
  }}
125
128
  />
126
129
  );
@@ -68,7 +68,8 @@ const Row = _ref => {
68
68
  "data-testid": "Grid",
69
69
  className: (0, _classify.classify)(_GridModule.default.gridRow, className),
70
70
  style: {
71
- gridTemplateColumns: `repeat(${gridRepeatCount}, ${repeatTracks})`
71
+ '--grid-repeat-count': gridRepeatCount,
72
+ '--repeat-tracks': repeatTracks
72
73
  }
73
74
  }, childrenWithProps);
74
75
  };
@@ -83,8 +84,8 @@ const Col = _ref2 => {
83
84
  return /*#__PURE__*/React.createElement("div", {
84
85
  className: (0, _classify.classify)(_GridModule.default.gridColumn, className),
85
86
  style: {
86
- gridColumnStart,
87
- gridColumnEnd
87
+ '--grid-column-start': gridColumnStart,
88
+ '--grid-column-end': gridColumnEnd
88
89
  }
89
90
  }, children);
90
91
  };
@@ -74,7 +74,8 @@ export const Row = ({
74
74
  data-testid="Grid"
75
75
  className={classify(css.gridRow, className)}
76
76
  style={{
77
- gridTemplateColumns: `repeat(${gridRepeatCount}, ${repeatTracks})`,
77
+ '--grid-repeat-count': gridRepeatCount,
78
+ '--repeat-tracks': repeatTracks,
78
79
  }}
79
80
  >
80
81
  {childrenWithProps}
@@ -99,7 +100,10 @@ export const Col = ({
99
100
  }: ColProps): React.Node => (
100
101
  <div
101
102
  className={classify(css.gridColumn, className)}
102
- style={{gridColumnStart, gridColumnEnd}}
103
+ style={{
104
+ '--grid-column-start': gridColumnStart,
105
+ '--grid-column-end': gridColumnEnd,
106
+ }}
103
107
  >
104
108
  {children}
105
109
  </div>
@@ -10,7 +10,10 @@
10
10
  ) from '../../styles/variables/_size.css';
11
11
 
12
12
  .gridRow {
13
+ --grid-repeat-count: 12;
14
+ --repeat-tracks: 1fr;
13
15
  display: grid !important;
16
+ grid-template-columns: repeat(var(--grid-repeat-count), var(--repeat-tracks));
14
17
  width: sizeFluid;
15
18
  height: sizeFluid;
16
19
  gap: spaceMedium;
@@ -24,6 +27,9 @@
24
27
  }
25
28
 
26
29
  .gridColumn {
30
+ --grid-column-start: auto;
31
+ --grid-column-end: span 1;
27
32
  display: flex;
28
33
  align-items: center;
34
+ grid-column: var(--grid-column-start) / var(--grid-column-end);
29
35
  }
@@ -31,27 +31,10 @@ const SpiderChart = _ref => {
31
31
  cardTitle,
32
32
  customExportOptions,
33
33
  headerActions,
34
- legend,
35
34
  series,
36
- xAxis: {
37
- categories,
38
- tickmarkPlacement = 'on',
39
- lineWidth: xAxisLineWidth = 0,
40
- ...xAxisProps
41
- } = {},
42
- yAxis: {
43
- gridLineInterpolation = 'polygon',
44
- lineWidth: yAxisLineWidth = 0,
45
- min: yAxisMin = 0,
46
- ...yAxisProps
47
- } = {},
48
35
  ...userOptions
49
36
  } = _ref;
50
37
  const chartRef = React.useRef(null);
51
- const [chartWidth, setChartWidth] = React.useState(0);
52
- React.useLayoutEffect(() => {
53
- setChartWidth(chartRef.current?.chart.plotWidth);
54
- }, []);
55
38
  const spiderSeries = series.map((seriesItem, index) => ({
56
39
  ...seriesItem,
57
40
  name: seriesItem.name,
@@ -71,9 +54,7 @@ const SpiderChart = _ref => {
71
54
  ...wrapperClassNames
72
55
  } = classNames || {};
73
56
  return /*#__PURE__*/React.createElement(_ChartWrapper.ChartWrapper, {
74
- title: cardTitle
75
- //$FlowFixMe[incompatible-type]
76
- ,
57
+ title: cardTitle,
77
58
  ref: chartRef,
78
59
  customExportOptions: customExportOptions,
79
60
  classNames: wrapperClassNames,