1 | import { string, oneOfType, element, func, bool } from 'prop-types';
|
2 | import { c as _objectWithoutPropertiesLoose } from './chunk-1f79df9b.js';
|
3 | import Box from 'reakit/Box';
|
4 | import 'reakit/Block';
|
5 | import 'reakit/Inline';
|
6 | import 'reakit/InlineBlock';
|
7 | import Flex from 'reakit/Flex';
|
8 | import 'reakit/InlineFlex';
|
9 | import 'reakit/Grid';
|
10 | import { createElement, cloneElement } from 'react';
|
11 | import _FieldWrapper, { Label, OptionalText, DescriptionText, HintText, ValidationText } from './FieldWrapper/styled.js';
|
12 |
|
13 | var FieldWrapper = function FieldWrapper(_ref) {
|
14 | var a11yId = _ref.a11yId,
|
15 | children = _ref.children,
|
16 | description = _ref.description,
|
17 | hint = _ref.hint,
|
18 | isOptional = _ref.isOptional,
|
19 | isRequired = _ref.isRequired,
|
20 | label = _ref.label,
|
21 | state = _ref.state,
|
22 | validationText = _ref.validationText,
|
23 | props = _objectWithoutPropertiesLoose(_ref, ["a11yId", "children", "description", "hint", "isOptional", "isRequired", "label", "state", "validationText"]);
|
24 |
|
25 | var elementProps = {
|
26 | isRequired: isRequired,
|
27 | a11yId: a11yId,
|
28 | state: state
|
29 | };
|
30 | return createElement(_FieldWrapper, props, label && createElement(Box, {
|
31 | marginBottom: "minor-2"
|
32 | }, createElement(Flex, {
|
33 | alignItems: "center"
|
34 | }, typeof label === 'string' ? createElement(Label, {
|
35 | htmlFor: a11yId
|
36 | }, label) : label, isOptional && createElement(OptionalText, null, "OPTIONAL")), typeof description === 'string' ? createElement(DescriptionText, null, description) : createElement("div", null, description)), typeof children === 'function' ? children({
|
37 | elementProps: elementProps
|
38 | }) : cloneElement(children, elementProps), typeof hint === 'string' ? createElement(HintText, null, hint) : createElement("div", null, hint), validationText && createElement(ValidationText, {
|
39 | color: state
|
40 | }, validationText));
|
41 | };
|
42 | var fieldWrapperPropTypes = {
|
43 | a11yId: string,
|
44 | children: oneOfType([element, func]).isRequired,
|
45 | className: string,
|
46 | description: oneOfType([string, element]),
|
47 | hint: oneOfType([string, element]),
|
48 | isOptional: bool,
|
49 | isRequired: bool,
|
50 | label: oneOfType([string, element]),
|
51 | state: string,
|
52 | validationText: string
|
53 | };
|
54 | FieldWrapper.propTypes = fieldWrapperPropTypes;
|
55 | var fieldWrapperDefaultProps = {
|
56 | a11yId: undefined,
|
57 | className: undefined,
|
58 | description: undefined,
|
59 | hint: undefined,
|
60 | isOptional: undefined,
|
61 | isRequired: undefined,
|
62 | label: undefined,
|
63 | state: undefined,
|
64 | validationText: undefined
|
65 | };
|
66 | FieldWrapper.defaultProps = fieldWrapperDefaultProps;
|
67 |
|
68 | var C = FieldWrapper;
|
69 |
|
70 | export { C as a, fieldWrapperPropTypes as b, fieldWrapperDefaultProps as c };
|