@salutejs/plasma-new-hope 0.141.0-canary.1421.10719019658.0 → 0.141.0-canary.1421.10763753065.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/TextArea/TextArea.js +4 -3
- package/cjs/components/TextArea/TextArea.js.map +1 -1
- package/cjs/components/TextField/TextField.js +12 -7
- package/cjs/components/TextField/TextField.js.map +1 -1
- package/cjs/index.js +3 -0
- package/cjs/index.js.map +1 -1
- package/cjs/utils/index.js.map +1 -1
- package/cjs/utils/setRefList.js +28 -0
- package/cjs/utils/setRefList.js.map +1 -0
- package/emotion/cjs/components/TextArea/TextArea.js +4 -4
- package/emotion/cjs/components/TextField/TextField.js +13 -8
- package/emotion/cjs/examples/plasma_b2c/components/Form/Form.stories.tsx +3 -41
- package/emotion/cjs/utils/index.js +15 -0
- package/emotion/cjs/utils/setRefList.js +27 -0
- package/emotion/es/components/TextArea/TextArea.js +5 -5
- package/emotion/es/components/TextField/TextField.js +13 -8
- package/emotion/es/examples/plasma_b2c/components/Form/Form.stories.tsx +3 -41
- package/emotion/es/utils/index.js +1 -0
- package/emotion/es/utils/setRefList.js +20 -0
- package/es/components/TextArea/TextArea.js +4 -3
- package/es/components/TextArea/TextArea.js.map +1 -1
- package/es/components/TextField/TextField.js +12 -7
- package/es/components/TextField/TextField.js.map +1 -1
- package/es/index.js +1 -0
- package/es/index.js.map +1 -1
- package/es/utils/index.js.map +1 -1
- package/es/utils/setRefList.js +23 -0
- package/es/utils/setRefList.js.map +1 -0
- package/package.json +4 -4
- package/styled-components/cjs/components/TextArea/TextArea.js +3 -3
- package/styled-components/cjs/components/TextField/TextField.js +12 -7
- package/styled-components/cjs/examples/plasma_b2c/components/Form/Form.stories.tsx +3 -41
- package/styled-components/cjs/utils/index.js +15 -0
- package/styled-components/cjs/utils/setRefList.js +27 -0
- package/styled-components/es/components/TextArea/TextArea.js +4 -4
- package/styled-components/es/components/TextField/TextField.js +12 -7
- package/styled-components/es/examples/plasma_b2c/components/Form/Form.stories.tsx +3 -41
- package/styled-components/es/utils/index.js +1 -0
- package/styled-components/es/utils/setRefList.js +20 -0
- package/types/components/TextArea/TextArea.d.ts.map +1 -1
- package/types/components/TextField/TextField.d.ts.map +1 -1
- package/types/utils/index.d.ts +1 -0
- package/types/utils/index.d.ts.map +1 -1
- package/types/utils/setRefList.d.ts +6 -0
- package/types/utils/setRefList.d.ts.map +1 -0
@@ -18,7 +18,7 @@ var _TextField = /*#__PURE__*/require("./TextField.styles");
|
|
18
18
|
var _TextField2 = /*#__PURE__*/require("./TextField.tokens");
|
19
19
|
var _ui = /*#__PURE__*/require("./ui");
|
20
20
|
var _hooks = /*#__PURE__*/require("./hooks");
|
21
|
-
var _excluded = ["id", "className", "style", "contentLeft", "contentRight", "label", "labelPlacement", "textBefore", "textAfter", "placeholder", "leftHelper", "enumerationType", "requiredPlacement", "view", "size", "readOnly", "disabled", "required", "optional", "chips", "onChange", "onChangeChips", "onSearch", "onKeyDown"];
|
21
|
+
var _excluded = ["id", "className", "style", "contentLeft", "contentRight", "label", "labelPlacement", "textBefore", "textAfter", "placeholder", "leftHelper", "enumerationType", "requiredPlacement", "view", "size", "readOnly", "disabled", "required", "optional", "value", "chips", "onChange", "onChangeChips", "onSearch", "onKeyDown"];
|
22
22
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
23
23
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
24
24
|
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); }
|
@@ -58,6 +58,7 @@ var textFieldRoot = exports.textFieldRoot = function textFieldRoot(Root) {
|
|
58
58
|
_ref$required = _ref.required,
|
59
59
|
required = _ref$required === void 0 ? false : _ref$required,
|
60
60
|
optional = _ref.optional,
|
61
|
+
outerValue = _ref.value,
|
61
62
|
values = _ref.chips,
|
62
63
|
onChange = _ref.onChange,
|
63
64
|
onChangeChips = _ref.onChangeChips,
|
@@ -73,7 +74,7 @@ var textFieldRoot = exports.textFieldRoot = function textFieldRoot(Root) {
|
|
73
74
|
inputRef: inputRef,
|
74
75
|
chipsRefs: chipsRefs
|
75
76
|
};
|
76
|
-
var _useState = (0, _react.useState)(
|
77
|
+
var _useState = (0, _react.useState)(Boolean(outerValue)),
|
77
78
|
_useState2 = _slicedToArray(_useState, 2),
|
78
79
|
hasValue = _useState2[0],
|
79
80
|
setHasValue = _useState2[1];
|
@@ -86,23 +87,23 @@ var textFieldRoot = exports.textFieldRoot = function textFieldRoot(Root) {
|
|
86
87
|
var labelId = (0, _plasmaCore.safeUseId)();
|
87
88
|
var helperTextId = (0, _plasmaCore.safeUseId)();
|
88
89
|
var isChipEnumeration = enumerationType === 'chip';
|
89
|
-
var isChipsVisible = isChipEnumeration &&
|
90
|
+
var isChipsVisible = isChipEnumeration && Boolean(chips === null || chips === void 0 ? void 0 : chips.length);
|
90
91
|
var withHasChips = isChipsVisible ? _TextField2.classes.hasChips : undefined;
|
91
|
-
var hasLabelValue =
|
92
|
+
var hasLabelValue = Boolean(label);
|
92
93
|
var hasInnerLabel = size !== 'xs' && labelPlacement === 'inner' && !isChipsVisible && hasLabelValue;
|
93
94
|
var hasOuterLabel = labelPlacement === 'outer' && hasLabelValue;
|
94
|
-
var hasPlaceholder =
|
95
|
+
var hasPlaceholder = Boolean(placeholder) && !hasInnerLabel;
|
95
96
|
var innerLabelValue = hasInnerLabel || hasOuterLabel ? label : undefined;
|
96
97
|
var innerLabelPlacementValue = labelPlacement === 'inner' && !hasInnerLabel ? undefined : labelPlacement;
|
97
98
|
var innerPlaceholderValue = hasPlaceholder ? placeholder : undefined;
|
98
|
-
var placeholderShown =
|
99
|
+
var placeholderShown = Boolean(innerPlaceholderValue) && !hasValue;
|
99
100
|
var requiredPlacementClass = requiredPlacement === 'right' ? 'align-right ' : undefined;
|
100
101
|
var labelPlacementClass = innerLabelPlacementValue ? _TextField2.classes["".concat(innerLabelPlacementValue, "LabelPlacement")] : undefined;
|
101
102
|
var hasValueClass = hasValue ? _TextField2.classes.hasValue : undefined;
|
102
103
|
var wrapperWithoutLeftContent = !contentLeft && isChipsVisible ? _TextField2.classes.hasEmptyContentLeft : undefined;
|
103
104
|
var wrapperWithoutRightContent = !contentRight && isChipsVisible ? _TextField2.classes.hasEmptyContentRight : undefined;
|
104
105
|
var handleInput = function handleInput(event) {
|
105
|
-
setHasValue(
|
106
|
+
setHasValue(Boolean(event.target.value));
|
106
107
|
};
|
107
108
|
var handleChange = function handleChange(event) {
|
108
109
|
if (disabled || readOnly) {
|
@@ -170,6 +171,9 @@ var textFieldRoot = exports.textFieldRoot = function textFieldRoot(Root) {
|
|
170
171
|
})) || [];
|
171
172
|
setChips(newChips);
|
172
173
|
}, [isChipEnumeration, values]);
|
174
|
+
(0, _react.useEffect)(function () {
|
175
|
+
setHasValue(Boolean(outerValue));
|
176
|
+
}, [outerValue]);
|
173
177
|
var innerOptional = Boolean(required ? false : optional);
|
174
178
|
var hasPlaceholderOptional = innerOptional && !innerLabelValue && !hasOuterLabel;
|
175
179
|
var optionalTextNode = innerOptional ? /*#__PURE__*/_react["default"].createElement(_TextField.StyledOptionalText, null, Boolean(hasPlaceholderOptional ? innerPlaceholderValue : innerLabelValue) && '\xa0', optionalText) : null;
|
@@ -223,6 +227,7 @@ var textFieldRoot = exports.textFieldRoot = function textFieldRoot(Root) {
|
|
223
227
|
})), /*#__PURE__*/_react["default"].createElement(_TextField.InputContainer, null, /*#__PURE__*/_react["default"].createElement(_TextField.Input, _extends({
|
224
228
|
ref: inputForkRef,
|
225
229
|
id: innerId,
|
230
|
+
value: outerValue,
|
226
231
|
"aria-labelledby": labelId,
|
227
232
|
"aria-describedby": helperTextId,
|
228
233
|
placeholder: innerPlaceholderValue,
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { useForm } from 'react-hook-form';
|
2
|
-
import React
|
2
|
+
import React from 'react';
|
3
3
|
import type { Meta, StoryObj } from '@storybook/react';
|
4
4
|
|
5
5
|
import { WithTheme } from '../../../_helpers';
|
@@ -9,7 +9,6 @@ import { TextArea } from '../TextArea/TextArea'; // TextArea.tsx 120 строк
|
|
9
9
|
import { Checkbox } from '../Checkbox/Checkbox';
|
10
10
|
import { Switch } from '../Switch/Switch';
|
11
11
|
import { Radiobox } from '../Radiobox/Radiobox';
|
12
|
-
import { Select } from '../Select/Select';
|
13
12
|
import { RadioGroup } from '../../../../components/Radiobox';
|
14
13
|
|
15
14
|
type StoryDropdownProps = {};
|
@@ -21,42 +20,6 @@ const itemsRadiobox = [
|
|
21
20
|
{ langName, value: 'assembly', label: 'Assembly', disabled: false },
|
22
21
|
];
|
23
22
|
|
24
|
-
const itemsSelect = [
|
25
|
-
{
|
26
|
-
value: 'north_america',
|
27
|
-
label: 'Северная Америка',
|
28
|
-
},
|
29
|
-
{
|
30
|
-
value: 'europe',
|
31
|
-
label: 'Европа',
|
32
|
-
},
|
33
|
-
{
|
34
|
-
value: 'asia',
|
35
|
-
label: 'Азия',
|
36
|
-
},
|
37
|
-
];
|
38
|
-
|
39
|
-
const FormSelect = (props) => {
|
40
|
-
const { onChange, onBlur, name, ref } = props;
|
41
|
-
const [value, setValue] = useState();
|
42
|
-
|
43
|
-
const onChangeValue = (e) => {
|
44
|
-
setValue(e);
|
45
|
-
onChange({
|
46
|
-
target: {
|
47
|
-
value: e,
|
48
|
-
name,
|
49
|
-
},
|
50
|
-
});
|
51
|
-
};
|
52
|
-
|
53
|
-
const onBlurValue = (e) => {
|
54
|
-
onBlur(e);
|
55
|
-
};
|
56
|
-
|
57
|
-
return <Select {...props} value={value} onChange={onChangeValue} onBlur={onBlurValue} name={name} ref={ref} />;
|
58
|
-
};
|
59
|
-
|
60
23
|
const DefaultForm = () => {
|
61
24
|
const { register, handleSubmit } = useForm();
|
62
25
|
const onSubmit = (data) => {
|
@@ -65,8 +28,8 @@ const DefaultForm = () => {
|
|
65
28
|
|
66
29
|
return (
|
67
30
|
<form onSubmit={handleSubmit(onSubmit)} style={{ display: 'flex', flexDirection: 'column', gap: '20px' }}>
|
68
|
-
<TextField {...register('textfield')} placeholder="Textfield" />
|
69
|
-
<TextArea {...register('textarea')} placeholder="Textarea" />
|
31
|
+
<TextField {...register('textfield')} placeholder="Textfield" required={false} />
|
32
|
+
<TextArea {...register('textarea')} autoResize placeholder="Textarea" />
|
70
33
|
<Checkbox {...register('checkbox')} label="Checkbox" />
|
71
34
|
<Switch {...register('switch')} label="Switch" labelPosition="after" />
|
72
35
|
<RadioGroup aria-labelledby="radiogroup-title-id">
|
@@ -83,7 +46,6 @@ const DefaultForm = () => {
|
|
83
46
|
/>
|
84
47
|
))}
|
85
48
|
</RadioGroup>
|
86
|
-
<FormSelect {...register('select')} items={itemsSelect} />
|
87
49
|
<Button type="submit">Отправить</Button>
|
88
50
|
</form>
|
89
51
|
);
|
@@ -12,6 +12,8 @@ var _exportNames = {
|
|
12
12
|
IS_REACT_18: true,
|
13
13
|
safeUseId: true,
|
14
14
|
isNumber: true,
|
15
|
+
mergeRefs: true,
|
16
|
+
setRef: true,
|
15
17
|
isEmpty: true
|
16
18
|
};
|
17
19
|
Object.defineProperty(exports, "IS_REACT_18", {
|
@@ -51,17 +53,30 @@ Object.defineProperty(exports, "isNumber", {
|
|
51
53
|
return _isNumber.isNumber;
|
52
54
|
}
|
53
55
|
});
|
56
|
+
Object.defineProperty(exports, "mergeRefs", {
|
57
|
+
enumerable: true,
|
58
|
+
get: function get() {
|
59
|
+
return _setRefList.mergeRefs;
|
60
|
+
}
|
61
|
+
});
|
54
62
|
Object.defineProperty(exports, "safeUseId", {
|
55
63
|
enumerable: true,
|
56
64
|
get: function get() {
|
57
65
|
return _react.safeUseId;
|
58
66
|
}
|
59
67
|
});
|
68
|
+
Object.defineProperty(exports, "setRef", {
|
69
|
+
enumerable: true,
|
70
|
+
get: function get() {
|
71
|
+
return _setRefList.setRef;
|
72
|
+
}
|
73
|
+
});
|
60
74
|
var _canUseDOM = /*#__PURE__*/require("./canUseDOM");
|
61
75
|
var _extractTextFrom = /*#__PURE__*/require("./extractTextFrom");
|
62
76
|
var _getSizeValueFromProp = /*#__PURE__*/require("./getSizeValueFromProp");
|
63
77
|
var _react = /*#__PURE__*/require("./react");
|
64
78
|
var _isNumber = /*#__PURE__*/require("./isNumber");
|
79
|
+
var _setRefList = /*#__PURE__*/require("./setRefList");
|
65
80
|
var _isEmpty = /*#__PURE__*/require("./isEmpty");
|
66
81
|
var _getPopoverPlacement = /*#__PURE__*/require("./getPopoverPlacement");
|
67
82
|
Object.keys(_getPopoverPlacement).forEach(function (key) {
|
@@ -0,0 +1,27 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.mergeRefs = mergeRefs;
|
7
|
+
exports.setRef = setRef;
|
8
|
+
function mergeRefs() {
|
9
|
+
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
10
|
+
refs[_key] = arguments[_key];
|
11
|
+
}
|
12
|
+
return function (val) {
|
13
|
+
setRef.apply(void 0, [val].concat(refs));
|
14
|
+
};
|
15
|
+
}
|
16
|
+
function setRef(val) {
|
17
|
+
for (var _len2 = arguments.length, refs = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
18
|
+
refs[_key2 - 1] = arguments[_key2];
|
19
|
+
}
|
20
|
+
refs.forEach(function (ref) {
|
21
|
+
if (typeof ref === 'function') {
|
22
|
+
ref(val);
|
23
|
+
} else if (ref != null) {
|
24
|
+
ref.current = val;
|
25
|
+
}
|
26
|
+
});
|
27
|
+
}
|
@@ -21,7 +21,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
21
21
|
import React, { forwardRef, useState, createRef, useCallback } from 'react';
|
22
22
|
import { css } from 'styled-components';
|
23
23
|
import { useResizeObserver } from '@salutejs/plasma-core';
|
24
|
-
import { cx } from '../../utils';
|
24
|
+
import { cx, mergeRefs } from '../../utils';
|
25
25
|
import { applyDynamicLabel } from './mixins';
|
26
26
|
import { useAutoResize, ROOT_FONT_SIZE } from './hooks';
|
27
27
|
import { StyledContent, StyledHelpers, StyledLeftHelper, StyledRightHelper, StyledLabel, StyledPlaceholder, StyledTextArea, StyledTextAreaWrapper, StyledContainer, StyledIndicator, StyledOptionalText } from './TextArea.styles';
|
@@ -118,8 +118,7 @@ export var textAreaRoot = function textAreaRoot(Root) {
|
|
118
118
|
_useState6 = _slicedToArray(_useState5, 2),
|
119
119
|
uncontrolledValue = _useState6[0],
|
120
120
|
setUncontrolledValue = _useState6[1];
|
121
|
-
var outerRef =
|
122
|
-
var ref = innerRef !== null && innerRef !== void 0 ? innerRef : /*#__PURE__*/createRef();
|
121
|
+
var outerRef = /*#__PURE__*/createRef();
|
123
122
|
var innerOptional = required ? false : optional;
|
124
123
|
var hasHelper = Boolean(leftHelper || rightHelper || helperText);
|
125
124
|
var hasOuterLabel = Boolean(label && labelPlacement === 'outer');
|
@@ -150,6 +149,7 @@ export var textAreaRoot = function textAreaRoot(Root) {
|
|
150
149
|
if (value === undefined) {
|
151
150
|
setUncontrolledValue(event === null || event === void 0 ? void 0 : event.target.value);
|
152
151
|
}
|
152
|
+
console.log(event);
|
153
153
|
onChange === null || onChange === void 0 || onChange(event);
|
154
154
|
}, [value, onChange]);
|
155
155
|
var dynamicLabelClasses = getDynamicLabelClasses(_objectSpread({
|
@@ -191,7 +191,7 @@ export var textAreaRoot = function textAreaRoot(Root) {
|
|
191
191
|
hasContentRight: Boolean(contentRight),
|
192
192
|
hasHelper: hasHelper,
|
193
193
|
applyCustomWidth: applyCustomWidth,
|
194
|
-
ref:
|
194
|
+
ref: mergeRefs(outerRef, innerRef),
|
195
195
|
disabled: disabled,
|
196
196
|
height: autoResize ? minAuto : height,
|
197
197
|
width: width,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
var _excluded = ["id", "className", "style", "contentLeft", "contentRight", "label", "labelPlacement", "textBefore", "textAfter", "placeholder", "leftHelper", "enumerationType", "requiredPlacement", "view", "size", "readOnly", "disabled", "required", "optional", "chips", "onChange", "onChangeChips", "onSearch", "onKeyDown"];
|
1
|
+
var _excluded = ["id", "className", "style", "contentLeft", "contentRight", "label", "labelPlacement", "textBefore", "textAfter", "placeholder", "leftHelper", "enumerationType", "requiredPlacement", "view", "size", "readOnly", "disabled", "required", "optional", "value", "chips", "onChange", "onChangeChips", "onSearch", "onKeyDown"];
|
2
2
|
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); }
|
3
3
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
4
4
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
@@ -49,6 +49,7 @@ export var textFieldRoot = function textFieldRoot(Root) {
|
|
49
49
|
_ref$required = _ref.required,
|
50
50
|
required = _ref$required === void 0 ? false : _ref$required,
|
51
51
|
optional = _ref.optional,
|
52
|
+
outerValue = _ref.value,
|
52
53
|
values = _ref.chips,
|
53
54
|
onChange = _ref.onChange,
|
54
55
|
onChangeChips = _ref.onChangeChips,
|
@@ -64,7 +65,7 @@ export var textFieldRoot = function textFieldRoot(Root) {
|
|
64
65
|
inputRef: inputRef,
|
65
66
|
chipsRefs: chipsRefs
|
66
67
|
};
|
67
|
-
var _useState = useState(
|
68
|
+
var _useState = useState(Boolean(outerValue)),
|
68
69
|
_useState2 = _slicedToArray(_useState, 2),
|
69
70
|
hasValue = _useState2[0],
|
70
71
|
setHasValue = _useState2[1];
|
@@ -77,23 +78,23 @@ export var textFieldRoot = function textFieldRoot(Root) {
|
|
77
78
|
var labelId = safeUseId();
|
78
79
|
var helperTextId = safeUseId();
|
79
80
|
var isChipEnumeration = enumerationType === 'chip';
|
80
|
-
var isChipsVisible = isChipEnumeration &&
|
81
|
+
var isChipsVisible = isChipEnumeration && Boolean(chips === null || chips === void 0 ? void 0 : chips.length);
|
81
82
|
var withHasChips = isChipsVisible ? classes.hasChips : undefined;
|
82
|
-
var hasLabelValue =
|
83
|
+
var hasLabelValue = Boolean(label);
|
83
84
|
var hasInnerLabel = size !== 'xs' && labelPlacement === 'inner' && !isChipsVisible && hasLabelValue;
|
84
85
|
var hasOuterLabel = labelPlacement === 'outer' && hasLabelValue;
|
85
|
-
var hasPlaceholder =
|
86
|
+
var hasPlaceholder = Boolean(placeholder) && !hasInnerLabel;
|
86
87
|
var innerLabelValue = hasInnerLabel || hasOuterLabel ? label : undefined;
|
87
88
|
var innerLabelPlacementValue = labelPlacement === 'inner' && !hasInnerLabel ? undefined : labelPlacement;
|
88
89
|
var innerPlaceholderValue = hasPlaceholder ? placeholder : undefined;
|
89
|
-
var placeholderShown =
|
90
|
+
var placeholderShown = Boolean(innerPlaceholderValue) && !hasValue;
|
90
91
|
var requiredPlacementClass = requiredPlacement === 'right' ? 'align-right ' : undefined;
|
91
92
|
var labelPlacementClass = innerLabelPlacementValue ? classes["".concat(innerLabelPlacementValue, "LabelPlacement")] : undefined;
|
92
93
|
var hasValueClass = hasValue ? classes.hasValue : undefined;
|
93
94
|
var wrapperWithoutLeftContent = !contentLeft && isChipsVisible ? classes.hasEmptyContentLeft : undefined;
|
94
95
|
var wrapperWithoutRightContent = !contentRight && isChipsVisible ? classes.hasEmptyContentRight : undefined;
|
95
96
|
var handleInput = function handleInput(event) {
|
96
|
-
setHasValue(
|
97
|
+
setHasValue(Boolean(event.target.value));
|
97
98
|
};
|
98
99
|
var handleChange = function handleChange(event) {
|
99
100
|
if (disabled || readOnly) {
|
@@ -161,6 +162,9 @@ export var textFieldRoot = function textFieldRoot(Root) {
|
|
161
162
|
})) || [];
|
162
163
|
setChips(newChips);
|
163
164
|
}, [isChipEnumeration, values]);
|
165
|
+
useEffect(function () {
|
166
|
+
setHasValue(Boolean(outerValue));
|
167
|
+
}, [outerValue]);
|
164
168
|
var innerOptional = Boolean(required ? false : optional);
|
165
169
|
var hasPlaceholderOptional = innerOptional && !innerLabelValue && !hasOuterLabel;
|
166
170
|
var optionalTextNode = innerOptional ? /*#__PURE__*/React.createElement(StyledOptionalText, null, Boolean(hasPlaceholderOptional ? innerPlaceholderValue : innerLabelValue) && '\xa0', optionalText) : null;
|
@@ -214,6 +218,7 @@ export var textFieldRoot = function textFieldRoot(Root) {
|
|
214
218
|
})), /*#__PURE__*/React.createElement(InputContainer, null, /*#__PURE__*/React.createElement(Input, _extends({
|
215
219
|
ref: inputForkRef,
|
216
220
|
id: innerId,
|
221
|
+
value: outerValue,
|
217
222
|
"aria-labelledby": labelId,
|
218
223
|
"aria-describedby": helperTextId,
|
219
224
|
placeholder: innerPlaceholderValue,
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { useForm } from 'react-hook-form';
|
2
|
-
import React
|
2
|
+
import React from 'react';
|
3
3
|
import type { Meta, StoryObj } from '@storybook/react';
|
4
4
|
|
5
5
|
import { WithTheme } from '../../../_helpers';
|
@@ -9,7 +9,6 @@ import { TextArea } from '../TextArea/TextArea'; // TextArea.tsx 120 строк
|
|
9
9
|
import { Checkbox } from '../Checkbox/Checkbox';
|
10
10
|
import { Switch } from '../Switch/Switch';
|
11
11
|
import { Radiobox } from '../Radiobox/Radiobox';
|
12
|
-
import { Select } from '../Select/Select';
|
13
12
|
import { RadioGroup } from '../../../../components/Radiobox';
|
14
13
|
|
15
14
|
type StoryDropdownProps = {};
|
@@ -21,42 +20,6 @@ const itemsRadiobox = [
|
|
21
20
|
{ langName, value: 'assembly', label: 'Assembly', disabled: false },
|
22
21
|
];
|
23
22
|
|
24
|
-
const itemsSelect = [
|
25
|
-
{
|
26
|
-
value: 'north_america',
|
27
|
-
label: 'Северная Америка',
|
28
|
-
},
|
29
|
-
{
|
30
|
-
value: 'europe',
|
31
|
-
label: 'Европа',
|
32
|
-
},
|
33
|
-
{
|
34
|
-
value: 'asia',
|
35
|
-
label: 'Азия',
|
36
|
-
},
|
37
|
-
];
|
38
|
-
|
39
|
-
const FormSelect = (props) => {
|
40
|
-
const { onChange, onBlur, name, ref } = props;
|
41
|
-
const [value, setValue] = useState();
|
42
|
-
|
43
|
-
const onChangeValue = (e) => {
|
44
|
-
setValue(e);
|
45
|
-
onChange({
|
46
|
-
target: {
|
47
|
-
value: e,
|
48
|
-
name,
|
49
|
-
},
|
50
|
-
});
|
51
|
-
};
|
52
|
-
|
53
|
-
const onBlurValue = (e) => {
|
54
|
-
onBlur(e);
|
55
|
-
};
|
56
|
-
|
57
|
-
return <Select {...props} value={value} onChange={onChangeValue} onBlur={onBlurValue} name={name} ref={ref} />;
|
58
|
-
};
|
59
|
-
|
60
23
|
const DefaultForm = () => {
|
61
24
|
const { register, handleSubmit } = useForm();
|
62
25
|
const onSubmit = (data) => {
|
@@ -65,8 +28,8 @@ const DefaultForm = () => {
|
|
65
28
|
|
66
29
|
return (
|
67
30
|
<form onSubmit={handleSubmit(onSubmit)} style={{ display: 'flex', flexDirection: 'column', gap: '20px' }}>
|
68
|
-
<TextField {...register('textfield')} placeholder="Textfield" />
|
69
|
-
<TextArea {...register('textarea')} placeholder="Textarea" />
|
31
|
+
<TextField {...register('textfield')} placeholder="Textfield" required={false} />
|
32
|
+
<TextArea {...register('textarea')} autoResize placeholder="Textarea" />
|
70
33
|
<Checkbox {...register('checkbox')} label="Checkbox" />
|
71
34
|
<Switch {...register('switch')} label="Switch" labelPosition="after" />
|
72
35
|
<RadioGroup aria-labelledby="radiogroup-title-id">
|
@@ -83,7 +46,6 @@ const DefaultForm = () => {
|
|
83
46
|
/>
|
84
47
|
))}
|
85
48
|
</RadioGroup>
|
86
|
-
<FormSelect {...register('select')} items={itemsSelect} />
|
87
49
|
<Button type="submit">Отправить</Button>
|
88
50
|
</form>
|
89
51
|
);
|
@@ -3,6 +3,7 @@ export { extractTextFrom } from './extractTextFrom';
|
|
3
3
|
export { getSizeValueFromProp } from './getSizeValueFromProp';
|
4
4
|
export { IS_REACT_18, safeUseId } from './react';
|
5
5
|
export { isNumber } from './isNumber';
|
6
|
+
export { mergeRefs, setRef } from './setRefList';
|
6
7
|
export { isEmpty } from './isEmpty';
|
7
8
|
export * from './getPopoverPlacement';
|
8
9
|
export var cx = function cx() {
|
@@ -0,0 +1,20 @@
|
|
1
|
+
export function mergeRefs() {
|
2
|
+
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
3
|
+
refs[_key] = arguments[_key];
|
4
|
+
}
|
5
|
+
return function (val) {
|
6
|
+
setRef.apply(void 0, [val].concat(refs));
|
7
|
+
};
|
8
|
+
}
|
9
|
+
export function setRef(val) {
|
10
|
+
for (var _len2 = arguments.length, refs = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
11
|
+
refs[_key2 - 1] = arguments[_key2];
|
12
|
+
}
|
13
|
+
refs.forEach(function (ref) {
|
14
|
+
if (typeof ref === 'function') {
|
15
|
+
ref(val);
|
16
|
+
} else if (ref != null) {
|
17
|
+
ref.current = val;
|
18
|
+
}
|
19
|
+
});
|
20
|
+
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"TextArea.d.ts","sourceRoot":"","sources":["../../../src/components/TextArea/TextArea.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuD,MAAM,OAAO,CAAC;AAK5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAqBrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AA+BtD,eAAO,MAAM,sBAAsB,UAAW,aAAa,WAAW,OAAO,2BA4B5E,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,UAAU,mBAAmB,EAAE,aAAa,CAAC,
|
1
|
+
{"version":3,"file":"TextArea.d.ts","sourceRoot":"","sources":["../../../src/components/TextArea/TextArea.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuD,MAAM,OAAO,CAAC;AAK5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAqBrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AA+BtD,eAAO,MAAM,sBAAsB,UAAW,aAAa,WAAW,OAAO,2BA4B5E,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,UAAU,mBAAmB,EAAE,aAAa,CAAC,8FAgL1E,CAAC;AAEP,eAAO,MAAM,cAAc;;;mBAlLQ,UAAU,mBAAmB,EAAE,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;CA0M/E,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"TextField.d.ts","sourceRoot":"","sources":["../../../src/components/TextField/TextField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAKvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG/C,OAAO,KAAK,EAAuC,cAAc,EAAE,MAAM,mBAAmB,CAAC;AA4B7F,eAAO,MAAM,IAAI,0CAGhB,CAAC;AAEF,eAAO,MAAM,aAAa,SAAU,UAAU,cAAc,EAAE,cAAc,CAAC,
|
1
|
+
{"version":3,"file":"TextField.d.ts","sourceRoot":"","sources":["../../../src/components/TextField/TextField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAKvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG/C,OAAO,KAAK,EAAuC,cAAc,EAAE,MAAM,mBAAmB,CAAC;AA4B7F,eAAO,MAAM,IAAI,0CAGhB,CAAC;AAEF,eAAO,MAAM,aAAa,SAAU,UAAU,cAAc,EAAE,cAAc,CAAC,4FAwQxE,CAAC;AAEN,eAAO,MAAM,eAAe;;;mBA1QQ,UAAU,cAAc,EAAE,cAAc,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;CAsS5E,CAAC"}
|
package/types/utils/index.d.ts
CHANGED
@@ -4,6 +4,7 @@ export { extractTextFrom } from './extractTextFrom';
|
|
4
4
|
export { getSizeValueFromProp } from './getSizeValueFromProp';
|
5
5
|
export { IS_REACT_18, safeUseId } from './react';
|
6
6
|
export { isNumber } from './isNumber';
|
7
|
+
export { mergeRefs, setRef } from './setRefList';
|
7
8
|
export { isEmpty } from './isEmpty';
|
8
9
|
export * from './getPopoverPlacement';
|
9
10
|
export declare const cx: (...classes: (string | undefined)[]) => string;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,cAAc,uBAAuB,CAAC;AAEtC,eAAO,MAAM,EAAE,eAAgB,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,WAAuD,CAAC;AAE7G,eAAO,MAAM,eAAe,MAAO,oBAAoB,WAAW,MAAM,MAAM,GAAG,MAAM,GAAG,aAAa,CAAC,KAAG,MAQ1G,CAAC"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,cAAc,uBAAuB,CAAC;AAEtC,eAAO,MAAM,EAAE,eAAgB,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,WAAuD,CAAC;AAE7G,eAAO,MAAM,eAAe,MAAO,oBAAoB,WAAW,MAAM,MAAM,GAAG,MAAM,GAAG,aAAa,CAAC,KAAG,MAQ1G,CAAC"}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import type { MutableRefObject, RefCallback } from 'react';
|
2
|
+
declare type MutableRefList<T> = Array<RefCallback<T> | MutableRefObject<T> | undefined | null>;
|
3
|
+
export declare function mergeRefs<T>(...refs: MutableRefList<T>): RefCallback<T>;
|
4
|
+
export declare function setRef<T>(val: T, ...refs: MutableRefList<T>): void;
|
5
|
+
export {};
|
6
|
+
//# sourceMappingURL=setRefList.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"setRefList.d.ts","sourceRoot":"","sources":["../../src/utils/setRefList.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAE3D,aAAK,cAAc,CAAC,CAAC,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC;AAExF,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAIvE;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI,CAQlE"}
|