@bifrostui/react 1.0.5 → 1.1.5
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/dist/ActionSheet/ActionSheet.less +31 -0
- package/dist/ActionSheet/ActionSheetItem.less +62 -0
- package/dist/Alert/index.less +112 -0
- package/dist/Avatar/Avatar.less +52 -0
- package/dist/Avatar/AvatarGroup.less +39 -0
- package/dist/Backdrop/{Backdrop.css → Backdrop.less} +4 -3
- package/dist/Badge/Badge.less +118 -0
- package/dist/Button/Button.less +244 -0
- package/dist/Calendar/Calendar.less +126 -0
- package/{es/Card/Card.css → dist/Card/Card.less} +1 -0
- package/dist/Card/CardHeader.less +53 -0
- package/dist/Checkbox/Checkbox.less +55 -0
- package/dist/CitySelector/CitySelector.d.ts +4 -0
- package/dist/CitySelector/CitySelector.js +36 -0
- package/dist/CitySelector/CitySelector.less +122 -0
- package/dist/CitySelector/CitySelector.miniapp.d.ts +5 -0
- package/dist/CitySelector/CitySelector.miniapp.js +79 -0
- package/dist/CitySelector/CitySelector.types.d.ts +47 -0
- package/dist/CitySelector/CitySelector.types.js +5 -0
- package/dist/CitySelector/CitySelectorCore.d.ts +5 -0
- package/dist/CitySelector/CitySelectorCore.js +183 -0
- package/dist/CitySelector/Selector/index.d.ts +9 -0
- package/dist/CitySelector/Selector/index.js +22 -0
- package/dist/CitySelector/Selector/index.less +13 -0
- package/dist/CitySelector/index.d.ts +2 -0
- package/dist/CitySelector/index.js +34 -0
- package/dist/CitySelector/miniapp.less +4 -0
- package/dist/Countdown/Countdown.less +39 -0
- package/dist/Divider/Divider.less +50 -0
- package/dist/Drawer/Drawer.less +40 -0
- package/dist/IconButton/IconButton.less +167 -0
- package/dist/Image/index.less +40 -0
- package/dist/Input/Input.less +72 -0
- package/dist/List/{List.css → List.less} +1 -0
- package/dist/List/{ListItem.css → ListItem.less} +17 -6
- package/dist/List/{ListItemContent.css → ListItemContent.less} +7 -2
- package/dist/List/{ListItemFooter.css → ListItemFooter.less} +4 -3
- package/dist/Loading/Loading.less +40 -0
- package/dist/Modal/{Modal.css → Modal.less} +8 -6
- package/dist/Modal/Modal.miniapp.d.ts +16 -0
- package/dist/Modal/Modal.miniapp.js +73 -0
- package/dist/NavBar/NavBar.less +67 -0
- package/dist/Picker/Picker.d.ts +5 -0
- package/dist/Picker/Picker.js +155 -0
- package/dist/Picker/Picker.less +62 -0
- package/dist/Picker/Picker.types.d.ts +98 -0
- package/dist/Picker/Picker.types.js +5 -0
- package/dist/Picker/PickerPanel.d.ts +5 -0
- package/dist/Picker/PickerPanel.js +210 -0
- package/dist/Picker/PickerPanel.less +67 -0
- package/dist/Picker/index.d.ts +2 -0
- package/dist/Picker/index.js +34 -0
- package/dist/Picker/utils.d.ts +13 -0
- package/dist/Picker/utils.js +66 -0
- package/dist/Progress/Progress.less +24 -0
- package/dist/Radio/Radio.less +81 -0
- package/dist/Rating/Rating.less +64 -0
- package/dist/ScrollView/{ScrollView.css → ScrollView.less} +4 -0
- package/dist/Select/Select.less +105 -0
- package/dist/Skeleton/Skeleton.less +72 -0
- package/dist/Slider/Slider.less +108 -0
- package/dist/Stack/demo/index.less +27 -0
- package/dist/Steps/Step.less +228 -0
- package/{es/Steps/Steps.css → dist/Steps/Steps.less} +5 -3
- package/dist/Swiper/Swiper.less +25 -0
- package/dist/Switch/Switch.less +177 -0
- package/dist/TabBar/TabBarItem.less +54 -0
- package/dist/Tabs/Tab.js +1 -1
- package/dist/Tabs/Tab.less +60 -0
- package/dist/Tabs/TabPanel.less +11 -0
- package/dist/Tabs/Tabs.less +77 -0
- package/dist/Tag/Tag.less +119 -0
- package/dist/Tag/TagGroup.less +52 -0
- package/dist/TextArea/{TextArea.css → TextArea.less} +27 -19
- package/dist/index.d.ts +2 -0
- package/dist/index.js +22 -0
- package/es/ActionSheet/ActionSheet.less +31 -0
- package/es/ActionSheet/ActionSheetItem.less +62 -0
- package/es/Alert/index.less +112 -0
- package/es/Avatar/Avatar.less +52 -0
- package/es/Avatar/AvatarGroup.less +39 -0
- package/es/Backdrop/{Backdrop.css → Backdrop.less} +4 -3
- package/es/Badge/Badge.less +118 -0
- package/es/Button/Button.less +244 -0
- package/es/Calendar/Calendar.less +126 -0
- package/{dist/Card/Card.css → es/Card/Card.less} +1 -0
- package/es/Card/CardHeader.less +53 -0
- package/es/Checkbox/Checkbox.less +55 -0
- package/es/CitySelector/CitySelector.d.ts +4 -0
- package/es/CitySelector/CitySelector.js +36 -0
- package/es/CitySelector/CitySelector.less +122 -0
- package/es/CitySelector/CitySelector.miniapp.d.ts +5 -0
- package/es/CitySelector/CitySelector.miniapp.js +77 -0
- package/es/CitySelector/CitySelector.types.d.ts +47 -0
- package/es/CitySelector/CitySelector.types.js +1 -0
- package/es/CitySelector/CitySelectorCore.d.ts +5 -0
- package/es/CitySelector/CitySelectorCore.js +194 -0
- package/es/CitySelector/Selector/index.d.ts +9 -0
- package/es/CitySelector/Selector/index.js +13 -0
- package/es/CitySelector/Selector/index.less +13 -0
- package/es/CitySelector/index.d.ts +2 -0
- package/es/CitySelector/index.js +2 -0
- package/es/CitySelector/miniapp.less +4 -0
- package/es/Countdown/Countdown.less +39 -0
- package/es/Divider/Divider.less +50 -0
- package/es/Drawer/Drawer.less +40 -0
- package/es/IconButton/IconButton.less +167 -0
- package/es/Image/index.less +40 -0
- package/es/Input/Input.less +72 -0
- package/es/List/{List.css → List.less} +1 -0
- package/es/List/{ListItem.css → ListItem.less} +17 -6
- package/es/List/{ListItemContent.css → ListItemContent.less} +7 -2
- package/es/List/{ListItemFooter.css → ListItemFooter.less} +4 -3
- package/es/Loading/Loading.less +40 -0
- package/es/Modal/{Modal.css → Modal.less} +8 -6
- package/es/Modal/Modal.miniapp.d.ts +16 -0
- package/es/Modal/Modal.miniapp.js +78 -0
- package/es/NavBar/NavBar.less +67 -0
- package/es/Picker/Picker.d.ts +5 -0
- package/es/Picker/Picker.js +171 -0
- package/es/Picker/Picker.less +62 -0
- package/es/Picker/Picker.types.d.ts +98 -0
- package/es/Picker/Picker.types.js +1 -0
- package/es/Picker/PickerPanel.d.ts +5 -0
- package/es/Picker/PickerPanel.js +234 -0
- package/es/Picker/PickerPanel.less +67 -0
- package/es/Picker/index.d.ts +2 -0
- package/es/Picker/index.js +2 -0
- package/es/Picker/utils.d.ts +13 -0
- package/es/Picker/utils.js +65 -0
- package/es/Progress/Progress.less +24 -0
- package/es/Radio/Radio.less +81 -0
- package/es/Rating/Rating.less +64 -0
- package/es/ScrollView/{ScrollView.css → ScrollView.less} +4 -0
- package/es/Select/Select.less +105 -0
- package/es/Skeleton/Skeleton.less +72 -0
- package/es/Slider/Slider.less +108 -0
- package/es/Stack/demo/index.less +27 -0
- package/es/Steps/Step.less +228 -0
- package/{dist/Steps/Steps.css → es/Steps/Steps.less} +5 -3
- package/es/Swiper/Swiper.less +25 -0
- package/es/Switch/Switch.less +177 -0
- package/es/TabBar/TabBarItem.less +54 -0
- package/es/Tabs/Tab.js +1 -1
- package/es/Tabs/Tab.less +60 -0
- package/es/Tabs/TabPanel.less +11 -0
- package/es/Tabs/Tabs.less +77 -0
- package/es/Tag/Tag.less +119 -0
- package/es/Tag/TagGroup.less +52 -0
- package/es/TextArea/{TextArea.css → TextArea.less} +27 -19
- package/es/index.d.ts +2 -0
- package/es/index.js +3 -1
- package/package.json +6 -6
- package/dist/ActionSheet/ActionSheet.css +0 -27
- package/dist/ActionSheet/ActionSheetItem.css +0 -51
- package/dist/Alert/index.css +0 -89
- package/dist/Avatar/Avatar.css +0 -43
- package/dist/Avatar/AvatarGroup.css +0 -31
- package/dist/Badge/Badge.css +0 -95
- package/dist/Button/Button.css +0 -200
- package/dist/Calendar/Calendar.css +0 -105
- package/dist/Card/CardHeader.css +0 -45
- package/dist/Checkbox/Checkbox.css +0 -45
- package/dist/Countdown/Countdown.css +0 -28
- package/dist/Divider/Divider.css +0 -41
- package/dist/Drawer/Drawer.css +0 -35
- package/dist/IconButton/IconButton.css +0 -130
- package/dist/Image/index.css +0 -35
- package/dist/Input/Input.css +0 -59
- package/dist/Loading/Loading.css +0 -31
- package/dist/NavBar/NavBar.css +0 -57
- package/dist/Progress/Progress.css +0 -22
- package/dist/Radio/Radio.css +0 -65
- package/dist/Rating/Rating.css +0 -52
- package/dist/Select/Select.css +0 -89
- package/dist/Skeleton/Skeleton.css +0 -54
- package/dist/Slider/Slider.css +0 -95
- package/dist/Stack/demo/index.css +0 -23
- package/dist/Steps/Step.css +0 -174
- package/dist/Swiper/Swiper.css +0 -20
- package/dist/Switch/Switch.css +0 -127
- package/dist/TabBar/TabBarItem.css +0 -38
- package/dist/Tabs/Tab.css +0 -52
- package/dist/Tabs/TabPanel.css +0 -9
- package/dist/Tabs/Tabs.css +0 -56
- package/dist/Tag/Tag.css +0 -97
- package/dist/Tag/TagGroup.css +0 -43
- package/es/ActionSheet/ActionSheet.css +0 -27
- package/es/ActionSheet/ActionSheetItem.css +0 -51
- package/es/Alert/index.css +0 -89
- package/es/Avatar/Avatar.css +0 -43
- package/es/Avatar/AvatarGroup.css +0 -31
- package/es/Badge/Badge.css +0 -95
- package/es/Button/Button.css +0 -200
- package/es/Calendar/Calendar.css +0 -105
- package/es/Card/CardHeader.css +0 -45
- package/es/Checkbox/Checkbox.css +0 -45
- package/es/Countdown/Countdown.css +0 -28
- package/es/Divider/Divider.css +0 -41
- package/es/Drawer/Drawer.css +0 -35
- package/es/IconButton/IconButton.css +0 -130
- package/es/Image/index.css +0 -35
- package/es/Input/Input.css +0 -59
- package/es/Loading/Loading.css +0 -31
- package/es/NavBar/NavBar.css +0 -57
- package/es/Progress/Progress.css +0 -22
- package/es/Radio/Radio.css +0 -65
- package/es/Rating/Rating.css +0 -52
- package/es/Select/Select.css +0 -89
- package/es/Skeleton/Skeleton.css +0 -54
- package/es/Slider/Slider.css +0 -95
- package/es/Stack/demo/index.css +0 -23
- package/es/Steps/Step.css +0 -174
- package/es/Swiper/Swiper.css +0 -20
- package/es/Switch/Switch.css +0 -127
- package/es/TabBar/TabBarItem.css +0 -38
- package/es/Tabs/Tab.css +0 -52
- package/es/Tabs/TabPanel.css +0 -9
- package/es/Tabs/Tabs.css +0 -56
- package/es/Tag/Tag.css +0 -97
- package/es/Tag/TagGroup.css +0 -43
- /package/dist/Card/{CardContent.css → CardContent.less} +0 -0
- /package/dist/Card/{CardFooter.css → CardFooter.less} +0 -0
- /package/dist/List/{ListItemExtra.css → ListItemExtra.less} +0 -0
- /package/dist/List/{ListItemHeader.css → ListItemHeader.less} +0 -0
- /package/dist/Stack/{Stack.css → Stack.less} +0 -0
- /package/dist/TabBar/{TabBar.css → TabBar.less} +0 -0
- /package/es/Card/{CardContent.css → CardContent.less} +0 -0
- /package/es/Card/{CardFooter.css → CardFooter.less} +0 -0
- /package/es/List/{ListItemExtra.css → ListItemExtra.less} +0 -0
- /package/es/List/{ListItemHeader.css → ListItemHeader.less} +0 -0
- /package/es/Stack/{Stack.css → Stack.less} +0 -0
- /package/es/TabBar/{TabBar.css → TabBar.less} +0 -0
|
@@ -4,20 +4,31 @@
|
|
|
4
4
|
align-items: center;
|
|
5
5
|
font-family: var(--bui-font-family);
|
|
6
6
|
}
|
|
7
|
+
|
|
7
8
|
.bui-list-item-disabled {
|
|
8
9
|
pointer-events: none;
|
|
9
10
|
background-color: var(--bui-color-bg-default);
|
|
10
11
|
color: var(--bui-color-fg-subtle);
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
.bui-list-small {
|
|
15
|
+
.bui-list-item {
|
|
16
|
+
padding: 5px 12px;
|
|
17
|
+
}
|
|
14
18
|
}
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
|
|
20
|
+
.bui-list-medium {
|
|
21
|
+
.bui-list-item {
|
|
22
|
+
padding: 18px 12px;
|
|
23
|
+
}
|
|
17
24
|
}
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
|
|
26
|
+
.bui-list-large {
|
|
27
|
+
.bui-list-item {
|
|
28
|
+
padding: 20px 12px;
|
|
29
|
+
}
|
|
20
30
|
}
|
|
31
|
+
|
|
21
32
|
.bui-list-item-divider:not(:last-child) {
|
|
22
33
|
border-bottom: 1px solid var(--bui-color-border-default);
|
|
23
34
|
}
|
|
@@ -6,12 +6,17 @@
|
|
|
6
6
|
width: 100%;
|
|
7
7
|
font-family: var(--bui-font-family);
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
|
|
10
|
+
.bui-list-small {
|
|
11
|
+
.bui-list-item-content {
|
|
12
|
+
font-size: var(--bui-text-size-2);
|
|
13
|
+
}
|
|
11
14
|
}
|
|
15
|
+
|
|
12
16
|
.bui-list-item-content-primary {
|
|
13
17
|
flex: 1 1 auto;
|
|
14
18
|
}
|
|
19
|
+
|
|
15
20
|
.bui-list-item-content-secondary {
|
|
16
21
|
font-size: 13px;
|
|
17
22
|
color: var(--bui-color-fg-muted);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
@import '~@bifrostui/styles/mixins/index.less';
|
|
2
|
+
|
|
3
|
+
.bui-loading {
|
|
4
|
+
--animation-duration: var(--bui-loading-animation-duration, 1.6s);
|
|
5
|
+
|
|
6
|
+
width: fit-content;
|
|
7
|
+
display: flex;
|
|
8
|
+
justify-content: center;
|
|
9
|
+
align-items: center;
|
|
10
|
+
padding: var(--bui-spacing-md);
|
|
11
|
+
font-family: var(--bui-font-family);
|
|
12
|
+
|
|
13
|
+
&-icon {
|
|
14
|
+
font-size: 30px;
|
|
15
|
+
animation: loading var(--animation-duration) linear infinite;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&-text {
|
|
19
|
+
padding: 10px;
|
|
20
|
+
font-size: var(--bui-title-size-3);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&-vertical {
|
|
24
|
+
flex-direction: row;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&-horizontal {
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@keyframes loading {
|
|
32
|
+
0% {
|
|
33
|
+
transform: rotate(0deg);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
100% {
|
|
37
|
+
transform: rotate(360deg);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -6,10 +6,12 @@
|
|
|
6
6
|
top: 0;
|
|
7
7
|
z-index: var(--bui-z-index-modal);
|
|
8
8
|
font-family: var(--bui-font-family);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
|
|
10
|
+
&-exited {
|
|
11
|
+
visibility: hidden;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&-backdrop {
|
|
15
|
+
z-index: -1;
|
|
16
|
+
}
|
|
15
17
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ViewProps } from '@tarojs/components';
|
|
3
|
+
import './Modal.less';
|
|
4
|
+
declare const Modal: React.ForwardRefExoticComponent<Omit<ViewProps & {
|
|
5
|
+
open?: boolean;
|
|
6
|
+
container?: Element | (() => Element);
|
|
7
|
+
hideBackdrop?: boolean;
|
|
8
|
+
BackdropProps?: Partial<import("../Backdrop").BackdropProps>;
|
|
9
|
+
onClose?: (e: React.SyntheticEvent<Element, Event>, detail: import("./Modal.types").CloseDetail) => void;
|
|
10
|
+
disableScrollLock?: boolean;
|
|
11
|
+
disablePortal?: boolean;
|
|
12
|
+
keepMounted?: boolean;
|
|
13
|
+
} & import("../../../bui-types/src").ICommonProps & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
14
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
15
|
+
}, "open" | keyof import("../../../bui-types/src").ICommonProps | "container" | "disablePortal" | "hideBackdrop" | "BackdropProps" | "onClose" | "disableScrollLock" | "keepMounted">, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
16
|
+
export default Modal;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _utils = require("@bifrostui/utils");
|
|
8
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _components = require("@tarojs/components");
|
|
11
|
+
var _Backdrop = _interopRequireDefault(require("../Backdrop"));
|
|
12
|
+
var _Portal = _interopRequireDefault(require("../Portal"));
|
|
13
|
+
require("./Modal.css");
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
|
+
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 && Object.prototype.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; }
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
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); }
|
|
18
|
+
const prefixCls = 'bui-modal';
|
|
19
|
+
const Modal = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
20
|
+
const {
|
|
21
|
+
className,
|
|
22
|
+
open,
|
|
23
|
+
BackdropProps,
|
|
24
|
+
children,
|
|
25
|
+
container,
|
|
26
|
+
disablePortal,
|
|
27
|
+
disableScrollLock,
|
|
28
|
+
hideBackdrop,
|
|
29
|
+
onClose,
|
|
30
|
+
keepMounted,
|
|
31
|
+
...others
|
|
32
|
+
} = props;
|
|
33
|
+
const modalRef = _react.default.useRef(null);
|
|
34
|
+
const handleRef = (0, _utils.useForkRef)(modalRef, ref);
|
|
35
|
+
const [backdropExited, setBackDropExited] = (0, _react.useState)(hideBackdrop || !open);
|
|
36
|
+
const mounted = open || !backdropExited || keepMounted;
|
|
37
|
+
const handleBackdropClick = event => {
|
|
38
|
+
if (event.target.id !== event.currentTarget.id) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (onClose) {
|
|
42
|
+
onClose(event, {
|
|
43
|
+
from: 'backdrop'
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
if (!mounted) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
return /*#__PURE__*/_react.default.createElement(_Portal.default, {
|
|
51
|
+
container: container,
|
|
52
|
+
disablePortal: disablePortal
|
|
53
|
+
}, /*#__PURE__*/_react.default.createElement(_components.View, _extends({
|
|
54
|
+
className: (0, _clsx.default)(prefixCls, className),
|
|
55
|
+
ref: handleRef,
|
|
56
|
+
catchMove: !disableScrollLock
|
|
57
|
+
}, others), !hideBackdrop ? /*#__PURE__*/_react.default.createElement(_Backdrop.default, _extends({
|
|
58
|
+
open: open,
|
|
59
|
+
onClick: handleBackdropClick,
|
|
60
|
+
onEnter: () => setBackDropExited(false),
|
|
61
|
+
onExited: () => setBackDropExited(true)
|
|
62
|
+
}, BackdropProps, {
|
|
63
|
+
className: (0, _clsx.default)(`${prefixCls}-backdrop`, BackdropProps?.className)
|
|
64
|
+
})) : null, (open || keepMounted) && children));
|
|
65
|
+
});
|
|
66
|
+
Modal.displayName = 'BuiModal';
|
|
67
|
+
Modal.defaultProps = {
|
|
68
|
+
open: false,
|
|
69
|
+
disablePortal: false,
|
|
70
|
+
disableScrollLock: false,
|
|
71
|
+
hideBackdrop: false
|
|
72
|
+
};
|
|
73
|
+
var _default = exports.default = Modal;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
@import '~@bifrostui/styles/mixins/index.less';
|
|
2
|
+
|
|
3
|
+
.bui-navbar {
|
|
4
|
+
--height: var(--bui-navbar-height, 45px);
|
|
5
|
+
--icon-size: var(--bui-navbar-icon-size, 24px);
|
|
6
|
+
--background-color: var(
|
|
7
|
+
--bui-navbar-background-color,
|
|
8
|
+
var(--bui-color-white)
|
|
9
|
+
);
|
|
10
|
+
--border-bottom: var(--bui-navbar-border-bottom, none);
|
|
11
|
+
--z-index: var(--bui-navbar-z-index, auto);
|
|
12
|
+
|
|
13
|
+
position: relative;
|
|
14
|
+
width: 100%;
|
|
15
|
+
height: var(--height);
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
padding: 0 8px;
|
|
18
|
+
display: flex;
|
|
19
|
+
justify-content: center;
|
|
20
|
+
align-items: center;
|
|
21
|
+
background-color: var(--background-color);
|
|
22
|
+
border-bottom: var(--border-bottom);
|
|
23
|
+
user-select: none;
|
|
24
|
+
z-index: var(--z-index);
|
|
25
|
+
font-family: var(--bui-font-family);
|
|
26
|
+
|
|
27
|
+
&-fixed {
|
|
28
|
+
position: fixed;
|
|
29
|
+
top: 0;
|
|
30
|
+
left: 0;
|
|
31
|
+
width: 100%;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&-title {
|
|
35
|
+
max-width: 60%;
|
|
36
|
+
padding: 0 8px;
|
|
37
|
+
font-size: var(--bui-title-size-2);
|
|
38
|
+
.ellipsis();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&-left,
|
|
42
|
+
&-right {
|
|
43
|
+
flex: 1;
|
|
44
|
+
display: flex;
|
|
45
|
+
align-items: center;
|
|
46
|
+
font-size: var(--bui-title-size-3);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&-left {
|
|
50
|
+
justify-content: flex-start;
|
|
51
|
+
text-align: left;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&-right {
|
|
55
|
+
justify-content: flex-end;
|
|
56
|
+
text-align: right;
|
|
57
|
+
align-self: stretch;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
&-icon {
|
|
61
|
+
font-size: var(--icon-size);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&-placeholder {
|
|
65
|
+
width: 100%;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _Drawer = _interopRequireDefault(require("../Drawer"));
|
|
10
|
+
var _PickerPanel = _interopRequireDefault(require("./PickerPanel"));
|
|
11
|
+
var _utils = require("./utils");
|
|
12
|
+
require("./Picker.css");
|
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (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 && Object.prototype.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 _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
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); }
|
|
17
|
+
const prefixCls = 'bui-picker';
|
|
18
|
+
const Picker = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
19
|
+
const {
|
|
20
|
+
className,
|
|
21
|
+
open = false,
|
|
22
|
+
title,
|
|
23
|
+
options = [],
|
|
24
|
+
value,
|
|
25
|
+
contentProps,
|
|
26
|
+
onConfirm,
|
|
27
|
+
onOptionChange,
|
|
28
|
+
onCancel,
|
|
29
|
+
onClose,
|
|
30
|
+
...others
|
|
31
|
+
} = props;
|
|
32
|
+
const pickerType = (0, _utils.pickerPanelType)(options);
|
|
33
|
+
const [columns, setColumns] = (0, _react.useState)([]);
|
|
34
|
+
const [internalValue, setInternalValue] = (0, _react.useState)([]);
|
|
35
|
+
(0, _react.useEffect)(() => {
|
|
36
|
+
if (!open) return;
|
|
37
|
+
|
|
38
|
+
// 初始化默认选中数据
|
|
39
|
+
const formatted = (0, _utils.formatOptions)(value, options);
|
|
40
|
+
const initialValue = [];
|
|
41
|
+
(formatted || []).forEach(item => {
|
|
42
|
+
initialValue.push(item?.[0]?.value);
|
|
43
|
+
});
|
|
44
|
+
const defaultValue = value?.length ? value : initialValue;
|
|
45
|
+
if (defaultValue?.length) {
|
|
46
|
+
setInternalValue(defaultValue);
|
|
47
|
+
}
|
|
48
|
+
}, [open, value, options]);
|
|
49
|
+
(0, _react.useEffect)(() => {
|
|
50
|
+
if (options?.length) {
|
|
51
|
+
const formatted = (0, _utils.formatOptions)(value, options);
|
|
52
|
+
setColumns(formatted);
|
|
53
|
+
}
|
|
54
|
+
}, [value, options]);
|
|
55
|
+
const confirm = e => {
|
|
56
|
+
const payload = {
|
|
57
|
+
value: internalValue,
|
|
58
|
+
options: columns
|
|
59
|
+
};
|
|
60
|
+
onConfirm?.(e, payload);
|
|
61
|
+
onClose?.(e, {
|
|
62
|
+
from: 'confirm',
|
|
63
|
+
...payload
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
const cancel = e => {
|
|
67
|
+
onCancel?.(e);
|
|
68
|
+
onClose?.(e, {
|
|
69
|
+
from: 'cancel',
|
|
70
|
+
value: internalValue,
|
|
71
|
+
options: columns
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
const updateItem = (e, columnOption, columnIndex) => {
|
|
75
|
+
const columnValues = internalValue?.slice(0, columnIndex) || [];
|
|
76
|
+
let colIndex = columnIndex;
|
|
77
|
+
let colOption = columnOption;
|
|
78
|
+
if (colOption && Object.keys(colOption).length) {
|
|
79
|
+
if (columnValues[columnIndex] === columnOption.value) return;
|
|
80
|
+
if (pickerType === 'cascade') {
|
|
81
|
+
columnValues[colIndex] = colOption.value || '';
|
|
82
|
+
while (colOption?.children?.[0]) {
|
|
83
|
+
columnValues[colIndex + 1] = colOption.children[0].value;
|
|
84
|
+
colIndex += 1;
|
|
85
|
+
colOption = {
|
|
86
|
+
...(colOption?.children?.[0] || {})
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
// 当前改变列的下一列 children 值为空
|
|
90
|
+
if (colOption?.children?.length) {
|
|
91
|
+
columnValues[columnIndex + 1] = '';
|
|
92
|
+
}
|
|
93
|
+
const conbineValues = [...(internalValue?.slice(0, columnIndex) || []), ...columnValues.slice(columnIndex)];
|
|
94
|
+
const formatted = (0, _utils.formatOptions)(conbineValues, options);
|
|
95
|
+
setColumns(formatted);
|
|
96
|
+
setInternalValue(conbineValues);
|
|
97
|
+
onOptionChange?.(e, {
|
|
98
|
+
value: conbineValues,
|
|
99
|
+
options: formatted,
|
|
100
|
+
currentOption: columnOption
|
|
101
|
+
});
|
|
102
|
+
} else {
|
|
103
|
+
const result = internalValue;
|
|
104
|
+
result[columnIndex] = columnOption.value;
|
|
105
|
+
setInternalValue(result);
|
|
106
|
+
onOptionChange?.(e, {
|
|
107
|
+
value: result,
|
|
108
|
+
options,
|
|
109
|
+
currentOption: columnOption
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const handleSelect = (e, {
|
|
115
|
+
columnIndex,
|
|
116
|
+
columnOption
|
|
117
|
+
}) => {
|
|
118
|
+
updateItem(e, columnOption, columnIndex);
|
|
119
|
+
};
|
|
120
|
+
const handleClose = (e, data) => {
|
|
121
|
+
onClose?.(e, {
|
|
122
|
+
value: internalValue,
|
|
123
|
+
options: columns,
|
|
124
|
+
...data
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
return /*#__PURE__*/_react.default.createElement(_Drawer.default, _extends({
|
|
128
|
+
ref: ref,
|
|
129
|
+
open: open,
|
|
130
|
+
className: (0, _clsx.default)(prefixCls, className),
|
|
131
|
+
onClose: handleClose
|
|
132
|
+
}, others), /*#__PURE__*/_react.default.createElement("div", _extends({}, contentProps, {
|
|
133
|
+
className: (0, _clsx.default)(`${prefixCls}-content`, contentProps?.className)
|
|
134
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
135
|
+
className: `${prefixCls}-header`
|
|
136
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
137
|
+
className: `${prefixCls}-cancel`,
|
|
138
|
+
onClick: cancel
|
|
139
|
+
}, "\u53D6\u6D88"), title && /*#__PURE__*/_react.default.createElement("div", {
|
|
140
|
+
className: `${prefixCls}-title`
|
|
141
|
+
}, title), /*#__PURE__*/_react.default.createElement("div", {
|
|
142
|
+
className: `${prefixCls}-confirm`,
|
|
143
|
+
onClick: confirm
|
|
144
|
+
}, "\u786E\u8BA4")), /*#__PURE__*/_react.default.createElement("div", {
|
|
145
|
+
className: `${prefixCls}-container`
|
|
146
|
+
}, columns.map((column, index) => /*#__PURE__*/_react.default.createElement(_PickerPanel.default, {
|
|
147
|
+
key: index,
|
|
148
|
+
options: column,
|
|
149
|
+
columnIndex: index,
|
|
150
|
+
defaultValue: internalValue?.[index],
|
|
151
|
+
onSelect: handleSelect
|
|
152
|
+
})))));
|
|
153
|
+
});
|
|
154
|
+
Picker.displayName = 'BuiPicker';
|
|
155
|
+
var _default = exports.default = Picker;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
@import '~@bifrostui/styles/mixins/index.less';
|
|
2
|
+
|
|
3
|
+
.bui-picker {
|
|
4
|
+
--cancel-color: var(--bui-color-fg-default);
|
|
5
|
+
--cancel-font-size: var(--bui-title-size-4, 15px);
|
|
6
|
+
--confirm-color: var(--bui-color-primary);
|
|
7
|
+
--confirm-font-size: var(--bui-title-size-4, 15px);
|
|
8
|
+
--title-color: var(--bui-color-fg-default);
|
|
9
|
+
--title-font-size: var(--bui-title-size-3, 16px);
|
|
10
|
+
--title-font-weight: var(--bui-font-weight-medium, 500);
|
|
11
|
+
--panel-container-height: 260px;
|
|
12
|
+
--indicator-top: 108px;
|
|
13
|
+
--indicator-height: 36px;
|
|
14
|
+
--indicator-border-color: var(--bui-color-border-default);
|
|
15
|
+
--option-color: var(--bui-color-fg-default);
|
|
16
|
+
--option-font-size: var(--bui-title-size-4);
|
|
17
|
+
--option-height: 36px;
|
|
18
|
+
font-family: var(--bui-font-family);
|
|
19
|
+
|
|
20
|
+
.bui-drawer-content {
|
|
21
|
+
border-radius: var(--bui-shape-radius-drawer) var(--bui-shape-radius-drawer)
|
|
22
|
+
0 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&-header {
|
|
26
|
+
height: 50px;
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
justify-content: space-between;
|
|
30
|
+
padding: 0 var(--bui-spacing-lg);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&-cancel {
|
|
34
|
+
width: 40px;
|
|
35
|
+
height: 100%;
|
|
36
|
+
font-size: var(--cancel-font-size);
|
|
37
|
+
text-align: center;
|
|
38
|
+
line-height: 50px;
|
|
39
|
+
color: var(--cancel-color);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&-title {
|
|
43
|
+
font-size: var(--title-font-size);
|
|
44
|
+
color: var(--title-color);
|
|
45
|
+
font-weight: var(--title-font-weight);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&-confirm {
|
|
49
|
+
width: 40px;
|
|
50
|
+
height: 100%;
|
|
51
|
+
font-size: var(--confirm-font-size);
|
|
52
|
+
text-align: center;
|
|
53
|
+
line-height: 50px;
|
|
54
|
+
color: var(--confirm-color);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&-container {
|
|
58
|
+
width: 100%;
|
|
59
|
+
height: var(--panel-container-height);
|
|
60
|
+
display: flex;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { OverrideProps } from '@bifrostui/types';
|
|
3
|
+
import { DrawerProps } from '../Drawer/Drawer.types';
|
|
4
|
+
export interface IPickerOptionItem {
|
|
5
|
+
/**
|
|
6
|
+
* 选项的文字内容
|
|
7
|
+
*/
|
|
8
|
+
label?: string | number;
|
|
9
|
+
/**
|
|
10
|
+
* 选项对应唯一的值
|
|
11
|
+
*/
|
|
12
|
+
value: string | number;
|
|
13
|
+
}
|
|
14
|
+
export type ICascadePickerOptionItem = IPickerOptionItem & {
|
|
15
|
+
/**
|
|
16
|
+
* 用于级联选项
|
|
17
|
+
*/
|
|
18
|
+
children?: ICascadePickerOptionItem[];
|
|
19
|
+
};
|
|
20
|
+
export type PickerProps<D extends React.ElementType = 'div', P = DrawerProps> = OverrideProps<{
|
|
21
|
+
props: P & {
|
|
22
|
+
/**
|
|
23
|
+
* 是否展示选择器
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
open?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* 标题
|
|
29
|
+
*/
|
|
30
|
+
title?: string;
|
|
31
|
+
/**
|
|
32
|
+
* 列表数据
|
|
33
|
+
* @default []
|
|
34
|
+
*/
|
|
35
|
+
options?: IPickerOptionItem[][] | ICascadePickerOptionItem[];
|
|
36
|
+
/**
|
|
37
|
+
* 选中的值
|
|
38
|
+
*/
|
|
39
|
+
value?: (string | number)[];
|
|
40
|
+
/**
|
|
41
|
+
* 内部内容DOM节点上的Props
|
|
42
|
+
*/
|
|
43
|
+
contentProps?: React.HTMLAttributes<HTMLDivElement>;
|
|
44
|
+
/**
|
|
45
|
+
* 点击确认按钮时候回调
|
|
46
|
+
*/
|
|
47
|
+
onConfirm?: (e: React.SyntheticEvent, data: {
|
|
48
|
+
value: (string | number)[];
|
|
49
|
+
options: ICascadePickerOptionItem[];
|
|
50
|
+
}) => void;
|
|
51
|
+
/**
|
|
52
|
+
* 选项值变更时的回调
|
|
53
|
+
*/
|
|
54
|
+
onOptionChange?: (e: React.SyntheticEvent, data: {
|
|
55
|
+
value: (string | number)[];
|
|
56
|
+
options: IPickerOptionItem[][] | ICascadePickerOptionItem[];
|
|
57
|
+
currentOption: ICascadePickerOptionItem;
|
|
58
|
+
}) => void;
|
|
59
|
+
/**
|
|
60
|
+
* 点击取消按钮时候回调
|
|
61
|
+
*/
|
|
62
|
+
onCancel?: (e: React.SyntheticEvent) => void;
|
|
63
|
+
/**
|
|
64
|
+
* 关闭选择器时执行
|
|
65
|
+
*/
|
|
66
|
+
onClose?: (e: React.SyntheticEvent, data: {
|
|
67
|
+
from: string;
|
|
68
|
+
value: (string | number)[];
|
|
69
|
+
options: IPickerOptionItem[][] | ICascadePickerOptionItem[];
|
|
70
|
+
}) => void;
|
|
71
|
+
};
|
|
72
|
+
defaultComponent: D;
|
|
73
|
+
}, D>;
|
|
74
|
+
export type PickerPanelProps<D extends React.ElementType = 'div', P = {}> = OverrideProps<{
|
|
75
|
+
props: P & {
|
|
76
|
+
/**
|
|
77
|
+
* 单列面板的列表数据
|
|
78
|
+
* @default []
|
|
79
|
+
*/
|
|
80
|
+
options?: IPickerOptionItem[][] | ICascadePickerOptionItem[];
|
|
81
|
+
/**
|
|
82
|
+
* 默认值
|
|
83
|
+
*/
|
|
84
|
+
defaultValue?: string | number;
|
|
85
|
+
/**
|
|
86
|
+
* 列索引
|
|
87
|
+
*/
|
|
88
|
+
columnIndex?: number;
|
|
89
|
+
/**
|
|
90
|
+
* 选择选项时的回调
|
|
91
|
+
*/
|
|
92
|
+
onSelect?: (e: React.SyntheticEvent, data: {
|
|
93
|
+
columnOption: IPickerOptionItem[] | ICascadePickerOptionItem;
|
|
94
|
+
columnIndex: number;
|
|
95
|
+
}) => void;
|
|
96
|
+
};
|
|
97
|
+
defaultComponent: D;
|
|
98
|
+
}, D>;
|