@telus-uds/components-base 3.5.2 → 3.7.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 (52) hide show
  1. package/CHANGELOG.md +29 -2
  2. package/lib/cjs/Box/Box.js +53 -7
  3. package/lib/cjs/Card/Card.js +12 -2
  4. package/lib/cjs/Card/PressableCardBase.js +67 -1
  5. package/lib/cjs/ExpandCollapseMini/ExpandCollapseMini.js +5 -0
  6. package/lib/cjs/ExpandCollapseMini/ExpandCollapseMiniControl.js +17 -26
  7. package/lib/cjs/Icon/Icon.js +2 -1
  8. package/lib/cjs/InputLabel/InputLabel.js +9 -3
  9. package/lib/cjs/InputSupports/InputSupports.js +6 -2
  10. package/lib/cjs/List/ListItemMark.js +8 -4
  11. package/lib/cjs/MultiSelectFilter/MultiSelectFilter.js +7 -1
  12. package/lib/cjs/ToggleSwitch/ToggleSwitch.js +11 -3
  13. package/lib/cjs/ToggleSwitch/ToggleSwitchGroup.js +9 -1
  14. package/lib/cjs/Tooltip/shared.js +5 -4
  15. package/lib/cjs/utils/getSpacingScale.js +66 -0
  16. package/lib/cjs/utils/index.js +9 -1
  17. package/lib/cjs/utils/props/inputSupportsProps.js +6 -2
  18. package/lib/esm/Box/Box.js +55 -9
  19. package/lib/esm/Card/Card.js +13 -3
  20. package/lib/esm/Card/PressableCardBase.js +67 -1
  21. package/lib/esm/ExpandCollapseMini/ExpandCollapseMini.js +5 -0
  22. package/lib/esm/ExpandCollapseMini/ExpandCollapseMiniControl.js +17 -26
  23. package/lib/esm/Icon/Icon.js +2 -1
  24. package/lib/esm/InputLabel/InputLabel.js +9 -3
  25. package/lib/esm/InputSupports/InputSupports.js +6 -2
  26. package/lib/esm/List/ListItemMark.js +9 -5
  27. package/lib/esm/MultiSelectFilter/MultiSelectFilter.js +7 -1
  28. package/lib/esm/ToggleSwitch/ToggleSwitch.js +11 -3
  29. package/lib/esm/ToggleSwitch/ToggleSwitchGroup.js +9 -1
  30. package/lib/esm/Tooltip/shared.js +2 -1
  31. package/lib/esm/utils/getSpacingScale.js +61 -0
  32. package/lib/esm/utils/index.js +2 -1
  33. package/lib/esm/utils/props/inputSupportsProps.js +6 -2
  34. package/lib/package.json +4 -4
  35. package/package.json +4 -4
  36. package/src/Box/Box.jsx +61 -8
  37. package/src/Card/Card.jsx +20 -3
  38. package/src/Card/PressableCardBase.jsx +60 -2
  39. package/src/ExpandCollapseMini/ExpandCollapseMini.jsx +5 -0
  40. package/src/ExpandCollapseMini/ExpandCollapseMiniControl.jsx +17 -21
  41. package/src/Icon/Icon.jsx +6 -1
  42. package/src/InputLabel/InputLabel.jsx +7 -2
  43. package/src/InputSupports/InputSupports.jsx +6 -2
  44. package/src/List/ListItemMark.jsx +5 -3
  45. package/src/MultiSelectFilter/MultiSelectFilter.jsx +7 -1
  46. package/src/ToggleSwitch/ToggleSwitch.jsx +14 -2
  47. package/src/ToggleSwitch/ToggleSwitchGroup.jsx +9 -1
  48. package/src/Tooltip/shared.js +2 -2
  49. package/src/utils/getSpacingScale.js +50 -0
  50. package/src/utils/index.js +1 -0
  51. package/src/utils/props/inputSupportsProps.js +6 -2
  52. package/types/ToggleSwitch.d.ts +1 -0
@@ -19,7 +19,8 @@ var _exportNames = {
19
19
  htmlAttrs: true,
20
20
  transformGradient: true,
21
21
  convertFromMegaByteToByte: true,
22
- formatImageSource: true
22
+ formatImageSource: true,
23
+ getSpacingScale: true
23
24
  };
24
25
  Object.defineProperty(exports, "BaseView", {
25
26
  enumerable: true,
@@ -45,6 +46,12 @@ Object.defineProperty(exports, "formatImageSource", {
45
46
  return _formatImageSource.default;
46
47
  }
47
48
  });
49
+ Object.defineProperty(exports, "getSpacingScale", {
50
+ enumerable: true,
51
+ get: function () {
52
+ return _getSpacingScale.default;
53
+ }
54
+ });
48
55
  Object.defineProperty(exports, "htmlAttrs", {
49
56
  enumerable: true,
50
57
  get: function () {
@@ -240,6 +247,7 @@ var _htmlAttrs = _interopRequireDefault(require("./htmlAttrs"));
240
247
  var _transformGradient = require("./transformGradient");
241
248
  var _convertFromMegaByteToByte = _interopRequireDefault(require("./convertFromMegaByteToByte"));
242
249
  var _formatImageSource = _interopRequireDefault(require("./formatImageSource"));
250
+ var _getSpacingScale = _interopRequireDefault(require("./getSpacingScale"));
243
251
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
244
252
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
245
253
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _propTypes = _interopRequireDefault(require("prop-types"));
8
+ var _shared = _interopRequireDefault(require("../../Tooltip/shared"));
8
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
10
  var _default = exports.default = {
10
11
  types: {
@@ -38,9 +39,12 @@ var _default = exports.default = {
38
39
  */
39
40
  feedbackProps: _propTypes.default.object,
40
41
  /**
41
- * Content of an optional `Tooltip`. If set, a tooltip button will be shown next to the label.
42
+ * an optional `Tooltip`. If set, tooltip will be shown next to the label.
43
+ * Props can be passed to the tooltip in one of the following ways.
44
+ * 1. `tooltip` as a string - The content of the tooltip.
45
+ * 2. `tooltip` as an object - Tooltip component props to be passed.
42
46
  */
43
- tooltip: _propTypes.default.string,
47
+ tooltip: _propTypes.default.oneOfType([_shared.default, _propTypes.default.string]),
44
48
  /**
45
49
  * Use to visually mark an input as valid or invalid.
46
50
  */
@@ -6,9 +6,10 @@ import Platform from "react-native-web/dist/exports/Platform";
6
6
  import StyleSheet from "react-native-web/dist/exports/StyleSheet";
7
7
  import ImageBackground from "react-native-web/dist/exports/ImageBackground";
8
8
  import Image from "react-native-web/dist/exports/Image";
9
- import { useThemeTokens } from '../ThemeProvider';
10
- import { a11yProps, getA11yPropsFromHtmlTag, getTokensPropType, layoutTags, responsiveProps, selectSystemProps, spacingProps, useResponsiveProp, useSpacingScale, variantProp, viewProps } from '../utils';
9
+ import { useTheme, useThemeTokens, useResponsiveThemeTokens, useThemeTokensCallback } from '../ThemeProvider';
10
+ import { a11yProps, createMediaQueryStyles, getA11yPropsFromHtmlTag, getTokensPropType, layoutTags, responsiveProps, selectSystemProps, spacingProps, useResponsiveProp, useSpacingScale, variantProp, viewProps, StyleSheet as RNMQStyleSheet, getSpacingScale } from '../utils';
11
11
  import backgroundImageStylesMap from './backgroundImageStylesMap';
12
+ import { useViewport } from '../ViewportProvider';
12
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
14
  const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
14
15
 
@@ -196,8 +197,19 @@ const Box = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
196
197
  ...getA11yPropsFromHtmlTag(tag, accessibilityRole),
197
198
  ...selectProps(rest)
198
199
  };
199
- const themeTokens = useThemeTokens('Box', tokens, variant);
200
- const styles = {
200
+ const viewport = useViewport();
201
+ const {
202
+ themeOptions
203
+ } = useTheme();
204
+ const {
205
+ enableMediaQueryStyleSheet
206
+ } = themeOptions;
207
+ const useTokens = enableMediaQueryStyleSheet ? useResponsiveThemeTokens : useThemeTokens;
208
+ const themeTokens = useTokens('Box', tokens, variant, !enableMediaQueryStyleSheet && {
209
+ viewport
210
+ });
211
+ const getSpacingTokens = useThemeTokensCallback('spacingScale');
212
+ let boxStyles = {
201
213
  flex,
202
214
  paddingLeft: useSpacingScale(left),
203
215
  paddingRight: useSpacingScale(right),
@@ -205,8 +217,38 @@ const Box = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
205
217
  paddingBottom: useSpacingScale(bottom),
206
218
  ...selectBoxStyles(themeTokens, customGradient)
207
219
  };
220
+ let boxMediaIds;
221
+ if (enableMediaQueryStyleSheet) {
222
+ const {
223
+ transformedThemeTokens
224
+ } = Object.entries(themeTokens).reduce((acc, _ref4) => {
225
+ let [vp] = _ref4;
226
+ acc.transformedThemeTokens[vp] = {
227
+ paddingLeft: getSpacingScale(left, vp, getSpacingTokens),
228
+ paddingRight: getSpacingScale(right, vp, getSpacingTokens),
229
+ paddingTop: getSpacingScale(top, vp, getSpacingTokens),
230
+ paddingBottom: getSpacingScale(bottom, vp, getSpacingTokens)
231
+ };
232
+ return acc;
233
+ }, {
234
+ transformedThemeTokens: {}
235
+ });
236
+ const mediaQueryStyles = createMediaQueryStyles(transformedThemeTokens);
237
+ const {
238
+ ids
239
+ } = RNMQStyleSheet.create({
240
+ box: {
241
+ ...mediaQueryStyles
242
+ }
243
+ });
244
+ boxStyles = {
245
+ flex,
246
+ ...selectBoxStyles(themeTokens[viewport], customGradient)
247
+ };
248
+ boxMediaIds = ids.box;
249
+ }
208
250
  let content = children;
209
- if (typeof customGradient === 'function') content = customGradient(styles.colors, styles)(children);
251
+ if (typeof customGradient === 'function') content = customGradient(boxStyles.colors, boxStyles)(children);
210
252
  const {
211
253
  src = '',
212
254
  alt = '',
@@ -240,23 +282,27 @@ const Box = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
240
282
  });
241
283
  }
242
284
  }, [backgroundImage, backgroundImageWidth, backgroundImageHeight, src]);
285
+ const dataSetValue = boxMediaIds ? {
286
+ media: boxMediaIds,
287
+ ...dataSet
288
+ } : dataSet;
243
289
  if (scroll) {
244
290
  const scrollProps = typeof scroll === 'object' ? scroll : {};
245
- scrollProps.contentContainerStyle = [styles, scrollProps.contentContainerStyle];
291
+ scrollProps.contentContainerStyle = [boxStyles, scrollProps.contentContainerStyle];
246
292
  return /*#__PURE__*/_jsx(ScrollView, {
247
293
  ...scrollProps,
248
294
  ...props,
249
295
  testID: testID,
250
- dataSet: dataSet,
296
+ dataSet: dataSetValue,
251
297
  ref: ref,
252
298
  children: content
253
299
  });
254
300
  }
255
301
  return /*#__PURE__*/_jsx(View, {
256
302
  ...props,
257
- style: styles,
303
+ style: boxStyles,
258
304
  testID: testID,
259
- dataSet: dataSet,
305
+ dataSet: dataSetValue,
260
306
  ref: ref,
261
307
  children: content
262
308
  });
@@ -4,7 +4,7 @@ import View from "react-native-web/dist/exports/View";
4
4
  import { useThemeTokens, useThemeTokensCallback, useResponsiveThemeTokens, useTheme } from '../ThemeProvider';
5
5
  import { getTokensPropType, variantProp, StyleSheet, createMediaQueryStyles } from '../utils';
6
6
  import { useViewport } from '../ViewportProvider';
7
- import { a11yProps, linkProps, selectSystemProps, viewProps, responsiveProps } from '../utils/props';
7
+ import { a11yProps, linkProps, selectSystemProps, viewProps, responsiveProps, hrefAttrsProp } from '../utils/props';
8
8
  import CardBase from './CardBase';
9
9
  import PressableCardBase from './PressableCardBase';
10
10
  import CheckboxButton from '../Checkbox/CheckboxButton';
@@ -244,6 +244,8 @@ const Card = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
244
244
  tokens: getThemeTokens,
245
245
  dataSet: dataSet,
246
246
  onPress: onPress,
247
+ href: interactiveCard?.href,
248
+ hrefAttrs: interactiveCard?.hrefAttrs,
247
249
  ...selectProps(rest),
248
250
  children: cardState => {
249
251
  const {
@@ -306,12 +308,16 @@ Card.propTypes = {
306
308
  - `radiogroup`
307
309
  - `checkbox`
308
310
  * - variant: The variant to be used for the interactive card
311
+ * - href: The href to be used for the interactive card
312
+ * - hrefAttrs: The href attributes to be used for the interactive card
309
313
  */
310
314
  interactiveCard: PropTypes.shape({
311
315
  body: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
312
316
  tokens: getTokensPropType('Card'),
313
317
  selectionType: PropTypes.oneOf(Object.values(SelectionType)),
314
- variant: variantProp.propType
318
+ variant: variantProp.propType,
319
+ href: PropTypes.string,
320
+ hrefAttrs: PropTypes.shape(hrefAttrsProp.types)
315
321
  }),
316
322
  /**
317
323
  * Apply background image to the card.
@@ -322,6 +328,10 @@ Card.propTypes = {
322
328
  src: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]).isRequired,
323
329
  alt: PropTypes.string,
324
330
  resizeMode: responsiveProps.getTypeOptionallyByViewport(PropTypes.oneOf(['cover', 'contain', 'stretch', 'repeat', 'center']))
325
- })
331
+ }),
332
+ /**
333
+ * Data set for the card.
334
+ */
335
+ dataSet: PropTypes.object
326
336
  };
327
337
  export default Card;
@@ -2,6 +2,8 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import Pressable from "react-native-web/dist/exports/Pressable";
4
4
  import Platform from "react-native-web/dist/exports/Platform";
5
+ import View from "react-native-web/dist/exports/View";
6
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
5
7
  import { useViewport } from '../ViewportProvider';
6
8
  import { applyOuterBorder, validateThemeTokens } from '../ThemeProvider';
7
9
  import { a11yProps, clickProps, focusHandlerProps, getTokensSetPropType, linkProps, resolvePressableState, resolvePressableTokens, selectSystemProps, selectTokens, variantProp, viewProps, withLinkRouter } from '../utils';
@@ -80,8 +82,66 @@ const PressableCardBase = /*#__PURE__*/React.forwardRef((_ref, ref) => {
80
82
  });
81
83
  const handleKeyDown = event => {
82
84
  // The expected keyboard shortcut for selecting a focused item is the Space key
83
- if (event?.key === ' ') handleChange(event);
85
+ if (event?.key === ' ') handleChange?.(event);
84
86
  };
87
+ const [hovered, setHovered] = React.useState(false);
88
+ const [focused, setFocused] = React.useState(false);
89
+ const [pressed, setPressed] = React.useState(false);
90
+ if (Platform.OS === 'web' && href) {
91
+ return /*#__PURE__*/_jsx(View, {
92
+ ref: ref,
93
+ style: getOuterBorderStyle({
94
+ pressed,
95
+ focused,
96
+ hovered
97
+ }),
98
+ dataSet: dataSet,
99
+ onMouseEnter: () => setHovered(true),
100
+ onMouseLeave: () => setHovered(false),
101
+ ...selectProps({
102
+ ...rest,
103
+ accessibilityRole
104
+ }),
105
+ children: /*#__PURE__*/_jsx("a", {
106
+ href: href,
107
+ tabIndex: 0,
108
+ onClick: event => {
109
+ setPressed(false);
110
+ handleChange?.(event);
111
+ },
112
+ onKeyDown: event => {
113
+ if (event.key === ' ') {
114
+ setPressed(true);
115
+ handleKeyDown(event);
116
+ }
117
+ },
118
+ onKeyUp: event => {
119
+ if (event.key === ' ') setPressed(false);
120
+ },
121
+ onMouseDown: () => setPressed(true),
122
+ onMouseUp: () => setPressed(false),
123
+ onFocus: () => setFocused(true),
124
+ onBlur: () => {
125
+ setFocused(false);
126
+ setPressed(false);
127
+ },
128
+ style: staticStyles.container,
129
+ ...(hrefAttrs || {}),
130
+ children: /*#__PURE__*/_jsx(CardBase, {
131
+ tokens: getCardTokens({
132
+ pressed,
133
+ focused,
134
+ hovered
135
+ }),
136
+ children: typeof children === 'function' ? children(getCardState({
137
+ pressed,
138
+ focused,
139
+ hovered
140
+ })) : children
141
+ })
142
+ })
143
+ });
144
+ }
85
145
  return /*#__PURE__*/_jsx(Pressable, {
86
146
  ref: ref,
87
147
  href: href,
@@ -100,6 +160,12 @@ const PressableCardBase = /*#__PURE__*/React.forwardRef((_ref, ref) => {
100
160
  })
101
161
  });
102
162
  });
163
+ const staticStyles = StyleSheet.create({
164
+ container: {
165
+ flex: 1,
166
+ display: 'flex'
167
+ }
168
+ });
103
169
  PressableCardBase.displayName = 'PressableCardBase';
104
170
  PressableCardBase.propTypes = {
105
171
  ...selectedSystemPropTypes,
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import ExpandCollapse from '../ExpandCollapse';
4
4
  import { getTokensPropType, selectSystemProps, contentfulProps } from '../utils';
5
+ import { variantProp } from '../utils/props';
5
6
  import ExpandCollapseMiniControl from './ExpandCollapseMiniControl';
6
7
  import { jsx as _jsx } from "react/jsx-runtime";
7
8
  const [selectContainerProps, selectedContainerPropTypes] = selectSystemProps([contentfulProps]);
@@ -78,6 +79,10 @@ ExpandCollapseMini.propTypes = {
78
79
  * Optional variant object to override the default theme tokens
79
80
  */
80
81
  tokens: getTokensPropType('ExpandCollapseMini'),
82
+ /**
83
+ * ExpandCollapseMini variant.
84
+ */
85
+ variant: variantProp.propType,
81
86
  /**
82
87
  * The dataSet prop allows to pass data-* attributes element to the component.
83
88
  */
@@ -16,21 +16,7 @@ const presentationOnly = {
16
16
  // Stop RNW from stopping clicks from bubbling to Control
17
17
  focusable: false // Stop RNW from setting tabIndex={0}: focus goes to Control only
18
18
  };
19
- const selectLinkTokens = _ref => {
20
- let {
21
- color,
22
- textLine,
23
- lineHeight,
24
- fontSize
25
- } = _ref;
26
- return {
27
- color,
28
- textLine,
29
- blockLineHeight: lineHeight,
30
- blockFontSize: fontSize
31
- };
32
- };
33
- const ExpandCollapseMiniControl = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
19
+ const ExpandCollapseMiniControl = /*#__PURE__*/React.forwardRef((_ref, ref) => {
34
20
  let {
35
21
  pressableState,
36
22
  collapseTitle,
@@ -39,22 +25,28 @@ const ExpandCollapseMiniControl = /*#__PURE__*/React.forwardRef((_ref2, ref) =>
39
25
  tokens,
40
26
  variant = {},
41
27
  ...rest
42
- } = _ref2;
28
+ } = _ref;
43
29
  const {
44
30
  expanded,
45
31
  hover,
46
- focus
32
+ focus,
33
+ pressed
47
34
  } = pressableState || {};
48
- // we only want focus outline when focusing, if user is pressing we don't want the border.
49
35
  const {
50
- outerBorderColor
51
- } = useThemeTokens('Link', {}, {}, {
52
- focus: Platform.OS !== 'web' ? expanded : focus
36
+ quiet
37
+ } = variant;
38
+ const isFocusVisible = Platform.OS === 'web' ? focus && !pressed && !hover : expanded;
39
+ const linkTokens = useThemeTokens('Link', {}, {
40
+ ...variant,
41
+ quiet: expanded ?? quiet
42
+ }, {
43
+ focus: isFocusVisible,
44
+ hover,
45
+ pressed
53
46
  });
54
47
  const {
55
48
  size,
56
- icon,
57
- ...themeTokens
49
+ icon
58
50
  } = useThemeTokens('ExpandCollapseMiniControl', tokens, variant, {
59
51
  expanded,
60
52
  focus
@@ -88,9 +80,8 @@ const ExpandCollapseMiniControl = /*#__PURE__*/React.forwardRef((_ref2, ref) =>
88
80
  icon: icon,
89
81
  iconPosition: iconPosition,
90
82
  tokens: linkState => ({
91
- ...getTokens(linkState),
92
- ...selectLinkTokens(themeTokens),
93
- outerBorderColor
83
+ ...linkTokens,
84
+ ...getTokens(linkState)
94
85
  }),
95
86
  ref: ref,
96
87
  ...presentationOnly,
@@ -24,7 +24,8 @@ const Icon = /*#__PURE__*/React.forwardRef((_ref, ref) => {
24
24
  const iconContent = /*#__PURE__*/_jsx(IconComponent, {
25
25
  title: accessibilityLabel,
26
26
  size: size,
27
- color: themeTokens.color
27
+ color: themeTokens.color,
28
+ gradient: themeTokens.gradient
28
29
  });
29
30
  const paddingStyles = variant?.padding ? {
30
31
  padding: themeTokens.width,
@@ -7,6 +7,7 @@ import { applyTextStyles, useTheme, useThemeTokens } from '../ThemeProvider';
7
7
  import { a11yProps, getTokensPropType, selectSystemProps, selectTokens, variantProp, viewProps } from '../utils';
8
8
  import LabelContent from './LabelContent';
9
9
  import Tooltip from '../Tooltip';
10
+ import tooltipPropTypes from '../Tooltip/shared';
10
11
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
11
12
  const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
12
13
  const selectLabelStyles = (tokens, themeOptions) => applyTextStyles({
@@ -59,6 +60,11 @@ const InputLabel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
59
60
  const {
60
61
  themeOptions
61
62
  } = useTheme();
63
+ const getTooltipProps = () => {
64
+ return typeof tooltip === 'string' ? {
65
+ content: tooltip
66
+ } : tooltip;
67
+ };
62
68
  return /*#__PURE__*/_jsxs(_Fragment, {
63
69
  children: [/*#__PURE__*/_jsxs(View, {
64
70
  ref: ref,
@@ -80,8 +86,8 @@ const InputLabel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
80
86
  color: themeTokens.color
81
87
  }],
82
88
  children: /*#__PURE__*/_jsx(Tooltip, {
83
- content: tooltip,
84
- copy: copy
89
+ copy: copy,
90
+ ...getTooltipProps()
85
91
  })
86
92
  }), maxCharacterAllowed && isHintInline && /*#__PURE__*/_jsxs(Text, {
87
93
  style: [selectHintStyles({
@@ -136,7 +142,7 @@ InputLabel.propTypes = {
136
142
  /**
137
143
  * Content of an optional `Tooltip`. If set, a tooltip button will be shown next to the label.
138
144
  */
139
- tooltip: PropTypes.string,
145
+ tooltip: PropTypes.oneOfType([tooltipPropTypes, PropTypes.string]),
140
146
  /**
141
147
  * Current number of characterts of an input text.
142
148
  */
@@ -7,6 +7,7 @@ import { useThemeTokens } from '../ThemeProvider';
7
7
  import useInputSupports from './useInputSupports';
8
8
  import { getTokensPropType, useCopy } from '../utils';
9
9
  import dictionary from './dictionary';
10
+ import tooltipPropTypes from '../Tooltip/shared';
10
11
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
12
  const InputSupports = /*#__PURE__*/React.forwardRef((_ref, ref) => {
12
13
  let {
@@ -110,9 +111,12 @@ InputSupports.propTypes = {
110
111
  */
111
112
  feedbackProps: PropTypes.object,
112
113
  /**
113
- * Content of an optional `Tooltip`. If set, a tooltip button will be shown next to the label.
114
+ * an optional `Tooltip`. If set, tooltip will be shown next to the label.
115
+ * Props can be passed to the tooltip in one of the following ways.
116
+ * 1. `tooltip` as a string - The content of the tooltip.
117
+ * 2. `tooltip` as an object - Tooltip component props to be passed.
114
118
  */
115
- tooltip: PropTypes.string,
119
+ tooltip: PropTypes.oneOfType([tooltipPropTypes, PropTypes.string]),
116
120
  /**
117
121
  * Use to visually mark an input as valid or invalid.
118
122
  */
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
3
3
  import View from "react-native-web/dist/exports/View";
4
4
  import StyleSheet from "react-native-web/dist/exports/StyleSheet";
5
5
  import Icon from '../Icon';
6
- import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
7
  export const tokenTypes = {
8
8
  itemIconSize: PropTypes.number.isRequired,
9
9
  itemIconColor: PropTypes.string.isRequired,
@@ -68,7 +68,6 @@ const ListItemMark = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
68
68
  iconSize,
69
69
  tokens = {}
70
70
  } = _ref5;
71
- const IconComponent = icon || /*#__PURE__*/_jsx(_Fragment, {});
72
71
  const themeTokens = typeof tokens === 'function' ? tokens() : tokens;
73
72
  const sideItemContainerStyles = selectSideItemContainerStyles(themeTokens);
74
73
  const bulletContainerStyles = selectBulletContainerStyles(themeTokens);
@@ -76,9 +75,14 @@ const ListItemMark = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
76
75
  const iconTokens = selectItemIconTokens(themeTokens);
77
76
  return /*#__PURE__*/_jsx(View, {
78
77
  style: [sideItemContainerStyles, bulletContainerStyles],
79
- children: /*#__PURE__*/_jsx(IconComponent, {
80
- size: iconSize || iconTokens.size,
81
- color: iconColor || iconTokens.color
78
+ children: /*#__PURE__*/_jsx(Icon, {
79
+ icon: icon,
80
+ tokens: {
81
+ size: iconSize ?? iconTokens.size
82
+ },
83
+ variant: {
84
+ color: iconColor ?? iconTokens.color
85
+ }
82
86
  })
83
87
  });
84
88
  }
@@ -130,6 +130,10 @@ const MultiSelectFilter = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
130
130
  buttonIconPadding,
131
131
  subtitleColor,
132
132
  dividerColor,
133
+ iconColor,
134
+ buttonBackgroundColor,
135
+ iconColorSelected,
136
+ buttonBackgroundColorSelected,
133
137
  ...restTokens
134
138
  } = useThemeTokens('MultiSelectFilter', tokens, {
135
139
  ...variant,
@@ -152,7 +156,9 @@ const MultiSelectFilter = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
152
156
  paddingBottom: labelPaddingBottom,
153
157
  paddingLeft: labelPaddingLeft,
154
158
  paddingRight: labelPaddingRight,
155
- iconBackground: buttonIconBackgroundColor
159
+ iconBackground: buttonIconBackgroundColor,
160
+ iconColor: isSelected ? iconColorSelected : iconColor,
161
+ backgroundColor: isSelected ? buttonBackgroundColorSelected : buttonBackgroundColor
156
162
  };
157
163
  const getButtonDropdownTokens = useThemeTokensCallback('ButtonDropdown', dropdownTokens, variant);
158
164
  const getButtonTokens = buttonState => selectTokens('ButtonDropdown', getButtonDropdownTokens(buttonState));
@@ -132,6 +132,7 @@ const ToggleSwitch = /*#__PURE__*/React.forwardRef((_ref9, ref) => {
132
132
  variant,
133
133
  accessibilityRole = 'switch',
134
134
  accessibilityLabel = label,
135
+ togglePosition = 'end',
135
136
  ...rest
136
137
  } = _ref9;
137
138
  const getTokens = useThemeTokensCallback('ToggleSwitch', tokens, variant);
@@ -150,9 +151,10 @@ const ToggleSwitch = /*#__PURE__*/React.forwardRef((_ref9, ref) => {
150
151
  const inputId = id ?? uniqueId;
151
152
  return /*#__PURE__*/_jsxs(StackView, {
152
153
  space: themeTokens.space,
153
- direction: "row",
154
+ direction: togglePosition === 'start' ? 'row-reverse' : 'row',
154
155
  tokens: {
155
- alignItems: 'center'
156
+ alignItems: 'center',
157
+ justifyContent: 'start'
156
158
  },
157
159
  children: [Boolean(label) && /*#__PURE__*/_jsx(View, {
158
160
  style: [selectLabelStyles(themeTokens), staticStyles.containText],
@@ -258,7 +260,13 @@ ToggleSwitch.propTypes = {
258
260
  /**
259
261
  * Content of an optional Tooltip. If set, a tooltip button will be shown next to the label.
260
262
  */
261
- tooltip: PropTypes.string
263
+ tooltip: PropTypes.string,
264
+ /**
265
+ * Controls the position of the switch in relation to the label.
266
+ * - 'start': switch on the start, before the `label` and `tooltip`.
267
+ * - 'end': switch to the end, after the `label` and `tooltip` (default).
268
+ */
269
+ togglePosition: PropTypes.oneOf(['start', 'end'])
262
270
  };
263
271
  const staticStyles = StyleSheet.create({
264
272
  track: {
@@ -72,6 +72,7 @@ const ToggleSwitchGroup = /*#__PURE__*/React.forwardRef((_ref, ref) => {
72
72
  onChange: itemOnChange,
73
73
  ref: itemRef,
74
74
  tooltip: itemTooltip,
75
+ togglePosition,
75
76
  ...itemRest
76
77
  } = _ref2;
77
78
  const isSelected = currentValues.includes(id);
@@ -97,6 +98,7 @@ const ToggleSwitchGroup = /*#__PURE__*/React.forwardRef((_ref, ref) => {
97
98
  inactive: inactive,
98
99
  label: label,
99
100
  tooltip: itemTooltip,
101
+ togglePosition: togglePosition,
100
102
  ...itemA11y,
101
103
  ...selectItemProps(itemRest)
102
104
  }, id);
@@ -156,7 +158,13 @@ ToggleSwitchGroup.propTypes = {
156
158
  /**
157
159
  * An optional ref for one individual ToggleSwitch in the ToggleSwitchGroup
158
160
  */
159
- ref: ABBPropTypes.ref()
161
+ ref: ABBPropTypes.ref(),
162
+ /**
163
+ * Controls the position of the switch in relation to the label.
164
+ * - 'start': switch on the start, before the `label` and `tooltip`.
165
+ * - 'end': switch to the end, after the `label` and `tooltip` (default).
166
+ */
167
+ togglePosition: PropTypes.oneOf(['start', 'end'])
160
168
  })),
161
169
  /**
162
170
  * If provided, this function is called when the current selection is changed
@@ -1,5 +1,6 @@
1
1
  import PropTypes from 'prop-types';
2
- import { getTokensPropType, variantProp } from '../utils';
2
+ import { getTokensPropType } from '../utils/props/tokens';
3
+ import variantProp from '../utils/props/variantProp';
3
4
  const propTypes = {
4
5
  /**
5
6
  * Used to render the control (i.e. tooltip trigger). If a render function is used it will receive the
@@ -0,0 +1,61 @@
1
+ import { resolveResponsiveProp } from './useResponsiveProp';
2
+
3
+ /**
4
+ * Resolves spacing options from the provided space object.
5
+ *
6
+ * @param {Object} space - The space configuration object.
7
+ * @param {Object} [space.options] - The options for spacing.
8
+ * @param {number|string} [space.options.size] - The size of the spacing. Can be a number or a string.
9
+ * @param {string} [space.options.variant] - The variant of the spacing.
10
+ * @param {number} [space.options.subtract=0] - A value to subtract from the spacing size.
11
+ * @returns {Object} An object containing resolved spacing tokens, variant, overridden flag, and subtract value.
12
+ * @property {Object} tokens - The resolved spacing tokens.
13
+ * @property {number|string} tokens.size - The size of the spacing.
14
+ * @property {string} [variant] - The variant of the spacing.
15
+ * @property {boolean} overridden - Indicates if the size is explicitly overridden as a number.
16
+ * @property {number} subtract - The value to subtract from the spacing size.
17
+ */
18
+ const resolveSpacingOptions = space => {
19
+ if (!space?.options) return {};
20
+ const {
21
+ size,
22
+ variant,
23
+ subtract = 0
24
+ } = space.options;
25
+ const overridden = typeof size === 'number';
26
+ return {
27
+ tokens: {
28
+ size
29
+ },
30
+ variant,
31
+ overridden,
32
+ subtract
33
+ };
34
+ };
35
+
36
+ /**
37
+ * Calculates the spacing scale based on the provided space value, viewport, and spacing tokens.
38
+ *
39
+ * @param {Object} spaceValue - The space value configuration, which may include responsive properties.
40
+ * @param {Object} viewport - The current viewport dimensions or configuration.
41
+ * @param {Function} getSpacingTokens - A function that retrieves spacing tokens based on the provided options.
42
+ * @returns {number} The calculated spacing scale, ensuring it is non-negative.
43
+ */
44
+ const getSpacingScale = (spaceValue, viewport, getSpacingTokens) => {
45
+ const {
46
+ tokens,
47
+ variant,
48
+ overridden,
49
+ subtract = 0
50
+ } = resolveSpacingOptions(spaceValue);
51
+ const space = !overridden && (spaceValue?.space ?? resolveResponsiveProp(spaceValue, viewport, 0));
52
+ const {
53
+ size
54
+ } = getSpacingTokens({
55
+ ...variant,
56
+ space: typeof space === 'number' ? space : 0,
57
+ viewport
58
+ }, tokens);
59
+ return Math.max(size - subtract, 0);
60
+ };
61
+ export default getSpacingScale;
@@ -22,4 +22,5 @@ export { default as BaseView } from './BaseView';
22
22
  export { default as htmlAttrs } from './htmlAttrs';
23
23
  export { transformGradient } from './transformGradient';
24
24
  export { default as convertFromMegaByteToByte } from './convertFromMegaByteToByte';
25
- export { default as formatImageSource } from './formatImageSource';
25
+ export { default as formatImageSource } from './formatImageSource';
26
+ export { default as getSpacingScale } from './getSpacingScale';