@cloud-ru/uikit-product-mobile-dropdown 0.9.21 → 0.9.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/cjs/components/AdaptiveDropdown/AdaptiveDropdown.d.ts +6 -0
- package/dist/cjs/components/AdaptiveDropdown/AdaptiveDropdown.js +22 -0
- package/dist/cjs/components/AdaptiveDropdown/index.d.ts +1 -0
- package/dist/cjs/components/AdaptiveDropdown/index.js +17 -0
- package/dist/cjs/components/AdaptiveDroplist/AdaptiveDroplist.d.ts +6 -0
- package/dist/cjs/components/AdaptiveDroplist/AdaptiveDroplist.js +22 -0
- package/dist/cjs/components/AdaptiveDroplist/index.d.ts +1 -0
- package/dist/cjs/components/AdaptiveDroplist/index.js +17 -0
- package/dist/cjs/components/MobileDropdown.d.ts +10 -0
- package/dist/cjs/components/MobileDropdown.js +44 -0
- package/dist/cjs/components/MobileDroplist.d.ts +7 -0
- package/dist/cjs/components/MobileDroplist.js +56 -0
- package/dist/cjs/components/index.d.ts +4 -0
- package/dist/cjs/components/index.js +20 -0
- package/dist/cjs/components/styles.module.css +25 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +24 -0
- package/dist/esm/components/AdaptiveDropdown/AdaptiveDropdown.d.ts +6 -0
- package/dist/esm/components/AdaptiveDropdown/AdaptiveDropdown.js +19 -0
- package/dist/esm/components/AdaptiveDropdown/index.d.ts +1 -0
- package/dist/esm/components/AdaptiveDropdown/index.js +1 -0
- package/dist/esm/components/AdaptiveDroplist/AdaptiveDroplist.d.ts +6 -0
- package/dist/esm/components/AdaptiveDroplist/AdaptiveDroplist.js +19 -0
- package/dist/esm/components/AdaptiveDroplist/index.d.ts +1 -0
- package/dist/esm/components/AdaptiveDroplist/index.js +1 -0
- package/dist/esm/components/MobileDropdown.d.ts +10 -0
- package/dist/esm/components/MobileDropdown.js +38 -0
- package/dist/esm/components/MobileDroplist.d.ts +7 -0
- package/dist/esm/components/MobileDroplist.js +50 -0
- package/dist/esm/components/index.d.ts +4 -0
- package/dist/esm/components/index.js +4 -0
- package/dist/esm/components/styles.module.css +25 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +2 -0
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,27 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 0.9.23 (2025-11-13)
|
|
7
|
+
|
|
8
|
+
### Only dependencies have been changed
|
|
9
|
+
* [@cloud-ru/uikit-product-mobile-modal@0.9.20](https://gitverse.ru/cloud-ru-tech/uikit-product/-/blob/master/packages/mobile-modal/CHANGELOG.md)
|
|
10
|
+
* [@cloud-ru/uikit-product-utils@7.0.2](https://gitverse.ru/cloud-ru-tech/uikit-product/-/blob/master/packages/utils/CHANGELOG.md)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## 0.9.22 (2025-11-12)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* **PD-3377:** contributors update to publish all packages ([719fd3e](https://gitverse.ru/cloud-ru-tech/uikit-product/commits/719fd3e1249e247443b125c47ea408d92c8395c3))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
6
27
|
## 0.9.21 (2025-11-12)
|
|
7
28
|
|
|
8
29
|
### Only dependencies have been changed
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WithLayoutType } from '@sbercloud/uikit-product-utils';
|
|
2
|
+
import { DropdownProps } from '@snack-uikit/dropdown';
|
|
3
|
+
import { MobileDropdownProps } from '../MobileDropdown';
|
|
4
|
+
export type AdaptiveDropdownProps = WithLayoutType<DropdownProps & Pick<MobileDropdownProps, 'children'>>;
|
|
5
|
+
export declare function AdaptiveDropdown({ layoutType, children, ...dropdownProps }: AdaptiveDropdownProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export type { DropdownProps };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.AdaptiveDropdown = AdaptiveDropdown;
|
|
15
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
const dropdown_1 = require("@snack-uikit/dropdown");
|
|
17
|
+
const MobileDropdown_1 = require("../MobileDropdown");
|
|
18
|
+
function AdaptiveDropdown(_a) {
|
|
19
|
+
var { layoutType, children } = _a, dropdownProps = __rest(_a, ["layoutType", "children"]);
|
|
20
|
+
const isMobile = layoutType === 'mobile';
|
|
21
|
+
return isMobile ? ((0, jsx_runtime_1.jsx)(MobileDropdown_1.MobileDropdown, Object.assign({}, dropdownProps, { children: children }))) : ((0, jsx_runtime_1.jsx)(dropdown_1.Dropdown, Object.assign({}, dropdownProps, { children: children })));
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AdaptiveDropdown';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./AdaptiveDropdown"), exports);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WithLayoutType } from '@sbercloud/uikit-product-utils';
|
|
2
|
+
import { DroplistProps } from '@snack-uikit/list';
|
|
3
|
+
import { MobileDroplistProps } from '../MobileDroplist';
|
|
4
|
+
export type AdaptiveDroplistProps = WithLayoutType<Omit<DroplistProps, 'children'> & Pick<MobileDroplistProps, 'children'>>;
|
|
5
|
+
export declare function AdaptiveDroplist({ layoutType, children, size, ...dropListProps }: AdaptiveDroplistProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export type { DroplistProps };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.AdaptiveDroplist = AdaptiveDroplist;
|
|
15
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
const list_1 = require("@snack-uikit/list");
|
|
17
|
+
const MobileDroplist_1 = require("../MobileDroplist");
|
|
18
|
+
function AdaptiveDroplist(_a) {
|
|
19
|
+
var { layoutType, children, size } = _a, dropListProps = __rest(_a, ["layoutType", "children", "size"]);
|
|
20
|
+
const isMobile = layoutType === 'mobile';
|
|
21
|
+
return isMobile ? ((0, jsx_runtime_1.jsx)(MobileDroplist_1.MobileDroplist, Object.assign({}, dropListProps, { children: children }))) : ((0, jsx_runtime_1.jsx)(list_1.Droplist, Object.assign({}, dropListProps, { size: size, children: children })));
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AdaptiveDroplist';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./AdaptiveDroplist"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PropsWithChildren, ReactNode } from 'react';
|
|
2
|
+
import { MobileModalCustomProps } from '@sbercloud/uikit-product-mobile-modal';
|
|
3
|
+
import { WithSupportProps } from '@snack-uikit/utils';
|
|
4
|
+
export type MobileDropdownProps = PropsWithChildren<WithSupportProps<{
|
|
5
|
+
open?: boolean;
|
|
6
|
+
onOpenChange?(value: boolean): void;
|
|
7
|
+
content: ReactNode;
|
|
8
|
+
closeOnPopstate?: boolean;
|
|
9
|
+
} & Pick<MobileModalCustomProps, 'size'>>>;
|
|
10
|
+
export declare function MobileDropdown({ open, onOpenChange, children, content, ...rest }: MobileDropdownProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.MobileDropdown = MobileDropdown;
|
|
18
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
+
const react_1 = require("react");
|
|
20
|
+
const uncontrollable_1 = require("uncontrollable");
|
|
21
|
+
const uikit_product_mobile_modal_1 = require("@sbercloud/uikit-product-mobile-modal");
|
|
22
|
+
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
23
|
+
function MobileDropdown(_a) {
|
|
24
|
+
var { open, onOpenChange, children, content } = _a, rest = __rest(_a, ["open", "onOpenChange", "children", "content"]);
|
|
25
|
+
const [isOpen, setIsOpen] = (0, uncontrollable_1.useUncontrolledProp)(open, false, onOpenChange);
|
|
26
|
+
const handleClose = () => setIsOpen(false);
|
|
27
|
+
const trigger = (0, react_1.useMemo)(() => {
|
|
28
|
+
const handleOpen = () => setIsOpen(true);
|
|
29
|
+
if ((0, react_1.isValidElement)(children)) {
|
|
30
|
+
return (0, react_1.cloneElement)(children, {
|
|
31
|
+
// todo: check if there is onClick
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
33
|
+
// @ts-ignore
|
|
34
|
+
onClick: (event) => {
|
|
35
|
+
var _a, _b;
|
|
36
|
+
(_b = (_a = children.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, event);
|
|
37
|
+
handleOpen();
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return ((0, jsx_runtime_1.jsx)("span", { role: 'button', tabIndex: 0, onClick: handleOpen, children: children }));
|
|
42
|
+
}, [children, setIsOpen]);
|
|
43
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [trigger, (0, jsx_runtime_1.jsx)(uikit_product_mobile_modal_1.MobileModalCustom, Object.assign({ open: isOpen, onClose: handleClose, className: styles_module_scss_1.default.modal }, rest, { children: content }))] }));
|
|
44
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DroplistProps, ListProps } from '@snack-uikit/list';
|
|
2
|
+
import { MobileDropdownProps } from './MobileDropdown';
|
|
3
|
+
export type MobileDroplistProps = Omit<MobileDropdownProps, 'content'> & Pick<DroplistProps, 'closeDroplistOnItemClick'> & ListProps & {
|
|
4
|
+
label?: string;
|
|
5
|
+
virtualized?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function MobileDroplist({ items, selection, open: openProp, onOpenChange, children, search, label, footer, virtualized, closeDroplistOnItemClick, ...rest }: MobileDroplistProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.MobileDroplist = MobileDroplist;
|
|
18
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
+
const react_1 = require("react");
|
|
20
|
+
const uikit_product_mobile_modal_1 = require("@sbercloud/uikit-product-mobile-modal");
|
|
21
|
+
const list_1 = require("@snack-uikit/list");
|
|
22
|
+
const utils_1 = require("@snack-uikit/utils");
|
|
23
|
+
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
24
|
+
function MobileDroplist(_a) {
|
|
25
|
+
var { items, selection, open: openProp, onOpenChange, children, search, label, footer, virtualized, closeDroplistOnItemClick } = _a, rest = __rest(_a, ["items", "selection", "open", "onOpenChange", "children", "search", "label", "footer", "virtualized", "closeDroplistOnItemClick"]);
|
|
26
|
+
const scrollRef = (0, react_1.useRef)(null);
|
|
27
|
+
const [open = false, setIsOpen] = (0, utils_1.useValueControl)({ value: openProp, onChange: onOpenChange });
|
|
28
|
+
const searchable = search;
|
|
29
|
+
const needCloseOnSelectItem = (selection === null || selection === void 0 ? void 0 : selection.mode) !== 'multiple' && closeDroplistOnItemClick;
|
|
30
|
+
const handleClose = () => setIsOpen(false);
|
|
31
|
+
const handleSelectItem = selectedItem => {
|
|
32
|
+
var _a;
|
|
33
|
+
if (needCloseOnSelectItem) {
|
|
34
|
+
handleClose();
|
|
35
|
+
}
|
|
36
|
+
(_a = selection === null || selection === void 0 ? void 0 : selection.onChange) === null || _a === void 0 ? void 0 : _a.call(selection, selectedItem);
|
|
37
|
+
};
|
|
38
|
+
const listJsx = ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.listWrapper, "data-virtualized": virtualized || undefined, children: (0, jsx_runtime_1.jsx)(list_1.List, Object.assign({ items: items, selection: selection && Object.assign(Object.assign({}, selection), { onChange: handleSelectItem }), size: 'l', search: searchable ? search : undefined, scrollRef: searchable || virtualized ? scrollRef : undefined, scroll: virtualized, virtualized: virtualized }, rest)) }));
|
|
39
|
+
const trigger = (0, react_1.useMemo)(() => {
|
|
40
|
+
const handleOpen = () => setIsOpen(true);
|
|
41
|
+
if ((0, react_1.isValidElement)(children)) {
|
|
42
|
+
return (0, react_1.cloneElement)(children, {
|
|
43
|
+
// todo: check if there is onClick
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
onClick: (event) => {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
(_b = (_a = children.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, event);
|
|
49
|
+
handleOpen();
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return ((0, jsx_runtime_1.jsx)("span", { role: 'button', tabIndex: 0, onClick: handleOpen, children: children }));
|
|
54
|
+
}, [children, setIsOpen]);
|
|
55
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [trigger, (0, jsx_runtime_1.jsxs)(uikit_product_mobile_modal_1.MobileModalCustom, { open: open, onClose: handleClose, size: searchable || virtualized ? 'full' : 'auto', children: [label && (0, jsx_runtime_1.jsx)(uikit_product_mobile_modal_1.MobileModalCustom.Header, { title: label }), searchable ? listJsx : (0, jsx_runtime_1.jsx)(uikit_product_mobile_modal_1.MobileModalCustom.Body, { className: styles_module_scss_1.default.bodyNoPadding, content: listJsx }), footer && (0, jsx_runtime_1.jsx)(uikit_product_mobile_modal_1.MobileModalCustom.Footer, { actions: footer })] })] }));
|
|
56
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./AdaptiveDroplist"), exports);
|
|
18
|
+
__exportStar(require("./AdaptiveDropdown"), exports);
|
|
19
|
+
__exportStar(require("./MobileDropdown"), exports);
|
|
20
|
+
__exportStar(require("./MobileDroplist"), exports);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
.modal{
|
|
2
|
+
box-sizing:border-box;
|
|
3
|
+
padding:var(--dimension-3m, 24px) 0;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.bodyNoPadding{
|
|
7
|
+
padding:0 !important;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.listWrapper{
|
|
11
|
+
font-family:var(--sans-body-m-font-family, SB Sans Interface);
|
|
12
|
+
font-weight:var(--sans-body-m-font-weight, Regular);
|
|
13
|
+
line-height:var(--sans-body-m-line-height, 20px);
|
|
14
|
+
font-size:var(--sans-body-m-font-size, 14px);
|
|
15
|
+
letter-spacing:var(--sans-body-m-letter-spacing, 0.1px);
|
|
16
|
+
paragraph-spacing:var(--sans-body-m-paragraph-spacing, 7.7px);
|
|
17
|
+
flex:1 1 auto;
|
|
18
|
+
box-sizing:border-box;
|
|
19
|
+
min-height:var(--dimension-2m, 16px);
|
|
20
|
+
color:var(--sys-neutral-text-main, #41424e);
|
|
21
|
+
padding:16px 0;
|
|
22
|
+
}
|
|
23
|
+
.listWrapper[data-virtualized]{
|
|
24
|
+
height:100%;
|
|
25
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export * from './components';
|
|
2
|
+
export { isBaseItemProps, isAccordionItemProps, isGroupItemProps, isGroupSelectItem, isNextListItemProps, } from '@snack-uikit/list';
|
|
3
|
+
export type { BaseItemProps, DroplistProps, GroupItemProps, GroupSelectItemProps, ItemContentProps, ItemId, NextListItemProps, SelectionMultipleState, SelectionSingleState, SelectionSingleValueType, } from '@snack-uikit/list';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.isNextListItemProps = exports.isGroupSelectItem = exports.isGroupItemProps = exports.isAccordionItemProps = exports.isBaseItemProps = void 0;
|
|
18
|
+
__exportStar(require("./components"), exports);
|
|
19
|
+
var list_1 = require("@snack-uikit/list");
|
|
20
|
+
Object.defineProperty(exports, "isBaseItemProps", { enumerable: true, get: function () { return list_1.isBaseItemProps; } });
|
|
21
|
+
Object.defineProperty(exports, "isAccordionItemProps", { enumerable: true, get: function () { return list_1.isAccordionItemProps; } });
|
|
22
|
+
Object.defineProperty(exports, "isGroupItemProps", { enumerable: true, get: function () { return list_1.isGroupItemProps; } });
|
|
23
|
+
Object.defineProperty(exports, "isGroupSelectItem", { enumerable: true, get: function () { return list_1.isGroupSelectItem; } });
|
|
24
|
+
Object.defineProperty(exports, "isNextListItemProps", { enumerable: true, get: function () { return list_1.isNextListItemProps; } });
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WithLayoutType } from '@sbercloud/uikit-product-utils';
|
|
2
|
+
import { DropdownProps } from '@snack-uikit/dropdown';
|
|
3
|
+
import { MobileDropdownProps } from '../MobileDropdown';
|
|
4
|
+
export type AdaptiveDropdownProps = WithLayoutType<DropdownProps & Pick<MobileDropdownProps, 'children'>>;
|
|
5
|
+
export declare function AdaptiveDropdown({ layoutType, children, ...dropdownProps }: AdaptiveDropdownProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export type { DropdownProps };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { Dropdown } from '@snack-uikit/dropdown';
|
|
14
|
+
import { MobileDropdown } from '../MobileDropdown';
|
|
15
|
+
export function AdaptiveDropdown(_a) {
|
|
16
|
+
var { layoutType, children } = _a, dropdownProps = __rest(_a, ["layoutType", "children"]);
|
|
17
|
+
const isMobile = layoutType === 'mobile';
|
|
18
|
+
return isMobile ? (_jsx(MobileDropdown, Object.assign({}, dropdownProps, { children: children }))) : (_jsx(Dropdown, Object.assign({}, dropdownProps, { children: children })));
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AdaptiveDropdown';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AdaptiveDropdown';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WithLayoutType } from '@sbercloud/uikit-product-utils';
|
|
2
|
+
import { DroplistProps } from '@snack-uikit/list';
|
|
3
|
+
import { MobileDroplistProps } from '../MobileDroplist';
|
|
4
|
+
export type AdaptiveDroplistProps = WithLayoutType<Omit<DroplistProps, 'children'> & Pick<MobileDroplistProps, 'children'>>;
|
|
5
|
+
export declare function AdaptiveDroplist({ layoutType, children, size, ...dropListProps }: AdaptiveDroplistProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export type { DroplistProps };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { Droplist } from '@snack-uikit/list';
|
|
14
|
+
import { MobileDroplist } from '../MobileDroplist';
|
|
15
|
+
export function AdaptiveDroplist(_a) {
|
|
16
|
+
var { layoutType, children, size } = _a, dropListProps = __rest(_a, ["layoutType", "children", "size"]);
|
|
17
|
+
const isMobile = layoutType === 'mobile';
|
|
18
|
+
return isMobile ? (_jsx(MobileDroplist, Object.assign({}, dropListProps, { children: children }))) : (_jsx(Droplist, Object.assign({}, dropListProps, { size: size, children: children })));
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AdaptiveDroplist';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AdaptiveDroplist';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PropsWithChildren, ReactNode } from 'react';
|
|
2
|
+
import { MobileModalCustomProps } from '@sbercloud/uikit-product-mobile-modal';
|
|
3
|
+
import { WithSupportProps } from '@snack-uikit/utils';
|
|
4
|
+
export type MobileDropdownProps = PropsWithChildren<WithSupportProps<{
|
|
5
|
+
open?: boolean;
|
|
6
|
+
onOpenChange?(value: boolean): void;
|
|
7
|
+
content: ReactNode;
|
|
8
|
+
closeOnPopstate?: boolean;
|
|
9
|
+
} & Pick<MobileModalCustomProps, 'size'>>>;
|
|
10
|
+
export declare function MobileDropdown({ open, onOpenChange, children, content, ...rest }: MobileDropdownProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { cloneElement, isValidElement, useMemo } from 'react';
|
|
14
|
+
import { useUncontrolledProp } from 'uncontrollable';
|
|
15
|
+
import { MobileModalCustom } from '@sbercloud/uikit-product-mobile-modal';
|
|
16
|
+
import styles from './styles.module.css';
|
|
17
|
+
export function MobileDropdown(_a) {
|
|
18
|
+
var { open, onOpenChange, children, content } = _a, rest = __rest(_a, ["open", "onOpenChange", "children", "content"]);
|
|
19
|
+
const [isOpen, setIsOpen] = useUncontrolledProp(open, false, onOpenChange);
|
|
20
|
+
const handleClose = () => setIsOpen(false);
|
|
21
|
+
const trigger = useMemo(() => {
|
|
22
|
+
const handleOpen = () => setIsOpen(true);
|
|
23
|
+
if (isValidElement(children)) {
|
|
24
|
+
return cloneElement(children, {
|
|
25
|
+
// todo: check if there is onClick
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
onClick: (event) => {
|
|
29
|
+
var _a, _b;
|
|
30
|
+
(_b = (_a = children.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, event);
|
|
31
|
+
handleOpen();
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return (_jsx("span", { role: 'button', tabIndex: 0, onClick: handleOpen, children: children }));
|
|
36
|
+
}, [children, setIsOpen]);
|
|
37
|
+
return (_jsxs(_Fragment, { children: [trigger, _jsx(MobileModalCustom, Object.assign({ open: isOpen, onClose: handleClose, className: styles.modal }, rest, { children: content }))] }));
|
|
38
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DroplistProps, ListProps } from '@snack-uikit/list';
|
|
2
|
+
import { MobileDropdownProps } from './MobileDropdown';
|
|
3
|
+
export type MobileDroplistProps = Omit<MobileDropdownProps, 'content'> & Pick<DroplistProps, 'closeDroplistOnItemClick'> & ListProps & {
|
|
4
|
+
label?: string;
|
|
5
|
+
virtualized?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function MobileDroplist({ items, selection, open: openProp, onOpenChange, children, search, label, footer, virtualized, closeDroplistOnItemClick, ...rest }: MobileDroplistProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
import { cloneElement, isValidElement, useMemo, useRef } from 'react';
|
|
14
|
+
import { MobileModalCustom } from '@sbercloud/uikit-product-mobile-modal';
|
|
15
|
+
import { List } from '@snack-uikit/list';
|
|
16
|
+
import { useValueControl } from '@snack-uikit/utils';
|
|
17
|
+
import styles from './styles.module.css';
|
|
18
|
+
export function MobileDroplist(_a) {
|
|
19
|
+
var { items, selection, open: openProp, onOpenChange, children, search, label, footer, virtualized, closeDroplistOnItemClick } = _a, rest = __rest(_a, ["items", "selection", "open", "onOpenChange", "children", "search", "label", "footer", "virtualized", "closeDroplistOnItemClick"]);
|
|
20
|
+
const scrollRef = useRef(null);
|
|
21
|
+
const [open = false, setIsOpen] = useValueControl({ value: openProp, onChange: onOpenChange });
|
|
22
|
+
const searchable = search;
|
|
23
|
+
const needCloseOnSelectItem = (selection === null || selection === void 0 ? void 0 : selection.mode) !== 'multiple' && closeDroplistOnItemClick;
|
|
24
|
+
const handleClose = () => setIsOpen(false);
|
|
25
|
+
const handleSelectItem = selectedItem => {
|
|
26
|
+
var _a;
|
|
27
|
+
if (needCloseOnSelectItem) {
|
|
28
|
+
handleClose();
|
|
29
|
+
}
|
|
30
|
+
(_a = selection === null || selection === void 0 ? void 0 : selection.onChange) === null || _a === void 0 ? void 0 : _a.call(selection, selectedItem);
|
|
31
|
+
};
|
|
32
|
+
const listJsx = (_jsx("div", { className: styles.listWrapper, "data-virtualized": virtualized || undefined, children: _jsx(List, Object.assign({ items: items, selection: selection && Object.assign(Object.assign({}, selection), { onChange: handleSelectItem }), size: 'l', search: searchable ? search : undefined, scrollRef: searchable || virtualized ? scrollRef : undefined, scroll: virtualized, virtualized: virtualized }, rest)) }));
|
|
33
|
+
const trigger = useMemo(() => {
|
|
34
|
+
const handleOpen = () => setIsOpen(true);
|
|
35
|
+
if (isValidElement(children)) {
|
|
36
|
+
return cloneElement(children, {
|
|
37
|
+
// todo: check if there is onClick
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
onClick: (event) => {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
(_b = (_a = children.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, event);
|
|
43
|
+
handleOpen();
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return (_jsx("span", { role: 'button', tabIndex: 0, onClick: handleOpen, children: children }));
|
|
48
|
+
}, [children, setIsOpen]);
|
|
49
|
+
return (_jsxs(_Fragment, { children: [trigger, _jsxs(MobileModalCustom, { open: open, onClose: handleClose, size: searchable || virtualized ? 'full' : 'auto', children: [label && _jsx(MobileModalCustom.Header, { title: label }), searchable ? listJsx : _jsx(MobileModalCustom.Body, { className: styles.bodyNoPadding, content: listJsx }), footer && _jsx(MobileModalCustom.Footer, { actions: footer })] })] }));
|
|
50
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
.modal{
|
|
2
|
+
box-sizing:border-box;
|
|
3
|
+
padding:var(--dimension-3m, 24px) 0;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.bodyNoPadding{
|
|
7
|
+
padding:0 !important;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.listWrapper{
|
|
11
|
+
font-family:var(--sans-body-m-font-family, SB Sans Interface);
|
|
12
|
+
font-weight:var(--sans-body-m-font-weight, Regular);
|
|
13
|
+
line-height:var(--sans-body-m-line-height, 20px);
|
|
14
|
+
font-size:var(--sans-body-m-font-size, 14px);
|
|
15
|
+
letter-spacing:var(--sans-body-m-letter-spacing, 0.1px);
|
|
16
|
+
paragraph-spacing:var(--sans-body-m-paragraph-spacing, 7.7px);
|
|
17
|
+
flex:1 1 auto;
|
|
18
|
+
box-sizing:border-box;
|
|
19
|
+
min-height:var(--dimension-2m, 16px);
|
|
20
|
+
color:var(--sys-neutral-text-main, #41424e);
|
|
21
|
+
padding:16px 0;
|
|
22
|
+
}
|
|
23
|
+
.listWrapper[data-virtualized]{
|
|
24
|
+
height:100%;
|
|
25
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export * from './components';
|
|
2
|
+
export { isBaseItemProps, isAccordionItemProps, isGroupItemProps, isGroupSelectItem, isNextListItemProps, } from '@snack-uikit/list';
|
|
3
|
+
export type { BaseItemProps, DroplistProps, GroupItemProps, GroupSelectItemProps, ItemContentProps, ItemId, NextListItemProps, SelectionMultipleState, SelectionSingleState, SelectionSingleValueType, } from '@snack-uikit/list';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloud-ru/uikit-product-mobile-dropdown",
|
|
3
3
|
"title": "Mobile Dropdown",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.23",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"*.css",
|
|
7
7
|
"*.woff",
|
|
@@ -30,18 +30,19 @@
|
|
|
30
30
|
"name": "Akhremenko Grigorii",
|
|
31
31
|
"url": "https://github.com/AGrigorii"
|
|
32
32
|
},
|
|
33
|
+
"contributors": [],
|
|
33
34
|
"license": "Apache-2.0",
|
|
34
35
|
"publishConfig": {
|
|
35
36
|
"access": "public"
|
|
36
37
|
},
|
|
37
38
|
"scripts": {},
|
|
38
39
|
"dependencies": {
|
|
39
|
-
"@cloud-ru/uikit-product-mobile-modal": "0.9.
|
|
40
|
-
"@cloud-ru/uikit-product-utils": "7.0.
|
|
40
|
+
"@cloud-ru/uikit-product-mobile-modal": "0.9.20",
|
|
41
|
+
"@cloud-ru/uikit-product-utils": "7.0.2",
|
|
41
42
|
"@snack-uikit/dropdown": "0.5.2",
|
|
42
43
|
"@snack-uikit/list": "0.32.1",
|
|
43
44
|
"@snack-uikit/utils": "3.10.1",
|
|
44
45
|
"uncontrollable": "8.0.4"
|
|
45
46
|
},
|
|
46
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "bf479ecf7238ef20b78f20acaef439efa535d1a1"
|
|
47
48
|
}
|