@spaced-out/ui-design-system 0.0.28 → 0.0.30

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 (29) hide show
  1. package/.github/workflows/pages.yml +3 -0
  2. package/CHANGELOG.md +16 -0
  3. package/lib/components/EmptyState/EmptyImages/CalendarEmptyImage.js +98 -0
  4. package/lib/components/EmptyState/EmptyImages/CalendarEmptyImage.js.flow +112 -0
  5. package/lib/components/EmptyState/EmptyImages/DataEmptyImage.js +110 -0
  6. package/lib/components/EmptyState/EmptyImages/DataEmptyImage.js.flow +120 -0
  7. package/lib/components/EmptyState/EmptyImages/FileEmptyImage.js +115 -0
  8. package/lib/components/EmptyState/EmptyImages/FileEmptyImage.js.flow +137 -0
  9. package/lib/components/EmptyState/EmptyImages/MessageEmptyImage.js +60 -0
  10. package/lib/components/EmptyState/EmptyImages/MessageEmptyImage.js.flow +68 -0
  11. package/lib/components/EmptyState/EmptyImages/UploadEmptyImage.js +62 -0
  12. package/lib/components/EmptyState/EmptyImages/UploadEmptyImage.js.flow +71 -0
  13. package/lib/components/EmptyState/EmptyImages/index.js +60 -0
  14. package/lib/components/EmptyState/EmptyImages/index.js.flow +7 -0
  15. package/lib/components/EmptyState/EmptyState.js +42 -0
  16. package/lib/components/EmptyState/EmptyState.js.flow +80 -0
  17. package/lib/components/EmptyState/EmptyState.module.css +30 -0
  18. package/lib/components/EmptyState/index.js +16 -0
  19. package/lib/components/EmptyState/index.js.flow +3 -0
  20. package/lib/components/Menu/Menu.js +2 -2
  21. package/lib/components/Menu/Menu.js.flow +13 -6
  22. package/lib/components/Menu/Menu.module.css +15 -4
  23. package/lib/components/Menu/MenuOptionButton.js +8 -3
  24. package/lib/components/Menu/MenuOptionButton.js.flow +9 -2
  25. package/lib/components/Tooltip/Tooltip.js +22 -3
  26. package/lib/components/Tooltip/Tooltip.js.flow +30 -2
  27. package/lib/components/Tooltip/index.js +11 -7
  28. package/lib/components/Tooltip/index.js.flow +1 -2
  29. package/package.json +1 -1
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _EmptyState = require("./EmptyState");
7
+ Object.keys(_EmptyState).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _EmptyState[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _EmptyState[key];
14
+ }
15
+ });
16
+ });
@@ -0,0 +1,3 @@
1
+ // @flow strict
2
+
3
+ export * from './EmptyState';
@@ -47,11 +47,11 @@ const Menu = props => {
47
47
  isFluid = true
48
48
  } = props;
49
49
  return /*#__PURE__*/React.createElement("div", {
50
- className: (0, _classify.classify)(_MenuModule.default.menuCard, classNames?.wrapper, {
50
+ className: (0, _classify.classify)(_MenuModule.default.menuCard, {
51
51
  [_MenuModule.default.fluid]: isFluid,
52
52
  [_MenuModule.default.medium]: size === 'medium',
53
53
  [_MenuModule.default.small]: size === 'small'
54
- }),
54
+ }, classNames?.wrapper),
55
55
  style: {
56
56
  width
57
57
  }
@@ -20,6 +20,7 @@ export type MenuOption = {
20
20
  iconRight?: string,
21
21
  iconRightType?: IconType,
22
22
  disabled?: boolean,
23
+ optionSize?: MenuSizeTypes,
23
24
  };
24
25
 
25
26
  // Render first available option set
@@ -28,13 +29,15 @@ export type MenuProps = {
28
29
  onSelect?: (option: MenuOption) => mixed,
29
30
  selectedOption?: MenuOption,
30
31
  classNames?: ClassNames,
31
- size?: 'medium' | 'small',
32
+ size?: MenuSizeTypes,
32
33
  width?: string,
33
34
  menuDisabled?: boolean,
34
35
  isFluid?: boolean,
35
36
  ...MenuOptionTypes,
36
37
  };
37
38
 
39
+ export type MenuSizeTypes = 'medium' | 'small';
40
+
38
41
  export type MenuOptionTypes = {
39
42
  options?: Array<MenuOption>,
40
43
  composeOptions?: Array<Array<MenuOption>>,
@@ -83,11 +86,15 @@ export const Menu = (props: MenuProps): React.Node => {
83
86
 
84
87
  return (
85
88
  <div
86
- className={classify(css.menuCard, classNames?.wrapper, {
87
- [css.fluid]: isFluid,
88
- [css.medium]: size === 'medium',
89
- [css.small]: size === 'small',
90
- })}
89
+ className={classify(
90
+ css.menuCard,
91
+ {
92
+ [css.fluid]: isFluid,
93
+ [css.medium]: size === 'medium',
94
+ [css.small]: size === 'small',
95
+ },
96
+ classNames?.wrapper,
97
+ )}
91
98
  style={{width}}
92
99
  >
93
100
  <RenderOption {...props} />
@@ -33,7 +33,8 @@
33
33
  spaceNone,
34
34
  spaceSmall,
35
35
  spaceXSmall,
36
- spaceXXSmall
36
+ spaceXXSmall,
37
+ spaceNone
37
38
  ) from '../../styles/variables/_space.css';
38
39
 
39
40
  @value (
@@ -161,11 +162,21 @@
161
162
  color: colorTextDisabled;
162
163
  }
163
164
 
165
+ .menuDivider {
166
+ padding-top: spaceXSmall;
167
+ padding-bottom: spaceXSmall;
168
+ }
169
+
164
170
  .menuDivider:not(:first-of-type) {
165
171
  border-top: borderWidthPrimary solid colorBorderPrimary;
166
- padding: spaceXSmall;
172
+ padding-top: spaceXSmall;
173
+ padding-bottom: spaceXSmall;
167
174
  }
168
175
 
169
- .menuDivider {
170
- padding: spaceXSmall;
176
+ .menuDivider:first-child {
177
+ padding-top: spaceNone;
178
+ }
179
+
180
+ .menuDivider:last-child {
181
+ padding-bottom: spaceNone;
171
182
  }
@@ -30,13 +30,18 @@ const MenuOptionButton = props => {
30
30
  iconLeftType,
31
31
  iconRight,
32
32
  iconRightType,
33
- disabled
33
+ disabled,
34
+ optionSize
34
35
  } = option;
36
+ const [buttonSize, setButtonSize] = React.useState(optionSize || size);
37
+ React.useEffect(() => {
38
+ setButtonSize(optionSize || size);
39
+ }, [optionSize, size]);
35
40
  return /*#__PURE__*/React.createElement(_Button.UnstyledButton, {
36
41
  className: (0, _classify.classify)(_MenuModule.default.option, {
37
42
  [_MenuModule.default.selected]: key === selectedOption?.key,
38
- [_MenuModule.default.optionSmall]: size === 'small',
39
- [_MenuModule.default.optionMedium]: size === 'medium',
43
+ [_MenuModule.default.optionSmall]: buttonSize === 'small',
44
+ [_MenuModule.default.optionMedium]: buttonSize === 'medium',
40
45
  [_MenuModule.default.disabled]: menuDisabled || disabled,
41
46
  [_MenuModule.default.withIconLeft]: !!iconLeft,
42
47
  [_MenuModule.default.withIconRight]: !!iconRight
@@ -35,13 +35,20 @@ export const MenuOptionButton = (props: MenuOptionProps): React.Node => {
35
35
  iconRight,
36
36
  iconRightType,
37
37
  disabled,
38
+ optionSize,
38
39
  } = option;
40
+ const [buttonSize, setButtonSize] = React.useState(optionSize || size);
41
+
42
+ React.useEffect(() => {
43
+ setButtonSize(optionSize || size);
44
+ }, [optionSize, size]);
45
+
39
46
  return (
40
47
  <UnstyledButton
41
48
  className={classify(css.option, {
42
49
  [css.selected]: key === selectedOption?.key,
43
- [css.optionSmall]: size === 'small',
44
- [css.optionMedium]: size === 'medium',
50
+ [css.optionSmall]: buttonSize === 'small',
51
+ [css.optionMedium]: buttonSize === 'medium',
45
52
  [css.disabled]: menuDisabled || disabled,
46
53
  [css.withIconLeft]: !!iconLeft,
47
54
  [css.withIconRight]: !!iconRight,
@@ -3,12 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Tooltip = void 0;
6
+ exports.Tooltip = exports.DELAY_MOTION_DURATION_TYPES = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
8
  var _reactDomInteractions = require("@floating-ui/react-dom-interactions");
9
+ var MOTION = _interopRequireWildcard(require("../../styles/variables/_motion"));
9
10
  var _space = require("../../styles/variables/_space");
10
11
  var _classify = require("../../utils/classify");
11
12
  var _mergeRefs = require("../../utils/merge-refs");
13
+ var _string = require("../../utils/string");
12
14
  var _Text = require("../Text");
13
15
  var _Truncate = require("../Truncate");
14
16
  var _TooltipModule = _interopRequireDefault(require("./Tooltip.module.css"));
@@ -16,6 +18,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
16
18
  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); }
17
19
  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; }
18
20
  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); }
21
+ const DELAY_MOTION_DURATION_TYPES = Object.freeze({
22
+ none: 'none',
23
+ fast: 'fast',
24
+ normal: 'normal',
25
+ slow: 'slow',
26
+ slower: 'slower',
27
+ slowest: 'slowest'
28
+ });
29
+ exports.DELAY_MOTION_DURATION_TYPES = DELAY_MOTION_DURATION_TYPES;
19
30
  const Tooltip = _ref => {
20
31
  let {
21
32
  classNames,
@@ -24,7 +35,8 @@ const Tooltip = _ref => {
24
35
  body,
25
36
  placement = 'top',
26
37
  bodyMaxLines = 2,
27
- titleMaxLines = 1
38
+ titleMaxLines = 1,
39
+ delayMotionDuration = 'none'
28
40
  } = _ref;
29
41
  const [open, setOpen] = React.useState(false);
30
42
  const {
@@ -41,10 +53,17 @@ const Tooltip = _ref => {
41
53
  middleware: [(0, _reactDomInteractions.offset)(parseInt(_space.spaceXXSmall)), (0, _reactDomInteractions.flip)(), (0, _reactDomInteractions.shift)()],
42
54
  whileElementsMounted: _reactDomInteractions.autoUpdate
43
55
  });
56
+ const motionDurationToken = 'motionDuration' + (0, _string.capitalize)(delayMotionDuration);
57
+ const hoverDelay = parseInt(MOTION[motionDurationToken]) === NaN ? 0 : parseInt(MOTION[motionDurationToken]);
44
58
  const {
45
59
  getReferenceProps,
46
60
  getFloatingProps
47
- } = (0, _reactDomInteractions.useInteractions)([(0, _reactDomInteractions.useHover)(context), (0, _reactDomInteractions.useFocus)(context), (0, _reactDomInteractions.useRole)(context, {
61
+ } = (0, _reactDomInteractions.useInteractions)([(0, _reactDomInteractions.useHover)(context, {
62
+ delay: {
63
+ open: hoverDelay,
64
+ close: 0
65
+ }
66
+ }), (0, _reactDomInteractions.useFocus)(context), (0, _reactDomInteractions.useRole)(context, {
48
67
  role: 'tooltip'
49
68
  }), (0, _reactDomInteractions.useDismiss)(context)]);
50
69
 
@@ -24,9 +24,11 @@ import {
24
24
  useRole,
25
25
  } from '@floating-ui/react-dom-interactions';
26
26
 
27
+ import * as MOTION from '../../styles/variables/_motion';
27
28
  import {spaceNone, spaceXXSmall} from '../../styles/variables/_space';
28
29
  import {classify} from '../../utils/classify';
29
30
  import {mergeRefs} from '../../utils/merge-refs';
31
+ import {capitalize} from '../../utils/string';
30
32
  import {BodyMedium, SubTitleExtraSmall} from '../Text';
31
33
  import {Truncate} from '../Truncate';
32
34
 
@@ -35,6 +37,19 @@ import css from './Tooltip.module.css';
35
37
 
36
38
  type ClassNames = $ReadOnly<{tooltip?: string}>;
37
39
 
40
+ export const DELAY_MOTION_DURATION_TYPES = Object.freeze({
41
+ none: 'none',
42
+ fast: 'fast',
43
+ normal: 'normal',
44
+ slow: 'slow',
45
+ slower: 'slower',
46
+ slowest: 'slowest',
47
+ });
48
+
49
+ export type DelayMotionDurationType = $Values<
50
+ typeof DELAY_MOTION_DURATION_TYPES,
51
+ >;
52
+
38
53
  export type PlacementType =
39
54
  | 'top'
40
55
  | 'top-start'
@@ -52,6 +67,7 @@ export type TooltipProps = {
52
67
  placement?: PlacementType,
53
68
  bodyMaxLines?: number,
54
69
  titleMaxLines?: number,
70
+ delayMotionDuration?: DelayMotionDurationType,
55
71
  // TODO(Nishant): Decide on a type to use
56
72
  // $FlowFixMe
57
73
  children: any,
@@ -65,9 +81,9 @@ export const Tooltip = ({
65
81
  placement = 'top',
66
82
  bodyMaxLines = 2,
67
83
  titleMaxLines = 1,
84
+ delayMotionDuration = 'none',
68
85
  }: TooltipProps): React.Node => {
69
86
  const [open, setOpen] = React.useState(false);
70
-
71
87
  const {x, y, reference, floating, strategy, context} = useFloating({
72
88
  placement,
73
89
  open,
@@ -76,8 +92,20 @@ export const Tooltip = ({
76
92
  whileElementsMounted: autoUpdate,
77
93
  });
78
94
 
95
+ const motionDurationToken =
96
+ 'motionDuration' + capitalize(delayMotionDuration);
97
+ const hoverDelay =
98
+ parseInt(MOTION[motionDurationToken]) === NaN
99
+ ? 0
100
+ : parseInt(MOTION[motionDurationToken]);
101
+
79
102
  const {getReferenceProps, getFloatingProps} = useInteractions([
80
- useHover(context),
103
+ useHover(context, {
104
+ delay: {
105
+ open: hoverDelay,
106
+ close: 0,
107
+ },
108
+ }),
81
109
  useFocus(context),
82
110
  useRole(context, {role: 'tooltip'}),
83
111
  useDismiss(context),
@@ -3,10 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "Tooltip", {
7
- enumerable: true,
8
- get: function () {
9
- return _Tooltip.Tooltip;
10
- }
11
- });
12
- var _Tooltip = require("./Tooltip");
6
+ var _Tooltip = require("./Tooltip");
7
+ Object.keys(_Tooltip).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _Tooltip[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _Tooltip[key];
14
+ }
15
+ });
16
+ });
@@ -1,4 +1,3 @@
1
1
  // @flow strict
2
2
 
3
- export type {PlacementType, TooltipProps} from './Tooltip';
4
- export {Tooltip} from './Tooltip';
3
+ export * from './Tooltip';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaced-out/ui-design-system",
3
- "version": "0.0.28",
3
+ "version": "0.0.30",
4
4
  "main": "index.js",
5
5
  "description": "Sense UI components library",
6
6
  "author": {