@bifrostui/react 1.4.6 → 1.4.7

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 (39) hide show
  1. package/dist/CitySelector/CitySelectorCore.js +3 -3
  2. package/dist/ItemSelector/ItemSelector.css +120 -0
  3. package/dist/ItemSelector/ItemSelector.d.ts +4 -0
  4. package/dist/ItemSelector/ItemSelector.js +84 -0
  5. package/dist/ItemSelector/ItemSelector.miniapp.d.ts +5 -0
  6. package/dist/ItemSelector/ItemSelector.miniapp.js +125 -0
  7. package/dist/ItemSelector/ItemSelector.types.d.ts +40 -0
  8. package/dist/ItemSelector/ItemSelector.types.js +15 -0
  9. package/dist/ItemSelector/ItemSelectorCore.d.ts +5 -0
  10. package/dist/ItemSelector/ItemSelectorCore.js +217 -0
  11. package/dist/ItemSelector/Selector/index.css +11 -0
  12. package/dist/ItemSelector/Selector/index.d.ts +9 -0
  13. package/dist/ItemSelector/Selector/index.js +48 -0
  14. package/dist/ItemSelector/index.d.ts +2 -0
  15. package/dist/ItemSelector/index.js +41 -0
  16. package/dist/ItemSelector/miniapp.css +4 -0
  17. package/dist/Modal/Modal.miniapp.d.ts +1 -1
  18. package/dist/index.d.ts +1 -0
  19. package/dist/index.js +2 -0
  20. package/es/CitySelector/CitySelectorCore.js +3 -3
  21. package/es/ItemSelector/ItemSelector.css +120 -0
  22. package/es/ItemSelector/ItemSelector.d.ts +4 -0
  23. package/es/ItemSelector/ItemSelector.js +57 -0
  24. package/es/ItemSelector/ItemSelector.miniapp.d.ts +5 -0
  25. package/es/ItemSelector/ItemSelector.miniapp.js +98 -0
  26. package/es/ItemSelector/ItemSelector.types.d.ts +40 -0
  27. package/es/ItemSelector/ItemSelector.types.js +1 -0
  28. package/es/ItemSelector/ItemSelectorCore.d.ts +5 -0
  29. package/es/ItemSelector/ItemSelectorCore.js +190 -0
  30. package/es/ItemSelector/Selector/index.css +11 -0
  31. package/es/ItemSelector/Selector/index.d.ts +9 -0
  32. package/es/ItemSelector/Selector/index.js +19 -0
  33. package/es/ItemSelector/index.d.ts +2 -0
  34. package/es/ItemSelector/index.js +6 -0
  35. package/es/ItemSelector/miniapp.css +4 -0
  36. package/es/Modal/Modal.miniapp.d.ts +1 -1
  37. package/es/index.d.ts +1 -0
  38. package/es/index.js +1 -0
  39. package/package.json +5 -5
@@ -0,0 +1,48 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var Selector_exports = {};
29
+ __export(Selector_exports, {
30
+ default: () => Selector_default
31
+ });
32
+ module.exports = __toCommonJS(Selector_exports);
33
+ var import_react = __toESM(require("react"));
34
+ var import_index = require("./index.css");
35
+ const Selector = (props) => {
36
+ const { item, onSelect } = props;
37
+ return /* @__PURE__ */ import_react.default.createElement(
38
+ "span",
39
+ {
40
+ className: "bui-item-selector-item",
41
+ onClick: (e) => {
42
+ onSelect == null ? void 0 : onSelect(e, item);
43
+ }
44
+ },
45
+ item.name
46
+ );
47
+ };
48
+ var Selector_default = Selector;
@@ -0,0 +1,2 @@
1
+ export { default as ItemSelector, default } from './ItemSelector';
2
+ export * from './ItemSelector.types';
@@ -0,0 +1,41 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var ItemSelector_exports = {};
30
+ __export(ItemSelector_exports, {
31
+ ItemSelector: () => import_ItemSelector.default,
32
+ default: () => import_ItemSelector.default
33
+ });
34
+ module.exports = __toCommonJS(ItemSelector_exports);
35
+ var import_ItemSelector = __toESM(require("./ItemSelector"));
36
+ __reExport(ItemSelector_exports, require("./ItemSelector.types"), module.exports);
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ ItemSelector,
40
+ ...require("./ItemSelector.types")
41
+ });
@@ -0,0 +1,4 @@
1
+ .bui-item-scroll-view-container {
2
+ height: 100%;
3
+ display: block;
4
+ }
@@ -12,5 +12,5 @@ declare const Modal: React.ForwardRefExoticComponent<Omit<ViewProps & {
12
12
  keepMounted?: boolean;
13
13
  } & import("@bifrostui/types").ICommonProps & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
14
14
  ref?: React.Ref<HTMLDivElement>;
15
- }, "open" | keyof import("@bifrostui/types").ICommonProps | "container" | "disablePortal" | "hideBackdrop" | "BackdropProps" | "onClose" | "disableScrollLock" | "keepMounted">, "ref"> & React.RefAttributes<HTMLDivElement>>;
15
+ }, "open" | "container" | "disablePortal" | keyof import("@bifrostui/types").ICommonProps | "hideBackdrop" | "BackdropProps" | "onClose" | "disableScrollLock" | "keepMounted">, "ref"> & React.RefAttributes<HTMLDivElement>>;
16
16
  export default Modal;
package/dist/index.d.ts CHANGED
@@ -40,6 +40,7 @@ export * from './Loading';
40
40
  export * from './TabBar';
41
41
  export * from './Countdown';
42
42
  export * from './CitySelector';
43
+ export * from './ItemSelector';
43
44
  export * from './Picker';
44
45
  export * from './CollapsePanel';
45
46
  export * from './Breadcrumb';
package/dist/index.js CHANGED
@@ -56,6 +56,7 @@ __reExport(src_exports, require("./Loading"), module.exports);
56
56
  __reExport(src_exports, require("./TabBar"), module.exports);
57
57
  __reExport(src_exports, require("./Countdown"), module.exports);
58
58
  __reExport(src_exports, require("./CitySelector"), module.exports);
59
+ __reExport(src_exports, require("./ItemSelector"), module.exports);
59
60
  __reExport(src_exports, require("./Picker"), module.exports);
60
61
  __reExport(src_exports, require("./CollapsePanel"), module.exports);
61
62
  __reExport(src_exports, require("./Breadcrumb"), module.exports);
@@ -107,6 +108,7 @@ __reExport(src_exports, require("./locales"), module.exports);
107
108
  ...require("./TabBar"),
108
109
  ...require("./Countdown"),
109
110
  ...require("./CitySelector"),
111
+ ...require("./ItemSelector"),
110
112
  ...require("./Picker"),
111
113
  ...require("./CollapsePanel"),
112
114
  ...require("./Breadcrumb"),
@@ -144,12 +144,12 @@ const CitySelector = /* @__PURE__ */ React.forwardRef(
144
144
  const closeHandler = (e) => {
145
145
  onClose == null ? void 0 : onClose(e);
146
146
  };
147
- const renderTitile = (title, titleCode) => {
147
+ const renderTitle = (title, titleCode) => {
148
148
  const parseTitle = (titleCode || title).toUpperCase();
149
149
  return /* @__PURE__ */ React.createElement("div", { className: "select-city-title", id: disableIndex ? "" : parseTitle }, title == null ? void 0 : title.toUpperCase());
150
150
  };
151
151
  const renderCity = (citys, title, titleCode) => {
152
- return /* @__PURE__ */ React.createElement("div", null, renderTitile(title, titleCode), /* @__PURE__ */ React.createElement("div", { className: "select-city-buttons" }, citys.map((city, index) => {
152
+ return /* @__PURE__ */ React.createElement("div", null, renderTitle(title, titleCode), /* @__PURE__ */ React.createElement("div", { className: "select-city-buttons" }, citys.map((city, index) => {
153
153
  return /* @__PURE__ */ React.createElement(Selector, { key: index, city, onSelect: selectHandler });
154
154
  })));
155
155
  };
@@ -170,7 +170,7 @@ const CitySelector = /* @__PURE__ */ React.forwardRef(
170
170
  ) : null, currentCity ? renderCity([currentCity], currentCityGroupName, GPS_TYPE.code) : null, (hotCities == null ? void 0 : hotCities.length) > 0 ? renderCity(hotCities, hotCitiesGroupName, HOT_CITY_TYPE.code) : null, (cities == null ? void 0 : cities.length) > 0 ? /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-list-container` }, cities.map((item, cityGroupIndex) => {
171
171
  if (!(item == null ? void 0 : item.groupName))
172
172
  return null;
173
- return /* @__PURE__ */ React.createElement("div", { key: cityGroupIndex }, renderTitile(item.groupName, item.groupName), /* @__PURE__ */ React.createElement("ul", { className: `${prefixCls}-list` }, item.cities.map((city, cityIndex) => {
173
+ return /* @__PURE__ */ React.createElement("div", { key: cityGroupIndex }, renderTitle(item.groupName, item.groupName), /* @__PURE__ */ React.createElement("ul", { className: `${prefixCls}-list` }, item.cities.map((city, cityIndex) => {
174
174
  return /* @__PURE__ */ React.createElement(
175
175
  "li",
176
176
  {
@@ -0,0 +1,120 @@
1
+ :root,
2
+ page,
3
+ xhs-page {
4
+ --bui-item-selector-item-width: 111px;
5
+ --bui-item-selector-item-height: 36px;
6
+ --bui-item-selector-item-border-radius: 20px;
7
+ --bui-item-selector-item-margin: 4.5px 0 4.5px 9px;
8
+ --bui-item-selector-title-height: 45px;
9
+ --bui-item-selector-title-line-height: 45px;
10
+ --bui-item-selector-btn-close-size: 45px;
11
+ --bui-item-selector-btn-close-font-size: 20px;
12
+ --bui-item-selector-container-with-title-height: calc(100% - var(--bui-item-selector-title-height));
13
+ --bui-item-selector-item-container-min-height: 500px;
14
+ --bui-item-selector-select-item-buttons-padding: 7.5px 0 0 3px;
15
+ --bui-item-selector-select-item-title-line-height: 15px;
16
+ --bui-item-selector-list-item-height: 45px;
17
+ --bui-item-selector-item-index-has-title-top: calc(50% + var(--bui-item-selector-title-height) / 2);
18
+ --bui-item-selector-index-item-height: 20px;
19
+ }
20
+ .bui-item-selector {
21
+ font-family: var(--bui-font-family);
22
+ height: 100%;
23
+ position: relative;
24
+ }
25
+ .bui-item-selector-title {
26
+ width: 100%;
27
+ height: var(--bui-item-selector-title-height);
28
+ color: var(--bui-color-fg-default);
29
+ font-size: var(--bui-title-size-3);
30
+ line-height: var(--bui-item-selector-title-line-height);
31
+ text-align: center;
32
+ position: sticky;
33
+ top: 0;
34
+ z-index: 1004;
35
+ border-bottom: solid 1px var(--bui-color-border-default);
36
+ background-color: var(--bui-color-bg-view);
37
+ }
38
+ .bui-item-selector-btn-close {
39
+ position: absolute;
40
+ top: 0;
41
+ right: 0;
42
+ width: var(--bui-item-selector-btn-close-size);
43
+ height: var(--bui-item-selector-btn-close-size);
44
+ color: var(--bui-color-fg-muted);
45
+ text-align: center;
46
+ font-size: var(--bui-item-selector-btn-close-font-size);
47
+ }
48
+ .bui-item-selector-scroll-view-container {
49
+ height: 100%;
50
+ }
51
+ .bui-item-selector-scroll-view-container.container-has-title {
52
+ height: var(--bui-item-selector-container-with-title-height);
53
+ }
54
+ .bui-item-selector-all-item {
55
+ min-height: var(--bui-item-selector-item-container-min-height);
56
+ font-size: var(--bui-text-size-2);
57
+ width: 100%;
58
+ background: var(--bui-color-bg-view);
59
+ align-self: flex-start;
60
+ }
61
+ .bui-item-selector-all-item .select-item-buttons {
62
+ display: flex;
63
+ flex-flow: wrap;
64
+ padding: var(--bui-item-selector-select-item-buttons-padding);
65
+ }
66
+ .bui-item-selector-all-item .select-item-title {
67
+ font-size: var(--bui-title-size-4);
68
+ line-height: var(--bui-item-selector-select-item-title-line-height);
69
+ font-weight: var(--bui-font-weight-bold);
70
+ padding-left: var(--bui-spacing-lg);
71
+ padding-top: var(--bui-spacing-md);
72
+ }
73
+ .bui-item-selector-list {
74
+ padding-left: var(--bui-spacing-lg);
75
+ list-style-type: none;
76
+ }
77
+ .bui-item-selector-list-item {
78
+ height: var(--bui-item-selector-list-item-height);
79
+ font-size: var(--bui-title-size-4);
80
+ display: flex;
81
+ align-items: center;
82
+ }
83
+ .bui-item-selector-list-item:not(:last-child) {
84
+ border-bottom: 0.5px solid var(--bui-color-border-default);
85
+ }
86
+ .bui-item-selector-index-container {
87
+ z-index: 1001;
88
+ position: absolute;
89
+ white-space: nowrap;
90
+ right: 0;
91
+ top: 50%;
92
+ width: 40px;
93
+ will-change: transform;
94
+ transform: translate(0, -50%);
95
+ transition: opacity 0.2s ease-out, transform 0.2s ease-out;
96
+ }
97
+ .bui-item-selector-index-container.left-in {
98
+ opacity: 1;
99
+ transform: translate(0, -50%);
100
+ }
101
+ .bui-item-selector-index-container.item-index-has-title {
102
+ top: var(--bui-item-selector-item-index-has-title-top);
103
+ }
104
+ .bui-item-selector-index-container ul {
105
+ margin: 0;
106
+ padding: 0;
107
+ float: left;
108
+ width: 100%;
109
+ touch-action: none;
110
+ }
111
+ .bui-item-selector-index-container li {
112
+ list-style: none;
113
+ height: var(--bui-item-selector-index-item-height);
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
+ }
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { ItemSelectorProps } from './ItemSelector.types';
3
+ declare const ItemSelector: React.ForwardRefExoticComponent<Omit<ItemSelectorProps<"div", {}>, "ref"> & React.RefAttributes<HTMLDivElement>>;
4
+ export default ItemSelector;
@@ -0,0 +1,57 @@
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, useState } from "react";
21
+ import ItemSelectorCore from "./ItemSelectorCore";
22
+ const ItemSelector = /* @__PURE__ */ React.forwardRef(
23
+ (props, ref) => {
24
+ const { items } = props;
25
+ const [height, setHeight] = useState("");
26
+ const touchHandler = (e, scrollToCode) => {
27
+ var _a;
28
+ const t = document.elementFromPoint(
29
+ e.changedTouches[0].clientX,
30
+ e.changedTouches[0].clientY
31
+ );
32
+ const code = (_a = t == null ? void 0 : t.dataset) == null ? void 0 : _a.code;
33
+ scrollToCode(code);
34
+ };
35
+ useEffect(() => {
36
+ var _a;
37
+ if (!(items == null ? void 0 : items.length) || height)
38
+ return;
39
+ const screenHeight = window.innerHeight || document.documentElement.clientHeight;
40
+ const domHeight = (_a = document.querySelector(".bui-item-selector-scroll-view-container")) == null ? void 0 : _a.getBoundingClientRect().height;
41
+ setHeight(`${domHeight / screenHeight * 100}vh`);
42
+ }, [items]);
43
+ return /* @__PURE__ */ React.createElement(
44
+ ItemSelectorCore,
45
+ __spreadProps(__spreadValues({}, props), {
46
+ ref,
47
+ touchHandler,
48
+ height
49
+ })
50
+ );
51
+ }
52
+ );
53
+ ItemSelector.displayName = "BuiItemSelector";
54
+ var ItemSelector_default = ItemSelector;
55
+ export {
56
+ ItemSelector_default as default
57
+ };
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { ItemSelectorProps } from './ItemSelector.types';
3
+ import './miniapp.less';
4
+ declare const ItemSelector: React.ForwardRefExoticComponent<Omit<ItemSelectorProps<"div", {}>, "ref"> & React.RefAttributes<HTMLDivElement>>;
5
+ export default ItemSelector;
@@ -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;