@telus-uds/components-base 1.3.0 → 1.5.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/.turbo/turbo-build.log +5 -2
- package/CHANGELOG.json +82 -0
- package/CHANGELOG.md +42 -2
- package/__tests__/ActivityIndicator/ActivityIndicator.test.jsx +35 -0
- package/__tests__/ActivityIndicator/__snapshots__/ActivityIndicator.test.jsx.snap +287 -0
- package/babel.config.js +27 -5
- package/component-docs.json +121 -438
- package/lib/A11yText/index.js +5 -4
- package/lib/ActivityIndicator/Spinner.js +46 -37
- package/lib/ActivityIndicator/Spinner.native.js +26 -15
- package/lib/Box/Box.js +4 -4
- package/lib/Button/ButtonBase.js +7 -8
- package/lib/Card/Card.js +5 -4
- package/lib/Card/PressableCardBase.js +6 -11
- package/lib/Checkbox/Checkbox.js +4 -6
- package/lib/Divider/Divider.js +12 -11
- package/lib/ExpandCollapse/Control.js +7 -7
- package/lib/ExpandCollapse/ExpandCollapse.js +6 -2
- package/lib/ExpandCollapse/Panel.js +6 -7
- package/lib/Feedback/Feedback.js +6 -5
- package/lib/Fieldset/Fieldset.js +1 -3
- package/lib/HorizontalScroll/HorizontalScroll.js +5 -7
- package/lib/HorizontalScroll/HorizontalScrollButton.js +23 -49
- package/lib/IconButton/IconButton.js +6 -6
- package/lib/InputLabel/InputLabel.js +7 -2
- package/lib/InputSupports/InputSupports.js +2 -2
- package/lib/Link/LinkBase.js +5 -6
- package/lib/List/List.js +4 -6
- package/lib/List/ListItem.js +6 -2
- package/lib/Modal/Modal.js +6 -2
- package/lib/Notification/Notification.js +12 -8
- package/lib/Pagination/Pagination.js +8 -3
- package/lib/Progress/Progress.js +5 -4
- package/lib/Progress/ProgressBar.js +8 -7
- package/lib/Radio/Radio.js +4 -6
- package/lib/Radio/RadioButton.js +6 -3
- package/lib/Radio/RadioGroup.js +7 -2
- package/lib/RadioCard/RadioCard.js +4 -4
- package/lib/RadioCard/RadioCardGroup.js +9 -6
- package/lib/Search/Search.js +7 -2
- package/lib/Select/Select.js +10 -9
- package/lib/SideNav/Item.js +7 -7
- package/lib/SideNav/SideNav.js +7 -3
- package/lib/Skeleton/Skeleton.js +6 -2
- package/lib/Spacer/Spacer.js +7 -18
- package/lib/StackView/StackView.js +7 -7
- package/lib/StackView/StackWrapBox.js +6 -7
- package/lib/StackView/StackWrapGap.js +6 -5
- package/lib/StepTracker/Step.js +7 -3
- package/lib/StepTracker/StepTracker.js +7 -7
- package/lib/Tabs/Tabs.js +6 -2
- package/lib/Tabs/TabsItem.js +6 -5
- package/lib/Tags/Tags.js +5 -6
- package/lib/TextInput/TextArea.js +13 -14
- package/lib/TextInput/TextInput.js +13 -14
- package/lib/TextInput/TextInputBase.js +5 -3
- package/lib/ToggleSwitch/ToggleSwitch.js +10 -9
- package/lib/ToggleSwitch/ToggleSwitchGroup.js +5 -7
- package/lib/Tooltip/Tooltip.js +7 -2
- package/lib/TooltipButton/TooltipButton.js +7 -2
- package/lib/Typography/Typography.js +8 -6
- package/lib/index.js +7 -0
- package/lib/utils/children.js +5 -1
- package/lib/utils/index.js +14 -0
- package/lib/utils/props/index.js +9 -0
- package/lib/{InputSupports/propTypes.js → utils/props/inputSupportsProps.js} +2 -3
- package/lib/utils/ssr.js +51 -0
- package/lib-module/A11yInfoProvider/index.js +62 -0
- package/lib-module/A11yText/index.js +55 -0
- package/lib-module/ActivityIndicator/Spinner.js +76 -0
- package/lib-module/ActivityIndicator/Spinner.native.js +143 -0
- package/lib-module/ActivityIndicator/index.js +40 -0
- package/lib-module/ActivityIndicator/shared.js +12 -0
- package/lib-module/BaseProvider/index.js +26 -0
- package/lib-module/Box/Box.js +243 -0
- package/lib-module/Box/index.js +2 -0
- package/lib-module/Button/Button.js +25 -0
- package/lib-module/Button/ButtonBase.js +254 -0
- package/lib-module/Button/ButtonGroup.js +164 -0
- package/lib-module/Button/ButtonLink.js +39 -0
- package/lib-module/Button/index.js +4 -0
- package/lib-module/Button/propTypes.js +36 -0
- package/lib-module/Card/Card.js +83 -0
- package/lib-module/Card/CardBase.js +62 -0
- package/lib-module/Card/PressableCardBase.js +113 -0
- package/lib-module/Card/index.js +4 -0
- package/lib-module/Checkbox/Checkbox.js +321 -0
- package/lib-module/Checkbox/CheckboxGroup.js +218 -0
- package/lib-module/Checkbox/CheckboxInput.js +58 -0
- package/lib-module/Checkbox/CheckboxInput.native.js +6 -0
- package/lib-module/Checkbox/index.js +3 -0
- package/lib-module/Divider/Divider.js +123 -0
- package/lib-module/Divider/index.js +2 -0
- package/lib-module/ExpandCollapse/Accordion.js +15 -0
- package/lib-module/ExpandCollapse/Control.js +130 -0
- package/lib-module/ExpandCollapse/ExpandCollapse.js +94 -0
- package/lib-module/ExpandCollapse/Panel.js +158 -0
- package/lib-module/ExpandCollapse/index.js +7 -0
- package/lib-module/Feedback/Feedback.js +144 -0
- package/lib-module/Feedback/index.js +2 -0
- package/lib-module/Fieldset/Fieldset.js +145 -0
- package/lib-module/Fieldset/FieldsetContainer.js +29 -0
- package/lib-module/Fieldset/FieldsetContainer.native.js +20 -0
- package/lib-module/Fieldset/Legend.js +21 -0
- package/lib-module/Fieldset/Legend.native.js +28 -0
- package/lib-module/Fieldset/cssReset.js +14 -0
- package/lib-module/Fieldset/index.js +2 -0
- package/lib-module/FlexGrid/Col/Col.js +265 -0
- package/lib-module/FlexGrid/Col/index.js +2 -0
- package/lib-module/FlexGrid/FlexGrid.js +147 -0
- package/lib-module/FlexGrid/Row/Row.js +177 -0
- package/lib-module/FlexGrid/Row/index.js +2 -0
- package/lib-module/FlexGrid/helpers/index.js +18 -0
- package/lib-module/FlexGrid/index.js +2 -0
- package/lib-module/FlexGrid/providers/GutterContext.js +3 -0
- package/lib-module/HorizontalScroll/HorizontalScroll.js +170 -0
- package/lib-module/HorizontalScroll/HorizontalScrollButton.js +77 -0
- package/lib-module/HorizontalScroll/ScrollViewEnd.js +47 -0
- package/lib-module/HorizontalScroll/ScrollViewEnd.native.js +24 -0
- package/lib-module/HorizontalScroll/dictionary.js +11 -0
- package/lib-module/HorizontalScroll/index.js +11 -0
- package/lib-module/HorizontalScroll/itemPositions.js +106 -0
- package/lib-module/Icon/Icon.js +61 -0
- package/lib-module/Icon/IconText.js +81 -0
- package/lib-module/Icon/index.js +4 -0
- package/lib-module/IconButton/IconButton.js +115 -0
- package/lib-module/IconButton/index.js +2 -0
- package/lib-module/InputLabel/InputLabel.js +131 -0
- package/lib-module/InputLabel/LabelContent.js +24 -0
- package/lib-module/InputLabel/LabelContent.native.js +16 -0
- package/lib-module/InputLabel/index.js +2 -0
- package/lib-module/InputSupports/InputSupports.js +88 -0
- package/lib-module/InputSupports/index.js +2 -0
- package/lib-module/InputSupports/useInputSupports.js +31 -0
- package/lib-module/Link/ChevronLink.js +51 -0
- package/lib-module/Link/InlinePressable.js +37 -0
- package/lib-module/Link/InlinePressable.native.js +85 -0
- package/lib-module/Link/Link.js +27 -0
- package/lib-module/Link/LinkBase.js +210 -0
- package/lib-module/Link/TextButton.js +43 -0
- package/lib-module/Link/index.js +5 -0
- package/lib-module/List/List.js +55 -0
- package/lib-module/List/ListItem.js +213 -0
- package/lib-module/List/index.js +5 -0
- package/lib-module/Modal/Modal.js +208 -0
- package/lib-module/Modal/dictionary.js +9 -0
- package/lib-module/Modal/index.js +2 -0
- package/lib-module/Notification/Notification.js +196 -0
- package/lib-module/Notification/dictionary.js +8 -0
- package/lib-module/Notification/index.js +2 -0
- package/lib-module/Pagination/PageButton.js +65 -0
- package/lib-module/Pagination/Pagination.js +140 -0
- package/lib-module/Pagination/SideButton.js +103 -0
- package/lib-module/Pagination/dictionary.js +18 -0
- package/lib-module/Pagination/index.js +2 -0
- package/lib-module/Pagination/usePagination.js +72 -0
- package/lib-module/Progress/Progress.js +85 -0
- package/lib-module/Progress/ProgressBar.js +134 -0
- package/lib-module/Progress/ProgressBarBackground.js +41 -0
- package/lib-module/Progress/index.js +4 -0
- package/lib-module/Radio/Radio.js +263 -0
- package/lib-module/Radio/RadioButton.js +128 -0
- package/lib-module/Radio/RadioGroup.js +225 -0
- package/lib-module/Radio/RadioInput.js +60 -0
- package/lib-module/Radio/RadioInput.native.js +6 -0
- package/lib-module/Radio/index.js +3 -0
- package/lib-module/RadioCard/RadioCard.js +218 -0
- package/lib-module/RadioCard/RadioCardGroup.js +232 -0
- package/lib-module/RadioCard/index.js +3 -0
- package/lib-module/Search/Search.js +233 -0
- package/lib-module/Search/dictionary.js +12 -0
- package/lib-module/Search/index.js +2 -0
- package/lib-module/Select/Group.js +20 -0
- package/lib-module/Select/Group.native.js +14 -0
- package/lib-module/Select/Item.js +17 -0
- package/lib-module/Select/Item.native.js +9 -0
- package/lib-module/Select/Picker.js +67 -0
- package/lib-module/Select/Picker.native.js +110 -0
- package/lib-module/Select/Select.js +317 -0
- package/lib-module/Select/index.js +6 -0
- package/lib-module/SideNav/Item.js +139 -0
- package/lib-module/SideNav/ItemContent.js +45 -0
- package/lib-module/SideNav/ItemsGroup.js +115 -0
- package/lib-module/SideNav/SideNav.js +133 -0
- package/lib-module/SideNav/index.js +1 -0
- package/lib-module/Skeleton/Skeleton.js +117 -0
- package/lib-module/Skeleton/index.js +2 -0
- package/lib-module/Skeleton/skeleton.constant.js +3 -0
- package/lib-module/Skeleton/skeletonWebAnimation.js +18 -0
- package/lib-module/Skeleton/useSkeletonNativeAnimation.js +24 -0
- package/lib-module/Spacer/Spacer.js +97 -0
- package/lib-module/Spacer/index.js +2 -0
- package/lib-module/StackView/StackView.js +124 -0
- package/lib-module/StackView/StackWrap.js +48 -0
- package/lib-module/StackView/StackWrap.native.js +3 -0
- package/lib-module/StackView/StackWrapBox.js +114 -0
- package/lib-module/StackView/StackWrapGap.js +58 -0
- package/lib-module/StackView/common.js +32 -0
- package/lib-module/StackView/getStackedContent.js +123 -0
- package/lib-module/StackView/index.js +5 -0
- package/lib-module/StepTracker/Step.js +229 -0
- package/lib-module/StepTracker/StepTracker.js +175 -0
- package/lib-module/StepTracker/dictionary.js +10 -0
- package/lib-module/StepTracker/index.js +2 -0
- package/lib-module/Tabs/Tabs.js +113 -0
- package/lib-module/Tabs/TabsItem.js +215 -0
- package/lib-module/Tabs/index.js +2 -0
- package/lib-module/Tags/Tags.js +238 -0
- package/lib-module/Tags/index.js +2 -0
- package/lib-module/TextInput/TextArea.js +88 -0
- package/lib-module/TextInput/TextInput.js +60 -0
- package/lib-module/TextInput/TextInputBase.js +233 -0
- package/lib-module/TextInput/index.js +3 -0
- package/lib-module/TextInput/propTypes.js +31 -0
- package/lib-module/ThemeProvider/ThemeProvider.js +35 -0
- package/lib-module/ThemeProvider/index.js +6 -0
- package/lib-module/ThemeProvider/useSetTheme.js +22 -0
- package/lib-module/ThemeProvider/useTheme.js +14 -0
- package/lib-module/ThemeProvider/useThemeTokens.js +105 -0
- package/lib-module/ThemeProvider/utils/index.js +2 -0
- package/lib-module/ThemeProvider/utils/styles.js +174 -0
- package/lib-module/ThemeProvider/utils/theme-tokens.js +151 -0
- package/lib-module/ToggleSwitch/ToggleSwitch.js +224 -0
- package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +202 -0
- package/lib-module/ToggleSwitch/index.js +3 -0
- package/lib-module/Tooltip/Backdrop.js +52 -0
- package/lib-module/Tooltip/Backdrop.native.js +43 -0
- package/lib-module/Tooltip/Tooltip.js +332 -0
- package/lib-module/Tooltip/dictionary.js +8 -0
- package/lib-module/Tooltip/getTooltipPosition.js +164 -0
- package/lib-module/Tooltip/index.js +2 -0
- package/lib-module/TooltipButton/TooltipButton.js +71 -0
- package/lib-module/TooltipButton/index.js +2 -0
- package/lib-module/Typography/Typography.js +118 -0
- package/lib-module/Typography/index.js +2 -0
- package/lib-module/ViewportProvider/ViewportProvider.js +28 -0
- package/lib-module/ViewportProvider/index.js +3 -0
- package/lib-module/ViewportProvider/useViewport.js +3 -0
- package/lib-module/ViewportProvider/useViewportListener.js +43 -0
- package/lib-module/index.js +48 -0
- package/lib-module/utils/a11y/index.js +2 -0
- package/lib-module/utils/a11y/semantics.js +154 -0
- package/lib-module/utils/a11y/textSize.js +34 -0
- package/lib-module/utils/animation/index.js +2 -0
- package/lib-module/utils/animation/useVerticalExpandAnimation.js +49 -0
- package/lib-module/utils/children.js +118 -0
- package/lib-module/utils/index.js +15 -0
- package/lib-module/utils/info/index.js +7 -0
- package/lib-module/utils/info/platform/index.js +11 -0
- package/lib-module/utils/info/platform/platform.android.js +1 -0
- package/lib-module/utils/info/platform/platform.ios.js +1 -0
- package/lib-module/utils/info/platform/platform.js +1 -0
- package/lib-module/utils/info/platform/platform.native.js +4 -0
- package/lib-module/utils/info/versions.js +5 -0
- package/lib-module/utils/input.js +180 -0
- package/lib-module/utils/pressability.js +97 -0
- package/lib-module/utils/props/a11yProps.js +140 -0
- package/lib-module/utils/props/clickProps.js +25 -0
- package/lib-module/utils/props/componentPropType.js +63 -0
- package/lib-module/utils/props/copyPropTypes.js +2 -0
- package/lib-module/utils/props/getPropSelector.js +6 -0
- package/lib-module/utils/props/hrefAttrsProp.js +30 -0
- package/lib-module/utils/props/index.js +16 -0
- package/lib-module/utils/props/inputSupportsProps.js +54 -0
- package/lib-module/utils/props/linkProps.js +47 -0
- package/lib-module/utils/props/paddingProp.js +9 -0
- package/lib-module/utils/props/pressProps.js +42 -0
- package/lib-module/utils/props/rectProp.js +9 -0
- package/lib-module/utils/props/responsiveProps.js +30 -0
- package/lib-module/utils/props/selectSystemProps.js +24 -0
- package/lib-module/utils/props/spacingProps.js +56 -0
- package/lib-module/utils/props/tokens.js +120 -0
- package/lib-module/utils/props/variantProp.js +18 -0
- package/lib-module/utils/props/viewProps.js +22 -0
- package/lib-module/utils/ssr.js +35 -0
- package/lib-module/utils/useCopy.js +42 -0
- package/lib-module/utils/useHash.js +44 -0
- package/lib-module/utils/useHash.native.js +7 -0
- package/lib-module/utils/useResponsiveProp.js +47 -0
- package/lib-module/utils/useSpacingScale.js +123 -0
- package/lib-module/utils/useUniqueId.js +12 -0
- package/lib-module/utils/withLinkRouter.js +82 -0
- package/package.json +9 -5
- package/src/A11yText/index.jsx +7 -3
- package/src/ActivityIndicator/Spinner.jsx +56 -44
- package/src/ActivityIndicator/Spinner.native.jsx +20 -12
- package/src/Box/Box.jsx +10 -9
- package/src/Button/ButtonBase.jsx +9 -8
- package/src/Card/Card.jsx +7 -4
- package/src/Card/PressableCardBase.jsx +12 -12
- package/src/Checkbox/Checkbox.jsx +12 -5
- package/src/Divider/Divider.jsx +17 -10
- package/src/ExpandCollapse/Control.jsx +12 -7
- package/src/ExpandCollapse/ExpandCollapse.jsx +13 -3
- package/src/ExpandCollapse/Panel.jsx +15 -5
- package/src/Feedback/Feedback.jsx +13 -3
- package/src/Fieldset/Fieldset.jsx +1 -1
- package/src/HorizontalScroll/HorizontalScroll.jsx +13 -6
- package/src/HorizontalScroll/HorizontalScrollButton.jsx +21 -58
- package/src/IconButton/IconButton.jsx +12 -8
- package/src/InputLabel/InputLabel.jsx +16 -2
- package/src/InputSupports/InputSupports.jsx +1 -1
- package/src/Link/LinkBase.jsx +10 -9
- package/src/List/List.jsx +12 -5
- package/src/List/ListItem.jsx +16 -2
- package/src/Modal/Modal.jsx +63 -50
- package/src/Notification/Notification.jsx +23 -6
- package/src/Pagination/Pagination.jsx +10 -3
- package/src/Progress/Progress.jsx +5 -3
- package/src/Progress/ProgressBar.jsx +8 -6
- package/src/Radio/Radio.jsx +13 -5
- package/src/Radio/RadioButton.jsx +13 -3
- package/src/Radio/RadioGroup.jsx +14 -2
- package/src/RadioCard/RadioCard.jsx +9 -6
- package/src/RadioCard/RadioCardGroup.jsx +16 -4
- package/src/Search/Search.jsx +15 -3
- package/src/Select/Select.jsx +21 -7
- package/src/SideNav/Item.jsx +15 -7
- package/src/SideNav/SideNav.jsx +13 -2
- package/src/Skeleton/Skeleton.jsx +55 -43
- package/src/Spacer/Spacer.jsx +8 -16
- package/src/StackView/StackView.jsx +13 -12
- package/src/StackView/StackWrapBox.jsx +12 -12
- package/src/StackView/StackWrapGap.jsx +9 -7
- package/src/StepTracker/Step.jsx +7 -4
- package/src/StepTracker/StepTracker.jsx +8 -8
- package/src/Tabs/Tabs.jsx +16 -3
- package/src/Tabs/TabsItem.jsx +13 -9
- package/src/Tags/Tags.jsx +20 -5
- package/src/TextInput/TextArea.jsx +20 -8
- package/src/TextInput/TextInput.jsx +20 -8
- package/src/TextInput/TextInputBase.jsx +13 -3
- package/src/ToggleSwitch/ToggleSwitch.jsx +16 -5
- package/src/ToggleSwitch/ToggleSwitchGroup.jsx +14 -6
- package/src/Tooltip/Tooltip.jsx +13 -3
- package/src/TooltipButton/TooltipButton.jsx +6 -4
- package/src/Typography/Typography.jsx +10 -6
- package/src/index.js +1 -1
- package/src/utils/children.jsx +2 -1
- package/src/utils/index.js +1 -0
- package/src/utils/props/index.js +1 -0
- package/src/{InputSupports/propTypes.js → utils/props/inputSupportsProps.js} +2 -4
- package/src/utils/ssr.js +35 -0
- package/release-context.json +0 -7
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import ButtonBase from './ButtonBase';
|
|
3
|
+
import buttonPropTypes, { textAndA11yText } from './propTypes';
|
|
4
|
+
import { a11yProps, hrefAttrsProp, linkProps } from '../utils/props';
|
|
5
|
+
import { useThemeTokensCallback } from '../ThemeProvider';
|
|
6
|
+
/**
|
|
7
|
+
* `ButtonLink` is a component with the semantics and behaviour of a link, but with the visual appearance of a button.
|
|
8
|
+
* ButtonLink is a block-level component and should not be used inline.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
const ButtonLink = /*#__PURE__*/forwardRef(({
|
|
13
|
+
accessibilityRole = 'link',
|
|
14
|
+
tokens,
|
|
15
|
+
variant,
|
|
16
|
+
dataSet,
|
|
17
|
+
...props
|
|
18
|
+
}, ref) => {
|
|
19
|
+
const {
|
|
20
|
+
hrefAttrs,
|
|
21
|
+
rest
|
|
22
|
+
} = hrefAttrsProp.bundle(props);
|
|
23
|
+
const getTokens = useThemeTokensCallback('Button', tokens, variant);
|
|
24
|
+
return /*#__PURE__*/_jsx(ButtonBase, {
|
|
25
|
+
ref: ref,
|
|
26
|
+
accessibilityRole: accessibilityRole,
|
|
27
|
+
tokens: getTokens,
|
|
28
|
+
hrefAttrs: hrefAttrs,
|
|
29
|
+
dataSet: dataSet,
|
|
30
|
+
...rest
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
ButtonLink.displayName = 'ButtonLink';
|
|
34
|
+
ButtonLink.propTypes = { ...a11yProps.types,
|
|
35
|
+
...buttonPropTypes,
|
|
36
|
+
...linkProps.types,
|
|
37
|
+
children: textAndA11yText
|
|
38
|
+
};
|
|
39
|
+
export default ButtonLink;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import ABBPropTypes from 'airbnb-prop-types';
|
|
3
|
+
import { variantProp, getTokensPropType } from '../utils/props';
|
|
4
|
+
import A11yText from '../A11yText';
|
|
5
|
+
export const textAndA11yText = ABBPropTypes.childrenOf(PropTypes.oneOfType([ABBPropTypes.elementType(A11yText), PropTypes.string]));
|
|
6
|
+
const buttonPropTypes = {
|
|
7
|
+
tokens: getTokensPropType('Button'),
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* If true, prevents the button from being pressed, changes the cursor (on web) and accessibility
|
|
11
|
+
* attributes to communicate this to the user, and applies `inactive: true` appearances from the theme
|
|
12
|
+
*/
|
|
13
|
+
inactive: PropTypes.bool,
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Alias for `inactive`
|
|
17
|
+
*/
|
|
18
|
+
disabled: PropTypes.bool,
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Button's children must be either:
|
|
22
|
+
* - One or more text strings and / or A11yText components
|
|
23
|
+
* - A render function with contents that responds to current button state by being passed an object of:
|
|
24
|
+
* ```
|
|
25
|
+
* { hovered<bool>, focused<bool>, pressed<bool>, inactive<bool>, selected<bool>, textStyles<RNStyle> }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
children: PropTypes.oneOfType([PropTypes.func, textAndA11yText]).isRequired,
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Function called when the button is pressed. Required unless the button has a href.
|
|
32
|
+
*/
|
|
33
|
+
onPress: PropTypes.func,
|
|
34
|
+
variant: variantProp.propType
|
|
35
|
+
};
|
|
36
|
+
export default buttonPropTypes;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { useThemeTokens } from '../ThemeProvider';
|
|
4
|
+
import { getTokensPropType, variantProp } from '../utils';
|
|
5
|
+
import { useViewport } from '../ViewportProvider';
|
|
6
|
+
import { a11yProps, selectSystemProps, viewProps } from '../utils/props';
|
|
7
|
+
import CardBase from './CardBase';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
10
|
+
/**
|
|
11
|
+
* A basic card component, unstyled by default.
|
|
12
|
+
*
|
|
13
|
+
* ## Component API
|
|
14
|
+
*
|
|
15
|
+
* ### Background
|
|
16
|
+
*
|
|
17
|
+
* In order to control the background of a card, the following tokens are currently
|
|
18
|
+
* supported:
|
|
19
|
+
*
|
|
20
|
+
* - `backgroundColor`
|
|
21
|
+
*
|
|
22
|
+
* ### Border
|
|
23
|
+
*
|
|
24
|
+
* The following border tokens can be used:
|
|
25
|
+
*
|
|
26
|
+
* - `borderColor`
|
|
27
|
+
* - `borderRadius`
|
|
28
|
+
* - `borderWidth`
|
|
29
|
+
*
|
|
30
|
+
* ### Padding
|
|
31
|
+
*
|
|
32
|
+
* Please use the following tokens to control the padding:
|
|
33
|
+
*
|
|
34
|
+
* - `paddingBottom`
|
|
35
|
+
* - `paddingLeft`
|
|
36
|
+
* - `paddingRight`
|
|
37
|
+
* - `paddingTop`
|
|
38
|
+
*
|
|
39
|
+
* Note that various viewport sizes are supported as well.
|
|
40
|
+
*
|
|
41
|
+
* ### Shadow
|
|
42
|
+
*
|
|
43
|
+
* Feel free to use the following properties within the `shadow` token:
|
|
44
|
+
*
|
|
45
|
+
* - `inset`: boolean
|
|
46
|
+
* - `color`: string
|
|
47
|
+
* - `offsetX`: number
|
|
48
|
+
* - `offsetY`: number
|
|
49
|
+
* - `blur`: number
|
|
50
|
+
* - `spread`: number
|
|
51
|
+
*
|
|
52
|
+
* ## Accessibility
|
|
53
|
+
*
|
|
54
|
+
* Card supports all the common a11y props. Please remember that by marking a card as `accessible`
|
|
55
|
+
* you automatically make inaccessible its children, which may or may not be appropriate
|
|
56
|
+
* depending on what you are trying to achieve.
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
const Card = ({
|
|
60
|
+
children,
|
|
61
|
+
tokens,
|
|
62
|
+
variant,
|
|
63
|
+
dataSet,
|
|
64
|
+
...rest
|
|
65
|
+
}) => {
|
|
66
|
+
const viewport = useViewport();
|
|
67
|
+
const themeTokens = useThemeTokens('Card', tokens, variant, {
|
|
68
|
+
viewport
|
|
69
|
+
});
|
|
70
|
+
return /*#__PURE__*/_jsx(CardBase, {
|
|
71
|
+
tokens: themeTokens,
|
|
72
|
+
dataSet: dataSet,
|
|
73
|
+
...selectProps(rest),
|
|
74
|
+
children: children
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
Card.propTypes = { ...selectedSystemPropTypes,
|
|
79
|
+
children: PropTypes.node,
|
|
80
|
+
tokens: getTokensPropType('Card'),
|
|
81
|
+
variant: variantProp.propType
|
|
82
|
+
};
|
|
83
|
+
export default Card;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import View from "react-native-web/dist/exports/View";
|
|
4
|
+
import { applyShadowToken } from '../ThemeProvider';
|
|
5
|
+
import { getTokensPropType } from '../utils';
|
|
6
|
+
import { a11yProps, viewProps, selectSystemProps } from '../utils/props';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]); // Ensure explicit selection of tokens
|
|
9
|
+
|
|
10
|
+
const selectStyles = ({
|
|
11
|
+
flex,
|
|
12
|
+
backgroundColor,
|
|
13
|
+
borderColor,
|
|
14
|
+
borderRadius,
|
|
15
|
+
borderWidth,
|
|
16
|
+
paddingBottom,
|
|
17
|
+
paddingLeft,
|
|
18
|
+
paddingRight,
|
|
19
|
+
paddingTop,
|
|
20
|
+
minWidth,
|
|
21
|
+
shadow
|
|
22
|
+
}) => ({
|
|
23
|
+
flex,
|
|
24
|
+
backgroundColor,
|
|
25
|
+
borderColor,
|
|
26
|
+
borderRadius,
|
|
27
|
+
borderWidth,
|
|
28
|
+
paddingBottom,
|
|
29
|
+
paddingLeft,
|
|
30
|
+
paddingRight,
|
|
31
|
+
paddingTop,
|
|
32
|
+
minWidth,
|
|
33
|
+
...applyShadowToken(shadow)
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* A themeless base component for Card which components can apply theme tokens to. Not
|
|
37
|
+
* intended to be used in apps or sites directly: build themed components on top of this.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
const CardBase = /*#__PURE__*/forwardRef(({
|
|
42
|
+
children,
|
|
43
|
+
tokens,
|
|
44
|
+
dataSet,
|
|
45
|
+
...rest
|
|
46
|
+
}, ref) => {
|
|
47
|
+
const cardStyle = selectStyles(typeof tokens === 'function' ? tokens() : tokens);
|
|
48
|
+
const props = selectProps(rest);
|
|
49
|
+
return /*#__PURE__*/_jsx(View, {
|
|
50
|
+
style: cardStyle,
|
|
51
|
+
dataSet: dataSet,
|
|
52
|
+
ref: ref,
|
|
53
|
+
...props,
|
|
54
|
+
children: children
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
CardBase.displayName = 'CardBase';
|
|
58
|
+
CardBase.propTypes = { ...selectedSystemPropTypes,
|
|
59
|
+
children: PropTypes.node,
|
|
60
|
+
tokens: getTokensPropType('Card')
|
|
61
|
+
};
|
|
62
|
+
export default CardBase;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Pressable from "react-native-web/dist/exports/Pressable";
|
|
4
|
+
import Platform from "react-native-web/dist/exports/Platform";
|
|
5
|
+
import { useViewport } from '../ViewportProvider';
|
|
6
|
+
import { applyOuterBorder, validateThemeTokens } from '../ThemeProvider';
|
|
7
|
+
import { a11yProps, clickProps, getTokenNames, getTokensSetPropType, linkProps, resolvePressableState, resolvePressableTokens, selectSystemProps, selectTokens, variantProp, viewProps, withLinkRouter } from '../utils';
|
|
8
|
+
import CardBase from './CardBase';
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
11
|
+
const tokenKeys = [...getTokenNames('Card'), // Outer border tokens. TODO: centralise common token sets like these as part of
|
|
12
|
+
// https://github.com/telus/universal-design-system/issues/782
|
|
13
|
+
'outerBorderColor', 'outerBorderWidth', 'outerBorderGap'];
|
|
14
|
+
export const selectPressableCardTokens = tokens => Object.fromEntries(tokenKeys.map(key => [key, tokens[key]]));
|
|
15
|
+
/**
|
|
16
|
+
* A pressable themeless base component that handles pressable states and passes tokens
|
|
17
|
+
* based on these to an outer border and a base Card component. Not intended to be used in
|
|
18
|
+
* apps or sites directly: build themed components on top of this.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const PressableCardBase = /*#__PURE__*/forwardRef(({
|
|
22
|
+
children,
|
|
23
|
+
tokens,
|
|
24
|
+
checked,
|
|
25
|
+
validation,
|
|
26
|
+
inactive,
|
|
27
|
+
href,
|
|
28
|
+
hrefAttrs,
|
|
29
|
+
accessibilityRole = href ? 'link' : undefined,
|
|
30
|
+
...rawRest
|
|
31
|
+
}, ref) => {
|
|
32
|
+
const {
|
|
33
|
+
onPress,
|
|
34
|
+
...rest
|
|
35
|
+
} = clickProps.toPressProps(rawRest);
|
|
36
|
+
const viewport = useViewport();
|
|
37
|
+
const additionalState = {
|
|
38
|
+
checked,
|
|
39
|
+
validation,
|
|
40
|
+
inactive,
|
|
41
|
+
viewport
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const getCardState = pressableState => resolvePressableState(pressableState, additionalState);
|
|
45
|
+
|
|
46
|
+
const getTokens = pressableState => validateThemeTokens(resolvePressableTokens(tokens, pressableState, additionalState), getTokensSetPropType(tokenKeys, {
|
|
47
|
+
requireAll: true
|
|
48
|
+
}), 'PressableCard');
|
|
49
|
+
|
|
50
|
+
const getCardTokens = pressableState => selectTokens('Card', getTokens(pressableState));
|
|
51
|
+
|
|
52
|
+
const getOuterBorderStyle = pressableState => {
|
|
53
|
+
const {
|
|
54
|
+
flex,
|
|
55
|
+
minWidth,
|
|
56
|
+
outerBorderColor,
|
|
57
|
+
outerBorderGap = 0,
|
|
58
|
+
outerBorderWidth = 0,
|
|
59
|
+
borderRadius
|
|
60
|
+
} = getTokens(pressableState);
|
|
61
|
+
return {
|
|
62
|
+
flex,
|
|
63
|
+
minWidth: minWidth + outerBorderGap + outerBorderWidth,
|
|
64
|
+
...applyOuterBorder({
|
|
65
|
+
outerBorderColor,
|
|
66
|
+
outerBorderGap,
|
|
67
|
+
outerBorderWidth,
|
|
68
|
+
borderRadius
|
|
69
|
+
}),
|
|
70
|
+
...Platform.select({
|
|
71
|
+
web: {
|
|
72
|
+
outline: 'none'
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const handleChange = linkProps.handleHref({
|
|
79
|
+
href,
|
|
80
|
+
onPress
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const handleKeyDown = event => {
|
|
84
|
+
// The expected keyboard shortcut for selecting a focused item is the Space key
|
|
85
|
+
if ((event === null || event === void 0 ? void 0 : event.key) === ' ') handleChange(event);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
return /*#__PURE__*/_jsx(Pressable, {
|
|
89
|
+
ref: ref,
|
|
90
|
+
href: href,
|
|
91
|
+
onPress: handleChange,
|
|
92
|
+
onKeyDown: handleKeyDown,
|
|
93
|
+
hrefAttrs: hrefAttrs,
|
|
94
|
+
style: getOuterBorderStyle,
|
|
95
|
+
...selectProps({ ...rest,
|
|
96
|
+
accessibilityRole
|
|
97
|
+
}),
|
|
98
|
+
children: pressableState => /*#__PURE__*/_jsx(CardBase, {
|
|
99
|
+
tokens: getCardTokens(pressableState),
|
|
100
|
+
children: typeof children === 'function' ? children(getCardState(pressableState)) : children
|
|
101
|
+
})
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
PressableCardBase.displayName = 'PressableCardBase';
|
|
105
|
+
PressableCardBase.propTypes = { ...selectedSystemPropTypes,
|
|
106
|
+
children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
107
|
+
tokens: getTokensSetPropType(tokenKeys, {
|
|
108
|
+
requireAll: true,
|
|
109
|
+
allowFunction: true
|
|
110
|
+
}),
|
|
111
|
+
variant: variantProp.propType
|
|
112
|
+
};
|
|
113
|
+
export default withLinkRouter(PressableCardBase);
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Platform from "react-native-web/dist/exports/Platform";
|
|
4
|
+
import Pressable from "react-native-web/dist/exports/Pressable";
|
|
5
|
+
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
6
|
+
import Text from "react-native-web/dist/exports/Text";
|
|
7
|
+
import View from "react-native-web/dist/exports/View";
|
|
8
|
+
import CheckboxInput from './CheckboxInput';
|
|
9
|
+
import CheckboxLabel from '../InputLabel/LabelContent';
|
|
10
|
+
import Feedback from '../Feedback';
|
|
11
|
+
import StackView from '../StackView';
|
|
12
|
+
import { applyShadowToken, applyTextStyles, useThemeTokensCallback } from '../ThemeProvider';
|
|
13
|
+
import { a11yProps, getTokensPropType, selectSystemProps, useInputValue, variantProp, viewProps } from '../utils';
|
|
14
|
+
import useUniqueId from '../utils/useUniqueId';
|
|
15
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
18
|
+
|
|
19
|
+
const selectInputStyles = ({
|
|
20
|
+
iconBackgroundColor,
|
|
21
|
+
inputBorderColor,
|
|
22
|
+
inputBorderRadius,
|
|
23
|
+
inputBorderWidth,
|
|
24
|
+
inputBackgroundColor,
|
|
25
|
+
inputHeight,
|
|
26
|
+
inputOutlineColor,
|
|
27
|
+
inputOutlineWidth,
|
|
28
|
+
inputShadow,
|
|
29
|
+
inputWidth
|
|
30
|
+
}, isChecked) => ({
|
|
31
|
+
borderColor: inputBorderColor,
|
|
32
|
+
borderWidth: inputBorderWidth,
|
|
33
|
+
borderRadius: inputBorderRadius,
|
|
34
|
+
backgroundColor: isChecked ? iconBackgroundColor : inputBackgroundColor,
|
|
35
|
+
height: inputHeight,
|
|
36
|
+
width: inputWidth,
|
|
37
|
+
...applyShadowToken(inputShadow),
|
|
38
|
+
...Platform.select({
|
|
39
|
+
web: {
|
|
40
|
+
outlineStyle: 'solid',
|
|
41
|
+
outlineColor: inputOutlineColor,
|
|
42
|
+
outlineWidth: inputOutlineWidth
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const selectLabelStyles = ({
|
|
48
|
+
labelColor,
|
|
49
|
+
labelFontName,
|
|
50
|
+
labelFontSize,
|
|
51
|
+
labelFontWeight,
|
|
52
|
+
labelMarginLeft,
|
|
53
|
+
labelLineHeight
|
|
54
|
+
}) => ({
|
|
55
|
+
marginLeft: labelMarginLeft,
|
|
56
|
+
...applyTextStyles({
|
|
57
|
+
color: labelColor,
|
|
58
|
+
fontName: labelFontName,
|
|
59
|
+
fontWeight: labelFontWeight,
|
|
60
|
+
fontSize: labelFontSize,
|
|
61
|
+
lineHeight: labelLineHeight
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const selectIconTokens = ({
|
|
66
|
+
icon,
|
|
67
|
+
iconColor,
|
|
68
|
+
iconSize
|
|
69
|
+
}) => ({
|
|
70
|
+
icon,
|
|
71
|
+
color: iconColor,
|
|
72
|
+
size: iconSize
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const selectFeedbackTokens = ({
|
|
76
|
+
feedbackMarginBottom,
|
|
77
|
+
feedbackMarginTop,
|
|
78
|
+
feedbackPosition
|
|
79
|
+
}) => ({
|
|
80
|
+
feedbackPosition,
|
|
81
|
+
feedbackMarginBottom,
|
|
82
|
+
feedbackMarginTop
|
|
83
|
+
});
|
|
84
|
+
/**
|
|
85
|
+
* Basic Checkbox component.
|
|
86
|
+
*
|
|
87
|
+
* ## Component API
|
|
88
|
+
*
|
|
89
|
+
* Use `label` prop to provide a label for the checkbox.
|
|
90
|
+
* For a disabled `Checkbox` set the `inactive` prop to `true`.
|
|
91
|
+
*
|
|
92
|
+
* ### Controlled version
|
|
93
|
+
*
|
|
94
|
+
* If the checkbox is controlled from outside, it needs to receive `checked` and `onChange` props.
|
|
95
|
+
*
|
|
96
|
+
* ### Uncontrolled version
|
|
97
|
+
*
|
|
98
|
+
* In case of uncontrolled checkbox you can use `defaultChecked` prop to provide the initial value.
|
|
99
|
+
* Whenever the checkbox gets toggled, it calls the `onChange` callback with the new value (boolean).
|
|
100
|
+
*
|
|
101
|
+
* ### Using within forms
|
|
102
|
+
*
|
|
103
|
+
* You can pass `name` and `value` props if you need a particular checkbox to be a part of a group of
|
|
104
|
+
* checkboxes on a form.
|
|
105
|
+
*
|
|
106
|
+
* ### Validation and feedback
|
|
107
|
+
*
|
|
108
|
+
* You can use the `feedback` prop to provide a comment related to the checkbox element. If the comment
|
|
109
|
+
* is related to a validation error, the checkbox and the feedback can be styled accordingly by setting
|
|
110
|
+
* the `error` prop to `true` (can also be done without feedback).
|
|
111
|
+
*
|
|
112
|
+
* ## A11y guidelines
|
|
113
|
+
*
|
|
114
|
+
* Checkbox component accepts all the common accessibility props, but also sets some defaults, including
|
|
115
|
+
* accessibility role `'checkbox'` and accessibility state that depends on the other props (`checked`, `inactive`)
|
|
116
|
+
* or the internal state in case of uncontrolled checkbox.
|
|
117
|
+
*
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
const Checkbox = /*#__PURE__*/forwardRef(({
|
|
122
|
+
checked,
|
|
123
|
+
defaultChecked,
|
|
124
|
+
error = false,
|
|
125
|
+
feedback,
|
|
126
|
+
id,
|
|
127
|
+
inactive,
|
|
128
|
+
label,
|
|
129
|
+
name,
|
|
130
|
+
onChange,
|
|
131
|
+
tokens,
|
|
132
|
+
value,
|
|
133
|
+
variant,
|
|
134
|
+
...rest
|
|
135
|
+
}, ref) => {
|
|
136
|
+
const {
|
|
137
|
+
currentValue: isChecked,
|
|
138
|
+
setValue: setIsChecked,
|
|
139
|
+
isControlled
|
|
140
|
+
} = useInputValue({
|
|
141
|
+
value: checked,
|
|
142
|
+
initialValue: defaultChecked,
|
|
143
|
+
onChange
|
|
144
|
+
}, 'useCheckboxValue');
|
|
145
|
+
const getTokens = useThemeTokensCallback('Checkbox', tokens, {
|
|
146
|
+
checked: isChecked,
|
|
147
|
+
inactive,
|
|
148
|
+
error,
|
|
149
|
+
...variant
|
|
150
|
+
});
|
|
151
|
+
const defaultTokens = getTokens();
|
|
152
|
+
const {
|
|
153
|
+
feedbackMarginBottom,
|
|
154
|
+
feedbackMarginTop,
|
|
155
|
+
feedbackPosition
|
|
156
|
+
} = selectFeedbackTokens(defaultTokens);
|
|
157
|
+
const styles = StyleSheet.create({
|
|
158
|
+
feedbackContainer: {
|
|
159
|
+
marginTop: feedbackMarginTop,
|
|
160
|
+
marginBottom: feedbackMarginBottom
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
const handleChange = event => {
|
|
165
|
+
if (!inactive) {
|
|
166
|
+
setIsChecked(!isChecked, event);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const handleKeyDown = event => {
|
|
171
|
+
// The expected keyboard shortcut for activating a checkbox is the Space key
|
|
172
|
+
if ((event === null || event === void 0 ? void 0 : event.key) === ' ') handleChange(event);
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const uniqueId = useUniqueId('checkbox');
|
|
176
|
+
const inputId = id ?? uniqueId;
|
|
177
|
+
return /*#__PURE__*/_jsx(View, {
|
|
178
|
+
style: staticStyles.wrapper,
|
|
179
|
+
ref: ref,
|
|
180
|
+
children: /*#__PURE__*/_jsxs(StackView, {
|
|
181
|
+
direction: feedbackPosition === 'top' ? 'column-reverse' : 'column',
|
|
182
|
+
space: 0,
|
|
183
|
+
children: [/*#__PURE__*/_jsx(Pressable, {
|
|
184
|
+
disabled: inactive,
|
|
185
|
+
onKeyDown: handleKeyDown,
|
|
186
|
+
onPress: handleChange,
|
|
187
|
+
accessibilityRole: "checkbox",
|
|
188
|
+
accessibilityState: {
|
|
189
|
+
checked: isChecked,
|
|
190
|
+
disabled: inactive
|
|
191
|
+
},
|
|
192
|
+
...selectProps(rest),
|
|
193
|
+
children: ({
|
|
194
|
+
focused: focus,
|
|
195
|
+
hovered: hover,
|
|
196
|
+
pressed
|
|
197
|
+
}) => {
|
|
198
|
+
const {
|
|
199
|
+
icon: IconComponent,
|
|
200
|
+
...stateTokens
|
|
201
|
+
} = getTokens({
|
|
202
|
+
focus,
|
|
203
|
+
hover,
|
|
204
|
+
pressed
|
|
205
|
+
});
|
|
206
|
+
const iconTokens = selectIconTokens(stateTokens);
|
|
207
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
208
|
+
style: staticStyles.container,
|
|
209
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
210
|
+
style: StyleSheet.flatten([staticStyles.defaultInputStyles, selectInputStyles(stateTokens, isChecked)]),
|
|
211
|
+
testID: "Checkbox-Input",
|
|
212
|
+
children: [/*#__PURE__*/_jsx(CheckboxInput, {
|
|
213
|
+
checked: isChecked,
|
|
214
|
+
defaultChecked: defaultChecked,
|
|
215
|
+
disabled: inactive,
|
|
216
|
+
id: inputId,
|
|
217
|
+
isControlled: isControlled,
|
|
218
|
+
name: name,
|
|
219
|
+
value: value
|
|
220
|
+
}), isChecked && IconComponent && /*#__PURE__*/_jsx(IconComponent, { ...iconTokens,
|
|
221
|
+
testID: "Checkbox-Icon"
|
|
222
|
+
})]
|
|
223
|
+
}), Boolean(label) && /*#__PURE__*/_jsx(Text, {
|
|
224
|
+
style: selectLabelStyles(stateTokens),
|
|
225
|
+
children: /*#__PURE__*/_jsx(CheckboxLabel, {
|
|
226
|
+
forId: inputId,
|
|
227
|
+
children: label
|
|
228
|
+
})
|
|
229
|
+
})]
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}), Boolean(feedback) && /*#__PURE__*/_jsx(View, {
|
|
233
|
+
style: styles.feedbackContainer,
|
|
234
|
+
children: /*#__PURE__*/_jsx(Feedback, {
|
|
235
|
+
title: feedback,
|
|
236
|
+
variant: {
|
|
237
|
+
icon: error === true
|
|
238
|
+
},
|
|
239
|
+
validation: error === true ? 'error' : undefined
|
|
240
|
+
})
|
|
241
|
+
})]
|
|
242
|
+
})
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
Checkbox.displayName = 'Checkbox';
|
|
246
|
+
Checkbox.propTypes = { ...selectedSystemPropTypes,
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Use `checked` for controlled Checkbox. For uncontrolled Checkbox, use the `defaultChecked` prop.
|
|
250
|
+
*/
|
|
251
|
+
checked: PropTypes.bool,
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Use `defaultChecked` to provide the initial value for an uncontrolled Checkbox.
|
|
255
|
+
*/
|
|
256
|
+
defaultChecked: PropTypes.bool,
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* A detailed description of related validation error or additional instructions (depending on the `error` prop).
|
|
260
|
+
*/
|
|
261
|
+
feedback: PropTypes.string,
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Checkbox ID.
|
|
265
|
+
*/
|
|
266
|
+
id: PropTypes.string,
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Whether the corresponding input is disabled or active.
|
|
270
|
+
*/
|
|
271
|
+
inactive: PropTypes.bool,
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* The label.
|
|
275
|
+
*/
|
|
276
|
+
label: PropTypes.string,
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Associate this checkbox with a group (set as the name attribute).
|
|
280
|
+
*/
|
|
281
|
+
name: PropTypes.string,
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Whether the underlying input triggered a validation error or not.
|
|
285
|
+
*/
|
|
286
|
+
error: PropTypes.bool,
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* The value. Must be unique within the group.
|
|
290
|
+
*/
|
|
291
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Callback called when a controlled checkbox gets interacted with.
|
|
295
|
+
*/
|
|
296
|
+
onChange: PropTypes.func,
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Checkbox tokens.
|
|
300
|
+
*/
|
|
301
|
+
tokens: getTokensPropType('Checkbox'),
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Checkbox variant.
|
|
305
|
+
*/
|
|
306
|
+
variant: variantProp.propType
|
|
307
|
+
};
|
|
308
|
+
export default Checkbox;
|
|
309
|
+
const staticStyles = StyleSheet.create({
|
|
310
|
+
wrapper: {
|
|
311
|
+
backgroundColor: 'transparent'
|
|
312
|
+
},
|
|
313
|
+
container: {
|
|
314
|
+
flexDirection: 'row',
|
|
315
|
+
alignItems: 'center'
|
|
316
|
+
},
|
|
317
|
+
defaultInputStyles: {
|
|
318
|
+
alignItems: 'center',
|
|
319
|
+
justifyContent: 'center'
|
|
320
|
+
}
|
|
321
|
+
});
|