@elliemae/ds-form-layout-blocks 2.0.0-alpha.3 → 2.0.0-alpha.7

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.
@@ -3,8 +3,9 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _jsx = require('@babel/runtime/helpers/jsx');
6
- require('react');
6
+ var React = require('react');
7
7
  var reactDesc = require('react-desc');
8
+ var uid = require('uid');
8
9
  var propTypes = require('./propTypes.js');
9
10
  var styles = require('./styles.js');
10
11
 
@@ -17,7 +18,7 @@ const DSFormLayoutBlockItem = props => {
17
18
  label,
18
19
  feedbackMessage,
19
20
  validationMessage,
20
- labelFor,
21
+ inputID,
21
22
  children,
22
23
  hasError,
23
24
  leftLabel,
@@ -25,24 +26,38 @@ const DSFormLayoutBlockItem = props => {
25
26
  optional,
26
27
  hideLabel,
27
28
  fitContent,
28
- withHighlight
29
+ withHighlight,
30
+ isGroup = false
29
31
  } = props;
30
- return /*#__PURE__*/_jsx__default['default'](styles.StyledContainer, {
32
+ const instanceUID = React.useMemo(() => uid.uid(6), []);
33
+ return /*#__PURE__*/_jsx__default["default"](styles.StyledContainer, {
31
34
  leftLabel: leftLabel,
32
35
  fitContent: fitContent,
33
36
  hideLabel: hideLabel,
34
- withHighlight: withHighlight
35
- }, void 0, /*#__PURE__*/_jsx__default['default'](styles.StyledLabel, {
36
- htmlFor: labelFor,
37
+ withHighlight: withHighlight,
38
+ as: isGroup ? 'fieldset' : 'div',
39
+ isGroup: isGroup,
40
+ "aria-describedby": `${inputID || instanceUID}_feedback_message`
41
+ }, void 0, /*#__PURE__*/_jsx__default["default"](styles.StyledLabel, {
42
+ htmlFor: inputID,
37
43
  leftLabel: leftLabel,
38
- hideLabel: hideLabel
39
- }, void 0, label, (required || optional) && /*#__PURE__*/_jsx__default['default'](styles.StyledMark, {
44
+ hideLabel: hideLabel,
45
+ "aria-hidden": isGroup
46
+ }, void 0, label, (required || optional) && /*#__PURE__*/_jsx__default["default"](styles.StyledMark, {
40
47
  required: required
41
- })), children, (validationMessage || feedbackMessage) && /*#__PURE__*/_jsx__default['default'](styles.StyledMessage, {
48
+ })), isGroup && /*#__PURE__*/_jsx__default["default"](styles.ScreenReaderOnly, {
49
+ as: "legend"
50
+ }, void 0, label), children, feedbackMessage && !hasError && /*#__PURE__*/_jsx__default["default"](styles.StyledMessage, {
51
+ leftLabel: leftLabel,
52
+ hideLabel: hideLabel,
53
+ "aria-hidden": isGroup,
54
+ id: `${inputID || instanceUID}_feedback_message`
55
+ }, void 0, feedbackMessage), validationMessage && hasError && /*#__PURE__*/_jsx__default["default"](styles.StyledMessage, {
42
56
  hasError: hasError,
43
57
  leftLabel: leftLabel,
44
- hideLabel: hideLabel
45
- }, void 0, hasError ? validationMessage : feedbackMessage));
58
+ hideLabel: hideLabel,
59
+ role: "alert"
60
+ }, void 0, validationMessage));
46
61
  };
47
62
 
48
63
  const DSFormLayoutBlockItemWithSchema = reactDesc.describe(DSFormLayoutBlockItem);
@@ -7,7 +7,7 @@ var reactDesc = require('react-desc');
7
7
  const propTypes = {
8
8
  children: reactDesc.PropTypes.node.isRequired.description('Input component. '),
9
9
  label: reactDesc.PropTypes.string.isRequired.description('Label property for the input component. This property is required for accesibility purposes.'),
10
- labelFor: reactDesc.PropTypes.string.isRequired.description("String that matches the input component's id. 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
11
  feedbackMessage: reactDesc.PropTypes.string.description('Feedback message to show below the input component.'),
12
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
13
  hasError: reactDesc.PropTypes.bool.description('Helper boolean property for the validation message.'),
@@ -16,7 +16,8 @@ const propTypes = {
16
16
  fitContent: reactDesc.PropTypes.bool.description('Set the width of the layout to the input component.'),
17
17
  leftLabel: reactDesc.PropTypes.bool.description('Adds the label at the left of the input component.'),
18
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.')
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.')
20
21
  };
21
22
 
22
23
  exports.propTypes = propTypes;
@@ -8,11 +8,13 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
8
8
 
9
9
  var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
10
10
 
11
- const StyledContainer = /*#__PURE__*/styled__default['default'].div.withConfig({
11
+ const StyledContainer = /*#__PURE__*/styled__default["default"].div.withConfig({
12
12
  componentId: "sc-196zgtg-0"
13
- })(["position:relative;", " display:grid;", " align-items:center;", ""], ({
13
+ })(["position:relative;padding:0;margin:0;display:grid;", " ", ";", " align-items:center;", ""], ({
14
14
  fitContent
15
15
  }) => fitContent ? 'width: fit-content;' : undefined, ({
16
+ isGroup
17
+ }) => isGroup ? 'border: none' : '', ({
16
18
  leftLabel,
17
19
  hideLabel
18
20
  }) => leftLabel && !hideLabel ? 'grid-template-columns: max-content auto;' : undefined, ({
@@ -49,7 +51,7 @@ const StyledContainer = /*#__PURE__*/styled__default['default'].div.withConfig({
49
51
  }
50
52
  }
51
53
  ` : undefined);
52
- const StyledLabel = /*#__PURE__*/styled__default['default'].label.withConfig({
54
+ const StyledLabel = /*#__PURE__*/styled__default["default"].label.withConfig({
53
55
  componentId: "sc-196zgtg-1"
54
56
  })(["display:flex;", " ", ""], ({
55
57
  theme,
@@ -66,9 +68,9 @@ const StyledLabel = /*#__PURE__*/styled__default['default'].label.withConfig({
66
68
  white-space: nowrap;
67
69
  border: 0;
68
70
  ` : undefined);
69
- const StyledMessage = /*#__PURE__*/styled__default['default'].div.withConfig({
71
+ const StyledMessage = /*#__PURE__*/styled__default["default"].div.withConfig({
70
72
  componentId: "sc-196zgtg-2"
71
- })(["font-size:", ";font-style:italic;text-align:right;line-height:15px;overflow:hidden;text-overflow:ellipsis;color:", ";", ""], ({
73
+ })(["font-size:", ";font-style:italic;text-align:right;line-height:15px;height:15px;overflow:hidden;text-overflow:ellipsis;color:", ";", ""], ({
72
74
  theme
73
75
  }) => theme.fontSizes.microText[200], ({
74
76
  theme,
@@ -77,7 +79,7 @@ const StyledMessage = /*#__PURE__*/styled__default['default'].div.withConfig({
77
79
  leftLabel,
78
80
  hideLabel
79
81
  }) => leftLabel && !hideLabel ? 'grid-column: 1/3;' : undefined);
80
- const StyledMark = /*#__PURE__*/styled__default['default'].span.withConfig({
82
+ const StyledMark = /*#__PURE__*/styled__default["default"].span.withConfig({
81
83
  componentId: "sc-196zgtg-3"
82
84
  })(["width:6px;height:6px;border-radius:50%;margin-left:", ";", ""], ({
83
85
  theme
@@ -89,7 +91,11 @@ const StyledMark = /*#__PURE__*/styled__default['default'].span.withConfig({
89
91
  ` : `
90
92
  border: 1px solid ${theme.colors.brand[600]};
91
93
  `);
94
+ const ScreenReaderOnly = /*#__PURE__*/styled__default["default"].div.withConfig({
95
+ componentId: "sc-196zgtg-4"
96
+ })(["clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px;"]);
92
97
 
98
+ exports.ScreenReaderOnly = ScreenReaderOnly;
93
99
  exports.StyledContainer = StyledContainer;
94
100
  exports.StyledLabel = StyledLabel;
95
101
  exports.StyledMark = StyledMark;
@@ -18,7 +18,7 @@ var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
18
18
  const DSFormLayoutCheckboxGroup = props => {
19
19
  useValidateProps.useValidateProps(props);
20
20
  const propsWithDefault = dsPropsHelpers.useMemoMergePropsWithDefault(props, defaultProps.defaultProps);
21
- return /*#__PURE__*/_jsx__default['default'](styles.StyledContainer, {
21
+ return /*#__PURE__*/_jsx__default["default"](styles.StyledContainer, {
22
22
  direction: propsWithDefault.direction
23
23
  }, void 0, propsWithDefault.children);
24
24
  };
@@ -36,7 +36,7 @@ const useValidateProps = props => {
36
36
  throwCheckboxGroupDirectionError(props.direction);
37
37
  }
38
38
 
39
- if (!React__default['default'].Children.count(props.children)) {
39
+ if (!React__default["default"].Children.count(props.children)) {
40
40
  throwCheckboxGroupChildrenError();
41
41
  }
42
42
  };
@@ -8,7 +8,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
8
8
 
9
9
  var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
10
10
 
11
- const StyledContainer = /*#__PURE__*/styled__default['default'].div.withConfig({
11
+ const StyledContainer = /*#__PURE__*/styled__default["default"].div.withConfig({
12
12
  componentId: "sc-1wopk9q-0"
13
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:", ";}"], ({
14
14
  direction
@@ -1,15 +1,16 @@
1
1
  import _jsx from '@babel/runtime/helpers/esm/jsx';
2
- import 'react';
2
+ import { useMemo } from 'react';
3
3
  import { describe } from 'react-desc';
4
+ import { uid } from 'uid';
4
5
  import { propTypes } from './propTypes.js';
5
- import { StyledContainer, StyledLabel, StyledMark, StyledMessage } from './styles.js';
6
+ import { StyledContainer, StyledLabel, StyledMark, ScreenReaderOnly, StyledMessage } from './styles.js';
6
7
 
7
8
  const DSFormLayoutBlockItem = props => {
8
9
  const {
9
10
  label,
10
11
  feedbackMessage,
11
12
  validationMessage,
12
- labelFor,
13
+ inputID,
13
14
  children,
14
15
  hasError,
15
16
  leftLabel,
@@ -17,24 +18,38 @@ const DSFormLayoutBlockItem = props => {
17
18
  optional,
18
19
  hideLabel,
19
20
  fitContent,
20
- withHighlight
21
+ withHighlight,
22
+ isGroup = false
21
23
  } = props;
24
+ const instanceUID = useMemo(() => uid(6), []);
22
25
  return /*#__PURE__*/_jsx(StyledContainer, {
23
26
  leftLabel: leftLabel,
24
27
  fitContent: fitContent,
25
28
  hideLabel: hideLabel,
26
- withHighlight: withHighlight
29
+ withHighlight: withHighlight,
30
+ as: isGroup ? 'fieldset' : 'div',
31
+ isGroup: isGroup,
32
+ "aria-describedby": `${inputID || instanceUID}_feedback_message`
27
33
  }, void 0, /*#__PURE__*/_jsx(StyledLabel, {
28
- htmlFor: labelFor,
34
+ htmlFor: inputID,
29
35
  leftLabel: leftLabel,
30
- hideLabel: hideLabel
36
+ hideLabel: hideLabel,
37
+ "aria-hidden": isGroup
31
38
  }, void 0, label, (required || optional) && /*#__PURE__*/_jsx(StyledMark, {
32
39
  required: required
33
- })), children, (validationMessage || feedbackMessage) && /*#__PURE__*/_jsx(StyledMessage, {
40
+ })), isGroup && /*#__PURE__*/_jsx(ScreenReaderOnly, {
41
+ as: "legend"
42
+ }, void 0, label), children, feedbackMessage && !hasError && /*#__PURE__*/_jsx(StyledMessage, {
43
+ leftLabel: leftLabel,
44
+ hideLabel: hideLabel,
45
+ "aria-hidden": isGroup,
46
+ id: `${inputID || instanceUID}_feedback_message`
47
+ }, void 0, feedbackMessage), validationMessage && hasError && /*#__PURE__*/_jsx(StyledMessage, {
34
48
  hasError: hasError,
35
49
  leftLabel: leftLabel,
36
- hideLabel: hideLabel
37
- }, void 0, hasError ? validationMessage : feedbackMessage));
50
+ hideLabel: hideLabel,
51
+ role: "alert"
52
+ }, void 0, validationMessage));
38
53
  };
39
54
 
40
55
  const DSFormLayoutBlockItemWithSchema = describe(DSFormLayoutBlockItem);
@@ -3,7 +3,7 @@ import { PropTypes } from 'react-desc';
3
3
  const propTypes = {
4
4
  children: PropTypes.node.isRequired.description('Input component. '),
5
5
  label: PropTypes.string.isRequired.description('Label property for the input component. This property is required for accesibility purposes.'),
6
- labelFor: PropTypes.string.isRequired.description("String that matches the input component's id. 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
7
  feedbackMessage: PropTypes.string.description('Feedback message to show below the input component.'),
8
8
  validationMessage: PropTypes.string.description('Validation message to show below the input component. It requires hasError property set to true to be visible.'),
9
9
  hasError: PropTypes.bool.description('Helper boolean property for the validation message.'),
@@ -12,7 +12,8 @@ const propTypes = {
12
12
  fitContent: PropTypes.bool.description('Set the width of the layout to the input component.'),
13
13
  leftLabel: PropTypes.bool.description('Adds the label at the left of the input component.'),
14
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.')
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.')
16
17
  };
17
18
 
18
19
  export { propTypes };
@@ -2,9 +2,11 @@ import styled from 'styled-components';
2
2
 
3
3
  const StyledContainer = /*#__PURE__*/styled.div.withConfig({
4
4
  componentId: "sc-196zgtg-0"
5
- })(["position:relative;", " display:grid;", " align-items:center;", ""], ({
5
+ })(["position:relative;padding:0;margin:0;display:grid;", " ", ";", " align-items:center;", ""], ({
6
6
  fitContent
7
7
  }) => fitContent ? 'width: fit-content;' : undefined, ({
8
+ isGroup
9
+ }) => isGroup ? 'border: none' : '', ({
8
10
  leftLabel,
9
11
  hideLabel
10
12
  }) => leftLabel && !hideLabel ? 'grid-template-columns: max-content auto;' : undefined, ({
@@ -60,7 +62,7 @@ const StyledLabel = /*#__PURE__*/styled.label.withConfig({
60
62
  ` : undefined);
61
63
  const StyledMessage = /*#__PURE__*/styled.div.withConfig({
62
64
  componentId: "sc-196zgtg-2"
63
- })(["font-size:", ";font-style:italic;text-align:right;line-height:15px;overflow:hidden;text-overflow:ellipsis;color:", ";", ""], ({
65
+ })(["font-size:", ";font-style:italic;text-align:right;line-height:15px;height:15px;overflow:hidden;text-overflow:ellipsis;color:", ";", ""], ({
64
66
  theme
65
67
  }) => theme.fontSizes.microText[200], ({
66
68
  theme,
@@ -81,5 +83,8 @@ const StyledMark = /*#__PURE__*/styled.span.withConfig({
81
83
  ` : `
82
84
  border: 1px solid ${theme.colors.brand[600]};
83
85
  `);
86
+ const ScreenReaderOnly = /*#__PURE__*/styled.div.withConfig({
87
+ componentId: "sc-196zgtg-4"
88
+ })(["clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px;"]);
84
89
 
85
- export { StyledContainer, StyledLabel, StyledMark, StyledMessage };
90
+ export { ScreenReaderOnly, StyledContainer, StyledLabel, StyledMark, StyledMessage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-form-layout-blocks",
3
- "version": "2.0.0-alpha.3",
3
+ "version": "2.0.0-alpha.7",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Form Layout",
6
6
  "module": "./esm/index.js",
@@ -72,7 +72,7 @@
72
72
  "build": "node ../../scripts/build/build.js"
73
73
  },
74
74
  "dependencies": {
75
- "@elliemae/ds-props-helpers": "2.0.0-alpha.3",
75
+ "@elliemae/ds-props-helpers": "2.0.0-alpha.7",
76
76
  "react-desc": "~4.1.3"
77
77
  },
78
78
  "devDependencies": {
@@ -5,7 +5,7 @@ declare const DSFormLayoutBlockItem: {
5
5
  propTypes: {
6
6
  children: any;
7
7
  label: any;
8
- labelFor: any;
8
+ inputID: any;
9
9
  feedbackMessage: any;
10
10
  validationMessage: any;
11
11
  hasError: any;
@@ -15,6 +15,7 @@ declare const DSFormLayoutBlockItem: {
15
15
  leftLabel: any;
16
16
  hideLabel: any;
17
17
  withHighlight: any;
18
+ isGroup: any;
18
19
  };
19
20
  };
20
21
  declare const DSFormLayoutBlockItemWithSchema: any;
@@ -2,7 +2,7 @@
2
2
  export interface DSFormLayoutBlockItemPropsT {
3
3
  children: JSX.Element;
4
4
  label: string;
5
- labelFor: string;
5
+ inputID: string;
6
6
  validationMessage?: string;
7
7
  feedbackMessage?: string;
8
8
  hasError?: boolean;
@@ -12,6 +12,7 @@ export interface DSFormLayoutBlockItemPropsT {
12
12
  optional?: boolean;
13
13
  hideLabel?: boolean;
14
14
  withHighlight?: boolean;
15
+ isGroup?: boolean;
15
16
  }
16
17
  export interface DSFormLayoutBlockItemStyledMessageT {
17
18
  hasError?: boolean;
@@ -23,6 +24,7 @@ export interface DSFormLayoutBlockItemStyledContainerT {
23
24
  fitContent?: boolean;
24
25
  hideLabel?: boolean;
25
26
  withHighlight?: boolean;
27
+ isGroup?: boolean;
26
28
  }
27
29
  export interface DSFormLayoutBlockItemStyledLabelT {
28
30
  leftLabel?: boolean;
@@ -1,7 +1,7 @@
1
1
  export declare const propTypes: {
2
2
  children: any;
3
3
  label: any;
4
- labelFor: any;
4
+ inputID: any;
5
5
  feedbackMessage: any;
6
6
  validationMessage: any;
7
7
  hasError: any;
@@ -11,4 +11,5 @@ export declare const propTypes: {
11
11
  leftLabel: any;
12
12
  hideLabel: any;
13
13
  withHighlight: any;
14
+ isGroup: any;
14
15
  };
@@ -3,3 +3,4 @@ export declare const StyledContainer: import("styled-components").StyledComponen
3
3
  export declare const StyledLabel: import("styled-components").StyledComponent<"label", any, DSFormLayoutBlockItemStyledLabelT, never>;
4
4
  export declare const StyledMessage: import("styled-components").StyledComponent<"div", any, DSFormLayoutBlockItemStyledMessageT, never>;
5
5
  export declare const StyledMark: import("styled-components").StyledComponent<"span", any, DSFormLayoutBlockItemStyledMarkT, never>;
6
+ export declare const ScreenReaderOnly: import("styled-components").StyledComponent<"div", any, {}, never>;