@salutejs/plasma-new-hope 0.186.0-canary.1542.11726237853.0 → 0.186.0-canary.1542.11727809479.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,10 +5,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var _rollupPluginBabelHelpers = require('../../../../_virtual/_rollupPluginBabelHelpers.js');
6
6
  var React = require('react');
7
7
  var syntheticEvent = require('./syntheticEvent.js');
8
+ var setRefList = require('../../../../utils/setRefList.js');
8
9
 
9
10
  var _excluded = ["onChange", "name", "defaultValue", "component"],
10
11
  _excluded2 = ["onChange", "name", "defaultValue", "component"];
11
- var SingleForm = function SingleForm(args) {
12
+ var SingleForm = /*#__PURE__*/React.forwardRef(function (args, ref) {
12
13
  var onChange = args.onChange,
13
14
  name = args.name,
14
15
  defaultValue = args.defaultValue,
@@ -27,7 +28,7 @@ var SingleForm = function SingleForm(args) {
27
28
  onChange && onChange(event);
28
29
  }, [value]);
29
30
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("select", {
30
- ref: selectRef,
31
+ ref: setRefList.mergeRefs(selectRef, ref),
31
32
  value: value,
32
33
  name: name,
33
34
  hidden: true
@@ -37,8 +38,8 @@ var SingleForm = function SingleForm(args) {
37
38
  value: value,
38
39
  onChange: handleChange
39
40
  })));
40
- };
41
- var MultipleForm = function MultipleForm(args) {
41
+ });
42
+ var MultipleForm = /*#__PURE__*/React.forwardRef(function (args, ref) {
42
43
  var onChange = args.onChange,
43
44
  name = args.name,
44
45
  defaultValue = args.defaultValue,
@@ -57,7 +58,7 @@ var MultipleForm = function MultipleForm(args) {
57
58
  onChange && onChange(event);
58
59
  }, [values]);
59
60
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("select", {
60
- ref: selectRef,
61
+ ref: setRefList.mergeRefs(selectRef, ref),
61
62
  value: values,
62
63
  name: name,
63
64
  multiple: true,
@@ -71,15 +72,17 @@ var MultipleForm = function MultipleForm(args) {
71
72
  value: values,
72
73
  onChange: handleChange
73
74
  })));
74
- };
75
+ });
75
76
  var getFormComponentGenerator = function getFormComponentGenerator(Component) {
76
- return function (args) {
77
+ return /*#__PURE__*/React.forwardRef(function (args, ref) {
77
78
  return args.multiple ? /*#__PURE__*/React.createElement(MultipleForm, _rollupPluginBabelHelpers.extends({}, args, {
79
+ ref: ref,
78
80
  component: Component
79
81
  })) : /*#__PURE__*/React.createElement(SingleForm, _rollupPluginBabelHelpers.extends({}, args, {
82
+ ref: ref,
80
83
  component: Component
81
84
  }));
82
- };
85
+ });
83
86
  };
84
87
 
85
88
  exports.getFormComponentGenerator = getFormComponentGenerator;
@@ -1 +1 @@
1
- {"version":3,"file":"getForm.js","sources":["../../../../../src/components/Combobox/ComboboxNew/utils/getForm.tsx"],"sourcesContent":["import React, { ComponentType, useEffect, useRef, useState } from 'react';\n\nimport { ComboboxProps, ComboboxFormProps } from '../Combobox.types';\n\nimport { createEvent } from './syntheticEvent';\n\ntype ComboboxWithComponent = ComboboxFormProps & {\n component: ComponentType<ComboboxProps>;\n};\n\nconst SingleForm = (args: ComboboxWithComponent) => {\n const { onChange, name, defaultValue, component: Component, ...rest } = args;\n const [value, setValue] = useState<string | undefined>(String(defaultValue));\n const selectRef = useRef<HTMLSelectElement | null>(null);\n\n const handleChange = (value: string) => {\n setValue(value);\n };\n\n useEffect(() => {\n const event = createEvent(selectRef);\n onChange && onChange(event);\n }, [value]);\n\n return (\n <>\n <select ref={selectRef} value={value} name={name} hidden>\n <option value={value}>{value}</option>\n </select>\n <Component {...(rest as any)} value={value} onChange={handleChange} />\n </>\n );\n};\n\nconst MultipleForm = (args: ComboboxWithComponent) => {\n const { onChange, name, defaultValue, component: Component, ...rest } = args;\n const [values, setValues] = useState<string[]>(defaultValue && Array.isArray(defaultValue) ? defaultValue : []);\n const selectRef = useRef<HTMLSelectElement | null>(null);\n\n const handleChange = (value: string[]) => {\n setValues(value);\n };\n\n useEffect(() => {\n const event = createEvent(selectRef);\n onChange && onChange(event);\n }, [values]);\n\n return (\n <>\n <select ref={selectRef} value={values} name={name} multiple hidden>\n {values.map((value) => (\n <option key={value} value={value}>\n {value}\n </option>\n ))}\n </select>\n <Component {...(rest as any)} value={values} onChange={handleChange} />\n </>\n );\n};\n\nexport const getFormComponentGenerator = (Component: ComponentType<ComboboxProps>) => {\n return (args: ComboboxFormProps) => {\n return args.multiple ? (\n <MultipleForm {...args} component={Component} />\n ) : (\n <SingleForm {...args} component={Component} />\n );\n };\n};\n"],"names":["SingleForm","args","onChange","name","defaultValue","Component","component","rest","_objectWithoutProperties","_excluded","_useState","useState","String","_useState2","_slicedToArray","value","setValue","selectRef","useRef","handleChange","useEffect","event","createEvent","React","createElement","Fragment","ref","hidden","_extends","MultipleForm","_excluded2","_useState3","Array","isArray","_useState4","values","setValues","multiple","map","key","getFormComponentGenerator"],"mappings":";;;;;;;;;;AAUA,IAAMA,UAAU,GAAG,SAAbA,UAAUA,CAAIC,IAA2B,EAAK;AAChD,EAAA,IAAQC,QAAQ,GAAwDD,IAAI,CAApEC,QAAQ;IAAEC,IAAI,GAAkDF,IAAI,CAA1DE,IAAI;IAAEC,YAAY,GAAoCH,IAAI,CAApDG,YAAY;IAAaC,SAAS,GAAcJ,IAAI,CAAtCK,SAAS;AAAgBC,IAAAA,IAAI,GAAAC,iDAAA,CAAKP,IAAI,EAAAQ,SAAA,CAAA,CAAA;EAC5E,IAAAC,SAAA,GAA0BC,cAAQ,CAAqBC,MAAM,CAACR,YAAY,CAAC,CAAC;IAAAS,UAAA,GAAAC,uCAAA,CAAAJ,SAAA,EAAA,CAAA,CAAA;AAArEK,IAAAA,KAAK,GAAAF,UAAA,CAAA,CAAA,CAAA;AAAEG,IAAAA,QAAQ,GAAAH,UAAA,CAAA,CAAA,CAAA,CAAA;AACtB,EAAA,IAAMI,SAAS,GAAGC,YAAM,CAA2B,IAAI,CAAC,CAAA;AAExD,EAAA,IAAMC,YAAY,GAAG,SAAfA,YAAYA,CAAIJ,KAAa,EAAK;IACpCC,QAA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O;AAACjC,IAAAA,QAAQ,EAAEiB,YAAAA;AAAa,GAAA,CAAE,CACxE,CAAC,CAAA;AAEX,CAAC,CAAA;IAEYqB,yBAAyB,GAAG,SAA5BA,yBAAyBA,CAAInC,SAAuC,EAAK;EAClF,OAAO,UAACJ,IAAuB,EAAK;AAChC,IAAA,OAAOA,IAAI,CAACoC,QAAQ,gBAChBd,KAAA,CAAAC,aAAA,CAACK,YAAY,EAAAD,iCAAA,CAAA,EAAA,EAAK3B,IAAI,EAAA;AAAEK,MAAAA,SAAS,EAAED,SAAAA;KAAY,CAAA,CAAC,gBAEhDkB,KAAA,CAAAC,aAAA,CAACxB,UAAU,EAAA4B,iCAAA,CAAA,EAAA,EAAK3B,IAAI,EAAA;AAAEK,MAAAA,SAAS,EAAED,SAAAA;AAAU,KAAA,CAAE,CAChD,CAAA;GACJ,CAAA;AACL;;;;"}
1
+ {"version":3,"file":"getForm.js","sources":["../../../../../src/components/Combobox/ComboboxNew/utils/getForm.tsx"],"sourcesContent":["import React, { ComponentType, forwardRef, useEffect, useRef, useState } from 'react';\n\nimport { ComboboxProps, ComboboxFormProps } from '../Combobox.types';\nimport { mergeRefs } from '../../../../utils';\n\nimport { createEvent } from './syntheticEvent';\n\ntype ComboboxWithComponent = ComboboxFormProps & {\n component: ComponentType<ComboboxProps>;\n};\n\nconst SingleForm = forwardRef<HTMLSelectElement, ComboboxWithComponent>((args, ref) => {\n const { onChange, name, defaultValue, component: Component, ...rest } = args;\n const [value, setValue] = useState<string | undefined>(String(defaultValue));\n const selectRef = useRef<HTMLSelectElement | null>(null);\n\n const handleChange = (value: string) => {\n setValue(value);\n };\n\n useEffect(() => {\n const event = createEvent(selectRef);\n onChange && onChange(event);\n }, [value]);\n\n return (\n <>\n <select ref={mergeRefs(selectRef, ref)} value={value} name={name} hidden>\n <option value={value}>{value}</option>\n </select>\n <Component {...(rest as any)} value={value} onChange={handleChange} />\n </>\n );\n});\n\nconst MultipleForm = forwardRef<HTMLSelectElement, ComboboxWithComponent>((args, ref) => {\n const { onChange, name, defaultValue, component: Component, ...rest } = args;\n const [values, setValues] = useState<string[]>(defaultValue && Array.isArray(defaultValue) ? defaultValue : []);\n const selectRef = useRef<HTMLSelectElement | null>(null);\n\n const handleChange = (value: string[]) => {\n setValues(value);\n };\n\n useEffect(() => {\n const event = createEvent(selectRef);\n onChange && onChange(event);\n }, [values]);\n\n return (\n <>\n <select ref={mergeRefs(selectRef, ref)} value={values} name={name} multiple hidden>\n {values.map((value) => (\n <option key={value} value={value}>\n {value}\n </option>\n ))}\n </select>\n <Component {...(rest as any)} value={values} onChange={handleChange} />\n </>\n );\n});\n\nexport const getFormComponentGenerator = (Component: ComponentType<ComboboxProps>) => {\n return forwardRef<HTMLSelectElement, ComboboxFormProps>((args, ref) => {\n return args.multiple ? (\n <MultipleForm {...args} ref={ref} component={Component} />\n ) : (\n <SingleForm {...args} ref={ref} component={Component} />\n );\n });\n};\n"],"names":["SingleForm","forwardRef","args","ref","onChange","name","defaultValue","Component","component","rest","_objectWithoutProperties","_excluded","_useState","useState","String","_useState2","_slicedToArray","value","setValue","selectRef","useRef","handleChange","useEffect","event","createEvent","React","createElement","Fragment","mergeRefs","hidden","_extends","MultipleForm","_excluded2","_useState3","Array","isArray","_useState4","values","setValues","multiple","map","key","getFormComponentGenerator"],"mappings":";;;;;;;;;;;AAWA,IAAMA,UAAU,gBAAGC,gBAAU,CAA2C,UAACC,IAAI,EAAEC,GAAG,EAAK;AACnF,EAAA,IAAQC,QAAQ,GAAwDF,IAAI,CAApEE,QAAQ;IAAEC,IAAI,GAAkDH,IAAI,CAA1DG,IAAI;IAAEC,YAAY,GAAoCJ,IAAI,CAApDI,YAAY;IAAaC,SAAS,GAAcL,IAAI,CAAtCM,SAAS;AAAgBC,IAAAA,IAAI,GAAAC,iDAAA,CAAKR,IAAI,EAAAS,SAAA,CAAA,CAAA;EAC5E,IAAAC,SAAA,GAA0BC,cAAQ,CAAqBC,MAAM,CAACR,YAAY,CAAC,CAAC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ACkC,QAAQ,EAAA,IAAA;IAACV,MAAM,EAAA,IAAA;AAAA,GAAA,EAC7EQ,MAAM,CAACG,GAAG,CAAC,UAACvB,KAAK,EAAA;IAAA,oBACdQ,KAAA,CAAAC,aAAA,CAAA,QAAA,EAAA;AAAQe,MAAAA,GAAG,EAAExB,KAAM;AAACA,MAAAA,KAAK,EAAEA,KAAAA;AAAM,KAAA,EAC5BA,KACG,CAAC,CAAA;GACZ,CACG,CAAC,eACTQ,KAAA,CAAAC,aAAA,CAACnB,SAAS,EAAAuB,iCAAA,CAAA,EAAA,EAAMrB,IAAI,EAAA;AAAUQ,IAAAA,KAAK,EAAEoB,MAAO;AAACjC,IAAAA,QAAQ,EAAEiB,YAAAA;AAAa,GAAA,CAAE,CACxE,CAAC,CAAA;AAEX,CAAC,CAAC,CAAA;IAEWqB,yBAAyB,GAAG,SAA5BA,yBAAyBA,CAAInC,SAAuC,EAAK;AAClF,EAAA,oBAAON,gBAAU,CAAuC,UAACC,IAAI,EAAEC,GAAG,EAAK;AACnE,IAAA,OAAOD,IAAI,CAACqC,QAAQ,gBAChBd,KAAA,CAAAC,aAAA,CAACK,YAAY,EAAAD,iCAAA,CAAA,EAAA,EAAK5B,IAAI,EAAA;AAAEC,MAAAA,GAAG,EAAEA,GAAI;AAACK,MAAAA,SAAS,EAAED,SAAAA;KAAY,CAAA,CAAC,gBAE1DkB,KAAA,CAAAC,aAAA,CAAC1B,UAAU,EAAA8B,iCAAA,CAAA,EAAA,EAAK5B,IAAI,EAAA;AAAEC,MAAAA,GAAG,EAAEA,GAAI;AAACK,MAAAA,SAAS,EAAED,SAAAA;AAAU,KAAA,CAAE,CAC1D,CAAA;AACL,GAAC,CAAC,CAAA;AACN;;;;"}
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.getFormComponentGenerator = void 0;
8
8
  var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
9
+ var _utils = /*#__PURE__*/require("../../../../utils");
9
10
  var _syntheticEvent = /*#__PURE__*/require("./syntheticEvent");
10
11
  var _excluded = ["onChange", "name", "defaultValue", "component"],
11
12
  _excluded2 = ["onChange", "name", "defaultValue", "component"];
@@ -20,7 +21,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
20
21
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
21
22
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
22
23
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
23
- var SingleForm = function SingleForm(args) {
24
+ var SingleForm = /*#__PURE__*/(0, _react.forwardRef)(function (args, ref) {
24
25
  var onChange = args.onChange,
25
26
  name = args.name,
26
27
  defaultValue = args.defaultValue,
@@ -39,7 +40,7 @@ var SingleForm = function SingleForm(args) {
39
40
  onChange && onChange(event);
40
41
  }, [value]);
41
42
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("select", {
42
- ref: selectRef,
43
+ ref: (0, _utils.mergeRefs)(selectRef, ref),
43
44
  value: value,
44
45
  name: name,
45
46
  hidden: true
@@ -49,8 +50,8 @@ var SingleForm = function SingleForm(args) {
49
50
  value: value,
50
51
  onChange: handleChange
51
52
  })));
52
- };
53
- var MultipleForm = function MultipleForm(args) {
53
+ });
54
+ var MultipleForm = /*#__PURE__*/(0, _react.forwardRef)(function (args, ref) {
54
55
  var onChange = args.onChange,
55
56
  name = args.name,
56
57
  defaultValue = args.defaultValue,
@@ -69,7 +70,7 @@ var MultipleForm = function MultipleForm(args) {
69
70
  onChange && onChange(event);
70
71
  }, [values]);
71
72
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("select", {
72
- ref: selectRef,
73
+ ref: (0, _utils.mergeRefs)(selectRef, ref),
73
74
  value: values,
74
75
  name: name,
75
76
  multiple: true,
@@ -83,13 +84,15 @@ var MultipleForm = function MultipleForm(args) {
83
84
  value: values,
84
85
  onChange: handleChange
85
86
  })));
86
- };
87
+ });
87
88
  var getFormComponentGenerator = exports.getFormComponentGenerator = function getFormComponentGenerator(Component) {
88
- return function (args) {
89
+ return /*#__PURE__*/(0, _react.forwardRef)(function (args, ref) {
89
90
  return args.multiple ? /*#__PURE__*/_react["default"].createElement(MultipleForm, _extends({}, args, {
91
+ ref: ref,
90
92
  component: Component
91
93
  })) : /*#__PURE__*/_react["default"].createElement(SingleForm, _extends({}, args, {
94
+ ref: ref,
92
95
  component: Component
93
96
  }));
94
- };
97
+ });
95
98
  };
@@ -9,9 +9,10 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
9
9
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
10
10
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
11
11
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
12
- import React, { useEffect, useRef, useState } from 'react';
12
+ import React, { forwardRef, useEffect, useRef, useState } from 'react';
13
+ import { mergeRefs } from '../../../../utils';
13
14
  import { createEvent } from './syntheticEvent';
14
- var SingleForm = function SingleForm(args) {
15
+ var SingleForm = /*#__PURE__*/forwardRef(function (args, ref) {
15
16
  var onChange = args.onChange,
16
17
  name = args.name,
17
18
  defaultValue = args.defaultValue,
@@ -30,7 +31,7 @@ var SingleForm = function SingleForm(args) {
30
31
  onChange && onChange(event);
31
32
  }, [value]);
32
33
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("select", {
33
- ref: selectRef,
34
+ ref: mergeRefs(selectRef, ref),
34
35
  value: value,
35
36
  name: name,
36
37
  hidden: true
@@ -40,8 +41,8 @@ var SingleForm = function SingleForm(args) {
40
41
  value: value,
41
42
  onChange: handleChange
42
43
  })));
43
- };
44
- var MultipleForm = function MultipleForm(args) {
44
+ });
45
+ var MultipleForm = /*#__PURE__*/forwardRef(function (args, ref) {
45
46
  var onChange = args.onChange,
46
47
  name = args.name,
47
48
  defaultValue = args.defaultValue,
@@ -60,7 +61,7 @@ var MultipleForm = function MultipleForm(args) {
60
61
  onChange && onChange(event);
61
62
  }, [values]);
62
63
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("select", {
63
- ref: selectRef,
64
+ ref: mergeRefs(selectRef, ref),
64
65
  value: values,
65
66
  name: name,
66
67
  multiple: true,
@@ -74,13 +75,15 @@ var MultipleForm = function MultipleForm(args) {
74
75
  value: values,
75
76
  onChange: handleChange
76
77
  })));
77
- };
78
+ });
78
79
  export var getFormComponentGenerator = function getFormComponentGenerator(Component) {
79
- return function (args) {
80
+ return /*#__PURE__*/forwardRef(function (args, ref) {
80
81
  return args.multiple ? /*#__PURE__*/React.createElement(MultipleForm, _extends({}, args, {
82
+ ref: ref,
81
83
  component: Component
82
84
  })) : /*#__PURE__*/React.createElement(SingleForm, _extends({}, args, {
85
+ ref: ref,
83
86
  component: Component
84
87
  }));
85
- };
88
+ });
86
89
  };
@@ -1,10 +1,11 @@
1
1
  import { extends as _extends, objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray } from '../../../../_virtual/_rollupPluginBabelHelpers.js';
2
- import React, { useState, useRef, useEffect } from 'react';
2
+ import React, { forwardRef, useState, useRef, useEffect } from 'react';
3
3
  import { createEvent } from './syntheticEvent.js';
4
+ import { mergeRefs } from '../../../../utils/setRefList.js';
4
5
 
5
6
  var _excluded = ["onChange", "name", "defaultValue", "component"],
6
7
  _excluded2 = ["onChange", "name", "defaultValue", "component"];
7
- var SingleForm = function SingleForm(args) {
8
+ var SingleForm = /*#__PURE__*/forwardRef(function (args, ref) {
8
9
  var onChange = args.onChange,
9
10
  name = args.name,
10
11
  defaultValue = args.defaultValue,
@@ -23,7 +24,7 @@ var SingleForm = function SingleForm(args) {
23
24
  onChange && onChange(event);
24
25
  }, [value]);
25
26
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("select", {
26
- ref: selectRef,
27
+ ref: mergeRefs(selectRef, ref),
27
28
  value: value,
28
29
  name: name,
29
30
  hidden: true
@@ -33,8 +34,8 @@ var SingleForm = function SingleForm(args) {
33
34
  value: value,
34
35
  onChange: handleChange
35
36
  })));
36
- };
37
- var MultipleForm = function MultipleForm(args) {
37
+ });
38
+ var MultipleForm = /*#__PURE__*/forwardRef(function (args, ref) {
38
39
  var onChange = args.onChange,
39
40
  name = args.name,
40
41
  defaultValue = args.defaultValue,
@@ -53,7 +54,7 @@ var MultipleForm = function MultipleForm(args) {
53
54
  onChange && onChange(event);
54
55
  }, [values]);
55
56
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("select", {
56
- ref: selectRef,
57
+ ref: mergeRefs(selectRef, ref),
57
58
  value: values,
58
59
  name: name,
59
60
  multiple: true,
@@ -67,15 +68,17 @@ var MultipleForm = function MultipleForm(args) {
67
68
  value: values,
68
69
  onChange: handleChange
69
70
  })));
70
- };
71
+ });
71
72
  var getFormComponentGenerator = function getFormComponentGenerator(Component) {
72
- return function (args) {
73
+ return /*#__PURE__*/forwardRef(function (args, ref) {
73
74
  return args.multiple ? /*#__PURE__*/React.createElement(MultipleForm, _extends({}, args, {
75
+ ref: ref,
74
76
  component: Component
75
77
  })) : /*#__PURE__*/React.createElement(SingleForm, _extends({}, args, {
78
+ ref: ref,
76
79
  component: Component
77
80
  }));
78
- };
81
+ });
79
82
  };
80
83
 
81
84
  export { getFormComponentGenerator };
@@ -1 +1 @@
1
- {"version":3,"file":"getForm.js","sources":["../../../../../src/components/Combobox/ComboboxNew/utils/getForm.tsx"],"sourcesContent":["import React, { ComponentType, useEffect, useRef, useState } from 'react';\n\nimport { ComboboxProps, ComboboxFormProps } from '../Combobox.types';\n\nimport { createEvent } from './syntheticEvent';\n\ntype ComboboxWithComponent = ComboboxFormProps & {\n component: ComponentType<ComboboxProps>;\n};\n\nconst SingleForm = (args: ComboboxWithComponent) => {\n const { onChange, name, defaultValue, component: Component, ...rest } = args;\n const [value, setValue] = useState<string | undefined>(String(defaultValue));\n const selectRef = useRef<HTMLSelectElement | null>(null);\n\n const handleChange = (value: string) => {\n setValue(value);\n };\n\n useEffect(() => {\n const event = createEvent(selectRef);\n onChange && onChange(event);\n }, [value]);\n\n return (\n <>\n <select ref={selectRef} value={value} name={name} hidden>\n <option value={value}>{value}</option>\n </select>\n <Component {...(rest as any)} value={value} onChange={handleChange} />\n </>\n );\n};\n\nconst MultipleForm = (args: ComboboxWithComponent) => {\n const { onChange, name, defaultValue, component: Component, ...rest } = args;\n const [values, setValues] = useState<string[]>(defaultValue && Array.isArray(defaultValue) ? defaultValue : []);\n const selectRef = useRef<HTMLSelectElement | null>(null);\n\n const handleChange = (value: string[]) => {\n setValues(value);\n };\n\n useEffect(() => {\n const event = createEvent(selectRef);\n onChange && onChange(event);\n }, [values]);\n\n return (\n <>\n <select ref={selectRef} value={values} name={name} multiple hidden>\n {values.map((value) => (\n <option key={value} value={value}>\n {value}\n </option>\n ))}\n </select>\n <Component {...(rest as any)} value={values} onChange={handleChange} />\n </>\n );\n};\n\nexport const getFormComponentGenerator = (Component: ComponentType<ComboboxProps>) => {\n return (args: ComboboxFormProps) => {\n return args.multiple ? (\n <MultipleForm {...args} component={Component} />\n ) : (\n <SingleForm {...args} component={Component} />\n );\n };\n};\n"],"names":["SingleForm","args","onChange","name","defaultValue","Component","component","rest","_objectWithoutProperties","_excluded","_useState","useState","String","_useState2","_slicedToArray","value","setValue","selectRef","useRef","handleChange","useEffect","event","createEvent","React","createElement","Fragment","ref","hidden","_extends","MultipleForm","_excluded2","_useState3","Array","isArray","_useState4","values","setValues","multiple","map","key","getFormComponentGenerator"],"mappings":";;;;;;AAUA,IAAMA,UAAU,GAAG,SAAbA,UAAUA,CAAIC,IAA2B,EAAK;AAChD,EAAA,IAAQC,QAAQ,GAAwDD,IAAI,CAApEC,QAAQ;IAAEC,IAAI,GAAkDF,IAAI,CAA1DE,IAAI;IAAEC,YAAY,GAAoCH,IAAI,CAApDG,YAAY;IAAaC,SAAS,GAAcJ,IAAI,CAAtCK,SAAS;AAAgBC,IAAAA,IAAI,GAAAC,wBAAA,CAAKP,IAAI,EAAAQ,SAAA,CAAA,CAAA;EAC5E,IAAAC,SAAA,GAA0BC,QAAQ,CAAqBC,MAAM,CAACR,YAAY,CAAC,CAAC;IAAAS,UAAA,GAAAC,cAAA,CAAAJ,SAAA,EAAA,CAAA,CAAA;AAArEK,IAAAA,KAAK,GAAAF,UAAA,CAAA,CAAA,CAAA;AAAEG,IAAAA,QAAQ,GAAAH,UAAA,CAAA,CAAA,CAAA,CAAA;AACtB,EAAA,IAAMI,SAAS,GAAGC,MAAM,CAA2B,IAAI,CAAC,CAAA;AAExD,EAAA,IAAMC,YAAY,GAAG,SAAfA,YAAYA,CAAIJ,KAAa,EAAK;IACpCC,QAAQ,CAACD,KAAK,CAAC,CAAA;GAClB,CAAA;AAEDK,EAAAA,S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E,CAAC,CAAA;AAEX,CAAC,CAAA;IAEYqB,yBAAyB,GAAG,SAA5BA,yBAAyBA,CAAInC,SAAuC,EAAK;EAClF,OAAO,UAACJ,IAAuB,EAAK;AAChC,IAAA,OAAOA,IAAI,CAACoC,QAAQ,gBAChBd,KAAA,CAAAC,aAAA,CAACK,YAAY,EAAAD,QAAA,CAAA,EAAA,EAAK3B,IAAI,EAAA;AAAEK,MAAAA,SAAS,EAAED,SAAAA;KAAY,CAAA,CAAC,gBAEhDkB,KAAA,CAAAC,aAAA,CAACxB,UAAU,EAAA4B,QAAA,CAAA,EAAA,EAAK3B,IAAI,EAAA;AAAEK,MAAAA,SAAS,EAAED,SAAAA;AAAU,KAAA,CAAE,CAChD,CAAA;GACJ,CAAA;AACL;;;;"}
1
+ {"version":3,"file":"getForm.js","sources":["../../../../../src/components/Combobox/ComboboxNew/utils/getForm.tsx"],"sourcesContent":["import React, { ComponentType, forwardRef, useEffect, useRef, useState } from 'react';\n\nimport { ComboboxProps, ComboboxFormProps } from '../Combobox.types';\nimport { mergeRefs } from '../../../../utils';\n\nimport { createEvent } from './syntheticEvent';\n\ntype ComboboxWithComponent = ComboboxFormProps & {\n component: ComponentType<ComboboxProps>;\n};\n\nconst SingleForm = forwardRef<HTMLSelectElement, ComboboxWithComponent>((args, ref) => {\n const { onChange, name, defaultValue, component: Component, ...rest } = args;\n const [value, setValue] = useState<string | undefined>(String(defaultValue));\n const selectRef = useRef<HTMLSelectElement | null>(null);\n\n const handleChange = (value: string) => {\n setValue(value);\n };\n\n useEffect(() => {\n const event = createEvent(selectRef);\n onChange && onChange(event);\n }, [value]);\n\n return (\n <>\n <select ref={mergeRefs(selectRef, ref)} value={value} name={name} hidden>\n <option value={value}>{value}</option>\n </select>\n <Component {...(rest as any)} value={value} onChange={handleChange} />\n </>\n );\n});\n\nconst MultipleForm = forwardRef<HTMLSelectElement, ComboboxWithComponent>((args, ref) => {\n const { onChange, name, defaultValue, component: Component, ...rest } = args;\n const [values, setValues] = useState<string[]>(defaultValue && Array.isArray(defaultValue) ? defaultValue : []);\n const selectRef = useRef<HTMLSelectElement | null>(null);\n\n const handleChange = (value: string[]) => {\n setValues(value);\n };\n\n useEffect(() => {\n const event = createEvent(selectRef);\n onChange && onChange(event);\n }, [values]);\n\n return (\n <>\n <select ref={mergeRefs(selectRef, ref)} value={values} name={name} multiple hidden>\n {values.map((value) => (\n <option key={value} value={value}>\n {value}\n </option>\n ))}\n </select>\n <Component {...(rest as any)} value={values} onChange={handleChange} />\n </>\n );\n});\n\nexport const getFormComponentGenerator = (Component: ComponentType<ComboboxProps>) => {\n return forwardRef<HTMLSelectElement, ComboboxFormProps>((args, ref) => {\n return args.multiple ? (\n <MultipleForm {...args} ref={ref} component={Component} />\n ) : (\n <SingleForm {...args} ref={ref} component={Component} />\n );\n });\n};\n"],"names":["SingleForm","forwardRef","args","ref","onChange","name","defaultValue","Component","component","rest","_objectWithoutProperties","_excluded","_useState","useState","String","_useState2","_slicedToArray","value","setValue","selectRef","useRef","handleChange","useEffect","event","createEvent","React","createElement","Fragment","mergeRefs","hidden","_extends","MultipleForm","_excluded2","_useState3","Array","isArray","_useState4","values","setValues","multiple","map","key","getFormComponentGenerator"],"mappings":";;;;;;;AAWA,IAAMA,UAAU,gBAAGC,UAAU,CAA2C,UAACC,IAAI,EAAEC,GAAG,EAAK;AACnF,EAAA,IAAQC,QAAQ,GAAwDF,IAAI,CAApEE,QAAQ;IAAEC,IAAI,GAAkDH,IAAI,CAA1DG,IAAI;IAAEC,YAAY,GAAoCJ,IAAI,CAApDI,YAAY;IAAaC,SAAS,GAAcL,IAAI,CAAtCM,SAAS;AAAgBC,IAAAA,IAAI,GAAAC,wBAAA,CAAKR,IAAI,EAAAS,SAAA,CAAA,CAAA;EAC5E,IAAAC,SAAA,GAA0BC,QAAQ,CAAqBC,MAAM,CAACR,YAAY,CAAC,CAAC;IAAAS,UAAA,GAAAC,cAAA,CAAAJ,SAAA,EAAA,CAAA,CAAA;AAArEK,IA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G,GAAG,CAAC,UAACvB,KAAK,EAAA;IAAA,oBACdQ,KAAA,CAAAC,aAAA,CAAA,QAAA,EAAA;AAAQe,MAAAA,GAAG,EAAExB,KAAM;AAACA,MAAAA,KAAK,EAAEA,KAAAA;AAAM,KAAA,EAC5BA,KACG,CAAC,CAAA;GACZ,CACG,CAAC,eACTQ,KAAA,CAAAC,aAAA,CAACnB,SAAS,EAAAuB,QAAA,CAAA,EAAA,EAAMrB,IAAI,EAAA;AAAUQ,IAAAA,KAAK,EAAEoB,MAAO;AAACjC,IAAAA,QAAQ,EAAEiB,YAAAA;AAAa,GAAA,CAAE,CACxE,CAAC,CAAA;AAEX,CAAC,CAAC,CAAA;IAEWqB,yBAAyB,GAAG,SAA5BA,yBAAyBA,CAAInC,SAAuC,EAAK;AAClF,EAAA,oBAAON,UAAU,CAAuC,UAACC,IAAI,EAAEC,GAAG,EAAK;AACnE,IAAA,OAAOD,IAAI,CAACqC,QAAQ,gBAChBd,KAAA,CAAAC,aAAA,CAACK,YAAY,EAAAD,QAAA,CAAA,EAAA,EAAK5B,IAAI,EAAA;AAAEC,MAAAA,GAAG,EAAEA,GAAI;AAACK,MAAAA,SAAS,EAAED,SAAAA;KAAY,CAAA,CAAC,gBAE1DkB,KAAA,CAAAC,aAAA,CAAC1B,UAAU,EAAA8B,QAAA,CAAA,EAAA,EAAK5B,IAAI,EAAA;AAAEC,MAAAA,GAAG,EAAEA,GAAI;AAACK,MAAAA,SAAS,EAAED,SAAAA;AAAU,KAAA,CAAE,CAC1D,CAAA;AACL,GAAC,CAAC,CAAA;AACN;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salutejs/plasma-new-hope",
3
- "version": "0.186.0-canary.1542.11726237853.0",
3
+ "version": "0.186.0-canary.1542.11727809479.0",
4
4
  "description": "Salute Design System blueprint",
5
5
  "main": "cjs/index.js",
6
6
  "module": "es/index.js",
@@ -128,5 +128,5 @@
128
128
  "sideEffects": [
129
129
  "*.css"
130
130
  ],
131
- "gitHead": "49f8f690dcf9719d488c8b7c920c245fb77a9194"
131
+ "gitHead": "5c4545f3624df440cd89a35c507bdd6ba1dbc0db"
132
132
  }
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.getFormComponentGenerator = void 0;
8
8
  var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
9
+ var _utils = /*#__PURE__*/require("../../../../utils");
9
10
  var _syntheticEvent = /*#__PURE__*/require("./syntheticEvent");
10
11
  var _excluded = ["onChange", "name", "defaultValue", "component"],
11
12
  _excluded2 = ["onChange", "name", "defaultValue", "component"];
@@ -20,7 +21,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
20
21
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
21
22
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
22
23
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
23
- var SingleForm = function SingleForm(args) {
24
+ var SingleForm = /*#__PURE__*/(0, _react.forwardRef)(function (args, ref) {
24
25
  var onChange = args.onChange,
25
26
  name = args.name,
26
27
  defaultValue = args.defaultValue,
@@ -39,7 +40,7 @@ var SingleForm = function SingleForm(args) {
39
40
  onChange && onChange(event);
40
41
  }, [value]);
41
42
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("select", {
42
- ref: selectRef,
43
+ ref: (0, _utils.mergeRefs)(selectRef, ref),
43
44
  value: value,
44
45
  name: name,
45
46
  hidden: true
@@ -49,8 +50,8 @@ var SingleForm = function SingleForm(args) {
49
50
  value: value,
50
51
  onChange: handleChange
51
52
  })));
52
- };
53
- var MultipleForm = function MultipleForm(args) {
53
+ });
54
+ var MultipleForm = /*#__PURE__*/(0, _react.forwardRef)(function (args, ref) {
54
55
  var onChange = args.onChange,
55
56
  name = args.name,
56
57
  defaultValue = args.defaultValue,
@@ -69,7 +70,7 @@ var MultipleForm = function MultipleForm(args) {
69
70
  onChange && onChange(event);
70
71
  }, [values]);
71
72
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("select", {
72
- ref: selectRef,
73
+ ref: (0, _utils.mergeRefs)(selectRef, ref),
73
74
  value: values,
74
75
  name: name,
75
76
  multiple: true,
@@ -83,13 +84,15 @@ var MultipleForm = function MultipleForm(args) {
83
84
  value: values,
84
85
  onChange: handleChange
85
86
  })));
86
- };
87
+ });
87
88
  var getFormComponentGenerator = exports.getFormComponentGenerator = function getFormComponentGenerator(Component) {
88
- return function (args) {
89
+ return /*#__PURE__*/(0, _react.forwardRef)(function (args, ref) {
89
90
  return args.multiple ? /*#__PURE__*/_react["default"].createElement(MultipleForm, _extends({}, args, {
91
+ ref: ref,
90
92
  component: Component
91
93
  })) : /*#__PURE__*/_react["default"].createElement(SingleForm, _extends({}, args, {
94
+ ref: ref,
92
95
  component: Component
93
96
  }));
94
- };
97
+ });
95
98
  };
@@ -9,9 +9,10 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
9
9
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
10
10
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
11
11
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
12
- import React, { useEffect, useRef, useState } from 'react';
12
+ import React, { forwardRef, useEffect, useRef, useState } from 'react';
13
+ import { mergeRefs } from '../../../../utils';
13
14
  import { createEvent } from './syntheticEvent';
14
- var SingleForm = function SingleForm(args) {
15
+ var SingleForm = /*#__PURE__*/forwardRef(function (args, ref) {
15
16
  var onChange = args.onChange,
16
17
  name = args.name,
17
18
  defaultValue = args.defaultValue,
@@ -30,7 +31,7 @@ var SingleForm = function SingleForm(args) {
30
31
  onChange && onChange(event);
31
32
  }, [value]);
32
33
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("select", {
33
- ref: selectRef,
34
+ ref: mergeRefs(selectRef, ref),
34
35
  value: value,
35
36
  name: name,
36
37
  hidden: true
@@ -40,8 +41,8 @@ var SingleForm = function SingleForm(args) {
40
41
  value: value,
41
42
  onChange: handleChange
42
43
  })));
43
- };
44
- var MultipleForm = function MultipleForm(args) {
44
+ });
45
+ var MultipleForm = /*#__PURE__*/forwardRef(function (args, ref) {
45
46
  var onChange = args.onChange,
46
47
  name = args.name,
47
48
  defaultValue = args.defaultValue,
@@ -60,7 +61,7 @@ var MultipleForm = function MultipleForm(args) {
60
61
  onChange && onChange(event);
61
62
  }, [values]);
62
63
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("select", {
63
- ref: selectRef,
64
+ ref: mergeRefs(selectRef, ref),
64
65
  value: values,
65
66
  name: name,
66
67
  multiple: true,
@@ -74,13 +75,15 @@ var MultipleForm = function MultipleForm(args) {
74
75
  value: values,
75
76
  onChange: handleChange
76
77
  })));
77
- };
78
+ });
78
79
  export var getFormComponentGenerator = function getFormComponentGenerator(Component) {
79
- return function (args) {
80
+ return /*#__PURE__*/forwardRef(function (args, ref) {
80
81
  return args.multiple ? /*#__PURE__*/React.createElement(MultipleForm, _extends({}, args, {
82
+ ref: ref,
81
83
  component: Component
82
84
  })) : /*#__PURE__*/React.createElement(SingleForm, _extends({}, args, {
85
+ ref: ref,
83
86
  component: Component
84
87
  }));
85
- };
88
+ });
86
89
  };
@@ -1,4 +1,4 @@
1
- import { ComponentType } from 'react';
1
+ import React, { ComponentType } from 'react';
2
2
  import { ComboboxProps, ComboboxFormProps } from '../Combobox.types';
3
- export declare const getFormComponentGenerator: (Component: ComponentType<ComboboxProps>) => (args: ComboboxFormProps) => JSX.Element;
3
+ export declare const getFormComponentGenerator: (Component: ComponentType<ComboboxProps>) => React.ForwardRefExoticComponent<ComboboxFormProps & React.RefAttributes<HTMLSelectElement>>;
4
4
  //# sourceMappingURL=getForm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getForm.d.ts","sourceRoot":"","sources":["../../../../../src/components/Combobox/ComboboxNew/utils/getForm.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAA+B,MAAM,OAAO,CAAC;AAE1E,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AA4DrE,eAAO,MAAM,yBAAyB,cAAe,cAAc,aAAa,CAAC,YAC/D,iBAAiB,gBAOlC,CAAC"}
1
+ {"version":3,"file":"getForm.d.ts","sourceRoot":"","sources":["../../../../../src/components/Combobox/ComboboxNew/utils/getForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAA2C,MAAM,OAAO,CAAC;AAEtF,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AA6DrE,eAAO,MAAM,yBAAyB,cAAe,cAAc,aAAa,CAAC,gGAQhF,CAAC"}