@baishuyun/ui-mobile 0.15.1 → 0.15.2

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.
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DSN6E54e.js";
1
+ import "../vendors/version-C9PBAUeQ.js";
2
2
  import "../ConfigProvider/useLocale-DiKogqPs.js";
3
3
  import "../Icon/Icon-C-WocsyI.js";
4
4
  import { n as e, t } from "./AMap-B-A2jg1r.js";
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DSN6E54e.js";
1
+ import "../vendors/version-C9PBAUeQ.js";
2
2
  import "../Overlay/Overlay-DFiZYsBs.js";
3
3
  import "../ConfigProvider/useLocale-DiKogqPs.js";
4
4
  import "../Popup/Popup-Cg3t422z.js";
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DSN6E54e.js";
1
+ import "../vendors/version-C9PBAUeQ.js";
2
2
  import "../ConfigProvider/useLocale-DiKogqPs.js";
3
3
  import "./timeUtils-t4A3-Hr6.js";
4
4
  import { t as e } from "./Calendar-CL7ZfXW1.js";
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DSN6E54e.js";
1
+ import "../vendors/version-C9PBAUeQ.js";
2
2
  import "../Overlay/Overlay-DFiZYsBs.js";
3
3
  import { r as e, t } from "./useLocale-DiKogqPs.js";
4
4
  import { t as n } from "./ConfigProvider-CNWefxiV.js";
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DSN6E54e.js";
1
+ import "../vendors/version-C9PBAUeQ.js";
2
2
  import "../Overlay/Overlay-DFiZYsBs.js";
3
3
  import "../ConfigProvider/useLocale-DiKogqPs.js";
4
4
  import "../Popup/Popup-Cg3t422z.js";
@@ -1,3 +1,3 @@
1
- import "../vendors/version-DSN6E54e.js";
1
+ import "../vendors/version-C9PBAUeQ.js";
2
2
  import { t as e } from "./FieldCard-D8z0UA88.js";
3
3
  export { e as FieldCard, e as default };
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DSN6E54e.js";
1
+ import "../vendors/version-C9PBAUeQ.js";
2
2
  import "../Overlay/Overlay-DFiZYsBs.js";
3
3
  import "../ConfigProvider/useLocale-DiKogqPs.js";
4
4
  import "../Popup/Popup-Cg3t422z.js";
@@ -1,3 +1,3 @@
1
- import "../vendors/version-DSN6E54e.js";
1
+ import "../vendors/version-C9PBAUeQ.js";
2
2
  import { t as e } from "./Icon-C-WocsyI.js";
3
3
  export { e as default };
@@ -0,0 +1,247 @@
1
+ import { t as e } from "../Icon/Icon-C-WocsyI.js";
2
+ import { t } from "../FieldCard/FieldCard-D8z0UA88.js";
3
+ import n, { useCallback as r, useEffect as i, useLayoutEffect as a, useMemo as o, useRef as s, useState as c } from "react";
4
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
5
+ import { useVirtualizer as d } from "@tanstack/react-virtual";
6
+ //#region src/components/Kanban/constants.ts
7
+ var f = {
8
+ small: 180,
9
+ middle: 240,
10
+ large: 320
11
+ };
12
+ //#endregion
13
+ //#region src/components/Kanban/hooks/useColumnWidth.ts
14
+ function p(e) {
15
+ let { columnSize: t = "middle", coverLayout: n, hasSideCover: r = !1 } = e ?? {};
16
+ return o(() => (f[t] ?? f.middle) + (r || n?.position === "left" || n?.position === "right" ? 80 : 0) + 20, [
17
+ t,
18
+ n?.position,
19
+ r
20
+ ]);
21
+ }
22
+ //#endregion
23
+ //#region src/components/Kanban/addButtonPlacement.ts
24
+ var m = 34, h = 40;
25
+ function g({ contentHeight: e, viewportHeight: t, hasPaging: n, hasFooter: r }) {
26
+ let i = n ? h : 0, a = e + (n ? i : 10), o = r && t > 0 && a + m > t;
27
+ return {
28
+ sticky: o,
29
+ buttonTop: a,
30
+ listHeight: o || !r ? e + i : a + m
31
+ };
32
+ }
33
+ //#endregion
34
+ //#region src/components/Kanban/Kanban.module.scss
35
+ var _ = {
36
+ "bsy-mobile-kanban": "_bsy-mobile-kanban_ry73g_2",
37
+ "bsy-mobile-kanban__board": "_bsy-mobile-kanban__board_ry73g_13",
38
+ "bsy-mobile-kanban__board--zoomed": "_bsy-mobile-kanban__board--zoomed_ry73g_28",
39
+ "bsy-mobile-kanban__list": "_bsy-mobile-kanban__list_ry73g_35",
40
+ "bsy-mobile-kanban__column": "_bsy-mobile-kanban__column_ry73g_42",
41
+ "bsy-mobile-kanban__column-header": "_bsy-mobile-kanban__column-header_ry73g_51",
42
+ "bsy-mobile-kanban__column-title": "_bsy-mobile-kanban__column-title_ry73g_60",
43
+ "bsy-mobile-kanban__column-badge": "_bsy-mobile-kanban__column-badge_ry73g_70",
44
+ "bsy-mobile-kanban__column-body": "_bsy-mobile-kanban__column-body_ry73g_76",
45
+ "bsy-mobile-kanban__virtual-container": "_bsy-mobile-kanban__virtual-container_ry73g_94",
46
+ "bsy-mobile-kanban__card-wrapper": "_bsy-mobile-kanban__card-wrapper_ry73g_99",
47
+ "bsy-mobile-kanban__column-footer": "_bsy-mobile-kanban__column-footer_ry73g_109",
48
+ "bsy-mobile-kanban__add-anchor": "_bsy-mobile-kanban__add-anchor_ry73g_114",
49
+ "bsy-mobile-kanban__paging": "_bsy-mobile-kanban__paging_ry73g_119",
50
+ "bsy-mobile-kanban__paging--no-more": "_bsy-mobile-kanban__paging--no-more_ry73g_126",
51
+ "bsy-mobile-kanban__add-btn": "_bsy-mobile-kanban__add-btn_ry73g_129",
52
+ "bsy-mobile-kanban__empty": "_bsy-mobile-kanban__empty_ry73g_148"
53
+ };
54
+ //#endregion
55
+ //#region src/components/Kanban/KanbanColumn.tsx
56
+ function v({ column: n, columnWidth: o, coverLayout: f, fieldLayout: p, renderColumnTitle: m, onAdd: h, onClick: v, onReachBottom: y }) {
57
+ let b = s(null), [x, S] = c(0), C = n.id, w = n.items || [], T = n.total, E = s(w);
58
+ E.current = w;
59
+ let D = n.paging, O = D?.loading === !0, k = D?.noMore === !0, A = s(!1);
60
+ i(() => {
61
+ O || (A.current = !1);
62
+ }, [O]);
63
+ let [j, M] = c(!1);
64
+ i(() => {
65
+ w.length === 0 && M(!1);
66
+ }, [w.length]);
67
+ let N = r((e) => {
68
+ let t = e.currentTarget, n = t.scrollHeight - t.scrollTop - t.clientHeight, r = t.scrollHeight > t.clientHeight + 10, i = n <= 50;
69
+ r && i && M(!0), i && !O && !k && !A.current && y && (A.current = !0, y(C));
70
+ }, [
71
+ C,
72
+ k,
73
+ O,
74
+ y
75
+ ]), P = d({
76
+ count: w.length,
77
+ getScrollElement: () => b.current,
78
+ estimateSize: () => 160,
79
+ overscan: 6,
80
+ gap: 10,
81
+ getItemKey: (e) => E.current[e]?.id ?? String(e)
82
+ }), F = P.getVirtualItems();
83
+ a(() => {
84
+ let e = b.current;
85
+ if (!e) return;
86
+ let t = () => S(e.clientHeight);
87
+ if (t(), typeof ResizeObserver > "u") return;
88
+ let n = new ResizeObserver(t);
89
+ return n.observe(e), () => n.disconnect();
90
+ }, []);
91
+ let I = m ? m(n) : n.title, L = /* @__PURE__ */ u("div", {
92
+ className: _["bsy-mobile-kanban__column-header"],
93
+ children: [/* @__PURE__ */ l("div", {
94
+ className: _["bsy-mobile-kanban__column-title"],
95
+ children: I
96
+ }), typeof T == "number" && /* @__PURE__ */ l("span", {
97
+ className: _["bsy-mobile-kanban__column-badge"],
98
+ children: T
99
+ })]
100
+ }), R = n.addable ? /* @__PURE__ */ l("div", {
101
+ className: _["bsy-mobile-kanban__column-footer"],
102
+ children: /* @__PURE__ */ l("button", {
103
+ type: "button",
104
+ className: _["bsy-mobile-kanban__add-btn"],
105
+ onClick: () => h?.(C),
106
+ "aria-label": "快速添加卡片",
107
+ "data-testid": `kanban-add-${C}`,
108
+ children: /* @__PURE__ */ l(e, {
109
+ name: "add",
110
+ size: 16,
111
+ color: "#000"
112
+ })
113
+ })
114
+ }) : null, z = w.length > 0 ? P.getTotalSize() : 0, B = O || k && j && w.length > 0, V = g({
115
+ contentHeight: z,
116
+ viewportHeight: x,
117
+ hasPaging: B,
118
+ hasFooter: !!R
119
+ }), H = B ? /* @__PURE__ */ l("div", {
120
+ className: O ? _["bsy-mobile-kanban__paging"] : `${_["bsy-mobile-kanban__paging"]} ${_["bsy-mobile-kanban__paging--no-more"]}`,
121
+ style: {
122
+ position: "absolute",
123
+ top: z,
124
+ left: 0,
125
+ right: 0
126
+ },
127
+ children: O ? "正在加载更多..." : "- 没有更多数据了 -"
128
+ }) : null;
129
+ return /* @__PURE__ */ u("div", {
130
+ className: _["bsy-mobile-kanban__column"],
131
+ style: {
132
+ width: `${o}px`,
133
+ minWidth: `${o}px`
134
+ },
135
+ "data-testid": `kanban-column-${C}`,
136
+ children: [
137
+ L,
138
+ /* @__PURE__ */ l("div", {
139
+ ref: b,
140
+ className: _["bsy-mobile-kanban__column-body"],
141
+ onScroll: N,
142
+ "data-testid": `kanban-column-body-${C}`,
143
+ children: w.length > 0 || R && !V.sticky ? /* @__PURE__ */ u("div", {
144
+ className: _["bsy-mobile-kanban__virtual-container"],
145
+ style: { height: `${V.listHeight}px` },
146
+ children: [
147
+ F.map((e) => {
148
+ let n = w[e.index];
149
+ return n ? /* @__PURE__ */ l("div", {
150
+ ref: P.measureElement,
151
+ "data-index": e.index,
152
+ className: _["bsy-mobile-kanban__card-wrapper"],
153
+ style: {
154
+ position: "absolute",
155
+ top: 0,
156
+ left: 0,
157
+ width: "100%",
158
+ transform: `translateY(${e.start}px)`
159
+ },
160
+ "data-testid": `kanban-card-${n.id}`,
161
+ onClick: () => v?.(n, C),
162
+ children: /* @__PURE__ */ u(t, {
163
+ title: n.title,
164
+ cover: n.cover,
165
+ coverPlaceholder: f?.position === "left",
166
+ coverLayout: f,
167
+ layout: p,
168
+ children: [n.fields?.map((e, n) => /* @__PURE__ */ l(t.Meta, {
169
+ label: e.label,
170
+ icon: e.icon,
171
+ value: e.value
172
+ }, e.key ?? n)), n.footer ? /* @__PURE__ */ l(t.Footer, { children: n.footer }) : null]
173
+ })
174
+ }, e.key) : null;
175
+ }),
176
+ H,
177
+ R && !V.sticky ? /* @__PURE__ */ l("div", {
178
+ className: _["bsy-mobile-kanban__add-anchor"],
179
+ style: { top: V.buttonTop },
180
+ children: R
181
+ }) : null
182
+ ]
183
+ }) : null
184
+ }),
185
+ V.sticky ? R : null
186
+ ]
187
+ });
188
+ }
189
+ var y = n.memo(v);
190
+ //#endregion
191
+ //#region src/components/Kanban/Kanban.tsx
192
+ function b({ columns: e, columnSize: t = "middle", coverLayout: n, hasSideCover: r = !1, fieldLayout: a = "vertical", zoomed: o = !1, renderColumnTitle: c, onAdd: u, onClick: d, onReachBottom: f, empty: m, style: h }) {
193
+ let g = s(null), v = p({
194
+ columnSize: t,
195
+ coverLayout: n,
196
+ hasSideCover: r
197
+ });
198
+ i(() => {
199
+ let e = g.current;
200
+ if (!e) return;
201
+ let t = e.scrollWidth || 1, n = e.scrollHeight || 1, r = (e.scrollLeft + e.clientWidth / 2) / t, i = (e.scrollTop + e.clientHeight / 2) / n;
202
+ requestAnimationFrame(() => {
203
+ e.scrollLeft = r * e.scrollWidth - e.clientWidth / 2, e.scrollTop = i * e.scrollHeight - e.clientHeight / 2;
204
+ });
205
+ }, [o]);
206
+ let b = !e || e.length === 0, x = [_["bsy-mobile-kanban__board"], o ? _["bsy-mobile-kanban__board--zoomed"] : ""].filter(Boolean).join(" ");
207
+ return /* @__PURE__ */ l("div", {
208
+ className: _["bsy-mobile-kanban"],
209
+ style: h,
210
+ "data-testid": "kanban-root",
211
+ children: /* @__PURE__ */ l("div", {
212
+ ref: g,
213
+ className: x,
214
+ "data-testid": "kanban-board",
215
+ children: b && m ? /* @__PURE__ */ l("div", {
216
+ className: _["bsy-mobile-kanban__empty"],
217
+ children: m
218
+ }) : /* @__PURE__ */ l("div", {
219
+ className: _["bsy-mobile-kanban__list"],
220
+ "data-testid": "kanban-list",
221
+ children: e?.map((e) => /* @__PURE__ */ l(y, {
222
+ column: e,
223
+ columnWidth: v,
224
+ coverLayout: n,
225
+ fieldLayout: a,
226
+ renderColumnTitle: c,
227
+ onAdd: u,
228
+ onClick: d,
229
+ onReachBottom: f
230
+ }, e.id))
231
+ })
232
+ })
233
+ });
234
+ }
235
+ //#endregion
236
+ //#region src/components/Kanban/utils/columnPage.ts
237
+ function x(e, t, n) {
238
+ if (t.length === 0) return [...e];
239
+ let r = n ?? ((e) => e?.id), i = new Set(e.map(r).filter(Boolean)), a = [];
240
+ for (let e of t) {
241
+ let t = r(e);
242
+ t && i.has(t) || (t && i.add(t), a.push(e));
243
+ }
244
+ return e.concat(a);
245
+ }
246
+ //#endregion
247
+ export { b as n, x as t };
@@ -1,5 +1,5 @@
1
- import "../vendors/version-DSN6E54e.js";
1
+ import "../vendors/version-C9PBAUeQ.js";
2
2
  import "../Icon/Icon-C-WocsyI.js";
3
3
  import "../FieldCard/FieldCard-D8z0UA88.js";
4
- import { a as e, i as t, n, r, t as i } from "./Kanban-CrSGrZ-g.js";
5
- export { n as Kanban, n as default, r as KanbanColumn, i as appendKanbanCards, e as useColumnWidth, t as useKanbanZoom };
4
+ import { n as e, t } from "./Kanban-CaeQxWJF.js";
5
+ export { e as Kanban, e as default, t as appendKanbanCards };
@@ -1,3 +1,3 @@
1
- import "../vendors/version-DSN6E54e.js";
1
+ import "../vendors/version-C9PBAUeQ.js";
2
2
  import { a as e, i as t, n, o as r, r as i, t as a } from "./Overlay-DFiZYsBs.js";
3
3
  export { a as OVERLAY_Z_BASE, n as OVERLAY_Z_STEP, i as OverlayProvider, t as getNextImperativeOverlayZIndex, e as imperativeOverlayStyle, r as useOverlayZIndex };
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DSN6E54e.js";
1
+ import "../vendors/version-C9PBAUeQ.js";
2
2
  import "../Overlay/Overlay-DFiZYsBs.js";
3
3
  import "../ConfigProvider/useLocale-DiKogqPs.js";
4
4
  import { t as e } from "./Popup-Cg3t422z.js";
@@ -1,3 +1,3 @@
1
- import "../vendors/version-DSN6E54e.js";
1
+ import "../vendors/version-C9PBAUeQ.js";
2
2
  import { t as e } from "./Segmented-BkRBZFEg.js";
3
3
  export { e as default };
@@ -1,6 +1,3 @@
1
- import { default as React } from 'react';
2
- import { KanbanProps, KanbanRef } from './interface';
3
- export declare const Kanban: <TMeta = unknown>(props: KanbanProps<TMeta> & {
4
- ref?: React.Ref<KanbanRef>;
5
- }) => React.ReactElement;
1
+ import { KanbanProps } from './interface';
2
+ declare function Kanban<TMeta = unknown>({ columns, columnSize, coverLayout, hasSideCover, fieldLayout, zoomed, renderColumnTitle, onAdd, onClick, onReachBottom, empty, style, }: KanbanProps<TMeta>): import("react").JSX.Element;
6
3
  export default Kanban;
@@ -6,12 +6,10 @@ export interface KanbanColumnProps<TMeta> {
6
6
  coverLayout?: KanbanCoverLayout;
7
7
  fieldLayout: KanbanFieldLayout;
8
8
  renderColumnTitle?: (column: KanbanColumnType<TMeta>) => React.ReactNode;
9
- renderColumnHeader?: (column: KanbanColumnType<TMeta>) => React.ReactNode;
10
- renderColumnFooter?: (column: KanbanColumnType<TMeta>) => React.ReactNode;
11
9
  onAdd?: (columnId: string) => void;
12
10
  onClick?: (card: KanbanCard<TMeta>, columnId: string) => void;
13
11
  onReachBottom?: (columnId: string) => void;
14
12
  }
15
- export declare function KanbanColumn<TMeta>({ column, columnWidth, coverLayout, fieldLayout, renderColumnTitle, renderColumnHeader, renderColumnFooter, onAdd, onClick, onReachBottom, }: KanbanColumnProps<TMeta>): React.JSX.Element;
13
+ export declare function KanbanColumn<TMeta>({ column, columnWidth, coverLayout, fieldLayout, renderColumnTitle, onAdd, onClick, onReachBottom, }: KanbanColumnProps<TMeta>): React.JSX.Element;
16
14
  declare const _default: typeof KanbanColumn;
17
15
  export default _default;
@@ -1,15 +1,7 @@
1
1
  import { KanbanColumnSize, KanbanCoverLayout } from '../interface';
2
2
  export interface UseColumnWidthOptions {
3
3
  columnSize?: KanbanColumnSize;
4
- columnWidth?: number;
5
4
  coverLayout?: KanbanCoverLayout;
6
5
  hasSideCover?: boolean;
7
6
  }
8
- /**
9
- * 计算移动端看板单列宽度的 Hook。
10
- * 命名与规则完全对齐 PC 端 (@baishuyun/ui-base/Kanban):
11
- * - columnWidth(自定义数值)优先级最高,且传入 columnWidth 后不再加封面侧栏宽度;
12
- * - 缺省 columnWidth 时使用 columnSize(默认 'middle');
13
- * - 封面处于左右侧(coverLayout 为 left/right 或 hasSideCover=true)时,在 columnSize 档位基础上增加 80px 宽度。
14
- */
15
7
  export declare function useColumnWidth(options?: UseColumnWidthOptions): number;
@@ -1,7 +1,4 @@
1
1
  export { default } from './Kanban';
2
2
  export { default as Kanban } from './Kanban';
3
- export { default as KanbanColumn } from './KanbanColumn';
4
- export type { KanbanCard, KanbanCardField, KanbanColumn as KanbanColumnType, KanbanColumnPaging, KanbanColumnSize, KanbanCoverLayout, KanbanFieldLayout, KanbanProps, KanbanRef, } from './interface';
3
+ export type { KanbanCard, KanbanCardField, KanbanColumn as KanbanColumnType, KanbanColumnPaging, KanbanColumnSize, KanbanCoverLayout, KanbanFieldLayout, KanbanProps, } from './interface';
5
4
  export { appendKanbanCards } from './utils/columnPage';
6
- export { useKanbanZoom } from './hooks/useKanbanZoom';
7
- export { useColumnWidth } from './hooks/useColumnWidth';
@@ -36,32 +36,14 @@ export interface KanbanColumn<TMeta = unknown> {
36
36
  /** 允许挂载业务透传的自定义元数据 */
37
37
  meta?: unknown;
38
38
  }
39
- export interface KanbanRef {
40
- /** 当前是否处于 0.6x 鸟瞰缩放模式 */
41
- isZoomedOut: boolean;
42
- /** 切换缩放状态 */
43
- toggleZoom: () => void;
44
- /** 设置缩放状态 */
45
- setZoom: (zoomed: boolean) => void;
46
- }
47
39
  export interface KanbanProps<TMeta = unknown> {
48
40
  /** 各列数据与配置 */
49
41
  columns: KanbanColumn<TMeta>[];
50
- /**
51
- * 三档栏宽。未传 `columnWidth` 时使用,缺省 'middle'
52
- */
42
+ /** 三档栏宽,缺省 middle。左右封面时再加 80 */
53
43
  columnSize?: KanbanColumnSize;
54
- /**
55
- * 自定义栏宽像素数值。优先于 columnSize,且不再加封面侧栏宽度
56
- */
57
- columnWidth?: number;
58
- /**
59
- * 整板封面布局。position 为 left 或 right 且未传 columnWidth 时,栏宽加 80
60
- */
44
+ /** 整板封面布局。position 为 left 或 right 时栏宽加 80 */
61
45
  coverLayout?: KanbanCoverLayout;
62
- /**
63
- * 是否有侧边封面。为 true 且未传 columnWidth 时,栏宽加 80
64
- */
46
+ /** 为 true 时栏宽加 80 */
65
47
  hasSideCover?: boolean;
66
48
  /** 字段行排列。缺省 vertical */
67
49
  fieldLayout?: KanbanFieldLayout;
@@ -69,14 +51,6 @@ export interface KanbanProps<TMeta = unknown> {
69
51
  * 自定义列标题内容(保留外层标准 Header 布局与数量 Badge)
70
52
  */
71
53
  renderColumnTitle?: (column: KanbanColumn<TMeta>) => React.ReactNode;
72
- /**
73
- * 完全接管列头整块区域渲染(若提供则完全覆盖默认 Header 与 Badge)
74
- */
75
- renderColumnHeader?: (column: KanbanColumn<TMeta>) => React.ReactNode;
76
- /**
77
- * 自定义添加按钮区域。卡片未撑满列时跟在最后一张后面,撑满后固定在列视口底部。
78
- */
79
- renderColumnFooter?: (column: KanbanColumn<TMeta>) => React.ReactNode;
80
54
  /**
81
55
  * 添加按钮点击。位置规则与默认按钮相同。
82
56
  */
@@ -93,15 +67,7 @@ export interface KanbanProps<TMeta = unknown> {
93
67
  * 空状态呈现节点(当 columns 列表为空时渲染)
94
68
  */
95
69
  empty?: React.ReactNode;
96
- /**
97
- * 是否处于 0.6x 鸟瞰缩放模式(受控属性)。
98
- * 看板不内置悬浮缩放按钮,缩放按钮由宿主页面实现。
99
- */
70
+ /** 为 true 时整板缩放到 0.6 倍 */
100
71
  zoomed?: boolean;
101
- /**
102
- * 缩放状态变更回调
103
- */
104
- onZoomChange?: (zoomed: boolean) => void;
105
- className?: string;
106
72
  style?: React.CSSProperties;
107
73
  }
@@ -21,5 +21,5 @@ export { default as Editor, EditorHtmlPreview } from './Editor';
21
21
  export type { EditorAi, EditorAiMode, EditorAiPreset, EditorAiStatus, EditorProps, EditorToolbarConfigButton, EditorToolbarGroup, EditorToolbarProps, EditorUpload, EditorUploadContext, EditorUploadResult, } from './Editor';
22
22
  export { default as FieldCard } from './FieldCard';
23
23
  export type { FieldCardCoverLayout, FieldCardLayout, FieldCardProps, FieldCardTheme, } from './FieldCard';
24
- export { default as Kanban, KanbanColumn, appendKanbanCards, useKanbanZoom, useColumnWidth, } from './Kanban';
25
- export type { KanbanCard, KanbanCardField, KanbanColumnType, KanbanColumnPaging, KanbanColumnSize, KanbanCoverLayout, KanbanFieldLayout, KanbanProps, KanbanRef, } from './Kanban';
24
+ export { default as Kanban, appendKanbanCards } from './Kanban';
25
+ export type { KanbanCard, KanbanCardField, KanbanColumnType, KanbanColumnPaging, KanbanColumnSize, KanbanCoverLayout, KanbanFieldLayout, KanbanProps, } from './Kanban';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./vendors/version-DSN6E54e.js";
1
+ import "./vendors/version-C9PBAUeQ.js";
2
2
  import { a as e, i as t, n, o as r, r as i, t as a } from "./Overlay/Overlay-DFiZYsBs.js";
3
3
  import { t as o } from "./ConfigProvider/useLocale-DiKogqPs.js";
4
4
  import { t as s } from "./Popup/Popup-Cg3t422z.js";
@@ -12,5 +12,5 @@ import { n as m, t as h } from "./AMap/AMap-B-A2jg1r.js";
12
12
  import { t as g } from "./ConfigProvider/ConfigProvider-CNWefxiV.js";
13
13
  import { n as _, t as v } from "./Editor/Editor-zj5lpqGC.js";
14
14
  import { t as y } from "./FieldCard/FieldCard-D8z0UA88.js";
15
- import { a as b, i as x, n as S, r as C, t as w } from "./Kanban/Kanban-CrSGrZ-g.js";
16
- export { u as ALL_ZOOM_LEVELS, h as AMap, l as ActionSheet, f as Calendar, g as ConfigProvider, v as Editor, _ as EditorHtmlPreview, y as FieldCard, d as Gantt, c as Icon, S as Kanban, C as KanbanColumn, a as OVERLAY_Z_BASE, n as OVERLAY_Z_STEP, i as OverlayProvider, s as Popup, p as Segmented, w as appendKanbanCards, t as getNextImperativeOverlayZIndex, e as imperativeOverlayStyle, m as useAMap, b as useColumnWidth, x as useKanbanZoom, o as useLocale, r as useOverlayZIndex };
15
+ import { n as b, t as x } from "./Kanban/Kanban-CaeQxWJF.js";
16
+ export { u as ALL_ZOOM_LEVELS, h as AMap, l as ActionSheet, f as Calendar, g as ConfigProvider, v as Editor, _ as EditorHtmlPreview, y as FieldCard, d as Gantt, c as Icon, b as Kanban, a as OVERLAY_Z_BASE, n as OVERLAY_Z_STEP, i as OverlayProvider, s as Popup, p as Segmented, x as appendKanbanCards, t as getNextImperativeOverlayZIndex, e as imperativeOverlayStyle, m as useAMap, o as useLocale, r as useOverlayZIndex };
@@ -1,6 +1,6 @@
1
1
  //#region src/version.ts
2
2
  if (typeof window < "u") {
3
3
  let e = window.__BSY_UI__ ??= {};
4
- e["@baishuyun/ui-mobile"] = "0.15.1";
4
+ e["@baishuyun/ui-mobile"] = "0.15.2";
5
5
  }
6
6
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baishuyun/ui-mobile",
3
- "version": "0.15.1",
3
+ "version": "0.15.2",
4
4
  "type": "module",
5
5
  "description": "百数云 H5 / Mobile UI 组件库",
6
6
  "author": "bsy-fe team",
@@ -1,281 +0,0 @@
1
- import { t as e } from "../Icon/Icon-C-WocsyI.js";
2
- import { t } from "../FieldCard/FieldCard-D8z0UA88.js";
3
- import n, { forwardRef as r, useCallback as i, useEffect as a, useImperativeHandle as o, useLayoutEffect as s, useMemo as c, useRef as l, useState as u } from "react";
4
- import { jsx as d, jsxs as f } from "react/jsx-runtime";
5
- import { useVirtualizer as p } from "@tanstack/react-virtual";
6
- //#region src/components/Kanban/constants.ts
7
- var m = {
8
- small: 180,
9
- middle: 240,
10
- large: 320
11
- };
12
- //#endregion
13
- //#region src/components/Kanban/hooks/useColumnWidth.ts
14
- function h(e) {
15
- let { columnSize: t = "middle", columnWidth: n, coverLayout: r, hasSideCover: i = !1 } = e ?? {};
16
- return c(() => typeof n == "number" && n > 0 ? n : (m[t] ?? m.middle) + (i || r?.position === "left" || r?.position === "right" ? 80 : 0) + 20, [
17
- t,
18
- n,
19
- r?.position,
20
- i
21
- ]);
22
- }
23
- //#endregion
24
- //#region src/components/Kanban/hooks/useKanbanZoom.ts
25
- function g(e, t) {
26
- let { zoomed: n, onZoomChange: r } = t ?? {}, o = n !== void 0, [s, c] = u(!1), l = o ? !!n : s;
27
- return a(() => {
28
- if (!e.current) return;
29
- let t = e.current, n = t.scrollWidth || 1, r = t.scrollHeight || 1, i = (t.scrollLeft + t.clientWidth / 2) / n, a = (t.scrollTop + t.clientHeight / 2) / r;
30
- requestAnimationFrame(() => {
31
- t.scrollLeft = i * t.scrollWidth - t.clientWidth / 2, t.scrollTop = a * t.scrollHeight - t.clientHeight / 2;
32
- });
33
- }, [l, e]), {
34
- isZoomedOut: l,
35
- toggleZoom: i(() => {
36
- let e = !l;
37
- o || c(e), r?.(e);
38
- }, [
39
- o,
40
- l,
41
- r
42
- ]),
43
- setZoom: i((e) => {
44
- o || c(e), r?.(e);
45
- }, [o, r])
46
- };
47
- }
48
- //#endregion
49
- //#region src/components/Kanban/addButtonPlacement.ts
50
- var _ = 34, v = 40;
51
- function y({ contentHeight: e, viewportHeight: t, hasPaging: n, hasFooter: r }) {
52
- let i = n ? v : 0, a = e + (n ? i : 10), o = r && t > 0 && a + _ > t;
53
- return {
54
- sticky: o,
55
- buttonTop: a,
56
- listHeight: o || !r ? e + i : a + _
57
- };
58
- }
59
- //#endregion
60
- //#region src/components/Kanban/Kanban.module.scss
61
- var b = {
62
- "bsy-mobile-kanban": "_bsy-mobile-kanban_ry73g_2",
63
- "bsy-mobile-kanban__board": "_bsy-mobile-kanban__board_ry73g_13",
64
- "bsy-mobile-kanban__board--zoomed": "_bsy-mobile-kanban__board--zoomed_ry73g_28",
65
- "bsy-mobile-kanban__list": "_bsy-mobile-kanban__list_ry73g_35",
66
- "bsy-mobile-kanban__column": "_bsy-mobile-kanban__column_ry73g_42",
67
- "bsy-mobile-kanban__column-header": "_bsy-mobile-kanban__column-header_ry73g_51",
68
- "bsy-mobile-kanban__column-title": "_bsy-mobile-kanban__column-title_ry73g_60",
69
- "bsy-mobile-kanban__column-badge": "_bsy-mobile-kanban__column-badge_ry73g_70",
70
- "bsy-mobile-kanban__column-body": "_bsy-mobile-kanban__column-body_ry73g_76",
71
- "bsy-mobile-kanban__virtual-container": "_bsy-mobile-kanban__virtual-container_ry73g_94",
72
- "bsy-mobile-kanban__card-wrapper": "_bsy-mobile-kanban__card-wrapper_ry73g_99",
73
- "bsy-mobile-kanban__column-footer": "_bsy-mobile-kanban__column-footer_ry73g_109",
74
- "bsy-mobile-kanban__add-anchor": "_bsy-mobile-kanban__add-anchor_ry73g_114",
75
- "bsy-mobile-kanban__paging": "_bsy-mobile-kanban__paging_ry73g_119",
76
- "bsy-mobile-kanban__paging--no-more": "_bsy-mobile-kanban__paging--no-more_ry73g_126",
77
- "bsy-mobile-kanban__add-btn": "_bsy-mobile-kanban__add-btn_ry73g_129",
78
- "bsy-mobile-kanban__empty": "_bsy-mobile-kanban__empty_ry73g_148"
79
- };
80
- //#endregion
81
- //#region src/components/Kanban/KanbanColumn.tsx
82
- function x({ column: n, columnWidth: r, coverLayout: o, fieldLayout: c, renderColumnTitle: m, renderColumnHeader: h, renderColumnFooter: g, onAdd: _, onClick: v, onReachBottom: x }) {
83
- let S = l(null), [C, w] = u(0), T = n.id, E = n.items || [], D = n.total, O = l(E);
84
- O.current = E;
85
- let k = n.paging, A = k?.loading === !0, j = k?.noMore === !0, M = l(!1);
86
- a(() => {
87
- A || (M.current = !1);
88
- }, [A]);
89
- let [N, P] = u(!1);
90
- a(() => {
91
- E.length === 0 && P(!1);
92
- }, [E.length]);
93
- let F = i((e) => {
94
- let t = e.currentTarget, n = t.scrollHeight - t.scrollTop - t.clientHeight, r = t.scrollHeight > t.clientHeight + 10, i = n <= 50;
95
- r && i && P(!0), i && !A && !j && !M.current && x && (M.current = !0, x(T));
96
- }, [
97
- T,
98
- j,
99
- A,
100
- x
101
- ]), I = p({
102
- count: E.length,
103
- getScrollElement: () => S.current,
104
- estimateSize: () => 160,
105
- overscan: 6,
106
- gap: 10,
107
- getItemKey: (e) => O.current[e]?.id ?? String(e)
108
- }), L = I.getVirtualItems();
109
- s(() => {
110
- let e = S.current;
111
- if (!e) return;
112
- let t = () => w(e.clientHeight);
113
- if (t(), typeof ResizeObserver > "u") return;
114
- let n = new ResizeObserver(t);
115
- return n.observe(e), () => n.disconnect();
116
- }, []);
117
- let R = m ? m(n) : n.title, z = h ? h(n) : /* @__PURE__ */ f("div", {
118
- className: b["bsy-mobile-kanban__column-header"],
119
- children: [/* @__PURE__ */ d("div", {
120
- className: b["bsy-mobile-kanban__column-title"],
121
- children: R
122
- }), typeof D == "number" && /* @__PURE__ */ d("span", {
123
- className: b["bsy-mobile-kanban__column-badge"],
124
- children: D
125
- })]
126
- }), B = g ? g(n) : n.addable ? /* @__PURE__ */ d("div", {
127
- className: b["bsy-mobile-kanban__column-footer"],
128
- children: /* @__PURE__ */ d("button", {
129
- type: "button",
130
- className: b["bsy-mobile-kanban__add-btn"],
131
- onClick: () => _?.(T),
132
- "aria-label": "快速添加卡片",
133
- "data-testid": `kanban-add-${T}`,
134
- children: /* @__PURE__ */ d(e, {
135
- name: "add",
136
- size: 16,
137
- color: "#000"
138
- })
139
- })
140
- }) : null, V = E.length > 0 ? I.getTotalSize() : 0, H = A || j && N && E.length > 0, U = y({
141
- contentHeight: V,
142
- viewportHeight: C,
143
- hasPaging: H,
144
- hasFooter: !!B
145
- }), W = H ? /* @__PURE__ */ d("div", {
146
- className: A ? b["bsy-mobile-kanban__paging"] : `${b["bsy-mobile-kanban__paging"]} ${b["bsy-mobile-kanban__paging--no-more"]}`,
147
- style: {
148
- position: "absolute",
149
- top: V,
150
- left: 0,
151
- right: 0
152
- },
153
- children: A ? "正在加载更多..." : "- 没有更多数据了 -"
154
- }) : null;
155
- return /* @__PURE__ */ f("div", {
156
- className: b["bsy-mobile-kanban__column"],
157
- style: {
158
- width: `${r}px`,
159
- minWidth: `${r}px`
160
- },
161
- "data-testid": `kanban-column-${T}`,
162
- children: [
163
- z,
164
- /* @__PURE__ */ d("div", {
165
- ref: S,
166
- className: b["bsy-mobile-kanban__column-body"],
167
- onScroll: F,
168
- "data-testid": `kanban-column-body-${T}`,
169
- children: E.length > 0 || B && !U.sticky ? /* @__PURE__ */ f("div", {
170
- className: b["bsy-mobile-kanban__virtual-container"],
171
- style: { height: `${U.listHeight}px` },
172
- children: [
173
- L.map((e) => {
174
- let n = E[e.index];
175
- return n ? /* @__PURE__ */ d("div", {
176
- ref: I.measureElement,
177
- "data-index": e.index,
178
- className: b["bsy-mobile-kanban__card-wrapper"],
179
- style: {
180
- position: "absolute",
181
- top: 0,
182
- left: 0,
183
- width: "100%",
184
- transform: `translateY(${e.start}px)`
185
- },
186
- "data-testid": `kanban-card-${n.id}`,
187
- onClick: () => v?.(n, T),
188
- children: /* @__PURE__ */ f(t, {
189
- title: n.title,
190
- cover: n.cover,
191
- coverPlaceholder: o?.position === "left",
192
- coverLayout: o,
193
- layout: c,
194
- children: [n.fields?.map((e, n) => /* @__PURE__ */ d(t.Meta, {
195
- label: e.label,
196
- icon: e.icon,
197
- value: e.value
198
- }, e.key ?? n)), n.footer ? /* @__PURE__ */ d(t.Footer, { children: n.footer }) : null]
199
- })
200
- }, e.key) : null;
201
- }),
202
- W,
203
- B && !U.sticky ? /* @__PURE__ */ d("div", {
204
- className: b["bsy-mobile-kanban__add-anchor"],
205
- style: { top: U.buttonTop },
206
- children: B
207
- }) : null
208
- ]
209
- }) : null
210
- }),
211
- U.sticky ? B : null
212
- ]
213
- });
214
- }
215
- var S = n.memo(x);
216
- //#endregion
217
- //#region src/components/Kanban/Kanban.tsx
218
- function C({ columns: e, columnSize: t = "middle", columnWidth: n, coverLayout: r, hasSideCover: i = !1, fieldLayout: a = "vertical", zoomed: s, onZoomChange: c, renderColumnTitle: u, renderColumnHeader: f, renderColumnFooter: p, onAdd: m, onClick: _, onReachBottom: v, empty: y, className: x, style: C }, w) {
219
- let T = l(null), E = h({
220
- columnSize: t,
221
- columnWidth: n,
222
- coverLayout: r,
223
- hasSideCover: i
224
- }), { isZoomedOut: D, toggleZoom: O, setZoom: k } = g(T, {
225
- zoomed: s,
226
- onZoomChange: c
227
- });
228
- o(w, () => ({
229
- isZoomedOut: D,
230
- toggleZoom: O,
231
- setZoom: k
232
- }), [
233
- D,
234
- O,
235
- k
236
- ]);
237
- let A = !e || e.length === 0, j = [b["bsy-mobile-kanban__board"], D ? b["bsy-mobile-kanban__board--zoomed"] : ""].filter(Boolean).join(" ");
238
- return /* @__PURE__ */ d("div", {
239
- className: [b["bsy-mobile-kanban"], x].filter(Boolean).join(" "),
240
- style: C,
241
- "data-testid": "kanban-root",
242
- children: /* @__PURE__ */ d("div", {
243
- ref: T,
244
- className: j,
245
- "data-testid": "kanban-board",
246
- children: A && y ? /* @__PURE__ */ d("div", {
247
- className: b["bsy-mobile-kanban__empty"],
248
- children: y
249
- }) : /* @__PURE__ */ d("div", {
250
- className: b["bsy-mobile-kanban__list"],
251
- "data-testid": "kanban-list",
252
- children: e?.map((e) => /* @__PURE__ */ d(S, {
253
- column: e,
254
- columnWidth: E,
255
- coverLayout: r,
256
- fieldLayout: a,
257
- renderColumnTitle: u,
258
- renderColumnHeader: f,
259
- renderColumnFooter: p,
260
- onAdd: m,
261
- onClick: _,
262
- onReachBottom: v
263
- }, e.id))
264
- })
265
- })
266
- });
267
- }
268
- var w = r(C);
269
- //#endregion
270
- //#region src/components/Kanban/utils/columnPage.ts
271
- function T(e, t, n) {
272
- if (t.length === 0) return [...e];
273
- let r = n ?? ((e) => e?.id), i = new Set(e.map(r).filter(Boolean)), a = [];
274
- for (let e of t) {
275
- let t = r(e);
276
- t && i.has(t) || (t && i.add(t), a.push(e));
277
- }
278
- return e.concat(a);
279
- }
280
- //#endregion
281
- export { h as a, g as i, w as n, S as r, T as t };
@@ -1,16 +0,0 @@
1
- import { RefObject } from 'react';
2
- export interface UseKanbanZoomOptions {
3
- /** 受控的缩放状态 */
4
- zoomed?: boolean;
5
- /** 缩放状态变更回调 */
6
- onZoomChange?: (zoomed: boolean) => void;
7
- }
8
- /**
9
- * 管理移动端看板视图的 0.6x 鸟瞰缩放状态,并在缩放前后通过 requestAnimationFrame
10
- * 精确维持当前视口中心点的相对滚动比例,杜绝画面位置跳变。
11
- */
12
- export declare function useKanbanZoom(containerRef: RefObject<HTMLDivElement | null>, options?: UseKanbanZoomOptions): {
13
- isZoomedOut: boolean;
14
- toggleZoom: () => void;
15
- setZoom: (zoomed: boolean) => void;
16
- };