@zendeskgarden/react-forms 9.15.7 → 9.16.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.
- package/dist/esm/elements/Checkbox.js +1 -0
- package/dist/esm/elements/ClearableInput.js +111 -0
- package/dist/esm/elements/FileUpload.js +1 -0
- package/dist/esm/elements/Input.js +4 -2
- package/dist/esm/elements/MediaInput.js +1 -0
- package/dist/esm/elements/Radio.js +1 -0
- package/dist/esm/elements/Range.js +1 -0
- package/dist/esm/elements/Select.js +1 -0
- package/dist/esm/elements/Textarea.js +1 -0
- package/dist/esm/elements/Toggle.js +1 -0
- package/dist/esm/elements/common/Field.js +6 -2
- package/dist/esm/elements/common/Fieldset.js +1 -0
- package/dist/esm/elements/common/Hint.js +1 -0
- package/dist/esm/elements/common/Label.js +9 -1
- package/dist/esm/elements/common/Legend.js +1 -0
- package/dist/esm/elements/common/Message.js +1 -0
- package/dist/esm/elements/common/MessageIcon.js +1 -0
- package/dist/esm/elements/faux-input/FauxInput.js +1 -0
- package/dist/esm/elements/faux-input/components/EndIcon.js +1 -0
- package/dist/esm/elements/faux-input/components/StartIcon.js +1 -0
- package/dist/esm/elements/file-list/FileList.js +1 -0
- package/dist/esm/elements/file-list/components/Close.js +1 -0
- package/dist/esm/elements/file-list/components/Delete.js +1 -0
- package/dist/esm/elements/file-list/components/File.js +1 -0
- package/dist/esm/elements/file-list/components/Item.js +1 -0
- package/dist/esm/elements/input-group/InputGroup.js +26 -49
- package/dist/esm/elements/tiles/components/Description.js +1 -0
- package/dist/esm/elements/tiles/components/Icon.js +1 -0
- package/dist/esm/elements/tiles/components/Label.js +1 -0
- package/dist/esm/elements/tiles/components/Tile.js +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/x-stroke.svg.js +6 -6
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/x-stroke.svg.js +6 -6
- package/dist/esm/styled/checkbox/StyledCheckHint.js +1 -1
- package/dist/esm/styled/checkbox/StyledCheckInput.js +1 -1
- package/dist/esm/styled/checkbox/StyledCheckLabel.js +1 -1
- package/dist/esm/styled/checkbox/StyledCheckMessage.js +1 -1
- package/dist/esm/styled/checkbox/StyledCheckSvg.js +1 -1
- package/dist/esm/styled/checkbox/StyledDashSvg.js +1 -1
- package/dist/esm/styled/common/StyledField.js +1 -1
- package/dist/esm/styled/common/StyledFieldset.js +1 -1
- package/dist/esm/styled/common/StyledHint.js +1 -1
- package/dist/esm/styled/common/StyledLabel.js +1 -1
- package/dist/esm/styled/common/StyledLegend.js +1 -1
- package/dist/esm/styled/common/StyledMessage.js +1 -1
- package/dist/esm/styled/common/StyledMessageIcon.js +1 -1
- package/dist/esm/styled/file-list/StyledFile.js +1 -1
- package/dist/esm/styled/file-list/StyledFileClose.js +1 -1
- package/dist/esm/styled/file-list/StyledFileDelete.js +1 -1
- package/dist/esm/styled/file-list/StyledFileIcon.js +1 -1
- package/dist/esm/styled/file-list/StyledFileList.js +1 -1
- package/dist/esm/styled/file-list/StyledFileListItem.js +1 -1
- package/dist/esm/styled/file-upload/StyledFileUpload.js +1 -1
- package/dist/esm/styled/input-group/StyledClearableInput.js +16 -0
- package/dist/esm/styled/input-group/StyledInputGroup.js +97 -5
- package/dist/esm/styled/radio/StyledRadioHint.js +1 -1
- package/dist/esm/styled/radio/StyledRadioInput.js +1 -1
- package/dist/esm/styled/radio/StyledRadioLabel.js +1 -1
- package/dist/esm/styled/radio/StyledRadioMessage.js +1 -1
- package/dist/esm/styled/radio/StyledRadioSvg.js +1 -1
- package/dist/esm/styled/range/StyledRangeInput.js +1 -1
- package/dist/esm/styled/select/StyledSelect.js +1 -1
- package/dist/esm/styled/select/StyledSelectWrapper.js +1 -1
- package/dist/esm/styled/text/StyledTextFauxInput.js +1 -1
- package/dist/esm/styled/text/StyledTextInput.js +2 -2
- package/dist/esm/styled/text/StyledTextMediaFigure.js +1 -1
- package/dist/esm/styled/text/StyledTextMediaInput.js +1 -1
- package/dist/esm/styled/text/StyledTextarea.js +1 -1
- package/dist/esm/styled/tiles/StyledTile.js +1 -1
- package/dist/esm/styled/tiles/StyledTileDescription.js +1 -1
- package/dist/esm/styled/tiles/StyledTileIcon.js +1 -1
- package/dist/esm/styled/tiles/StyledTileLabel.js +1 -1
- package/dist/esm/styled/toggle/StyledToggleHint.js +1 -1
- package/dist/esm/styled/toggle/StyledToggleInput.js +1 -1
- package/dist/esm/styled/toggle/StyledToggleLabel.js +1 -1
- package/dist/esm/styled/toggle/StyledToggleMessage.js +1 -1
- package/dist/esm/styled/toggle/StyledToggleSvg.js +1 -1
- package/dist/esm/utils/useInputGroupContext.js +53 -2
- package/dist/index.cjs.js +362 -91
- package/dist/typings/elements/ClearableInput.d.ts +12 -0
- package/dist/typings/index.d.ts +3 -1
- package/dist/typings/styled/index.d.ts +1 -0
- package/dist/typings/styled/input-group/StyledClearableInput.d.ts +12 -0
- package/dist/typings/styled/input-group/StyledInputGroup.d.ts +4 -0
- package/dist/typings/types/index.d.ts +22 -3
- package/dist/typings/utils/useFieldContext.d.ts +2 -0
- package/dist/typings/utils/useInputGroupContext.d.ts +22 -0
- package/package.json +4 -3
|
@@ -11,7 +11,7 @@ import { StyledRadioLabel } from '../radio/StyledRadioLabel.js';
|
|
|
11
11
|
const COMPONENT_ID$s = 'forms.checkbox_label';
|
|
12
12
|
const StyledCheckLabel = styled(StyledRadioLabel).attrs({
|
|
13
13
|
'data-garden-id': COMPONENT_ID$s,
|
|
14
|
-
'data-garden-version': '9.
|
|
14
|
+
'data-garden-version': '9.16.0'
|
|
15
15
|
}).withConfig({
|
|
16
16
|
displayName: "StyledCheckLabel",
|
|
17
17
|
componentId: "sc-x7nr1-0"
|
|
@@ -11,7 +11,7 @@ import { StyledRadioMessage } from '../radio/StyledRadioMessage.js';
|
|
|
11
11
|
const COMPONENT_ID$m = 'forms.checkbox_message';
|
|
12
12
|
const StyledCheckMessage = styled(StyledRadioMessage).attrs({
|
|
13
13
|
'data-garden-id': COMPONENT_ID$m,
|
|
14
|
-
'data-garden-version': '9.
|
|
14
|
+
'data-garden-version': '9.16.0'
|
|
15
15
|
}).withConfig({
|
|
16
16
|
displayName: "StyledCheckMessage",
|
|
17
17
|
componentId: "sc-s4p6kd-0"
|
|
@@ -13,7 +13,7 @@ import { StyledCheckLabel } from './StyledCheckLabel.js';
|
|
|
13
13
|
const COMPONENT_ID$l = 'forms.check_svg';
|
|
14
14
|
const StyledCheckSvg = styled(SvgCheckSmFill).attrs({
|
|
15
15
|
'data-garden-id': COMPONENT_ID$l,
|
|
16
|
-
'data-garden-version': '9.
|
|
16
|
+
'data-garden-version': '9.16.0'
|
|
17
17
|
}).withConfig({
|
|
18
18
|
displayName: "StyledCheckSvg",
|
|
19
19
|
componentId: "sc-fvxetk-0"
|
|
@@ -13,7 +13,7 @@ import { StyledCheckLabel } from './StyledCheckLabel.js';
|
|
|
13
13
|
const COMPONENT_ID$k = 'forms.dash_svg';
|
|
14
14
|
const StyledDashSvg = styled(SvgDashFill).attrs({
|
|
15
15
|
'data-garden-id': COMPONENT_ID$k,
|
|
16
|
-
'data-garden-version': '9.
|
|
16
|
+
'data-garden-version': '9.16.0'
|
|
17
17
|
}).withConfig({
|
|
18
18
|
displayName: "StyledDashSvg",
|
|
19
19
|
componentId: "sc-z3vq71-0"
|
|
@@ -10,7 +10,7 @@ import { componentStyles } from '@zendeskgarden/react-theming';
|
|
|
10
10
|
const COMPONENT_ID$G = 'forms.field';
|
|
11
11
|
const StyledField = styled.div.attrs({
|
|
12
12
|
'data-garden-id': COMPONENT_ID$G,
|
|
13
|
-
'data-garden-version': '9.
|
|
13
|
+
'data-garden-version': '9.16.0'
|
|
14
14
|
}).withConfig({
|
|
15
15
|
displayName: "StyledField",
|
|
16
16
|
componentId: "sc-12gzfsu-0"
|
|
@@ -12,7 +12,7 @@ const COMPONENT_ID$F = 'forms.fieldset';
|
|
|
12
12
|
const StyledFieldset = styled(StyledField).attrs({
|
|
13
13
|
as: 'fieldset',
|
|
14
14
|
'data-garden-id': COMPONENT_ID$F,
|
|
15
|
-
'data-garden-version': '9.
|
|
15
|
+
'data-garden-version': '9.16.0'
|
|
16
16
|
}).withConfig({
|
|
17
17
|
displayName: "StyledFieldset",
|
|
18
18
|
componentId: "sc-1vr4mxv-0"
|
|
@@ -10,7 +10,7 @@ import { getLineHeight, getColor, componentStyles } from '@zendeskgarden/react-t
|
|
|
10
10
|
const COMPONENT_ID$C = 'forms.input_hint';
|
|
11
11
|
const StyledHint = styled.div.attrs(props => ({
|
|
12
12
|
'data-garden-id': props['data-garden-id'] || COMPONENT_ID$C,
|
|
13
|
-
'data-garden-version': props['data-garden-version'] || '9.
|
|
13
|
+
'data-garden-version': props['data-garden-version'] || '9.16.0'
|
|
14
14
|
})).withConfig({
|
|
15
15
|
displayName: "StyledHint",
|
|
16
16
|
componentId: "sc-17c2wu8-0"
|
|
@@ -11,7 +11,7 @@ import { getLineHeight, getColor, componentStyles } from '@zendeskgarden/react-t
|
|
|
11
11
|
const COMPONENT_ID$E = 'forms.input_label';
|
|
12
12
|
const StyledLabel = styled.label.attrs(props => ({
|
|
13
13
|
'data-garden-id': props['data-garden-id'] || COMPONENT_ID$E,
|
|
14
|
-
'data-garden-version': props['data-garden-version'] || '9.
|
|
14
|
+
'data-garden-version': props['data-garden-version'] || '9.16.0'
|
|
15
15
|
})).withConfig({
|
|
16
16
|
displayName: "StyledLabel",
|
|
17
17
|
componentId: "sc-2utmsz-0"
|
|
@@ -12,7 +12,7 @@ const COMPONENT_ID$D = 'forms.fieldset_legend';
|
|
|
12
12
|
const StyledLegend = styled(StyledLabel).attrs({
|
|
13
13
|
as: 'legend',
|
|
14
14
|
'data-garden-id': COMPONENT_ID$D,
|
|
15
|
-
'data-garden-version': '9.
|
|
15
|
+
'data-garden-version': '9.16.0'
|
|
16
16
|
}).withConfig({
|
|
17
17
|
displayName: "StyledLegend",
|
|
18
18
|
componentId: "sc-6s0zwq-0"
|
|
@@ -43,7 +43,7 @@ const sizeStyles$g = ({
|
|
|
43
43
|
};
|
|
44
44
|
const StyledMessage = styled.div.attrs(props => ({
|
|
45
45
|
'data-garden-id': props['data-garden-id'] || COMPONENT_ID$A,
|
|
46
|
-
'data-garden-version': props['data-garden-version'] || '9.
|
|
46
|
+
'data-garden-version': props['data-garden-version'] || '9.16.0'
|
|
47
47
|
})).withConfig({
|
|
48
48
|
displayName: "StyledMessage",
|
|
49
49
|
componentId: "sc-30hgg7-0"
|
|
@@ -10,7 +10,7 @@ import { StyledBaseIcon, componentStyles } from '@zendeskgarden/react-theming';
|
|
|
10
10
|
const COMPONENT_ID$B = 'forms.input_message_icon';
|
|
11
11
|
const StyledMessageIcon = styled(StyledBaseIcon).attrs({
|
|
12
12
|
'data-garden-id': COMPONENT_ID$B,
|
|
13
|
-
'data-garden-version': '9.
|
|
13
|
+
'data-garden-version': '9.16.0'
|
|
14
14
|
}).withConfig({
|
|
15
15
|
displayName: "StyledMessageIcon",
|
|
16
16
|
componentId: "sc-1ph2gba-0"
|
|
@@ -10,7 +10,7 @@ import { getColor, componentStyles } from '@zendeskgarden/react-theming';
|
|
|
10
10
|
const COMPONENT_ID$i = 'forms.file.close';
|
|
11
11
|
const StyledFileClose = styled.button.attrs({
|
|
12
12
|
'data-garden-id': COMPONENT_ID$i,
|
|
13
|
-
'data-garden-version': '9.
|
|
13
|
+
'data-garden-version': '9.16.0'
|
|
14
14
|
}).withConfig({
|
|
15
15
|
displayName: "StyledFileClose",
|
|
16
16
|
componentId: "sc-1m31jbf-0"
|
|
@@ -11,7 +11,7 @@ import { StyledFileClose } from './StyledFileClose.js';
|
|
|
11
11
|
const COMPONENT_ID$g = 'forms.file.delete';
|
|
12
12
|
const StyledFileDelete = styled(StyledFileClose).attrs({
|
|
13
13
|
'data-garden-id': COMPONENT_ID$g,
|
|
14
|
-
'data-garden-version': '9.
|
|
14
|
+
'data-garden-version': '9.16.0'
|
|
15
15
|
}).withConfig({
|
|
16
16
|
displayName: "StyledFileDelete",
|
|
17
17
|
componentId: "sc-a8nnhx-0"
|
|
@@ -28,7 +28,7 @@ const sizeStyles$9 = ({
|
|
|
28
28
|
};
|
|
29
29
|
const StyledFileIcon = styled(StyledBaseIcon).attrs({
|
|
30
30
|
'data-garden-id': COMPONENT_ID$f,
|
|
31
|
-
'data-garden-version': '9.
|
|
31
|
+
'data-garden-version': '9.16.0'
|
|
32
32
|
}).withConfig({
|
|
33
33
|
displayName: "StyledFileIcon",
|
|
34
34
|
componentId: "sc-7b3q0c-0"
|
|
@@ -10,7 +10,7 @@ import { componentStyles } from '@zendeskgarden/react-theming';
|
|
|
10
10
|
const COMPONENT_ID$e = 'forms.file_list';
|
|
11
11
|
const StyledFileList = styled.ul.attrs({
|
|
12
12
|
'data-garden-id': COMPONENT_ID$e,
|
|
13
|
-
'data-garden-version': '9.
|
|
13
|
+
'data-garden-version': '9.16.0'
|
|
14
14
|
}).withConfig({
|
|
15
15
|
displayName: "StyledFileList",
|
|
16
16
|
componentId: "sc-gbahjg-0"
|
|
@@ -12,7 +12,7 @@ import { StyledFileUpload } from '../file-upload/StyledFileUpload.js';
|
|
|
12
12
|
const COMPONENT_ID$d = 'forms.file_list.item';
|
|
13
13
|
const StyledFileListItem = styled.li.attrs({
|
|
14
14
|
'data-garden-id': COMPONENT_ID$d,
|
|
15
|
-
'data-garden-version': '9.
|
|
15
|
+
'data-garden-version': '9.16.0'
|
|
16
16
|
}).withConfig({
|
|
17
17
|
displayName: "StyledFileListItem",
|
|
18
18
|
componentId: "sc-1ova3lo-0"
|
|
@@ -102,7 +102,7 @@ const sizeStyles$b = ({
|
|
|
102
102
|
};
|
|
103
103
|
const StyledFileUpload = styled.div.attrs({
|
|
104
104
|
'data-garden-id': COMPONENT_ID$j,
|
|
105
|
-
'data-garden-version': '9.
|
|
105
|
+
'data-garden-version': '9.16.0'
|
|
106
106
|
}).withConfig({
|
|
107
107
|
displayName: "StyledFileUpload",
|
|
108
108
|
componentId: "sc-1rodjgn-0"
|
|
@@ -0,0 +1,16 @@
|
|
|
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 styled, { css } from 'styled-components';
|
|
8
|
+
import { InputGroup } from '../../elements/input-group/InputGroup.js';
|
|
9
|
+
import { StyledInputGroup } from './StyledInputGroup.js';
|
|
10
|
+
|
|
11
|
+
const StyledClearableInput = styled(InputGroup).withConfig({
|
|
12
|
+
displayName: "StyledClearableInput",
|
|
13
|
+
componentId: "sc-v0381a-0"
|
|
14
|
+
})(["", ""], props => props.$isBare && css(["&&", "{border:none;border-radius:0;background-color:transparent;&:focus-within{box-shadow:none;}}"], StyledInputGroup));
|
|
15
|
+
|
|
16
|
+
export { StyledClearableInput };
|
|
@@ -5,28 +5,120 @@
|
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
7
|
import styled, { css } from 'styled-components';
|
|
8
|
-
import {
|
|
8
|
+
import { math, em } from 'polished';
|
|
9
|
+
import { componentStyles, getColor, focusStyles } from '@zendeskgarden/react-theming';
|
|
9
10
|
import { StyledTextInput } from '../text/StyledTextInput.js';
|
|
10
11
|
import { StyledLabel } from '../common/StyledLabel.js';
|
|
11
12
|
import { StyledHint } from '../common/StyledHint.js';
|
|
12
13
|
import { StyledMessage } from '../common/StyledMessage.js';
|
|
13
14
|
|
|
14
15
|
const COMPONENT_ID$u = 'forms.input_group';
|
|
16
|
+
const BUTTON_SELECTOR = "button[data-garden-id='buttons.button']";
|
|
17
|
+
const ICON_BUTTON_SELECTOR = "button[data-garden-id='buttons.icon_button']";
|
|
18
|
+
const getCompactIconButtonSize = theme => math(`${theme.space.base}px * 6`);
|
|
19
|
+
const VALIDATION_BORDER_VARIABLE = {
|
|
20
|
+
success: 'border.successEmphasis',
|
|
21
|
+
warning: 'border.warningEmphasis',
|
|
22
|
+
error: 'border.dangerEmphasis'
|
|
23
|
+
};
|
|
24
|
+
const readOnlyStyles = props => {
|
|
25
|
+
const {
|
|
26
|
+
theme
|
|
27
|
+
} = props;
|
|
28
|
+
const backgroundColor = getColor({
|
|
29
|
+
theme,
|
|
30
|
+
variable: 'background.disabled'
|
|
31
|
+
});
|
|
32
|
+
return css(["&:has(", "[readonly]){background-color:", ";}"], StyledTextInput, backgroundColor);
|
|
33
|
+
};
|
|
34
|
+
const disabledStyles = props => {
|
|
35
|
+
const {
|
|
36
|
+
theme
|
|
37
|
+
} = props;
|
|
38
|
+
const borderColor = getColor({
|
|
39
|
+
theme,
|
|
40
|
+
variable: 'border.disabled'
|
|
41
|
+
});
|
|
42
|
+
const backgroundColor = getColor({
|
|
43
|
+
theme,
|
|
44
|
+
variable: 'background.disabled'
|
|
45
|
+
});
|
|
46
|
+
return css(["&:has(", ":disabled){border-color:", ";background-color:", ";cursor:default;}"], StyledTextInput, borderColor, backgroundColor);
|
|
47
|
+
};
|
|
48
|
+
const unifiedItemStyles = props => {
|
|
49
|
+
const {
|
|
50
|
+
theme,
|
|
51
|
+
$isCompact,
|
|
52
|
+
$focusInset,
|
|
53
|
+
$validation
|
|
54
|
+
} = props;
|
|
55
|
+
const fontSize = theme.fontSizes.md;
|
|
56
|
+
const containerSize = $isCompact ? theme.space.lg : theme.space.xl;
|
|
57
|
+
const buttonSize = math(`${theme.space.base}px * ${$isCompact ? 6 : 7}`);
|
|
58
|
+
const iconButtonSize = $isCompact ? getCompactIconButtonSize(theme) : theme.space.lg;
|
|
59
|
+
const backgroundColor = getColor({
|
|
60
|
+
theme,
|
|
61
|
+
variable: 'background.default'
|
|
62
|
+
});
|
|
63
|
+
const buttonLineHeight = math(`${buttonSize} - (${theme.borderWidths.sm} * 2)`);
|
|
64
|
+
let borderColor;
|
|
65
|
+
let hoverBorderColor;
|
|
66
|
+
let borderVariable;
|
|
67
|
+
if ($validation) {
|
|
68
|
+
borderVariable = VALIDATION_BORDER_VARIABLE[$validation];
|
|
69
|
+
borderColor = getColor({
|
|
70
|
+
theme,
|
|
71
|
+
variable: borderVariable
|
|
72
|
+
});
|
|
73
|
+
hoverBorderColor = borderColor;
|
|
74
|
+
} else {
|
|
75
|
+
borderVariable = 'border.primaryEmphasis';
|
|
76
|
+
borderColor = getColor({
|
|
77
|
+
theme,
|
|
78
|
+
variable: 'border.default',
|
|
79
|
+
dark: {
|
|
80
|
+
offset: -100
|
|
81
|
+
},
|
|
82
|
+
light: {
|
|
83
|
+
offset: 100
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
hoverBorderColor = getColor({
|
|
87
|
+
theme,
|
|
88
|
+
variable: borderVariable
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
const focusBorderColor = hoverBorderColor;
|
|
92
|
+
const buttonEdgeTarget = em(theme.space.sm, fontSize);
|
|
93
|
+
const iconButtonInset = (parseFloat(iconButtonSize) - parseFloat(theme.iconSizes.md)) / 2;
|
|
94
|
+
const iconButtonPaddingInline = `calc(${buttonEdgeTarget} - ${iconButtonInset}px)`;
|
|
95
|
+
return css(["box-sizing:border-box;align-items:center;transition:border-color 0.25s ease-in-out,box-shadow 0.1s ease-in-out;border:", ";border-radius:", ";border-color:", ";background-color:", ";cursor:text;min-height:", ";font-size:", ";padding-inline:", ";&:hover{border-color:", ";}&:has(> ", ":first-child){padding-inline-start:", ";}&:has(> ", ":last-child){padding-inline-end:", ";}&:has(> ", ":first-child),&:has(> [data-garden-id='", "']:first-child){padding-inline-start:0;}&:has(> ", ":last-child),&:has(> [data-garden-id='", "']:last-child){padding-inline-end:0;}& > * + ", "{margin-inline-start:", ";}& > ", " + ", "{margin-inline-start:", ";}", " & ", "{align-self:stretch;}& > ", "{padding-inline:", ";}& > * + ", "{margin-inline-start:", ";}& > ", ":first-child{border-start-start-radius:", ";border-end-start-radius:", ";padding-inline-start:", ";}& > ", ":last-child{border-start-end-radius:", ";border-end-end-radius:", ";padding-inline-end:", ";}& > [data-garden-id='", "']:first-child > ", ":first-child{border-start-start-radius:", ";border-end-start-radius:", ";}& > [data-garden-id='", "']:last-child > ", ":last-child{border-start-end-radius:", ";border-end-end-radius:", ";}& ", "{flex:none;align-self:center;width:", ";min-width:", ";height:", ";min-height:", ";}& > [data-garden-id='", "']{flex:1 1 auto;align-self:stretch;border:none;background-color:transparent;min-width:0;min-height:0;padding-block:0;padding-inline:0;&:has(> ", ":last-child){padding-inline-end:0;}&:has(> ", ":first-child){padding-inline-start:0;}&:focus-within:not(:has(button:focus-visible)){border-color:transparent;box-shadow:none;}&:has(", ":disabled),&:has(", "[readonly]){background-color:transparent;}}& ", "{height:", ";min-height:", ";line-height:", ";}", " ", " ", ""], theme.borders.sm, theme.borderRadii.md, borderColor, backgroundColor, containerSize, fontSize, theme.space.xxs, hoverBorderColor, ICON_BUTTON_SELECTOR, iconButtonPaddingInline, ICON_BUTTON_SELECTOR, iconButtonPaddingInline, StyledTextInput, COMPONENT_ID$u, StyledTextInput, COMPONENT_ID$u, BUTTON_SELECTOR, theme.space.xxs, StyledTextInput, ICON_BUTTON_SELECTOR, theme.space.xxs, $isCompact && css(["& > [data-garden-id='", "'] + ", "{margin-inline-start:", ";}"], COMPONENT_ID$u, ICON_BUTTON_SELECTOR, theme.space.xs), StyledTextInput, StyledTextInput, theme.space.xs, StyledTextInput, theme.space.xxs, StyledTextInput, theme.borderRadii.md, theme.borderRadii.md, theme.space.sm, StyledTextInput, theme.borderRadii.md, theme.borderRadii.md, theme.space.sm, COMPONENT_ID$u, StyledTextInput, theme.borderRadii.md, theme.borderRadii.md, COMPONENT_ID$u, StyledTextInput, theme.borderRadii.md, theme.borderRadii.md, ICON_BUTTON_SELECTOR, iconButtonSize, iconButtonSize, iconButtonSize, iconButtonSize, COMPONENT_ID$u, ICON_BUTTON_SELECTOR, ICON_BUTTON_SELECTOR, StyledTextInput, StyledTextInput, BUTTON_SELECTOR, buttonSize, buttonSize, buttonLineHeight, focusStyles({
|
|
96
|
+
theme,
|
|
97
|
+
inset: $focusInset,
|
|
98
|
+
color: {
|
|
99
|
+
variable: borderVariable
|
|
100
|
+
},
|
|
101
|
+
selector: '&:focus-within:not(:has(button:focus-visible))',
|
|
102
|
+
styles: {
|
|
103
|
+
borderColor: focusBorderColor
|
|
104
|
+
}
|
|
105
|
+
}), readOnlyStyles(props), disabledStyles(props));
|
|
106
|
+
};
|
|
15
107
|
const positionStyles = props => {
|
|
16
108
|
const topMargin = `${props.theme.space.base * (props.$isCompact ? 1 : 2)}px`;
|
|
17
|
-
return css(["", ":not([hidden]) + &&,", " + &&,", "
|
|
109
|
+
return css(["", ":not([hidden]) + &&,", " + &&,", " ~ &&,&& + ", ",&& ~ ", "{margin-top:", ";}& > ", "{position:relative;flex:1 1 auto;margin-top:0;margin-bottom:0;width:auto;min-width:0;}"], StyledLabel, StyledHint, StyledMessage, StyledHint, StyledMessage, topMargin, StyledTextInput);
|
|
18
110
|
};
|
|
19
|
-
const
|
|
111
|
+
const segmentedItemStyles = props => {
|
|
20
112
|
const startDirection = props.theme.rtl ? 'right' : 'left';
|
|
21
113
|
const endDirection = props.theme.rtl ? 'left' : 'right';
|
|
22
114
|
return css(["& > *{z-index:-1;}& > ", "{z-index:0;}& > ", ":disabled{z-index:-2;}& > ", ":hover,& > button:hover,& > ", ":focus-visible,& > button:focus-visible,& > ", ":active,& > button:active,& > button[aria-pressed='true'],& > button[aria-pressed='mixed']{z-index:1;}& > button:disabled{border-top-width:0;border-bottom-width:0;}& > *:not(:first-child){margin-", ":-", ";}& > *:first-child:not(:last-child){border-top-", "-radius:0;border-bottom-", "-radius:0;}& > *:last-child:not(:first-child){border-top-", "-radius:0;border-bottom-", "-radius:0;}& > *:not(:first-child):not(:last-child){border-radius:0;}"], StyledTextInput, StyledTextInput, StyledTextInput, StyledTextInput, StyledTextInput, startDirection, props.theme.borderWidths.sm, endDirection, endDirection, startDirection, startDirection);
|
|
23
115
|
};
|
|
24
116
|
const StyledInputGroup = styled.div.attrs({
|
|
25
117
|
'data-garden-id': COMPONENT_ID$u,
|
|
26
|
-
'data-garden-version': '9.
|
|
118
|
+
'data-garden-version': '9.16.0'
|
|
27
119
|
}).withConfig({
|
|
28
120
|
displayName: "StyledInputGroup",
|
|
29
121
|
componentId: "sc-kjh1f0-0"
|
|
30
|
-
})(["display:inline-flex;position:relative;flex-wrap:nowrap;align-items:stretch;z-index:0;width:100%;", ";", ";", ";"], props => positionStyles(props), props =>
|
|
122
|
+
})(["display:inline-flex;position:relative;flex-wrap:nowrap;align-items:stretch;z-index:0;width:100%;", ";", ";", ";", ";"], props => positionStyles(props), props => !props.$isUnified && segmentedItemStyles(props), props => props.$isUnified && unifiedItemStyles(props), componentStyles);
|
|
31
123
|
|
|
32
124
|
export { StyledInputGroup };
|
|
@@ -12,7 +12,7 @@ import { StyledHint } from '../common/StyledHint.js';
|
|
|
12
12
|
const COMPONENT_ID$r = 'forms.radio_hint';
|
|
13
13
|
const StyledRadioHint = styled(StyledHint).attrs({
|
|
14
14
|
'data-garden-id': COMPONENT_ID$r,
|
|
15
|
-
'data-garden-version': '9.
|
|
15
|
+
'data-garden-version': '9.16.0'
|
|
16
16
|
}).withConfig({
|
|
17
17
|
displayName: "StyledRadioHint",
|
|
18
18
|
componentId: "sc-eo8twg-0"
|
|
@@ -107,7 +107,7 @@ const sizeStyles$c = ({
|
|
|
107
107
|
};
|
|
108
108
|
const StyledRadioInput = styled.input.attrs({
|
|
109
109
|
'data-garden-id': COMPONENT_ID$p,
|
|
110
|
-
'data-garden-version': '9.
|
|
110
|
+
'data-garden-version': '9.16.0',
|
|
111
111
|
type: 'radio'
|
|
112
112
|
}).withConfig({
|
|
113
113
|
displayName: "StyledRadioInput",
|
|
@@ -17,7 +17,7 @@ const sizeStyles$d = props => {
|
|
|
17
17
|
};
|
|
18
18
|
const StyledRadioLabel = styled(StyledLabel).attrs({
|
|
19
19
|
'data-garden-id': COMPONENT_ID$t,
|
|
20
|
-
'data-garden-version': '9.
|
|
20
|
+
'data-garden-version': '9.16.0',
|
|
21
21
|
$isRadio: true
|
|
22
22
|
}).withConfig({
|
|
23
23
|
displayName: "StyledRadioLabel",
|
|
@@ -12,7 +12,7 @@ import { StyledMessage } from '../common/StyledMessage.js';
|
|
|
12
12
|
const COMPONENT_ID$n = 'forms.radio_message';
|
|
13
13
|
const StyledRadioMessage = styled(StyledMessage).attrs({
|
|
14
14
|
'data-garden-id': COMPONENT_ID$n,
|
|
15
|
-
'data-garden-version': '9.
|
|
15
|
+
'data-garden-version': '9.16.0'
|
|
16
16
|
}).withConfig({
|
|
17
17
|
displayName: "StyledRadioMessage",
|
|
18
18
|
componentId: "sc-1pmi0q8-0"
|
|
@@ -13,7 +13,7 @@ import { StyledRadioLabel } from './StyledRadioLabel.js';
|
|
|
13
13
|
const COMPONENT_ID$c = 'forms.radio_svg';
|
|
14
14
|
const StyledRadioSvg = styled(SvgCircleSmFill).attrs({
|
|
15
15
|
'data-garden-id': COMPONENT_ID$c,
|
|
16
|
-
'data-garden-version': '9.
|
|
16
|
+
'data-garden-version': '9.16.0'
|
|
17
17
|
}).withConfig({
|
|
18
18
|
displayName: "StyledRadioSvg",
|
|
19
19
|
componentId: "sc-1r1qtr1-0"
|
|
@@ -172,7 +172,7 @@ const sizeStyles$4 = ({
|
|
|
172
172
|
};
|
|
173
173
|
const StyledRangeInput = styled.input.attrs(props => ({
|
|
174
174
|
'data-garden-id': COMPONENT_ID$4,
|
|
175
|
-
'data-garden-version': '9.
|
|
175
|
+
'data-garden-version': '9.16.0',
|
|
176
176
|
type: 'range',
|
|
177
177
|
style: {
|
|
178
178
|
backgroundSize: props.$hasLowerTrack ?? true ? props.$backgroundSize ?? '0%' : undefined
|
|
@@ -42,7 +42,7 @@ const sizeStyles$6 = ({
|
|
|
42
42
|
};
|
|
43
43
|
const StyledSelect = styled(StyledTextInput).attrs({
|
|
44
44
|
'data-garden-id': COMPONENT_ID$6,
|
|
45
|
-
'data-garden-version': '9.
|
|
45
|
+
'data-garden-version': '9.16.0',
|
|
46
46
|
as: 'select'
|
|
47
47
|
}).withConfig({
|
|
48
48
|
displayName: "StyledSelect",
|
|
@@ -19,7 +19,7 @@ const sizeStyles$5 = ({
|
|
|
19
19
|
};
|
|
20
20
|
const StyledSelectWrapper = styled(StyledTextFauxInput).attrs({
|
|
21
21
|
'data-garden-id': COMPONENT_ID$5,
|
|
22
|
-
'data-garden-version': '9.
|
|
22
|
+
'data-garden-version': '9.16.0'
|
|
23
23
|
}).withConfig({
|
|
24
24
|
displayName: "StyledSelectWrapper",
|
|
25
25
|
componentId: "sc-i7b6hw-0"
|
|
@@ -56,7 +56,7 @@ const StyledTextFauxInput = styled(StyledTextInput).attrs(props => ({
|
|
|
56
56
|
'aria-readonly': props.$isReadOnly,
|
|
57
57
|
'aria-disabled': props.$isDisabled,
|
|
58
58
|
'data-garden-id': COMPONENT_ID$w,
|
|
59
|
-
'data-garden-version': '9.
|
|
59
|
+
'data-garden-version': '9.16.0'
|
|
60
60
|
})).withConfig({
|
|
61
61
|
displayName: "StyledTextFauxInput",
|
|
62
62
|
componentId: "sc-yqw7j9-0"
|
|
@@ -134,8 +134,8 @@ const sizeStyles$f = ({
|
|
|
134
134
|
return css(["padding:", ";min-height:", ";line-height:", ";font-size:", ";&::-ms-browse{font-size:", ";}&[type='date'],&[type='datetime-local'],&[type='file'],&[type='month'],&[type='time'],&[type='week']{max-height:", ";}&[type='file']{line-height:1;}@supports (-ms-ime-align:auto){&[type='color']{padding:", ";}}&::-moz-color-swatch{margin-top:", ";margin-left:", ";width:calc(100% + ", ");height:", ";}&::-webkit-calendar-picker-indicator{background-position:center;background-size:", ";padding:0;width:", ";height:", ";}&::-webkit-color-swatch{margin:", " ", ";}", ":not([hidden]) + &&,", " + &&,", " + &&,&& + ", ",&& ~ ", "{margin-top:", "px;}"], padding, $isBare ? '1em' : height, getLineHeight(lineHeight, fontSize), fontSize, browseFontSize, height, $isCompact ? '0 2px' : '1px 3px', swatchMarginVertical, swatchMarginHorizontal, math(`${swatchMarginHorizontal} * -2`), swatchHeight, calendarPickerBackgroundSize, calendarPickerSize, calendarPickerSize, swatchMarginVertical, swatchMarginHorizontal, StyledLabel, StyledHint, StyledMessage, StyledHint, StyledMessage, theme.space.base * ($isCompact ? 1 : 2));
|
|
135
135
|
};
|
|
136
136
|
const StyledTextInput = styled.input.attrs(props => ({
|
|
137
|
-
'data-garden-id': COMPONENT_ID$z,
|
|
138
|
-
'data-garden-version': '9.
|
|
137
|
+
'data-garden-id': props['data-garden-id'] || COMPONENT_ID$z,
|
|
138
|
+
'data-garden-version': '9.16.0',
|
|
139
139
|
'aria-invalid': isInvalid(props.$validation)
|
|
140
140
|
})).withConfig({
|
|
141
141
|
displayName: "StyledTextInput",
|
|
@@ -55,7 +55,7 @@ const sizeStyles$e = props => {
|
|
|
55
55
|
};
|
|
56
56
|
const StyledTextMediaFigure = styled(StyledBaseIcon).attrs({
|
|
57
57
|
'data-garden-id': COMPONENT_ID$x,
|
|
58
|
-
'data-garden-version': '9.
|
|
58
|
+
'data-garden-version': '9.16.0'
|
|
59
59
|
}).withConfig({
|
|
60
60
|
displayName: "StyledTextMediaFigure",
|
|
61
61
|
componentId: "sc-1qepknj-0"
|
|
@@ -11,7 +11,7 @@ import { StyledTextInput } from './StyledTextInput.js';
|
|
|
11
11
|
const COMPONENT_ID$v = 'forms.media_input';
|
|
12
12
|
const StyledTextMediaInput = styled(StyledTextInput).attrs({
|
|
13
13
|
'data-garden-id': COMPONENT_ID$v,
|
|
14
|
-
'data-garden-version': '9.
|
|
14
|
+
'data-garden-version': '9.16.0',
|
|
15
15
|
$isBare: true
|
|
16
16
|
}).withConfig({
|
|
17
17
|
displayName: "StyledTextMediaInput",
|
|
@@ -21,7 +21,7 @@ const hiddenStyles = `
|
|
|
21
21
|
const StyledTextarea = styled(StyledTextInput).attrs({
|
|
22
22
|
as: 'textarea',
|
|
23
23
|
'data-garden-id': COMPONENT_ID$y,
|
|
24
|
-
'data-garden-version': '9.
|
|
24
|
+
'data-garden-version': '9.16.0'
|
|
25
25
|
}).withConfig({
|
|
26
26
|
displayName: "StyledTextarea",
|
|
27
27
|
componentId: "sc-wxschl-0"
|
|
@@ -100,7 +100,7 @@ const sizeStyles$3 = ({
|
|
|
100
100
|
};
|
|
101
101
|
const StyledTile = styled.label.attrs({
|
|
102
102
|
'data-garden-id': COMPONENT_ID$3,
|
|
103
|
-
'data-garden-version': '9.
|
|
103
|
+
'data-garden-version': '9.16.0'
|
|
104
104
|
}).withConfig({
|
|
105
105
|
displayName: "StyledTile",
|
|
106
106
|
componentId: "sc-1jjvmxs-0"
|
|
@@ -21,7 +21,7 @@ const sizeStyles$2 = ({
|
|
|
21
21
|
};
|
|
22
22
|
const StyledTileDescription = styled.span.attrs({
|
|
23
23
|
'data-garden-id': COMPONENT_ID$2,
|
|
24
|
-
'data-garden-version': '9.
|
|
24
|
+
'data-garden-version': '9.16.0'
|
|
25
25
|
}).withConfig({
|
|
26
26
|
displayName: "StyledTileDescription",
|
|
27
27
|
componentId: "sc-xfuu7u-0"
|
|
@@ -63,7 +63,7 @@ const sizeStyles$1 = ({
|
|
|
63
63
|
};
|
|
64
64
|
const StyledTileIcon = styled.span.attrs({
|
|
65
65
|
'data-garden-id': COMPONENT_ID$1,
|
|
66
|
-
'data-garden-version': '9.
|
|
66
|
+
'data-garden-version': '9.16.0'
|
|
67
67
|
}).withConfig({
|
|
68
68
|
displayName: "StyledTileIcon",
|
|
69
69
|
componentId: "sc-1wazhg4-0"
|
|
@@ -21,7 +21,7 @@ const sizeStyles = ({
|
|
|
21
21
|
};
|
|
22
22
|
const StyledTileLabel = styled.span.attrs({
|
|
23
23
|
'data-garden-id': COMPONENT_ID,
|
|
24
|
-
'data-garden-version': '9.
|
|
24
|
+
'data-garden-version': '9.16.0'
|
|
25
25
|
}).withConfig({
|
|
26
26
|
displayName: "StyledTileLabel",
|
|
27
27
|
componentId: "sc-1mypv27-0"
|
|
@@ -12,7 +12,7 @@ import { StyledHint } from '../common/StyledHint.js';
|
|
|
12
12
|
const COMPONENT_ID$a = 'forms.toggle_hint';
|
|
13
13
|
const StyledToggleHint = styled(StyledHint).attrs({
|
|
14
14
|
'data-garden-id': COMPONENT_ID$a,
|
|
15
|
-
'data-garden-version': '9.
|
|
15
|
+
'data-garden-version': '9.16.0'
|
|
16
16
|
}).withConfig({
|
|
17
17
|
displayName: "StyledToggleHint",
|
|
18
18
|
componentId: "sc-nziggu-0"
|
|
@@ -51,7 +51,7 @@ const sizeStyles$7 = ({
|
|
|
51
51
|
};
|
|
52
52
|
const StyledToggleInput = styled(StyledCheckInput).attrs({
|
|
53
53
|
'data-garden-id': COMPONENT_ID$9,
|
|
54
|
-
'data-garden-version': '9.
|
|
54
|
+
'data-garden-version': '9.16.0'
|
|
55
55
|
}).withConfig({
|
|
56
56
|
displayName: "StyledToggleInput",
|
|
57
57
|
componentId: "sc-sgp47s-0"
|
|
@@ -16,7 +16,7 @@ const sizeStyles$8 = props => {
|
|
|
16
16
|
};
|
|
17
17
|
const StyledToggleLabel = styled(StyledCheckLabel).attrs({
|
|
18
18
|
'data-garden-id': COMPONENT_ID$b,
|
|
19
|
-
'data-garden-version': '9.
|
|
19
|
+
'data-garden-version': '9.16.0'
|
|
20
20
|
}).withConfig({
|
|
21
21
|
displayName: "StyledToggleLabel",
|
|
22
22
|
componentId: "sc-e0asdk-0"
|
|
@@ -13,7 +13,7 @@ import { StyledMessageIcon } from '../common/StyledMessageIcon.js';
|
|
|
13
13
|
const COMPONENT_ID$8 = 'forms.toggle_message';
|
|
14
14
|
const StyledToggleMessage = styled(StyledMessage).attrs({
|
|
15
15
|
'data-garden-id': COMPONENT_ID$8,
|
|
16
|
-
'data-garden-version': '9.
|
|
16
|
+
'data-garden-version': '9.16.0'
|
|
17
17
|
}).withConfig({
|
|
18
18
|
displayName: "StyledToggleMessage",
|
|
19
19
|
componentId: "sc-13vuvl1-0"
|
|
@@ -11,7 +11,7 @@ import { componentStyles } from '@zendeskgarden/react-theming';
|
|
|
11
11
|
const COMPONENT_ID$7 = 'forms.toggle_svg';
|
|
12
12
|
const StyledToggleSvg = styled(SvgCircleSmFill).attrs({
|
|
13
13
|
'data-garden-id': COMPONENT_ID$7,
|
|
14
|
-
'data-garden-version': '9.
|
|
14
|
+
'data-garden-version': '9.16.0'
|
|
15
15
|
}).withConfig({
|
|
16
16
|
displayName: "StyledToggleSvg",
|
|
17
17
|
componentId: "sc-162xbyx-0"
|
|
@@ -4,11 +4,62 @@
|
|
|
4
4
|
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
|
-
import { createContext, useContext } from 'react';
|
|
7
|
+
import { createContext, useRef, useState, useCallback, useContext, useLayoutEffect } from 'react';
|
|
8
8
|
|
|
9
9
|
const InputGroupContext = createContext(undefined);
|
|
10
10
|
const useInputGroupContext = () => {
|
|
11
11
|
return useContext(InputGroupContext);
|
|
12
12
|
};
|
|
13
|
+
const deriveValidation = map => {
|
|
14
|
+
let derived;
|
|
15
|
+
map.forEach(value => {
|
|
16
|
+
derived = value;
|
|
17
|
+
});
|
|
18
|
+
return derived;
|
|
19
|
+
};
|
|
20
|
+
const useInputGroupValidationState = () => {
|
|
21
|
+
const validationsRef = useRef(new Map());
|
|
22
|
+
const [validation, setValidation] = useState();
|
|
23
|
+
const registerValidation = useCallback((id, next) => {
|
|
24
|
+
const map = validationsRef.current;
|
|
25
|
+
if (next === undefined) {
|
|
26
|
+
if (!map.has(id)) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
map.delete(id);
|
|
30
|
+
} else if (map.get(id) === next) {
|
|
31
|
+
return;
|
|
32
|
+
} else {
|
|
33
|
+
if (!map.has(id) && map.size > 0 && process.env.NODE_ENV === 'development') {
|
|
34
|
+
console.warn('Warning: a unified <InputGroup> supports a single Input with a `validation` prop. Multiple validation-bearing Inputs produce an ambiguous container validation state. Render a single Input per unified group, or use the classic InputGroup for multi-input layouts.');
|
|
35
|
+
}
|
|
36
|
+
map.set(id, next);
|
|
37
|
+
}
|
|
38
|
+
const derived = deriveValidation(map);
|
|
39
|
+
setValidation(prev => prev === derived ? prev : derived);
|
|
40
|
+
}, []);
|
|
41
|
+
return {
|
|
42
|
+
validation,
|
|
43
|
+
registerValidation
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
const usePublishInputGroupValidation = validation => {
|
|
47
|
+
const context = useInputGroupContext();
|
|
48
|
+
const id = useRef({});
|
|
49
|
+
const {
|
|
50
|
+
registerValidation,
|
|
51
|
+
isUnified
|
|
52
|
+
} = context || {};
|
|
53
|
+
useLayoutEffect(() => {
|
|
54
|
+
if (!registerValidation || !isUnified) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
const validationId = id.current;
|
|
58
|
+
registerValidation(validationId, validation);
|
|
59
|
+
return () => {
|
|
60
|
+
registerValidation(validationId, undefined);
|
|
61
|
+
};
|
|
62
|
+
}, [isUnified, registerValidation, validation]);
|
|
63
|
+
};
|
|
13
64
|
|
|
14
|
-
export { InputGroupContext, useInputGroupContext };
|
|
65
|
+
export { InputGroupContext, useInputGroupContext, useInputGroupValidationState, usePublishInputGroupValidation };
|