@salutejs/plasma-new-hope 0.142.2-canary.1431.10830104806.0 → 0.143.0-canary.1421.10814573412.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/Autocomplete/Autocomplete.css +15 -16
- package/cjs/components/Combobox/ComboboxNew/Combobox.css +15 -16
- package/cjs/components/Combobox/ComboboxNew/ui/Inner/Inner.css +15 -16
- package/cjs/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.css +15 -16
- package/cjs/components/DatePicker/RangeDate/RangeDate.css +15 -16
- package/cjs/components/DatePicker/RangeDate/RangeDatePopover/RangeDatePopover.css +15 -16
- package/cjs/components/DatePicker/SingleDate/SingleDate.css +15 -16
- package/cjs/components/Grid/Grid.js +1 -1
- package/cjs/components/Grid/Grid.js.map +1 -1
- package/cjs/components/Range/Range.css +15 -16
- package/cjs/components/Slider/Slider.css +21 -21
- package/cjs/components/Slider/Slider.js +12 -5
- package/cjs/components/Slider/Slider.js.map +1 -1
- package/cjs/components/Slider/components/Double/Double.css +15 -16
- package/cjs/components/Slider/components/Single/Single.css +6 -5
- package/cjs/components/Slider/components/Single/Single.js +34 -7
- package/cjs/components/Slider/components/Single/Single.js.map +1 -1
- package/cjs/components/Slider/components/Single/Single.styles.js +7 -1
- package/cjs/components/Slider/components/Single/Single.styles.js.map +1 -1
- package/cjs/components/Slider/components/Single/{Single.styles_1r9f1e0.css → Single.styles_9lxkbx.css} +1 -0
- package/cjs/components/TextArea/TextArea.js +3 -2
- package/cjs/components/TextArea/TextArea.js.map +1 -1
- package/cjs/components/TextField/TextField.js +1 -1
- package/cjs/components/TextField/TextField.js.map +1 -1
- package/cjs/components/TextField/TextField.styles.js +11 -22
- package/cjs/components/TextField/TextField.styles.js.map +1 -1
- package/{es/components/TextField/TextField.styles_ht6ibd.css → cjs/components/TextField/TextField.styles_u6pm7v.css} +4 -5
- package/cjs/components/TextField/TextField.tokens.js +1 -5
- package/cjs/components/TextField/TextField.tokens.js.map +1 -1
- package/cjs/components/TextField/variations/_label-placement/base.js +1 -1
- package/{es/components/TextField/variations/_label-placement/base_6k17xp.css → cjs/components/TextField/variations/_label-placement/base_1dbnupp.css} +1 -1
- package/cjs/components/TextField/variations/_read-only/base.js +1 -1
- package/{es/components/TextField/variations/_read-only/base_8onybn.css → cjs/components/TextField/variations/_read-only/base_4tqave.css} +1 -1
- package/cjs/components/TextField/variations/_size/base.js +1 -1
- package/cjs/components/TextField/variations/_size/{base_1h8l0kj.css → base_uk56yo.css} +1 -1
- package/cjs/components/TextField/variations/_view/base.js +1 -1
- package/cjs/components/TextField/variations/_view/{base_1ph5cr0.css → base_uszjx8.css} +1 -1
- package/cjs/hooks/useForm.js +71 -0
- package/cjs/hooks/useForm.js.map +1 -0
- package/cjs/index.css +21 -21
- package/cjs/index.js +5 -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/Grid/Grid.js +1 -1
- package/emotion/cjs/components/Slider/Slider.js +15 -6
- package/emotion/cjs/components/Slider/components/Single/Single.js +34 -7
- package/emotion/cjs/components/Slider/components/Single/Single.styles.js +26 -13
- package/emotion/cjs/components/TextArea/TextArea.js +3 -3
- package/emotion/cjs/components/TextField/TextField.js +2 -2
- package/emotion/cjs/components/TextField/TextField.styles.js +23 -27
- package/emotion/cjs/components/TextField/TextField.template-doc.mdx +2 -2
- package/emotion/cjs/components/TextField/TextField.tokens.js +1 -5
- package/emotion/cjs/components/TextFieldGroup/TextFieldGroup.template-doc.mdx +1 -1
- package/emotion/cjs/examples/plasma_b2c/components/Form/Form.stories.tsx +182 -0
- package/emotion/cjs/examples/plasma_b2c/components/TextField/TextField.config.js +12 -12
- package/emotion/cjs/examples/plasma_b2c/components/TextField/TextField.stories.tsx +2 -3
- package/emotion/cjs/examples/plasma_web/components/TextField/TextField.config.js +12 -12
- package/emotion/cjs/examples/plasma_web/components/TextField/TextField.stories.tsx +1 -2
- package/emotion/cjs/hooks/index.js +8 -1
- package/emotion/cjs/hooks/useForm.js +72 -0
- package/emotion/cjs/utils/index.js +15 -0
- package/emotion/cjs/utils/setRefList.js +27 -0
- package/emotion/es/components/Grid/Grid.js +1 -1
- package/emotion/es/components/Slider/Slider.js +15 -5
- package/emotion/es/components/Slider/components/Single/Single.js +35 -8
- package/emotion/es/components/Slider/components/Single/Single.styles.js +25 -12
- package/emotion/es/components/TextArea/TextArea.js +4 -4
- package/emotion/es/components/TextField/TextField.js +2 -2
- package/emotion/es/components/TextField/TextField.styles.js +23 -27
- package/emotion/es/components/TextField/TextField.template-doc.mdx +2 -2
- package/emotion/es/components/TextField/TextField.tokens.js +1 -5
- package/emotion/es/components/TextFieldGroup/TextFieldGroup.template-doc.mdx +1 -1
- package/emotion/es/examples/plasma_b2c/components/Form/Form.stories.tsx +182 -0
- package/emotion/es/examples/plasma_b2c/components/TextField/TextField.config.js +12 -12
- package/emotion/es/examples/plasma_b2c/components/TextField/TextField.stories.tsx +2 -3
- package/emotion/es/examples/plasma_web/components/TextField/TextField.config.js +12 -12
- package/emotion/es/examples/plasma_web/components/TextField/TextField.stories.tsx +1 -2
- package/emotion/es/hooks/index.js +2 -1
- package/emotion/es/hooks/useForm.js +63 -0
- package/emotion/es/utils/index.js +1 -0
- package/emotion/es/utils/setRefList.js +20 -0
- package/es/components/Autocomplete/Autocomplete.css +15 -16
- package/es/components/Combobox/ComboboxNew/Combobox.css +15 -16
- package/es/components/Combobox/ComboboxNew/ui/Inner/Inner.css +15 -16
- package/es/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.css +15 -16
- package/es/components/DatePicker/RangeDate/RangeDate.css +15 -16
- package/es/components/DatePicker/RangeDate/RangeDatePopover/RangeDatePopover.css +15 -16
- package/es/components/DatePicker/SingleDate/SingleDate.css +15 -16
- package/es/components/Grid/Grid.js +1 -1
- package/es/components/Grid/Grid.js.map +1 -1
- package/es/components/Range/Range.css +15 -16
- package/es/components/Slider/Slider.css +21 -21
- package/es/components/Slider/Slider.js +13 -6
- package/es/components/Slider/Slider.js.map +1 -1
- package/es/components/Slider/components/Double/Double.css +15 -16
- package/es/components/Slider/components/Single/Single.css +6 -5
- package/es/components/Slider/components/Single/Single.js +35 -8
- package/es/components/Slider/components/Single/Single.js.map +1 -1
- package/es/components/Slider/components/Single/Single.styles.js +7 -2
- package/es/components/Slider/components/Single/Single.styles.js.map +1 -1
- package/es/components/Slider/components/Single/{Single.styles_1r9f1e0.css → Single.styles_9lxkbx.css} +1 -0
- package/es/components/TextArea/TextArea.js +3 -2
- package/es/components/TextArea/TextArea.js.map +1 -1
- package/es/components/TextField/TextField.js +1 -1
- package/es/components/TextField/TextField.js.map +1 -1
- package/es/components/TextField/TextField.styles.js +11 -22
- package/es/components/TextField/TextField.styles.js.map +1 -1
- package/{cjs/components/TextField/TextField.styles_ht6ibd.css → es/components/TextField/TextField.styles_u6pm7v.css} +4 -5
- package/es/components/TextField/TextField.tokens.js +1 -5
- package/es/components/TextField/TextField.tokens.js.map +1 -1
- package/es/components/TextField/variations/_label-placement/base.js +1 -1
- package/{cjs/components/TextField/variations/_label-placement/base_6k17xp.css → es/components/TextField/variations/_label-placement/base_1dbnupp.css} +1 -1
- package/es/components/TextField/variations/_read-only/base.js +1 -1
- package/{cjs/components/TextField/variations/_read-only/base_8onybn.css → es/components/TextField/variations/_read-only/base_4tqave.css} +1 -1
- package/es/components/TextField/variations/_size/base.js +1 -1
- package/es/components/TextField/variations/_size/{base_1h8l0kj.css → base_uk56yo.css} +1 -1
- package/es/components/TextField/variations/_view/base.js +1 -1
- package/es/components/TextField/variations/_view/{base_1ph5cr0.css → base_uszjx8.css} +1 -1
- package/es/hooks/useForm.js +67 -0
- package/es/hooks/useForm.js.map +1 -0
- package/es/index.css +21 -21
- package/es/index.js +2 -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 +3 -2
- package/styled-components/cjs/components/Grid/Grid.js +1 -1
- package/styled-components/cjs/components/Slider/Slider.js +15 -6
- package/styled-components/cjs/components/Slider/components/Single/Single.js +34 -7
- package/styled-components/cjs/components/Slider/components/Single/Single.styles.js +5 -2
- package/styled-components/cjs/components/TextArea/TextArea.js +2 -2
- package/styled-components/cjs/components/TextField/TextField.js +1 -1
- package/styled-components/cjs/components/TextField/TextField.styles.js +9 -12
- package/styled-components/cjs/components/TextField/TextField.template-doc.mdx +2 -2
- package/styled-components/cjs/components/TextField/TextField.tokens.js +1 -5
- package/styled-components/cjs/components/TextFieldGroup/TextFieldGroup.template-doc.mdx +1 -1
- package/styled-components/cjs/examples/plasma_b2c/components/Form/Form.stories.tsx +182 -0
- package/styled-components/cjs/examples/plasma_b2c/components/TextField/TextField.config.js +4 -4
- package/styled-components/cjs/examples/plasma_b2c/components/TextField/TextField.stories.tsx +2 -3
- package/styled-components/cjs/examples/plasma_web/components/TextField/TextField.config.js +4 -4
- package/styled-components/cjs/examples/plasma_web/components/TextField/TextField.stories.tsx +1 -2
- package/styled-components/cjs/hooks/index.js +8 -1
- package/styled-components/cjs/hooks/useForm.js +72 -0
- package/styled-components/cjs/utils/index.js +15 -0
- package/styled-components/cjs/utils/setRefList.js +27 -0
- package/styled-components/es/components/Grid/Grid.js +1 -1
- package/styled-components/es/components/Slider/Slider.js +15 -5
- package/styled-components/es/components/Slider/components/Single/Single.js +35 -8
- package/styled-components/es/components/Slider/components/Single/Single.styles.js +4 -1
- package/styled-components/es/components/TextArea/TextArea.js +3 -3
- package/styled-components/es/components/TextField/TextField.js +1 -1
- package/styled-components/es/components/TextField/TextField.styles.js +9 -12
- package/styled-components/es/components/TextField/TextField.template-doc.mdx +2 -2
- package/styled-components/es/components/TextField/TextField.tokens.js +1 -5
- package/styled-components/es/components/TextFieldGroup/TextFieldGroup.template-doc.mdx +1 -1
- package/styled-components/es/examples/plasma_b2c/components/Form/Form.stories.tsx +182 -0
- package/styled-components/es/examples/plasma_b2c/components/TextField/TextField.config.js +4 -4
- package/styled-components/es/examples/plasma_b2c/components/TextField/TextField.stories.tsx +2 -3
- package/styled-components/es/examples/plasma_web/components/TextField/TextField.config.js +4 -4
- package/styled-components/es/examples/plasma_web/components/TextField/TextField.stories.tsx +1 -2
- package/styled-components/es/hooks/index.js +2 -1
- package/styled-components/es/hooks/useForm.js +63 -0
- package/styled-components/es/utils/index.js +1 -0
- package/styled-components/es/utils/setRefList.js +20 -0
- package/types/components/Autocomplete/ui/TextField/TextField.styles.d.ts +4 -4
- package/types/components/Autocomplete/ui/TextField/TextField.styles.d.ts.map +1 -1
- package/types/components/Combobox/ComboboxNew/ui/Target/Target.styles.d.ts +4 -4
- package/types/components/Combobox/ComboboxNew/ui/Target/Target.styles.d.ts.map +1 -1
- package/types/components/DatePicker/SingleDate/SingleDate.styles.d.ts +4 -4
- package/types/components/DatePicker/SingleDate/SingleDate.styles.d.ts.map +1 -1
- package/types/components/Range/Range.styles.d.ts +4 -4
- package/types/components/Range/Range.styles.d.ts.map +1 -1
- package/types/components/Slider/Slider.d.ts.map +1 -1
- package/types/components/Slider/components/Double/Double.styles.d.ts +4 -4
- package/types/components/Slider/components/Double/Double.styles.d.ts.map +1 -1
- package/types/components/Slider/components/Double/Double.types.d.ts +2 -0
- package/types/components/Slider/components/Double/Double.types.d.ts.map +1 -1
- package/types/components/Slider/components/Single/Single.d.ts.map +1 -1
- package/types/components/Slider/components/Single/Single.styles.d.ts +1 -0
- package/types/components/Slider/components/Single/Single.styles.d.ts.map +1 -1
- package/types/components/Slider/components/Single/Single.types.d.ts +3 -1
- package/types/components/Slider/components/Single/Single.types.d.ts.map +1 -1
- package/types/components/TextArea/TextArea.d.ts.map +1 -1
- package/types/components/TextField/TextField.styles.d.ts +2 -6
- package/types/components/TextField/TextField.styles.d.ts.map +1 -1
- package/types/components/TextField/TextField.tokens.d.ts +0 -3
- package/types/components/TextField/TextField.tokens.d.ts.map +1 -1
- package/types/components/TextField/TextField.types.d.ts +1 -2
- package/types/components/TextField/TextField.types.d.ts.map +1 -1
- package/types/examples/plasma_b2c/components/TextField/TextField.config.d.ts.map +1 -1
- package/types/examples/plasma_b2c/components/TextField/TextField.d.ts +4 -4
- package/types/examples/plasma_b2c/components/TextField/TextField.d.ts.map +1 -1
- package/types/examples/plasma_web/components/TextField/TextField.config.d.ts.map +1 -1
- package/types/examples/plasma_web/components/TextField/TextField.d.ts +4 -4
- package/types/examples/plasma_web/components/TextField/TextField.d.ts.map +1 -1
- package/types/hooks/index.d.ts +1 -0
- package/types/hooks/index.d.ts.map +1 -1
- package/types/hooks/useForm.d.ts +10 -0
- package/types/hooks/useForm.d.ts.map +1 -0
- 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
@@ -1,5 +1,5 @@
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
2
|
-
var _excluded = ["min", "max", "value", "disabled", "onChangeCommitted", "onChange", "ariaLabel", "label", "labelContentLeft", "showRangeValues", "showCurrentValue", "hideMinValueDiff", "hideMaxValueDiff", "labelPlacement", "rangeValuesPlacement", "multipleStepSize", "size"];
|
2
|
+
var _excluded = ["min", "max", "value", "disabled", "onChangeCommitted", "onChange", "ariaLabel", "label", "labelContentLeft", "showRangeValues", "showCurrentValue", "hideMinValueDiff", "hideMaxValueDiff", "labelPlacement", "rangeValuesPlacement", "multipleStepSize", "size", "name"];
|
3
3
|
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); }
|
4
4
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
5
5
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
@@ -20,11 +20,12 @@ import { Handler } from '../../ui';
|
|
20
20
|
import { sizeData } from '../../utils';
|
21
21
|
import { cx, isNumber } from '../../../../utils';
|
22
22
|
import { classes } from '../../Slider.tokens';
|
23
|
-
import { Label, LabelContentLeft, LabelWrapper, SingleWrapper, SliderBaseWrapper, StyledRangeValue } from './Single.styles';
|
23
|
+
import { Label, LabelContentLeft, LabelWrapper, SingleWrapper, SliderBaseWrapper, StyledRangeValue, InputHidden } from './Single.styles';
|
24
24
|
export var SingleSlider = function SingleSlider(_ref) {
|
25
25
|
var min = _ref.min,
|
26
26
|
max = _ref.max,
|
27
|
-
value = _ref.value,
|
27
|
+
_ref$value = _ref.value,
|
28
|
+
value = _ref$value === void 0 ? min : _ref$value,
|
28
29
|
disabled = _ref.disabled,
|
29
30
|
onChangeCommitted = _ref.onChangeCommitted,
|
30
31
|
onChange = _ref.onChange,
|
@@ -43,6 +44,7 @@ export var SingleSlider = function SingleSlider(_ref) {
|
|
43
44
|
multipleStepSize = _ref$multipleStepSize === void 0 ? 10 : _ref$multipleStepSize,
|
44
45
|
_ref$size = _ref.size,
|
45
46
|
size = _ref$size === void 0 ? 'm' : _ref$size,
|
47
|
+
name = _ref.name,
|
46
48
|
rest = _objectWithoutProperties(_ref, _excluded);
|
47
49
|
var _useState = useState({
|
48
50
|
xHandle: 0,
|
@@ -52,6 +54,7 @@ export var SingleSlider = function SingleSlider(_ref) {
|
|
52
54
|
_useState2 = _slicedToArray(_useState, 2),
|
53
55
|
state = _useState2[0],
|
54
56
|
setState = _useState2[1];
|
57
|
+
var innerRef = useRef(null);
|
55
58
|
var _useState3 = useState(0),
|
56
59
|
_useState4 = _slicedToArray(_useState3, 2),
|
57
60
|
startOffset = _useState4[0],
|
@@ -68,14 +71,14 @@ export var SingleSlider = function SingleSlider(_ref) {
|
|
68
71
|
var hasLabelContent = label || labelContentLeft;
|
69
72
|
var labelPlacementClass = labelPlacement === 'outer' ? classes.labelPlacementOuter : classes.labelPlacementInner;
|
70
73
|
var rangeValuesPlacementClass = rangeValuesPlacement === 'outer' ? classes.rangeValuesPlacementOuter : classes.rangeValuesPlacementInner;
|
71
|
-
var hideMinValueDiffClass = hideMinValueDiff &&
|
72
|
-
var hideMaxValueDiffClass = hideMaxValueDiff && max -
|
74
|
+
var hideMinValueDiffClass = hideMinValueDiff && dragValue - min <= hideMinValueDiff ? classes.hideMinValue : '';
|
75
|
+
var hideMaxValueDiffClass = hideMaxValueDiff && max - dragValue <= hideMaxValueDiff ? classes.hideMaxValue : '';
|
73
76
|
var startLabelRef = useRef(null);
|
74
77
|
var endLabelRef = useRef(null);
|
75
78
|
var activeFirstValue = dragValue === min ? classes.activeRangeValue : undefined;
|
76
79
|
var activeSecondValue = dragValue === max ? classes.activeRangeValue : undefined;
|
77
80
|
useEffect(function () {
|
78
|
-
var localValue = Math.min(Math.max(
|
81
|
+
var localValue = Math.min(Math.max(dragValue, min), max) - min;
|
79
82
|
if (rangeValuesPlacement === 'outer') {
|
80
83
|
var _startLabelRef$curren, _endLabelRef$current;
|
81
84
|
var startWidth = (_startLabelRef$curren = startLabelRef.current) === null || _startLabelRef$curren === void 0 ? void 0 : _startLabelRef$curren.offsetWidth;
|
@@ -96,7 +99,25 @@ export var SingleSlider = function SingleSlider(_ref) {
|
|
96
99
|
railFillWidth: stepSize * localValue
|
97
100
|
});
|
98
101
|
});
|
99
|
-
}, [
|
102
|
+
}, [dragValue, labelPlacement, stepSize, rangeValuesPlacement, min, max, setStartOffset, setEndOffset]);
|
103
|
+
useEffect(function () {
|
104
|
+
if (innerRef.current) {
|
105
|
+
innerRef.current.addEventListener('setInitValue', function (e) {
|
106
|
+
var item = e.target;
|
107
|
+
var defaultValue = Number(item.getAttribute('defaultValue'));
|
108
|
+
setDragValue(defaultValue);
|
109
|
+
});
|
110
|
+
}
|
111
|
+
return function () {
|
112
|
+
if (innerRef.current) {
|
113
|
+
innerRef.current.addEventListener('setInitValue', function (e) {
|
114
|
+
var item = e.target;
|
115
|
+
var defaultValue = Number(item.getAttribute('defaultValue'));
|
116
|
+
setDragValue(defaultValue);
|
117
|
+
});
|
118
|
+
}
|
119
|
+
};
|
120
|
+
}, [innerRef]);
|
100
121
|
var setStepSize = useCallback(function (newStepSize) {
|
101
122
|
setState(function (prevState) {
|
102
123
|
return _objectSpread(_objectSpread({}, prevState), {}, {
|
@@ -164,5 +185,11 @@ export var SingleSlider = function SingleSlider(_ref) {
|
|
164
185
|
})), showRangeValues && /*#__PURE__*/React.createElement(StyledRangeValue, {
|
165
186
|
ref: endLabelRef,
|
166
187
|
className: cx(classes.maxRangeValue, hideMaxValueDiffClass, activeSecondValue)
|
167
|
-
}, max))
|
188
|
+
}, max)), /*#__PURE__*/React.createElement(InputHidden, {
|
189
|
+
name: name,
|
190
|
+
type: "number",
|
191
|
+
datatype: "slider-single",
|
192
|
+
value: dragValue,
|
193
|
+
ref: innerRef
|
194
|
+
}));
|
168
195
|
};
|
@@ -17,4 +17,7 @@ export var SliderBaseWrapper = /*#__PURE__*/styled.div.withConfig({
|
|
17
17
|
})(["position:relative;display:flex;flex:1;&.", "{", "{position:absolute;bottom:var(", ");left:0;&.", "{left:unset;right:0;}}}&.", "{align-items:center;", "{margin-right:var(", ");&.", "{margin-right:0;margin-left:var(", ");}}}"], classes.rangeValuesPlacementOuter, StyledRangeValue, tokens.rangeValueBottomOffset, classes.maxRangeValue, classes.rangeValuesPlacementInner, StyledRangeValue, tokens.rangeMinValueMargin, classes.maxRangeValue, tokens.rangeMaxValueMargin);
|
18
18
|
export var SingleWrapper = /*#__PURE__*/styled.div.withConfig({
|
19
19
|
componentId: "plasma-new-hope__sc-1qm4elt-5"
|
20
|
-
})(["display:flex;opacity:var(", ");&.", "{flex-direction:column;", "{margin-bottom:var(", ");}}&.", "{", "{margin-right:var(", ");}}"], tokens.disabledOpacity, classes.labelPlacementOuter, LabelWrapper, tokens.labelWrapperMarginBottom, classes.labelPlacementInner, LabelWrapper, tokens.labelWrapperMarginRight);
|
20
|
+
})(["display:flex;opacity:var(", ");&.", "{flex-direction:column;", "{margin-bottom:var(", ");}}&.", "{", "{margin-right:var(", ");}}"], tokens.disabledOpacity, classes.labelPlacementOuter, LabelWrapper, tokens.labelWrapperMarginBottom, classes.labelPlacementInner, LabelWrapper, tokens.labelWrapperMarginRight);
|
21
|
+
export var InputHidden = /*#__PURE__*/styled.input.withConfig({
|
22
|
+
componentId: "plasma-new-hope__sc-1qm4elt-6"
|
23
|
+
})(["visibility:hidden;width:0;height:0;opacity:0;margin:0;padding:0;"]);
|
@@ -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,7 +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 =
|
121
|
+
var outerRef = /*#__PURE__*/createRef();
|
122
122
|
var innerOptional = required ? false : optional;
|
123
123
|
var hasHelper = Boolean(leftHelper || rightHelper || helperText);
|
124
124
|
var hasOuterLabel = Boolean(label && labelPlacement === 'outer');
|
@@ -190,7 +190,7 @@ export var textAreaRoot = function textAreaRoot(Root) {
|
|
190
190
|
hasContentRight: Boolean(contentRight),
|
191
191
|
hasHelper: hasHelper,
|
192
192
|
applyCustomWidth: applyCustomWidth,
|
193
|
-
ref: outerRef,
|
193
|
+
ref: mergeRefs(outerRef, innerRef),
|
194
194
|
disabled: disabled,
|
195
195
|
height: autoResize ? minAuto : height,
|
196
196
|
width: width,
|
@@ -183,7 +183,7 @@ export var textFieldRoot = function textFieldRoot(Root) {
|
|
183
183
|
}, required && /*#__PURE__*/React.createElement(StyledIndicator, {
|
184
184
|
className: cx(classes.outerLabelPlacement, requiredPlacementClass)
|
185
185
|
}), innerLabelValue, optionalTextNode), /*#__PURE__*/React.createElement(InputWrapper
|
186
|
-
//
|
186
|
+
// Рефка для внутреннего использования. Не отдается наружу.
|
187
187
|
, {
|
188
188
|
ref: rest.inputWrapperRef,
|
189
189
|
className: cx(withHasChips, wrapperWithoutLeftContent, wrapperWithoutRightContent)
|
@@ -21,27 +21,24 @@ export var InputPlaceholder = /*#__PURE__*/styled.div.withConfig({
|
|
21
21
|
export var Label = /*#__PURE__*/styled.label.withConfig({
|
22
22
|
componentId: "plasma-new-hope__sc-g4vxbb-6"
|
23
23
|
})(["position:relative;display:inline-flex;"]);
|
24
|
-
var
|
24
|
+
export var StyledContentLeft = /*#__PURE__*/styled.div.withConfig({
|
25
25
|
componentId: "plasma-new-hope__sc-g4vxbb-7"
|
26
|
-
})(["
|
27
|
-
export var
|
26
|
+
})(["margin:var(", ");line-height:0;"], tokens.leftContentMargin);
|
27
|
+
export var StyledContentRight = /*#__PURE__*/styled.div.withConfig({
|
28
28
|
componentId: "plasma-new-hope__sc-g4vxbb-8"
|
29
|
-
})(["margin:var(", ");"], tokens.
|
30
|
-
export var StyledContentRight = /*#__PURE__*/styled(StyledContentSlot).withConfig({
|
31
|
-
componentId: "plasma-new-hope__sc-g4vxbb-9"
|
32
|
-
})(["margin:var(", ");&:hover{color:var(", ");cursor:pointer;}&:active{color:var(", ");}"], tokens.rightContentMargin, tokens.contentSlotColorHover, tokens.contentSlotColorActive);
|
29
|
+
})(["margin:var(", ");line-height:0;"], tokens.rightContentMargin);
|
33
30
|
export var LeftHelper = /*#__PURE__*/styled.div.withConfig({
|
34
|
-
componentId: "plasma-new-hope__sc-g4vxbb-
|
31
|
+
componentId: "plasma-new-hope__sc-g4vxbb-9"
|
35
32
|
})([""]);
|
36
33
|
export var StyledTextBefore = /*#__PURE__*/styled.div.withConfig({
|
37
|
-
componentId: "plasma-new-hope__sc-g4vxbb-
|
34
|
+
componentId: "plasma-new-hope__sc-g4vxbb-10"
|
38
35
|
})([""]);
|
39
36
|
export var StyledTextAfter = /*#__PURE__*/styled.div.withConfig({
|
40
|
-
componentId: "plasma-new-hope__sc-g4vxbb-
|
37
|
+
componentId: "plasma-new-hope__sc-g4vxbb-11"
|
41
38
|
})([""]);
|
42
39
|
export var StyledOptionalText = /*#__PURE__*/styled.span.withConfig({
|
43
|
-
componentId: "plasma-new-hope__sc-g4vxbb-
|
40
|
+
componentId: "plasma-new-hope__sc-g4vxbb-12"
|
44
41
|
})(["color:var(", ");"], tokens.optionalColor);
|
45
42
|
export var StyledIndicator = /*#__PURE__*/styled.div.withConfig({
|
46
|
-
componentId: "plasma-new-hope__sc-g4vxbb-
|
43
|
+
componentId: "plasma-new-hope__sc-g4vxbb-13"
|
47
44
|
})(["position:absolute;border-radius:50%;background-color:var(", ");&.", "{width:var(", ");height:var(", ");inset:var(", ");&.align-right{inset:var(", ");}}&.", "{width:var(", ");height:var(", ");inset:var(", ");&.align-right{inset:var(", ");}}"], tokens.indicatorColor, classes.outerLabelPlacement, tokens.indicatorSizeOuter, tokens.indicatorSizeOuter, tokens.indicatorLabelPlacementOuter, tokens.indicatorLabelPlacementOuterRight, classes.innerLabelPlacement, tokens.indicatorSizeInner, tokens.indicatorSizeInner, tokens.indicatorLabelPlacementInner, tokens.indicatorLabelPlacementInnerRight);
|
@@ -24,12 +24,12 @@ export function App() {
|
|
24
24
|
<TextField
|
25
25
|
placeholder="Положение иконки"
|
26
26
|
defaultValue="Слева"
|
27
|
-
contentLeft={<IconDownload
|
27
|
+
contentLeft={<IconDownload />}
|
28
28
|
/>
|
29
29
|
<TextField
|
30
30
|
placeholder="Положение иконки"
|
31
31
|
defaultValue="Справа"
|
32
|
-
contentRight={<IconDownload
|
32
|
+
contentRight={<IconDownload />}
|
33
33
|
/>
|
34
34
|
</div>
|
35
35
|
);
|
@@ -31,7 +31,7 @@ export var tokens = {
|
|
31
31
|
/** Отступ от границы ТextField */
|
32
32
|
padding: '--plasma-textfield-padding',
|
33
33
|
paddingWithChips: '--plasma-textfield-padding-with-chips',
|
34
|
-
/* Токены для
|
34
|
+
/* Токены для инпута */
|
35
35
|
leftContentMargin: '--plasma-textfield__left-content-margin',
|
36
36
|
rightContentMargin: '--plasma-textfield__right-content-margin',
|
37
37
|
fontFamily: '--plasma-textfield-font-family',
|
@@ -40,10 +40,6 @@ export var tokens = {
|
|
40
40
|
fontWeight: '--plasma-textfield-font-weight',
|
41
41
|
letterSpacing: '--plasma-textfield-letter-spacing',
|
42
42
|
lineHeight: '--plasma-textfield-line-height',
|
43
|
-
/* Tokens for content slot */
|
44
|
-
contentSlotColor: '--plasma-textfield-content-slot-color',
|
45
|
-
contentSlotColorHover: '--plasma-textfield-content-slot-color-hover',
|
46
|
-
contentSlotColorActive: '--plasma-textfield-content-slot-color-active',
|
47
43
|
/** Токены лейбла */
|
48
44
|
labelColor: '--plasma-textfield__label-color',
|
49
45
|
labelColorReadOnly: '--plasma-textfield__label-color-readonly',
|
@@ -34,7 +34,7 @@ export function App() {
|
|
34
34
|
### Размер
|
35
35
|
Размер TextFieldGroup задается с помощью свойства `size`.
|
36
36
|
С помощью свойства `isCommonTextFieldStyles` можно отключить переопределение стилей для всех input внутри группы.
|
37
|
-
Тогда
|
37
|
+
Тогда каждкаждый input будет иметь настраиваемый размер.
|
38
38
|
|
39
39
|
```tsx live
|
40
40
|
import React from 'react';
|
@@ -0,0 +1,182 @@
|
|
1
|
+
import { useForm, Controller } from 'react-hook-form';
|
2
|
+
import React from 'react';
|
3
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
4
|
+
|
5
|
+
import { WithTheme } from '../../../_helpers';
|
6
|
+
import { Button } from '../Button/Button';
|
7
|
+
import { TextField } from '../TextField/TextField';
|
8
|
+
import { TextArea } from '../TextArea/TextArea'; // TextArea.tsx 120 строка, не работает из-за некорректного ref
|
9
|
+
import { Checkbox } from '../Checkbox/Checkbox';
|
10
|
+
import { Switch } from '../Switch/Switch';
|
11
|
+
import { Radiobox } from '../Radiobox/Radiobox';
|
12
|
+
import { RadioGroup } from '../../../../components/Radiobox';
|
13
|
+
import { Slider } from '../Slider/Slider';
|
14
|
+
import { useFormPlasma } from '../../../../hooks';
|
15
|
+
|
16
|
+
type StoryDropdownProps = {};
|
17
|
+
|
18
|
+
const langName = 'language';
|
19
|
+
const itemsRadiobox = [
|
20
|
+
{ langName, value: 'c', label: 'C', disabled: false },
|
21
|
+
{ langName, value: 'cpp', label: 'C++', disabled: false },
|
22
|
+
{ langName, value: 'assembly', label: 'Assembly', disabled: false },
|
23
|
+
];
|
24
|
+
|
25
|
+
const DefaultForm = () => {
|
26
|
+
const onSubmit = (data) => {
|
27
|
+
console.log(data);
|
28
|
+
};
|
29
|
+
|
30
|
+
const { formRef, formData } = useFormPlasma(onSubmit, {
|
31
|
+
textfield: 'textfield',
|
32
|
+
textarea: 'textarea',
|
33
|
+
checkbox: 'checkobox',
|
34
|
+
switch: true,
|
35
|
+
radiobox: 'c',
|
36
|
+
slider: 10,
|
37
|
+
});
|
38
|
+
|
39
|
+
return (
|
40
|
+
<form onSubmit={formData} style={{ display: 'flex', flexDirection: 'column', gap: '20px' }} ref={formRef}>
|
41
|
+
<TextField name="textfield" placeholder="Textfield" required={false} />
|
42
|
+
<TextArea name="textarea" autoResize placeholder="Textarea" />
|
43
|
+
<Checkbox name="checkbox" label="Checkbox" />
|
44
|
+
<Switch name="switch" label="Switch" labelPosition="after" />
|
45
|
+
<RadioGroup aria-labelledby="radiogroup-title-id">
|
46
|
+
<div id="radiogroup-title-id" style={{ margin: '1rem 0', fontWeight: '600' }}>
|
47
|
+
Выберите язык программирования для изучения.
|
48
|
+
</div>
|
49
|
+
{itemsRadiobox.map((item) => (
|
50
|
+
<Radiobox
|
51
|
+
name="radiobox"
|
52
|
+
key={item.value}
|
53
|
+
value={item.value}
|
54
|
+
label={item.label}
|
55
|
+
disabled={item.disabled}
|
56
|
+
/>
|
57
|
+
))}
|
58
|
+
</RadioGroup>
|
59
|
+
<Slider name="slider" label="Slider" type="single" min={0} max={100} />
|
60
|
+
<Button type="submit">Отправить</Button>
|
61
|
+
</form>
|
62
|
+
);
|
63
|
+
};
|
64
|
+
|
65
|
+
const meta: Meta<StoryDropdownProps> = {
|
66
|
+
title: 'plasma_b2c/Form',
|
67
|
+
decorators: [WithTheme],
|
68
|
+
component: DefaultForm,
|
69
|
+
};
|
70
|
+
|
71
|
+
export default meta;
|
72
|
+
|
73
|
+
const StoryPlasmaForm = () => {
|
74
|
+
return <DefaultForm />;
|
75
|
+
};
|
76
|
+
|
77
|
+
export const Default: StoryObj<StoryDropdownProps> = {
|
78
|
+
render: () => <StoryPlasmaForm />,
|
79
|
+
};
|
80
|
+
|
81
|
+
const DefaultUseForm = () => {
|
82
|
+
const { register, handleSubmit } = useForm({
|
83
|
+
defaultValues: {
|
84
|
+
textfield: 'John Doe',
|
85
|
+
textarea: 'Default description',
|
86
|
+
checkbox: true,
|
87
|
+
switch: true,
|
88
|
+
radiobox: 'c',
|
89
|
+
slider: 10,
|
90
|
+
},
|
91
|
+
});
|
92
|
+
const onSubmit = (data) => {
|
93
|
+
console.log(data);
|
94
|
+
};
|
95
|
+
|
96
|
+
return (
|
97
|
+
<form onSubmit={handleSubmit(onSubmit)} style={{ display: 'flex', flexDirection: 'column', gap: '20px' }}>
|
98
|
+
<TextField {...register('textfield')} placeholder="Textfield" required={false} />
|
99
|
+
<TextArea {...register('textarea')} autoResize placeholder="Textarea" />
|
100
|
+
<Checkbox {...register('checkbox')} label="Checkbox" />
|
101
|
+
<Switch {...register('switch')} label="Switch" labelPosition="after" />
|
102
|
+
<RadioGroup aria-labelledby="radiogroup-title-id">
|
103
|
+
<div id="radiogroup-title-id" style={{ margin: '1rem 0', fontWeight: '600' }}>
|
104
|
+
Выберите язык программирования для изучения.
|
105
|
+
</div>
|
106
|
+
{itemsRadiobox.map((item) => (
|
107
|
+
<Radiobox
|
108
|
+
{...register('radiobox')}
|
109
|
+
key={item.value}
|
110
|
+
value={item.value}
|
111
|
+
label={item.label}
|
112
|
+
disabled={item.disabled}
|
113
|
+
/>
|
114
|
+
))}
|
115
|
+
</RadioGroup>
|
116
|
+
<Button type="submit">Отправить</Button>
|
117
|
+
</form>
|
118
|
+
);
|
119
|
+
};
|
120
|
+
|
121
|
+
const StoryHookForm = () => {
|
122
|
+
return <DefaultUseForm />;
|
123
|
+
};
|
124
|
+
|
125
|
+
export const UseHookForm: StoryObj<StoryDropdownProps> = {
|
126
|
+
render: () => <StoryHookForm />,
|
127
|
+
};
|
128
|
+
|
129
|
+
const DefaultUseFormController = () => {
|
130
|
+
const { control, handleSubmit } = useForm({
|
131
|
+
defaultValues: {
|
132
|
+
textfield: 'John Doe',
|
133
|
+
textarea: 'Default description',
|
134
|
+
checkbox: true,
|
135
|
+
switch: true,
|
136
|
+
radiobox: 'c',
|
137
|
+
slider: 10,
|
138
|
+
},
|
139
|
+
});
|
140
|
+
const onSubmit = (data) => {
|
141
|
+
console.log(data);
|
142
|
+
};
|
143
|
+
|
144
|
+
return (
|
145
|
+
<form onSubmit={handleSubmit(onSubmit)} style={{ display: 'flex', flexDirection: 'column', gap: '20px' }}>
|
146
|
+
<Controller
|
147
|
+
name="textfield"
|
148
|
+
control={control}
|
149
|
+
render={({ field }) => <TextField {...field} label="TextField" />}
|
150
|
+
/>
|
151
|
+
<Controller
|
152
|
+
name="textarea"
|
153
|
+
control={control}
|
154
|
+
render={({ field }) => <TextArea {...field} label="TextArea" />}
|
155
|
+
/>
|
156
|
+
<Controller
|
157
|
+
name="checkbox"
|
158
|
+
control={control}
|
159
|
+
render={({ field }) => <Checkbox {...field} checked={field.value} label="Checkbox" />}
|
160
|
+
/>
|
161
|
+
<Controller
|
162
|
+
name="switch"
|
163
|
+
control={control}
|
164
|
+
render={({ field }) => <Switch {...field} checked={field.value} labelPosition="after" label="Switch" />}
|
165
|
+
/>
|
166
|
+
<Controller
|
167
|
+
name="slider"
|
168
|
+
control={control}
|
169
|
+
render={({ field }) => <Slider {...field} type="single" label="Slider" min={0} max={100} />}
|
170
|
+
/>
|
171
|
+
<Button type="submit">Отправить</Button>
|
172
|
+
</form>
|
173
|
+
);
|
174
|
+
};
|
175
|
+
|
176
|
+
const StoryHookFormController = () => {
|
177
|
+
return <DefaultUseFormController />;
|
178
|
+
};
|
179
|
+
|
180
|
+
export const UseHookFormController: StoryObj<StoryDropdownProps> = {
|
181
|
+
render: () => <StoryHookFormController />,
|
182
|
+
};
|
@@ -8,10 +8,10 @@ export var config = {
|
|
8
8
|
},
|
9
9
|
variations: {
|
10
10
|
view: {
|
11
|
-
"default": /*#__PURE__*/css(["", ":var(--text-primary);", ":var(--surface-transparent-primary);", ":var(--surface-transparent-secondary);", ":var(--text-accent);", ":var(--text-secondary);", ":var(--text-tertiary);", ":var(--text-tertiary);", ":var(--text-primary);", ":var(--text-secondary);", ":var(--text-secondary);", ":var(--text-
|
12
|
-
positive: /*#__PURE__*/css(["", ":var(--text-primary);", ":var(--surface-transparent-positive);", ":var(--surface-transparent-positive-active);", ":var(--text-accent);", ":var(--text-secondary);", ":var(--text-tertiary);", ":var(--text-tertiary);", ":var(--text-primary);", ":var(--text-positive);", ":var(--text-secondary);", ":var(--text-
|
13
|
-
warning: /*#__PURE__*/css(["", ":var(--text-primary);", ":var(--surface-transparent-warning);", ":var(--surface-transparent-warning-active);", ":var(--text-accent);", ":var(--text-secondary);", ":var(--text-tertiary);", ":var(--text-tertiary);", ":var(--text-primary);", ":var(--text-warning);", ":var(--text-secondary);", ":var(--text-
|
14
|
-
negative: /*#__PURE__*/css(["", ":var(--text-primary);", ":var(--surface-transparent-negative);", ":var(--surface-transparent-negative-active);", ":var(--text-accent);", ":var(--text-secondary);", ":var(--text-tertiary);", ":var(--text-tertiary);", ":var(--text-primary);", ":var(--text-negative);", ":var(--text-secondary);", ":var(--text-
|
11
|
+
"default": /*#__PURE__*/css(["", ":var(--text-primary);", ":var(--surface-transparent-primary);", ":var(--surface-transparent-secondary);", ":var(--text-accent);", ":var(--text-secondary);", ":var(--text-tertiary);", ":var(--text-tertiary);", ":var(--text-primary);", ":var(--text-secondary);", ":var(--text-secondary);", ":var(--text-primary);", ":var(--surface-transparent-secondary);", ":var(--text-primary);", ":var(--surface-transparent-secondary-hover);", ":var(--text-primary);", ":var(--surface-transparent-secondary-active);", ":var(--surface-transparent-secondary);", ":var(--text-primary);", ":var(--surface-transparent-secondary);", ":var(--text-primary);", ":0.72;", ":var(--text-accent);", ":var(--surface-negative);", ":var(--text-tertiary);"], tokens.color, tokens.backgroundColor, tokens.backgroundColorFocus, tokens.caretColor, tokens.placeholderColor, tokens.textBeforeColor, tokens.textAfterColor, tokens.labelColor, tokens.leftHelperColor, tokens.chipCloseIconColor, tokens.chipColor, tokens.chipBackground, tokens.chipColorHover, tokens.chipBackgroundHover, tokens.chipColorActive, tokens.chipBackgroundActive, tokens.chipBackgroundReadOnly, tokens.chipColorReadOnly, tokens.chipBackgroundReadOnlyHover, tokens.chipColorReadOnlyHover, tokens.chipOpacityReadonly, tokens.focusColor, tokens.indicatorColor, tokens.optionalColor),
|
12
|
+
positive: /*#__PURE__*/css(["", ":var(--text-primary);", ":var(--surface-transparent-positive);", ":var(--surface-transparent-positive-active);", ":var(--text-accent);", ":var(--text-secondary);", ":var(--text-tertiary);", ":var(--text-tertiary);", ":var(--text-primary);", ":var(--text-positive);", ":var(--text-secondary);", ":var(--text-primary);", ":var(--surface-transparent-secondary);", ":var(--text-primary);", ":var(--surface-transparent-secondary-hover);", ":var(--text-primary);", ":var(--surface-transparent-secondary-active);", ":var(--surface-transparent-secondary);", ":var(--text-primary);", ":var(--surface-transparent-secondary);", ":var(--text-primary);", ":0.72;", ":var(--text-accent);", ":var(--surface-negative);", ":var(--text-tertiary);"], tokens.color, tokens.backgroundColor, tokens.backgroundColorFocus, tokens.caretColor, tokens.placeholderColor, tokens.textBeforeColor, tokens.textAfterColor, tokens.labelColor, tokens.leftHelperColor, tokens.chipCloseIconColor, tokens.chipColor, tokens.chipBackground, tokens.chipColorHover, tokens.chipBackgroundHover, tokens.chipColorActive, tokens.chipBackgroundActive, tokens.chipBackgroundReadOnly, tokens.chipColorReadOnly, tokens.chipBackgroundReadOnlyHover, tokens.chipColorReadOnlyHover, tokens.chipOpacityReadonly, tokens.focusColor, tokens.indicatorColor, tokens.optionalColor),
|
13
|
+
warning: /*#__PURE__*/css(["", ":var(--text-primary);", ":var(--surface-transparent-warning);", ":var(--surface-transparent-warning-active);", ":var(--text-accent);", ":var(--text-secondary);", ":var(--text-tertiary);", ":var(--text-tertiary);", ":var(--text-primary);", ":var(--text-warning);", ":var(--text-secondary);", ":var(--text-primary);", ":var(--surface-transparent-secondary);", ":var(--text-primary);", ":var(--surface-transparent-secondary-hover);", ":var(--text-primary);", ":var(--surface-transparent-secondary-active);", ":var(--surface-transparent-secondary);", ":var(--text-primary);", ":var(--surface-transparent-secondary);", ":var(--text-primary);", ":0.72;", ":var(--text-accent);", ":var(--surface-negative);", ":var(--text-tertiary);"], tokens.color, tokens.backgroundColor, tokens.backgroundColorFocus, tokens.caretColor, tokens.placeholderColor, tokens.textBeforeColor, tokens.textAfterColor, tokens.labelColor, tokens.leftHelperColor, tokens.chipCloseIconColor, tokens.chipColor, tokens.chipBackground, tokens.chipColorHover, tokens.chipBackgroundHover, tokens.chipColorActive, tokens.chipBackgroundActive, tokens.chipBackgroundReadOnly, tokens.chipColorReadOnly, tokens.chipBackgroundReadOnlyHover, tokens.chipColorReadOnlyHover, tokens.chipOpacityReadonly, tokens.focusColor, tokens.indicatorColor, tokens.optionalColor),
|
14
|
+
negative: /*#__PURE__*/css(["", ":var(--text-primary);", ":var(--surface-transparent-negative);", ":var(--surface-transparent-negative-active);", ":var(--text-accent);", ":var(--text-secondary);", ":var(--text-tertiary);", ":var(--text-tertiary);", ":var(--text-primary);", ":var(--text-negative);", ":var(--text-secondary);", ":var(--text-primary);", ":var(--surface-transparent-secondary);", ":var(--text-primary);", ":var(--surface-transparent-secondary-hover);", ":var(--text-primary);", ":var(--surface-transparent-secondary-active);", ":var(--surface-transparent-secondary);", ":var(--text-primary);", ":var(--surface-transparent-secondary);", ":var(--text-primary);", ":0.72;", ":var(--text-accent);", ":var(--surface-negative);", ":var(--text-tertiary);"], tokens.color, tokens.backgroundColor, tokens.backgroundColorFocus, tokens.caretColor, tokens.placeholderColor, tokens.textBeforeColor, tokens.textAfterColor, tokens.labelColor, tokens.leftHelperColor, tokens.chipCloseIconColor, tokens.chipColor, tokens.chipBackground, tokens.chipColorHover, tokens.chipBackgroundHover, tokens.chipColorActive, tokens.chipBackgroundActive, tokens.chipBackgroundReadOnly, tokens.chipColorReadOnly, tokens.chipBackgroundReadOnlyHover, tokens.chipColorReadOnlyHover, tokens.chipOpacityReadonly, tokens.focusColor, tokens.indicatorColor, tokens.optionalColor)
|
15
15
|
},
|
16
16
|
size: {
|
17
17
|
l: /*#__PURE__*/css(["", ":3.5rem;", ":1.0625rem 1.125rem 1.0625rem 1.125rem;", ":0.375rem;", ":0.875rem;", ":0.0625rem;", ":-0.0625rem 0.5rem -0.0625rem -0.125rem;", ":-0.0625rem -0.125rem -0.0625rem 0.75rem;", ":var(--plasma-typo-body-l-font-family);", ":var(--plasma-typo-body-l-font-size);", ":var(--plasma-typo-body-l-font-style);", ":var(--plasma-typo-body-l-font-weight);", ":var(--plasma-typo-body-l-letter-spacing);", ":var(--plasma-typo-body-l-line-height);", ":0.75rem;", ":var(--plasma-typo-body-l-font-family);", ":var(--plasma-typo-body-l-font-size);", ":var(--plasma-typo-body-l-font-style);", ":var(--plasma-typo-body-l-font-weight);", ":var(--plasma-typo-body-l-letter-spacing);", ":var(--plasma-typo-body-l-line-height);", ":0.25rem;", ":var(--plasma-typo-body-xs-font-family);", ":var(--plasma-typo-body-xs-font-size);", ":var(--plasma-typo-body-xs-font-style);", ":var(--plasma-typo-body-xs-font-weight);", ":var(--plasma-typo-body-xs-letter-spacing);", ":var(--plasma-typo-body-xs-line-height);", ":0.5625rem 0 0.125rem 0;", ":1.5625rem 0 0.5625rem 0;", ":0.25rem;", ":0.5rem;", ":auto;", ":2.75rem;", ":0.75rem;", ":1rem;", ":0.625rem;", ":0rem;", ":1.5rem;", ":var(--plasma-typo-body-l-font-family);", ":var(--plasma-typo-body-l-font-size);", ":var(--plasma-typo-body-l-font-style);", ":var(--plasma-typo-body-l-font-weight);", ":var(--plasma-typo-body-l-letter-spacing);", ":var(--plasma-typo-body-l-line-height);", ":0.5rem;", ":0.375rem;", ":0 0 0 0;", ":0.5rem auto auto -0.75rem;", ":0 0 auto auto;", ":0.25rem -0.625rem auto auto;"], tokens.height, tokens.padding, tokens.paddingWithChips, tokens.borderRadius, tokens.borderWidth, tokens.leftContentMargin, tokens.rightContentMargin, tokens.fontFamily, tokens.fontSize, tokens.fontStyle, tokens.fontWeight, tokens.letterSpacing, tokens.lineHeight, tokens.labelOffset, tokens.labelFontFamily, tokens.labelFontSize, tokens.labelFontStyle, tokens.labelFontWeight, tokens.labelLetterSpacing, tokens.labelLineHeight, tokens.leftHelperOffset, tokens.leftHelperFontFamily, tokens.leftHelperFontSize, tokens.leftHelperFontStyle, tokens.leftHelperFontWeight, tokens.leftHelperLetterSpacing, tokens.leftHelperLineHeight, tokens.labelInnerPadding, tokens.contentLabelInnerPadding, tokens.chipGap, tokens.chipBorderRadius, tokens.chipWidth, tokens.chipHeight, tokens.chipPaddingRight, tokens.chipPaddingLeft, tokens.chipClearContentMarginLeft, tokens.chipClearContentMarginRight, tokens.chipCloseIconSize, tokens.chipFontFamily, tokens.chipFontSize, tokens.chipFontStyle, tokens.chipFontWeight, tokens.chipLetterSpacing, tokens.chipLineHeight, tokens.indicatorSizeInner, tokens.indicatorSizeOuter, tokens.indicatorLabelPlacementInner, tokens.indicatorLabelPlacementOuter, tokens.indicatorLabelPlacementInnerRight, tokens.indicatorLabelPlacementOuterRight),
|
@@ -4,7 +4,6 @@ import { action } from '@storybook/addon-actions';
|
|
4
4
|
import { IconPlaceholder } from '@salutejs/plasma-sb-utils';
|
5
5
|
|
6
6
|
import { WithTheme } from '../../../_helpers';
|
7
|
-
import { IconCross } from '../../../../components/_Icon';
|
8
7
|
|
9
8
|
import { TextField } from './TextField';
|
10
9
|
|
@@ -104,8 +103,8 @@ const StoryDemo = ({ enableContentLeft, enableContentRight, view, ...rest }: Sto
|
|
104
103
|
{...rest}
|
105
104
|
enumerationType="plain"
|
106
105
|
value={text}
|
107
|
-
contentLeft={enableContentLeft ? <
|
108
|
-
contentRight={enableContentRight ? <
|
106
|
+
contentLeft={enableContentLeft ? <IconPlaceholder size={iconSize} /> : undefined}
|
107
|
+
contentRight={enableContentRight ? <IconPlaceholder size={iconSize} /> : undefined}
|
109
108
|
view={view}
|
110
109
|
onChange={(e) => {
|
111
110
|
setText(e.target.value);
|
@@ -8,10 +8,10 @@ export var config = {
|
|
8
8
|
},
|
9
9
|
variations: {
|
10
10
|
view: {
|
11
|
-
"default": /*#__PURE__*/css(["", ":var(--text-primary);", ":var(--surface-clear);", ":var(--text-accent);", ":var(--text-secondary);", ":var(--text-primary);", ":var(--text-secondary);", ":var(--
|
12
|
-
positive: /*#__PURE__*/css(["", ":var(--text-primary);", ":var(--surface-clear);", ":var(--text-accent);", ":var(--text-secondary);", ":var(--text-primary);", ":var(--text-positive);", ":var(--
|
13
|
-
warning: /*#__PURE__*/css(["", ":var(--text-primary);", ":var(--surface-clear);", ":var(--text-accent);", ":var(--text-secondary);", ":var(--text-primary);", ":var(--text-warning);", ":var(--
|
14
|
-
negative: /*#__PURE__*/css(["", ":var(--text-primary);", ":var(--surface-clear);", ":var(--text-accent);", ":var(--text-secondary);", ":var(--text-primary);", ":var(--text-negative);", ":var(--
|
11
|
+
"default": /*#__PURE__*/css(["", ":var(--text-primary);", ":var(--surface-clear);", ":var(--text-accent);", ":var(--text-secondary);", ":var(--text-primary);", ":var(--text-secondary);", ":var(--surface-transparent-tertiary);", ":var(--text-secondary);", ":var(--surface-accent);", ":var(--text-secondary);", ":var(--text-primary);", ":var(--surface-transparent-secondary);", ":var(--text-primary);", ":var(--surface-transparent-secondary-hover);", ":var(--text-primary);", ":var(--surface-transparent-secondary-active);", ":var(--surface-transparent-secondary);", ":var(--text-primary);", ":var(--surface-transparent-secondary);", ":var(--text-primary);", ":0.72;", ":var(--text-accent);", ":var(--surface-negative);", ":var(--text-tertiary);"], tokens.color, tokens.backgroundColor, tokens.caretColor, tokens.placeholderColor, tokens.labelColor, tokens.leftHelperColor, tokens.borderColor, tokens.borderColorHover, tokens.borderColorFocus, tokens.chipCloseIconColor, tokens.chipColor, tokens.chipBackground, tokens.chipColorHover, tokens.chipBackgroundHover, tokens.chipColorActive, tokens.chipBackgroundActive, tokens.chipBackgroundReadOnly, tokens.chipColorReadOnly, tokens.chipBackgroundReadOnlyHover, tokens.chipColorReadOnlyHover, tokens.chipOpacityReadonly, tokens.focusColor, tokens.indicatorColor, tokens.optionalColor),
|
12
|
+
positive: /*#__PURE__*/css(["", ":var(--text-primary);", ":var(--surface-clear);", ":var(--text-accent);", ":var(--text-secondary);", ":var(--text-primary);", ":var(--text-positive);", ":var(--surface-positive);", ":var(--surface-positive);", ":var(--surface-accent);", ":var(--text-secondary);", ":var(--text-primary);", ":var(--surface-transparent-secondary);", ":var(--text-primary);", ":var(--surface-transparent-secondary-hover);", ":var(--text-primary);", ":var(--surface-transparent-secondary-active);", ":var(--surface-transparent-secondary);", ":var(--text-primary);", ":var(--surface-transparent-secondary);", ":var(--text-primary);", ":0.72;", ":var(--text-accent);", ":var(--surface-negative);", ":var(--text-tertiary);"], tokens.color, tokens.backgroundColor, tokens.caretColor, tokens.placeholderColor, tokens.labelColor, tokens.leftHelperColor, tokens.borderColor, tokens.borderColorHover, tokens.borderColorFocus, tokens.chipCloseIconColor, tokens.chipColor, tokens.chipBackground, tokens.chipColorHover, tokens.chipBackgroundHover, tokens.chipColorActive, tokens.chipBackgroundActive, tokens.chipBackgroundReadOnly, tokens.chipColorReadOnly, tokens.chipBackgroundReadOnlyHover, tokens.chipColorReadOnlyHover, tokens.chipOpacityReadonly, tokens.focusColor, tokens.indicatorColor, tokens.optionalColor),
|
13
|
+
warning: /*#__PURE__*/css(["", ":var(--text-primary);", ":var(--surface-clear);", ":var(--text-accent);", ":var(--text-secondary);", ":var(--text-primary);", ":var(--text-warning);", ":var(--surface-warning);", ":var(--surface-warning);", ":var(--surface-accent);", ":var(--text-secondary);", ":var(--text-primary);", ":var(--surface-transparent-secondary);", ":var(--text-primary);", ":var(--surface-transparent-secondary-hover);", ":var(--text-primary);", ":var(--surface-transparent-secondary-active);", ":var(--surface-transparent-secondary);", ":var(--text-primary);", ":var(--surface-transparent-secondary);", ":var(--text-primary);", ":0.72;", ":var(--text-accent);", ":var(--surface-negative);", ":var(--text-tertiary);"], tokens.color, tokens.backgroundColor, tokens.caretColor, tokens.placeholderColor, tokens.labelColor, tokens.leftHelperColor, tokens.borderColor, tokens.borderColorHover, tokens.borderColorFocus, tokens.chipCloseIconColor, tokens.chipColor, tokens.chipBackground, tokens.chipColorHover, tokens.chipBackgroundHover, tokens.chipColorActive, tokens.chipBackgroundActive, tokens.chipBackgroundReadOnly, tokens.chipColorReadOnly, tokens.chipBackgroundReadOnlyHover, tokens.chipColorReadOnlyHover, tokens.chipOpacityReadonly, tokens.focusColor, tokens.indicatorColor, tokens.optionalColor),
|
14
|
+
negative: /*#__PURE__*/css(["", ":var(--text-primary);", ":var(--surface-clear);", ":var(--text-accent);", ":var(--text-secondary);", ":var(--text-primary);", ":var(--text-negative);", ":var(--surface-negative);", ":var(--surface-negative);", ":var(--surface-accent);", ":var(--text-secondary);", ":var(--text-primary);", ":var(--surface-transparent-secondary);", ":var(--text-primary);", ":var(--surface-transparent-secondary-hover);", ":var(--text-primary);", ":var(--surface-transparent-secondary-active);", ":var(--surface-transparent-secondary);", ":var(--text-primary);", ":var(--surface-transparent-secondary);", ":var(--text-primary);", ":0.72;", ":var(--text-accent);", ":var(--surface-negative);", ":var(--text-tertiary);"], tokens.color, tokens.backgroundColor, tokens.caretColor, tokens.placeholderColor, tokens.labelColor, tokens.leftHelperColor, tokens.borderColor, tokens.borderColorHover, tokens.borderColorFocus, tokens.chipCloseIconColor, tokens.chipColor, tokens.chipBackground, tokens.chipColorHover, tokens.chipBackgroundHover, tokens.chipColorActive, tokens.chipBackgroundActive, tokens.chipBackgroundReadOnly, tokens.chipColorReadOnly, tokens.chipBackgroundReadOnlyHover, tokens.chipColorReadOnlyHover, tokens.chipOpacityReadonly, tokens.focusColor, tokens.indicatorColor, tokens.optionalColor)
|
15
15
|
},
|
16
16
|
size: {
|
17
17
|
l: /*#__PURE__*/css(["", ":3.5rem;", ":1.0625rem 1.125rem 1.0625rem 1.125rem;", ":0.375rem;", ":0.875rem;", ":0.0625rem;", ":-0.0625rem 0.5rem -0.0625rem -0.125rem;", ":-0.0625rem -0.125rem -0.0625rem 0.75rem;", ":var(--plasma-typo-body-l-font-family);", ":var(--plasma-typo-body-l-font-size);", ":var(--plasma-typo-body-l-font-style);", ":var(--plasma-typo-body-l-font-weight);", ":var(--plasma-typo-body-l-letter-spacing);", ":var(--plasma-typo-body-l-line-height);", ":0.75rem;", ":var(--plasma-typo-body-l-font-family);", ":var(--plasma-typo-body-l-font-size);", ":var(--plasma-typo-body-l-font-style);", ":var(--plasma-typo-body-l-font-weight);", ":var(--plasma-typo-body-l-letter-spacing);", ":var(--plasma-typo-body-l-line-height);", ":0.25rem;", ":var(--plasma-typo-body-xs-font-family);", ":var(--plasma-typo-body-xs-font-size);", ":var(--plasma-typo-body-xs-font-style);", ":var(--plasma-typo-body-xs-font-weight);", ":var(--plasma-typo-body-xs-letter-spacing);", ":var(--plasma-typo-body-xs-line-height);", ":0.5625rem 0 0.125rem 0;", ":1.5625rem 0 0.5625rem 0;", ":0.25rem;", ":0.5rem;", ":auto;", ":2.75rem;", ":0.75rem;", ":1rem;", ":0.625rem;", ":0rem;", ":1.5rem;", ":var(--plasma-typo-body-l-font-family);", ":var(--plasma-typo-body-l-font-size);", ":var(--plasma-typo-body-l-font-style);", ":var(--plasma-typo-body-l-font-weight);", ":var(--plasma-typo-body-l-letter-spacing);", ":var(--plasma-typo-body-l-line-height);", ":0.5rem;", ":0.375rem;", ":0 0 0 0;", ":0.5rem auto auto -0.75rem;", ":0 0 auto auto;", ":0.25rem -0.625rem auto auto;"], tokens.height, tokens.padding, tokens.paddingWithChips, tokens.borderRadius, tokens.borderWidth, tokens.leftContentMargin, tokens.rightContentMargin, tokens.fontFamily, tokens.fontSize, tokens.fontStyle, tokens.fontWeight, tokens.letterSpacing, tokens.lineHeight, tokens.labelOffset, tokens.labelFontFamily, tokens.labelFontSize, tokens.labelFontStyle, tokens.labelFontWeight, tokens.labelLetterSpacing, tokens.labelLineHeight, tokens.leftHelperOffset, tokens.leftHelperFontFamily, tokens.leftHelperFontSize, tokens.leftHelperFontStyle, tokens.leftHelperFontWeight, tokens.leftHelperLetterSpacing, tokens.leftHelperLineHeight, tokens.labelInnerPadding, tokens.contentLabelInnerPadding, tokens.chipGap, tokens.chipBorderRadius, tokens.chipWidth, tokens.chipHeight, tokens.chipPaddingRight, tokens.chipPaddingLeft, tokens.chipClearContentMarginLeft, tokens.chipClearContentMarginRight, tokens.chipCloseIconSize, tokens.chipFontFamily, tokens.chipFontSize, tokens.chipFontStyle, tokens.chipFontWeight, tokens.chipLetterSpacing, tokens.chipLineHeight, tokens.indicatorSizeInner, tokens.indicatorSizeOuter, tokens.indicatorLabelPlacementInner, tokens.indicatorLabelPlacementOuter, tokens.indicatorLabelPlacementInnerRight, tokens.indicatorLabelPlacementOuterRight),
|
@@ -4,7 +4,6 @@ import { action } from '@storybook/addon-actions';
|
|
4
4
|
import { IconPlaceholder } from '@salutejs/plasma-sb-utils';
|
5
5
|
|
6
6
|
import { WithTheme } from '../../../_helpers';
|
7
|
-
import { IconChevronLeft } from '../../../../components/_Icon';
|
8
7
|
|
9
8
|
import { TextField } from './TextField';
|
10
9
|
|
@@ -186,7 +185,7 @@ const StoryChips = ({ enableContentLeft, enableContentRight, view, ...rest }: St
|
|
186
185
|
{...rest}
|
187
186
|
enumerationType="chip"
|
188
187
|
value={text}
|
189
|
-
contentLeft={enableContentLeft ? <
|
188
|
+
contentLeft={enableContentLeft ? <IconPlaceholder size={iconSize} /> : undefined}
|
190
189
|
contentRight={enableContentRight ? <IconPlaceholder size={iconSize} /> : undefined}
|
191
190
|
view={view}
|
192
191
|
onChange={(e) => {
|
@@ -4,4 +4,5 @@ export { usePreviousValue } from './usePreviousValue';
|
|
4
4
|
export { useForceUpdate } from './useForceUpdate';
|
5
5
|
export { useDidMountEffect } from './useDidMountEffect';
|
6
6
|
export { useOutsideClick } from './useOutsideClick';
|
7
|
-
export { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';
|
7
|
+
export { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';
|
8
|
+
export { useFormPlasma } from './useForm';
|
@@ -0,0 +1,63 @@
|
|
1
|
+
import React, { useEffect } from 'react';
|
2
|
+
var initData = function initData(ref, defaultValues) {
|
3
|
+
if (ref.current) {
|
4
|
+
var form = ref.current;
|
5
|
+
var items = form.elements;
|
6
|
+
for (var i = 0; i < items.length; i++) {
|
7
|
+
var item = items[i];
|
8
|
+
var _name = item.name,
|
9
|
+
value = item.value,
|
10
|
+
type = item.type;
|
11
|
+
if (type === 'text' || type === 'textarea') {
|
12
|
+
item.value = String(defaultValues[_name]);
|
13
|
+
}
|
14
|
+
if (type === 'checkbox') {
|
15
|
+
item.checked = Boolean(defaultValues[_name]);
|
16
|
+
}
|
17
|
+
if (type === 'radio') {
|
18
|
+
item.checked = defaultValues[_name] === value;
|
19
|
+
}
|
20
|
+
if (type === 'number') {
|
21
|
+
item.setAttribute('defaultValue', String(defaultValues[_name]));
|
22
|
+
var event = new Event('setInitValue');
|
23
|
+
item.dispatchEvent(event);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}
|
27
|
+
};
|
28
|
+
export var useFormPlasma = function useFormPlasma(onSubmit, defaultValues) {
|
29
|
+
var formRef = /*#__PURE__*/React.createRef();
|
30
|
+
useEffect(function () {
|
31
|
+
initData(formRef, defaultValues);
|
32
|
+
});
|
33
|
+
var formData = function formData(event) {
|
34
|
+
event.preventDefault();
|
35
|
+
var result = {};
|
36
|
+
var form = event.target;
|
37
|
+
var items = form.elements;
|
38
|
+
for (var i = 0; i < items.length; i++) {
|
39
|
+
var item = items[i];
|
40
|
+
var _name2 = item.name,
|
41
|
+
value = item.value,
|
42
|
+
type = item.type;
|
43
|
+
if (type === 'text' || type === 'textarea' || type === 'number') {
|
44
|
+
result[_name2] = value;
|
45
|
+
}
|
46
|
+
if (type === 'checkbox') {
|
47
|
+
result[_name2] = item.checked;
|
48
|
+
}
|
49
|
+
if (type === 'radio') {
|
50
|
+
if (item.checked) {
|
51
|
+
result[_name2] = value;
|
52
|
+
} else if (!(_name2 in result)) {
|
53
|
+
result[_name2] = null;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
onSubmit(result);
|
58
|
+
};
|
59
|
+
return {
|
60
|
+
formRef: formRef,
|
61
|
+
formData: formData
|
62
|
+
};
|
63
|
+
};
|
@@ -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, setRefList } from './setRefList';
|
6
7
|
export { isEmpty } from './isEmpty';
|
7
8
|
export * from './getPopoverPlacement';
|
8
9
|
export var cx = function cx() {
|