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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. package/cjs/components/Combobox/ComboboxNew/utils/getForm.js +86 -0
  2. package/cjs/components/Combobox/ComboboxNew/utils/getForm.js.map +1 -0
  3. package/cjs/components/Combobox/ComboboxNew/utils/syntheticEvent.js +55 -0
  4. package/cjs/components/Combobox/ComboboxNew/utils/syntheticEvent.js.map +1 -0
  5. package/cjs/index.js +2 -0
  6. package/cjs/index.js.map +1 -1
  7. package/emotion/cjs/components/Combobox/ComboboxNew/index.js +8 -1
  8. package/emotion/cjs/components/Combobox/ComboboxNew/utils/getForm.js +10 -5
  9. package/emotion/cjs/components/Combobox/ComboboxNew/utils/index.js +8 -1
  10. package/emotion/cjs/components/Combobox/index.js +6 -0
  11. package/emotion/cjs/examples/plasma_b2c/components/Combobox/Combobox.js +1 -2
  12. package/emotion/cjs/examples/plasma_b2c/components/Combobox/Combobox.stories.tsx +4 -5
  13. package/emotion/cjs/examples/plasma_web/components/Combobox/Combobox.js +6 -2
  14. package/emotion/cjs/examples/plasma_web/components/Combobox/Combobox.stories.tsx +5 -5
  15. package/emotion/es/components/Combobox/ComboboxNew/index.js +2 -1
  16. package/emotion/es/components/Combobox/ComboboxNew/utils/getForm.js +10 -7
  17. package/emotion/es/components/Combobox/ComboboxNew/utils/index.js +2 -1
  18. package/emotion/es/components/Combobox/index.js +1 -1
  19. package/emotion/es/examples/plasma_b2c/components/Combobox/Combobox.js +1 -2
  20. package/emotion/es/examples/plasma_b2c/components/Combobox/Combobox.stories.tsx +4 -5
  21. package/emotion/es/examples/plasma_web/components/Combobox/Combobox.js +6 -2
  22. package/emotion/es/examples/plasma_web/components/Combobox/Combobox.stories.tsx +5 -5
  23. package/es/components/Combobox/ComboboxNew/utils/getForm.js +82 -0
  24. package/es/components/Combobox/ComboboxNew/utils/getForm.js.map +1 -0
  25. package/es/components/Combobox/ComboboxNew/utils/syntheticEvent.js +50 -0
  26. package/es/components/Combobox/ComboboxNew/utils/syntheticEvent.js.map +1 -0
  27. package/es/index.js +1 -0
  28. package/es/index.js.map +1 -1
  29. package/package.json +2 -2
  30. package/styled-components/cjs/components/Combobox/ComboboxNew/index.js +8 -1
  31. package/styled-components/cjs/components/Combobox/ComboboxNew/utils/getForm.js +10 -5
  32. package/styled-components/cjs/components/Combobox/ComboboxNew/utils/index.js +8 -1
  33. package/styled-components/cjs/components/Combobox/index.js +6 -0
  34. package/styled-components/cjs/examples/plasma_b2c/components/Combobox/Combobox.js +1 -2
  35. package/styled-components/cjs/examples/plasma_b2c/components/Combobox/Combobox.stories.tsx +4 -5
  36. package/styled-components/cjs/examples/plasma_web/components/Combobox/Combobox.js +6 -2
  37. package/styled-components/cjs/examples/plasma_web/components/Combobox/Combobox.stories.tsx +5 -5
  38. package/styled-components/es/components/Combobox/ComboboxNew/index.js +2 -1
  39. package/styled-components/es/components/Combobox/ComboboxNew/utils/getForm.js +10 -7
  40. package/styled-components/es/components/Combobox/ComboboxNew/utils/index.js +2 -1
  41. package/styled-components/es/components/Combobox/index.js +1 -1
  42. package/styled-components/es/examples/plasma_b2c/components/Combobox/Combobox.js +1 -2
  43. package/styled-components/es/examples/plasma_b2c/components/Combobox/Combobox.stories.tsx +4 -5
  44. package/styled-components/es/examples/plasma_web/components/Combobox/Combobox.js +6 -2
  45. package/styled-components/es/examples/plasma_web/components/Combobox/Combobox.stories.tsx +5 -5
  46. package/types/components/Combobox/ComboboxNew/Combobox.types.d.ts +2 -0
  47. package/types/components/Combobox/ComboboxNew/Combobox.types.d.ts.map +1 -1
  48. package/types/components/Combobox/ComboboxNew/index.d.ts +1 -0
  49. package/types/components/Combobox/ComboboxNew/index.d.ts.map +1 -1
  50. package/types/components/Combobox/ComboboxNew/utils/getForm.d.ts +2 -2
  51. package/types/components/Combobox/ComboboxNew/utils/getForm.d.ts.map +1 -1
  52. package/types/components/Combobox/ComboboxNew/utils/index.d.ts +1 -0
  53. package/types/components/Combobox/ComboboxNew/utils/index.d.ts.map +1 -1
  54. package/types/components/Combobox/index.d.ts +1 -1
  55. package/types/components/Combobox/index.d.ts.map +1 -1
  56. package/types/examples/plasma_b2c/components/Combobox/Combobox.d.ts +459 -2
  57. package/types/examples/plasma_b2c/components/Combobox/Combobox.d.ts.map +1 -1
  58. package/types/examples/plasma_web/components/Combobox/Combobox.d.ts +459 -1
  59. package/types/examples/plasma_web/components/Combobox/Combobox.d.ts.map +1 -1
@@ -0,0 +1,86 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _rollupPluginBabelHelpers = require('../../../../_virtual/_rollupPluginBabelHelpers.js');
6
+ var React = require('react');
7
+ var syntheticEvent = require('./syntheticEvent.js');
8
+
9
+ var _excluded = ["onChange", "name", "defaultValue", "component"],
10
+ _excluded2 = ["onChange", "name", "defaultValue", "component"];
11
+ var SingleForm = function SingleForm(args) {
12
+ var onChange = args.onChange,
13
+ name = args.name,
14
+ defaultValue = args.defaultValue,
15
+ Component = args.component,
16
+ rest = _rollupPluginBabelHelpers.objectWithoutProperties(args, _excluded);
17
+ var _useState = React.useState(String(defaultValue)),
18
+ _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
19
+ value = _useState2[0],
20
+ setValue = _useState2[1];
21
+ var selectRef = React.useRef(null);
22
+ var handleChange = function handleChange(value) {
23
+ setValue(value);
24
+ };
25
+ React.useEffect(function () {
26
+ var event = syntheticEvent.createEvent(selectRef);
27
+ onChange && onChange(event);
28
+ }, [value]);
29
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("select", {
30
+ ref: selectRef,
31
+ value: value,
32
+ name: name,
33
+ hidden: true
34
+ }, /*#__PURE__*/React.createElement("option", {
35
+ value: value
36
+ }, value)), /*#__PURE__*/React.createElement(Component, _rollupPluginBabelHelpers.extends({}, rest, {
37
+ value: value,
38
+ onChange: handleChange
39
+ })));
40
+ };
41
+ var MultipleForm = function MultipleForm(args) {
42
+ var onChange = args.onChange,
43
+ name = args.name,
44
+ defaultValue = args.defaultValue,
45
+ Component = args.component,
46
+ rest = _rollupPluginBabelHelpers.objectWithoutProperties(args, _excluded2);
47
+ var _useState3 = React.useState(defaultValue && Array.isArray(defaultValue) ? defaultValue : []),
48
+ _useState4 = _rollupPluginBabelHelpers.slicedToArray(_useState3, 2),
49
+ values = _useState4[0],
50
+ setValues = _useState4[1];
51
+ var selectRef = React.useRef(null);
52
+ var handleChange = function handleChange(value) {
53
+ setValues(value);
54
+ };
55
+ React.useEffect(function () {
56
+ var event = syntheticEvent.createEvent(selectRef);
57
+ onChange && onChange(event);
58
+ }, [values]);
59
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("select", {
60
+ ref: selectRef,
61
+ value: values,
62
+ name: name,
63
+ multiple: true,
64
+ hidden: true
65
+ }, values.map(function (value) {
66
+ return /*#__PURE__*/React.createElement("option", {
67
+ key: value,
68
+ value: value
69
+ }, value);
70
+ })), /*#__PURE__*/React.createElement(Component, _rollupPluginBabelHelpers.extends({}, rest, {
71
+ value: values,
72
+ onChange: handleChange
73
+ })));
74
+ };
75
+ var getFormComponentGenerator = function getFormComponentGenerator(Component) {
76
+ return function (args) {
77
+ return args.multiple ? /*#__PURE__*/React.createElement(MultipleForm, _rollupPluginBabelHelpers.extends({}, args, {
78
+ component: Component
79
+ })) : /*#__PURE__*/React.createElement(SingleForm, _rollupPluginBabelHelpers.extends({}, args, {
80
+ component: Component
81
+ }));
82
+ };
83
+ };
84
+
85
+ exports.getFormComponentGenerator = getFormComponentGenerator;
86
+ //# sourceMappingURL=getForm.js.map
@@ -0,0 +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,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
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var createEvent = function createEvent(ref) {
6
+ if (ref.current) {
7
+ var event = new Event('change', {
8
+ bubbles: true
9
+ });
10
+ Object.defineProperty(event, 'target', {
11
+ writable: false,
12
+ value: ref.current
13
+ });
14
+ var syntheticEvent = createSyntheticEvent(event);
15
+ return syntheticEvent;
16
+ }
17
+ return null;
18
+ };
19
+ var createSyntheticEvent = function createSyntheticEvent(event) {
20
+ var _isDefaultPrevented = false;
21
+ var _isPropagationStopped = false;
22
+ var preventDefault = function preventDefault() {
23
+ _isDefaultPrevented = true;
24
+ event.preventDefault();
25
+ };
26
+ var stopPropagation = function stopPropagation() {
27
+ _isPropagationStopped = true;
28
+ event.stopPropagation();
29
+ };
30
+ return {
31
+ nativeEvent: event,
32
+ currentTarget: event.currentTarget,
33
+ target: event.target,
34
+ bubbles: event.bubbles,
35
+ cancelable: event.cancelable,
36
+ defaultPrevented: event.defaultPrevented,
37
+ eventPhase: event.eventPhase,
38
+ isTrusted: event.isTrusted,
39
+ preventDefault: preventDefault,
40
+ isDefaultPrevented: function isDefaultPrevented() {
41
+ return _isDefaultPrevented;
42
+ },
43
+ stopPropagation: stopPropagation,
44
+ isPropagationStopped: function isPropagationStopped() {
45
+ return _isPropagationStopped;
46
+ },
47
+ persist: function persist() {},
48
+ timeStamp: event.timeStamp,
49
+ type: event.type
50
+ };
51
+ };
52
+
53
+ exports.createEvent = createEvent;
54
+ exports.createSyntheticEvent = createSyntheticEvent;
55
+ //# sourceMappingURL=syntheticEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syntheticEvent.js","sources":["../../../../../src/components/Combobox/ComboboxNew/utils/syntheticEvent.ts"],"sourcesContent":["import { RefObject } from 'react';\n\nexport const createEvent = (ref: RefObject<HTMLSelectElement>) => {\n if (ref.current) {\n const event = new Event('change', { bubbles: true });\n Object.defineProperty(event, 'target', { writable: false, value: ref.current });\n const syntheticEvent = createSyntheticEvent(event) as React.ChangeEvent<typeof ref.current>;\n return syntheticEvent;\n }\n\n return null;\n};\n\nexport const createSyntheticEvent = <T extends Element, E extends Event>(event: E): React.SyntheticEvent<T, E> => {\n let isDefaultPrevented = false;\n let isPropagationStopped = false;\n const preventDefault = () => {\n isDefaultPrevented = true;\n event.preventDefault();\n };\n const stopPropagation = () => {\n isPropagationStopped = true;\n event.stopPropagation();\n };\n return {\n nativeEvent: event,\n currentTarget: event.currentTarget as EventTarget & T,\n target: event.target as EventTarget & T,\n bubbles: event.bubbles,\n cancelable: event.cancelable,\n defaultPrevented: event.defaultPrevented,\n eventPhase: event.eventPhase,\n isTrusted: event.isTrusted,\n preventDefault,\n isDefaultPrevented: () => isDefaultPrevented,\n stopPropagation,\n isPropagationStopped: () => isPropagationStopped,\n persist: () => {},\n timeStamp: event.timeStamp,\n type: event.type,\n };\n};\n"],"names":["createEvent","ref","current","event","Event","bubbles","Object","defineProperty","writable","value","syntheticEvent","createSyntheticEvent","isDefaultPrevented","isPropagationStopped","preventDefault","stopPropagation","nativeEvent","currentTarget","target","cancelable","defaultPrevented","eventPhase","isTrusted","persist","timeStamp","type"],"mappings":";;;;IAEaA,WAAW,GAAG,SAAdA,WAAWA,CAAIC,GAAiC,EAAK;EAC9D,IAAIA,GAAG,CAACC,OAAO,EAAE;AACb,IAAA,IAAMC,KAAK,GAAG,IAAIC,KAAK,CAAC,QAAQ,EAAE;AAAEC,MAAAA,OAAO,EAAE,IAAA;AAAK,KAAC,CAAC,CAAA;AACpDC,IAAAA,MAAM,CAACC,cAAc,CAACJ,KAAK,EAAE,QAAQ,EAAE;AAAEK,MAAAA,QAAQ,EAAE,KAAK;MAAEC,KAAK,EAAER,GAAG,CAACC,OAAAA;AAAQ,KAAC,CAAC,CAAA;AAC/E,IAAA,IAAMQ,cAAc,GAAGC,oBAAoB,CAACR,KAAK,CAA0C,CAAA;AAC3F,IAAA,OAAOO,cAAc,CAAA;AACzB,GAAA;AAEA,EAAA,OAAO,IAAI,CAAA;AACf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ox/ComboboxOld/Combobox.tokens
163
163
  var Combobox_tokens$1 = require('./components/Combobox/ComboboxNew/Combobox.tokens.js');
164
164
  var Combobox$1 = require('./components/Combobox/ComboboxNew/Combobox.js');
165
165
  var Combobox_boundler = require('./components/Combobox/ComboboxNew/Combobox.boundler.js');
166
+ var getForm = require('./components/Combobox/ComboboxNew/utils/getForm.js');
166
167
  var Indicator = require('./components/Indicator/Indicator.js');
167
168
  var Indicator_tokens = require('./components/Indicator/Indicator.tokens.js');
168
169
  var Grid = require('./components/Grid/Grid.js');
@@ -533,6 +534,7 @@ exports.comboboxNewTokens = Combobox_tokens$1.tokens;
533
534
  exports.comboboxNewConfig = Combobox$1.comboboxConfig;
534
535
  exports.comboboxNewRoot = Combobox$1.comboboxRoot;
535
536
  exports.boundCombobox = Combobox_boundler.boundCombobox;
537
+ exports.getFormComponentGenerator = getForm.getFormComponentGenerator;
536
538
  exports.indicatorConfig = Indicator.indicatorConfig;
537
539
  exports.indicatorRoot = Indicator.indicatorRoot;
538
540
  exports.indicatorTokens = Indicator_tokens.tokens;
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -27,6 +27,13 @@ Object.defineProperty(exports, "comboboxTokens", {
27
27
  return _Combobox2.tokens;
28
28
  }
29
29
  });
30
+ Object.defineProperty(exports, "getFormComponentGenerator", {
31
+ enumerable: true,
32
+ get: function get() {
33
+ return _utils.getFormComponentGenerator;
34
+ }
35
+ });
30
36
  var _Combobox = /*#__PURE__*/require("./Combobox");
31
37
  var _Combobox2 = /*#__PURE__*/require("./Combobox.tokens");
32
- var _Combobox3 = /*#__PURE__*/require("./Combobox.boundler");
38
+ var _Combobox3 = /*#__PURE__*/require("./Combobox.boundler");
39
+ var _utils = /*#__PURE__*/require("./utils");
@@ -7,9 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.getFormComponentGenerator = void 0;
8
8
  var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
9
9
  var _syntheticEvent = /*#__PURE__*/require("./syntheticEvent");
10
- var _excluded = ["onChange", "component"],
11
- _excluded2 = ["onChange", "component"]; // eslint-disable-next-line @typescript-eslint/ban-ts-comment
12
- // @ts-nocheck
10
+ var _excluded = ["onChange", "name", "defaultValue", "component"],
11
+ _excluded2 = ["onChange", "name", "defaultValue", "component"];
13
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); }
14
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; }
15
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); }
@@ -23,9 +22,11 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
23
22
  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; }
24
23
  var SingleForm = function SingleForm(args) {
25
24
  var onChange = args.onChange,
25
+ name = args.name,
26
+ defaultValue = args.defaultValue,
26
27
  Component = args.component,
27
28
  rest = _objectWithoutProperties(args, _excluded);
28
- var _useState = (0, _react.useState)(),
29
+ var _useState = (0, _react.useState)(String(defaultValue)),
29
30
  _useState2 = _slicedToArray(_useState, 2),
30
31
  value = _useState2[0],
31
32
  setValue = _useState2[1];
@@ -40,6 +41,7 @@ var SingleForm = function SingleForm(args) {
40
41
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("select", {
41
42
  ref: selectRef,
42
43
  value: value,
44
+ name: name,
43
45
  hidden: true
44
46
  }, /*#__PURE__*/_react["default"].createElement("option", {
45
47
  value: value
@@ -50,9 +52,11 @@ var SingleForm = function SingleForm(args) {
50
52
  };
51
53
  var MultipleForm = function MultipleForm(args) {
52
54
  var onChange = args.onChange,
55
+ name = args.name,
56
+ defaultValue = args.defaultValue,
53
57
  Component = args.component,
54
58
  rest = _objectWithoutProperties(args, _excluded2);
55
- var _useState3 = (0, _react.useState)([]),
59
+ var _useState3 = (0, _react.useState)(defaultValue && Array.isArray(defaultValue) ? defaultValue : []),
56
60
  _useState4 = _slicedToArray(_useState3, 2),
57
61
  values = _useState4[0],
58
62
  setValues = _useState4[1];
@@ -67,6 +71,7 @@ var MultipleForm = function MultipleForm(args) {
67
71
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("select", {
68
72
  ref: selectRef,
69
73
  value: values,
74
+ name: name,
70
75
  multiple: true,
71
76
  hidden: true
72
77
  }, values.map(function (value) {
@@ -9,6 +9,12 @@ Object.defineProperty(exports, "filterItems", {
9
9
  return _filterItems.filterItems;
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "getFormComponentGenerator", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _getForm.getFormComponentGenerator;
16
+ }
17
+ });
12
18
  Object.defineProperty(exports, "getInitialValue", {
13
19
  enumerable: true,
14
20
  get: function get() {
@@ -58,4 +64,5 @@ var _updateSingleAncestors = /*#__PURE__*/require("./updateSingleAncestors");
58
64
  var _sizeToIconSize = /*#__PURE__*/require("./sizeToIconSize");
59
65
  var _filterItems = /*#__PURE__*/require("./filterItems");
60
66
  var _getItemId = /*#__PURE__*/require("./getItemId");
61
- var _getInitialValue = /*#__PURE__*/require("./getInitialValue");
67
+ var _getInitialValue = /*#__PURE__*/require("./getInitialValue");
68
+ var _getForm = /*#__PURE__*/require("./getForm");
@@ -117,5 +117,11 @@ Object.defineProperty(exports, "comboboxOldTokens", {
117
117
  return _ComboboxOld.comboboxTokens;
118
118
  }
119
119
  });
120
+ Object.defineProperty(exports, "getFormComponentGenerator", {
121
+ enumerable: true,
122
+ get: function get() {
123
+ return _ComboboxNew.getFormComponentGenerator;
124
+ }
125
+ });
120
126
  var _ComboboxOld = /*#__PURE__*/require("./ComboboxOld");
121
127
  var _ComboboxNew = /*#__PURE__*/require("./ComboboxNew");
@@ -6,12 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.ComboboxWithForm = exports.Combobox = void 0;
7
7
  var _engines = /*#__PURE__*/require("../../../../engines");
8
8
  var _ = /*#__PURE__*/require("../../../..");
9
- var _getForm = /*#__PURE__*/require("../../../../components/Combobox/ComboboxNew/utils/getForm");
10
9
  var _Combobox = /*#__PURE__*/require("./Combobox.config");
11
10
  var mergedConfig = /*#__PURE__*/(0, _engines.mergeConfig)(_.comboboxNewConfig, _Combobox.config);
12
11
  var ComboboxComponent = /*#__PURE__*/(0, _engines.component)(mergedConfig);
13
12
  var Combobox = exports.Combobox = ComboboxComponent;
14
13
  var ComboboxWithForm = exports.ComboboxWithForm = /*#__PURE__*/(0, _.boundCombobox)({
15
14
  base: ComboboxComponent,
16
- baseForm: /*#__PURE__*/(0, _getForm.getFormComponentGenerator)(ComboboxComponent)
15
+ baseForm: /*#__PURE__*/(0, _.getFormComponentGenerator)(ComboboxComponent)
17
16
  });
@@ -1,14 +1,13 @@
1
- import React, { useEffect, useRef, useState } from 'react';
1
+ import React, { useState } from 'react';
2
2
  import type { ComponentProps } from 'react';
3
3
  import type { Meta, StoryObj } from '@storybook/react';
4
4
 
5
5
  import { WithTheme } from '../../../_helpers';
6
6
  import { IconDone } from '../../../../components/_Icon';
7
- import { createEvent } from '../../../../components/Combobox/ComboboxNew/utils/syntheticEvent';
8
7
 
9
- import { Combobox, ComboboxWithForm } from './Combobox';
8
+ import { ComboboxWithForm } from './Combobox';
10
9
 
11
- type StorySelectProps = ComponentProps<typeof Combobox> & {
10
+ type StorySelectProps = ComponentProps<typeof ComboboxWithForm> & {
12
11
  enableContentLeft?: boolean;
13
12
  };
14
13
 
@@ -20,7 +19,7 @@ const variant = ['normal', 'tight'];
20
19
  const meta: Meta<StorySelectProps> = {
21
20
  title: 'plasma_b2c/Combobox',
22
21
  decorators: [WithTheme],
23
- component: Combobox,
22
+ component: ComboboxWithForm,
24
23
  argTypes: {
25
24
  size: {
26
25
  options: size,
@@ -3,10 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Combobox = void 0;
6
+ exports.ComboboxWithForm = exports.Combobox = void 0;
7
7
  var _engines = /*#__PURE__*/require("../../../../engines");
8
8
  var _ = /*#__PURE__*/require("../../../..");
9
9
  var _Combobox = /*#__PURE__*/require("./Combobox.config");
10
10
  var mergedConfig = /*#__PURE__*/(0, _engines.mergeConfig)(_.comboboxNewConfig, _Combobox.config);
11
11
  var ComboboxComponent = /*#__PURE__*/(0, _engines.component)(mergedConfig);
12
- var Combobox = exports.Combobox = ComboboxComponent;
12
+ var Combobox = exports.Combobox = ComboboxComponent;
13
+ var ComboboxWithForm = exports.ComboboxWithForm = /*#__PURE__*/(0, _.boundCombobox)({
14
+ base: ComboboxComponent,
15
+ baseForm: /*#__PURE__*/(0, _.getFormComponentGenerator)(ComboboxComponent)
16
+ });
@@ -5,9 +5,9 @@ import type { Meta, StoryObj } from '@storybook/react';
5
5
  import { WithTheme } from '../../../_helpers';
6
6
  import { IconDone } from '../../../../components/_Icon';
7
7
 
8
- import { Combobox } from './Combobox';
8
+ import { ComboboxWithForm } from './Combobox';
9
9
 
10
- type StorySelectProps = ComponentProps<typeof Combobox> & {
10
+ type StorySelectProps = ComponentProps<typeof ComboboxWithForm> & {
11
11
  enableContentLeft?: boolean;
12
12
  };
13
13
 
@@ -19,7 +19,7 @@ const variant = ['normal', 'tight'];
19
19
  const meta: Meta<StorySelectProps> = {
20
20
  title: 'plasma_web/Combobox',
21
21
  decorators: [WithTheme],
22
- component: Combobox,
22
+ component: ComboboxWithForm,
23
23
  argTypes: {
24
24
  size: {
25
25
  options: size,
@@ -356,7 +356,7 @@ const SingleStory = (args: StorySelectProps) => {
356
356
 
357
357
  return (
358
358
  <div style={{ width: '400px' }}>
359
- <Combobox
359
+ <ComboboxWithForm
360
360
  {...args}
361
361
  items={items}
362
362
  value={value}
@@ -384,7 +384,7 @@ const MultipleStory = (args: StorySelectProps) => {
384
384
 
385
385
  return (
386
386
  <div style={{ width: '400px' }}>
387
- <Combobox
387
+ <ComboboxWithForm
388
388
  {...args}
389
389
  multiple
390
390
  items={items}
@@ -1,3 +1,4 @@
1
1
  export { comboboxConfig, comboboxRoot } from './Combobox';
2
2
  export { tokens as comboboxTokens } from './Combobox.tokens';
3
- export { boundCombobox } from './Combobox.boundler';
3
+ export { boundCombobox } from './Combobox.boundler';
4
+ export { getFormComponentGenerator } from './utils';
@@ -1,5 +1,5 @@
1
- var _excluded = ["onChange", "component"],
2
- _excluded2 = ["onChange", "component"];
1
+ var _excluded = ["onChange", "name", "defaultValue", "component"],
2
+ _excluded2 = ["onChange", "name", "defaultValue", "component"];
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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
5
5
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -9,16 +9,15 @@ 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
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
13
- // @ts-nocheck
14
-
15
12
  import React, { useEffect, useRef, useState } from 'react';
16
13
  import { createEvent } from './syntheticEvent';
17
14
  var SingleForm = function SingleForm(args) {
18
15
  var onChange = args.onChange,
16
+ name = args.name,
17
+ defaultValue = args.defaultValue,
19
18
  Component = args.component,
20
19
  rest = _objectWithoutProperties(args, _excluded);
21
- var _useState = useState(),
20
+ var _useState = useState(String(defaultValue)),
22
21
  _useState2 = _slicedToArray(_useState, 2),
23
22
  value = _useState2[0],
24
23
  setValue = _useState2[1];
@@ -33,6 +32,7 @@ var SingleForm = function SingleForm(args) {
33
32
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("select", {
34
33
  ref: selectRef,
35
34
  value: value,
35
+ name: name,
36
36
  hidden: true
37
37
  }, /*#__PURE__*/React.createElement("option", {
38
38
  value: value
@@ -43,9 +43,11 @@ var SingleForm = function SingleForm(args) {
43
43
  };
44
44
  var MultipleForm = function MultipleForm(args) {
45
45
  var onChange = args.onChange,
46
+ name = args.name,
47
+ defaultValue = args.defaultValue,
46
48
  Component = args.component,
47
49
  rest = _objectWithoutProperties(args, _excluded2);
48
- var _useState3 = useState([]),
50
+ var _useState3 = useState(defaultValue && Array.isArray(defaultValue) ? defaultValue : []),
49
51
  _useState4 = _slicedToArray(_useState3, 2),
50
52
  values = _useState4[0],
51
53
  setValues = _useState4[1];
@@ -60,6 +62,7 @@ var MultipleForm = function MultipleForm(args) {
60
62
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("select", {
61
63
  ref: selectRef,
62
64
  value: values,
65
+ name: name,
63
66
  multiple: true,
64
67
  hidden: true
65
68
  }, values.map(function (value) {
@@ -5,4 +5,5 @@ export { updateSingleAncestors } from './updateSingleAncestors';
5
5
  export { sizeToIconSize } from './sizeToIconSize';
6
6
  export { filterItems } from './filterItems';
7
7
  export { getItemId } from './getItemId';
8
- export { getInitialValue } from './getInitialValue';
8
+ export { getInitialValue } from './getInitialValue';
9
+ export { getFormComponentGenerator } from './getForm';
@@ -1,2 +1,2 @@
1
1
  export { comboboxRoot as comboboxOldRoot, comboboxConfig as comboboxOldConfig, comboboxDividerRoot, comboboxDividerConfig, comboboxFooterRoot, comboboxFooterConfig, comboboxGroupRoot, comboboxGroupConfig, comboboxHeaderRoot, comboboxHeaderConfig, comboboxItemRoot, comboboxItemConfig, ComboboxTarget, comboboxClasses as comboboxOldClasses, comboboxTokens as comboboxOldTokens } from './ComboboxOld';
2
- export { comboboxTokens as comboboxNewTokens, comboboxRoot as comboboxNewRoot, comboboxConfig as comboboxNewConfig, boundCombobox } from './ComboboxNew';
2
+ export { comboboxTokens as comboboxNewTokens, comboboxRoot as comboboxNewRoot, comboboxConfig as comboboxNewConfig, boundCombobox, getFormComponentGenerator } from './ComboboxNew';
@@ -1,6 +1,5 @@
1
1
  import { component, mergeConfig } from '../../../../engines';
2
- import { comboboxNewConfig, boundCombobox } from '../../../..';
3
- import { getFormComponentGenerator } from '../../../../components/Combobox/ComboboxNew/utils/getForm';
2
+ import { comboboxNewConfig, boundCombobox, getFormComponentGenerator } from '../../../..';
4
3
  import { config } from './Combobox.config';
5
4
  var mergedConfig = /*#__PURE__*/mergeConfig(comboboxNewConfig, config);
6
5
  var ComboboxComponent = /*#__PURE__*/component(mergedConfig);
@@ -1,14 +1,13 @@
1
- import React, { useEffect, useRef, useState } from 'react';
1
+ import React, { useState } from 'react';
2
2
  import type { ComponentProps } from 'react';
3
3
  import type { Meta, StoryObj } from '@storybook/react';
4
4
 
5
5
  import { WithTheme } from '../../../_helpers';
6
6
  import { IconDone } from '../../../../components/_Icon';
7
- import { createEvent } from '../../../../components/Combobox/ComboboxNew/utils/syntheticEvent';
8
7
 
9
- import { Combobox, ComboboxWithForm } from './Combobox';
8
+ import { ComboboxWithForm } from './Combobox';
10
9
 
11
- type StorySelectProps = ComponentProps<typeof Combobox> & {
10
+ type StorySelectProps = ComponentProps<typeof ComboboxWithForm> & {
12
11
  enableContentLeft?: boolean;
13
12
  };
14
13
 
@@ -20,7 +19,7 @@ const variant = ['normal', 'tight'];
20
19
  const meta: Meta<StorySelectProps> = {
21
20
  title: 'plasma_b2c/Combobox',
22
21
  decorators: [WithTheme],
23
- component: Combobox,
22
+ component: ComboboxWithForm,
24
23
  argTypes: {
25
24
  size: {
26
25
  options: size,
@@ -1,7 +1,11 @@
1
1
  import { component, mergeConfig } from '../../../../engines';
2
- import { comboboxNewConfig } from '../../../..';
2
+ import { comboboxNewConfig, boundCombobox, getFormComponentGenerator } from '../../../..';
3
3
  import { config } from './Combobox.config';
4
4
  var mergedConfig = /*#__PURE__*/mergeConfig(comboboxNewConfig, config);
5
5
  var ComboboxComponent = /*#__PURE__*/component(mergedConfig);
6
6
  var Combobox = ComboboxComponent;
7
- export { Combobox };
7
+ var ComboboxWithForm = /*#__PURE__*/boundCombobox({
8
+ base: ComboboxComponent,
9
+ baseForm: /*#__PURE__*/getFormComponentGenerator(ComboboxComponent)
10
+ });
11
+ export { Combobox, ComboboxWithForm };
@@ -5,9 +5,9 @@ import type { Meta, StoryObj } from '@storybook/react';
5
5
  import { WithTheme } from '../../../_helpers';
6
6
  import { IconDone } from '../../../../components/_Icon';
7
7
 
8
- import { Combobox } from './Combobox';
8
+ import { ComboboxWithForm } from './Combobox';
9
9
 
10
- type StorySelectProps = ComponentProps<typeof Combobox> & {
10
+ type StorySelectProps = ComponentProps<typeof ComboboxWithForm> & {
11
11
  enableContentLeft?: boolean;
12
12
  };
13
13
 
@@ -19,7 +19,7 @@ const variant = ['normal', 'tight'];
19
19
  const meta: Meta<StorySelectProps> = {
20
20
  title: 'plasma_web/Combobox',
21
21
  decorators: [WithTheme],
22
- component: Combobox,
22
+ component: ComboboxWithForm,
23
23
  argTypes: {
24
24
  size: {
25
25
  options: size,
@@ -356,7 +356,7 @@ const SingleStory = (args: StorySelectProps) => {
356
356
 
357
357
  return (
358
358
  <div style={{ width: '400px' }}>
359
- <Combobox
359
+ <ComboboxWithForm
360
360
  {...args}
361
361
  items={items}
362
362
  value={value}
@@ -384,7 +384,7 @@ const MultipleStory = (args: StorySelectProps) => {
384
384
 
385
385
  return (
386
386
  <div style={{ width: '400px' }}>
387
- <Combobox
387
+ <ComboboxWithForm
388
388
  {...args}
389
389
  multiple
390
390
  items={items}
@@ -0,0 +1,82 @@
1
+ import { extends as _extends, objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray } from '../../../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import React, { useState, useRef, useEffect } from 'react';
3
+ import { createEvent } from './syntheticEvent.js';
4
+
5
+ var _excluded = ["onChange", "name", "defaultValue", "component"],
6
+ _excluded2 = ["onChange", "name", "defaultValue", "component"];
7
+ var SingleForm = function SingleForm(args) {
8
+ var onChange = args.onChange,
9
+ name = args.name,
10
+ defaultValue = args.defaultValue,
11
+ Component = args.component,
12
+ rest = _objectWithoutProperties(args, _excluded);
13
+ var _useState = useState(String(defaultValue)),
14
+ _useState2 = _slicedToArray(_useState, 2),
15
+ value = _useState2[0],
16
+ setValue = _useState2[1];
17
+ var selectRef = useRef(null);
18
+ var handleChange = function handleChange(value) {
19
+ setValue(value);
20
+ };
21
+ useEffect(function () {
22
+ var event = createEvent(selectRef);
23
+ onChange && onChange(event);
24
+ }, [value]);
25
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("select", {
26
+ ref: selectRef,
27
+ value: value,
28
+ name: name,
29
+ hidden: true
30
+ }, /*#__PURE__*/React.createElement("option", {
31
+ value: value
32
+ }, value)), /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
33
+ value: value,
34
+ onChange: handleChange
35
+ })));
36
+ };
37
+ var MultipleForm = function MultipleForm(args) {
38
+ var onChange = args.onChange,
39
+ name = args.name,
40
+ defaultValue = args.defaultValue,
41
+ Component = args.component,
42
+ rest = _objectWithoutProperties(args, _excluded2);
43
+ var _useState3 = useState(defaultValue && Array.isArray(defaultValue) ? defaultValue : []),
44
+ _useState4 = _slicedToArray(_useState3, 2),
45
+ values = _useState4[0],
46
+ setValues = _useState4[1];
47
+ var selectRef = useRef(null);
48
+ var handleChange = function handleChange(value) {
49
+ setValues(value);
50
+ };
51
+ useEffect(function () {
52
+ var event = createEvent(selectRef);
53
+ onChange && onChange(event);
54
+ }, [values]);
55
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("select", {
56
+ ref: selectRef,
57
+ value: values,
58
+ name: name,
59
+ multiple: true,
60
+ hidden: true
61
+ }, values.map(function (value) {
62
+ return /*#__PURE__*/React.createElement("option", {
63
+ key: value,
64
+ value: value
65
+ }, value);
66
+ })), /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
67
+ value: values,
68
+ onChange: handleChange
69
+ })));
70
+ };
71
+ var getFormComponentGenerator = function getFormComponentGenerator(Component) {
72
+ return function (args) {
73
+ return args.multiple ? /*#__PURE__*/React.createElement(MultipleForm, _extends({}, args, {
74
+ component: Component
75
+ })) : /*#__PURE__*/React.createElement(SingleForm, _extends({}, args, {
76
+ component: Component
77
+ }));
78
+ };
79
+ };
80
+
81
+ export { getFormComponentGenerator };
82
+ //# sourceMappingURL=getForm.js.map