@spaced-out/ui-design-system 0.1.4 → 0.1.5

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,18 @@
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.5](https://github.com/spaced-out/ui-design-system/compare/v0.1.4...v0.1.5) (2023-04-04)
6
+
7
+
8
+ ### Features
9
+
10
+ * in context aleart and banner focus states ([9d3144d](https://github.com/spaced-out/ui-design-system/commit/9d3144dad0cc32f21cfd1ed4284b6eb5da99e742))
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * typeahead and dropdown fixes ([fa9d5ed](https://github.com/spaced-out/ui-design-system/commit/fa9d5ed1276fb3381fa71ac2f57c203ca9900dd8))
16
+
5
17
  ### [0.1.4](https://github.com/spaced-out/ui-design-system/compare/v0.1.3...v0.1.4) (2023-04-03)
6
18
 
7
19
 
@@ -27,10 +27,9 @@ const Dropdown = _ref => {
27
27
  menu,
28
28
  onMenuOpen,
29
29
  onMenuClose,
30
- dropdownInputText,
30
+ dropdownInputText = '',
31
31
  ...inputProps
32
32
  } = _ref;
33
- const [inputValue, setInputValue] = React.useState(dropdownInputText || '');
34
33
  const dropdownRef = React.useRef();
35
34
  const {
36
35
  x,
@@ -44,9 +43,6 @@ const Dropdown = _ref => {
44
43
  whileElementsMounted: _reactDom.autoUpdate,
45
44
  middleware: [(0, _reactDom.flip)(), (0, _reactDom.offset)(parseInt(_space.spaceXXSmall))]
46
45
  });
47
- React.useEffect(() => {
48
- setInputValue(dropdownInputText || '');
49
- }, [dropdownInputText]);
50
46
  const onMenuToggle = isOpen => {
51
47
  isOpen ? onMenuOpen && onMenuOpen() : onMenuClose && onMenuClose();
52
48
  };
@@ -67,7 +63,7 @@ const Dropdown = _ref => {
67
63
  boxRef: reference,
68
64
  size: size,
69
65
  placeholder: placeholder,
70
- value: inputValue,
66
+ value: dropdownInputText,
71
67
  classNames: {
72
68
  box: _DropdownModule.default.inputBox
73
69
  }
@@ -45,10 +45,9 @@ export const Dropdown = ({
45
45
  menu,
46
46
  onMenuOpen,
47
47
  onMenuClose,
48
- dropdownInputText,
48
+ dropdownInputText = '',
49
49
  ...inputProps
50
50
  }: DropdownProps): React.Node => {
51
- const [inputValue, setInputValue] = React.useState(dropdownInputText || '');
52
51
  const dropdownRef = React.useRef();
53
52
  const {x, y, reference, floating, strategy} = useFloating({
54
53
  strategy: 'absolute',
@@ -57,10 +56,6 @@ export const Dropdown = ({
57
56
  middleware: [flip(), offset(parseInt(spaceXXSmall))],
58
57
  });
59
58
 
60
- React.useEffect(() => {
61
- setInputValue(dropdownInputText || '');
62
- }, [dropdownInputText]);
63
-
64
59
  const onMenuToggle = (isOpen: boolean) => {
65
60
  isOpen ? onMenuOpen && onMenuOpen() : onMenuClose && onMenuClose();
66
61
  };
@@ -77,7 +72,7 @@ export const Dropdown = ({
77
72
  boxRef={reference}
78
73
  size={size}
79
74
  placeholder={placeholder}
80
- value={inputValue}
75
+ value={dropdownInputText}
81
76
  classNames={{box: css.inputBox}}
82
77
  {...inputProps}
83
78
  iconRightName={isOpen ? 'angle-up' : 'angle-down'}
@@ -8,6 +8,7 @@ var React = _interopRequireWildcard(require("react"));
8
8
  var _typography = require("../../types/typography");
9
9
  var _classify = require("../../utils/classify");
10
10
  var _Icon = require("../Icon");
11
+ var _Link = require("../Link");
11
12
  var _Text = require("../Text");
12
13
  var _Truncate = require("../Truncate");
13
14
  var _InContextAlertModule = _interopRequireDefault(require("./InContextAlert.module.css"));
@@ -110,10 +111,10 @@ const InContextAlert = props => {
110
111
  line: 2
111
112
  }, children)), !!(actionText || dismissable) && /*#__PURE__*/React.createElement("div", {
112
113
  className: (0, _classify.classify)(_InContextAlertModule.default.actionContainer, classNames?.actionContainer)
113
- }, !!actionText && /*#__PURE__*/React.createElement(_Text.ButtonTextExtraSmall, {
114
- className: _InContextAlertModule.default.actionText,
115
- onClick: onAction
116
- }, actionText), !!dismissable && /*#__PURE__*/React.createElement(_Icon.Icon, {
114
+ }, !!actionText && /*#__PURE__*/React.createElement(_Link.Link, {
115
+ onClick: onAction,
116
+ color: "primary"
117
+ }, actionText), !!dismissable && /*#__PURE__*/React.createElement(_Icon.ClickableIcon, {
117
118
  color: _typography.TEXT_COLORS.primary,
118
119
  name: "close",
119
120
  size: "small",
@@ -5,8 +5,9 @@ import * as React from 'react';
5
5
  import {TEXT_COLORS} from '../../types/typography';
6
6
  import {classify} from '../../utils/classify';
7
7
  import type {IconType} from '../Icon';
8
- import {Icon} from '../Icon';
9
- import {ButtonTextExtraSmall, SubTitleExtraSmall} from '../Text';
8
+ import {ClickableIcon, Icon} from '../Icon';
9
+ import {Link} from '../Link';
10
+ import {SubTitleExtraSmall} from '../Text';
10
11
  import {Truncate} from '../Truncate';
11
12
 
12
13
  import css from './InContextAlert.module.css';
@@ -172,15 +173,12 @@ export const InContextAlert = (props: InContextAlertProps): React.Node => {
172
173
  )}
173
174
  >
174
175
  {!!actionText && (
175
- <ButtonTextExtraSmall
176
- className={css.actionText}
177
- onClick={onAction}
178
- >
176
+ <Link onClick={onAction} color="primary">
179
177
  {actionText}
180
- </ButtonTextExtraSmall>
178
+ </Link>
181
179
  )}
182
180
  {!!dismissable && (
183
- <Icon
181
+ <ClickableIcon
184
182
  color={TEXT_COLORS.primary}
185
183
  name="close"
186
184
  size="small"
@@ -65,7 +65,6 @@
65
65
  }
66
66
 
67
67
  .closeIcon {
68
- cursor: pointer;
69
68
  margin-left: auto;
70
69
  }
71
70
 
@@ -75,9 +74,3 @@
75
74
  align-items: center;
76
75
  gap: spaceSmall;
77
76
  }
78
-
79
- .actionText {
80
- cursor: pointer;
81
- text-decoration: underline;
82
- white-space: nowrap;
83
- }
@@ -66,7 +66,7 @@ export type LinkProps = {
66
66
  underline?: boolean,
67
67
  target?: AnchorTarget,
68
68
  href?: string,
69
- onClick?: (SyntheticEvent<HTMLElement>) => mixed,
69
+ onClick?: ?(SyntheticEvent<HTMLElement>) => mixed,
70
70
  tabIndex?: number,
71
71
  disabled?: boolean,
72
72
  ...
@@ -29,11 +29,10 @@ const Typeahead = _ref => {
29
29
  menu,
30
30
  onMenuOpen,
31
31
  onMenuClose,
32
- typeaheadInputText,
32
+ typeaheadInputText = '',
33
33
  ...inputProps
34
34
  } = _ref;
35
35
  const typeaheadRef = React.useRef();
36
- const [inputValue, setInputValue] = React.useState(typeaheadInputText || '');
37
36
  const [filteredOptions, setFilteredOptions] = React.useState(menu?.options);
38
37
  const {
39
38
  x,
@@ -47,28 +46,19 @@ const Typeahead = _ref => {
47
46
  whileElementsMounted: _reactDom.autoUpdate,
48
47
  middleware: [(0, _reactDom.flip)(), (0, _reactDom.offset)(parseInt(_space.spaceXXSmall))]
49
48
  });
50
- const handleSelect = option => {
51
- if (option?.key) {
52
- onSelect && onSelect(option);
53
- setInputValue(option.label);
54
- }
55
- };
56
- React.useEffect(() => {
57
- setInputValue(typeaheadInputText || '');
58
- }, [typeaheadInputText]);
59
49
  const onMenuToggle = isOpen => {
60
50
  isOpen ? onMenuOpen && onMenuOpen() : onMenuClose && onMenuClose();
61
51
  };
62
52
  React.useEffect(() => {
63
53
  const optionsFiltered = menu?.options && menu.options.filter(option => {
64
- if (!option.label || !inputValue) {
54
+ if (!option.label || !typeaheadInputText) {
65
55
  return true;
66
56
  } else {
67
- return option.label.toLowerCase().indexOf(inputValue.toLowerCase()) !== -1;
57
+ return option.label.toLowerCase().indexOf(typeaheadInputText.toLowerCase()) !== -1;
68
58
  }
69
59
  });
70
60
  setFilteredOptions(optionsFiltered || []);
71
- }, [inputValue]);
61
+ }, [typeaheadInputText]);
72
62
  return /*#__PURE__*/React.createElement(_clickAway.ClickAway, {
73
63
  onChange: onMenuToggle
74
64
  }, _ref2 => {
@@ -86,14 +76,13 @@ const Typeahead = _ref => {
86
76
  boxRef: reference,
87
77
  size: size,
88
78
  placeholder: placeholder,
89
- value: inputValue,
79
+ value: typeaheadInputText,
90
80
  classNames: {
91
81
  box: classNames?.box
92
82
  }
93
83
  }, inputProps, {
94
84
  onChange: e => {
95
85
  e.stopPropagation();
96
- setInputValue(e.target.value);
97
86
  onSearch && onSearch(e);
98
87
  if (e.target.value.length > 0) {
99
88
  onOpen();
@@ -102,7 +91,6 @@ const Typeahead = _ref => {
102
91
  }
103
92
  },
104
93
  onClear: _e => {
105
- setInputValue('');
106
94
  onClear?.();
107
95
  }
108
96
  })), isOpen && menu && filteredOptions && !!filteredOptions.length && /*#__PURE__*/React.createElement("div", {
@@ -118,7 +106,7 @@ const Typeahead = _ref => {
118
106
  }, /*#__PURE__*/React.createElement(_Menu.Menu, _extends({}, menu, {
119
107
  options: filteredOptions,
120
108
  onSelect: option => {
121
- handleSelect(option);
109
+ onSelect && onSelect(option);
122
110
  if (!menu.optionsVariant || menu.optionsVariant === 'normal') {
123
111
  clickAway();
124
112
  }
@@ -49,12 +49,10 @@ export const Typeahead = ({
49
49
  menu,
50
50
  onMenuOpen,
51
51
  onMenuClose,
52
- typeaheadInputText,
52
+ typeaheadInputText = '',
53
53
  ...inputProps
54
54
  }: TypeaheadProps): React.Node => {
55
55
  const typeaheadRef = React.useRef();
56
-
57
- const [inputValue, setInputValue] = React.useState(typeaheadInputText || '');
58
56
  const [filteredOptions, setFilteredOptions] = React.useState(menu?.options);
59
57
 
60
58
  const {x, y, reference, floating, strategy} = useFloating({
@@ -64,17 +62,6 @@ export const Typeahead = ({
64
62
  middleware: [flip(), offset(parseInt(spaceXXSmall))],
65
63
  });
66
64
 
67
- const handleSelect = (option?: MenuOption) => {
68
- if (option?.key) {
69
- onSelect && onSelect(option);
70
- setInputValue(option.label);
71
- }
72
- };
73
-
74
- React.useEffect(() => {
75
- setInputValue(typeaheadInputText || '');
76
- }, [typeaheadInputText]);
77
-
78
65
  const onMenuToggle = (isOpen: boolean) => {
79
66
  isOpen ? onMenuOpen && onMenuOpen() : onMenuClose && onMenuClose();
80
67
  };
@@ -83,16 +70,18 @@ export const Typeahead = ({
83
70
  const optionsFiltered =
84
71
  menu?.options &&
85
72
  menu.options.filter((option) => {
86
- if (!option.label || !inputValue) {
73
+ if (!option.label || !typeaheadInputText) {
87
74
  return true;
88
75
  } else {
89
76
  return (
90
- option.label.toLowerCase().indexOf(inputValue.toLowerCase()) !== -1
77
+ option.label
78
+ .toLowerCase()
79
+ .indexOf(typeaheadInputText.toLowerCase()) !== -1
91
80
  );
92
81
  }
93
82
  });
94
83
  setFilteredOptions(optionsFiltered || []);
95
- }, [inputValue]);
84
+ }, [typeaheadInputText]);
96
85
 
97
86
  return (
98
87
  <ClickAway onChange={onMenuToggle}>
@@ -106,12 +95,11 @@ export const Typeahead = ({
106
95
  boxRef={reference}
107
96
  size={size}
108
97
  placeholder={placeholder}
109
- value={inputValue}
98
+ value={typeaheadInputText}
110
99
  classNames={{box: classNames?.box}}
111
100
  {...inputProps}
112
101
  onChange={(e) => {
113
102
  e.stopPropagation();
114
- setInputValue(e.target.value);
115
103
  onSearch && onSearch(e);
116
104
  if (e.target.value.length > 0) {
117
105
  onOpen();
@@ -120,7 +108,6 @@ export const Typeahead = ({
120
108
  }
121
109
  }}
122
110
  onClear={(_e) => {
123
- setInputValue('');
124
111
  onClear?.();
125
112
  }}
126
113
  />
@@ -141,7 +128,7 @@ export const Typeahead = ({
141
128
  {...menu}
142
129
  options={filteredOptions}
143
130
  onSelect={(option) => {
144
- handleSelect(option);
131
+ onSelect && onSelect(option);
145
132
  if (
146
133
  !menu.optionsVariant ||
147
134
  menu.optionsVariant === 'normal'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaced-out/ui-design-system",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "main": "index.js",
5
5
  "description": "Sense UI components library",
6
6
  "author": {