carbon-react 104.52.0 → 104.53.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.
@@ -1,3 +1,4 @@
1
+ export function getDefaultValue(value: any): any;
1
2
  export function assertStyleMatch(styleSpec: any, component: any, opts: any): void;
2
3
  export function toCSSCase(str: any): any;
3
4
  export function hoverList(wrapper: any): (item: any) => void;
@@ -1,5 +1,6 @@
1
1
  import { mount } from "enzyme";
2
2
  import { sprintf } from "sprintf-js";
3
+ import { space } from "style/themes/base/base-theme.config";
3
4
  import { carbonThemeList } from "../style/themes";
4
5
  import { mockMatchMedia } from "./mock-match-media";
5
6
 
@@ -119,9 +120,19 @@ const widthProps = ["width", "width", "200px"];
119
120
  const layoutProps = [widthProps, ["height", "height", "200px"], ["minWidth", "min-width", "120px"], ["maxWidth", "max-width", "120px"], ["minHeight", "min-height", "120px"], ["maxHeight", "max-height", "120px"], ["size", "width", "120px"], ["size", "height", "120px"], ["display", "display", "inline-block"], ["verticalAlign", "vertical-align", "baseline"], ["overflow", "overflow", "hidden"], ["overflowX", "overflow-x", "hidden"], ["overflowY", "overflow-y", "hidden"]];
120
121
  const flexBoxProps = [["alignItems", "alignItems", "center"], ["alignContent", "alignContent", "center"], ["justifyItems", "justifyItems", "center"], ["justifyContent", "justifyContent", "center"], ["flexWrap", "flexWrap", "wrap"], ["flexDirection", "flexDirection", "row-reverse"], ["flex", "flex", "1"], ["flexGrow", "flexGrow", "1"], ["flexShrink", "flexShrink", "1"], ["flexBasis", "flexBasis", "100px"], ["justifySelf", "justifySelf", "center"], ["alignSelf", "alignSelf", "center"], ["order", "order", "1"]];
121
122
  const backgroundProps = [["background", "background", "lightblue url('foo.jpg') no-repeat fixed center"], ["backgroundImage", "background-image", "url(foo.jpg)"], ["backgroundSize", "background-size", "center"], ["backgroundRepeat", "background-repeat", "no-repeat"]];
123
+ export const getDefaultValue = value => {
124
+ const spaceArrayLength = space.length - 1;
125
+ const parsedValue = +value;
122
126
 
123
- const getDefaultValue = value => {
124
- if (typeof value === "number") {
127
+ if (typeof value === "string" && value > spaceArrayLength) {
128
+ return `${value}px`;
129
+ }
130
+
131
+ if (parsedValue <= spaceArrayLength) {
132
+ return space[value];
133
+ }
134
+
135
+ if (parsedValue > spaceArrayLength) {
125
136
  return `${value * 8}px`;
126
137
  }
127
138
 
@@ -130,7 +141,8 @@ const getDefaultValue = value => {
130
141
 
131
142
  const testStyledSystemMargin = (component, defaults, styleContainer, assertOpts) => {
132
143
  describe("default props", () => {
133
- const wrapper = mount(component());
144
+ const wrapper = mount(component({ ...defaults
145
+ }));
134
146
  const StyleElement = styleContainer ? styleContainer(wrapper) : wrapper;
135
147
  it("should set the correct margins", () => {
136
148
  let margin;
@@ -170,7 +182,7 @@ const testStyledSystemMargin = (component, defaults, styleContainer, assertOpts)
170
182
  wrapper = mount(component({ ...props
171
183
  }));
172
184
  expect(assertStyleMatch({
173
- [propName]: "16px"
185
+ [propName]: "var(--spacing200)"
174
186
  }, styleContainer ? styleContainer(wrapper) : wrapper, assertOpts));
175
187
  });
176
188
  });
@@ -178,7 +190,8 @@ const testStyledSystemMargin = (component, defaults, styleContainer, assertOpts)
178
190
 
179
191
  const testStyledSystemPadding = (component, defaults, styleContainer, assertOpts) => {
180
192
  describe("default props", () => {
181
- const wrapper = mount(component());
193
+ const wrapper = mount(component({ ...defaults
194
+ }));
182
195
  const StyleElement = styleContainer ? styleContainer(wrapper) : wrapper;
183
196
  it("should set the correct paddings", () => {
184
197
  let padding;
@@ -218,7 +231,7 @@ const testStyledSystemPadding = (component, defaults, styleContainer, assertOpts
218
231
  wrapper = mount(component({ ...props
219
232
  }));
220
233
  expect(assertStyleMatch({
221
- [propName]: "16px"
234
+ [propName]: "var(--spacing200)"
222
235
  }, styleContainer ? styleContainer(wrapper) : wrapper, assertOpts));
223
236
  });
224
237
  });
@@ -23,7 +23,7 @@ const calculateWidthValue = props => {
23
23
  padding
24
24
  } = paddingFn(props);
25
25
  const paddingValue = paddingLeft ?? paddingRight ?? padding;
26
- return paddingValue === undefined ? HORIZONTAL_PADDING * 2 : paddingValue * 2;
26
+ return paddingValue === undefined ? HORIZONTAL_PADDING : paddingValue;
27
27
  };
28
28
 
29
29
  const calculateFormSpacingValues = (props, isFormContent) => {
@@ -38,19 +38,22 @@ const calculateFormSpacingValues = (props, isFormContent) => {
38
38
  const spacingRightValue = paddingRight ?? padding ?? HORIZONTAL_PADDING;
39
39
  const spacingBottomValue = paddingBottom ?? padding ?? CONTENT_BOTTOM_PADDING;
40
40
  const spacingLeftValue = paddingLeft ?? padding ?? HORIZONTAL_PADDING;
41
+
42
+ const setNegativeValue = value => `calc(-1px * ${value})`;
43
+
41
44
  return {
42
- "margin-left": spacingLeftValue ? `-${spacingLeftValue}px` : spacingLeftValue,
43
- "margin-right": spacingRightValue ? `-${spacingRightValue}px` : spacingRightValue,
45
+ "margin-left": setNegativeValue(spacingLeftValue),
46
+ "margin-right": setNegativeValue(spacingRightValue),
44
47
  ...(isFormContent && {
45
- "margin-top": spacingTopValue ? `-${spacingTopValue}px` : spacingTopValue,
48
+ "margin-top": setNegativeValue(spacingTopValue),
46
49
  "padding-top": spacingTopValue,
47
50
  "padding-bottom": spacingBottomValue,
48
51
  "padding-left": spacingLeftValue,
49
52
  "padding-right": spacingRightValue
50
53
  }),
51
54
  ...(!isFormContent && {
52
- "margin-bottom": spacingBottomValue ? `-${spacingBottomValue}px` : spacingBottomValue,
53
- bottom: spacingBottomValue ? `-${spacingBottomValue}px` : spacingBottomValue
55
+ "margin-bottom": setNegativeValue(spacingBottomValue),
56
+ bottom: setNegativeValue(spacingBottomValue)
54
57
  })
55
58
  };
56
59
  };
@@ -106,7 +109,7 @@ const DialogStyle = styled.div`
106
109
  }
107
110
 
108
111
  ${StyledFormFooter}.sticky {
109
- width: calc(100% + ${calculateWidthValue}px);
112
+ width: calc(100% + (2px * ${calculateWidthValue}));
110
113
  ${props => calculateFormSpacingValues(props, false)}
111
114
  }
112
115
 
@@ -16,6 +16,7 @@ const FilterableSelect = /*#__PURE__*/React.forwardRef(({
16
16
  defaultValue,
17
17
  id,
18
18
  name,
19
+ label,
19
20
  children,
20
21
  onOpen,
21
22
  onChange,
@@ -45,7 +46,7 @@ const FilterableSelect = /*#__PURE__*/React.forwardRef(({
45
46
  }, inputRef) => {
46
47
  const [activeDescendantId, setActiveDescendantId] = useState();
47
48
  const selectListId = useRef(guid());
48
- const labelId = useRef(guid());
49
+ const labelId = useRef(label ? guid() : undefined);
49
50
  const containerRef = useRef();
50
51
  const listboxRef = useRef();
51
52
  const isControlled = useRef(value !== undefined);
@@ -366,6 +367,7 @@ const FilterableSelect = /*#__PURE__*/React.forwardRef(({
366
367
  return {
367
368
  id,
368
369
  name,
370
+ label,
369
371
  disabled,
370
372
  readOnly,
371
373
  inputRef: assignInput,
@@ -391,7 +393,7 @@ const FilterableSelect = /*#__PURE__*/React.forwardRef(({
391
393
  const selectList = /*#__PURE__*/React.createElement(FilterableSelectList, {
392
394
  ref: listboxRef,
393
395
  id: selectListId.current,
394
- labelId: labelId.current,
396
+ labelId: label ? labelId.current : undefined,
395
397
  anchorElement: textboxRef && textboxRef.parentElement,
396
398
  onSelect: onSelectOption,
397
399
  onSelectListClose: onSelectListClose,
@@ -426,10 +428,10 @@ const FilterableSelect = /*#__PURE__*/React.forwardRef(({
426
428
  ref: containerRef
427
429
  }, /*#__PURE__*/React.createElement(SelectTextbox, _extends({
428
430
  activeDescendantId: activeDescendantId,
431
+ labelId: label ? labelId.current : undefined,
429
432
  "aria-controls": isOpen ? selectListId.current : undefined,
430
433
  isOpen: isOpen,
431
434
  hasTextCursor: true,
432
- labelId: labelId.current,
433
435
  textboxRef: textboxRef
434
436
  }, getTextboxProps()))), isOpen && selectList);
435
437
  });
@@ -1,14 +1,14 @@
1
1
  export default SelectTextbox;
2
- declare function SelectTextbox({ accessibilityLabelId, "aria-controls": ariaControls, value, disabled, isOpen, readOnly, placeholder, labelId, size, onClick, onFocus, onBlur, onChange, selectedValue, required, textboxRef, hasTextCursor, transparent, activeDescendantId, ...restProps }: {
2
+ declare function SelectTextbox({ accessibilityLabelId, labelId, "aria-controls": ariaControls, value, disabled, isOpen, readOnly, placeholder, size, onClick, onFocus, onBlur, onChange, selectedValue, required, textboxRef, hasTextCursor, transparent, activeDescendantId, ...restProps }: {
3
3
  [x: string]: any;
4
- accessibilityLabelId?: string | undefined;
4
+ accessibilityLabelId: any;
5
+ labelId: any;
5
6
  "aria-controls": any;
6
7
  value: any;
7
8
  disabled: any;
8
9
  isOpen: any;
9
10
  readOnly: any;
10
11
  placeholder: any;
11
- labelId: any;
12
12
  size: any;
13
13
  onClick: any;
14
14
  onFocus: any;
@@ -45,14 +45,14 @@ const modifiers = [{
45
45
  }];
46
46
 
47
47
  const SelectTextbox = ({
48
- accessibilityLabelId = "",
48
+ accessibilityLabelId,
49
+ labelId,
49
50
  "aria-controls": ariaControls,
50
51
  value,
51
52
  disabled,
52
53
  isOpen,
53
54
  readOnly,
54
55
  placeholder,
55
- labelId,
56
56
  size,
57
57
  onClick,
58
58
  onFocus,
@@ -133,9 +133,12 @@ const SelectTextbox = ({
133
133
  }
134
134
 
135
135
  function getInputAriaAttributes() {
136
+ const joinIds = (...ids) => ids.filter(item => item !== undefined).join(" ");
137
+
138
+ const ariaLabelledby = hasTextCursor ? joinIds(labelId, accessibilityLabelId) : joinIds(labelId, textId.current);
136
139
  return {
137
140
  "aria-expanded": isOpen,
138
- "aria-labelledby": hasTextCursor ? `${labelId} ${accessibilityLabelId}` : `${labelId} ${textId.current}`,
141
+ "aria-labelledby": ariaLabelledby || undefined,
139
142
  "aria-activedescendant": activeDescendantId,
140
143
  "aria-controls": ariaControls,
141
144
  "aria-autocomplete": hasTextCursor ? "both" : undefined,
@@ -1,8 +1,9 @@
1
+ export const space: string[];
1
2
  declare function _default(palette: any): {
2
3
  name: string;
3
4
  palette: any;
4
5
  spacing: number;
5
- space: number[];
6
+ space: string[];
6
7
  colors: {
7
8
  base: any;
8
9
  primary: any;
@@ -336,22 +337,6 @@ declare function _default(palette: any): {
336
337
  colorsSemanticNegative600: any;
337
338
  colorsSemanticCaution500: any;
338
339
  colorsSemanticInfo500: any;
339
- spacing000: string;
340
- spacing025: string;
341
- spacing050: string;
342
- spacing075: string;
343
- spacing100: string;
344
- spacing125: string;
345
- spacing150: string;
346
- spacing200: string;
347
- spacing250: string;
348
- spacing300: string;
349
- spacing400: string;
350
- spacing500: string;
351
- spacing600: string;
352
- spacing700: string;
353
- spacing800: string;
354
- spacing900: string;
355
340
  fontSizes100: string;
356
341
  metaName: string;
357
342
  metaPublic: string;
@@ -546,7 +531,23 @@ declare function _default(palette: any): {
546
531
  sizing075: string;
547
532
  sizingLogowidth: string;
548
533
  sizing010: string;
534
+ spacing100: string;
535
+ spacing125: string;
536
+ spacing150: string;
537
+ spacing200: string;
538
+ spacing250: string;
539
+ spacing300: string;
540
+ spacing400: string;
541
+ spacing500: string;
542
+ spacing600: string;
543
+ spacing700: string;
544
+ spacing800: string;
545
+ spacing900: string;
549
546
  spacing1000: string;
547
+ spacing000: string;
548
+ spacing025: string;
549
+ spacing050: string;
550
+ spacing075: string;
550
551
  borderWidth100: string;
551
552
  borderWidth200: string;
552
553
  borderWidth300: string;
@@ -1,12 +1,13 @@
1
1
  import tokens from "@sage/design-tokens/js/base/common";
2
2
  import atOpacity from "../../utils/at-opacity";
3
+ export const space = ["var(--spacing000)", "var(--spacing100)", "var(--spacing200)", "var(--spacing300)", "var(--spacing400)", "var(--spacing500)", "var(--spacing600)", "var(--spacing700)", "var(--spacing800)", "var(--spacing900)", "var(--spacing1000)"];
3
4
  export default (palette => {
4
5
  const baseWithOpacity = atOpacity(palette.productGreen);
5
6
  return {
6
7
  name: "base",
7
8
  palette,
8
9
  spacing: 8,
9
- space: [0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80],
10
+ space,
10
11
  colors: {
11
12
  // main
12
13
  base: palette.productGreen,
@@ -348,32 +349,6 @@ export default (palette => {
348
349
  colorsSemanticNegative600: this.colors.destructive.hover,
349
350
  colorsSemanticCaution500: this.colors.warning,
350
351
  colorsSemanticInfo500: this.colors.info,
351
- spacing000: `${this.space[0]}px`,
352
- // 0px
353
- spacing025: "2px",
354
- spacing050: "4px",
355
- spacing075: "6px",
356
- spacing100: `${this.space[1]}px`,
357
- // 8px
358
- spacing125: "10px",
359
- spacing150: "12px",
360
- spacing200: `${this.space[2]}px`,
361
- // 16px
362
- spacing250: "20px",
363
- spacing300: `${this.space[3]}px`,
364
- // 24px
365
- spacing400: `${this.space[4]}px`,
366
- // 32px
367
- spacing500: `${this.space[5]}px`,
368
- // 40px
369
- spacing600: `${this.space[6]}px`,
370
- // 48px
371
- spacing700: `${this.space[7]}px`,
372
- // 56px
373
- spacing800: `${this.space[8]}px`,
374
- // 64px
375
- spacing900: `${this.space[9]}px`,
376
- // 72px
377
352
  fontSizes100: this.text.size
378
353
  };
379
354
  }
@@ -51,7 +51,7 @@ export interface ThemeObject {
51
51
  name: string;
52
52
  palette: BasePalette;
53
53
  spacing: number;
54
- space: number[];
54
+ space: string[];
55
55
 
56
56
  colors: Colors;
57
57
 
@@ -374,7 +374,7 @@ declare var _default: {
374
374
  whiteOpacity: (opacity: number) => string;
375
375
  };
376
376
  spacing: number;
377
- space: number[];
377
+ space: string[];
378
378
  colors: import("../base").Colors;
379
379
  anchorNavigation: {
380
380
  divider: string;
@@ -1,3 +1,4 @@
1
+ export function getDefaultValue(value: any): any;
1
2
  export function assertStyleMatch(styleSpec: any, component: any, opts: any): void;
2
3
  export function toCSSCase(str: any): any;
3
4
  export function hoverList(wrapper: any): (item: any) => void;
@@ -9,12 +9,14 @@ Object.defineProperty(exports, "mockMatchMedia", {
9
9
  return _mockMatchMedia.mockMatchMedia;
10
10
  }
11
11
  });
12
- exports.expectError = exports.testStyledSystemBackground = exports.testStyledSystemFlexBox = exports.testStyledSystemLayout = exports.testStyledSystemWidth = exports.testStyledSystemColor = exports.testStyledSystemPadding = exports.testStyledSystemMargin = exports.testStyledSystemSpacing = exports.carbonThemesJestTable = exports.simulate = exports.click = exports.listFrom = exports.assertHoverTraversal = exports.assertKeyboardTraversal = exports.keyboard = exports.makeArrayKeys = exports.childrenFrom = exports.selectedItemOf = exports.hoverList = exports.toCSSCase = exports.assertStyleMatch = void 0;
12
+ exports.expectError = exports.testStyledSystemBackground = exports.testStyledSystemFlexBox = exports.testStyledSystemLayout = exports.testStyledSystemWidth = exports.testStyledSystemColor = exports.testStyledSystemPadding = exports.testStyledSystemMargin = exports.testStyledSystemSpacing = exports.carbonThemesJestTable = exports.simulate = exports.click = exports.listFrom = exports.assertHoverTraversal = exports.assertKeyboardTraversal = exports.keyboard = exports.makeArrayKeys = exports.childrenFrom = exports.selectedItemOf = exports.hoverList = exports.toCSSCase = exports.assertStyleMatch = exports.getDefaultValue = void 0;
13
13
 
14
14
  var _enzyme = require("enzyme");
15
15
 
16
16
  var _sprintfJs = require("sprintf-js");
17
17
 
18
+ var _baseTheme = require("style/themes/base/base-theme.config");
19
+
18
20
  var _themes = require("../style/themes");
19
21
 
20
22
  var _mockMatchMedia = require("./mock-match-media");
@@ -159,16 +161,30 @@ const flexBoxProps = [["alignItems", "alignItems", "center"], ["alignContent", "
159
161
  const backgroundProps = [["background", "background", "lightblue url('foo.jpg') no-repeat fixed center"], ["backgroundImage", "background-image", "url(foo.jpg)"], ["backgroundSize", "background-size", "center"], ["backgroundRepeat", "background-repeat", "no-repeat"]];
160
162
 
161
163
  const getDefaultValue = value => {
162
- if (typeof value === "number") {
164
+ const spaceArrayLength = _baseTheme.space.length - 1;
165
+ const parsedValue = +value;
166
+
167
+ if (typeof value === "string" && value > spaceArrayLength) {
168
+ return `${value}px`;
169
+ }
170
+
171
+ if (parsedValue <= spaceArrayLength) {
172
+ return _baseTheme.space[value];
173
+ }
174
+
175
+ if (parsedValue > spaceArrayLength) {
163
176
  return `${value * 8}px`;
164
177
  }
165
178
 
166
179
  return value;
167
180
  };
168
181
 
182
+ exports.getDefaultValue = getDefaultValue;
183
+
169
184
  const testStyledSystemMargin = (component, defaults, styleContainer, assertOpts) => {
170
185
  describe("default props", () => {
171
- const wrapper = (0, _enzyme.mount)(component());
186
+ const wrapper = (0, _enzyme.mount)(component({ ...defaults
187
+ }));
172
188
  const StyleElement = styleContainer ? styleContainer(wrapper) : wrapper;
173
189
  it("should set the correct margins", () => {
174
190
  let margin;
@@ -208,7 +224,7 @@ const testStyledSystemMargin = (component, defaults, styleContainer, assertOpts)
208
224
  wrapper = (0, _enzyme.mount)(component({ ...props
209
225
  }));
210
226
  expect(assertStyleMatch({
211
- [propName]: "16px"
227
+ [propName]: "var(--spacing200)"
212
228
  }, styleContainer ? styleContainer(wrapper) : wrapper, assertOpts));
213
229
  });
214
230
  });
@@ -218,7 +234,8 @@ exports.testStyledSystemMargin = testStyledSystemMargin;
218
234
 
219
235
  const testStyledSystemPadding = (component, defaults, styleContainer, assertOpts) => {
220
236
  describe("default props", () => {
221
- const wrapper = (0, _enzyme.mount)(component());
237
+ const wrapper = (0, _enzyme.mount)(component({ ...defaults
238
+ }));
222
239
  const StyleElement = styleContainer ? styleContainer(wrapper) : wrapper;
223
240
  it("should set the correct paddings", () => {
224
241
  let padding;
@@ -258,7 +275,7 @@ const testStyledSystemPadding = (component, defaults, styleContainer, assertOpts
258
275
  wrapper = (0, _enzyme.mount)(component({ ...props
259
276
  }));
260
277
  expect(assertStyleMatch({
261
- [propName]: "16px"
278
+ [propName]: "var(--spacing200)"
262
279
  }, styleContainer ? styleContainer(wrapper) : wrapper, assertOpts));
263
280
  });
264
281
  });
@@ -43,7 +43,7 @@ const calculateWidthValue = props => {
43
43
  padding
44
44
  } = (0, _styledSystem.padding)(props);
45
45
  const paddingValue = paddingLeft ?? paddingRight ?? padding;
46
- return paddingValue === undefined ? _dialog.HORIZONTAL_PADDING * 2 : paddingValue * 2;
46
+ return paddingValue === undefined ? _dialog.HORIZONTAL_PADDING : paddingValue;
47
47
  };
48
48
 
49
49
  const calculateFormSpacingValues = (props, isFormContent) => {
@@ -58,19 +58,22 @@ const calculateFormSpacingValues = (props, isFormContent) => {
58
58
  const spacingRightValue = paddingRight ?? padding ?? _dialog.HORIZONTAL_PADDING;
59
59
  const spacingBottomValue = paddingBottom ?? padding ?? _dialog.CONTENT_BOTTOM_PADDING;
60
60
  const spacingLeftValue = paddingLeft ?? padding ?? _dialog.HORIZONTAL_PADDING;
61
+
62
+ const setNegativeValue = value => `calc(-1px * ${value})`;
63
+
61
64
  return {
62
- "margin-left": spacingLeftValue ? `-${spacingLeftValue}px` : spacingLeftValue,
63
- "margin-right": spacingRightValue ? `-${spacingRightValue}px` : spacingRightValue,
65
+ "margin-left": setNegativeValue(spacingLeftValue),
66
+ "margin-right": setNegativeValue(spacingRightValue),
64
67
  ...(isFormContent && {
65
- "margin-top": spacingTopValue ? `-${spacingTopValue}px` : spacingTopValue,
68
+ "margin-top": setNegativeValue(spacingTopValue),
66
69
  "padding-top": spacingTopValue,
67
70
  "padding-bottom": spacingBottomValue,
68
71
  "padding-left": spacingLeftValue,
69
72
  "padding-right": spacingRightValue
70
73
  }),
71
74
  ...(!isFormContent && {
72
- "margin-bottom": spacingBottomValue ? `-${spacingBottomValue}px` : spacingBottomValue,
73
- bottom: spacingBottomValue ? `-${spacingBottomValue}px` : spacingBottomValue
75
+ "margin-bottom": setNegativeValue(spacingBottomValue),
76
+ bottom: setNegativeValue(spacingBottomValue)
74
77
  })
75
78
  };
76
79
  };
@@ -126,7 +129,7 @@ const DialogStyle = _styledComponents.default.div`
126
129
  }
127
130
 
128
131
  ${_form.StyledFormFooter}.sticky {
129
- width: calc(100% + ${calculateWidthValue}px);
132
+ width: calc(100% + (2px * ${calculateWidthValue}));
130
133
  ${props => calculateFormSpacingValues(props, false)}
131
134
  }
132
135
 
@@ -40,6 +40,7 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
40
40
  defaultValue,
41
41
  id,
42
42
  name,
43
+ label,
43
44
  children,
44
45
  onOpen,
45
46
  onChange,
@@ -69,7 +70,7 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
69
70
  }, inputRef) => {
70
71
  const [activeDescendantId, setActiveDescendantId] = (0, _react.useState)();
71
72
  const selectListId = (0, _react.useRef)((0, _guid.default)());
72
- const labelId = (0, _react.useRef)((0, _guid.default)());
73
+ const labelId = (0, _react.useRef)(label ? (0, _guid.default)() : undefined);
73
74
  const containerRef = (0, _react.useRef)();
74
75
  const listboxRef = (0, _react.useRef)();
75
76
  const isControlled = (0, _react.useRef)(value !== undefined);
@@ -390,6 +391,7 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
390
391
  return {
391
392
  id,
392
393
  name,
394
+ label,
393
395
  disabled,
394
396
  readOnly,
395
397
  inputRef: assignInput,
@@ -415,7 +417,7 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
415
417
  const selectList = /*#__PURE__*/_react.default.createElement(FilterableSelectList, {
416
418
  ref: listboxRef,
417
419
  id: selectListId.current,
418
- labelId: labelId.current,
420
+ labelId: label ? labelId.current : undefined,
419
421
  anchorElement: textboxRef && textboxRef.parentElement,
420
422
  onSelect: onSelectOption,
421
423
  onSelectListClose: onSelectListClose,
@@ -451,10 +453,10 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
451
453
  ref: containerRef
452
454
  }, /*#__PURE__*/_react.default.createElement(_selectTextbox.default, _extends({
453
455
  activeDescendantId: activeDescendantId,
456
+ labelId: label ? labelId.current : undefined,
454
457
  "aria-controls": isOpen ? selectListId.current : undefined,
455
458
  isOpen: isOpen,
456
459
  hasTextCursor: true,
457
- labelId: labelId.current,
458
460
  textboxRef: textboxRef
459
461
  }, getTextboxProps()))), isOpen && selectList);
460
462
  });
@@ -1,14 +1,14 @@
1
1
  export default SelectTextbox;
2
- declare function SelectTextbox({ accessibilityLabelId, "aria-controls": ariaControls, value, disabled, isOpen, readOnly, placeholder, labelId, size, onClick, onFocus, onBlur, onChange, selectedValue, required, textboxRef, hasTextCursor, transparent, activeDescendantId, ...restProps }: {
2
+ declare function SelectTextbox({ accessibilityLabelId, labelId, "aria-controls": ariaControls, value, disabled, isOpen, readOnly, placeholder, size, onClick, onFocus, onBlur, onChange, selectedValue, required, textboxRef, hasTextCursor, transparent, activeDescendantId, ...restProps }: {
3
3
  [x: string]: any;
4
- accessibilityLabelId?: string | undefined;
4
+ accessibilityLabelId: any;
5
+ labelId: any;
5
6
  "aria-controls": any;
6
7
  value: any;
7
8
  disabled: any;
8
9
  isOpen: any;
9
10
  readOnly: any;
10
11
  placeholder: any;
11
- labelId: any;
12
12
  size: any;
13
13
  onClick: any;
14
14
  onFocus: any;
@@ -66,14 +66,14 @@ const modifiers = [{
66
66
  }];
67
67
 
68
68
  const SelectTextbox = ({
69
- accessibilityLabelId = "",
69
+ accessibilityLabelId,
70
+ labelId,
70
71
  "aria-controls": ariaControls,
71
72
  value,
72
73
  disabled,
73
74
  isOpen,
74
75
  readOnly,
75
76
  placeholder,
76
- labelId,
77
77
  size,
78
78
  onClick,
79
79
  onFocus,
@@ -154,9 +154,12 @@ const SelectTextbox = ({
154
154
  }
155
155
 
156
156
  function getInputAriaAttributes() {
157
+ const joinIds = (...ids) => ids.filter(item => item !== undefined).join(" ");
158
+
159
+ const ariaLabelledby = hasTextCursor ? joinIds(labelId, accessibilityLabelId) : joinIds(labelId, textId.current);
157
160
  return {
158
161
  "aria-expanded": isOpen,
159
- "aria-labelledby": hasTextCursor ? `${labelId} ${accessibilityLabelId}` : `${labelId} ${textId.current}`,
162
+ "aria-labelledby": ariaLabelledby || undefined,
160
163
  "aria-activedescendant": activeDescendantId,
161
164
  "aria-controls": ariaControls,
162
165
  "aria-autocomplete": hasTextCursor ? "both" : undefined,
@@ -1,8 +1,9 @@
1
+ export const space: string[];
1
2
  declare function _default(palette: any): {
2
3
  name: string;
3
4
  palette: any;
4
5
  spacing: number;
5
- space: number[];
6
+ space: string[];
6
7
  colors: {
7
8
  base: any;
8
9
  primary: any;
@@ -336,22 +337,6 @@ declare function _default(palette: any): {
336
337
  colorsSemanticNegative600: any;
337
338
  colorsSemanticCaution500: any;
338
339
  colorsSemanticInfo500: any;
339
- spacing000: string;
340
- spacing025: string;
341
- spacing050: string;
342
- spacing075: string;
343
- spacing100: string;
344
- spacing125: string;
345
- spacing150: string;
346
- spacing200: string;
347
- spacing250: string;
348
- spacing300: string;
349
- spacing400: string;
350
- spacing500: string;
351
- spacing600: string;
352
- spacing700: string;
353
- spacing800: string;
354
- spacing900: string;
355
340
  fontSizes100: string;
356
341
  metaName: string;
357
342
  metaPublic: string;
@@ -546,7 +531,23 @@ declare function _default(palette: any): {
546
531
  sizing075: string;
547
532
  sizingLogowidth: string;
548
533
  sizing010: string;
534
+ spacing100: string;
535
+ spacing125: string;
536
+ spacing150: string;
537
+ spacing200: string;
538
+ spacing250: string;
539
+ spacing300: string;
540
+ spacing400: string;
541
+ spacing500: string;
542
+ spacing600: string;
543
+ spacing700: string;
544
+ spacing800: string;
545
+ spacing900: string;
549
546
  spacing1000: string;
547
+ spacing000: string;
548
+ spacing025: string;
549
+ spacing050: string;
550
+ spacing075: string;
550
551
  borderWidth100: string;
551
552
  borderWidth200: string;
552
553
  borderWidth300: string;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = exports.space = void 0;
7
7
 
8
8
  var _common = _interopRequireDefault(require("@sage/design-tokens/js/base/common"));
9
9
 
@@ -11,13 +11,16 @@ var _atOpacity = _interopRequireDefault(require("../../utils/at-opacity"));
11
11
 
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
 
14
+ const space = ["var(--spacing000)", "var(--spacing100)", "var(--spacing200)", "var(--spacing300)", "var(--spacing400)", "var(--spacing500)", "var(--spacing600)", "var(--spacing700)", "var(--spacing800)", "var(--spacing900)", "var(--spacing1000)"];
15
+ exports.space = space;
16
+
14
17
  var _default = palette => {
15
18
  const baseWithOpacity = (0, _atOpacity.default)(palette.productGreen);
16
19
  return {
17
20
  name: "base",
18
21
  palette,
19
22
  spacing: 8,
20
- space: [0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80],
23
+ space,
21
24
  colors: {
22
25
  // main
23
26
  base: palette.productGreen,
@@ -359,32 +362,6 @@ var _default = palette => {
359
362
  colorsSemanticNegative600: this.colors.destructive.hover,
360
363
  colorsSemanticCaution500: this.colors.warning,
361
364
  colorsSemanticInfo500: this.colors.info,
362
- spacing000: `${this.space[0]}px`,
363
- // 0px
364
- spacing025: "2px",
365
- spacing050: "4px",
366
- spacing075: "6px",
367
- spacing100: `${this.space[1]}px`,
368
- // 8px
369
- spacing125: "10px",
370
- spacing150: "12px",
371
- spacing200: `${this.space[2]}px`,
372
- // 16px
373
- spacing250: "20px",
374
- spacing300: `${this.space[3]}px`,
375
- // 24px
376
- spacing400: `${this.space[4]}px`,
377
- // 32px
378
- spacing500: `${this.space[5]}px`,
379
- // 40px
380
- spacing600: `${this.space[6]}px`,
381
- // 48px
382
- spacing700: `${this.space[7]}px`,
383
- // 56px
384
- spacing800: `${this.space[8]}px`,
385
- // 64px
386
- spacing900: `${this.space[9]}px`,
387
- // 72px
388
365
  fontSizes100: this.text.size
389
366
  };
390
367
  }
@@ -51,7 +51,7 @@ export interface ThemeObject {
51
51
  name: string;
52
52
  palette: BasePalette;
53
53
  spacing: number;
54
- space: number[];
54
+ space: string[];
55
55
 
56
56
  colors: Colors;
57
57
 
@@ -374,7 +374,7 @@ declare var _default: {
374
374
  whiteOpacity: (opacity: number) => string;
375
375
  };
376
376
  spacing: number;
377
- space: number[];
377
+ space: string[];
378
378
  colors: import("../base").Colors;
379
379
  anchorNavigation: {
380
380
  divider: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "104.52.0",
3
+ "version": "104.53.0",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "engineStrict": true,
6
6
  "engines": {