@workday/canvas-kit-preview-react 10.0.0-alpha.472-next.0 → 10.0.0-alpha.476-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/index.d.ts +1 -0
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +1 -0
- package/dist/commonjs/radio/index.d.ts +4 -0
- package/dist/commonjs/radio/index.d.ts.map +1 -0
- package/dist/commonjs/radio/index.js +15 -0
- package/dist/commonjs/radio/lib/RadioButton.d.ts +13 -0
- package/dist/commonjs/radio/lib/RadioButton.d.ts.map +1 -0
- package/dist/commonjs/radio/lib/RadioButton.js +18 -0
- package/dist/commonjs/radio/lib/RadioGroup.d.ts +103 -0
- package/dist/commonjs/radio/lib/RadioGroup.d.ts.map +1 -0
- package/dist/commonjs/radio/lib/RadioGroup.js +62 -0
- package/dist/commonjs/radio/lib/RadioInput.d.ts +13 -0
- package/dist/commonjs/radio/lib/RadioInput.d.ts.map +1 -0
- package/dist/commonjs/radio/lib/RadioInput.js +31 -0
- package/dist/commonjs/radio/lib/RadioLabel.d.ts +72 -0
- package/dist/commonjs/radio/lib/RadioLabel.d.ts.map +1 -0
- package/dist/commonjs/radio/lib/RadioLabel.js +48 -0
- package/dist/commonjs/radio/lib/RadioText.d.ts +12 -0
- package/dist/commonjs/radio/lib/RadioText.d.ts.map +1 -0
- package/dist/commonjs/radio/lib/RadioText.js +28 -0
- package/dist/commonjs/radio/lib/StyledRadioButton.d.ts +14 -0
- package/dist/commonjs/radio/lib/StyledRadioButton.d.ts.map +1 -0
- package/dist/commonjs/radio/lib/StyledRadioButton.js +122 -0
- package/dist/commonjs/radio/lib/hooks/useRadioModel.d.ts +106 -0
- package/dist/commonjs/radio/lib/hooks/useRadioModel.d.ts.map +1 -0
- package/dist/commonjs/radio/lib/hooks/useRadioModel.js +67 -0
- package/dist/es6/index.d.ts +1 -0
- package/dist/es6/index.d.ts.map +1 -1
- package/dist/es6/index.js +1 -0
- package/dist/es6/radio/index.d.ts +4 -0
- package/dist/es6/radio/index.d.ts.map +1 -0
- package/dist/es6/radio/index.js +3 -0
- package/dist/es6/radio/lib/RadioButton.d.ts +13 -0
- package/dist/es6/radio/lib/RadioButton.d.ts.map +1 -0
- package/dist/es6/radio/lib/RadioButton.js +12 -0
- package/dist/es6/radio/lib/RadioGroup.d.ts +103 -0
- package/dist/es6/radio/lib/RadioGroup.d.ts.map +1 -0
- package/dist/es6/radio/lib/RadioGroup.js +56 -0
- package/dist/es6/radio/lib/RadioInput.d.ts +13 -0
- package/dist/es6/radio/lib/RadioInput.d.ts.map +1 -0
- package/dist/es6/radio/lib/RadioInput.js +25 -0
- package/dist/es6/radio/lib/RadioLabel.d.ts +72 -0
- package/dist/es6/radio/lib/RadioLabel.d.ts.map +1 -0
- package/dist/es6/radio/lib/RadioLabel.js +42 -0
- package/dist/es6/radio/lib/RadioText.d.ts +12 -0
- package/dist/es6/radio/lib/RadioText.d.ts.map +1 -0
- package/dist/es6/radio/lib/RadioText.js +22 -0
- package/dist/es6/radio/lib/StyledRadioButton.d.ts +14 -0
- package/dist/es6/radio/lib/StyledRadioButton.d.ts.map +1 -0
- package/dist/es6/radio/lib/StyledRadioButton.js +116 -0
- package/dist/es6/radio/lib/hooks/useRadioModel.d.ts +106 -0
- package/dist/es6/radio/lib/hooks/useRadioModel.d.ts.map +1 -0
- package/dist/es6/radio/lib/hooks/useRadioModel.js +61 -0
- package/index.ts +1 -0
- package/package.json +3 -3
- package/radio/LICENSE +52 -0
- package/radio/README.md +36 -0
- package/radio/index.ts +3 -0
- package/radio/lib/RadioButton.tsx +17 -0
- package/radio/lib/RadioGroup.tsx +90 -0
- package/radio/lib/RadioInput.tsx +28 -0
- package/radio/lib/RadioLabel.tsx +72 -0
- package/radio/lib/RadioText.tsx +32 -0
- package/radio/lib/StyledRadioButton.tsx +178 -0
- package/radio/lib/hooks/useRadioModel.tsx +64 -0
- package/radio/package.json +6 -0
package/dist/commonjs/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
|
package/dist/commonjs/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../radio/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./lib/RadioGroup"), exports);
|
|
14
|
+
__exportStar(require("./lib/hooks/useRadioModel"), exports);
|
|
15
|
+
__exportStar(require("./lib/StyledRadioButton"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { RadioLabelProps } from './RadioLabel';
|
|
3
|
+
export declare const RadioButton: import("@workday/canvas-kit-react/common").ElementComponentM<"input", RadioLabelProps, {
|
|
4
|
+
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
5
|
+
state: {
|
|
6
|
+
value: string | number | undefined;
|
|
7
|
+
name: string;
|
|
8
|
+
'aria-describedby': string | undefined;
|
|
9
|
+
inputRef: React.MutableRefObject<HTMLInputElement | undefined>;
|
|
10
|
+
};
|
|
11
|
+
events: {};
|
|
12
|
+
}>;
|
|
13
|
+
//# sourceMappingURL=RadioButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioButton.d.ts","sourceRoot":"","sources":["../../../../radio/lib/RadioButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAC,eAAe,EAAC,MAAM,cAAc,CAAC;AAE7C,eAAO,MAAM,WAAW;;;;;;;;;EAUtB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.RadioButton = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
9
|
+
const useRadioModel_1 = require("./hooks/useRadioModel");
|
|
10
|
+
const RadioGroup_1 = require("./RadioGroup");
|
|
11
|
+
exports.RadioButton = common_1.createSubcomponent('input')({
|
|
12
|
+
displayName: 'Radio',
|
|
13
|
+
modelHook: useRadioModel_1.useRadioModel,
|
|
14
|
+
})(({ children, variant, ref, value, disabled, ...elemProps }) => {
|
|
15
|
+
return (react_1.default.createElement(RadioGroup_1.RadioGroup.Label, { variant: variant, disabled: disabled },
|
|
16
|
+
react_1.default.createElement(RadioGroup_1.RadioGroup.Label.Input, Object.assign({ value: value }, elemProps, { ref: ref })),
|
|
17
|
+
react_1.default.createElement(RadioGroup_1.RadioGroup.Label.Text, null, children)));
|
|
18
|
+
});
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Themeable, ErrorType, ExtractProps } from '@workday/canvas-kit-react/common';
|
|
3
|
+
import { Flex } from '@workday/canvas-kit-react/layout';
|
|
4
|
+
export interface RadioGroupProps extends Themeable, ExtractProps<typeof Flex, never> {
|
|
5
|
+
/**
|
|
6
|
+
* The type of error associated with the RadioGroup (if applicable).
|
|
7
|
+
*/
|
|
8
|
+
error?: ErrorType;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Use `RadioGroup` to group a collection of `RadioGroup.RadioButton` components under a common `name`.
|
|
12
|
+
*
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <RadioGroup name="pizza-crust" value="thin">
|
|
15
|
+
* <RadioGroup.RadioButton value="deep-dish">Deep dish</RadioGroup.RadioButton>
|
|
16
|
+
* <RadioGroup.RadioButton value="thin">Thin</RadioGroup.RadioButton>
|
|
17
|
+
* </RadioGroup>
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const RadioGroup: import("@workday/canvas-kit-react/common").ElementComponentM<import("@workday/canvas-kit-react/common").ElementComponent<"div", Omit<import("@workday/canvas-kit-react/layout").BoxProps, "display"> & import("@workday/canvas-kit-react/layout").FlexStyleProps> & {
|
|
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>;
|
|
22
|
+
}, RadioGroupProps & Partial<{
|
|
23
|
+
'aria-describedby': string | undefined;
|
|
24
|
+
name: string;
|
|
25
|
+
value: string | number | undefined;
|
|
26
|
+
onChange(event: React.ChangeEvent<HTMLInputElement>): void;
|
|
27
|
+
}> & {} & {}, {
|
|
28
|
+
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
29
|
+
state: {
|
|
30
|
+
value: string | number | undefined;
|
|
31
|
+
name: string;
|
|
32
|
+
'aria-describedby': string | undefined;
|
|
33
|
+
inputRef: React.MutableRefObject<HTMLInputElement | undefined>;
|
|
34
|
+
};
|
|
35
|
+
events: {};
|
|
36
|
+
}> & {
|
|
37
|
+
/**
|
|
38
|
+
* `RadioGroup.Radio` renders an `<input type="radio" />` and its associated `<label>` (using `children` as the label's contents).
|
|
39
|
+
* This component should satisfy most use cases; use `RadioGroup.Label` if you require more flexibility.
|
|
40
|
+
*
|
|
41
|
+
* ```tsx
|
|
42
|
+
* <RadioGroup name="pizza-crust" value="thin">
|
|
43
|
+
* <RadioGroup.RadioButton value="deep-dish">Deep dish</RadioGroup.RadioButton>
|
|
44
|
+
* <RadioGroup.RadioButton value="thin">Thin</RadioGroup.RadioButton>
|
|
45
|
+
* </RadioGroup>
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
RadioButton: import("@workday/canvas-kit-react/common").ElementComponentM<"input", import("./RadioLabel").RadioLabelProps, {
|
|
49
|
+
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
50
|
+
state: {
|
|
51
|
+
value: string | number | undefined;
|
|
52
|
+
name: string;
|
|
53
|
+
'aria-describedby': string | undefined;
|
|
54
|
+
inputRef: React.MutableRefObject<HTMLInputElement | undefined>;
|
|
55
|
+
};
|
|
56
|
+
events: {};
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Use `RadioGroup.Label` instead of `RadioGroup.Radio` if you need direct access to the label and the radio input.
|
|
60
|
+
* This will render a `<label>` that wraps an `<input type="radio" />` and a `<span>` for the label text.
|
|
61
|
+
*
|
|
62
|
+
* ```tsx
|
|
63
|
+
* <RadioGroup name"pizza-crust" value="deep-dish">
|
|
64
|
+
* <RadioGroup.Label>
|
|
65
|
+
* <RadioGroup.Label.Input value="deep-dish" />
|
|
66
|
+
* <RadioGroup.Label.Text>Deep dish</RadioGroup.Label.Text>
|
|
67
|
+
* </RadioGroup.Label>
|
|
68
|
+
* </RadioGroup>
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
Label: import("@workday/canvas-kit-react/common").ElementComponentM<"label", import("./RadioLabel").RadioLabelProps, {
|
|
72
|
+
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
73
|
+
state: {
|
|
74
|
+
value: string | number | undefined;
|
|
75
|
+
name: string;
|
|
76
|
+
'aria-describedby': string | undefined;
|
|
77
|
+
inputRef: React.MutableRefObject<HTMLInputElement | undefined>;
|
|
78
|
+
};
|
|
79
|
+
events: {};
|
|
80
|
+
}> & {
|
|
81
|
+
Input: import("@workday/canvas-kit-react/common").ElementComponentM<"input", import("./RadioLabel").RadioLabelProps, {
|
|
82
|
+
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
83
|
+
state: {
|
|
84
|
+
value: string | number | undefined;
|
|
85
|
+
name: string;
|
|
86
|
+
'aria-describedby': string | undefined;
|
|
87
|
+
inputRef: React.MutableRefObject<HTMLInputElement | undefined>;
|
|
88
|
+
};
|
|
89
|
+
events: {};
|
|
90
|
+
}>;
|
|
91
|
+
Text: import("@workday/canvas-kit-react/common").ElementComponentM<"span", import("@workday/canvas-kit-react/text").TextProps & React.HTMLAttributes<HTMLSpanElement>, {
|
|
92
|
+
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
93
|
+
state: {
|
|
94
|
+
value: string | number | undefined;
|
|
95
|
+
name: string;
|
|
96
|
+
'aria-describedby': string | undefined;
|
|
97
|
+
inputRef: React.MutableRefObject<HTMLInputElement | undefined>;
|
|
98
|
+
};
|
|
99
|
+
events: {};
|
|
100
|
+
}>;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=RadioGroup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../../../../radio/lib/RadioGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAEL,SAAS,EACT,SAAS,EAET,YAAY,EACb,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAAC,IAAI,EAAC,MAAM,kCAAkC,CAAC;AAItD,MAAM,WAAW,eAAgB,SAAQ,SAAS,EAAE,YAAY,CAAC,OAAO,IAAI,EAAE,KAAK,CAAC;IAClF;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;IAInB;;;;;;;;;;OAUG;;;;;;;;;;;IAEH;;;;;;;;;;;;OAYG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BL,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.RadioGroup = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
9
|
+
const tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
10
|
+
const useRadioModel_1 = require("./hooks/useRadioModel");
|
|
11
|
+
const layout_1 = require("@workday/canvas-kit-react/layout");
|
|
12
|
+
const RadioLabel_1 = require("./RadioLabel");
|
|
13
|
+
const RadioButton_1 = require("./RadioButton");
|
|
14
|
+
/**
|
|
15
|
+
* Use `RadioGroup` to group a collection of `RadioGroup.RadioButton` components under a common `name`.
|
|
16
|
+
*
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <RadioGroup name="pizza-crust" value="thin">
|
|
19
|
+
* <RadioGroup.RadioButton value="deep-dish">Deep dish</RadioGroup.RadioButton>
|
|
20
|
+
* <RadioGroup.RadioButton value="thin">Thin</RadioGroup.RadioButton>
|
|
21
|
+
* </RadioGroup>
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
exports.RadioGroup = common_1.createContainer(layout_1.Flex)({
|
|
25
|
+
displayName: 'RadioGroup',
|
|
26
|
+
modelHook: useRadioModel_1.useRadioModel,
|
|
27
|
+
subComponents: {
|
|
28
|
+
/**
|
|
29
|
+
* `RadioGroup.Radio` renders an `<input type="radio" />` and its associated `<label>` (using `children` as the label's contents).
|
|
30
|
+
* This component should satisfy most use cases; use `RadioGroup.Label` if you require more flexibility.
|
|
31
|
+
*
|
|
32
|
+
* ```tsx
|
|
33
|
+
* <RadioGroup name="pizza-crust" value="thin">
|
|
34
|
+
* <RadioGroup.RadioButton value="deep-dish">Deep dish</RadioGroup.RadioButton>
|
|
35
|
+
* <RadioGroup.RadioButton value="thin">Thin</RadioGroup.RadioButton>
|
|
36
|
+
* </RadioGroup>
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
RadioButton: RadioButton_1.RadioButton,
|
|
40
|
+
/**
|
|
41
|
+
* Use `RadioGroup.Label` instead of `RadioGroup.Radio` if you need direct access to the label and the radio input.
|
|
42
|
+
* This will render a `<label>` that wraps an `<input type="radio" />` and a `<span>` for the label text.
|
|
43
|
+
*
|
|
44
|
+
* ```tsx
|
|
45
|
+
* <RadioGroup name"pizza-crust" value="deep-dish">
|
|
46
|
+
* <RadioGroup.Label>
|
|
47
|
+
* <RadioGroup.Label.Input value="deep-dish" />
|
|
48
|
+
* <RadioGroup.Label.Text>Deep dish</RadioGroup.Label.Text>
|
|
49
|
+
* </RadioGroup.Label>
|
|
50
|
+
* </RadioGroup>
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
Label: RadioLabel_1.RadioLabel,
|
|
54
|
+
},
|
|
55
|
+
})(({ children, error, theme, ...elemProps }, Element, model) => {
|
|
56
|
+
const errorColors = common_1.getErrorColors(error, theme);
|
|
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", style: {
|
|
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));
|
|
62
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { RadioLabelProps } from './RadioLabel';
|
|
3
|
+
export declare const RadioInput: import("@workday/canvas-kit-react/common").ElementComponentM<"input", RadioLabelProps, {
|
|
4
|
+
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
5
|
+
state: {
|
|
6
|
+
value: string | number | undefined;
|
|
7
|
+
name: string;
|
|
8
|
+
'aria-describedby': string | undefined;
|
|
9
|
+
inputRef: React.MutableRefObject<HTMLInputElement | undefined>;
|
|
10
|
+
};
|
|
11
|
+
events: {};
|
|
12
|
+
}>;
|
|
13
|
+
//# sourceMappingURL=RadioInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioInput.d.ts","sourceRoot":"","sources":["../../../../radio/lib/RadioInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAC,eAAe,EAAoB,MAAM,cAAc,CAAC;AAmBhE,eAAO,MAAM,UAAU;;;;;;;;;EAKrB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.RadioInput = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
9
|
+
const useRadioModel_1 = require("./hooks/useRadioModel");
|
|
10
|
+
const RadioLabel_1 = require("./RadioLabel");
|
|
11
|
+
const StyledRadioButton_1 = require("./StyledRadioButton");
|
|
12
|
+
const useRadioInput = common_1.createElemPropsHook(useRadioModel_1.useRadioModel)((model, _ref, elemProps = {}) => {
|
|
13
|
+
const { disabled, variant } = react_1.default.useContext(RadioLabel_1.RadioLabelContext);
|
|
14
|
+
return {
|
|
15
|
+
'aria-describedby': model.state['aria-describedby'],
|
|
16
|
+
disabled: disabled,
|
|
17
|
+
variant: variant,
|
|
18
|
+
checked: elemProps.value === model.state.value,
|
|
19
|
+
'aria-checked': elemProps.value === model.state.value,
|
|
20
|
+
onChange(event) {
|
|
21
|
+
model.onChange(event);
|
|
22
|
+
},
|
|
23
|
+
name: model.state.name,
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
exports.RadioInput = common_1.createSubcomponent('input')({
|
|
27
|
+
modelHook: useRadioModel_1.useRadioModel,
|
|
28
|
+
elemPropsHook: useRadioInput,
|
|
29
|
+
})(({ ...elemProps }, _Element, _model) => {
|
|
30
|
+
return react_1.default.createElement(StyledRadioButton_1.StyledRadioButton, Object.assign({}, elemProps));
|
|
31
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Themeable, ExtractProps } from '@workday/canvas-kit-react/common';
|
|
3
|
+
import { Flex } from '@workday/canvas-kit-react/layout';
|
|
4
|
+
interface RadioLabelContextInterface {
|
|
5
|
+
disabled?: boolean | undefined;
|
|
6
|
+
variant?: 'inverse' | undefined;
|
|
7
|
+
value?: string | number;
|
|
8
|
+
}
|
|
9
|
+
export interface RadioLabelProps extends Themeable, ExtractProps<typeof Flex, never>, RadioLabelContextInterface {
|
|
10
|
+
/**
|
|
11
|
+
* The Radio input and label children of RadioLabel
|
|
12
|
+
*/
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export declare const RadioLabelContext: React.Context<RadioLabelContextInterface>;
|
|
16
|
+
export declare const RadioLabel: import("@workday/canvas-kit-react/common").ElementComponentM<"label", RadioLabelProps, {
|
|
17
|
+
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
18
|
+
state: {
|
|
19
|
+
value: string | number | undefined;
|
|
20
|
+
name: string;
|
|
21
|
+
'aria-describedby': string | undefined;
|
|
22
|
+
inputRef: React.MutableRefObject<HTMLInputElement | undefined>;
|
|
23
|
+
};
|
|
24
|
+
events: {};
|
|
25
|
+
}> & {
|
|
26
|
+
/**
|
|
27
|
+
* Use `RadioGroup.Label.Input` within a `RadioGroup.Label` to render the input portion of a radio button.
|
|
28
|
+
*
|
|
29
|
+
* ```tsx
|
|
30
|
+
* <RadioGroup name"pizza-crust" value="deep-dish">
|
|
31
|
+
* <RadioGroup.Label>
|
|
32
|
+
* <RadioGroup.Label.Input value="deep-dish" />
|
|
33
|
+
* <RadioGroup.Label.Text>Deep dish</RadioGroup.Label.Text>
|
|
34
|
+
* </RadioGroup.Label>
|
|
35
|
+
* </RadioGroup>
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
Input: import("@workday/canvas-kit-react/common").ElementComponentM<"input", RadioLabelProps, {
|
|
39
|
+
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
40
|
+
state: {
|
|
41
|
+
value: string | number | undefined;
|
|
42
|
+
name: string;
|
|
43
|
+
'aria-describedby': string | undefined;
|
|
44
|
+
inputRef: React.MutableRefObject<HTMLInputElement | undefined>;
|
|
45
|
+
};
|
|
46
|
+
events: {};
|
|
47
|
+
}>;
|
|
48
|
+
/**
|
|
49
|
+
* Use `RadioGroup.Label.Text` within a `RadioGroup.Label` to render the label text portion of a radio button.
|
|
50
|
+
*
|
|
51
|
+
* ```tsx
|
|
52
|
+
* <RadioGroup name"pizza-crust" value="deep-dish">
|
|
53
|
+
* <RadioGroup.Label>
|
|
54
|
+
* <RadioGroup.Label.Input value="deep-dish" />
|
|
55
|
+
* <RadioGroup.Label.Text>Deep dish</RadioGroup.Label.Text>
|
|
56
|
+
* </RadioGroup.Label>
|
|
57
|
+
* </RadioGroup>
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
Text: import("@workday/canvas-kit-react/common").ElementComponentM<"span", import("@workday/canvas-kit-react/text").TextProps & React.HTMLAttributes<HTMLSpanElement>, {
|
|
61
|
+
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
62
|
+
state: {
|
|
63
|
+
value: string | number | undefined;
|
|
64
|
+
name: string;
|
|
65
|
+
'aria-describedby': string | undefined;
|
|
66
|
+
inputRef: React.MutableRefObject<HTMLInputElement | undefined>;
|
|
67
|
+
};
|
|
68
|
+
events: {};
|
|
69
|
+
}>;
|
|
70
|
+
};
|
|
71
|
+
export {};
|
|
72
|
+
//# sourceMappingURL=RadioLabel.d.ts.map
|
|
@@ -0,0 +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,EAAC,MAAM,kCAAkC,CAAC;AAItD,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,YAAY,CAAC,OAAO,IAAI,EAAE,KAAK,CAAC,EAChC,0BAA0B;IAC5B;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,eAAO,MAAM,iBAAiB,2CAAwD,CAAC;AAEvF,eAAO,MAAM,UAAU;;;;;;;;;;IAInB;;;;;;;;;;;OAWG;;;;;;;;;;;IAEH;;;;;;;;;;;OAWG;;;;;;;;;;;CAkBL,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.RadioLabel = exports.RadioLabelContext = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
9
|
+
const useRadioModel_1 = require("./hooks/useRadioModel");
|
|
10
|
+
const layout_1 = require("@workday/canvas-kit-react/layout");
|
|
11
|
+
const RadioInput_1 = require("./RadioInput");
|
|
12
|
+
const RadioText_1 = require("./RadioText");
|
|
13
|
+
exports.RadioLabelContext = react_1.default.createContext({});
|
|
14
|
+
exports.RadioLabel = common_1.createSubcomponent('label')({
|
|
15
|
+
displayName: 'Radio.Label',
|
|
16
|
+
modelHook: useRadioModel_1.useRadioModel,
|
|
17
|
+
subComponents: {
|
|
18
|
+
/**
|
|
19
|
+
* Use `RadioGroup.Label.Input` within a `RadioGroup.Label` to render the input portion of a radio button.
|
|
20
|
+
*
|
|
21
|
+
* ```tsx
|
|
22
|
+
* <RadioGroup name"pizza-crust" value="deep-dish">
|
|
23
|
+
* <RadioGroup.Label>
|
|
24
|
+
* <RadioGroup.Label.Input value="deep-dish" />
|
|
25
|
+
* <RadioGroup.Label.Text>Deep dish</RadioGroup.Label.Text>
|
|
26
|
+
* </RadioGroup.Label>
|
|
27
|
+
* </RadioGroup>
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
Input: RadioInput_1.RadioInput,
|
|
31
|
+
/**
|
|
32
|
+
* Use `RadioGroup.Label.Text` within a `RadioGroup.Label` to render the label text portion of a radio button.
|
|
33
|
+
*
|
|
34
|
+
* ```tsx
|
|
35
|
+
* <RadioGroup name"pizza-crust" value="deep-dish">
|
|
36
|
+
* <RadioGroup.Label>
|
|
37
|
+
* <RadioGroup.Label.Input value="deep-dish" />
|
|
38
|
+
* <RadioGroup.Label.Text>Deep dish</RadioGroup.Label.Text>
|
|
39
|
+
* </RadioGroup.Label>
|
|
40
|
+
* </RadioGroup>
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
Text: RadioText_1.RadioText,
|
|
44
|
+
},
|
|
45
|
+
})(({ children, variant, disabled, value, ...elemProps }, Element, model) => {
|
|
46
|
+
return (react_1.default.createElement(exports.RadioLabelContext.Provider, { value: { variant, disabled } },
|
|
47
|
+
react_1.default.createElement(layout_1.Flex, Object.assign({ as: Element, alignItems: "flex-start", minHeight: "m", position: "relative", gap: "xs" }, elemProps), children)));
|
|
48
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const RadioText: import("@workday/canvas-kit-react/common").ElementComponentM<"span", import("@workday/canvas-kit-react/text").TextProps & React.HTMLAttributes<HTMLSpanElement>, {
|
|
3
|
+
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
4
|
+
state: {
|
|
5
|
+
value: string | number | undefined;
|
|
6
|
+
name: string;
|
|
7
|
+
'aria-describedby': string | undefined;
|
|
8
|
+
inputRef: React.MutableRefObject<HTMLInputElement | undefined>;
|
|
9
|
+
};
|
|
10
|
+
events: {};
|
|
11
|
+
}>;
|
|
12
|
+
//# sourceMappingURL=RadioText.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioText.d.ts","sourceRoot":"","sources":["../../../../radio/lib/RadioText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,eAAO,MAAM,SAAS;;;;;;;;;EAwBpB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.RadioText = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
9
|
+
const tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
10
|
+
const useRadioModel_1 = require("./hooks/useRadioModel");
|
|
11
|
+
const RadioLabel_1 = require("./RadioLabel");
|
|
12
|
+
const text_1 = require("@workday/canvas-kit-react/text");
|
|
13
|
+
exports.RadioText = common_1.createSubcomponent('span')({
|
|
14
|
+
displayName: 'RadioButton.Text',
|
|
15
|
+
modelHook: useRadioModel_1.useRadioModel,
|
|
16
|
+
})(({ children, ...elemProps }, Element) => {
|
|
17
|
+
const { disabled, variant } = react_1.default.useContext(RadioLabel_1.RadioLabelContext);
|
|
18
|
+
const inverse = variant === 'inverse';
|
|
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));
|
|
28
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ExtractProps, Themeable } from '@workday/canvas-kit-react/common';
|
|
2
|
+
import { Box } from '@workday/canvas-kit-react/layout';
|
|
3
|
+
export interface StyledRadioButtonProps extends ExtractProps<typeof Box, 'input'>, Themeable {
|
|
4
|
+
variant?: 'inverse' | undefined;
|
|
5
|
+
}
|
|
6
|
+
export interface StyledRadioButtonProps extends ExtractProps<typeof Box, 'input'> {
|
|
7
|
+
variant?: 'inverse' | undefined;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Use `StyledRadioButton` when you want a styled radio button on its own without using `RadioGroup`.
|
|
11
|
+
* You will need to handle behavior and accessibility.
|
|
12
|
+
*/
|
|
13
|
+
export declare const StyledRadioButton: import("@workday/canvas-kit-react/common").ElementComponent<"input", StyledRadioButtonProps>;
|
|
14
|
+
//# sourceMappingURL=StyledRadioButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StyledRadioButton.d.ts","sourceRoot":"","sources":["../../../../radio/lib/StyledRadioButton.tsx"],"names":[],"mappings":"AACA,OAAO,EAML,YAAY,EACZ,SAAS,EACV,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAAC,GAAG,EAAO,MAAM,kCAAkC,CAAC;AAM3D,MAAM,WAAW,sBAAuB,SAAQ,YAAY,CAAC,OAAO,GAAG,EAAE,OAAO,CAAC,EAAE,SAAS;IAC1F,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CACjC;AA8HD,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,8FAuB5B,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.StyledRadioButton = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
9
|
+
const tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
10
|
+
const layout_1 = require("@workday/canvas-kit-react/layout");
|
|
11
|
+
const radioWidth = 18;
|
|
12
|
+
const rippleRadius = (tokens_1.spaceNumbers.l - radioWidth) / 2;
|
|
13
|
+
const radioHeight = 18;
|
|
14
|
+
const StyledRadioInput = common_1.styled(layout_1.Box.as('input'))({
|
|
15
|
+
'&:focus, &:active': {
|
|
16
|
+
outline: 'transparent',
|
|
17
|
+
},
|
|
18
|
+
}, ({ disabled, variant, theme: { canvas: { palette: { primary: themePrimary, common: { focusOutline: themeFocusOutline }, }, }, }, }) => ({
|
|
19
|
+
cursor: !disabled ? 'pointer' : undefined,
|
|
20
|
+
opacity: disabled && variant === 'inverse' ? '.4' : '1',
|
|
21
|
+
height: '18px',
|
|
22
|
+
width: '18px',
|
|
23
|
+
// Circle element styles the radio as checked or unchecked
|
|
24
|
+
'+ .cnvs-radio-check': {
|
|
25
|
+
display: 'flex',
|
|
26
|
+
flexDirection: 'column',
|
|
27
|
+
alignItems: 'center',
|
|
28
|
+
backgroundColor: disabled ? tokens_1.inputColors.disabled.background : tokens_1.colors.frenchVanilla100,
|
|
29
|
+
borderRadius: '999px',
|
|
30
|
+
boxSizing: 'border-box',
|
|
31
|
+
border: `1px solid`,
|
|
32
|
+
borderColor: disabled
|
|
33
|
+
? tokens_1.inputColors.disabled.border
|
|
34
|
+
: variant === 'inverse'
|
|
35
|
+
? tokens_1.colors.soap300
|
|
36
|
+
: tokens_1.inputColors.border,
|
|
37
|
+
height: '18px',
|
|
38
|
+
width: '18px',
|
|
39
|
+
justifyContent: 'center',
|
|
40
|
+
pointerEvents: 'none',
|
|
41
|
+
position: 'absolute',
|
|
42
|
+
transition: 'border 200ms ease, background 200ms',
|
|
43
|
+
opacity: disabled && variant === 'inverse' ? '.4' : '1',
|
|
44
|
+
},
|
|
45
|
+
'&:hover + .cnvs-radio-check': {
|
|
46
|
+
borderColor: disabled
|
|
47
|
+
? tokens_1.inputColors.disabled.border
|
|
48
|
+
: variant === 'inverse'
|
|
49
|
+
? tokens_1.colors.soap300
|
|
50
|
+
: tokens_1.colors.licorice500,
|
|
51
|
+
},
|
|
52
|
+
'&:focus + .cnvs-radio-check': {
|
|
53
|
+
borderColor: disabled
|
|
54
|
+
? tokens_1.inputColors.disabled.border
|
|
55
|
+
: variant === 'inverse'
|
|
56
|
+
? tokens_1.colors.soap300
|
|
57
|
+
: tokens_1.colors.blueberry400,
|
|
58
|
+
},
|
|
59
|
+
'&:checked + .cnvs-radio-check': {
|
|
60
|
+
backgroundColor: variant === 'inverse' ? themePrimary.main : themePrimary.contrast,
|
|
61
|
+
border: `5px solid`,
|
|
62
|
+
borderColor: variant === 'inverse' ? tokens_1.colors.frenchVanilla100 : themePrimary.main, // outer circle color
|
|
63
|
+
},
|
|
64
|
+
'&:focus + .cnvs-radio-check, &:focus:hover + .cnvs-radio-check': {
|
|
65
|
+
outline: 'transparent',
|
|
66
|
+
...common_1.focusRing({
|
|
67
|
+
width: variant === 'inverse' ? 2 : 1,
|
|
68
|
+
separation: 0,
|
|
69
|
+
animate: false,
|
|
70
|
+
innerColor: variant === 'inverse' ? tokens_1.colors.blackPepper400 : tokens_1.colors.frenchVanilla100,
|
|
71
|
+
outerColor: variant === 'inverse' ? tokens_1.colors.frenchVanilla100 : themeFocusOutline,
|
|
72
|
+
}),
|
|
73
|
+
},
|
|
74
|
+
'&:focus:checked + .cnvs-radio-check, &:focus:hover:checked + .cnvs-radio-check': {
|
|
75
|
+
outline: 'transparent',
|
|
76
|
+
...common_1.focusRing({
|
|
77
|
+
width: 2,
|
|
78
|
+
separation: 2,
|
|
79
|
+
animate: false,
|
|
80
|
+
innerColor: variant === 'inverse' ? tokens_1.colors.blackPepper400 : tokens_1.colors.frenchVanilla100,
|
|
81
|
+
outerColor: variant === 'inverse' ? tokens_1.colors.frenchVanilla100 : themeFocusOutline,
|
|
82
|
+
}),
|
|
83
|
+
},
|
|
84
|
+
...common_1.mouseFocusBehavior({
|
|
85
|
+
'&:focus + .cnvs-radio-check, &:focus:hover + .cnvs-radio-check, &:focus:active + .cnvs-radio-check, &:focus:hover:checked + .cnvs-radio-check, &:focus:active:checked + .cnvs-radio-check': {
|
|
86
|
+
...common_1.focusRing({
|
|
87
|
+
width: 0,
|
|
88
|
+
outerColor: variant === 'inverse' ? tokens_1.colors.frenchVanilla100 : themeFocusOutline,
|
|
89
|
+
}),
|
|
90
|
+
},
|
|
91
|
+
}),
|
|
92
|
+
}));
|
|
93
|
+
const RadioInputWrapper = common_1.styled(layout_1.Flex)({
|
|
94
|
+
// Hover Ripple element
|
|
95
|
+
'::before': {
|
|
96
|
+
content: "''",
|
|
97
|
+
borderRadius: tokens_1.borderRadius.circle,
|
|
98
|
+
height: radioHeight,
|
|
99
|
+
transition: 'box-shadow 150ms ease-out',
|
|
100
|
+
width: radioWidth,
|
|
101
|
+
pointerEvents: 'none',
|
|
102
|
+
},
|
|
103
|
+
}, ({ variant, disabled }) => ({
|
|
104
|
+
'::before': {
|
|
105
|
+
opacity: variant === 'inverse' ? '0.4' : '1',
|
|
106
|
+
},
|
|
107
|
+
'&:hover:before': {
|
|
108
|
+
boxShadow: !disabled ? `0 0 0 ${rippleRadius}px ${tokens_1.colors.soap200}` : undefined,
|
|
109
|
+
},
|
|
110
|
+
}));
|
|
111
|
+
/**
|
|
112
|
+
* Use `StyledRadioButton` when you want a styled radio button on its own without using `RadioGroup`.
|
|
113
|
+
* You will need to handle behavior and accessibility.
|
|
114
|
+
*/
|
|
115
|
+
exports.StyledRadioButton = common_1.createComponent('input')({
|
|
116
|
+
displayName: 'Radio',
|
|
117
|
+
Component: ({ ...elemProps }, ref, Element) => {
|
|
118
|
+
return (react_1.default.createElement(RadioInputWrapper, Object.assign({ height: "18px", width: "18px", flex: "0 0 auto" }, elemProps),
|
|
119
|
+
react_1.default.createElement(StyledRadioInput, Object.assign({ borderRadius: "circle", position: "absolute", margin: "zero", as: Element, type: "radio", ref: ref }, elemProps)),
|
|
120
|
+
react_1.default.createElement("span", { className: "cnvs-radio-check" })));
|
|
121
|
+
},
|
|
122
|
+
});
|