@spaced-out/ui-design-system 0.3.39-beta.0 → 0.3.40-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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,25 @@
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.3.40-beta.0](https://github.com/spaced-out/ui-design-system/compare/v0.3.39...v0.3.40-beta.0) (2025-05-14)
6
+
7
+
8
+ ### Features
9
+
10
+ * [GDS-512] simple and generic typeahead story for paginated api calls & useDebounce hook ([#344](https://github.com/spaced-out/ui-design-system/issues/344)) ([c5b917d](https://github.com/spaced-out/ui-design-system/commit/c5b917d963031f75ca3c73b4bc06f89d224ce0c1))
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * fixes TLI story ([4e3d6d4](https://github.com/spaced-out/ui-design-system/commit/4e3d6d46852f125553127d3d1d5b6e5d746486a1))
16
+
17
+ ### [0.3.39](https://github.com/spaced-out/ui-design-system/compare/v0.3.39-beta.0...v0.3.39) (2025-05-13)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * revert react 19 ([#341](https://github.com/spaced-out/ui-design-system/issues/341)) ([2132e96](https://github.com/spaced-out/ui-design-system/commit/2132e969e50675e14070a168721a5a27f736552f))
23
+
5
24
  ### [0.3.39-beta.0](https://github.com/spaced-out/ui-design-system/compare/v0.3.38...v0.3.39-beta.0) (2025-05-13)
6
25
 
7
26
 
@@ -165,6 +165,7 @@ export const Chip: React$AbstractComponent<ChipProps, HTMLDivElement> =
165
165
  type={iconType}
166
166
  size="small"
167
167
  ariaLabel="Dismiss"
168
+ disabled={disabled}
168
169
  onClick={(event) => {
169
170
  event.stopPropagation();
170
171
 
@@ -107,6 +107,7 @@ const Chip = /*#__PURE__*/React.forwardRef((_ref, ref) => {
107
107
  type: iconType,
108
108
  size: "small",
109
109
  ariaLabel: "Dismiss",
110
+ disabled: disabled,
110
111
  onClick: event => {
111
112
  event.stopPropagation();
112
113
  if (!disabled && onDismiss) {
@@ -166,6 +166,7 @@ export const Chip: React$AbstractComponent<ChipProps, HTMLDivElement> =
166
166
  type={iconType}
167
167
  size="small"
168
168
  ariaLabel="Dismiss"
169
+ disabled={disabled}
169
170
  onClick={(event) => {
170
171
  event.stopPropagation();
171
172
  if (!disabled && onDismiss) {
@@ -12,6 +12,7 @@ type ClassNames = $ReadOnly<{
12
12
  button?: string;
13
13
  }>;
14
14
  export type ClickableIconProps = IconProps & {
15
+ disabled?: boolean;
15
16
  classNames?: ClassNames;
16
17
  };
17
18
  export const ClickableIcon: React$AbstractComponent<
@@ -26,6 +27,7 @@ export const ClickableIcon: React$AbstractComponent<
26
27
  className,
27
28
  // Deprecated for Clickable Icon
28
29
  classNames,
30
+ disabled,
29
31
  ...props
30
32
  }: ClickableIconProps,
31
33
  ref,
@@ -41,6 +43,7 @@ export const ClickableIcon: React$AbstractComponent<
41
43
  <UnstyledButton
42
44
  {...props}
43
45
  onClick={onClick}
46
+ disabled={disabled}
44
47
  onKeyDown={onKeyDownHandler}
45
48
  ariaLabel={ariaLabel}
46
49
  className={classify(
@@ -74,6 +77,7 @@ export type CloseIconProps = {
74
77
  className?: string;
75
78
  // Deprecated for Clickable Icon
76
79
  ariaLabel?: string;
80
+ disabled?: boolean;
77
81
  classNames?: ClassNames;
78
82
  };
79
83
  export const CloseIcon: React$AbstractComponent<
@@ -22,6 +22,7 @@ const ClickableIcon = /*#__PURE__*/React.forwardRef((_ref, ref) => {
22
22
  className,
23
23
  // Deprecated for Clickable Icon
24
24
  classNames,
25
+ disabled,
25
26
  ...props
26
27
  } = _ref;
27
28
  const onKeyDownHandler = e => {
@@ -32,6 +33,7 @@ const ClickableIcon = /*#__PURE__*/React.forwardRef((_ref, ref) => {
32
33
  };
33
34
  return /*#__PURE__*/React.createElement(_Button.UnstyledButton, _extends({}, props, {
34
35
  onClick: onClick,
36
+ disabled: disabled,
35
37
  onKeyDown: onKeyDownHandler,
36
38
  ariaLabel: ariaLabel,
37
39
  className: (0, _classify.default)(_ClickableIconModule.default.button, {
@@ -20,6 +20,7 @@ type ClassNames = $ReadOnly<{
20
20
 
21
21
  export type ClickableIconProps = {
22
22
  ...IconProps,
23
+ disabled?: boolean,
23
24
  classNames?: ClassNames,
24
25
  };
25
26
 
@@ -34,6 +35,7 @@ export const ClickableIcon: React$AbstractComponent<
34
35
  onClick,
35
36
  className, // Deprecated for Clickable Icon
36
37
  classNames,
38
+ disabled,
37
39
  ...props
38
40
  }: ClickableIconProps,
39
41
  ref,
@@ -48,6 +50,7 @@ export const ClickableIcon: React$AbstractComponent<
48
50
  <UnstyledButton
49
51
  {...props}
50
52
  onClick={onClick}
53
+ disabled={disabled}
51
54
  onKeyDown={onKeyDownHandler}
52
55
  ariaLabel={ariaLabel}
53
56
  className={classify(
@@ -78,6 +81,7 @@ export type CloseIconProps = {
78
81
  onClick?: ?(SyntheticEvent<HTMLElement>) => mixed,
79
82
  className?: string, // Deprecated for Clickable Icon
80
83
  ariaLabel?: string,
84
+ disabled?: boolean,
81
85
  classNames?: ClassNames,
82
86
  };
83
87
 
@@ -29,7 +29,6 @@
29
29
  width: size42;
30
30
  align-items: center;
31
31
  justify-content: center;
32
- align-items: center;
33
32
  margin-left: calc(size42 * -1);
34
33
  }
35
34
 
@@ -7,6 +7,7 @@ import {
7
7
  offset, // $FlowFixMe[untyped-import]
8
8
  useFloating,
9
9
  } from '@floating-ui/react';
10
+ import without from 'lodash/without';
10
11
  import {sizeFluid} from '../../styles/variables/_size';
11
12
  import {spaceNone, spaceXXSmall} from '../../styles/variables/_space';
12
13
  import {TEXT_COLORS} from '../../types/typography';
@@ -19,6 +20,7 @@ import {
19
20
  getFirstOptionFromGroup,
20
21
  } from '../../utils/token-list-input/token-list-input';
21
22
  import {ANCHOR_POSITION_TYPE, STRATEGY_TYPE} from '../ButtonDropdown';
23
+ import {CircularLoader} from '../CircularLoader';
22
24
  import {Icon} from '../Icon';
23
25
  import type {InputProps} from '../Input';
24
26
  import type {BaseMenuProps} from '../Menu';
@@ -50,6 +52,7 @@ export type Props<T> = {
50
52
  clickAwayRef?: ClickAwayRefType;
51
53
  disabled?: boolean;
52
54
  // disables user interaction with the input
55
+ error?: boolean;
53
56
  errorText?: string;
54
57
  focusOnMount?: boolean;
55
58
  helperText?: string;
@@ -57,6 +60,7 @@ export type Props<T> = {
57
60
  inputPlaceholder?: string;
58
61
  limit?: number;
59
62
  // maximum number of values
63
+ isLoading?: boolean;
60
64
  locked?: boolean;
61
65
  onChange: (values: Array<T>) => unknown;
62
66
  // an onChange handler
@@ -79,12 +83,14 @@ export function TokenListInput<T>(props: Props<T>): React.ReactNode {
79
83
  classNames,
80
84
  clickAwayRef,
81
85
  disabled = false,
86
+ error,
82
87
  errorText,
83
88
  focusOnMount,
84
89
  helperText,
85
90
  inputValue = '',
86
91
  inputPlaceholder = '',
87
92
  limit = DEFAULT_LIMIT_VALUE,
93
+ isLoading,
88
94
  locked,
89
95
  onChange,
90
96
  menu,
@@ -144,6 +150,13 @@ export function TokenListInput<T>(props: Props<T>): React.ReactNode {
144
150
  }, 0);
145
151
  };
146
152
 
153
+ const removeValue = (value: T) => {
154
+ !disabled && !locked && onChange(without(values, value));
155
+ setTimeout(() => {
156
+ inputRef.current && inputRef.current.focus();
157
+ }, 0);
158
+ };
159
+
147
160
  const hideInput = values.length >= limit || disabled || locked;
148
161
 
149
162
  const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
@@ -227,7 +240,7 @@ export function TokenListInput<T>(props: Props<T>): React.ReactNode {
227
240
  [css.inputDisabled]: disabled,
228
241
  [css.medium]: size === 'medium',
229
242
  [css.small]: size === 'small',
230
- [css.withError]: errorText,
243
+ [css.withError]: error,
231
244
  [css.inputLocked]: locked,
232
245
  },
233
246
  classNames?.box,
@@ -239,7 +252,7 @@ export function TokenListInput<T>(props: Props<T>): React.ReactNode {
239
252
  resolveTokenValue={resolveTokenValue}
240
253
  disabled={disabled}
241
254
  locked={locked}
242
- onChange={onChange}
255
+ onDismiss={removeValue}
243
256
  />
244
257
  {!hideInput && (
245
258
  <input
@@ -271,6 +284,11 @@ export function TokenListInput<T>(props: Props<T>): React.ReactNode {
271
284
  autoComplete="off"
272
285
  />
273
286
  )}
287
+ {isLoading && (
288
+ <div className={css.loaderContainer}>
289
+ <CircularLoader size="small" colorToken="colorFillPrimary" />
290
+ </div>
291
+ )}
274
292
  {locked && (
275
293
  <Icon
276
294
  name="lock"
@@ -282,7 +300,7 @@ export function TokenListInput<T>(props: Props<T>): React.ReactNode {
282
300
  </div>
283
301
  {!isOpen && (Boolean(helperText) || errorText) && (
284
302
  <div className={css.footerTextContainer}>
285
- {errorText ? (
303
+ {error && errorText ? (
286
304
  <BodySmall color={TEXT_COLORS.danger}>{errorText}</BodySmall>
287
305
  ) : typeof helperText === 'string' ? (
288
306
  <BodySmall color={TEXT_COLORS.secondary}>
@@ -7,6 +7,7 @@ exports.DEFAULT_LIMIT_VALUE = void 0;
7
7
  exports.TokenListInput = TokenListInput;
8
8
  var React = _interopRequireWildcard(require("react"));
9
9
  var _react2 = require("@floating-ui/react");
10
+ var _without = _interopRequireDefault(require("lodash/without"));
10
11
  var _size = require("../../styles/variables/_size");
11
12
  var _space = require("../../styles/variables/_space");
12
13
  var _typography = require("../../types/typography");
@@ -15,6 +16,7 @@ var _clickAway = require("../../utils/click-away");
15
16
  var _mergeRefs = require("../../utils/merge-refs");
16
17
  var _tokenListInput = require("../../utils/token-list-input/token-list-input");
17
18
  var _ButtonDropdown = require("../ButtonDropdown");
19
+ var _CircularLoader = require("../CircularLoader");
18
20
  var _Icon = require("../Icon");
19
21
  var _Menu = require("../Menu");
20
22
  var _Text = require("../Text");
@@ -31,12 +33,14 @@ function TokenListInput(props) {
31
33
  classNames,
32
34
  clickAwayRef,
33
35
  disabled = false,
36
+ error,
34
37
  errorText,
35
38
  focusOnMount,
36
39
  helperText,
37
40
  inputValue = '',
38
41
  inputPlaceholder = '',
39
42
  limit = DEFAULT_LIMIT_VALUE,
43
+ isLoading,
40
44
  locked,
41
45
  onChange,
42
46
  menu,
@@ -95,6 +99,12 @@ function TokenListInput(props) {
95
99
  inputRef.current && inputRef.current.focus();
96
100
  }, 0);
97
101
  };
102
+ const removeValue = value => {
103
+ !disabled && !locked && onChange((0, _without.default)(values, value));
104
+ setTimeout(() => {
105
+ inputRef.current && inputRef.current.focus();
106
+ }, 0);
107
+ };
98
108
  const hideInput = values.length >= limit || disabled || locked;
99
109
  const handleInputKeyDown = event => {
100
110
  const value = event.currentTarget.value;
@@ -169,7 +179,7 @@ function TokenListInput(props) {
169
179
  [_TokenListInputModule.default.inputDisabled]: disabled,
170
180
  [_TokenListInputModule.default.medium]: size === 'medium',
171
181
  [_TokenListInputModule.default.small]: size === 'small',
172
- [_TokenListInputModule.default.withError]: errorText,
182
+ [_TokenListInputModule.default.withError]: error,
173
183
  [_TokenListInputModule.default.inputLocked]: locked
174
184
  }, classNames?.box),
175
185
  ref: (0, _mergeRefs.mergeRefs)([refs.setReference, triggerRef])
@@ -178,7 +188,7 @@ function TokenListInput(props) {
178
188
  resolveTokenValue: resolveTokenValue,
179
189
  disabled: disabled,
180
190
  locked: locked,
181
- onChange: onChange
191
+ onDismiss: removeValue
182
192
  }), !hideInput && /*#__PURE__*/React.createElement("input", _extends({}, inputProps, {
183
193
  ref: inputRef,
184
194
  type: "text",
@@ -198,6 +208,11 @@ function TokenListInput(props) {
198
208
  [_TokenListInputModule.default.inputSmall]: size === 'small'
199
209
  }, classNames?.input),
200
210
  autoComplete: "off"
211
+ })), isLoading && /*#__PURE__*/React.createElement("div", {
212
+ className: _TokenListInputModule.default.loaderContainer
213
+ }, /*#__PURE__*/React.createElement(_CircularLoader.CircularLoader, {
214
+ size: "small",
215
+ colorToken: "colorFillPrimary"
201
216
  })), locked && /*#__PURE__*/React.createElement(_Icon.Icon, {
202
217
  name: "lock",
203
218
  color: disabled ? 'disabled' : 'secondary',
@@ -205,7 +220,7 @@ function TokenListInput(props) {
205
220
  className: _TokenListInputModule.default.lockIcon
206
221
  })), !isOpen && (Boolean(helperText) || errorText) && /*#__PURE__*/React.createElement("div", {
207
222
  className: _TokenListInputModule.default.footerTextContainer
208
- }, errorText ? /*#__PURE__*/React.createElement(_Text.BodySmall, {
223
+ }, error && errorText ? /*#__PURE__*/React.createElement(_Text.BodySmall, {
209
224
  color: _typography.TEXT_COLORS.danger
210
225
  }, errorText) : typeof helperText === 'string' ? /*#__PURE__*/React.createElement(_Text.BodySmall, {
211
226
  color: _typography.TEXT_COLORS.secondary
@@ -11,6 +11,7 @@ import {
11
11
  // $FlowFixMe[untyped-import]
12
12
  useFloating,
13
13
  } from '@floating-ui/react';
14
+ import without from 'lodash/without';
14
15
 
15
16
  import {sizeFluid} from '../../styles/variables/_size';
16
17
  import {spaceNone, spaceXXSmall} from '../../styles/variables/_space';
@@ -24,6 +25,7 @@ import {
24
25
  getFirstOptionFromGroup,
25
26
  } from '../../utils/token-list-input/token-list-input';
26
27
  import {ANCHOR_POSITION_TYPE, STRATEGY_TYPE} from '../ButtonDropdown';
28
+ import {CircularLoader} from '../CircularLoader';
27
29
  import {Icon} from '../Icon';
28
30
  import type {InputProps} from '../Input';
29
31
  import type {BaseMenuProps} from '../Menu';
@@ -67,12 +69,14 @@ export type Props<T> = {
67
69
  classNames?: ClassNames,
68
70
  clickAwayRef?: ClickAwayRefType,
69
71
  disabled?: boolean, // disables user interaction with the input
72
+ error?: boolean,
70
73
  errorText?: string,
71
74
  focusOnMount?: boolean,
72
75
  helperText?: string,
73
76
  inputValue?: string,
74
77
  inputPlaceholder?: string,
75
78
  limit?: number, // maximum number of values
79
+ isLoading?: boolean,
76
80
  locked?: boolean,
77
81
  onChange: (values: Array<T>) => mixed, // an onChange handler
78
82
  onInputBlur?: (e: SyntheticEvent<HTMLInputElement>) => mixed,
@@ -94,12 +98,14 @@ export function TokenListInput<T>(props: Props<T>): React.Node {
94
98
  classNames,
95
99
  clickAwayRef,
96
100
  disabled = false,
101
+ error,
97
102
  errorText,
98
103
  focusOnMount,
99
104
  helperText,
100
105
  inputValue = '',
101
106
  inputPlaceholder = '',
102
107
  limit = DEFAULT_LIMIT_VALUE,
108
+ isLoading,
103
109
  locked,
104
110
  onChange,
105
111
  menu,
@@ -158,6 +164,14 @@ export function TokenListInput<T>(props: Props<T>): React.Node {
158
164
  inputRef.current && inputRef.current.focus();
159
165
  }, 0);
160
166
  };
167
+
168
+ const removeValue = (value: T) => {
169
+ !disabled && !locked && onChange(without(values, value));
170
+ setTimeout(() => {
171
+ inputRef.current && inputRef.current.focus();
172
+ }, 0);
173
+ };
174
+
161
175
  const hideInput = values.length >= limit || disabled || locked;
162
176
 
163
177
  const handleInputKeyDown = (
@@ -238,7 +252,7 @@ export function TokenListInput<T>(props: Props<T>): React.Node {
238
252
  [css.inputDisabled]: disabled,
239
253
  [css.medium]: size === 'medium',
240
254
  [css.small]: size === 'small',
241
- [css.withError]: errorText,
255
+ [css.withError]: error,
242
256
  [css.inputLocked]: locked,
243
257
  },
244
258
  classNames?.box,
@@ -250,7 +264,7 @@ export function TokenListInput<T>(props: Props<T>): React.Node {
250
264
  resolveTokenValue={resolveTokenValue}
251
265
  disabled={disabled}
252
266
  locked={locked}
253
- onChange={onChange}
267
+ onDismiss={removeValue}
254
268
  />
255
269
  {!hideInput && (
256
270
  <input
@@ -282,6 +296,11 @@ export function TokenListInput<T>(props: Props<T>): React.Node {
282
296
  autoComplete="off"
283
297
  />
284
298
  )}
299
+ {isLoading && (
300
+ <div className={css.loaderContainer}>
301
+ <CircularLoader size="small" colorToken="colorFillPrimary" />
302
+ </div>
303
+ )}
285
304
  {locked && (
286
305
  <Icon
287
306
  name="lock"
@@ -293,7 +312,7 @@ export function TokenListInput<T>(props: Props<T>): React.Node {
293
312
  </div>
294
313
  {!isOpen && (Boolean(helperText) || errorText) && (
295
314
  <div className={css.footerTextContainer}>
296
- {errorText ? (
315
+ {error && errorText ? (
297
316
  <BodySmall color={TEXT_COLORS.danger}>{errorText}</BodySmall>
298
317
  ) : typeof helperText === 'string' ? (
299
318
  <BodySmall color={TEXT_COLORS.secondary}>
@@ -4,20 +4,15 @@
4
4
  spaceXSmall,
5
5
  spaceXXSmall
6
6
  ) from '../../styles/variables/_space.css';
7
-
8
7
  @value (
9
- colorFocusPrimary,
10
8
  colorFocusDanger,
11
-
9
+ colorFillPrimary,
12
10
  colorFillDisabled,
13
-
14
- colorBorderPrimary,
15
- colorBorderTertiary,
11
+ colorFocusPrimary,
16
12
  colorBorderDanger,
17
-
18
- colorFillPrimary
13
+ colorBorderPrimary,
14
+ colorBorderTertiary
19
15
  ) from '../../styles/variables/_color.css';
20
-
21
16
  @value (
22
17
  borderWidthPrimary,
23
18
  borderRadiusMedium,
@@ -25,11 +20,11 @@
25
20
  borderWidthNone,
26
21
  borderWidthTertiary
27
22
  ) from '../../styles/variables/_border.css';
28
-
29
23
  @value (
30
24
  size2,
31
- size8,
32
25
  size4,
26
+ size8,
27
+ size26,
33
28
  size228,
34
29
  sizeFluid
35
30
  ) from '../../styles/variables/_size.css';
@@ -89,6 +84,7 @@
89
84
  position: relative;
90
85
  flex-flow: column;
91
86
  width: sizeFluid;
87
+ gap: spaceXXSmall;
92
88
  }
93
89
 
94
90
  .tokenListHeader {
@@ -145,3 +141,12 @@
145
141
  justify-content: center;
146
142
  margin-left: auto;
147
143
  }
144
+
145
+ .loaderContainer {
146
+ display: flex;
147
+ align-items: center;
148
+ justify-content: center;
149
+ width: size26;
150
+ height: size26;
151
+ margin-left: auto;
152
+ }
@@ -1,18 +1,17 @@
1
1
  import * as React from 'react';
2
- import without from 'lodash/without';
3
2
  import {Chip} from '../Chip';
4
3
  import {Tooltip} from '../Tooltip';
5
4
  type Props<T> = {
6
5
  values: Array<T>;
7
6
  disabled?: boolean;
8
7
  locked?: boolean;
9
- onChange: (arg0: Array<T>) => unknown;
8
+ onDismiss: (arg0: T) => unknown;
10
9
  resolveTokenValue?: (arg0: ResolveTokenValueProps<T>) => React.ReactNode;
11
10
  };
12
11
  export type ResolveTokenValueProps<T> = {
13
12
  token: T;
14
13
  disabled?: boolean;
15
- onDismiss?: (e: React.SyntheticEvent<HTMLElement>) => unknown;
14
+ onDismiss?: (arg0: T) => unknown;
16
15
  locked?: boolean;
17
16
  };
18
17
 
@@ -27,7 +26,7 @@ function defaultResolveTokenValue<T>({
27
26
  <Tooltip body={token?.label}>
28
27
  <Chip // $FlowFixMe - assumes token has key
29
28
  key={token?.key}
30
- onDismiss={onDismiss}
29
+ onDismiss={(_) => onDismiss?.(token)}
31
30
  dismissable={true}
32
31
  semantic={'primary'}
33
32
  disabled={disabled}
@@ -44,14 +43,10 @@ export function TokenValueChips<T>(props: Props<T>): React.ReactNode {
44
43
  values,
45
44
  disabled,
46
45
  locked,
47
- onChange,
46
+ onDismiss,
48
47
  resolveTokenValue = defaultResolveTokenValue,
49
48
  } = props;
50
49
  return values.map((token) => {
51
- const onDismiss = (e) => {
52
- !disabled && !locked && onChange(without(values, token));
53
- };
54
-
55
50
  const resolvedTokenValue = resolveTokenValue({
56
51
  token,
57
52
  onDismiss,
@@ -5,10 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.TokenValueChips = TokenValueChips;
7
7
  var React = _interopRequireWildcard(require("react"));
8
- var _without = _interopRequireDefault(require("lodash/without"));
9
8
  var _Chip = require("../Chip");
10
9
  var _Tooltip = require("../Tooltip");
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
10
  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); }
13
11
  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; }
14
12
 
@@ -19,6 +17,7 @@ function defaultResolveTokenValue(_ref) {
19
17
  onDismiss
20
18
  } = _ref;
21
19
  // $FlowFixMe[prop-missing] - assumes token has label and key
20
+
22
21
  return (
23
22
  /*#__PURE__*/
24
23
  // $FlowFixMe - assumes token has label and key
@@ -28,7 +27,7 @@ function defaultResolveTokenValue(_ref) {
28
27
  // $FlowFixMe - assumes token has key
29
28
  , {
30
29
  key: token?.key,
31
- onDismiss: onDismiss,
30
+ onDismiss: _ => onDismiss?.(token),
32
31
  dismissable: true,
33
32
  semantic: 'primary',
34
33
  disabled: disabled
@@ -40,13 +39,10 @@ function TokenValueChips(props) {
40
39
  values,
41
40
  disabled,
42
41
  locked,
43
- onChange,
42
+ onDismiss,
44
43
  resolveTokenValue = defaultResolveTokenValue
45
44
  } = props;
46
45
  return values.map(token => {
47
- const onDismiss = e => {
48
- !disabled && !locked && onChange((0, _without.default)(values, token));
49
- };
50
46
  const resolvedTokenValue = resolveTokenValue({
51
47
  token,
52
48
  onDismiss,
@@ -1,6 +1,5 @@
1
1
  // @flow strict
2
2
  import * as React from 'react';
3
- import without from 'lodash/without';
4
3
 
5
4
  import {Chip} from '../Chip';
6
5
  import {Tooltip} from '../Tooltip';
@@ -10,14 +9,14 @@ type Props<T> = {
10
9
  values: Array<T>,
11
10
  disabled?: boolean,
12
11
  locked?: boolean,
13
- onChange: (Array<T>) => mixed,
12
+ onDismiss: (T) => mixed,
14
13
  resolveTokenValue?: (ResolveTokenValueProps<T>) => React.Node,
15
14
  };
16
15
 
17
16
  export type ResolveTokenValueProps<T> = {
18
17
  token: T,
19
18
  disabled?: boolean,
20
- onDismiss?: (e: SyntheticEvent<HTMLElement>) => mixed,
19
+ onDismiss?: (T) => mixed,
21
20
  locked?: boolean,
22
21
  };
23
22
 
@@ -27,13 +26,14 @@ function defaultResolveTokenValue<T>({
27
26
  onDismiss,
28
27
  }: ResolveTokenValueProps<T>): React.Node {
29
28
  // $FlowFixMe[prop-missing] - assumes token has label and key
29
+
30
30
  return (
31
31
  // $FlowFixMe - assumes token has label and key
32
32
  <Tooltip body={token?.label}>
33
33
  <Chip
34
34
  // $FlowFixMe - assumes token has key
35
35
  key={token?.key}
36
- onDismiss={onDismiss}
36
+ onDismiss={(_) => onDismiss?.(token)}
37
37
  dismissable={true}
38
38
  semantic={'primary'}
39
39
  disabled={disabled}
@@ -50,14 +50,11 @@ export function TokenValueChips<T>(props: Props<T>): React.Node {
50
50
  values,
51
51
  disabled,
52
52
  locked,
53
- onChange,
53
+ onDismiss,
54
54
  resolveTokenValue = defaultResolveTokenValue,
55
55
  } = props;
56
56
 
57
57
  return values.map((token) => {
58
- const onDismiss = (e) => {
59
- !disabled && !locked && onChange(without(values, token));
60
- };
61
58
  const resolvedTokenValue = resolveTokenValue({
62
59
  token,
63
60
  onDismiss,
@@ -1,5 +1,6 @@
1
1
  export * from './useArbitraryOptionAddition';
2
2
  export * from './useCopyToClipboard';
3
+ export * from './useDebounce';
3
4
  export * from './useFileUpload';
4
5
  export * from './useFilteredOptions';
5
6
  export * from './useInputState';
@@ -25,6 +25,17 @@ Object.keys(_useCopyToClipboard).forEach(function (key) {
25
25
  }
26
26
  });
27
27
  });
28
+ var _useDebounce = require("./useDebounce");
29
+ Object.keys(_useDebounce).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _useDebounce[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _useDebounce[key];
36
+ }
37
+ });
38
+ });
28
39
  var _useFileUpload = require("./useFileUpload");
29
40
  Object.keys(_useFileUpload).forEach(function (key) {
30
41
  if (key === "default" || key === "__esModule") return;
@@ -2,6 +2,7 @@
2
2
 
3
3
  export * from './useArbitraryOptionAddition';
4
4
  export * from './useCopyToClipboard';
5
+ export * from './useDebounce';
5
6
  export * from './useFileUpload';
6
7
  export * from './useFilteredOptions';
7
8
  export * from './useInputState';
@@ -0,0 +1 @@
1
+ export * from './useDebounce';
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _useDebounce = require("./useDebounce");
7
+ Object.keys(_useDebounce).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _useDebounce[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _useDebounce[key];
14
+ }
15
+ });
16
+ });
@@ -0,0 +1,3 @@
1
+ // @flow strict
2
+
3
+ export * from './useDebounce';
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ export const useDebounce = <T>(value: T, delay: number): T => {
3
+ const [debouncedValue, setDebouncedValue] = React.useState<T>(value);
4
+ React.useEffect(() => {
5
+ const handler = setTimeout(() => {
6
+ setDebouncedValue(value);
7
+ }, delay);
8
+ return () => {
9
+ clearTimeout(handler);
10
+ };
11
+ }, [value, delay]);
12
+ return debouncedValue;
13
+ };
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useDebounce = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ 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); }
9
+ 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; }
10
+
11
+ const useDebounce = (value, delay) => {
12
+ const [debouncedValue, setDebouncedValue] = React.useState(value);
13
+ React.useEffect(() => {
14
+ const handler = setTimeout(() => {
15
+ setDebouncedValue(value);
16
+ }, delay);
17
+ return () => {
18
+ clearTimeout(handler);
19
+ };
20
+ }, [value, delay]);
21
+ return debouncedValue;
22
+ };
23
+ exports.useDebounce = useDebounce;
@@ -0,0 +1,17 @@
1
+ // @flow strict
2
+
3
+ import * as React from 'react';
4
+
5
+
6
+ export const useDebounce = <T>(value: T, delay: number): T => {
7
+ const [debouncedValue, setDebouncedValue] = React.useState<T>(value);
8
+ React.useEffect(() => {
9
+ const handler = setTimeout(() => {
10
+ setDebouncedValue(value);
11
+ }, delay);
12
+ return () => {
13
+ clearTimeout(handler);
14
+ };
15
+ }, [value, delay]);
16
+ return debouncedValue;
17
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaced-out/ui-design-system",
3
- "version": "0.3.39-beta.0",
3
+ "version": "0.3.40-beta.0",
4
4
  "main": "index.js",
5
5
  "description": "Sense UI components library",
6
6
  "author": {
@@ -40,8 +40,8 @@
40
40
  "Sense"
41
41
  ],
42
42
  "peerDependencies": {
43
- "react": ">=19.1.0",
44
- "react-dom": ">=19.1.0"
43
+ "react": ">=16.8.0",
44
+ "react-dom": ">=16.8.0"
45
45
  },
46
46
  "dependencies": {
47
47
  "@floating-ui/react": "^0.24.0",
@@ -106,8 +106,8 @@
106
106
  "lint-staged": "^10.5.1",
107
107
  "paths.macro": "^3.0.1",
108
108
  "prettier": "^2.5.1",
109
- "react": "^19.1.0",
110
- "react-dom": "^19.1.0",
109
+ "react": "17.0.2",
110
+ "react-dom": "17.0.2",
111
111
  "rimraf": "^3.0.2",
112
112
  "simple-git": "^3.12.0",
113
113
  "standard-version": "^9.5.0",