@automattic/vip-design-system 1.2.2 → 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/.eslintignore +2 -1
- package/.prettierignore +1 -0
- package/.storybook/decorators/withBoundingBox.tsx +30 -4
- package/.storybook/decorators/withColorMode.tsx +5 -5
- package/CONTRIBUTING.md +1 -1
- package/build/system/Accordion/Accordion.js +6 -6
- package/build/system/Accordion/Accordion.stories.js +1 -1
- package/build/system/Accordion/Accordion.test.js +7 -5
- package/build/system/Avatar/Avatar.js +3 -2
- package/build/system/Badge/Badge.js +1 -0
- package/build/system/Button/Button.d.ts +11 -0
- package/build/system/Button/Button.js +15 -2
- package/build/system/Button/Button.stories.d.ts +2 -1
- package/build/system/Button/Button.stories.js +9 -2
- package/build/system/Button/Button.test.js +72 -45
- package/build/system/Button/ButtonSubmit.d.ts +17 -1
- package/build/system/Button/ButtonSubmit.js +58 -65
- package/build/system/Button/ButtonSubmit.stories.d.ts +17 -37
- package/build/system/Button/ButtonSubmit.stories.js +52 -0
- package/build/system/Button/ButtonSubmit.test.js +55 -35
- package/build/system/Button/index.d.ts +7 -3
- package/build/system/Button/index.js +8 -7
- package/build/system/Dropdown/DropdownContent.js +1 -1
- package/build/system/Dropdown/DropdownItem.js +1 -1
- package/build/system/Dropdown/DropdownLabel.js +1 -1
- package/build/system/Form/Checkbox.d.ts +9 -9
- package/build/system/Form/Checkbox.js +56 -61
- package/build/system/Form/Checkbox.stories.d.ts +6 -6
- package/build/system/Form/Checkbox.stories.js +71 -0
- package/build/system/Form/Input.d.ts +14 -1
- package/build/system/Form/Input.js +59 -72
- package/build/system/Form/Input.stories.d.ts +6 -4
- package/build/system/Form/Input.stories.js +53 -0
- package/build/system/Form/Input.styles.d.ts +23 -14
- package/build/system/Form/Input.styles.js +40 -28
- package/build/system/Form/InputWithCopyButton.stories.jsx +7 -0
- package/build/system/Form/Label.d.ts +19 -8
- package/build/system/Form/Label.js +39 -43
- package/build/system/Form/Label.stories.d.ts +7 -5
- package/build/system/Form/Label.stories.js +32 -0
- package/build/system/Form/Radio.js +4 -4
- package/build/system/Form/Radio.stories.jsx +1 -1
- package/build/system/Form/RadioBoxGroup.js +1 -1
- package/build/system/Form/RequiredLabel.d.ts +2 -1
- package/build/system/Form/RequiredLabel.js +16 -7
- package/build/system/Form/Toggle.js +2 -2
- package/build/system/Form/Validation.d.ts +8 -13
- package/build/system/Form/Validation.js +39 -35
- package/build/system/Heading/Heading.stories.js +3 -0
- package/build/system/Link/Link.js +1 -1
- package/build/system/NewDialog/DialogClose.js +2 -2
- package/build/system/NewDialog/DialogContent.js +3 -3
- package/build/system/NewDialog/DialogTitle.js +3 -1
- package/build/system/NewDialog/NewDialog.stories.d.ts +0 -1
- package/build/system/NewDialog/NewDialog.stories.jsx +0 -27
- package/build/system/NewForm/Fieldset.d.ts +12 -1
- package/build/system/NewForm/Fieldset.js +38 -40
- package/build/system/NewForm/Form.d.ts +8 -1
- package/build/system/NewForm/Form.js +24 -23
- package/build/system/NewForm/FormAutocomplete.css +0 -11
- package/build/system/NewForm/FormAutocomplete.js +8 -8
- package/build/system/NewForm/FormAutocomplete.stories.jsx +1 -3
- package/build/system/NewForm/FormAutocompleteMultiselect.js +10 -10
- package/build/system/NewForm/FormSelect.js +1 -1
- package/build/system/NewForm/FormSelectArrow.js +1 -1
- package/build/system/NewForm/FormSelectInline.js +1 -1
- package/build/system/NewForm/FormSelectLoading.js +1 -1
- package/build/system/NewForm/FormSelectSearch.js +2 -2
- package/build/system/NewForm/Legend.d.ts +12 -1
- package/build/system/NewForm/Legend.js +32 -34
- package/build/system/NewForm/index.d.ts +1 -1
- package/build/system/OptionRow/OptionRow.js +1 -1
- package/build/system/Progress/Progress.d.ts +9 -2
- package/build/system/Progress/Progress.js +75 -70
- package/build/system/Progress/Progress.stories.d.ts +9 -7
- package/build/system/Progress/Progress.stories.js +34 -0
- package/build/system/Progress/Progress.test.d.ts +1 -0
- package/build/system/Progress/Progress.test.js +65 -0
- package/build/system/Progress/index.d.ts +4 -2
- package/build/system/Progress/index.js +5 -5
- package/build/system/ScreenReaderText/ScreenReaderText.js +1 -2
- package/build/system/Tabs/TabsTrigger.js +1 -2
- package/build/system/Text/Text.js +1 -1
- package/build/system/Text/Text.stories.js +36 -0
- package/build/system/Tooltip/Tooltip.css +6 -2
- package/build/system/Tooltip/Tooltip.stories.js +2 -2
- package/build/system/Wizard/Wizard.d.ts +14 -1
- package/build/system/Wizard/Wizard.js +62 -93
- package/build/system/Wizard/Wizard.stories.d.ts +11 -8
- package/build/system/Wizard/Wizard.stories.js +167 -0
- package/build/system/Wizard/WizardStep.d.ts +24 -1
- package/build/system/Wizard/WizardStep.js +180 -190
- package/build/system/Wizard/index.d.ts +4 -2
- package/build/system/Wizard/index.js +6 -7
- package/build/system/index.d.ts +2 -2
- package/build/system/index.js +2 -1
- package/build/system/theme/generated/valet-theme-dark.json +1219 -476
- package/build/system/theme/generated/valet-theme-light.json +1217 -474
- package/build/system/theme/{getColor.d.ts → getPropValue.d.ts} +2 -1
- package/{src/system/theme/getColor.js → build/system/theme/getPropValue.js} +36 -4
- package/build/system/theme/index.d.ts +20 -65
- package/build/system/theme/index.js +27 -57
- package/package.json +4 -4
- package/src/system/Accordion/Accordion.stories.tsx +1 -1
- package/src/system/Accordion/Accordion.test.tsx +3 -0
- package/src/system/Accordion/Accordion.tsx +6 -6
- package/src/system/Avatar/Avatar.tsx +3 -3
- package/src/system/Badge/Badge.tsx +1 -1
- package/src/system/Button/Button.stories.tsx +6 -3
- package/src/system/Button/{Button.test.js → Button.test.tsx} +2 -2
- package/src/system/Button/Button.tsx +15 -1
- package/src/system/Button/ButtonSubmit.stories.tsx +31 -0
- package/src/system/Button/{ButtonSubmit.test.js → ButtonSubmit.test.tsx} +4 -4
- package/src/system/Button/{ButtonSubmit.js → ButtonSubmit.tsx} +21 -27
- package/src/system/Button/index.ts +8 -0
- package/src/system/Dropdown/DropdownContent.js +1 -1
- package/src/system/Dropdown/DropdownItem.js +1 -1
- package/src/system/Dropdown/DropdownLabel.js +1 -1
- package/src/system/Form/{Checkbox.stories.jsx → Checkbox.stories.tsx} +3 -2
- package/src/system/Form/{Checkbox.js → Checkbox.tsx} +6 -10
- package/src/system/Form/{Input.stories.jsx → Input.stories.tsx} +1 -0
- package/src/system/Form/{Input.styles.js → Input.styles.ts} +14 -5
- package/src/system/Form/{Input.js → Input.tsx} +10 -19
- package/src/system/Form/InputWithCopyButton.stories.jsx +7 -0
- package/src/system/Form/{Label.js → Label.tsx} +8 -13
- package/src/system/Form/Radio.js +4 -4
- package/src/system/Form/Radio.stories.jsx +1 -1
- package/src/system/Form/RadioBoxGroup.js +1 -1
- package/src/system/Form/{RequiredLabel.js → RequiredLabel.tsx} +1 -3
- package/src/system/Form/Toggle.js +2 -2
- package/src/system/Form/{Validation.js → Validation.tsx} +11 -12
- package/src/system/Heading/Heading.stories.tsx +1 -0
- package/src/system/Link/Link.tsx +1 -1
- package/src/system/NewDialog/DialogClose.js +2 -2
- package/src/system/NewDialog/DialogContent.js +3 -3
- package/src/system/NewDialog/DialogTitle.js +3 -1
- package/src/system/NewDialog/NewDialog.stories.jsx +0 -27
- package/src/system/NewForm/Fieldset.tsx +46 -0
- package/src/system/NewForm/Form.tsx +23 -0
- package/src/system/NewForm/FormAutocomplete.css +0 -11
- package/src/system/NewForm/FormAutocomplete.js +8 -8
- package/src/system/NewForm/FormAutocomplete.stories.jsx +1 -3
- package/src/system/NewForm/FormAutocompleteMultiselect.js +10 -10
- package/src/system/NewForm/FormSelect.js +1 -1
- package/src/system/NewForm/FormSelectArrow.js +1 -1
- package/src/system/NewForm/FormSelectInline.js +1 -1
- package/src/system/NewForm/FormSelectLoading.js +1 -1
- package/src/system/NewForm/FormSelectSearch.js +2 -2
- package/src/system/NewForm/Legend.tsx +40 -0
- package/src/system/OptionRow/OptionRow.js +1 -1
- package/src/system/Progress/Progress.test.tsx +33 -0
- package/src/system/Progress/{Progress.js → Progress.tsx} +16 -19
- package/src/system/Progress/index.ts +4 -0
- package/src/system/ScreenReaderText/ScreenReaderText.tsx +0 -2
- package/src/system/Tabs/TabsTrigger.js +1 -2
- package/src/system/Text/Text.stories.tsx +7 -0
- package/src/system/Text/Text.tsx +1 -1
- package/src/system/Tooltip/Tooltip.css +6 -2
- package/src/system/Tooltip/Tooltip.stories.tsx +4 -4
- package/{build/system/Wizard/Wizard.stories.jsx → src/system/Wizard/Wizard.stories.tsx} +18 -23
- package/src/system/Wizard/Wizard.tsx +62 -0
- package/src/system/Wizard/{WizardStep.js → WizardStep.tsx} +38 -41
- package/src/system/Wizard/index.ts +7 -0
- package/src/system/index.js +2 -1
- package/src/system/theme/generated/valet-theme-dark.json +1219 -476
- package/src/system/theme/generated/valet-theme-light.json +1217 -474
- package/{build/system/theme/getColor.js → src/system/theme/getPropValue.js} +36 -4
- package/src/system/theme/index.js +27 -57
- package/tokens/utilities/colors/color output/blue.json +305 -0
- package/tokens/utilities/colors/color output/gold.json +305 -0
- package/tokens/utilities/colors/color output/gray.json +305 -0
- package/tokens/utilities/colors/color output/green.json +305 -0
- package/tokens/utilities/colors/color output/orange.json +305 -0
- package/tokens/utilities/colors/color output/pink.json +305 -0
- package/tokens/utilities/colors/color output/red.json +305 -0
- package/tokens/utilities/colors/color output/salmon.json +305 -0
- package/tokens/utilities/colors/color output/yellow.json +305 -0
- package/tokens/utilities/colors/colorOutput.json +4062 -0
- package/tokens/utilities/colors/color_3d_plot.js +43 -0
- package/tokens/utilities/colors/color_graph.js +31 -0
- package/tokens/utilities/colors/colors.json +1981 -0
- package/tokens/utilities/colors/index.js +118 -0
- package/tokens/utilities/colors/package-lock.json +6749 -0
- package/tokens/utilities/colors/package.json +21 -0
- package/tokens/utilities/figma-type-calculator/responsive-type.js +98 -0
- package/tokens/valet-core/$metadata.json +19 -15
- package/tokens/valet-core/$themes.json +3323 -419
- package/tokens/valet-core/{figma-parsely-expressive-type.json → figma-parsely-web-type.json} +128 -128
- package/tokens/valet-core/{figma-valet-expressive-type.json → figma-valet-web-type.json} +126 -126
- package/tokens/valet-core/figma-wpvip-services-web-type.json +1267 -0
- package/tokens/valet-core/{figma-wpvip-expressive-type.json → figma-wpvip-web-type.json} +162 -162
- package/tokens/valet-core/{parsely-expressive-color.json → parsely-web-color.json} +1 -1
- package/tokens/valet-core/{wpvip-expressive-core.json → parsely-web-core.json} +73 -23
- package/tokens/valet-core/{parsely-expressive-type.json → parsely-web-type.json} +21 -9
- package/tokens/valet-core/valet-core.json +331 -232
- package/tokens/valet-core/{valet-expressive-color.json → valet-web-color.json} +1 -1
- package/tokens/valet-core/{parsely-expressive-core.json → valet-web-core.json} +72 -22
- package/tokens/valet-core/{wpvip-productive-color.json → wpvip-product-core.json} +663 -7
- package/tokens/valet-core/{wpvip-productive-color-dark.json → wpvip-product-dark.json} +332 -10
- package/tokens/valet-core/{wpvip-expressive-color.json → wpvip-services-web-color.json} +1 -1
- package/tokens/valet-core/{valet-expressive-core.json → wpvip-services-web-core.json} +72 -22
- package/tokens/valet-core/wpvip-services-web-type.json +412 -0
- package/tokens/valet-core/{wpvip-expressive-color-dark.json → wpvip-web-color-dark.json} +1 -1
- package/tokens/valet-core/wpvip-web-color.json +730 -0
- package/tokens/valet-core/{wpvip-expressive-type.json → wpvip-web-type.json} +24 -12
- package/tokens/valet-core/wpvip-web.json +1310 -0
- package/tsconfig.json +2 -1
- package/build/system/Button/ButtonSubmit.stories.jsx +0 -40
- package/build/system/Button/variants.d.ts +0 -2
- package/build/system/Button/variants.js +0 -1
- package/build/system/Form/Checkbox.stories.jsx +0 -54
- package/build/system/Form/Input.stories.jsx +0 -38
- package/build/system/Wizard/WizardStepHorizontal.d.ts +0 -2
- package/build/system/Wizard/WizardStepHorizontal.js +0 -55
- package/build/system/theme/textStyles.d.ts +0 -71
- package/build/system/theme/textStyles.js +0 -46
- package/src/system/Button/ButtonSubmit.stories.jsx +0 -40
- package/src/system/Button/index.js +0 -8
- package/src/system/Button/variants.js +0 -1
- package/src/system/Form/Label.stories.jsx +0 -36
- package/src/system/NewForm/Fieldset.js +0 -47
- package/src/system/NewForm/Form.js +0 -26
- package/src/system/NewForm/Legend.js +0 -41
- package/src/system/Progress/Progress.stories.jsx +0 -25
- package/src/system/Progress/index.js +0 -6
- package/src/system/Wizard/Wizard.js +0 -103
- package/src/system/Wizard/Wizard.stories.jsx +0 -145
- package/src/system/Wizard/WizardStepHorizontal.js +0 -55
- package/src/system/Wizard/index.js +0 -8
- package/src/system/theme/textStyles.js +0 -46
- /package/{build/system/Form/Label.stories.jsx → src/system/Form/Label.stories.tsx} +0 -0
- /package/{build/system/Progress/Progress.stories.jsx → src/system/Progress/Progress.stories.tsx} +0 -0
package/.eslintignore
CHANGED
package/.prettierignore
CHANGED
|
@@ -1,11 +1,37 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { makeDecorator } from '@storybook/addons';
|
|
3
|
-
import { Box
|
|
3
|
+
import { Box } from '../../src/system';
|
|
4
|
+
import { Global, css } from '@emotion/react';
|
|
4
5
|
|
|
5
6
|
export default makeDecorator( {
|
|
6
7
|
name: 'withBoundingBox',
|
|
7
8
|
parameterName: 'colorMode2',
|
|
8
|
-
wrapper: storyFn =>
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
wrapper: storyFn => (
|
|
10
|
+
<>
|
|
11
|
+
<Global
|
|
12
|
+
styles={ css`
|
|
13
|
+
@font-face {
|
|
14
|
+
font-family: 'recoletaregular';
|
|
15
|
+
src: url( 'https://dashboard.wpvip.com/fonts/recoleta-regular-webfont.eot' );
|
|
16
|
+
src: url( 'https://dashboard.wpvip.com/fonts/recoleta-regular-webfont.eot?#iefix' )
|
|
17
|
+
format( 'embedded-opentype' ),
|
|
18
|
+
url( 'https://dashboard.wpvip.com/fonts/recoleta-regular-webfont.woff2' )
|
|
19
|
+
format( 'woff2' ),
|
|
20
|
+
url( 'https://dashboard.wpvip.com/fonts/recoleta-regular-webfont.woff' )
|
|
21
|
+
format( 'woff' ),
|
|
22
|
+
url( 'https://dashboard.wpvip.com/fonts/recoleta-regular-webfont.ttf' )
|
|
23
|
+
format( 'truetype' ),
|
|
24
|
+
url( 'https://dashboard.wpvip.com/fonts/recoleta-regular-webfont.svg#recoletaregular' )
|
|
25
|
+
format( 'svg' );
|
|
26
|
+
font-weight: normal;
|
|
27
|
+
font-style: normal;
|
|
28
|
+
}
|
|
29
|
+
body {
|
|
30
|
+
backgroundcolor: '#fbfbfb';
|
|
31
|
+
}
|
|
32
|
+
` }
|
|
33
|
+
/>
|
|
34
|
+
<Box sx={ { p: 3 } }>{ storyFn() }</Box>
|
|
35
|
+
</>
|
|
36
|
+
),
|
|
11
37
|
} );
|
|
@@ -9,16 +9,16 @@ import { useColorMode } from 'theme-ui';
|
|
|
9
9
|
/**
|
|
10
10
|
* Internal dependencies
|
|
11
11
|
*/
|
|
12
|
-
import ThemeBuilder from '../../src/system/theme/
|
|
12
|
+
import ThemeBuilder from '../../src/system/theme/getPropValue';
|
|
13
13
|
|
|
14
14
|
import Valet from '../../src/system/theme/generated/valet-theme-light.json';
|
|
15
15
|
import ValetDark from '../../src/system/theme/generated/valet-theme-dark.json';
|
|
16
|
-
const {
|
|
17
|
-
const {
|
|
16
|
+
const { getPropValue } = ThemeBuilder( Valet );
|
|
17
|
+
const { getPropValue: getPropValueDark } = ThemeBuilder( ValetDark );
|
|
18
18
|
|
|
19
19
|
// These need to be updated to import VIP design tokens;
|
|
20
|
-
const lightBackground =
|
|
21
|
-
const darkBackground =
|
|
20
|
+
const lightBackground = getPropValue( 'background', 'primary' );
|
|
21
|
+
const darkBackground = getPropValueDark( 'background', 'primary' );
|
|
22
22
|
|
|
23
23
|
export const backgrounds = {
|
|
24
24
|
default: 'Light',
|
package/CONTRIBUTING.md
CHANGED
|
@@ -43,7 +43,7 @@ You need to update the tokens once the VIP Design System updates the core files.
|
|
|
43
43
|
|
|
44
44
|
We use the VIP Design System Tokens as our base theme structure. All colors, spaces, types should come from a dynamic token system provided by the VIP Design team, currently using Figma as the design software. When the design system is updated by the Design team, they push a file to the root of this repository: `tokens/valet-core.json`.
|
|
45
45
|
|
|
46
|
-
By using the [Token Transformer](https://docs.tokens.studio/sync/github#7-how-to-use-tokens-stored-in-github-in-development) and a custom npm script, we parse this file getting only the VIP Dashboard theme we need for the react components. The light theme is called: `wpvip-
|
|
46
|
+
By using the [Token Transformer](https://docs.tokens.studio/sync/github#7-how-to-use-tokens-stored-in-github-in-development) and a custom npm script, we parse this file getting only the VIP Dashboard theme we need for the react components. The light theme is called: `wpvip-product-core`, and the dark theme is called `wpvip-product-dark`.
|
|
47
47
|
|
|
48
48
|
Once the new file is updated, we need to generate a custom theme file in `src/generated/valet-theme-light.json`. This operation generates a small json file with the colors we need already filled in.
|
|
49
49
|
|
|
@@ -56,12 +56,12 @@ var Item = exports.Item = function Item(_ref) {
|
|
|
56
56
|
borderColor: 'borders.2',
|
|
57
57
|
'&:first-of-type': {
|
|
58
58
|
borderTopWidth: '1px',
|
|
59
|
-
borderTopLeftRadius:
|
|
60
|
-
borderTopRightRadius:
|
|
59
|
+
borderTopLeftRadius: 1,
|
|
60
|
+
borderTopRightRadius: 1
|
|
61
61
|
},
|
|
62
62
|
'&:last-child': {
|
|
63
|
-
borderBottomLeftRadius:
|
|
64
|
-
borderBottomRightRadius:
|
|
63
|
+
borderBottomLeftRadius: 1,
|
|
64
|
+
borderBottomRightRadius: 1
|
|
65
65
|
},
|
|
66
66
|
'&:focus-within': function focusWithin(theme) {
|
|
67
67
|
return theme.outline;
|
|
@@ -97,7 +97,7 @@ var Trigger = exports.Trigger = /*#__PURE__*/_react["default"].forwardRef(functi
|
|
|
97
97
|
alignItems: 'center',
|
|
98
98
|
justifyContent: 'space-between',
|
|
99
99
|
fontSize: 1,
|
|
100
|
-
fontWeight:
|
|
100
|
+
fontWeight: 'bold',
|
|
101
101
|
'&[data-state="closed"]': {
|
|
102
102
|
backgroundColor: 'accordion.background.closed'
|
|
103
103
|
},
|
|
@@ -193,7 +193,7 @@ var Root = exports.Root = /*#__PURE__*/_react["default"].forwardRef(function (_r
|
|
|
193
193
|
type: "single",
|
|
194
194
|
ref: forwardRef,
|
|
195
195
|
sx: _extends({
|
|
196
|
-
borderRadius:
|
|
196
|
+
borderRadius: 2
|
|
197
197
|
}, sx)
|
|
198
198
|
}, props, {
|
|
199
199
|
children: children
|
|
@@ -74,7 +74,7 @@ var WithLargeText = exports.WithLargeText = function WithLargeText() {
|
|
|
74
74
|
return (0, _jsxRuntime.jsx)(_.Box, {
|
|
75
75
|
sx: {
|
|
76
76
|
'.vip-heading-component > button': {
|
|
77
|
-
fontSize:
|
|
77
|
+
fontSize: 4
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
80
|
children: (0, _jsxRuntime.jsx)(ExampleAccordion, {})
|
|
@@ -10,11 +10,13 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
10
10
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
11
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(typeof e + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
12
12
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
13
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } // TODO: Fix this
|
|
14
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */ // @ts-nocheck
|
|
15
|
+
/** @jsxImportSource theme-ui */ /**
|
|
16
|
+
* External dependencies
|
|
17
|
+
*/ /**
|
|
18
|
+
* Internal dependencies
|
|
19
|
+
*/
|
|
18
20
|
var renderWithTheme = function renderWithTheme(children) {
|
|
19
21
|
return (0, _react.render)((0, _jsxRuntime.jsx)(_themeUi.ThemeUIProvider, {
|
|
20
22
|
theme: _.theme,
|
|
@@ -28,7 +28,7 @@ var Avatar = exports.Avatar = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
28
28
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
29
29
|
return (0, _jsxRuntime.jsx)(_.Box, _extends({
|
|
30
30
|
sx: {
|
|
31
|
-
borderRadius:
|
|
31
|
+
borderRadius: '100%',
|
|
32
32
|
height: size + 2,
|
|
33
33
|
// +2 to compensate padding on both sides
|
|
34
34
|
width: size + 2,
|
|
@@ -42,6 +42,7 @@ var Avatar = exports.Avatar = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
42
42
|
justifyContent: 'center',
|
|
43
43
|
color: 'white',
|
|
44
44
|
padding: '1px',
|
|
45
|
+
// this should probably be replaced with a token
|
|
45
46
|
textAlign: 'center'
|
|
46
47
|
},
|
|
47
48
|
className: (0, _classnames["default"])('vip-avatar-component', className),
|
|
@@ -52,7 +53,7 @@ var Avatar = exports.Avatar = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
52
53
|
src: src,
|
|
53
54
|
alt: "Avatar image from " + name,
|
|
54
55
|
sx: {
|
|
55
|
-
borderRadius:
|
|
56
|
+
borderRadius: '100%',
|
|
56
57
|
width: '100%',
|
|
57
58
|
display: 'block'
|
|
58
59
|
}
|
|
@@ -27,6 +27,7 @@ var Badge = exports.Badge = /*#__PURE__*/(0, _react.forwardRef)(function (_ref,
|
|
|
27
27
|
sx: _extends({
|
|
28
28
|
fontSize: 0,
|
|
29
29
|
padding: 0,
|
|
30
|
+
// do we need padding declared twice here?
|
|
30
31
|
bg: "tag." + variant + ".background",
|
|
31
32
|
color: "tag." + variant + ".text",
|
|
32
33
|
py: 1,
|
|
@@ -4,9 +4,20 @@
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { ButtonProps as ThemeButtonProps } from 'theme-ui';
|
|
6
6
|
type ButtonClickType = React.MouseEvent<HTMLButtonElement, MouseEvent>;
|
|
7
|
+
export declare enum ButtonVariant {
|
|
8
|
+
'danger' = 0,
|
|
9
|
+
'display' = 1,
|
|
10
|
+
'ghost' = 2,
|
|
11
|
+
'icon' = 3,
|
|
12
|
+
'primary' = 4,
|
|
13
|
+
'secondary' = 5,
|
|
14
|
+
'tertiary' = 6,
|
|
15
|
+
'text' = 7
|
|
16
|
+
}
|
|
7
17
|
export interface ButtonProps extends ThemeButtonProps {
|
|
8
18
|
disabled?: boolean;
|
|
9
19
|
onClick?: (event: ButtonClickType) => void;
|
|
20
|
+
variant?: keyof typeof ButtonVariant;
|
|
10
21
|
}
|
|
11
22
|
declare const Button: React.ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
12
23
|
export { Button };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.Button = void 0;
|
|
4
|
+
exports.ButtonVariant = exports.Button = void 0;
|
|
5
5
|
var _react = _interopRequireWildcard(require("react"));
|
|
6
6
|
var _themeUi = require("theme-ui");
|
|
7
7
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
@@ -15,6 +15,17 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
15
15
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
16
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
17
17
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
18
|
+
var ButtonVariant = exports.ButtonVariant = /*#__PURE__*/function (ButtonVariant) {
|
|
19
|
+
ButtonVariant[ButtonVariant["danger"] = 0] = "danger";
|
|
20
|
+
ButtonVariant[ButtonVariant["display"] = 1] = "display";
|
|
21
|
+
ButtonVariant[ButtonVariant["ghost"] = 2] = "ghost";
|
|
22
|
+
ButtonVariant[ButtonVariant["icon"] = 3] = "icon";
|
|
23
|
+
ButtonVariant[ButtonVariant["primary"] = 4] = "primary";
|
|
24
|
+
ButtonVariant[ButtonVariant["secondary"] = 5] = "secondary";
|
|
25
|
+
ButtonVariant[ButtonVariant["tertiary"] = 6] = "tertiary";
|
|
26
|
+
ButtonVariant[ButtonVariant["text"] = 7] = "text";
|
|
27
|
+
return ButtonVariant;
|
|
28
|
+
}({});
|
|
18
29
|
var Button = exports.Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
19
30
|
var className = _ref.className,
|
|
20
31
|
disabled = _ref.disabled,
|
|
@@ -46,8 +57,10 @@ var Button = exports.Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
46
57
|
},
|
|
47
58
|
'&[aria-disabled="true"]': {
|
|
48
59
|
opacity: 0.7,
|
|
60
|
+
backgroundColor: 'input.border.disabled',
|
|
61
|
+
color: 'texts.secondary',
|
|
49
62
|
cursor: 'not-allowed',
|
|
50
|
-
pointerEvents: '
|
|
63
|
+
pointerEvents: 'none'
|
|
51
64
|
}
|
|
52
65
|
}, sx)
|
|
53
66
|
}, rest, {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* External dependencies
|
|
4
4
|
*/
|
|
5
5
|
import React from 'react';
|
|
6
|
+
import { ButtonVariant } from '..';
|
|
6
7
|
declare const _default: {
|
|
7
8
|
title: string;
|
|
8
9
|
component: React.ForwardRefExoticComponent<Omit<import("./Button").ButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -15,7 +16,7 @@ declare const _default: {
|
|
|
15
16
|
};
|
|
16
17
|
variant: {
|
|
17
18
|
type: string;
|
|
18
|
-
options: string[];
|
|
19
|
+
options: (string | ButtonVariant)[];
|
|
19
20
|
};
|
|
20
21
|
};
|
|
21
22
|
parameters: {
|
|
@@ -6,7 +6,6 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
6
6
|
var _bi = require("react-icons/bi");
|
|
7
7
|
var _ScreenReaderText = _interopRequireDefault(require("../ScreenReaderText"));
|
|
8
8
|
var _ = require("..");
|
|
9
|
-
var _variants = _interopRequireDefault(require("./variants"));
|
|
10
9
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
11
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
11
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } /** @jsxImportSource theme-ui */ /**
|
|
@@ -26,7 +25,7 @@ var _default = exports["default"] = {
|
|
|
26
25
|
},
|
|
27
26
|
variant: {
|
|
28
27
|
type: 'select',
|
|
29
|
-
options:
|
|
28
|
+
options: Object.values(_.ButtonVariant)
|
|
30
29
|
}
|
|
31
30
|
},
|
|
32
31
|
parameters: {
|
|
@@ -76,6 +75,14 @@ var Template = function Template(args) {
|
|
|
76
75
|
}
|
|
77
76
|
}, args, {
|
|
78
77
|
children: "Danger"
|
|
78
|
+
})), (0, _jsxRuntime.jsx)(_.Button, _extends({
|
|
79
|
+
variant: "primary",
|
|
80
|
+
disabled: true,
|
|
81
|
+
sx: {
|
|
82
|
+
ml: 2
|
|
83
|
+
}
|
|
84
|
+
}, args, {
|
|
85
|
+
children: "Disabled"
|
|
79
86
|
})), (0, _jsxRuntime.jsx)(_.Button, _extends({
|
|
80
87
|
variant: "text",
|
|
81
88
|
sx: {
|
|
@@ -1,48 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { fireEvent, render, screen } from '@testing-library/react';
|
|
5
|
-
import { axe } from 'jest-axe';
|
|
1
|
+
"use strict";
|
|
6
2
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
var _react = require("@testing-library/react");
|
|
4
|
+
var _jestAxe = require("jest-axe");
|
|
5
|
+
var _Button = require("./Button");
|
|
6
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
7
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(typeof e + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
8
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
9
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } /**
|
|
10
|
+
* External dependencies
|
|
11
|
+
*/ /**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
var BUTTON_TEXT = 'Button Text';
|
|
15
|
+
describe('<Button />', function () {
|
|
16
|
+
it('renders the Button component', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
17
|
+
var onClick, _render, container, component;
|
|
18
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
19
|
+
while (1) switch (_context.prev = _context.next) {
|
|
20
|
+
case 0:
|
|
21
|
+
onClick = jest.fn(function () {});
|
|
22
|
+
_render = (0, _react.render)((0, _jsxRuntime.jsx)(_Button.Button, {
|
|
23
|
+
onClick: onClick,
|
|
24
|
+
children: BUTTON_TEXT
|
|
25
|
+
})), container = _render.container;
|
|
26
|
+
component = _react.screen.getByText(BUTTON_TEXT);
|
|
27
|
+
expect(component).toBeInTheDocument();
|
|
28
|
+
_react.fireEvent.click(component);
|
|
29
|
+
expect(onClick).toHaveBeenCalledTimes(1);
|
|
11
30
|
|
|
12
|
-
|
|
31
|
+
// Check for accessibility issues
|
|
32
|
+
_context.t0 = expect;
|
|
33
|
+
_context.next = 9;
|
|
34
|
+
return (0, _jestAxe.axe)(container);
|
|
35
|
+
case 9:
|
|
36
|
+
_context.t1 = _context.sent;
|
|
37
|
+
(0, _context.t0)(_context.t1).toHaveNoViolations();
|
|
38
|
+
case 11:
|
|
39
|
+
case "end":
|
|
40
|
+
return _context.stop();
|
|
41
|
+
}
|
|
42
|
+
}, _callee);
|
|
43
|
+
})));
|
|
44
|
+
it('renders the Button with disabled prop', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
45
|
+
var onClick, _render2, container, component;
|
|
46
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
47
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
48
|
+
case 0:
|
|
49
|
+
onClick = jest.fn(function () {});
|
|
50
|
+
_render2 = (0, _react.render)((0, _jsxRuntime.jsx)(_Button.Button, {
|
|
51
|
+
disabled: true,
|
|
52
|
+
onClick: onClick,
|
|
53
|
+
children: BUTTON_TEXT
|
|
54
|
+
})), container = _render2.container;
|
|
55
|
+
component = _react.screen.getByText(BUTTON_TEXT);
|
|
56
|
+
expect(component).toBeInTheDocument();
|
|
57
|
+
expect(component).toHaveAttribute('aria-disabled', 'true');
|
|
58
|
+
expect(component).not.toHaveAttribute('disabled');
|
|
59
|
+
_react.fireEvent.click(component);
|
|
60
|
+
expect(onClick).toHaveBeenCalledTimes(0);
|
|
13
61
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
it( 'renders the Button with disabled prop', async () => {
|
|
30
|
-
const onClick = jest.fn( () => {} );
|
|
31
|
-
const { container } = render(
|
|
32
|
-
<Button disabled onClick={ onClick }>
|
|
33
|
-
{ BUTTON_TEXT }
|
|
34
|
-
</Button>
|
|
35
|
-
);
|
|
36
|
-
const component = screen.getByText( BUTTON_TEXT );
|
|
37
|
-
|
|
38
|
-
expect( component ).toBeInTheDocument();
|
|
39
|
-
expect( component ).toHaveAttribute( 'aria-disabled', 'true' );
|
|
40
|
-
expect( component ).not.toHaveAttribute( 'disabled' );
|
|
41
|
-
|
|
42
|
-
fireEvent.click( component );
|
|
43
|
-
expect( onClick ).toHaveBeenCalledTimes( 0 );
|
|
44
|
-
|
|
45
|
-
// Check for accessibility issues
|
|
46
|
-
await expect( await axe( container ) ).toHaveNoViolations();
|
|
47
|
-
} );
|
|
48
|
-
} );
|
|
62
|
+
// Check for accessibility issues
|
|
63
|
+
_context2.t0 = expect;
|
|
64
|
+
_context2.next = 11;
|
|
65
|
+
return (0, _jestAxe.axe)(container);
|
|
66
|
+
case 11:
|
|
67
|
+
_context2.t1 = _context2.sent;
|
|
68
|
+
(0, _context2.t0)(_context2.t1).toHaveNoViolations();
|
|
69
|
+
case 13:
|
|
70
|
+
case "end":
|
|
71
|
+
return _context2.stop();
|
|
72
|
+
}
|
|
73
|
+
}, _callee2);
|
|
74
|
+
})));
|
|
75
|
+
});
|
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
2
4
|
import React from 'react';
|
|
5
|
+
import { ButtonProps } from './Button';
|
|
6
|
+
interface DefaultSpinnerProps {
|
|
7
|
+
color?: string;
|
|
8
|
+
size: number;
|
|
9
|
+
}
|
|
10
|
+
export interface ButtonSubmitProps extends ButtonProps {
|
|
11
|
+
label: React.ReactNode;
|
|
12
|
+
loading?: boolean;
|
|
13
|
+
loadingIcon?: (props: DefaultSpinnerProps) => JSX.Element;
|
|
14
|
+
loadingIconSize?: number;
|
|
15
|
+
show?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare const ButtonSubmit: React.ForwardRefExoticComponent<Omit<ButtonSubmitProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
18
|
+
export {};
|
|
@@ -1,69 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.ButtonSubmit = void 0;
|
|
5
|
+
var _react = _interopRequireDefault(require("react"));
|
|
6
|
+
var _Button = require("./Button");
|
|
7
|
+
var _Spinner = require("../Spinner");
|
|
8
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
10
|
+
var _excluded = ["show", "variant", "label", "loading", "disabled", "loadingIcon", "loadingIconSize"];
|
|
3
11
|
/**
|
|
4
12
|
* External dependencies
|
|
5
13
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
21
|
-
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
16
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
17
|
+
function DefaultSpinner(_ref) {
|
|
18
|
+
var size = _ref.size,
|
|
19
|
+
_ref$color = _ref.color,
|
|
20
|
+
color = _ref$color === void 0 ? 'link' : _ref$color;
|
|
21
|
+
return (0, _jsxRuntime.jsx)(_Spinner.Spinner, {
|
|
22
|
+
size: size,
|
|
23
|
+
sx: {
|
|
24
|
+
ml: 2,
|
|
25
|
+
color: color
|
|
26
|
+
},
|
|
27
|
+
className: "vip-button-submit-spinner"
|
|
28
|
+
});
|
|
29
|
+
}
|
|
22
30
|
DefaultSpinner.displayName = 'DefaultSpinner';
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
ButtonSubmit.displayName = 'ButtonSubmit';
|
|
60
|
-
|
|
61
|
-
ButtonSubmit.propTypes = {
|
|
62
|
-
label: PropTypes.node.isRequired,
|
|
63
|
-
disabled: PropTypes.bool,
|
|
64
|
-
loading: PropTypes.bool,
|
|
65
|
-
variant: PropTypes.oneOf( variants ),
|
|
66
|
-
show: PropTypes.bool,
|
|
67
|
-
loadingIcon: PropTypes.any,
|
|
68
|
-
loadingIconSize: PropTypes.number,
|
|
69
|
-
};
|
|
31
|
+
var ButtonSubmit = exports.ButtonSubmit = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
32
|
+
var _ref2$show = _ref2.show,
|
|
33
|
+
show = _ref2$show === void 0 ? true : _ref2$show,
|
|
34
|
+
_ref2$variant = _ref2.variant,
|
|
35
|
+
variant = _ref2$variant === void 0 ? 'secondary' : _ref2$variant,
|
|
36
|
+
label = _ref2.label,
|
|
37
|
+
_ref2$loading = _ref2.loading,
|
|
38
|
+
loading = _ref2$loading === void 0 ? false : _ref2$loading,
|
|
39
|
+
_ref2$disabled = _ref2.disabled,
|
|
40
|
+
disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
|
|
41
|
+
_ref2$loadingIcon = _ref2.loadingIcon,
|
|
42
|
+
loadingIcon = _ref2$loadingIcon === void 0 ? DefaultSpinner : _ref2$loadingIcon,
|
|
43
|
+
_ref2$loadingIconSize = _ref2.loadingIconSize,
|
|
44
|
+
loadingIconSize = _ref2$loadingIconSize === void 0 ? 20 : _ref2$loadingIconSize,
|
|
45
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
46
|
+
if (!show) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return (0, _jsxRuntime.jsxs)(_Button.Button, _extends({
|
|
50
|
+
ref: ref,
|
|
51
|
+
className: (0, _classnames["default"])('vip-button-submit-component', "vip-button-submit-" + variant),
|
|
52
|
+
disabled: disabled || loading,
|
|
53
|
+
variant: variant,
|
|
54
|
+
"aria-busy": loading
|
|
55
|
+
}, rest, {
|
|
56
|
+
children: [label, ' ', !!loading && loadingIcon({
|
|
57
|
+
size: loadingIconSize,
|
|
58
|
+
color: "button." + variant + ".label.default"
|
|
59
|
+
})]
|
|
60
|
+
}));
|
|
61
|
+
});
|
|
62
|
+
ButtonSubmit.displayName = 'ButtonSubmit';
|