@spaced-out/ui-design-system 0.1.12 → 0.1.13

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.1.13](https://github.com/spaced-out/ui-design-system/compare/v0.1.12...v0.1.13) (2023-04-14)
6
+
7
+
8
+ ### Features
9
+
10
+ * added escape button capabilities to click-away ([#99](https://github.com/spaced-out/ui-design-system/issues/99)) ([79cff71](https://github.com/spaced-out/ui-design-system/commit/79cff71912d3e92d9ea12c95f543aa3c623df143))
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * docs update ([78756c0](https://github.com/spaced-out/ui-design-system/commit/78756c066afdcd2574e8eaa70db94c3ddc638cf2))
16
+ * docs update ([10ac5a6](https://github.com/spaced-out/ui-design-system/commit/10ac5a69d98744f16540efb61d9b1fdce5a2620f))
17
+ * fixed elevation story ([ef5cf99](https://github.com/spaced-out/ui-design-system/commit/ef5cf99f3655edb606ec6141701f596759cb0713))
18
+ * removed file extensions ([1e9b6fa](https://github.com/spaced-out/ui-design-system/commit/1e9b6fade3557f55baf9ba37c6dbc49bb180b7bc))
19
+ * stories docs reuired optional props fix ([bdf9592](https://github.com/spaced-out/ui-design-system/commit/bdf959298f5c77890ac3f7c62c74960b4a6ce738))
20
+ * support button classnames in button dropdown ([#100](https://github.com/spaced-out/ui-design-system/issues/100)) ([26c68f7](https://github.com/spaced-out/ui-design-system/commit/26c68f7f8aa1264cf1868bd250021767b888f4d2))
21
+ * truncate word break changes ([#98](https://github.com/spaced-out/ui-design-system/issues/98)) ([0ff5cc1](https://github.com/spaced-out/ui-design-system/commit/0ff5cc1cc730350e449d9d42015b57a46ad5a302))
22
+
5
23
  ### [0.1.12](https://github.com/spaced-out/ui-design-system/compare/v0.1.11...v0.1.12) (2023-04-12)
6
24
 
7
25
 
@@ -6,6 +6,9 @@
6
6
  "card": {
7
7
  "value": "{baseElevation.4.value}"
8
8
  },
9
+ "tooltip": {
10
+ "value": "{baseElevation.4.value}"
11
+ },
9
12
  "menu": {
10
13
  "value": "{baseElevation.12.value}"
11
14
  },
@@ -17,9 +20,6 @@
17
20
  },
18
21
  "toast": {
19
22
  "value": "{baseElevation.60.value}"
20
- },
21
- "tooltip": {
22
- "value": "{baseElevation.4.value}"
23
23
  }
24
24
  }
25
25
  }
@@ -86,7 +86,8 @@ const ButtonDropdown = /*#__PURE__*/React.forwardRef((_ref, forwardRef) => {
86
86
  },
87
87
  isFluid: isFluid,
88
88
  classNames: {
89
- wrapper: classNames?.buttonWrapper
89
+ wrapper: classNames?.buttonWrapper,
90
+ icon: classNames?.buttonIcon
90
91
  }
91
92
  }), children), isOpen && menu && /*#__PURE__*/React.createElement("div", {
92
93
  onClickCapture: cancelNext,
@@ -39,6 +39,7 @@ export type AnchorType = $Values<typeof ANCHOR_POSITION_TYPE>;
39
39
  type ClassNames = $ReadOnly<{
40
40
  buttonWrapper?: string,
41
41
  dropdownContainer?: string,
42
+ buttonIcon?: string,
42
43
  }>;
43
44
 
44
45
  export type ButtonDropdownProps = {
@@ -117,7 +118,10 @@ export const ButtonDropdown: React$AbstractComponent<
117
118
  onOpen();
118
119
  }}
119
120
  isFluid={isFluid}
120
- classNames={{wrapper: classNames?.buttonWrapper}}
121
+ classNames={{
122
+ wrapper: classNames?.buttonWrapper,
123
+ icon: classNames?.buttonIcon,
124
+ }}
121
125
  >
122
126
  {children}
123
127
  </Button>
@@ -44,7 +44,7 @@ type InContextAlertBaseProps = {
44
44
 
45
45
  export type InContextAlertProps = {
46
46
  ...InContextAlertBaseProps,
47
- semantic: AlertSemanticType,
47
+ semantic?: AlertSemanticType,
48
48
  leftIconName?: string,
49
49
  leftIconType?: IconType,
50
50
  };
@@ -13,7 +13,7 @@ import css from './OptionButton.module.css';
13
13
 
14
14
  export type OptionButtonProps = {
15
15
  ...ButtonProps,
16
- menu: MenuProps,
16
+ menu?: MenuProps,
17
17
  anchorPosition?: AnchorType,
18
18
  onOptionSelect?: (option: MenuOption) => mixed,
19
19
  onButtonClick?: ?(SyntheticEvent<HTMLElement>) => mixed,
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.PaginationItem = exports.PaginationButton = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
8
  var _classify = _interopRequireDefault(require("../../utils/classify"));
9
- var _Button = require("../Button/Button.js");
10
- var _Text = require("../Text/Text.js");
9
+ var _Button = require("../Button");
10
+ var _Text = require("../Text");
11
11
  var _PaginationModule = _interopRequireDefault(require("./Pagination.module.css"));
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
  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); }
@@ -3,10 +3,10 @@
3
3
  import * as React from 'react';
4
4
 
5
5
  import classify from '../../utils/classify';
6
- import {Button} from '../Button/Button.js';
7
- import {ButtonTextSmall} from '../Text/Text.js';
6
+ import {Button} from '../Button';
7
+ import {ButtonTextSmall} from '../Text';
8
8
 
9
- import type {PaginationItemProps} from './Pagination.js';
9
+ import type {PaginationItemProps} from './Pagination';
10
10
 
11
11
  import css from './Pagination.module.css';
12
12
 
@@ -15,12 +15,15 @@ const BaseTruncate = /*#__PURE__*/React.forwardRef((_ref, ref) => {
15
15
  let {
16
16
  children,
17
17
  line = 1,
18
- showFullTextOnHover = false
18
+ showFullTextOnHover = false,
19
+ wordBreak = 'break-all',
20
+ className
19
21
  } = _ref;
20
22
  return /*#__PURE__*/React.createElement("span", {
21
- className: (0, _classify.classify)(_TruncateModule.default.truncateLineClamp),
23
+ className: (0, _classify.classify)(_TruncateModule.default.truncateLineClamp, className),
22
24
  style: {
23
- WebkitLineClamp: `${line}`
25
+ '--line-clamp': line,
26
+ '--word-break': wordBreak
24
27
  },
25
28
  title: showFullTextOnHover ? children : '',
26
29
  ref: ref
@@ -31,7 +34,9 @@ const Truncate = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
31
34
  let {
32
35
  children,
33
36
  line = 1,
34
- showFullTextOnHover = false
37
+ showFullTextOnHover = false,
38
+ wordBreak = 'break-all',
39
+ className: truncateClassName
35
40
  } = _ref2;
36
41
  const arrayChildren = React.Children.toArray(children);
37
42
  if (arrayChildren.length) {
@@ -42,9 +47,10 @@ const Truncate = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
42
47
  children
43
48
  } = child.props;
44
49
  return /*#__PURE__*/React.cloneElement(child, {
45
- className: (0, _classify.classify)(_TruncateModule.default.truncateLineClamp, className),
50
+ className: (0, _classify.classify)(_TruncateModule.default.truncateLineClamp, className, truncateClassName),
46
51
  style: {
47
- WebkitLineClamp: `${line}`
52
+ '--line-clamp': line,
53
+ '--word-break': wordBreak
48
54
  },
49
55
  title: showFullTextOnHover ? children : '',
50
56
  ref
@@ -53,7 +59,9 @@ const Truncate = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
53
59
  return /*#__PURE__*/React.createElement(BaseTruncate, {
54
60
  line: line,
55
61
  showFullTextOnHover: showFullTextOnHover,
56
- ref: ref
62
+ ref: ref,
63
+ wordBreak: wordBreak,
64
+ className: truncateClassName
57
65
  }, children);
58
66
  }
59
67
  return null;
@@ -11,6 +11,8 @@ export type TruncateProps = {
11
11
  children?: React.Node,
12
12
  line?: number,
13
13
  showFullTextOnHover?: boolean,
14
+ wordBreak?: string,
15
+ className?: string,
14
16
  };
15
17
 
16
18
  export const BaseTruncate: React$AbstractComponent<
@@ -18,12 +20,18 @@ export const BaseTruncate: React$AbstractComponent<
18
20
  HTMLSpanElement,
19
21
  > = React.forwardRef<TruncateProps, HTMLSpanElement>(
20
22
  (
21
- {children, line = 1, showFullTextOnHover = false}: TruncateProps,
23
+ {
24
+ children,
25
+ line = 1,
26
+ showFullTextOnHover = false,
27
+ wordBreak = 'break-all',
28
+ className,
29
+ }: TruncateProps,
22
30
  ref,
23
31
  ): React.Node => (
24
32
  <span
25
- className={classify(css.truncateLineClamp)}
26
- style={{WebkitLineClamp: `${line}`}}
33
+ className={classify(css.truncateLineClamp, className)}
34
+ style={{'--line-clamp': line, '--word-break': wordBreak}}
27
35
  title={showFullTextOnHover ? children : ''}
28
36
  ref={ref}
29
37
  >
@@ -35,7 +43,13 @@ export const BaseTruncate: React$AbstractComponent<
35
43
  export const Truncate: React$AbstractComponent<TruncateProps, HTMLSpanElement> =
36
44
  React.forwardRef<TruncateProps, HTMLSpanElement>(
37
45
  (
38
- {children, line = 1, showFullTextOnHover = false}: TruncateProps,
46
+ {
47
+ children,
48
+ line = 1,
49
+ showFullTextOnHover = false,
50
+ wordBreak = 'break-all',
51
+ className: truncateClassName,
52
+ }: TruncateProps,
39
53
  ref,
40
54
  ): React.Node => {
41
55
  const arrayChildren = React.Children.toArray(children);
@@ -45,8 +59,12 @@ export const Truncate: React$AbstractComponent<TruncateProps, HTMLSpanElement> =
45
59
  const {className, children} = child.props;
46
60
 
47
61
  return React.cloneElement(child, {
48
- className: classify(css.truncateLineClamp, className),
49
- style: {WebkitLineClamp: `${line}`},
62
+ className: classify(
63
+ css.truncateLineClamp,
64
+ className,
65
+ truncateClassName,
66
+ ),
67
+ style: {'--line-clamp': line, '--word-break': wordBreak},
50
68
  title: showFullTextOnHover ? children : '',
51
69
  ref,
52
70
  });
@@ -56,6 +74,8 @@ export const Truncate: React$AbstractComponent<TruncateProps, HTMLSpanElement> =
56
74
  line={line}
57
75
  showFullTextOnHover={showFullTextOnHover}
58
76
  ref={ref}
77
+ wordBreak={wordBreak}
78
+ className={truncateClassName}
59
79
  >
60
80
  {children}
61
81
  </BaseTruncate>
@@ -1,5 +1,3 @@
1
1
  .truncateLineClamp {
2
- display: -webkit-box;
3
- -webkit-box-orient: vertical;
4
- overflow: hidden;
2
+ composes: truncate from '../../styles/typography.module.css';
5
3
  }
@@ -3,7 +3,7 @@
3
3
  import type {
4
4
  PaginationBaseProps,
5
5
  PaginationItemProps,
6
- } from '../components/Pagination/Pagination.js';
6
+ } from '../components/Pagination';
7
7
  import {range} from '../utils/helpers';
8
8
 
9
9
 
@@ -233,9 +233,13 @@
233
233
  }
234
234
 
235
235
  .truncate {
236
- white-space: nowrap;
236
+ --line-clamp: 1;
237
+ --word-break: break-all;
238
+ -webkit-line-clamp: var(--line-clamp);
239
+ display: -webkit-box;
240
+ -webkit-box-orient: vertical;
237
241
  overflow: hidden;
238
- text-overflow: ellipsis;
242
+ word-break: var(--word-break);
239
243
  }
240
244
 
241
245
  .highlightText {
@@ -2,6 +2,8 @@
2
2
 
3
3
  @value elevationCard: 4;
4
4
 
5
+ @value elevationTooltip: 4;
6
+
5
7
  @value elevationMenu: 12;
6
8
 
7
9
  @value elevationBackdrop: 40;
@@ -9,5 +11,3 @@
9
11
  @value elevationModal: 40;
10
12
 
11
13
  @value elevationToast: 60;
12
-
13
- @value elevationTooltip: 4;
@@ -9,6 +9,8 @@ const elevationNone = '0';
9
9
  exports.elevationNone = elevationNone;
10
10
  const elevationCard = '4';
11
11
  exports.elevationCard = elevationCard;
12
+ const elevationTooltip = '4';
13
+ exports.elevationTooltip = elevationTooltip;
12
14
  const elevationMenu = '12';
13
15
  exports.elevationMenu = elevationMenu;
14
16
  const elevationBackdrop = '40';
@@ -16,6 +18,4 @@ exports.elevationBackdrop = elevationBackdrop;
16
18
  const elevationModal = '40';
17
19
  exports.elevationModal = elevationModal;
18
20
  const elevationToast = '60';
19
- exports.elevationToast = elevationToast;
20
- const elevationTooltip = '4';
21
- exports.elevationTooltip = elevationTooltip;
21
+ exports.elevationToast = elevationToast;
@@ -4,6 +4,8 @@ export const elevationNone = '0';
4
4
 
5
5
  export const elevationCard = '4';
6
6
 
7
+ export const elevationTooltip = '4';
8
+
7
9
  export const elevationMenu = '12';
8
10
 
9
11
  export const elevationBackdrop = '40';
@@ -11,5 +13,3 @@ export const elevationBackdrop = '40';
11
13
  export const elevationModal = '40';
12
14
 
13
15
  export const elevationToast = '60';
14
-
15
- export const elevationTooltip = '4';
@@ -49,6 +49,11 @@ class ClickAway extends React.Component {
49
49
  }, this.handleOnChange);
50
50
  }
51
51
  });
52
+ _defineProperty(this, "handleCloseOnEscapeKeypress", evt => {
53
+ if (evt?.key === 'Escape') {
54
+ this.forceClose();
55
+ }
56
+ });
52
57
  _defineProperty(this, "forceClose", () => {
53
58
  this.setState({
54
59
  isOpen: false
@@ -74,13 +79,18 @@ class ClickAway extends React.Component {
74
79
  if (prevState.isOpen !== isOpen) {
75
80
  if (this.state.isOpen) {
76
81
  window.document.addEventListener('click', this.handleCloseClick);
82
+ if (this.props.closeOnEscapeKeypress) {
83
+ window.document.addEventListener('keyup', this.handleCloseOnEscapeKeypress);
84
+ }
77
85
  } else {
78
86
  window.document.removeEventListener('click', this.handleCloseClick);
87
+ window.document.removeEventListener('keyup', this.handleCloseOnEscapeKeypress);
79
88
  }
80
89
  }
81
90
  }
82
91
  componentWillUnmount() {
83
92
  window.document.removeEventListener('click', this.handleCloseClick);
93
+ window.document.removeEventListener('keyup', this.handleCloseOnEscapeKeypress);
84
94
  }
85
95
  render() {
86
96
  const {
@@ -106,5 +116,6 @@ class ClickAway extends React.Component {
106
116
  }
107
117
  exports.ClickAway = ClickAway;
108
118
  _defineProperty(ClickAway, "defaultProps", {
109
- shouldCancel: () => false
119
+ shouldCancel: () => false,
120
+ closeOnEscapeKeypress: true
110
121
  });
@@ -17,6 +17,7 @@ export type ChildProps = {
17
17
  };
18
18
 
19
19
  type ClickAwayProps = {
20
+ closeOnEscapeKeypress?: boolean,
20
21
  children: (props: ChildProps) => React.Node,
21
22
  shouldCancel: (event: MouseEvent) => boolean,
22
23
  onChange?: (isOpen: boolean) => mixed,
@@ -31,9 +32,13 @@ type ClickAwayState = {
31
32
  // TODO(Nishant): Make this a functional component
32
33
 
33
34
  export class ClickAway extends React.Component<ClickAwayProps, ClickAwayState> {
34
- static defaultProps: {shouldCancel: () => boolean} = {
35
- shouldCancel: () => false,
36
- };
35
+ static defaultProps: {
36
+ shouldCancel: () => boolean,
37
+ closeOnEscapeKeypress?: boolean,
38
+ } = {
39
+ shouldCancel: () => false,
40
+ closeOnEscapeKeypress: true,
41
+ };
37
42
 
38
43
  state: ClickAwayState = {
39
44
  isOpen: false,
@@ -58,14 +63,28 @@ export class ClickAway extends React.Component<ClickAwayProps, ClickAwayState> {
58
63
  if (prevState.isOpen !== isOpen) {
59
64
  if (this.state.isOpen) {
60
65
  window.document.addEventListener('click', this.handleCloseClick);
66
+ if (this.props.closeOnEscapeKeypress) {
67
+ window.document.addEventListener(
68
+ 'keyup',
69
+ this.handleCloseOnEscapeKeypress,
70
+ );
71
+ }
61
72
  } else {
62
73
  window.document.removeEventListener('click', this.handleCloseClick);
74
+ window.document.removeEventListener(
75
+ 'keyup',
76
+ this.handleCloseOnEscapeKeypress,
77
+ );
63
78
  }
64
79
  }
65
80
  }
66
81
 
67
82
  componentWillUnmount() {
68
83
  window.document.removeEventListener('click', this.handleCloseClick);
84
+ window.document.removeEventListener(
85
+ 'keyup',
86
+ this.handleCloseOnEscapeKeypress,
87
+ );
69
88
  }
70
89
 
71
90
  render(): React.Node {
@@ -115,6 +134,14 @@ export class ClickAway extends React.Component<ClickAwayProps, ClickAwayState> {
115
134
  }
116
135
  };
117
136
 
137
+ handleCloseOnEscapeKeypress: (
138
+ evt?: SyntheticKeyboardEvent<EventTarget>,
139
+ ) => void = (evt?: SyntheticKeyboardEvent<EventTarget>) => {
140
+ if (evt?.key === 'Escape') {
141
+ this.forceClose();
142
+ }
143
+ };
144
+
118
145
  forceClose: () => void = () => {
119
146
  this.setState({isOpen: false}, this.handleOnChange);
120
147
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaced-out/ui-design-system",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "main": "index.js",
5
5
  "description": "Sense UI components library",
6
6
  "author": {