@bifrostui/react 1.3.2 → 1.4.0-beta.1
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.css +6 -3
- package/dist/ActionSheet/ActionSheetItem.css +10 -6
- package/dist/Alert/index.css +14 -8
- package/dist/Avatar/Avatar.css +13 -9
- package/dist/Avatar/AvatarGroup.css +15 -8
- package/dist/Backdrop/Backdrop.css +2 -1
- package/dist/Badge/Badge.css +27 -17
- package/dist/Breadcrumb/Breadcrumb.css +34 -0
- package/dist/Breadcrumb/Breadcrumb.d.ts +5 -0
- package/dist/Breadcrumb/Breadcrumb.js +128 -0
- package/dist/Breadcrumb/Breadcrumb.types.d.ts +49 -0
- package/dist/Breadcrumb/Breadcrumb.types.js +15 -0
- package/dist/Breadcrumb/BreadcrumbItem.d.ts +4 -0
- package/dist/Breadcrumb/BreadcrumbItem.js +78 -0
- package/dist/Breadcrumb/index.d.ts +4 -0
- package/dist/Breadcrumb/index.js +45 -0
- package/dist/Button/Button.css +37 -25
- package/dist/Calendar/Calendar.css +33 -18
- package/dist/Calendar/Calendar.d.ts +1 -1
- package/dist/Calendar/Calendar.js +38 -17
- package/dist/Calendar/Calendar.types.d.ts +21 -0
- package/dist/Card/CardFooter.css +2 -1
- package/dist/Card/CardHeader.css +3 -1
- package/dist/Checkbox/Checkbox.css +7 -5
- package/dist/CitySelector/CitySelector.css +29 -15
- package/dist/CitySelector/CitySelectorCore.js +25 -16
- package/dist/CitySelector/Selector/index.css +4 -4
- package/dist/Collapse/Collapse.css +6 -0
- package/dist/Collapse/Collapse.d.ts +5 -0
- package/dist/Collapse/Collapse.js +165 -0
- package/dist/Collapse/Collapse.types.d.ts +16 -0
- package/dist/Collapse/Collapse.types.js +15 -0
- package/dist/Collapse/index.d.ts +2 -0
- package/dist/Collapse/index.js +41 -0
- package/dist/CollapsePanel/CollapsePanel.css +32 -0
- package/dist/CollapsePanel/CollapsePanel.d.ts +5 -0
- package/dist/CollapsePanel/CollapsePanel.js +159 -0
- package/dist/CollapsePanel/CollapsePanel.types.d.ts +64 -0
- package/dist/CollapsePanel/CollapsePanel.types.js +15 -0
- package/dist/CollapsePanel/CollapsePanelItem.d.ts +4 -0
- package/dist/CollapsePanel/CollapsePanelItem.js +112 -0
- package/dist/CollapsePanel/index.d.ts +4 -0
- package/dist/CollapsePanel/index.js +45 -0
- package/dist/Countdown/Countdown.css +2 -1
- package/dist/Dialog/Dialog.d.ts +2 -2
- package/dist/Dialog/Dialog.js +20 -8
- package/dist/Dialog/Dialog.types.d.ts +12 -1
- package/dist/Dialog/FunctionalDialog.js +38 -2
- package/dist/Dialog/index.css +27 -18
- package/dist/Divider/Divider.css +6 -4
- package/dist/IconButton/IconButton.css +9 -7
- package/dist/Image/index.css +2 -1
- package/dist/Input/Input.css +14 -7
- package/dist/List/List.css +3 -0
- package/dist/List/ListItem.css +3 -3
- package/dist/List/ListItemContent.css +1 -1
- package/dist/Loading/Loading.css +4 -2
- package/dist/NavBar/NavBar.css +9 -5
- package/dist/Picker/Picker.css +25 -29
- package/dist/Picker/Picker.js +31 -11
- package/dist/Picker/Picker.types.d.ts +4 -0
- package/dist/Picker/PickerPanel.css +8 -8
- package/dist/Picker/PickerPanel.js +14 -8
- package/dist/Picker/utils.d.ts +16 -0
- package/dist/Picker/utils.js +32 -2
- package/dist/Popover/Popover.css +94 -0
- package/dist/Popover/Popover.d.ts +5 -0
- package/dist/Popover/Popover.js +209 -0
- package/dist/Popover/Popover.types.d.ts +58 -0
- package/dist/Popover/Popover.types.js +15 -0
- package/dist/Popover/index.d.ts +2 -0
- package/dist/Popover/index.js +41 -0
- package/dist/Portal/Portal.types.d.ts +5 -1
- package/dist/Portal/PortalCore.js +8 -1
- package/dist/Progress/Progress.css +9 -7
- package/dist/Radio/Radio.css +5 -4
- package/dist/Rating/Rating.css +8 -4
- package/dist/Select/Select.css +21 -10
- package/dist/Select/Select.js +1 -1
- package/dist/Select/SelectOption.js +3 -0
- package/dist/Skeleton/Skeleton.css +5 -5
- package/dist/Slider/Slider.css +29 -18
- package/dist/Steps/Step.css +13 -13
- package/dist/Steps/Steps.css +14 -7
- package/dist/Swiper/Swiper.css +2 -1
- package/dist/Switch/Switch.css +31 -16
- package/dist/TabBar/TabBar.css +7 -3
- package/dist/TabBar/TabBarItem.css +0 -1
- package/dist/Tabs/Tab.css +6 -10
- package/dist/Tabs/Tabs.css +10 -9
- package/dist/Tag/Tag.css +7 -10
- package/dist/Tag/TagGroup.css +9 -1
- package/dist/TextArea/TextArea.css +23 -13
- package/dist/ThemeProvider/ThemeProvider.d.ts +4 -0
- package/dist/ThemeProvider/ThemeProvider.js +91 -0
- package/dist/ThemeProvider/ThemeProvider.types.d.ts +127 -0
- package/dist/ThemeProvider/ThemeProvider.types.js +27 -0
- package/dist/ThemeProvider/hooks/ThemeContext.d.ts +4 -0
- package/dist/ThemeProvider/hooks/ThemeContext.js +35 -0
- package/dist/ThemeProvider/hooks/createTheme.d.ts +2 -0
- package/dist/ThemeProvider/hooks/createTheme.js +55 -0
- package/dist/ThemeProvider/hooks/index.d.ts +4 -0
- package/dist/ThemeProvider/hooks/index.js +43 -0
- package/dist/ThemeProvider/hooks/useTheme.d.ts +1 -0
- package/dist/ThemeProvider/hooks/useTheme.js +39 -0
- package/dist/ThemeProvider/index.d.ts +4 -0
- package/dist/ThemeProvider/index.js +45 -0
- package/dist/ThemeProvider/utils/constants.d.ts +38 -0
- package/dist/ThemeProvider/utils/constants.js +65 -0
- package/dist/ThemeProvider/utils/index.d.ts +2 -0
- package/dist/ThemeProvider/utils/index.js +23 -0
- package/dist/ThemeProvider/utils/mountTokens.d.ts +26 -0
- package/dist/ThemeProvider/utils/mountTokens.js +123 -0
- package/dist/Toast/FunctionalToast.js +18 -0
- package/dist/Toast/Toast.css +18 -20
- package/dist/Toast/Toast.d.ts +2 -2
- package/dist/Toast/Toast.js +52 -48
- package/dist/Toast/Toast.types.d.ts +15 -1
- package/dist/Tooltip/Tooltip.css +91 -0
- package/dist/Tooltip/Tooltip.d.ts +5 -0
- package/dist/Tooltip/Tooltip.js +198 -0
- package/dist/Tooltip/Tooltip.types.d.ts +49 -0
- package/dist/Tooltip/Tooltip.types.js +15 -0
- package/dist/Tooltip/index.d.ts +2 -0
- package/dist/Tooltip/index.js +41 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +15 -1
- package/dist/locales/base.d.ts +40 -0
- package/dist/locales/base.js +15 -0
- package/dist/locales/en-US.d.ts +3 -0
- package/dist/locales/en-US.js +69 -0
- package/dist/locales/hooks/useLocaleText.d.ts +3 -0
- package/dist/locales/hooks/useLocaleText.js +43 -0
- package/dist/locales/index.d.ts +5 -0
- package/dist/locales/index.js +49 -0
- package/dist/locales/zh-CN.d.ts +3 -0
- package/dist/locales/zh-CN.js +51 -0
- package/dist/locales/zh-TW.d.ts +3 -0
- package/dist/locales/zh-TW.js +51 -0
- package/es/ActionSheet/ActionSheet.css +6 -3
- package/es/ActionSheet/ActionSheetItem.css +10 -6
- package/es/Alert/index.css +14 -8
- package/es/Avatar/Avatar.css +13 -9
- package/es/Avatar/AvatarGroup.css +15 -8
- package/es/Backdrop/Backdrop.css +2 -1
- package/es/Badge/Badge.css +27 -17
- package/es/Breadcrumb/Breadcrumb.css +34 -0
- package/es/Breadcrumb/Breadcrumb.d.ts +5 -0
- package/es/Breadcrumb/Breadcrumb.js +101 -0
- package/es/Breadcrumb/Breadcrumb.types.d.ts +49 -0
- package/es/Breadcrumb/Breadcrumb.types.js +1 -0
- package/es/Breadcrumb/BreadcrumbItem.d.ts +4 -0
- package/es/Breadcrumb/BreadcrumbItem.js +51 -0
- package/es/Breadcrumb/index.d.ts +4 -0
- package/es/Breadcrumb/index.js +9 -0
- package/es/Button/Button.css +37 -25
- package/es/Calendar/Calendar.css +33 -18
- package/es/Calendar/Calendar.d.ts +1 -1
- package/es/Calendar/Calendar.js +38 -17
- package/es/Calendar/Calendar.types.d.ts +21 -0
- package/es/Card/CardFooter.css +2 -1
- package/es/Card/CardHeader.css +3 -1
- package/es/Checkbox/Checkbox.css +7 -5
- package/es/CitySelector/CitySelector.css +29 -15
- package/es/CitySelector/CitySelectorCore.js +25 -16
- package/es/CitySelector/Selector/index.css +4 -4
- package/es/Collapse/Collapse.css +6 -0
- package/es/Collapse/Collapse.d.ts +5 -0
- package/es/Collapse/Collapse.js +144 -0
- package/es/Collapse/Collapse.types.d.ts +16 -0
- package/es/Collapse/Collapse.types.js +1 -0
- package/es/Collapse/index.d.ts +2 -0
- package/es/Collapse/index.js +6 -0
- package/es/CollapsePanel/CollapsePanel.css +32 -0
- package/es/CollapsePanel/CollapsePanel.d.ts +5 -0
- package/es/CollapsePanel/CollapsePanel.js +132 -0
- package/es/CollapsePanel/CollapsePanel.types.d.ts +64 -0
- package/es/CollapsePanel/CollapsePanel.types.js +1 -0
- package/es/CollapsePanel/CollapsePanelItem.d.ts +4 -0
- package/es/CollapsePanel/CollapsePanelItem.js +85 -0
- package/es/CollapsePanel/index.d.ts +4 -0
- package/es/CollapsePanel/index.js +9 -0
- package/es/Countdown/Countdown.css +2 -1
- package/es/Dialog/Dialog.d.ts +2 -2
- package/es/Dialog/Dialog.js +20 -8
- package/es/Dialog/Dialog.types.d.ts +12 -1
- package/es/Dialog/FunctionalDialog.js +38 -2
- package/es/Dialog/index.css +27 -18
- package/es/Divider/Divider.css +6 -4
- package/es/IconButton/IconButton.css +9 -7
- package/es/Image/index.css +2 -1
- package/es/Input/Input.css +14 -7
- package/es/List/List.css +3 -0
- package/es/List/ListItem.css +3 -3
- package/es/List/ListItemContent.css +1 -1
- package/es/Loading/Loading.css +4 -2
- package/es/Modal/Modal.miniapp.d.ts +1 -1
- package/es/NavBar/NavBar.css +9 -5
- package/es/Picker/Picker.css +25 -29
- package/es/Picker/Picker.js +32 -12
- package/es/Picker/Picker.types.d.ts +4 -0
- package/es/Picker/PickerPanel.css +8 -8
- package/es/Picker/PickerPanel.js +14 -8
- package/es/Picker/utils.d.ts +16 -0
- package/es/Picker/utils.js +29 -1
- package/es/Popover/Popover.css +94 -0
- package/es/Popover/Popover.d.ts +5 -0
- package/es/Popover/Popover.js +186 -0
- package/es/Popover/Popover.types.d.ts +58 -0
- package/es/Popover/Popover.types.js +1 -0
- package/es/Popover/index.d.ts +2 -0
- package/es/Popover/index.js +6 -0
- package/es/Portal/Portal.types.d.ts +5 -1
- package/es/Portal/PortalCore.js +8 -1
- package/es/Progress/Progress.css +9 -7
- package/es/Radio/Radio.css +5 -4
- package/es/Rating/Rating.css +8 -4
- package/es/Select/Select.css +21 -10
- package/es/Select/Select.js +1 -1
- package/es/Select/SelectOption.js +3 -0
- package/es/Skeleton/Skeleton.css +5 -5
- package/es/Slider/Slider.css +29 -18
- package/es/Steps/Step.css +13 -13
- package/es/Steps/Steps.css +14 -7
- package/es/Swiper/Swiper.css +2 -1
- package/es/Switch/Switch.css +31 -16
- package/es/TabBar/TabBar.css +7 -3
- package/es/TabBar/TabBarItem.css +0 -1
- package/es/Tabs/Tab.css +6 -10
- package/es/Tabs/Tabs.css +10 -9
- package/es/Tag/Tag.css +7 -10
- package/es/Tag/TagGroup.css +9 -1
- package/es/TextArea/TextArea.css +23 -13
- package/es/ThemeProvider/ThemeProvider.d.ts +4 -0
- package/es/ThemeProvider/ThemeProvider.js +62 -0
- package/es/ThemeProvider/ThemeProvider.types.d.ts +127 -0
- package/es/ThemeProvider/ThemeProvider.types.js +1 -0
- package/es/ThemeProvider/hooks/ThemeContext.d.ts +4 -0
- package/es/ThemeProvider/hooks/ThemeContext.js +6 -0
- package/es/ThemeProvider/hooks/createTheme.d.ts +2 -0
- package/es/ThemeProvider/hooks/createTheme.js +38 -0
- package/es/ThemeProvider/hooks/index.d.ts +4 -0
- package/es/ThemeProvider/hooks/index.js +8 -0
- package/es/ThemeProvider/hooks/useTheme.d.ts +1 -0
- package/es/ThemeProvider/hooks/useTheme.js +10 -0
- package/es/ThemeProvider/index.d.ts +4 -0
- package/es/ThemeProvider/index.js +8 -0
- package/es/ThemeProvider/utils/constants.d.ts +38 -0
- package/es/ThemeProvider/utils/constants.js +40 -0
- package/es/ThemeProvider/utils/index.d.ts +2 -0
- package/es/ThemeProvider/utils/index.js +2 -0
- package/es/ThemeProvider/utils/mountTokens.d.ts +26 -0
- package/es/ThemeProvider/utils/mountTokens.js +88 -0
- package/es/Toast/FunctionalToast.js +18 -0
- package/es/Toast/Toast.css +18 -20
- package/es/Toast/Toast.d.ts +2 -2
- package/es/Toast/Toast.js +53 -49
- package/es/Toast/Toast.types.d.ts +15 -1
- package/es/Tooltip/Tooltip.css +91 -0
- package/es/Tooltip/Tooltip.d.ts +5 -0
- package/es/Tooltip/Tooltip.js +175 -0
- package/es/Tooltip/Tooltip.types.d.ts +49 -0
- package/es/Tooltip/Tooltip.types.js +1 -0
- package/es/Tooltip/index.d.ts +2 -0
- package/es/Tooltip/index.js +6 -0
- package/es/index.d.ts +7 -0
- package/es/index.js +7 -0
- package/es/locales/base.d.ts +40 -0
- package/es/locales/base.js +0 -0
- package/es/locales/en-US.d.ts +3 -0
- package/es/locales/en-US.js +50 -0
- package/es/locales/hooks/useLocaleText.d.ts +3 -0
- package/es/locales/hooks/useLocaleText.js +26 -0
- package/es/locales/index.d.ts +5 -0
- package/es/locales/index.js +11 -0
- package/es/locales/zh-CN.d.ts +3 -0
- package/es/locales/zh-CN.js +32 -0
- package/es/locales/zh-TW.d.ts +3 -0
- package/es/locales/zh-TW.js +32 -0
- package/package.json +5 -5
package/es/NavBar/NavBar.css
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
.bui-navbar {
|
|
2
|
+
--width: var(--bui-navbar-width, 100%);
|
|
2
3
|
--height: var(--bui-navbar-height, 45px);
|
|
4
|
+
--padding: var(--bui-navbar-padding, 0 8px);
|
|
3
5
|
--icon-size: var(--bui-navbar-icon-size, 24px);
|
|
6
|
+
--icon-font-size: var(--bui-navbar-icon-font-size, var(--bui-title-size-3));
|
|
4
7
|
--background-color: var(--bui-navbar-background-color, var(--bui-color-white));
|
|
5
8
|
--border-bottom: var(--bui-navbar-border-bottom, none);
|
|
6
9
|
--z-index: var(--bui-navbar-z-index, auto);
|
|
10
|
+
--title-max-width: var(--bui-navbar-title-max-width, 60%);
|
|
7
11
|
position: relative;
|
|
8
|
-
width:
|
|
12
|
+
width: var(--width);
|
|
9
13
|
height: var(--height);
|
|
10
14
|
box-sizing: border-box;
|
|
11
|
-
padding:
|
|
15
|
+
padding: var(--padding);
|
|
12
16
|
display: flex;
|
|
13
17
|
justify-content: center;
|
|
14
18
|
align-items: center;
|
|
@@ -25,8 +29,8 @@
|
|
|
25
29
|
width: 100%;
|
|
26
30
|
}
|
|
27
31
|
.bui-navbar-title {
|
|
28
|
-
max-width:
|
|
29
|
-
padding:
|
|
32
|
+
max-width: var(--title-max-width);
|
|
33
|
+
padding: var(--padding);
|
|
30
34
|
font-size: var(--bui-title-size-2);
|
|
31
35
|
width: auto;
|
|
32
36
|
overflow: hidden;
|
|
@@ -38,7 +42,7 @@
|
|
|
38
42
|
flex: 1;
|
|
39
43
|
display: flex;
|
|
40
44
|
align-items: center;
|
|
41
|
-
font-size: var(--
|
|
45
|
+
font-size: var(--icon-font-size);
|
|
42
46
|
}
|
|
43
47
|
.bui-navbar-left {
|
|
44
48
|
justify-content: flex-start;
|
package/es/Picker/Picker.css
CHANGED
|
@@ -1,53 +1,49 @@
|
|
|
1
1
|
.bui-picker {
|
|
2
|
-
--
|
|
3
|
-
--
|
|
4
|
-
--
|
|
5
|
-
--
|
|
6
|
-
--
|
|
7
|
-
--
|
|
8
|
-
--
|
|
9
|
-
--
|
|
10
|
-
--
|
|
11
|
-
--indicator-height: 36px;
|
|
12
|
-
--indicator-border-color: var(--bui-color-border-default);
|
|
13
|
-
--option-color: var(--bui-color-fg-default);
|
|
14
|
-
--option-font-size: var(--bui-title-size-4);
|
|
15
|
-
--option-height: 36px;
|
|
2
|
+
--header-height: var(--bui-picker-header-height, 50px);
|
|
3
|
+
--header-padding: var(--bui-picker-header-padding, 0 var(--bui-spacing-lg));
|
|
4
|
+
--cancel-height: var(--bui-picker-cancel-height, 100%);
|
|
5
|
+
--cancel-line-height: var(--bui-picker-cancel-line-height, 50px);
|
|
6
|
+
--confirm-height: var(--bui-picker-confirm-height, 100%);
|
|
7
|
+
--confirm-line-height: var(--bui-picker-confirm-line-height, 50px);
|
|
8
|
+
--panel-container-height: var(--bui-picker-panel-height, 260px);
|
|
9
|
+
--indicator-top: var(--bui-picker-indicator-top, 108px);
|
|
10
|
+
--option-height: var(--bui-picker-option-height, 36px);
|
|
16
11
|
font-family: var(--bui-font-family);
|
|
17
12
|
}
|
|
18
13
|
.bui-picker .bui-drawer-content {
|
|
19
14
|
border-radius: var(--bui-shape-radius-drawer) var(--bui-shape-radius-drawer) 0 0;
|
|
20
15
|
}
|
|
21
16
|
.bui-picker-header {
|
|
22
|
-
height:
|
|
17
|
+
height: var(--header-height);
|
|
23
18
|
display: flex;
|
|
24
19
|
align-items: center;
|
|
25
20
|
justify-content: space-between;
|
|
26
|
-
padding:
|
|
21
|
+
padding: var(--header-padding);
|
|
27
22
|
}
|
|
28
23
|
.bui-picker-cancel {
|
|
29
|
-
|
|
30
|
-
height:
|
|
31
|
-
font-size: var(--
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
height: var(--cancel-height);
|
|
26
|
+
font-size: var(--bui-title-size-4);
|
|
32
27
|
text-align: center;
|
|
33
|
-
line-height:
|
|
34
|
-
color: var(--
|
|
28
|
+
line-height: var(--cancel-line-height);
|
|
29
|
+
color: var(--bui-color-fg-default);
|
|
35
30
|
}
|
|
36
31
|
.bui-picker-title {
|
|
37
|
-
font-size: var(--title-
|
|
38
|
-
color: var(--
|
|
39
|
-
font-weight: var(--
|
|
32
|
+
font-size: var(--bui-title-size-3);
|
|
33
|
+
color: var(--bui-color-fg-default);
|
|
34
|
+
font-weight: var(--bui-font-weight-medium);
|
|
40
35
|
}
|
|
41
36
|
.bui-picker-confirm {
|
|
42
|
-
|
|
43
|
-
height:
|
|
44
|
-
font-size: var(--
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
height: var(--confirm-height);
|
|
39
|
+
font-size: var(--bui-title-size-4);
|
|
45
40
|
text-align: center;
|
|
46
|
-
line-height:
|
|
47
|
-
color: var(--
|
|
41
|
+
line-height: var(--confirm-line-height);
|
|
42
|
+
color: var(--bui-color-primary);
|
|
48
43
|
}
|
|
49
44
|
.bui-picker-container {
|
|
50
45
|
width: 100%;
|
|
51
46
|
height: var(--panel-container-height);
|
|
52
47
|
display: flex;
|
|
48
|
+
overflow: hidden;
|
|
53
49
|
}
|
package/es/Picker/Picker.js
CHANGED
|
@@ -33,7 +33,8 @@ import clsx from "clsx";
|
|
|
33
33
|
import React, { useEffect, useRef, useState, useCallback } from "react";
|
|
34
34
|
import Drawer from "../Drawer";
|
|
35
35
|
import PickerPanel from "./PickerPanel";
|
|
36
|
-
import {
|
|
36
|
+
import { useLocaleText } from "../locales";
|
|
37
|
+
import { formatOptions, pickerPanelType, safeData } from "./utils";
|
|
37
38
|
import "./Picker.css";
|
|
38
39
|
const prefixCls = "bui-picker";
|
|
39
40
|
const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
@@ -64,6 +65,7 @@ const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
64
65
|
const rollerRefs = useRef([]);
|
|
65
66
|
const [columns, setColumns] = useState([]);
|
|
66
67
|
const [internalValue, setInternalValue] = useState([]);
|
|
68
|
+
const { cancel: cancelText, confirm: confirmText } = useLocaleText("picker");
|
|
67
69
|
useEffect(() => {
|
|
68
70
|
if (!open)
|
|
69
71
|
return;
|
|
@@ -85,13 +87,18 @@ const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
85
87
|
}
|
|
86
88
|
}, [value, options]);
|
|
87
89
|
const confirm = (e) => {
|
|
88
|
-
const payload = {
|
|
89
|
-
value: internalValue,
|
|
90
|
-
options: columns
|
|
91
|
-
};
|
|
92
90
|
const isMoving = rollerRefs.current.some((roller) => roller == null ? void 0 : roller.isMoving);
|
|
93
91
|
if (isMoving)
|
|
94
92
|
return;
|
|
93
|
+
const { safeValue } = safeData({
|
|
94
|
+
value: internalValue,
|
|
95
|
+
formatted: columns,
|
|
96
|
+
options
|
|
97
|
+
});
|
|
98
|
+
const payload = {
|
|
99
|
+
value: safeValue,
|
|
100
|
+
options: columns
|
|
101
|
+
};
|
|
95
102
|
onConfirm == null ? void 0 : onConfirm(e, payload);
|
|
96
103
|
onClose == null ? void 0 : onClose(e, __spreadValues({
|
|
97
104
|
from: "confirm"
|
|
@@ -99,11 +106,18 @@ const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
99
106
|
};
|
|
100
107
|
const cancel = (e) => {
|
|
101
108
|
onCancel == null ? void 0 : onCancel(e);
|
|
102
|
-
|
|
103
|
-
from: "cancel",
|
|
109
|
+
const { safeValue } = safeData({
|
|
104
110
|
value: internalValue,
|
|
105
|
-
|
|
111
|
+
formatted: columns,
|
|
112
|
+
options
|
|
106
113
|
});
|
|
114
|
+
const payload = {
|
|
115
|
+
value: safeValue,
|
|
116
|
+
options: columns
|
|
117
|
+
};
|
|
118
|
+
onClose == null ? void 0 : onClose(e, __spreadValues({
|
|
119
|
+
from: "cancel"
|
|
120
|
+
}, payload));
|
|
107
121
|
};
|
|
108
122
|
const updateItem = (e, columnOption, columnIndex) => {
|
|
109
123
|
var _a2, _b, _c;
|
|
@@ -136,7 +150,7 @@ const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
136
150
|
currentOption: columnOption
|
|
137
151
|
});
|
|
138
152
|
} else {
|
|
139
|
-
const result = internalValue;
|
|
153
|
+
const result = [...internalValue];
|
|
140
154
|
result[columnIndex] = columnOption.value;
|
|
141
155
|
setInternalValue(result);
|
|
142
156
|
onOptionChange == null ? void 0 : onOptionChange(e, {
|
|
@@ -151,8 +165,13 @@ const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
151
165
|
updateItem(e, columnOption, columnIndex);
|
|
152
166
|
};
|
|
153
167
|
const handleClose = (e, data) => {
|
|
154
|
-
|
|
168
|
+
const { safeValue } = safeData({
|
|
155
169
|
value: internalValue,
|
|
170
|
+
formatted: columns,
|
|
171
|
+
options
|
|
172
|
+
});
|
|
173
|
+
onClose == null ? void 0 : onClose(e, __spreadValues({
|
|
174
|
+
value: safeValue,
|
|
156
175
|
options: columns
|
|
157
176
|
}, data));
|
|
158
177
|
};
|
|
@@ -176,7 +195,7 @@ const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
176
195
|
__spreadProps(__spreadValues({}, contentProps), {
|
|
177
196
|
className: clsx(`${prefixCls}-content`, contentProps == null ? void 0 : contentProps.className)
|
|
178
197
|
}),
|
|
179
|
-
/* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-header` }, /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-cancel`, onClick: cancel },
|
|
198
|
+
/* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-header` }, /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-cancel`, onClick: cancel }, cancelText), title && /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-title` }, title), /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-confirm`, onClick: confirm }, confirmText)),
|
|
180
199
|
/* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-container` }, columns.map((column, index) => /* @__PURE__ */ React.createElement(
|
|
181
200
|
PickerPanel,
|
|
182
201
|
{
|
|
@@ -185,7 +204,8 @@ const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
185
204
|
options: column,
|
|
186
205
|
columnIndex: index,
|
|
187
206
|
defaultValue: internalValue == null ? void 0 : internalValue[index],
|
|
188
|
-
onSelect: handleSelect
|
|
207
|
+
onSelect: handleSelect,
|
|
208
|
+
pickerStyle: others == null ? void 0 : others.style
|
|
189
209
|
}
|
|
190
210
|
)))
|
|
191
211
|
)
|
|
@@ -86,6 +86,10 @@ export type PickerPanelProps<D extends React.ElementType = 'div', P = {}> = Over
|
|
|
86
86
|
* 列索引
|
|
87
87
|
*/
|
|
88
88
|
columnIndex?: number;
|
|
89
|
+
/**
|
|
90
|
+
* Piker组件的样式,PickerPanel的主题定制与css变量传入的Tokens有关,需要透传计算
|
|
91
|
+
*/
|
|
92
|
+
pickerStyle?: React.CSSProperties;
|
|
89
93
|
/**
|
|
90
94
|
* 选择选项时的回调
|
|
91
95
|
*/
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
background-image:
|
|
22
22
|
linear-gradient(
|
|
23
23
|
180deg,
|
|
24
|
-
var(--bui-color-bg-
|
|
25
|
-
var(--bui-color-bg-
|
|
24
|
+
var(--bui-color-bg-alpha-light-9),
|
|
25
|
+
var(--bui-color-bg-alpha-light-3)),
|
|
26
26
|
linear-gradient(
|
|
27
27
|
0deg,
|
|
28
|
-
var(--bui-color-bg-
|
|
29
|
-
var(--bui-color-bg-
|
|
28
|
+
var(--bui-color-bg-alpha-light-9),
|
|
29
|
+
var(--bui-color-bg-alpha-light-3));
|
|
30
30
|
background-position: top, bottom;
|
|
31
31
|
background-size: 100% var(--indicator-top);
|
|
32
32
|
background-repeat: no-repeat;
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
.bui-picker-panel-indicator {
|
|
36
36
|
position: absolute;
|
|
37
37
|
top: var(--indicator-top);
|
|
38
|
-
height: var(--
|
|
38
|
+
height: var(--option-height);
|
|
39
39
|
width: 100%;
|
|
40
|
-
border-top: 1px solid var(--
|
|
41
|
-
border-bottom: 1px solid var(--
|
|
40
|
+
border-top: 1px solid var(--bui-color-border-default);
|
|
41
|
+
border-bottom: 1px solid var(--bui-color-border-default);
|
|
42
42
|
}
|
|
43
43
|
.bui-picker-panel-option {
|
|
44
44
|
position: absolute;
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
text-align: center;
|
|
48
48
|
height: var(--option-height);
|
|
49
49
|
line-height: var(--option-height);
|
|
50
|
-
color: var(--
|
|
50
|
+
color: var(--bui-color-fg-default);
|
|
51
51
|
font-size: var(--option-font-size);
|
|
52
52
|
backface-visibility: hidden;
|
|
53
53
|
width: auto;
|
package/es/Picker/PickerPanel.js
CHANGED
|
@@ -33,25 +33,31 @@ import "./PickerPanel.css";
|
|
|
33
33
|
const prefixCls = "bui-picker-panel";
|
|
34
34
|
const PickerPanel = /* @__PURE__ */ React.forwardRef(
|
|
35
35
|
(props, ref) => {
|
|
36
|
+
var _b;
|
|
36
37
|
const _a = props, {
|
|
37
38
|
options = [],
|
|
38
39
|
defaultValue,
|
|
39
40
|
onSelect,
|
|
40
|
-
columnIndex
|
|
41
|
+
columnIndex,
|
|
42
|
+
pickerStyle
|
|
41
43
|
} = _a, others = __objRest(_a, [
|
|
42
44
|
"options",
|
|
43
45
|
"defaultValue",
|
|
44
46
|
"onSelect",
|
|
45
|
-
"columnIndex"
|
|
47
|
+
"columnIndex",
|
|
48
|
+
"pickerStyle"
|
|
46
49
|
]);
|
|
47
50
|
const touch = useTouch();
|
|
48
51
|
let timer;
|
|
49
52
|
const INERTIA_TIME = 200;
|
|
50
53
|
const INERTIA_DISTANCE = 15;
|
|
51
54
|
const DEFAULT_DURATION = 200;
|
|
52
|
-
const LINE_SPACING = 36;
|
|
53
55
|
const ROTATION = 20;
|
|
54
56
|
const TOUCH_END = "end";
|
|
57
|
+
const DEFAULT_LINE_SPACING = 36;
|
|
58
|
+
const LINE_SPACING_STR = (_b = ((pickerStyle == null ? void 0 : pickerStyle["--option-height"]) ? `${pickerStyle == null ? void 0 : pickerStyle["--option-height"]}` : `${DEFAULT_LINE_SPACING}`).match(/\d+/)) == null ? void 0 : _b[0];
|
|
59
|
+
const LINE_SPACING = parseInt(LINE_SPACING_STR, 10);
|
|
60
|
+
const INDICATOR_OFFSET = LINE_SPACING * 108 / DEFAULT_LINE_SPACING;
|
|
55
61
|
const [startY, setStartY] = useState(0);
|
|
56
62
|
const [currIndex, setCurrIndex] = useState(1);
|
|
57
63
|
const [startTime, setStartTime] = useState(0);
|
|
@@ -167,17 +173,17 @@ const PickerPanel = /* @__PURE__ */ React.forwardRef(
|
|
|
167
173
|
}, 0);
|
|
168
174
|
};
|
|
169
175
|
useEffect(() => {
|
|
170
|
-
var _a2,
|
|
176
|
+
var _a2, _b2, _c;
|
|
171
177
|
(_a2 = PickerPanelRef.current) == null ? void 0 : _a2.addEventListener("touchstart", panelTouchStart);
|
|
172
|
-
(
|
|
178
|
+
(_b2 = PickerPanelRef.current) == null ? void 0 : _b2.addEventListener("touchmove", panelTouchMove);
|
|
173
179
|
(_c = PickerPanelRef.current) == null ? void 0 : _c.addEventListener("touchend", panelTouchEnd);
|
|
174
180
|
return () => {
|
|
175
|
-
var _a3,
|
|
181
|
+
var _a3, _b3, _c2;
|
|
176
182
|
(_a3 = PickerPanelRef.current) == null ? void 0 : _a3.removeEventListener(
|
|
177
183
|
"touchstart",
|
|
178
184
|
panelTouchStart
|
|
179
185
|
);
|
|
180
|
-
(
|
|
186
|
+
(_b3 = PickerPanelRef.current) == null ? void 0 : _b3.removeEventListener(
|
|
181
187
|
"touchmove",
|
|
182
188
|
panelTouchMove
|
|
183
189
|
);
|
|
@@ -223,7 +229,7 @@ const PickerPanel = /* @__PURE__ */ React.forwardRef(
|
|
|
223
229
|
}),
|
|
224
230
|
key: `${item == null ? void 0 : item.value}-${i}`,
|
|
225
231
|
style: {
|
|
226
|
-
transform: `rotate3d(1, 0, 0, ${-ROTATION * (i + 1)}deg) translate3d(0px, 0px,
|
|
232
|
+
transform: `rotate3d(1, 0, 0, ${-ROTATION * (i + 1)}deg) translate3d(0px, 0px, ${INDICATOR_OFFSET}px)`
|
|
227
233
|
}
|
|
228
234
|
},
|
|
229
235
|
item == null ? void 0 : item.label
|
package/es/Picker/utils.d.ts
CHANGED
|
@@ -11,3 +11,19 @@ export declare const formatCascade: (columns: ICascadePickerOptionItem[], values
|
|
|
11
11
|
* 统一options数据格式
|
|
12
12
|
*/
|
|
13
13
|
export declare const formatOptions: (internalValue: any, options?: any[]) => any[];
|
|
14
|
+
/**
|
|
15
|
+
* 在格式化后的数据源中是否存在等长子项的value
|
|
16
|
+
*/
|
|
17
|
+
export declare const existSameLengthValue: (value: any, formatted: any) => any;
|
|
18
|
+
/**
|
|
19
|
+
* 关闭选择器时,纠正value和格式化数据
|
|
20
|
+
* 取决于formatted后的options有几列,若value为格式化后数据源(formatted)的等长子集,则取value,否则执行纠正逻辑
|
|
21
|
+
*/
|
|
22
|
+
export declare const safeData: ({ value, formatted, options }: {
|
|
23
|
+
value: any;
|
|
24
|
+
formatted: any;
|
|
25
|
+
options: any;
|
|
26
|
+
}) => {
|
|
27
|
+
safeValue: any[];
|
|
28
|
+
safeFormatted: any[];
|
|
29
|
+
};
|
package/es/Picker/utils.js
CHANGED
|
@@ -39,8 +39,36 @@ const formatOptions = (internalValue, options = []) => {
|
|
|
39
39
|
return options;
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
+
const existSameLengthValue = (value, formatted) => {
|
|
43
|
+
const result = formatted.every(
|
|
44
|
+
(item, idx) => item.some((i) => (value == null ? void 0 : value[idx]) === (i == null ? void 0 : i.value))
|
|
45
|
+
);
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
48
|
+
const safeData = ({ value, formatted, options }) => {
|
|
49
|
+
let safeValue = [];
|
|
50
|
+
let safeFormatted = [];
|
|
51
|
+
const existValidChildren = existSameLengthValue(value, formatted);
|
|
52
|
+
if (existValidChildren) {
|
|
53
|
+
safeValue = value;
|
|
54
|
+
safeFormatted = formatted;
|
|
55
|
+
} else {
|
|
56
|
+
formatted.forEach((item, index) => {
|
|
57
|
+
var _a, _b;
|
|
58
|
+
const childIndex = item.findIndex((i) => i.value === value[index]);
|
|
59
|
+
safeValue[index] = ((_a = item == null ? void 0 : item[childIndex]) == null ? void 0 : _a.value) || ((_b = item == null ? void 0 : item[0]) == null ? void 0 : _b.value);
|
|
60
|
+
});
|
|
61
|
+
safeFormatted = formatOptions(safeValue, options);
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
safeValue,
|
|
65
|
+
safeFormatted
|
|
66
|
+
};
|
|
67
|
+
};
|
|
42
68
|
export {
|
|
69
|
+
existSameLengthValue,
|
|
43
70
|
formatCascade,
|
|
44
71
|
formatOptions,
|
|
45
|
-
pickerPanelType
|
|
72
|
+
pickerPanelType,
|
|
73
|
+
safeData
|
|
46
74
|
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
.bui-popover {
|
|
2
|
+
--arrow-size: var(--bui-popover-arrow-size, 8PX);
|
|
3
|
+
--localtion-position: var(--bui-popover-localtion-position, 8PX);
|
|
4
|
+
--max-width: var(--bui-popover-max-width, 350px);
|
|
5
|
+
--content-min-width: var(--bui-popover-content-min-width, 30px);
|
|
6
|
+
--content-padding: var(--bui-popover-content-padding, 6px 8px);
|
|
7
|
+
max-width: var(--max-width);
|
|
8
|
+
font-size: var(--bui-text-size-1);
|
|
9
|
+
position: absolute;
|
|
10
|
+
visibility: hidden;
|
|
11
|
+
z-index: var(--bui-z-index-tooltip);
|
|
12
|
+
}
|
|
13
|
+
.bui-popover .bui-popover-arrow {
|
|
14
|
+
width: 0;
|
|
15
|
+
height: 0;
|
|
16
|
+
position: absolute;
|
|
17
|
+
}
|
|
18
|
+
.bui-popover .bui-popover-arrow.location-left {
|
|
19
|
+
left: var(--localtion-position);
|
|
20
|
+
}
|
|
21
|
+
.bui-popover .bui-popover-arrow.location-right {
|
|
22
|
+
right: var(--localtion-position);
|
|
23
|
+
}
|
|
24
|
+
.bui-popover .bui-popover-arrow.location-top {
|
|
25
|
+
top: var(--localtion-position);
|
|
26
|
+
}
|
|
27
|
+
.bui-popover .bui-popover-arrow.location-bottom {
|
|
28
|
+
bottom: var(--localtion-position);
|
|
29
|
+
}
|
|
30
|
+
.bui-popover.popover-top .location-center,
|
|
31
|
+
.bui-popover.popover-bottom .location-center {
|
|
32
|
+
left: 50%;
|
|
33
|
+
transform: translateX(-50%);
|
|
34
|
+
}
|
|
35
|
+
.bui-popover.popover-left .location-center,
|
|
36
|
+
.bui-popover.popover-right .location-center {
|
|
37
|
+
top: 50%;
|
|
38
|
+
transform: translateY(-50%);
|
|
39
|
+
}
|
|
40
|
+
.bui-popover.popover-top {
|
|
41
|
+
padding-bottom: var(--arrow-size);
|
|
42
|
+
}
|
|
43
|
+
.bui-popover.popover-top .bui-popover-arrow {
|
|
44
|
+
border-left: var(--arrow-size) solid transparent;
|
|
45
|
+
border-right: var(--arrow-size) solid transparent;
|
|
46
|
+
border-top: var(--arrow-size) solid var(--bui-color-bg-view);
|
|
47
|
+
bottom: 0;
|
|
48
|
+
}
|
|
49
|
+
.bui-popover.popover-bottom {
|
|
50
|
+
padding-top: var(--arrow-size);
|
|
51
|
+
}
|
|
52
|
+
.bui-popover.popover-bottom .bui-popover-arrow {
|
|
53
|
+
border-left: var(--arrow-size) solid transparent;
|
|
54
|
+
border-right: var(--arrow-size) solid transparent;
|
|
55
|
+
border-bottom: var(--arrow-size) solid var(--bui-color-bg-view);
|
|
56
|
+
top: 0;
|
|
57
|
+
}
|
|
58
|
+
.bui-popover.popover-left {
|
|
59
|
+
padding-right: var(--arrow-size);
|
|
60
|
+
}
|
|
61
|
+
.bui-popover.popover-left .bui-popover-arrow {
|
|
62
|
+
border-top: var(--arrow-size) solid transparent;
|
|
63
|
+
border-bottom: var(--arrow-size) solid transparent;
|
|
64
|
+
border-left: var(--arrow-size) solid var(--bui-color-bg-view);
|
|
65
|
+
right: 0;
|
|
66
|
+
}
|
|
67
|
+
.bui-popover.popover-right {
|
|
68
|
+
padding-left: var(--arrow-size);
|
|
69
|
+
}
|
|
70
|
+
.bui-popover.popover-right .bui-popover-arrow {
|
|
71
|
+
border-top: var(--arrow-size) solid transparent;
|
|
72
|
+
border-bottom: var(--arrow-size) solid transparent;
|
|
73
|
+
border-right: var(--arrow-size) solid var(--bui-color-bg-view);
|
|
74
|
+
left: 0;
|
|
75
|
+
}
|
|
76
|
+
.bui-popover .bui-popover-title {
|
|
77
|
+
font-weight: var(--bui-font-weight-bold);
|
|
78
|
+
}
|
|
79
|
+
.bui-popover .bui-popover-content {
|
|
80
|
+
min-width: var(--content-min-width);
|
|
81
|
+
color: var(--bui-color-fg-muted);
|
|
82
|
+
text-align: left;
|
|
83
|
+
text-decoration: none;
|
|
84
|
+
word-wrap: break-word;
|
|
85
|
+
background-color: var(--bui-color-bg-popover);
|
|
86
|
+
border-radius: var(--bui-shape-radius-poster);
|
|
87
|
+
box-shadow:
|
|
88
|
+
0 3px 6px -4px rgba(0, 0, 0, 0.12),
|
|
89
|
+
0 6px 16px 0 rgba(0, 0, 0, 0.08),
|
|
90
|
+
0 9px 28px 8px rgba(0, 0, 0, 0.05);
|
|
91
|
+
}
|
|
92
|
+
.bui-popover .bui-popover-content .bui-popover-title + .bui-popover-inner-content {
|
|
93
|
+
margin-top: var(--bui-spacing-md);
|
|
94
|
+
}
|