@telus-uds/components-base 1.18.0 → 1.19.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +30 -2
  2. package/component-docs.json +111 -16
  3. package/jest.config-android.js +17 -0
  4. package/jest.config-ios.js +18 -0
  5. package/jest.config-web.js +31 -0
  6. package/lib/Button/ButtonBase.js +6 -2
  7. package/lib/Carousel/Carousel.js +32 -4
  8. package/lib/Carousel/CarouselTabs/CarouselTabsPanel.js +1 -10
  9. package/lib/Pagination/SideButton.js +6 -4
  10. package/lib/Responsive/Responsive.js +58 -0
  11. package/lib/Responsive/index.js +13 -0
  12. package/lib/Search/Search.js +37 -62
  13. package/lib/Tags/Tags.js +10 -4
  14. package/lib/TextInput/TextInputBase.js +53 -19
  15. package/lib/index.js +9 -0
  16. package/lib-module/Button/ButtonBase.js +6 -2
  17. package/lib-module/Carousel/Carousel.js +32 -4
  18. package/lib-module/Carousel/CarouselTabs/CarouselTabsPanel.js +1 -10
  19. package/lib-module/Pagination/SideButton.js +6 -4
  20. package/lib-module/Responsive/Responsive.js +45 -0
  21. package/lib-module/Responsive/index.js +2 -0
  22. package/lib-module/Search/Search.js +37 -60
  23. package/lib-module/Tags/Tags.js +10 -4
  24. package/lib-module/TextInput/TextInputBase.js +52 -19
  25. package/lib-module/index.js +1 -0
  26. package/package.json +6 -3
  27. package/src/Button/ButtonBase.jsx +4 -2
  28. package/src/Carousel/Carousel.jsx +42 -10
  29. package/src/Carousel/CarouselTabs/CarouselTabsPanel.jsx +0 -10
  30. package/src/Pagination/SideButton.jsx +5 -5
  31. package/src/Responsive/Responsive.jsx +33 -0
  32. package/src/Responsive/index.js +3 -0
  33. package/src/Search/Search.jsx +20 -32
  34. package/src/Tags/Tags.jsx +46 -33
  35. package/src/TextInput/TextInputBase.jsx +46 -16
  36. package/src/index.js +1 -0
package/CHANGELOG.md CHANGED
@@ -1,12 +1,40 @@
1
1
  # Change Log - @telus-uds/components-base
2
2
 
3
- This log was last generated on Tue, 27 Sep 2022 19:31:35 GMT and should not be manually modified.
3
+ This log was last generated on Fri, 14 Oct 2022 19:26:37 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 1.19.0
8
+
9
+ Fri, 14 Oct 2022 19:26:37 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - Responsive component implementation and tests (srikanthkhari@gmail.com)
14
+ - Add snapshot tests for base components (evander.owusu@telus.com)
15
+ - feat: add right-side buttons to the TextInputBase (ruslan.bredikhin@nearform.com)
16
+ - Add a `text` variant for `Button` (shahzaibkhalidmalik@outlook.com)
17
+ - Show/Hide Previous and Next on Pagination for larger screens (tiagohldb@gmail.com)
18
+ - Bump @telus-uds/system-constants to v1.1.0
19
+ - Bump @telus-uds/system-theme-tokens to v2.7.0
20
+
21
+ ### Patches
22
+
23
+ - Fix double-icon bug in Tags (alan.slater@nearform.com)
24
+ - Make initial focus of a Carousel more intuitive when refocus is on (alan.slater@nearform.com)
25
+ - Don't jump focus to next carousel tab on focusing first item in tabs (alan.slater@nearform.com)
26
+
27
+ ## 1.18.1
28
+
29
+ Wed, 05 Oct 2022 21:32:07 GMT
30
+
31
+ ### Patches
32
+
33
+ - feat: add passing native / test ID from the search to the input (ruslan.bredikhin@nearform.com)
34
+
7
35
  ## 1.18.0
8
36
 
9
- Tue, 27 Sep 2022 19:31:35 GMT
37
+ Tue, 27 Sep 2022 19:33:40 GMT
10
38
 
11
39
  ### Minor changes
12
40
 
@@ -35,7 +35,9 @@
35
35
  "outerBorderColor": "color",
36
36
  "outerBorderWidth": "border",
37
37
  "outerBorderGap": "size",
38
- "outerBackgroundColor": "color"
38
+ "outerBackgroundColor": "color",
39
+ "textLine": "textLine",
40
+ "textLineStyle": "textLineStyle"
39
41
  },
40
42
  "ButtonGroup": {
41
43
  "space": "integer",
@@ -403,7 +405,8 @@
403
405
  "iconSize": "size",
404
406
  "iconDisplace": "size",
405
407
  "width": "size",
406
- "textAlign": "flexJustifyContent"
408
+ "textAlign": "flexJustifyContent",
409
+ "displayLabel": "show"
407
410
  },
408
411
  "Progress": {
409
412
  "backgroundColor": "color",
@@ -821,6 +824,9 @@
821
824
  "borderWidth": "border",
822
825
  "borderColor": "color",
823
826
  "borderRadius": "radius",
827
+ "buttonSize": "size",
828
+ "buttonsGap": "size",
829
+ "buttonsPaddingRight": "size",
824
830
  "paddingTop": "size",
825
831
  "paddingBottom": "size",
826
832
  "paddingLeft": "size",
@@ -1344,6 +1350,13 @@
1344
1350
  ],
1345
1351
  "description": "Determines which way does the button navigate in Pagination's context",
1346
1352
  "type": "state"
1353
+ },
1354
+ "compact": {
1355
+ "values": [
1356
+ true
1357
+ ],
1358
+ "description": "Determines if the \"Next\" and \"Previous\" labels should be omitted",
1359
+ "type": "state"
1347
1360
  }
1348
1361
  },
1349
1362
  "ProgressBar": {
@@ -5496,7 +5509,8 @@
5496
5509
  "iconSize": "size",
5497
5510
  "iconDisplace": "size",
5498
5511
  "width": "size",
5499
- "textAlign": "flexJustifyContent"
5512
+ "textAlign": "flexJustifyContent",
5513
+ "displayLabel": "show"
5500
5514
  }
5501
5515
  },
5502
5516
  "required": false,
@@ -6409,6 +6423,81 @@
6409
6423
  }
6410
6424
  }
6411
6425
  },
6426
+ "Responsive": {
6427
+ "docs": {
6428
+ "description": "Responsive conditionally renders children based on whether the viewport matches the provided\nmin and max viewports.\n\nIn SSR, like other viewport utilities, it treats the viewport as `xs` both in SSR itself and\nduring first hydration on the client side; then if the viewport is not `xs`, it re-renders\nafter hydration. This may cause a layout shift on devices other than the narrowest.",
6429
+ "props": {
6430
+ "min": {
6431
+ "defaultValue": {
6432
+ "value": "'xs'",
6433
+ "computed": false
6434
+ },
6435
+ "type": {
6436
+ "name": "enum",
6437
+ "value": [
6438
+ {
6439
+ "value": "'xs'",
6440
+ "computed": false
6441
+ },
6442
+ {
6443
+ "value": "'sm'",
6444
+ "computed": false
6445
+ },
6446
+ {
6447
+ "value": "'md'",
6448
+ "computed": false
6449
+ },
6450
+ {
6451
+ "value": "'lg'",
6452
+ "computed": false
6453
+ },
6454
+ {
6455
+ "value": "'xl'",
6456
+ "computed": false
6457
+ }
6458
+ ]
6459
+ },
6460
+ "required": false,
6461
+ "description": ""
6462
+ },
6463
+ "max": {
6464
+ "type": {
6465
+ "name": "enum",
6466
+ "value": [
6467
+ {
6468
+ "value": "'sm'",
6469
+ "computed": false
6470
+ },
6471
+ {
6472
+ "value": "'md'",
6473
+ "computed": false
6474
+ },
6475
+ {
6476
+ "value": "'lg'",
6477
+ "computed": false
6478
+ },
6479
+ {
6480
+ "value": "'xl'",
6481
+ "computed": false
6482
+ }
6483
+ ]
6484
+ },
6485
+ "required": false,
6486
+ "description": ""
6487
+ },
6488
+ "children": {
6489
+ "type": {
6490
+ "name": "node"
6491
+ },
6492
+ "required": true,
6493
+ "description": ""
6494
+ }
6495
+ },
6496
+ "attributes": {
6497
+ "acceptsRNA11yProps": false
6498
+ }
6499
+ }
6500
+ },
6412
6501
  "Search": {
6413
6502
  "docs": {
6414
6503
  "description": "The `Search` component is a combination of a `TextInput` and 2 different kinds of custom buttons.\nUse `Search` to feature autocomplete interactions.\n\nThis component includes a clear button, which will appear as text is entered and pressing it will\ncause the input's internal state value to be set to an empty string.\n\nThis component may only be used as uncontrolled, as the search value is managed within an internal state.\nYou can use the `onChange` prop to react to value changes and the `onSubmit` prop to react on search submission.\n\nUse the following props to supply additional accessibility labels for the input - `accessibilityLabel`,\nclear button - `clearButtonAccessibilityLabel`, and submit button - `submitButtonAccessibilityLabel`.",
@@ -8763,7 +8852,9 @@
8763
8852
  "outerBorderColor": "color",
8764
8853
  "outerBorderWidth": "border",
8765
8854
  "outerBorderGap": "size",
8766
- "outerBackgroundColor": "color"
8855
+ "outerBackgroundColor": "color",
8856
+ "textLine": "textLine",
8857
+ "textLineStyle": "textLineStyle"
8767
8858
  }
8768
8859
  },
8769
8860
  "required": false,
@@ -9152,7 +9243,9 @@
9152
9243
  "outerBorderColor": "color",
9153
9244
  "outerBorderWidth": "border",
9154
9245
  "outerBorderGap": "size",
9155
- "outerBackgroundColor": "color"
9246
+ "outerBackgroundColor": "color",
9247
+ "textLine": "textLine",
9248
+ "textLineStyle": "textLineStyle"
9156
9249
  }
9157
9250
  },
9158
9251
  "required": false,
@@ -9571,17 +9664,6 @@
9571
9664
  "required": false,
9572
9665
  "description": "HTML tag to use for the Carousel item's immediate parent. Defaults to `'ul'` so that\nassistive technology tools know to intepret the carousel as a list.\n\nNote that if the immediate Carousel children do not all render as `'li'` elements,\nthis should be changed (e.g. pass tag=\"div\") because only 'li' is a valid child of 'ul'."
9573
9666
  },
9574
- "accessibilityLabel": {
9575
- "defaultValue": {
9576
- "value": "title",
9577
- "computed": true
9578
- },
9579
- "type": {
9580
- "name": "string"
9581
- },
9582
- "required": false,
9583
- "description": "Provide custom accessibilityLabel for Carousel container"
9584
- },
9585
9667
  "accessibilityLiveRegion": {
9586
9668
  "defaultValue": {
9587
9669
  "value": "'polite'",
@@ -9728,6 +9810,13 @@
9728
9810
  },
9729
9811
  "required": false,
9730
9812
  "description": "Provide custom accessibilityRole for Carousel container"
9813
+ },
9814
+ "accessibilityLabel": {
9815
+ "type": {
9816
+ "name": "string"
9817
+ },
9818
+ "required": false,
9819
+ "description": "Provide custom accessibilityLabel for Carousel container"
9731
9820
  }
9732
9821
  },
9733
9822
  "attributes": {
@@ -11757,6 +11846,9 @@
11757
11846
  "borderWidth": "border",
11758
11847
  "borderColor": "color",
11759
11848
  "borderRadius": "radius",
11849
+ "buttonSize": "size",
11850
+ "buttonsGap": "size",
11851
+ "buttonsPaddingRight": "size",
11760
11852
  "paddingTop": "size",
11761
11853
  "paddingBottom": "size",
11762
11854
  "paddingLeft": "size",
@@ -11855,6 +11947,9 @@
11855
11947
  "borderWidth": "border",
11856
11948
  "borderColor": "color",
11857
11949
  "borderRadius": "radius",
11950
+ "buttonSize": "size",
11951
+ "buttonsGap": "size",
11952
+ "buttonsPaddingRight": "size",
11858
11953
  "paddingTop": "size",
11859
11954
  "paddingBottom": "size",
11860
11955
  "paddingLeft": "size",
@@ -0,0 +1,17 @@
1
+ const defaultConfig = require('./jest.config')
2
+
3
+ const config = { ...defaultConfig }
4
+
5
+ // Run tests so React Native sees Platform as 'android'
6
+ config.haste.defaultPlatform = 'android'
7
+ // Save snapshots with `.android` in filename
8
+ config.snapshotResolver = './jest-snapshots/resolver-android.js'
9
+
10
+ // Ignore non-applicable test files
11
+ config.testPathIgnorePatterns = [
12
+ ...(config.testPathIgnorePatterns || []),
13
+ '\\.web\\.test\\.',
14
+ '\\.ios\\.test\\.'
15
+ ]
16
+
17
+ module.exports = config
@@ -0,0 +1,18 @@
1
+ const defaultConfig = require('./jest.config')
2
+
3
+ const config = { ...defaultConfig }
4
+
5
+ // ios is the React Native Jest default, but let's make it explicit:
6
+ // Run tests so React Native sees Platform as 'ios'
7
+ config.haste.defaultPlatform = 'ios'
8
+ // Save snapshots with `.ios` in filename
9
+ config.snapshotResolver = './jest-snapshots/resolver-ios.js'
10
+
11
+ // Ignore non-applicable test files
12
+ config.testPathIgnorePatterns = [
13
+ ...(config.testPathIgnorePatterns || []),
14
+ '\\.web\\.test\\.',
15
+ '\\.android\\.test\\.'
16
+ ]
17
+
18
+ module.exports = config
@@ -0,0 +1,31 @@
1
+ const defaultConfig = require('./jest.config')
2
+
3
+ const config = { ...defaultConfig }
4
+
5
+ // Run tests so React Native sees Platform as 'web'
6
+ config.haste.defaultPlatform = 'web'
7
+ config.haste.platforms = [...config.haste.platforms, 'web']
8
+
9
+ // Save snapshots with `.web` in filename
10
+ config.snapshotResolver = './jest-snapshots/resolver-web.js'
11
+ // Alias react-native to react-native-web
12
+ config.moduleNameMapper = {
13
+ '^react-native$': 'react-native-web',
14
+ ...config.moduleNameMapper
15
+ }
16
+
17
+ // Don't include the original react native setup file as it doesn't work with web
18
+ // React-native-web no longer has a matching file so it gets lost looking for `..\Libraries\...` etc
19
+ config.setupFiles = config.setupFiles.filter(
20
+ (file) => !file.match(/[\\/]react-native[\\/]jest[\\/]/)
21
+ )
22
+
23
+ // Ignore non-applicable test files
24
+ config.testPathIgnorePatterns = [
25
+ ...(config.testPathIgnorePatterns || []),
26
+ '\\.native\\.test\\.',
27
+ '\\.android\\.test\\.',
28
+ '\\.ios\\.test\\.'
29
+ ]
30
+
31
+ module.exports = config
@@ -163,7 +163,9 @@ const selectTextStyles = (_ref6, themeOptions) => {
163
163
  lineHeight,
164
164
  fontName,
165
165
  fontWeight,
166
- textAlign
166
+ textAlign,
167
+ textLine,
168
+ textLineStyle
167
169
  } = _ref6;
168
170
  return (0, _ThemeProvider.applyTextStyles)({
169
171
  fontSize,
@@ -172,7 +174,9 @@ const selectTextStyles = (_ref6, themeOptions) => {
172
174
  fontName,
173
175
  fontWeight,
174
176
  themeOptions,
175
- textAlign
177
+ textAlign,
178
+ textDecorationLine: textLine,
179
+ textDecorationStyle: textLineStyle
176
180
  });
177
181
  };
178
182
 
@@ -157,6 +157,8 @@ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_u
157
157
  */
158
158
 
159
159
  const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
160
+ var _systemProps$accessib;
161
+
160
162
  let {
161
163
  tokens,
162
164
  variant,
@@ -180,7 +182,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
180
182
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_CarouselStepTracker.default, {}),
181
183
  tag = 'ul',
182
184
  accessibilityRole,
183
- accessibilityLabel = title,
185
+ accessibilityLabel,
184
186
  accessibilityLiveRegion = 'polite',
185
187
  copy,
186
188
  ...rest
@@ -451,6 +453,33 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
451
453
  const activePanelNavigation = tabs && showPanelTabs ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_CarouselTabsPanel.default, {
452
454
  items: tabs
453
455
  }) : panelNavigation;
456
+ const isFirstFocusContainer = Boolean(refocus && !skipLinkHref);
457
+
458
+ const containerRef = element => {
459
+ // Apply both firstFocusRef to the container
460
+ firstFocusRef.current = element; // Also apply forwarded ref if there is one (which could be a function ref)
461
+
462
+ if (ref) {
463
+ if (typeof ref === 'object') {
464
+ // eslint-disable-next-line no-param-reassign
465
+ ref.current = element;
466
+ } else if (typeof ref === 'function') {
467
+ ref(element);
468
+ }
469
+ }
470
+ }; // If container isn't used for focus, give it a label of title if none is passed in,
471
+ // otherwise read the current position on focus
472
+
473
+
474
+ const containerAccessibilityLabel = ((_systemProps$accessib = systemProps.accessibilityLabel) !== null && _systemProps$accessib !== void 0 ? _systemProps$accessib : isFirstFocusContainer) ? "".concat(title ? "".concat(title, " ") : '').concat(getCopyWithPlaceholders('stepTrackerLabel')) : title;
475
+ const containerProps = {
476
+ accessibilityLabel: containerAccessibilityLabel,
477
+ // If used for focus, attach the ref and draw a focus box around the whole carousel
478
+ ...(isFirstFocusContainer && {
479
+ ref: containerRef,
480
+ focusable: true
481
+ })
482
+ };
454
483
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_CarouselContext.CarouselProvider, {
455
484
  activeIndex: activeIndex,
456
485
  goTo: goTo,
@@ -466,6 +495,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
466
495
  onLayout: onContainerLayout,
467
496
  ref: ref,
468
497
  ...systemProps,
498
+ ...containerProps,
469
499
  children: [showPreviousNextNavigation && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
470
500
  style: selectPreviousNextNavigationButtonStyles(previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, true),
471
501
  testID: "previous-button-container",
@@ -480,12 +510,10 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
480
510
  ref: firstFocusRef,
481
511
  href: skipLinkHref,
482
512
  children: getCopyWithPlaceholders('skipLink')
483
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_A11yText.default // Read the current slide position to screen readers on slide.
513
+ }), !isFirstFocusContainer && /*#__PURE__*/(0, _jsxRuntime.jsx)(_A11yText.default // Read the current slide position to screen readers on slide.
484
514
  // If it's set to refocus and doesn't have a SkipLink to focus to, focus this.
485
515
  , {
486
- ref: !skipLinkHref && refocus ? firstFocusRef : null,
487
516
  accessibilityLiveRegion: !skipLinkHref && refocus ? undefined : 'polite',
488
- focusable: !skipLinkHref && refocus,
489
517
  text: getCopyWithPlaceholders('stepTrackerLabel')
490
518
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
491
519
  style: selectContainerStyles(containerLayout.width),
@@ -43,16 +43,7 @@ const CarouselTabsPanel = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
43
43
  };
44
44
  const lastTabSelected = activeIndex === items.length - 1;
45
45
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
46
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
47
- focusable: true,
48
- accessible: true,
49
- onFocus: event => {
50
- // When user forward-tabs into this section, focus the next tab; if they backwards-tab
51
- // (shift-tab) back into the carousel content, don't interfere.
52
- const previousWebFocus = event.relatedTarget;
53
- if (previousWebFocus !== firstTabRef.current) nextFocusRef.current.focus();
54
- }
55
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_StackView.default, {
46
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_StackView.default, {
56
47
  direction: "row",
57
48
  space: 3,
58
49
  divider: {
@@ -34,10 +34,12 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
34
34
  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; }
35
35
 
36
36
  // We need to drop the icon here since it gets rendered via children and not
37
- // `ButtonBase` in order to tap into the state of the button
37
+ // `ButtonBase` in order to tap into the state of the button; `displayLabel` flag
38
+ // is also not needed
38
39
  const selectButtonTokens = _ref => {
39
40
  let {
40
41
  icon: _,
42
+ displayLabel: __,
41
43
  ...rest
42
44
  } = _ref;
43
45
  return (0, _utils.selectTokens)('Button', rest);
@@ -82,7 +84,8 @@ const SideButton = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
82
84
  copy
83
85
  });
84
86
  const {
85
- icon
87
+ icon,
88
+ displayLabel
86
89
  } = getTokens(tokens, buttonVariant);
87
90
 
88
91
  const getButtonTokens = buttonState => selectButtonTokens(getTokens(buttonState));
@@ -90,7 +93,6 @@ const SideButton = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
90
93
  const getIconTokens = buttonState => selectIconTokens(getTokens(buttonState), direction);
91
94
 
92
95
  const label = direction === 'previous' ? getCopy('previousText') : getCopy('nextText');
93
- const showLabel = viewport !== 'sm' && viewport !== 'xs';
94
96
  const accessibilityLabel = direction === 'previous' ? getCopy('previousLabel') : getCopy('nextLabel');
95
97
  const accessibilityRole = href !== undefined ? 'link' : 'button';
96
98
 
@@ -124,7 +126,7 @@ const SideButton = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
124
126
  space: 1,
125
127
  iconPosition: directionToSide[direction],
126
128
  iconProps: iconProps,
127
- children: showLabel && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
129
+ children: displayLabel && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
128
130
  style: textStyles,
129
131
  children: label
130
132
  })
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _systemConstants = require("@telus-uds/system-constants");
13
+
14
+ var _utils = require("../utils");
15
+
16
+ var _jsxRuntime = require("react/jsx-runtime");
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ /**
21
+ * Responsive conditionally renders children based on whether the viewport matches the provided
22
+ * min and max viewports.
23
+ *
24
+ * In SSR, like other viewport utilities, it treats the viewport as `xs` both in SSR itself and
25
+ * during first hydration on the client side; then if the viewport is not `xs`, it re-renders
26
+ * after hydration. This may cause a layout shift on devices other than the narrowest.
27
+ */
28
+ const Responsive = _ref => {
29
+ let {
30
+ min = 'xs',
31
+ max,
32
+ children
33
+ } = _ref;
34
+ // Start returning children at the 'min' viewport or greater
35
+ const byViewports = {
36
+ [min]: children
37
+ };
38
+
39
+ if (max && max !== 'xl') {
40
+ // Stop returning children at the viewport one above 'max' or greater
41
+ const maxIndex = _systemConstants.viewports.keys.indexOf(max);
42
+
43
+ const maxPlusOne = maxIndex >= 0 ? _systemConstants.viewports.keys[maxIndex + 1] : null;
44
+ if (maxPlusOne) byViewports[maxPlusOne] = null;
45
+ }
46
+
47
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
48
+ children: (0, _utils.useResponsiveProp)(byViewports, null)
49
+ });
50
+ };
51
+
52
+ Responsive.propTypes = {
53
+ min: _propTypes.default.oneOf(['xs', 'sm', 'md', 'lg', 'xl']),
54
+ max: _propTypes.default.oneOf(['sm', 'md', 'lg', 'xl']),
55
+ children: _propTypes.default.node.isRequired
56
+ };
57
+ var _default = Responsive;
58
+ exports.default = _default;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _Responsive = _interopRequireDefault(require("./Responsive"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ var _default = _Responsive.default;
13
+ exports.default = _default;