@salutejs/plasma-new-hope 0.194.0-canary.1562.11852874401.0 → 0.194.0-canary.1562.11857238836.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/Select/ui/Target/ui/Textfield/Textfield.js +18 -3
- package/cjs/components/Select/ui/Target/ui/Textfield/Textfield.js.map +1 -1
- package/emotion/cjs/components/Select/ui/Target/ui/Textfield/Textfield.js +24 -3
- package/emotion/es/components/Select/ui/Target/ui/Textfield/Textfield.js +24 -3
- package/es/components/Select/ui/Target/ui/Textfield/Textfield.js +19 -4
- package/es/components/Select/ui/Target/ui/Textfield/Textfield.js.map +1 -1
- package/package.json +2 -2
- package/styled-components/cjs/components/Select/ui/Target/ui/Textfield/Textfield.js +24 -3
- package/styled-components/es/components/Select/ui/Target/ui/Textfield/Textfield.js +24 -3
- package/types/components/Select/ui/Target/ui/Textfield/Textfield.d.ts.map +1 -1
@@ -53,9 +53,24 @@ var Textfield = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
53
53
|
|
54
54
|
// Обработчик чипов
|
55
55
|
var handleChipsChange = function handleChipsChange(chipLabels) {
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
if (!Array.isArray(value)) return;
|
57
|
+
|
58
|
+
// TODO: #1564
|
59
|
+
// Из лейблов чипов получаем value у item и далее прокидываем его в onChange.
|
60
|
+
if (renderValue && !isTargetAmount) {
|
61
|
+
var resultValues = _rollupPluginBabelHelpers.toConsumableArray(value);
|
62
|
+
value.forEach(function (_, index) {
|
63
|
+
var labelAfterRenderValue = renderValue(labelToItemMap.get(valueToItemMap.get(value[index]).label));
|
64
|
+
if (!chipLabels.includes(labelAfterRenderValue)) {
|
65
|
+
resultValues.splice(index, 1);
|
66
|
+
}
|
67
|
+
});
|
68
|
+
onChange(resultValues);
|
69
|
+
} else {
|
70
|
+
onChange(chipLabels.map(function (chipLabel) {
|
71
|
+
return labelToItemMap.get(chipLabel).value;
|
72
|
+
}));
|
73
|
+
}
|
59
74
|
};
|
60
75
|
return /*#__PURE__*/React.createElement(Textfield_styles.StyledTextField, _rollupPluginBabelHelpers.extends({
|
61
76
|
ref: ref,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Textfield.js","sources":["../../../../../../../src/components/Select/ui/Target/ui/Textfield/Textfield.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { sizeToIconSize, getItemId } from '../../../../utils';\nimport { classes } from '../../../../Select.tokens';\n\nimport { IconArrowWrapper, StyledArrow, StyledTextField } from './Textfield.styles';\nimport { TextfieldProps } from './Textfield.types';\n\nexport const Textfield = forwardRef<HTMLInputElement, TextfieldProps>(\n (\n {\n inputWrapperRef,\n opened,\n multiselect,\n value,\n label,\n placeholder,\n onKeyDown,\n labelPlacement,\n size,\n view,\n handleClickArrow,\n contentLeft,\n helperText,\n treeId,\n activeDescendantItemValue,\n disabled,\n isTargetAmount,\n valueToItemMap,\n renderValue,\n onChange,\n labelToItemMap,\n chipView,\n },\n ref,\n ) => {\n const withArrowInverse = opened ? classes.arrowInverse : undefined;\n\n const getChips = (): string[] => {\n if (multiselect && Array.isArray(value)) {\n if (value.length === 0) return [];\n\n if (isTargetAmount) {\n return [`Выбрано ${value.length}`];\n }\n\n const renderValueMapper =\n renderValue && ((stringValue: string | number) => renderValue(valueToItemMap.get(stringValue)!));\n const valueToItemMapper = (stringValue: string | number) => valueToItemMap.get(stringValue)!.label;\n\n return value.map(renderValueMapper || valueToItemMapper);\n }\n\n return [];\n };\n\n // Обработчик чипов\n const handleChipsChange = (chipLabels: any[]) => {\n onChange(chipLabels.map((chipLabel) => labelToItemMap.get(chipLabel)!.value));\n };\n\n return (\n <StyledTextField\n ref={ref}\n inputWrapperRef={inputWrapperRef}\n readOnly\n value={multiselect ? undefined : valueToItemMap.get(value.toString())?.label || ''}\n size={size}\n view={view}\n chipView={chipView}\n labelPlacement={labelPlacement}\n disabled={disabled}\n label={label}\n placeholder={value instanceof Array && value.length ? '' : placeholder}\n contentLeft={contentLeft as React.ReactElement}\n contentRight={\n <IconArrowWrapper disabled={Boolean(disabled)} onClick={handleClickArrow}>\n <StyledArrow color=\"inherit\" size={sizeToIconSize(size)} className={withArrowInverse} />\n </IconArrowWrapper>\n }\n onKeyDown={onKeyDown}\n leftHelper={helperText}\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-controls={`${treeId}_tree_level_1`}\n aria-expanded={opened}\n aria-activedescendant={activeDescendantItemValue ? getItemId(treeId, activeDescendantItemValue) : ''}\n {...(multiselect\n ? {\n enumerationType: 'chip',\n chips: getChips(),\n onChangeChips: handleChipsChange,\n }\n : { enumerationType: 'plain' })}\n onEnterDisabled // Пропс для отключения обработчика Enter внутри Textfield\n opened={opened}\n // TODO: #1547\n _forceChipManipulationWithReadonly\n />\n );\n },\n);\n"],"names":["Textfield","forwardRef","_ref","ref","_valueToItemMap$get","inputWrapperRef","opened","multiselect","value","label","placeholder","onKeyDown","labelPlacement","size","view","handleClickArrow","contentLeft","helperText","treeId","activeDescendantItemValue","disabled","isTargetAmount","valueToItemMap","renderValue","onChange","labelToItemMap","chipView","withArrowInverse","classes","arrowInverse","undefined","getChips","Array","isArray","length","concat","renderValueMapper","stringValue","get","valueToItemMapper","map","handleChipsChange","chipLabels","chipLabel","React","createElement","StyledTextField","_extends","readOnly","toString","contentRight","IconArrowWrapper","Boolean","onClick","StyledArrow","color","sizeToIconSize","className","leftHelper","role","getItemId","enumerationType","chips","onChangeChips","onEnterDisabled","_forceChipManipulationWithReadonly"],"mappings":";;;;;;;;;;;AAQO,IAAMA,SAAS,gBAAGC,gBAAU,CAC/B,UAAAC,IAAA,EAyBIC,GAAG,EACF;AAAA,EAAA,IAAAC,mBAAA,CAAA;AAAA,EAAA,IAxBGC,eAAe,GAAAH,IAAA,CAAfG,eAAe;IACfC,MAAM,GAAAJ,IAAA,CAANI,MAAM;IACNC,WAAW,GAAAL,IAAA,CAAXK,WAAW;IACXC,KAAK,GAAAN,IAAA,CAALM,KAAK;IACLC,KAAK,GAAAP,IAAA,CAALO,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AW,CAAE,CAAC,CAAA;OAAC,CAAA;AACpG,MAAA,IAAME,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAIF,WAA4B,EAAA;AAAA,QAAA,OAAKf,cAAc,CAACgB,GAAG,CAACD,WAAW,CAAC,CAAE5B,KAAK,CAAA;AAAA,OAAA,CAAA;AAElG,MAAA,OAAOD,KAAK,CAACgC,GAAG,CAACJ,iBAAiB,IAAIG,iBAAiB,CAAC,CAAA;AAC5D,KAAA;AAEA,IAAA,OAAO,EAAE,CAAA;GACZ,CAAA;;AAED;AACA,EAAA,IAAME,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAIC,UAAiB,EAAK;
|
1
|
+
{"version":3,"file":"Textfield.js","sources":["../../../../../../../src/components/Select/ui/Target/ui/Textfield/Textfield.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { sizeToIconSize, getItemId } from '../../../../utils';\nimport { classes } from '../../../../Select.tokens';\n\nimport { IconArrowWrapper, StyledArrow, StyledTextField } from './Textfield.styles';\nimport { TextfieldProps } from './Textfield.types';\n\nexport const Textfield = forwardRef<HTMLInputElement, TextfieldProps>(\n (\n {\n inputWrapperRef,\n opened,\n multiselect,\n value,\n label,\n placeholder,\n onKeyDown,\n labelPlacement,\n size,\n view,\n handleClickArrow,\n contentLeft,\n helperText,\n treeId,\n activeDescendantItemValue,\n disabled,\n isTargetAmount,\n valueToItemMap,\n renderValue,\n onChange,\n labelToItemMap,\n chipView,\n },\n ref,\n ) => {\n const withArrowInverse = opened ? classes.arrowInverse : undefined;\n\n const getChips = (): string[] => {\n if (multiselect && Array.isArray(value)) {\n if (value.length === 0) return [];\n\n if (isTargetAmount) {\n return [`Выбрано ${value.length}`];\n }\n\n const renderValueMapper =\n renderValue && ((stringValue: string | number) => renderValue(valueToItemMap.get(stringValue)!));\n const valueToItemMapper = (stringValue: string | number) => valueToItemMap.get(stringValue)!.label;\n\n return value.map(renderValueMapper || valueToItemMapper);\n }\n\n return [];\n };\n\n // Обработчик чипов\n const handleChipsChange = (chipLabels: any[]) => {\n if (!Array.isArray(value)) return;\n\n // TODO: #1564\n // Из лейблов чипов получаем value у item и далее прокидываем его в onChange.\n if (renderValue && !isTargetAmount) {\n const resultValues = [...value];\n\n value.forEach((_, index) => {\n const labelAfterRenderValue = renderValue(\n labelToItemMap.get(valueToItemMap.get(value[index])!.label)!,\n );\n\n if (!chipLabels.includes(labelAfterRenderValue)) {\n resultValues.splice(index, 1);\n }\n });\n\n onChange(resultValues);\n } else {\n onChange(chipLabels.map((chipLabel) => labelToItemMap.get(chipLabel)!.value));\n }\n };\n\n return (\n <StyledTextField\n ref={ref}\n inputWrapperRef={inputWrapperRef}\n readOnly\n value={multiselect ? undefined : valueToItemMap.get(value.toString())?.label || ''}\n size={size}\n view={view}\n chipView={chipView}\n labelPlacement={labelPlacement}\n disabled={disabled}\n label={label}\n placeholder={value instanceof Array && value.length ? '' : placeholder}\n contentLeft={contentLeft as React.ReactElement}\n contentRight={\n <IconArrowWrapper disabled={Boolean(disabled)} onClick={handleClickArrow}>\n <StyledArrow color=\"inherit\" size={sizeToIconSize(size)} className={withArrowInverse} />\n </IconArrowWrapper>\n }\n onKeyDown={onKeyDown}\n leftHelper={helperText}\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-controls={`${treeId}_tree_level_1`}\n aria-expanded={opened}\n aria-activedescendant={activeDescendantItemValue ? getItemId(treeId, activeDescendantItemValue) : ''}\n {...(multiselect\n ? {\n enumerationType: 'chip',\n chips: getChips(),\n onChangeChips: handleChipsChange,\n }\n : { enumerationType: 'plain' })}\n onEnterDisabled // Пропс для отключения обработчика Enter внутри Textfield\n opened={opened}\n // TODO: #1547\n _forceChipManipulationWithReadonly\n />\n );\n },\n);\n"],"names":["Textfield","forwardRef","_ref","ref","_valueToItemMap$get","inputWrapperRef","opened","multiselect","value","label","placeholder","onKeyDown","labelPlacement","size","view","handleClickArrow","contentLeft","helperText","treeId","activeDescendantItemValue","disabled","isTargetAmount","valueToItemMap","renderValue","onChange","labelToItemMap","chipView","withArrowInverse","classes","arrowInverse","undefined","getChips","Array","isArray","length","concat","renderValueMapper","stringValue","get","valueToItemMapper","map","handleChipsChange","chipLabels","resultValues","_toConsumableArray","forEach","_","index","labelAfterRenderValue","includes","splice","chipLabel","React","createElement","StyledTextField","_extends","readOnly","toString","contentRight","IconArrowWrapper","Boolean","onClick","StyledArrow","color","sizeToIconSize","className","leftHelper","role","getItemId","enumerationType","chips","onChangeChips","onEnterDisabled","_forceChipManipulationWithReadonly"],"mappings":";;;;;;;;;;;AAQO,IAAMA,SAAS,gBAAGC,gBAAU,CAC/B,UAAAC,IAAA,EAyBIC,GAAG,EACF;AAAA,EAAA,IAAAC,mBAAA,CAAA;AAAA,EAAA,IAxBGC,eAAe,GAAAH,IAAA,CAAfG,eAAe;IACfC,MAAM,GAAAJ,IAAA,CAANI,MAAM;IACNC,WAAW,GAAAL,IAAA,CAAXK,WAAW;IACXC,KAAK,GAAAN,IAAA,CAALM,KAAK;IACLC,KAAK,GAAAP,IAAA,CAALO,KAAK;IACLC,WAAW,GAAAR,IAAA,CAAXQ,WAAW;IACXC,SAAS,GAAAT,IAAA,CAATS,SAAS;IACTC,cAAc,GAAAV,IAAA,CAAdU,cAAc;IACdC,IAAI,GAAAX,IAAA,CAAJW,IAAI;IACJC,IAAI,GAAAZ,IAAA,CAAJY,IAAI;IACJC,gBAAgB,GAAAb,IAAA,CAAhBa,gBAAgB;IAChBC,WAAW,GAAAd,IAAA,CAAXc,WAAW;IACXC,UAAU,GAAAf,IAAA,CAAVe,UAAU;IACVC,MAAM,GAAAhB,IAAA,CAANgB,MAAM;IACNC,yBAAyB,GAAAjB,IAAA,CAAzBiB,yBAAyB;IACzBC,QAAQ,GAAAlB,IAAA,CAARkB,QAAQ;IACRC,cAAc,GAAAnB,IAAA,CAAdmB,cAAc;IACdC,cAAc,GAAApB,IAAA,CAAdoB,cAAc;IACdC,WAAW,GAAArB,IAAA,CAAXqB,WAAW;IACXC,QAAQ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AAA,CACrC,CAAC,CAAA;AAEV,CACJ;;;;"}
|
@@ -12,6 +12,12 @@ var _Textfield = /*#__PURE__*/require("./Textfield.styles");
|
|
12
12
|
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); }
|
13
13
|
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; }
|
14
14
|
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); }
|
15
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
16
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
17
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
18
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
19
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
20
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
15
21
|
var Textfield = exports.Textfield = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
16
22
|
var _valueToItemMap$get;
|
17
23
|
var inputWrapperRef = _ref.inputWrapperRef,
|
@@ -56,9 +62,24 @@ var Textfield = exports.Textfield = /*#__PURE__*/(0, _react.forwardRef)(function
|
|
56
62
|
|
57
63
|
// Обработчик чипов
|
58
64
|
var handleChipsChange = function handleChipsChange(chipLabels) {
|
59
|
-
|
60
|
-
|
61
|
-
|
65
|
+
if (!Array.isArray(value)) return;
|
66
|
+
|
67
|
+
// TODO: #1564
|
68
|
+
// Из лейблов чипов получаем value у item и далее прокидываем его в onChange.
|
69
|
+
if (renderValue && !isTargetAmount) {
|
70
|
+
var resultValues = _toConsumableArray(value);
|
71
|
+
value.forEach(function (_, index) {
|
72
|
+
var labelAfterRenderValue = renderValue(labelToItemMap.get(valueToItemMap.get(value[index]).label));
|
73
|
+
if (!chipLabels.includes(labelAfterRenderValue)) {
|
74
|
+
resultValues.splice(index, 1);
|
75
|
+
}
|
76
|
+
});
|
77
|
+
onChange(resultValues);
|
78
|
+
} else {
|
79
|
+
onChange(chipLabels.map(function (chipLabel) {
|
80
|
+
return labelToItemMap.get(chipLabel).value;
|
81
|
+
}));
|
82
|
+
}
|
62
83
|
};
|
63
84
|
return /*#__PURE__*/_react["default"].createElement(_Textfield.StyledTextField, _extends({
|
64
85
|
ref: ref,
|
@@ -1,4 +1,10 @@
|
|
1
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
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
4
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
6
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
2
8
|
import React, { forwardRef } from 'react';
|
3
9
|
import { sizeToIconSize, getItemId } from '../../../../utils';
|
4
10
|
import { classes } from '../../../../Select.tokens';
|
@@ -47,9 +53,24 @@ export var Textfield = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
47
53
|
|
48
54
|
// Обработчик чипов
|
49
55
|
var handleChipsChange = function handleChipsChange(chipLabels) {
|
50
|
-
|
51
|
-
|
52
|
-
|
56
|
+
if (!Array.isArray(value)) return;
|
57
|
+
|
58
|
+
// TODO: #1564
|
59
|
+
// Из лейблов чипов получаем value у item и далее прокидываем его в onChange.
|
60
|
+
if (renderValue && !isTargetAmount) {
|
61
|
+
var resultValues = _toConsumableArray(value);
|
62
|
+
value.forEach(function (_, index) {
|
63
|
+
var labelAfterRenderValue = renderValue(labelToItemMap.get(valueToItemMap.get(value[index]).label));
|
64
|
+
if (!chipLabels.includes(labelAfterRenderValue)) {
|
65
|
+
resultValues.splice(index, 1);
|
66
|
+
}
|
67
|
+
});
|
68
|
+
onChange(resultValues);
|
69
|
+
} else {
|
70
|
+
onChange(chipLabels.map(function (chipLabel) {
|
71
|
+
return labelToItemMap.get(chipLabel).value;
|
72
|
+
}));
|
73
|
+
}
|
53
74
|
};
|
54
75
|
return /*#__PURE__*/React.createElement(StyledTextField, _extends({
|
55
76
|
ref: ref,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { extends as _extends } from '../../../../../../_virtual/_rollupPluginBabelHelpers.js';
|
1
|
+
import { extends as _extends, toConsumableArray as _toConsumableArray } from '../../../../../../_virtual/_rollupPluginBabelHelpers.js';
|
2
2
|
import React, { forwardRef } from 'react';
|
3
3
|
import { classes } from '../../../../Select.tokens.js';
|
4
4
|
import { StyledTextField, IconArrowWrapper, StyledArrow } from './Textfield.styles.js';
|
@@ -49,9 +49,24 @@ var Textfield = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
49
49
|
|
50
50
|
// Обработчик чипов
|
51
51
|
var handleChipsChange = function handleChipsChange(chipLabels) {
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
if (!Array.isArray(value)) return;
|
53
|
+
|
54
|
+
// TODO: #1564
|
55
|
+
// Из лейблов чипов получаем value у item и далее прокидываем его в onChange.
|
56
|
+
if (renderValue && !isTargetAmount) {
|
57
|
+
var resultValues = _toConsumableArray(value);
|
58
|
+
value.forEach(function (_, index) {
|
59
|
+
var labelAfterRenderValue = renderValue(labelToItemMap.get(valueToItemMap.get(value[index]).label));
|
60
|
+
if (!chipLabels.includes(labelAfterRenderValue)) {
|
61
|
+
resultValues.splice(index, 1);
|
62
|
+
}
|
63
|
+
});
|
64
|
+
onChange(resultValues);
|
65
|
+
} else {
|
66
|
+
onChange(chipLabels.map(function (chipLabel) {
|
67
|
+
return labelToItemMap.get(chipLabel).value;
|
68
|
+
}));
|
69
|
+
}
|
55
70
|
};
|
56
71
|
return /*#__PURE__*/React.createElement(StyledTextField, _extends({
|
57
72
|
ref: ref,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Textfield.js","sources":["../../../../../../../src/components/Select/ui/Target/ui/Textfield/Textfield.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { sizeToIconSize, getItemId } from '../../../../utils';\nimport { classes } from '../../../../Select.tokens';\n\nimport { IconArrowWrapper, StyledArrow, StyledTextField } from './Textfield.styles';\nimport { TextfieldProps } from './Textfield.types';\n\nexport const Textfield = forwardRef<HTMLInputElement, TextfieldProps>(\n (\n {\n inputWrapperRef,\n opened,\n multiselect,\n value,\n label,\n placeholder,\n onKeyDown,\n labelPlacement,\n size,\n view,\n handleClickArrow,\n contentLeft,\n helperText,\n treeId,\n activeDescendantItemValue,\n disabled,\n isTargetAmount,\n valueToItemMap,\n renderValue,\n onChange,\n labelToItemMap,\n chipView,\n },\n ref,\n ) => {\n const withArrowInverse = opened ? classes.arrowInverse : undefined;\n\n const getChips = (): string[] => {\n if (multiselect && Array.isArray(value)) {\n if (value.length === 0) return [];\n\n if (isTargetAmount) {\n return [`Выбрано ${value.length}`];\n }\n\n const renderValueMapper =\n renderValue && ((stringValue: string | number) => renderValue(valueToItemMap.get(stringValue)!));\n const valueToItemMapper = (stringValue: string | number) => valueToItemMap.get(stringValue)!.label;\n\n return value.map(renderValueMapper || valueToItemMapper);\n }\n\n return [];\n };\n\n // Обработчик чипов\n const handleChipsChange = (chipLabels: any[]) => {\n onChange(chipLabels.map((chipLabel) => labelToItemMap.get(chipLabel)!.value));\n };\n\n return (\n <StyledTextField\n ref={ref}\n inputWrapperRef={inputWrapperRef}\n readOnly\n value={multiselect ? undefined : valueToItemMap.get(value.toString())?.label || ''}\n size={size}\n view={view}\n chipView={chipView}\n labelPlacement={labelPlacement}\n disabled={disabled}\n label={label}\n placeholder={value instanceof Array && value.length ? '' : placeholder}\n contentLeft={contentLeft as React.ReactElement}\n contentRight={\n <IconArrowWrapper disabled={Boolean(disabled)} onClick={handleClickArrow}>\n <StyledArrow color=\"inherit\" size={sizeToIconSize(size)} className={withArrowInverse} />\n </IconArrowWrapper>\n }\n onKeyDown={onKeyDown}\n leftHelper={helperText}\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-controls={`${treeId}_tree_level_1`}\n aria-expanded={opened}\n aria-activedescendant={activeDescendantItemValue ? getItemId(treeId, activeDescendantItemValue) : ''}\n {...(multiselect\n ? {\n enumerationType: 'chip',\n chips: getChips(),\n onChangeChips: handleChipsChange,\n }\n : { enumerationType: 'plain' })}\n onEnterDisabled // Пропс для отключения обработчика Enter внутри Textfield\n opened={opened}\n // TODO: #1547\n _forceChipManipulationWithReadonly\n />\n );\n },\n);\n"],"names":["Textfield","forwardRef","_ref","ref","_valueToItemMap$get","inputWrapperRef","opened","multiselect","value","label","placeholder","onKeyDown","labelPlacement","size","view","handleClickArrow","contentLeft","helperText","treeId","activeDescendantItemValue","disabled","isTargetAmount","valueToItemMap","renderValue","onChange","labelToItemMap","chipView","withArrowInverse","classes","arrowInverse","undefined","getChips","Array","isArray","length","concat","renderValueMapper","stringValue","get","valueToItemMapper","map","handleChipsChange","chipLabels","chipLabel","React","createElement","StyledTextField","_extends","readOnly","toString","contentRight","IconArrowWrapper","Boolean","onClick","StyledArrow","color","sizeToIconSize","className","leftHelper","role","getItemId","enumerationType","chips","onChangeChips","onEnterDisabled","_forceChipManipulationWithReadonly"],"mappings":";;;;;;;AAQO,IAAMA,SAAS,gBAAGC,UAAU,CAC/B,UAAAC,IAAA,EAyBIC,GAAG,EACF;AAAA,EAAA,IAAAC,mBAAA,CAAA;AAAA,EAAA,IAxBGC,eAAe,GAAAH,IAAA,CAAfG,eAAe;IACfC,MAAM,GAAAJ,IAAA,CAANI,MAAM;IACNC,WAAW,GAAAL,IAAA,CAAXK,WAAW;IACXC,KAAK,GAAAN,IAA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AKd,WAAW,CAACD,cAAc,CAACgB,GAAG,CAACD,WAAW,CAAE,CAAC,CAAA;OAAC,CAAA;AACpG,MAAA,IAAME,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAIF,WAA4B,EAAA;AAAA,QAAA,OAAKf,cAAc,CAACgB,GAAG,CAACD,WAAW,CAAC,CAAE5B,KAAK,CAAA;AAAA,OAAA,CAAA;AAElG,MAAA,OAAOD,KAAK,CAACgC,GAAG,CAACJ,iBAAiB,IAAIG,iBAAiB,CAAC,CAAA;AAC5D,KAAA;AAEA,IAAA,OAAO,EAAE,CAAA;GACZ,CAAA;;AAED;AACA,EAAA,IAAME,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAIC,UAAiB,EAAK;
|
1
|
+
{"version":3,"file":"Textfield.js","sources":["../../../../../../../src/components/Select/ui/Target/ui/Textfield/Textfield.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { sizeToIconSize, getItemId } from '../../../../utils';\nimport { classes } from '../../../../Select.tokens';\n\nimport { IconArrowWrapper, StyledArrow, StyledTextField } from './Textfield.styles';\nimport { TextfieldProps } from './Textfield.types';\n\nexport const Textfield = forwardRef<HTMLInputElement, TextfieldProps>(\n (\n {\n inputWrapperRef,\n opened,\n multiselect,\n value,\n label,\n placeholder,\n onKeyDown,\n labelPlacement,\n size,\n view,\n handleClickArrow,\n contentLeft,\n helperText,\n treeId,\n activeDescendantItemValue,\n disabled,\n isTargetAmount,\n valueToItemMap,\n renderValue,\n onChange,\n labelToItemMap,\n chipView,\n },\n ref,\n ) => {\n const withArrowInverse = opened ? classes.arrowInverse : undefined;\n\n const getChips = (): string[] => {\n if (multiselect && Array.isArray(value)) {\n if (value.length === 0) return [];\n\n if (isTargetAmount) {\n return [`Выбрано ${value.length}`];\n }\n\n const renderValueMapper =\n renderValue && ((stringValue: string | number) => renderValue(valueToItemMap.get(stringValue)!));\n const valueToItemMapper = (stringValue: string | number) => valueToItemMap.get(stringValue)!.label;\n\n return value.map(renderValueMapper || valueToItemMapper);\n }\n\n return [];\n };\n\n // Обработчик чипов\n const handleChipsChange = (chipLabels: any[]) => {\n if (!Array.isArray(value)) return;\n\n // TODO: #1564\n // Из лейблов чипов получаем value у item и далее прокидываем его в onChange.\n if (renderValue && !isTargetAmount) {\n const resultValues = [...value];\n\n value.forEach((_, index) => {\n const labelAfterRenderValue = renderValue(\n labelToItemMap.get(valueToItemMap.get(value[index])!.label)!,\n );\n\n if (!chipLabels.includes(labelAfterRenderValue)) {\n resultValues.splice(index, 1);\n }\n });\n\n onChange(resultValues);\n } else {\n onChange(chipLabels.map((chipLabel) => labelToItemMap.get(chipLabel)!.value));\n }\n };\n\n return (\n <StyledTextField\n ref={ref}\n inputWrapperRef={inputWrapperRef}\n readOnly\n value={multiselect ? undefined : valueToItemMap.get(value.toString())?.label || ''}\n size={size}\n view={view}\n chipView={chipView}\n labelPlacement={labelPlacement}\n disabled={disabled}\n label={label}\n placeholder={value instanceof Array && value.length ? '' : placeholder}\n contentLeft={contentLeft as React.ReactElement}\n contentRight={\n <IconArrowWrapper disabled={Boolean(disabled)} onClick={handleClickArrow}>\n <StyledArrow color=\"inherit\" size={sizeToIconSize(size)} className={withArrowInverse} />\n </IconArrowWrapper>\n }\n onKeyDown={onKeyDown}\n leftHelper={helperText}\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-controls={`${treeId}_tree_level_1`}\n aria-expanded={opened}\n aria-activedescendant={activeDescendantItemValue ? getItemId(treeId, activeDescendantItemValue) : ''}\n {...(multiselect\n ? {\n enumerationType: 'chip',\n chips: getChips(),\n onChangeChips: handleChipsChange,\n }\n : { enumerationType: 'plain' })}\n onEnterDisabled // Пропс для отключения обработчика Enter внутри Textfield\n opened={opened}\n // TODO: #1547\n _forceChipManipulationWithReadonly\n />\n );\n },\n);\n"],"names":["Textfield","forwardRef","_ref","ref","_valueToItemMap$get","inputWrapperRef","opened","multiselect","value","label","placeholder","onKeyDown","labelPlacement","size","view","handleClickArrow","contentLeft","helperText","treeId","activeDescendantItemValue","disabled","isTargetAmount","valueToItemMap","renderValue","onChange","labelToItemMap","chipView","withArrowInverse","classes","arrowInverse","undefined","getChips","Array","isArray","length","concat","renderValueMapper","stringValue","get","valueToItemMapper","map","handleChipsChange","chipLabels","resultValues","_toConsumableArray","forEach","_","index","labelAfterRenderValue","includes","splice","chipLabel","React","createElement","StyledTextField","_extends","readOnly","toString","contentRight","IconArrowWrapper","Boolean","onClick","StyledArrow","color","sizeToIconSize","className","leftHelper","role","getItemId","enumerationType","chips","onChangeChips","onEnterDisabled","_forceChipManipulationWithReadonly"],"mappings":";;;;;;;AAQO,IAAMA,SAAS,gBAAGC,UAAU,CAC/B,UAAAC,IAAA,EAyBIC,GAAG,EACF;AAAA,EAAA,IAAAC,mBAAA,CAAA;AAAA,EAAA,IAxBGC,eAAe,GAAAH,IAAA,CAAfG,eAAe;IACfC,MAAM,GAAAJ,IAAA,CAANI,MAAM;IACNC,WAAW,GAAAL,IAAA,CAAXK,WAAW;IACXC,KAAK,GAAAN,IAAA,CAALM,KAAK;IACLC,KAAK,GAAAP,IAAA,CAALO,KAAK;IACLC,WAAW,GAAAR,IAAA,CAAXQ,WAAW;IACXC,SAAS,GAAAT,IAAA,CAATS,SAAS;IACTC,cAAc,GAAAV,IAAA,CAAdU,cAAc;IACdC,IAAI,GAAAX,IAAA,CAAJW,IAAI;IACJC,IAAI,GAAAZ,IAAA,CAAJY,IAAI;IACJC,gBAAgB,GAAAb,IAAA,CAAhBa,gBAAgB;IAChBC,WAAW,GAAAd,IAAA,CAAXc,WAAW;IACXC,UAAU,GAAAf,IAAA,CAAVe,UAAU;IACVC,MAAM,GAAAhB,IAAA,CAANgB,MAAM;IACNC,yBAAyB,GAAAjB,IAAA,CAAzBiB,yBAAyB;IACzBC,QAAQ,GAAAlB,IAAA,CAARkB,QAAQ;IACRC,cAAc,GAAAnB,IAAA,CAAdmB,cAAc;IACdC,cAAc,GAAApB,IAAA,CAAdoB,cAAc;IACdC,WAAW,G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mE,kCAAkC,EAAA,IAAA;AAAA,GAAA,CACrC,CAAC,CAAA;AAEV,CACJ;;;;"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@salutejs/plasma-new-hope",
|
3
|
-
"version": "0.194.0-canary.1562.
|
3
|
+
"version": "0.194.0-canary.1562.11857238836.0",
|
4
4
|
"description": "Salute Design System blueprint",
|
5
5
|
"main": "cjs/index.js",
|
6
6
|
"module": "es/index.js",
|
@@ -129,5 +129,5 @@
|
|
129
129
|
"sideEffects": [
|
130
130
|
"*.css"
|
131
131
|
],
|
132
|
-
"gitHead": "
|
132
|
+
"gitHead": "ab766838da1cd0dac89f2b4ee0601a7f1cf7a210"
|
133
133
|
}
|
@@ -12,6 +12,12 @@ var _Textfield = /*#__PURE__*/require("./Textfield.styles");
|
|
12
12
|
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); }
|
13
13
|
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; }
|
14
14
|
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); }
|
15
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
16
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
17
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
18
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
19
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
20
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
15
21
|
var Textfield = exports.Textfield = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
16
22
|
var _valueToItemMap$get;
|
17
23
|
var inputWrapperRef = _ref.inputWrapperRef,
|
@@ -56,9 +62,24 @@ var Textfield = exports.Textfield = /*#__PURE__*/(0, _react.forwardRef)(function
|
|
56
62
|
|
57
63
|
// Обработчик чипов
|
58
64
|
var handleChipsChange = function handleChipsChange(chipLabels) {
|
59
|
-
|
60
|
-
|
61
|
-
|
65
|
+
if (!Array.isArray(value)) return;
|
66
|
+
|
67
|
+
// TODO: #1564
|
68
|
+
// Из лейблов чипов получаем value у item и далее прокидываем его в onChange.
|
69
|
+
if (renderValue && !isTargetAmount) {
|
70
|
+
var resultValues = _toConsumableArray(value);
|
71
|
+
value.forEach(function (_, index) {
|
72
|
+
var labelAfterRenderValue = renderValue(labelToItemMap.get(valueToItemMap.get(value[index]).label));
|
73
|
+
if (!chipLabels.includes(labelAfterRenderValue)) {
|
74
|
+
resultValues.splice(index, 1);
|
75
|
+
}
|
76
|
+
});
|
77
|
+
onChange(resultValues);
|
78
|
+
} else {
|
79
|
+
onChange(chipLabels.map(function (chipLabel) {
|
80
|
+
return labelToItemMap.get(chipLabel).value;
|
81
|
+
}));
|
82
|
+
}
|
62
83
|
};
|
63
84
|
return /*#__PURE__*/_react["default"].createElement(_Textfield.StyledTextField, _extends({
|
64
85
|
ref: ref,
|
@@ -1,4 +1,10 @@
|
|
1
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
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
4
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
6
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
2
8
|
import React, { forwardRef } from 'react';
|
3
9
|
import { sizeToIconSize, getItemId } from '../../../../utils';
|
4
10
|
import { classes } from '../../../../Select.tokens';
|
@@ -47,9 +53,24 @@ export var Textfield = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
47
53
|
|
48
54
|
// Обработчик чипов
|
49
55
|
var handleChipsChange = function handleChipsChange(chipLabels) {
|
50
|
-
|
51
|
-
|
52
|
-
|
56
|
+
if (!Array.isArray(value)) return;
|
57
|
+
|
58
|
+
// TODO: #1564
|
59
|
+
// Из лейблов чипов получаем value у item и далее прокидываем его в onChange.
|
60
|
+
if (renderValue && !isTargetAmount) {
|
61
|
+
var resultValues = _toConsumableArray(value);
|
62
|
+
value.forEach(function (_, index) {
|
63
|
+
var labelAfterRenderValue = renderValue(labelToItemMap.get(valueToItemMap.get(value[index]).label));
|
64
|
+
if (!chipLabels.includes(labelAfterRenderValue)) {
|
65
|
+
resultValues.splice(index, 1);
|
66
|
+
}
|
67
|
+
});
|
68
|
+
onChange(resultValues);
|
69
|
+
} else {
|
70
|
+
onChange(chipLabels.map(function (chipLabel) {
|
71
|
+
return labelToItemMap.get(chipLabel).value;
|
72
|
+
}));
|
73
|
+
}
|
53
74
|
};
|
54
75
|
return /*#__PURE__*/React.createElement(StyledTextField, _extends({
|
55
76
|
ref: ref,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Textfield.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/Select/ui/Target/ui/Textfield/Textfield.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAM1C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,eAAO,MAAM,SAAS,
|
1
|
+
{"version":3,"file":"Textfield.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/Select/ui/Target/ui/Textfield/Textfield.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAM1C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,eAAO,MAAM,SAAS,yFAiHrB,CAAC"}
|