@workday/canvas-kit-preview-react 9.1.0-473-next.0 → 9.1.0-477-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.
Files changed (67) hide show
  1. package/dist/commonjs/index.d.ts +1 -0
  2. package/dist/commonjs/index.d.ts.map +1 -1
  3. package/dist/commonjs/index.js +1 -0
  4. package/dist/commonjs/radio/index.d.ts +4 -0
  5. package/dist/commonjs/radio/index.d.ts.map +1 -0
  6. package/dist/commonjs/radio/index.js +15 -0
  7. package/dist/commonjs/radio/lib/RadioButton.d.ts +13 -0
  8. package/dist/commonjs/radio/lib/RadioButton.d.ts.map +1 -0
  9. package/dist/commonjs/radio/lib/RadioButton.js +18 -0
  10. package/dist/commonjs/radio/lib/RadioGroup.d.ts +103 -0
  11. package/dist/commonjs/radio/lib/RadioGroup.d.ts.map +1 -0
  12. package/dist/commonjs/radio/lib/RadioGroup.js +62 -0
  13. package/dist/commonjs/radio/lib/RadioInput.d.ts +13 -0
  14. package/dist/commonjs/radio/lib/RadioInput.d.ts.map +1 -0
  15. package/dist/commonjs/radio/lib/RadioInput.js +31 -0
  16. package/dist/commonjs/radio/lib/RadioLabel.d.ts +72 -0
  17. package/dist/commonjs/radio/lib/RadioLabel.d.ts.map +1 -0
  18. package/dist/commonjs/radio/lib/RadioLabel.js +48 -0
  19. package/dist/commonjs/radio/lib/RadioText.d.ts +12 -0
  20. package/dist/commonjs/radio/lib/RadioText.d.ts.map +1 -0
  21. package/dist/commonjs/radio/lib/RadioText.js +28 -0
  22. package/dist/commonjs/radio/lib/StyledRadioButton.d.ts +14 -0
  23. package/dist/commonjs/radio/lib/StyledRadioButton.d.ts.map +1 -0
  24. package/dist/commonjs/radio/lib/StyledRadioButton.js +122 -0
  25. package/dist/commonjs/radio/lib/hooks/useRadioModel.d.ts +106 -0
  26. package/dist/commonjs/radio/lib/hooks/useRadioModel.d.ts.map +1 -0
  27. package/dist/commonjs/radio/lib/hooks/useRadioModel.js +67 -0
  28. package/dist/es6/index.d.ts +1 -0
  29. package/dist/es6/index.d.ts.map +1 -1
  30. package/dist/es6/index.js +1 -0
  31. package/dist/es6/radio/index.d.ts +4 -0
  32. package/dist/es6/radio/index.d.ts.map +1 -0
  33. package/dist/es6/radio/index.js +3 -0
  34. package/dist/es6/radio/lib/RadioButton.d.ts +13 -0
  35. package/dist/es6/radio/lib/RadioButton.d.ts.map +1 -0
  36. package/dist/es6/radio/lib/RadioButton.js +12 -0
  37. package/dist/es6/radio/lib/RadioGroup.d.ts +103 -0
  38. package/dist/es6/radio/lib/RadioGroup.d.ts.map +1 -0
  39. package/dist/es6/radio/lib/RadioGroup.js +56 -0
  40. package/dist/es6/radio/lib/RadioInput.d.ts +13 -0
  41. package/dist/es6/radio/lib/RadioInput.d.ts.map +1 -0
  42. package/dist/es6/radio/lib/RadioInput.js +25 -0
  43. package/dist/es6/radio/lib/RadioLabel.d.ts +72 -0
  44. package/dist/es6/radio/lib/RadioLabel.d.ts.map +1 -0
  45. package/dist/es6/radio/lib/RadioLabel.js +42 -0
  46. package/dist/es6/radio/lib/RadioText.d.ts +12 -0
  47. package/dist/es6/radio/lib/RadioText.d.ts.map +1 -0
  48. package/dist/es6/radio/lib/RadioText.js +22 -0
  49. package/dist/es6/radio/lib/StyledRadioButton.d.ts +14 -0
  50. package/dist/es6/radio/lib/StyledRadioButton.d.ts.map +1 -0
  51. package/dist/es6/radio/lib/StyledRadioButton.js +116 -0
  52. package/dist/es6/radio/lib/hooks/useRadioModel.d.ts +106 -0
  53. package/dist/es6/radio/lib/hooks/useRadioModel.d.ts.map +1 -0
  54. package/dist/es6/radio/lib/hooks/useRadioModel.js +61 -0
  55. package/index.ts +1 -0
  56. package/package.json +3 -3
  57. package/radio/LICENSE +52 -0
  58. package/radio/README.md +36 -0
  59. package/radio/index.ts +3 -0
  60. package/radio/lib/RadioButton.tsx +17 -0
  61. package/radio/lib/RadioGroup.tsx +90 -0
  62. package/radio/lib/RadioInput.tsx +28 -0
  63. package/radio/lib/RadioLabel.tsx +72 -0
  64. package/radio/lib/RadioText.tsx +32 -0
  65. package/radio/lib/StyledRadioButton.tsx +178 -0
  66. package/radio/lib/hooks/useRadioModel.tsx +64 -0
  67. package/radio/package.json +6 -0
@@ -0,0 +1,106 @@
1
+ import React from 'react';
2
+ export declare const useRadioModel: (<TT_Special_Generic>(config?: (Partial<{
3
+ /**
4
+ * Use this attribute when you have a `FormField` that is in an `Alert` | `Error` or `Required` state. This will add attach an `aria-describedby` to each radio input so that screen readers can read out the message attached to the form field.
5
+ * The value of this attribute needs to match the value passed to `hintId` on the `FormField`.
6
+ *
7
+ * ```tsx
8
+ * <FormField
9
+ * error={FormField.ErrorType.Alert}
10
+ * hintId="hint-alert"
11
+ * hintText="Deep dish is an extra $2.99"
12
+ * label="Choose Your Pizza Crust"
13
+ * useFieldset={true}
14
+ * >
15
+ * <RadioGroup
16
+ * name="crust"
17
+ * onChange={handleChange}
18
+ * initialValue={value}
19
+ * aria-describedby="hint-alert"
20
+ * >
21
+ * <RadioGroup.RadioButton value="deep-dish">Deep dish</RadioGroup.RadioButton>
22
+ * <RadioGroup.RadioButton value="thin">Thin</RadioGroup.RadioButton>
23
+ * <RadioGroup.RadioButton value="gluten-free">Gluten free</RadioGroup.RadioButton>
24
+ * <RadioGroup.RadioButton value="cauliflower">Cauliflower</RadioGroup.RadioButton>
25
+ * </RadioGroup>
26
+ * </FormField>
27
+ * ```
28
+ */
29
+ 'aria-describedby': string | undefined;
30
+ /**
31
+ * The common `name` passed to all Radio button children of the RadioGroup. This enables you to avoid specifying the `name` for each child.
32
+ */
33
+ name: string;
34
+ /**
35
+ * The selected value of the RadioGroup. Providing this prop will cause the model be in a controlled state
36
+ */
37
+ value: string | number | undefined;
38
+ /**
39
+ * `onChange` handler. Any `onChange` passed to children will be overwritten by this event so that there is only one per group.
40
+ */
41
+ onChange(event: React.ChangeEvent<HTMLInputElement>): void;
42
+ }> & {} & {}) | undefined) => {
43
+ onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
44
+ state: {
45
+ value: string | number | undefined;
46
+ name: string;
47
+ 'aria-describedby': string | undefined;
48
+ inputRef: React.MutableRefObject<HTMLInputElement | undefined>;
49
+ };
50
+ events: {};
51
+ }) & import("@workday/canvas-kit-react/common").ModelExtras<{
52
+ /**
53
+ * Use this attribute when you have a `FormField` that is in an `Alert` | `Error` or `Required` state. This will add attach an `aria-describedby` to each radio input so that screen readers can read out the message attached to the form field.
54
+ * The value of this attribute needs to match the value passed to `hintId` on the `FormField`.
55
+ *
56
+ * ```tsx
57
+ * <FormField
58
+ * error={FormField.ErrorType.Alert}
59
+ * hintId="hint-alert"
60
+ * hintText="Deep dish is an extra $2.99"
61
+ * label="Choose Your Pizza Crust"
62
+ * useFieldset={true}
63
+ * >
64
+ * <RadioGroup
65
+ * name="crust"
66
+ * onChange={handleChange}
67
+ * initialValue={value}
68
+ * aria-describedby="hint-alert"
69
+ * >
70
+ * <RadioGroup.RadioButton value="deep-dish">Deep dish</RadioGroup.RadioButton>
71
+ * <RadioGroup.RadioButton value="thin">Thin</RadioGroup.RadioButton>
72
+ * <RadioGroup.RadioButton value="gluten-free">Gluten free</RadioGroup.RadioButton>
73
+ * <RadioGroup.RadioButton value="cauliflower">Cauliflower</RadioGroup.RadioButton>
74
+ * </RadioGroup>
75
+ * </FormField>
76
+ * ```
77
+ */
78
+ 'aria-describedby': string | undefined;
79
+ /**
80
+ * The common `name` passed to all Radio button children of the RadioGroup. This enables you to avoid specifying the `name` for each child.
81
+ */
82
+ name: string;
83
+ /**
84
+ * The selected value of the RadioGroup. Providing this prop will cause the model be in a controlled state
85
+ */
86
+ value: string | number | undefined;
87
+ /**
88
+ * `onChange` handler. Any `onChange` passed to children will be overwritten by this event so that there is only one per group.
89
+ */
90
+ onChange(event: React.ChangeEvent<HTMLInputElement>): void;
91
+ }, {}, {
92
+ value: string | number | undefined;
93
+ name: string;
94
+ 'aria-describedby': string | undefined;
95
+ inputRef: React.MutableRefObject<HTMLInputElement | undefined>;
96
+ }, {}, {
97
+ onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
98
+ state: {
99
+ value: string | number | undefined;
100
+ name: string;
101
+ 'aria-describedby': string | undefined;
102
+ inputRef: React.MutableRefObject<HTMLInputElement | undefined>;
103
+ };
104
+ events: {};
105
+ }>;
106
+ //# sourceMappingURL=useRadioModel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRadioModel.d.ts","sourceRoot":"","sources":["../../../../../radio/lib/hooks/useRadioModel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,eAAO,MAAM,aAAa;IAEtB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;oBACa,MAAM,WAAW,CAAC,gBAAgB,CAAC;;sBAAnC,MAAM,WAAW,CAAC,gBAAgB,CAAC;;;;;;;;;IAtCnD;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;oBACa,MAAM,WAAW,CAAC,gBAAgB,CAAC;;;;;;;sBAAnC,MAAM,WAAW,CAAC,gBAAgB,CAAC;;;;;;;;EAmBrD,CAAC"}
@@ -0,0 +1,67 @@
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.useRadioModel = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const common_1 = require("@workday/canvas-kit-react/common");
9
+ exports.useRadioModel = common_1.createModelHook({
10
+ defaultConfig: {
11
+ /**
12
+ * Use this attribute when you have a `FormField` that is in an `Alert` | `Error` or `Required` state. This will add attach an `aria-describedby` to each radio input so that screen readers can read out the message attached to the form field.
13
+ * The value of this attribute needs to match the value passed to `hintId` on the `FormField`.
14
+ *
15
+ * ```tsx
16
+ * <FormField
17
+ * error={FormField.ErrorType.Alert}
18
+ * hintId="hint-alert"
19
+ * hintText="Deep dish is an extra $2.99"
20
+ * label="Choose Your Pizza Crust"
21
+ * useFieldset={true}
22
+ * >
23
+ * <RadioGroup
24
+ * name="crust"
25
+ * onChange={handleChange}
26
+ * initialValue={value}
27
+ * aria-describedby="hint-alert"
28
+ * >
29
+ * <RadioGroup.RadioButton value="deep-dish">Deep dish</RadioGroup.RadioButton>
30
+ * <RadioGroup.RadioButton value="thin">Thin</RadioGroup.RadioButton>
31
+ * <RadioGroup.RadioButton value="gluten-free">Gluten free</RadioGroup.RadioButton>
32
+ * <RadioGroup.RadioButton value="cauliflower">Cauliflower</RadioGroup.RadioButton>
33
+ * </RadioGroup>
34
+ * </FormField>
35
+ * ```
36
+ */
37
+ 'aria-describedby': undefined,
38
+ /**
39
+ * The common `name` passed to all Radio button children of the RadioGroup. This enables you to avoid specifying the `name` for each child.
40
+ */
41
+ name: '',
42
+ /**
43
+ * The selected value of the RadioGroup. Providing this prop will cause the model be in a controlled state
44
+ */
45
+ value: undefined,
46
+ /**
47
+ * `onChange` handler. Any `onChange` passed to children will be overwritten by this event so that there is only one per group.
48
+ */
49
+ onChange(event) {
50
+ return;
51
+ },
52
+ },
53
+ })(config => {
54
+ const inputRef = react_1.default.useRef();
55
+ const state = {
56
+ value: config.value,
57
+ name: config.name,
58
+ 'aria-describedby': config['aria-describedby'],
59
+ inputRef,
60
+ };
61
+ const events = {};
62
+ return {
63
+ onChange: config.onChange,
64
+ state,
65
+ events,
66
+ };
67
+ });
@@ -8,4 +8,5 @@ export * from './side-panel';
8
8
  export * from './status-indicator';
9
9
  export * from './text-area';
10
10
  export * from './text-input';
11
+ export * from './radio';
11
12
  //# sourceMappingURL=index.d.ts.map
@@ -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,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,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/es6/index.js CHANGED
@@ -8,3 +8,4 @@ export * from './side-panel';
8
8
  export * from './status-indicator';
9
9
  export * from './text-area';
10
10
  export * from './text-input';
11
+ export * from './radio';
@@ -0,0 +1,4 @@
1
+ export * from './lib/RadioGroup';
2
+ export * from './lib/hooks/useRadioModel';
3
+ export * from './lib/StyledRadioButton';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -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,3 @@
1
+ export * from './lib/RadioGroup';
2
+ export * from './lib/hooks/useRadioModel';
3
+ export * from './lib/StyledRadioButton';
@@ -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,12 @@
1
+ import React from 'react';
2
+ import { createSubcomponent } from '@workday/canvas-kit-react/common';
3
+ import { useRadioModel } from './hooks/useRadioModel';
4
+ import { RadioGroup } from './RadioGroup';
5
+ export const RadioButton = createSubcomponent('input')({
6
+ displayName: 'Radio',
7
+ modelHook: useRadioModel,
8
+ })(({ children, variant, ref, value, disabled, ...elemProps }) => {
9
+ return (React.createElement(RadioGroup.Label, { variant: variant, disabled: disabled },
10
+ React.createElement(RadioGroup.Label.Input, Object.assign({ value: value }, elemProps, { ref: ref })),
11
+ React.createElement(RadioGroup.Label.Text, null, children)));
12
+ });
@@ -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,56 @@
1
+ import React from 'react';
2
+ import { createContainer, getErrorColors, } from '@workday/canvas-kit-react/common';
3
+ import { space } from '@workday/canvas-kit-react/tokens';
4
+ import { useRadioModel } from './hooks/useRadioModel';
5
+ import { Flex } from '@workday/canvas-kit-react/layout';
6
+ import { RadioLabel } from './RadioLabel';
7
+ import { RadioButton } from './RadioButton';
8
+ /**
9
+ * Use `RadioGroup` to group a collection of `RadioGroup.RadioButton` components under a common `name`.
10
+ *
11
+ * ```tsx
12
+ * <RadioGroup name="pizza-crust" value="thin">
13
+ * <RadioGroup.RadioButton value="deep-dish">Deep dish</RadioGroup.RadioButton>
14
+ * <RadioGroup.RadioButton value="thin">Thin</RadioGroup.RadioButton>
15
+ * </RadioGroup>
16
+ * ```
17
+ */
18
+ export const RadioGroup = createContainer(Flex)({
19
+ displayName: 'RadioGroup',
20
+ modelHook: useRadioModel,
21
+ subComponents: {
22
+ /**
23
+ * `RadioGroup.Radio` renders an `<input type="radio" />` and its associated `<label>` (using `children` as the label's contents).
24
+ * This component should satisfy most use cases; use `RadioGroup.Label` if you require more flexibility.
25
+ *
26
+ * ```tsx
27
+ * <RadioGroup name="pizza-crust" value="thin">
28
+ * <RadioGroup.RadioButton value="deep-dish">Deep dish</RadioGroup.RadioButton>
29
+ * <RadioGroup.RadioButton value="thin">Thin</RadioGroup.RadioButton>
30
+ * </RadioGroup>
31
+ * ```
32
+ */
33
+ RadioButton: RadioButton,
34
+ /**
35
+ * Use `RadioGroup.Label` instead of `RadioGroup.Radio` if you need direct access to the label and the radio input.
36
+ * This will render a `<label>` that wraps an `<input type="radio" />` and a `<span>` for the label text.
37
+ *
38
+ * ```tsx
39
+ * <RadioGroup name"pizza-crust" value="deep-dish">
40
+ * <RadioGroup.Label>
41
+ * <RadioGroup.Label.Input value="deep-dish" />
42
+ * <RadioGroup.Label.Text>Deep dish</RadioGroup.Label.Text>
43
+ * </RadioGroup.Label>
44
+ * </RadioGroup>
45
+ * ```
46
+ */
47
+ Label: RadioLabel,
48
+ },
49
+ })(({ children, error, theme, ...elemProps }, Element, model) => {
50
+ const errorColors = getErrorColors(error, theme);
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", style: {
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));
56
+ });
@@ -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,25 @@
1
+ import React from 'react';
2
+ import { createSubcomponent, createElemPropsHook } from '@workday/canvas-kit-react/common';
3
+ import { useRadioModel } from './hooks/useRadioModel';
4
+ import { RadioLabelContext } from './RadioLabel';
5
+ import { StyledRadioButton } from './StyledRadioButton';
6
+ const useRadioInput = createElemPropsHook(useRadioModel)((model, _ref, elemProps = {}) => {
7
+ const { disabled, variant } = React.useContext(RadioLabelContext);
8
+ return {
9
+ 'aria-describedby': model.state['aria-describedby'],
10
+ disabled: disabled,
11
+ variant: variant,
12
+ checked: elemProps.value === model.state.value,
13
+ 'aria-checked': elemProps.value === model.state.value,
14
+ onChange(event) {
15
+ model.onChange(event);
16
+ },
17
+ name: model.state.name,
18
+ };
19
+ });
20
+ export const RadioInput = createSubcomponent('input')({
21
+ modelHook: useRadioModel,
22
+ elemPropsHook: useRadioInput,
23
+ })(({ ...elemProps }, _Element, _model) => {
24
+ return React.createElement(StyledRadioButton, Object.assign({}, elemProps));
25
+ });
@@ -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,42 @@
1
+ import React from 'react';
2
+ import { createSubcomponent } from '@workday/canvas-kit-react/common';
3
+ import { useRadioModel } from './hooks/useRadioModel';
4
+ import { Flex } from '@workday/canvas-kit-react/layout';
5
+ import { RadioInput } from './RadioInput';
6
+ import { RadioText } from './RadioText';
7
+ export const RadioLabelContext = React.createContext({});
8
+ export const RadioLabel = createSubcomponent('label')({
9
+ displayName: 'Radio.Label',
10
+ modelHook: useRadioModel,
11
+ subComponents: {
12
+ /**
13
+ * Use `RadioGroup.Label.Input` within a `RadioGroup.Label` to render the input portion of a radio button.
14
+ *
15
+ * ```tsx
16
+ * <RadioGroup name"pizza-crust" value="deep-dish">
17
+ * <RadioGroup.Label>
18
+ * <RadioGroup.Label.Input value="deep-dish" />
19
+ * <RadioGroup.Label.Text>Deep dish</RadioGroup.Label.Text>
20
+ * </RadioGroup.Label>
21
+ * </RadioGroup>
22
+ * ```
23
+ */
24
+ Input: RadioInput,
25
+ /**
26
+ * Use `RadioGroup.Label.Text` within a `RadioGroup.Label` to render the label text portion of a radio button.
27
+ *
28
+ * ```tsx
29
+ * <RadioGroup name"pizza-crust" value="deep-dish">
30
+ * <RadioGroup.Label>
31
+ * <RadioGroup.Label.Input value="deep-dish" />
32
+ * <RadioGroup.Label.Text>Deep dish</RadioGroup.Label.Text>
33
+ * </RadioGroup.Label>
34
+ * </RadioGroup>
35
+ * ```
36
+ */
37
+ Text: RadioText,
38
+ },
39
+ })(({ children, variant, disabled, value, ...elemProps }, Element, model) => {
40
+ return (React.createElement(RadioLabelContext.Provider, { value: { variant, disabled } },
41
+ React.createElement(Flex, Object.assign({ as: Element, alignItems: "flex-start", minHeight: "m", position: "relative", gap: "xs" }, elemProps), children)));
42
+ });
@@ -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,22 @@
1
+ import React from 'react';
2
+ import { createSubcomponent } from '@workday/canvas-kit-react/common';
3
+ import { inputColors, colors } from '@workday/canvas-kit-react/tokens';
4
+ import { useRadioModel } from './hooks/useRadioModel';
5
+ import { RadioLabelContext } from './RadioLabel';
6
+ import { Text } from '@workday/canvas-kit-react/text';
7
+ export const RadioText = createSubcomponent('span')({
8
+ displayName: 'RadioButton.Text',
9
+ modelHook: useRadioModel,
10
+ })(({ children, ...elemProps }, Element) => {
11
+ const { disabled, variant } = React.useContext(RadioLabelContext);
12
+ const inverse = variant === 'inverse';
13
+ return (React.createElement(Text, Object.assign({ as: Element, style: {
14
+ cursor: !disabled ? 'pointer' : undefined,
15
+ opacity: disabled && inverse ? '.4' : '1',
16
+ color: inverse
17
+ ? colors.frenchVanilla100
18
+ : disabled
19
+ ? inputColors.disabled.text
20
+ : elemProps.color,
21
+ }, typeLevel: "subtext.large" }, elemProps), children));
22
+ });
@@ -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"}