@salutejs/plasma-new-hope 0.186.0-canary.1538.11705586782.0 → 0.186.0-canary.1542.11716355955.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/Combobox/ComboboxNew/Combobox.boundler.js +22 -0
- package/cjs/components/Combobox/ComboboxNew/Combobox.boundler.js.map +1 -0
- package/cjs/components/Dropdown/Dropdown.js +4 -6
- package/cjs/components/Dropdown/Dropdown.js.map +1 -1
- package/cjs/index.js +2 -0
- package/cjs/index.js.map +1 -1
- package/emotion/cjs/components/Combobox/ComboboxNew/Combobox.boundler.js +21 -0
- package/emotion/cjs/components/Combobox/ComboboxNew/index.js +8 -1
- package/emotion/cjs/components/Combobox/ComboboxNew/utils/getForm.js +90 -0
- package/emotion/cjs/components/Combobox/ComboboxNew/utils/syntheticEvent.js +53 -0
- package/emotion/cjs/components/Combobox/index.js +6 -0
- package/emotion/cjs/components/Dropdown/Dropdown.js +4 -6
- package/emotion/cjs/examples/plasma_b2c/components/Combobox/Combobox.js +7 -2
- package/emotion/cjs/examples/plasma_b2c/components/Combobox/Combobox.stories.tsx +62 -4
- package/emotion/es/components/Combobox/ComboboxNew/Combobox.boundler.js +14 -0
- package/emotion/es/components/Combobox/ComboboxNew/index.js +2 -1
- package/emotion/es/components/Combobox/ComboboxNew/utils/getForm.js +83 -0
- package/emotion/es/components/Combobox/ComboboxNew/utils/syntheticEvent.js +47 -0
- package/emotion/es/components/Combobox/index.js +1 -1
- package/emotion/es/components/Dropdown/Dropdown.js +4 -6
- package/emotion/es/examples/plasma_b2c/components/Combobox/Combobox.js +7 -2
- package/emotion/es/examples/plasma_b2c/components/Combobox/Combobox.stories.tsx +62 -4
- package/es/components/Combobox/ComboboxNew/Combobox.boundler.js +18 -0
- package/es/components/Combobox/ComboboxNew/Combobox.boundler.js.map +1 -0
- package/es/components/Dropdown/Dropdown.js +4 -6
- package/es/components/Dropdown/Dropdown.js.map +1 -1
- package/es/index.js +1 -0
- package/es/index.js.map +1 -1
- package/package.json +2 -2
- package/styled-components/cjs/components/Combobox/ComboboxNew/Combobox.boundler.js +21 -0
- package/styled-components/cjs/components/Combobox/ComboboxNew/index.js +8 -1
- package/styled-components/cjs/components/Combobox/ComboboxNew/utils/getForm.js +90 -0
- package/styled-components/cjs/components/Combobox/ComboboxNew/utils/syntheticEvent.js +53 -0
- package/styled-components/cjs/components/Combobox/index.js +6 -0
- package/styled-components/cjs/components/Dropdown/Dropdown.js +4 -6
- package/styled-components/cjs/examples/plasma_b2c/components/Combobox/Combobox.js +7 -2
- package/styled-components/cjs/examples/plasma_b2c/components/Combobox/Combobox.stories.tsx +62 -4
- package/styled-components/es/components/Combobox/ComboboxNew/Combobox.boundler.js +14 -0
- package/styled-components/es/components/Combobox/ComboboxNew/index.js +2 -1
- package/styled-components/es/components/Combobox/ComboboxNew/utils/getForm.js +83 -0
- package/styled-components/es/components/Combobox/ComboboxNew/utils/syntheticEvent.js +47 -0
- package/styled-components/es/components/Combobox/index.js +1 -1
- package/styled-components/es/components/Dropdown/Dropdown.js +4 -6
- package/styled-components/es/examples/plasma_b2c/components/Combobox/Combobox.js +7 -2
- package/styled-components/es/examples/plasma_b2c/components/Combobox/Combobox.stories.tsx +62 -4
- package/types/components/Combobox/ComboboxNew/Combobox.boundler.d.ts +4 -0
- package/types/components/Combobox/ComboboxNew/Combobox.boundler.d.ts.map +1 -0
- package/types/components/Combobox/ComboboxNew/Combobox.types.d.ts +21 -0
- package/types/components/Combobox/ComboboxNew/Combobox.types.d.ts.map +1 -1
- package/types/components/Combobox/ComboboxNew/index.d.ts +1 -0
- package/types/components/Combobox/ComboboxNew/index.d.ts.map +1 -1
- package/types/components/Combobox/ComboboxNew/utils/getForm.d.ts +4 -0
- package/types/components/Combobox/ComboboxNew/utils/getForm.d.ts.map +1 -0
- package/types/components/Combobox/ComboboxNew/utils/syntheticEvent.d.ts +4 -0
- package/types/components/Combobox/ComboboxNew/utils/syntheticEvent.d.ts.map +1 -0
- package/types/components/Combobox/index.d.ts +1 -1
- package/types/components/Combobox/index.d.ts.map +1 -1
- package/types/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/types/components/Dropdown/Dropdown.types.d.ts +0 -4
- package/types/components/Dropdown/Dropdown.types.d.ts.map +1 -1
- package/types/examples/plasma_b2c/components/Combobox/Combobox.d.ts +3 -2
- package/types/examples/plasma_b2c/components/Combobox/Combobox.d.ts.map +1 -1
@@ -0,0 +1,83 @@
|
|
1
|
+
var _excluded = ["onChange", "component"],
|
2
|
+
_excluded2 = ["onChange", "component"];
|
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
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
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."); }
|
6
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
8
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
9
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
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
|
+
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
|
+
import React, { useEffect, useRef, useState } from 'react';
|
16
|
+
import { createEvent } from './syntheticEvent';
|
17
|
+
var SingleForm = function SingleForm(args) {
|
18
|
+
var onChange = args.onChange,
|
19
|
+
Component = args.component,
|
20
|
+
rest = _objectWithoutProperties(args, _excluded);
|
21
|
+
var _useState = useState(),
|
22
|
+
_useState2 = _slicedToArray(_useState, 2),
|
23
|
+
value = _useState2[0],
|
24
|
+
setValue = _useState2[1];
|
25
|
+
var selectRef = useRef(null);
|
26
|
+
var handleChange = function handleChange(value) {
|
27
|
+
setValue(value);
|
28
|
+
};
|
29
|
+
useEffect(function () {
|
30
|
+
var event = createEvent(selectRef);
|
31
|
+
onChange && onChange(event);
|
32
|
+
}, [value]);
|
33
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("select", {
|
34
|
+
ref: selectRef,
|
35
|
+
value: value,
|
36
|
+
hidden: true
|
37
|
+
}, /*#__PURE__*/React.createElement("option", {
|
38
|
+
value: value
|
39
|
+
}, value)), /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
|
40
|
+
value: value,
|
41
|
+
onChange: handleChange
|
42
|
+
})));
|
43
|
+
};
|
44
|
+
var MultipleForm = function MultipleForm(args) {
|
45
|
+
var onChange = args.onChange,
|
46
|
+
Component = args.component,
|
47
|
+
rest = _objectWithoutProperties(args, _excluded2);
|
48
|
+
var _useState3 = useState([]),
|
49
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
50
|
+
values = _useState4[0],
|
51
|
+
setValues = _useState4[1];
|
52
|
+
var selectRef = useRef(null);
|
53
|
+
var handleChange = function handleChange(value) {
|
54
|
+
setValues(value);
|
55
|
+
};
|
56
|
+
useEffect(function () {
|
57
|
+
var event = createEvent(selectRef);
|
58
|
+
onChange && onChange(event);
|
59
|
+
}, [values]);
|
60
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("select", {
|
61
|
+
ref: selectRef,
|
62
|
+
value: values,
|
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, _extends({}, rest, {
|
71
|
+
value: values,
|
72
|
+
onChange: handleChange
|
73
|
+
})));
|
74
|
+
};
|
75
|
+
export var getFormComponentGenerator = function getFormComponentGenerator(Component) {
|
76
|
+
return function (args) {
|
77
|
+
return args.multiple ? /*#__PURE__*/React.createElement(MultipleForm, _extends({}, args, {
|
78
|
+
component: Component
|
79
|
+
})) : /*#__PURE__*/React.createElement(SingleForm, _extends({}, args, {
|
80
|
+
component: Component
|
81
|
+
}));
|
82
|
+
};
|
83
|
+
};
|
@@ -0,0 +1,47 @@
|
|
1
|
+
export 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
|
+
export 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
|
+
};
|
@@ -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 } from './ComboboxNew';
|
2
|
+
export { comboboxTokens as comboboxNewTokens, comboboxRoot as comboboxNewRoot, comboboxConfig as comboboxNewConfig, boundCombobox } from './ComboboxNew';
|
@@ -1,4 +1,4 @@
|
|
1
|
-
var _excluded = ["items", "children", "placement", "offset", "closeOnOverlayClick", "onToggle", "size", "view", "itemRole", "className", "listWidth", "listHeight", "listOverflow", "closeOnSelect", "onHover", "onItemSelect", "onItemClick", "trigger", "variant", "hasArrow", "
|
1
|
+
var _excluded = ["items", "children", "placement", "offset", "closeOnOverlayClick", "onToggle", "size", "view", "itemRole", "className", "listWidth", "listHeight", "listOverflow", "closeOnSelect", "onHover", "onItemSelect", "onItemClick", "trigger", "variant", "hasArrow", "portal"];
|
2
2
|
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); }
|
3
3
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
4
4
|
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."); }
|
@@ -57,8 +57,6 @@ export var dropdownRoot = function dropdownRoot(Root) {
|
|
57
57
|
variant = _ref$variant === void 0 ? 'normal' : _ref$variant,
|
58
58
|
_ref$hasArrow = _ref.hasArrow,
|
59
59
|
hasArrow = _ref$hasArrow === void 0 ? true : _ref$hasArrow,
|
60
|
-
_ref$alwaysOpened = _ref.alwaysOpened,
|
61
|
-
alwaysOpened = _ref$alwaysOpened === void 0 ? false : _ref$alwaysOpened,
|
62
60
|
portal = _ref.portal,
|
63
61
|
rest = _objectWithoutProperties(_ref, _excluded);
|
64
62
|
var _useReducer = useReducer(pathReducer, []),
|
@@ -79,7 +77,7 @@ export var dropdownRoot = function dropdownRoot(Root) {
|
|
79
77
|
|
80
78
|
// Логика работы при клике за пределами выпадающего списка
|
81
79
|
var targetRef = useOutsideClick(function (event) {
|
82
|
-
if (!isCurrentListOpen || !closeOnOverlayClick
|
80
|
+
if (!isCurrentListOpen || !closeOnOverlayClick) {
|
83
81
|
return;
|
84
82
|
}
|
85
83
|
dispatchPath({
|
@@ -93,7 +91,7 @@ export var dropdownRoot = function dropdownRoot(Root) {
|
|
93
91
|
}
|
94
92
|
}, floatingPopoverRef);
|
95
93
|
var handleGlobalToggle = function handleGlobalToggle(opened, event) {
|
96
|
-
if (
|
94
|
+
if (opened) {
|
97
95
|
dispatchPath({
|
98
96
|
type: 'opened_first_level'
|
99
97
|
});
|
@@ -122,7 +120,7 @@ export var dropdownRoot = function dropdownRoot(Root) {
|
|
122
120
|
onItemClick: onItemClick
|
123
121
|
}),
|
124
122
|
onKeyDown = _useKeyNavigation.onKeyDown;
|
125
|
-
var isCurrentListOpen =
|
123
|
+
var isCurrentListOpen = Boolean(path[0]);
|
126
124
|
return /*#__PURE__*/React.createElement(Context.Provider, {
|
127
125
|
value: {
|
128
126
|
focusedPath: focusedPath,
|
@@ -1,7 +1,12 @@
|
|
1
1
|
import { component, mergeConfig } from '../../../../engines';
|
2
|
-
import { comboboxNewConfig } from '../../../..';
|
2
|
+
import { comboboxNewConfig, boundCombobox } from '../../../..';
|
3
|
+
import { getFormComponentGenerator } from '../../../../components/Combobox/ComboboxNew/utils/getForm';
|
3
4
|
import { config } from './Combobox.config';
|
4
5
|
var mergedConfig = /*#__PURE__*/mergeConfig(comboboxNewConfig, config);
|
5
6
|
var ComboboxComponent = /*#__PURE__*/component(mergedConfig);
|
6
7
|
var Combobox = ComboboxComponent;
|
7
|
-
|
8
|
+
var ComboboxWithForm = /*#__PURE__*/boundCombobox({
|
9
|
+
base: ComboboxComponent,
|
10
|
+
baseForm: /*#__PURE__*/getFormComponentGenerator(ComboboxComponent)
|
11
|
+
});
|
12
|
+
export { Combobox, ComboboxWithForm };
|
@@ -1,11 +1,12 @@
|
|
1
|
-
import React, { useState } from 'react';
|
1
|
+
import React, { useEffect, useRef, 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';
|
7
8
|
|
8
|
-
import { Combobox } from './Combobox';
|
9
|
+
import { Combobox, ComboboxWithForm } from './Combobox';
|
9
10
|
|
10
11
|
type StorySelectProps = ComponentProps<typeof Combobox> & {
|
11
12
|
enableContentLeft?: boolean;
|
@@ -356,7 +357,7 @@ const SingleStory = (args: StorySelectProps) => {
|
|
356
357
|
|
357
358
|
return (
|
358
359
|
<div style={{ width: '400px' }}>
|
359
|
-
<
|
360
|
+
<ComboboxWithForm
|
360
361
|
{...args}
|
361
362
|
items={items}
|
362
363
|
value={value}
|
@@ -367,6 +368,24 @@ const SingleStory = (args: StorySelectProps) => {
|
|
367
368
|
);
|
368
369
|
};
|
369
370
|
|
371
|
+
const SingleFormStory = (args: StorySelectProps) => {
|
372
|
+
const handleChange = (event) => {
|
373
|
+
console.log(event);
|
374
|
+
};
|
375
|
+
|
376
|
+
return (
|
377
|
+
<div style={{ width: '400px' }}>
|
378
|
+
<ComboboxWithForm
|
379
|
+
{...args}
|
380
|
+
items={items}
|
381
|
+
formType
|
382
|
+
onChange={handleChange}
|
383
|
+
contentLeft={args.enableContentLeft ? <IconDone size="s" /> : undefined}
|
384
|
+
/>
|
385
|
+
</div>
|
386
|
+
);
|
387
|
+
};
|
388
|
+
|
370
389
|
export const Single: StoryObj<StorySelectProps> = {
|
371
390
|
render: (args) => <SingleStory {...args} />,
|
372
391
|
args: {
|
@@ -379,14 +398,27 @@ export const Single: StoryObj<StorySelectProps> = {
|
|
379
398
|
},
|
380
399
|
};
|
381
400
|
|
401
|
+
export const SingleForm: StoryObj<StorySelectProps> = {
|
402
|
+
render: (args) => <SingleFormStory {...args} />,
|
403
|
+
args: {
|
404
|
+
closeAfterSelect: true,
|
405
|
+
},
|
406
|
+
parameters: {
|
407
|
+
controls: {
|
408
|
+
exclude: ['isTargetAmount'],
|
409
|
+
},
|
410
|
+
},
|
411
|
+
};
|
412
|
+
|
382
413
|
const MultipleStory = (args: StorySelectProps) => {
|
383
414
|
const [value, setValue] = useState([]);
|
384
415
|
|
385
416
|
return (
|
386
417
|
<div style={{ width: '400px' }}>
|
387
|
-
<
|
418
|
+
<ComboboxWithForm
|
388
419
|
{...args}
|
389
420
|
multiple
|
421
|
+
formType={false}
|
390
422
|
items={items}
|
391
423
|
value={value}
|
392
424
|
onChange={setValue}
|
@@ -396,9 +428,35 @@ const MultipleStory = (args: StorySelectProps) => {
|
|
396
428
|
);
|
397
429
|
};
|
398
430
|
|
431
|
+
const MultipleStoryForm = (args: StorySelectProps) => {
|
432
|
+
const handleChange = (event) => {
|
433
|
+
console.log(event);
|
434
|
+
};
|
435
|
+
|
436
|
+
return (
|
437
|
+
<div style={{ width: '400px' }}>
|
438
|
+
<ComboboxWithForm
|
439
|
+
{...args}
|
440
|
+
multiple
|
441
|
+
formType
|
442
|
+
onChange={handleChange}
|
443
|
+
items={items}
|
444
|
+
contentLeft={args.enableContentLeft ? <IconDone size="s" /> : undefined}
|
445
|
+
/>
|
446
|
+
</div>
|
447
|
+
);
|
448
|
+
};
|
449
|
+
|
399
450
|
export const Multiple: StoryObj<StorySelectProps> = {
|
400
451
|
render: (args) => <MultipleStory {...args} />,
|
401
452
|
args: {
|
402
453
|
closeAfterSelect: false,
|
403
454
|
},
|
404
455
|
};
|
456
|
+
|
457
|
+
export const MultipleForm: StoryObj<StorySelectProps> = {
|
458
|
+
render: (args) => <MultipleStoryForm {...args} />,
|
459
|
+
args: {
|
460
|
+
closeAfterSelect: false,
|
461
|
+
},
|
462
|
+
};
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
|
3
|
+
var boundCombobox = function boundCombobox(_ref) {
|
4
|
+
var ComboboxBase = _ref.base,
|
5
|
+
ComboboxBaseForm = _ref.baseForm;
|
6
|
+
return function (rest) {
|
7
|
+
if (rest.formType) {
|
8
|
+
return /*#__PURE__*/React.createElement(ComboboxBaseForm, rest);
|
9
|
+
}
|
10
|
+
if (!rest.formType) {
|
11
|
+
return /*#__PURE__*/React.createElement(ComboboxBase, rest);
|
12
|
+
}
|
13
|
+
return null;
|
14
|
+
};
|
15
|
+
};
|
16
|
+
|
17
|
+
export { boundCombobox };
|
18
|
+
//# sourceMappingURL=Combobox.boundler.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Combobox.boundler.js","sources":["../../../../src/components/Combobox/ComboboxNew/Combobox.boundler.tsx"],"sourcesContent":["import React from 'react';\n\nimport { ComboboxBoundlerProps, ComboboxBoundlerPropsComponent } from './Combobox.types';\n\nexport const boundCombobox: (args: ComboboxBoundlerProps) => React.FC<ComboboxBoundlerPropsComponent> = ({\n base: ComboboxBase,\n baseForm: ComboboxBaseForm,\n}) => (rest) => {\n if (rest.formType) {\n return <ComboboxBaseForm {...rest} />;\n }\n\n if (!rest.formType) {\n return <ComboboxBase {...rest} />;\n }\n\n return null;\n};\n"],"names":["boundCombobox","_ref","ComboboxBase","base","ComboboxBaseForm","baseForm","rest","formType","React","createElement"],"mappings":";;IAIaA,aAAwF,GAAG,SAA3FA,aAAwFA,CAAAC,IAAA,EAAA;AAAA,EAAA,IAC3FC,YAAY,GAAAD,IAAA,CAAlBE,IAAI;IACMC,gBAAgB,GAAAH,IAAA,CAA1BI,QAAQ,CAAA;EAAA,OACN,UAACC,IAAI,EAAK;IACZ,IAAIA,IAAI,CAACC,QAAQ,EAAE;AACf,MAAA,oBAAOC,KAAA,CAAAC,aAAA,CAACL,gBAAgB,EAAKE,IAAO,CAAC,CAAA;AACzC,KAAA;AAEA,IAAA,IAAI,CAACA,IAAI,CAACC,QAAQ,EAAE;AAChB,MAAA,oBAAOC,KAAA,CAAAC,aAAA,CAACP,YAAY,EAAKI,IAAO,CAAC,CAAA;AACrC,KAAA;AAEA,IAAA,OAAO,IAAI,CAAA;GACd,CAAA;AAAA;;;;"}
|
@@ -18,7 +18,7 @@ import { getPlacement } from './utils/getPlacement.js';
|
|
18
18
|
import { getItemId } from './utils/getItemId.js';
|
19
19
|
import { DropdownInner } from './ui/DropdownInner/DropdownInner.js';
|
20
20
|
|
21
|
-
var _excluded = ["items", "children", "placement", "offset", "closeOnOverlayClick", "onToggle", "size", "view", "itemRole", "className", "listWidth", "listHeight", "listOverflow", "closeOnSelect", "onHover", "onItemSelect", "onItemClick", "trigger", "variant", "hasArrow", "
|
21
|
+
var _excluded = ["items", "children", "placement", "offset", "closeOnOverlayClick", "onToggle", "size", "view", "itemRole", "className", "listWidth", "listHeight", "listOverflow", "closeOnSelect", "onHover", "onItemSelect", "onItemClick", "trigger", "variant", "hasArrow", "portal"];
|
22
22
|
var Context = /*#__PURE__*/createContext({});
|
23
23
|
|
24
24
|
/**
|
@@ -53,8 +53,6 @@ var dropdownRoot = function dropdownRoot(Root) {
|
|
53
53
|
variant = _ref$variant === void 0 ? 'normal' : _ref$variant,
|
54
54
|
_ref$hasArrow = _ref.hasArrow,
|
55
55
|
hasArrow = _ref$hasArrow === void 0 ? true : _ref$hasArrow,
|
56
|
-
_ref$alwaysOpened = _ref.alwaysOpened,
|
57
|
-
alwaysOpened = _ref$alwaysOpened === void 0 ? false : _ref$alwaysOpened,
|
58
56
|
portal = _ref.portal,
|
59
57
|
rest = _objectWithoutProperties(_ref, _excluded);
|
60
58
|
var _useReducer = useReducer(pathReducer, []),
|
@@ -75,7 +73,7 @@ var dropdownRoot = function dropdownRoot(Root) {
|
|
75
73
|
|
76
74
|
// Логика работы при клике за пределами выпадающего списка
|
77
75
|
var targetRef = useOutsideClick(function (event) {
|
78
|
-
if (!isCurrentListOpen || !closeOnOverlayClick
|
76
|
+
if (!isCurrentListOpen || !closeOnOverlayClick) {
|
79
77
|
return;
|
80
78
|
}
|
81
79
|
dispatchPath({
|
@@ -89,7 +87,7 @@ var dropdownRoot = function dropdownRoot(Root) {
|
|
89
87
|
}
|
90
88
|
}, floatingPopoverRef);
|
91
89
|
var handleGlobalToggle = function handleGlobalToggle(opened, event) {
|
92
|
-
if (
|
90
|
+
if (opened) {
|
93
91
|
dispatchPath({
|
94
92
|
type: 'opened_first_level'
|
95
93
|
});
|
@@ -118,7 +116,7 @@ var dropdownRoot = function dropdownRoot(Root) {
|
|
118
116
|
onItemClick: onItemClick
|
119
117
|
}),
|
120
118
|
onKeyDown = _useKeyNavigation.onKeyDown;
|
121
|
-
var isCurrentListOpen =
|
119
|
+
var isCurrentListOpen = Boolean(path[0]);
|
122
120
|
return /*#__PURE__*/React.createElement(Context.Provider, {
|
123
121
|
value: {
|
124
122
|
focusedPath: focusedPath,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Dropdown.js","sources":["../../../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["import React, { createContext, forwardRef, useReducer, useRef } from 'react';\nimport { safeUseId } from '@salutejs/plasma-core';\n\nimport { RootProps } from '../../engines';\nimport { cx } from '../../utils';\nimport { useOutsideClick } from '../../hooks';\n\nimport { pathReducer } from './reducers/pathReducer';\nimport { focusedPathReducer } from './reducers/focusedPathReducer';\nimport { DropdownInner } from './ui';\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { Ul, base } from './Dropdown.styles';\nimport { childrenWithProps, getItemByFocused, getItemId, getPlacement } from './utils';\nimport type { DropdownProps, HandleGlobalToggleType, ItemContext } from './Dropdown.types';\nimport { classes } from './Dropdown.tokens';\nimport { useKeyNavigation } from './hooks/useKeyboardNavigation';\nimport { useHashMaps } from './hooks/useHashMaps';\nimport { FloatingPopover } from './FloatingPopover';\n\nexport const Context = createContext<ItemContext>({} as ItemContext);\n\n/**\n * Выпадающий список.\n */\nexport const dropdownRoot = (Root: RootProps<HTMLDivElement, Omit<DropdownProps, 'items'>>) =>\n forwardRef<HTMLDivElement, DropdownProps>(\n (\n {\n items,\n children,\n placement,\n offset,\n closeOnOverlayClick = true,\n onToggle,\n size,\n view,\n itemRole = 'treeitem',\n className,\n listWidth,\n listHeight,\n listOverflow,\n closeOnSelect = true,\n onHover,\n onItemSelect,\n onItemClick,\n trigger = 'click',\n variant = 'normal',\n hasArrow = true,\n alwaysOpened = false,\n portal,\n ...rest\n },\n ref,\n ) => {\n const [path, dispatchPath] = useReducer(pathReducer, []);\n const [focusedPath, dispatchFocusedPath] = useReducer(focusedPathReducer, []);\n\n const [pathMap, focusedToValueMap] = useHashMaps(items);\n\n const activeDescendantItemValue = getItemByFocused(focusedPath, focusedToValueMap)?.value || '';\n\n const floatingPopoverRef = useRef<HTMLDivElement>(null);\n\n const treeId = safeUseId();\n\n // Логика работы при клике за пределами выпадающего списка\n const targetRef = useOutsideClick<HTMLUListElement>((event) => {\n if (!isCurrentListOpen || !closeOnOverlayClick || alwaysOpened) {\n return;\n }\n\n dispatchPath({ type: 'reset' });\n dispatchFocusedPath({ type: 'reset' });\n\n if (onToggle) {\n onToggle(false, event);\n }\n }, floatingPopoverRef);\n\n const handleGlobalToggle: HandleGlobalToggleType = (opened, event) => {\n if (alwaysOpened || opened) {\n dispatchPath({ type: 'opened_first_level' });\n } else {\n dispatchFocusedPath({ type: 'reset' });\n dispatchPath({ type: 'reset' });\n }\n\n if (onToggle) {\n onToggle(opened, event);\n }\n };\n\n const { onKeyDown } = useKeyNavigation({\n focusedPath,\n dispatchFocusedPath,\n path,\n dispatchPath,\n pathMap,\n focusedToValueMap,\n handleGlobalToggle,\n closeOnSelect,\n onItemSelect,\n onItemClick,\n });\n\n const isCurrentListOpen = alwaysOpened || Boolean(path[0]);\n\n return (\n <Context.Provider\n value={{\n focusedPath,\n size,\n variant,\n itemRole,\n handleGlobalToggle,\n closeOnSelect,\n onHover,\n onItemClick,\n onItemSelect,\n hasArrow,\n treeId,\n }}\n >\n <FloatingPopover\n ref={floatingPopoverRef}\n opened={isCurrentListOpen}\n onToggle={handleGlobalToggle}\n placement={getPlacement(placement)}\n offset={offset}\n portal={portal}\n trigger={trigger}\n target={childrenWithProps(children, {\n role: 'combobox',\n 'aria-controls': `${treeId}_tree_level_1`,\n 'aria-expanded': isCurrentListOpen,\n 'aria-activedescendant': activeDescendantItemValue\n ? getItemId(treeId, activeDescendantItemValue.toString())\n : '',\n onKeyDown,\n })}\n >\n <Root\n className={cx(className, classes.dropdownRoot)}\n ref={ref}\n view={view}\n size={size}\n style={{ display: 'inline-block' }}\n {...rest}\n >\n <Ul\n ref={targetRef}\n id={`${treeId}_tree_level_1`}\n role=\"tree\"\n listHeight={listHeight}\n listOverflow={listOverflow}\n listWidth={listWidth}\n >\n {items.map((item, index) => (\n <DropdownInner\n key={`${index}/0`}\n item={item}\n currentLevel={0}\n trigger={trigger}\n path={path}\n dispatchPath={dispatchPath}\n index={index}\n listHeight={listHeight}\n listOverflow={listOverflow}\n listWidth={listWidth}\n />\n ))}\n </Ul>\n </Root>\n </FloatingPopover>\n </Context.Provider>\n );\n },\n );\n\nexport const dropdownConfig = {\n name: 'Dropdown',\n tag: 'div',\n layout: dropdownRoot,\n base,\n variations: {\n view: {\n css: viewCSS,\n },\n size: {\n css: sizeCSS,\n },\n },\n defaults: {\n view: 'default',\n size: 'm',\n },\n};\n"],"names":["Context","createContext","dropdownRoot","Root","forwardRef","_ref","ref","_getItemByFocused","items","children","placement","offset","_ref$closeOnOverlayCl","closeOnOverlayClick","onToggle","size","view","_ref$itemRole","itemRole","className","listWidth","listHeight","listOverflow","_ref$closeOnSelect","closeOnSelect","onHover","onItemSelect","onItemClick","_ref$trigger","trigger","_ref$variant","variant","_ref$hasArrow","hasArrow","_ref$alwaysOpened","alwaysOpened","portal","rest","_objectWithoutProperties","_excluded","_useReducer","useReducer","pathReducer","_useReducer2","_slicedToArray","path","dispatchPath","_useReducer3","focusedPathReducer","_useReducer4","focusedPath","dispatchFocusedPath","_useHashMaps","useHashMaps","_useHashMaps2","pathMap","focusedToValueMap","activeDescendantItemValue","getItemByFocused","value","floatingPopoverRef","useRef","treeId","safeUseId","targetRef","useOutsideClick","event","isCurrentListOpen","type","handleGlobalToggle","opened","_useKeyNavigation","useKeyNavigation","onKeyDown","Boolean","React","createElement","Provider","FloatingPopover","getPlacement","target","childrenWithProps","role","concat","getItemId","toString","_extends","cx","classes","style","display","Ul","id","map","item","index","DropdownInner","key","currentLevel","dropdownConfig","name","tag","layout","base","variations","css","viewCSS","sizeCSS","defaults"],"mappings":";;;;;;;;;;;;;;;;;;;;;IAoBaA,OAAO,gBAAGC,aAAa,CAAc,EAAiB,EAAC;;AAEpE;AACA;AACA;IACaC,YAAY,GAAG,SAAfA,YAAYA,CAAIC,IAA6D,EAAA;AAAA,EAAA,oBACtFC,UAAU,CACN,UAAAC,IAAA,EA0BIC,GAAG,EACF;AAAA,IAAA,IAAAC,iBAAA,CAAA;AAAA,IAAA,IAzBGC,KAAK,GAAAH,IAAA,CAALG,KAAK;MACLC,QAAQ,GAAAJ,IAAA,CAARI,QAAQ;MACRC,SAAS,GAAAL,IAAA,CAATK,SAAS;MACTC,MAAM,GAAAN,IAAA,CAANM,MAAM;MAAAC,qBAAA,GAAAP,IAAA,CACNQ,mBAAmB;AAAnBA,MAAAA,mBAAmB,GAAAD,qBAAA,KAAG,KAAA,CAAA,GAAA,IAAI,GAAAA,qBAAA;MAC1BE,QAAQ,GAAAT,IAAA,CAARS,QAAQ;MACRC,IAAI,GAAAV,IAAA,CAAJU,IAAI;MACJC,IAAI,GAAAX,IAAA,CAAJW,IAAI;MAAAC,aAAA,GAAAZ,IAAA,CACJa,QAAQ;A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E,IAAM+E,cAAc,GAAG;AAC1BC,EAAAA,IAAI,EAAE,UAAU;AAChBC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAEpG,YAAY;AACpBqG,EAAAA,IAAI,EAAJA,IAAI;AACJC,EAAAA,UAAU,EAAE;AACRxF,IAAAA,IAAI,EAAE;AACFyF,MAAAA,GAAG,EAAEC,MAAAA;KACR;AACD3F,IAAAA,IAAI,EAAE;AACF0F,MAAAA,GAAG,EAAEE,MAAAA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACN5F,IAAAA,IAAI,EAAE,SAAS;AACfD,IAAAA,IAAI,EAAE,GAAA;AACV,GAAA;AACJ;;;;"}
|
1
|
+
{"version":3,"file":"Dropdown.js","sources":["../../../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["import React, { createContext, forwardRef, useReducer, useRef } from 'react';\nimport { safeUseId } from '@salutejs/plasma-core';\n\nimport { RootProps } from '../../engines';\nimport { cx } from '../../utils';\nimport { useOutsideClick } from '../../hooks';\n\nimport { pathReducer } from './reducers/pathReducer';\nimport { focusedPathReducer } from './reducers/focusedPathReducer';\nimport { DropdownInner } from './ui';\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { Ul, base } from './Dropdown.styles';\nimport { childrenWithProps, getItemByFocused, getItemId, getPlacement } from './utils';\nimport type { DropdownProps, HandleGlobalToggleType, ItemContext } from './Dropdown.types';\nimport { classes } from './Dropdown.tokens';\nimport { useKeyNavigation } from './hooks/useKeyboardNavigation';\nimport { useHashMaps } from './hooks/useHashMaps';\nimport { FloatingPopover } from './FloatingPopover';\n\nexport const Context = createContext<ItemContext>({} as ItemContext);\n\n/**\n * Выпадающий список.\n */\nexport const dropdownRoot = (Root: RootProps<HTMLDivElement, Omit<DropdownProps, 'items'>>) =>\n forwardRef<HTMLDivElement, DropdownProps>(\n (\n {\n items,\n children,\n placement,\n offset,\n closeOnOverlayClick = true,\n onToggle,\n size,\n view,\n itemRole = 'treeitem',\n className,\n listWidth,\n listHeight,\n listOverflow,\n closeOnSelect = true,\n onHover,\n onItemSelect,\n onItemClick,\n trigger = 'click',\n variant = 'normal',\n hasArrow = true,\n portal,\n ...rest\n },\n ref,\n ) => {\n const [path, dispatchPath] = useReducer(pathReducer, []);\n const [focusedPath, dispatchFocusedPath] = useReducer(focusedPathReducer, []);\n\n const [pathMap, focusedToValueMap] = useHashMaps(items);\n\n const activeDescendantItemValue = getItemByFocused(focusedPath, focusedToValueMap)?.value || '';\n\n const floatingPopoverRef = useRef<HTMLDivElement>(null);\n\n const treeId = safeUseId();\n\n // Логика работы при клике за пределами выпадающего списка\n const targetRef = useOutsideClick<HTMLUListElement>((event) => {\n if (!isCurrentListOpen || !closeOnOverlayClick) {\n return;\n }\n\n dispatchPath({ type: 'reset' });\n dispatchFocusedPath({ type: 'reset' });\n\n if (onToggle) {\n onToggle(false, event);\n }\n }, floatingPopoverRef);\n\n const handleGlobalToggle: HandleGlobalToggleType = (opened, event) => {\n if (opened) {\n dispatchPath({ type: 'opened_first_level' });\n } else {\n dispatchFocusedPath({ type: 'reset' });\n dispatchPath({ type: 'reset' });\n }\n\n if (onToggle) {\n onToggle(opened, event);\n }\n };\n\n const { onKeyDown } = useKeyNavigation({\n focusedPath,\n dispatchFocusedPath,\n path,\n dispatchPath,\n pathMap,\n focusedToValueMap,\n handleGlobalToggle,\n closeOnSelect,\n onItemSelect,\n onItemClick,\n });\n\n const isCurrentListOpen = Boolean(path[0]);\n\n return (\n <Context.Provider\n value={{\n focusedPath,\n size,\n variant,\n itemRole,\n handleGlobalToggle,\n closeOnSelect,\n onHover,\n onItemClick,\n onItemSelect,\n hasArrow,\n treeId,\n }}\n >\n <FloatingPopover\n ref={floatingPopoverRef}\n opened={isCurrentListOpen}\n onToggle={handleGlobalToggle}\n placement={getPlacement(placement)}\n offset={offset}\n portal={portal}\n trigger={trigger}\n target={childrenWithProps(children, {\n role: 'combobox',\n 'aria-controls': `${treeId}_tree_level_1`,\n 'aria-expanded': isCurrentListOpen,\n 'aria-activedescendant': activeDescendantItemValue\n ? getItemId(treeId, activeDescendantItemValue.toString())\n : '',\n onKeyDown,\n })}\n >\n <Root\n className={cx(className, classes.dropdownRoot)}\n ref={ref}\n view={view}\n size={size}\n style={{ display: 'inline-block' }}\n {...rest}\n >\n <Ul\n ref={targetRef}\n id={`${treeId}_tree_level_1`}\n role=\"tree\"\n listHeight={listHeight}\n listOverflow={listOverflow}\n listWidth={listWidth}\n >\n {items.map((item, index) => (\n <DropdownInner\n key={`${index}/0`}\n item={item}\n currentLevel={0}\n trigger={trigger}\n path={path}\n dispatchPath={dispatchPath}\n index={index}\n listHeight={listHeight}\n listOverflow={listOverflow}\n listWidth={listWidth}\n />\n ))}\n </Ul>\n </Root>\n </FloatingPopover>\n </Context.Provider>\n );\n },\n );\n\nexport const dropdownConfig = {\n name: 'Dropdown',\n tag: 'div',\n layout: dropdownRoot,\n base,\n variations: {\n view: {\n css: viewCSS,\n },\n size: {\n css: sizeCSS,\n },\n },\n defaults: {\n view: 'default',\n size: 'm',\n },\n};\n"],"names":["Context","createContext","dropdownRoot","Root","forwardRef","_ref","ref","_getItemByFocused","items","children","placement","offset","_ref$closeOnOverlayCl","closeOnOverlayClick","onToggle","size","view","_ref$itemRole","itemRole","className","listWidth","listHeight","listOverflow","_ref$closeOnSelect","closeOnSelect","onHover","onItemSelect","onItemClick","_ref$trigger","trigger","_ref$variant","variant","_ref$hasArrow","hasArrow","portal","rest","_objectWithoutProperties","_excluded","_useReducer","useReducer","pathReducer","_useReducer2","_slicedToArray","path","dispatchPath","_useReducer3","focusedPathReducer","_useReducer4","focusedPath","dispatchFocusedPath","_useHashMaps","useHashMaps","_useHashMaps2","pathMap","focusedToValueMap","activeDescendantItemValue","getItemByFocused","value","floatingPopoverRef","useRef","treeId","safeUseId","targetRef","useOutsideClick","event","isCurrentListOpen","type","handleGlobalToggle","opened","_useKeyNavigation","useKeyNavigation","onKeyDown","Boolean","React","createElement","Provider","FloatingPopover","getPlacement","target","childrenWithProps","role","concat","getItemId","toString","_extends","cx","classes","style","display","Ul","id","map","item","index","DropdownInner","key","currentLevel","dropdownConfig","name","tag","layout","base","variations","css","viewCSS","sizeCSS","defaults"],"mappings":";;;;;;;;;;;;;;;;;;;;;IAoBaA,OAAO,gBAAGC,aAAa,CAAc,EAAiB,EAAC;;AAEpE;AACA;AACA;IACaC,YAAY,GAAG,SAAfA,YAAYA,CAAIC,IAA6D,EAAA;AAAA,EAAA,oBACtFC,UAAU,CACN,UAAAC,IAAA,EAyBIC,GAAG,EACF;AAAA,IAAA,IAAAC,iBAAA,CAAA;AAAA,IAAA,IAxBGC,KAAK,GAAAH,IAAA,CAALG,KAAK;MACLC,QAAQ,GAAAJ,IAAA,CAARI,QAAQ;MACRC,SAAS,GAAAL,IAAA,CAATK,SAAS;MACTC,MAAM,GAAAN,IAAA,CAANM,MAAM;MAAAC,qBAAA,GAAAP,IAAA,CACNQ,mBAAmB;AAAnBA,MAAAA,mBAAmB,GAAAD,qBAAA,KAAG,KAAA,CAAA,GAAA,IAAI,GAAAA,qBAAA;MAC1BE,QAAQ,GAAAT,IAAA,CAARS,QAAQ;MACRC,IAAI,GAAAV,IAAA,CAAJU,IAAI;MACJC,IAAI,GAAAX,IAAA,CAAJW,IAAI;MAAAC,aAAA,GAAAZ,IAAA,CACJa,QAAQ;AAARA,MAAAA,QAAQ,GAAAD,aAAA,KAAG,KAAA,CAAA,GAAA,UAAU,GAAAA,aAAA;MACrBE,SAAS,GAAAd,IAAA,CAATc,SAAS;MACTC,SAAS,GAAAf,IAAA,CAATe,SAAS;MACTC,UAAU,GAAAhB,IAAA,CAAVgB,UAAU;MACVC,YAAY,GAAAjB,IAAA,CAAZiB,YAAY;MAAAC,kBAAA,GAAAlB,IAAA,CACZmB,aAAa;AAAbA,MAAAA,aAAa,GAAAD,kBAAA,KAAG,KAAA,CAAA,GAAA,IAAI,GAAAA,kBAAA;MACpBE,OAAO,G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
159
|
export { classes as comboboxOldClasses, tokens as comboboxOldTokens } from './components/Combobox/ComboboxOld/Combobox.tokens.js';
|
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
|
+
export { boundCombobox } from './components/Combobox/ComboboxNew/Combobox.boundler.js';
|
162
163
|
export { indicatorConfig, indicatorRoot } from './components/Indicator/Indicator.js';
|
163
164
|
export { tokens as indicatorTokens } from './components/Indicator/Indicator.tokens.js';
|
164
165
|
export { gridConfig, gridRoot } from './components/Grid/Grid.js';
|
package/es/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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@salutejs/plasma-new-hope",
|
3
|
-
"version": "0.186.0-canary.
|
3
|
+
"version": "0.186.0-canary.1542.11716355955.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": "
|
131
|
+
"gitHead": "26b528aaa0040df1c7a450a3b023bb7847a03078"
|
132
132
|
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.boundCombobox = void 0;
|
7
|
+
var _react = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("react"));
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
9
|
+
var boundCombobox = exports.boundCombobox = function boundCombobox(_ref) {
|
10
|
+
var ComboboxBase = _ref.base,
|
11
|
+
ComboboxBaseForm = _ref.baseForm;
|
12
|
+
return function (rest) {
|
13
|
+
if (rest.formType) {
|
14
|
+
return /*#__PURE__*/_react["default"].createElement(ComboboxBaseForm, rest);
|
15
|
+
}
|
16
|
+
if (!rest.formType) {
|
17
|
+
return /*#__PURE__*/_react["default"].createElement(ComboboxBase, rest);
|
18
|
+
}
|
19
|
+
return null;
|
20
|
+
};
|
21
|
+
};
|
@@ -3,6 +3,12 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
+
Object.defineProperty(exports, "boundCombobox", {
|
7
|
+
enumerable: true,
|
8
|
+
get: function get() {
|
9
|
+
return _Combobox3.boundCombobox;
|
10
|
+
}
|
11
|
+
});
|
6
12
|
Object.defineProperty(exports, "comboboxConfig", {
|
7
13
|
enumerable: true,
|
8
14
|
get: function get() {
|
@@ -22,4 +28,5 @@ Object.defineProperty(exports, "comboboxTokens", {
|
|
22
28
|
}
|
23
29
|
});
|
24
30
|
var _Combobox = /*#__PURE__*/require("./Combobox");
|
25
|
-
var _Combobox2 = /*#__PURE__*/require("./Combobox.tokens");
|
31
|
+
var _Combobox2 = /*#__PURE__*/require("./Combobox.tokens");
|
32
|
+
var _Combobox3 = /*#__PURE__*/require("./Combobox.boundler");
|
@@ -0,0 +1,90 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
5
|
+
value: true
|
6
|
+
});
|
7
|
+
exports.getFormComponentGenerator = void 0;
|
8
|
+
var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
|
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
|
13
|
+
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
|
+
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
|
+
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); }
|
16
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
17
|
+
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."); }
|
18
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
19
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
20
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
21
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
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; }
|
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; }
|
24
|
+
var SingleForm = function SingleForm(args) {
|
25
|
+
var onChange = args.onChange,
|
26
|
+
Component = args.component,
|
27
|
+
rest = _objectWithoutProperties(args, _excluded);
|
28
|
+
var _useState = (0, _react.useState)(),
|
29
|
+
_useState2 = _slicedToArray(_useState, 2),
|
30
|
+
value = _useState2[0],
|
31
|
+
setValue = _useState2[1];
|
32
|
+
var selectRef = (0, _react.useRef)(null);
|
33
|
+
var handleChange = function handleChange(value) {
|
34
|
+
setValue(value);
|
35
|
+
};
|
36
|
+
(0, _react.useEffect)(function () {
|
37
|
+
var event = (0, _syntheticEvent.createEvent)(selectRef);
|
38
|
+
onChange && onChange(event);
|
39
|
+
}, [value]);
|
40
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("select", {
|
41
|
+
ref: selectRef,
|
42
|
+
value: value,
|
43
|
+
hidden: true
|
44
|
+
}, /*#__PURE__*/_react["default"].createElement("option", {
|
45
|
+
value: value
|
46
|
+
}, value)), /*#__PURE__*/_react["default"].createElement(Component, _extends({}, rest, {
|
47
|
+
value: value,
|
48
|
+
onChange: handleChange
|
49
|
+
})));
|
50
|
+
};
|
51
|
+
var MultipleForm = function MultipleForm(args) {
|
52
|
+
var onChange = args.onChange,
|
53
|
+
Component = args.component,
|
54
|
+
rest = _objectWithoutProperties(args, _excluded2);
|
55
|
+
var _useState3 = (0, _react.useState)([]),
|
56
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
57
|
+
values = _useState4[0],
|
58
|
+
setValues = _useState4[1];
|
59
|
+
var selectRef = (0, _react.useRef)(null);
|
60
|
+
var handleChange = function handleChange(value) {
|
61
|
+
setValues(value);
|
62
|
+
};
|
63
|
+
(0, _react.useEffect)(function () {
|
64
|
+
var event = (0, _syntheticEvent.createEvent)(selectRef);
|
65
|
+
onChange && onChange(event);
|
66
|
+
}, [values]);
|
67
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("select", {
|
68
|
+
ref: selectRef,
|
69
|
+
value: values,
|
70
|
+
multiple: true,
|
71
|
+
hidden: true
|
72
|
+
}, values.map(function (value) {
|
73
|
+
return /*#__PURE__*/_react["default"].createElement("option", {
|
74
|
+
key: value,
|
75
|
+
value: value
|
76
|
+
}, value);
|
77
|
+
})), /*#__PURE__*/_react["default"].createElement(Component, _extends({}, rest, {
|
78
|
+
value: values,
|
79
|
+
onChange: handleChange
|
80
|
+
})));
|
81
|
+
};
|
82
|
+
var getFormComponentGenerator = exports.getFormComponentGenerator = function getFormComponentGenerator(Component) {
|
83
|
+
return function (args) {
|
84
|
+
return args.multiple ? /*#__PURE__*/_react["default"].createElement(MultipleForm, _extends({}, args, {
|
85
|
+
component: Component
|
86
|
+
})) : /*#__PURE__*/_react["default"].createElement(SingleForm, _extends({}, args, {
|
87
|
+
component: Component
|
88
|
+
}));
|
89
|
+
};
|
90
|
+
};
|