@elliemae/ds-form-layout-blocks 2.3.0-alpha.8 → 2.3.0-next.2
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/cjs/form-layout-block-item/DSFormLayoutBlockItem.js +67 -0
- package/cjs/form-layout-block-item/index.d.js +2 -0
- package/cjs/form-layout-block-item/index.js +10 -0
- package/cjs/form-layout-block-item/propTypes.js +23 -0
- package/cjs/form-layout-block-item/styles.js +92 -0
- package/cjs/form-layout-checkbox-group/DSFormLayoutCheckboxGroup.js +30 -0
- package/cjs/form-layout-checkbox-group/config/useValidateProps.js +36 -0
- package/cjs/form-layout-checkbox-group/defaultProps.js +9 -0
- package/cjs/form-layout-checkbox-group/index.d.js +2 -0
- package/cjs/form-layout-checkbox-group/index.js +10 -0
- package/cjs/form-layout-checkbox-group/propTypes.js +11 -0
- package/cjs/form-layout-checkbox-group/styles.js +46 -0
- package/cjs/index.d.js +2 -0
- package/cjs/index.js +13 -0
- package/esm/form-layout-block-item/DSFormLayoutBlockItem.js +58 -0
- package/esm/form-layout-block-item/index.d.js +1 -0
- package/esm/form-layout-block-item/index.js +1 -0
- package/esm/form-layout-block-item/propTypes.js +19 -0
- package/esm/form-layout-block-item/styles.js +80 -0
- package/esm/form-layout-checkbox-group/DSFormLayoutCheckboxGroup.js +21 -0
- package/esm/form-layout-checkbox-group/config/useValidateProps.js +28 -0
- package/esm/form-layout-checkbox-group/defaultProps.js +5 -0
- package/esm/form-layout-checkbox-group/index.d.js +1 -0
- package/esm/form-layout-checkbox-group/index.js +1 -0
- package/esm/form-layout-checkbox-group/propTypes.js +7 -0
- package/esm/form-layout-checkbox-group/styles.js +38 -0
- package/esm/index.d.js +1 -0
- package/esm/index.js +2 -0
- package/package.json +37 -39
- package/types/form-layout-block-item/DSFormLayoutBlockItem.d.ts +77 -0
- package/types/form-layout-block-item/index.d.d.ts +35 -0
- package/types/form-layout-block-item/index.d.ts +1 -0
- package/types/form-layout-block-item/propTypes.d.ts +66 -0
- package/types/form-layout-block-item/styles.d.ts +6 -0
- package/types/form-layout-checkbox-group/DSFormLayoutCheckboxGroup.d.ts +20 -0
- package/types/form-layout-checkbox-group/config/useValidateProps.d.ts +2 -0
- package/types/form-layout-checkbox-group/defaultProps.d.ts +3 -0
- package/types/form-layout-checkbox-group/index.d.d.ts +10 -0
- package/types/form-layout-checkbox-group/index.d.ts +1 -0
- package/types/form-layout-checkbox-group/propTypes.d.ts +9 -0
- package/types/form-layout-checkbox-group/styles.d.ts +2 -0
- package/types/index.d.ts +2 -0
- package/dist/cjs/form-layout-block-item/DSFormLayoutBlockItem.js +0 -89
- package/dist/cjs/form-layout-block-item/DSFormLayoutBlockItem.js.map +0 -7
- package/dist/cjs/form-layout-block-item/index.d.js +0 -27
- package/dist/cjs/form-layout-block-item/index.d.js.map +0 -7
- package/dist/cjs/form-layout-block-item/index.js +0 -28
- package/dist/cjs/form-layout-block-item/index.js.map +0 -7
- package/dist/cjs/form-layout-block-item/propTypes.js +0 -50
- package/dist/cjs/form-layout-block-item/propTypes.js.map +0 -7
- package/dist/cjs/form-layout-block-item/styles.js +0 -125
- package/dist/cjs/form-layout-block-item/styles.js.map +0 -7
- package/dist/cjs/form-layout-checkbox-group/DSFormLayoutCheckboxGroup.js +0 -52
- package/dist/cjs/form-layout-checkbox-group/DSFormLayoutCheckboxGroup.js.map +0 -7
- package/dist/cjs/form-layout-checkbox-group/config/useValidateProps.js +0 -66
- package/dist/cjs/form-layout-checkbox-group/config/useValidateProps.js.map +0 -7
- package/dist/cjs/form-layout-checkbox-group/defaultProps.js +0 -37
- package/dist/cjs/form-layout-checkbox-group/defaultProps.js.map +0 -7
- package/dist/cjs/form-layout-checkbox-group/index.d.js +0 -27
- package/dist/cjs/form-layout-checkbox-group/index.d.js.map +0 -7
- package/dist/cjs/form-layout-checkbox-group/index.js +0 -28
- package/dist/cjs/form-layout-checkbox-group/index.js.map +0 -7
- package/dist/cjs/form-layout-checkbox-group/propTypes.js +0 -38
- package/dist/cjs/form-layout-checkbox-group/propTypes.js.map +0 -7
- package/dist/cjs/form-layout-checkbox-group/styles.js +0 -50
- package/dist/cjs/form-layout-checkbox-group/styles.js.map +0 -7
- package/dist/cjs/index.d.js +0 -29
- package/dist/cjs/index.d.js.map +0 -7
- package/dist/cjs/index.js +0 -29
- package/dist/cjs/index.js.map +0 -7
- package/dist/esm/form-layout-block-item/DSFormLayoutBlockItem.js +0 -60
- package/dist/esm/form-layout-block-item/DSFormLayoutBlockItem.js.map +0 -7
- package/dist/esm/form-layout-block-item/index.d.js +0 -2
- package/dist/esm/form-layout-block-item/index.d.js.map +0 -7
- package/dist/esm/form-layout-block-item/index.js +0 -3
- package/dist/esm/form-layout-block-item/index.js.map +0 -7
- package/dist/esm/form-layout-block-item/propTypes.js +0 -21
- package/dist/esm/form-layout-block-item/propTypes.js.map +0 -7
- package/dist/esm/form-layout-block-item/styles.js +0 -96
- package/dist/esm/form-layout-block-item/styles.js.map +0 -7
- package/dist/esm/form-layout-checkbox-group/DSFormLayoutCheckboxGroup.js +0 -23
- package/dist/esm/form-layout-checkbox-group/DSFormLayoutCheckboxGroup.js.map +0 -7
- package/dist/esm/form-layout-checkbox-group/config/useValidateProps.js +0 -37
- package/dist/esm/form-layout-checkbox-group/config/useValidateProps.js.map +0 -7
- package/dist/esm/form-layout-checkbox-group/defaultProps.js +0 -8
- package/dist/esm/form-layout-checkbox-group/defaultProps.js.map +0 -7
- package/dist/esm/form-layout-checkbox-group/index.d.js +0 -2
- package/dist/esm/form-layout-checkbox-group/index.d.js.map +0 -7
- package/dist/esm/form-layout-checkbox-group/index.js +0 -3
- package/dist/esm/form-layout-checkbox-group/index.js.map +0 -7
- package/dist/esm/form-layout-checkbox-group/propTypes.js +0 -9
- package/dist/esm/form-layout-checkbox-group/propTypes.js.map +0 -7
- package/dist/esm/form-layout-checkbox-group/styles.js +0 -21
- package/dist/esm/form-layout-checkbox-group/styles.js.map +0 -7
- package/dist/esm/index.d.js +0 -4
- package/dist/esm/index.d.js.map +0 -7
- package/dist/esm/index.js +0 -4
- package/dist/esm/index.js.map +0 -7
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var reactDesc = require('react-desc');
|
|
8
|
+
var uid = require('uid');
|
|
9
|
+
var propTypes = require('./propTypes.js');
|
|
10
|
+
var styles = require('./styles.js');
|
|
11
|
+
|
|
12
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
|
+
|
|
14
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
15
|
+
|
|
16
|
+
const DSFormLayoutBlockItem = props => {
|
|
17
|
+
const {
|
|
18
|
+
label,
|
|
19
|
+
feedbackMessage,
|
|
20
|
+
validationMessage,
|
|
21
|
+
inputID,
|
|
22
|
+
children,
|
|
23
|
+
hasError,
|
|
24
|
+
leftLabel,
|
|
25
|
+
required,
|
|
26
|
+
optional,
|
|
27
|
+
hideLabel,
|
|
28
|
+
fitContent,
|
|
29
|
+
withHighlight,
|
|
30
|
+
isGroup = false
|
|
31
|
+
} = props;
|
|
32
|
+
const instanceUID = React.useMemo(() => uid.uid(6), []);
|
|
33
|
+
return /*#__PURE__*/_jsx__default["default"](styles.StyledContainer, {
|
|
34
|
+
leftLabel: leftLabel,
|
|
35
|
+
fitContent: fitContent,
|
|
36
|
+
hideLabel: hideLabel,
|
|
37
|
+
withHighlight: withHighlight,
|
|
38
|
+
as: isGroup ? 'fieldset' : 'div',
|
|
39
|
+
isGroup: isGroup,
|
|
40
|
+
"aria-describedby": "".concat(inputID || instanceUID, "_feedback_message")
|
|
41
|
+
}, void 0, /*#__PURE__*/_jsx__default["default"](styles.StyledLabel, {
|
|
42
|
+
htmlFor: inputID,
|
|
43
|
+
leftLabel: leftLabel,
|
|
44
|
+
hideLabel: hideLabel,
|
|
45
|
+
"aria-hidden": isGroup
|
|
46
|
+
}, void 0, label, (required || optional) && /*#__PURE__*/_jsx__default["default"](styles.StyledMark, {
|
|
47
|
+
required: required
|
|
48
|
+
})), isGroup && /*#__PURE__*/_jsx__default["default"](styles.ScreenReaderOnly, {
|
|
49
|
+
as: "legend"
|
|
50
|
+
}, void 0, "".concat(label, ". ").concat(feedbackMessage || '')), children, feedbackMessage && !hasError && /*#__PURE__*/_jsx__default["default"](styles.StyledMessage, {
|
|
51
|
+
leftLabel: leftLabel,
|
|
52
|
+
hideLabel: hideLabel,
|
|
53
|
+
"aria-hidden": isGroup,
|
|
54
|
+
id: "".concat(inputID || instanceUID, "_feedback_message")
|
|
55
|
+
}, void 0, feedbackMessage), validationMessage && hasError && /*#__PURE__*/_jsx__default["default"](styles.StyledMessage, {
|
|
56
|
+
hasError: hasError,
|
|
57
|
+
leftLabel: leftLabel,
|
|
58
|
+
hideLabel: hideLabel,
|
|
59
|
+
role: "alert"
|
|
60
|
+
}, void 0, validationMessage));
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const DSFormLayoutBlockItemWithSchema = reactDesc.describe(DSFormLayoutBlockItem);
|
|
64
|
+
DSFormLayoutBlockItemWithSchema.propTypes = propTypes.propTypes;
|
|
65
|
+
|
|
66
|
+
exports.DSFormLayoutBlockItem = DSFormLayoutBlockItem;
|
|
67
|
+
exports.DSFormLayoutBlockItemWithSchema = DSFormLayoutBlockItemWithSchema;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var DSFormLayoutBlockItem = require('./DSFormLayoutBlockItem.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.DSFormLayoutBlockItem = DSFormLayoutBlockItem.DSFormLayoutBlockItem;
|
|
10
|
+
exports.DSFormLayoutBlockItemWithSchema = DSFormLayoutBlockItem.DSFormLayoutBlockItemWithSchema;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var reactDesc = require('react-desc');
|
|
6
|
+
|
|
7
|
+
const propTypes = {
|
|
8
|
+
children: reactDesc.PropTypes.node.isRequired.description('Input component. '),
|
|
9
|
+
label: reactDesc.PropTypes.string.isRequired.description('Label property for the input component. This property is required for accesibility purposes.'),
|
|
10
|
+
inputID: reactDesc.PropTypes.string.isRequired.description("String that matches the input component's id. This property is required for accesibility purposes."),
|
|
11
|
+
feedbackMessage: reactDesc.PropTypes.string.description('Feedback message to show below the input component.'),
|
|
12
|
+
validationMessage: reactDesc.PropTypes.string.description('Validation message to show below the input component. It requires hasError property set to true to be visible.'),
|
|
13
|
+
hasError: reactDesc.PropTypes.bool.description('Helper boolean property for the validation message.'),
|
|
14
|
+
required: reactDesc.PropTypes.bool.description('Adds required extra styling.'),
|
|
15
|
+
optional: reactDesc.PropTypes.bool.description('Adds optional extra styling.'),
|
|
16
|
+
fitContent: reactDesc.PropTypes.bool.description('Set the width of the layout to the input component.'),
|
|
17
|
+
leftLabel: reactDesc.PropTypes.bool.description('Adds the label at the left of the input component.'),
|
|
18
|
+
hideLabel: reactDesc.PropTypes.bool.description('Hides the input label. It still requires label and labelFor property for accesibility purposes'),
|
|
19
|
+
withHighlight: reactDesc.PropTypes.bool.description('Adds highlight extra styling. It requires extra spacing, please check withHighlight explanation tab.'),
|
|
20
|
+
isGroup: reactDesc.PropTypes.bool.description('Sets the HTML elements as fieldset and legend. This should be used when you want to group more than one input.')
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.propTypes = propTypes;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var styled = require('styled-components');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
10
|
+
|
|
11
|
+
const StyledContainer = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
12
|
+
componentId: "sc-196zgtg-0"
|
|
13
|
+
})(["position:relative;padding:0;margin:0;display:grid;", " ", ";", " align-items:center;", ""], _ref => {
|
|
14
|
+
let {
|
|
15
|
+
fitContent
|
|
16
|
+
} = _ref;
|
|
17
|
+
return fitContent ? 'width: fit-content;' : undefined;
|
|
18
|
+
}, _ref2 => {
|
|
19
|
+
let {
|
|
20
|
+
isGroup
|
|
21
|
+
} = _ref2;
|
|
22
|
+
return isGroup ? 'border: none' : '';
|
|
23
|
+
}, _ref3 => {
|
|
24
|
+
let {
|
|
25
|
+
leftLabel,
|
|
26
|
+
hideLabel
|
|
27
|
+
} = _ref3;
|
|
28
|
+
return leftLabel && !hideLabel ? 'grid-template-columns: max-content auto;' : undefined;
|
|
29
|
+
}, _ref4 => {
|
|
30
|
+
let {
|
|
31
|
+
theme,
|
|
32
|
+
withHighlight
|
|
33
|
+
} = _ref4;
|
|
34
|
+
return withHighlight ? "\n &::after {\n position: absolute;\n content: '';\n left: -".concat(theme.space.xxs, ";\n top: -").concat(theme.space.xxxs, ";\n z-index: -1;\n width: calc(100% + ").concat(theme.space.xs, ");\n height: calc(100% + ").concat(theme.space.xxs, ");\n background-color: #FEFBEE;\n border : 1px solid #8F6326;\n border-radius : 4px;\n box-shadow: 0 1px 3px 0 rgba(0,0,0,0.35);\n }\n &:hover, \n &:focus-within {\n &::after {\n position: absolute;\n content: '';\n left: -").concat(theme.space.xxs, ";\n top: -").concat(theme.space.xxxs, ";\n z-index: -1;\n width: calc(100% + ").concat(theme.space.xs, ");\n height: calc(100% + ").concat(theme.space.xxs, ");\n background-color: #FFF9D3;\n border : 2px solid #8F6326;\n border-radius : 4px;\n box-shadow: 0 6px 10px 0 rgba(0,0,0,0.30);\n }\n }\n ") : undefined;
|
|
35
|
+
});
|
|
36
|
+
const StyledLabel = /*#__PURE__*/styled__default["default"].label.withConfig({
|
|
37
|
+
componentId: "sc-196zgtg-1"
|
|
38
|
+
})(["display:flex;", " ", ""], _ref5 => {
|
|
39
|
+
let {
|
|
40
|
+
theme,
|
|
41
|
+
leftLabel
|
|
42
|
+
} = _ref5;
|
|
43
|
+
return leftLabel ? "padding-right: ".concat(theme.space.xxs, ";") : undefined;
|
|
44
|
+
}, _ref6 => {
|
|
45
|
+
let {
|
|
46
|
+
hideLabel
|
|
47
|
+
} = _ref6;
|
|
48
|
+
return hideLabel ? "position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n " : undefined;
|
|
49
|
+
});
|
|
50
|
+
const StyledMessage = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
51
|
+
componentId: "sc-196zgtg-2"
|
|
52
|
+
})(["font-size:", ";font-style:italic;text-align:right;line-height:15px;height:15px;overflow:hidden;text-overflow:ellipsis;color:", ";", ""], _ref7 => {
|
|
53
|
+
let {
|
|
54
|
+
theme
|
|
55
|
+
} = _ref7;
|
|
56
|
+
return theme.fontSizes.microText[200];
|
|
57
|
+
}, _ref8 => {
|
|
58
|
+
let {
|
|
59
|
+
theme,
|
|
60
|
+
hasError
|
|
61
|
+
} = _ref8;
|
|
62
|
+
return hasError ? theme.colors.danger[900] : theme.colors.neutral[500];
|
|
63
|
+
}, _ref9 => {
|
|
64
|
+
let {
|
|
65
|
+
leftLabel,
|
|
66
|
+
hideLabel
|
|
67
|
+
} = _ref9;
|
|
68
|
+
return leftLabel && !hideLabel ? 'grid-column: 1/3;' : undefined;
|
|
69
|
+
});
|
|
70
|
+
const StyledMark = /*#__PURE__*/styled__default["default"].span.withConfig({
|
|
71
|
+
componentId: "sc-196zgtg-3"
|
|
72
|
+
})(["width:6px;height:6px;border-radius:50%;margin-left:", ";", ""], _ref10 => {
|
|
73
|
+
let {
|
|
74
|
+
theme
|
|
75
|
+
} = _ref10;
|
|
76
|
+
return theme.space.xxxs;
|
|
77
|
+
}, _ref11 => {
|
|
78
|
+
let {
|
|
79
|
+
theme,
|
|
80
|
+
required
|
|
81
|
+
} = _ref11;
|
|
82
|
+
return required ? "\n background-color: ".concat(theme.colors.danger[900], ";\n ") : "\n border: 1px solid ".concat(theme.colors.brand[600], ";\n ");
|
|
83
|
+
});
|
|
84
|
+
const ScreenReaderOnly = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
85
|
+
componentId: "sc-196zgtg-4"
|
|
86
|
+
})(["clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px;"]);
|
|
87
|
+
|
|
88
|
+
exports.ScreenReaderOnly = ScreenReaderOnly;
|
|
89
|
+
exports.StyledContainer = StyledContainer;
|
|
90
|
+
exports.StyledLabel = StyledLabel;
|
|
91
|
+
exports.StyledMark = StyledMark;
|
|
92
|
+
exports.StyledMessage = StyledMessage;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
6
|
+
require('react');
|
|
7
|
+
var reactDesc = require('react-desc');
|
|
8
|
+
var dsPropsHelpers = require('@elliemae/ds-props-helpers');
|
|
9
|
+
var propTypes = require('./propTypes.js');
|
|
10
|
+
var styles = require('./styles.js');
|
|
11
|
+
var defaultProps = require('./defaultProps.js');
|
|
12
|
+
var useValidateProps = require('./config/useValidateProps.js');
|
|
13
|
+
|
|
14
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
|
+
|
|
16
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
17
|
+
|
|
18
|
+
const DSFormLayoutCheckboxGroup = props => {
|
|
19
|
+
useValidateProps.useValidateProps(props);
|
|
20
|
+
const propsWithDefault = dsPropsHelpers.useMemoMergePropsWithDefault(props, defaultProps.defaultProps);
|
|
21
|
+
return /*#__PURE__*/_jsx__default["default"](styles.StyledContainer, {
|
|
22
|
+
direction: propsWithDefault.direction
|
|
23
|
+
}, void 0, propsWithDefault.children);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const DSFormLayoutCheckboxGroupWithSchema = reactDesc.describe(DSFormLayoutCheckboxGroup);
|
|
27
|
+
DSFormLayoutCheckboxGroupWithSchema.propTypes = propTypes.propTypes;
|
|
28
|
+
|
|
29
|
+
exports.DSFormLayoutCheckboxGroup = DSFormLayoutCheckboxGroup;
|
|
30
|
+
exports.DSFormLayoutCheckboxGroupWithSchema = DSFormLayoutCheckboxGroupWithSchema;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
10
|
+
|
|
11
|
+
const getVariableType = arg => {
|
|
12
|
+
if (Array.isArray(arg)) return 'array';
|
|
13
|
+
if (arg === null) return 'null';
|
|
14
|
+
if (arg === undefined) return 'undefined';
|
|
15
|
+
return typeof arg;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const throwCheckboxGroupDirectionError = invalidProp => {
|
|
19
|
+
throw new Error("You are trying to pass a not valid \"direction\" property value for a checkbox group, please provide a valid type.\n\n Received: ".concat(invalidProp, " (").concat(getVariableType(invalidProp), ")\n Expected: \"horizontal\" or \"vertical\" (string)\n "));
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const throwCheckboxGroupChildrenError = () => {
|
|
23
|
+
throw new Error("You are trying to use a checkbox group without any React children, please provide at least one children to use.\n \n Received: (null)\n Expected: React children\n ");
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const useValidateProps = props => {
|
|
27
|
+
if (props.direction !== undefined && props.direction !== 'vertical' && props.direction !== 'horizontal') {
|
|
28
|
+
throwCheckboxGroupDirectionError(props.direction);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (!React__default["default"].Children.count(props.children)) {
|
|
32
|
+
throwCheckboxGroupChildrenError();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.useValidateProps = useValidateProps;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var DSFormLayoutCheckboxGroup = require('./DSFormLayoutCheckboxGroup.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.DSFormLayoutCheckboxGroup = DSFormLayoutCheckboxGroup.DSFormLayoutCheckboxGroup;
|
|
10
|
+
exports.DSFormLayoutCheckboxGroupWithSchema = DSFormLayoutCheckboxGroup.DSFormLayoutCheckboxGroupWithSchema;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var reactDesc = require('react-desc');
|
|
6
|
+
|
|
7
|
+
const propTypes = {
|
|
8
|
+
direction: reactDesc.PropTypes.oneOf(['horizontal', 'vertical']).description('Set direction for the checkbox group.')
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
exports.propTypes = propTypes;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var styled = require('styled-components');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
10
|
+
|
|
11
|
+
const StyledContainer = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
12
|
+
componentId: "sc-1wopk9q-0"
|
|
13
|
+
})(["display:inline-flex;flex-wrap:wrap;flex-direction:", ";margin-left:", ";margin-right:", ";margin-top:", ";& div{padding:0;margin-bottom:", ";}& div:not(:last-child){margin-right:", ";}"], _ref => {
|
|
14
|
+
let {
|
|
15
|
+
direction
|
|
16
|
+
} = _ref;
|
|
17
|
+
return direction === 'horizontal' ? 'row' : 'column';
|
|
18
|
+
}, _ref2 => {
|
|
19
|
+
let {
|
|
20
|
+
theme
|
|
21
|
+
} = _ref2;
|
|
22
|
+
return theme.space.xs;
|
|
23
|
+
}, _ref3 => {
|
|
24
|
+
let {
|
|
25
|
+
theme
|
|
26
|
+
} = _ref3;
|
|
27
|
+
return theme.space.xs;
|
|
28
|
+
}, _ref4 => {
|
|
29
|
+
let {
|
|
30
|
+
theme
|
|
31
|
+
} = _ref4;
|
|
32
|
+
return theme.space.xxs;
|
|
33
|
+
}, _ref5 => {
|
|
34
|
+
let {
|
|
35
|
+
theme
|
|
36
|
+
} = _ref5;
|
|
37
|
+
return theme.space.xxs;
|
|
38
|
+
}, _ref6 => {
|
|
39
|
+
let {
|
|
40
|
+
theme,
|
|
41
|
+
direction
|
|
42
|
+
} = _ref6;
|
|
43
|
+
return direction === 'horizontal' ? theme.space.s : '0';
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
exports.StyledContainer = StyledContainer;
|
package/cjs/index.d.js
ADDED
package/cjs/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var DSFormLayoutBlockItem = require('./form-layout-block-item/DSFormLayoutBlockItem.js');
|
|
6
|
+
var DSFormLayoutCheckboxGroup = require('./form-layout-checkbox-group/DSFormLayoutCheckboxGroup.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.DSFormLayoutBlockItem = DSFormLayoutBlockItem.DSFormLayoutBlockItem;
|
|
11
|
+
exports.DSFormLayoutBlockItemWithSchema = DSFormLayoutBlockItem.DSFormLayoutBlockItemWithSchema;
|
|
12
|
+
exports.DSFormLayoutCheckboxGroup = DSFormLayoutCheckboxGroup.DSFormLayoutCheckboxGroup;
|
|
13
|
+
exports.DSFormLayoutCheckboxGroupWithSchema = DSFormLayoutCheckboxGroup.DSFormLayoutCheckboxGroupWithSchema;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { describe } from 'react-desc';
|
|
4
|
+
import { uid } from 'uid';
|
|
5
|
+
import { propTypes } from './propTypes.js';
|
|
6
|
+
import { StyledContainer, StyledLabel, StyledMark, ScreenReaderOnly, StyledMessage } from './styles.js';
|
|
7
|
+
|
|
8
|
+
const DSFormLayoutBlockItem = props => {
|
|
9
|
+
const {
|
|
10
|
+
label,
|
|
11
|
+
feedbackMessage,
|
|
12
|
+
validationMessage,
|
|
13
|
+
inputID,
|
|
14
|
+
children,
|
|
15
|
+
hasError,
|
|
16
|
+
leftLabel,
|
|
17
|
+
required,
|
|
18
|
+
optional,
|
|
19
|
+
hideLabel,
|
|
20
|
+
fitContent,
|
|
21
|
+
withHighlight,
|
|
22
|
+
isGroup = false
|
|
23
|
+
} = props;
|
|
24
|
+
const instanceUID = useMemo(() => uid(6), []);
|
|
25
|
+
return /*#__PURE__*/_jsx(StyledContainer, {
|
|
26
|
+
leftLabel: leftLabel,
|
|
27
|
+
fitContent: fitContent,
|
|
28
|
+
hideLabel: hideLabel,
|
|
29
|
+
withHighlight: withHighlight,
|
|
30
|
+
as: isGroup ? 'fieldset' : 'div',
|
|
31
|
+
isGroup: isGroup,
|
|
32
|
+
"aria-describedby": "".concat(inputID || instanceUID, "_feedback_message")
|
|
33
|
+
}, void 0, /*#__PURE__*/_jsx(StyledLabel, {
|
|
34
|
+
htmlFor: inputID,
|
|
35
|
+
leftLabel: leftLabel,
|
|
36
|
+
hideLabel: hideLabel,
|
|
37
|
+
"aria-hidden": isGroup
|
|
38
|
+
}, void 0, label, (required || optional) && /*#__PURE__*/_jsx(StyledMark, {
|
|
39
|
+
required: required
|
|
40
|
+
})), isGroup && /*#__PURE__*/_jsx(ScreenReaderOnly, {
|
|
41
|
+
as: "legend"
|
|
42
|
+
}, void 0, "".concat(label, ". ").concat(feedbackMessage || '')), children, feedbackMessage && !hasError && /*#__PURE__*/_jsx(StyledMessage, {
|
|
43
|
+
leftLabel: leftLabel,
|
|
44
|
+
hideLabel: hideLabel,
|
|
45
|
+
"aria-hidden": isGroup,
|
|
46
|
+
id: "".concat(inputID || instanceUID, "_feedback_message")
|
|
47
|
+
}, void 0, feedbackMessage), validationMessage && hasError && /*#__PURE__*/_jsx(StyledMessage, {
|
|
48
|
+
hasError: hasError,
|
|
49
|
+
leftLabel: leftLabel,
|
|
50
|
+
hideLabel: hideLabel,
|
|
51
|
+
role: "alert"
|
|
52
|
+
}, void 0, validationMessage));
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const DSFormLayoutBlockItemWithSchema = describe(DSFormLayoutBlockItem);
|
|
56
|
+
DSFormLayoutBlockItemWithSchema.propTypes = propTypes;
|
|
57
|
+
|
|
58
|
+
export { DSFormLayoutBlockItem, DSFormLayoutBlockItemWithSchema };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DSFormLayoutBlockItem, DSFormLayoutBlockItemWithSchema } from './DSFormLayoutBlockItem.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PropTypes } from 'react-desc';
|
|
2
|
+
|
|
3
|
+
const propTypes = {
|
|
4
|
+
children: PropTypes.node.isRequired.description('Input component. '),
|
|
5
|
+
label: PropTypes.string.isRequired.description('Label property for the input component. This property is required for accesibility purposes.'),
|
|
6
|
+
inputID: PropTypes.string.isRequired.description("String that matches the input component's id. This property is required for accesibility purposes."),
|
|
7
|
+
feedbackMessage: PropTypes.string.description('Feedback message to show below the input component.'),
|
|
8
|
+
validationMessage: PropTypes.string.description('Validation message to show below the input component. It requires hasError property set to true to be visible.'),
|
|
9
|
+
hasError: PropTypes.bool.description('Helper boolean property for the validation message.'),
|
|
10
|
+
required: PropTypes.bool.description('Adds required extra styling.'),
|
|
11
|
+
optional: PropTypes.bool.description('Adds optional extra styling.'),
|
|
12
|
+
fitContent: PropTypes.bool.description('Set the width of the layout to the input component.'),
|
|
13
|
+
leftLabel: PropTypes.bool.description('Adds the label at the left of the input component.'),
|
|
14
|
+
hideLabel: PropTypes.bool.description('Hides the input label. It still requires label and labelFor property for accesibility purposes'),
|
|
15
|
+
withHighlight: PropTypes.bool.description('Adds highlight extra styling. It requires extra spacing, please check withHighlight explanation tab.'),
|
|
16
|
+
isGroup: PropTypes.bool.description('Sets the HTML elements as fieldset and legend. This should be used when you want to group more than one input.')
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { propTypes };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
const StyledContainer = /*#__PURE__*/styled.div.withConfig({
|
|
4
|
+
componentId: "sc-196zgtg-0"
|
|
5
|
+
})(["position:relative;padding:0;margin:0;display:grid;", " ", ";", " align-items:center;", ""], _ref => {
|
|
6
|
+
let {
|
|
7
|
+
fitContent
|
|
8
|
+
} = _ref;
|
|
9
|
+
return fitContent ? 'width: fit-content;' : undefined;
|
|
10
|
+
}, _ref2 => {
|
|
11
|
+
let {
|
|
12
|
+
isGroup
|
|
13
|
+
} = _ref2;
|
|
14
|
+
return isGroup ? 'border: none' : '';
|
|
15
|
+
}, _ref3 => {
|
|
16
|
+
let {
|
|
17
|
+
leftLabel,
|
|
18
|
+
hideLabel
|
|
19
|
+
} = _ref3;
|
|
20
|
+
return leftLabel && !hideLabel ? 'grid-template-columns: max-content auto;' : undefined;
|
|
21
|
+
}, _ref4 => {
|
|
22
|
+
let {
|
|
23
|
+
theme,
|
|
24
|
+
withHighlight
|
|
25
|
+
} = _ref4;
|
|
26
|
+
return withHighlight ? "\n &::after {\n position: absolute;\n content: '';\n left: -".concat(theme.space.xxs, ";\n top: -").concat(theme.space.xxxs, ";\n z-index: -1;\n width: calc(100% + ").concat(theme.space.xs, ");\n height: calc(100% + ").concat(theme.space.xxs, ");\n background-color: #FEFBEE;\n border : 1px solid #8F6326;\n border-radius : 4px;\n box-shadow: 0 1px 3px 0 rgba(0,0,0,0.35);\n }\n &:hover, \n &:focus-within {\n &::after {\n position: absolute;\n content: '';\n left: -").concat(theme.space.xxs, ";\n top: -").concat(theme.space.xxxs, ";\n z-index: -1;\n width: calc(100% + ").concat(theme.space.xs, ");\n height: calc(100% + ").concat(theme.space.xxs, ");\n background-color: #FFF9D3;\n border : 2px solid #8F6326;\n border-radius : 4px;\n box-shadow: 0 6px 10px 0 rgba(0,0,0,0.30);\n }\n }\n ") : undefined;
|
|
27
|
+
});
|
|
28
|
+
const StyledLabel = /*#__PURE__*/styled.label.withConfig({
|
|
29
|
+
componentId: "sc-196zgtg-1"
|
|
30
|
+
})(["display:flex;", " ", ""], _ref5 => {
|
|
31
|
+
let {
|
|
32
|
+
theme,
|
|
33
|
+
leftLabel
|
|
34
|
+
} = _ref5;
|
|
35
|
+
return leftLabel ? "padding-right: ".concat(theme.space.xxs, ";") : undefined;
|
|
36
|
+
}, _ref6 => {
|
|
37
|
+
let {
|
|
38
|
+
hideLabel
|
|
39
|
+
} = _ref6;
|
|
40
|
+
return hideLabel ? "position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n " : undefined;
|
|
41
|
+
});
|
|
42
|
+
const StyledMessage = /*#__PURE__*/styled.div.withConfig({
|
|
43
|
+
componentId: "sc-196zgtg-2"
|
|
44
|
+
})(["font-size:", ";font-style:italic;text-align:right;line-height:15px;height:15px;overflow:hidden;text-overflow:ellipsis;color:", ";", ""], _ref7 => {
|
|
45
|
+
let {
|
|
46
|
+
theme
|
|
47
|
+
} = _ref7;
|
|
48
|
+
return theme.fontSizes.microText[200];
|
|
49
|
+
}, _ref8 => {
|
|
50
|
+
let {
|
|
51
|
+
theme,
|
|
52
|
+
hasError
|
|
53
|
+
} = _ref8;
|
|
54
|
+
return hasError ? theme.colors.danger[900] : theme.colors.neutral[500];
|
|
55
|
+
}, _ref9 => {
|
|
56
|
+
let {
|
|
57
|
+
leftLabel,
|
|
58
|
+
hideLabel
|
|
59
|
+
} = _ref9;
|
|
60
|
+
return leftLabel && !hideLabel ? 'grid-column: 1/3;' : undefined;
|
|
61
|
+
});
|
|
62
|
+
const StyledMark = /*#__PURE__*/styled.span.withConfig({
|
|
63
|
+
componentId: "sc-196zgtg-3"
|
|
64
|
+
})(["width:6px;height:6px;border-radius:50%;margin-left:", ";", ""], _ref10 => {
|
|
65
|
+
let {
|
|
66
|
+
theme
|
|
67
|
+
} = _ref10;
|
|
68
|
+
return theme.space.xxxs;
|
|
69
|
+
}, _ref11 => {
|
|
70
|
+
let {
|
|
71
|
+
theme,
|
|
72
|
+
required
|
|
73
|
+
} = _ref11;
|
|
74
|
+
return required ? "\n background-color: ".concat(theme.colors.danger[900], ";\n ") : "\n border: 1px solid ".concat(theme.colors.brand[600], ";\n ");
|
|
75
|
+
});
|
|
76
|
+
const ScreenReaderOnly = /*#__PURE__*/styled.div.withConfig({
|
|
77
|
+
componentId: "sc-196zgtg-4"
|
|
78
|
+
})(["clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px;"]);
|
|
79
|
+
|
|
80
|
+
export { ScreenReaderOnly, StyledContainer, StyledLabel, StyledMark, StyledMessage };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'react';
|
|
3
|
+
import { describe } from 'react-desc';
|
|
4
|
+
import { useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';
|
|
5
|
+
import { propTypes } from './propTypes.js';
|
|
6
|
+
import { StyledContainer } from './styles.js';
|
|
7
|
+
import { defaultProps } from './defaultProps.js';
|
|
8
|
+
import { useValidateProps } from './config/useValidateProps.js';
|
|
9
|
+
|
|
10
|
+
const DSFormLayoutCheckboxGroup = props => {
|
|
11
|
+
useValidateProps(props);
|
|
12
|
+
const propsWithDefault = useMemoMergePropsWithDefault(props, defaultProps);
|
|
13
|
+
return /*#__PURE__*/_jsx(StyledContainer, {
|
|
14
|
+
direction: propsWithDefault.direction
|
|
15
|
+
}, void 0, propsWithDefault.children);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const DSFormLayoutCheckboxGroupWithSchema = describe(DSFormLayoutCheckboxGroup);
|
|
19
|
+
DSFormLayoutCheckboxGroupWithSchema.propTypes = propTypes;
|
|
20
|
+
|
|
21
|
+
export { DSFormLayoutCheckboxGroup, DSFormLayoutCheckboxGroupWithSchema };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
const getVariableType = arg => {
|
|
4
|
+
if (Array.isArray(arg)) return 'array';
|
|
5
|
+
if (arg === null) return 'null';
|
|
6
|
+
if (arg === undefined) return 'undefined';
|
|
7
|
+
return typeof arg;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const throwCheckboxGroupDirectionError = invalidProp => {
|
|
11
|
+
throw new Error("You are trying to pass a not valid \"direction\" property value for a checkbox group, please provide a valid type.\n\n Received: ".concat(invalidProp, " (").concat(getVariableType(invalidProp), ")\n Expected: \"horizontal\" or \"vertical\" (string)\n "));
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const throwCheckboxGroupChildrenError = () => {
|
|
15
|
+
throw new Error("You are trying to use a checkbox group without any React children, please provide at least one children to use.\n \n Received: (null)\n Expected: React children\n ");
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const useValidateProps = props => {
|
|
19
|
+
if (props.direction !== undefined && props.direction !== 'vertical' && props.direction !== 'horizontal') {
|
|
20
|
+
throwCheckboxGroupDirectionError(props.direction);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (!React.Children.count(props.children)) {
|
|
24
|
+
throwCheckboxGroupChildrenError();
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { useValidateProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DSFormLayoutCheckboxGroup, DSFormLayoutCheckboxGroupWithSchema } from './DSFormLayoutCheckboxGroup.js';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
const StyledContainer = /*#__PURE__*/styled.div.withConfig({
|
|
4
|
+
componentId: "sc-1wopk9q-0"
|
|
5
|
+
})(["display:inline-flex;flex-wrap:wrap;flex-direction:", ";margin-left:", ";margin-right:", ";margin-top:", ";& div{padding:0;margin-bottom:", ";}& div:not(:last-child){margin-right:", ";}"], _ref => {
|
|
6
|
+
let {
|
|
7
|
+
direction
|
|
8
|
+
} = _ref;
|
|
9
|
+
return direction === 'horizontal' ? 'row' : 'column';
|
|
10
|
+
}, _ref2 => {
|
|
11
|
+
let {
|
|
12
|
+
theme
|
|
13
|
+
} = _ref2;
|
|
14
|
+
return theme.space.xs;
|
|
15
|
+
}, _ref3 => {
|
|
16
|
+
let {
|
|
17
|
+
theme
|
|
18
|
+
} = _ref3;
|
|
19
|
+
return theme.space.xs;
|
|
20
|
+
}, _ref4 => {
|
|
21
|
+
let {
|
|
22
|
+
theme
|
|
23
|
+
} = _ref4;
|
|
24
|
+
return theme.space.xxs;
|
|
25
|
+
}, _ref5 => {
|
|
26
|
+
let {
|
|
27
|
+
theme
|
|
28
|
+
} = _ref5;
|
|
29
|
+
return theme.space.xxs;
|
|
30
|
+
}, _ref6 => {
|
|
31
|
+
let {
|
|
32
|
+
theme,
|
|
33
|
+
direction
|
|
34
|
+
} = _ref6;
|
|
35
|
+
return direction === 'horizontal' ? theme.space.s : '0';
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export { StyledContainer };
|
package/esm/index.d.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|