@zendeskgarden/react-forms 9.0.0-next.9 → 9.1.0

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 (140) hide show
  1. package/dist/esm/elements/Checkbox.js +4 -3
  2. package/dist/esm/elements/FileUpload.js +7 -3
  3. package/dist/esm/elements/Input.js +18 -17
  4. package/dist/esm/elements/MediaInput.js +2 -2
  5. package/dist/esm/elements/Radio.js +4 -3
  6. package/dist/esm/elements/Range.js +9 -9
  7. package/dist/esm/elements/Select.js +9 -8
  8. package/dist/esm/elements/Textarea.js +24 -14
  9. package/dist/esm/elements/Toggle.js +4 -3
  10. package/dist/esm/elements/common/Fieldset.js +10 -5
  11. package/dist/esm/elements/common/Hint.js +1 -1
  12. package/dist/esm/elements/common/Label.js +35 -33
  13. package/dist/esm/elements/common/Legend.js +1 -3
  14. package/dist/esm/elements/common/Message.js +7 -6
  15. package/dist/esm/elements/common/MessageIcon.js +78 -0
  16. package/dist/esm/elements/faux-input/FauxInput.js +20 -8
  17. package/dist/esm/elements/faux-input/components/EndIcon.js +4 -0
  18. package/dist/esm/elements/faux-input/components/StartIcon.js +4 -0
  19. package/dist/esm/elements/file-list/components/File.js +6 -5
  20. package/dist/esm/elements/input-group/InputGroup.js +3 -3
  21. package/dist/esm/elements/tiles/components/Description.js +1 -1
  22. package/dist/esm/elements/tiles/components/Icon.js +1 -1
  23. package/dist/esm/elements/tiles/components/Label.js +1 -1
  24. package/dist/esm/elements/tiles/components/Tile.js +1 -3
  25. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/check-circle-stroke.svg.js +1 -1
  26. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/check-sm-fill.svg.js +1 -1
  27. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/circle-sm-fill.svg.js +1 -1
  28. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/dash-fill.svg.js +1 -1
  29. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/file-document-stroke.svg.js +1 -1
  30. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/file-error-stroke.svg.js +1 -1
  31. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/file-generic-stroke.svg.js +1 -1
  32. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/file-image-stroke.svg.js +1 -1
  33. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/file-pdf-stroke.svg.js +1 -1
  34. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/file-presentation-stroke.svg.js +1 -1
  35. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/file-spreadsheet-stroke.svg.js +1 -1
  36. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/file-zip-stroke.svg.js +1 -1
  37. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/trash-stroke.svg.js +1 -1
  38. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/x-stroke.svg.js +1 -1
  39. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/alert-error-stroke.svg.js +1 -1
  40. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/alert-warning-stroke.svg.js +1 -1
  41. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/check-circle-stroke.svg.js +1 -1
  42. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/chevron-down-stroke.svg.js +1 -1
  43. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/circle-sm-fill.svg.js +1 -1
  44. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/file-document-stroke.svg.js +1 -1
  45. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/file-error-stroke.svg.js +1 -1
  46. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/file-generic-stroke.svg.js +1 -1
  47. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/file-image-stroke.svg.js +1 -1
  48. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/file-pdf-stroke.svg.js +1 -1
  49. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/file-presentation-stroke.svg.js +1 -1
  50. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/file-spreadsheet-stroke.svg.js +1 -1
  51. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/file-zip-stroke.svg.js +1 -1
  52. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/trash-stroke.svg.js +1 -1
  53. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/x-stroke.svg.js +1 -1
  54. package/dist/esm/styled/checkbox/StyledCheckHint.js +2 -5
  55. package/dist/esm/styled/checkbox/StyledCheckInput.js +55 -14
  56. package/dist/esm/styled/checkbox/StyledCheckLabel.js +2 -5
  57. package/dist/esm/styled/checkbox/StyledCheckMessage.js +2 -5
  58. package/dist/esm/styled/checkbox/StyledCheckSvg.js +2 -5
  59. package/dist/esm/styled/checkbox/StyledDashSvg.js +2 -5
  60. package/dist/esm/styled/common/StyledField.js +2 -5
  61. package/dist/esm/styled/common/StyledFieldset.js +3 -6
  62. package/dist/esm/styled/common/StyledHint.js +6 -6
  63. package/dist/esm/styled/common/StyledLabel.js +6 -6
  64. package/dist/esm/styled/common/StyledLegend.js +2 -5
  65. package/dist/esm/styled/common/StyledMessage.js +33 -19
  66. package/dist/esm/styled/common/StyledMessageIcon.js +3 -29
  67. package/dist/esm/styled/file-list/StyledFile.js +49 -31
  68. package/dist/esm/styled/file-list/StyledFileClose.js +6 -6
  69. package/dist/esm/styled/file-list/StyledFileDelete.js +6 -6
  70. package/dist/esm/styled/file-list/StyledFileIcon.js +24 -7
  71. package/dist/esm/styled/file-list/StyledFileList.js +2 -5
  72. package/dist/esm/styled/file-list/StyledFileListItem.js +2 -5
  73. package/dist/esm/styled/file-upload/StyledFileUpload.js +89 -23
  74. package/dist/esm/styled/input-group/StyledInputGroup.js +3 -6
  75. package/dist/esm/styled/radio/StyledRadioHint.js +2 -5
  76. package/dist/esm/styled/radio/StyledRadioInput.js +85 -27
  77. package/dist/esm/styled/radio/StyledRadioLabel.js +3 -6
  78. package/dist/esm/styled/radio/StyledRadioMessage.js +2 -5
  79. package/dist/esm/styled/radio/StyledRadioSvg.js +2 -5
  80. package/dist/esm/styled/range/StyledRangeInput.js +79 -29
  81. package/dist/esm/styled/select/StyledSelect.js +35 -14
  82. package/dist/esm/styled/select/StyledSelectWrapper.js +12 -7
  83. package/dist/esm/styled/text/StyledTextFauxInput.js +40 -35
  84. package/dist/esm/styled/text/StyledTextInput.js +104 -62
  85. package/dist/esm/styled/text/StyledTextMediaFigure.js +35 -13
  86. package/dist/esm/styled/text/StyledTextMediaInput.js +3 -6
  87. package/dist/esm/styled/text/StyledTextarea.js +3 -6
  88. package/dist/esm/styled/tiles/StyledTile.js +93 -37
  89. package/dist/esm/styled/tiles/StyledTileDescription.js +13 -16
  90. package/dist/esm/styled/tiles/StyledTileIcon.js +52 -16
  91. package/dist/esm/styled/tiles/StyledTileInput.js +1 -5
  92. package/dist/esm/styled/tiles/StyledTileLabel.js +13 -18
  93. package/dist/esm/styled/toggle/StyledToggleHint.js +2 -5
  94. package/dist/esm/styled/toggle/StyledToggleInput.js +38 -16
  95. package/dist/esm/styled/toggle/StyledToggleLabel.js +2 -5
  96. package/dist/esm/styled/toggle/StyledToggleMessage.js +2 -5
  97. package/dist/esm/styled/toggle/StyledToggleSvg.js +2 -5
  98. package/dist/index.cjs.js +1212 -773
  99. package/dist/typings/elements/common/Field.d.ts +1 -1
  100. package/dist/typings/elements/common/Fieldset.d.ts +3 -1
  101. package/dist/typings/elements/common/MessageIcon.d.ts +9 -0
  102. package/dist/typings/elements/faux-input/FauxInput.d.ts +3 -1
  103. package/dist/typings/elements/faux-input/components/EndIcon.d.ts +1 -1
  104. package/dist/typings/elements/faux-input/components/StartIcon.d.ts +1 -1
  105. package/dist/typings/elements/file-list/FileList.d.ts +3 -1
  106. package/dist/typings/elements/file-list/components/File.d.ts +3 -1
  107. package/dist/typings/elements/tiles/Tiles.d.ts +3 -1
  108. package/dist/typings/styled/checkbox/StyledCheckLabel.d.ts +2 -2
  109. package/dist/typings/styled/common/StyledFieldset.d.ts +1 -1
  110. package/dist/typings/styled/common/StyledLabel.d.ts +2 -2
  111. package/dist/typings/styled/common/StyledLegend.d.ts +1 -5
  112. package/dist/typings/styled/common/StyledMessage.d.ts +1 -1
  113. package/dist/typings/styled/common/StyledMessageIcon.d.ts +2 -9
  114. package/dist/typings/styled/file-list/StyledFile.d.ts +3 -3
  115. package/dist/typings/styled/file-list/StyledFileIcon.d.ts +7 -2
  116. package/dist/typings/styled/file-upload/StyledFileUpload.d.ts +2 -2
  117. package/dist/typings/styled/input-group/StyledInputGroup.d.ts +1 -1
  118. package/dist/typings/styled/radio/StyledRadioInput.d.ts +1 -1
  119. package/dist/typings/styled/radio/StyledRadioLabel.d.ts +2 -2
  120. package/dist/typings/styled/range/StyledRangeInput.d.ts +2 -2
  121. package/dist/typings/styled/select/StyledSelect.d.ts +0 -3
  122. package/dist/typings/styled/select/StyledSelectWrapper.d.ts +3 -1
  123. package/dist/typings/styled/text/StyledTextFauxInput.d.ts +3 -7
  124. package/dist/typings/styled/text/StyledTextInput.d.ts +6 -6
  125. package/dist/typings/styled/text/StyledTextMediaFigure.d.ts +1 -2
  126. package/dist/typings/styled/text/StyledTextMediaInput.d.ts +2 -2
  127. package/dist/typings/styled/text/StyledTextarea.d.ts +2 -2
  128. package/dist/typings/styled/tiles/StyledTile.d.ts +4 -7
  129. package/dist/typings/styled/tiles/StyledTileDescription.d.ts +1 -1
  130. package/dist/typings/styled/tiles/StyledTileIcon.d.ts +1 -1
  131. package/dist/typings/styled/tiles/StyledTileLabel.d.ts +1 -1
  132. package/dist/typings/styled/toggle/StyledToggleLabel.d.ts +2 -2
  133. package/dist/typings/types/index.d.ts +9 -3
  134. package/dist/typings/utils/useFieldContext.d.ts +0 -1
  135. package/dist/typings/utils/useFieldsetContext.d.ts +0 -1
  136. package/dist/typings/utils/useFileContext.d.ts +0 -1
  137. package/dist/typings/utils/useInputContext.d.ts +0 -1
  138. package/dist/typings/utils/useInputGroupContext.d.ts +0 -1
  139. package/dist/typings/utils/useTilesContext.d.ts +0 -1
  140. package/package.json +8 -8
@@ -58,7 +58,8 @@ const Checkbox = React__default.forwardRef((_ref, ref) => {
58
58
  let {
59
59
  indeterminate,
60
60
  children,
61
- ...props
61
+ isCompact,
62
+ ...other
62
63
  } = _ref;
63
64
  const fieldsetContext = useFieldsetContext();
64
65
  const fieldContext = useFieldContext();
@@ -77,9 +78,9 @@ const Checkbox = React__default.forwardRef((_ref, ref) => {
77
78
  });
78
79
  };
79
80
  let combinedProps = {
81
+ $isCompact: fieldsetContext ? fieldsetContext.isCompact : isCompact,
80
82
  ref: combinedRef,
81
- ...props,
82
- ...fieldsetContext
83
+ ...other
83
84
  };
84
85
  if (fieldContext) {
85
86
  combinedProps = fieldContext.getInputProps(combinedProps);
@@ -54,13 +54,17 @@ import '../styled/tiles/StyledTileLabel.js';
54
54
  const FileUpload = React__default.forwardRef((_ref, ref) => {
55
55
  let {
56
56
  disabled,
57
- ...props
57
+ isCompact,
58
+ isDragging,
59
+ ...other
58
60
  } = _ref;
59
61
  return (
60
62
  React__default.createElement(StyledFileUpload, Object.assign({
61
63
  ref: ref,
62
- "aria-disabled": disabled
63
- }, props, {
64
+ "aria-disabled": disabled,
65
+ $isCompact: isCompact,
66
+ $isDragging: isDragging
67
+ }, other, {
64
68
  role: "button"
65
69
  }))
66
70
  );
@@ -58,29 +58,30 @@ import '../styled/tiles/StyledTileLabel.js';
58
58
  const Input = React__default.forwardRef((_ref, ref) => {
59
59
  let {
60
60
  onSelect,
61
- ...props
61
+ isBare,
62
+ isCompact,
63
+ focusInset,
64
+ validation,
65
+ ...other
62
66
  } = _ref;
63
67
  const fieldContext = useFieldContext();
64
68
  const inputGroupContext = useInputGroupContext();
65
- const onSelectHandler = props.readOnly ? composeEventHandlers(onSelect, event => {
66
- event.currentTarget.select();
67
- }) : onSelect;
68
- let combinedProps = {
69
- ref,
70
- onSelect: onSelectHandler,
71
- ...props
72
- };
73
- if (inputGroupContext) {
74
- combinedProps = {
75
- ...combinedProps,
76
- isCompact: inputGroupContext.isCompact || combinedProps.isCompact,
77
- focusInset: props.focusInset === undefined ? true : props.focusInset
78
- };
79
- }
69
+ let combinedProps = other;
80
70
  if (fieldContext) {
81
71
  combinedProps = fieldContext.getInputProps(combinedProps);
82
72
  }
83
- return React__default.createElement(StyledTextInput, combinedProps);
73
+ const onSelectHandler = other.readOnly ? composeEventHandlers(onSelect, event => {
74
+ event.currentTarget.select();
75
+ }) : onSelect;
76
+ return React__default.createElement(StyledTextInput, Object.assign({
77
+ ref: ref,
78
+ onSelect: onSelectHandler
79
+ }, combinedProps, {
80
+ $isBare: isBare,
81
+ $isCompact: inputGroupContext ? inputGroupContext.isCompact : isCompact,
82
+ $focusInset: inputGroupContext && focusInset === undefined ? true : focusInset,
83
+ $validation: validation
84
+ }));
84
85
  });
85
86
  Input.propTypes = {
86
87
  isCompact: PropTypes.bool,
@@ -131,11 +131,11 @@ const MediaInput = React__default.forwardRef((_ref, ref) => {
131
131
  mediaLayout: true
132
132
  }, otherWrapperProps, {
133
133
  ref: wrapperRef
134
- }), start && React__default.createElement(FauxInput.StartIcon, {
134
+ }), !!start && React__default.createElement(FauxInput.StartIcon, {
135
135
  isDisabled: disabled,
136
136
  isFocused: isFocused,
137
137
  isHovered: isHovered || isLabelHovered
138
- }, start), React__default.createElement(StyledTextMediaInput, combinedProps), end && React__default.createElement(FauxInput.EndIcon, {
138
+ }, start), React__default.createElement(StyledTextMediaInput, combinedProps), !!end && React__default.createElement(FauxInput.EndIcon, {
139
139
  isDisabled: disabled,
140
140
  isFocused: isFocused,
141
141
  isHovered: isHovered || isLabelHovered
@@ -57,14 +57,15 @@ import useFieldsetContext from '../utils/useFieldsetContext.js';
57
57
  const Radio = React__default.forwardRef((_ref, ref) => {
58
58
  let {
59
59
  children,
60
- ...props
60
+ isCompact,
61
+ ...other
61
62
  } = _ref;
62
63
  const fieldsetContext = useFieldsetContext();
63
64
  const fieldContext = useFieldContext();
64
65
  let combinedProps = {
66
+ $isCompact: fieldsetContext ? fieldsetContext.isCompact : isCompact,
65
67
  ref,
66
- ...props,
67
- ...fieldsetContext
68
+ ...other
68
69
  };
69
70
  if (fieldContext) {
70
71
  combinedProps = fieldContext.getInputProps(combinedProps);
@@ -59,7 +59,7 @@ const Range = React__default.forwardRef((_ref, ref) => {
59
59
  min,
60
60
  max,
61
61
  step,
62
- ...props
62
+ ...other
63
63
  } = _ref;
64
64
  const [backgroundSize, setBackgroundSize] = useState('0');
65
65
  const rangeRef = useRef();
@@ -78,18 +78,18 @@ const Range = React__default.forwardRef((_ref, ref) => {
78
78
  [max, min, step]);
79
79
  useEffect(() => {
80
80
  updateBackgroundWidthFromInput(rangeRef.current);
81
- }, [rangeRef, updateBackgroundWidthFromInput, props.value]);
82
- const onChange = hasLowerTrack ? composeEventHandlers(props.onChange, event => {
81
+ }, [rangeRef, updateBackgroundWidthFromInput, other.value]);
82
+ const onChange = hasLowerTrack ? composeEventHandlers(other.onChange, event => {
83
83
  updateBackgroundWidthFromInput(event.target);
84
- }) : props.onChange;
84
+ }) : other.onChange;
85
85
  let combinedProps = {
86
- ref: mergeRefs([rangeRef, ref]),
87
- hasLowerTrack,
88
- min,
86
+ $backgroundSize: backgroundSize,
87
+ $hasLowerTrack: hasLowerTrack,
89
88
  max,
89
+ min,
90
+ ref: mergeRefs([rangeRef, ref]),
90
91
  step,
91
- backgroundSize,
92
- ...props,
92
+ ...other,
93
93
  onChange
94
94
  };
95
95
  if (fieldContext) {
@@ -66,11 +66,11 @@ const Select = React__default.forwardRef((_ref, ref) => {
66
66
  } = _ref;
67
67
  const fieldContext = useFieldContext();
68
68
  let combinedProps = {
69
+ $focusInset: focusInset,
70
+ $isBare: isBare,
71
+ $isCompact: isCompact,
72
+ $validation: validation,
69
73
  disabled,
70
- isBare,
71
- isCompact,
72
- validation,
73
- focusInset,
74
74
  ref,
75
75
  ...props
76
76
  };
@@ -78,10 +78,11 @@ const Select = React__default.forwardRef((_ref, ref) => {
78
78
  combinedProps = fieldContext.getInputProps(combinedProps);
79
79
  }
80
80
  return React__default.createElement(StyledSelectWrapper, {
81
- isCompact: isCompact,
82
- isBare: isBare,
83
- validation: validation,
84
- focusInset: focusInset
81
+ $isCompact: isCompact,
82
+ $isBare: isBare,
83
+ $isDisabled: disabled,
84
+ $validation: validation,
85
+ $focusInset: focusInset
85
86
  }, React__default.createElement(StyledSelect, combinedProps), !isBare && React__default.createElement(FauxInput.EndIcon, {
86
87
  isDisabled: disabled
87
88
  }, React__default.createElement(SvgChevronDownStroke, null)));
@@ -60,12 +60,17 @@ const parseStyleValue = value => {
60
60
  };
61
61
  const Textarea = React__default.forwardRef((_ref, ref) => {
62
62
  let {
63
+ isCompact,
64
+ isBare,
65
+ focusInset,
66
+ isResizable,
63
67
  minRows,
64
68
  maxRows,
65
69
  style,
70
+ validation,
66
71
  onChange,
67
72
  onSelect,
68
- ...props
73
+ ...other
69
74
  } = _ref;
70
75
  const fieldContext = useFieldContext();
71
76
  const textAreaRef = useRef();
@@ -74,8 +79,8 @@ const Textarea = React__default.forwardRef((_ref, ref) => {
74
79
  overflow: false,
75
80
  height: 0
76
81
  });
77
- const isControlled = props.value !== null && props.value !== undefined;
78
- const isAutoResizable = (minRows !== undefined || maxRows !== undefined) && !props.isResizable;
82
+ const isControlled = other.value !== null && other.value !== undefined;
83
+ const isAutoResizable = (minRows !== undefined || maxRows !== undefined) && !isResizable;
79
84
  const calculateHeight = useCallback(() => {
80
85
  if (!isAutoResizable) {
81
86
  return;
@@ -127,33 +132,38 @@ const Textarea = React__default.forwardRef((_ref, ref) => {
127
132
  computedStyle.height = state.height;
128
133
  computedStyle.overflow = state.overflow ? 'hidden' : undefined;
129
134
  }
130
- const onSelectHandler = props.readOnly ? composeEventHandlers(onSelect, event => {
135
+ const onSelectHandler = other.readOnly ? composeEventHandlers(onSelect, event => {
131
136
  event.currentTarget.select();
132
137
  }) : onSelect;
133
138
  let combinedProps = {
134
- ref: mergeRefs([textAreaRef, ref]),
135
- rows: minRows,
139
+ $focusInset: focusInset,
140
+ $isBare: isBare,
141
+ $isCompact: isCompact,
142
+ $isResizable: isResizable,
143
+ $validation: validation,
136
144
  onChange: onChangeHandler,
137
145
  onSelect: onSelectHandler,
146
+ ref: mergeRefs([textAreaRef, ref]),
147
+ rows: minRows,
138
148
  style: {
139
149
  ...computedStyle,
140
150
  ...style
141
151
  },
142
- ...props
152
+ ...other
143
153
  };
144
154
  if (fieldContext) {
145
155
  combinedProps = fieldContext.getInputProps(combinedProps);
146
156
  }
147
- return React__default.createElement(React__default.Fragment, null, React__default.createElement(StyledTextarea, combinedProps), isAutoResizable && React__default.createElement(StyledTextarea, {
157
+ return React__default.createElement(React__default.Fragment, null, React__default.createElement(StyledTextarea, combinedProps), !!isAutoResizable && React__default.createElement(StyledTextarea, {
158
+ $isBare: isBare,
159
+ $isCompact: isCompact,
160
+ $isHidden: true,
148
161
  "aria-hidden": true,
162
+ className: other.className,
149
163
  readOnly: true,
150
- isHidden: true,
151
- className: props.className,
152
164
  ref: shadowTextAreaRef,
153
- tabIndex: -1,
154
- isBare: props.isBare,
155
- isCompact: props.isCompact,
156
- style: style
165
+ style: style,
166
+ tabIndex: -1
157
167
  }));
158
168
  });
159
169
  Textarea.propTypes = {
@@ -57,14 +57,15 @@ import useFieldsetContext from '../utils/useFieldsetContext.js';
57
57
  const Toggle = React__default.forwardRef((_ref, ref) => {
58
58
  let {
59
59
  children,
60
- ...props
60
+ isCompact,
61
+ ...other
61
62
  } = _ref;
62
63
  const fieldsetContext = useFieldsetContext();
63
64
  const fieldContext = useFieldContext();
64
65
  let combinedProps = {
66
+ $isCompact: fieldsetContext ? fieldsetContext.isCompact : isCompact,
65
67
  ref,
66
- ...props,
67
- ...fieldsetContext
68
+ ...other
68
69
  };
69
70
  if (fieldContext) {
70
71
  combinedProps = fieldContext.getInputProps(combinedProps);
@@ -53,14 +53,19 @@ import '../../styled/tiles/StyledTileInput.js';
53
53
  import '../../styled/tiles/StyledTileLabel.js';
54
54
  import { FieldsetContext } from '../../utils/useFieldsetContext.js';
55
55
 
56
- const FieldsetComponent = forwardRef((props, ref) => {
56
+ const FieldsetComponent = forwardRef((_ref, ref) => {
57
+ let {
58
+ isCompact,
59
+ ...other
60
+ } = _ref;
57
61
  const fieldsetContext = useMemo(() => ({
58
- isCompact: props.isCompact
59
- }), [props.isCompact]);
62
+ isCompact
63
+ }), [isCompact]);
60
64
  return React__default.createElement(FieldsetContext.Provider, {
61
65
  value: fieldsetContext
62
- }, React__default.createElement(StyledFieldset, Object.assign({}, props, {
63
- ref: ref
66
+ }, React__default.createElement(StyledFieldset, Object.assign({}, other, {
67
+ ref: ref,
68
+ $isCompact: isCompact
64
69
  })));
65
70
  });
66
71
  FieldsetComponent.displayName = 'Fieldset';
@@ -87,6 +87,6 @@ const Hint = React__default.forwardRef((props, ref) => {
87
87
  ref: ref
88
88
  }, combinedProps));
89
89
  });
90
- Hint.displayName = 'Hint';
90
+ Hint.displayName = 'Field.Hint';
91
91
 
92
92
  export { Hint };
@@ -55,11 +55,17 @@ import '../../styled/tiles/StyledTileIcon.js';
55
55
  import '../../styled/tiles/StyledTileInput.js';
56
56
  import '../../styled/tiles/StyledTileLabel.js';
57
57
 
58
- const Label = React__default.forwardRef((props, ref) => {
58
+ const Label = React__default.forwardRef((_ref, ref) => {
59
+ let {
60
+ children,
61
+ isRegular,
62
+ ...other
63
+ } = _ref;
59
64
  const fieldContext = useFieldContext();
60
65
  const fieldsetContext = useFieldsetContext();
61
66
  const type = useInputContext();
62
- let combinedProps = props;
67
+ const $isRegular = fieldsetContext && isRegular === undefined ? true : isRegular;
68
+ let combinedProps = other;
63
69
  if (fieldContext) {
64
70
  combinedProps = fieldContext.getLabelProps(combinedProps);
65
71
  if (type === undefined) {
@@ -67,36 +73,29 @@ const Label = React__default.forwardRef((props, ref) => {
67
73
  setIsLabelActive,
68
74
  setIsLabelHovered
69
75
  } = fieldContext;
70
- combinedProps = {
71
- ...combinedProps,
72
- onMouseUp: composeEventHandlers(props.onMouseUp, () => {
73
- setIsLabelActive(false);
74
- }),
75
- onMouseDown: composeEventHandlers(props.onMouseDown, () => {
76
- setIsLabelActive(true);
77
- }),
78
- onMouseEnter: composeEventHandlers(props.onMouseEnter, () => {
79
- setIsLabelHovered(true);
80
- }),
81
- onMouseLeave: composeEventHandlers(props.onMouseLeave, () => {
82
- setIsLabelHovered(false);
83
- })
84
- };
76
+ combinedProps.onMouseUp = composeEventHandlers(other.onMouseUp, () => {
77
+ setIsLabelActive(false);
78
+ });
79
+ combinedProps.onMouseDown = composeEventHandlers(other.onMouseDown, () => {
80
+ setIsLabelActive(true);
81
+ });
82
+ combinedProps.onMouseEnter = composeEventHandlers(other.onMouseEnter, () => {
83
+ setIsLabelHovered(true);
84
+ });
85
+ combinedProps.onMouseLeave = composeEventHandlers(other.onMouseLeave, () => {
86
+ setIsLabelHovered(false);
87
+ });
85
88
  }
86
89
  }
87
- if (fieldsetContext) {
88
- combinedProps = {
89
- ...combinedProps,
90
- isRegular: combinedProps.isRegular === undefined ? true : combinedProps.isRegular
91
- };
92
- }
93
90
  if (type === 'radio') {
94
91
  return React__default.createElement(StyledRadioLabel, Object.assign({
95
92
  ref: ref
96
- }, combinedProps), React__default.createElement(StyledRadioSvg, null), props.children);
93
+ }, combinedProps, {
94
+ $isRegular: $isRegular
95
+ }), React__default.createElement(StyledRadioSvg, null), children);
97
96
  } else if (type === 'checkbox') {
98
97
  const onLabelSelect = e => {
99
- const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
98
+ const isFirefox = navigator?.userAgent.toLowerCase().indexOf('firefox') > -1;
100
99
  if (fieldContext && isFirefox && e.target instanceof Element) {
101
100
  const inputId = e.target.getAttribute('for');
102
101
  if (!inputId) return;
@@ -110,23 +109,26 @@ const Label = React__default.forwardRef((props, ref) => {
110
109
  }
111
110
  }
112
111
  };
113
- combinedProps = {
114
- ...combinedProps,
115
- onClick: composeEventHandlers(combinedProps.onClick, onLabelSelect)
116
- };
112
+ combinedProps.onClick = composeEventHandlers(combinedProps.onClick, onLabelSelect);
117
113
  return React__default.createElement(StyledCheckLabel, Object.assign({
118
114
  ref: ref
119
- }, combinedProps), React__default.createElement(StyledCheckSvg, null), React__default.createElement(StyledDashSvg, null), props.children);
115
+ }, combinedProps, {
116
+ $isRegular: $isRegular
117
+ }), React__default.createElement(StyledCheckSvg, null), React__default.createElement(StyledDashSvg, null), children);
120
118
  } else if (type === 'toggle') {
121
119
  return React__default.createElement(StyledToggleLabel, Object.assign({
122
120
  ref: ref
123
- }, combinedProps), React__default.createElement(StyledToggleSvg, null), props.children);
121
+ }, combinedProps, {
122
+ $isRegular: $isRegular
123
+ }), React__default.createElement(StyledToggleSvg, null), children);
124
124
  }
125
125
  return React__default.createElement(StyledLabel, Object.assign({
126
126
  ref: ref
127
- }, combinedProps));
127
+ }, combinedProps, {
128
+ $isRegular: $isRegular
129
+ }), children);
128
130
  });
129
- Label.displayName = 'Label';
131
+ Label.displayName = 'Field.Label';
130
132
  Label.propTypes = {
131
133
  isRegular: PropTypes.bool
132
134
  };
@@ -49,11 +49,9 @@ import '../../styled/tiles/StyledTileDescription.js';
49
49
  import '../../styled/tiles/StyledTileIcon.js';
50
50
  import '../../styled/tiles/StyledTileInput.js';
51
51
  import '../../styled/tiles/StyledTileLabel.js';
52
- import useFieldsetContext from '../../utils/useFieldsetContext.js';
53
52
 
54
53
  const LegendComponent = forwardRef((props, ref) => {
55
- const fieldsetContext = useFieldsetContext();
56
- return React__default.createElement(StyledLegend, Object.assign({}, props, fieldsetContext, {
54
+ return React__default.createElement(StyledLegend, Object.assign({}, props, {
57
55
  ref: ref
58
56
  }));
59
57
  });
@@ -16,7 +16,7 @@ import '../../styled/common/StyledLegend.js';
16
16
  import '../../styled/common/StyledHint.js';
17
17
  import '../../styled/common/StyledLabel.js';
18
18
  import { StyledMessage } from '../../styled/common/StyledMessage.js';
19
- import { StyledMessageIcon } from '../../styled/common/StyledMessageIcon.js';
19
+ import '../../styled/common/StyledMessageIcon.js';
20
20
  import '../../styled/text/StyledTextInput.js';
21
21
  import '../../styled/text/StyledTextarea.js';
22
22
  import '../../styled/text/StyledTextFauxInput.js';
@@ -54,13 +54,14 @@ import '../../styled/tiles/StyledTileDescription.js';
54
54
  import '../../styled/tiles/StyledTileIcon.js';
55
55
  import '../../styled/tiles/StyledTileInput.js';
56
56
  import '../../styled/tiles/StyledTileLabel.js';
57
+ import { MessageIcon } from './MessageIcon.js';
57
58
 
58
59
  const Message = React__default.forwardRef((_ref, ref) => {
59
60
  let {
60
61
  validation,
61
62
  validationLabel,
62
63
  children,
63
- ...props
64
+ ...other
64
65
  } = _ref;
65
66
  const {
66
67
  hasMessage,
@@ -89,9 +90,9 @@ const Message = React__default.forwardRef((_ref, ref) => {
89
90
  MessageComponent = StyledMessage;
90
91
  }
91
92
  let combinedProps = {
92
- validation,
93
+ $validation: validation,
93
94
  validationLabel,
94
- ...props
95
+ ...other
95
96
  };
96
97
  if (getMessageProps) {
97
98
  combinedProps = getMessageProps(combinedProps);
@@ -99,12 +100,12 @@ const Message = React__default.forwardRef((_ref, ref) => {
99
100
  const ariaLabel = useText(Message, combinedProps, 'validationLabel', validation, validation !== undefined);
100
101
  return React__default.createElement(MessageComponent, Object.assign({
101
102
  ref: ref
102
- }, combinedProps), validation && React__default.createElement(StyledMessageIcon, {
103
+ }, combinedProps), !!validation && React__default.createElement(MessageIcon, {
103
104
  validation: validation,
104
105
  "aria-label": ariaLabel
105
106
  }), children);
106
107
  });
107
- Message.displayName = 'Message';
108
+ Message.displayName = 'Field.Message';
108
109
  Message.propTypes = {
109
110
  validation: PropTypes.oneOf(VALIDATION),
110
111
  validationLabel: PropTypes.string
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import React__default from 'react';
8
+ import PropTypes from 'prop-types';
9
+ import SvgAlertErrorStroke from '../../node_modules/@zendeskgarden/svg-icons/src/16/alert-error-stroke.svg.js';
10
+ import SvgAlertWarningStroke from '../../node_modules/@zendeskgarden/svg-icons/src/16/alert-warning-stroke.svg.js';
11
+ import SvgCheckCircleStroke from '../../node_modules/@zendeskgarden/svg-icons/src/16/check-circle-stroke.svg.js';
12
+ import '../../styled/common/StyledField.js';
13
+ import '../../styled/common/StyledFieldset.js';
14
+ import '../../styled/common/StyledLegend.js';
15
+ import '../../styled/common/StyledHint.js';
16
+ import '../../styled/common/StyledLabel.js';
17
+ import '../../styled/common/StyledMessage.js';
18
+ import { StyledMessageIcon } from '../../styled/common/StyledMessageIcon.js';
19
+ import '../../styled/text/StyledTextInput.js';
20
+ import '../../styled/text/StyledTextarea.js';
21
+ import '../../styled/text/StyledTextFauxInput.js';
22
+ import '../../styled/text/StyledTextMediaInput.js';
23
+ import '../../styled/text/StyledTextMediaFigure.js';
24
+ import '../../styled/input-group/StyledInputGroup.js';
25
+ import '../../styled/checkbox/StyledCheckLabel.js';
26
+ import '../../styled/checkbox/StyledCheckHint.js';
27
+ import '../../styled/checkbox/StyledCheckInput.js';
28
+ import '../../styled/checkbox/StyledCheckMessage.js';
29
+ import '../../styled/checkbox/StyledCheckSvg.js';
30
+ import '../../styled/checkbox/StyledDashSvg.js';
31
+ import '../../styled/file-upload/StyledFileUpload.js';
32
+ import '../../styled/file-list/StyledFile.js';
33
+ import '../../styled/file-list/StyledFileClose.js';
34
+ import '../../styled/file-list/StyledFileDelete.js';
35
+ import '../../styled/file-list/StyledFileIcon.js';
36
+ import '../../styled/file-list/StyledFileList.js';
37
+ import '../../styled/file-list/StyledFileListItem.js';
38
+ import '../../styled/radio/StyledRadioLabel.js';
39
+ import '../../styled/radio/StyledRadioHint.js';
40
+ import '../../styled/radio/StyledRadioInput.js';
41
+ import '../../styled/radio/StyledRadioMessage.js';
42
+ import '../../styled/radio/StyledRadioSvg.js';
43
+ import '../../styled/toggle/StyledToggleLabel.js';
44
+ import '../../styled/toggle/StyledToggleHint.js';
45
+ import '../../styled/toggle/StyledToggleInput.js';
46
+ import '../../styled/toggle/StyledToggleMessage.js';
47
+ import '../../styled/toggle/StyledToggleSvg.js';
48
+ import '../../styled/select/StyledSelect.js';
49
+ import '../../styled/select/StyledSelectWrapper.js';
50
+ import '../../styled/range/StyledRangeInput.js';
51
+ import '../../styled/tiles/StyledTile.js';
52
+ import '../../styled/tiles/StyledTileDescription.js';
53
+ import '../../styled/tiles/StyledTileIcon.js';
54
+ import '../../styled/tiles/StyledTileInput.js';
55
+ import '../../styled/tiles/StyledTileLabel.js';
56
+ import { VALIDATION } from '../../types/index.js';
57
+
58
+ const MessageIcon = _ref => {
59
+ let {
60
+ validation,
61
+ children,
62
+ ...props
63
+ } = _ref;
64
+ return React__default.createElement(StyledMessageIcon, Object.assign({
65
+ "aria-hidden": null,
66
+ role: "img"
67
+ }, props), validation ? {
68
+ error: React__default.createElement(SvgAlertErrorStroke, null),
69
+ success: React__default.createElement(SvgCheckCircleStroke, null),
70
+ warning: React__default.createElement(SvgAlertWarningStroke, null)
71
+ }[validation] : children);
72
+ };
73
+ MessageIcon.displayName = 'Field.MessageIcon';
74
+ MessageIcon.propTypes = {
75
+ validation: PropTypes.oneOf(VALIDATION)
76
+ };
77
+
78
+ export { MessageIcon };
@@ -57,12 +57,18 @@ import { EndIcon } from './components/EndIcon.js';
57
57
 
58
58
  const FauxInputComponent = forwardRef((_ref, ref) => {
59
59
  let {
60
- onFocus,
61
- onBlur,
62
60
  disabled,
63
- readOnly,
61
+ focusInset,
62
+ isBare,
63
+ isCompact,
64
64
  isFocused: controlledIsFocused,
65
- ...props
65
+ isHovered,
66
+ onBlur,
67
+ onFocus,
68
+ readOnly,
69
+ validation,
70
+ mediaLayout,
71
+ ...other
66
72
  } = _ref;
67
73
  const [isFocused, setIsFocused] = useState(false);
68
74
  const onFocusHandler = composeEventHandlers(onFocus, () => {
@@ -74,11 +80,17 @@ const FauxInputComponent = forwardRef((_ref, ref) => {
74
80
  return React__default.createElement(StyledTextFauxInput, Object.assign({
75
81
  onFocus: onFocusHandler,
76
82
  onBlur: onBlurHandler,
77
- isFocused: controlledIsFocused === undefined ? isFocused : controlledIsFocused,
78
- isReadOnly: readOnly,
79
- isDisabled: disabled,
83
+ $focusInset: focusInset,
84
+ $isBare: isBare,
85
+ $isCompact: isCompact,
86
+ $isDisabled: disabled,
87
+ $isFocused: controlledIsFocused === undefined ? isFocused : controlledIsFocused,
88
+ $isHovered: isHovered,
89
+ $isReadOnly: readOnly,
90
+ $mediaLayout: mediaLayout,
91
+ $validation: validation,
80
92
  tabIndex: disabled ? undefined : 0
81
- }, props, {
93
+ }, other, {
82
94
  ref: ref
83
95
  }));
84
96
  });
@@ -53,12 +53,16 @@ import '../../../styled/tiles/StyledTileLabel.js';
53
53
  const EndIconComponent = _ref => {
54
54
  let {
55
55
  isDisabled,
56
+ isFocused,
57
+ isHovered,
56
58
  isRotated,
57
59
  ...props
58
60
  } = _ref;
59
61
  return React__default.createElement(StyledTextMediaFigure, Object.assign({
60
62
  $position: "end",
61
63
  $isDisabled: isDisabled,
64
+ $isFocused: isFocused,
65
+ $isHovered: isHovered,
62
66
  $isRotated: isRotated
63
67
  }, props));
64
68
  };
@@ -53,12 +53,16 @@ import '../../../styled/tiles/StyledTileLabel.js';
53
53
  const StartIconComponent = _ref => {
54
54
  let {
55
55
  isDisabled,
56
+ isFocused,
57
+ isHovered,
56
58
  isRotated,
57
59
  ...props
58
60
  } = _ref;
59
61
  return React__default.createElement(StyledTextMediaFigure, Object.assign({
60
62
  $position: "start",
61
63
  $isDisabled: isDisabled,
64
+ $isFocused: isFocused,
65
+ $isHovered: isHovered,
62
66
  $isRotated: isRotated
63
67
  }, props));
64
68
  };