@zohodesk/components 1.2.4 → 1.2.6
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/README.md +8 -0
- package/coverage/Button/Button.js.html +1 -1
- package/coverage/Button/css/Button.module.css.html +1 -1
- package/coverage/Button/css/cssJSLogic.js.html +1 -1
- package/coverage/Button/css/index.html +1 -1
- package/coverage/Button/index.html +1 -1
- package/coverage/Button/props/defaultProps.js.html +1 -1
- package/coverage/Button/props/index.html +1 -1
- package/coverage/Button/props/propTypes.js.html +1 -1
- package/coverage/Buttongroup/Buttongroup.js.html +1 -1
- package/coverage/Buttongroup/Buttongroup.module.css.html +1 -1
- package/coverage/Buttongroup/index.html +1 -1
- package/coverage/Buttongroup/props/defaultProps.js.html +1 -1
- package/coverage/Buttongroup/props/index.html +1 -1
- package/coverage/Buttongroup/props/propTypes.js.html +1 -1
- package/coverage/index.html +1 -1
- package/coverage/utils/dummyFunction.js.html +1 -1
- package/coverage/utils/index.html +1 -1
- package/es/AppContainer/AppContainer.js +3 -0
- package/es/v1/Accordion/Accordion.js +65 -0
- package/es/v1/Accordion/AccordionItem.js +57 -0
- package/es/v1/Accordion/index.js +2 -0
- package/es/v1/Animation/Animation.js +127 -0
- package/es/v1/AppContainer/AppContainer.js +137 -0
- package/es/v1/Avatar/Avatar.js +189 -0
- package/es/v1/AvatarTeam/AvatarTeam.js +70 -0
- package/es/v1/Button/Button.js +68 -0
- package/es/v1/Buttongroup/Buttongroup.js +31 -0
- package/es/v1/Card/Card.js +271 -0
- package/es/v1/CheckBox/CheckBox.js +155 -0
- package/es/v1/DateTime/CalendarView.js +218 -0
- package/es/v1/DateTime/DateTime.js +783 -0
- package/es/v1/DateTime/DateTimePopupFooter.js +47 -0
- package/es/v1/DateTime/DateTimePopupHeader.js +105 -0
- package/es/v1/DateTime/DateWidget.js +1098 -0
- package/es/v1/DateTime/DaysRow.js +31 -0
- package/es/v1/DateTime/Time.js +166 -0
- package/es/v1/DateTime/YearView.js +264 -0
- package/es/v1/DateTime/index.js +1 -0
- package/es/v1/DropBox/DropBox.js +91 -0
- package/es/v1/DropBox/DropBoxElement/DropBoxElement.js +132 -0
- package/es/v1/DropDown/DropDown.js +73 -0
- package/es/v1/DropDown/DropDownHeading.js +44 -0
- package/es/v1/DropDown/DropDownItem.js +76 -0
- package/es/v1/DropDown/DropDownSearch.js +63 -0
- package/es/v1/DropDown/DropDownSeparator.js +15 -0
- package/es/v1/Heading/Heading.js +32 -0
- package/es/v1/Label/Label.js +40 -0
- package/es/v1/Layout/Box.js +115 -0
- package/es/v1/Layout/Container.js +132 -0
- package/es/v1/Layout/index.js +2 -0
- package/es/v1/ListItem/ListContainer.js +102 -0
- package/es/v1/ListItem/ListItem.js +124 -0
- package/es/v1/ListItem/ListItemWithAvatar.js +145 -0
- package/es/v1/ListItem/ListItemWithCheckBox.js +104 -0
- package/es/v1/ListItem/ListItemWithIcon.js +127 -0
- package/es/v1/ListItem/ListItemWithRadio.js +105 -0
- package/es/v1/ListItem/index.js +6 -0
- package/es/v1/Modal/Modal.js +154 -0
- package/es/v1/MultiSelect/AdvancedGroupMultiSelect.js +1079 -0
- package/es/v1/MultiSelect/AdvancedMultiSelect.js +568 -0
- package/es/v1/MultiSelect/EmptyState.js +64 -0
- package/es/v1/MultiSelect/MobileHeader/MobileHeader.js +50 -0
- package/es/v1/MultiSelect/MultiSelect.js +1120 -0
- package/es/v1/MultiSelect/MultiSelectHeader.js +32 -0
- package/es/v1/MultiSelect/MultiSelectWithAvatar.js +216 -0
- package/es/v1/MultiSelect/SelectedOptions.js +82 -0
- package/es/v1/MultiSelect/Suggestions.js +142 -0
- package/es/v1/MultiSelect/index.js +4 -0
- package/es/v1/PopOver/PopOver.js +211 -0
- package/es/v1/Popup/Popup.js +645 -0
- package/es/v1/Radio/Radio.js +115 -0
- package/es/v1/Responsive/CustomResponsive.js +195 -0
- package/es/v1/Responsive/RefWrapper.js +39 -0
- package/es/v1/Responsive/ResizeComponent.js +197 -0
- package/es/v1/Responsive/ResizeObserver.js +140 -0
- package/es/v1/Responsive/Responsive.js +194 -0
- package/es/v1/Responsive/index.js +9 -0
- package/es/v1/ResponsiveDropBox/ResponsiveDropBox.js +58 -0
- package/es/v1/Ribbon/Ribbon.js +33 -0
- package/es/v1/RippleEffect/RippleEffect.js +24 -0
- package/es/v1/Select/GroupSelect.js +803 -0
- package/es/v1/Select/Select.js +969 -0
- package/es/v1/Select/SelectWithAvatar.js +344 -0
- package/es/v1/Select/SelectWithIcon.js +535 -0
- package/es/v1/Select/index.js +4 -0
- package/es/v1/Stencils/Stencils.js +26 -0
- package/es/v1/Switch/Switch.js +94 -0
- package/es/v1/Tab/Tab.js +108 -0
- package/es/v1/Tab/TabContent.js +30 -0
- package/es/v1/Tab/TabContentWrapper.js +29 -0
- package/es/v1/Tab/TabWrapper.js +57 -0
- package/es/v1/Tab/Tabs.js +612 -0
- package/es/v1/Tab/index.js +5 -0
- package/es/v1/Tag/Tag.js +134 -0
- package/es/v1/TextBox/TextBox.js +154 -0
- package/es/v1/TextBoxIcon/TextBoxIcon.js +158 -0
- package/es/v1/Textarea/Textarea.js +102 -0
- package/es/v1/Tooltip/Tooltip.js +518 -0
- package/es/v1/Typography/Typography.js +38 -0
- package/es/v1/Typography/css/Typography.module.css +376 -0
- package/es/v1/Typography/css/cssJSLogic.js +46 -0
- package/es/v1/Typography/css/letterSpacingMap.js +12 -0
- package/es/v1/Typography/props/defaultProps.js +8 -0
- package/es/v1/Typography/props/propTypes.js +24 -0
- package/es/v1/VelocityAnimation/VelocityAnimation/VelocityAnimation.js +69 -0
- package/es/v1/VelocityAnimation/VelocityAnimationGroup/VelocityAnimationGroup.js +100 -0
- package/es/v1/semantic/Button/Button.js +53 -0
- package/es/v1/semantic/index.js +1 -0
- package/lib/AppContainer/AppContainer.js +5 -0
- package/lib/v1/Accordion/Accordion.js +96 -0
- package/lib/v1/Accordion/AccordionItem.js +68 -0
- package/lib/v1/Accordion/index.js +23 -0
- package/lib/v1/Animation/Animation.js +143 -0
- package/lib/v1/AppContainer/AppContainer.js +209 -0
- package/lib/v1/Avatar/Avatar.js +246 -0
- package/lib/v1/AvatarTeam/AvatarTeam.js +81 -0
- package/lib/v1/Button/Button.js +82 -0
- package/lib/v1/Buttongroup/Buttongroup.js +44 -0
- package/lib/v1/Card/Card.js +365 -0
- package/lib/v1/CheckBox/CheckBox.js +166 -0
- package/lib/v1/DateTime/CalendarView.js +285 -0
- package/lib/v1/DateTime/DateTime.js +872 -0
- package/lib/v1/DateTime/DateTimePopupFooter.js +96 -0
- package/lib/v1/DateTime/DateTimePopupHeader.js +166 -0
- package/lib/v1/DateTime/DateWidget.js +1125 -0
- package/lib/v1/DateTime/DaysRow.js +80 -0
- package/lib/v1/DateTime/Time.js +254 -0
- package/lib/v1/DateTime/YearView.js +325 -0
- package/lib/v1/DateTime/index.js +15 -0
- package/lib/v1/DropBox/DropBox.js +119 -0
- package/lib/v1/DropBox/DropBoxElement/DropBoxElement.js +145 -0
- package/lib/v1/DropDown/DropDown.js +170 -0
- package/lib/v1/DropDown/DropDownHeading.js +93 -0
- package/lib/v1/DropDown/DropDownItem.js +127 -0
- package/lib/v1/DropDown/DropDownSearch.js +113 -0
- package/lib/v1/DropDown/DropDownSeparator.js +64 -0
- package/lib/v1/Heading/Heading.js +49 -0
- package/lib/v1/Label/Label.js +51 -0
- package/lib/v1/Layout/Box.js +128 -0
- package/lib/v1/Layout/Container.js +145 -0
- package/lib/v1/Layout/index.js +23 -0
- package/lib/v1/ListItem/ListContainer.js +120 -0
- package/lib/v1/ListItem/ListItem.js +138 -0
- package/lib/v1/ListItem/ListItemWithAvatar.js +162 -0
- package/lib/v1/ListItem/ListItemWithCheckBox.js +125 -0
- package/lib/v1/ListItem/ListItemWithIcon.js +143 -0
- package/lib/v1/ListItem/ListItemWithRadio.js +126 -0
- package/lib/v1/ListItem/index.js +55 -0
- package/lib/v1/Modal/Modal.js +212 -0
- package/lib/v1/MultiSelect/AdvancedGroupMultiSelect.js +1167 -0
- package/lib/v1/MultiSelect/AdvancedMultiSelect.js +634 -0
- package/lib/v1/MultiSelect/EmptyState.js +112 -0
- package/lib/v1/MultiSelect/MobileHeader/MobileHeader.js +62 -0
- package/lib/v1/MultiSelect/MultiSelect.js +1201 -0
- package/lib/v1/MultiSelect/MultiSelectHeader.js +78 -0
- package/lib/v1/MultiSelect/MultiSelectWithAvatar.js +270 -0
- package/lib/v1/MultiSelect/SelectedOptions.js +126 -0
- package/lib/v1/MultiSelect/Suggestions.js +195 -0
- package/lib/v1/MultiSelect/index.js +39 -0
- package/lib/v1/PopOver/PopOver.js +293 -0
- package/lib/v1/Popup/Popup.js +715 -0
- package/lib/v1/Radio/Radio.js +126 -0
- package/lib/v1/Responsive/CustomResponsive.js +242 -0
- package/lib/v1/Responsive/RefWrapper.js +57 -0
- package/lib/v1/Responsive/ResizeComponent.js +268 -0
- package/lib/v1/Responsive/ResizeObserver.js +168 -0
- package/lib/v1/Responsive/Responsive.js +274 -0
- package/lib/v1/Responsive/index.js +55 -0
- package/lib/v1/ResponsiveDropBox/ResponsiveDropBox.js +79 -0
- package/lib/v1/Ribbon/Ribbon.js +44 -0
- package/lib/v1/RippleEffect/RippleEffect.js +39 -0
- package/lib/v1/Select/GroupSelect.js +877 -0
- package/lib/v1/Select/Select.js +1013 -0
- package/lib/v1/Select/SelectWithAvatar.js +394 -0
- package/lib/v1/Select/SelectWithIcon.js +597 -0
- package/lib/v1/Select/index.js +39 -0
- package/lib/v1/Stencils/Stencils.js +43 -0
- package/lib/v1/Switch/Switch.js +108 -0
- package/lib/v1/Tab/Tab.js +132 -0
- package/lib/v1/Tab/TabContent.js +42 -0
- package/lib/v1/Tab/TabContentWrapper.js +42 -0
- package/lib/v1/Tab/TabWrapper.js +89 -0
- package/lib/v1/Tab/Tabs.js +680 -0
- package/lib/v1/Tab/index.js +47 -0
- package/lib/v1/Tag/Tag.js +154 -0
- package/lib/v1/TextBox/TextBox.js +168 -0
- package/lib/v1/TextBoxIcon/TextBoxIcon.js +196 -0
- package/lib/v1/Textarea/Textarea.js +118 -0
- package/lib/v1/Tooltip/Tooltip.js +586 -0
- package/lib/v1/Typography/Typography.js +56 -0
- package/lib/v1/Typography/css/Typography.module.css +376 -0
- package/lib/v1/Typography/css/cssJSLogic.js +41 -0
- package/lib/v1/Typography/css/letterSpacingMap.js +20 -0
- package/lib/v1/Typography/props/defaultProps.js +15 -0
- package/lib/v1/Typography/props/propTypes.js +35 -0
- package/lib/v1/VelocityAnimation/VelocityAnimation/VelocityAnimation.js +90 -0
- package/lib/v1/VelocityAnimation/VelocityAnimationGroup/VelocityAnimationGroup.js +126 -0
- package/lib/v1/semantic/Button/Button.js +63 -0
- package/lib/v1/semantic/index.js +15 -0
- package/package.json +1 -1
- package/result.json +1 -1
package/es/v1/Tag/Tag.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
|
+
import { defaultProps } from '../../Tag/props/defaultProps';
|
|
3
|
+
import { propTypes } from '../../Tag/props/propTypes';
|
|
4
|
+
import { Icon } from '@zohodesk/icons';
|
|
5
|
+
import Avatar from '../Avatar/Avatar';
|
|
6
|
+
import { Container } from '../Layout';
|
|
7
|
+
import Button from '../semantic/Button/Button';
|
|
8
|
+
import { useUniqueId } from '../../Provider/IdProvider';
|
|
9
|
+
import style from '../../Tag/Tag.module.css';
|
|
10
|
+
/*
|
|
11
|
+
* eslint css-modules/no-unused-class: [2, { markAsUsed: ['small', 'medium',
|
|
12
|
+
* 'closedanger', 'closeprimary', 'default', 'danger', 'secondary',
|
|
13
|
+
* 'pureDotted', 'primaryDotted'] }]
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
* eslint css-modules/no-unused-class: [2, { markAsUsed: ['small', 'medium',
|
|
18
|
+
* 'closedanger', 'closeprimary', 'default', 'danger', 'secondary',
|
|
19
|
+
* 'pureDotted', 'primaryDotted'] }]
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
function Tag(props) {
|
|
23
|
+
let {
|
|
24
|
+
imageURL,
|
|
25
|
+
hasAvatar,
|
|
26
|
+
text,
|
|
27
|
+
onRemove,
|
|
28
|
+
initial,
|
|
29
|
+
active,
|
|
30
|
+
size,
|
|
31
|
+
rounded,
|
|
32
|
+
palette,
|
|
33
|
+
disabled,
|
|
34
|
+
closePalette,
|
|
35
|
+
onSelectTag,
|
|
36
|
+
closeTitle,
|
|
37
|
+
dataId,
|
|
38
|
+
dataSelectorId,
|
|
39
|
+
iconName,
|
|
40
|
+
iconSize,
|
|
41
|
+
tooltip,
|
|
42
|
+
avatarPalette,
|
|
43
|
+
customClass,
|
|
44
|
+
a11y,
|
|
45
|
+
needEffect,
|
|
46
|
+
isReadOnly,
|
|
47
|
+
id
|
|
48
|
+
} = props;
|
|
49
|
+
|
|
50
|
+
const handleSelect = e => {
|
|
51
|
+
e && e.preventDefault();
|
|
52
|
+
e.stopPropagation && e.stopPropagation();
|
|
53
|
+
e.nativeEvent.stopImmediatePropagation && e.nativeEvent.stopImmediatePropagation();
|
|
54
|
+
onSelectTag && onSelectTag(id, e);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const handleRemove = e => {
|
|
58
|
+
e && e.preventDefault();
|
|
59
|
+
e.stopPropagation && e.stopPropagation();
|
|
60
|
+
e.nativeEvent.stopImmediatePropagation && e.nativeEvent.stopImmediatePropagation();
|
|
61
|
+
onRemove && onRemove(id);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const getRef = el => {
|
|
65
|
+
let {
|
|
66
|
+
getRef
|
|
67
|
+
} = props;
|
|
68
|
+
getRef && getRef(el, id);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
let {
|
|
72
|
+
customTag = '',
|
|
73
|
+
customTagClose = '',
|
|
74
|
+
customTagIcon = '',
|
|
75
|
+
customAvatar = ''
|
|
76
|
+
} = customClass;
|
|
77
|
+
let textSizes = size === 'small' ? style.smalltext : style.mediumtext;
|
|
78
|
+
const getNextAriaId = useUniqueId();
|
|
79
|
+
const getAriaId = getNextAriaId();
|
|
80
|
+
let {
|
|
81
|
+
clearLabel = 'Delete'
|
|
82
|
+
} = a11y;
|
|
83
|
+
let isDarkPalette = palette === 'dark';
|
|
84
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
85
|
+
className: `${style.container} ${needEffect && !isReadOnly ? style.effect : style.readonly} ${active ? `${style.selected} ${style[`active${palette}`]}` : ''} ${onRemove ? active ? `${style[`active${size}Effect`]}` : '' : ''} ${style[size]} ${rounded ? style.lgRadius : style.smRadius} ${style[palette]} ${disabled ? style.disabled : ''} ${onSelectTag ? style.pointer : ''} ${customTag}`,
|
|
86
|
+
"data-id": active ? `${dataId}_TagSelected` : `${dataId}_Tag`,
|
|
87
|
+
"data-test-id": active ? `${dataId}_TagSelected` : `${dataId}_Tag`,
|
|
88
|
+
onClick: handleSelect,
|
|
89
|
+
ref: getRef,
|
|
90
|
+
"data-title": tooltip ? tooltip : text,
|
|
91
|
+
tabIndex: disabled ? '-1' : '0',
|
|
92
|
+
"aria-labelledby": getAriaId,
|
|
93
|
+
"data-selector-id": dataSelectorId
|
|
94
|
+
}, hasAvatar ? /*#__PURE__*/React.createElement("div", {
|
|
95
|
+
className: style.avatar
|
|
96
|
+
}, /*#__PURE__*/React.createElement(Avatar, {
|
|
97
|
+
palette: isDarkPalette ? 'info' : avatarPalette,
|
|
98
|
+
name: initial,
|
|
99
|
+
size: "small",
|
|
100
|
+
src: imageURL,
|
|
101
|
+
textPalette: isDarkPalette ? 'white' : '',
|
|
102
|
+
customClass: customAvatar
|
|
103
|
+
})) : null, iconName ? /*#__PURE__*/React.createElement("div", {
|
|
104
|
+
className: `${style.icon} ${customTagIcon}`,
|
|
105
|
+
"aria-hidden": true
|
|
106
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
107
|
+
name: iconName,
|
|
108
|
+
size: iconSize
|
|
109
|
+
})) : null, /*#__PURE__*/React.createElement("div", {
|
|
110
|
+
className: `${style.text} ${textSizes}`,
|
|
111
|
+
"aria-hidden": true,
|
|
112
|
+
id: getAriaId
|
|
113
|
+
}, text), onRemove && /*#__PURE__*/React.createElement(Button, {
|
|
114
|
+
customClass: `${style.close} ${active ? style[`active${closePalette}Close`] : ''}
|
|
115
|
+
${rounded ? style.lgRadiusClose : style.smRadiusClose} ${isDarkPalette ? style.darkTagClose : ''}
|
|
116
|
+
${customTagClose} ${style[`close${closePalette}`]}`,
|
|
117
|
+
dataId: `${dataId}_RemoveTag`,
|
|
118
|
+
"data-title": closeTitle,
|
|
119
|
+
onClick: handleRemove,
|
|
120
|
+
a11y: {
|
|
121
|
+
ariaLabel: clearLabel
|
|
122
|
+
}
|
|
123
|
+
}, /*#__PURE__*/React.createElement(Container, {
|
|
124
|
+
align: "both"
|
|
125
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
126
|
+
isBold: true,
|
|
127
|
+
name: "ZD-close2",
|
|
128
|
+
size: "8"
|
|
129
|
+
}))));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export default /*#__PURE__*/memo(Tag);
|
|
133
|
+
Tag.defaultProps = defaultProps;
|
|
134
|
+
Tag.propTypes = propTypes;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
import React, { useRef, useCallback } from 'react';
|
|
4
|
+
import { defaultProps } from '../../TextBox/props/defaultProps';
|
|
5
|
+
import { propTypes } from '../../TextBox/props/propTypes';
|
|
6
|
+
import style from '../../TextBox/TextBox.module.css';
|
|
7
|
+
export default function TextBox(props) {
|
|
8
|
+
let {
|
|
9
|
+
type,
|
|
10
|
+
name,
|
|
11
|
+
id,
|
|
12
|
+
maxLength,
|
|
13
|
+
placeHolder,
|
|
14
|
+
size,
|
|
15
|
+
onKeyUp,
|
|
16
|
+
isReadOnly,
|
|
17
|
+
isDisabled,
|
|
18
|
+
onKeyDown,
|
|
19
|
+
variant,
|
|
20
|
+
onClick,
|
|
21
|
+
needBorder,
|
|
22
|
+
value,
|
|
23
|
+
dataId,
|
|
24
|
+
autofocus,
|
|
25
|
+
needReadOnlyStyle,
|
|
26
|
+
needAppearance,
|
|
27
|
+
isClickable,
|
|
28
|
+
onKeyPress,
|
|
29
|
+
needEffect,
|
|
30
|
+
autoComplete,
|
|
31
|
+
borderColor,
|
|
32
|
+
onMouseDown,
|
|
33
|
+
htmlId,
|
|
34
|
+
a11y,
|
|
35
|
+
customClass,
|
|
36
|
+
isFocus,
|
|
37
|
+
customProps,
|
|
38
|
+
dataSelectorId,
|
|
39
|
+
onFocus,
|
|
40
|
+
onBlur,
|
|
41
|
+
onChange,
|
|
42
|
+
inputRef
|
|
43
|
+
} = props;
|
|
44
|
+
let {
|
|
45
|
+
ariaLabel,
|
|
46
|
+
ariaAutocomplete,
|
|
47
|
+
ariaControls,
|
|
48
|
+
ariaExpanded,
|
|
49
|
+
role,
|
|
50
|
+
ariaDescribedby,
|
|
51
|
+
ariaHaspopup,
|
|
52
|
+
ariaRequired,
|
|
53
|
+
ariaLabelledby,
|
|
54
|
+
ariaInvalid,
|
|
55
|
+
ariaOwns,
|
|
56
|
+
ariaActivedescendant,
|
|
57
|
+
ariaReadonly,
|
|
58
|
+
ariaMultiselectable
|
|
59
|
+
} = a11y;
|
|
60
|
+
let inputEle = useRef();
|
|
61
|
+
let options = useRef({});
|
|
62
|
+
|
|
63
|
+
if (isReadOnly) {
|
|
64
|
+
options.current.readOnly = true;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (isDisabled) {
|
|
68
|
+
options.current.disabled = true;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (autofocus) {
|
|
72
|
+
options.current.autoFocus = true;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (!autoComplete) {
|
|
76
|
+
options.current.autoComplete = 'off';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const handleFocus = () => {
|
|
80
|
+
onFocus && onFocus(id, value, name);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const handleBlur = () => {
|
|
84
|
+
onBlur && onBlur(id, value, name);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const handleRef = useCallback(ref => {
|
|
88
|
+
inputEle.current = ref;
|
|
89
|
+
inputRef && inputRef(ref);
|
|
90
|
+
}, []);
|
|
91
|
+
|
|
92
|
+
const setFocus = () => {
|
|
93
|
+
if (inputEle.current) {
|
|
94
|
+
inputEle.current.focus({
|
|
95
|
+
preventScroll: true
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const handleChange = e => {
|
|
101
|
+
e.preventDefault();
|
|
102
|
+
let {
|
|
103
|
+
value
|
|
104
|
+
} = e.target;
|
|
105
|
+
onChange && !isReadOnly && onChange(value, e);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
let classList = needAppearance ? `${style.container} ${style[size]} ${style[variant]} ${needBorder ? style.border : ''} ${isDisabled && !needEffect || isReadOnly && !needEffect ? '' : style.effect} ${isFocus ? style.focus : ''}` : `${style.basic}`;
|
|
109
|
+
value = value === null || value === undefined ? '' : value;
|
|
110
|
+
return /*#__PURE__*/React.createElement("input", _extends({
|
|
111
|
+
"aria-label": ariaLabel,
|
|
112
|
+
"aria-invalid": ariaInvalid,
|
|
113
|
+
"aria-autocomplete": ariaAutocomplete,
|
|
114
|
+
"aria-controls": ariaControls,
|
|
115
|
+
"aria-expanded": ariaExpanded,
|
|
116
|
+
"aria-describedby": ariaDescribedby,
|
|
117
|
+
role: role,
|
|
118
|
+
"aria-haspopup": ariaHaspopup,
|
|
119
|
+
"aria-required": ariaRequired,
|
|
120
|
+
"aria-labelledby": ariaLabelledby,
|
|
121
|
+
"aria-owns": ariaOwns,
|
|
122
|
+
"aria-activedescendant": ariaActivedescendant,
|
|
123
|
+
"aria-readonly": ariaReadonly,
|
|
124
|
+
"aria-multiselectable": ariaMultiselectable,
|
|
125
|
+
className: `${isReadOnly && needReadOnlyStyle ? style.readonly : ''} ${isClickable ? style.pointer : ''} ${classList} ${style[`borderColor_${borderColor}`]} ${customClass ? customClass : ''}`,
|
|
126
|
+
"data-id": `${dataId}`,
|
|
127
|
+
"data-test-id": `${dataId}`,
|
|
128
|
+
"data-selector-id": dataSelectorId,
|
|
129
|
+
id: htmlId || id,
|
|
130
|
+
maxLength: maxLength,
|
|
131
|
+
name: name,
|
|
132
|
+
onBlur: handleBlur,
|
|
133
|
+
onChange: handleChange,
|
|
134
|
+
onClick: onClick,
|
|
135
|
+
onFocus: handleFocus,
|
|
136
|
+
onKeyDown: onKeyDown,
|
|
137
|
+
onKeyUp: onKeyUp,
|
|
138
|
+
placeholder: placeHolder,
|
|
139
|
+
ref: handleRef,
|
|
140
|
+
type: type,
|
|
141
|
+
value: value,
|
|
142
|
+
onKeyPress: onKeyPress,
|
|
143
|
+
onMouseDown: onMouseDown
|
|
144
|
+
}, options.current, customProps));
|
|
145
|
+
}
|
|
146
|
+
TextBox.defaultProps = defaultProps;
|
|
147
|
+
TextBox.propTypes = propTypes; // if (__DOCS__) {
|
|
148
|
+
// Textbox.docs = {
|
|
149
|
+
// componentGroup: 'Form Elements',
|
|
150
|
+
// folderName: 'Style Guide',
|
|
151
|
+
// external: true,
|
|
152
|
+
// description: ' '
|
|
153
|
+
// };
|
|
154
|
+
// }
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
import React, { useState, useRef, useCallback } from 'react';
|
|
4
|
+
import { defaultProps } from '../../TextBoxIcon/props/defaultProps';
|
|
5
|
+
import { propTypes } from '../../TextBoxIcon/props/propTypes';
|
|
6
|
+
import TextBox from '../TextBox/TextBox';
|
|
7
|
+
import { Container, Box } from '../Layout';
|
|
8
|
+
import { Icon } from '@zohodesk/icons';
|
|
9
|
+
import btnStyle from '../../semantic/Button/semanticButton.module.css';
|
|
10
|
+
import style from '../../TextBoxIcon/TextBoxIcon.module.css';
|
|
11
|
+
/* eslint-disable react/forbid-component-props */
|
|
12
|
+
|
|
13
|
+
export default function TextBoxIcon(props) {
|
|
14
|
+
const {
|
|
15
|
+
type,
|
|
16
|
+
name,
|
|
17
|
+
id,
|
|
18
|
+
maxLength,
|
|
19
|
+
placeHolder,
|
|
20
|
+
size,
|
|
21
|
+
onKeyUp,
|
|
22
|
+
isReadOnly,
|
|
23
|
+
isDisabled,
|
|
24
|
+
children,
|
|
25
|
+
onKeyDown,
|
|
26
|
+
onClick,
|
|
27
|
+
value,
|
|
28
|
+
iconRotated,
|
|
29
|
+
needBorder,
|
|
30
|
+
variant,
|
|
31
|
+
onClear,
|
|
32
|
+
onChange,
|
|
33
|
+
title,
|
|
34
|
+
dataId,
|
|
35
|
+
dataSelectorId,
|
|
36
|
+
needReadOnlyStyle,
|
|
37
|
+
isClickable,
|
|
38
|
+
needEffect,
|
|
39
|
+
onKeyPress,
|
|
40
|
+
borderColor,
|
|
41
|
+
onMouseDown,
|
|
42
|
+
showClearIcon,
|
|
43
|
+
htmlId,
|
|
44
|
+
i18nKeys,
|
|
45
|
+
customClass,
|
|
46
|
+
iconOnHover,
|
|
47
|
+
isFocus,
|
|
48
|
+
onClearMouseDown,
|
|
49
|
+
customProps,
|
|
50
|
+
inputRef,
|
|
51
|
+
onFocus,
|
|
52
|
+
onBlur
|
|
53
|
+
} = props;
|
|
54
|
+
const {
|
|
55
|
+
customTBoxWrap = '',
|
|
56
|
+
customTextBox = '',
|
|
57
|
+
customTBoxIcon = '',
|
|
58
|
+
customTBoxLine = ''
|
|
59
|
+
} = customClass;
|
|
60
|
+
const {
|
|
61
|
+
clearText = 'Clear'
|
|
62
|
+
} = i18nKeys;
|
|
63
|
+
let {
|
|
64
|
+
TextBoxProps = {}
|
|
65
|
+
} = customProps;
|
|
66
|
+
const [isActive, setActive] = useState(false);
|
|
67
|
+
const inputEle = useRef();
|
|
68
|
+
const handleRef = useCallback(ele => {
|
|
69
|
+
inputEle.current = ele;
|
|
70
|
+
inputRef && inputRef(ele);
|
|
71
|
+
}, []);
|
|
72
|
+
|
|
73
|
+
const handleClear = () => {
|
|
74
|
+
onClear && onClear();
|
|
75
|
+
inputEle.current && inputEle.current.focus({
|
|
76
|
+
preventScroll: true
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const handleFocus = e => {
|
|
81
|
+
if (!needReadOnlyStyle || !isReadOnly && needReadOnlyStyle) {
|
|
82
|
+
setActive(true);
|
|
83
|
+
onFocus && onFocus(e);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const handleBlur = e => {
|
|
88
|
+
setActive(false);
|
|
89
|
+
onBlur && onBlur(e);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
return /*#__PURE__*/React.createElement(Container, {
|
|
93
|
+
alignBox: "row",
|
|
94
|
+
isCover: false,
|
|
95
|
+
className: `${style.container} ${isDisabled ? style.disabled : isReadOnly ? needEffect ? style.effect : style.readonly : style.effect} ${isActive || isFocus ? style.effectFocused : ''} ${customTBoxWrap} ${iconOnHover && (isReadOnly || isDisabled) ? style.iconOnHoverReadonly : iconOnHover && !(isReadOnly || isDisabled) ? style.iconOnHoverStyle : ''}`,
|
|
96
|
+
dataSelectorId: dataSelectorId,
|
|
97
|
+
"data-title": isDisabled ? title : null
|
|
98
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
99
|
+
flexible: true
|
|
100
|
+
}, /*#__PURE__*/React.createElement(TextBox, _extends({}, props, {
|
|
101
|
+
dataId: dataId,
|
|
102
|
+
size: size,
|
|
103
|
+
variant: variant,
|
|
104
|
+
type: type,
|
|
105
|
+
value: value,
|
|
106
|
+
name: name,
|
|
107
|
+
id: id,
|
|
108
|
+
htmlId: htmlId,
|
|
109
|
+
maxLength: maxLength,
|
|
110
|
+
placeHolder: placeHolder,
|
|
111
|
+
onKeyUp: onKeyUp,
|
|
112
|
+
onFocus: handleFocus,
|
|
113
|
+
onKeyDown: onKeyDown,
|
|
114
|
+
onChange: onChange,
|
|
115
|
+
onBlur: handleBlur,
|
|
116
|
+
onClick: onClick,
|
|
117
|
+
isReadOnly: isReadOnly,
|
|
118
|
+
isDisabled: isDisabled,
|
|
119
|
+
inputRef: handleRef,
|
|
120
|
+
needReadOnlyStyle: needReadOnlyStyle,
|
|
121
|
+
isClickable: isClickable,
|
|
122
|
+
onKeyPress: onKeyPress,
|
|
123
|
+
onMouseDown: onMouseDown,
|
|
124
|
+
needBorder: false,
|
|
125
|
+
customClass: customTextBox,
|
|
126
|
+
customProps: TextBoxProps
|
|
127
|
+
}))), /*#__PURE__*/React.createElement(Box, {
|
|
128
|
+
className: `${style.iconContainer} ${customTBoxIcon}`
|
|
129
|
+
}, /*#__PURE__*/React.createElement(Container, {
|
|
130
|
+
alignBox: "row"
|
|
131
|
+
}, value && onClear && value.length > 1 && !isDisabled && !isReadOnly || showClearIcon ? /*#__PURE__*/React.createElement(Box, {
|
|
132
|
+
className: `${btnStyle.buttonReset} ${style.icon}`,
|
|
133
|
+
onClick: handleClear,
|
|
134
|
+
dataId: `${dataId}_ClearIcon`,
|
|
135
|
+
"data-title": clearText,
|
|
136
|
+
tagName: "button"
|
|
137
|
+
}, /*#__PURE__*/React.createElement(Container, {
|
|
138
|
+
align: "both",
|
|
139
|
+
"aria-hidden": true,
|
|
140
|
+
onMouseDown: onClearMouseDown
|
|
141
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
142
|
+
name: "ZD-delete",
|
|
143
|
+
size: "14"
|
|
144
|
+
}))) : null, children ? /*#__PURE__*/React.createElement(Box, {
|
|
145
|
+
className: `${style.icon} ${iconRotated ? style.rotated : ''}`
|
|
146
|
+
}, children) : null)), needBorder && /*#__PURE__*/React.createElement("div", {
|
|
147
|
+
className: `${style.line} ${style[`borderColor_${borderColor}`]} ${customTBoxLine}`
|
|
148
|
+
}));
|
|
149
|
+
}
|
|
150
|
+
TextBoxIcon.defaultProps = defaultProps;
|
|
151
|
+
TextBoxIcon.propTypes = propTypes; // if (__DOCS__) {
|
|
152
|
+
// TextBoxIcon.docs = {
|
|
153
|
+
// componentGroup: 'Form Elements',
|
|
154
|
+
// folderName: 'Style Guide',
|
|
155
|
+
// external: true,
|
|
156
|
+
// description: ' '
|
|
157
|
+
// };
|
|
158
|
+
// }
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
import React, { useRef } from 'react';
|
|
4
|
+
import { defaultProps } from '../../Textarea/props/defaultProps';
|
|
5
|
+
import { propTypes } from '../../Textarea/props/propTypes';
|
|
6
|
+
import style from '../../Textarea/Textarea.module.css';
|
|
7
|
+
export default function Textarea(props) {
|
|
8
|
+
let {
|
|
9
|
+
size,
|
|
10
|
+
placeHolder,
|
|
11
|
+
needBorder,
|
|
12
|
+
text,
|
|
13
|
+
isDisabled,
|
|
14
|
+
resize,
|
|
15
|
+
maxLength,
|
|
16
|
+
animated,
|
|
17
|
+
variant,
|
|
18
|
+
getRef,
|
|
19
|
+
onFocus,
|
|
20
|
+
dataId,
|
|
21
|
+
dataSelectorId,
|
|
22
|
+
isReadOnly,
|
|
23
|
+
needAppearance,
|
|
24
|
+
needReadOnlyStyle,
|
|
25
|
+
borderColor,
|
|
26
|
+
needEffect,
|
|
27
|
+
autoFocus,
|
|
28
|
+
htmlId,
|
|
29
|
+
a11y,
|
|
30
|
+
customClass,
|
|
31
|
+
onChange,
|
|
32
|
+
onBlur,
|
|
33
|
+
onKeyDown
|
|
34
|
+
} = props;
|
|
35
|
+
let {
|
|
36
|
+
ariaLabel,
|
|
37
|
+
ariaLabelledby
|
|
38
|
+
} = a11y;
|
|
39
|
+
|
|
40
|
+
const handleChange = e => {
|
|
41
|
+
e && e.preventDefault();
|
|
42
|
+
onChange && onChange(e.target.value, e);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const handleBlur = e => {
|
|
46
|
+
e && e.preventDefault();
|
|
47
|
+
onBlur && onBlur(e.target.value, e);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const handleKeyDown = e => {
|
|
51
|
+
onKeyDown && onKeyDown(e);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
let resizes = useRef({
|
|
55
|
+
horizontal: 'resizeX',
|
|
56
|
+
vertical: 'resizeY',
|
|
57
|
+
both: 'resizeboth',
|
|
58
|
+
none: 'noresize'
|
|
59
|
+
});
|
|
60
|
+
let options = useRef({});
|
|
61
|
+
|
|
62
|
+
if (isReadOnly) {
|
|
63
|
+
options.current.readOnly = 'readOnly';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (isDisabled) {
|
|
67
|
+
options.current.disabled = 'disabled';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (autoFocus) {
|
|
71
|
+
options.current.autoFocus = true;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
let classList = needAppearance ? `${style.container} ${style[size]} ${style[variant]} ${needBorder ? style.needBorder : style.noBorder} ${resize ? style[resizes.current[resize]] : style[resizes.current.none]} ${animated ? `${style[`${size}animated`]}` : ''} ${isDisabled && !needEffect || isReadOnly && !needEffect ? '' : style.effect}` : `${style.basic}`;
|
|
75
|
+
return /*#__PURE__*/React.createElement("textarea", _extends({
|
|
76
|
+
"aria-label": ariaLabel,
|
|
77
|
+
"aria-labelledby": ariaLabelledby,
|
|
78
|
+
className: `${customClass} ${isReadOnly && needReadOnlyStyle ? style.readonly : ''} ${classList} ${style[`borderColor_${borderColor}`]}`,
|
|
79
|
+
placeholder: placeHolder
|
|
80
|
+
}, options.current, {
|
|
81
|
+
"data-id": dataId,
|
|
82
|
+
"data-test-id": dataId,
|
|
83
|
+
maxLength: maxLength,
|
|
84
|
+
onChange: handleChange,
|
|
85
|
+
onKeyDown: handleKeyDown,
|
|
86
|
+
onFocus: onFocus,
|
|
87
|
+
onBlur: handleBlur,
|
|
88
|
+
ref: getRef,
|
|
89
|
+
value: text,
|
|
90
|
+
id: htmlId,
|
|
91
|
+
"data-selector-id": dataSelectorId
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
Textarea.defaultProps = defaultProps;
|
|
95
|
+
Textarea.propTypes = propTypes; // if (__DOCS__) {
|
|
96
|
+
// Textarea.docs = {
|
|
97
|
+
// componentGroup: 'Form Elements',
|
|
98
|
+
// folderName: 'Style Guide',
|
|
99
|
+
// external: true,
|
|
100
|
+
// description: ' '
|
|
101
|
+
// };
|
|
102
|
+
// }
|