@bifrostui/react 1.4.5 → 1.4.7-beta.0

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 (231) hide show
  1. package/dist/Calendar/Calendar.js +5 -1
  2. package/dist/Calendar/Calendar.types.d.ts +5 -0
  3. package/dist/CitySelector/CitySelectorCore.js +3 -3
  4. package/dist/Collapse/Collapse.css +0 -1
  5. package/dist/Collapse/Collapse.d.ts +1 -1
  6. package/dist/Collapse/Collapse.js +11 -8
  7. package/dist/Collapse/Collapse.miniapp.d.ts +5 -0
  8. package/dist/Collapse/Collapse.miniapp.js +177 -0
  9. package/dist/CollapsePanel/CollapsePanel.css +4 -2
  10. package/dist/DatePicker/DatePicker.d.ts +4 -0
  11. package/dist/DatePicker/DatePicker.js +335 -0
  12. package/dist/DatePicker/DatePicker.types.d.ts +43 -0
  13. package/dist/DatePicker/DatePicker.types.js +35 -0
  14. package/dist/DatePicker/index.d.ts +2 -0
  15. package/dist/DatePicker/index.js +41 -0
  16. package/dist/DesktopDatePicker/DesktopDatePicker.d.ts +5 -0
  17. package/dist/DesktopDatePicker/DesktopDatePicker.js +280 -0
  18. package/dist/DesktopDatePicker/DesktopDatePicker.types.d.ts +163 -0
  19. package/dist/DesktopDatePicker/DesktopDatePicker.types.js +15 -0
  20. package/dist/DesktopDatePicker/deskTopPickerContainer.css +100 -0
  21. package/dist/DesktopDatePicker/index.css +61 -0
  22. package/dist/DesktopDatePicker/index.d.ts +2 -0
  23. package/dist/DesktopDatePicker/index.js +41 -0
  24. package/dist/DesktopDatePicker/useGetDatePickerContent.d.ts +6 -0
  25. package/dist/DesktopDatePicker/useGetDatePickerContent.js +343 -0
  26. package/dist/DesktopDateTimePicker/DesktopDateTimePicker.d.ts +5 -0
  27. package/dist/DesktopDateTimePicker/DesktopDateTimePicker.js +322 -0
  28. package/dist/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +163 -0
  29. package/dist/DesktopDateTimePicker/DesktopDateTimePicker.types.js +15 -0
  30. package/dist/DesktopDateTimePicker/index.css +66 -0
  31. package/dist/DesktopDateTimePicker/index.d.ts +2 -0
  32. package/dist/DesktopDateTimePicker/index.js +41 -0
  33. package/dist/DesktopPicker/DesktopPicker.d.ts +5 -0
  34. package/dist/DesktopPicker/DesktopPicker.js +238 -0
  35. package/dist/DesktopPicker/DesktopPicker.types.d.ts +57 -0
  36. package/dist/DesktopPicker/DesktopPicker.types.js +15 -0
  37. package/dist/DesktopPicker/index.css +37 -0
  38. package/dist/DesktopPicker/index.d.ts +2 -0
  39. package/dist/DesktopPicker/index.js +41 -0
  40. package/dist/DesktopPicker/utils/calcAfterMounted.d.ts +2 -0
  41. package/dist/{Tabs/utils/bound.js → DesktopPicker/utils/calcAfterMounted.js} +7 -14
  42. package/dist/DesktopPicker/utils/calcAfterMounted.miniapp.d.ts +2 -0
  43. package/dist/DesktopPicker/utils/calcAfterMounted.miniapp.js +38 -0
  44. package/dist/DesktopTimePicker/DesktopTimePicker.d.ts +5 -0
  45. package/dist/DesktopTimePicker/DesktopTimePicker.js +288 -0
  46. package/dist/DesktopTimePicker/DesktopTimePicker.types.d.ts +182 -0
  47. package/dist/DesktopTimePicker/DesktopTimePicker.types.js +15 -0
  48. package/dist/DesktopTimePicker/DesktopTimePickerList.d.ts +4 -0
  49. package/dist/DesktopTimePicker/DesktopTimePickerList.js +111 -0
  50. package/dist/DesktopTimePicker/index.css +170 -0
  51. package/dist/DesktopTimePicker/index.d.ts +2 -0
  52. package/dist/DesktopTimePicker/index.js +41 -0
  53. package/dist/DesktopTimePicker/useGetTimePickerContent.d.ts +6 -0
  54. package/dist/DesktopTimePicker/useGetTimePickerContent.js +246 -0
  55. package/dist/DesktopTimePicker/utils/scrollUtil.d.ts +2 -0
  56. package/dist/DesktopTimePicker/utils/scrollUtil.js +27 -0
  57. package/dist/DesktopTimePicker/utils/scrollUtil.miniapp.d.ts +2 -0
  58. package/dist/DesktopTimePicker/utils/scrollUtil.miniapp.js +51 -0
  59. package/dist/DesktopTimePicker/utils/utils.d.ts +28 -0
  60. package/dist/DesktopTimePicker/utils/utils.js +408 -0
  61. package/dist/Dialog/FunctionalDialog.js +1 -1
  62. package/dist/ItemSelector/ItemSelector.css +120 -0
  63. package/dist/ItemSelector/ItemSelector.d.ts +4 -0
  64. package/dist/ItemSelector/ItemSelector.js +84 -0
  65. package/dist/ItemSelector/ItemSelector.miniapp.d.ts +5 -0
  66. package/dist/ItemSelector/ItemSelector.miniapp.js +125 -0
  67. package/dist/ItemSelector/ItemSelector.types.d.ts +40 -0
  68. package/dist/ItemSelector/ItemSelector.types.js +15 -0
  69. package/dist/ItemSelector/ItemSelectorCore.d.ts +5 -0
  70. package/dist/ItemSelector/ItemSelectorCore.js +217 -0
  71. package/dist/ItemSelector/Selector/index.css +11 -0
  72. package/dist/ItemSelector/Selector/index.d.ts +9 -0
  73. package/dist/ItemSelector/Selector/index.js +48 -0
  74. package/dist/ItemSelector/index.d.ts +2 -0
  75. package/dist/ItemSelector/index.js +41 -0
  76. package/dist/ItemSelector/miniapp.css +4 -0
  77. package/dist/Modal/Modal.miniapp.d.ts +1 -1
  78. package/dist/Picker/Picker.css +5 -0
  79. package/dist/Picker/Picker.js +27 -5
  80. package/dist/Picker/Picker.types.d.ts +15 -2
  81. package/dist/Picker/PickerPanel.css +4 -0
  82. package/dist/Picker/PickerPanel.js +7 -6
  83. package/dist/Popover/Popover.js +70 -27
  84. package/dist/Portal/Portal.miniapp.js +7 -4
  85. package/dist/ScrollView/ScrollView.js +24 -11
  86. package/dist/ScrollView/ScrollView.types.d.ts +0 -1
  87. package/dist/Select/Select.css +1 -4
  88. package/dist/Select/Select.js +63 -40
  89. package/dist/Slider/Slider.js +13 -5
  90. package/dist/SwipeAction/SwipeAction.css +79 -0
  91. package/dist/SwipeAction/SwipeAction.d.ts +5 -0
  92. package/dist/SwipeAction/SwipeAction.js +349 -0
  93. package/dist/SwipeAction/SwipeAction.types.d.ts +83 -0
  94. package/dist/SwipeAction/SwipeAction.types.js +39 -0
  95. package/dist/SwipeAction/SwipeActionContext.d.ts +4 -0
  96. package/dist/SwipeAction/SwipeActionContext.js +30 -0
  97. package/dist/SwipeAction/SwipeActionItem.css +31 -0
  98. package/dist/SwipeAction/SwipeActionItem.d.ts +5 -0
  99. package/dist/SwipeAction/SwipeActionItem.js +105 -0
  100. package/dist/SwipeAction/index.d.ts +4 -0
  101. package/dist/SwipeAction/index.js +45 -0
  102. package/dist/Tabs/Tab.js +13 -4
  103. package/dist/Tabs/Tabs.js +30 -15
  104. package/dist/Tabs/utils/scroll.d.ts +2 -0
  105. package/dist/Tabs/utils/scroll.js +55 -0
  106. package/dist/Toast/FunctionalToast.js +1 -1
  107. package/dist/Toast/Toast.css +0 -1
  108. package/dist/Tooltip/Tooltip.js +70 -27
  109. package/dist/index.d.ts +7 -0
  110. package/dist/index.js +15 -1
  111. package/dist/locales/base.d.ts +11 -0
  112. package/dist/locales/en-US.js +24 -0
  113. package/dist/locales/zh-CN.js +24 -0
  114. package/dist/locales/zh-TW.js +24 -0
  115. package/es/Calendar/Calendar.js +5 -1
  116. package/es/Calendar/Calendar.types.d.ts +5 -0
  117. package/es/CitySelector/CitySelectorCore.js +3 -3
  118. package/es/Collapse/Collapse.css +0 -1
  119. package/es/Collapse/Collapse.d.ts +1 -1
  120. package/es/Collapse/Collapse.js +11 -8
  121. package/es/Collapse/Collapse.miniapp.d.ts +5 -0
  122. package/es/Collapse/Collapse.miniapp.js +157 -0
  123. package/es/CollapsePanel/CollapsePanel.css +4 -2
  124. package/es/DatePicker/DatePicker.d.ts +4 -0
  125. package/es/DatePicker/DatePicker.js +310 -0
  126. package/es/DatePicker/DatePicker.types.d.ts +43 -0
  127. package/es/DatePicker/DatePicker.types.js +1 -0
  128. package/es/DatePicker/index.d.ts +2 -0
  129. package/es/DatePicker/index.js +6 -0
  130. package/es/DesktopDatePicker/DesktopDatePicker.d.ts +5 -0
  131. package/es/DesktopDatePicker/DesktopDatePicker.js +253 -0
  132. package/es/DesktopDatePicker/DesktopDatePicker.types.d.ts +163 -0
  133. package/es/DesktopDatePicker/DesktopDatePicker.types.js +1 -0
  134. package/es/DesktopDatePicker/deskTopPickerContainer.css +100 -0
  135. package/es/DesktopDatePicker/index.css +61 -0
  136. package/es/DesktopDatePicker/index.d.ts +2 -0
  137. package/es/DesktopDatePicker/index.js +6 -0
  138. package/es/DesktopDatePicker/useGetDatePickerContent.d.ts +6 -0
  139. package/es/DesktopDatePicker/useGetDatePickerContent.js +316 -0
  140. package/es/DesktopDateTimePicker/DesktopDateTimePicker.d.ts +5 -0
  141. package/es/DesktopDateTimePicker/DesktopDateTimePicker.js +295 -0
  142. package/es/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +163 -0
  143. package/es/DesktopDateTimePicker/DesktopDateTimePicker.types.js +1 -0
  144. package/es/DesktopDateTimePicker/index.css +66 -0
  145. package/es/DesktopDateTimePicker/index.d.ts +2 -0
  146. package/es/DesktopDateTimePicker/index.js +9 -0
  147. package/es/DesktopPicker/DesktopPicker.d.ts +5 -0
  148. package/es/DesktopPicker/DesktopPicker.js +221 -0
  149. package/es/DesktopPicker/DesktopPicker.types.d.ts +57 -0
  150. package/es/DesktopPicker/DesktopPicker.types.js +1 -0
  151. package/es/DesktopPicker/index.css +37 -0
  152. package/es/DesktopPicker/index.d.ts +2 -0
  153. package/es/DesktopPicker/index.js +6 -0
  154. package/es/DesktopPicker/utils/calcAfterMounted.d.ts +2 -0
  155. package/es/DesktopPicker/utils/calcAfterMounted.js +6 -0
  156. package/es/DesktopPicker/utils/calcAfterMounted.miniapp.d.ts +2 -0
  157. package/es/DesktopPicker/utils/calcAfterMounted.miniapp.js +9 -0
  158. package/es/DesktopTimePicker/DesktopTimePicker.d.ts +5 -0
  159. package/es/DesktopTimePicker/DesktopTimePicker.js +261 -0
  160. package/es/DesktopTimePicker/DesktopTimePicker.types.d.ts +182 -0
  161. package/es/DesktopTimePicker/DesktopTimePicker.types.js +1 -0
  162. package/es/DesktopTimePicker/DesktopTimePickerList.d.ts +4 -0
  163. package/es/DesktopTimePicker/DesktopTimePickerList.js +84 -0
  164. package/es/DesktopTimePicker/index.css +170 -0
  165. package/es/DesktopTimePicker/index.d.ts +2 -0
  166. package/es/DesktopTimePicker/index.js +6 -0
  167. package/es/DesktopTimePicker/useGetTimePickerContent.d.ts +6 -0
  168. package/es/DesktopTimePicker/useGetTimePickerContent.js +223 -0
  169. package/es/DesktopTimePicker/utils/scrollUtil.d.ts +2 -0
  170. package/es/DesktopTimePicker/utils/scrollUtil.js +8 -0
  171. package/es/DesktopTimePicker/utils/scrollUtil.miniapp.d.ts +2 -0
  172. package/es/DesktopTimePicker/utils/scrollUtil.miniapp.js +22 -0
  173. package/es/DesktopTimePicker/utils/utils.d.ts +28 -0
  174. package/es/DesktopTimePicker/utils/utils.js +365 -0
  175. package/es/Dialog/FunctionalDialog.js +2 -2
  176. package/es/ItemSelector/ItemSelector.css +120 -0
  177. package/es/ItemSelector/ItemSelector.d.ts +4 -0
  178. package/es/ItemSelector/ItemSelector.js +57 -0
  179. package/es/ItemSelector/ItemSelector.miniapp.d.ts +5 -0
  180. package/es/ItemSelector/ItemSelector.miniapp.js +98 -0
  181. package/es/ItemSelector/ItemSelector.types.d.ts +40 -0
  182. package/es/ItemSelector/ItemSelector.types.js +1 -0
  183. package/es/ItemSelector/ItemSelectorCore.d.ts +5 -0
  184. package/es/ItemSelector/ItemSelectorCore.js +190 -0
  185. package/es/ItemSelector/Selector/index.css +11 -0
  186. package/es/ItemSelector/Selector/index.d.ts +9 -0
  187. package/es/ItemSelector/Selector/index.js +19 -0
  188. package/es/ItemSelector/index.d.ts +2 -0
  189. package/es/ItemSelector/index.js +6 -0
  190. package/es/ItemSelector/miniapp.css +4 -0
  191. package/es/Picker/Picker.css +5 -0
  192. package/es/Picker/Picker.js +27 -5
  193. package/es/Picker/Picker.types.d.ts +15 -2
  194. package/es/Picker/PickerPanel.css +4 -0
  195. package/es/Picker/PickerPanel.js +7 -6
  196. package/es/Popover/Popover.js +73 -29
  197. package/es/Portal/Portal.miniapp.js +8 -5
  198. package/es/ScrollView/ScrollView.js +24 -11
  199. package/es/ScrollView/ScrollView.types.d.ts +0 -1
  200. package/es/Select/Select.css +1 -4
  201. package/es/Select/Select.js +63 -41
  202. package/es/Slider/Slider.js +16 -6
  203. package/es/SwipeAction/SwipeAction.css +79 -0
  204. package/es/SwipeAction/SwipeAction.d.ts +5 -0
  205. package/es/SwipeAction/SwipeAction.js +337 -0
  206. package/es/SwipeAction/SwipeAction.types.d.ts +83 -0
  207. package/es/SwipeAction/SwipeAction.types.js +1 -0
  208. package/es/SwipeAction/SwipeActionContext.d.ts +4 -0
  209. package/es/SwipeAction/SwipeActionContext.js +11 -0
  210. package/es/SwipeAction/SwipeActionItem.css +31 -0
  211. package/es/SwipeAction/SwipeActionItem.d.ts +5 -0
  212. package/es/SwipeAction/SwipeActionItem.js +78 -0
  213. package/es/SwipeAction/index.d.ts +4 -0
  214. package/es/SwipeAction/index.js +9 -0
  215. package/es/Tabs/Tab.js +13 -4
  216. package/es/Tabs/Tabs.js +30 -15
  217. package/es/Tabs/utils/scroll.d.ts +2 -0
  218. package/es/Tabs/utils/scroll.js +36 -0
  219. package/es/Toast/FunctionalToast.js +2 -2
  220. package/es/Toast/Toast.css +0 -1
  221. package/es/Tooltip/Tooltip.js +73 -29
  222. package/es/index.d.ts +7 -0
  223. package/es/index.js +7 -0
  224. package/es/locales/base.d.ts +11 -0
  225. package/es/locales/en-US.js +24 -0
  226. package/es/locales/zh-CN.js +24 -0
  227. package/es/locales/zh-TW.js +24 -0
  228. package/package.json +5 -5
  229. package/dist/Tabs/utils/bound.d.ts +0 -1
  230. package/es/Tabs/utils/bound.d.ts +0 -1
  231. package/es/Tabs/utils/bound.js +0 -13
@@ -0,0 +1,98 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ import React, { useEffect, useRef, useState } from "react";
21
+ import Taro from "@tarojs/taro";
22
+ import ItemSelectorCore from "./ItemSelectorCore";
23
+ import "./miniapp.css";
24
+ const ItemSelector = /* @__PURE__ */ React.forwardRef(
25
+ (props, ref) => {
26
+ const { items } = props;
27
+ const containerTop = useRef(0);
28
+ const codeHeight = useRef(0);
29
+ const [height, setHeight] = useState("");
30
+ const queryContainerTop = (cbk) => {
31
+ const query = Taro.createSelectorQuery();
32
+ query.select(".bui-item-selector-index-container").boundingClientRect();
33
+ query.exec((res) => {
34
+ var _a;
35
+ containerTop.current = (_a = res[0]) == null ? void 0 : _a.top;
36
+ cbk == null ? void 0 : cbk();
37
+ });
38
+ };
39
+ useEffect(() => {
40
+ if ((items == null ? void 0 : items.length) === 0 || codeHeight.current)
41
+ return;
42
+ setTimeout(() => {
43
+ const query = Taro.createSelectorQuery();
44
+ query.select(".bui-item-selector-index-item").boundingClientRect();
45
+ query.exec((res) => {
46
+ var _a;
47
+ codeHeight.current = (_a = res[0]) == null ? void 0 : _a.height;
48
+ });
49
+ }, 300);
50
+ }, [items, height]);
51
+ useEffect(() => {
52
+ if (!(items == null ? void 0 : items.length) || height)
53
+ return;
54
+ const { screenHeight } = Taro.getSystemInfoSync();
55
+ const query = Taro.createSelectorQuery();
56
+ query.select(".bui-item-selector-scroll-view-container").boundingClientRect();
57
+ query.exec((codeRect) => {
58
+ var _a;
59
+ const domHeight = (_a = codeRect == null ? void 0 : codeRect[0]) == null ? void 0 : _a.height;
60
+ setHeight(`${domHeight / screenHeight * 100}vh`);
61
+ });
62
+ }, [items]);
63
+ const parseIndex = (length, index) => {
64
+ if (index <= 0)
65
+ return 0;
66
+ if (index >= length - 1)
67
+ return length - 1;
68
+ return index;
69
+ };
70
+ const pxToCode = (clientY, scrollToCode, codeGroup) => {
71
+ let index = Math.floor(
72
+ (clientY - containerTop.current) / codeHeight.current
73
+ );
74
+ index = parseIndex(codeGroup.length, index);
75
+ const codeItem = codeGroup[index];
76
+ scrollToCode(codeItem.code || codeItem);
77
+ };
78
+ const touchHandler = (event, scrollToCode, codeGroup) => {
79
+ const { clientY } = event.changedTouches[0];
80
+ queryContainerTop(() => {
81
+ pxToCode(clientY, scrollToCode, codeGroup);
82
+ });
83
+ };
84
+ return /* @__PURE__ */ React.createElement(
85
+ ItemSelectorCore,
86
+ __spreadProps(__spreadValues({}, props), {
87
+ ref,
88
+ touchHandler,
89
+ height
90
+ })
91
+ );
92
+ }
93
+ );
94
+ ItemSelector.displayName = "BuiItemSelector";
95
+ var ItemSelector_miniapp_default = ItemSelector;
96
+ export {
97
+ ItemSelector_miniapp_default as default
98
+ };
@@ -0,0 +1,40 @@
1
+ /// <reference types="react" />
2
+ import { OverrideProps } from '@bifrostui/types';
3
+ export type itemType = {
4
+ /** Item名 */
5
+ name: string;
6
+ };
7
+ export type ItemGroup = {
8
+ /** Item列表 */
9
+ items: itemType[];
10
+ /** 组名 */
11
+ groupName?: string;
12
+ /** 索引字母 */
13
+ indexName?: string;
14
+ /** 索引Code */
15
+ indexCode?: string;
16
+ /** 是否平铺 */
17
+ isFlat?: boolean;
18
+ };
19
+ export type ItemSelectorProps<D extends React.ElementType = 'div', P = {}> = OverrideProps<{
20
+ props: P & {
21
+ /** Item列表 */
22
+ items: ItemGroup[];
23
+ /** 禁用展示索引 默认false 即展示索引 */
24
+ disableIndex?: boolean;
25
+ /** 头部标题 */
26
+ title?: string;
27
+ /** 选择Item回调 */
28
+ onSelect: (e: React.SyntheticEvent, data: {
29
+ item: itemType;
30
+ group: ItemGroup;
31
+ }) => void;
32
+ /** 和title配合使用,头部右侧的关闭回调 */
33
+ onClose?: (e: React.SyntheticEvent) => void;
34
+ };
35
+ defaultComponent: D;
36
+ }, D>;
37
+ export type ItemSelectorCoreProps = ItemSelectorProps & {
38
+ touchHandler: any;
39
+ height?: string;
40
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { ItemSelectorCoreProps } from './ItemSelector.types';
3
+ import './ItemSelector.less';
4
+ declare const ItemSelector: React.ForwardRefExoticComponent<Omit<ItemSelectorCoreProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
5
+ export default ItemSelector;
@@ -0,0 +1,190 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ var __objRest = (source, exclude) => {
18
+ var target = {};
19
+ for (var prop in source)
20
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
21
+ target[prop] = source[prop];
22
+ if (source != null && __getOwnPropSymbols)
23
+ for (var prop of __getOwnPropSymbols(source)) {
24
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
25
+ target[prop] = source[prop];
26
+ }
27
+ return target;
28
+ };
29
+ import React, { useState, useEffect, useRef } from "react";
30
+ import clsx from "clsx";
31
+ import { throttle, useForkRef, useTouchEmulator } from "@bifrostui/utils";
32
+ import ScrollView from "../ScrollView";
33
+ import Selector from "./Selector";
34
+ import "./ItemSelector.css";
35
+ const DEVIATION_HEIGHT = "6vmin";
36
+ const prefixCls = "bui-item-selector";
37
+ const ItemSelector = /* @__PURE__ */ React.forwardRef(
38
+ (props, ref) => {
39
+ const _a = props, {
40
+ className,
41
+ title: pageTitle,
42
+ items,
43
+ disableIndex,
44
+ touchHandler,
45
+ height,
46
+ onSelect,
47
+ onClose
48
+ } = _a, others = __objRest(_a, [
49
+ "className",
50
+ "title",
51
+ "items",
52
+ "disableIndex",
53
+ "touchHandler",
54
+ "height",
55
+ "onSelect",
56
+ "onClose"
57
+ ]);
58
+ const itemRef = useRef(null);
59
+ const nodeRef = useForkRef(ref, itemRef);
60
+ useTouchEmulator(itemRef.current);
61
+ const [codeGroup, setCodeGroup] = useState([]);
62
+ const [codeShow, setCodeShow] = useState(false);
63
+ const [targetId, setTargetId] = useState("");
64
+ const getGroupName = (item) => item.groupName || "";
65
+ const getIdxName = (item) => typeof item.indexName === "string" ? item.indexName : getGroupName(item);
66
+ const getIdxCode = (item) => typeof item.indexCode === "string" ? item.indexCode : getIdxName(item);
67
+ const renderTitle = (item) => {
68
+ const title = getGroupName(item);
69
+ return title ? /* @__PURE__ */ React.createElement(
70
+ "div",
71
+ {
72
+ className: "select-item-title",
73
+ id: disableIndex ? "" : getIdxCode(item)
74
+ },
75
+ title
76
+ ) : null;
77
+ };
78
+ useEffect(() => {
79
+ if (!items || (items == null ? void 0 : items.length) === 0 || codeGroup.length !== 0 || disableIndex) {
80
+ return;
81
+ }
82
+ setCodeGroup(
83
+ items.map((item) => {
84
+ return {
85
+ name: getIdxName(item),
86
+ code: getIdxCode(item)
87
+ };
88
+ })
89
+ );
90
+ }, [items]);
91
+ useEffect(() => {
92
+ if (codeGroup.length === 0)
93
+ return;
94
+ setCodeShow(true);
95
+ }, [codeGroup]);
96
+ const scrollToCode = (targetCode) => {
97
+ if (!targetCode)
98
+ return;
99
+ setTargetId((oldCode) => {
100
+ if (targetCode !== oldCode)
101
+ return targetCode;
102
+ return oldCode;
103
+ });
104
+ };
105
+ const touchCbk = (e) => {
106
+ e.stopPropagation();
107
+ touchHandler == null ? void 0 : touchHandler(e, scrollToCode, codeGroup);
108
+ };
109
+ const codeClickHandler = (rightCode) => {
110
+ setTargetId(rightCode);
111
+ };
112
+ const scrollHandler = throttle(() => {
113
+ if (targetId) {
114
+ setTargetId(void 0);
115
+ }
116
+ }, 500);
117
+ const closeHandler = (e) => {
118
+ onClose == null ? void 0 : onClose(e);
119
+ };
120
+ return /* @__PURE__ */ React.createElement("div", __spreadValues({ className: clsx(prefixCls, className), ref: nodeRef }, others), pageTitle ? /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-title` }, pageTitle, /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-btn-close`, onClick: closeHandler }, "\u2715")) : null, /* @__PURE__ */ React.createElement(
121
+ ScrollView,
122
+ {
123
+ scrollIntoView: targetId,
124
+ scrollY: true,
125
+ className: clsx(`${prefixCls}-scroll-view-container tph`, {
126
+ "container-has-title": pageTitle
127
+ }),
128
+ onScroll: scrollHandler
129
+ },
130
+ /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-all-item` }, (items == null ? void 0 : items.length) > 0 ? /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-list-container` }, items.map((item, itemGroupIndex) => {
131
+ if (!(item == null ? void 0 : item.groupName))
132
+ return null;
133
+ return /* @__PURE__ */ React.createElement("div", { key: itemGroupIndex }, renderTitle(item), item.isFlat ? /* @__PURE__ */ React.createElement("div", { className: "select-item-buttons" }, item.items.map((it, index) => {
134
+ return /* @__PURE__ */ React.createElement(
135
+ Selector,
136
+ {
137
+ key: index,
138
+ item: it,
139
+ onSelect: (e) => {
140
+ onSelect(e, { item: it, group: item });
141
+ }
142
+ }
143
+ );
144
+ })) : /* @__PURE__ */ React.createElement("ul", { className: `${prefixCls}-list` }, item.items.map((it, itemIndex) => {
145
+ return /* @__PURE__ */ React.createElement(
146
+ "li",
147
+ {
148
+ className: `${prefixCls}-list-item`,
149
+ key: itemIndex,
150
+ onClick: (e) => {
151
+ onSelect(e, { item: it, group: item });
152
+ }
153
+ },
154
+ it.name
155
+ );
156
+ })));
157
+ })) : null)
158
+ ), (codeGroup == null ? void 0 : codeGroup.length) > 0 && height ? /* @__PURE__ */ React.createElement(
159
+ "div",
160
+ {
161
+ className: clsx(`${prefixCls}-index-container`, {
162
+ "left-in": codeShow,
163
+ "item-index-has-title": pageTitle
164
+ })
165
+ },
166
+ /* @__PURE__ */ React.createElement("ul", { onTouchMove: touchCbk, className: `${prefixCls}-index-list` }, codeGroup.map((item, idx) => {
167
+ return item.name ? /* @__PURE__ */ React.createElement(
168
+ "li",
169
+ {
170
+ className: `${prefixCls}-index-item`,
171
+ key: idx,
172
+ "data-code": item.code,
173
+ onClick: () => {
174
+ codeClickHandler(item.code);
175
+ },
176
+ style: {
177
+ maxHeight: `calc((${height} - ${DEVIATION_HEIGHT}) / ${codeGroup.length})`
178
+ }
179
+ },
180
+ item.name
181
+ ) : null;
182
+ }))
183
+ ) : null);
184
+ }
185
+ );
186
+ ItemSelector.displayName = "BuiItemSelector";
187
+ var ItemSelectorCore_default = ItemSelector;
188
+ export {
189
+ ItemSelectorCore_default as default
190
+ };
@@ -0,0 +1,11 @@
1
+ .bui-item-selector-item {
2
+ width: var(--bui-item-selector-item-width);
3
+ height: var(--bui-item-selector-item-height);
4
+ display: inline-flex;
5
+ justify-content: center;
6
+ align-items: center;
7
+ border-radius: var(--bui-item-selector-item-border-radius);
8
+ margin: var(--bui-item-selector-item-margin);
9
+ background-color: var(--bui-color-bg-default);
10
+ font-size: var(--bui-text-size-2);
11
+ }
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { itemType } from '../ItemSelector.types';
3
+ import './index.less';
4
+ type propsType = {
5
+ item: itemType;
6
+ onSelect: (e: React.SyntheticEvent, item: itemType) => void;
7
+ };
8
+ declare const Selector: (props: propsType) => React.JSX.Element;
9
+ export default Selector;
@@ -0,0 +1,19 @@
1
+ import React from "react";
2
+ import "./index.css";
3
+ const Selector = (props) => {
4
+ const { item, onSelect } = props;
5
+ return /* @__PURE__ */ React.createElement(
6
+ "span",
7
+ {
8
+ className: "bui-item-selector-item",
9
+ onClick: (e) => {
10
+ onSelect == null ? void 0 : onSelect(e, item);
11
+ }
12
+ },
13
+ item.name
14
+ );
15
+ };
16
+ var Selector_default = Selector;
17
+ export {
18
+ Selector_default as default
19
+ };
@@ -0,0 +1,2 @@
1
+ export { default as ItemSelector, default } from './ItemSelector';
2
+ export * from './ItemSelector.types';
@@ -0,0 +1,6 @@
1
+ import { default as default2, default as default3 } from "./ItemSelector";
2
+ export * from "./ItemSelector.types";
3
+ export {
4
+ default2 as ItemSelector,
5
+ default3 as default
6
+ };
@@ -0,0 +1,4 @@
1
+ .bui-item-scroll-view-container {
2
+ height: 100%;
3
+ display: block;
4
+ }
@@ -8,6 +8,7 @@
8
8
  --panel-container-height: var(--bui-picker-panel-height, 260px);
9
9
  --indicator-top: var(--bui-picker-indicator-top, 108px);
10
10
  --option-height: var(--bui-picker-option-height, 36px);
11
+ --bui-picker-confirm-disabled-opacity: 0.38;
11
12
  font-family: var(--bui-font-family);
12
13
  }
13
14
  .bui-picker .bui-drawer-content {
@@ -41,6 +42,10 @@
41
42
  line-height: var(--confirm-line-height);
42
43
  color: var(--bui-color-primary);
43
44
  }
45
+ .bui-picker-confirm-disabled {
46
+ color: var(--bui-color-fg-default);
47
+ opacity: var(--bui-picker-confirm-disabled-opacity);
48
+ }
44
49
  .bui-picker-container {
45
50
  width: 100%;
46
51
  height: var(--panel-container-height);
@@ -37,6 +37,12 @@ import { useLocaleText } from "../locales";
37
37
  import { formatOptions, pickerPanelType, safeData } from "./utils";
38
38
  import "./Picker.css";
39
39
  const prefixCls = "bui-picker";
40
+ const checkDisabled = (values, columns) => values.find(
41
+ (value, index) => {
42
+ var _a, _b;
43
+ return (_b = (_a = columns == null ? void 0 : columns[index]) == null ? void 0 : _a.find((column) => (column == null ? void 0 : column.value) === value)) == null ? void 0 : _b.disabled;
44
+ }
45
+ );
40
46
  const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
41
47
  const _a = props, {
42
48
  className,
@@ -44,6 +50,8 @@ const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
44
50
  title,
45
51
  options = [],
46
52
  value,
53
+ confirmText: propConfirmText,
54
+ cancelText: propCancelText,
47
55
  contentProps,
48
56
  onConfirm,
49
57
  onOptionChange,
@@ -55,6 +63,8 @@ const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
55
63
  "title",
56
64
  "options",
57
65
  "value",
66
+ "confirmText",
67
+ "cancelText",
58
68
  "contentProps",
59
69
  "onConfirm",
60
70
  "onOptionChange",
@@ -66,6 +76,7 @@ const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
66
76
  const [columns, setColumns] = useState([]);
67
77
  const [internalValue, setInternalValue] = useState([]);
68
78
  const { cancel: cancelText, confirm: confirmText } = useLocaleText("picker");
79
+ const disabled = checkDisabled(internalValue, columns);
69
80
  useEffect(() => {
70
81
  if (!open)
71
82
  return;
@@ -88,7 +99,7 @@ const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
88
99
  }, [value, options]);
89
100
  const confirm = (e) => {
90
101
  const isMoving = rollerRefs.current.some((roller) => roller == null ? void 0 : roller.isMoving);
91
- if (isMoving)
102
+ if (isMoving || disabled)
92
103
  return;
93
104
  const { safeValue } = safeData({
94
105
  value: internalValue,
@@ -147,7 +158,8 @@ const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
147
158
  onOptionChange == null ? void 0 : onOptionChange(e, {
148
159
  value: conbineValues,
149
160
  options: formatted,
150
- currentOption: columnOption
161
+ currentOption: columnOption,
162
+ columnIndex
151
163
  });
152
164
  } else {
153
165
  const result = [...internalValue];
@@ -156,7 +168,8 @@ const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
156
168
  onOptionChange == null ? void 0 : onOptionChange(e, {
157
169
  value: result,
158
170
  options,
159
- currentOption: columnOption
171
+ currentOption: columnOption,
172
+ columnIndex
160
173
  });
161
174
  }
162
175
  }
@@ -198,7 +211,16 @@ const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
198
211
  __spreadProps(__spreadValues({}, contentProps), {
199
212
  className: clsx(`${prefixCls}-content`, contentProps == null ? void 0 : contentProps.className)
200
213
  }),
201
- /* @__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)),
214
+ /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-header` }, /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-cancel`, onClick: cancel }, propCancelText || cancelText), title && /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-title` }, title), /* @__PURE__ */ React.createElement(
215
+ "div",
216
+ {
217
+ className: clsx(`${prefixCls}-confirm`, {
218
+ [`${prefixCls}-confirm-disabled`]: disabled
219
+ }),
220
+ onClick: confirm
221
+ },
222
+ propConfirmText || confirmText
223
+ )),
202
224
  /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-container` }, columns.map((column, index) => /* @__PURE__ */ React.createElement(
203
225
  PickerPanel,
204
226
  {
@@ -206,7 +228,7 @@ const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
206
228
  key: index,
207
229
  options: column,
208
230
  columnIndex: index,
209
- defaultValue: internalValue == null ? void 0 : internalValue[index],
231
+ value: internalValue == null ? void 0 : internalValue[index],
210
232
  onSelect: handleSelect,
211
233
  pickerStyle: others == null ? void 0 : others.style
212
234
  }
@@ -10,6 +10,10 @@ export interface IPickerOptionItem {
10
10
  * 选项对应唯一的值
11
11
  */
12
12
  value: string | number;
13
+ /**
14
+ * 是否禁用
15
+ */
16
+ disabled?: boolean;
13
17
  }
14
18
  export type ICascadePickerChildOptionItem = IPickerOptionItem & {
15
19
  /**
@@ -34,6 +38,14 @@ export type PickerProps<D extends React.ElementType = 'div', P = DrawerProps> =
34
38
  * 标题
35
39
  */
36
40
  title?: string;
41
+ /**
42
+ * 确认文本内容
43
+ */
44
+ confirmText?: string;
45
+ /**
46
+ * 取消文本内容
47
+ */
48
+ cancelText?: string;
37
49
  /**
38
50
  * 列表数据
39
51
  * @default []
@@ -61,6 +73,7 @@ export type PickerProps<D extends React.ElementType = 'div', P = DrawerProps> =
61
73
  value: (string | number)[];
62
74
  options: ICascadePickerChildOptionItem[][];
63
75
  currentOption: ICascadePickerChildOptionItem;
76
+ columnIndex: number;
64
77
  }) => void;
65
78
  /**
66
79
  * 点击取消按钮时候回调
@@ -85,9 +98,9 @@ export type PickerPanelProps<D extends React.ElementType = 'div', P = {}> = Over
85
98
  */
86
99
  options?: ICascadePickerChildOptionItem[];
87
100
  /**
88
- * 默认值
101
+ * 选中值
89
102
  */
90
- defaultValue?: string | number;
103
+ value?: string | number;
91
104
  /**
92
105
  * 列索引
93
106
  */
@@ -1,4 +1,5 @@
1
1
  .bui-picker-panel {
2
+ --bui-picker-option-disabled-opacity: 0.38;
2
3
  flex: 1;
3
4
  flex-shrink: 0;
4
5
  position: relative;
@@ -56,6 +57,9 @@
56
57
  white-space: nowrap;
57
58
  width: 100%;
58
59
  }
60
+ .bui-picker-panel-option-disabled {
61
+ opacity: var(--bui-picker-option-disabled-opacity);
62
+ }
59
63
  .bui-picker-panel-option-hidden {
60
64
  visibility: hidden;
61
65
  opacity: 0;
@@ -36,13 +36,13 @@ const PickerPanel = /* @__PURE__ */ React.forwardRef(
36
36
  var _b;
37
37
  const _a = props, {
38
38
  options = [],
39
- defaultValue,
39
+ value,
40
40
  onSelect,
41
41
  columnIndex,
42
42
  pickerStyle
43
43
  } = _a, others = __objRest(_a, [
44
44
  "options",
45
- "defaultValue",
45
+ "value",
46
46
  "onSelect",
47
47
  "columnIndex",
48
48
  "pickerStyle"
@@ -72,9 +72,9 @@ const PickerPanel = /* @__PURE__ */ React.forwardRef(
72
72
  useTouchEmulator(PickerPanelRef.current);
73
73
  const updateSelect = () => {
74
74
  let index = -1;
75
- if (defaultValue) {
75
+ if (value) {
76
76
  options.some((item, idx) => {
77
- if (item.value === defaultValue) {
77
+ if (item.value === value) {
78
78
  index = idx;
79
79
  return true;
80
80
  }
@@ -92,7 +92,7 @@ const PickerPanel = /* @__PURE__ */ React.forwardRef(
92
92
  return () => {
93
93
  clearTimeout(timer);
94
94
  };
95
- }, [options]);
95
+ }, [options, value]);
96
96
  const setTransform = (type, deg, time = DEFAULT_DURATION, translateY = 0) => {
97
97
  let nTime = time;
98
98
  if (type !== TOUCH_END) {
@@ -225,7 +225,8 @@ const PickerPanel = /* @__PURE__ */ React.forwardRef(
225
225
  "div",
226
226
  {
227
227
  className: clsx(`${prefixCls}-option`, {
228
- [`${prefixCls}-option-hidden`]: i + 1 <= currIndex - 8 || i + 1 >= currIndex + 8
228
+ [`${prefixCls}-option-hidden`]: i + 1 <= currIndex - 8 || i + 1 >= currIndex + 8,
229
+ [`${prefixCls}-option-disabled`]: item == null ? void 0 : item.disabled
229
230
  }),
230
231
  key: `${item == null ? void 0 : item.value}-${i}`,
231
232
  style: {