@telus-uds/components-base 3.23.0 → 3.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -1
- package/lib/cjs/Button/ButtonGroup.js +9 -2
- package/lib/cjs/Card/CardBase.js +97 -17
- package/lib/cjs/Card/PressableCardBase.js +12 -8
- package/lib/cjs/Carousel/Carousel.js +35 -4
- package/lib/cjs/FlexGrid/FlexGrid.js +31 -35
- package/lib/cjs/HorizontalScroll/HorizontalScroll.js +5 -2
- package/lib/cjs/Icon/Icon.js +3 -0
- package/lib/cjs/IconButton/IconButton.js +15 -5
- package/lib/cjs/Listbox/GroupControl.js +12 -6
- package/lib/cjs/Listbox/Listbox.js +41 -7
- package/lib/cjs/Listbox/ListboxGroup.js +139 -8
- package/lib/cjs/Listbox/ListboxOverlay.js +10 -5
- package/lib/cjs/Listbox/SecondLevelHeader.js +201 -0
- package/lib/cjs/Listbox/dictionary.js +14 -0
- package/lib/cjs/Shortcuts/Shortcuts.js +169 -0
- package/lib/cjs/Shortcuts/ShortcutsItem.js +280 -0
- package/lib/cjs/Shortcuts/index.js +16 -0
- package/lib/cjs/TextInput/TextInputBase.js +2 -3
- package/lib/cjs/Tooltip/Tooltip.native.js +2 -0
- package/lib/cjs/index.js +15 -0
- package/lib/cjs/utils/index.js +9 -1
- package/lib/cjs/utils/resolveContentMaxWidth.js +30 -0
- package/lib/esm/Button/ButtonGroup.js +9 -2
- package/lib/esm/Card/CardBase.js +97 -17
- package/lib/esm/Card/PressableCardBase.js +10 -8
- package/lib/esm/Carousel/Carousel.js +37 -6
- package/lib/esm/FlexGrid/FlexGrid.js +31 -35
- package/lib/esm/HorizontalScroll/HorizontalScroll.js +6 -3
- package/lib/esm/Icon/Icon.js +3 -0
- package/lib/esm/IconButton/IconButton.js +15 -5
- package/lib/esm/Listbox/GroupControl.js +12 -6
- package/lib/esm/Listbox/Listbox.js +41 -7
- package/lib/esm/Listbox/ListboxGroup.js +141 -10
- package/lib/esm/Listbox/ListboxOverlay.js +10 -5
- package/lib/esm/Listbox/SecondLevelHeader.js +194 -0
- package/lib/esm/Listbox/dictionary.js +8 -0
- package/lib/esm/Shortcuts/Shortcuts.js +160 -0
- package/lib/esm/Shortcuts/ShortcutsItem.js +273 -0
- package/lib/esm/Shortcuts/index.js +3 -0
- package/lib/esm/TextInput/TextInputBase.js +2 -3
- package/lib/esm/Tooltip/Tooltip.native.js +2 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/utils/index.js +2 -1
- package/lib/esm/utils/resolveContentMaxWidth.js +24 -0
- package/lib/package.json +2 -2
- package/package.json +2 -2
- package/src/Button/ButtonGroup.jsx +20 -3
- package/src/Card/CardBase.jsx +113 -14
- package/src/Card/PressableCardBase.jsx +17 -5
- package/src/Carousel/Carousel.jsx +38 -6
- package/src/FlexGrid/FlexGrid.jsx +30 -39
- package/src/HorizontalScroll/HorizontalScroll.jsx +6 -3
- package/src/Icon/Icon.jsx +3 -0
- package/src/IconButton/IconButton.jsx +12 -5
- package/src/Listbox/GroupControl.jsx +41 -33
- package/src/Listbox/Listbox.jsx +41 -2
- package/src/Listbox/ListboxGroup.jsx +158 -26
- package/src/Listbox/ListboxOverlay.jsx +18 -5
- package/src/Listbox/SecondLevelHeader.jsx +182 -0
- package/src/Listbox/dictionary.js +8 -0
- package/src/Shortcuts/Shortcuts.jsx +174 -0
- package/src/Shortcuts/ShortcutsItem.jsx +297 -0
- package/src/Shortcuts/index.js +4 -0
- package/src/TextInput/TextInputBase.jsx +2 -2
- package/src/Tooltip/Tooltip.native.jsx +2 -1
- package/src/index.js +1 -0
- package/src/utils/index.js +1 -0
- package/src/utils/resolveContentMaxWidth.js +28 -0
- package/types/Listbox.d.ts +24 -0
- package/types/Shortcuts.d.ts +136 -0
- package/types/Status.d.ts +42 -0
- package/types/index.d.ts +15 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
10
|
+
var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
|
|
11
|
+
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
12
|
+
var _systemConstants = require("@telus-uds/system-constants");
|
|
13
|
+
var _ThemeProvider = require("../ThemeProvider");
|
|
14
|
+
var _ViewportProvider = require("../ViewportProvider");
|
|
15
|
+
var _utils = require("../utils");
|
|
16
|
+
var _HorizontalScroll = _interopRequireWildcard(require("../HorizontalScroll"));
|
|
17
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
+
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); }
|
|
19
|
+
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; }
|
|
20
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
|
+
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
|
|
22
|
+
const {
|
|
23
|
+
selectHorizontalScrollTokens,
|
|
24
|
+
useItemPositions
|
|
25
|
+
} = _HorizontalScroll.horizontalScrollUtils;
|
|
26
|
+
const selectStyles = (themeTokens, maxWidth, viewport) => {
|
|
27
|
+
const isDesktop = viewport === _systemConstants.viewports.md || viewport === _systemConstants.viewports.lg || viewport === _systemConstants.viewports.xl;
|
|
28
|
+
return {
|
|
29
|
+
wrapper: {
|
|
30
|
+
alignItems: isDesktop ? 'center' : 'flex-start'
|
|
31
|
+
},
|
|
32
|
+
scrollContainer: {
|
|
33
|
+
width: '100%',
|
|
34
|
+
...(isDesktop && {
|
|
35
|
+
maxWidth
|
|
36
|
+
})
|
|
37
|
+
},
|
|
38
|
+
container: {
|
|
39
|
+
paddingTop: themeTokens.mainContainerTopPadding,
|
|
40
|
+
paddingBottom: themeTokens.mainContainerBottomPadding,
|
|
41
|
+
paddingLeft: themeTokens.mainContainerLeftPadding,
|
|
42
|
+
paddingRight: themeTokens.mainContainerRightPadding,
|
|
43
|
+
gap: themeTokens.mainContainerGap,
|
|
44
|
+
...(isDesktop && {
|
|
45
|
+
alignItems: 'flex-start',
|
|
46
|
+
justifyContent: 'center'
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A horizontal scrollable shortcuts component that displays a collection of shortcut items.
|
|
54
|
+
* This component automatically injects shared configuration props to all ShortcutsItem children
|
|
55
|
+
* via React.cloneElement, including variant settings, hideLabels, and iconVariant.
|
|
56
|
+
*
|
|
57
|
+
* @component
|
|
58
|
+
* @param {Object} props - Component properties
|
|
59
|
+
* @param {Object} [props.tokens] - Theme tokens to customize the component's appearance
|
|
60
|
+
* @param {Object} [props.variant] - Visual variant configuration for the shortcuts container and its items
|
|
61
|
+
* @param {string} [props.variant.width] - Width variant to apply to all items (e.g., 'equal', 'dynamic')
|
|
62
|
+
* @param {Object} [props.scrollButtonTokens] - Tokens to customize scroll button appearance
|
|
63
|
+
* @param {boolean} [props.hideLabels=false] - Whether to hide labels on all shortcut items (can be overridden per item)
|
|
64
|
+
* @param {Object} [props.iconVariant] - Icon variant to apply to all shortcut items (can be overridden per item)
|
|
65
|
+
* @param {React.ReactNode} props.children - ShortcutsItem components to render
|
|
66
|
+
* @param {React.Ref} ref - Forwarded ref to the component's root element
|
|
67
|
+
* @returns {React.ReactElement} Rendered shortcuts component with horizontal scroll functionality
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* <Shortcuts hideLabels={false} variant={{ width: 'equal' }}>
|
|
71
|
+
* <ShortcutsItem icon={HomeIcon} label="Home" href="/home" />
|
|
72
|
+
* <ShortcutsItem icon={SettingsIcon} label="Settings" href="/settings" />
|
|
73
|
+
* </Shortcuts>
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* // Item-level props override container props
|
|
77
|
+
* <Shortcuts hideLabels iconVariant={{ size: 'small' }}>
|
|
78
|
+
* <ShortcutsItem icon={HomeIcon} label="Home" hideLabel={false} />
|
|
79
|
+
* <ShortcutsItem icon={SettingsIcon} label="Settings" />
|
|
80
|
+
* </Shortcuts>
|
|
81
|
+
*/
|
|
82
|
+
const Shortcuts = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
83
|
+
let {
|
|
84
|
+
tokens,
|
|
85
|
+
variant,
|
|
86
|
+
scrollButtonTokens,
|
|
87
|
+
hideLabels = false,
|
|
88
|
+
iconVariant,
|
|
89
|
+
children,
|
|
90
|
+
...rest
|
|
91
|
+
} = _ref;
|
|
92
|
+
const viewport = (0, _ViewportProvider.useViewport)();
|
|
93
|
+
const themeTokens = (0, _ThemeProvider.useThemeTokens)('Shortcuts', tokens, variant, {
|
|
94
|
+
viewport
|
|
95
|
+
});
|
|
96
|
+
const {
|
|
97
|
+
themeOptions
|
|
98
|
+
} = (0, _ThemeProvider.useTheme)();
|
|
99
|
+
const maxWidth = (0, _utils.useResponsiveProp)(themeOptions?.contentMaxWidth, _systemConstants.viewports.map.get(_systemConstants.viewports.xl));
|
|
100
|
+
const [itemPositions] = useItemPositions();
|
|
101
|
+
const [maxItemWidth, setMaxItemWidth] = _react.default.useState(null);
|
|
102
|
+
const registerWidth = _react.default.useCallback(width => setMaxItemWidth(prev => prev == null || width > prev ? width : prev), []);
|
|
103
|
+
const styles = selectStyles(themeTokens, maxWidth, viewport);
|
|
104
|
+
const childrenWithProps = _react.default.Children.map(children, child => {
|
|
105
|
+
if (! /*#__PURE__*/_react.default.isValidElement(child)) {
|
|
106
|
+
return child;
|
|
107
|
+
}
|
|
108
|
+
return /*#__PURE__*/_react.default.cloneElement(child, {
|
|
109
|
+
maxWidth: maxItemWidth,
|
|
110
|
+
registerWidth,
|
|
111
|
+
containerVariant: variant,
|
|
112
|
+
containerHideLabels: hideLabels,
|
|
113
|
+
containerIconVariant: iconVariant
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
117
|
+
style: [staticStyles.wrapper, styles.wrapper],
|
|
118
|
+
ref: ref,
|
|
119
|
+
...selectProps(rest),
|
|
120
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
121
|
+
style: styles.scrollContainer,
|
|
122
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_HorizontalScroll.default, {
|
|
123
|
+
ScrollButton: _HorizontalScroll.HorizontalScrollButton,
|
|
124
|
+
itemPositions: itemPositions,
|
|
125
|
+
tokens: selectHorizontalScrollTokens(themeTokens),
|
|
126
|
+
scrollButtonTokens: scrollButtonTokens,
|
|
127
|
+
variant: {
|
|
128
|
+
hideNavigationButtons: _Platform.default.OS !== 'web'
|
|
129
|
+
},
|
|
130
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
131
|
+
style: [staticStyles.container, styles.container],
|
|
132
|
+
children: childrenWithProps
|
|
133
|
+
})
|
|
134
|
+
})
|
|
135
|
+
})
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
Shortcuts.displayName = 'Shortcuts';
|
|
139
|
+
Shortcuts.propTypes = {
|
|
140
|
+
...selectedSystemPropTypes,
|
|
141
|
+
tokens: (0, _utils.getTokensPropType)('Shortcuts'),
|
|
142
|
+
variant: _utils.variantProp.propType,
|
|
143
|
+
/**
|
|
144
|
+
* Custom tokens for `HorizontalScrollButton`
|
|
145
|
+
*/
|
|
146
|
+
scrollButtonTokens: (0, _utils.getTokensPropType)('HorizontalScrollButton'),
|
|
147
|
+
/**
|
|
148
|
+
* Hide labels for all ShortcutsItem children. When true, labels are visually hidden but remain accessible to screen readers via the icon's accessibilityLabel.
|
|
149
|
+
*/
|
|
150
|
+
hideLabels: _propTypes.default.bool,
|
|
151
|
+
/**
|
|
152
|
+
* Icon variant to apply to all ShortcutsItem children.
|
|
153
|
+
*/
|
|
154
|
+
iconVariant: _utils.variantProp.propType,
|
|
155
|
+
/**
|
|
156
|
+
* ShortcutsItem components to be rendered within the Shortcuts container
|
|
157
|
+
*/
|
|
158
|
+
children: _propTypes.default.node
|
|
159
|
+
};
|
|
160
|
+
const staticStyles = _StyleSheet.default.create({
|
|
161
|
+
wrapper: {
|
|
162
|
+
flexGrow: 1
|
|
163
|
+
},
|
|
164
|
+
container: {
|
|
165
|
+
flexDirection: 'row',
|
|
166
|
+
flex: 1
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
var _default = exports.default = Shortcuts;
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _Image = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Image"));
|
|
9
|
+
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
10
|
+
var _Pressable = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Pressable"));
|
|
11
|
+
var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
|
|
12
|
+
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
13
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
14
|
+
var _ThemeProvider = require("../ThemeProvider");
|
|
15
|
+
var _utils = require("../utils");
|
|
16
|
+
var _Icon = _interopRequireDefault(require("../Icon"));
|
|
17
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
|
+
const DYNAMIC_WIDTH_VARIANT = 'dynamic';
|
|
20
|
+
const EQUAL_WIDTH_VARIANT = 'equal';
|
|
21
|
+
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.linkProps, _utils.viewProps]);
|
|
22
|
+
const selectPressableStyles = (tokens, widthVariant, equalWidth) => {
|
|
23
|
+
const styles = {
|
|
24
|
+
borderColor: tokens.borderColor,
|
|
25
|
+
borderRadius: tokens.borderRadius,
|
|
26
|
+
borderWidth: tokens.borderWidth,
|
|
27
|
+
..._Platform.default.select({
|
|
28
|
+
web: {
|
|
29
|
+
outline: 'none'
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
};
|
|
33
|
+
if (widthVariant === DYNAMIC_WIDTH_VARIANT) {
|
|
34
|
+
styles.width = 'auto';
|
|
35
|
+
} else if (widthVariant === EQUAL_WIDTH_VARIANT) {
|
|
36
|
+
if (equalWidth) {
|
|
37
|
+
styles.width = equalWidth;
|
|
38
|
+
} else {
|
|
39
|
+
styles.minWidth = tokens.width;
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
styles.width = tokens.width;
|
|
43
|
+
}
|
|
44
|
+
return styles;
|
|
45
|
+
};
|
|
46
|
+
const selectIconContainerStyles = tokens => ({
|
|
47
|
+
paddingBottom: tokens.iconContainerPaddingBottom,
|
|
48
|
+
paddingLeft: tokens.iconContainerPaddingLeft,
|
|
49
|
+
paddingRight: tokens.iconContainerPaddingRight,
|
|
50
|
+
paddingTop: tokens.iconContainerPaddingTop
|
|
51
|
+
});
|
|
52
|
+
const selectIconVariant = () => ({
|
|
53
|
+
background: true,
|
|
54
|
+
padding: 'medium'
|
|
55
|
+
});
|
|
56
|
+
const selectIconTokens = tokens => ({
|
|
57
|
+
backgroundColor: tokens.iconBackgroundColor,
|
|
58
|
+
color: tokens.iconColor,
|
|
59
|
+
size: tokens.iconSize,
|
|
60
|
+
width: tokens.iconWidth
|
|
61
|
+
});
|
|
62
|
+
const selectImageStyles = tokens => ({
|
|
63
|
+
width: tokens.imageWidth,
|
|
64
|
+
height: tokens.imageHeight
|
|
65
|
+
});
|
|
66
|
+
const selectLabelContainerStyles = tokens => ({
|
|
67
|
+
paddingBottom: tokens.labelContainerPaddingBottom,
|
|
68
|
+
paddingLeft: tokens.labelContainerPaddingLeft,
|
|
69
|
+
paddingRight: tokens.labelContainerPaddingRight,
|
|
70
|
+
paddingTop: tokens.labelContainerPaddingTop
|
|
71
|
+
});
|
|
72
|
+
const selectTitleTextStyles = tokens => (0, _ThemeProvider.applyTextStyles)({
|
|
73
|
+
fontColor: tokens.labelFontColor,
|
|
74
|
+
fontName: tokens.labelFontName,
|
|
75
|
+
fontSize: tokens.labelFontSize,
|
|
76
|
+
fontWeight: tokens.labelFontWeight,
|
|
77
|
+
lineHeight: tokens.labelLineHeight,
|
|
78
|
+
textDecorationLine: tokens.labelUnderline,
|
|
79
|
+
textAlign: tokens.labelTextAlign
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* A clickable shortcut item component that displays an icon or image with an optional label.
|
|
84
|
+
* Can be used within a Shortcuts container to create a grid of navigation shortcuts.
|
|
85
|
+
*
|
|
86
|
+
* @component
|
|
87
|
+
* @param {Object} props - Component props
|
|
88
|
+
* @param {string} [props.icon] - Icon identifier to display
|
|
89
|
+
* @param {Object} [props.image={ src: '', alt: '' }] - Image object with src and alt properties
|
|
90
|
+
* @param {string} [props.image.src] - Image source URL
|
|
91
|
+
* @param {string} [props.image.alt] - Image alt text for accessibility
|
|
92
|
+
* @param {string|React.ReactNode} props.label - Label text or content to display below the icon/image
|
|
93
|
+
* @param {boolean} [props.hideLabel=false] - Whether to hide the label for this specific item
|
|
94
|
+
* @param {string} [props.href] - Link URL for navigation
|
|
95
|
+
* @param {Object} [props.iconVariant] - Icon variant to apply to this specific item
|
|
96
|
+
* @param {Object} [props.tokens] - Theme tokens to customize appearance
|
|
97
|
+
* @param {Object} [props.variant] - Variant configuration object for this specific item
|
|
98
|
+
* @param {string} [props.variant.width] - Width variant (e.g., 'dynamic', 'equal')
|
|
99
|
+
* @param {Function} [props.onPressableStateChange] - Callback function that receives the pressable state object (pressed, hovered, focused)
|
|
100
|
+
* @param {number} [props.maxWidth] - Maximum width for equal width variant (injected by Shortcuts container)
|
|
101
|
+
* @param {Function} [props.registerWidth] - Callback to register width for equal width variant (injected by Shortcuts container)
|
|
102
|
+
* @param {Object} [props.containerVariant] - Variant configuration from Shortcuts container (injected by Shortcuts container)
|
|
103
|
+
* @param {boolean} [props.containerHideLabels] - Hide labels setting from Shortcuts container (injected by Shortcuts container)
|
|
104
|
+
* @param {Object} [props.containerIconVariant] - Icon variant from Shortcuts container (injected by Shortcuts container)
|
|
105
|
+
* @param {React.Ref} ref - Forwarded ref to the Pressable component
|
|
106
|
+
* @returns {React.ReactElement} The rendered shortcut item
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* <ShortcutsItem
|
|
110
|
+
* icon={HomeIcon}
|
|
111
|
+
* label="Home"
|
|
112
|
+
* href="/home"
|
|
113
|
+
* onPressableStateChange={(state) => console.log(state)}
|
|
114
|
+
* />
|
|
115
|
+
*/
|
|
116
|
+
const ShortcutsItem = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
117
|
+
let {
|
|
118
|
+
icon,
|
|
119
|
+
image = {
|
|
120
|
+
src: '',
|
|
121
|
+
alt: ''
|
|
122
|
+
},
|
|
123
|
+
label,
|
|
124
|
+
hideLabel = false,
|
|
125
|
+
href,
|
|
126
|
+
iconVariant,
|
|
127
|
+
tokens,
|
|
128
|
+
variant,
|
|
129
|
+
onPressableStateChange,
|
|
130
|
+
maxWidth,
|
|
131
|
+
registerWidth,
|
|
132
|
+
containerVariant,
|
|
133
|
+
containerHideLabels,
|
|
134
|
+
containerIconVariant,
|
|
135
|
+
...rest
|
|
136
|
+
} = _ref;
|
|
137
|
+
const mergedVariant = {
|
|
138
|
+
...containerVariant,
|
|
139
|
+
...variant
|
|
140
|
+
};
|
|
141
|
+
const widthVariant = mergedVariant?.width;
|
|
142
|
+
const shouldHideLabel = hideLabel || containerHideLabels;
|
|
143
|
+
const mergedIconVariant = iconVariant ?? containerIconVariant;
|
|
144
|
+
const getThemeTokens = (0, _ThemeProvider.useThemeTokensCallback)('ShortcutsItem', tokens, mergedVariant);
|
|
145
|
+
const getTokens = pressableState => getThemeTokens((0, _utils.resolvePressableState)(pressableState));
|
|
146
|
+
const {
|
|
147
|
+
onPress,
|
|
148
|
+
...props
|
|
149
|
+
} = _utils.clickProps.toPressProps(rest);
|
|
150
|
+
const {
|
|
151
|
+
hrefAttrs,
|
|
152
|
+
rawRest
|
|
153
|
+
} = _utils.hrefAttrsProp.bundle(props);
|
|
154
|
+
const selectedProps = selectProps({
|
|
155
|
+
href,
|
|
156
|
+
onPress: _utils.linkProps.handleHref({
|
|
157
|
+
href,
|
|
158
|
+
onPress
|
|
159
|
+
}),
|
|
160
|
+
hrefAttrs,
|
|
161
|
+
...rawRest
|
|
162
|
+
});
|
|
163
|
+
const handleLayout = event => {
|
|
164
|
+
if (widthVariant === EQUAL_WIDTH_VARIANT && registerWidth) {
|
|
165
|
+
const {
|
|
166
|
+
width
|
|
167
|
+
} = event.nativeEvent.layout;
|
|
168
|
+
registerWidth(width);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Pressable.default, {
|
|
172
|
+
ref: ref,
|
|
173
|
+
style: pressableState => selectPressableStyles(getTokens(pressableState), widthVariant, maxWidth),
|
|
174
|
+
onLayout: handleLayout,
|
|
175
|
+
...selectedProps,
|
|
176
|
+
children: pressableState => {
|
|
177
|
+
const themeTokens = getTokens(pressableState);
|
|
178
|
+
if (onPressableStateChange) {
|
|
179
|
+
onPressableStateChange((0, _utils.resolvePressableState)(pressableState));
|
|
180
|
+
}
|
|
181
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
|
|
182
|
+
style: staticStyles.container,
|
|
183
|
+
children: [icon && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
184
|
+
style: selectIconContainerStyles(themeTokens),
|
|
185
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
|
|
186
|
+
icon: icon,
|
|
187
|
+
variant: mergedIconVariant ?? selectIconVariant(),
|
|
188
|
+
tokens: mergedIconVariant ? {} : selectIconTokens(themeTokens),
|
|
189
|
+
...(_Platform.default.OS === 'web' && {
|
|
190
|
+
accessibilityLabel: label
|
|
191
|
+
})
|
|
192
|
+
})
|
|
193
|
+
}), !icon && image && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Image.default, {
|
|
194
|
+
source: image.src,
|
|
195
|
+
alt: image.alt,
|
|
196
|
+
style: selectImageStyles(themeTokens),
|
|
197
|
+
resizeMethod: "resize",
|
|
198
|
+
accessibilityIgnoresInvertColors: true
|
|
199
|
+
}), label && !shouldHideLabel && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
200
|
+
style: [staticStyles.label, selectLabelContainerStyles(themeTokens)],
|
|
201
|
+
children: (0, _utils.wrapStringsInText)(label, {
|
|
202
|
+
style: selectTitleTextStyles(themeTokens)
|
|
203
|
+
})
|
|
204
|
+
})]
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
ShortcutsItem.displayName = 'ShortcutsItem';
|
|
210
|
+
ShortcutsItem.propTypes = {
|
|
211
|
+
...selectedSystemPropTypes,
|
|
212
|
+
tokens: (0, _utils.getTokensPropType)('ShortcutsItem'),
|
|
213
|
+
variant: _utils.variantProp.propType,
|
|
214
|
+
/**
|
|
215
|
+
* Icon for the ShortcutsItem
|
|
216
|
+
*/
|
|
217
|
+
icon: _propTypes.default.elementType,
|
|
218
|
+
/**
|
|
219
|
+
* Image for the ShortcutsItem
|
|
220
|
+
*/
|
|
221
|
+
image: _propTypes.default.shape({
|
|
222
|
+
src: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number, _propTypes.default.object]),
|
|
223
|
+
alt: _propTypes.default.string
|
|
224
|
+
}),
|
|
225
|
+
/**
|
|
226
|
+
* Label for the ShortcutsItem
|
|
227
|
+
*/
|
|
228
|
+
label: _propTypes.default.string,
|
|
229
|
+
/**
|
|
230
|
+
* Hide the label for this specific ShortcutsItem. When true, the label is visually hidden but remains accessible to screen readers via the icon's accessibilityLabel.
|
|
231
|
+
*/
|
|
232
|
+
hideLabel: _propTypes.default.bool,
|
|
233
|
+
/**
|
|
234
|
+
* href for the ShortcutsItem
|
|
235
|
+
*/
|
|
236
|
+
href: _propTypes.default.string,
|
|
237
|
+
/**
|
|
238
|
+
* Icon variant for this specific ShortcutsItem
|
|
239
|
+
*/
|
|
240
|
+
iconVariant: _utils.variantProp.propType,
|
|
241
|
+
/**
|
|
242
|
+
* Callback function that receives the pressable state object containing pressed, hovered, and focused boolean properties
|
|
243
|
+
*/
|
|
244
|
+
onPressableStateChange: _propTypes.default.func,
|
|
245
|
+
/**
|
|
246
|
+
* Maximum width for equal width variant (automatically injected by Shortcuts container)
|
|
247
|
+
* @private
|
|
248
|
+
*/
|
|
249
|
+
maxWidth: _propTypes.default.number,
|
|
250
|
+
/**
|
|
251
|
+
* Callback to register width for equal width variant (automatically injected by Shortcuts container)
|
|
252
|
+
* @private
|
|
253
|
+
*/
|
|
254
|
+
registerWidth: _propTypes.default.func,
|
|
255
|
+
/**
|
|
256
|
+
* Variant configuration from Shortcuts container (automatically injected by Shortcuts container)
|
|
257
|
+
* @private
|
|
258
|
+
*/
|
|
259
|
+
containerVariant: _utils.variantProp.propType,
|
|
260
|
+
/**
|
|
261
|
+
* Hide labels setting from Shortcuts container (automatically injected by Shortcuts container)
|
|
262
|
+
* @private
|
|
263
|
+
*/
|
|
264
|
+
containerHideLabels: _propTypes.default.bool,
|
|
265
|
+
/**
|
|
266
|
+
* Icon variant from Shortcuts container (automatically injected by Shortcuts container)
|
|
267
|
+
* @private
|
|
268
|
+
*/
|
|
269
|
+
containerIconVariant: _utils.variantProp.propType
|
|
270
|
+
};
|
|
271
|
+
const staticStyles = _StyleSheet.default.create({
|
|
272
|
+
container: {
|
|
273
|
+
alignItems: 'center',
|
|
274
|
+
justifyContent: 'center'
|
|
275
|
+
},
|
|
276
|
+
label: {
|
|
277
|
+
flexWrap: 'wrap'
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
var _default = exports.default = ShortcutsItem;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "ShortcutsItem", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _ShortcutsItem.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
exports.default = void 0;
|
|
13
|
+
var _Shortcuts = _interopRequireDefault(require("./Shortcuts"));
|
|
14
|
+
var _ShortcutsItem = _interopRequireDefault(require("./ShortcutsItem"));
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
var _default = exports.default = _Shortcuts.default;
|
|
@@ -332,7 +332,7 @@ const TextInputBase = /*#__PURE__*/_react.default.forwardRef((_ref8, ref) => {
|
|
|
332
332
|
icon: ClearButtonIcon,
|
|
333
333
|
onPress: handleClear,
|
|
334
334
|
variant: {
|
|
335
|
-
|
|
335
|
+
subtle: true
|
|
336
336
|
}
|
|
337
337
|
}, "clear"));
|
|
338
338
|
}
|
|
@@ -342,8 +342,7 @@ const TextInputBase = /*#__PURE__*/_react.default.forwardRef((_ref8, ref) => {
|
|
|
342
342
|
icon: !showPassword ? passwordShowButtonIcon : passwordHideButtonIcon,
|
|
343
343
|
onPress: handleShowOrHide,
|
|
344
344
|
variant: {
|
|
345
|
-
|
|
346
|
-
password: true,
|
|
345
|
+
subtle: true,
|
|
347
346
|
inactive: variant.inactive,
|
|
348
347
|
size: 'large'
|
|
349
348
|
},
|
|
@@ -169,6 +169,7 @@ const Tooltip = /*#__PURE__*/_react.default.forwardRef((_ref7, ref) => {
|
|
|
169
169
|
nativeID,
|
|
170
170
|
activateOnHover = false,
|
|
171
171
|
tooltipButtonTokens,
|
|
172
|
+
testID,
|
|
172
173
|
...rest
|
|
173
174
|
} = _ref7;
|
|
174
175
|
const [isOpen, setIsOpen] = _react.default.useState(false);
|
|
@@ -312,6 +313,7 @@ const Tooltip = /*#__PURE__*/_react.default.forwardRef((_ref7, ref) => {
|
|
|
312
313
|
display: inline ? 'inline-block' : 'flex'
|
|
313
314
|
}
|
|
314
315
|
})],
|
|
316
|
+
testID: testID,
|
|
315
317
|
...selectProps(rest),
|
|
316
318
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Pressable.default, {
|
|
317
319
|
onPress: toggleIsOpen,
|
package/lib/cjs/index.js
CHANGED
|
@@ -59,6 +59,8 @@ var _exportNames = {
|
|
|
59
59
|
Responsive: true,
|
|
60
60
|
Search: true,
|
|
61
61
|
Select: true,
|
|
62
|
+
Shortcuts: true,
|
|
63
|
+
ShortcutsItem: true,
|
|
62
64
|
SideNav: true,
|
|
63
65
|
Skeleton: true,
|
|
64
66
|
SkipLink: true,
|
|
@@ -432,6 +434,18 @@ Object.defineProperty(exports, "Select", {
|
|
|
432
434
|
return _Select.default;
|
|
433
435
|
}
|
|
434
436
|
});
|
|
437
|
+
Object.defineProperty(exports, "Shortcuts", {
|
|
438
|
+
enumerable: true,
|
|
439
|
+
get: function () {
|
|
440
|
+
return _Shortcuts.default;
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
Object.defineProperty(exports, "ShortcutsItem", {
|
|
444
|
+
enumerable: true,
|
|
445
|
+
get: function () {
|
|
446
|
+
return _Shortcuts.ShortcutsItem;
|
|
447
|
+
}
|
|
448
|
+
});
|
|
435
449
|
Object.defineProperty(exports, "SideNav", {
|
|
436
450
|
enumerable: true,
|
|
437
451
|
get: function () {
|
|
@@ -744,6 +758,7 @@ var _RadioCard = _interopRequireWildcard(require("./RadioCard"));
|
|
|
744
758
|
var _Responsive = _interopRequireDefault(require("./Responsive"));
|
|
745
759
|
var _Search = _interopRequireDefault(require("./Search"));
|
|
746
760
|
var _Select = _interopRequireDefault(require("./Select"));
|
|
761
|
+
var _Shortcuts = _interopRequireWildcard(require("./Shortcuts"));
|
|
747
762
|
var _SideNav = _interopRequireDefault(require("./SideNav"));
|
|
748
763
|
var _Skeleton = _interopRequireDefault(require("./Skeleton"));
|
|
749
764
|
var _SkipLink = _interopRequireDefault(require("./SkipLink"));
|
package/lib/cjs/utils/index.js
CHANGED
|
@@ -23,7 +23,8 @@ var _exportNames = {
|
|
|
23
23
|
formatImageSource: true,
|
|
24
24
|
getSpacingScale: true,
|
|
25
25
|
useVariants: true,
|
|
26
|
-
isTouchDevice: true
|
|
26
|
+
isTouchDevice: true,
|
|
27
|
+
resolveContentMaxWidth: true
|
|
27
28
|
};
|
|
28
29
|
Object.defineProperty(exports, "BaseView", {
|
|
29
30
|
enumerable: true,
|
|
@@ -73,6 +74,12 @@ Object.defineProperty(exports, "isTouchDevice", {
|
|
|
73
74
|
return _isTouchDevice.default;
|
|
74
75
|
}
|
|
75
76
|
});
|
|
77
|
+
Object.defineProperty(exports, "resolveContentMaxWidth", {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
get: function () {
|
|
80
|
+
return _resolveContentMaxWidth.default;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
76
83
|
Object.defineProperty(exports, "transformGradient", {
|
|
77
84
|
enumerable: true,
|
|
78
85
|
get: function () {
|
|
@@ -272,6 +279,7 @@ var _formatImageSource = _interopRequireDefault(require("./formatImageSource"));
|
|
|
272
279
|
var _getSpacingScale = _interopRequireDefault(require("./getSpacingScale"));
|
|
273
280
|
var _useVariants = _interopRequireDefault(require("./useVariants"));
|
|
274
281
|
var _isTouchDevice = _interopRequireDefault(require("./isTouchDevice"));
|
|
282
|
+
var _resolveContentMaxWidth = _interopRequireDefault(require("./resolveContentMaxWidth"));
|
|
275
283
|
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); }
|
|
276
284
|
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; }
|
|
277
285
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const CONTENT_MAX_WIDTH = 'max';
|
|
8
|
+
const CONTENT_FULL_WIDTH = 'full';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Resolves the maximum width for content based on the provided value and responsive width.
|
|
12
|
+
*
|
|
13
|
+
* @param {number|string|null|undefined} contentMaxWidthValue - The maximum width value for the content.
|
|
14
|
+
* Can be a number, a special string constant (e.g., CONTENT_FULL_WIDTH, CONTENT_MAX_WIDTH), or null/undefined.
|
|
15
|
+
* @param {number} responsiveWidth - The responsive width to use when contentMaxWidthValue is CONTENT_MAX_WIDTH.
|
|
16
|
+
* @returns {number|string|null} The resolved maximum width value, or null if full width is desired.
|
|
17
|
+
*/
|
|
18
|
+
const resolveContentMaxWidth = (contentMaxWidthValue, responsiveWidth) => {
|
|
19
|
+
if (!contentMaxWidthValue || contentMaxWidthValue === CONTENT_FULL_WIDTH) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
if (Number.isFinite(contentMaxWidthValue)) {
|
|
23
|
+
return contentMaxWidthValue;
|
|
24
|
+
}
|
|
25
|
+
if (contentMaxWidthValue === CONTENT_MAX_WIDTH) {
|
|
26
|
+
return responsiveWidth;
|
|
27
|
+
}
|
|
28
|
+
return contentMaxWidthValue;
|
|
29
|
+
};
|
|
30
|
+
var _default = exports.default = resolveContentMaxWidth;
|
|
@@ -129,6 +129,7 @@ const ButtonGroup = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
129
129
|
id = label,
|
|
130
130
|
accessibilityLabel,
|
|
131
131
|
ref: itemRef,
|
|
132
|
+
inactive: itemInactive,
|
|
132
133
|
...itemRest
|
|
133
134
|
} = _ref2;
|
|
134
135
|
const isSelected = currentValues.includes(id);
|
|
@@ -152,6 +153,7 @@ const ButtonGroup = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
152
153
|
accessibilityLabel,
|
|
153
154
|
...a11yProps.getPositionInSet(items.length, index)
|
|
154
155
|
};
|
|
156
|
+
const isInactive = itemInactive !== undefined ? itemInactive : inactive;
|
|
155
157
|
|
|
156
158
|
// Ensure button is direct child of group as MacOS voiceover only applies "X of Y" to
|
|
157
159
|
// "radio" if it's a direct child of "radiogroup", even if aria-posinset etc exists
|
|
@@ -162,7 +164,7 @@ const ButtonGroup = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
162
164
|
onPress: handlePress,
|
|
163
165
|
tokens: getButtonTokens,
|
|
164
166
|
selected: isSelected,
|
|
165
|
-
inactive:
|
|
167
|
+
inactive: isInactive,
|
|
166
168
|
icon: iconProp,
|
|
167
169
|
...selectItemProps({
|
|
168
170
|
...itemRest,
|
|
@@ -216,7 +218,12 @@ ButtonGroup.propTypes = {
|
|
|
216
218
|
/**
|
|
217
219
|
* An optional ref for one individual button in the ButtonGroup
|
|
218
220
|
*/
|
|
219
|
-
ref: ABBPropTypes.ref()
|
|
221
|
+
ref: ABBPropTypes.ref(),
|
|
222
|
+
/**
|
|
223
|
+
* If true, this individual button cannot be interacted with. Takes precedence
|
|
224
|
+
* over the group-level `inactive` prop. Useful for disabling specific options.
|
|
225
|
+
*/
|
|
226
|
+
inactive: PropTypes.bool
|
|
220
227
|
})),
|
|
221
228
|
/**
|
|
222
229
|
* If provided, this function is called when the current selection is changed
|