@telus-uds/components-base 1.12.0 → 1.12.1

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 (78) hide show
  1. package/CHANGELOG.md +10 -2
  2. package/component-docs.json +67 -11
  3. package/lib/BaseProvider/index.js +7 -2
  4. package/lib/Button/ButtonBase.js +18 -14
  5. package/lib/Carousel/Carousel.js +19 -51
  6. package/lib/Carousel/CarouselContext.js +12 -4
  7. package/lib/Carousel/CarouselStepTracker/CarouselStepTracker.js +56 -0
  8. package/lib/Carousel/CarouselStepTracker/index.js +13 -0
  9. package/lib/Checkbox/Checkbox.js +7 -3
  10. package/lib/Checkbox/CheckboxGroup.js +1 -1
  11. package/lib/Feedback/Feedback.js +18 -10
  12. package/lib/Icon/IconText.js +5 -0
  13. package/lib/InputLabel/InputLabel.js +11 -5
  14. package/lib/Link/LinkBase.js +7 -3
  15. package/lib/List/ListItem.js +7 -3
  16. package/lib/Notification/Notification.js +7 -2
  17. package/lib/Pagination/Pagination.js +7 -3
  18. package/lib/RadioCard/RadioCard.js +6 -1
  19. package/lib/Select/Select.js +7 -3
  20. package/lib/StepTracker/Step.js +8 -4
  21. package/lib/StepTracker/StepTracker.js +7 -3
  22. package/lib/Tabs/TabsItem.js +4 -0
  23. package/lib/TextInput/TextInputBase.js +7 -3
  24. package/lib/ThemeProvider/ThemeProvider.js +20 -3
  25. package/lib/ThemeProvider/utils/styles.js +8 -1
  26. package/lib/ThemeProvider/utils/theme-tokens.js +1 -1
  27. package/lib/Typography/Typography.js +6 -2
  28. package/lib-module/BaseProvider/index.js +7 -2
  29. package/lib-module/Button/ButtonBase.js +7 -3
  30. package/lib-module/Carousel/Carousel.js +18 -50
  31. package/lib-module/Carousel/CarouselContext.js +11 -4
  32. package/lib-module/Carousel/CarouselStepTracker/CarouselStepTracker.js +42 -0
  33. package/lib-module/Carousel/CarouselStepTracker/index.js +2 -0
  34. package/lib-module/Checkbox/Checkbox.js +8 -4
  35. package/lib-module/Checkbox/CheckboxGroup.js +1 -1
  36. package/lib-module/Feedback/Feedback.js +19 -11
  37. package/lib-module/Icon/IconText.js +5 -0
  38. package/lib-module/InputLabel/InputLabel.js +12 -6
  39. package/lib-module/Link/LinkBase.js +8 -4
  40. package/lib-module/List/ListItem.js +8 -4
  41. package/lib-module/Notification/Notification.js +8 -3
  42. package/lib-module/Pagination/Pagination.js +8 -4
  43. package/lib-module/RadioCard/RadioCard.js +7 -2
  44. package/lib-module/Select/Select.js +8 -4
  45. package/lib-module/StepTracker/Step.js +9 -5
  46. package/lib-module/StepTracker/StepTracker.js +8 -4
  47. package/lib-module/Tabs/TabsItem.js +5 -1
  48. package/lib-module/TextInput/TextInputBase.js +8 -4
  49. package/lib-module/ThemeProvider/ThemeProvider.js +20 -3
  50. package/lib-module/ThemeProvider/utils/styles.js +8 -1
  51. package/lib-module/ThemeProvider/utils/theme-tokens.js +1 -1
  52. package/lib-module/Typography/Typography.js +7 -3
  53. package/package.json +1 -1
  54. package/src/BaseProvider/index.jsx +6 -3
  55. package/src/Button/ButtonBase.jsx +8 -3
  56. package/src/Carousel/Carousel.jsx +27 -58
  57. package/src/Carousel/CarouselContext.jsx +15 -4
  58. package/src/Carousel/CarouselStepTracker/CarouselStepTracker.jsx +36 -0
  59. package/src/Carousel/CarouselStepTracker/index.js +3 -0
  60. package/src/Checkbox/Checkbox.jsx +14 -11
  61. package/src/Checkbox/CheckboxGroup.jsx +1 -1
  62. package/src/Feedback/Feedback.jsx +14 -7
  63. package/src/Icon/IconText.jsx +2 -0
  64. package/src/InputLabel/InputLabel.jsx +13 -12
  65. package/src/Link/LinkBase.jsx +10 -4
  66. package/src/List/ListItem.jsx +9 -4
  67. package/src/Notification/Notification.jsx +5 -3
  68. package/src/Pagination/Pagination.jsx +6 -4
  69. package/src/RadioCard/RadioCard.jsx +3 -2
  70. package/src/Select/Select.jsx +12 -3
  71. package/src/StepTracker/Step.jsx +12 -4
  72. package/src/StepTracker/StepTracker.jsx +11 -10
  73. package/src/Tabs/TabsItem.jsx +3 -2
  74. package/src/TextInput/TextInputBase.jsx +11 -3
  75. package/src/ThemeProvider/ThemeProvider.jsx +16 -3
  76. package/src/ThemeProvider/utils/styles.js +9 -1
  77. package/src/ThemeProvider/utils/theme-tokens.js +1 -1
  78. package/src/Typography/Typography.jsx +11 -12
package/CHANGELOG.md CHANGED
@@ -1,12 +1,20 @@
1
1
  # Change Log - @telus-uds/components-base
2
2
 
3
- This log was last generated on Thu, 28 Jul 2022 19:37:23 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 02 Aug 2022 22:59:06 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 1.12.1
8
+
9
+ Tue, 02 Aug 2022 22:59:06 GMT
10
+
11
+ ### Patches
12
+
13
+ - relative font sizes and carousel enhancements (srikanthkhari@gmail.com)
14
+
7
15
  ## 1.12.0
8
16
 
9
- Thu, 28 Jul 2022 19:37:23 GMT
17
+ Thu, 28 Jul 2022 19:38:24 GMT
10
18
 
11
19
  ### Minor changes
12
20
 
@@ -1888,6 +1888,13 @@
1888
1888
  "docs": {
1889
1889
  "description": "",
1890
1890
  "props": {
1891
+ "children": {
1892
+ "type": {
1893
+ "name": "node"
1894
+ },
1895
+ "required": true,
1896
+ "description": ""
1897
+ },
1891
1898
  "defaultTheme": {
1892
1899
  "type": {
1893
1900
  "name": "custom",
@@ -1896,11 +1903,17 @@
1896
1903
  "required": false,
1897
1904
  "description": ""
1898
1905
  },
1899
- "children": {
1906
+ "themeOptions": {
1900
1907
  "type": {
1901
- "name": "node"
1908
+ "name": "shape",
1909
+ "value": {
1910
+ "forceAbsoluteFontSizing": {
1911
+ "name": "bool",
1912
+ "required": false
1913
+ }
1914
+ }
1902
1915
  },
1903
- "required": true,
1916
+ "required": false,
1904
1917
  "description": ""
1905
1918
  }
1906
1919
  },
@@ -7472,6 +7485,23 @@
7472
7485
  "docs": {
7473
7486
  "description": "",
7474
7487
  "props": {
7488
+ "themeOptions": {
7489
+ "defaultValue": {
7490
+ "value": "{ forceAbsoluteFontSizing: true }",
7491
+ "computed": false
7492
+ },
7493
+ "type": {
7494
+ "name": "shape",
7495
+ "value": {
7496
+ "forceAbsoluteFontSizing": {
7497
+ "name": "bool",
7498
+ "required": false
7499
+ }
7500
+ }
7501
+ },
7502
+ "required": false,
7503
+ "description": "An object containing options allowing to customize the theming experience:\n\n- `forceAbsoluteFontSizing`: available on web only; when set to true, allows\n using absolute font sizing (in pixels, doesn't scale) instead of the\n relative sizing (in `rem`, scales depending on the browser settings)"
7504
+ },
7475
7505
  "children": {
7476
7506
  "type": {
7477
7507
  "name": "node"
@@ -8504,6 +8534,17 @@
8504
8534
  "required": false,
8505
8535
  "description": "Carousel uses `Animated.spring` to animate slide changes, use this option to pass custom animation configuration"
8506
8536
  },
8537
+ "panelNavigation": {
8538
+ "defaultValue": {
8539
+ "value": "<CarouselStepTracker />",
8540
+ "computed": false
8541
+ },
8542
+ "type": {
8543
+ "name": "element"
8544
+ },
8545
+ "required": false,
8546
+ "description": "Use this to render a custom panel navigation element instead of the default StepTracker's based navigation\nYou can make use of `useCarousel` within your custom panel navigation component to hook into various Carousel states such as:\n- activeIndex: index of current slide\n- totalItems: total number of slides\nUse it as follows:\n```js\n <Carousel\n panelNavigation={<CustomPanelNavigation />}\n >\n <Carousel.Item>First Slide</Carousel.Item>\n </Carousel>\n```"
8547
+ },
8507
8548
  "tag": {
8508
8549
  "defaultValue": {
8509
8550
  "value": "'ul'",
@@ -8676,13 +8717,6 @@
8676
8717
  "required": false,
8677
8718
  "description": "Called when active index changed\nThis function is also provided with a parameter indicating changed index (either 1, or -1)\nUse it as follows:\n```js\n const onIndexChangedCallback = React.useCallback((changedIndex) => {\n console.log(changedIndex)\n }, []) // pass local dependencies as per your component\n <Carousel\n onIndexChanged={onIndexChangedCallback}\n >\n <Carousel.Item>First Slide</Carousel.Item>\n </Carousel>\n```\nCaution: Always consider wrapping your callback for `onIndexChanged` in `useCallback` in order to avoid bugs and performance issues"
8678
8719
  },
8679
- "onRenderPanelNavigation": {
8680
- "type": {
8681
- "name": "func"
8682
- },
8683
- "required": false,
8684
- "description": "Use this to render a custom panel navigation element instead of dots navigation\nThis function is also provided with an object with the following properties\nactiveIndex: index of current slide\ntotalItems: total number of slides\nUse it as follows:\n```js\n <Carousel\n onRenderPanelNavigation={({ totalItems, activeIndex }) => <Text>Showing {activeIndex + 1}</Text>}\n >\n <Carousel.Item>First Slide</Carousel.Item>\n </Carousel>\n```"
8685
- },
8686
8720
  "onAnimationStart": {
8687
8721
  "type": {
8688
8722
  "name": "func"
@@ -8904,6 +8938,28 @@
8904
8938
  },
8905
8939
  "required": true,
8906
8940
  "description": ""
8941
+ },
8942
+ "getCopyWithPlaceholders": {
8943
+ "type": {
8944
+ "name": "func"
8945
+ },
8946
+ "required": true,
8947
+ "description": ""
8948
+ },
8949
+ "themeTokens": {
8950
+ "type": {
8951
+ "name": "custom",
8952
+ "raw": {
8953
+ "nextIcon": "icon",
8954
+ "previousIcon": "icon",
8955
+ "showPreviousNextNavigation": "show",
8956
+ "showPanelNavigation": "show",
8957
+ "spaceBetweenSlideAndPreviousNextNavigation": "size",
8958
+ "spaceBetweenSlideAndPanelNavigation": "size"
8959
+ }
8960
+ },
8961
+ "required": false,
8962
+ "description": ""
8907
8963
  }
8908
8964
  },
8909
8965
  "attributes": {
@@ -8913,7 +8969,7 @@
8913
8969
  },
8914
8970
  "CheckboxGroup": {
8915
8971
  "docs": {
8916
- "description": "A group of Checkboxs that behave as a fieldset. Use when users select any number of choices from options.\n\n## Component API\n\nUse the `items` prop to pass an array of objects describing each Checkbox in the group:\n\n - `label`: main text passed to CheckboxGroup's `label` prop\n - `id`: identifier used to store which CheckboxGroup is selected (uses `label` if undefinded)\n - `onChange`: optional function called on selection, in addition to updating the group's selection state\n\n### Controlled version\n\nIf the selection state is controlled from outside, it needs to receive `checkedId` and `onChange` props.\n\n### Uncontrolled version\n\nIf the CheckboxGroup manages its own state, you can use `initialCheckedId` prop to provide the initial value.\nWhenever the radio card gets toggled, it calls the `onChange` callback with the new value (string).\n\n### Use in forms\n\nFor web forms, the `name` prop may be used to define the name of the group's `fieldset` and input elements.\n\n### Validation\n\nValidation state may be set by passing 'error' or 'success' to the `validation` prop.\n\n## A11y guidelines\n\nCheckboxGroup accepts all the common accessibility props, and controls the accessibility state\nof children like Checkbox and Feedback based on current state.\n\n@example\n```jsx\n<CheckboxGroup\n initialCheckedId=\"check1\"\n items={[\n { label: 'Checkbox 1', id: 'check1' },\n { label: 'Checkbox 2', id: 'check2' },\n { label: 'Checkbox 3', id: 'check3' }\n ]}\n legend=\"Checkboxes\"\n hint=\"Choose from these options\"\n/>\n```",
8972
+ "description": "A group of Checkboxs that behave as a fieldset. Use when users select any number of choices from options.\n\n## Component API\n\nUse the `items` prop to pass an array of objects describing each Checkbox in the group:\n\n - `label`: main text passed to CheckboxGroup's `label` prop\n - `id`: identifier used to store which CheckboxGroup is selected (uses `label` if undefinded)\n - `onChange`: optional function called on selection, in addition to updating the group's selection state\n\n### Controlled version\n\nIf the selection state is controlled from outside, it needs to receive `checkedId` and `onChange` props.\n\n### Uncontrolled version\n\nIf the CheckboxGroup manages its own state, you can use `initialCheckedId` prop to provide the initial value.\nWhenever the radio card gets toggled, it calls the `onChange` callback with the new value (string).\n\n### Use in forms\n\nFor web forms, the `name` prop may be used to define the name of the group's `fieldset` and input elements.\n\n### Validation\n\nValidation state may be set by passing 'error' or 'success' to the `validation` prop.\n\n## A11y guidelines\n\nCheckboxGroup accepts all the common accessibility props, and controls the accessibility state\nof children like Checkbox and Feedback based on current state.\n\n@example\n```jsx\n<CheckboxGroup\n initialCheckedIds=\"check1\"\n items={[\n { label: 'Checkbox 1', id: 'check1' },\n { label: 'Checkbox 2', id: 'check2' },\n { label: 'Checkbox 3', id: 'check3' }\n ]}\n legend=\"Checkboxes\"\n hint=\"Choose from these options\"\n/>\n```",
8917
8973
  "props": {
8918
8974
  "items": {
8919
8975
  "defaultValue": {
@@ -24,12 +24,14 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
24
24
  const BaseProvider = _ref => {
25
25
  let {
26
26
  defaultTheme,
27
- children
27
+ children,
28
+ themeOptions
28
29
  } = _ref;
29
30
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_A11yInfoProvider.default, {
30
31
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ViewportProvider.default, {
31
32
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ThemeProvider.default, {
32
33
  defaultTheme: defaultTheme,
34
+ themeOptions: themeOptions,
33
35
  children: children
34
36
  })
35
37
  })
@@ -37,8 +39,11 @@ const BaseProvider = _ref => {
37
39
  };
38
40
 
39
41
  BaseProvider.propTypes = {
42
+ children: _propTypes.default.node.isRequired,
40
43
  defaultTheme: (_ThemeProvider$propTy = _ThemeProvider.default.propTypes) === null || _ThemeProvider$propTy === void 0 ? void 0 : _ThemeProvider$propTy.defaultTheme,
41
- children: _propTypes.default.node.isRequired
44
+ themeOptions: _propTypes.default.shape({
45
+ forceAbsoluteFontSizing: _propTypes.default.bool
46
+ })
42
47
  };
43
48
  var _default = BaseProvider;
44
49
  exports.default = _default;
@@ -17,11 +17,11 @@ var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/expo
17
17
 
18
18
  var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
19
19
 
20
- var _utils = require("../ThemeProvider/utils");
20
+ var _ThemeProvider = require("../ThemeProvider");
21
21
 
22
22
  var _propTypes2 = _interopRequireDefault(require("./propTypes"));
23
23
 
24
- var _utils2 = require("../utils");
24
+ var _utils = require("../utils");
25
25
 
26
26
  var _jsxRuntime = require("react/jsx-runtime");
27
27
 
@@ -31,7 +31,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
31
31
 
32
32
  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; }
33
33
 
34
- const [selectProps, selectedSystemPropTypes] = (0, _utils2.selectSystemProps)([_utils2.a11yProps, _utils2.focusHandlerProps, _utils2.linkProps, _utils2.viewProps]);
34
+ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.linkProps, _utils.viewProps]);
35
35
 
36
36
  const getOuterBorderOffset = _ref => {
37
37
  let {
@@ -55,7 +55,7 @@ const selectOuterContainerStyles = _ref2 => {
55
55
  alignSelf,
56
56
  backgroundColor: outerBackgroundColor,
57
57
  opacity,
58
- ...(0, _utils.applyOuterBorder)({
58
+ ...(0, _ThemeProvider.applyOuterBorder)({
59
59
  outerBorderGap,
60
60
  outerBorderWidth,
61
61
  outerBorderColor,
@@ -137,7 +137,7 @@ const selectInnerContainerStyles = _ref4 => {
137
137
  paddingBottom: offsetBorder(paddingBottom),
138
138
  backgroundColor,
139
139
  minWidth,
140
- ...(0, _utils.applyShadowToken)(shadow)
140
+ ...(0, _ThemeProvider.applyShadowToken)(shadow)
141
141
  };
142
142
  };
143
143
 
@@ -154,7 +154,7 @@ const selectBorderStyles = _ref5 => {
154
154
  };
155
155
  };
156
156
 
157
- const selectTextStyles = _ref6 => {
157
+ const selectTextStyles = (_ref6, themeOptions) => {
158
158
  let {
159
159
  fontSize,
160
160
  color,
@@ -163,12 +163,13 @@ const selectTextStyles = _ref6 => {
163
163
  fontWeight,
164
164
  textAlign
165
165
  } = _ref6;
166
- return (0, _utils.applyTextStyles)({
166
+ return (0, _ThemeProvider.applyTextStyles)({
167
167
  fontSize,
168
168
  color,
169
169
  lineHeight,
170
170
  fontName,
171
171
  fontWeight,
172
+ themeOptions,
172
173
  textAlign
173
174
  });
174
175
  };
@@ -183,7 +184,7 @@ const selectWebOnlyStyles = (inactive, themeTokens, _ref7) => {
183
184
  maxWidth: "calc(100% + ".concat(getOuterBorderOffset(themeTokens) * 2, "px)"),
184
185
  outline: 'none',
185
186
  // removes the default browser :focus outline
186
- ...(0, _utils2.getCursorStyle)(inactive, accessibilityRole)
187
+ ...(0, _utils.getCursorStyle)(inactive, accessibilityRole)
187
188
  },
188
189
  default: {}
189
190
  });
@@ -206,14 +207,14 @@ const ButtonBase = /*#__PURE__*/(0, _react.forwardRef)((_ref8, ref) => {
206
207
  const {
207
208
  onPress,
208
209
  ...rest
209
- } = _utils2.clickProps.toPressProps(rawRest);
210
+ } = _utils.clickProps.toPressProps(rawRest);
210
211
 
211
212
  const extraButtonState = {
212
213
  inactive,
213
214
  selected
214
215
  };
215
216
 
216
- const resolveButtonTokens = pressableState => (0, _utils2.resolvePressableTokens)(tokens, pressableState, extraButtonState);
217
+ const resolveButtonTokens = pressableState => (0, _utils.resolvePressableTokens)(tokens, pressableState, extraButtonState);
217
218
 
218
219
  const systemProps = selectProps(rest);
219
220
 
@@ -222,10 +223,13 @@ const ButtonBase = /*#__PURE__*/(0, _react.forwardRef)((_ref8, ref) => {
222
223
  return [staticStyles.row, selectWebOnlyStyles(inactive, themeTokens, systemProps), selectOuterContainerStyles(themeTokens), selectOuterWidthStyles(themeTokens)];
223
224
  };
224
225
 
226
+ const {
227
+ themeOptions
228
+ } = (0, _ThemeProvider.useTheme)();
225
229
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Pressable.default, {
226
230
  ref: ref,
227
231
  href: href,
228
- onPress: _utils2.linkProps.handleHref({
232
+ onPress: _utils.linkProps.handleHref({
229
233
  href,
230
234
  onPress
231
235
  }),
@@ -237,7 +241,7 @@ const ButtonBase = /*#__PURE__*/(0, _react.forwardRef)((_ref8, ref) => {
237
241
  const themeTokens = resolveButtonTokens(pressableState);
238
242
  const containerStyles = selectInnerContainerStyles(themeTokens);
239
243
  const borderStyles = selectBorderStyles(themeTokens);
240
- const textStyles = [selectTextStyles(themeTokens), staticStyles.text]; // If the container has a width set, fill it instead of sizing from content.
244
+ const textStyles = [selectTextStyles(themeTokens, themeOptions), staticStyles.text]; // If the container has a width set, fill it instead of sizing from content.
241
245
  // If in future we support text alignments other than center, add here.
242
246
 
243
247
  const stretchStyles = themeTokens.width ? staticStyles.stretch : staticStyles.align;
@@ -251,7 +255,7 @@ const ButtonBase = /*#__PURE__*/(0, _react.forwardRef)((_ref8, ref) => {
251
255
  transition: 'background-color 200ms, border-color 200ms'
252
256
  }
253
257
  })],
254
- children: (0, _utils2.wrapStringsInText)(typeof children === 'function' ? children({ ...(0, _utils2.resolvePressableState)(pressableState, extraButtonState),
258
+ children: (0, _utils.wrapStringsInText)(typeof children === 'function' ? children({ ...(0, _utils.resolvePressableState)(pressableState, extraButtonState),
255
259
  textStyles
256
260
  }) : children, {
257
261
  style: textStyles
@@ -295,6 +299,6 @@ const staticStyles = _StyleSheet.default.create({
295
299
  }
296
300
  });
297
301
 
298
- var _default = (0, _utils2.withLinkRouter)(ButtonBase);
302
+ var _default = (0, _utils.withLinkRouter)(ButtonBase);
299
303
 
300
304
  exports.default = _default;
@@ -31,12 +31,10 @@ var _CarouselContext = require("./CarouselContext");
31
31
 
32
32
  var _CarouselItem = _interopRequireDefault(require("./CarouselItem"));
33
33
 
34
- var _StepTracker = _interopRequireDefault(require("../StepTracker"));
35
-
36
- var _StackView = _interopRequireDefault(require("../StackView"));
37
-
38
34
  var _IconButton = _interopRequireDefault(require("../IconButton"));
39
35
 
36
+ var _CarouselStepTracker = _interopRequireDefault(require("./CarouselStepTracker/CarouselStepTracker"));
37
+
40
38
  var _dictionary = _interopRequireDefault(require("./dictionary"));
41
39
 
42
40
  var _jsxRuntime = require("react/jsx-runtime");
@@ -54,19 +52,6 @@ const staticStyles = _StyleSheet.default.create({
54
52
  }
55
53
  });
56
54
 
57
- const staticTokens = {
58
- stackView: {
59
- justifyContent: 'center'
60
- },
61
- stepTracker: {
62
- showStepLabel: false,
63
- showStepTrackerLabel: true,
64
- knobCompletedBackgroundColor: 'none',
65
- connectorCompletedColor: 'none',
66
- connectorColor: 'none'
67
- }
68
- };
69
-
70
55
  const selectContainerStyles = width => ({
71
56
  backgroundColor: 'transparent',
72
57
  overflow: 'hidden',
@@ -175,7 +160,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
175
160
  onAnimationEnd,
176
161
  onIndexChanged,
177
162
  springConfig = undefined,
178
- onRenderPanelNavigation,
163
+ panelNavigation = /*#__PURE__*/(0, _jsxRuntime.jsx)(_CarouselStepTracker.default, {}),
179
164
  tag = 'ul',
180
165
  accessibilityRole = 'adjustable',
181
166
  accessibilityLabel = 'carousel',
@@ -183,16 +168,16 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
183
168
  ...rest
184
169
  } = _ref;
185
170
  const viewport = (0, _ViewportProvider.useViewport)();
171
+ const themeTokens = (0, _ThemeProvider.useThemeTokens)('Carousel', tokens, variant, {
172
+ viewport
173
+ });
186
174
  const {
187
175
  previousIcon,
188
176
  nextIcon,
189
177
  showPreviousNextNavigation,
190
178
  showPanelNavigation,
191
- spaceBetweenSlideAndPreviousNextNavigation,
192
- spaceBetweenSlideAndPanelNavigation
193
- } = (0, _ThemeProvider.useThemeTokens)('Carousel', tokens, variant, {
194
- viewport
195
- });
179
+ spaceBetweenSlideAndPreviousNextNavigation
180
+ } = themeTokens;
196
181
 
197
182
  const [activeIndex, setActiveIndex] = _react.default.useState(0);
198
183
 
@@ -244,9 +229,6 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
244
229
 
245
230
  const isFirstSlide = !activeIndex;
246
231
  const isLastSlide = activeIndex + 1 >= children.length;
247
- const panelNavigationTokens = { ...staticTokens.stepTracker,
248
- containerPaddingTop: spaceBetweenSlideAndPanelNavigation
249
- };
250
232
 
251
233
  const onContainerLayout = _ref2 => {
252
234
  let {
@@ -438,17 +420,19 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
438
420
  raised: true
439
421
  };
440
422
 
441
- const getCopyWithPlaceholders = copyKey => {
423
+ const getCopyWithPlaceholders = _react.default.useCallback(copyKey => {
442
424
  const copyText = getCopy(copyKey).replace(/%\{itemLabel\}/g, itemLabel).replace(/%\{stepNumber\}/g, activeIndex + 1).replace(/%\{stepCount\}/g, childrenArray.length); // First word might be a lowercase placeholder: capitalize the first letter
443
425
 
444
426
  return "".concat(copyText[0].toUpperCase()).concat(copyText.slice(1));
445
- };
427
+ }, [activeIndex, childrenArray.length, itemLabel, getCopy]);
446
428
 
447
429
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_CarouselContext.CarouselProvider, {
448
430
  activeIndex: activeIndex,
449
431
  totalItems: childrenArray.length,
450
432
  width: containerLayout.width,
451
433
  goTo: goTo,
434
+ getCopyWithPlaceholders: getCopyWithPlaceholders,
435
+ themeTokens: themeTokens,
452
436
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
453
437
  style: staticStyles.root,
454
438
  onLayout: onContainerLayout,
@@ -500,23 +484,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
500
484
  accessibilityLabel: getCopyWithPlaceholders('iconButtonLabel').replace('%{targetStep}', activeIndex + 2)
501
485
  })
502
486
  })]
503
- }), showPanelNavigation ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_StackView.default, {
504
- direction: "row",
505
- tokens: staticTokens.stackView,
506
- children: onRenderPanelNavigation ? onRenderPanelNavigation({
507
- activeIndex,
508
- totalItems: childrenArray.length
509
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_StepTracker.default, {
510
- current: activeIndex,
511
- steps: childrenArray.map((_, index) => String(index)),
512
- copy: {
513
- // Give StepTracker copy from Carousel's language and dictionary
514
- stepLabel: getCopyWithPlaceholders('stepLabel'),
515
- stepTrackerLabel: getCopyWithPlaceholders('stepTrackerLabel')
516
- },
517
- tokens: panelNavigationTokens
518
- })
519
- }) : null]
487
+ }), showPanelNavigation ? panelNavigation : null]
520
488
  });
521
489
  });
522
490
 
@@ -584,20 +552,20 @@ Carousel.propTypes = { ...selectedSystemPropTypes,
584
552
  onIndexChanged: _propTypes.default.func,
585
553
 
586
554
  /**
587
- * Use this to render a custom panel navigation element instead of dots navigation
588
- * This function is also provided with an object with the following properties
589
- * activeIndex: index of current slide
590
- * totalItems: total number of slides
555
+ * Use this to render a custom panel navigation element instead of the default StepTracker's based navigation
556
+ * You can make use of `useCarousel` within your custom panel navigation component to hook into various Carousel states such as:
557
+ * - activeIndex: index of current slide
558
+ * - totalItems: total number of slides
591
559
  * Use it as follows:
592
560
  * ```js
593
561
  * <Carousel
594
- * onRenderPanelNavigation={({ totalItems, activeIndex }) => <Text>Showing {activeIndex + 1}</Text>}
562
+ * panelNavigation={<CustomPanelNavigation />}
595
563
  * >
596
564
  * <Carousel.Item>First Slide</Carousel.Item>
597
565
  * </Carousel>
598
566
  * ```
599
567
  */
600
- onRenderPanelNavigation: _propTypes.default.func,
568
+ panelNavigation: _propTypes.default.element,
601
569
 
602
570
  /**
603
571
  * When slide animation start
@@ -10,6 +10,8 @@ var _react = _interopRequireDefault(require("react"));
10
10
 
11
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
12
12
 
13
+ var _utils = require("../utils");
14
+
13
15
  var _jsxRuntime = require("react/jsx-runtime");
14
16
 
15
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -22,15 +24,19 @@ const CarouselProvider = _ref => {
22
24
  activeIndex,
23
25
  totalItems,
24
26
  width,
25
- goTo
27
+ goTo,
28
+ getCopyWithPlaceholders,
29
+ themeTokens
26
30
  } = _ref;
27
31
 
28
32
  const value = _react.default.useMemo(() => ({
29
33
  activeIndex,
30
34
  totalItems,
31
35
  width,
32
- goTo
33
- }), [activeIndex, totalItems, width, goTo]);
36
+ goTo,
37
+ getCopyWithPlaceholders,
38
+ themeTokens
39
+ }), [activeIndex, totalItems, width, goTo, getCopyWithPlaceholders, themeTokens]);
34
40
 
35
41
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(CarouselContext.Provider, {
36
42
  value: value,
@@ -55,5 +61,7 @@ CarouselProvider.propTypes = {
55
61
  activeIndex: _propTypes.default.number.isRequired,
56
62
  totalItems: _propTypes.default.number.isRequired,
57
63
  width: _propTypes.default.number.isRequired,
58
- goTo: _propTypes.default.func.isRequired
64
+ goTo: _propTypes.default.func.isRequired,
65
+ getCopyWithPlaceholders: _propTypes.default.func.isRequired,
66
+ themeTokens: (0, _utils.getTokensPropType)('Carousel')
59
67
  };
@@ -0,0 +1,56 @@
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 _CarouselContext = require("../CarouselContext");
11
+
12
+ var _StepTracker = _interopRequireDefault(require("../../StepTracker"));
13
+
14
+ var _StackView = _interopRequireDefault(require("../../StackView"));
15
+
16
+ var _jsxRuntime = require("react/jsx-runtime");
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ const CarouselStepTracker = () => {
21
+ const {
22
+ activeIndex,
23
+ totalItems,
24
+ getCopyWithPlaceholders,
25
+ themeTokens
26
+ } = (0, _CarouselContext.useCarousel)();
27
+ const stackViewTokens = {
28
+ justifyContent: 'center'
29
+ };
30
+ const stepTrackerTokens = {
31
+ showStepLabel: false,
32
+ showStepTrackerLabel: true,
33
+ knobCompletedBackgroundColor: 'none',
34
+ connectorCompletedColor: 'none',
35
+ connectorColor: 'none',
36
+ containerPaddingTop: themeTokens.spaceBetweenSlideAndPanelNavigation
37
+ };
38
+ const steps = Array.from(Array(totalItems)).map((_, index) => String(index));
39
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_StackView.default, {
40
+ direction: "row",
41
+ tokens: stackViewTokens,
42
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_StepTracker.default, {
43
+ current: activeIndex,
44
+ steps: steps,
45
+ copy: {
46
+ // Give StepTracker copy from Carousel's language and dictionary
47
+ stepLabel: getCopyWithPlaceholders('stepLabel'),
48
+ stepTrackerLabel: getCopyWithPlaceholders('stepTrackerLabel')
49
+ },
50
+ tokens: stepTrackerTokens
51
+ })
52
+ });
53
+ };
54
+
55
+ var _default = CarouselStepTracker;
56
+ 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 _CarouselStepTracker = _interopRequireDefault(require("./CarouselStepTracker"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ var _default = _CarouselStepTracker.default;
13
+ exports.default = _default;
@@ -74,7 +74,7 @@ const selectInputStyles = (_ref, isChecked) => {
74
74
  };
75
75
  };
76
76
 
77
- const selectLabelStyles = _ref2 => {
77
+ const selectLabelStyles = (_ref2, themeOptions) => {
78
78
  let {
79
79
  labelColor,
80
80
  labelFontName,
@@ -90,7 +90,8 @@ const selectLabelStyles = _ref2 => {
90
90
  fontName: labelFontName,
91
91
  fontWeight: labelFontWeight,
92
92
  fontSize: labelFontSize,
93
- lineHeight: labelLineHeight
93
+ lineHeight: labelLineHeight,
94
+ themeOptions
94
95
  })
95
96
  };
96
97
  };
@@ -215,6 +216,9 @@ const Checkbox = /*#__PURE__*/(0, _react.forwardRef)((_ref5, ref) => {
215
216
 
216
217
  const uniqueId = (0, _useUniqueId.default)('checkbox');
217
218
  const inputId = id !== null && id !== void 0 ? id : uniqueId;
219
+ const {
220
+ themeOptions
221
+ } = (0, _ThemeProvider.useTheme)();
218
222
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
219
223
  style: staticStyles.wrapper,
220
224
  ref: ref,
@@ -246,7 +250,7 @@ const Checkbox = /*#__PURE__*/(0, _react.forwardRef)((_ref5, ref) => {
246
250
  pressed
247
251
  });
248
252
  const iconTokens = selectIconTokens(stateTokens);
249
- const labelStyles = selectLabelStyles(stateTokens);
253
+ const labelStyles = selectLabelStyles(stateTokens, themeOptions);
250
254
  const alignWithLabel = label ? [staticStyles.alignWithLabel, {
251
255
  height: labelStyles.lineHeight
252
256
  }] : null;
@@ -69,7 +69,7 @@ const [selectItemProps, selectedItemPropTypes] = (0, _utils.selectSystemProps)([
69
69
  * @example
70
70
  * ```jsx
71
71
  * <CheckboxGroup
72
- * initialCheckedId="check1"
72
+ * initialCheckedIds="check1"
73
73
  * items={[
74
74
  * { label: 'Checkbox 1', id: 'check1' },
75
75
  * { label: 'Checkbox 2', id: 'check2' },