@primer/components 0.0.0-20211030172251 → 0.0.0-20211030173748

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 (149) hide show
  1. package/CHANGELOG.md +2 -2
  2. package/dist/browser.esm.js +605 -591
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +212 -198
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/ActionList2/Divider.d.ts +2 -3
  7. package/lib/ActionList2/Divider.js +5 -10
  8. package/lib/ActionList2/Item.js +5 -21
  9. package/lib/ActionList2/List.js +1 -11
  10. package/lib/ActionList2/Selection.js +0 -11
  11. package/lib/ActionList2/index.d.ts +2 -1
  12. package/lib/Autocomplete/AutocompleteMenu.js +6 -13
  13. package/lib/Checkbox.d.ts +1 -1
  14. package/lib/CheckboxInputField.d.ts +11 -0
  15. package/lib/CheckboxInputField.js +73 -0
  16. package/lib/ChoiceFieldset/ChoiceField.d.ts +22 -0
  17. package/lib/ChoiceFieldset/ChoiceField.js +58 -0
  18. package/lib/ChoiceFieldset/ChoiceFieldCaption.d.ts +3 -0
  19. package/lib/ChoiceFieldset/ChoiceFieldCaption.js +35 -0
  20. package/lib/ChoiceFieldset/ChoiceFieldInput.d.ts +13 -0
  21. package/lib/ChoiceFieldset/ChoiceFieldInput.js +43 -0
  22. package/lib/ChoiceFieldset/ChoiceFieldLabel.d.ts +3 -0
  23. package/lib/ChoiceFieldset/ChoiceFieldLabel.js +35 -0
  24. package/lib/ChoiceFieldset/ChoiceFieldset.d.ts +57 -0
  25. package/lib/ChoiceFieldset/ChoiceFieldset.js +95 -0
  26. package/lib/ChoiceFieldset/ChoiceFieldsetCaption.d.ts +3 -0
  27. package/lib/ChoiceFieldset/ChoiceFieldsetCaption.js +28 -0
  28. package/lib/ChoiceFieldset/ChoiceFieldsetLegend.d.ts +6 -0
  29. package/lib/ChoiceFieldset/ChoiceFieldsetLegend.js +41 -0
  30. package/lib/ChoiceFieldset/ChoiceFieldsetList.d.ts +6 -0
  31. package/lib/ChoiceFieldset/ChoiceFieldsetList.js +85 -0
  32. package/lib/ChoiceFieldset/ChoiceFieldsetListContext.d.ts +17 -0
  33. package/lib/ChoiceFieldset/ChoiceFieldsetListContext.js +15 -0
  34. package/lib/ChoiceFieldset/ChoiceFieldsetValidation.d.ts +6 -0
  35. package/lib/ChoiceFieldset/ChoiceFieldsetValidation.js +17 -0
  36. package/lib/ChoiceFieldset/index.d.ts +3 -0
  37. package/lib/ChoiceFieldset/index.js +23 -0
  38. package/lib/RadioInputField.d.ts +9 -0
  39. package/lib/RadioInputField.js +82 -0
  40. package/lib/TextInputField.d.ts +581 -0
  41. package/lib/TextInputField.js +66 -0
  42. package/lib/_InputCaption.d.ts +13 -0
  43. package/lib/_InputCaption.js +27 -0
  44. package/lib/_InputField/InputField.d.ts +39 -0
  45. package/lib/_InputField/InputField.js +90 -0
  46. package/lib/_InputField/InputFieldCaption.d.ts +3 -0
  47. package/lib/_InputField/InputFieldCaption.js +30 -0
  48. package/lib/_InputField/InputFieldLabel.d.ts +9 -0
  49. package/lib/_InputField/InputFieldLabel.js +34 -0
  50. package/lib/_InputField/InputFieldValidation.d.ts +6 -0
  51. package/lib/{ActionList2/MenuContext.js → _InputField/InputFieldValidation.js} +6 -4
  52. package/lib/_InputField/ToggleInputField.d.ts +13 -0
  53. package/lib/_InputField/ToggleInputField.js +71 -0
  54. package/lib/_InputField/ToggleInputLeadingVisual.d.ts +3 -0
  55. package/lib/_InputField/ToggleInputLeadingVisual.js +22 -0
  56. package/lib/_InputField/ValidationAnimationContainer.d.ts +6 -0
  57. package/lib/_InputField/ValidationAnimationContainer.js +48 -0
  58. package/lib/_InputField/index.d.ts +1 -0
  59. package/lib/_InputField/index.js +15 -0
  60. package/lib/_InputField/slots.d.ts +13 -0
  61. package/lib/_InputField/slots.js +17 -0
  62. package/lib/_InputLabel.d.ts +8 -0
  63. package/lib/_InputLabel.js +44 -0
  64. package/lib/_InputValidation.d.ts +8 -0
  65. package/lib/_InputValidation.js +56 -0
  66. package/lib/_VisuallyHidden.d.ts +6 -0
  67. package/lib/_VisuallyHidden.js +39 -0
  68. package/lib/drafts.d.ts +0 -1
  69. package/lib/drafts.js +0 -13
  70. package/lib/index.d.ts +4 -0
  71. package/lib/index.js +38 -0
  72. package/lib/utils/types/FormValidationStatus.d.ts +1 -0
  73. package/lib/utils/types/FormValidationStatus.js +1 -0
  74. package/lib-esm/ActionList2/Divider.d.ts +2 -3
  75. package/lib-esm/ActionList2/Divider.js +5 -8
  76. package/lib-esm/ActionList2/Item.js +5 -19
  77. package/lib-esm/ActionList2/List.js +1 -9
  78. package/lib-esm/ActionList2/Selection.js +0 -9
  79. package/lib-esm/ActionList2/index.d.ts +2 -1
  80. package/lib-esm/Autocomplete/AutocompleteMenu.js +3 -13
  81. package/lib-esm/Checkbox.d.ts +1 -1
  82. package/lib-esm/CheckboxInputField.d.ts +11 -0
  83. package/lib-esm/CheckboxInputField.js +56 -0
  84. package/lib-esm/ChoiceFieldset/ChoiceField.d.ts +22 -0
  85. package/lib-esm/ChoiceFieldset/ChoiceField.js +36 -0
  86. package/lib-esm/ChoiceFieldset/ChoiceFieldCaption.d.ts +3 -0
  87. package/lib-esm/ChoiceFieldset/ChoiceFieldCaption.js +20 -0
  88. package/lib-esm/ChoiceFieldset/ChoiceFieldInput.d.ts +13 -0
  89. package/lib-esm/ChoiceFieldset/ChoiceFieldInput.js +28 -0
  90. package/lib-esm/ChoiceFieldset/ChoiceFieldLabel.d.ts +3 -0
  91. package/lib-esm/ChoiceFieldset/ChoiceFieldLabel.js +20 -0
  92. package/lib-esm/ChoiceFieldset/ChoiceFieldset.d.ts +57 -0
  93. package/lib-esm/ChoiceFieldset/ChoiceFieldset.js +72 -0
  94. package/lib-esm/ChoiceFieldset/ChoiceFieldsetCaption.d.ts +3 -0
  95. package/lib-esm/ChoiceFieldset/ChoiceFieldsetCaption.js +16 -0
  96. package/lib-esm/ChoiceFieldset/ChoiceFieldsetLegend.d.ts +6 -0
  97. package/lib-esm/ChoiceFieldset/ChoiceFieldsetLegend.js +28 -0
  98. package/lib-esm/ChoiceFieldset/ChoiceFieldsetList.d.ts +6 -0
  99. package/lib-esm/ChoiceFieldset/ChoiceFieldsetList.js +68 -0
  100. package/lib-esm/ChoiceFieldset/ChoiceFieldsetListContext.d.ts +17 -0
  101. package/lib-esm/ChoiceFieldset/ChoiceFieldsetListContext.js +5 -0
  102. package/lib-esm/ChoiceFieldset/ChoiceFieldsetValidation.d.ts +6 -0
  103. package/lib-esm/ChoiceFieldset/ChoiceFieldsetValidation.js +7 -0
  104. package/lib-esm/ChoiceFieldset/index.d.ts +3 -0
  105. package/lib-esm/ChoiceFieldset/index.js +2 -0
  106. package/lib-esm/RadioInputField.d.ts +9 -0
  107. package/lib-esm/RadioInputField.js +65 -0
  108. package/lib-esm/TextInputField.d.ts +581 -0
  109. package/lib-esm/TextInputField.js +50 -0
  110. package/lib-esm/_InputCaption.d.ts +13 -0
  111. package/lib-esm/_InputCaption.js +16 -0
  112. package/lib-esm/_InputField/InputField.d.ts +39 -0
  113. package/lib-esm/_InputField/InputField.js +70 -0
  114. package/lib-esm/_InputField/InputFieldCaption.d.ts +3 -0
  115. package/lib-esm/_InputField/InputFieldCaption.js +18 -0
  116. package/lib-esm/_InputField/InputFieldLabel.d.ts +9 -0
  117. package/lib-esm/_InputField/InputFieldLabel.js +22 -0
  118. package/lib-esm/_InputField/InputFieldValidation.d.ts +6 -0
  119. package/lib-esm/_InputField/InputFieldValidation.js +7 -0
  120. package/lib-esm/_InputField/ToggleInputField.d.ts +13 -0
  121. package/lib-esm/_InputField/ToggleInputField.js +54 -0
  122. package/lib-esm/_InputField/ToggleInputLeadingVisual.d.ts +3 -0
  123. package/lib-esm/_InputField/ToggleInputLeadingVisual.js +11 -0
  124. package/lib-esm/_InputField/ValidationAnimationContainer.d.ts +6 -0
  125. package/lib-esm/_InputField/ValidationAnimationContainer.js +33 -0
  126. package/lib-esm/_InputField/index.d.ts +1 -0
  127. package/lib-esm/_InputField/index.js +1 -0
  128. package/lib-esm/_InputField/slots.d.ts +13 -0
  129. package/lib-esm/_InputField/slots.js +5 -0
  130. package/lib-esm/_InputLabel.d.ts +8 -0
  131. package/lib-esm/_InputLabel.js +32 -0
  132. package/lib-esm/_InputValidation.d.ts +8 -0
  133. package/lib-esm/_InputValidation.js +43 -0
  134. package/lib-esm/_VisuallyHidden.d.ts +6 -0
  135. package/lib-esm/_VisuallyHidden.js +26 -0
  136. package/lib-esm/drafts.d.ts +0 -1
  137. package/lib-esm/drafts.js +1 -2
  138. package/lib-esm/index.d.ts +4 -0
  139. package/lib-esm/index.js +4 -0
  140. package/lib-esm/utils/types/FormValidationStatus.d.ts +1 -0
  141. package/lib-esm/utils/types/FormValidationStatus.js +1 -0
  142. package/package.json +2 -2
  143. package/lib/ActionList2/MenuContext.d.ts +0 -10
  144. package/lib/ActionMenu2.d.ts +0 -310
  145. package/lib/ActionMenu2.js +0 -91
  146. package/lib-esm/ActionList2/MenuContext.d.ts +0 -10
  147. package/lib-esm/ActionList2/MenuContext.js +0 -3
  148. package/lib-esm/ActionMenu2.d.ts +0 -310
  149. package/lib-esm/ActionMenu2.js +0 -67
@@ -0,0 +1,20 @@
1
+ import React, { useContext } from 'react';
2
+ import ChoiceFieldsetListContext from './ChoiceFieldsetListContext';
3
+
4
+ const ChoiceFieldLabel = ({
5
+ children
6
+ }) => {
7
+ const choiceFieldsetListContext = useContext(ChoiceFieldsetListContext);
8
+
9
+ if (choiceFieldsetListContext === null) {
10
+ throw new Error('ChoiceFieldsetListContext returned null');
11
+ }
12
+
13
+ const {
14
+ fieldComponent: FieldComponent
15
+ } = choiceFieldsetListContext;
16
+ return /*#__PURE__*/React.createElement(FieldComponent.Label, null, children);
17
+ };
18
+
19
+ ChoiceFieldLabel.displayName = "ChoiceFieldLabel";
20
+ export default ChoiceFieldLabel;
@@ -0,0 +1,57 @@
1
+ import React, { ComponentProps } from 'react';
2
+ import { FormValidationStatus } from '../utils/types/FormValidationStatus';
3
+ export interface ChoiceFieldsetProps<T = Record<string, FormValidationStatus>> {
4
+ children?: React.ReactNode;
5
+ /**
6
+ * The unique identifier for this fieldset. Used to associate the validation text and caption text with the fieldset
7
+ */
8
+ id?: string;
9
+ /**
10
+ * The unique identifier used to associate the inputs with eachother
11
+ */
12
+ name?: string;
13
+ /**
14
+ * The callback that is called when a user toggles a choice on or off
15
+ */
16
+ onSelect?: (selectedValues?: string[]) => void;
17
+ /**
18
+ * Whether this field must have a value for the user to complete their task
19
+ */
20
+ required?: boolean;
21
+ /**
22
+ * A map of validation statuses and their associated validation keys. When one of the validation keys is passed to the `validationResult` prop,
23
+ * the associated validation message will be rendered in the correct style
24
+ */
25
+ validationMap?: T;
26
+ /**
27
+ * The key of the validation message to show
28
+ */
29
+ validationResult?: keyof T;
30
+ }
31
+ export interface ChoiceFieldsetContext extends ChoiceFieldsetProps {
32
+ captionId: string;
33
+ validationMessageId: string;
34
+ }
35
+ declare const Slot: React.FC<{
36
+ name: "Caption" | "ChoiceList" | "Legend" | "Validation";
37
+ children: React.ReactNode;
38
+ }>;
39
+ export { Slot };
40
+ declare const ChoiceFieldset: <T extends Record<string, FormValidationStatus>>({ children, id, name, onSelect, required, validationMap, validationResult }: ChoiceFieldsetProps<T>) => JSX.Element;
41
+ export declare type InputFieldComponentProps = ComponentProps<typeof ChoiceFieldset>;
42
+ export type { ChoiceFieldsetListProps } from './ChoiceFieldsetList';
43
+ export type { ChoiceFieldsetLegendProps } from './ChoiceFieldsetLegend';
44
+ export type { ChoiceFieldProps } from './ChoiceField';
45
+ declare const _default: (<T extends Record<string, FormValidationStatus>>({ children, id, name, onSelect, required, validationMap, validationResult }: ChoiceFieldsetProps<T>) => JSX.Element) & {
46
+ ChoiceField: React.FC<import("./ChoiceField").ChoiceFieldProps> & {
47
+ Caption: React.FC<{}>;
48
+ Input: React.FC<import("./ChoiceFieldInput").ChoiceFieldInputProps>;
49
+ Label: React.FC<{}>;
50
+ LeadingVisual: React.FC<{}>;
51
+ };
52
+ Caption: React.FC<{}>;
53
+ Legend: React.FC<import("./ChoiceFieldsetLegend").ChoiceFieldsetLegendProps>;
54
+ List: React.FC<import("./ChoiceFieldsetList").ChoiceFieldsetListProps>;
55
+ Validation: React.FC<import("./ChoiceFieldsetValidation").ChoiceFieldsetValidationProps>;
56
+ };
57
+ export default _default;
@@ -0,0 +1,72 @@
1
+ import React from 'react';
2
+ import { Box } from '..';
3
+ import createSlots from '../utils/create-slots';
4
+ import { uniqueId } from '../utils/uniqueId';
5
+ import ValidationAnimationContainer from '../_InputField/ValidationAnimationContainer';
6
+ import InputValidation from '../_InputValidation';
7
+ import ChoiceField from './ChoiceField';
8
+ import ChoiceFieldsetCaption from './ChoiceFieldsetCaption';
9
+ import ChoiceFieldsetLegend from './ChoiceFieldsetLegend';
10
+ import ChoiceFieldsetList from './ChoiceFieldsetList';
11
+ import ChoiceFieldsetValidation from './ChoiceFieldsetValidation';
12
+ const {
13
+ Slots,
14
+ Slot
15
+ } = createSlots(['Caption', 'ChoiceList', 'Legend', 'Validation']);
16
+ export { Slot };
17
+
18
+ const ChoiceFieldset = ({
19
+ children,
20
+ id,
21
+ name,
22
+ onSelect,
23
+ required,
24
+ validationMap,
25
+ validationResult
26
+ }) => {
27
+ var _React$Children$map;
28
+
29
+ const fieldsetId = id || uniqueId();
30
+ const validationChildren = (_React$Children$map = React.Children.map(children, child => /*#__PURE__*/React.isValidElement(child) && child.type === ChoiceFieldsetValidation ? child : null)) === null || _React$Children$map === void 0 ? void 0 : _React$Children$map.filter(Boolean);
31
+ const validationChildToRender = validationChildren === null || validationChildren === void 0 ? void 0 : validationChildren.find(child => child.props.validationKey === validationResult);
32
+ const captionId = `${fieldsetId}-caption`;
33
+ const validationMessageId = validationChildToRender ? `${fieldsetId}-validationMsg` : undefined;
34
+ return /*#__PURE__*/React.createElement(Slots, {
35
+ context: {
36
+ captionId,
37
+ name,
38
+ onSelect,
39
+ required,
40
+ validationMessageId
41
+ }
42
+ }, slots => {
43
+ const isLegendVisible = /*#__PURE__*/React.isValidElement(slots.Legend) && slots.Legend.props.isVisible;
44
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Box, {
45
+ as: "fieldset",
46
+ border: "none",
47
+ margin: 0,
48
+ padding: 0,
49
+ "aria-describedby": [validationMessageId, captionId].filter(Boolean).join(' ')
50
+ }, React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child) && child.type !== ChoiceFieldsetValidation), /*#__PURE__*/React.createElement(Box, {
51
+ mb: isLegendVisible ? 3 : undefined
52
+ }, slots.Legend), slots.ChoiceList), (validationChildToRender || slots.Caption) && /*#__PURE__*/React.createElement(Box, {
53
+ mt: 3
54
+ }, validationChildToRender && validationMap && validationResult && validationMessageId && /*#__PURE__*/React.createElement(ValidationAnimationContainer, {
55
+ show: true
56
+ }, /*#__PURE__*/React.createElement(InputValidation, {
57
+ validationStatus: validationMap[validationResult],
58
+ id: validationMessageId
59
+ }, validationChildToRender)), /*#__PURE__*/React.createElement(Box, {
60
+ mt: validationChildToRender ? 1 : undefined
61
+ }, slots.Caption)));
62
+ });
63
+ };
64
+
65
+ ChoiceFieldset.displayName = "ChoiceFieldset";
66
+ export default Object.assign(ChoiceFieldset, {
67
+ ChoiceField,
68
+ Caption: ChoiceFieldsetCaption,
69
+ Legend: ChoiceFieldsetLegend,
70
+ List: ChoiceFieldsetList,
71
+ Validation: ChoiceFieldsetValidation
72
+ });
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const ChoiceFieldsetCaption: React.FC;
3
+ export default ChoiceFieldsetCaption;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import InputCaption from '../_InputCaption';
3
+ import { Slot } from './ChoiceFieldset';
4
+
5
+ const ChoiceFieldsetCaption = ({
6
+ children
7
+ }) => /*#__PURE__*/React.createElement(Slot, {
8
+ name: "Caption"
9
+ }, ({
10
+ captionId
11
+ }) => /*#__PURE__*/React.createElement(InputCaption, {
12
+ id: captionId
13
+ }, children));
14
+
15
+ ChoiceFieldsetCaption.displayName = "ChoiceFieldsetCaption";
16
+ export default ChoiceFieldsetCaption;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export interface ChoiceFieldsetLegendProps {
3
+ visuallyHidden?: boolean;
4
+ }
5
+ declare const ChoiceFieldsetLegend: React.FC<ChoiceFieldsetLegendProps>;
6
+ export default ChoiceFieldsetLegend;
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import { Box } from '..';
3
+ import VisuallyHidden from '../_VisuallyHidden';
4
+ import { Slot } from './ChoiceFieldset';
5
+
6
+ const ChoiceFieldsetLegend = ({
7
+ children,
8
+ visuallyHidden
9
+ }) => /*#__PURE__*/React.createElement(Slot, {
10
+ name: "Legend"
11
+ }, ({
12
+ required
13
+ }) => /*#__PURE__*/React.createElement(VisuallyHidden, {
14
+ isVisible: !visuallyHidden,
15
+ title: required ? 'required field' : undefined,
16
+ sx: {
17
+ fontSize: 2,
18
+ padding: 0
19
+ }
20
+ }, required ? /*#__PURE__*/React.createElement(Box, {
21
+ display: "flex",
22
+ as: "span"
23
+ }, /*#__PURE__*/React.createElement(Box, {
24
+ mr: 1
25
+ }, children), /*#__PURE__*/React.createElement("span", null, "*")) : children));
26
+
27
+ ChoiceFieldsetLegend.displayName = "ChoiceFieldsetLegend";
28
+ export default ChoiceFieldsetLegend;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export interface ChoiceFieldsetListProps {
3
+ selectionVariant?: 'single' | 'multiple';
4
+ }
5
+ declare const ChoiceFieldsetList: React.FC<ChoiceFieldsetListProps>;
6
+ export default ChoiceFieldsetList;
@@ -0,0 +1,68 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+ import { CheckboxInputField, RadioInputField } from '..';
4
+ import { get } from '../constants';
5
+ import { uniqueId } from '../utils/uniqueId';
6
+ import { Slot } from './ChoiceFieldset';
7
+ import ChoiceFieldsetListContext from './ChoiceFieldsetListContext';
8
+ const List = styled.ul.withConfig({
9
+ displayName: "ChoiceFieldsetList__List",
10
+ componentId: "sc-16da7ba-0"
11
+ })(["display:flex;flex-direction:column;list-style:none;margin:0;padding:0;> li + li{margin-top:", ";}"], get('space.2'));
12
+
13
+ const ChoiceFieldsetList = ({
14
+ selectionVariant,
15
+ children
16
+ }) => {
17
+ var _React$Children$map;
18
+
19
+ const initialSelectedChoices = ((_React$Children$map = React.Children.map(children, child => {
20
+ if ( /*#__PURE__*/React.isValidElement(child) && child.props.checked) {
21
+ return child.props.value;
22
+ }
23
+
24
+ return '';
25
+ })) === null || _React$Children$map === void 0 ? void 0 : _React$Children$map.filter(Boolean)) || [];
26
+
27
+ const getSelectedCheckboxes = (value, checked) => {
28
+ if (checked) {
29
+ return selectionVariant === 'multiple' ? [...initialSelectedChoices, value] : [value];
30
+ }
31
+
32
+ return initialSelectedChoices.filter(selectedValue => selectedValue !== value);
33
+ }; // generates a name to pass to radio inputs if one was not passed in ChoiceFieldset props
34
+
35
+
36
+ const getRadioGroupName = nameFromContext => {
37
+ if (nameFromContext || selectionVariant !== 'multiple') {
38
+ return nameFromContext;
39
+ }
40
+
41
+ const generatedName = uniqueId();
42
+ return generatedName;
43
+ };
44
+
45
+ return /*#__PURE__*/React.createElement(Slot, {
46
+ name: "ChoiceList"
47
+ }, ({
48
+ name,
49
+ onSelect
50
+ }) => /*#__PURE__*/React.createElement(ChoiceFieldsetListContext.Provider, {
51
+ value: {
52
+ initialSelectedChoices,
53
+ name: getRadioGroupName(name),
54
+ fieldComponent: selectionVariant === 'multiple' ? CheckboxInputField : RadioInputField,
55
+ onChange: e => {
56
+ onSelect && onSelect(getSelectedCheckboxes(e.currentTarget.value, e.currentTarget.checked));
57
+ }
58
+ }
59
+ }, /*#__PURE__*/React.createElement(List, null, React.Children.map(children, (child, i) => /*#__PURE__*/React.createElement("li", {
60
+ key: i
61
+ }, child)))));
62
+ };
63
+
64
+ ChoiceFieldsetList.displayName = "ChoiceFieldsetList";
65
+ ChoiceFieldsetList.defaultProps = {
66
+ selectionVariant: 'single'
67
+ };
68
+ export default ChoiceFieldsetList;
@@ -0,0 +1,17 @@
1
+ import { ChangeEventHandler } from 'react';
2
+ import { CheckboxInputField, RadioInputField } from '..';
3
+ import { ComponentProps } from '../utils/types';
4
+ import InputField from '../_InputField';
5
+ import ToggleInputField, { ToggleInputFieldProps } from '../_InputField/ToggleInputField';
6
+ declare const ChoiceFieldsetListContext: import("react").Context<{
7
+ initialSelectedChoices?: string[] | undefined;
8
+ name?: string | undefined;
9
+ onChange: ChangeEventHandler<HTMLInputElement>;
10
+ fieldComponent: React.FC<ToggleInputFieldProps> & {
11
+ Input: React.FC<ComponentProps<typeof RadioInputField.Input>> | React.FC<ComponentProps<typeof CheckboxInputField.Input>>;
12
+ Caption: React.FC<ComponentProps<typeof InputField.Caption>>;
13
+ Label: React.FC<ComponentProps<typeof InputField.Label>>;
14
+ LeadingVisual: React.FC<ComponentProps<typeof ToggleInputField.LeadingVisual>>;
15
+ };
16
+ } | null>;
17
+ export default ChoiceFieldsetListContext;
@@ -0,0 +1,5 @@
1
+ import { createContext } from 'react';
2
+ import { CheckboxInputField } from '..';
3
+ const ChoiceFieldsetListContext = /*#__PURE__*/createContext(null);
4
+ CheckboxInputField.Input;
5
+ export default ChoiceFieldsetListContext;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export interface ChoiceFieldsetValidationProps {
3
+ validationKey: string;
4
+ }
5
+ declare const ChoiceFieldsetValidation: React.FC<ChoiceFieldsetValidationProps>;
6
+ export default ChoiceFieldsetValidation;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+
3
+ const ChoiceFieldsetValidation = ({
4
+ children
5
+ }) => /*#__PURE__*/React.createElement(React.Fragment, null, children);
6
+
7
+ export default ChoiceFieldsetValidation;
@@ -0,0 +1,3 @@
1
+ export { default } from './ChoiceFieldset';
2
+ export { default as ChoiceField } from './ChoiceField';
3
+ export type { ChoiceFieldsetProps } from './ChoiceFieldset';
@@ -0,0 +1,2 @@
1
+ export { default } from './ChoiceFieldset';
2
+ export { default as ChoiceField } from './ChoiceField';
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { ToggleInputFieldProps } from './_InputField/ToggleInputField';
3
+ declare const _default: React.FC<ToggleInputFieldProps> & {
4
+ Input: React.FC<React.HTMLProps<HTMLInputElement>>;
5
+ Caption: React.FC<{}>;
6
+ Label: React.FC<import("./_InputField/InputFieldLabel").Props>;
7
+ LeadingVisual: React.FC<{}>;
8
+ };
9
+ export default _default;
@@ -0,0 +1,65 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ import React from 'react';
4
+ import InputField from './_InputField/InputField';
5
+ import { Slot } from './_InputField/slots';
6
+ import ToggleInputField from './_InputField/ToggleInputField';
7
+ import ToggleInputLeadingVisual from './_InputField/ToggleInputLeadingVisual'; // TODO: use Primer's checkbox input once it's available
8
+ // https://github.com/github/primer/issues/489
9
+
10
+ const RadioInput = props => {
11
+ return /*#__PURE__*/React.createElement("input", _extends({
12
+ type: "radio"
13
+ }, props));
14
+ };
15
+
16
+ RadioInput.displayName = "RadioInput";
17
+
18
+ // pulling out `id`, `disabled`, and `required` because those should come from the parent TextInputField component
19
+ const Input = ({
20
+ id: idProp,
21
+ required: requiredProp,
22
+ disabled: disabledProp,
23
+ ...rest
24
+ }) => {
25
+ if (idProp) {
26
+ // eslint-disable-next-line no-console
27
+ console.warn("instead of passing the 'id' prop directly to <TextInputField.Input>, it should be passed to the parent component, <TextInputField>");
28
+ }
29
+
30
+ if (disabledProp) {
31
+ // eslint-disable-next-line no-console
32
+ console.warn("instead of passing the 'disabled' prop directly to <TextInputField.Input>, it should be passed to the parent component, <TextInputField>");
33
+ }
34
+
35
+ if (requiredProp) {
36
+ // eslint-disable-next-line no-console
37
+ console.warn("instead of passing the 'required' prop directly to <TextInputField.Input>, it should be passed to the parent component, <TextInputField>");
38
+ }
39
+
40
+ return /*#__PURE__*/React.createElement(Slot, {
41
+ name: "Input"
42
+ }, ({
43
+ disabled,
44
+ id,
45
+ required,
46
+ captionId
47
+ }) => /*#__PURE__*/React.createElement(RadioInput, _extends({
48
+ "aria-describedby": captionId,
49
+ id: id,
50
+ required: required,
51
+ disabled: disabled
52
+ }, rest)));
53
+ };
54
+
55
+ Input.displayName = "Input";
56
+
57
+ const RadioInputField = props => /*#__PURE__*/React.createElement(ToggleInputField, props);
58
+
59
+ RadioInputField.displayName = "RadioInputField";
60
+ export default Object.assign(RadioInputField, {
61
+ Input,
62
+ Caption: InputField.Caption,
63
+ Label: InputField.Label,
64
+ LeadingVisual: ToggleInputLeadingVisual
65
+ });