@baishuyun/ui-base 2.2.4 → 2.3.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.
@@ -0,0 +1,86 @@
1
+ import { jsxs as y, jsx as r } from "react/jsx-runtime";
2
+ import { useState as N, useCallback as b, useMemo as h } from "react";
3
+ import { c as i } from "../vendors/clsx-OuTLNxxd.js";
4
+ import { I as k } from "../Icon/Icon-CBlIwtp2.js";
5
+ const a = {
6
+ "bsy-card": "_bsy-card_myftj_1",
7
+ "bsy-card__header": "_bsy-card__header_myftj_6",
8
+ "bsy-card__title": "_bsy-card__title_myftj_13",
9
+ "bsy-card__icon-container": "_bsy-card__icon-container_myftj_24",
10
+ "bsy-card__icon": "_bsy-card__icon_myftj_24",
11
+ "bsy-card__icon--expanded": "_bsy-card__icon--expanded_myftj_43",
12
+ "bsy-card__content": "_bsy-card__content_myftj_46",
13
+ "bsy-card__content--expanded": "_bsy-card__content--expanded_myftj_52",
14
+ "bsy-card__content-inner": "_bsy-card__content-inner_myftj_55"
15
+ }, I = ({
16
+ title: l,
17
+ children: m,
18
+ minWidth: s = 240,
19
+ defaultExpanded: f = !1,
20
+ expanded: d,
21
+ onExpandedChange: n,
22
+ className: p,
23
+ style: o,
24
+ styles: c
25
+ }) => {
26
+ const [x, j] = N(f), e = d ?? x, t = b(() => {
27
+ const _ = !e;
28
+ d === void 0 && j(_), n == null || n(_);
29
+ }, [e, d, n]), u = b(
30
+ (_) => {
31
+ (_.key === "Enter" || _.key === " ") && (_.preventDefault(), t());
32
+ },
33
+ [t]
34
+ ), v = h(
35
+ () => ({
36
+ minWidth: `${s}px`,
37
+ ...o
38
+ }),
39
+ [s, o]
40
+ );
41
+ return /* @__PURE__ */ y("div", { className: i(a["bsy-card"], p), style: v, children: [
42
+ /* @__PURE__ */ y(
43
+ "div",
44
+ {
45
+ className: a["bsy-card__header"],
46
+ onClick: t,
47
+ onKeyDown: u,
48
+ role: "button",
49
+ tabIndex: 0,
50
+ "aria-expanded": e,
51
+ "aria-controls": "card-content",
52
+ style: c == null ? void 0 : c.header,
53
+ children: [
54
+ /* @__PURE__ */ r("div", { className: a["bsy-card__title"], id: "card-title", role: "heading", children: l }),
55
+ /* @__PURE__ */ r("div", { className: a["bsy-card__icon-container"], children: /* @__PURE__ */ r(
56
+ k,
57
+ {
58
+ name: "xialakuangxiala1",
59
+ className: i(
60
+ a["bsy-card__icon"],
61
+ e && a["bsy-card__icon--expanded"]
62
+ )
63
+ }
64
+ ) })
65
+ ]
66
+ }
67
+ ),
68
+ /* @__PURE__ */ r(
69
+ "div",
70
+ {
71
+ id: "card-content",
72
+ role: "region",
73
+ "aria-labelledby": "card-title",
74
+ className: i(
75
+ a["bsy-card__content"],
76
+ e && a["bsy-card__content--expanded"]
77
+ ),
78
+ children: /* @__PURE__ */ r("div", { className: a["bsy-card__content-inner"], style: c == null ? void 0 : c.body, children: m })
79
+ }
80
+ )
81
+ ] });
82
+ };
83
+ I.displayName = "BsyCard";
84
+ export {
85
+ I as C
86
+ };
@@ -1,4 +1,4 @@
1
- import { C as f } from "./Card-hi1s-MYD.js";
1
+ import { C as f } from "./Card-Y1ISqAp9.js";
2
2
  export {
3
3
  f as default
4
4
  };
@@ -0,0 +1,216 @@
1
+ import { jsx as e, jsxs as b, Fragment as O } from "react/jsx-runtime";
2
+ import { ColorPicker as R } from "antd";
3
+ import { AnimatePresence as A, motion as F } from "motion/react";
4
+ import { useFloating as x, offset as L, flip as E, shift as T, useClick as V, useDismiss as j, useInteractions as B, FloatingPortal as M } from "@floating-ui/react";
5
+ import { useState as k, isValidElement as D, cloneElement as G, useRef as $, useMemo as q } from "react";
6
+ import { useControllableValue as z } from "ahooks";
7
+ import { I as u } from "../Icon/Icon-CBlIwtp2.js";
8
+ import { u as g } from "../vendors/useLocale-DgqW9M3h.js";
9
+ import { c as H } from "../vendors/clsx-OuTLNxxd.js";
10
+ import { a as y } from "../vendors/color-VzwvCPhF.js";
11
+ import { t as J } from "../vendors/tinycolor2-Begv3Jc8.js";
12
+ import { P as K } from "../vendors/index-MTmG1Ezy.js";
13
+ import { c as Q } from "../vendors/lodash-es-DFpaJB4Y.js";
14
+ const U = [
15
+ "rgba(240, 102, 72, 1)",
16
+ // #F06648
17
+ "rgba(255, 197, 2, 1)",
18
+ // #FFC502
19
+ "rgba(74, 204, 140, 1)",
20
+ // #4ACC8C
21
+ "rgba(74, 192, 236, 1)",
22
+ // #4AC0EC
23
+ "rgba(255, 153, 33, 1)",
24
+ // #ff9921
25
+ "rgba(101, 101, 101, 1)",
26
+ // #656565
27
+ "rgba(255, 156, 136, 1)",
28
+ // #ff9c88
29
+ "rgba(98, 98, 206, 1)",
30
+ // #6262ce
31
+ "rgba(241, 104, 182, 1)",
32
+ // #f168b6
33
+ "rgba(55, 103, 241, 1)",
34
+ // #3767f1
35
+ "rgba(162, 206, 30, 1)",
36
+ // #a2ce1e
37
+ "rgba(179, 179, 179, 1)",
38
+ // #b3b3b3
39
+ "rgba(0, 0, 0, 1)",
40
+ // #000000
41
+ "rgba(102, 102, 102, 1)",
42
+ // #666
43
+ "rgba(153, 153, 153, 1)",
44
+ // #999
45
+ "rgba(194, 194, 194, 1)",
46
+ // #c2c2c2
47
+ "rgba(224, 224, 224, 1)",
48
+ // #e0e0e0
49
+ "rgba(77, 96, 159, 1)"
50
+ // #4d609f
51
+ ], W = (o = "bottom-start") => {
52
+ const [t, r] = k(!1), { refs: n, floatingStyles: c, context: i } = x({
53
+ open: t,
54
+ onOpenChange: r,
55
+ placement: o,
56
+ middleware: [
57
+ L(4),
58
+ // 浮层与触发器间距
59
+ E(),
60
+ // 超出边界时自动翻转
61
+ T({ padding: 8 })
62
+ // 自动避开边界
63
+ ]
64
+ }), m = V(i), l = j(i), { getReferenceProps: _, getFloatingProps: a } = B([m, l]);
65
+ return {
66
+ isOpen: t,
67
+ refs: n,
68
+ floatingStyles: c,
69
+ getReferenceProps: _,
70
+ getFloatingProps: a,
71
+ setIsOpen: r
72
+ };
73
+ }, s = {
74
+ "bsy-color-picker__floating": "_bsy-color-picker__floating_1kfi6_1",
75
+ "bsy-color-picker__content": "_bsy-color-picker__content_1kfi6_4",
76
+ "bsy-color-picker__grid": "_bsy-color-picker__grid_1kfi6_11",
77
+ "bsy-color-picker__preset-colors-title": "_bsy-color-picker__preset-colors-title_1kfi6_15",
78
+ "bsy-color-picker__preset-colors-grid": "_bsy-color-picker__preset-colors-grid_1kfi6_19",
79
+ "bsy-color-picker__preset-colors-item": "_bsy-color-picker__preset-colors-item_1kfi6_24",
80
+ "bsy-color-picker__custom-color-title": "_bsy-color-picker__custom-color-title_1kfi6_47",
81
+ "bsy-color-picker__custom-color-btn": "_bsy-color-picker__custom-color-btn_1kfi6_51",
82
+ "bsy-color-picker__custom-color-btn--active": "_bsy-color-picker__custom-color-btn--active_1kfi6_61",
83
+ "bsy-color-picker__custom-color-btn--preview": "_bsy-color-picker__custom-color-btn--preview_1kfi6_65",
84
+ "bsy-color-picker__custom-color-content": "_bsy-color-picker__custom-color-content_1kfi6_68",
85
+ "bsy-color-picker__check-icon": "_bsy-color-picker__check-icon_1kfi6_72"
86
+ }, f = ({
87
+ currentColor: o,
88
+ onColorSelect: t,
89
+ options: r,
90
+ style: n
91
+ }) => /* @__PURE__ */ e("div", { className: s["bsy-color-picker__preset-colors-grid"], style: n, children: r.map((c) => /* @__PURE__ */ e(
92
+ "div",
93
+ {
94
+ className: s["bsy-color-picker__preset-colors-item"],
95
+ style: {
96
+ backgroundColor: c,
97
+ "--hover-color": J(c).setAlpha(0.5).toRgbString()
98
+ },
99
+ onClick: () => t(c),
100
+ children: y(o, c) && /* @__PURE__ */ e(u, { name: "checkthebox", className: s["bsy-color-picker__check-icon"] })
101
+ },
102
+ c
103
+ )) }), X = (o) => {
104
+ const {
105
+ children: t,
106
+ placement: r = "bottom-start",
107
+ disabled: n = !1,
108
+ presetColors: c,
109
+ getPopupContainer: i
110
+ } = o, { t: m } = g(), [l, _] = z(o, {
111
+ defaultValue: o.value
112
+ }), { isOpen: a, refs: d, floatingStyles: C, getReferenceProps: h, getFloatingProps: v } = W(r), P = D(t) ? G(t, {
113
+ ...h(),
114
+ // @ts-ignore
115
+ ref: d.setReference,
116
+ disabled: n
117
+ }) : t, p = Q(c) && c.length ? c : U, N = p.some((I) => y(I, l)), S = $(N ? [] : [l]), w = q(() => a ? i == null ? void 0 : i() : void 0, [a, i]);
118
+ return /* @__PURE__ */ b(O, { children: [
119
+ P,
120
+ /* @__PURE__ */ e(M, { root: w, children: /* @__PURE__ */ e(A, { children: a && /* @__PURE__ */ e(
121
+ "div",
122
+ {
123
+ ref: d.setFloating,
124
+ style: C,
125
+ ...v(),
126
+ className: s["bsy-color-picker__floating"],
127
+ children: /* @__PURE__ */ e(F.div, { ...K, children: /* @__PURE__ */ e("div", { className: s["bsy-color-picker__content"], children: /* @__PURE__ */ b("div", { className: s["bsy-color-picker__grid"], children: [
128
+ /* @__PURE__ */ b("div", { className: s["bsy-color-picker__preset-colors"], children: [
129
+ /* @__PURE__ */ e("div", { className: s["bsy-color-picker__preset-colors-title"], children: m("presetColors") }),
130
+ /* @__PURE__ */ e(
131
+ f,
132
+ {
133
+ currentColor: l,
134
+ onColorSelect: _,
135
+ options: p
136
+ }
137
+ )
138
+ ] }),
139
+ /* @__PURE__ */ e(
140
+ Y,
141
+ {
142
+ value: l,
143
+ onChange: _,
144
+ onColorInput: o.onColorInput,
145
+ options: p,
146
+ list: S.current
147
+ }
148
+ )
149
+ ] }) }) })
150
+ }
151
+ ) }) })
152
+ ] });
153
+ }, Y = (o) => {
154
+ const { list: t } = o, [r, n] = k(), [c, i] = k(!1), { t: m } = g();
155
+ return /* @__PURE__ */ b("div", { className: s["bsy-color-picker__custom-color"], children: [
156
+ /* @__PURE__ */ e("div", { className: s["bsy-color-picker__custom-color-title"], children: m("customColor") }),
157
+ /* @__PURE__ */ b("div", { className: s["bsy-color-picker__custom-color-content"], children: [
158
+ /* @__PURE__ */ e(
159
+ R,
160
+ {
161
+ value: r,
162
+ onChange: (l) => {
163
+ var a;
164
+ const _ = l.toRgbString();
165
+ n(_), (a = o.onColorInput) == null || a.call(o, _);
166
+ },
167
+ open: c,
168
+ onOpenChange: (l) => {
169
+ i(l), !l && r && (t.includes(r) || t.unshift(r), o.onChange(r), n(void 0));
170
+ },
171
+ children: /* @__PURE__ */ e(
172
+ "div",
173
+ {
174
+ className: H(s["bsy-color-picker__custom-color-btn"], {
175
+ [s["bsy-color-picker__custom-color-btn--active"]]: c && !r,
176
+ [s["bsy-color-picker__custom-color-btn--preview"]]: !!r
177
+ }),
178
+ role: "button",
179
+ style: {
180
+ backgroundColor: r || void 0
181
+ },
182
+ onClick: () => {
183
+ i(!0);
184
+ },
185
+ children: /* @__PURE__ */ e(
186
+ u,
187
+ {
188
+ name: "add",
189
+ style: {
190
+ visibility: r ? "hidden" : "visible"
191
+ }
192
+ }
193
+ )
194
+ }
195
+ )
196
+ }
197
+ ),
198
+ /* @__PURE__ */ e(
199
+ f,
200
+ {
201
+ currentColor: o.value,
202
+ onColorSelect: o.onChange,
203
+ options: t.slice(0, 5),
204
+ style: {
205
+ gridTemplateColumns: "repeat(5, 1fr)"
206
+ }
207
+ }
208
+ )
209
+ ] })
210
+ ] });
211
+ };
212
+ X.displayName = "BsyColorPicker";
213
+ export {
214
+ X as C,
215
+ U as a
216
+ };
@@ -1,4 +1,4 @@
1
- import { a as e, C as f } from "./ColorPicker-B8U3ubrp.js";
1
+ import { a as e, C as f } from "./ColorPicker-D0D5azon.js";
2
2
  export {
3
3
  e as COLOR_OPTIONS_RGBA,
4
4
  f as default
@@ -1,4 +1,4 @@
1
- import { b as r, g as a, l as e, r as s, u as l } from "../../index-cVFSiCP9.js";
1
+ import { b as r, g as a, l as e, r as s, u as l } from "../../index-C0Rjz8DK.js";
2
2
  export {
3
3
  r as default,
4
4
  a as getToolbarButton,
@@ -6,7 +6,7 @@ import { l as ce, i as de, P as T, _ as O, y as X, w as $, E as ee, p as we, x a
6
6
  import { u as w } from "../vendors/useLocale-DgqW9M3h.js";
7
7
  import { D as pe } from "../DropDown/DropDown-DGkSeXQT.js";
8
8
  import { FONT_SIZES as Se } from "./constants/index.js";
9
- import { C as me } from "../ColorPicker/ColorPicker-B8U3ubrp.js";
9
+ import { C as me } from "../ColorPicker/ColorPicker-D0D5azon.js";
10
10
  import { AlignLeftOutlined as te, AlignCenterOutlined as Le, AlignRightOutlined as Te } from "@ant-design/icons";
11
11
  import { M as _e } from "../Modal/Modal-z3TvEXwN.js";
12
12
  import { message as Z, Input as V, Button as j, Form as J } from "antd";
@@ -1,8 +1,8 @@
1
1
  import { jsx as u, jsxs as W, Fragment as et } from "react/jsx-runtime";
2
2
  import { o as N, P as F, _ as $, Y as M, w as U, f as nt, x as G, j as it, C as ot, L as rt, $ as B, S as st, a as at, W as V, J as lt, F as ct, B as ut, M as dt, b as J, g as ht, m as gt, h as mt, c as ft, d as _t, e as bt, n as pt, q as z, s as xt, i as yt, k as vt } from "../vendors/lexical-DO7eMeC2.js";
3
3
  import wt, { useState as S, useEffect as y, useRef as O, useCallback as E, useMemo as Tt } from "react";
4
- import { p as Ct, T as Et, g as Lt, a as Z, k as X, v as H, I as Nt, m as kt } from "./index-cVFSiCP9.js";
5
- import { B as ie, l as oe, r as re, u as se } from "./index-cVFSiCP9.js";
4
+ import { p as Ct, T as Et, g as Lt, a as Z, k as X, v as H, I as Nt, m as kt } from "./index-C0Rjz8DK.js";
5
+ import { B as ie, l as oe, r as re, u as se } from "./index-C0Rjz8DK.js";
6
6
  import { DEFAULT_BACKGROUND_COLOR as j, DEFAULT_FONT_COLOR as K, DEFAULT_FONT_SIZE as Y } from "./constants/index.js";
7
7
  import { c as R } from "../vendors/clsx-OuTLNxxd.js";
8
8
  const I = {
@@ -0,0 +1,155 @@
1
+ import { jsxs as S, jsx as o } from "react/jsx-runtime";
2
+ import { useControllableValue as W } from "ahooks";
3
+ import { useState as N, useLayoutEffect as A, useRef as m, useEffect as z, useCallback as D } from "react";
4
+ import { c as T } from "../vendors/clsx-OuTLNxxd.js";
5
+ import { I as V } from "../Icon/Icon-CBlIwtp2.js";
6
+ import { motion as B } from "motion/react";
7
+ import { S as F } from "../vendors/simplebar-react-D68KzE44.js";
8
+ const _ = {
9
+ "bsy-inputTag": "_bsy-inputTag_46spj_11",
10
+ "bsy-inputTag__container": "_bsy-inputTag__container_46spj_22",
11
+ "bsy-inputTag__inputContainer": "_bsy-inputTag__inputContainer_46spj_27",
12
+ "bsy-inputTag__inputContainer--zeroMargin": "_bsy-inputTag__inputContainer--zeroMargin_46spj_37",
13
+ "bsy-inputTag__input": "_bsy-inputTag__input_46spj_27"
14
+ }, b = {
15
+ GAP: 4,
16
+ OFFSET: 3,
17
+ CONTAINER_PADDING: 10,
18
+ INPUT_MARGIN: 4
19
+ }, L = (l, x) => {
20
+ const [c, y] = N(0);
21
+ return A(() => {
22
+ const i = l.current;
23
+ if (!i) return;
24
+ const n = () => {
25
+ const a = i.children;
26
+ let f = 0;
27
+ for (let r = 0; r < a.length; r++)
28
+ f += a[r].clientWidth;
29
+ const h = Math.max(0, a.length - 1) * b.GAP, d = Math.max(0, f + h + b.OFFSET);
30
+ y((r) => r === d ? r : d);
31
+ };
32
+ n();
33
+ const u = new ResizeObserver(n);
34
+ return u.observe(i), () => {
35
+ u.disconnect();
36
+ };
37
+ }, [x, l]), c;
38
+ }, K = (l) => {
39
+ const { defaultValue: x, enableActive: c = !1, defaultActiveIndex: y, onActiveIndexChange: i } = l, [n, u] = W(l, {
40
+ defaultValue: x || []
41
+ }), [a, f] = W(
42
+ l,
43
+ {
44
+ valuePropName: "activeIndex",
45
+ trigger: "onActiveIndexChange",
46
+ defaultValue: y
47
+ }
48
+ ), [h, d] = N(""), r = m(null), p = m(null), g = m(null), v = m(!1), w = () => {
49
+ if (p.current && p.current.children.length > 0) {
50
+ const t = p.current.children.length - 1;
51
+ p.current.children[t].scrollIntoView({
52
+ behavior: "smooth",
53
+ block: "nearest",
54
+ inline: "end"
55
+ });
56
+ }
57
+ };
58
+ z(() => {
59
+ v.current && n.length > 0 && (w(), v.current = !1);
60
+ }, [n.length]);
61
+ const k = (t) => {
62
+ d(t.currentTarget.value);
63
+ }, C = () => {
64
+ const t = h.trim();
65
+ if (t !== "") {
66
+ const e = t;
67
+ v.current = !0, u([...n, e]), d("");
68
+ }
69
+ }, M = (t, e) => {
70
+ if (!c) return;
71
+ const s = a === t ? void 0 : t;
72
+ f(s), i == null || i(s ?? -1, e);
73
+ }, E = (t) => {
74
+ t.key === "Enter" || t.key === "NumpadEnter" ? C() : t.key === "Backspace" && h === "" && n.length > 0 && u(n.slice(0, -1));
75
+ }, R = (t) => {
76
+ u(n.filter((e, s) => s !== t));
77
+ }, [G, P] = N(0), j = L(p, n.length), I = D(() => {
78
+ if (!r.current || !g.current) return;
79
+ const t = r.current.clientWidth - g.current.clientWidth - b.INPUT_MARGIN - b.CONTAINER_PADDING, e = Math.max(0, t);
80
+ P((s) => s === e ? s : e);
81
+ }, []);
82
+ A(() => {
83
+ if (!r.current || !g.current) return;
84
+ I();
85
+ const t = new ResizeObserver(() => {
86
+ I();
87
+ });
88
+ return t.observe(r.current), t.observe(g.current), () => {
89
+ t.disconnect();
90
+ };
91
+ }, [I]);
92
+ const O = Math.min(j, G);
93
+ return /* @__PURE__ */ S("div", { className: _["bsy-inputTag"], ref: r, children: [
94
+ /* @__PURE__ */ o("div", { className: _["bsy-inputTag__container"], children: n.length ? /* @__PURE__ */ o(F, { style: { width: O + "px" }, children: /* @__PURE__ */ o("div", { className: "flex gap-1 py-[3px]", ref: p, children: n.map((t, e) => /* @__PURE__ */ S(
95
+ B.div,
96
+ {
97
+ className: T(
98
+ "rounded-[2px] gap-1 px-[6px] h-[26px] flex items-center flex-shrink-0",
99
+ {
100
+ "cursor-pointer": c,
101
+ "hover:bg-[#e0e0e0]": c && a !== e,
102
+ "bg-[#0265ff] text-white": c && a === e,
103
+ "bg-[#eee] text-black": !c || a !== e
104
+ }
105
+ ),
106
+ onClick: () => M(e, t),
107
+ children: [
108
+ /* @__PURE__ */ o("span", { children: t }),
109
+ /* @__PURE__ */ o(
110
+ "div",
111
+ {
112
+ className: T(
113
+ "cursor-pointer",
114
+ c && a === e ? "text-white hover:text-gray-200" : "text-[#666] hover:text-[#0265ff]"
115
+ ),
116
+ onClick: (s) => {
117
+ s.stopPropagation(), R(e);
118
+ },
119
+ children: /* @__PURE__ */ o(V, { name: "close", size: 12 })
120
+ }
121
+ )
122
+ ]
123
+ },
124
+ e
125
+ )) }) }) : null }),
126
+ /* @__PURE__ */ o(
127
+ "div",
128
+ {
129
+ ref: g,
130
+ className: T(
131
+ _["bsy-inputTag__inputContainer"],
132
+ {
133
+ [_["bsy-inputTag__inputContainer--zeroMargin"]]: n.length === 0
134
+ },
135
+ "py-[3px]"
136
+ ),
137
+ children: /* @__PURE__ */ o(
138
+ "input",
139
+ {
140
+ value: h,
141
+ onChange: k,
142
+ onKeyDown: E,
143
+ onBlur: C,
144
+ className: T(_["bsy-inputTag__input"], "placeholder:text-[#999]"),
145
+ placeholder: "输入标签"
146
+ }
147
+ )
148
+ }
149
+ )
150
+ ] });
151
+ };
152
+ K.displayName = "BsyInputTag";
153
+ export {
154
+ K as I
155
+ };
@@ -1,4 +1,4 @@
1
- import { I as t } from "./InputTag-C6MbuO-e.js";
1
+ import { I as t } from "./InputTag-C-rQUJnF.js";
2
2
  export {
3
3
  t as default
4
4
  };
@@ -17,10 +17,18 @@ export interface CardProps {
17
17
  */
18
18
  minWidth?: number;
19
19
  /**
20
- * 是否默认展开
20
+ * 是否默认展开(非受控模式)
21
21
  * @default false
22
22
  */
23
23
  defaultExpanded?: boolean;
24
+ /**
25
+ * 是否展开(受控模式)
26
+ */
27
+ expanded?: boolean;
28
+ /**
29
+ * 展开状态变化回调
30
+ */
31
+ onExpandedChange?: (expanded: boolean) => void;
24
32
  /**
25
33
  * 自定义类名
26
34
  */
@@ -12,6 +12,12 @@ export interface ColorPickerProps {
12
12
  defaultValue?: string;
13
13
  /** 颜色变化时的回调函数 */
14
14
  onChange?: (color: string) => void;
15
+ /**
16
+ * 颜色输入过程中的回调函数
17
+ * @description 在用户拖动/选择颜色时实时触发,用于实时预览
18
+ * @param color - 当前正在输入的颜色值(RGB/RGBA 格式字符串)
19
+ */
20
+ onColorInput?: (color: string) => void;
15
21
  /** 浮层的放置位置 */
16
22
  /** @default 'bottom-start' */
17
23
  placement?: 'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'bottom-start';
@@ -22,4 +28,15 @@ export interface ColorPickerProps {
22
28
  * 预设颜色
23
29
  */
24
30
  presetColors?: string[];
31
+ /**
32
+ * 指定颜色选择器浮层菜单渲染的父级 DOM 节点
33
+ * @default undefined (默认渲染到 body 元素上)
34
+ * @example
35
+ * ```tsx
36
+ * <ColorPicker getPopupContainer={() => document.getElementById('container')}>
37
+ * <button>选择颜色</button>
38
+ * </ColorPicker>
39
+ * ```
40
+ */
41
+ getPopupContainer?: () => HTMLElement;
25
42
  }
package/dist/index.js CHANGED
@@ -2,9 +2,9 @@ import { I as W } from "./Icon/Icon-CBlIwtp2.js";
2
2
  import { jsx as p } from "react/jsx-runtime";
3
3
  import { useMemo as a, useCallback as u } from "react";
4
4
  import { z as i, L as f } from "./vendors/useLocale-DgqW9M3h.js";
5
- import { C as Y } from "./Card/Card-hi1s-MYD.js";
5
+ import { C as Y } from "./Card/Card-Y1ISqAp9.js";
6
6
  import { M as _ } from "./Modal/Modal-z3TvEXwN.js";
7
- import { C as oe } from "./ColorPicker/ColorPicker-B8U3ubrp.js";
7
+ import { C as oe } from "./ColorPicker/ColorPicker-D0D5azon.js";
8
8
  import { S as ae } from "./Segmented/Segmented-UgzW78Ey.js";
9
9
  import { S as re } from "./Select/Select-hwXXDuLU.js";
10
10
  import { T as se } from "./vendors/Tree-CLEy-xqz.js";
@@ -14,7 +14,7 @@ import { a as pe, T as ue } from "./Tabs/TabSelect-DL8Bhehc.js";
14
14
  import { D as Ce } from "./DropDown/DropDown-DGkSeXQT.js";
15
15
  import { L as Ie } from "./Loading/Loading-CEB4PLUE.js";
16
16
  import { N as Le } from "./NotFoundContent/NotFoundContent-h0-oIXlk.js";
17
- import { I as ke } from "./InputTag/InputTag-C6MbuO-e.js";
17
+ import { I as ke } from "./InputTag/InputTag-C-rQUJnF.js";
18
18
  const C = "Please select", U = "search", I = "No search data", x = "Select All", L = "Please enter the content", S = "No Data", k = "No Data Found", h = "Data Searching...", A = "Select All by Search", P = "Left Align", y = "Center Align", N = "Right Align", R = "Underline", F = "Link", T = "Hyper Link", D = "Show Content", b = "Link Address", v = "Open in New Tab", z = "Confirm", w = "Cancel", M = "Cancel Link", E = "preset color", O = { linkTip: "Support https://link or @form alias", bold: "Bold", italic: "Italic", fontSize: "Font Size", fontColor: "Font Color", fill: "fill", alignment: "Alignment", centerAlign: "Center Align", rightAlign: "Right Align", uploadImage: "Upload Image", imageUrl: "Image URL", imageUrlPlaceholder: "Please enter image URL", imageUrlRequired: "Please enter image URL", imageUrlInvalid: "Please enter a valid image URL", imageUrlNote: "Note: Enter image URL to insert image", inputImageUrl: "Enter Image URL", uploadImageNote: "Note: Single image size cannot exceed 1MB", uploadImageText: "Click or drag to upload image", previewImage: "Preview Image", underline: "Underline", imageFormatOnly: "Only image formats are supported", uploadImageFirst: "Please upload image first", imageAddSuccess: "Image added successfully", operationFailed: "Operation failed", onlyImageFormatsSupported: "Only image formats are supported", pleaseUploadImageFirst: "Please upload image first", imageSizeNote: "Image size cannot exceed 1MB", clickOrDragToUpload: "Click or drag to upload image", enterImageUrl: "Enter image URL", pleaseEnterImageUrl: "Please enter image URL", pleaseEnterValidImageUrl: "Please enter a valid image URL", linkAddressEmpty: "Link address cannot be empty" }, B = "Picture", V = "Custom Color", j = "Add Picture", q = {
19
19
  select: C,
20
20
  search: U,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baishuyun/ui-base",
3
- "version": "2.2.4",
3
+ "version": "2.3.0",
4
4
  "type": "module",
5
5
  "description": "百数云低代码平台通用组件库",
6
6
  "author": "bsy-fe team",
@@ -1,74 +0,0 @@
1
- import { jsxs as e, jsx as c } from "react/jsx-runtime";
2
- import { useState as l } from "react";
3
- import { c as n } from "../vendors/clsx-OuTLNxxd.js";
4
- import { I as p } from "../Icon/Icon-CBlIwtp2.js";
5
- const _ = {
6
- "bsy-card": "_bsy-card_myftj_1",
7
- "bsy-card__header": "_bsy-card__header_myftj_6",
8
- "bsy-card__title": "_bsy-card__title_myftj_13",
9
- "bsy-card__icon-container": "_bsy-card__icon-container_myftj_24",
10
- "bsy-card__icon": "_bsy-card__icon_myftj_24",
11
- "bsy-card__icon--expanded": "_bsy-card__icon--expanded_myftj_43",
12
- "bsy-card__content": "_bsy-card__content_myftj_46",
13
- "bsy-card__content--expanded": "_bsy-card__content--expanded_myftj_52",
14
- "bsy-card__content-inner": "_bsy-card__content-inner_myftj_55"
15
- }, x = ({
16
- title: r,
17
- children: t,
18
- minWidth: s = 240,
19
- defaultExpanded: i = !1,
20
- className: o,
21
- style: y,
22
- styles: a
23
- }) => {
24
- const [d, b] = l(i), m = () => {
25
- b(!d);
26
- };
27
- return /* @__PURE__ */ e(
28
- "div",
29
- {
30
- className: n(_["bsy-card"], o),
31
- style: {
32
- minWidth: `${s}px`,
33
- ...y
34
- },
35
- children: [
36
- /* @__PURE__ */ e(
37
- "div",
38
- {
39
- className: _["bsy-card__header"],
40
- onClick: m,
41
- style: a == null ? void 0 : a.header,
42
- children: [
43
- /* @__PURE__ */ c("div", { className: _["bsy-card__title"], role: "heading", children: r }),
44
- /* @__PURE__ */ c("div", { className: _["bsy-card__icon-container"], children: /* @__PURE__ */ c(
45
- p,
46
- {
47
- name: "xialakuangxiala1",
48
- className: n(
49
- _["bsy-card__icon"],
50
- d && _["bsy-card__icon--expanded"]
51
- )
52
- }
53
- ) })
54
- ]
55
- }
56
- ),
57
- /* @__PURE__ */ c(
58
- "div",
59
- {
60
- className: n(
61
- _["bsy-card__content"],
62
- d && _["bsy-card__content--expanded"]
63
- ),
64
- children: /* @__PURE__ */ c("div", { className: _["bsy-card__content-inner"], style: a == null ? void 0 : a.body, children: t })
65
- }
66
- )
67
- ]
68
- }
69
- );
70
- };
71
- x.displayName = "BsyCard";
72
- export {
73
- x as C
74
- };
@@ -1,205 +0,0 @@
1
- import { jsx as r, jsxs as _, Fragment as O } from "react/jsx-runtime";
2
- import { ColorPicker as w } from "antd";
3
- import { AnimatePresence as R, motion as A } from "motion/react";
4
- import { useFloating as F, offset as I, flip as x, shift as L, useClick as E, useDismiss as T, useInteractions as V, FloatingPortal as j } from "@floating-ui/react";
5
- import { useState as k, isValidElement as B, cloneElement as D, useRef as G } from "react";
6
- import { useControllableValue as M } from "ahooks";
7
- import { I as d } from "../Icon/Icon-CBlIwtp2.js";
8
- import { u as g } from "../vendors/useLocale-DgqW9M3h.js";
9
- import { c as $ } from "../vendors/clsx-OuTLNxxd.js";
10
- import { a as u } from "../vendors/color-VzwvCPhF.js";
11
- import { t as q } from "../vendors/tinycolor2-Begv3Jc8.js";
12
- import { P as z } from "../vendors/index-MTmG1Ezy.js";
13
- import { c as H } from "../vendors/lodash-es-DFpaJB4Y.js";
14
- const J = [
15
- "rgba(240, 102, 72, 1)",
16
- // #F06648
17
- "rgba(255, 197, 2, 1)",
18
- // #FFC502
19
- "rgba(74, 204, 140, 1)",
20
- // #4ACC8C
21
- "rgba(74, 192, 236, 1)",
22
- // #4AC0EC
23
- "rgba(255, 153, 33, 1)",
24
- // #ff9921
25
- "rgba(101, 101, 101, 1)",
26
- // #656565
27
- "rgba(255, 156, 136, 1)",
28
- // #ff9c88
29
- "rgba(98, 98, 206, 1)",
30
- // #6262ce
31
- "rgba(241, 104, 182, 1)",
32
- // #f168b6
33
- "rgba(55, 103, 241, 1)",
34
- // #3767f1
35
- "rgba(162, 206, 30, 1)",
36
- // #a2ce1e
37
- "rgba(179, 179, 179, 1)",
38
- // #b3b3b3
39
- "rgba(0, 0, 0, 1)",
40
- // #000000
41
- "rgba(102, 102, 102, 1)",
42
- // #666
43
- "rgba(153, 153, 153, 1)",
44
- // #999
45
- "rgba(194, 194, 194, 1)",
46
- // #c2c2c2
47
- "rgba(224, 224, 224, 1)",
48
- // #e0e0e0
49
- "rgba(77, 96, 159, 1)"
50
- // #4d609f
51
- ], K = (s = "bottom-start") => {
52
- const [t, o] = k(!1), { refs: i, floatingStyles: e, context: a } = F({
53
- open: t,
54
- onOpenChange: o,
55
- placement: s,
56
- middleware: [
57
- I(4),
58
- // 浮层与触发器间距
59
- x(),
60
- // 超出边界时自动翻转
61
- L({ padding: 8 })
62
- // 自动避开边界
63
- ]
64
- }), n = E(a), l = T(a), { getReferenceProps: p, getFloatingProps: m } = V([n, l]);
65
- return {
66
- isOpen: t,
67
- refs: i,
68
- floatingStyles: e,
69
- getReferenceProps: p,
70
- getFloatingProps: m,
71
- setIsOpen: o
72
- };
73
- }, c = {
74
- "bsy-color-picker__floating": "_bsy-color-picker__floating_1kfi6_1",
75
- "bsy-color-picker__content": "_bsy-color-picker__content_1kfi6_4",
76
- "bsy-color-picker__grid": "_bsy-color-picker__grid_1kfi6_11",
77
- "bsy-color-picker__preset-colors-title": "_bsy-color-picker__preset-colors-title_1kfi6_15",
78
- "bsy-color-picker__preset-colors-grid": "_bsy-color-picker__preset-colors-grid_1kfi6_19",
79
- "bsy-color-picker__preset-colors-item": "_bsy-color-picker__preset-colors-item_1kfi6_24",
80
- "bsy-color-picker__custom-color-title": "_bsy-color-picker__custom-color-title_1kfi6_47",
81
- "bsy-color-picker__custom-color-btn": "_bsy-color-picker__custom-color-btn_1kfi6_51",
82
- "bsy-color-picker__custom-color-btn--active": "_bsy-color-picker__custom-color-btn--active_1kfi6_61",
83
- "bsy-color-picker__custom-color-btn--preview": "_bsy-color-picker__custom-color-btn--preview_1kfi6_65",
84
- "bsy-color-picker__custom-color-content": "_bsy-color-picker__custom-color-content_1kfi6_68",
85
- "bsy-color-picker__check-icon": "_bsy-color-picker__check-icon_1kfi6_72"
86
- }, y = ({
87
- currentColor: s,
88
- onColorSelect: t,
89
- options: o,
90
- style: i
91
- }) => /* @__PURE__ */ r("div", { className: c["bsy-color-picker__preset-colors-grid"], style: i, children: o.map((e) => /* @__PURE__ */ r(
92
- "div",
93
- {
94
- className: c["bsy-color-picker__preset-colors-item"],
95
- style: {
96
- backgroundColor: e,
97
- "--hover-color": q(e).setAlpha(0.5).toRgbString()
98
- },
99
- onClick: () => t(e),
100
- children: u(s, e) && /* @__PURE__ */ r(d, { name: "checkthebox", className: c["bsy-color-picker__check-icon"] })
101
- },
102
- e
103
- )) }), Q = (s) => {
104
- const { children: t, placement: o = "bottom-start", disabled: i = !1, presetColors: e } = s, { t: a } = g(), [n, l] = M(s, {
105
- defaultValue: s.value
106
- }), { isOpen: p, refs: m, floatingStyles: f, getReferenceProps: C, getFloatingProps: h } = K(o), v = B(t) ? D(t, {
107
- ...C(),
108
- // @ts-ignore
109
- ref: m.setReference,
110
- disabled: i
111
- }) : t, b = H(e) && e.length ? e : J, P = b.some((S) => u(S, n)), N = G(P ? [] : [n]);
112
- return /* @__PURE__ */ _(O, { children: [
113
- v,
114
- /* @__PURE__ */ r(j, { children: /* @__PURE__ */ r(R, { children: p && /* @__PURE__ */ r(
115
- "div",
116
- {
117
- ref: m.setFloating,
118
- style: f,
119
- ...h(),
120
- className: c["bsy-color-picker__floating"],
121
- children: /* @__PURE__ */ r(A.div, { ...z, children: /* @__PURE__ */ r("div", { className: c["bsy-color-picker__content"], children: /* @__PURE__ */ _("div", { className: c["bsy-color-picker__grid"], children: [
122
- /* @__PURE__ */ _("div", { className: c["bsy-color-picker__preset-colors"], children: [
123
- /* @__PURE__ */ r("div", { className: c["bsy-color-picker__preset-colors-title"], children: a("presetColors") }),
124
- /* @__PURE__ */ r(
125
- y,
126
- {
127
- currentColor: n,
128
- onColorSelect: l,
129
- options: b
130
- }
131
- )
132
- ] }),
133
- /* @__PURE__ */ r(
134
- U,
135
- {
136
- value: n,
137
- onChange: l,
138
- options: b,
139
- list: N.current
140
- }
141
- )
142
- ] }) }) })
143
- }
144
- ) }) })
145
- ] });
146
- }, U = (s) => {
147
- const { list: t } = s, [o, i] = k(), [e, a] = k(!1), { t: n } = g();
148
- return /* @__PURE__ */ _("div", { className: c["bsy-color-picker__custom-color"], children: [
149
- /* @__PURE__ */ r("div", { className: c["bsy-color-picker__custom-color-title"], children: n("customColor") }),
150
- /* @__PURE__ */ _("div", { className: c["bsy-color-picker__custom-color-content"], children: [
151
- /* @__PURE__ */ r(
152
- w,
153
- {
154
- value: o,
155
- onChange: (l) => i(l.toRgbString()),
156
- open: e,
157
- onOpenChange: (l) => {
158
- a(l), !l && o && (t.includes(o) || t.unshift(o), s.onChange(o), i(void 0));
159
- },
160
- children: /* @__PURE__ */ r(
161
- "div",
162
- {
163
- className: $(c["bsy-color-picker__custom-color-btn"], {
164
- [c["bsy-color-picker__custom-color-btn--active"]]: e && !o,
165
- [c["bsy-color-picker__custom-color-btn--preview"]]: !!o
166
- }),
167
- role: "button",
168
- style: {
169
- backgroundColor: o || void 0
170
- },
171
- onClick: () => {
172
- a(!0);
173
- },
174
- children: /* @__PURE__ */ r(
175
- d,
176
- {
177
- name: "add",
178
- style: {
179
- visibility: o ? "hidden" : "visible"
180
- }
181
- }
182
- )
183
- }
184
- )
185
- }
186
- ),
187
- /* @__PURE__ */ r(
188
- y,
189
- {
190
- currentColor: s.value,
191
- onColorSelect: s.onChange,
192
- options: t.slice(0, 5),
193
- style: {
194
- gridTemplateColumns: "repeat(5, 1fr)"
195
- }
196
- }
197
- )
198
- ] })
199
- ] });
200
- };
201
- Q.displayName = "BsyColorPicker";
202
- export {
203
- Q as C,
204
- J as a
205
- };
@@ -1,137 +0,0 @@
1
- import { jsxs as C, jsx as l } from "react/jsx-runtime";
2
- import { useControllableValue as A } from "ahooks";
3
- import { useState as S, useLayoutEffect as k, useRef as p, useEffect as D } from "react";
4
- import { c as h } from "../vendors/clsx-OuTLNxxd.js";
5
- import { I as M } from "../Icon/Icon-CBlIwtp2.js";
6
- import { motion as O } from "motion/react";
7
- import { S as V } from "../vendors/simplebar-react-D68KzE44.js";
8
- const g = {
9
- "bsy-inputTag": "_bsy-inputTag_46spj_11",
10
- "bsy-inputTag__container": "_bsy-inputTag__container_46spj_22",
11
- "bsy-inputTag__inputContainer": "_bsy-inputTag__inputContainer_46spj_27",
12
- "bsy-inputTag__inputContainer--zeroMargin": "_bsy-inputTag__inputContainer--zeroMargin_46spj_37",
13
- "bsy-inputTag__input": "_bsy-inputTag__input_46spj_27"
14
- }, d = {
15
- GAP: 4,
16
- OFFSET: 3,
17
- CONTAINER_PADDING: 10,
18
- INPUT_MARGIN: 4
19
- }, z = (s, _) => {
20
- const [a, f] = S(0);
21
- return k(() => {
22
- if (s.current) {
23
- const i = s.current.children;
24
- let e = 0;
25
- for (let r = 0; r < i.length; r++)
26
- e += i[r].clientWidth;
27
- const u = (i.length - 1) * d.GAP;
28
- f(e + u + d.OFFSET);
29
- }
30
- }, [_, s]), a;
31
- }, B = (s) => {
32
- const { defaultValue: _, enableActive: a = !1, defaultActiveIndex: f, onActiveIndexChange: i } = s, [e, u] = A(s, {
33
- defaultValue: _ || []
34
- }), [r, w] = A(
35
- s,
36
- {
37
- valuePropName: "activeIndex",
38
- trigger: "onActiveIndexChange",
39
- defaultValue: f
40
- }
41
- ), [T, x] = S(""), m = p(null), c = p(null), y = p(null), b = p(!1), E = () => {
42
- if (c.current && c.current.children.length > 0) {
43
- const t = c.current.children.length - 1;
44
- c.current.children[t].scrollIntoView({
45
- behavior: "smooth",
46
- block: "nearest",
47
- inline: "end"
48
- });
49
- }
50
- };
51
- D(() => {
52
- b.current && e.length > 0 && (E(), b.current = !1);
53
- }, [e.length]);
54
- const W = (t) => {
55
- x(t.currentTarget.value);
56
- }, N = () => {
57
- const t = T.trim();
58
- if (t !== "") {
59
- const n = t;
60
- b.current = !0, u([...e, n]), x("");
61
- }
62
- }, G = (t, n) => {
63
- if (!a) return;
64
- const o = r === t ? void 0 : t;
65
- w(o), i == null || i(o ?? -1, n);
66
- }, P = (t) => {
67
- t.key === "Enter" || t.key === "NumpadEnter" ? N() : t.key === "Backspace" && T === "" && e.length > 0 && u(e.slice(0, -1));
68
- }, j = (t) => {
69
- u(e.filter((n, o) => o !== t));
70
- }, I = p(0), v = z(c, e.length);
71
- k(() => {
72
- m.current && y.current && (I.current = m.current.clientWidth - y.current.clientWidth - d.INPUT_MARGIN - d.CONTAINER_PADDING);
73
- }, []);
74
- const R = v > I.current ? I.current : v;
75
- return /* @__PURE__ */ C("div", { className: g["bsy-inputTag"], ref: m, children: [
76
- /* @__PURE__ */ l("div", { className: g["bsy-inputTag__container"], children: e.length ? /* @__PURE__ */ l(V, { style: { width: R + "px" }, children: /* @__PURE__ */ l("div", { className: "flex gap-1 py-[3px]", ref: c, children: e.map((t, n) => /* @__PURE__ */ C(
77
- O.div,
78
- {
79
- className: h(
80
- "rounded-[2px] gap-1 px-[6px] h-[26px] flex items-center flex-shrink-0",
81
- {
82
- "cursor-pointer": a,
83
- "hover:bg-[#e0e0e0]": a && r !== n,
84
- "bg-[#0265ff] text-white": a && r === n,
85
- "bg-[#eee] text-black": !a || r !== n
86
- }
87
- ),
88
- onClick: () => G(n, t),
89
- children: [
90
- /* @__PURE__ */ l("span", { children: t }),
91
- /* @__PURE__ */ l(
92
- "div",
93
- {
94
- className: h(
95
- "cursor-pointer",
96
- a && r === n ? "text-white hover:text-gray-200" : "text-[#666] hover:text-[#0265ff]"
97
- ),
98
- onClick: (o) => {
99
- o.stopPropagation(), j(n);
100
- },
101
- children: /* @__PURE__ */ l(M, { name: "close", size: 12 })
102
- }
103
- )
104
- ]
105
- },
106
- n
107
- )) }) }) : null }),
108
- /* @__PURE__ */ l(
109
- "div",
110
- {
111
- ref: y,
112
- className: h(
113
- g["bsy-inputTag__inputContainer"],
114
- {
115
- [g["bsy-inputTag__inputContainer--zeroMargin"]]: e.length === 0
116
- },
117
- "py-[3px]"
118
- ),
119
- children: /* @__PURE__ */ l(
120
- "input",
121
- {
122
- value: T,
123
- onChange: W,
124
- onKeyDown: P,
125
- onBlur: N,
126
- className: h(g["bsy-inputTag__input"], "placeholder:text-[#999]"),
127
- placeholder: "输入标签"
128
- }
129
- )
130
- }
131
- )
132
- ] });
133
- };
134
- B.displayName = "BsyInputTag";
135
- export {
136
- B as I
137
- };