@primer/components 0.0.0-20211030143938 → 0.0.0-20211030163410
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/CHANGELOG.md +8 -2
- package/dist/browser.esm.js +586 -582
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +204 -200
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList/Item.js +2 -2
- package/lib/Autocomplete/AutocompleteMenu.js +6 -13
- package/lib/Checkbox.d.ts +1 -1
- package/lib/CheckboxInputField.d.ts +11 -0
- package/lib/CheckboxInputField.js +74 -0
- package/lib/RadioInputField.d.ts +9 -0
- package/lib/RadioInputField.js +83 -0
- package/lib/TextInputField.d.ts +581 -0
- package/lib/TextInputField.js +66 -0
- package/lib/_InputCaption.d.ts +6 -0
- package/lib/_InputCaption.js +23 -0
- package/lib/_InputField/InputField.d.ts +39 -0
- package/lib/_InputField/InputField.js +90 -0
- package/lib/_InputField/InputFieldCaption.d.ts +3 -0
- package/lib/_InputField/InputFieldCaption.js +28 -0
- package/lib/_InputField/InputFieldLabel.d.ts +9 -0
- package/lib/_InputField/InputFieldLabel.js +34 -0
- package/lib/_InputField/InputFieldValidation.d.ts +6 -0
- package/lib/_InputField/InputFieldValidation.js +17 -0
- package/lib/_InputField/ToggleInputField.d.ts +13 -0
- package/lib/_InputField/ToggleInputField.js +71 -0
- package/lib/_InputField/ToggleInputLeadingVisual.d.ts +3 -0
- package/lib/_InputField/ToggleInputLeadingVisual.js +22 -0
- package/lib/_InputField/ValidationAnimationContainer.d.ts +6 -0
- package/lib/_InputField/ValidationAnimationContainer.js +48 -0
- package/lib/_InputField/index.d.ts +1 -0
- package/lib/_InputField/index.js +15 -0
- package/lib/_InputField/slots.d.ts +13 -0
- package/lib/_InputField/slots.js +17 -0
- package/lib/_InputLabel.d.ts +8 -0
- package/lib/_InputLabel.js +44 -0
- package/lib/_InputValidation.d.ts +8 -0
- package/lib/_InputValidation.js +56 -0
- package/lib/_VisuallyHidden.d.ts +6 -0
- package/lib/_VisuallyHidden.js +39 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +24 -0
- package/lib/utils/types/FormValidationStatus.d.ts +1 -0
- package/lib/utils/types/FormValidationStatus.js +1 -0
- package/lib-esm/ActionList/Item.js +2 -2
- package/lib-esm/Autocomplete/AutocompleteMenu.js +3 -13
- package/lib-esm/Checkbox.d.ts +1 -1
- package/lib-esm/CheckboxInputField.d.ts +11 -0
- package/lib-esm/CheckboxInputField.js +57 -0
- package/lib-esm/RadioInputField.d.ts +9 -0
- package/lib-esm/RadioInputField.js +66 -0
- package/lib-esm/TextInputField.d.ts +581 -0
- package/lib-esm/TextInputField.js +50 -0
- package/lib-esm/_InputCaption.d.ts +6 -0
- package/lib-esm/_InputCaption.js +12 -0
- package/lib-esm/_InputField/InputField.d.ts +39 -0
- package/lib-esm/_InputField/InputField.js +70 -0
- package/lib-esm/_InputField/InputFieldCaption.d.ts +3 -0
- package/lib-esm/_InputField/InputFieldCaption.js +16 -0
- package/lib-esm/_InputField/InputFieldLabel.d.ts +9 -0
- package/lib-esm/_InputField/InputFieldLabel.js +22 -0
- package/lib-esm/_InputField/InputFieldValidation.d.ts +6 -0
- package/lib-esm/_InputField/InputFieldValidation.js +7 -0
- package/lib-esm/_InputField/ToggleInputField.d.ts +13 -0
- package/lib-esm/_InputField/ToggleInputField.js +54 -0
- package/lib-esm/_InputField/ToggleInputLeadingVisual.d.ts +3 -0
- package/lib-esm/_InputField/ToggleInputLeadingVisual.js +11 -0
- package/lib-esm/_InputField/ValidationAnimationContainer.d.ts +6 -0
- package/lib-esm/_InputField/ValidationAnimationContainer.js +33 -0
- package/lib-esm/_InputField/index.d.ts +1 -0
- package/lib-esm/_InputField/index.js +1 -0
- package/lib-esm/_InputField/slots.d.ts +13 -0
- package/lib-esm/_InputField/slots.js +5 -0
- package/lib-esm/_InputLabel.d.ts +8 -0
- package/lib-esm/_InputLabel.js +32 -0
- package/lib-esm/_InputValidation.d.ts +8 -0
- package/lib-esm/_InputValidation.js +43 -0
- package/lib-esm/_VisuallyHidden.d.ts +6 -0
- package/lib-esm/_VisuallyHidden.js +26 -0
- package/lib-esm/index.d.ts +3 -0
- package/lib-esm/index.js +3 -0
- package/lib-esm/utils/types/FormValidationStatus.d.ts +1 -0
- package/lib-esm/utils/types/FormValidationStatus.js +1 -0
- package/package.json +2 -2
@@ -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,23 @@
|
|
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
|
+
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); }
|
15
|
+
|
16
|
+
const InputCaption = props => /*#__PURE__*/_react.default.createElement(_.Text, _extends({
|
17
|
+
color: "fg.muted",
|
18
|
+
fontSize: 0
|
19
|
+
}, props));
|
20
|
+
|
21
|
+
InputCaption.displayName = "InputCaption";
|
22
|
+
var _default = InputCaption;
|
23
|
+
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,28 @@
|
|
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
|
+
}) => /*#__PURE__*/_react.default.createElement(_InputCaption.default, {
|
23
|
+
id: captionId
|
24
|
+
}, children));
|
25
|
+
|
26
|
+
InputFieldCaption.displayName = "InputFieldCaption";
|
27
|
+
var _default = InputFieldCaption;
|
28
|
+
exports.default = _default;
|
@@ -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,17 @@
|
|
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
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
|
+
|
12
|
+
const InputFieldValidation = ({
|
13
|
+
children
|
14
|
+
}) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
|
15
|
+
|
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 Props 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<Props> & {
|
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,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,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,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;
|