@primer/components 0.0.0-2021111193153 → 0.0.0-202111121740

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 (171) hide show
  1. package/CHANGELOG.md +2 -12
  2. package/dist/browser.esm.js +605 -587
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +222 -204
  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/Avatar.d.ts +2 -1
  14. package/lib/Avatar.js +1 -1
  15. package/lib/BranchName.d.ts +2 -1
  16. package/lib/BranchName.js +1 -1
  17. package/lib/Checkbox.d.ts +1 -1
  18. package/lib/CheckboxInputField.d.ts +11 -0
  19. package/lib/CheckboxInputField.js +73 -0
  20. package/lib/ChoiceFieldset/ChoiceFieldCaption.d.ts +3 -0
  21. package/lib/ChoiceFieldset/ChoiceFieldCaption.js +35 -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 +63 -0
  25. package/lib/ChoiceFieldset/ChoiceFieldset.js +95 -0
  26. package/lib/ChoiceFieldset/ChoiceFieldsetDescription.d.ts +3 -0
  27. package/lib/ChoiceFieldset/ChoiceFieldsetDescription.js +29 -0
  28. package/lib/ChoiceFieldset/ChoiceFieldsetLegend.d.ts +6 -0
  29. package/lib/ChoiceFieldset/ChoiceFieldsetLegend.js +44 -0
  30. package/lib/ChoiceFieldset/ChoiceFieldsetList.d.ts +6 -0
  31. package/lib/ChoiceFieldset/ChoiceFieldsetList.js +80 -0
  32. package/lib/ChoiceFieldset/ChoiceFieldsetListContext.d.ts +18 -0
  33. package/lib/ChoiceFieldset/ChoiceFieldsetListContext.js +15 -0
  34. package/lib/ChoiceFieldset/ChoiceFieldsetListItem.d.ts +25 -0
  35. package/lib/ChoiceFieldset/ChoiceFieldsetListItem.js +74 -0
  36. package/lib/ChoiceFieldset/ChoiceFieldsetValidation.d.ts +6 -0
  37. package/lib/ChoiceFieldset/ChoiceFieldsetValidation.js +17 -0
  38. package/lib/ChoiceFieldset/index.d.ts +3 -0
  39. package/lib/ChoiceFieldset/index.js +23 -0
  40. package/lib/Details.d.ts +2 -1
  41. package/lib/Details.js +3 -1
  42. package/lib/Dropdown.d.ts +66 -2
  43. package/lib/Heading.d.ts +2 -1
  44. package/lib/Heading.js +6 -1
  45. package/lib/ProgressBar.d.ts +11 -16
  46. package/lib/ProgressBar.js +10 -6
  47. package/lib/RadioInputField.d.ts +9 -0
  48. package/lib/RadioInputField.js +82 -0
  49. package/lib/Spinner.d.ts +2 -1
  50. package/lib/Spinner.js +3 -1
  51. package/lib/TextInputField.d.ts +581 -0
  52. package/lib/TextInputField.js +66 -0
  53. package/lib/_InputCaption.d.ts +13 -0
  54. package/lib/_InputCaption.js +27 -0
  55. package/lib/_InputField/InputField.d.ts +39 -0
  56. package/lib/_InputField/InputField.js +90 -0
  57. package/lib/_InputField/InputFieldCaption.d.ts +3 -0
  58. package/lib/_InputField/InputFieldCaption.js +30 -0
  59. package/lib/_InputField/InputFieldLabel.d.ts +9 -0
  60. package/lib/_InputField/InputFieldLabel.js +34 -0
  61. package/lib/_InputField/InputFieldValidation.d.ts +6 -0
  62. package/lib/{ActionList2/MenuContext.js → _InputField/InputFieldValidation.js} +6 -4
  63. package/lib/_InputField/ToggleInputField.d.ts +13 -0
  64. package/lib/_InputField/ToggleInputField.js +71 -0
  65. package/lib/_InputField/ToggleInputLeadingVisual.d.ts +3 -0
  66. package/lib/_InputField/ToggleInputLeadingVisual.js +22 -0
  67. package/lib/_InputField/ValidationAnimationContainer.d.ts +6 -0
  68. package/lib/_InputField/ValidationAnimationContainer.js +48 -0
  69. package/lib/_InputField/index.d.ts +1 -0
  70. package/lib/_InputField/index.js +15 -0
  71. package/lib/_InputField/slots.d.ts +13 -0
  72. package/lib/_InputField/slots.js +17 -0
  73. package/lib/_InputLabel.d.ts +8 -0
  74. package/lib/_InputLabel.js +44 -0
  75. package/lib/_InputValidation.d.ts +8 -0
  76. package/lib/_InputValidation.js +56 -0
  77. package/lib/_VisuallyHidden.d.ts +6 -0
  78. package/lib/_VisuallyHidden.js +39 -0
  79. package/lib/drafts.d.ts +0 -1
  80. package/lib/drafts.js +0 -13
  81. package/lib/index.d.ts +4 -0
  82. package/lib/index.js +38 -0
  83. package/lib/utils/types/FormValidationStatus.d.ts +1 -0
  84. package/lib/utils/types/FormValidationStatus.js +1 -0
  85. package/lib-esm/ActionList2/Divider.d.ts +2 -3
  86. package/lib-esm/ActionList2/Divider.js +5 -8
  87. package/lib-esm/ActionList2/Item.js +5 -19
  88. package/lib-esm/ActionList2/List.js +1 -9
  89. package/lib-esm/ActionList2/Selection.js +0 -9
  90. package/lib-esm/ActionList2/index.d.ts +2 -1
  91. package/lib-esm/Autocomplete/AutocompleteMenu.js +3 -13
  92. package/lib-esm/Avatar.d.ts +2 -1
  93. package/lib-esm/Avatar.js +2 -2
  94. package/lib-esm/BranchName.d.ts +2 -1
  95. package/lib-esm/BranchName.js +2 -2
  96. package/lib-esm/Checkbox.d.ts +1 -1
  97. package/lib-esm/CheckboxInputField.d.ts +11 -0
  98. package/lib-esm/CheckboxInputField.js +56 -0
  99. package/lib-esm/ChoiceFieldset/ChoiceFieldCaption.d.ts +3 -0
  100. package/lib-esm/ChoiceFieldset/ChoiceFieldCaption.js +20 -0
  101. package/lib-esm/ChoiceFieldset/ChoiceFieldLabel.d.ts +3 -0
  102. package/lib-esm/ChoiceFieldset/ChoiceFieldLabel.js +20 -0
  103. package/lib-esm/ChoiceFieldset/ChoiceFieldset.d.ts +63 -0
  104. package/lib-esm/ChoiceFieldset/ChoiceFieldset.js +72 -0
  105. package/lib-esm/ChoiceFieldset/ChoiceFieldsetDescription.d.ts +3 -0
  106. package/lib-esm/ChoiceFieldset/ChoiceFieldsetDescription.js +17 -0
  107. package/lib-esm/ChoiceFieldset/ChoiceFieldsetLegend.d.ts +6 -0
  108. package/lib-esm/ChoiceFieldset/ChoiceFieldsetLegend.js +31 -0
  109. package/lib-esm/ChoiceFieldset/ChoiceFieldsetList.d.ts +6 -0
  110. package/lib-esm/ChoiceFieldset/ChoiceFieldsetList.js +63 -0
  111. package/lib-esm/ChoiceFieldset/ChoiceFieldsetListContext.d.ts +18 -0
  112. package/lib-esm/ChoiceFieldset/ChoiceFieldsetListContext.js +5 -0
  113. package/lib-esm/ChoiceFieldset/ChoiceFieldsetListItem.d.ts +25 -0
  114. package/lib-esm/ChoiceFieldset/ChoiceFieldsetListItem.js +50 -0
  115. package/lib-esm/ChoiceFieldset/ChoiceFieldsetValidation.d.ts +6 -0
  116. package/lib-esm/ChoiceFieldset/ChoiceFieldsetValidation.js +7 -0
  117. package/lib-esm/ChoiceFieldset/index.d.ts +3 -0
  118. package/lib-esm/ChoiceFieldset/index.js +2 -0
  119. package/lib-esm/Details.d.ts +2 -1
  120. package/lib-esm/Details.js +2 -1
  121. package/lib-esm/Dropdown.d.ts +66 -2
  122. package/lib-esm/Heading.d.ts +2 -1
  123. package/lib-esm/Heading.js +6 -2
  124. package/lib-esm/ProgressBar.d.ts +11 -16
  125. package/lib-esm/ProgressBar.js +11 -7
  126. package/lib-esm/RadioInputField.d.ts +9 -0
  127. package/lib-esm/RadioInputField.js +65 -0
  128. package/lib-esm/Spinner.d.ts +2 -1
  129. package/lib-esm/Spinner.js +2 -1
  130. package/lib-esm/TextInputField.d.ts +581 -0
  131. package/lib-esm/TextInputField.js +50 -0
  132. package/lib-esm/_InputCaption.d.ts +13 -0
  133. package/lib-esm/_InputCaption.js +16 -0
  134. package/lib-esm/_InputField/InputField.d.ts +39 -0
  135. package/lib-esm/_InputField/InputField.js +70 -0
  136. package/lib-esm/_InputField/InputFieldCaption.d.ts +3 -0
  137. package/lib-esm/_InputField/InputFieldCaption.js +18 -0
  138. package/lib-esm/_InputField/InputFieldLabel.d.ts +9 -0
  139. package/lib-esm/_InputField/InputFieldLabel.js +22 -0
  140. package/lib-esm/_InputField/InputFieldValidation.d.ts +6 -0
  141. package/lib-esm/_InputField/InputFieldValidation.js +7 -0
  142. package/lib-esm/_InputField/ToggleInputField.d.ts +13 -0
  143. package/lib-esm/_InputField/ToggleInputField.js +54 -0
  144. package/lib-esm/_InputField/ToggleInputLeadingVisual.d.ts +3 -0
  145. package/lib-esm/_InputField/ToggleInputLeadingVisual.js +11 -0
  146. package/lib-esm/_InputField/ValidationAnimationContainer.d.ts +6 -0
  147. package/lib-esm/_InputField/ValidationAnimationContainer.js +33 -0
  148. package/lib-esm/_InputField/index.d.ts +1 -0
  149. package/lib-esm/_InputField/index.js +1 -0
  150. package/lib-esm/_InputField/slots.d.ts +13 -0
  151. package/lib-esm/_InputField/slots.js +5 -0
  152. package/lib-esm/_InputLabel.d.ts +8 -0
  153. package/lib-esm/_InputLabel.js +32 -0
  154. package/lib-esm/_InputValidation.d.ts +8 -0
  155. package/lib-esm/_InputValidation.js +43 -0
  156. package/lib-esm/_VisuallyHidden.d.ts +6 -0
  157. package/lib-esm/_VisuallyHidden.js +26 -0
  158. package/lib-esm/drafts.d.ts +0 -1
  159. package/lib-esm/drafts.js +1 -2
  160. package/lib-esm/index.d.ts +4 -0
  161. package/lib-esm/index.js +4 -0
  162. package/lib-esm/utils/types/FormValidationStatus.d.ts +1 -0
  163. package/lib-esm/utils/types/FormValidationStatus.js +1 -0
  164. package/package.json +2 -2
  165. package/lib/ActionList2/MenuContext.d.ts +0 -10
  166. package/lib/ActionMenu2.d.ts +0 -310
  167. package/lib/ActionMenu2.js +0 -91
  168. package/lib-esm/ActionList2/MenuContext.d.ts +0 -10
  169. package/lib-esm/ActionList2/MenuContext.js +0 -3
  170. package/lib-esm/ActionMenu2.d.ts +0 -310
  171. package/lib-esm/ActionMenu2.js +0 -67
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _ = require(".");
11
+
12
+ var _InputField = _interopRequireDefault(require("./_InputField/InputField"));
13
+
14
+ var _slots = require("./_InputField/slots");
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ 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); }
19
+
20
+ const Input = /*#__PURE__*/_react.default.forwardRef(({
21
+ as: Component = _.TextInput,
22
+ id: idProp,
23
+ required: requiredProp,
24
+ disabled: disabledProp,
25
+ ...rest
26
+ }, ref) => {
27
+ if (idProp) {
28
+ // eslint-disable-next-line no-console
29
+ console.warn("instead of passing the 'id' prop directly to <TextInputField.Input>, it should be passed to the parent component, <TextInputField>");
30
+ }
31
+
32
+ if (disabledProp) {
33
+ // eslint-disable-next-line no-console
34
+ console.warn("instead of passing the 'disabled' prop directly to <TextInputField.Input>, it should be passed to the parent component, <TextInputField>");
35
+ }
36
+
37
+ if (requiredProp) {
38
+ // eslint-disable-next-line no-console
39
+ console.warn("instead of passing the 'required' prop directly to <TextInputField.Input>, it should be passed to the parent component, <TextInputField>");
40
+ }
41
+
42
+ return /*#__PURE__*/_react.default.createElement(_slots.Slot, {
43
+ name: "Input"
44
+ }, ({
45
+ disabled,
46
+ id,
47
+ required,
48
+ validationMessageId,
49
+ captionId
50
+ }) => /*#__PURE__*/_react.default.createElement(Component, _extends({
51
+ ref: ref,
52
+ "aria-describedby": [validationMessageId, captionId].filter(Boolean).join(' '),
53
+ id: id,
54
+ required: required,
55
+ disabled: disabled
56
+ }, rest)));
57
+ });
58
+
59
+ var _default = Object.assign(_InputField.default, {
60
+ Input,
61
+ Caption: _InputField.default.Caption,
62
+ Label: _InputField.default.Label,
63
+ Validation: _InputField.default.Validation
64
+ });
65
+
66
+ exports.default = _default;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ interface Props {
3
+ /**
4
+ * The unique identifier used to associate the caption with an input
5
+ */
6
+ id: string;
7
+ /**
8
+ * Whether the input associated with this caption is disabled
9
+ */
10
+ disabled?: boolean;
11
+ }
12
+ declare const InputCaption: React.FC<Props>;
13
+ export default InputCaption;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _ = require(".");
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ const InputCaption = ({
15
+ children,
16
+ disabled,
17
+ id
18
+ }) => /*#__PURE__*/_react.default.createElement(_.Text, {
19
+ color: disabled ? 'fg.subtle' : 'fg.muted',
20
+ display: "block",
21
+ fontSize: 0,
22
+ id: id
23
+ }, children);
24
+
25
+ InputCaption.displayName = "InputCaption";
26
+ var _default = InputCaption;
27
+ exports.default = _default;
@@ -0,0 +1,39 @@
1
+ import React from 'react';
2
+ import { ComponentProps } from '../utils/types';
3
+ import { FormValidationStatus } from '../utils/types/FormValidationStatus';
4
+ export interface Props<T = Record<string, FormValidationStatus>> {
5
+ children?: React.ReactNode;
6
+ /**
7
+ * Whether the field is ready for user input
8
+ */
9
+ disabled?: boolean;
10
+ /**
11
+ * The unique identifier for this field. Used to associate the label, validation text, and caption text
12
+ */
13
+ id?: string;
14
+ /**
15
+ * Whether this field must have a value for the user to complete their task
16
+ */
17
+ required?: boolean;
18
+ /**
19
+ * A map of validation statuses and their associated validation keys. When one of the validation keys is passed to the `validationResult` prop,
20
+ * the associated validation message will be rendered in the correct style
21
+ */
22
+ validationMap?: T;
23
+ /**
24
+ * The key of the validation message to show
25
+ */
26
+ validationResult?: keyof T;
27
+ }
28
+ export interface InputFieldContext extends Pick<Props<Record<string, FormValidationStatus>>, 'disabled' | 'id' | 'required'> {
29
+ captionId: string;
30
+ validationMessageId: string;
31
+ }
32
+ declare const InputField: <T extends Record<string, FormValidationStatus>>({ children, disabled, id: idProp, required, validationMap, validationResult }: Props<T>) => JSX.Element;
33
+ export declare type InputFieldComponentProps = ComponentProps<typeof InputField>;
34
+ declare const _default: (<T extends Record<string, FormValidationStatus>>({ children, disabled, id: idProp, required, validationMap, validationResult }: Props<T>) => JSX.Element) & {
35
+ Caption: React.FC<{}>;
36
+ Label: React.FC<import("./InputFieldLabel").Props>;
37
+ Validation: React.FC<import("./InputFieldValidation").InputFieldValidationProps>;
38
+ };
39
+ export default _default;
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _ = require("..");
11
+
12
+ var _InputValidation = _interopRequireDefault(require("../_InputValidation"));
13
+
14
+ var _uniqueId = require("../utils/uniqueId");
15
+
16
+ var _InputFieldCaption = _interopRequireDefault(require("./InputFieldCaption"));
17
+
18
+ var _InputFieldLabel = _interopRequireDefault(require("./InputFieldLabel"));
19
+
20
+ var _InputFieldValidation = _interopRequireDefault(require("./InputFieldValidation"));
21
+
22
+ var _slots = require("./slots");
23
+
24
+ var _ValidationAnimationContainer = _interopRequireDefault(require("./ValidationAnimationContainer"));
25
+
26
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
+
28
+ const InputField = ({
29
+ children,
30
+ disabled,
31
+ id: idProp,
32
+ required,
33
+ validationMap,
34
+ validationResult
35
+ }) => {
36
+ var _React$Children$map, _React$Children$map2;
37
+
38
+ const id = idProp || (0, _uniqueId.uniqueId)();
39
+ const validationChildren = (_React$Children$map = _react.default.Children.map(children, child => /*#__PURE__*/_react.default.isValidElement(child) && child.type === _InputFieldValidation.default ? child : null)) === null || _React$Children$map === void 0 ? void 0 : _React$Children$map.filter(Boolean);
40
+ const captionChildren = (_React$Children$map2 = _react.default.Children.map(children, child => /*#__PURE__*/_react.default.isValidElement(child) && child.type === _InputFieldCaption.default ? child : null)) === null || _React$Children$map2 === void 0 ? void 0 : _React$Children$map2.filter(Boolean);
41
+ const validationChildToRender = validationChildren === null || validationChildren === void 0 ? void 0 : validationChildren.find(child => child.props.validationKey === validationResult);
42
+ const validationMessageId = validationChildToRender ? `${id}-validationMsg` : undefined;
43
+ const captionId = captionChildren !== null && captionChildren !== void 0 && captionChildren.length ? `${id}-caption` : undefined;
44
+ return /*#__PURE__*/_react.default.createElement(_slots.Slots, {
45
+ context: {
46
+ captionId,
47
+ disabled,
48
+ id,
49
+ required,
50
+ validationMessageId
51
+ }
52
+ }, slots => {
53
+ const isLabelHidden = /*#__PURE__*/_react.default.isValidElement(slots.Label) && slots.Label.props.visuallyHidden;
54
+
55
+ if (slots.Input && !slots.Label) {
56
+ // eslint-disable-next-line no-console
57
+ console.error(`The input field with the id ${id} MUST have a Label child (e.g.: <TextInputField.Label>).\n\nIf you want to hide the label, pass the 'visuallyHidden' prop to the Label component.`);
58
+ }
59
+
60
+ return /*#__PURE__*/_react.default.createElement(_.Box, {
61
+ display: "flex",
62
+ flexDirection: "column",
63
+ width: "100%",
64
+ sx: isLabelHidden ? {
65
+ '> *:not(label) + *': {
66
+ marginTop: 2
67
+ }
68
+ } : {
69
+ '> * + *': {
70
+ marginTop: 2
71
+ }
72
+ }
73
+ }, _react.default.Children.toArray(children).filter(child => /*#__PURE__*/_react.default.isValidElement(child) && child.type !== _InputFieldValidation.default), slots.Label, slots.Input, validationChildToRender && validationMap && validationResult && validationMessageId && /*#__PURE__*/_react.default.createElement(_ValidationAnimationContainer.default, {
74
+ show: true
75
+ }, /*#__PURE__*/_react.default.createElement(_InputValidation.default, {
76
+ validationStatus: validationMap[validationResult],
77
+ id: validationMessageId
78
+ }, validationChildToRender)), slots.Caption);
79
+ });
80
+ };
81
+
82
+ InputField.displayName = "InputField";
83
+
84
+ var _default = Object.assign(InputField, {
85
+ Caption: _InputFieldCaption.default,
86
+ Label: _InputFieldLabel.default,
87
+ Validation: _InputFieldValidation.default
88
+ });
89
+
90
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const InputFieldCaption: React.FC;
3
+ export default InputFieldCaption;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _InputCaption = _interopRequireDefault(require("../_InputCaption"));
11
+
12
+ var _slots = require("./slots");
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ const InputFieldCaption = ({
17
+ children
18
+ }) => /*#__PURE__*/_react.default.createElement(_slots.Slot, {
19
+ name: "Caption"
20
+ }, ({
21
+ captionId,
22
+ disabled
23
+ }) => /*#__PURE__*/_react.default.createElement(_InputCaption.default, {
24
+ id: captionId,
25
+ disabled: disabled
26
+ }, children));
27
+
28
+ InputFieldCaption.displayName = "InputFieldCaption";
29
+ var _default = InputFieldCaption;
30
+ exports.default = _default;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ export interface Props {
3
+ /**
4
+ * Whether the label should be visually hidden
5
+ */
6
+ visuallyHidden?: boolean;
7
+ }
8
+ declare const InputFieldLabel: React.FC<Props>;
9
+ export default InputFieldLabel;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _InputLabel = _interopRequireDefault(require("../_InputLabel"));
11
+
12
+ var _slots = require("./slots");
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ const InputFieldLabel = ({
17
+ children,
18
+ visuallyHidden
19
+ }) => /*#__PURE__*/_react.default.createElement(_slots.Slot, {
20
+ name: "Label"
21
+ }, ({
22
+ disabled,
23
+ id,
24
+ required
25
+ }) => /*#__PURE__*/_react.default.createElement(_InputLabel.default, {
26
+ htmlFor: id,
27
+ visuallyHidden: visuallyHidden,
28
+ required: required,
29
+ disabled: disabled
30
+ }, children));
31
+
32
+ InputFieldLabel.displayName = "InputFieldLabel";
33
+ var _default = InputFieldLabel;
34
+ exports.default = _default;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export interface InputFieldValidationProps {
3
+ validationKey: string;
4
+ }
5
+ declare const InputFieldValidation: React.FC<InputFieldValidationProps>;
6
+ export default InputFieldValidation;
@@ -3,13 +3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.MenuContext = void 0;
6
+ exports.default = void 0;
7
7
 
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
 
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
 
12
- /** This context can be used by components that compose ActionList inside a Menu */
13
- const MenuContext = /*#__PURE__*/_react.default.createContext({});
12
+ const InputFieldValidation = ({
13
+ children
14
+ }) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
14
15
 
15
- exports.MenuContext = MenuContext;
16
+ var _default = InputFieldValidation;
17
+ exports.default = _default;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { Props as InputFieldProps } from './InputField';
3
+ import { FormValidationStatus } from '../utils/types/FormValidationStatus';
4
+ export interface ToggleInputFieldProps extends Pick<InputFieldProps, 'disabled' | 'id'> {
5
+ /**
6
+ * Styles the field to visually communicate the result of form validation
7
+ */
8
+ validationStatus?: FormValidationStatus;
9
+ }
10
+ declare const _default: React.FC<ToggleInputFieldProps> & {
11
+ LeadingVisual: React.FC<{}>;
12
+ };
13
+ export default _default;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _ = require("..");
11
+
12
+ var _constants = require("../constants");
13
+
14
+ var _uniqueId = require("../utils/uniqueId");
15
+
16
+ var _slots = require("./slots");
17
+
18
+ var _ToggleInputLeadingVisual = _interopRequireDefault(require("./ToggleInputLeadingVisual"));
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+
22
+ const ToggleInputField = ({
23
+ children,
24
+ disabled,
25
+ id,
26
+ validationStatus
27
+ }) => {
28
+ const fieldId = id || (0, _uniqueId.uniqueId)();
29
+ return /*#__PURE__*/_react.default.createElement(_slots.Slots, {
30
+ context: {
31
+ captionId: `${id}-caption`,
32
+ disabled,
33
+ id: fieldId,
34
+ validationStatus
35
+ }
36
+ }, slots => {
37
+ return /*#__PURE__*/_react.default.createElement(_.Box, {
38
+ display: "flex",
39
+ alignItems: slots.LeadingVisual ? 'center' : undefined
40
+ }, children, /*#__PURE__*/_react.default.createElement(_.Box, {
41
+ sx: {
42
+ '> input': {
43
+ marginLeft: 0,
44
+ marginRight: 0
45
+ }
46
+ }
47
+ }, slots.Input), slots.LeadingVisual && /*#__PURE__*/_react.default.createElement(_.Box, {
48
+ color: disabled ? 'fg.muted' : 'fg.default',
49
+ sx: {
50
+ '> *': {
51
+ minWidth: slots.Caption ? (0, _constants.get)('fontSizes.4') : (0, _constants.get)('fontSizes.2'),
52
+ minHeight: slots.Caption ? (0, _constants.get)('fontSizes.4') : (0, _constants.get)('fontSizes.2'),
53
+ fill: 'currentColor'
54
+ }
55
+ },
56
+ ml: 2
57
+ }, slots.LeadingVisual), /*#__PURE__*/_react.default.isValidElement(slots.Label) && !slots.Label.props.visuallyHidden || slots.Caption ? /*#__PURE__*/_react.default.createElement(_.Box, {
58
+ display: "flex",
59
+ flexDirection: "column",
60
+ ml: 2
61
+ }, slots.Label, slots.Caption) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, slots.Label, slots.Caption));
62
+ });
63
+ };
64
+
65
+ ToggleInputField.displayName = "ToggleInputField";
66
+
67
+ var _default = Object.assign(ToggleInputField, {
68
+ LeadingVisual: _ToggleInputLeadingVisual.default
69
+ });
70
+
71
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const ToggleInputLeadingVisual: React.FC;
3
+ export default ToggleInputLeadingVisual;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _slots = require("./slots");
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ const ToggleInputLeadingVisual = ({
15
+ children
16
+ }) => /*#__PURE__*/_react.default.createElement(_slots.Slot, {
17
+ name: "LeadingVisual"
18
+ }, children);
19
+
20
+ ToggleInputLeadingVisual.displayName = "ToggleInputLeadingVisual";
21
+ var _default = ToggleInputLeadingVisual;
22
+ exports.default = _default;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ interface Props {
3
+ show?: boolean;
4
+ }
5
+ declare const ValidationAnimationContainer: React.FC<Props>;
6
+ export default ValidationAnimationContainer;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _styledComponents = _interopRequireWildcard(require("styled-components"));
11
+
12
+ var _ = require("..");
13
+
14
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
+
16
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
+
18
+ const fadeIn = (0, _styledComponents.keyframes)(["0%{opacity:0;transform:translateY(-100%);}100%{opacity:1;transform:translateY(0);}"]); // using easeOutQuint easing fn https://easings.net/#easeOutQuint
19
+
20
+ const AnimatedElement = _styledComponents.default.div.withConfig({
21
+ displayName: "ValidationAnimationContainer__AnimatedElement",
22
+ componentId: "sc-1grmoaz-0"
23
+ })(["animation:", ";"], props => props.show && (0, _styledComponents.css)(["170ms ", " cubic-bezier(0.44,0.74,0.36,1);"], fadeIn));
24
+
25
+ const ValidationAnimationContainer = ({
26
+ show,
27
+ children
28
+ }) => {
29
+ const [shouldRender, setRender] = (0, _react.useState)(show);
30
+ (0, _react.useEffect)(() => {
31
+ if (show) setRender(true);
32
+ }, [show]);
33
+
34
+ const onAnimationEnd = () => {
35
+ if (!show) setRender(false);
36
+ };
37
+
38
+ return shouldRender ? /*#__PURE__*/_react.default.createElement(_.Box, {
39
+ height: show ? 'auto' : 0,
40
+ overflow: "hidden"
41
+ }, /*#__PURE__*/_react.default.createElement(AnimatedElement, {
42
+ show: show,
43
+ onAnimationEnd: onAnimationEnd
44
+ }, children)) : null;
45
+ };
46
+
47
+ var _default = ValidationAnimationContainer;
48
+ exports.default = _default;
@@ -0,0 +1 @@
1
+ export { default } from './InputField';
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "default", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _InputField.default;
10
+ }
11
+ });
12
+
13
+ var _InputField = _interopRequireDefault(require("./InputField"));
14
+
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ export declare const Slots: import("react").FC<{
3
+ context?: Record<string, unknown> | undefined;
4
+ children: (slots: {
5
+ LeadingVisual?: import("react").ReactNode;
6
+ Caption?: import("react").ReactNode;
7
+ Input?: import("react").ReactNode;
8
+ Label?: import("react").ReactNode;
9
+ }) => import("react").ReactNode;
10
+ }>, Slot: import("react").FC<{
11
+ name: "LeadingVisual" | "Caption" | "Input" | "Label";
12
+ children: import("react").ReactNode;
13
+ }>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Slot = exports.Slots = void 0;
7
+
8
+ var _createSlots = _interopRequireDefault(require("../utils/create-slots"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ const {
13
+ Slots,
14
+ Slot
15
+ } = (0, _createSlots.default)(['Caption', 'Input', 'Label', 'LeadingVisual']);
16
+ exports.Slot = Slot;
17
+ exports.Slots = Slots;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ interface Props extends React.HTMLProps<HTMLLabelElement> {
3
+ disabled?: boolean;
4
+ required?: boolean;
5
+ visuallyHidden?: boolean;
6
+ }
7
+ declare const InputLabel: React.FC<Props>;
8
+ export default InputLabel;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _ = require(".");
11
+
12
+ var _VisuallyHidden = _interopRequireDefault(require("./_VisuallyHidden"));
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ const InputLabel = ({
17
+ children,
18
+ disabled,
19
+ required,
20
+ visuallyHidden,
21
+ htmlFor
22
+ }) => {
23
+ return /*#__PURE__*/_react.default.createElement(_VisuallyHidden.default, {
24
+ isVisible: !visuallyHidden,
25
+ as: "label",
26
+ htmlFor: htmlFor,
27
+ title: required ? 'required field' : undefined,
28
+ sx: {
29
+ fontWeight: 'bold',
30
+ fontSize: 1,
31
+ display: 'block',
32
+ color: disabled ? 'fg.muted' : 'fg.default'
33
+ }
34
+ }, required ? /*#__PURE__*/_react.default.createElement(_.Box, {
35
+ display: "flex",
36
+ as: "span"
37
+ }, /*#__PURE__*/_react.default.createElement(_.Box, {
38
+ mr: 1
39
+ }, children), /*#__PURE__*/_react.default.createElement("span", null, "*")) : children);
40
+ };
41
+
42
+ InputLabel.displayName = "InputLabel";
43
+ var _default = InputLabel;
44
+ exports.default = _default;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { FormValidationStatus } from './utils/types/FormValidationStatus';
3
+ interface Props {
4
+ id: string;
5
+ validationStatus?: FormValidationStatus;
6
+ }
7
+ declare const InputValidation: React.FC<Props>;
8
+ export default InputValidation;