@notificationapi/react 0.0.37 → 1.0.1

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 (72) hide show
  1. package/dist/assets/Badge.js +456 -0
  2. package/dist/assets/Box.js +57 -0
  3. package/dist/assets/ButtonBase.js +1224 -0
  4. package/dist/assets/DefaultPropsProvider.js +4368 -0
  5. package/dist/assets/Divider.js +343 -0
  6. package/dist/assets/IconButton.js +225 -0
  7. package/dist/assets/Inbox.js +3051 -0
  8. package/dist/assets/InboxHeader.js +2338 -0
  9. package/dist/assets/Notification.js +5349 -7150
  10. package/dist/assets/NotificationPreferencesPopup.js +1694 -0
  11. package/dist/assets/Paper.js +154 -0
  12. package/dist/assets/Popover.js +451 -0
  13. package/dist/assets/Portal.js +110 -0
  14. package/dist/assets/PreferenceInput.js +1545 -1366
  15. package/dist/assets/Typography.js +292 -0
  16. package/dist/assets/WebPushOptInMessage.js +794 -407
  17. package/dist/assets/channelUtils.js +33 -65
  18. package/dist/assets/createSimplePaletteValueFilter.js +17 -0
  19. package/dist/assets/createSvgIcon.js +248 -0
  20. package/dist/assets/integerPropType.js +31 -0
  21. package/dist/assets/resolveComponentProps.js +93 -0
  22. package/dist/assets/style.css +1 -0
  23. package/dist/assets/useSlotProps.js +24 -0
  24. package/dist/assets/useTheme.js +10 -0
  25. package/dist/assets/useTheme2.js +16 -0
  26. package/dist/assets/utils.js +743 -0
  27. package/dist/components/Notifications/DefaultEmpty.d.ts +3 -0
  28. package/dist/components/Notifications/DefaultEmpty.js +7 -0
  29. package/dist/components/Notifications/Inbox.d.ts +4 -4
  30. package/dist/components/Notifications/Inbox.js +9 -6450
  31. package/dist/components/Notifications/InboxHeader.d.ts +1 -1
  32. package/dist/components/Notifications/InboxHeader.js +7 -53
  33. package/dist/components/Notifications/Notification.d.ts +3 -4
  34. package/dist/components/Notifications/Notification.js +6 -5
  35. package/dist/components/Notifications/NotificationCounter.js +16 -6
  36. package/dist/components/Notifications/NotificationFeed.d.ts +1 -2
  37. package/dist/components/Notifications/NotificationFeed.js +41 -38
  38. package/dist/components/Notifications/NotificationLauncher.d.ts +1 -0
  39. package/dist/components/Notifications/NotificationLauncher.js +100 -114
  40. package/dist/components/Notifications/NotificationPopup.d.ts +3 -4
  41. package/dist/components/Notifications/NotificationPopup.js +86 -88
  42. package/dist/components/Notifications/UnreadBadge.d.ts +7 -4
  43. package/dist/components/Notifications/UnreadBadge.js +28 -20
  44. package/dist/components/Notifications/interface.d.ts +0 -4
  45. package/dist/components/Notifications/interface.js +4 -5
  46. package/dist/components/Preferences/NotificationPreferencesInline.js +14 -14
  47. package/dist/components/Preferences/NotificationPreferencesPopup.js +7 -2068
  48. package/dist/components/Preferences/PreferenceInput.js +4 -3
  49. package/dist/components/Preferences/Preferences.js +1042 -547
  50. package/dist/components/Preferences/channelUtils.js +3 -4
  51. package/dist/components/Preferences/index.js +1 -1
  52. package/dist/components/Provider/context.d.ts +27 -0
  53. package/dist/components/Provider/context.js +7 -0
  54. package/dist/components/Provider/index.d.ts +2 -25
  55. package/dist/components/Provider/index.js +22 -24
  56. package/dist/components/WebPush/WebPushOptInMessage.js +3 -4
  57. package/dist/main.d.ts +1 -0
  58. package/dist/main.js +4 -4
  59. package/package.json +14 -12
  60. package/dist/assets/AntdIcon.js +0 -200
  61. package/dist/assets/CloseOutlined.js +0 -13
  62. package/dist/assets/PurePanel.js +0 -59
  63. package/dist/assets/RightOutlined.js +0 -13
  64. package/dist/assets/button.js +0 -1660
  65. package/dist/assets/colors.js +0 -36
  66. package/dist/assets/compact-item.js +0 -860
  67. package/dist/assets/index.js +0 -271
  68. package/dist/assets/index2.js +0 -647
  69. package/dist/assets/index3.js +0 -7527
  70. package/dist/assets/pickAttrs.js +0 -42
  71. package/dist/assets/presets.js +0 -810
  72. package/dist/assets/reactNode.js +0 -20821
@@ -1,1660 +0,0 @@
1
- import * as ee from "react";
2
- import u, { forwardRef as ie, useState as ye, useRef as j, useEffect as ne, useMemo as te, useContext as he, Children as pt, createRef as Ct } from "react";
3
- import { c as L, b as _, e as Xe, _ as P, d as yt, f as U, a as fe } from "./presets.js";
4
- import { c as St, u as xt, g as Ht, d as $t, a as Et, o as Bt, W as _t } from "./compact-item.js";
5
- import { a as Ye, A as Ot, f as Ue, c as Rt, E as Lt, e as wt, o as Nt, F as Pt, b as Je, _ as Ke, v as Qe, m as ae, G as me, g as Dt, u as re, q as zt, H as It, D as jt, i as Tt } from "./reactNode.js";
6
- var At = function(e, t) {
7
- var r = {};
8
- for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && t.indexOf(o) < 0 && (r[o] = e[o]);
9
- if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var n = 0, o = Object.getOwnPropertySymbols(e); n < o.length; n++)
10
- t.indexOf(o[n]) < 0 && Object.prototype.propertyIsEnumerable.call(e, o[n]) && (r[o[n]] = e[o[n]]);
11
- return r;
12
- };
13
- const Ze = /* @__PURE__ */ ee.createContext(void 0), Mt = (e) => {
14
- const {
15
- getPrefixCls: t,
16
- direction: r
17
- } = ee.useContext(Ye), {
18
- prefixCls: o,
19
- size: n,
20
- className: i
21
- } = e, s = At(e, ["prefixCls", "size", "className"]), a = t("btn-group", o), [, , l] = Ot();
22
- let c = "";
23
- switch (n) {
24
- case "large":
25
- c = "lg";
26
- break;
27
- case "small":
28
- c = "sm";
29
- break;
30
- }
31
- if (process.env.NODE_ENV !== "production") {
32
- const g = Ue("Button.Group");
33
- process.env.NODE_ENV !== "production" && g(!n || ["large", "small", "middle"].includes(n), "usage", "Invalid prop `size`.");
34
- }
35
- const d = L(a, {
36
- [`${a}-${c}`]: c,
37
- [`${a}-rtl`]: r === "rtl"
38
- }, i, l);
39
- return /* @__PURE__ */ ee.createElement(Ze.Provider, {
40
- value: n
41
- }, /* @__PURE__ */ ee.createElement("div", Object.assign({}, s, {
42
- className: d
43
- })));
44
- }, Ge = /^[\u4E00-\u9FA5]{2}$/, Se = Ge.test.bind(Ge);
45
- function Ar(e) {
46
- return e === "danger" ? {
47
- danger: !0
48
- } : {
49
- type: e
50
- };
51
- }
52
- function We(e) {
53
- return typeof e == "string";
54
- }
55
- function oe(e) {
56
- return e === "text" || e === "link";
57
- }
58
- function Gt(e, t) {
59
- if (e == null)
60
- return;
61
- const r = t ? " " : "";
62
- return typeof e != "string" && typeof e != "number" && We(e.type) && Se(e.props.children) ? Rt(e, {
63
- children: e.props.children.split("").join(r)
64
- }) : We(e) ? Se(e) ? /* @__PURE__ */ u.createElement("span", null, e.split("").join(r)) : /* @__PURE__ */ u.createElement("span", null, e) : Lt(e) ? /* @__PURE__ */ u.createElement("span", null, e) : e;
65
- }
66
- function Wt(e, t) {
67
- let r = !1;
68
- const o = [];
69
- return u.Children.forEach(e, (n) => {
70
- const i = typeof n, s = i === "string" || i === "number";
71
- if (r && s) {
72
- const a = o.length - 1, l = o[a];
73
- o[a] = `${l}${n}`;
74
- } else
75
- o.push(n);
76
- r = s;
77
- }), u.Children.map(o, (n) => Gt(n, t));
78
- }
79
- const ke = /* @__PURE__ */ ie((e, t) => {
80
- const {
81
- className: r,
82
- style: o,
83
- children: n,
84
- prefixCls: i
85
- } = e, s = L(`${i}-icon`, r);
86
- return /* @__PURE__ */ u.createElement("span", {
87
- ref: t,
88
- className: s,
89
- style: o
90
- }, n);
91
- }), Ve = /* @__PURE__ */ ie((e, t) => {
92
- const {
93
- prefixCls: r,
94
- className: o,
95
- style: n,
96
- iconClassName: i
97
- } = e, s = L(`${r}-loading-icon`, o);
98
- return /* @__PURE__ */ u.createElement(ke, {
99
- prefixCls: r,
100
- className: s,
101
- style: n,
102
- ref: t
103
- }, /* @__PURE__ */ u.createElement(St, {
104
- className: i
105
- }));
106
- }), ve = () => ({
107
- width: 0,
108
- opacity: 0,
109
- transform: "scale(0)"
110
- }), be = (e) => ({
111
- width: e.scrollWidth,
112
- opacity: 1,
113
- transform: "scale(1)"
114
- }), Vt = (e) => {
115
- const {
116
- prefixCls: t,
117
- loading: r,
118
- existIcon: o,
119
- className: n,
120
- style: i
121
- } = e, s = !!r;
122
- return o ? /* @__PURE__ */ u.createElement(Ve, {
123
- prefixCls: t,
124
- className: n,
125
- style: i
126
- }) : /* @__PURE__ */ u.createElement(wt, {
127
- visible: s,
128
- // We do not really use this motionName
129
- motionName: `${t}-loading-icon-motion`,
130
- motionLeave: s,
131
- removeOnLeave: !0,
132
- onAppearStart: ve,
133
- onAppearActive: be,
134
- onEnterStart: ve,
135
- onEnterActive: be,
136
- onLeaveStart: be,
137
- onLeaveActive: ve
138
- }, (a, l) => {
139
- let {
140
- className: c,
141
- style: d
142
- } = a;
143
- return /* @__PURE__ */ u.createElement(Ve, {
144
- prefixCls: t,
145
- className: n,
146
- style: Object.assign(Object.assign({}, i), d),
147
- ref: l,
148
- iconClassName: c
149
- });
150
- });
151
- }, Fe = (e, t) => ({
152
- // Border
153
- [`> span, > ${e}`]: {
154
- "&:not(:last-child)": {
155
- [`&, & > ${e}`]: {
156
- "&:not(:disabled)": {
157
- borderInlineEndColor: t
158
- }
159
- }
160
- },
161
- "&:not(:first-child)": {
162
- [`&, & > ${e}`]: {
163
- "&:not(:disabled)": {
164
- borderInlineStartColor: t
165
- }
166
- }
167
- }
168
- }
169
- }), Ft = (e) => {
170
- const {
171
- componentCls: t,
172
- fontSize: r,
173
- lineWidth: o,
174
- groupBorderColor: n,
175
- colorErrorHover: i
176
- } = e;
177
- return {
178
- [`${t}-group`]: [
179
- {
180
- position: "relative",
181
- display: "inline-flex",
182
- // Border
183
- [`> span, > ${t}`]: {
184
- "&:not(:last-child)": {
185
- [`&, & > ${t}`]: {
186
- borderStartEndRadius: 0,
187
- borderEndEndRadius: 0
188
- }
189
- },
190
- "&:not(:first-child)": {
191
- marginInlineStart: e.calc(o).mul(-1).equal(),
192
- [`&, & > ${t}`]: {
193
- borderStartStartRadius: 0,
194
- borderEndStartRadius: 0
195
- }
196
- }
197
- },
198
- [t]: {
199
- position: "relative",
200
- zIndex: 1,
201
- "&:hover, &:focus, &:active": {
202
- zIndex: 2
203
- },
204
- "&[disabled]": {
205
- zIndex: 0
206
- }
207
- },
208
- [`${t}-icon-only`]: {
209
- fontSize: r
210
- }
211
- },
212
- // Border Color
213
- Fe(`${t}-primary`, n),
214
- Fe(`${t}-danger`, i)
215
- ]
216
- };
217
- }, $ = Math.round;
218
- function pe(e, t) {
219
- const r = e.replace(/^[^(]*\((.*)/, "$1").replace(/\).*/, "").match(/\d*\.?\d+%?/g) || [], o = r.map((n) => parseFloat(n));
220
- for (let n = 0; n < 3; n += 1)
221
- o[n] = t(o[n] || 0, r[n] || "", n);
222
- return r[3] ? o[3] = r[3].includes("%") ? o[3] / 100 : o[3] : o[3] = 1, o;
223
- }
224
- const qe = (e, t, r) => r === 0 ? e : e / 100;
225
- function k(e, t) {
226
- const r = t || 255;
227
- return e > r ? r : e < 0 ? 0 : e;
228
- }
229
- class se {
230
- constructor(t) {
231
- _(this, "isValid", !0), _(this, "r", 0), _(this, "g", 0), _(this, "b", 0), _(this, "a", 1), _(this, "_h", void 0), _(this, "_s", void 0), _(this, "_l", void 0), _(this, "_v", void 0), _(this, "_max", void 0), _(this, "_min", void 0), _(this, "_brightness", void 0);
232
- function r(o) {
233
- return o[0] in t && o[1] in t && o[2] in t;
234
- }
235
- if (t) if (typeof t == "string") {
236
- let n = function(i) {
237
- return o.startsWith(i);
238
- };
239
- const o = t.trim();
240
- /^#?[A-F\d]{3,8}$/i.test(o) ? this.fromHexString(o) : n("rgb") ? this.fromRgbString(o) : n("hsl") ? this.fromHslString(o) : (n("hsv") || n("hsb")) && this.fromHsvString(o);
241
- } else if (t instanceof se)
242
- this.r = t.r, this.g = t.g, this.b = t.b, this.a = t.a, this._h = t._h, this._s = t._s, this._l = t._l, this._v = t._v;
243
- else if (r("rgb"))
244
- this.r = k(t.r), this.g = k(t.g), this.b = k(t.b), this.a = typeof t.a == "number" ? k(t.a, 1) : 1;
245
- else if (r("hsl"))
246
- this.fromHsl(t);
247
- else if (r("hsv"))
248
- this.fromHsv(t);
249
- else
250
- throw new Error("@ant-design/fast-color: unsupported input " + JSON.stringify(t));
251
- }
252
- // ======================= Setter =======================
253
- setR(t) {
254
- return this._sc("r", t);
255
- }
256
- setG(t) {
257
- return this._sc("g", t);
258
- }
259
- setB(t) {
260
- return this._sc("b", t);
261
- }
262
- setA(t) {
263
- return this._sc("a", t, 1);
264
- }
265
- setHue(t) {
266
- const r = this.toHsv();
267
- return r.h = t, this._c(r);
268
- }
269
- // ======================= Getter =======================
270
- /**
271
- * Returns the perceived luminance of a color, from 0-1.
272
- * @see http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
273
- */
274
- getLuminance() {
275
- function t(i) {
276
- const s = i / 255;
277
- return s <= 0.03928 ? s / 12.92 : Math.pow((s + 0.055) / 1.055, 2.4);
278
- }
279
- const r = t(this.r), o = t(this.g), n = t(this.b);
280
- return 0.2126 * r + 0.7152 * o + 0.0722 * n;
281
- }
282
- getHue() {
283
- if (typeof this._h > "u") {
284
- const t = this.getMax() - this.getMin();
285
- t === 0 ? this._h = 0 : this._h = $(60 * (this.r === this.getMax() ? (this.g - this.b) / t + (this.g < this.b ? 6 : 0) : this.g === this.getMax() ? (this.b - this.r) / t + 2 : (this.r - this.g) / t + 4));
286
- }
287
- return this._h;
288
- }
289
- getSaturation() {
290
- if (typeof this._s > "u") {
291
- const t = this.getMax() - this.getMin();
292
- t === 0 ? this._s = 0 : this._s = t / this.getMax();
293
- }
294
- return this._s;
295
- }
296
- getLightness() {
297
- return typeof this._l > "u" && (this._l = (this.getMax() + this.getMin()) / 510), this._l;
298
- }
299
- getValue() {
300
- return typeof this._v > "u" && (this._v = this.getMax() / 255), this._v;
301
- }
302
- /**
303
- * Returns the perceived brightness of the color, from 0-255.
304
- * Note: this is not the b of HSB
305
- * @see http://www.w3.org/TR/AERT#color-contrast
306
- */
307
- getBrightness() {
308
- return typeof this._brightness > "u" && (this._brightness = (this.r * 299 + this.g * 587 + this.b * 114) / 1e3), this._brightness;
309
- }
310
- // ======================== Func ========================
311
- darken(t = 10) {
312
- const r = this.getHue(), o = this.getSaturation();
313
- let n = this.getLightness() - t / 100;
314
- return n < 0 && (n = 0), this._c({
315
- h: r,
316
- s: o,
317
- l: n,
318
- a: this.a
319
- });
320
- }
321
- lighten(t = 10) {
322
- const r = this.getHue(), o = this.getSaturation();
323
- let n = this.getLightness() + t / 100;
324
- return n > 1 && (n = 1), this._c({
325
- h: r,
326
- s: o,
327
- l: n,
328
- a: this.a
329
- });
330
- }
331
- /**
332
- * Mix the current color a given amount with another color, from 0 to 100.
333
- * 0 means no mixing (return current color).
334
- */
335
- mix(t, r = 50) {
336
- const o = this._c(t), n = r / 100, i = (a) => (o[a] - this[a]) * n + this[a], s = {
337
- r: $(i("r")),
338
- g: $(i("g")),
339
- b: $(i("b")),
340
- a: $(i("a") * 100) / 100
341
- };
342
- return this._c(s);
343
- }
344
- /**
345
- * Mix the color with pure white, from 0 to 100.
346
- * Providing 0 will do nothing, providing 100 will always return white.
347
- */
348
- tint(t = 10) {
349
- return this.mix({
350
- r: 255,
351
- g: 255,
352
- b: 255,
353
- a: 1
354
- }, t);
355
- }
356
- /**
357
- * Mix the color with pure black, from 0 to 100.
358
- * Providing 0 will do nothing, providing 100 will always return black.
359
- */
360
- shade(t = 10) {
361
- return this.mix({
362
- r: 0,
363
- g: 0,
364
- b: 0,
365
- a: 1
366
- }, t);
367
- }
368
- onBackground(t) {
369
- const r = this._c(t), o = this.a + r.a * (1 - this.a), n = (i) => $((this[i] * this.a + r[i] * r.a * (1 - this.a)) / o);
370
- return this._c({
371
- r: n("r"),
372
- g: n("g"),
373
- b: n("b"),
374
- a: o
375
- });
376
- }
377
- // ======================= Status =======================
378
- isDark() {
379
- return this.getBrightness() < 128;
380
- }
381
- isLight() {
382
- return this.getBrightness() >= 128;
383
- }
384
- // ======================== MISC ========================
385
- equals(t) {
386
- return this.r === t.r && this.g === t.g && this.b === t.b && this.a === t.a;
387
- }
388
- clone() {
389
- return this._c(this);
390
- }
391
- // ======================= Format =======================
392
- toHexString() {
393
- let t = "#";
394
- const r = (this.r || 0).toString(16);
395
- t += r.length === 2 ? r : "0" + r;
396
- const o = (this.g || 0).toString(16);
397
- t += o.length === 2 ? o : "0" + o;
398
- const n = (this.b || 0).toString(16);
399
- if (t += n.length === 2 ? n : "0" + n, typeof this.a == "number" && this.a >= 0 && this.a < 1) {
400
- const i = $(this.a * 255).toString(16);
401
- t += i.length === 2 ? i : "0" + i;
402
- }
403
- return t;
404
- }
405
- /** CSS support color pattern */
406
- toHsl() {
407
- return {
408
- h: this.getHue(),
409
- s: this.getSaturation(),
410
- l: this.getLightness(),
411
- a: this.a
412
- };
413
- }
414
- /** CSS support color pattern */
415
- toHslString() {
416
- const t = this.getHue(), r = $(this.getSaturation() * 100), o = $(this.getLightness() * 100);
417
- return this.a !== 1 ? `hsla(${t},${r}%,${o}%,${this.a})` : `hsl(${t},${r}%,${o}%)`;
418
- }
419
- /** Same as toHsb */
420
- toHsv() {
421
- return {
422
- h: this.getHue(),
423
- s: this.getSaturation(),
424
- v: this.getValue(),
425
- a: this.a
426
- };
427
- }
428
- toRgb() {
429
- return {
430
- r: this.r,
431
- g: this.g,
432
- b: this.b,
433
- a: this.a
434
- };
435
- }
436
- toRgbString() {
437
- return this.a !== 1 ? `rgba(${this.r},${this.g},${this.b},${this.a})` : `rgb(${this.r},${this.g},${this.b})`;
438
- }
439
- toString() {
440
- return this.toRgbString();
441
- }
442
- // ====================== Privates ======================
443
- /** Return a new FastColor object with one channel changed */
444
- _sc(t, r, o) {
445
- const n = this.clone();
446
- return n[t] = k(r, o), n;
447
- }
448
- _c(t) {
449
- return new this.constructor(t);
450
- }
451
- getMax() {
452
- return typeof this._max > "u" && (this._max = Math.max(this.r, this.g, this.b)), this._max;
453
- }
454
- getMin() {
455
- return typeof this._min > "u" && (this._min = Math.min(this.r, this.g, this.b)), this._min;
456
- }
457
- fromHexString(t) {
458
- const r = t.replace("#", "");
459
- function o(n, i) {
460
- return parseInt(r[n] + r[i || n], 16);
461
- }
462
- r.length < 6 ? (this.r = o(0), this.g = o(1), this.b = o(2), this.a = r[3] ? o(3) / 255 : 1) : (this.r = o(0, 1), this.g = o(2, 3), this.b = o(4, 5), this.a = r[6] ? o(6, 7) / 255 : 1);
463
- }
464
- fromHsl({
465
- h: t,
466
- s: r,
467
- l: o,
468
- a: n
469
- }) {
470
- if (this._h = t % 360, this._s = r, this._l = o, this.a = typeof n == "number" ? n : 1, r <= 0) {
471
- const b = $(o * 255);
472
- this.r = b, this.g = b, this.b = b;
473
- }
474
- let i = 0, s = 0, a = 0;
475
- const l = t / 60, c = (1 - Math.abs(2 * o - 1)) * r, d = c * (1 - Math.abs(l % 2 - 1));
476
- l >= 0 && l < 1 ? (i = c, s = d) : l >= 1 && l < 2 ? (i = d, s = c) : l >= 2 && l < 3 ? (s = c, a = d) : l >= 3 && l < 4 ? (s = d, a = c) : l >= 4 && l < 5 ? (i = d, a = c) : l >= 5 && l < 6 && (i = c, a = d);
477
- const g = o - c / 2;
478
- this.r = $((i + g) * 255), this.g = $((s + g) * 255), this.b = $((a + g) * 255);
479
- }
480
- fromHsv({
481
- h: t,
482
- s: r,
483
- v: o,
484
- a: n
485
- }) {
486
- this._h = t % 360, this._s = r, this._v = o, this.a = typeof n == "number" ? n : 1;
487
- const i = $(o * 255);
488
- if (this.r = i, this.g = i, this.b = i, r <= 0)
489
- return;
490
- const s = t / 60, a = Math.floor(s), l = s - a, c = $(o * (1 - r) * 255), d = $(o * (1 - r * l) * 255), g = $(o * (1 - r * (1 - l)) * 255);
491
- switch (a) {
492
- case 0:
493
- this.g = g, this.b = c;
494
- break;
495
- case 1:
496
- this.r = d, this.b = c;
497
- break;
498
- case 2:
499
- this.r = c, this.b = g;
500
- break;
501
- case 3:
502
- this.r = c, this.g = d;
503
- break;
504
- case 4:
505
- this.r = g, this.g = c;
506
- break;
507
- case 5:
508
- default:
509
- this.g = c, this.b = d;
510
- break;
511
- }
512
- }
513
- fromHsvString(t) {
514
- const r = pe(t, qe);
515
- this.fromHsv({
516
- h: r[0],
517
- s: r[1],
518
- v: r[2],
519
- a: r[3]
520
- });
521
- }
522
- fromHslString(t) {
523
- const r = pe(t, qe);
524
- this.fromHsl({
525
- h: r[0],
526
- s: r[1],
527
- l: r[2],
528
- a: r[3]
529
- });
530
- }
531
- fromRgbString(t) {
532
- const r = pe(t, (o, n) => (
533
- // Convert percentage to number. e.g. 50% -> 128
534
- n.includes("%") ? $(o / 100 * 255) : o
535
- ));
536
- this.r = r[0], this.g = r[1], this.b = r[2], this.a = r[3];
537
- }
538
- }
539
- var qt = ["b"], Xt = ["v"], Ce = function(t) {
540
- return Math.round(Number(t || 0));
541
- }, Yt = function(t) {
542
- if (t instanceof se)
543
- return t;
544
- if (t && yt(t) === "object" && "h" in t && "b" in t) {
545
- var r = t, o = r.b, n = Xe(r, qt);
546
- return P(P({}, n), {}, {
547
- v: o
548
- });
549
- }
550
- return typeof t == "string" && /hsb/.test(t) ? t.replace(/hsb/, "hsv") : t;
551
- }, D = /* @__PURE__ */ function(e) {
552
- Nt(r, e);
553
- var t = Pt(r);
554
- function r(o) {
555
- return Je(this, r), t.call(this, Yt(o));
556
- }
557
- return Ke(r, [{
558
- key: "toHsbString",
559
- value: function() {
560
- var n = this.toHsb(), i = Ce(n.s * 100), s = Ce(n.b * 100), a = Ce(n.h), l = n.a, c = "hsb(".concat(a, ", ").concat(i, "%, ").concat(s, "%)"), d = "hsba(".concat(a, ", ").concat(i, "%, ").concat(s, "%, ").concat(l.toFixed(l === 0 ? 0 : 2), ")");
561
- return l === 1 ? c : d;
562
- }
563
- }, {
564
- key: "toHsb",
565
- value: function() {
566
- var n = this.toHsv(), i = n.v, s = Xe(n, Xt);
567
- return P(P({}, s), {}, {
568
- b: i,
569
- a: this.a
570
- });
571
- }
572
- }]), r;
573
- }(se), Ut = "rc-color-picker", Y = function(t) {
574
- return t instanceof D ? t : new D(t);
575
- }, Jt = Y("#1677ff"), et = function(t) {
576
- var r = t.offset, o = t.targetRef, n = t.containerRef, i = t.color, s = t.type, a = n.current.getBoundingClientRect(), l = a.width, c = a.height, d = o.current.getBoundingClientRect(), g = d.width, b = d.height, f = g / 2, p = b / 2, E = (r.x + f) / l, B = 1 - (r.y + p) / c, S = i.toHsb(), x = E, O = (r.x + f) / l * 360;
577
- if (s)
578
- switch (s) {
579
- case "hue":
580
- return Y(P(P({}, S), {}, {
581
- h: O <= 0 ? 0 : O
582
- }));
583
- case "alpha":
584
- return Y(P(P({}, S), {}, {
585
- a: x <= 0 ? 0 : x
586
- }));
587
- }
588
- return Y({
589
- h: S.h,
590
- s: E <= 0 ? 0 : E,
591
- b: B >= 1 ? 1 : B,
592
- a: S.a
593
- });
594
- }, tt = function(t, r) {
595
- var o = t.toHsb();
596
- switch (r) {
597
- case "hue":
598
- return {
599
- x: o.h / 360 * 100,
600
- y: 50
601
- };
602
- case "alpha":
603
- return {
604
- x: t.a * 100,
605
- y: 50
606
- };
607
- default:
608
- return {
609
- x: o.s * 100,
610
- y: (1 - o.b) * 100
611
- };
612
- }
613
- }, Kt = function(t) {
614
- var r = t.color, o = t.prefixCls, n = t.className, i = t.style, s = t.onClick, a = "".concat(o, "-color-block");
615
- return /* @__PURE__ */ u.createElement("div", {
616
- className: L(a, n),
617
- style: i,
618
- onClick: s
619
- }, /* @__PURE__ */ u.createElement("div", {
620
- className: "".concat(a, "-inner"),
621
- style: {
622
- background: r
623
- }
624
- }));
625
- };
626
- function Qt(e) {
627
- var t = "touches" in e ? e.touches[0] : e, r = document.documentElement.scrollLeft || document.body.scrollLeft || window.pageXOffset, o = document.documentElement.scrollTop || document.body.scrollTop || window.pageYOffset;
628
- return {
629
- pageX: t.pageX - r,
630
- pageY: t.pageY - o
631
- };
632
- }
633
- function rt(e) {
634
- var t = e.targetRef, r = e.containerRef, o = e.direction, n = e.onDragChange, i = e.onDragChangeComplete, s = e.calculate, a = e.color, l = e.disabledDrag, c = ye({
635
- x: 0,
636
- y: 0
637
- }), d = U(c, 2), g = d[0], b = d[1], f = j(null), p = j(null);
638
- ne(function() {
639
- b(s());
640
- }, [a]), ne(function() {
641
- return function() {
642
- document.removeEventListener("mousemove", f.current), document.removeEventListener("mouseup", p.current), document.removeEventListener("touchmove", f.current), document.removeEventListener("touchend", p.current), f.current = null, p.current = null;
643
- };
644
- }, []);
645
- var E = function(h) {
646
- var y = Qt(h), K = y.pageX, T = y.pageY, w = r.current.getBoundingClientRect(), z = w.x, A = w.y, M = w.width, F = w.height, R = t.current.getBoundingClientRect(), q = R.width, I = R.height, G = q / 2, W = I / 2, m = Math.max(0, Math.min(K - z, M)) - G, C = Math.max(0, Math.min(T - A, F)) - W, v = {
647
- x: m,
648
- y: o === "x" ? g.y : C
649
- };
650
- if (q === 0 && I === 0 || q !== I)
651
- return !1;
652
- n == null || n(v);
653
- }, B = function(h) {
654
- h.preventDefault(), E(h);
655
- }, S = function(h) {
656
- h.preventDefault(), document.removeEventListener("mousemove", f.current), document.removeEventListener("mouseup", p.current), document.removeEventListener("touchmove", f.current), document.removeEventListener("touchend", p.current), f.current = null, p.current = null, i == null || i();
657
- }, x = function(h) {
658
- document.removeEventListener("mousemove", f.current), document.removeEventListener("mouseup", p.current), !l && (E(h), document.addEventListener("mousemove", B), document.addEventListener("mouseup", S), document.addEventListener("touchmove", B), document.addEventListener("touchend", S), f.current = B, p.current = S);
659
- };
660
- return [g, x];
661
- }
662
- var ot = function(t) {
663
- var r = t.size, o = r === void 0 ? "default" : r, n = t.color, i = t.prefixCls;
664
- return /* @__PURE__ */ u.createElement("div", {
665
- className: L("".concat(i, "-handler"), _({}, "".concat(i, "-handler-sm"), o === "small")),
666
- style: {
667
- backgroundColor: n
668
- }
669
- });
670
- }, nt = function(t) {
671
- var r = t.children, o = t.style, n = t.prefixCls;
672
- return /* @__PURE__ */ u.createElement("div", {
673
- className: "".concat(n, "-palette"),
674
- style: P({
675
- position: "relative"
676
- }, o)
677
- }, r);
678
- }, it = /* @__PURE__ */ ie(function(e, t) {
679
- var r = e.children, o = e.x, n = e.y;
680
- return /* @__PURE__ */ u.createElement("div", {
681
- ref: t,
682
- style: {
683
- position: "absolute",
684
- left: "".concat(o, "%"),
685
- top: "".concat(n, "%"),
686
- zIndex: 1,
687
- transform: "translate(-50%, -50%)"
688
- }
689
- }, r);
690
- }), Zt = function(t) {
691
- var r = t.color, o = t.onChange, n = t.prefixCls, i = t.onChangeComplete, s = t.disabled, a = j(), l = j(), c = j(r), d = Qe(function(E) {
692
- var B = et({
693
- offset: E,
694
- targetRef: l,
695
- containerRef: a,
696
- color: r
697
- });
698
- c.current = B, o(B);
699
- }), g = rt({
700
- color: r,
701
- containerRef: a,
702
- targetRef: l,
703
- calculate: function() {
704
- return tt(r);
705
- },
706
- onDragChange: d,
707
- onDragChangeComplete: function() {
708
- return i == null ? void 0 : i(c.current);
709
- },
710
- disabledDrag: s
711
- }), b = U(g, 2), f = b[0], p = b[1];
712
- return /* @__PURE__ */ u.createElement("div", {
713
- ref: a,
714
- className: "".concat(n, "-select"),
715
- onMouseDown: p,
716
- onTouchStart: p
717
- }, /* @__PURE__ */ u.createElement(nt, {
718
- prefixCls: n
719
- }, /* @__PURE__ */ u.createElement(it, {
720
- x: f.x,
721
- y: f.y,
722
- ref: l
723
- }, /* @__PURE__ */ u.createElement(ot, {
724
- color: r.toRgbString(),
725
- prefixCls: n
726
- })), /* @__PURE__ */ u.createElement("div", {
727
- className: "".concat(n, "-saturation"),
728
- style: {
729
- backgroundColor: "hsl(".concat(r.toHsb().h, ",100%, 50%)"),
730
- backgroundImage: "linear-gradient(0deg, #000, transparent),linear-gradient(90deg, #fff, hsla(0, 0%, 100%, 0))"
731
- }
732
- })));
733
- }, kt = function(t, r) {
734
- var o = xt(t, {
735
- value: r
736
- }), n = U(o, 2), i = n[0], s = n[1], a = te(function() {
737
- return Y(i);
738
- }, [i]);
739
- return [a, s];
740
- }, er = function(t) {
741
- var r = t.colors, o = t.children, n = t.direction, i = n === void 0 ? "to right" : n, s = t.type, a = t.prefixCls, l = te(function() {
742
- return r.map(function(c, d) {
743
- var g = Y(c);
744
- return s === "alpha" && d === r.length - 1 && (g = new D(g.setA(1))), g.toRgbString();
745
- }).join(",");
746
- }, [r, s]);
747
- return /* @__PURE__ */ u.createElement("div", {
748
- className: "".concat(a, "-gradient"),
749
- style: {
750
- position: "absolute",
751
- inset: 0,
752
- background: "linear-gradient(".concat(i, ", ").concat(l, ")")
753
- }
754
- }, o);
755
- }, tr = function(t) {
756
- var r = t.prefixCls, o = t.colors, n = t.disabled, i = t.onChange, s = t.onChangeComplete, a = t.color, l = t.type, c = j(), d = j(), g = j(a), b = function(y) {
757
- return l === "hue" ? y.getHue() : y.a * 100;
758
- }, f = Qe(function(h) {
759
- var y = et({
760
- offset: h,
761
- targetRef: d,
762
- containerRef: c,
763
- color: a,
764
- type: l
765
- });
766
- g.current = y, i(b(y));
767
- }), p = rt({
768
- color: a,
769
- targetRef: d,
770
- containerRef: c,
771
- calculate: function() {
772
- return tt(a, l);
773
- },
774
- onDragChange: f,
775
- onDragChangeComplete: function() {
776
- s(b(g.current));
777
- },
778
- direction: "x",
779
- disabledDrag: n
780
- }), E = U(p, 2), B = E[0], S = E[1], x = u.useMemo(function() {
781
- if (l === "hue") {
782
- var h = a.toHsb();
783
- h.s = 1, h.b = 1, h.a = 1;
784
- var y = new D(h);
785
- return y;
786
- }
787
- return a;
788
- }, [a, l]), O = u.useMemo(function() {
789
- return o.map(function(h) {
790
- return "".concat(h.color, " ").concat(h.percent, "%");
791
- });
792
- }, [o]);
793
- return /* @__PURE__ */ u.createElement("div", {
794
- ref: c,
795
- className: L("".concat(r, "-slider"), "".concat(r, "-slider-").concat(l)),
796
- onMouseDown: S,
797
- onTouchStart: S
798
- }, /* @__PURE__ */ u.createElement(nt, {
799
- prefixCls: r
800
- }, /* @__PURE__ */ u.createElement(it, {
801
- x: B.x,
802
- y: B.y,
803
- ref: d
804
- }, /* @__PURE__ */ u.createElement(ot, {
805
- size: "small",
806
- color: x.toHexString(),
807
- prefixCls: r
808
- })), /* @__PURE__ */ u.createElement(er, {
809
- colors: O,
810
- type: l,
811
- prefixCls: r
812
- })));
813
- };
814
- function rr(e) {
815
- return ee.useMemo(function() {
816
- var t = e || {}, r = t.slider;
817
- return [r || tr];
818
- }, [e]);
819
- }
820
- var or = [{
821
- color: "rgb(255, 0, 0)",
822
- percent: 0
823
- }, {
824
- color: "rgb(255, 255, 0)",
825
- percent: 17
826
- }, {
827
- color: "rgb(0, 255, 0)",
828
- percent: 33
829
- }, {
830
- color: "rgb(0, 255, 255)",
831
- percent: 50
832
- }, {
833
- color: "rgb(0, 0, 255)",
834
- percent: 67
835
- }, {
836
- color: "rgb(255, 0, 255)",
837
- percent: 83
838
- }, {
839
- color: "rgb(255, 0, 0)",
840
- percent: 100
841
- }], nr = /* @__PURE__ */ ie(function(e, t) {
842
- var r = e.value, o = e.defaultValue, n = e.prefixCls, i = n === void 0 ? Ut : n, s = e.onChange, a = e.onChangeComplete, l = e.className, c = e.style, d = e.panelRender, g = e.disabledAlpha, b = g === void 0 ? !1 : g, f = e.disabled, p = f === void 0 ? !1 : f, E = e.components, B = rr(E), S = U(B, 1), x = S[0], O = kt(o || Jt, r), h = U(O, 2), y = h[0], K = h[1], T = te(function() {
843
- return y.setA(1).toRgbString();
844
- }, [y]), w = function(C, v) {
845
- r || K(C), s == null || s(C, v);
846
- }, z = function(C) {
847
- return new D(y.setHue(C));
848
- }, A = function(C) {
849
- return new D(y.setA(C / 100));
850
- }, M = function(C) {
851
- w(z(C), {
852
- type: "hue",
853
- value: C
854
- });
855
- }, F = function(C) {
856
- w(A(C), {
857
- type: "alpha",
858
- value: C
859
- });
860
- }, R = function(C) {
861
- a && a(z(C));
862
- }, q = function(C) {
863
- a && a(A(C));
864
- }, I = L("".concat(i, "-panel"), l, _({}, "".concat(i, "-panel-disabled"), p)), G = {
865
- prefixCls: i,
866
- disabled: p,
867
- color: y
868
- }, W = /* @__PURE__ */ u.createElement(u.Fragment, null, /* @__PURE__ */ u.createElement(Zt, fe({
869
- onChange: w
870
- }, G, {
871
- onChangeComplete: a
872
- })), /* @__PURE__ */ u.createElement("div", {
873
- className: "".concat(i, "-slider-container")
874
- }, /* @__PURE__ */ u.createElement("div", {
875
- className: L("".concat(i, "-slider-group"), _({}, "".concat(i, "-slider-group-disabled-alpha"), b))
876
- }, /* @__PURE__ */ u.createElement(x, fe({}, G, {
877
- type: "hue",
878
- colors: or,
879
- min: 0,
880
- max: 359,
881
- value: y.getHue(),
882
- onChange: M,
883
- onChangeComplete: R
884
- })), !b && /* @__PURE__ */ u.createElement(x, fe({}, G, {
885
- type: "alpha",
886
- colors: [{
887
- percent: 0,
888
- color: "rgba(255, 0, 4, 0)"
889
- }, {
890
- percent: 100,
891
- color: T
892
- }],
893
- min: 0,
894
- max: 100,
895
- value: y.a * 100,
896
- onChange: F,
897
- onChangeComplete: q
898
- }))), /* @__PURE__ */ u.createElement(Kt, {
899
- color: y.toRgbString(),
900
- prefixCls: i
901
- })));
902
- return /* @__PURE__ */ u.createElement("div", {
903
- className: I,
904
- style: c,
905
- ref: t
906
- }, typeof d == "function" ? d(W) : W);
907
- });
908
- process.env.NODE_ENV !== "production" && (nr.displayName = "ColorPicker");
909
- const ir = (e, t) => (e == null ? void 0 : e.replace(/[^\w/]/g, "").slice(0, t ? 8 : 6)) || "", ar = (e, t) => e ? ir(e, t) : "";
910
- let sr = /* @__PURE__ */ function() {
911
- function e(t) {
912
- Je(this, e);
913
- var r;
914
- if (this.cleared = !1, t instanceof e) {
915
- this.metaColor = t.metaColor.clone(), this.colors = (r = t.colors) === null || r === void 0 ? void 0 : r.map((n) => ({
916
- color: new e(n.color),
917
- percent: n.percent
918
- })), this.cleared = t.cleared;
919
- return;
920
- }
921
- const o = Array.isArray(t);
922
- o && t.length ? (this.colors = t.map((n) => {
923
- let {
924
- color: i,
925
- percent: s
926
- } = n;
927
- return {
928
- color: new e(i),
929
- percent: s
930
- };
931
- }), this.metaColor = new D(this.colors[0].color.metaColor)) : this.metaColor = new D(o ? "" : t), (!t || o && !this.colors) && (this.metaColor = this.metaColor.setA(0), this.cleared = !0);
932
- }
933
- return Ke(e, [{
934
- key: "toHsb",
935
- value: function() {
936
- return this.metaColor.toHsb();
937
- }
938
- }, {
939
- key: "toHsbString",
940
- value: function() {
941
- return this.metaColor.toHsbString();
942
- }
943
- }, {
944
- key: "toHex",
945
- value: function() {
946
- return ar(this.toHexString(), this.metaColor.a < 1);
947
- }
948
- }, {
949
- key: "toHexString",
950
- value: function() {
951
- return this.metaColor.toHexString();
952
- }
953
- }, {
954
- key: "toRgb",
955
- value: function() {
956
- return this.metaColor.toRgb();
957
- }
958
- }, {
959
- key: "toRgbString",
960
- value: function() {
961
- return this.metaColor.toRgbString();
962
- }
963
- }, {
964
- key: "isGradient",
965
- value: function() {
966
- return !!this.colors && !this.cleared;
967
- }
968
- }, {
969
- key: "getColors",
970
- value: function() {
971
- return this.colors || [{
972
- color: this,
973
- percent: 0
974
- }];
975
- }
976
- }, {
977
- key: "toCssString",
978
- value: function() {
979
- const {
980
- colors: r
981
- } = this;
982
- return r ? `linear-gradient(90deg, ${r.map((n) => `${n.color.toRgbString()} ${n.percent}%`).join(", ")})` : this.metaColor.toRgbString();
983
- }
984
- }, {
985
- key: "equals",
986
- value: function(r) {
987
- return !r || this.isGradient() !== r.isGradient() ? !1 : this.isGradient() ? this.colors.length === r.colors.length && this.colors.every((o, n) => {
988
- const i = r.colors[n];
989
- return o.percent === i.percent && o.color.equals(i.color);
990
- }) : this.toHexString() === r.toHexString();
991
- }
992
- }]);
993
- }();
994
- const lr = (e, t) => {
995
- const {
996
- r,
997
- g: o,
998
- b: n,
999
- a: i
1000
- } = e.toRgb(), s = new D(e.toRgbString()).onBackground(t).toHsv();
1001
- return i <= 0.5 ? s.v > 0.5 : r * 0.299 + o * 0.587 + n * 0.114 > 192;
1002
- }, at = (e) => {
1003
- const {
1004
- paddingInline: t,
1005
- onlyIconSize: r,
1006
- paddingBlock: o
1007
- } = e;
1008
- return ae(e, {
1009
- buttonPaddingHorizontal: t,
1010
- buttonPaddingVertical: o,
1011
- buttonIconOnlyFontSize: r
1012
- });
1013
- }, st = (e) => {
1014
- var t, r, o, n, i, s;
1015
- const a = (t = e.contentFontSize) !== null && t !== void 0 ? t : e.fontSize, l = (r = e.contentFontSizeSM) !== null && r !== void 0 ? r : e.fontSize, c = (o = e.contentFontSizeLG) !== null && o !== void 0 ? o : e.fontSizeLG, d = (n = e.contentLineHeight) !== null && n !== void 0 ? n : me(a), g = (i = e.contentLineHeightSM) !== null && i !== void 0 ? i : me(l), b = (s = e.contentLineHeightLG) !== null && s !== void 0 ? s : me(c), f = lr(new sr(e.colorBgSolid), "#fff") ? "#000" : "#fff";
1016
- return {
1017
- fontWeight: 400,
1018
- defaultShadow: `0 ${e.controlOutlineWidth}px 0 ${e.controlTmpOutline}`,
1019
- primaryShadow: `0 ${e.controlOutlineWidth}px 0 ${e.controlOutline}`,
1020
- dangerShadow: `0 ${e.controlOutlineWidth}px 0 ${e.colorErrorOutline}`,
1021
- primaryColor: e.colorTextLightSolid,
1022
- dangerColor: e.colorTextLightSolid,
1023
- borderColorDisabled: e.colorBorder,
1024
- defaultGhostColor: e.colorBgContainer,
1025
- ghostBg: "transparent",
1026
- defaultGhostBorderColor: e.colorBgContainer,
1027
- paddingInline: e.paddingContentHorizontal - e.lineWidth,
1028
- paddingInlineLG: e.paddingContentHorizontal - e.lineWidth,
1029
- paddingInlineSM: 8 - e.lineWidth,
1030
- onlyIconSize: e.fontSizeLG,
1031
- onlyIconSizeSM: e.fontSizeLG - 2,
1032
- onlyIconSizeLG: e.fontSizeLG + 2,
1033
- groupBorderColor: e.colorPrimaryHover,
1034
- linkHoverBg: "transparent",
1035
- textTextColor: e.colorText,
1036
- textTextHoverColor: e.colorText,
1037
- textTextActiveColor: e.colorText,
1038
- textHoverBg: e.colorBgTextHover,
1039
- defaultColor: e.colorText,
1040
- defaultBg: e.colorBgContainer,
1041
- defaultBorderColor: e.colorBorder,
1042
- defaultBorderColorDisabled: e.colorBorder,
1043
- defaultHoverBg: e.colorBgContainer,
1044
- defaultHoverColor: e.colorPrimaryHover,
1045
- defaultHoverBorderColor: e.colorPrimaryHover,
1046
- defaultActiveBg: e.colorBgContainer,
1047
- defaultActiveColor: e.colorPrimaryActive,
1048
- defaultActiveBorderColor: e.colorPrimaryActive,
1049
- solidTextColor: f,
1050
- contentFontSize: a,
1051
- contentFontSizeSM: l,
1052
- contentFontSizeLG: c,
1053
- contentLineHeight: d,
1054
- contentLineHeightSM: g,
1055
- contentLineHeightLG: b,
1056
- paddingBlock: Math.max((e.controlHeight - a * d) / 2 - e.lineWidth, 0),
1057
- paddingBlockSM: Math.max((e.controlHeightSM - l * g) / 2 - e.lineWidth, 0),
1058
- paddingBlockLG: Math.max((e.controlHeightLG - c * b) / 2 - e.lineWidth, 0)
1059
- };
1060
- }, cr = (e) => {
1061
- const {
1062
- componentCls: t,
1063
- iconCls: r,
1064
- fontWeight: o
1065
- } = e;
1066
- return {
1067
- [t]: {
1068
- outline: "none",
1069
- position: "relative",
1070
- display: "inline-flex",
1071
- gap: e.marginXS,
1072
- alignItems: "center",
1073
- justifyContent: "center",
1074
- fontWeight: o,
1075
- whiteSpace: "nowrap",
1076
- textAlign: "center",
1077
- backgroundImage: "none",
1078
- background: "transparent",
1079
- border: `${re(e.lineWidth)} ${e.lineType} transparent`,
1080
- cursor: "pointer",
1081
- transition: `all ${e.motionDurationMid} ${e.motionEaseInOut}`,
1082
- userSelect: "none",
1083
- touchAction: "manipulation",
1084
- color: e.colorText,
1085
- "&:disabled > *": {
1086
- pointerEvents: "none"
1087
- },
1088
- "> span": {
1089
- display: "inline-block"
1090
- },
1091
- [`${t}-icon`]: {
1092
- lineHeight: 1
1093
- },
1094
- "> a": {
1095
- color: "currentColor"
1096
- },
1097
- "&:not(:disabled)": Object.assign({}, zt(e)),
1098
- [`&${t}-two-chinese-chars::first-letter`]: {
1099
- letterSpacing: "0.34em"
1100
- },
1101
- [`&${t}-two-chinese-chars > *:not(${r})`]: {
1102
- marginInlineEnd: "-0.34em",
1103
- letterSpacing: "0.34em"
1104
- },
1105
- // iconPosition="end"
1106
- "&-icon-end": {
1107
- flexDirection: "row-reverse"
1108
- }
1109
- }
1110
- };
1111
- }, lt = (e, t, r) => ({
1112
- [`&:not(:disabled):not(${e}-disabled)`]: {
1113
- "&:hover": t,
1114
- "&:active": r
1115
- }
1116
- }), ur = (e) => ({
1117
- minWidth: e.controlHeight,
1118
- paddingInlineStart: 0,
1119
- paddingInlineEnd: 0,
1120
- borderRadius: "50%"
1121
- }), dr = (e) => ({
1122
- borderRadius: e.controlHeight,
1123
- paddingInlineStart: e.calc(e.controlHeight).div(2).equal(),
1124
- paddingInlineEnd: e.calc(e.controlHeight).div(2).equal()
1125
- }), gr = (e) => ({
1126
- cursor: "not-allowed",
1127
- borderColor: e.borderColorDisabled,
1128
- color: e.colorTextDisabled,
1129
- background: e.colorBgContainerDisabled,
1130
- boxShadow: "none"
1131
- }), xe = (e, t, r, o, n, i, s, a) => ({
1132
- [`&${e}-background-ghost`]: Object.assign(Object.assign({
1133
- color: r || void 0,
1134
- background: t,
1135
- borderColor: o || void 0,
1136
- boxShadow: "none"
1137
- }, lt(e, Object.assign({
1138
- background: t
1139
- }, s), Object.assign({
1140
- background: t
1141
- }, a))), {
1142
- "&:disabled": {
1143
- cursor: "not-allowed",
1144
- color: n || void 0,
1145
- borderColor: i || void 0
1146
- }
1147
- })
1148
- }), hr = (e) => ({
1149
- [`&:disabled, &${e.componentCls}-disabled`]: Object.assign({}, gr(e))
1150
- }), fr = (e) => ({
1151
- [`&:disabled, &${e.componentCls}-disabled`]: {
1152
- cursor: "not-allowed",
1153
- color: e.colorTextDisabled
1154
- }
1155
- }), le = (e, t, r, o) => {
1156
- const i = o && ["link", "text"].includes(o) ? fr : hr;
1157
- return Object.assign(Object.assign({}, i(e)), lt(e.componentCls, t, r));
1158
- }, He = (e, t, r, o, n) => ({
1159
- [`&${e.componentCls}-variant-solid`]: Object.assign({
1160
- color: t,
1161
- background: r
1162
- }, le(e, o, n))
1163
- }), $e = (e, t, r, o, n) => ({
1164
- [`&${e.componentCls}-variant-outlined, &${e.componentCls}-variant-dashed`]: Object.assign({
1165
- borderColor: t,
1166
- background: r
1167
- }, le(e, o, n))
1168
- }), Ee = (e) => ({
1169
- [`&${e.componentCls}-variant-dashed`]: {
1170
- borderStyle: "dashed"
1171
- }
1172
- }), Be = (e, t, r, o) => ({
1173
- [`&${e.componentCls}-variant-filled`]: Object.assign({
1174
- boxShadow: "none",
1175
- background: t
1176
- }, le(e, r, o))
1177
- }), J = (e, t, r, o, n) => ({
1178
- [`&${e.componentCls}-variant-${r}`]: Object.assign({
1179
- color: t,
1180
- boxShadow: "none"
1181
- }, le(e, o, n, r))
1182
- }), mr = (e) => Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({
1183
- color: e.defaultColor,
1184
- boxShadow: e.defaultShadow
1185
- }, He(e, e.solidTextColor, e.colorBgSolid, {
1186
- background: e.colorBgSolidHover
1187
- }, {
1188
- background: e.colorBgSolidActive
1189
- })), Ee(e)), Be(e, e.colorFillTertiary, {
1190
- background: e.colorFillSecondary
1191
- }, {
1192
- background: e.colorFill
1193
- })), J(e, e.textTextColor, "link", {
1194
- color: e.colorLinkHover,
1195
- background: e.linkHoverBg
1196
- }, {
1197
- color: e.colorLinkActive
1198
- })), xe(e.componentCls, e.ghostBg, e.defaultGhostColor, e.defaultGhostBorderColor, e.colorTextDisabled, e.colorBorder)), vr = (e) => Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({
1199
- color: e.colorPrimary,
1200
- boxShadow: e.primaryShadow
1201
- }, $e(e, e.colorPrimary, e.colorBgContainer, {
1202
- color: e.colorPrimaryTextHover,
1203
- borderColor: e.colorPrimaryHover,
1204
- background: e.colorBgContainer
1205
- }, {
1206
- color: e.colorPrimaryTextActive,
1207
- borderColor: e.colorPrimaryActive,
1208
- background: e.colorBgContainer
1209
- })), Ee(e)), Be(e, e.colorPrimaryBg, {
1210
- background: e.colorPrimaryBgHover
1211
- }, {
1212
- background: e.colorPrimaryBorder
1213
- })), J(e, e.colorLink, "text", {
1214
- color: e.colorPrimaryTextHover,
1215
- background: e.colorPrimaryBg
1216
- }, {
1217
- color: e.colorPrimaryTextActive,
1218
- background: e.colorPrimaryBorder
1219
- })), xe(e.componentCls, e.ghostBg, e.colorPrimary, e.colorPrimary, e.colorTextDisabled, e.colorBorder, {
1220
- color: e.colorPrimaryHover,
1221
- borderColor: e.colorPrimaryHover
1222
- }, {
1223
- color: e.colorPrimaryActive,
1224
- borderColor: e.colorPrimaryActive
1225
- })), br = (e) => Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({
1226
- color: e.colorError,
1227
- boxShadow: e.dangerShadow
1228
- }, He(e, e.dangerColor, e.colorError, {
1229
- background: e.colorErrorHover
1230
- }, {
1231
- background: e.colorErrorActive
1232
- })), $e(e, e.colorError, e.colorBgContainer, {
1233
- color: e.colorErrorHover,
1234
- borderColor: e.colorErrorBorderHover
1235
- }, {
1236
- color: e.colorErrorActive,
1237
- borderColor: e.colorErrorActive
1238
- })), Ee(e)), Be(e, e.colorErrorBg, {
1239
- background: e.colorErrorBgFilledHover
1240
- }, {
1241
- background: e.colorErrorBgActive
1242
- })), J(e, e.colorError, "text", {
1243
- color: e.colorErrorHover,
1244
- background: e.colorErrorBg
1245
- }, {
1246
- color: e.colorErrorHover,
1247
- background: e.colorErrorBgActive
1248
- })), J(e, e.colorError, "link", {
1249
- color: e.colorErrorHover
1250
- }, {
1251
- color: e.colorErrorActive
1252
- })), xe(e.componentCls, e.ghostBg, e.colorError, e.colorError, e.colorTextDisabled, e.colorBorder, {
1253
- color: e.colorErrorHover,
1254
- borderColor: e.colorErrorHover
1255
- }, {
1256
- color: e.colorErrorActive,
1257
- borderColor: e.colorErrorActive
1258
- })), pr = (e) => {
1259
- const {
1260
- componentCls: t
1261
- } = e;
1262
- return {
1263
- [`${t}-color-default`]: mr(e),
1264
- [`${t}-color-primary`]: vr(e),
1265
- [`${t}-color-dangerous`]: br(e)
1266
- };
1267
- }, Cr = (e) => Object.assign(Object.assign(Object.assign(Object.assign({}, $e(e, e.defaultBorderColor, e.defaultBg, {
1268
- color: e.defaultHoverColor,
1269
- borderColor: e.defaultHoverBorderColor,
1270
- background: e.defaultHoverBg
1271
- }, {
1272
- color: e.defaultActiveColor,
1273
- borderColor: e.defaultActiveBorderColor,
1274
- background: e.defaultActiveBg
1275
- })), J(e, e.textTextColor, "text", {
1276
- color: e.textTextHoverColor,
1277
- background: e.textHoverBg
1278
- }, {
1279
- color: e.textTextActiveColor,
1280
- background: e.colorBgTextActive
1281
- })), He(e, e.primaryColor, e.colorPrimary, {
1282
- background: e.colorPrimaryHover,
1283
- color: e.primaryColor
1284
- }, {
1285
- background: e.colorPrimaryActive,
1286
- color: e.primaryColor
1287
- })), J(e, e.colorLink, "link", {
1288
- color: e.colorLinkHover,
1289
- background: e.linkHoverBg
1290
- }, {
1291
- color: e.colorLinkActive
1292
- })), _e = function(e) {
1293
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
1294
- const {
1295
- componentCls: r,
1296
- controlHeight: o,
1297
- fontSize: n,
1298
- lineHeight: i,
1299
- borderRadius: s,
1300
- buttonPaddingHorizontal: a,
1301
- iconCls: l,
1302
- buttonPaddingVertical: c
1303
- } = e, d = `${r}-icon-only`;
1304
- return [
1305
- {
1306
- [t]: {
1307
- fontSize: n,
1308
- lineHeight: i,
1309
- height: o,
1310
- padding: `${re(c)} ${re(a)}`,
1311
- borderRadius: s,
1312
- [`&${d}`]: {
1313
- width: o,
1314
- paddingInline: 0,
1315
- // make `btn-icon-only` not too narrow
1316
- [`&${r}-compact-item`]: {
1317
- flex: "none"
1318
- },
1319
- [`&${r}-round`]: {
1320
- width: "auto"
1321
- },
1322
- [l]: {
1323
- fontSize: e.buttonIconOnlyFontSize
1324
- }
1325
- },
1326
- // Loading
1327
- [`&${r}-loading`]: {
1328
- opacity: e.opacityLoading,
1329
- cursor: "default"
1330
- },
1331
- [`${r}-loading-icon`]: {
1332
- transition: `width ${e.motionDurationSlow} ${e.motionEaseInOut}, opacity ${e.motionDurationSlow} ${e.motionEaseInOut}`
1333
- }
1334
- }
1335
- },
1336
- // Shape - patch prefixCls again to override solid border radius style
1337
- {
1338
- [`${r}${r}-circle${t}`]: ur(e)
1339
- },
1340
- {
1341
- [`${r}${r}-round${t}`]: dr(e)
1342
- }
1343
- ];
1344
- }, yr = (e) => {
1345
- const t = ae(e, {
1346
- fontSize: e.contentFontSize,
1347
- lineHeight: e.contentLineHeight
1348
- });
1349
- return _e(t, e.componentCls);
1350
- }, Sr = (e) => {
1351
- const t = ae(e, {
1352
- controlHeight: e.controlHeightSM,
1353
- fontSize: e.contentFontSizeSM,
1354
- lineHeight: e.contentLineHeightSM,
1355
- padding: e.paddingXS,
1356
- buttonPaddingHorizontal: e.paddingInlineSM,
1357
- buttonPaddingVertical: e.paddingBlockSM,
1358
- borderRadius: e.borderRadiusSM,
1359
- buttonIconOnlyFontSize: e.onlyIconSizeSM
1360
- });
1361
- return _e(t, `${e.componentCls}-sm`);
1362
- }, xr = (e) => {
1363
- const t = ae(e, {
1364
- controlHeight: e.controlHeightLG,
1365
- fontSize: e.contentFontSizeLG,
1366
- lineHeight: e.contentLineHeightLG,
1367
- buttonPaddingHorizontal: e.paddingInlineLG,
1368
- buttonPaddingVertical: e.paddingBlockLG,
1369
- borderRadius: e.borderRadiusLG,
1370
- buttonIconOnlyFontSize: e.onlyIconSizeLG
1371
- });
1372
- return _e(t, `${e.componentCls}-lg`);
1373
- }, Hr = (e) => {
1374
- const {
1375
- componentCls: t
1376
- } = e;
1377
- return {
1378
- [t]: {
1379
- [`&${t}-block`]: {
1380
- width: "100%"
1381
- }
1382
- }
1383
- };
1384
- }, $r = Dt("Button", (e) => {
1385
- const t = at(e);
1386
- return [
1387
- // Shared
1388
- cr(t),
1389
- // Size
1390
- yr(t),
1391
- Sr(t),
1392
- xr(t),
1393
- // Block
1394
- Hr(t),
1395
- // Color
1396
- pr(t),
1397
- // https://github.com/ant-design/ant-design/issues/50969
1398
- Cr(t),
1399
- // Button Group
1400
- Ft(t)
1401
- ];
1402
- }, st, {
1403
- unitless: {
1404
- fontWeight: !0,
1405
- contentLineHeight: !0,
1406
- contentLineHeightSM: !0,
1407
- contentLineHeightLG: !0
1408
- }
1409
- });
1410
- function Er(e, t) {
1411
- return {
1412
- // border collapse
1413
- [`&-item:not(${t}-last-item)`]: {
1414
- marginBottom: e.calc(e.lineWidth).mul(-1).equal()
1415
- },
1416
- "&-item": {
1417
- "&:hover,&:focus,&:active": {
1418
- zIndex: 2
1419
- },
1420
- "&[disabled]": {
1421
- zIndex: 0
1422
- }
1423
- }
1424
- };
1425
- }
1426
- function Br(e, t) {
1427
- return {
1428
- [`&-item:not(${t}-first-item):not(${t}-last-item)`]: {
1429
- borderRadius: 0
1430
- },
1431
- [`&-item${t}-first-item:not(${t}-last-item)`]: {
1432
- [`&, &${e}-sm, &${e}-lg`]: {
1433
- borderEndEndRadius: 0,
1434
- borderEndStartRadius: 0
1435
- }
1436
- },
1437
- [`&-item${t}-last-item:not(${t}-first-item)`]: {
1438
- [`&, &${e}-sm, &${e}-lg`]: {
1439
- borderStartStartRadius: 0,
1440
- borderStartEndRadius: 0
1441
- }
1442
- }
1443
- };
1444
- }
1445
- function _r(e) {
1446
- const t = `${e.componentCls}-compact-vertical`;
1447
- return {
1448
- [t]: Object.assign(Object.assign({}, Er(e, t)), Br(e.componentCls, t))
1449
- };
1450
- }
1451
- const Or = (e) => {
1452
- const {
1453
- componentCls: t,
1454
- calc: r
1455
- } = e;
1456
- return {
1457
- [t]: {
1458
- // Special styles for Primary Button
1459
- [`&-compact-item${t}-primary`]: {
1460
- [`&:not([disabled]) + ${t}-compact-item${t}-primary:not([disabled])`]: {
1461
- position: "relative",
1462
- "&:before": {
1463
- position: "absolute",
1464
- top: r(e.lineWidth).mul(-1).equal(),
1465
- insetInlineStart: r(e.lineWidth).mul(-1).equal(),
1466
- display: "inline-block",
1467
- width: e.lineWidth,
1468
- height: `calc(100% + ${re(e.lineWidth)} * 2)`,
1469
- backgroundColor: e.colorPrimaryHover,
1470
- content: '""'
1471
- }
1472
- }
1473
- },
1474
- // Special styles for Primary Button
1475
- "&-compact-vertical-item": {
1476
- [`&${t}-primary`]: {
1477
- [`&:not([disabled]) + ${t}-compact-vertical-item${t}-primary:not([disabled])`]: {
1478
- position: "relative",
1479
- "&:before": {
1480
- position: "absolute",
1481
- top: r(e.lineWidth).mul(-1).equal(),
1482
- insetInlineStart: r(e.lineWidth).mul(-1).equal(),
1483
- display: "inline-block",
1484
- width: `calc(100% + ${re(e.lineWidth)} * 2)`,
1485
- height: e.lineWidth,
1486
- backgroundColor: e.colorPrimaryHover,
1487
- content: '""'
1488
- }
1489
- }
1490
- }
1491
- }
1492
- }
1493
- };
1494
- }, Rr = It(["Button", "compact"], (e) => {
1495
- const t = at(e);
1496
- return [
1497
- // Space Compact
1498
- Ht(t),
1499
- _r(t),
1500
- Or(t)
1501
- ];
1502
- }, st);
1503
- var Lr = function(e, t) {
1504
- var r = {};
1505
- for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && t.indexOf(o) < 0 && (r[o] = e[o]);
1506
- if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var n = 0, o = Object.getOwnPropertySymbols(e); n < o.length; n++)
1507
- t.indexOf(o[n]) < 0 && Object.prototype.propertyIsEnumerable.call(e, o[n]) && (r[o[n]] = e[o[n]]);
1508
- return r;
1509
- };
1510
- function wr(e) {
1511
- if (typeof e == "object" && e) {
1512
- let t = e == null ? void 0 : e.delay;
1513
- return t = !Number.isNaN(t) && typeof t == "number" ? t : 0, {
1514
- loading: t <= 0,
1515
- delay: t
1516
- };
1517
- }
1518
- return {
1519
- loading: !!e,
1520
- delay: 0
1521
- };
1522
- }
1523
- const Nr = {
1524
- default: ["default", "outlined"],
1525
- primary: ["primary", "solid"],
1526
- dashed: ["default", "dashed"],
1527
- link: ["primary", "link"],
1528
- text: ["default", "text"]
1529
- }, Pr = /* @__PURE__ */ u.forwardRef((e, t) => {
1530
- var r, o, n;
1531
- const {
1532
- loading: i = !1,
1533
- prefixCls: s,
1534
- color: a,
1535
- variant: l,
1536
- type: c,
1537
- danger: d = !1,
1538
- shape: g = "default",
1539
- size: b,
1540
- styles: f,
1541
- disabled: p,
1542
- className: E,
1543
- rootClassName: B,
1544
- children: S,
1545
- icon: x,
1546
- iconPosition: O = "start",
1547
- ghost: h = !1,
1548
- block: y = !1,
1549
- // React does not recognize the `htmlType` prop on a DOM element. Here we pick it out of `rest`.
1550
- htmlType: K = "button",
1551
- classNames: T,
1552
- style: w = {},
1553
- autoInsertSpace: z
1554
- } = e, A = Lr(e, ["loading", "prefixCls", "color", "variant", "type", "danger", "shape", "size", "styles", "disabled", "className", "rootClassName", "children", "icon", "iconPosition", "ghost", "block", "htmlType", "classNames", "style", "autoInsertSpace"]), M = c || "default", [F, R] = te(() => {
1555
- if (a && l)
1556
- return [a, l];
1557
- const H = Nr[M] || [];
1558
- return d ? ["danger", H[1]] : H;
1559
- }, [c, a, l, d]), I = F === "danger" ? "dangerous" : F, {
1560
- getPrefixCls: G,
1561
- direction: W,
1562
- button: m
1563
- } = he(Ye), C = (r = z ?? (m == null ? void 0 : m.autoInsertSpace)) !== null && r !== void 0 ? r : !0, v = G("btn", s), [Re, ct, ut] = $r(v), dt = he(jt), Q = p ?? dt, gt = he(Ze), Z = te(() => wr(i), [i]), [V, Le] = ye(Z.loading), [ce, we] = ye(!1), X = Tt(t, /* @__PURE__ */ Ct()), Ne = pt.count(S) === 1 && !x && !oe(R);
1564
- ne(() => {
1565
- let H = null;
1566
- Z.delay > 0 ? H = setTimeout(() => {
1567
- H = null, Le(!0);
1568
- }, Z.delay) : Le(Z.loading);
1569
- function N() {
1570
- H && (clearTimeout(H), H = null);
1571
- }
1572
- return N;
1573
- }, [Z]), ne(() => {
1574
- if (!X || !X.current || !C)
1575
- return;
1576
- const H = X.current.textContent;
1577
- Ne && Se(H) ? ce || we(!0) : ce && we(!1);
1578
- }, [X]);
1579
- const Pe = (H) => {
1580
- const {
1581
- onClick: N
1582
- } = e;
1583
- if (V || Q) {
1584
- H.preventDefault();
1585
- return;
1586
- }
1587
- N == null || N(H);
1588
- };
1589
- if (process.env.NODE_ENV !== "production") {
1590
- const H = Ue("Button");
1591
- process.env.NODE_ENV !== "production" && H(!(typeof x == "string" && x.length > 2), "breaking", `\`icon\` is using ReactNode instead of string naming in v4. Please check \`${x}\` at https://ant.design/components/icon`), process.env.NODE_ENV !== "production" && H(!(h && oe(R)), "usage", "`link` or `text` button can't be a `ghost` button.");
1592
- }
1593
- const {
1594
- compactSize: ht,
1595
- compactItemClassnames: De
1596
- } = $t(v, W), ft = {
1597
- large: "lg",
1598
- small: "sm",
1599
- middle: void 0
1600
- }, ze = Et((H) => {
1601
- var N, ge;
1602
- return (ge = (N = b ?? ht) !== null && N !== void 0 ? N : gt) !== null && ge !== void 0 ? ge : H;
1603
- }), Ie = ze && ft[ze] || "", mt = V ? "loading" : x, ue = Bt(A, ["navigate"]), je = L(v, ct, ut, {
1604
- [`${v}-${g}`]: g !== "default" && g,
1605
- // line(253 - 254): Compatible with versions earlier than 5.21.0
1606
- [`${v}-${M}`]: M,
1607
- [`${v}-dangerous`]: d,
1608
- [`${v}-color-${I}`]: I,
1609
- [`${v}-variant-${R}`]: R,
1610
- [`${v}-${Ie}`]: Ie,
1611
- [`${v}-icon-only`]: !S && S !== 0 && !!mt,
1612
- [`${v}-background-ghost`]: h && !oe(R),
1613
- [`${v}-loading`]: V,
1614
- [`${v}-two-chinese-chars`]: ce && C && !V,
1615
- [`${v}-block`]: y,
1616
- [`${v}-rtl`]: W === "rtl",
1617
- [`${v}-icon-end`]: O === "end"
1618
- }, De, E, B, m == null ? void 0 : m.className), Te = Object.assign(Object.assign({}, m == null ? void 0 : m.style), w), vt = L(T == null ? void 0 : T.icon, (o = m == null ? void 0 : m.classNames) === null || o === void 0 ? void 0 : o.icon), bt = Object.assign(Object.assign({}, (f == null ? void 0 : f.icon) || {}), ((n = m == null ? void 0 : m.styles) === null || n === void 0 ? void 0 : n.icon) || {}), Ae = x && !V ? /* @__PURE__ */ u.createElement(ke, {
1619
- prefixCls: v,
1620
- className: vt,
1621
- style: bt
1622
- }, x) : /* @__PURE__ */ u.createElement(Vt, {
1623
- existIcon: !!x,
1624
- prefixCls: v,
1625
- loading: V
1626
- }), Me = S || S === 0 ? Wt(S, Ne && C) : null;
1627
- if (ue.href !== void 0)
1628
- return Re(/* @__PURE__ */ u.createElement("a", Object.assign({}, ue, {
1629
- className: L(je, {
1630
- [`${v}-disabled`]: Q
1631
- }),
1632
- href: Q ? void 0 : ue.href,
1633
- style: Te,
1634
- onClick: Pe,
1635
- ref: X,
1636
- tabIndex: Q ? -1 : 0
1637
- }), Ae, Me));
1638
- let de = /* @__PURE__ */ u.createElement("button", Object.assign({}, A, {
1639
- type: K,
1640
- className: je,
1641
- style: Te,
1642
- onClick: Pe,
1643
- disabled: Q,
1644
- ref: X
1645
- }), Ae, Me, !!De && /* @__PURE__ */ u.createElement(Rr, {
1646
- key: "compact",
1647
- prefixCls: v
1648
- }));
1649
- return oe(R) || (de = /* @__PURE__ */ u.createElement(_t, {
1650
- component: "Button",
1651
- disabled: V
1652
- }, de)), Re(de);
1653
- }), Oe = Pr;
1654
- Oe.Group = Mt;
1655
- Oe.__ANT_BUTTON = !0;
1656
- process.env.NODE_ENV !== "production" && (Oe.displayName = "Button");
1657
- export {
1658
- Oe as B,
1659
- Ar as c
1660
- };