@spaced-out/ui-design-system 0.3.41 → 0.3.43

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 (77) hide show
  1. package/.cspell/custom-words.txt +1 -0
  2. package/.github/workflows/pages.yml +1 -1
  3. package/.github/workflows/publish_to_npm.yml +2 -12
  4. package/.github/workflows/pull_request_checks.yml +1 -11
  5. package/.storybook/SenseTheme.js +1 -1
  6. package/.storybook/main.js +16 -40
  7. package/.storybook/manager.js +2 -3
  8. package/.storybook/preview.js +22 -1
  9. package/.vscode/settings.json +2 -1
  10. package/CHANGELOG.md +32 -0
  11. package/CONTRIBUTING.md +19 -0
  12. package/dts-generator/package.json +1 -1
  13. package/lib/components/Chip/Chip.d.ts +5 -2
  14. package/lib/components/Chip/Chip.js +2 -2
  15. package/lib/components/Chip/Chip.js.flow +5 -2
  16. package/lib/components/DateRangePicker/Calendar.d.ts +1 -23
  17. package/lib/components/DateRangePicker/Calendar.js +1 -16
  18. package/lib/components/DateRangePicker/Calendar.js.flow +1 -20
  19. package/lib/components/DateRangePicker/DateRangeWrapper.d.ts +39 -3
  20. package/lib/components/DateRangePicker/DateRangeWrapper.js +20 -2
  21. package/lib/components/DateRangePicker/DateRangeWrapper.js.flow +39 -3
  22. package/lib/components/DateRangePicker/DateRangeWrapper.module.css +32 -1
  23. package/lib/components/EmptyState/EmptyImages/ChartEmptyImage.d.ts +2 -2
  24. package/lib/components/EmptyState/EmptyImages/ChartEmptyImage.js +2 -2
  25. package/lib/components/EmptyState/EmptyImages/ChartEmptyImage.js.flow +2 -2
  26. package/lib/components/FilterButtonOverlay/FilterButtonOverlay.d.ts +130 -0
  27. package/lib/components/FilterButtonOverlay/FilterButtonOverlay.js +90 -0
  28. package/lib/components/FilterButtonOverlay/FilterButtonOverlay.js.flow +135 -0
  29. package/lib/components/FilterButtonOverlay/FilterButtonOverlay.module.css +35 -0
  30. package/lib/components/FilterButtonOverlay/index.d.ts +1 -0
  31. package/lib/components/FilterButtonOverlay/index.js +16 -0
  32. package/lib/components/FilterButtonOverlay/index.js.flow +3 -0
  33. package/lib/components/Icon/ClickableIcon.d.ts +2 -1
  34. package/lib/components/Icon/ClickableIcon.js +3 -2
  35. package/lib/components/Icon/ClickableIcon.js.flow +2 -1
  36. package/lib/components/Icon/ClickableIcon.module.css +2 -2
  37. package/lib/components/Icon/Icon.docs.d.ts +15 -1
  38. package/lib/components/Icon/Icon.docs.js +15 -1
  39. package/lib/components/Icon/Icon.docs.js.flow +11 -1
  40. package/lib/components/InfinitePagination/InfinitePagination.d.ts +112 -0
  41. package/lib/components/InfinitePagination/InfinitePagination.js +84 -0
  42. package/lib/components/InfinitePagination/InfinitePagination.js.flow +122 -0
  43. package/lib/components/InfinitePagination/InfinitePagination.module.css +18 -0
  44. package/lib/components/InfinitePagination/index.d.ts +1 -0
  45. package/lib/components/InfinitePagination/index.js +16 -0
  46. package/lib/components/InfinitePagination/index.js.flow +3 -0
  47. package/lib/components/Modal/Modal.d.ts +9 -1
  48. package/lib/components/Modal/Modal.js +13 -5
  49. package/lib/components/Modal/Modal.js.flow +9 -1
  50. package/lib/components/Table/Table.docs.d.ts +1 -1
  51. package/lib/components/Table/Table.docs.js +1 -1
  52. package/lib/components/Table/Table.docs.js.flow +1 -1
  53. package/lib/components/TokenListInput/TokenValueChips.d.ts +2 -1
  54. package/lib/components/TokenListInput/TokenValueChips.js +3 -1
  55. package/lib/components/TokenListInput/TokenValueChips.js.flow +2 -1
  56. package/lib/components/index.d.ts +2 -0
  57. package/lib/components/index.js +22 -0
  58. package/lib/components/index.js.flow +2 -0
  59. package/lib/hooks/index.d.ts +2 -0
  60. package/lib/hooks/index.js +22 -0
  61. package/lib/hooks/index.js.flow +2 -0
  62. package/lib/hooks/useInfiniteScroll/index.d.ts +1 -0
  63. package/lib/hooks/useInfiniteScroll/index.js +16 -0
  64. package/lib/hooks/useInfiniteScroll/index.js.flow +3 -0
  65. package/lib/hooks/useInfiniteScroll/useInfiniteScroll.d.ts +77 -0
  66. package/lib/hooks/useInfiniteScroll/useInfiniteScroll.js +58 -0
  67. package/lib/hooks/useInfiniteScroll/useInfiniteScroll.js.flow +82 -0
  68. package/lib/hooks/useResizeObserver/index.d.ts +1 -0
  69. package/lib/hooks/useResizeObserver/index.js +16 -0
  70. package/lib/hooks/useResizeObserver/index.js.flow +3 -0
  71. package/lib/hooks/useResizeObserver/useResizeObserver.d.ts +22 -0
  72. package/lib/hooks/useResizeObserver/useResizeObserver.js +30 -0
  73. package/lib/hooks/useResizeObserver/useResizeObserver.js.flow +28 -0
  74. package/lib/utils/date-range-picker/date-range-picker.d.ts +22 -2
  75. package/lib/utils/date-range-picker/date-range-picker.js +19 -3
  76. package/lib/utils/date-range-picker/date-range-picker.js.flow +21 -2
  77. package/package.json +9 -16
@@ -18,6 +18,7 @@ import classify from '../../utils/classify';
18
18
  import {
19
19
  addTimezoneEndOfDay,
20
20
  addTimezoneStartOfDay,
21
+ getFormattedDate,
21
22
  isAfter,
22
23
  isSameOrAfter,
23
24
  isSameOrBefore,
@@ -33,7 +34,8 @@ import {
33
34
  } from '../Card';
34
35
  import {Dropdown, SimpleDropdown} from '../Dropdown';
35
36
  import {FocusManager} from '../FocusManager';
36
- import {ClickableIcon} from '../Icon';
37
+ import {ClickableIcon, Icon, ICON_SIZE, ICON_TYPE} from '../Icon';
38
+ import {BodySmall, TEXT_COLORS} from '../Text';
37
39
 
38
40
  import {Calendar} from './Calendar.js';
39
41
 
@@ -79,6 +81,8 @@ type DateRangeWrapperProps = {
79
81
  ) => void,
80
82
  },
81
83
  today: string,
84
+ startDateLabel?: string,
85
+ endDateLabel?: string,
82
86
  };
83
87
 
84
88
  const CalendarHeader = ({
@@ -184,6 +188,8 @@ export const DateRangeWrapper: React$AbstractComponent<
184
188
  cardWrapperClass,
185
189
  hideTimezone,
186
190
  today,
191
+ startDateLabel = 'Start Date',
192
+ endDateLabel = 'End Date',
187
193
  }: DateRangeWrapperProps,
188
194
  ref,
189
195
  ): React.Node => {
@@ -228,6 +234,35 @@ export const DateRangeWrapper: React$AbstractComponent<
228
234
  ref={ref}
229
235
  >
230
236
  <CardHeader className={css.cardHeader}>
237
+ <BodySmall
238
+ className={css.selectedDate}
239
+ color={TEXT_COLORS.secondary}
240
+ >
241
+ {`${startDateLabel}: ${getFormattedDate(
242
+ MARKERS.DATE_RANGE_START,
243
+ dateRange,
244
+ )}`}
245
+ </BodySmall>
246
+
247
+ <Icon
248
+ name="minus"
249
+ size={ICON_SIZE.small}
250
+ type={ICON_TYPE.regular}
251
+ color={TEXT_COLORS.secondary}
252
+ />
253
+
254
+ <BodySmall
255
+ className={css.selectedDate}
256
+ color={TEXT_COLORS.secondary}
257
+ >
258
+ {`${endDateLabel}: ${getFormattedDate(
259
+ MARKERS.DATE_RANGE_END,
260
+ dateRange,
261
+ )}`}
262
+ </BodySmall>
263
+ </CardHeader>
264
+
265
+ <div className={css.calendarMenuContainer}>
231
266
  <CalendarHeader
232
267
  marker={MARKERS.DATE_RANGE_START}
233
268
  rangeStartMonth={rangeStartMonth}
@@ -268,7 +303,8 @@ export const DateRangeWrapper: React$AbstractComponent<
268
303
  onMonthNavigate(MARKERS.DATE_RANGE_END, NAVIGATION_ACTION.PREV)
269
304
  }
270
305
  />
271
- </CardHeader>
306
+ </div>
307
+
272
308
  <CardContent className={css.dateRangeCalendars}>
273
309
  <Calendar
274
310
  marker={MARKERS.DATE_RANGE_START}
@@ -282,7 +318,7 @@ export const DateRangeWrapper: React$AbstractComponent<
282
318
  {...commonProps}
283
319
  />
284
320
  </CardContent>
285
- <CardFooter>
321
+ <CardFooter className={css.cardFooter}>
286
322
  <CardTitle className={css.timezoneDropdownContainer}>
287
323
  {!hideTimezone && (
288
324
  <SimpleDropdown
@@ -6,8 +6,11 @@
6
6
  @value (
7
7
  spaceNone,
8
8
  spaceSmall,
9
- spaceXSmall
9
+ spaceXSmall,
10
+ spaceMedium
10
11
  ) from '../../styles/variables/_space.css';
12
+ @value (borderRadiusMedium) from '../../styles/variables/_border.css';
13
+ @value (colorBackgroundPrimary) from '../../styles/variables/_color.css';
11
14
 
12
15
  .dateRangeWrapper {
13
16
  display: flex;
@@ -18,6 +21,15 @@
18
21
  width: sizeFluid;
19
22
  padding: spaceXSmall;
20
23
  gap: spaceSmall;
24
+ background-color: colorBackgroundPrimary;
25
+ border-top-left-radius: borderRadiusMedium;
26
+ border-top-right-radius: borderRadiusMedium;
27
+ }
28
+
29
+ .cardFooter {
30
+ background-color: colorBackgroundPrimary;
31
+ border-bottom-left-radius: borderRadiusMedium;
32
+ border-bottom-right-radius: borderRadiusMedium;
21
33
  }
22
34
 
23
35
  .calendarHeader {
@@ -62,3 +74,22 @@
62
74
  .mainContainer {
63
75
  width: sizeFluid;
64
76
  }
77
+
78
+ .selectedDateContainer {
79
+ display: flex;
80
+ gap: spaceMedium;
81
+ padding: spaceXSmall spaceSmall;
82
+ }
83
+
84
+ .selectedDate {
85
+ display: flex;
86
+ width: 100%;
87
+ justify-content: center;
88
+ }
89
+
90
+ .calendarMenuContainer {
91
+ display: flex;
92
+ gap: spaceSmall;
93
+ width: sizeFluid;
94
+ padding: spaceXSmall;
95
+ }
@@ -183,8 +183,8 @@ export const ChartEmptyImage = (): React.ReactNode => (
183
183
  <path
184
184
  d="M120 68.2411C120 82.6282 113.908 96.1623 104.213 105L25.7991 104.496C24.7996 104.496 24 103.674 24 102.647V35.8498C24 34.8221 24.7996 34 25.7991 34L104 34.5C112.796 43.0295 120 54.6762 120 68.2411Z"
185
185
  stroke="#D3D2E0"
186
- stroke-width="2"
187
- stroke-miterlimit="10"
186
+ strokeWidth="2"
187
+ strokeMiterlimit="10"
188
188
  />
189
189
  <path
190
190
  d="M29.5054 29.1312C32.3772 29.1312 34.7054 26.8031 34.7054 23.9312C34.7054 21.0593 32.3772 18.7312 29.5054 18.7312C26.6335 18.7312 24.3054 21.0593 24.3054 23.9312C24.3054 26.8031 26.6335 29.1312 29.5054 29.1312Z"
@@ -167,8 +167,8 @@ const ChartEmptyImage = () => /*#__PURE__*/React.createElement("svg", {
167
167
  }), /*#__PURE__*/React.createElement("path", {
168
168
  d: "M120 68.2411C120 82.6282 113.908 96.1623 104.213 105L25.7991 104.496C24.7996 104.496 24 103.674 24 102.647V35.8498C24 34.8221 24.7996 34 25.7991 34L104 34.5C112.796 43.0295 120 54.6762 120 68.2411Z",
169
169
  stroke: "#D3D2E0",
170
- "stroke-width": "2",
171
- "stroke-miterlimit": "10"
170
+ strokeWidth: "2",
171
+ strokeMiterlimit: "10"
172
172
  }), /*#__PURE__*/React.createElement("path", {
173
173
  d: "M29.5054 29.1312C32.3772 29.1312 34.7054 26.8031 34.7054 23.9312C34.7054 21.0593 32.3772 18.7312 29.5054 18.7312C26.6335 18.7312 24.3054 21.0593 24.3054 23.9312C24.3054 26.8031 26.6335 29.1312 29.5054 29.1312Z",
174
174
  fill: "#9F9FBC"
@@ -187,8 +187,8 @@ export const ChartEmptyImage = (): React.Node => (
187
187
  <path
188
188
  d="M120 68.2411C120 82.6282 113.908 96.1623 104.213 105L25.7991 104.496C24.7996 104.496 24 103.674 24 102.647V35.8498C24 34.8221 24.7996 34 25.7991 34L104 34.5C112.796 43.0295 120 54.6762 120 68.2411Z"
189
189
  stroke="#D3D2E0"
190
- stroke-width="2"
191
- stroke-miterlimit="10"
190
+ strokeWidth="2"
191
+ strokeMiterlimit="10"
192
192
  />
193
193
  <path
194
194
  d="M29.5054 29.1312C32.3772 29.1312 34.7054 26.8031 34.7054 23.9312C34.7054 21.0593 32.3772 18.7312 29.5054 18.7312C26.6335 18.7312 24.3054 21.0593 24.3054 23.9312C24.3054 26.8031 26.6335 29.1312 29.5054 29.1312Z"
@@ -0,0 +1,130 @@
1
+ import {$ReadOnly, $Diff} from 'utility-types';
2
+ import * as React from 'react';
3
+ import {
4
+ // $FlowFixMe[untyped-import]
5
+ autoUpdate, // $FlowFixMe[untyped-import]
6
+ flip, // $FlowFixMe[untyped-import]
7
+ offset, // $FlowFixMe[untyped-import]
8
+ shift, // $FlowFixMe[untyped-import]
9
+ useFloating,
10
+ } from '@floating-ui/react';
11
+ import {sizeFluid} from '../../styles/variables/_size';
12
+ import {spaceNone, spaceXXSmall} from '../../styles/variables/_space';
13
+ import type {ClickAwayRefType} from '../../utils';
14
+ import {ClickAway, mergeRefs} from '../../utils';
15
+ import classify from '../../utils/classify';
16
+ import type {ButtonProps, ButtonSize} from '../Button';
17
+ import {Button} from '../Button';
18
+ import type {AnchorType, Strategy} from '../ButtonDropdown';
19
+ import {ANCHOR_POSITION_TYPE, STRATEGY_TYPE} from '../ButtonDropdown';
20
+ import css from './FilterButtonOverlay.module.css';
21
+ type ClassNames = $ReadOnly<{
22
+ wrapper?: string;
23
+ overlayContainer?: string;
24
+ }>;
25
+ export type FilterButtonOverlaySizeTypes = 'medium' | 'small';
26
+ export type NewButtonProps = $Diff<
27
+ ButtonProps,
28
+ {
29
+ children?: React.ReactNode;
30
+ }
31
+ >;
32
+ export type FilterButtonOverlayProps = NewButtonProps & {
33
+ classNames?: ClassNames;
34
+ children: React.ReactNode;
35
+ positionStrategy?: Strategy;
36
+ anchorPosition?: AnchorType;
37
+ clickAwayRef?: ClickAwayRefType;
38
+ isFluid?: boolean;
39
+ size?: FilterButtonOverlaySizeTypes;
40
+ buttonLabel?: React.ReactNode;
41
+ buttonSize?: ButtonSize;
42
+ buttonIsFluid?: boolean;
43
+ };
44
+ export const FilterButtonOverlay: React$AbstractComponent<
45
+ FilterButtonOverlayProps,
46
+ HTMLDivElement
47
+ > = React.forwardRef<FilterButtonOverlayProps, HTMLDivElement>(
48
+ (
49
+ {
50
+ classNames,
51
+ anchorPosition = ANCHOR_POSITION_TYPE.bottomStart,
52
+ positionStrategy = STRATEGY_TYPE.absolute,
53
+ clickAwayRef,
54
+ size,
55
+ children,
56
+ isFluid,
57
+ buttonLabel,
58
+ buttonIsFluid,
59
+ buttonSize,
60
+ ...restProps
61
+ }: FilterButtonOverlayProps,
62
+ ref,
63
+ ) => {
64
+ const {x, y, refs, strategy} = useFloating({
65
+ open: true,
66
+ strategy: positionStrategy,
67
+ placement: anchorPosition,
68
+ whileElementsMounted: autoUpdate,
69
+ middleware: [shift(), flip(), offset(parseInt(spaceXXSmall))],
70
+ });
71
+ return (
72
+ <ClickAway clickAwayRef={clickAwayRef} closeOnEscapeKeypress>
73
+ {({isOpen, onOpen, boundaryRef, triggerRef}) => (
74
+ <div
75
+ data-testid="FilterButtonOverlay"
76
+ className={classify(
77
+ {
78
+ [css.isFluid]: buttonIsFluid,
79
+ },
80
+ classNames?.wrapper,
81
+ )}
82
+ ref={ref}
83
+ >
84
+ <Button
85
+ {...restProps}
86
+ ref={mergeRefs([refs.setReference, triggerRef])}
87
+ onClick={(e) => {
88
+ e.stopPropagation();
89
+ onOpen();
90
+ }}
91
+ isFluid={buttonIsFluid}
92
+ size={buttonSize}
93
+ >
94
+ {buttonLabel}
95
+ </Button>
96
+
97
+ {isOpen && (
98
+ <div
99
+ ref={mergeRefs([refs.setFloating, boundaryRef])}
100
+ style={{
101
+ display: 'flex',
102
+ position: strategy,
103
+ top: y ?? spaceNone,
104
+ left: x ?? spaceNone,
105
+ ...(isFluid && {
106
+ width: sizeFluid,
107
+ }),
108
+ }}
109
+ >
110
+ <div
111
+ className={classify(
112
+ css.overlayWrapper,
113
+ {
114
+ [css.fluid]: isFluid,
115
+ [css.medium]: size === 'medium',
116
+ [css.small]: size === 'small',
117
+ },
118
+ classNames?.overlayContainer,
119
+ )}
120
+ >
121
+ {children}
122
+ </div>
123
+ </div>
124
+ )}
125
+ </div>
126
+ )}
127
+ </ClickAway>
128
+ );
129
+ },
130
+ );
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.FilterButtonOverlay = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _react2 = require("@floating-ui/react");
9
+ var _size = require("../../styles/variables/_size");
10
+ var _space = require("../../styles/variables/_space");
11
+ var _utils = require("../../utils");
12
+ var _classify = _interopRequireDefault(require("../../utils/classify"));
13
+ var _Button = require("../Button");
14
+ var _ButtonDropdown = require("../ButtonDropdown");
15
+ var _FilterButtonOverlayModule = _interopRequireDefault(require("./FilterButtonOverlay.module.css"));
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
20
+ const FilterButtonOverlay = /*#__PURE__*/React.forwardRef((_ref, ref) => {
21
+ let {
22
+ classNames,
23
+ anchorPosition = _ButtonDropdown.ANCHOR_POSITION_TYPE.bottomStart,
24
+ positionStrategy = _ButtonDropdown.STRATEGY_TYPE.absolute,
25
+ clickAwayRef,
26
+ size,
27
+ children,
28
+ isFluid,
29
+ buttonLabel,
30
+ buttonIsFluid,
31
+ buttonSize,
32
+ ...restProps
33
+ } = _ref;
34
+ const {
35
+ x,
36
+ y,
37
+ refs,
38
+ strategy
39
+ } = (0, _react2.useFloating)({
40
+ open: true,
41
+ strategy: positionStrategy,
42
+ placement: anchorPosition,
43
+ whileElementsMounted: _react2.autoUpdate,
44
+ middleware: [(0, _react2.shift)(), (0, _react2.flip)(), (0, _react2.offset)(parseInt(_space.spaceXXSmall))]
45
+ });
46
+ return /*#__PURE__*/React.createElement(_utils.ClickAway, {
47
+ clickAwayRef: clickAwayRef,
48
+ closeOnEscapeKeypress: true
49
+ }, _ref2 => {
50
+ let {
51
+ isOpen,
52
+ onOpen,
53
+ boundaryRef,
54
+ triggerRef
55
+ } = _ref2;
56
+ return /*#__PURE__*/React.createElement("div", {
57
+ "data-testid": "FilterButtonOverlay",
58
+ className: (0, _classify.default)({
59
+ [_FilterButtonOverlayModule.default.isFluid]: buttonIsFluid
60
+ }, classNames?.wrapper),
61
+ ref: ref
62
+ }, /*#__PURE__*/React.createElement(_Button.Button, _extends({}, restProps, {
63
+ ref: (0, _utils.mergeRefs)([refs.setReference, triggerRef]),
64
+ onClick: e => {
65
+ e.stopPropagation();
66
+ onOpen();
67
+ },
68
+ isFluid: buttonIsFluid,
69
+ size: buttonSize
70
+ }), buttonLabel), isOpen && /*#__PURE__*/React.createElement("div", {
71
+ ref: (0, _utils.mergeRefs)([refs.setFloating, boundaryRef]),
72
+ style: {
73
+ display: 'flex',
74
+ position: strategy,
75
+ top: y ?? _space.spaceNone,
76
+ left: x ?? _space.spaceNone,
77
+ ...(isFluid && {
78
+ width: _size.sizeFluid
79
+ })
80
+ }
81
+ }, /*#__PURE__*/React.createElement("div", {
82
+ className: (0, _classify.default)(_FilterButtonOverlayModule.default.overlayWrapper, {
83
+ [_FilterButtonOverlayModule.default.fluid]: isFluid,
84
+ [_FilterButtonOverlayModule.default.medium]: size === 'medium',
85
+ [_FilterButtonOverlayModule.default.small]: size === 'small'
86
+ }, classNames?.overlayContainer)
87
+ }, children)));
88
+ });
89
+ });
90
+ exports.FilterButtonOverlay = FilterButtonOverlay;
@@ -0,0 +1,135 @@
1
+ // @flow strict
2
+
3
+ import * as React from 'react';
4
+ import {
5
+ // $FlowFixMe[untyped-import]
6
+ autoUpdate,
7
+ // $FlowFixMe[untyped-import]
8
+ flip,
9
+ // $FlowFixMe[untyped-import]
10
+ offset,
11
+ // $FlowFixMe[untyped-import]
12
+ shift,
13
+ // $FlowFixMe[untyped-import]
14
+ useFloating,
15
+ } from '@floating-ui/react';
16
+
17
+ import {sizeFluid} from '../../styles/variables/_size';
18
+ import {spaceNone, spaceXXSmall} from '../../styles/variables/_space';
19
+ import type {ClickAwayRefType} from '../../utils';
20
+ import {ClickAway, mergeRefs} from '../../utils';
21
+ import classify from '../../utils/classify';
22
+ import type {ButtonProps, ButtonSize} from '../Button';
23
+ import {Button} from '../Button';
24
+ import type {AnchorType, Strategy} from '../ButtonDropdown';
25
+ import {ANCHOR_POSITION_TYPE, STRATEGY_TYPE} from '../ButtonDropdown';
26
+
27
+ import css from './FilterButtonOverlay.module.css';
28
+
29
+
30
+ type ClassNames = $ReadOnly<{wrapper?: string, overlayContainer?: string}>;
31
+ export type FilterButtonOverlaySizeTypes = 'medium' | 'small';
32
+
33
+ export type NewButtonProps = $Diff<ButtonProps, {children?: React.Node}>;
34
+
35
+ export type FilterButtonOverlayProps = {
36
+ ...NewButtonProps,
37
+ classNames?: ClassNames,
38
+ children: React.Node,
39
+ positionStrategy?: Strategy,
40
+ anchorPosition?: AnchorType,
41
+ clickAwayRef?: ClickAwayRefType,
42
+ isFluid?: boolean,
43
+ size?: FilterButtonOverlaySizeTypes,
44
+ buttonLabel?: React.Node,
45
+ buttonSize?: ButtonSize,
46
+ buttonIsFluid?: boolean,
47
+ ...
48
+ };
49
+
50
+ export const FilterButtonOverlay: React$AbstractComponent<
51
+ FilterButtonOverlayProps,
52
+ HTMLDivElement,
53
+ > = React.forwardRef<FilterButtonOverlayProps, HTMLDivElement>(
54
+ (
55
+ {
56
+ classNames,
57
+ anchorPosition = ANCHOR_POSITION_TYPE.bottomStart,
58
+ positionStrategy = STRATEGY_TYPE.absolute,
59
+ clickAwayRef,
60
+ size,
61
+ children,
62
+ isFluid,
63
+ buttonLabel,
64
+ buttonIsFluid,
65
+ buttonSize,
66
+ ...restProps
67
+ }: FilterButtonOverlayProps,
68
+ ref,
69
+ ) => {
70
+ const {x, y, refs, strategy} = useFloating({
71
+ open: true,
72
+ strategy: positionStrategy,
73
+ placement: anchorPosition,
74
+ whileElementsMounted: autoUpdate,
75
+ middleware: [shift(), flip(), offset(parseInt(spaceXXSmall))],
76
+ });
77
+
78
+ return (
79
+ <ClickAway clickAwayRef={clickAwayRef} closeOnEscapeKeypress>
80
+ {({isOpen, onOpen, boundaryRef, triggerRef}) => (
81
+ <div
82
+ data-testid="FilterButtonOverlay"
83
+ className={classify(
84
+ {
85
+ [css.isFluid]: buttonIsFluid,
86
+ },
87
+ classNames?.wrapper,
88
+ )}
89
+ ref={ref}
90
+ >
91
+ <Button
92
+ {...restProps}
93
+ ref={mergeRefs([refs.setReference, triggerRef])}
94
+ onClick={(e) => {
95
+ e.stopPropagation();
96
+ onOpen();
97
+ }}
98
+ isFluid={buttonIsFluid}
99
+ size={buttonSize}
100
+ >
101
+ {buttonLabel}
102
+ </Button>
103
+
104
+ {isOpen && (
105
+ <div
106
+ ref={mergeRefs([refs.setFloating, boundaryRef])}
107
+ style={{
108
+ display: 'flex',
109
+ position: strategy,
110
+ top: y ?? spaceNone,
111
+ left: x ?? spaceNone,
112
+ ...(isFluid && {width: sizeFluid}),
113
+ }}
114
+ >
115
+ <div
116
+ className={classify(
117
+ css.overlayWrapper,
118
+ {
119
+ [css.fluid]: isFluid,
120
+ [css.medium]: size === 'medium',
121
+ [css.small]: size === 'small',
122
+ },
123
+ classNames?.overlayContainer,
124
+ )}
125
+ >
126
+ {children}
127
+ </div>
128
+ </div>
129
+ )}
130
+ </div>
131
+ )}
132
+ </ClickAway>
133
+ );
134
+ },
135
+ );
@@ -0,0 +1,35 @@
1
+ @value (colorBackgroundTertiary) from '../../styles/variables/_color.css';
2
+ @value (size160, sizeFluid, size300, size240) from '../../styles/variables/_size.css';
3
+ @value (borderRadiusMedium) from '../../styles/variables/_border.css';
4
+ @value (elevationMenu) from '../../styles/variables/_elevation.css';
5
+
6
+ .overlayWrapper {
7
+ position: relative;
8
+ composes: boxShadow2 from '../../styles/shadow.module.css';
9
+ composes: borderPrimary from '../../styles/border.module.css';
10
+ background-color: colorBackgroundTertiary;
11
+ display: flex;
12
+ flex-flow: column;
13
+ min-width: size160;
14
+ border-radius: borderRadiusMedium;
15
+ z-index: elevationMenu;
16
+ }
17
+
18
+ .fluid {
19
+ width: sizeFluid;
20
+ min-width: size160;
21
+ }
22
+
23
+ .medium {
24
+ width: size300;
25
+ min-width: size300;
26
+ }
27
+
28
+ .small {
29
+ width: size240;
30
+ min-width: size240;
31
+ }
32
+
33
+ .isFluid {
34
+ width: sizeFluid;
35
+ }
@@ -0,0 +1 @@
1
+ export * from './FilterButtonOverlay';
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _FilterButtonOverlay = require("./FilterButtonOverlay");
7
+ Object.keys(_FilterButtonOverlay).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _FilterButtonOverlay[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _FilterButtonOverlay[key];
14
+ }
15
+ });
16
+ });
@@ -0,0 +1,3 @@
1
+ // @flow strict
2
+
3
+ export * from './FilterButtonOverlay';
@@ -58,9 +58,10 @@ export const ClickableIcon: React$AbstractComponent<
58
58
  ref={ref}
59
59
  >
60
60
  <Icon
61
+ {...props}
61
62
  size={size}
63
+ color={disabled ? TEXT_COLORS.disabled : props.color}
62
64
  className={classNames?.icon || className}
63
- {...props}
64
65
  />
65
66
  </UnstyledButton>
66
67
  );
@@ -42,10 +42,11 @@ const ClickableIcon = /*#__PURE__*/React.forwardRef((_ref, ref) => {
42
42
  [_ClickableIconModule.default.large]: size === 'large'
43
43
  }, classNames?.button),
44
44
  ref: ref
45
- }), /*#__PURE__*/React.createElement(_.Icon, _extends({
45
+ }), /*#__PURE__*/React.createElement(_.Icon, _extends({}, props, {
46
46
  size: size,
47
+ color: disabled ? _Text.TEXT_COLORS.disabled : props.color,
47
48
  className: classNames?.icon || className
48
- }, props)));
49
+ })));
49
50
  });
50
51
  exports.ClickableIcon = ClickableIcon;
51
52
  const CloseIcon = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
@@ -65,9 +65,10 @@ export const ClickableIcon: React$AbstractComponent<
65
65
  ref={ref}
66
66
  >
67
67
  <Icon
68
+ {...props}
68
69
  size={size}
70
+ color={disabled ? TEXT_COLORS.disabled : props.color}
69
71
  className={classNames?.icon || className}
70
- {...props}
71
72
  />
72
73
  </UnstyledButton>
73
74
  );
@@ -54,12 +54,12 @@ button {
54
54
  border-radius: borderRadiusXSmall;
55
55
  }
56
56
 
57
- .button:focus {
57
+ .button:focus-visible:not(:disabled) {
58
58
  box-shadow: borderWidthNone borderWidthNone borderWidthNone
59
59
  borderWidthTertiary colorFocusPrimary;
60
60
  }
61
61
 
62
- .button:hover {
62
+ .button:hover:not(:disabled) {
63
63
  background-color: colorButtonFillGhostPressed;
64
64
  color: colorTextPrimary;
65
65
  }
@@ -100,6 +100,20 @@ export const ICON_DOCS = {
100
100
  },
101
101
  },
102
102
  },
103
+ disabled: {
104
+ description: 'If **true**, the clickable icon is disabled',
105
+ control: {
106
+ type: 'boolean',
107
+ },
108
+ table: {
109
+ type: {
110
+ summary: 'boolean',
111
+ },
112
+ defaultValue: {
113
+ summary: 'false',
114
+ },
115
+ },
116
+ },
103
117
  ariaLabel: {
104
118
  control: {
105
119
  type: 'text',
@@ -114,8 +128,8 @@ export const ICON_DOCS = {
114
128
  },
115
129
  },
116
130
  parameters: {
117
- componentSubtitle: 'Generates a Icon component',
118
131
  docs: {
132
+ subtitle: 'Generates a Icon component',
119
133
  description: {
120
134
  component: `
121
135
  \`\`\`js