@telus-uds/components-base 1.0.1 → 1.3.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/.storybook/main.js +4 -0
- package/.storybook/preview.js +37 -0
- package/.turbo/turbo-build.log +5 -0
- package/CHANGELOG.md +32 -0
- package/README.md +1 -1
- package/__fixtures__/Accessible.js +4 -2
- package/__fixtures__/Accessible.native.js +5 -2
- package/__fixtures__/testTheme.js +9 -0
- package/__tests__/FlexGrid/Col.test.jsx +6 -10
- package/__tests__/HorizontalScroll/HorizontalScroll.test.jsx +1 -0
- package/__tests__/ToggleSwitch/ToggleSwitch.test.jsx +10 -0
- package/__tests__/ToggleSwitch/ToggleSwitchGroup.test.jsx +192 -0
- package/__tests__/utils/props.test.js +36 -0
- package/__tests__/utils/semantics.test.jsx +1 -10
- package/babel.config.js +9 -16
- package/component-docs.json +10142 -0
- package/generate-component-docs.js +59 -0
- package/lib/A11yText/index.js +2 -2
- package/lib/ActivityIndicator/index.js +3 -3
- package/lib/Box/Box.js +4 -4
- package/lib/Button/Button.js +2 -2
- package/lib/Button/ButtonBase.js +20 -6
- package/lib/Button/ButtonGroup.js +10 -12
- package/lib/Button/ButtonLink.js +4 -4
- package/lib/Button/propTypes.js +4 -2
- package/lib/Card/Card.js +2 -2
- package/lib/Card/CardBase.js +6 -9
- package/lib/Card/PressableCardBase.js +12 -6
- package/lib/Checkbox/Checkbox.js +3 -5
- package/lib/Divider/Divider.js +2 -2
- package/lib/FlexGrid/FlexGrid.js +4 -4
- package/lib/FlexGrid/helpers/index.js +1 -4
- package/lib/IconButton/IconButton.js +11 -6
- package/lib/Link/LinkBase.js +19 -12
- package/lib/List/List.js +4 -5
- package/lib/List/ListItem.js +14 -27
- package/lib/List/index.js +15 -0
- package/lib/Pagination/PageButton.js +4 -8
- package/lib/Pagination/Pagination.js +16 -4
- package/lib/Pagination/SideButton.js +3 -1
- package/lib/Progress/Progress.js +2 -2
- package/lib/Progress/ProgressBar.js +2 -2
- package/lib/Radio/Radio.js +3 -5
- package/lib/Spacer/Spacer.js +2 -2
- package/lib/StackView/StackWrap.js +9 -5
- package/lib/StackView/getStackedContent.js +1 -1
- package/lib/StepTracker/StepTracker.js +2 -2
- package/lib/Tabs/Tabs.js +12 -4
- package/lib/Tabs/TabsItem.js +12 -6
- package/lib/Tags/Tags.js +9 -9
- package/lib/ThemeProvider/useThemeTokens.js +3 -3
- package/lib/ThemeProvider/utils/theme-tokens.js +3 -3
- package/lib/ToggleSwitch/ToggleSwitch.js +105 -43
- package/lib/ToggleSwitch/ToggleSwitchGroup.js +230 -0
- package/lib/ToggleSwitch/index.js +14 -4
- package/lib/index.js +28 -9
- package/lib/utils/a11y/semantics.js +4 -3
- package/lib/utils/index.js +14 -5
- package/lib/utils/pressability.js +2 -2
- package/lib/utils/props/a11yProps.js +153 -0
- package/lib/utils/props/clickProps.js +36 -0
- package/lib/utils/props/componentPropType.js +70 -0
- package/lib/utils/props/copyPropTypes.js +14 -0
- package/lib/utils/props/getPropSelector.js +13 -0
- package/lib/utils/props/hrefAttrsProp.js +41 -0
- package/lib/utils/props/index.js +149 -0
- package/lib/utils/props/linkProps.js +64 -0
- package/lib/utils/props/paddingProp.js +20 -0
- package/lib/utils/props/pressProps.js +57 -0
- package/lib/utils/props/rectProp.js +20 -0
- package/lib/utils/props/responsiveProps.js +40 -0
- package/lib/utils/props/selectSystemProps.js +31 -0
- package/lib/utils/props/spacingProps.js +71 -0
- package/lib/utils/props/tokens.js +145 -0
- package/lib/utils/props/variantProp.js +28 -0
- package/lib/utils/props/viewProps.js +34 -0
- package/lib/utils/useResponsiveProp.js +1 -1
- package/lib/utils/useSpacingScale.js +4 -4
- package/lib/utils/withLinkRouter.js +98 -0
- package/package.json +9 -5
- package/release-context.json +4 -4
- package/src/A11yText/index.jsx +1 -1
- package/src/ActivityIndicator/index.jsx +1 -1
- package/src/Box/Box.jsx +5 -4
- package/src/Button/Button.jsx +1 -1
- package/src/Button/ButtonBase.jsx +11 -4
- package/src/Button/ButtonGroup.jsx +17 -8
- package/src/Button/ButtonLink.jsx +1 -1
- package/src/Button/propTypes.js +2 -1
- package/src/Card/Card.jsx +1 -1
- package/src/Card/CardBase.jsx +6 -5
- package/src/Card/PressableCardBase.jsx +7 -5
- package/src/Checkbox/Checkbox.jsx +1 -3
- package/src/Divider/Divider.jsx +2 -2
- package/src/FlexGrid/FlexGrid.jsx +11 -5
- package/src/FlexGrid/helpers/index.js +1 -3
- package/src/IconButton/IconButton.jsx +7 -5
- package/src/Link/LinkBase.jsx +7 -5
- package/src/List/List.jsx +2 -4
- package/src/List/ListItem.jsx +11 -26
- package/src/List/index.js +5 -0
- package/src/Pagination/PageButton.jsx +5 -8
- package/src/Pagination/Pagination.jsx +29 -2
- package/src/Pagination/SideButton.jsx +2 -2
- package/src/Progress/Progress.jsx +1 -1
- package/src/Progress/ProgressBar.jsx +1 -1
- package/src/Radio/Radio.jsx +1 -3
- package/src/Spacer/Spacer.jsx +2 -2
- package/src/StackView/StackWrap.jsx +7 -6
- package/src/StackView/getStackedContent.jsx +1 -1
- package/src/StepTracker/StepTracker.jsx +1 -1
- package/src/Tabs/Tabs.jsx +49 -22
- package/src/Tabs/TabsItem.jsx +11 -7
- package/src/Tags/Tags.jsx +1 -7
- package/src/ThemeProvider/useThemeTokens.js +3 -3
- package/src/ThemeProvider/utils/theme-tokens.js +3 -3
- package/src/ToggleSwitch/ToggleSwitch.jsx +93 -41
- package/src/ToggleSwitch/ToggleSwitchGroup.jsx +203 -0
- package/src/ToggleSwitch/index.js +2 -1
- package/src/index.js +2 -2
- package/src/utils/a11y/semantics.js +3 -2
- package/src/utils/index.js +2 -1
- package/src/utils/pressability.js +1 -1
- package/src/utils/props/a11yProps.js +151 -0
- package/src/utils/props/clickProps.js +31 -0
- package/src/utils/props/componentPropType.js +67 -0
- package/src/utils/props/copyPropTypes.js +3 -0
- package/src/utils/props/getPropSelector.js +14 -0
- package/src/utils/props/hrefAttrsProp.js +25 -0
- package/src/utils/props/index.js +15 -0
- package/src/utils/props/linkProps.js +43 -0
- package/src/utils/props/paddingProp.js +10 -0
- package/src/utils/props/pressProps.js +45 -0
- package/src/utils/props/rectProp.js +10 -0
- package/src/utils/props/responsiveProps.js +30 -0
- package/src/utils/props/selectSystemProps.js +25 -0
- package/src/utils/props/spacingProps.js +58 -0
- package/src/utils/props/tokens.js +150 -0
- package/src/utils/props/variantProp.js +20 -0
- package/src/utils/props/viewProps.js +23 -0
- package/src/utils/useResponsiveProp.js +1 -1
- package/src/utils/useSpacingScale.js +4 -4
- package/src/utils/withLinkRouter.jsx +68 -0
- package/stories/A11yText/A11yText.stories.jsx +1 -1
- package/stories/ActivityIndicator/ActivityIndicator.stories.jsx +1 -1
- package/stories/Box/Box.stories.jsx +1 -1
- package/stories/Button/Button.stories.jsx +1 -1
- package/stories/Button/ButtonGroup.stories.jsx +1 -1
- package/stories/Button/ButtonLink.stories.jsx +1 -1
- package/stories/Card/Card.stories.jsx +1 -1
- package/stories/Checkbox/Checkbox.stories.jsx +1 -1
- package/stories/Divider/Divider.stories.jsx +1 -1
- package/stories/ExpandCollapse/ExpandCollapse.stories.jsx +1 -1
- package/stories/Feedback/Feedback.stories.jsx +1 -1
- package/stories/FlexGrid/01 FlexGrid.stories.jsx +1 -1
- package/stories/FlexGrid/02 Row.stories.jsx +1 -1
- package/stories/FlexGrid/03 Col.stories.jsx +1 -1
- package/stories/Icon/Icon.stories.jsx +1 -1
- package/stories/IconButton/IconButton.stories.jsx +1 -1
- package/stories/InputLabel/InputLabel.stories.jsx +1 -1
- package/stories/Link/ChevronLink.stories.jsx +1 -1
- package/stories/Link/Link.stories.jsx +1 -1
- package/stories/Link/TextButton.stories.jsx +1 -1
- package/stories/List/List.stories.jsx +1 -1
- package/stories/Modal/Modal.stories.jsx +1 -1
- package/stories/Notification/Notification.stories.jsx +1 -1
- package/stories/Pagination/Pagination.stories.jsx +1 -1
- package/stories/Progress/Progress.stories.jsx +1 -1
- package/stories/Radio/Radio.stories.jsx +1 -1
- package/stories/RadioCard/RadioCard.stories.jsx +1 -1
- package/stories/Search/Search.stories.jsx +1 -1
- package/stories/Select/Select.stories.jsx +1 -1
- package/stories/SideNav/SideNav.stories.jsx +1 -1
- package/stories/SideNav/SideNavItem.stories.jsx +1 -1
- package/stories/SideNav/SideNavItemsGroup.stories.jsx +1 -1
- package/stories/Skeleton/Skeleton.stories.jsx +1 -1
- package/stories/Spacer/Spacer.stories.jsx +1 -1
- package/stories/StackView/StackView.stories.jsx +1 -1
- package/stories/StackView/StackWrap.stories.jsx +1 -1
- package/stories/StepTracker/StepTracker.stories.jsx +1 -1
- package/stories/Tabs/Tabs.stories.jsx +1 -1
- package/stories/Tags/Tags.stories.jsx +1 -1
- package/stories/TextInput/TextArea.stories.jsx +2 -1
- package/stories/TextInput/TextInput.stories.jsx +1 -1
- package/stories/ToggleSwitch/ToggleSwitch.stories.jsx +6 -2
- package/stories/ToggleSwitch/ToggleSwitchGroup.stories.jsx +81 -0
- package/stories/Tooltip/Tooltip.stories.jsx +1 -1
- package/stories/TooltipButton/TooltipButton.stories.jsx +1 -1
- package/stories/Typography/Typography.stories.jsx +1 -1
- package/stories/supports.jsx +2 -3
- package/.ultra.cache.json +0 -1
- package/lib/utils/propTypes.js +0 -623
- package/src/utils/propTypes.js +0 -640
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
|
+
import '@telus-uds/palette-allium/build/rn/fonts/fonts.css'
|
|
3
|
+
import '@telus-uds/palette-koodo/build/rn/fonts/fonts.css'
|
|
4
|
+
import '@telus-uds/palette-public-mobile/build/rn/fonts/fonts.css'
|
|
5
|
+
|
|
6
|
+
import alliumTheme from '@telus-uds/theme-allium'
|
|
7
|
+
import koodoTheme from '@telus-uds/theme-koodo'
|
|
8
|
+
import pmTheme from '@telus-uds/theme-public-mobile'
|
|
9
|
+
/* eslint-enable import/no-extraneous-dependencies */
|
|
10
|
+
|
|
11
|
+
import testTheme from '../__fixtures__/testTheme'
|
|
12
|
+
|
|
13
|
+
import { BaseProvider } from '../src'
|
|
14
|
+
|
|
15
|
+
const themes = [alliumTheme, koodoTheme, pmTheme, testTheme]
|
|
16
|
+
const themeLookup = themes.reduce((memo, t) => ({ ...memo, [t.metadata.name]: t }), {})
|
|
17
|
+
|
|
18
|
+
const baseDecorator = (Story, { globals }) => (
|
|
19
|
+
<BaseProvider key={globals.theme} defaultTheme={themeLookup[globals.theme]}>
|
|
20
|
+
<Story />
|
|
21
|
+
</BaseProvider>
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
export const decorators = [baseDecorator]
|
|
25
|
+
|
|
26
|
+
// globals persist in browser session store - not fun if you have multiple branded storybooks on the same domain/port
|
|
27
|
+
export const globalTypes = {
|
|
28
|
+
theme: {
|
|
29
|
+
name: 'Theme',
|
|
30
|
+
description: 'UDS theme for components',
|
|
31
|
+
defaultValue: alliumTheme.metadata.name,
|
|
32
|
+
toolbar: {
|
|
33
|
+
icon: 'beaker',
|
|
34
|
+
items: Object.keys(themeLookup)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
@telus-uds/components-base:build: cache hit, replaying output 00426a473859b487
|
|
2
|
+
@telus-uds/components-base:build: [2K[1G[2m$ yarn build:code && yarn build:docs[22m
|
|
3
|
+
@telus-uds/components-base:build: [2K[1G[2m$ babel src -d lib[22m
|
|
4
|
+
@telus-uds/components-base:build: Successfully compiled 214 files with Babel (15991ms).
|
|
5
|
+
@telus-uds/components-base:build: [2K[1G[2m$ babel-node --plugins=react-docgen-alpha generate-component-docs.js[22m
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,38 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.3.0](https://github.com/telus/universal-design-system/compare/@telus-uds/components-base/v1.2.0...@telus-uds/components-base/v1.3.0) (2022-03-21)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- **components-base:** add common system props handler and restructure props-related utils ([#1444](https://github.com/telus/universal-design-system/issues/1444)) ([ab655ec](https://github.com/telus/universal-design-system/commit/ab655ec61796b6a6d7094c2c42ceef8b5197c634))
|
|
10
|
+
- **docs:** add tokens override documentation ([#1330](https://github.com/telus/universal-design-system/issues/1330)) ([49092e5](https://github.com/telus/universal-design-system/commit/49092e5d5f6c2d3a85de930a74a03afff8a60062))
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- **base:** inherit FlexGrid.Col responsive size if 0 ([#1419](https://github.com/telus/universal-design-system/issues/1419)) ([9defeb0](https://github.com/telus/universal-design-system/commit/9defeb0da08099afb83df9e7ee902f037cb4de02))
|
|
15
|
+
- **ds-allium:** fix some errors in RN builds ([#1448](https://github.com/telus/universal-design-system/issues/1448)) ([8bc4778](https://github.com/telus/universal-design-system/commit/8bc477890f0183584fdc1009d7929b71d23820a3))
|
|
16
|
+
|
|
17
|
+
## [1.2.0](https://github.com/telus/universal-design-system/compare/@telus-uds/components-base/v1.1.0...@telus-uds/components-base/v1.2.0) (2022-03-02)
|
|
18
|
+
|
|
19
|
+
### Features
|
|
20
|
+
|
|
21
|
+
- add withLinkRouter to support router integration ([#1324](https://github.com/telus/universal-design-system/issues/1324)) ([e56f491](https://github.com/telus/universal-design-system/commit/e56f491ac088a005f364330cfc70901532df7cea))
|
|
22
|
+
- **component-base:** refactor ToggleSwitch to use input label and add tooltip support ([#1341](https://github.com/telus/universal-design-system/issues/1341)) ([979da1a](https://github.com/telus/universal-design-system/commit/979da1afb5b319df51026f44299d363f50f1be7d))
|
|
23
|
+
- **components-base:** add ToggleSwitchGroup ([#1307](https://github.com/telus/universal-design-system/issues/1307)) ([402630a](https://github.com/telus/universal-design-system/commit/402630ad04c2d81c4f882fed564cf4ae33096cea))
|
|
24
|
+
|
|
25
|
+
## [1.1.0](https://github.com/telus/universal-design-system/compare/@telus-uds/components-base/v1.0.1...@telus-uds/components-base/v1.1.0) (2022-02-28)
|
|
26
|
+
|
|
27
|
+
### Features
|
|
28
|
+
|
|
29
|
+
- **component-base:** add some fixes to the list component ([#1226](https://github.com/telus/universal-design-system/issues/1226)) ([35a42e0](https://github.com/telus/universal-design-system/commit/35a42e05e23630696286e7c8607e7a1e8da9d6c2))
|
|
30
|
+
- **ds-allium:** add an Allium List ([#1304](https://github.com/telus/universal-design-system/issues/1304)) ([2f91c74](https://github.com/telus/universal-design-system/commit/2f91c74d6c0b30f09089e8f11beb3739e5be1887))
|
|
31
|
+
- generate component docs ([#1292](https://github.com/telus/universal-design-system/issues/1292)) ([e0c03a5](https://github.com/telus/universal-design-system/commit/e0c03a5c4b5186e97d424c5b1c4594b1dda8201f))
|
|
32
|
+
|
|
33
|
+
### Bug Fixes
|
|
34
|
+
|
|
35
|
+
- **base:** no SSR crash on transpiled global CSS ([#1311](https://github.com/telus/universal-design-system/issues/1311)) ([7bc585c](https://github.com/telus/universal-design-system/commit/7bc585cc76bf7d760b1630a6f90f336f2be2abda))
|
|
36
|
+
|
|
5
37
|
### [1.0.1](https://github.com/telus/universal-design-system/compare/@telus-uds/components-base/v1.0.0...@telus-uds/components-base/v1.0.1) (2022-02-07)
|
|
6
38
|
|
|
7
39
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// this is a copy of an autogenerated file
|
|
2
|
-
/* eslint-disable */
|
|
2
|
+
/* eslint-disable spaced-comment */
|
|
3
|
+
/* eslint-disable react/prop-types */
|
|
3
4
|
|
|
4
5
|
import * as React from 'react'
|
|
5
6
|
|
|
@@ -25,7 +26,8 @@ const Accessible = ({ title, titleId, size, color }) =>
|
|
|
25
26
|
)
|
|
26
27
|
: null,
|
|
27
28
|
/*#__PURE__*/ React.createElement('path', {
|
|
28
|
-
d:
|
|
29
|
+
d:
|
|
30
|
+
'M4.231 12.257l.662.662a5.87 5.87 0 00-.982 3.235c0 1.585.618 3.078 1.74 4.2a5.903 5.903 0 004.2 1.739 5.839 5.839 0 002.991-.831l.242-.151.647.645c-1.167.81-2.517 1.244-3.88 1.244a6.83 6.83 0 01-4.845-2.003A6.805 6.805 0 013 16.154c0-1.315.378-2.568 1.067-3.65l.165-.247zm5.81-9.99c.178 0 .358.037.527.112l.175.093c.575.334 5.897 3.426 5.907 3.433.307.192.507.492.579.822.124.433.054.913-.22 1.3l-.1.125-2.68 2.738c.106.088.21.178.313.273l.166.162.014.016 5.136-.603.07-.002a1.3 1.3 0 011.3 1.265l-.004.14-.39 6.71a1.46 1.46 0 01-1.455 1.369l-.094-.003a1.456 1.456 0 01-1.362-1.41l.003-.141.337-4.465a.09.09 0 00-.09-.103l-1.71.3a6.86 6.86 0 01-.809 5.367l-.165.254-.66-.66a5.882 5.882 0 00.96-3.206 5.903 5.903 0 00-1.738-4.2 5.904 5.904 0 00-4.201-1.74c-1.06 0-2.073.291-2.966.813l-.24.148-.648-.648a6.827 6.827 0 012.94-1.156l.312-.035 2.507-2.778-1.5-.876L8.33 7.31a1.47 1.47 0 01-2.081.002c-.542-.542-.554-1.423-.078-2.008l.102-.112 2.902-2.596c.244-.217.552-.33.865-.33zm10.24 10.386c.096-.848-.406-.964-.75-.955l-.061.003-3.975.467c.223.338.41.701.576 1.073l.12.28 1.75-.308.077-.022.156-.004c.288 0 .562.125.754.34.15.174.236.392.246.618l-.003.136-.337 4.454a.541.541 0 00.136.389.536.536 0 00.287.171l.086.013c.289 0 .509-.18.567-.422l.015-.093.357-6.14zm-10.24-9.475a.387.387 0 00-.202.056l-.057.043L6.905 5.85c-.215.23-.222.607-.012.817a.558.558 0 00.725.057l.068-.058.027-.027 2.444-2.07 3.024 1.766-2.663 2.952a6.958 6.958 0 012.683.85l.31.183 2.727-2.784a.602.602 0 00.135-.46l-.02-.1-.013-.053a.385.385 0 00-.165-.241l-5.94-3.451a.38.38 0 00-.194-.053zM17.743 1c1.16 0 2.106.945 2.106 2.106a2.11 2.11 0 01-2.106 2.107 2.11 2.11 0 01-2.106-2.107c0-1.161.945-2.106 2.106-2.106zm0 .91a1.196 1.196 0 000 2.392 1.196 1.196 0 000-2.391z',
|
|
29
31
|
fillRule: 'evenodd'
|
|
30
32
|
})
|
|
31
33
|
)
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// this is a copy of an autogenerated file
|
|
2
|
-
/* eslint-disable */
|
|
2
|
+
/* eslint-disable spaced-comment */
|
|
3
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
|
4
|
+
/* eslint-disable react/prop-types */
|
|
3
5
|
|
|
4
6
|
import * as React from 'react'
|
|
5
7
|
import Svg, { Path } from 'react-native-svg'
|
|
@@ -24,7 +26,8 @@ const Accessible = ({ title, titleId, size, color }) =>
|
|
|
24
26
|
)
|
|
25
27
|
: null,
|
|
26
28
|
/*#__PURE__*/ React.createElement(Path, {
|
|
27
|
-
d:
|
|
29
|
+
d:
|
|
30
|
+
'M4.231 12.257l.662.662a5.87 5.87 0 00-.982 3.235c0 1.585.618 3.078 1.74 4.2a5.903 5.903 0 004.2 1.739 5.839 5.839 0 002.991-.831l.242-.151.647.645c-1.167.81-2.517 1.244-3.88 1.244a6.83 6.83 0 01-4.845-2.003A6.805 6.805 0 013 16.154c0-1.315.378-2.568 1.067-3.65l.165-.247zm5.81-9.99c.178 0 .358.037.527.112l.175.093c.575.334 5.897 3.426 5.907 3.433.307.192.507.492.579.822.124.433.054.913-.22 1.3l-.1.125-2.68 2.738c.106.088.21.178.313.273l.166.162.014.016 5.136-.603.07-.002a1.3 1.3 0 011.3 1.265l-.004.14-.39 6.71a1.46 1.46 0 01-1.455 1.369l-.094-.003a1.456 1.456 0 01-1.362-1.41l.003-.141.337-4.465a.09.09 0 00-.09-.103l-1.71.3a6.86 6.86 0 01-.809 5.367l-.165.254-.66-.66a5.882 5.882 0 00.96-3.206 5.903 5.903 0 00-1.738-4.2 5.904 5.904 0 00-4.201-1.74c-1.06 0-2.073.291-2.966.813l-.24.148-.648-.648a6.827 6.827 0 012.94-1.156l.312-.035 2.507-2.778-1.5-.876L8.33 7.31a1.47 1.47 0 01-2.081.002c-.542-.542-.554-1.423-.078-2.008l.102-.112 2.902-2.596c.244-.217.552-.33.865-.33zm10.24 10.386c.096-.848-.406-.964-.75-.955l-.061.003-3.975.467c.223.338.41.701.576 1.073l.12.28 1.75-.308.077-.022.156-.004c.288 0 .562.125.754.34.15.174.236.392.246.618l-.003.136-.337 4.454a.541.541 0 00.136.389.536.536 0 00.287.171l.086.013c.289 0 .509-.18.567-.422l.015-.093.357-6.14zm-10.24-9.475a.387.387 0 00-.202.056l-.057.043L6.905 5.85c-.215.23-.222.607-.012.817a.558.558 0 00.725.057l.068-.058.027-.027 2.444-2.07 3.024 1.766-2.663 2.952a6.958 6.958 0 012.683.85l.31.183 2.727-2.784a.602.602 0 00.135-.46l-.02-.1-.013-.053a.385.385 0 00-.165-.241l-5.94-3.451a.38.38 0 00-.194-.053zM17.743 1c1.16 0 2.106.945 2.106 2.106a2.11 2.11 0 01-2.106 2.107 2.11 2.11 0 01-2.106-2.107c0-1.161.945-2.106 2.106-2.106zm0 .91a1.196 1.196 0 000 2.392 1.196 1.196 0 000-2.391z',
|
|
28
31
|
fillRule: 'evenodd'
|
|
29
32
|
})
|
|
30
33
|
)
|
|
@@ -1515,6 +1515,15 @@ export default {
|
|
|
1515
1515
|
}
|
|
1516
1516
|
]
|
|
1517
1517
|
},
|
|
1518
|
+
ToggleSwitchGroup: {
|
|
1519
|
+
tokens: {
|
|
1520
|
+
space: 2,
|
|
1521
|
+
direction: 'row',
|
|
1522
|
+
alignItems: 'flex-start',
|
|
1523
|
+
justifyContent: 'flex-start',
|
|
1524
|
+
flexGrow: 1
|
|
1525
|
+
}
|
|
1526
|
+
},
|
|
1518
1527
|
TextInput: {
|
|
1519
1528
|
appearances: {
|
|
1520
1529
|
validation: appearances.TextInput.validation,
|
|
@@ -48,7 +48,6 @@ describe('FlexGrid.Col offsets', () => {
|
|
|
48
48
|
)
|
|
49
49
|
const expectIfOffsetExpected = (propViewport) => {
|
|
50
50
|
const target = getByText(`${propViewport}Offset`).parent
|
|
51
|
-
// eslint-disable-next-line jest/valid-expect
|
|
52
51
|
return expected[propViewport] ? expect(target) : expect(target).not
|
|
53
52
|
}
|
|
54
53
|
expectIfOffsetExpected('xs').toHaveStyle(getOffsetStyle('xs'))
|
|
@@ -104,7 +103,6 @@ describe('FlexGrid.Col sizes', () => {
|
|
|
104
103
|
|
|
105
104
|
const expectIfSizeExpected = (propViewport) => {
|
|
106
105
|
const target = getByText(propViewport).parent
|
|
107
|
-
// eslint-disable-next-line jest/valid-expect
|
|
108
106
|
return expected[propViewport] ? expect(target) : expect(target).not
|
|
109
107
|
}
|
|
110
108
|
expectIfSizeExpected('xs').toHaveStyle(getNumericSizeStyle('xs'))
|
|
@@ -154,7 +152,6 @@ describe('FlexGrid.Col sizes', () => {
|
|
|
154
152
|
|
|
155
153
|
const expectIfSizeExpected = (text) => {
|
|
156
154
|
const target = getByText(text).parent
|
|
157
|
-
// eslint-disable-next-line jest/valid-expect
|
|
158
155
|
return expected[text] ? expect(target) : expect(target).not
|
|
159
156
|
}
|
|
160
157
|
expectIfSizeExpected('xs-md').toHaveStyle(getNumericSizeStyle('xs'))
|
|
@@ -166,16 +163,17 @@ describe('FlexGrid.Col sizes', () => {
|
|
|
166
163
|
})
|
|
167
164
|
|
|
168
165
|
// Testing special "hiding" case on passing xs, sm, md, lg, xl props as 0.
|
|
169
|
-
//
|
|
166
|
+
// Should inherit like other values for these props, confirmed in:
|
|
167
|
+
// https://github.com/telus/universal-design-system/pull/364#discussion_r671382300
|
|
170
168
|
it.each(
|
|
171
169
|
// true here indicates hiding styles should apply
|
|
172
170
|
// Align expected results like a table so they're easier to read
|
|
173
171
|
/* prettier-ignore */ [
|
|
174
172
|
['xs', { xs: true, sm: false, md: false, lg: false, xl: false }],
|
|
175
|
-
['sm', { xs:
|
|
176
|
-
['md', { xs:
|
|
177
|
-
['lg', { xs:
|
|
178
|
-
['xl', { xs:
|
|
173
|
+
['sm', { xs: true, sm: true, md: false, lg: false, xl: false }],
|
|
174
|
+
['md', { xs: true, sm: true, md: true, lg: false, xl: false }],
|
|
175
|
+
['lg', { xs: true, sm: true, md: true, lg: true, xl: false }],
|
|
176
|
+
['xl', { xs: true, sm: true, md: true, lg: true, xl: true }]
|
|
179
177
|
]
|
|
180
178
|
)('applies hiding styles from one prop at viewport "%s"', (viewport, expected) => {
|
|
181
179
|
const hidingStyle = { display: 'none' }
|
|
@@ -199,7 +197,6 @@ describe('FlexGrid.Col sizes', () => {
|
|
|
199
197
|
)
|
|
200
198
|
const expectIfHidingExpected = (propViewport) => {
|
|
201
199
|
const target = getByText(propViewport).parent
|
|
202
|
-
// eslint-disable-next-line jest/valid-expect
|
|
203
200
|
return expected[propViewport] ? expect(target) : expect(target).not
|
|
204
201
|
}
|
|
205
202
|
expectIfHidingExpected('xs').toHaveStyle(hidingStyle)
|
|
@@ -248,7 +245,6 @@ describe('FlexGrid.Col horizontalAlign', () => {
|
|
|
248
245
|
|
|
249
246
|
const expectIfAlignExpected = (propViewport) => {
|
|
250
247
|
const target = getByText(propViewport).parent
|
|
251
|
-
// eslint-disable-next-line jest/valid-expect
|
|
252
248
|
return expected[propViewport] ? expect(target) : expect(target).not
|
|
253
249
|
}
|
|
254
250
|
expectIfAlignExpected('xs').toHaveStyle(alignRightStyle)
|
|
@@ -69,4 +69,14 @@ describe('ToggleSwitch', () => {
|
|
|
69
69
|
expect(handleChange).toHaveBeenLastCalledWith(true, { nativeEvent: 'example' })
|
|
70
70
|
expect(queryAllByA11yState(checked)).toHaveLength(0)
|
|
71
71
|
})
|
|
72
|
+
|
|
73
|
+
it('displays the label', () => {
|
|
74
|
+
const label = 'Toggle me!'
|
|
75
|
+
const { getByText } = render(
|
|
76
|
+
<Theme>
|
|
77
|
+
<ToggleSwitch label={label} />
|
|
78
|
+
</Theme>
|
|
79
|
+
)
|
|
80
|
+
expect(getByText(label)).toBeTruthy()
|
|
81
|
+
})
|
|
72
82
|
})
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { render, fireEvent, within } from '@testing-library/react-native'
|
|
3
|
+
|
|
4
|
+
import Theme from '../../__fixtures__/Theme'
|
|
5
|
+
import ToggleSwitchGroup from '../../src/ToggleSwitch/ToggleSwitchGroup'
|
|
6
|
+
|
|
7
|
+
const items = [
|
|
8
|
+
{ label: 'One', id: 'one', accessibilityLabel: 'Option one' },
|
|
9
|
+
{ label: 'Two', id: 'two', accessibilityLabel: 'Option two' },
|
|
10
|
+
{ label: 'Three', id: 'three', accessibilityLabel: 'Option three' },
|
|
11
|
+
{ label: 'Four', id: 'four', accessibilityLabel: 'Option four' }
|
|
12
|
+
]
|
|
13
|
+
const checked = { checked: true }
|
|
14
|
+
const setup = (props) =>
|
|
15
|
+
render(
|
|
16
|
+
<Theme>
|
|
17
|
+
<ToggleSwitchGroup items={items} {...props} />
|
|
18
|
+
</Theme>
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
const hasA11yLabel = (queryResult, label) =>
|
|
22
|
+
queryResult.some((testInstance) => within(testInstance).queryAllByA11yLabel(label).length)
|
|
23
|
+
|
|
24
|
+
describe('ToggleSwitchGroup', () => {
|
|
25
|
+
describe('when uncontrolled', () => {
|
|
26
|
+
it('toggles on one and only one item by default', async () => {
|
|
27
|
+
const { getAllByA11yRole, queryAllByA11yState } = setup()
|
|
28
|
+
|
|
29
|
+
expect(queryAllByA11yState(checked)).toHaveLength(0)
|
|
30
|
+
|
|
31
|
+
const switches = getAllByA11yRole('radio')
|
|
32
|
+
const one = switches[0]
|
|
33
|
+
await fireEvent.press(one)
|
|
34
|
+
let toggledOn = queryAllByA11yState(checked)
|
|
35
|
+
expect(toggledOn).toHaveLength(1)
|
|
36
|
+
expect(hasA11yLabel(toggledOn, 'Option one')).toBeTruthy()
|
|
37
|
+
|
|
38
|
+
const two = switches[1]
|
|
39
|
+
await fireEvent.press(two)
|
|
40
|
+
toggledOn = queryAllByA11yState(checked)
|
|
41
|
+
expect(toggledOn).toHaveLength(1)
|
|
42
|
+
expect(hasA11yLabel(toggledOn, 'Option two')).toBeTruthy()
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('is accessible as a radio group by default', async () => {
|
|
46
|
+
const { queryAllByA11yRole } = setup()
|
|
47
|
+
expect(queryAllByA11yRole('checkbox')).toHaveLength(0)
|
|
48
|
+
expect(queryAllByA11yRole('radiogroup')).toHaveLength(1)
|
|
49
|
+
const switches = queryAllByA11yRole('radio')
|
|
50
|
+
expect(switches).toHaveLength(4)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('is accessible as checkboxes button when maxValues > 1', async () => {
|
|
54
|
+
const { queryAllByA11yRole, queryAllByA11yState } = setup({ maxValues: 2 })
|
|
55
|
+
|
|
56
|
+
expect(queryAllByA11yRole('radiogroup')).toHaveLength(0)
|
|
57
|
+
expect(queryAllByA11yRole('radio')).toHaveLength(0)
|
|
58
|
+
|
|
59
|
+
const switches = queryAllByA11yRole('switch')
|
|
60
|
+
expect(switches).toHaveLength(4)
|
|
61
|
+
|
|
62
|
+
expect(queryAllByA11yState(checked)).toHaveLength(0)
|
|
63
|
+
await fireEvent.press(switches[0])
|
|
64
|
+
expect(queryAllByA11yState(checked)).toHaveLength(1)
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it('selects unlimited items when maxValues is turned off', async () => {
|
|
68
|
+
const { getAllByA11yRole, queryAllByA11yState } = setup({ maxValues: null })
|
|
69
|
+
|
|
70
|
+
expect(queryAllByA11yState(checked)).toHaveLength(0)
|
|
71
|
+
|
|
72
|
+
const switches = getAllByA11yRole('switch')
|
|
73
|
+
const one = switches[0]
|
|
74
|
+
await fireEvent.press(one)
|
|
75
|
+
expect(queryAllByA11yState(checked)).toHaveLength(1)
|
|
76
|
+
expect(hasA11yLabel(queryAllByA11yState(checked), 'Option one')).toBeTruthy()
|
|
77
|
+
|
|
78
|
+
const two = switches[1]
|
|
79
|
+
await fireEvent.press(two)
|
|
80
|
+
expect(queryAllByA11yState(checked)).toHaveLength(2)
|
|
81
|
+
expect(hasA11yLabel(queryAllByA11yState(checked), 'Option two')).toBeTruthy()
|
|
82
|
+
expect(hasA11yLabel(queryAllByA11yState(checked), 'Option one')).toBeTruthy()
|
|
83
|
+
|
|
84
|
+
const three = switches[2]
|
|
85
|
+
await fireEvent.press(three)
|
|
86
|
+
expect(queryAllByA11yState(checked)).toHaveLength(3)
|
|
87
|
+
expect(hasA11yLabel(queryAllByA11yState(checked), 'Option three')).toBeTruthy()
|
|
88
|
+
expect(hasA11yLabel(queryAllByA11yState(checked), 'Option two')).toBeTruthy()
|
|
89
|
+
expect(hasA11yLabel(queryAllByA11yState(checked), 'Option one')).toBeTruthy()
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
it('auto-selects any provided initialValues', async () => {
|
|
93
|
+
const { queryAllByA11yState } = setup({
|
|
94
|
+
initialValues: ['one', 'two'],
|
|
95
|
+
maxValues: 2
|
|
96
|
+
})
|
|
97
|
+
expect(queryAllByA11yState(checked)).toHaveLength(2)
|
|
98
|
+
expect(hasA11yLabel(queryAllByA11yState(checked), 'Option one')).toBeTruthy()
|
|
99
|
+
expect(hasA11yLabel(queryAllByA11yState(checked), 'Option two')).toBeTruthy()
|
|
100
|
+
expect(hasA11yLabel(queryAllByA11yState(checked), 'Option three')).not.toBeTruthy()
|
|
101
|
+
expect(hasA11yLabel(queryAllByA11yState(checked), 'Option four')).not.toBeTruthy()
|
|
102
|
+
})
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
describe('when controlled', () => {
|
|
106
|
+
it('calls onChange handler on press in controlled mode, providing pressed id', async () => {
|
|
107
|
+
const handleChange = jest.fn((arg) => arg)
|
|
108
|
+
const { getAllByA11yRole } = setup({ values: [], onChange: handleChange })
|
|
109
|
+
|
|
110
|
+
expect(handleChange).toHaveBeenCalledTimes(0)
|
|
111
|
+
|
|
112
|
+
const switches = getAllByA11yRole('radio')
|
|
113
|
+
const one = switches[0]
|
|
114
|
+
await fireEvent(one, 'press', { nativeEvent: 'example' })
|
|
115
|
+
expect(handleChange).toHaveBeenCalledTimes(1)
|
|
116
|
+
expect(handleChange).toHaveBeenCalledWith(['one'], { nativeEvent: 'example' })
|
|
117
|
+
|
|
118
|
+
const two = switches[1]
|
|
119
|
+
await fireEvent(two, 'press', { nativeEvent: 'example2' })
|
|
120
|
+
expect(handleChange).toHaveBeenCalledTimes(2)
|
|
121
|
+
expect(handleChange).toHaveBeenLastCalledWith(['two'], { nativeEvent: 'example2' })
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
it("doesn't change its own selection if `values` is passed", async () => {
|
|
125
|
+
const { getByA11yLabel, queryAllByA11yState } = setup({ values: ['one'], onChange: () => {} })
|
|
126
|
+
|
|
127
|
+
expect(queryAllByA11yState(checked)).toHaveLength(1)
|
|
128
|
+
expect(hasA11yLabel(queryAllByA11yState(checked), 'Option one')).toBeTruthy()
|
|
129
|
+
|
|
130
|
+
const one = getByA11yLabel('Option one')
|
|
131
|
+
await fireEvent.press(one)
|
|
132
|
+
expect(queryAllByA11yState(checked)).toHaveLength(1)
|
|
133
|
+
expect(hasA11yLabel(queryAllByA11yState(checked), 'Option one')).toBeTruthy()
|
|
134
|
+
|
|
135
|
+
const two = getByA11yLabel('Option two')
|
|
136
|
+
await fireEvent.press(two)
|
|
137
|
+
expect(queryAllByA11yState(checked)).toHaveLength(1)
|
|
138
|
+
expect(hasA11yLabel(queryAllByA11yState(checked), 'Option two')).not.toBeTruthy()
|
|
139
|
+
expect(hasA11yLabel(queryAllByA11yState(checked), 'Option one')).toBeTruthy()
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
it('does not render an invalid `values` invalidly', async () => {
|
|
143
|
+
const { queryAllByA11yState } = setup({
|
|
144
|
+
values: ['one', 'two', 'three'],
|
|
145
|
+
maxValues: 2,
|
|
146
|
+
onChange: () => {}
|
|
147
|
+
})
|
|
148
|
+
expect(queryAllByA11yState(checked)).toHaveLength(2)
|
|
149
|
+
expect(hasA11yLabel(queryAllByA11yState(checked), 'Option one')).not.toBeTruthy()
|
|
150
|
+
expect(hasA11yLabel(queryAllByA11yState(checked), 'Option two')).toBeTruthy()
|
|
151
|
+
expect(hasA11yLabel(queryAllByA11yState(checked), 'Option three')).toBeTruthy()
|
|
152
|
+
})
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
describe('when read-only', () => {
|
|
156
|
+
it("doesn't call onChange handler when read-only", async () => {
|
|
157
|
+
const handleChange = jest.fn((arg) => arg)
|
|
158
|
+
const { getByA11yLabel } = setup({ values: [], onChange: handleChange, readOnly: true })
|
|
159
|
+
|
|
160
|
+
expect(handleChange).toHaveBeenCalledTimes(0)
|
|
161
|
+
|
|
162
|
+
const one = getByA11yLabel('Option one')
|
|
163
|
+
await fireEvent.press(one)
|
|
164
|
+
expect(handleChange).toHaveBeenCalledTimes(0)
|
|
165
|
+
|
|
166
|
+
const two = getByA11yLabel('Option two')
|
|
167
|
+
await fireEvent.press(two)
|
|
168
|
+
expect(handleChange).toHaveBeenCalledTimes(0)
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
it("doesn't change its selection on press", async () => {
|
|
172
|
+
const { getByA11yLabel, queryAllByA11yState } = setup({
|
|
173
|
+
values: ['one'],
|
|
174
|
+
readOnly: true
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
expect(queryAllByA11yState(checked)).toHaveLength(1)
|
|
178
|
+
expect(hasA11yLabel(queryAllByA11yState(checked), 'Option one')).toBeTruthy()
|
|
179
|
+
|
|
180
|
+
const one = getByA11yLabel('Option one')
|
|
181
|
+
await fireEvent.press(one)
|
|
182
|
+
expect(queryAllByA11yState(checked)).toHaveLength(1)
|
|
183
|
+
expect(hasA11yLabel(queryAllByA11yState(checked), 'Option one')).toBeTruthy()
|
|
184
|
+
|
|
185
|
+
const two = getByA11yLabel('Option two')
|
|
186
|
+
await fireEvent.press(two)
|
|
187
|
+
expect(queryAllByA11yState(checked)).toHaveLength(1)
|
|
188
|
+
expect(hasA11yLabel(queryAllByA11yState(checked), 'Option two')).not.toBeTruthy()
|
|
189
|
+
expect(hasA11yLabel(queryAllByA11yState(checked), 'Option one')).toBeTruthy()
|
|
190
|
+
})
|
|
191
|
+
})
|
|
192
|
+
})
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { selectSystemProps } from '../../src/utils'
|
|
2
|
+
|
|
3
|
+
describe('selectSystemProps', () => {
|
|
4
|
+
it('reduces the selectors and the types correctly', () => {
|
|
5
|
+
const somePropNames = ['a', 'b']
|
|
6
|
+
const someTypes = { a: 1, b: 2 }
|
|
7
|
+
const someOtherPropNames = ['c', 'd']
|
|
8
|
+
const someOtherTypes = { c: 3, d: 4 }
|
|
9
|
+
const reducer = (props) => (acc, allowedPropName) =>
|
|
10
|
+
allowedPropName in props ? { ...acc, [allowedPropName]: props[allowedPropName] } : acc
|
|
11
|
+
const exampleProps = { a: 'a', c: 'c', e: 'e' }
|
|
12
|
+
const [selectProps, selectedPropTypes] = selectSystemProps([
|
|
13
|
+
{ select: (props) => somePropNames.reduce(reducer(props), {}), types: someTypes },
|
|
14
|
+
{ select: (props) => someOtherPropNames.reduce(reducer(props), {}), types: someOtherTypes }
|
|
15
|
+
])
|
|
16
|
+
expect(selectProps(exampleProps)).toEqual({ a: 'a', c: 'c' })
|
|
17
|
+
expect(selectedPropTypes).toEqual({ a: 1, b: 2, c: 3, d: 4 })
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('returns selector throwing if one of the prop helpers does not have any valid prop selectors', () => {
|
|
21
|
+
const [selectProps] = selectSystemProps([{ types: {} }])
|
|
22
|
+
expect(() => {
|
|
23
|
+
selectProps({ someProp: 'some value' })
|
|
24
|
+
}).toThrowError(
|
|
25
|
+
"An invalid system prop helper has been passed to 'selectSystemProps': prop selector ('.select') is missing in"
|
|
26
|
+
)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('throws if one of the prop helpers does not have any valid prop types selectors', () => {
|
|
30
|
+
expect(() => {
|
|
31
|
+
selectSystemProps([{ select: () => {} }])
|
|
32
|
+
}).toThrowError(
|
|
33
|
+
"An invalid system prop helper has been passed to 'selectSystemProps': types selector ('.types') is missing in"
|
|
34
|
+
)
|
|
35
|
+
})
|
|
36
|
+
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Platform } from 'react-native'
|
|
2
2
|
|
|
3
|
-
import { getA11yPropsFromHtmlTag,
|
|
3
|
+
import { getA11yPropsFromHtmlTag, supportedTags } from '../../src'
|
|
4
4
|
|
|
5
5
|
// Note that currently all tests run as ios so only native logic can be tested here
|
|
6
6
|
// until cross-platform tests are set up. See issue:
|
|
@@ -8,16 +8,7 @@ import { getA11yPropsFromHtmlTag, tagsToRoles, supportedTags } from '../../src'
|
|
|
8
8
|
|
|
9
9
|
// As a temporary measure, there are tests on web-context HTML output for Box component
|
|
10
10
|
// in @telus-uds/ds-allium which test the actual output when the tags are rendered.
|
|
11
|
-
|
|
12
|
-
// These tests will therefore just test the values returned in a native context.
|
|
13
11
|
describe('getA11yPropsFromHtmlTag', () => {
|
|
14
|
-
it.each(Object.entries(tagsToRoles))(
|
|
15
|
-
'responds to tag "%s" with accessibilityRole "%s"',
|
|
16
|
-
(tag, role) => {
|
|
17
|
-
expect(getA11yPropsFromHtmlTag(tag)).toEqual({ accessibilityRole: role })
|
|
18
|
-
}
|
|
19
|
-
)
|
|
20
|
-
|
|
21
12
|
it.each([
|
|
22
13
|
[1, 'h1'],
|
|
23
14
|
[2, 'h2'],
|
package/babel.config.js
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
env
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* default. However the default BABEL_ENV value is development (jest sets it
|
|
7
|
-
* to test)
|
|
8
|
-
*/
|
|
9
|
-
development: {
|
|
10
|
-
presets: ['@babel/preset-env', ['@babel/preset-react', { runtime: 'automatic' }]],
|
|
11
|
-
plugins: [['react-native-web', { commonjs: true }]]
|
|
12
|
-
},
|
|
13
|
-
/*
|
|
14
|
-
* jest is testing for just ios at the moment, use a preset which best matches that env
|
|
15
|
-
*/
|
|
16
|
-
test: {
|
|
1
|
+
module.exports = (api) => {
|
|
2
|
+
const env = api.cache(() => process.env.NODE_ENV)
|
|
3
|
+
if (env === 'test') {
|
|
4
|
+
// configuration for jest
|
|
5
|
+
return {
|
|
17
6
|
presets: ['module:metro-react-native-babel-preset']
|
|
18
7
|
}
|
|
19
8
|
}
|
|
9
|
+
return {
|
|
10
|
+
presets: ['@babel/preset-env', ['@babel/preset-react', { runtime: 'automatic' }]],
|
|
11
|
+
plugins: [['react-native-web', { commonjs: true }]]
|
|
12
|
+
}
|
|
20
13
|
}
|