@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.
Files changed (233) hide show
  1. package/dist/ActionSheet/ActionSheet.less +31 -0
  2. package/dist/ActionSheet/ActionSheetItem.less +62 -0
  3. package/dist/Alert/index.less +112 -0
  4. package/dist/Avatar/Avatar.less +52 -0
  5. package/dist/Avatar/AvatarGroup.less +39 -0
  6. package/dist/Backdrop/{Backdrop.css → Backdrop.less} +4 -3
  7. package/dist/Badge/Badge.less +118 -0
  8. package/dist/Button/Button.less +244 -0
  9. package/dist/Calendar/Calendar.less +126 -0
  10. package/{es/Card/Card.css → dist/Card/Card.less} +1 -0
  11. package/dist/Card/CardHeader.less +53 -0
  12. package/dist/Checkbox/Checkbox.less +55 -0
  13. package/dist/CitySelector/CitySelector.d.ts +4 -0
  14. package/dist/CitySelector/CitySelector.js +36 -0
  15. package/dist/CitySelector/CitySelector.less +122 -0
  16. package/dist/CitySelector/CitySelector.miniapp.d.ts +5 -0
  17. package/dist/CitySelector/CitySelector.miniapp.js +79 -0
  18. package/dist/CitySelector/CitySelector.types.d.ts +47 -0
  19. package/dist/CitySelector/CitySelector.types.js +5 -0
  20. package/dist/CitySelector/CitySelectorCore.d.ts +5 -0
  21. package/dist/CitySelector/CitySelectorCore.js +183 -0
  22. package/dist/CitySelector/Selector/index.d.ts +9 -0
  23. package/dist/CitySelector/Selector/index.js +22 -0
  24. package/dist/CitySelector/Selector/index.less +13 -0
  25. package/dist/CitySelector/index.d.ts +2 -0
  26. package/dist/CitySelector/index.js +34 -0
  27. package/dist/CitySelector/miniapp.less +4 -0
  28. package/dist/Countdown/Countdown.less +39 -0
  29. package/dist/Divider/Divider.less +50 -0
  30. package/dist/Drawer/Drawer.less +40 -0
  31. package/dist/IconButton/IconButton.less +167 -0
  32. package/dist/Image/index.less +40 -0
  33. package/dist/Input/Input.less +72 -0
  34. package/dist/List/{List.css → List.less} +1 -0
  35. package/dist/List/{ListItem.css → ListItem.less} +17 -6
  36. package/dist/List/{ListItemContent.css → ListItemContent.less} +7 -2
  37. package/dist/List/{ListItemFooter.css → ListItemFooter.less} +4 -3
  38. package/dist/Loading/Loading.less +40 -0
  39. package/dist/Modal/{Modal.css → Modal.less} +8 -6
  40. package/dist/Modal/Modal.miniapp.d.ts +16 -0
  41. package/dist/Modal/Modal.miniapp.js +73 -0
  42. package/dist/NavBar/NavBar.less +67 -0
  43. package/dist/Picker/Picker.d.ts +5 -0
  44. package/dist/Picker/Picker.js +155 -0
  45. package/dist/Picker/Picker.less +62 -0
  46. package/dist/Picker/Picker.types.d.ts +98 -0
  47. package/dist/Picker/Picker.types.js +5 -0
  48. package/dist/Picker/PickerPanel.d.ts +5 -0
  49. package/dist/Picker/PickerPanel.js +210 -0
  50. package/dist/Picker/PickerPanel.less +67 -0
  51. package/dist/Picker/index.d.ts +2 -0
  52. package/dist/Picker/index.js +34 -0
  53. package/dist/Picker/utils.d.ts +13 -0
  54. package/dist/Picker/utils.js +66 -0
  55. package/dist/Progress/Progress.less +24 -0
  56. package/dist/Radio/Radio.less +81 -0
  57. package/dist/Rating/Rating.less +64 -0
  58. package/dist/ScrollView/{ScrollView.css → ScrollView.less} +4 -0
  59. package/dist/Select/Select.less +105 -0
  60. package/dist/Skeleton/Skeleton.less +72 -0
  61. package/dist/Slider/Slider.less +108 -0
  62. package/dist/Stack/demo/index.less +27 -0
  63. package/dist/Steps/Step.less +228 -0
  64. package/{es/Steps/Steps.css → dist/Steps/Steps.less} +5 -3
  65. package/dist/Swiper/Swiper.less +25 -0
  66. package/dist/Switch/Switch.less +177 -0
  67. package/dist/TabBar/TabBarItem.less +54 -0
  68. package/dist/Tabs/Tab.js +1 -1
  69. package/dist/Tabs/Tab.less +60 -0
  70. package/dist/Tabs/TabPanel.less +11 -0
  71. package/dist/Tabs/Tabs.less +77 -0
  72. package/dist/Tag/Tag.less +119 -0
  73. package/dist/Tag/TagGroup.less +52 -0
  74. package/dist/TextArea/{TextArea.css → TextArea.less} +27 -19
  75. package/dist/index.d.ts +2 -0
  76. package/dist/index.js +22 -0
  77. package/es/ActionSheet/ActionSheet.less +31 -0
  78. package/es/ActionSheet/ActionSheetItem.less +62 -0
  79. package/es/Alert/index.less +112 -0
  80. package/es/Avatar/Avatar.less +52 -0
  81. package/es/Avatar/AvatarGroup.less +39 -0
  82. package/es/Backdrop/{Backdrop.css → Backdrop.less} +4 -3
  83. package/es/Badge/Badge.less +118 -0
  84. package/es/Button/Button.less +244 -0
  85. package/es/Calendar/Calendar.less +126 -0
  86. package/{dist/Card/Card.css → es/Card/Card.less} +1 -0
  87. package/es/Card/CardHeader.less +53 -0
  88. package/es/Checkbox/Checkbox.less +55 -0
  89. package/es/CitySelector/CitySelector.d.ts +4 -0
  90. package/es/CitySelector/CitySelector.js +36 -0
  91. package/es/CitySelector/CitySelector.less +122 -0
  92. package/es/CitySelector/CitySelector.miniapp.d.ts +5 -0
  93. package/es/CitySelector/CitySelector.miniapp.js +77 -0
  94. package/es/CitySelector/CitySelector.types.d.ts +47 -0
  95. package/es/CitySelector/CitySelector.types.js +1 -0
  96. package/es/CitySelector/CitySelectorCore.d.ts +5 -0
  97. package/es/CitySelector/CitySelectorCore.js +194 -0
  98. package/es/CitySelector/Selector/index.d.ts +9 -0
  99. package/es/CitySelector/Selector/index.js +13 -0
  100. package/es/CitySelector/Selector/index.less +13 -0
  101. package/es/CitySelector/index.d.ts +2 -0
  102. package/es/CitySelector/index.js +2 -0
  103. package/es/CitySelector/miniapp.less +4 -0
  104. package/es/Countdown/Countdown.less +39 -0
  105. package/es/Divider/Divider.less +50 -0
  106. package/es/Drawer/Drawer.less +40 -0
  107. package/es/IconButton/IconButton.less +167 -0
  108. package/es/Image/index.less +40 -0
  109. package/es/Input/Input.less +72 -0
  110. package/es/List/{List.css → List.less} +1 -0
  111. package/es/List/{ListItem.css → ListItem.less} +17 -6
  112. package/es/List/{ListItemContent.css → ListItemContent.less} +7 -2
  113. package/es/List/{ListItemFooter.css → ListItemFooter.less} +4 -3
  114. package/es/Loading/Loading.less +40 -0
  115. package/es/Modal/{Modal.css → Modal.less} +8 -6
  116. package/es/Modal/Modal.miniapp.d.ts +16 -0
  117. package/es/Modal/Modal.miniapp.js +78 -0
  118. package/es/NavBar/NavBar.less +67 -0
  119. package/es/Picker/Picker.d.ts +5 -0
  120. package/es/Picker/Picker.js +171 -0
  121. package/es/Picker/Picker.less +62 -0
  122. package/es/Picker/Picker.types.d.ts +98 -0
  123. package/es/Picker/Picker.types.js +1 -0
  124. package/es/Picker/PickerPanel.d.ts +5 -0
  125. package/es/Picker/PickerPanel.js +234 -0
  126. package/es/Picker/PickerPanel.less +67 -0
  127. package/es/Picker/index.d.ts +2 -0
  128. package/es/Picker/index.js +2 -0
  129. package/es/Picker/utils.d.ts +13 -0
  130. package/es/Picker/utils.js +65 -0
  131. package/es/Progress/Progress.less +24 -0
  132. package/es/Radio/Radio.less +81 -0
  133. package/es/Rating/Rating.less +64 -0
  134. package/es/ScrollView/{ScrollView.css → ScrollView.less} +4 -0
  135. package/es/Select/Select.less +105 -0
  136. package/es/Skeleton/Skeleton.less +72 -0
  137. package/es/Slider/Slider.less +108 -0
  138. package/es/Stack/demo/index.less +27 -0
  139. package/es/Steps/Step.less +228 -0
  140. package/{dist/Steps/Steps.css → es/Steps/Steps.less} +5 -3
  141. package/es/Swiper/Swiper.less +25 -0
  142. package/es/Switch/Switch.less +177 -0
  143. package/es/TabBar/TabBarItem.less +54 -0
  144. package/es/Tabs/Tab.js +1 -1
  145. package/es/Tabs/Tab.less +60 -0
  146. package/es/Tabs/TabPanel.less +11 -0
  147. package/es/Tabs/Tabs.less +77 -0
  148. package/es/Tag/Tag.less +119 -0
  149. package/es/Tag/TagGroup.less +52 -0
  150. package/es/TextArea/{TextArea.css → TextArea.less} +27 -19
  151. package/es/index.d.ts +2 -0
  152. package/es/index.js +3 -1
  153. package/package.json +6 -6
  154. package/dist/ActionSheet/ActionSheet.css +0 -27
  155. package/dist/ActionSheet/ActionSheetItem.css +0 -51
  156. package/dist/Alert/index.css +0 -89
  157. package/dist/Avatar/Avatar.css +0 -43
  158. package/dist/Avatar/AvatarGroup.css +0 -31
  159. package/dist/Badge/Badge.css +0 -95
  160. package/dist/Button/Button.css +0 -200
  161. package/dist/Calendar/Calendar.css +0 -105
  162. package/dist/Card/CardHeader.css +0 -45
  163. package/dist/Checkbox/Checkbox.css +0 -45
  164. package/dist/Countdown/Countdown.css +0 -28
  165. package/dist/Divider/Divider.css +0 -41
  166. package/dist/Drawer/Drawer.css +0 -35
  167. package/dist/IconButton/IconButton.css +0 -130
  168. package/dist/Image/index.css +0 -35
  169. package/dist/Input/Input.css +0 -59
  170. package/dist/Loading/Loading.css +0 -31
  171. package/dist/NavBar/NavBar.css +0 -57
  172. package/dist/Progress/Progress.css +0 -22
  173. package/dist/Radio/Radio.css +0 -65
  174. package/dist/Rating/Rating.css +0 -52
  175. package/dist/Select/Select.css +0 -89
  176. package/dist/Skeleton/Skeleton.css +0 -54
  177. package/dist/Slider/Slider.css +0 -95
  178. package/dist/Stack/demo/index.css +0 -23
  179. package/dist/Steps/Step.css +0 -174
  180. package/dist/Swiper/Swiper.css +0 -20
  181. package/dist/Switch/Switch.css +0 -127
  182. package/dist/TabBar/TabBarItem.css +0 -38
  183. package/dist/Tabs/Tab.css +0 -52
  184. package/dist/Tabs/TabPanel.css +0 -9
  185. package/dist/Tabs/Tabs.css +0 -56
  186. package/dist/Tag/Tag.css +0 -97
  187. package/dist/Tag/TagGroup.css +0 -43
  188. package/es/ActionSheet/ActionSheet.css +0 -27
  189. package/es/ActionSheet/ActionSheetItem.css +0 -51
  190. package/es/Alert/index.css +0 -89
  191. package/es/Avatar/Avatar.css +0 -43
  192. package/es/Avatar/AvatarGroup.css +0 -31
  193. package/es/Badge/Badge.css +0 -95
  194. package/es/Button/Button.css +0 -200
  195. package/es/Calendar/Calendar.css +0 -105
  196. package/es/Card/CardHeader.css +0 -45
  197. package/es/Checkbox/Checkbox.css +0 -45
  198. package/es/Countdown/Countdown.css +0 -28
  199. package/es/Divider/Divider.css +0 -41
  200. package/es/Drawer/Drawer.css +0 -35
  201. package/es/IconButton/IconButton.css +0 -130
  202. package/es/Image/index.css +0 -35
  203. package/es/Input/Input.css +0 -59
  204. package/es/Loading/Loading.css +0 -31
  205. package/es/NavBar/NavBar.css +0 -57
  206. package/es/Progress/Progress.css +0 -22
  207. package/es/Radio/Radio.css +0 -65
  208. package/es/Rating/Rating.css +0 -52
  209. package/es/Select/Select.css +0 -89
  210. package/es/Skeleton/Skeleton.css +0 -54
  211. package/es/Slider/Slider.css +0 -95
  212. package/es/Stack/demo/index.css +0 -23
  213. package/es/Steps/Step.css +0 -174
  214. package/es/Swiper/Swiper.css +0 -20
  215. package/es/Switch/Switch.css +0 -127
  216. package/es/TabBar/TabBarItem.css +0 -38
  217. package/es/Tabs/Tab.css +0 -52
  218. package/es/Tabs/TabPanel.css +0 -9
  219. package/es/Tabs/Tabs.css +0 -56
  220. package/es/Tag/Tag.css +0 -97
  221. package/es/Tag/TagGroup.css +0 -43
  222. /package/dist/Card/{CardContent.css → CardContent.less} +0 -0
  223. /package/dist/Card/{CardFooter.css → CardFooter.less} +0 -0
  224. /package/dist/List/{ListItemExtra.css → ListItemExtra.less} +0 -0
  225. /package/dist/List/{ListItemHeader.css → ListItemHeader.less} +0 -0
  226. /package/dist/Stack/{Stack.css → Stack.less} +0 -0
  227. /package/dist/TabBar/{TabBar.css → TabBar.less} +0 -0
  228. /package/es/Card/{CardContent.css → CardContent.less} +0 -0
  229. /package/es/Card/{CardFooter.css → CardFooter.less} +0 -0
  230. /package/es/List/{ListItemExtra.css → ListItemExtra.less} +0 -0
  231. /package/es/List/{ListItemHeader.css → ListItemHeader.less} +0 -0
  232. /package/es/Stack/{Stack.css → Stack.less} +0 -0
  233. /package/es/TabBar/{TabBar.css → TabBar.less} +0 -0
@@ -0,0 +1,122 @@
1
+ @import '~@bifrostui/styles/mixins/index.less';
2
+
3
+ .bui-city-selector {
4
+ font-family: var(--bui-font-family);
5
+ height: 100%;
6
+ position: relative;
7
+
8
+ &-title {
9
+ width: 100%;
10
+ height: 45px;
11
+ color: var(--bui-color-fg-default);
12
+ font-size: var(--bui-title-size-3);
13
+ line-height: 45px;
14
+ text-align: center;
15
+ position: sticky;
16
+ top: 0;
17
+ z-index: 1004;
18
+ border-bottom: solid 1px var(--bui-color-border-default);
19
+ background-color: var(--bui-color-bg-view);
20
+ }
21
+
22
+ &-btn-close {
23
+ position: absolute;
24
+ top: 0;
25
+ right: 0;
26
+ width: 45px;
27
+ height: 45px;
28
+ color: var(--bui-color-fg-muted);
29
+ text-align: center;
30
+ font-size: 20px;
31
+ }
32
+
33
+ &-scroll-view-container {
34
+ height: 100%;
35
+
36
+ &.container-has-title {
37
+ height: calc(100% - 45px);
38
+ }
39
+ }
40
+
41
+ &-all-city {
42
+ min-height: 500px;
43
+ font-size: var(--bui-text-size-2);
44
+ width: 100%;
45
+ background: var(--bui-color-bg-view);
46
+ align-self: flex-start;
47
+
48
+ .select-city-buttons {
49
+ display: flex;
50
+ flex-flow: wrap;
51
+ padding-left: 3px;
52
+ padding-top: 7.5px;
53
+ }
54
+
55
+ .select-city-title {
56
+ font-size: var(--bui-title-size-4);
57
+ line-height: 15px;
58
+ font-weight: 600;
59
+ padding-left: var(--bui-spacing-lg);
60
+ padding-top: 9px;
61
+ }
62
+ }
63
+
64
+ &-list {
65
+ padding-left: var(--bui-spacing-lg);
66
+ list-style-type: none;
67
+ }
68
+
69
+ &-list-item {
70
+ height: 45px;
71
+ font-size: var(--bui-title-size-4);
72
+ display: flex;
73
+ align-items: center;
74
+
75
+ &:not(:last-child) {
76
+ border-bottom: 0.5px solid var(--bui-color-border-default);
77
+ }
78
+ }
79
+
80
+ &-index-container {
81
+ z-index: 1001;
82
+ position: absolute;
83
+ white-space: nowrap;
84
+ right: 0;
85
+ top: 50%;
86
+ width: 40px;
87
+ will-change: transform;
88
+ // transform: translate(100%, -50%);
89
+ transform: translate(0, -50%);
90
+ transition:
91
+ opacity 0.2s ease-out,
92
+ transform 0.2s ease-out;
93
+
94
+ &.left-in {
95
+ opacity: 1;
96
+ transform: translate(0, -50%);
97
+ }
98
+
99
+ &.city-index-has-title {
100
+ top: calc(50% + 22.5px);
101
+ }
102
+
103
+ ul {
104
+ margin: 0;
105
+ padding: 0;
106
+ float: left;
107
+ width: 100%;
108
+ touch-action: none;
109
+ }
110
+
111
+ li {
112
+ list-style: none;
113
+ height: 20px;
114
+ text-align: center;
115
+ font-size: var(--bui-text-size-3);
116
+ color: var(--bui-color-info, --bui-color-info);
117
+ display: flex;
118
+ align-items: center;
119
+ justify-content: center;
120
+ }
121
+ }
122
+ }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { CitySelectorProps } from './CitySelector.types';
3
+ import './miniapp.less';
4
+ declare const CitySelector: React.ForwardRefExoticComponent<Omit<CitySelectorProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
5
+ export default CitySelector;
@@ -0,0 +1,77 @@
1
+ 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); }
2
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
6
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
7
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
8
+ import React, { useEffect, useRef, useState } from 'react';
9
+ import Taro from '@tarojs/taro';
10
+ import CitySelectorCore from "./CitySelectorCore";
11
+ import "./miniapp.css";
12
+ var CitySelector = /*#__PURE__*/React.forwardRef(function (props, ref) {
13
+ var cities = props.cities;
14
+ var containerTop = useRef(0);
15
+ var codeHeight = useRef(0);
16
+ var _useState = useState(''),
17
+ _useState2 = _slicedToArray(_useState, 2),
18
+ height = _useState2[0],
19
+ setHeight = _useState2[1];
20
+ var queryContainerTop = function queryContainerTop(cbk) {
21
+ var query = Taro.createSelectorQuery();
22
+ query.select('.bui-city-selector-index-container').boundingClientRect();
23
+ query.exec(function (res) {
24
+ var _res$;
25
+ containerTop.current = (_res$ = res[0]) === null || _res$ === void 0 ? void 0 : _res$.top;
26
+ cbk === null || cbk === void 0 || cbk();
27
+ });
28
+ };
29
+ useEffect(function () {
30
+ if ((cities === null || cities === void 0 ? void 0 : cities.length) === 0 || codeHeight.current) return;
31
+ // 演示获取字母高度
32
+ setTimeout(function () {
33
+ var query = Taro.createSelectorQuery();
34
+ query.select('.bui-city-selector-index-item').boundingClientRect();
35
+ query.exec(function (res) {
36
+ var _res$2;
37
+ codeHeight.current = (_res$2 = res[0]) === null || _res$2 === void 0 ? void 0 : _res$2.height;
38
+ });
39
+ }, 300);
40
+ }, [cities, height]);
41
+ useEffect(function () {
42
+ if (!(cities !== null && cities !== void 0 && cities.length) || height) return;
43
+ var _Taro$getSystemInfoSy = Taro.getSystemInfoSync(),
44
+ screenHeight = _Taro$getSystemInfoSy.screenHeight;
45
+ var query = Taro.createSelectorQuery();
46
+ query.select('.bui-city-selector-scroll-view-container').boundingClientRect();
47
+ query.exec(function (codeRect) {
48
+ var _codeRect$;
49
+ var domHeight = codeRect === null || codeRect === void 0 || (_codeRect$ = codeRect[0]) === null || _codeRect$ === void 0 ? void 0 : _codeRect$.height;
50
+ setHeight("".concat(domHeight / screenHeight * 100, "vh"));
51
+ });
52
+ }, [cities]);
53
+ var parseIndex = function parseIndex(length, index) {
54
+ if (index <= 0) return 0;
55
+ if (index >= length - 1) return length - 1;
56
+ return index;
57
+ };
58
+ var pxToCode = function pxToCode(clientY, scrollToCode, codeGroup) {
59
+ var index = Math.floor((clientY - containerTop.current) / codeHeight.current);
60
+ index = parseIndex(codeGroup.length, index);
61
+ var codeItem = codeGroup[index];
62
+ scrollToCode(codeItem.code || codeItem);
63
+ };
64
+ var touchHandler = function touchHandler(event, scrollToCode, codeGroup) {
65
+ var clientY = event.changedTouches[0].clientY;
66
+ queryContainerTop(function () {
67
+ pxToCode(clientY, scrollToCode, codeGroup);
68
+ });
69
+ };
70
+ return /*#__PURE__*/React.createElement(CitySelectorCore, _extends({}, props, {
71
+ ref: ref,
72
+ touchHandler: touchHandler,
73
+ height: height
74
+ }));
75
+ });
76
+ CitySelector.displayName = 'BuiCitySelector';
77
+ export default CitySelector;
@@ -0,0 +1,47 @@
1
+ /// <reference types="react" />
2
+ import { OverrideProps } from '@bifrostui/types';
3
+ export type cityType = {
4
+ /** 城市名 */
5
+ name: string;
6
+ /** 城市名id */
7
+ code: string;
8
+ };
9
+ export type allCityItemType = {
10
+ /** 城市列表 */
11
+ cities: cityType[];
12
+ /** 索引字母 */
13
+ groupName: string;
14
+ };
15
+ export type CitySelectorProps<D extends React.ElementType = 'div', P = {}> = OverrideProps<{
16
+ props: P & {
17
+ /** 当前城市信息 */
18
+ selectedCity?: cityType;
19
+ /** 当前城市栏的title */
20
+ selectedCityGroupName?: string;
21
+ /** 定位城市信息 */
22
+ currentCity?: cityType;
23
+ /** 定位城市栏的title */
24
+ currentCityGroupName?: string;
25
+ /** 热门城市信息 */
26
+ hotCities?: cityType[];
27
+ /** 热门城市栏的title */
28
+ hotCitiesGroupName?: string;
29
+ /** 城市列表 */
30
+ cities: allCityItemType[];
31
+ /** 禁用展示索引 默认false 即展示索引 */
32
+ disableIndex?: boolean;
33
+ /** 头部标题 */
34
+ title?: string;
35
+ /** 选择城市回调 */
36
+ onSelect: (e: React.SyntheticEvent, data: {
37
+ city: cityType;
38
+ }) => void;
39
+ /** 和title配合使用,头部右侧的关闭回调 */
40
+ onClose?: (e: React.SyntheticEvent) => void;
41
+ };
42
+ defaultComponent: D;
43
+ }, D>;
44
+ export type CitySelectorCoreProps = CitySelectorProps & {
45
+ touchHandler: any;
46
+ height?: string;
47
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { CitySelectorCoreProps } from './CitySelector.types';
3
+ import './CitySelector.less';
4
+ declare const CitySelector: React.ForwardRefExoticComponent<Omit<CitySelectorCoreProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
5
+ export default CitySelector;
@@ -0,0 +1,194 @@
1
+ var _excluded = ["className", "title", "selectedCity", "selectedCityGroupName", "currentCity", "currentCityGroupName", "hotCities", "hotCitiesGroupName", "cities", "disableIndex", "touchHandler", "height", "onSelect", "onClose"];
2
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
7
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
8
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
9
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
10
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
11
+ import React, { useState, useEffect, useRef } from 'react';
12
+ import clsx from 'clsx';
13
+ import { throttle, useForkRef, useTouchEmulator } from '@bifrostui/utils';
14
+ import { ScrollView } from "../ScrollView";
15
+ import Selector from "./Selector";
16
+ import "./CitySelector.css";
17
+
18
+ // 误差偏移量
19
+ var DEVIATION_HEIGHT = '6vmin';
20
+ var GPS_TYPE = {
21
+ title: '定位',
22
+ code: 'GPS'
23
+ };
24
+ var CURRENT_TYPE = {
25
+ title: '当前',
26
+ code: 'CRRT'
27
+ };
28
+ var HOT_CITY_TYPE = {
29
+ title: '热门',
30
+ code: 'HOT'
31
+ };
32
+ var prefixCls = 'bui-city-selector';
33
+ var CitySelector = /*#__PURE__*/React.forwardRef(function (props, ref) {
34
+ var className = props.className,
35
+ pageTitle = props.title,
36
+ selectedCity = props.selectedCity,
37
+ _props$selectedCityGr = props.selectedCityGroupName,
38
+ selectedCityGroupName = _props$selectedCityGr === void 0 ? '当前城市' : _props$selectedCityGr,
39
+ currentCity = props.currentCity,
40
+ _props$currentCityGro = props.currentCityGroupName,
41
+ currentCityGroupName = _props$currentCityGro === void 0 ? '定位城市' : _props$currentCityGro,
42
+ hotCities = props.hotCities,
43
+ _props$hotCitiesGroup = props.hotCitiesGroupName,
44
+ hotCitiesGroupName = _props$hotCitiesGroup === void 0 ? '热门城市' : _props$hotCitiesGroup,
45
+ cities = props.cities,
46
+ disableIndex = props.disableIndex,
47
+ touchHandler = props.touchHandler,
48
+ height = props.height,
49
+ onSelect = props.onSelect,
50
+ onClose = props.onClose,
51
+ others = _objectWithoutProperties(props, _excluded);
52
+ var cityRef = useRef(null);
53
+ var nodeRef = useForkRef(ref, cityRef);
54
+ useTouchEmulator(cityRef.current);
55
+ var _useState = useState([]),
56
+ _useState2 = _slicedToArray(_useState, 2),
57
+ codeGroup = _useState2[0],
58
+ setCodeGroup = _useState2[1];
59
+ var _useState3 = useState(false),
60
+ _useState4 = _slicedToArray(_useState3, 2),
61
+ codeShow = _useState4[0],
62
+ setCodeShow = _useState4[1];
63
+ var _useState5 = useState(''),
64
+ _useState6 = _slicedToArray(_useState5, 2),
65
+ targetId = _useState6[0],
66
+ setTargetId = _useState6[1];
67
+
68
+ // 提取字母
69
+ useEffect(function () {
70
+ if (!cities || (cities === null || cities === void 0 ? void 0 : cities.length) === 0 || codeGroup.length !== 0 || disableIndex) return;
71
+ var newGroup = [];
72
+ if (selectedCity) {
73
+ newGroup.push(CURRENT_TYPE);
74
+ }
75
+ if (currentCity) {
76
+ newGroup.push(GPS_TYPE);
77
+ }
78
+ if (hotCities) {
79
+ newGroup.push(HOT_CITY_TYPE);
80
+ }
81
+ cities.forEach(function (item) {
82
+ newGroup.push(item.groupName.toUpperCase());
83
+ });
84
+ setCodeGroup(newGroup);
85
+ }, [cities, selectedCity, currentCity, hotCities]);
86
+
87
+ // 计算每个code的top
88
+ useEffect(function () {
89
+ if (codeGroup.length === 0) return;
90
+ setCodeShow(true);
91
+ }, [codeGroup]);
92
+ var selectHandler = function selectHandler(e, city) {
93
+ onSelect(e, {
94
+ city: city
95
+ });
96
+ };
97
+ var scrollToCode = function scrollToCode(targetCode) {
98
+ if (!targetCode) return;
99
+ setTargetId(function (oldCode) {
100
+ if (targetCode !== oldCode) return targetCode;
101
+ return oldCode;
102
+ });
103
+ };
104
+ var touchCbk = function touchCbk(e) {
105
+ e.stopPropagation();
106
+ touchHandler === null || touchHandler === void 0 || touchHandler(e, scrollToCode, codeGroup);
107
+ };
108
+ var codeClickHandler = function codeClickHandler(rightCode) {
109
+ setTargetId(rightCode);
110
+ };
111
+ var scrollHandler = throttle(function () {
112
+ if (targetId) {
113
+ setTargetId(undefined);
114
+ }
115
+ }, 500);
116
+ var closeHandler = function closeHandler(e) {
117
+ onClose === null || onClose === void 0 || onClose(e);
118
+ };
119
+ var renderTitile = function renderTitile(title, titleCode) {
120
+ var parseTitle = (titleCode || title).toUpperCase();
121
+ return /*#__PURE__*/React.createElement("div", {
122
+ className: "select-city-title",
123
+ id: disableIndex ? '' : parseTitle
124
+ }, title.toUpperCase());
125
+ };
126
+ var renderCity = function renderCity(citys, title, titleCode) {
127
+ return /*#__PURE__*/React.createElement("div", null, renderTitile(title, titleCode), /*#__PURE__*/React.createElement("div", {
128
+ className: "select-city-buttons"
129
+ }, citys.map(function (city, index) {
130
+ return /*#__PURE__*/React.createElement(Selector, {
131
+ key: index,
132
+ city: city,
133
+ onSelect: selectHandler
134
+ });
135
+ })));
136
+ };
137
+ return /*#__PURE__*/React.createElement("div", _extends({
138
+ className: clsx(prefixCls, className),
139
+ ref: nodeRef
140
+ }, others), pageTitle ? /*#__PURE__*/React.createElement("div", {
141
+ className: "".concat(prefixCls, "-title")
142
+ }, pageTitle, /*#__PURE__*/React.createElement("div", {
143
+ className: "".concat(prefixCls, "-btn-close"),
144
+ onClick: closeHandler
145
+ }, "\u2715")) : null, /*#__PURE__*/React.createElement(ScrollView, {
146
+ scrollIntoView: targetId,
147
+ scrollY: true,
148
+ className: clsx("".concat(prefixCls, "-scroll-view-container tph"), {
149
+ 'container-has-title': pageTitle
150
+ }),
151
+ onScroll: scrollHandler
152
+ }, /*#__PURE__*/React.createElement("div", {
153
+ className: "".concat(prefixCls, "-all-city")
154
+ }, selectedCity ? renderCity([selectedCity], selectedCityGroupName, CURRENT_TYPE.code) : null, currentCity ? renderCity([currentCity], currentCityGroupName, GPS_TYPE.code) : null, (hotCities === null || hotCities === void 0 ? void 0 : hotCities.length) > 0 ? renderCity(hotCities, hotCitiesGroupName, HOT_CITY_TYPE.code) : null, (cities === null || cities === void 0 ? void 0 : cities.length) > 0 ? /*#__PURE__*/React.createElement("div", {
155
+ className: "".concat(prefixCls, "-list-container")
156
+ }, cities.map(function (item, cityGroupIndex) {
157
+ if (!(item !== null && item !== void 0 && item.groupName)) return null;
158
+ return /*#__PURE__*/React.createElement("div", {
159
+ key: cityGroupIndex
160
+ }, renderTitile(item.groupName, item.groupName), /*#__PURE__*/React.createElement("ul", {
161
+ className: "".concat(prefixCls, "-list")
162
+ }, item.cities.map(function (city, cityIndex) {
163
+ return /*#__PURE__*/React.createElement("li", {
164
+ className: "".concat(prefixCls, "-list-item"),
165
+ key: cityIndex,
166
+ onClick: function onClick(e) {
167
+ selectHandler(e, city);
168
+ }
169
+ }, city.name);
170
+ })));
171
+ })) : null)), (codeGroup === null || codeGroup === void 0 ? void 0 : codeGroup.length) > 0 && height ? /*#__PURE__*/React.createElement("div", {
172
+ className: clsx("".concat(prefixCls, "-index-container"), {
173
+ 'left-in': codeShow,
174
+ 'city-index-has-title': pageTitle
175
+ })
176
+ }, /*#__PURE__*/React.createElement("ul", {
177
+ onTouchMove: touchCbk,
178
+ className: "".concat(prefixCls, "-index-list")
179
+ }, codeGroup.map(function (item, chartIndex) {
180
+ return /*#__PURE__*/React.createElement("li", {
181
+ className: "".concat(prefixCls, "-index-item"),
182
+ key: chartIndex,
183
+ "data-code": item.code || item,
184
+ onClick: function onClick() {
185
+ codeClickHandler(item.code || item);
186
+ },
187
+ style: {
188
+ maxHeight: "calc((".concat(height, " - ").concat(DEVIATION_HEIGHT, ") / ").concat(codeGroup.length, ")")
189
+ }
190
+ }, item.title || item);
191
+ }))) : null);
192
+ });
193
+ CitySelector.displayName = 'BuiCitySelector';
194
+ export default CitySelector;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { cityType } from '../CitySelector.types';
3
+ import './index.less';
4
+ type propsType = {
5
+ city: cityType;
6
+ onSelect: (e: React.SyntheticEvent, city: cityType) => void;
7
+ };
8
+ declare const Selector: (props: propsType) => React.JSX.Element;
9
+ export default Selector;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import "./index.css";
3
+ var Selector = function Selector(props) {
4
+ var city = props.city,
5
+ onSelect = props.onSelect;
6
+ return /*#__PURE__*/React.createElement("span", {
7
+ className: "bui-city-selector-item",
8
+ onClick: function onClick(e) {
9
+ onSelect === null || onSelect === void 0 || onSelect(e, city);
10
+ }
11
+ }, city.name);
12
+ };
13
+ export default Selector;
@@ -0,0 +1,13 @@
1
+ @import '~@bifrostui/styles/mixins/index.less';
2
+
3
+ .bui-city-selector-item {
4
+ width: 111px;
5
+ height: 36px;
6
+ display: inline-flex;
7
+ justify-content: center;
8
+ align-items: center;
9
+ border-radius: 20px;
10
+ margin: 4.5px 0 4.5px 9px;
11
+ background-color: var(--bui-color-bg-default);
12
+ font-size: var(--bui-text-size-2);
13
+ }
@@ -0,0 +1,2 @@
1
+ export { default as CitySelector, default } from './CitySelector';
2
+ export * from './CitySelector.types';
@@ -0,0 +1,2 @@
1
+ export { default as CitySelector, default } from "./CitySelector";
2
+ export * from "./CitySelector.types";
@@ -0,0 +1,4 @@
1
+ .bui-city-scroll-view-container {
2
+ height: 100%;
3
+ display: block;
4
+ }
@@ -0,0 +1,39 @@
1
+ @import '~@bifrostui/styles/mixins/index.less';
2
+
3
+ .bui-countdown {
4
+ --font-size: var(--bui-countdown-font-size, var(--bui-text-size-1));
5
+ --color: var(--bui-countdown-color, var(--bui-color-fg-default));
6
+ --font-weight: var(
7
+ --bui-countdown-font-weight,
8
+ var(--bui-font-weight-normal)
9
+ );
10
+ display: flex;
11
+ flex-direction: row;
12
+ align-items: center;
13
+ font-size: var(--font-size);
14
+ color: var(--color);
15
+ font-weight: var(--font-weight);
16
+ font-family: var(--bui-font-family);
17
+
18
+ &-slice {
19
+ display: flex;
20
+ flex-direction: row;
21
+ align-items: center;
22
+
23
+ &-item {
24
+ display: flex;
25
+ flex-direction: row;
26
+ align-items: center;
27
+ }
28
+
29
+ &-value {
30
+ font-family: 'Helvetica Neue', helvetica, 'PingFang SC', 'Chinese Quote',
31
+ 'Segoe UI', roboto, 'Hiragino Sans GB', 'Microsoft YaHei', arial,
32
+ sans-serif;
33
+ }
34
+
35
+ &-unit {
36
+ margin: 0 2px;
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,50 @@
1
+ .bui-divider {
2
+ --height: var(--bui-divider-height, 100%);
3
+ --width: var(--bui-divider-width, 100%);
4
+
5
+ border-color: var(--bui-color-border-default);
6
+ font-family: var(--bui-font-family);
7
+
8
+ &-vertical {
9
+ height: var(--height);
10
+ display: inline-block;
11
+ border-right-width: 1px;
12
+ border-right-style: solid;
13
+ }
14
+
15
+ &-horizontal {
16
+ width: var(--width);
17
+ border-bottom-width: 1px;
18
+ border-bottom-style: solid;
19
+ }
20
+
21
+ &-vertical-dashed {
22
+ border-right-style: dashed;
23
+ }
24
+
25
+ &-horizontal-dashed {
26
+ border-bottom-style: dashed;
27
+ }
28
+
29
+ &-content {
30
+ width: 100%;
31
+ // border-width 设置border粗细
32
+ border-width: 0;
33
+ display: flex;
34
+ align-items: center;
35
+ justify-content: center;
36
+ }
37
+
38
+ &-line {
39
+ width: 40px;
40
+ border-bottom-width: 1px;
41
+ border-bottom-style: solid;
42
+ border-color: var(--bui-color-border-default);
43
+ }
44
+
45
+ &-text {
46
+ flex-shrink: 0;
47
+ color: var(--bui-color-fg-subtle);
48
+ font-size: var(--bui-text-size-2);
49
+ }
50
+ }
@@ -0,0 +1,40 @@
1
+ .bui-drawer {
2
+ font-family: var(--bui-font-family);
3
+
4
+ &-content {
5
+ display: flex;
6
+ flex-direction: column;
7
+ height: 100%;
8
+ flex: 1 0 auto;
9
+ position: fixed;
10
+ top: 0;
11
+ outline: 0;
12
+ background-color: var(--bui-color-bg-view);
13
+
14
+ &-left {
15
+ left: 0;
16
+ }
17
+
18
+ &-top {
19
+ top: 0;
20
+ left: 0;
21
+ right: 0;
22
+ height: auto;
23
+ max-height: 100%;
24
+ }
25
+
26
+ &-right {
27
+ right: 0;
28
+ }
29
+
30
+ &-bottom {
31
+ bottom: 0;
32
+ top: auto;
33
+ left: 0;
34
+ /* stylelint-disable-next-line declaration-block-no-redundant-longhand-properties */
35
+ right: 0;
36
+ height: auto;
37
+ max-height: 100%;
38
+ }
39
+ }
40
+ }