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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. package/cjs/components/Combobox/ComboboxNew/utils/getForm.js +80 -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 +1 -2
  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 +0 -3
  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 +76 -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 +1 -2
  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 +0 -3
  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/index.d.ts +1 -0
  47. package/types/components/Combobox/ComboboxNew/index.d.ts.map +1 -1
  48. package/types/components/Combobox/ComboboxNew/utils/getForm.d.ts +2 -2
  49. package/types/components/Combobox/ComboboxNew/utils/getForm.d.ts.map +1 -1
  50. package/types/components/Combobox/ComboboxNew/utils/index.d.ts +1 -0
  51. package/types/components/Combobox/ComboboxNew/utils/index.d.ts.map +1 -1
  52. package/types/components/Combobox/index.d.ts +1 -1
  53. package/types/components/Combobox/index.d.ts.map +1 -1
  54. package/types/examples/plasma_b2c/components/Combobox/Combobox.d.ts +459 -2
  55. package/types/examples/plasma_b2c/components/Combobox/Combobox.d.ts.map +1 -1
  56. package/types/examples/plasma_web/components/Combobox/Combobox.d.ts +459 -1
  57. package/types/examples/plasma_web/components/Combobox/Combobox.d.ts.map +1 -1
@@ -0,0 +1,80 @@
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", "component"],
10
+ _excluded2 = ["onChange", "component"];
11
+ var SingleForm = function SingleForm(args) {
12
+ var onChange = args.onChange,
13
+ Component = args.component,
14
+ rest = _rollupPluginBabelHelpers.objectWithoutProperties(args, _excluded);
15
+ var _useState = React.useState(),
16
+ _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
17
+ value = _useState2[0],
18
+ setValue = _useState2[1];
19
+ var selectRef = React.useRef(null);
20
+ var handleChange = function handleChange(value) {
21
+ setValue(value);
22
+ };
23
+ React.useEffect(function () {
24
+ var event = syntheticEvent.createEvent(selectRef);
25
+ onChange && onChange(event);
26
+ }, [value]);
27
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("select", {
28
+ ref: selectRef,
29
+ value: value,
30
+ hidden: true
31
+ }, /*#__PURE__*/React.createElement("option", {
32
+ value: value
33
+ }, value)), /*#__PURE__*/React.createElement(Component, _rollupPluginBabelHelpers.extends({}, rest, {
34
+ value: value,
35
+ onChange: handleChange
36
+ })));
37
+ };
38
+ var MultipleForm = function MultipleForm(args) {
39
+ var onChange = args.onChange,
40
+ Component = args.component,
41
+ rest = _rollupPluginBabelHelpers.objectWithoutProperties(args, _excluded2);
42
+ var _useState3 = React.useState([]),
43
+ _useState4 = _rollupPluginBabelHelpers.slicedToArray(_useState3, 2),
44
+ values = _useState4[0],
45
+ setValues = _useState4[1];
46
+ var selectRef = React.useRef(null);
47
+ var handleChange = function handleChange(value) {
48
+ setValues(value);
49
+ };
50
+ React.useEffect(function () {
51
+ var event = syntheticEvent.createEvent(selectRef);
52
+ onChange && onChange(event);
53
+ }, [values]);
54
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("select", {
55
+ ref: selectRef,
56
+ value: values,
57
+ multiple: true,
58
+ hidden: true
59
+ }, values.map(function (value) {
60
+ return /*#__PURE__*/React.createElement("option", {
61
+ key: value,
62
+ value: value
63
+ }, value);
64
+ })), /*#__PURE__*/React.createElement(Component, _rollupPluginBabelHelpers.extends({}, rest, {
65
+ value: values,
66
+ onChange: handleChange
67
+ })));
68
+ };
69
+ var getFormComponentGenerator = function getFormComponentGenerator(Component) {
70
+ return function (args) {
71
+ return args.multiple ? /*#__PURE__*/React.createElement(MultipleForm, _rollupPluginBabelHelpers.extends({}, args, {
72
+ component: Component
73
+ })) : /*#__PURE__*/React.createElement(SingleForm, _rollupPluginBabelHelpers.extends({}, args, {
74
+ component: Component
75
+ }));
76
+ };
77
+ };
78
+
79
+ exports.getFormComponentGenerator = getFormComponentGenerator;
80
+ //# 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, component: Component, ...rest } = args;\n const [value, setValue] = useState<string | undefined>();\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} 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, component: Component, ...rest } = args;\n const [values, setValues] = useState<string[]>([]);\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} 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","Component","component","rest","_objectWithoutProperties","_excluded","_useState","useState","_useState2","_slicedToArray","value","setValue","selectRef","useRef","handleChange","useEffect","event","createEvent","React","createElement","Fragment","ref","hidden","_extends","MultipleForm","_excluded2","_useState3","_useState4","values","setValues","multiple","map","key","getFormComponentGenerator"],"mappings":";;;;;;;;;;AAUA,IAAMA,UAAU,GAAG,SAAbA,UAAUA,CAAIC,IAA2B,EAAK;AAChD,EAAA,IAAQC,QAAQ,GAAoCD,IAAI,CAAhDC,QAAQ;IAAaC,SAAS,GAAcF,IAAI,CAAtCG,SAAS;AAAgBC,IAAAA,IAAI,GAAAC,iDAAA,CAAKL,IAAI,EAAAM,SAAA,CAAA,CAAA;AACxD,EAAA,IAAAC,SAAA,GAA0BC,cAAQ,EAAsB;IAAAC,UAAA,GAAAC,uCAAA,CAAAH,SAAA,EAAA,CAAA,CAAA;AAAjDI,IAAAA,KAAK,GAAAF,UAAA,CAAA,CAAA,CAAA;AA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AAAA;AAAa,GAAA,CAAE,CACxE,CAAC,CAAA;AAEX,CAAC,CAAA;IAEYmB,yBAAyB,GAAG,SAA5BA,yBAAyBA,CAAIhC,SAAuC,EAAK;EAClF,OAAO,UAACF,IAAuB,EAAK;AAChC,IAAA,OAAOA,IAAI,CAAC+B,QAAQ,gBAChBZ,KAAA,CAAAC,aAAA,CAACK,YAAY,EAAAD,iCAAA,CAAA,EAAA,EAAKxB,IAAI,EAAA;AAAEG,MAAAA,SAAS,EAAED,SAAAA;KAAY,CAAA,CAAC,gBAEhDiB,KAAA,CAAAC,aAAA,CAACrB,UAAU,EAAAyB,iCAAA,CAAA,EAAA,EAAKxB,IAAI,EAAA;AAAEG,MAAAA,SAAS,EAAED,SAAAA;AAAU,KAAA,CAAE,CAChD,CAAA;GACJ,CAAA;AACL;;;;"}
@@ -0,0 +1,55 @@
1
+ 'use strict';
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","pers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B;IACxCC,UAAU,EAAElB,KAAK,CAACkB,UAAU;IAC5BC,SAAS,EAAEnB,KAAK,CAACmB,SAAS;AAC1BR,IAAAA,cAAc,EAAdA,cAAc;IACdF,kBAAkB,EAAE,SAAAA,kBAAA,GAAA;AAAA,MAAA,OAAMA,mBAAkB,CAAA;AAAA,KAAA;AAC5CG,IAAAA,eAAe,EAAfA,eAAe;IACfF,oBAAoB,EAAE,SAAAA,oBAAA,GAAA;AAAA,MAAA,OAAMA,qBAAoB,CAAA;AAAA,KAAA;AAChDU,IAAAA,OAAO,EAAE,SAAAA,OAAA,GAAM,EAAE;IACjBC,SAAS,EAAErB,KAAK,CAACqB,SAAS;IAC1BC,IAAI,EAAEtB,KAAK,CAACsB,IAAAA;GACf,CAAA;AACL;;;;;"}
package/cjs/index.js CHANGED
@@ -163,6 +163,7 @@ var Combobox_tokens = require('./components/Combobox/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
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -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");
@@ -8,8 +8,7 @@ exports.getFormComponentGenerator = void 0;
8
8
  var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
9
9
  var _syntheticEvent = /*#__PURE__*/require("./syntheticEvent");
10
10
  var _excluded = ["onChange", "component"],
11
- _excluded2 = ["onChange", "component"]; // eslint-disable-next-line @typescript-eslint/ban-ts-comment
12
- // @ts-nocheck
11
+ _excluded2 = ["onChange", "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); }
@@ -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';
@@ -9,9 +9,6 @@ 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) {
@@ -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,76 @@
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", "component"],
6
+ _excluded2 = ["onChange", "component"];
7
+ var SingleForm = function SingleForm(args) {
8
+ var onChange = args.onChange,
9
+ Component = args.component,
10
+ rest = _objectWithoutProperties(args, _excluded);
11
+ var _useState = useState(),
12
+ _useState2 = _slicedToArray(_useState, 2),
13
+ value = _useState2[0],
14
+ setValue = _useState2[1];
15
+ var selectRef = useRef(null);
16
+ var handleChange = function handleChange(value) {
17
+ setValue(value);
18
+ };
19
+ useEffect(function () {
20
+ var event = createEvent(selectRef);
21
+ onChange && onChange(event);
22
+ }, [value]);
23
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("select", {
24
+ ref: selectRef,
25
+ value: value,
26
+ hidden: true
27
+ }, /*#__PURE__*/React.createElement("option", {
28
+ value: value
29
+ }, value)), /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
30
+ value: value,
31
+ onChange: handleChange
32
+ })));
33
+ };
34
+ var MultipleForm = function MultipleForm(args) {
35
+ var onChange = args.onChange,
36
+ Component = args.component,
37
+ rest = _objectWithoutProperties(args, _excluded2);
38
+ var _useState3 = useState([]),
39
+ _useState4 = _slicedToArray(_useState3, 2),
40
+ values = _useState4[0],
41
+ setValues = _useState4[1];
42
+ var selectRef = useRef(null);
43
+ var handleChange = function handleChange(value) {
44
+ setValues(value);
45
+ };
46
+ useEffect(function () {
47
+ var event = createEvent(selectRef);
48
+ onChange && onChange(event);
49
+ }, [values]);
50
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("select", {
51
+ ref: selectRef,
52
+ value: values,
53
+ multiple: true,
54
+ hidden: true
55
+ }, values.map(function (value) {
56
+ return /*#__PURE__*/React.createElement("option", {
57
+ key: value,
58
+ value: value
59
+ }, value);
60
+ })), /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
61
+ value: values,
62
+ onChange: handleChange
63
+ })));
64
+ };
65
+ var getFormComponentGenerator = function getFormComponentGenerator(Component) {
66
+ return function (args) {
67
+ return args.multiple ? /*#__PURE__*/React.createElement(MultipleForm, _extends({}, args, {
68
+ component: Component
69
+ })) : /*#__PURE__*/React.createElement(SingleForm, _extends({}, args, {
70
+ component: Component
71
+ }));
72
+ };
73
+ };
74
+
75
+ export { getFormComponentGenerator };
76
+ //# 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, component: Component, ...rest } = args;\n const [value, setValue] = useState<string | undefined>();\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} 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, component: Component, ...rest } = args;\n const [values, setValues] = useState<string[]>([]);\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} 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","Component","component","rest","_objectWithoutProperties","_excluded","_useState","useState","_useState2","_slicedToArray","value","setValue","selectRef","useRef","handleChange","useEffect","event","createEvent","React","createElement","Fragment","ref","hidden","_extends","MultipleForm","_excluded2","_useState3","_useState4","values","setValues","multiple","map","key","getFormComponentGenerator"],"mappings":";;;;;;AAUA,IAAMA,UAAU,GAAG,SAAbA,UAAUA,CAAIC,IAA2B,EAAK;AAChD,EAAA,IAAQC,QAAQ,GAAoCD,IAAI,CAAhDC,QAAQ;IAAaC,SAAS,GAAcF,IAAI,CAAtCG,SAAS;AAAgBC,IAAAA,IAAI,GAAAC,wBAAA,CAAKL,IAAI,EAAAM,SAAA,CAAA,CAAA;AACxD,EAAA,IAAAC,SAAA,GAA0BC,QAAQ,EAAsB;IAAAC,UAAA,GAAAC,cAAA,CAAAH,SAAA,EAAA,CAAA,CAAA;AAAjDI,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,SAAS,CAAC,YAAM;AACZ,IAAA,IAAMC,KAAK,GAA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AED,SAAAA;KAAY,CAAA,CAAC,gBAEhDiB,KAAA,CAAAC,aAAA,CAACrB,UAAU,EAAAyB,QAAA,CAAA,EAAA,EAAKxB,IAAI,EAAA;AAAEG,MAAAA,SAAS,EAAED,SAAAA;AAAU,KAAA,CAAE,CAChD,CAAA;GACJ,CAAA;AACL;;;;"}
@@ -0,0 +1,50 @@
1
+ var createEvent = function createEvent(ref) {
2
+ if (ref.current) {
3
+ var event = new Event('change', {
4
+ bubbles: true
5
+ });
6
+ Object.defineProperty(event, 'target', {
7
+ writable: false,
8
+ value: ref.current
9
+ });
10
+ var syntheticEvent = createSyntheticEvent(event);
11
+ return syntheticEvent;
12
+ }
13
+ return null;
14
+ };
15
+ var createSyntheticEvent = function createSyntheticEvent(event) {
16
+ var _isDefaultPrevented = false;
17
+ var _isPropagationStopped = false;
18
+ var preventDefault = function preventDefault() {
19
+ _isDefaultPrevented = true;
20
+ event.preventDefault();
21
+ };
22
+ var stopPropagation = function stopPropagation() {
23
+ _isPropagationStopped = true;
24
+ event.stopPropagation();
25
+ };
26
+ return {
27
+ nativeEvent: event,
28
+ currentTarget: event.currentTarget,
29
+ target: event.target,
30
+ bubbles: event.bubbles,
31
+ cancelable: event.cancelable,
32
+ defaultPrevented: event.defaultPrevented,
33
+ eventPhase: event.eventPhase,
34
+ isTrusted: event.isTrusted,
35
+ preventDefault: preventDefault,
36
+ isDefaultPrevented: function isDefaultPrevented() {
37
+ return _isDefaultPrevented;
38
+ },
39
+ stopPropagation: stopPropagation,
40
+ isPropagationStopped: function isPropagationStopped() {
41
+ return _isPropagationStopped;
42
+ },
43
+ persist: function persist() {},
44
+ timeStamp: event.timeStamp,
45
+ type: event.type
46
+ };
47
+ };
48
+
49
+ export { createEvent, createSyntheticEvent };
50
+ //# 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,CAA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ErB,KAAK,CAACqB,SAAS;IAC1BC,IAAI,EAAEtB,KAAK,CAACsB,IAAAA;GACf,CAAA;AACL;;;;"}
package/es/index.js CHANGED
@@ -160,6 +160,7 @@ export { classes as comboboxOldClasses, tokens as comboboxOldTokens } from './co
160
160
  export { tokens as comboboxNewTokens } from './components/Combobox/ComboboxNew/Combobox.tokens.js';
161
161
  export { comboboxConfig as comboboxNewConfig, comboboxRoot as comboboxNewRoot } from './components/Combobox/ComboboxNew/Combobox.js';
162
162
  export { boundCombobox } from './components/Combobox/ComboboxNew/Combobox.boundler.js';
163
+ export { getFormComponentGenerator } from './components/Combobox/ComboboxNew/utils/getForm.js';
163
164
  export { indicatorConfig, indicatorRoot } from './components/Indicator/Indicator.js';
164
165
  export { tokens as indicatorTokens } from './components/Indicator/Indicator.tokens.js';
165
166
  export { gridConfig, gridRoot } from './components/Grid/Grid.js';