@workday/canvas-kit-preview-react 11.0.0-alpha.669-next.0 → 11.0.0-alpha.682-next.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/dist/commonjs/radio/lib/RadioGroup.d.ts +5 -6
- package/dist/commonjs/radio/lib/RadioGroup.d.ts.map +1 -1
- package/dist/commonjs/radio/lib/RadioGroup.js +30 -9
- package/dist/commonjs/radio/lib/RadioLabel.d.ts +2 -1
- package/dist/commonjs/radio/lib/RadioLabel.d.ts.map +1 -1
- package/dist/commonjs/radio/lib/RadioLabel.js +12 -2
- package/dist/commonjs/radio/lib/RadioText.d.ts.map +1 -1
- package/dist/commonjs/radio/lib/RadioText.js +32 -12
- package/dist/commonjs/radio/lib/StyledRadioButton.d.ts +3 -2
- package/dist/commonjs/radio/lib/StyledRadioButton.d.ts.map +1 -1
- package/dist/commonjs/radio/lib/StyledRadioButton.js +183 -94
- package/dist/es6/radio/lib/RadioGroup.d.ts +5 -6
- package/dist/es6/radio/lib/RadioGroup.d.ts.map +1 -1
- package/dist/es6/radio/lib/RadioGroup.js +32 -11
- package/dist/es6/radio/lib/RadioLabel.d.ts +2 -1
- package/dist/es6/radio/lib/RadioLabel.d.ts.map +1 -1
- package/dist/es6/radio/lib/RadioLabel.js +13 -3
- package/dist/es6/radio/lib/RadioText.d.ts.map +1 -1
- package/dist/es6/radio/lib/RadioText.js +32 -12
- package/dist/es6/radio/lib/StyledRadioButton.d.ts +3 -2
- package/dist/es6/radio/lib/StyledRadioButton.d.ts.map +1 -1
- package/dist/es6/radio/lib/StyledRadioButton.js +185 -96
- package/package.json +4 -4
- package/radio/lib/RadioGroup.tsx +36 -38
- package/radio/lib/RadioLabel.tsx +15 -10
- package/radio/lib/RadioText.tsx +33 -17
- package/radio/lib/StyledRadioButton.tsx +170 -105
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Themeable, ErrorType
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
import { Themeable, ErrorType } from '@workday/canvas-kit-react/common';
|
|
3
|
+
import { FlexProps } from '@workday/canvas-kit-react/layout';
|
|
4
|
+
import { CSProps } from '@workday/canvas-kit-styling';
|
|
5
|
+
export interface RadioGroupProps extends Themeable, CSProps, FlexProps {
|
|
5
6
|
/**
|
|
6
7
|
* The type of error associated with the RadioGroup (if applicable).
|
|
7
8
|
*/
|
|
@@ -17,9 +18,7 @@ export interface RadioGroupProps extends Themeable, ExtractProps<typeof Flex, ne
|
|
|
17
18
|
* </RadioGroup>
|
|
18
19
|
* ```
|
|
19
20
|
*/
|
|
20
|
-
export declare const RadioGroup: import("@workday/canvas-kit-react/common").ElementComponentM<
|
|
21
|
-
Item: import("@workday/canvas-kit-react/common").ElementComponent<"div", import("@workday/canvas-kit-react/layout").BackgroundStyleProps & import("@workday/canvas-kit-react/layout/lib/utils/border/color").BorderColorStyleProps & import("@workday/canvas-kit-react/layout/lib/utils/border/lineStyle").BorderLineStyleProps & import("@workday/canvas-kit-react/layout/lib/utils/border/radius").BorderRadiusStyleProps & import("@workday/canvas-kit-react/layout/lib/utils/border/shorthand").BorderShorthandStyleProps & import("@workday/canvas-kit-react/layout/lib/utils/border/width").BorderWidthStyleProps & import("@workday/canvas-kit-react/layout").ColorStyleProps & import("@workday/canvas-kit-react/layout").DepthStyleProps & import("@workday/canvas-kit-react/layout").FlexItemStyleProps & import("@workday/canvas-kit-react/layout").GridItemStyleProps & import("@workday/canvas-kit-react/layout").LayoutStyleProps & import("@workday/canvas-kit-react/layout").OtherStyleProps & import("@workday/canvas-kit-react/layout").PositionStyleProps & import("@workday/canvas-kit-react/layout").SpaceStyleProps & import("@workday/canvas-kit-react/layout").TextStyleProps & import("@workday/canvas-kit-styling").CSProps>;
|
|
22
|
-
}, RadioGroupProps & Partial<{
|
|
21
|
+
export declare const RadioGroup: import("@workday/canvas-kit-react/common").ElementComponentM<"div", RadioGroupProps & Partial<{
|
|
23
22
|
'aria-describedby': string | undefined;
|
|
24
23
|
name: string;
|
|
25
24
|
value: string | number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../../../../radio/lib/RadioGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,
|
|
1
|
+
{"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../../../../radio/lib/RadioGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAkB,SAAS,EAAE,SAAS,EAAC,MAAM,kCAAkC,CAAC;AAEvF,OAAO,EAAC,SAAS,EAAc,MAAM,kCAAkC,CAAC;AAGxE,OAAO,EAAgB,OAAO,EAAe,MAAM,6BAA6B,CAAC;AAGjF,MAAM,WAAW,eAAgB,SAAQ,SAAS,EAAE,OAAO,EAAE,SAAS;IACpE;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AA8BD;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;IAInB;;;;;;;;;;OAUG;;;;;;;;;;;IAEH;;;;;;;;;;;;OAYG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKL,CAAC"}
|
|
@@ -6,11 +6,37 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.RadioGroup = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const common_1 = require("@workday/canvas-kit-react/common");
|
|
9
|
-
const tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
10
9
|
const useRadioModel_1 = require("./hooks/useRadioModel");
|
|
11
10
|
const layout_1 = require("@workday/canvas-kit-react/layout");
|
|
12
11
|
const RadioLabel_1 = require("./RadioLabel");
|
|
13
12
|
const RadioButton_1 = require("./RadioButton");
|
|
13
|
+
const canvas_kit_styling_1 = require("@workday/canvas-kit-styling");
|
|
14
|
+
const canvas_tokens_web_1 = require("@workday/canvas-tokens-web");
|
|
15
|
+
/**
|
|
16
|
+
* Styles for RadioGroup
|
|
17
|
+
*/
|
|
18
|
+
const radioGroupStyles = canvas_kit_styling_1.createStencil({
|
|
19
|
+
base: {
|
|
20
|
+
display: 'flex',
|
|
21
|
+
flexDirection: 'column',
|
|
22
|
+
borderRadius: canvas_tokens_web_1.system.shape.x1,
|
|
23
|
+
gap: canvas_tokens_web_1.system.space.x2,
|
|
24
|
+
padding: `${canvas_kit_styling_1.px2rem(10)} ${canvas_tokens_web_1.system.space.x3} ${canvas_tokens_web_1.system.space.x2}`,
|
|
25
|
+
margin: `${canvas_kit_styling_1.calc.negate(canvas_tokens_web_1.system.space.x1)} ${canvas_kit_styling_1.calc.negate(canvas_tokens_web_1.system.space.x3)}`,
|
|
26
|
+
transition: '100ms box-shadow',
|
|
27
|
+
width: 'fit-content',
|
|
28
|
+
},
|
|
29
|
+
modifiers: {
|
|
30
|
+
error: {
|
|
31
|
+
error: {
|
|
32
|
+
boxShadow: `inset 0 0 0 ${canvas_kit_styling_1.px2rem(2)} ${canvas_tokens_web_1.brand.error.base}`,
|
|
33
|
+
},
|
|
34
|
+
alert: {
|
|
35
|
+
boxShadow: `inset 0 0 0 ${canvas_kit_styling_1.px2rem(1)} ${canvas_tokens_web_1.brand.alert.darkest}, inset 0 0 0 ${canvas_kit_styling_1.px2rem(3)} ${canvas_tokens_web_1.brand.alert.base}`,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
});
|
|
14
40
|
/**
|
|
15
41
|
* Use `RadioGroup` to group a collection of `RadioGroup.RadioButton` components under a common `name`.
|
|
16
42
|
*
|
|
@@ -21,7 +47,7 @@ const RadioButton_1 = require("./RadioButton");
|
|
|
21
47
|
* </RadioGroup>
|
|
22
48
|
* ```
|
|
23
49
|
*/
|
|
24
|
-
exports.RadioGroup = common_1.createContainer(
|
|
50
|
+
exports.RadioGroup = common_1.createContainer('div')({
|
|
25
51
|
displayName: 'RadioGroup',
|
|
26
52
|
modelHook: useRadioModel_1.useRadioModel,
|
|
27
53
|
subComponents: {
|
|
@@ -52,11 +78,6 @@ exports.RadioGroup = common_1.createContainer(layout_1.Flex)({
|
|
|
52
78
|
*/
|
|
53
79
|
Label: RadioLabel_1.RadioLabel,
|
|
54
80
|
},
|
|
55
|
-
})(({ children, error, theme, ...elemProps }, Element
|
|
56
|
-
|
|
57
|
-
return (react_1.default.createElement(layout_1.Flex, Object.assign({ as: Element, boxSizing: "border-box", flexDirection: "column", borderRadius: "m", paddingTop: "10px", paddingBottom: "8px", paddingX: "xs", gap: "xxs", marginY: `-${tokens_1.space.xxxs}`, transition: "100ms box-shadow", marginX: `-${tokens_1.space.xs}`, width: "fit-content", cs: {
|
|
58
|
-
boxShadow: errorColors.outer !== errorColors.inner
|
|
59
|
-
? `inset 0 0 0 1px ${errorColors.outer}, inset 0 0 0 3px ${errorColors.inner}`
|
|
60
|
-
: `inset 0 0 0 2px ${errorColors.inner}`,
|
|
61
|
-
} }, elemProps), children));
|
|
81
|
+
})(({ children, error, theme, ...elemProps }, Element) => {
|
|
82
|
+
return react_1.default.createElement(Element, Object.assign({}, layout_1.mergeStyles(elemProps, radioGroupStyles({ error }))), children);
|
|
62
83
|
});
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Themeable, ExtractProps } from '@workday/canvas-kit-react/common';
|
|
3
3
|
import { Flex } from '@workday/canvas-kit-react/layout';
|
|
4
|
+
import { CSProps } from '@workday/canvas-kit-styling';
|
|
4
5
|
interface RadioLabelContextInterface {
|
|
5
6
|
disabled?: boolean | undefined;
|
|
6
7
|
variant?: 'inverse' | undefined;
|
|
7
8
|
value?: string | number;
|
|
8
9
|
}
|
|
9
|
-
export interface RadioLabelProps extends Themeable, ExtractProps<typeof Flex, never>, RadioLabelContextInterface {
|
|
10
|
+
export interface RadioLabelProps extends Themeable, CSProps, ExtractProps<typeof Flex, never>, RadioLabelContextInterface {
|
|
10
11
|
/**
|
|
11
12
|
* The Radio input and label children of RadioLabel
|
|
12
13
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioLabel.d.ts","sourceRoot":"","sources":["../../../../radio/lib/RadioLabel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,SAAS,EAAsB,YAAY,EAAC,MAAM,kCAAkC,CAAC;AAE7F,OAAO,EAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"RadioLabel.d.ts","sourceRoot":"","sources":["../../../../radio/lib/RadioLabel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,SAAS,EAAsB,YAAY,EAAC,MAAM,kCAAkC,CAAC;AAE7F,OAAO,EAAC,IAAI,EAAc,MAAM,kCAAkC,CAAC;AAGnE,OAAO,EAAgB,OAAO,EAAC,MAAM,6BAA6B,CAAC;AAGnE,UAAU,0BAA0B;IAClC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB;AACD,MAAM,WAAW,eACf,SAAQ,SAAS,EACf,OAAO,EACP,YAAY,CAAC,OAAO,IAAI,EAAE,KAAK,CAAC,EAChC,0BAA0B;IAC5B;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAWD,eAAO,MAAM,iBAAiB,2CAAwD,CAAC;AAEvF,eAAO,MAAM,UAAU;;;;;;;;;;IAInB;;;;;;;;;;;OAWG;;;;;;;;;;;IAEH;;;;;;;;;;;OAWG;;;;;;;;;;;CAWL,CAAC"}
|
|
@@ -10,6 +10,16 @@ const useRadioModel_1 = require("./hooks/useRadioModel");
|
|
|
10
10
|
const layout_1 = require("@workday/canvas-kit-react/layout");
|
|
11
11
|
const RadioInput_1 = require("./RadioInput");
|
|
12
12
|
const RadioText_1 = require("./RadioText");
|
|
13
|
+
const canvas_kit_styling_1 = require("@workday/canvas-kit-styling");
|
|
14
|
+
const canvas_tokens_web_1 = require("@workday/canvas-tokens-web");
|
|
15
|
+
const radioLabelStyles = canvas_kit_styling_1.createStencil({
|
|
16
|
+
base: {
|
|
17
|
+
alignItems: 'flex-start',
|
|
18
|
+
minHeight: canvas_tokens_web_1.system.space.x6,
|
|
19
|
+
position: 'relative',
|
|
20
|
+
gap: canvas_tokens_web_1.system.space.x3,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
13
23
|
exports.RadioLabelContext = react_1.default.createContext({});
|
|
14
24
|
exports.RadioLabel = common_1.createSubcomponent('label')({
|
|
15
25
|
displayName: 'Radio.Label',
|
|
@@ -42,7 +52,7 @@ exports.RadioLabel = common_1.createSubcomponent('label')({
|
|
|
42
52
|
*/
|
|
43
53
|
Text: RadioText_1.RadioText,
|
|
44
54
|
},
|
|
45
|
-
})(({ children, variant, disabled, value, ...elemProps }, Element
|
|
55
|
+
})(({ children, variant, disabled, value, ...elemProps }, Element) => {
|
|
46
56
|
return (react_1.default.createElement(exports.RadioLabelContext.Provider, { value: { variant, disabled } },
|
|
47
|
-
react_1.default.createElement(layout_1.Flex, Object.assign({ as: Element
|
|
57
|
+
react_1.default.createElement(layout_1.Flex, Object.assign({ as: Element }, layout_1.mergeStyles(elemProps, radioLabelStyles({ variant }))), children)));
|
|
48
58
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioText.d.ts","sourceRoot":"","sources":["../../../../radio/lib/RadioText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"RadioText.d.ts","sourceRoot":"","sources":["../../../../radio/lib/RadioText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAqC1B,eAAO,MAAM,SAAS;;;;;;;;;EAUpB,CAAC"}
|
|
@@ -6,23 +6,43 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.RadioText = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const common_1 = require("@workday/canvas-kit-react/common");
|
|
9
|
-
const tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
10
9
|
const useRadioModel_1 = require("./hooks/useRadioModel");
|
|
11
10
|
const RadioLabel_1 = require("./RadioLabel");
|
|
12
11
|
const text_1 = require("@workday/canvas-kit-react/text");
|
|
12
|
+
const canvas_kit_styling_1 = require("@workday/canvas-kit-styling");
|
|
13
|
+
const canvas_tokens_web_1 = require("@workday/canvas-tokens-web");
|
|
14
|
+
const layout_1 = require("@workday/canvas-kit-react/layout");
|
|
15
|
+
const radioTextStyles = canvas_kit_styling_1.createStencil({
|
|
16
|
+
base: {
|
|
17
|
+
...canvas_tokens_web_1.system.type.subtext.large,
|
|
18
|
+
cursor: 'pointer',
|
|
19
|
+
opacity: '1',
|
|
20
|
+
color: canvas_tokens_web_1.base.blackPepper300,
|
|
21
|
+
},
|
|
22
|
+
modifiers: {
|
|
23
|
+
variant: {
|
|
24
|
+
inverse: {
|
|
25
|
+
color: canvas_tokens_web_1.base.frenchVanilla100,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
disabled: {
|
|
29
|
+
true: {
|
|
30
|
+
cursor: 'none',
|
|
31
|
+
color: canvas_tokens_web_1.base.licorice100,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
compound: [
|
|
36
|
+
{
|
|
37
|
+
modifiers: { variant: 'inverse', disabled: true },
|
|
38
|
+
styles: { color: canvas_tokens_web_1.base.frenchVanilla100, opacity: canvas_tokens_web_1.system.opacity.disabled },
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
});
|
|
13
42
|
exports.RadioText = common_1.createSubcomponent('span')({
|
|
14
43
|
displayName: 'RadioButton.Text',
|
|
15
44
|
modelHook: useRadioModel_1.useRadioModel,
|
|
16
45
|
})(({ children, ...elemProps }, Element) => {
|
|
17
|
-
const {
|
|
18
|
-
|
|
19
|
-
return (react_1.default.createElement(text_1.Text, Object.assign({ as: Element, style: {
|
|
20
|
-
cursor: !disabled ? 'pointer' : undefined,
|
|
21
|
-
opacity: disabled && inverse ? '.4' : '1',
|
|
22
|
-
color: inverse
|
|
23
|
-
? tokens_1.colors.frenchVanilla100
|
|
24
|
-
: disabled
|
|
25
|
-
? tokens_1.inputColors.disabled.text
|
|
26
|
-
: elemProps.color,
|
|
27
|
-
}, typeLevel: "subtext.large" }, elemProps), children));
|
|
46
|
+
const { variant, disabled } = react_1.default.useContext(RadioLabel_1.RadioLabelContext);
|
|
47
|
+
return (react_1.default.createElement(text_1.Text, Object.assign({ as: Element }, layout_1.mergeStyles(elemProps, radioTextStyles({ variant, disabled }))), children));
|
|
28
48
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ExtractProps
|
|
1
|
+
import { ExtractProps } from '@workday/canvas-kit-react/common';
|
|
2
2
|
import { Box } from '@workday/canvas-kit-react/layout';
|
|
3
|
-
|
|
3
|
+
import { CSProps } from '@workday/canvas-kit-styling';
|
|
4
|
+
export interface StyledRadioButtonProps extends CSProps {
|
|
4
5
|
variant?: 'inverse' | undefined;
|
|
5
6
|
}
|
|
6
7
|
export interface StyledRadioButtonProps extends ExtractProps<typeof Box, 'input'> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StyledRadioButton.d.ts","sourceRoot":"","sources":["../../../../radio/lib/StyledRadioButton.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"StyledRadioButton.d.ts","sourceRoot":"","sources":["../../../../radio/lib/StyledRadioButton.tsx"],"names":[],"mappings":"AACA,OAAO,EAIL,YAAY,EACb,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAC,GAAG,EAAO,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAC,OAAO,EAA4C,MAAM,6BAA6B,CAAC;AAO/F,MAAM,WAAW,sBAAuB,SAAQ,OAAO;IACrD,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CACjC;AA8MD,MAAM,WAAW,sBAAuB,SAAQ,YAAY,CAAC,OAAO,GAAG,EAAE,OAAO,CAAC;IAC/E,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CACjC;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,8FAY5B,CAAC"}
|
|
@@ -6,109 +6,198 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.StyledRadioButton = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const common_1 = require("@workday/canvas-kit-react/common");
|
|
9
|
-
const tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
10
9
|
const layout_1 = require("@workday/canvas-kit-react/layout");
|
|
10
|
+
const canvas_kit_styling_1 = require("@workday/canvas-kit-styling");
|
|
11
|
+
const canvas_tokens_web_1 = require("@workday/canvas-tokens-web");
|
|
12
|
+
const RadioLabel_1 = require("./RadioLabel");
|
|
11
13
|
const radioWidth = 18;
|
|
12
14
|
const radioHeight = 18;
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
height: '18px',
|
|
21
|
-
width: '18px',
|
|
22
|
-
// Circle element styles the radio as checked or unchecked
|
|
23
|
-
'+ .cnvs-radio-check': {
|
|
24
|
-
display: 'flex',
|
|
25
|
-
flexDirection: 'column',
|
|
26
|
-
alignItems: 'center',
|
|
27
|
-
backgroundColor: disabled ? tokens_1.inputColors.disabled.background : tokens_1.colors.frenchVanilla100,
|
|
28
|
-
borderRadius: '999px',
|
|
29
|
-
boxSizing: 'border-box',
|
|
30
|
-
border: `1px solid`,
|
|
31
|
-
borderColor: disabled
|
|
32
|
-
? tokens_1.inputColors.disabled.border
|
|
33
|
-
: variant === 'inverse'
|
|
34
|
-
? tokens_1.colors.soap300
|
|
35
|
-
: tokens_1.inputColors.border,
|
|
36
|
-
height: '18px',
|
|
37
|
-
width: '18px',
|
|
38
|
-
justifyContent: 'center',
|
|
39
|
-
pointerEvents: 'none',
|
|
15
|
+
const radioInputStyles = canvas_kit_styling_1.createStencil({
|
|
16
|
+
base: {
|
|
17
|
+
cursor: 'pointer',
|
|
18
|
+
opacity: '1',
|
|
19
|
+
height: canvas_kit_styling_1.px2rem(radioHeight),
|
|
20
|
+
width: canvas_kit_styling_1.px2rem(radioWidth),
|
|
21
|
+
borderRadius: canvas_tokens_web_1.system.shape.round,
|
|
40
22
|
position: 'absolute',
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
:
|
|
48
|
-
|
|
49
|
-
:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
23
|
+
margin: '0',
|
|
24
|
+
'&:focus-visible, &.focus, &:active': {
|
|
25
|
+
outline: 'transparent',
|
|
26
|
+
},
|
|
27
|
+
'&:disabled, &.disabled': {
|
|
28
|
+
cursor: 'auto',
|
|
29
|
+
'+ .cnvs-radio-check': {
|
|
30
|
+
borderColor: canvas_tokens_web_1.base.licorice100,
|
|
31
|
+
backgroundColor: canvas_tokens_web_1.base.soap100,
|
|
32
|
+
},
|
|
33
|
+
'&:hover + .cnvs-radio-check, &.hover + .cnvs-radio-check': {
|
|
34
|
+
borderColor: canvas_tokens_web_1.base.licorice100,
|
|
35
|
+
},
|
|
36
|
+
// This creates the inner circle when the Radio is checked.
|
|
37
|
+
// The backgroundColor represents the dot in the middle of the radio.
|
|
38
|
+
// The borderColor represents the border around the middle dot of the radio.
|
|
39
|
+
'&:checked + .cnvs-radio-check, &.checked + .cnvs-radio-check': {
|
|
40
|
+
backgroundColor: canvas_tokens_web_1.brand.primary.accent,
|
|
41
|
+
border: `5px solid ${canvas_tokens_web_1.brand.primary.base}`, // inner circle border color
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
// Circle element styles the radio as checked or unchecked
|
|
45
|
+
'+ .cnvs-radio-check': {
|
|
46
|
+
display: 'flex',
|
|
47
|
+
flexDirection: 'column',
|
|
48
|
+
alignItems: 'center',
|
|
49
|
+
backgroundColor: canvas_tokens_web_1.base.frenchVanilla100,
|
|
50
|
+
borderRadius: canvas_tokens_web_1.system.shape.round,
|
|
51
|
+
boxSizing: 'border-box',
|
|
52
|
+
border: `${canvas_kit_styling_1.px2rem(1)} solid ${canvas_tokens_web_1.base.licorice200}`,
|
|
53
|
+
height: canvas_kit_styling_1.px2rem(radioHeight),
|
|
54
|
+
width: canvas_kit_styling_1.px2rem(radioWidth),
|
|
55
|
+
justifyContent: 'center',
|
|
56
|
+
pointerEvents: 'none',
|
|
57
|
+
position: 'absolute',
|
|
58
|
+
transition: 'border 200ms ease, background 200ms',
|
|
59
|
+
opacity: '1',
|
|
60
|
+
},
|
|
61
|
+
'&:hover + .cnvs-radio-check, &.hover + .cnvs-radio-check': {
|
|
62
|
+
borderColor: canvas_tokens_web_1.base.licorice500,
|
|
63
|
+
},
|
|
64
|
+
'&:focus-visible + .cnvs-radio-check, &.focus + .cnvs-radio-check': {
|
|
65
|
+
borderColor: canvas_tokens_web_1.base.blueberry400,
|
|
66
|
+
...common_1.focusRing({
|
|
67
|
+
width: 1,
|
|
68
|
+
separation: 0,
|
|
69
|
+
animate: false,
|
|
70
|
+
innerColor: canvas_tokens_web_1.base.frenchVanilla100,
|
|
71
|
+
outerColor: canvas_tokens_web_1.brand.common.focusOutline,
|
|
72
|
+
}),
|
|
73
|
+
},
|
|
74
|
+
'&:focus-visible:hover + .cnvs-radio-check, &.focus:hover + .cnvs-radio-check': {
|
|
75
|
+
outline: 'transparent',
|
|
76
|
+
},
|
|
77
|
+
// This creates the inner circle when the Radio is checked.
|
|
78
|
+
// The backgroundColor represents the dot in the middle of the radio.
|
|
79
|
+
// The borderColor represents the border around the middle dot of the radio.
|
|
80
|
+
'&:checked + .cnvs-radio-check, &.checked + .cnvs-radio-check': {
|
|
81
|
+
backgroundColor: canvas_tokens_web_1.brand.primary.accent,
|
|
82
|
+
border: `${canvas_kit_styling_1.px2rem(5)} solid ${canvas_tokens_web_1.brand.primary.base}`, // inner circle border color
|
|
83
|
+
},
|
|
84
|
+
'&:focus-visible:checked + .cnvs-radio-check, &:focus-visible:hover:checked + .cnvs-radio-check, &.focus:checked + .cnvs-radio-check, &.focus:hover:checked + .cnvs-radio-check': {
|
|
85
|
+
outline: 'transparent',
|
|
86
|
+
...common_1.focusRing({
|
|
87
|
+
width: 2,
|
|
88
|
+
separation: 2,
|
|
89
|
+
animate: false,
|
|
90
|
+
innerColor: canvas_tokens_web_1.base.frenchVanilla100,
|
|
91
|
+
outerColor: canvas_tokens_web_1.brand.common.focusOutline,
|
|
92
|
+
}),
|
|
93
|
+
},
|
|
62
94
|
},
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
95
|
+
modifiers: {
|
|
96
|
+
variant: {
|
|
97
|
+
inverse: {
|
|
98
|
+
'+ .cnvs-radio-check': {
|
|
99
|
+
backgroundColor: canvas_tokens_web_1.base.soap100,
|
|
100
|
+
borderColor: canvas_tokens_web_1.base.soap300,
|
|
101
|
+
},
|
|
102
|
+
'&:disabled, &.disabled': {
|
|
103
|
+
opacity: canvas_tokens_web_1.system.opacity.disabled,
|
|
104
|
+
'+ .cnvs-radio-check': {
|
|
105
|
+
backgroundColor: canvas_tokens_web_1.base.soap100,
|
|
106
|
+
borderColor: canvas_tokens_web_1.base.licorice100,
|
|
107
|
+
opacity: canvas_tokens_web_1.system.opacity.disabled,
|
|
108
|
+
},
|
|
109
|
+
// This creates the inner circle when the Radio is checked.
|
|
110
|
+
// The backgroundColor represents the dot in the middle of the radio.
|
|
111
|
+
// The borderColor represents the border around the middle dot of the radio.
|
|
112
|
+
'&:checked + .cnvs-radio-check, &.checked + .cnvs-radio-check': {
|
|
113
|
+
backgroundColor: canvas_tokens_web_1.brand.primary.base,
|
|
114
|
+
borderColor: canvas_tokens_web_1.base.frenchVanilla100, // inner circle border color
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
'&:hover + .cnvs-radio-check, &.hover + .cnvs-radio-check': {
|
|
118
|
+
borderColor: canvas_tokens_web_1.base.soap300,
|
|
119
|
+
},
|
|
120
|
+
'&:focus-visible + .cnvs-radio-check, &.focus + .cnvs-radio-check': {
|
|
121
|
+
borderColor: canvas_tokens_web_1.base.soap300,
|
|
122
|
+
},
|
|
123
|
+
// This creates the inner circle when the Radio is checked.
|
|
124
|
+
// The backgroundColor represents the dot in the middle of the radio.
|
|
125
|
+
// The borderColor represents the border around the middle dot of the radio.
|
|
126
|
+
'&:checked + .cnvs-radio-check, &.checked + .cnvs-radio-check': {
|
|
127
|
+
backgroundColor: canvas_tokens_web_1.brand.primary.base,
|
|
128
|
+
borderColor: canvas_tokens_web_1.base.frenchVanilla100, // inner circle border color
|
|
129
|
+
},
|
|
130
|
+
'&:focus-visible + .cnvs-radio-check, &:focus-visible:hover + .cnvs-radio-check, &.focus + .cnvs-radio-check, &.focus:hover + .cnvs-radio-check': {
|
|
131
|
+
...common_1.focusRing({
|
|
132
|
+
width: 2,
|
|
133
|
+
separation: 0,
|
|
134
|
+
innerColor: canvas_tokens_web_1.base.blackPepper400,
|
|
135
|
+
outerColor: canvas_tokens_web_1.base.frenchVanilla100,
|
|
136
|
+
}),
|
|
137
|
+
},
|
|
138
|
+
'&:focus-visible:checked + .cnvs-radio-check, &:focus-visible:hover:checked + .cnvs-radio-check, &.focus:checked + .cnvs-radio-check, &.focus:hover:checked + .cnvs-radio-check': {
|
|
139
|
+
...common_1.focusRing({
|
|
140
|
+
width: 2,
|
|
141
|
+
separation: 2,
|
|
142
|
+
innerColor: canvas_tokens_web_1.base.blackPepper400,
|
|
143
|
+
outerColor: canvas_tokens_web_1.base.frenchVanilla100,
|
|
144
|
+
}),
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
72
148
|
},
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
animate: false,
|
|
79
|
-
innerColor: variant === 'inverse' ? tokens_1.colors.blackPepper400 : tokens_1.colors.frenchVanilla100,
|
|
80
|
-
outerColor: variant === 'inverse' ? tokens_1.colors.frenchVanilla100 : themeFocusOutline,
|
|
81
|
-
}),
|
|
149
|
+
});
|
|
150
|
+
const StyledRadioInput = common_1.createComponent('input')({
|
|
151
|
+
displayName: 'StyledRadioInput',
|
|
152
|
+
Component: ({ children, variant, ...elemProps }, ref, Element) => {
|
|
153
|
+
return react_1.default.createElement(Element, Object.assign({ ref: ref }, canvas_kit_styling_1.handleCsProp(elemProps, radioInputStyles({ variant }))));
|
|
82
154
|
},
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
155
|
+
});
|
|
156
|
+
const radioInputWrapperStyles = canvas_kit_styling_1.createStencil({
|
|
157
|
+
base: {
|
|
158
|
+
height: canvas_kit_styling_1.px2rem(radioHeight),
|
|
159
|
+
width: canvas_kit_styling_1.px2rem(radioWidth),
|
|
160
|
+
flex: '0 0 auto',
|
|
161
|
+
// Hover Ripple element
|
|
162
|
+
'::before': {
|
|
163
|
+
content: "''",
|
|
164
|
+
position: 'absolute',
|
|
165
|
+
borderRadius: canvas_tokens_web_1.system.shape.round,
|
|
166
|
+
height: canvas_kit_styling_1.px2rem(radioHeight),
|
|
167
|
+
transition: 'box-shadow 150ms ease-out',
|
|
168
|
+
width: canvas_kit_styling_1.px2rem(radioWidth),
|
|
169
|
+
pointerEvents: 'none',
|
|
170
|
+
opacity: '1',
|
|
171
|
+
},
|
|
172
|
+
'&:hover:before, &.hover:before': {
|
|
173
|
+
boxShadow: `0 0 0 ${canvas_kit_styling_1.calc.subtract(canvas_tokens_web_1.system.space.x2, canvas_kit_styling_1.px2rem(1))} ${canvas_tokens_web_1.base.soap200}`,
|
|
89
174
|
},
|
|
90
|
-
}),
|
|
91
|
-
}));
|
|
92
|
-
const RadioInputWrapper = common_1.styled(layout_1.Flex)({
|
|
93
|
-
// Hover Ripple element
|
|
94
|
-
'::before': {
|
|
95
|
-
content: "''",
|
|
96
|
-
borderRadius: tokens_1.borderRadius.circle,
|
|
97
|
-
height: radioHeight,
|
|
98
|
-
transition: 'box-shadow 150ms ease-out',
|
|
99
|
-
width: radioWidth,
|
|
100
|
-
pointerEvents: 'none',
|
|
101
175
|
},
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
176
|
+
modifiers: {
|
|
177
|
+
variant: {
|
|
178
|
+
inverse: {
|
|
179
|
+
'::before': {
|
|
180
|
+
opacity: canvas_tokens_web_1.system.opacity.disabled,
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
disabled: {
|
|
185
|
+
true: {
|
|
186
|
+
'&:hover:before, &.hover:before': {
|
|
187
|
+
boxShadow: 'none',
|
|
188
|
+
cursor: 'auto',
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
},
|
|
105
192
|
},
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
193
|
+
});
|
|
194
|
+
const RadioInputWrapper = common_1.createComponent(layout_1.Flex)({
|
|
195
|
+
displayName: 'RadioInputWrapper',
|
|
196
|
+
Component: ({ children, variant, ...elemProps }, ref, Element) => {
|
|
197
|
+
const { disabled } = react_1.default.useContext(RadioLabel_1.RadioLabelContext);
|
|
198
|
+
return (react_1.default.createElement(Element, Object.assign({ ref: ref }, canvas_kit_styling_1.handleCsProp(elemProps, radioInputWrapperStyles({ variant, disabled }))), children));
|
|
110
199
|
},
|
|
111
|
-
})
|
|
200
|
+
});
|
|
112
201
|
/**
|
|
113
202
|
* Use `StyledRadioButton` when you want a styled radio button on its own without using `RadioGroup`.
|
|
114
203
|
* You will need to handle behavior and accessibility.
|
|
@@ -116,8 +205,8 @@ const RadioInputWrapper = common_1.styled(layout_1.Flex)({
|
|
|
116
205
|
exports.StyledRadioButton = common_1.createComponent('input')({
|
|
117
206
|
displayName: 'Radio',
|
|
118
207
|
Component: ({ ...elemProps }, ref, Element) => {
|
|
119
|
-
return (react_1.default.createElement(RadioInputWrapper, Object.assign({
|
|
120
|
-
react_1.default.createElement(StyledRadioInput, Object.assign({
|
|
208
|
+
return (react_1.default.createElement(RadioInputWrapper, Object.assign({}, elemProps),
|
|
209
|
+
react_1.default.createElement(StyledRadioInput, Object.assign({ type: "radio" }, elemProps)),
|
|
121
210
|
react_1.default.createElement("span", { className: "cnvs-radio-check" })));
|
|
122
211
|
},
|
|
123
212
|
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Themeable, ErrorType
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
import { Themeable, ErrorType } from '@workday/canvas-kit-react/common';
|
|
3
|
+
import { FlexProps } from '@workday/canvas-kit-react/layout';
|
|
4
|
+
import { CSProps } from '@workday/canvas-kit-styling';
|
|
5
|
+
export interface RadioGroupProps extends Themeable, CSProps, FlexProps {
|
|
5
6
|
/**
|
|
6
7
|
* The type of error associated with the RadioGroup (if applicable).
|
|
7
8
|
*/
|
|
@@ -17,9 +18,7 @@ export interface RadioGroupProps extends Themeable, ExtractProps<typeof Flex, ne
|
|
|
17
18
|
* </RadioGroup>
|
|
18
19
|
* ```
|
|
19
20
|
*/
|
|
20
|
-
export declare const RadioGroup: import("@workday/canvas-kit-react/common").ElementComponentM<
|
|
21
|
-
Item: import("@workday/canvas-kit-react/common").ElementComponent<"div", import("@workday/canvas-kit-react/layout").BackgroundStyleProps & import("@workday/canvas-kit-react/layout/lib/utils/border/color").BorderColorStyleProps & import("@workday/canvas-kit-react/layout/lib/utils/border/lineStyle").BorderLineStyleProps & import("@workday/canvas-kit-react/layout/lib/utils/border/radius").BorderRadiusStyleProps & import("@workday/canvas-kit-react/layout/lib/utils/border/shorthand").BorderShorthandStyleProps & import("@workday/canvas-kit-react/layout/lib/utils/border/width").BorderWidthStyleProps & import("@workday/canvas-kit-react/layout").ColorStyleProps & import("@workday/canvas-kit-react/layout").DepthStyleProps & import("@workday/canvas-kit-react/layout").FlexItemStyleProps & import("@workday/canvas-kit-react/layout").GridItemStyleProps & import("@workday/canvas-kit-react/layout").LayoutStyleProps & import("@workday/canvas-kit-react/layout").OtherStyleProps & import("@workday/canvas-kit-react/layout").PositionStyleProps & import("@workday/canvas-kit-react/layout").SpaceStyleProps & import("@workday/canvas-kit-react/layout").TextStyleProps & import("@workday/canvas-kit-styling").CSProps>;
|
|
22
|
-
}, RadioGroupProps & Partial<{
|
|
21
|
+
export declare const RadioGroup: import("@workday/canvas-kit-react/common").ElementComponentM<"div", RadioGroupProps & Partial<{
|
|
23
22
|
'aria-describedby': string | undefined;
|
|
24
23
|
name: string;
|
|
25
24
|
value: string | number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../../../../radio/lib/RadioGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,
|
|
1
|
+
{"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../../../../radio/lib/RadioGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAkB,SAAS,EAAE,SAAS,EAAC,MAAM,kCAAkC,CAAC;AAEvF,OAAO,EAAC,SAAS,EAAc,MAAM,kCAAkC,CAAC;AAGxE,OAAO,EAAgB,OAAO,EAAe,MAAM,6BAA6B,CAAC;AAGjF,MAAM,WAAW,eAAgB,SAAQ,SAAS,EAAE,OAAO,EAAE,SAAS;IACpE;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AA8BD;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;IAInB;;;;;;;;;;OAUG;;;;;;;;;;;IAEH;;;;;;;;;;;;OAYG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKL,CAAC"}
|
|
@@ -1,10 +1,36 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { createContainer
|
|
3
|
-
import { space } from '@workday/canvas-kit-react/tokens';
|
|
2
|
+
import { createContainer } from '@workday/canvas-kit-react/common';
|
|
4
3
|
import { useRadioModel } from './hooks/useRadioModel';
|
|
5
|
-
import {
|
|
4
|
+
import { mergeStyles } from '@workday/canvas-kit-react/layout';
|
|
6
5
|
import { RadioLabel } from './RadioLabel';
|
|
7
6
|
import { RadioButton } from './RadioButton';
|
|
7
|
+
import { createStencil, calc, px2rem } from '@workday/canvas-kit-styling';
|
|
8
|
+
import { brand, system } from '@workday/canvas-tokens-web';
|
|
9
|
+
/**
|
|
10
|
+
* Styles for RadioGroup
|
|
11
|
+
*/
|
|
12
|
+
const radioGroupStyles = createStencil({
|
|
13
|
+
base: {
|
|
14
|
+
display: 'flex',
|
|
15
|
+
flexDirection: 'column',
|
|
16
|
+
borderRadius: system.shape.x1,
|
|
17
|
+
gap: system.space.x2,
|
|
18
|
+
padding: `${px2rem(10)} ${system.space.x3} ${system.space.x2}`,
|
|
19
|
+
margin: `${calc.negate(system.space.x1)} ${calc.negate(system.space.x3)}`,
|
|
20
|
+
transition: '100ms box-shadow',
|
|
21
|
+
width: 'fit-content',
|
|
22
|
+
},
|
|
23
|
+
modifiers: {
|
|
24
|
+
error: {
|
|
25
|
+
error: {
|
|
26
|
+
boxShadow: `inset 0 0 0 ${px2rem(2)} ${brand.error.base}`,
|
|
27
|
+
},
|
|
28
|
+
alert: {
|
|
29
|
+
boxShadow: `inset 0 0 0 ${px2rem(1)} ${brand.alert.darkest}, inset 0 0 0 ${px2rem(3)} ${brand.alert.base}`,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
});
|
|
8
34
|
/**
|
|
9
35
|
* Use `RadioGroup` to group a collection of `RadioGroup.RadioButton` components under a common `name`.
|
|
10
36
|
*
|
|
@@ -15,7 +41,7 @@ import { RadioButton } from './RadioButton';
|
|
|
15
41
|
* </RadioGroup>
|
|
16
42
|
* ```
|
|
17
43
|
*/
|
|
18
|
-
export const RadioGroup = createContainer(
|
|
44
|
+
export const RadioGroup = createContainer('div')({
|
|
19
45
|
displayName: 'RadioGroup',
|
|
20
46
|
modelHook: useRadioModel,
|
|
21
47
|
subComponents: {
|
|
@@ -46,11 +72,6 @@ export const RadioGroup = createContainer(Flex)({
|
|
|
46
72
|
*/
|
|
47
73
|
Label: RadioLabel,
|
|
48
74
|
},
|
|
49
|
-
})(({ children, error, theme, ...elemProps }, Element
|
|
50
|
-
|
|
51
|
-
return (React.createElement(Flex, Object.assign({ as: Element, boxSizing: "border-box", flexDirection: "column", borderRadius: "m", paddingTop: "10px", paddingBottom: "8px", paddingX: "xs", gap: "xxs", marginY: `-${space.xxxs}`, transition: "100ms box-shadow", marginX: `-${space.xs}`, width: "fit-content", cs: {
|
|
52
|
-
boxShadow: errorColors.outer !== errorColors.inner
|
|
53
|
-
? `inset 0 0 0 1px ${errorColors.outer}, inset 0 0 0 3px ${errorColors.inner}`
|
|
54
|
-
: `inset 0 0 0 2px ${errorColors.inner}`,
|
|
55
|
-
} }, elemProps), children));
|
|
75
|
+
})(({ children, error, theme, ...elemProps }, Element) => {
|
|
76
|
+
return React.createElement(Element, Object.assign({}, mergeStyles(elemProps, radioGroupStyles({ error }))), children);
|
|
56
77
|
});
|