@bioturing/components 0.42.0 → 0.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/components/button/component.d.ts.map +1 -1
  2. package/dist/components/button/component.js +41 -34
  3. package/dist/components/button/component.js.map +1 -1
  4. package/dist/components/button/style.css +1 -1
  5. package/dist/components/combobox/component.d.ts.map +1 -1
  6. package/dist/components/combobox/component.js +136 -126
  7. package/dist/components/combobox/component.js.map +1 -1
  8. package/dist/components/command-palette/component.d.ts +7 -0
  9. package/dist/components/command-palette/component.d.ts.map +1 -1
  10. package/dist/components/command-palette/component.js +35 -33
  11. package/dist/components/command-palette/component.js.map +1 -1
  12. package/dist/components/dropdown-menu/component.d.ts +8 -1
  13. package/dist/components/dropdown-menu/component.d.ts.map +1 -1
  14. package/dist/components/dropdown-menu/component.js +165 -141
  15. package/dist/components/dropdown-menu/component.js.map +1 -1
  16. package/dist/components/dropdown-menu/style.css +1 -1
  17. package/dist/components/ds-root/component.d.ts +6 -1
  18. package/dist/components/ds-root/component.d.ts.map +1 -1
  19. package/dist/components/ds-root/component.js +15 -14
  20. package/dist/components/ds-root/component.js.map +1 -1
  21. package/dist/components/form/style.css +1 -1
  22. package/dist/components/hooks/index.d.ts +0 -1
  23. package/dist/components/hooks/index.d.ts.map +1 -1
  24. package/dist/components/index.d.ts +1 -0
  25. package/dist/components/index.d.ts.map +1 -1
  26. package/dist/components/label-with-help/component.d.ts +20 -0
  27. package/dist/components/label-with-help/component.d.ts.map +1 -0
  28. package/dist/components/label-with-help/component.js +39 -0
  29. package/dist/components/label-with-help/component.js.map +1 -0
  30. package/dist/components/label-with-help/index.d.ts +2 -0
  31. package/dist/components/label-with-help/index.d.ts.map +1 -0
  32. package/dist/components/label-with-help/style.css +1 -0
  33. package/dist/components/modal/Modal.d.ts.map +1 -1
  34. package/dist/components/modal/Modal.js +157 -133
  35. package/dist/components/modal/Modal.js.map +1 -1
  36. package/dist/components/popup-panel/component.d.ts +2 -111
  37. package/dist/components/popup-panel/component.d.ts.map +1 -1
  38. package/dist/components/popup-panel/component.js +253 -139
  39. package/dist/components/popup-panel/component.js.map +1 -1
  40. package/dist/components/popup-panel/constants.d.ts +1 -0
  41. package/dist/components/popup-panel/constants.d.ts.map +1 -1
  42. package/dist/components/popup-panel/constants.js +2 -0
  43. package/dist/components/popup-panel/constants.js.map +1 -1
  44. package/dist/components/popup-panel/index.d.ts +1 -0
  45. package/dist/components/popup-panel/index.d.ts.map +1 -1
  46. package/dist/components/popup-panel/types.d.ts +124 -0
  47. package/dist/components/popup-panel/types.d.ts.map +1 -0
  48. package/dist/components/popup-panel/utils.d.ts +1 -1
  49. package/dist/components/popup-panel/utils.d.ts.map +1 -1
  50. package/dist/components/popup-panel/utils.js +5 -5
  51. package/dist/components/popup-panel/utils.js.map +1 -1
  52. package/dist/components/resizable/component.d.ts.map +1 -1
  53. package/dist/components/resizable/component.js +28 -28
  54. package/dist/components/resizable/component.js.map +1 -1
  55. package/dist/components/select/component.d.ts.map +1 -1
  56. package/dist/components/select/component.js +130 -120
  57. package/dist/components/select/component.js.map +1 -1
  58. package/dist/components/toast/component.d.ts +2 -2
  59. package/dist/components/toast/component.d.ts.map +1 -1
  60. package/dist/components/toast/component.js +14 -20
  61. package/dist/components/toast/component.js.map +1 -1
  62. package/dist/components/toast/function.d.ts +7 -8
  63. package/dist/components/toast/function.d.ts.map +1 -1
  64. package/dist/components/toast/function.js.map +1 -1
  65. package/dist/components/toast/style.css +1 -1
  66. package/dist/components/toast/types.d.ts +4 -0
  67. package/dist/components/toast/types.d.ts.map +1 -1
  68. package/dist/components/utils/placement.d.ts +9 -2
  69. package/dist/components/utils/placement.d.ts.map +1 -1
  70. package/dist/components/utils/placement.js +29 -18
  71. package/dist/components/utils/placement.js.map +1 -1
  72. package/dist/components/utils/reactElement.d.ts +2 -0
  73. package/dist/components/utils/reactElement.d.ts.map +1 -1
  74. package/dist/components/utils/reactElement.js +10 -2
  75. package/dist/components/utils/reactElement.js.map +1 -1
  76. package/dist/components/utils/renderProp.d.ts.map +1 -1
  77. package/dist/components/utils/renderProp.js +9 -8
  78. package/dist/components/utils/renderProp.js.map +1 -1
  79. package/dist/index.js +191 -189
  80. package/dist/metadata.d.ts +8 -0
  81. package/dist/metadata.d.ts.map +1 -1
  82. package/dist/metadata.js +15 -0
  83. package/dist/metadata.js.map +1 -1
  84. package/dist/stats.html +1 -1
  85. package/package.json +2 -2
  86. package/dist/components/hooks/useBaseUIPlacement.d.ts +0 -64
  87. package/dist/components/hooks/useBaseUIPlacement.d.ts.map +0 -1
  88. package/dist/components/hooks/useBaseUIPlacement.js +0 -61
  89. package/dist/components/hooks/useBaseUIPlacement.js.map +0 -1
@@ -0,0 +1,39 @@
1
+ "use client";
2
+ import { jsx as e, jsxs as o } from "react/jsx-runtime";
3
+ import { forwardRef as p } from "react";
4
+ import { QuestionIcon as c } from "@bioturing/assets";
5
+ import './style.css';/* empty css */
6
+ import { useCls as h } from "../utils/antdUtils.js";
7
+ import { clsx as m } from "../utils/cn.js";
8
+ import { IconButton as b } from "../icon-button/component.js";
9
+ const f = p(
10
+ ({ children: r, tooltip: s, iconButtonProps: a, className: t, ...n }, i) => {
11
+ const l = h();
12
+ return s ? /* @__PURE__ */ o(
13
+ "span",
14
+ {
15
+ ref: i,
16
+ className: m(l("label-with-help"), t),
17
+ ...n,
18
+ children: [
19
+ /* @__PURE__ */ e("span", { className: l("label-with-help-content"), children: r }),
20
+ /* @__PURE__ */ e("span", { className: l("label-with-help-icon"), children: /* @__PURE__ */ e(
21
+ b,
22
+ {
23
+ ...a,
24
+ className: m(l("label-with-help-icon-button"), a?.className),
25
+ render: a?.render ?? /* @__PURE__ */ e("span", {}),
26
+ label: s,
27
+ children: /* @__PURE__ */ e(c, {})
28
+ }
29
+ ) })
30
+ ]
31
+ }
32
+ ) : /* @__PURE__ */ e("span", { ref: i, className: t, ...n, children: r });
33
+ }
34
+ );
35
+ f.displayName = "LabelWithHelp";
36
+ export {
37
+ f as LabelWithHelp
38
+ };
39
+ //# sourceMappingURL=component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.js","sources":["../../../src/components/label-with-help/component.tsx"],"sourcesContent":["\"use client\";\nimport React, { forwardRef } from \"react\";\nimport { useCls, clsx } from \"../utils\";\nimport { IconButton, type IconButtonProps } from \"../icon-button\";\nimport { QuestionIcon } from \"@bioturing/assets\";\n\nimport \"./style.css\";\n\nexport interface LabelWithHelpProps\n extends React.ComponentPropsWithRef<\"span\"> {\n /**\n * The content to display alongside the help icon\n */\n children: React.ReactNode;\n /**\n * Tooltip content shown when hovering the question icon.\n * When falsy, the component renders children directly without wrapper.\n */\n tooltip?: React.ReactNode;\n /**\n * Props to pass to the inner IconButton component for customization\n * (e.g. size, tooltipProps, negativeMargin)\n */\n iconButtonProps?: Partial<IconButtonProps>;\n}\n\nexport const LabelWithHelp = forwardRef<HTMLSpanElement, LabelWithHelpProps>(\n ({ children, tooltip, iconButtonProps, className, ...props }, ref) => {\n const cls = useCls();\n\n if (!tooltip) {\n return (\n <span ref={ref} className={className} {...props}>\n {children}\n </span>\n );\n }\n\n return (\n <span\n ref={ref}\n className={clsx(cls(\"label-with-help\"), className)}\n {...props}\n >\n <span className={cls(\"label-with-help-content\")}>{children}</span>\n <span className={cls(\"label-with-help-icon\")}>\n <IconButton\n {...iconButtonProps}\n className={clsx(cls(\"label-with-help-icon-button\"), iconButtonProps?.className)}\n render={iconButtonProps?.render ?? <span />}\n label={tooltip}\n >\n <QuestionIcon />\n </IconButton>\n </span>\n </span>\n );\n },\n);\n\nLabelWithHelp.displayName = \"LabelWithHelp\";\n"],"names":["LabelWithHelp","forwardRef","children","tooltip","iconButtonProps","className","props","ref","cls","useCls","jsxs","clsx","jsx","IconButton","QuestionIcon"],"mappings":";;;;;;;;AA0BO,MAAMA,IAAgBC;AAAA,EAC3B,CAAC,EAAE,UAAAC,GAAU,SAAAC,GAAS,iBAAAC,GAAiB,WAAAC,GAAW,GAAGC,EAAA,GAASC,MAAQ;AACpE,UAAMC,IAAMC,EAAA;AAEZ,WAAKN,IASH,gBAAAO;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAAH;AAAA,QACA,WAAWI,EAAKH,EAAI,iBAAiB,GAAGH,CAAS;AAAA,QAChD,GAAGC;AAAA,QAEJ,UAAA;AAAA,UAAA,gBAAAM,EAAC,QAAA,EAAK,WAAWJ,EAAI,yBAAyB,GAAI,UAAAN,GAAS;AAAA,UAC3D,gBAAAU,EAAC,QAAA,EAAK,WAAWJ,EAAI,sBAAsB,GACzC,UAAA,gBAAAI;AAAA,YAACC;AAAA,YAAA;AAAA,cACE,GAAGT;AAAA,cACJ,WAAWO,EAAKH,EAAI,6BAA6B,GAAGJ,GAAiB,SAAS;AAAA,cAC9E,QAAQA,GAAiB,UAAU,gBAAAQ,EAAC,QAAA,CAAA,CAAK;AAAA,cACzC,OAAOT;AAAA,cAEP,4BAACW,GAAA,CAAA,CAAa;AAAA,YAAA;AAAA,UAAA,EAChB,CACF;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA,sBAtBC,QAAA,EAAK,KAAAP,GAAU,WAAAF,GAAuB,GAAGC,GACvC,UAAAJ,GACH;AAAA,EAuBN;AACF;AAEAF,EAAc,cAAc;"}
@@ -0,0 +1,2 @@
1
+ export * from './component';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/label-with-help/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
@@ -0,0 +1 @@
1
+ @layer components{.ds-label-with-help{display:inline-block}.ds-label-with-help-content{vertical-align:middle}.ds-label-with-help-icon{margin-inline-start:.25rem;height:1em;height:1lh;vertical-align:middle}.ds-label-with-help-icon-button{cursor:help;vertical-align:top}}
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../src/components/modal/Modal.tsx"],"names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Z,CAAC"}
@@ -1,169 +1,193 @@
1
1
  "use client";
2
- import { jsx as o, jsxs as c, Fragment as H } from "react/jsx-runtime";
3
- import pe from "antd/es/modal";
4
- import { XIcon as he } from "@bioturing/assets";
5
- import { useState as R, useRef as ye, useCallback as be, useEffect as Ce } from "react";
6
- import { ModalContextProvider as ve } from "antd/es/modal/context";
7
- import j from "antd/es/modal/components/NormalCancelBtn";
8
- import E from "antd/es/modal/components/NormalOkBtn";
9
- import { getConfirmLocale as ge } from "antd/es/modal/locale";
10
- import { useLocale as ke } from "antd/es/locale";
11
- import { ModalSize as m } from "./constants.js";
12
- import { Stack as f } from "../stack/index.js";
13
- import { Truncate as we } from "../truncate/component.js";
14
- import { IconButton as xe } from "../icon-button/component.js";
15
- import { useCls as Oe } from "../utils/antdUtils.js";
16
- import { useTheme as ze } from "../theme-provider/context/themeStore.js";
17
- import { clsx as Be } from "../utils/cn.js";
18
- const Je = ({
19
- open: u,
20
- closeIcon: p,
21
- children: F,
22
- size: L,
23
- footer: h,
24
- width: P,
25
- style: W,
26
- styles: y,
27
- classNames: $,
28
- okButtonProps: q,
29
- cancelButtonProps: A,
30
- loading: X,
31
- onOk: b,
32
- onCancel: C,
33
- okText: v,
34
- okType: D = "primary",
35
- confirmLoading: s,
36
- cancelText: g = "Close",
37
- hideOkButton: k = !1,
38
- hideCancelButton: w = !1,
2
+ import { jsx as o, jsxs as m, Fragment as L } from "react/jsx-runtime";
3
+ import Ce from "antd/es/modal";
4
+ import { XIcon as ve } from "@bioturing/assets";
5
+ import { useMemo as s, useState as V, useRef as ye, useCallback as we, useEffect as xe } from "react";
6
+ import { useStableCallback as ge } from "@base-ui/utils/useStableCallback";
7
+ import { ModalContextProvider as ze } from "antd/es/modal/context";
8
+ import X from "antd/es/modal/components/NormalCancelBtn";
9
+ import D from "antd/es/modal/components/NormalOkBtn";
10
+ import { getConfirmLocale as Me } from "antd/es/modal/locale";
11
+ import { useLocale as Se } from "antd/es/locale";
12
+ import { ModalSize as i } from "./constants.js";
13
+ import { Stack as w } from "../stack/index.js";
14
+ import { Truncate as ke } from "../truncate/component.js";
15
+ import { IconButton as Ie } from "../icon-button/component.js";
16
+ import { useCls as Ne } from "../utils/antdUtils.js";
17
+ import { useTheme as Oe } from "../theme-provider/context/themeStore.js";
18
+ import { clsx as Te } from "../utils/cn.js";
19
+ const Ye = ({
20
+ open: x,
21
+ closeIcon: g,
22
+ children: G,
23
+ size: J,
24
+ footer: z,
25
+ width: K,
26
+ style: M,
27
+ styles: f,
28
+ classNames: Q,
29
+ okButtonProps: S,
30
+ cancelButtonProps: k,
31
+ loading: U,
32
+ onOk: d,
33
+ onCancel: I,
34
+ okText: N,
35
+ okType: O = "primary",
36
+ confirmLoading: n,
37
+ cancelText: T = "Close",
38
+ hideOkButton: u = !1,
39
+ hideCancelButton: p = !1,
39
40
  contentPadding: r,
40
- title: i,
41
- afterTitle: x,
42
- beforeCloseButton: G,
43
- afterCloseButton: J,
44
- defaultFixedHeaderFooter: K = !1,
45
- centered: Q = !0,
46
- type: U = "default",
47
- defaultOpen: V = !0,
48
- background: Y,
49
- bodyScrollable: Z = !0,
50
- rootClassName: _,
51
- ...ee
41
+ title: h,
42
+ afterTitle: H,
43
+ beforeCloseButton: Y,
44
+ afterCloseButton: Z,
45
+ defaultFixedHeaderFooter: _ = !1,
46
+ centered: P = !0,
47
+ type: ee = "default",
48
+ defaultOpen: oe = !0,
49
+ background: re,
50
+ bodyScrollable: le = !0,
51
+ rootClassName: te,
52
+ ...se
52
53
  }) => {
53
- const oe = p === void 0 ? /* @__PURE__ */ o(he, { size: 16, weight: "bold" }) : p, t = L || (U === "default" ? "medium" : "xsmall"), re = P || m[t], te = {
54
- "--ds-modal-bg": `var(--ds-color-bg-${Y || (t in m && parseInt(m[t]) <= parseInt(m.medium) ? "elevated" : "container")})`,
55
- ...W,
56
- ...t === "fullscreen" ? { top: 0, maxWidth: "100%", height: "100%" } : {}
57
- }, le = {
58
- ...y,
59
- body: {
60
- ...typeof r < "u" ? {
61
- "--ds-modal-content-padding": r === !1 || r === 0 ? "0" : typeof r == "number" ? `${r}px` : r
62
- } : {},
63
- ...y?.body
64
- }
65
- }, [O, z] = R(!1), n = Oe(), { className: ne } = ze(), a = ye(null), se = be(
54
+ const ne = g === void 0 ? /* @__PURE__ */ o(ve, { size: 16, weight: "bold" }) : g, l = J || (ee === "default" ? "medium" : "xsmall"), ae = K || i[l], R = re || (l in i && parseInt(i[l]) <= parseInt(i.medium) ? "elevated" : "container"), ce = s(
55
+ () => ({
56
+ "--ds-modal-bg": `var(--ds-color-bg-${R})`,
57
+ ...M,
58
+ ...l === "fullscreen" ? { top: 0, maxWidth: "100%", height: "100%" } : {}
59
+ }),
60
+ [R, M, l]
61
+ ), me = s(
62
+ () => ({
63
+ ...f,
64
+ body: {
65
+ ...typeof r < "u" ? {
66
+ "--ds-modal-content-padding": r === !1 || r === 0 ? "0" : typeof r == "number" ? `${r}px` : r
67
+ } : {},
68
+ ...f?.body
69
+ }
70
+ }),
71
+ [f, r]
72
+ ), [B, j] = V(!1), a = Ne(), { className: ie } = Oe(), c = ye(null), fe = we(
66
73
  (e) => {
67
74
  if (!e) return;
68
- const l = e.querySelector("." + n("modal-body"));
69
- if (!(l instanceof HTMLElement)) return;
70
- const T = new ResizeObserver(() => {
71
- const ue = l.scrollHeight > l.clientHeight;
72
- z(ue);
75
+ const t = e.querySelector("." + a("modal-body"));
76
+ if (!(t instanceof HTMLElement)) return;
77
+ const A = new ResizeObserver(() => {
78
+ const be = t.scrollHeight > t.clientHeight;
79
+ j(be);
73
80
  });
74
- a.current = T, T.observe(l);
75
- const fe = l.scrollHeight > l.clientHeight;
76
- z(fe);
81
+ c.current = A, A.observe(t);
82
+ const he = t.scrollHeight > t.clientHeight;
83
+ j(he);
77
84
  },
78
- [n]
85
+ [a]
79
86
  );
80
- Ce(() => () => {
81
- a.current && (a.current.disconnect(), a.current = null);
87
+ xe(() => () => {
88
+ c.current && (c.current.disconnect(), c.current = null);
82
89
  }, []);
83
- const [B] = ke("Modal", ge()), ae = v || B?.okText, ce = g || B?.cancelText, I = {
84
- // loading: typeof confirmLoading === "boolean" ? confirmLoading : loading,
85
- ...q
86
- }, M = {
87
- ...A
88
- }, [me, N] = R(V), d = typeof u > "u", ie = d ? me : u, S = (e) => {
89
- s || C?.(e);
90
- }, de = /* @__PURE__ */ o(
91
- ve,
92
- {
93
- value: {
94
- okButtonProps: I,
95
- cancelButtonProps: M,
96
- onCancel: S,
97
- onOk: b,
98
- okType: D,
99
- confirmLoading: s,
100
- okTextLocale: ae,
101
- cancelTextLocale: ce
102
- },
103
- children: k ? /* @__PURE__ */ o(j, {}) : w ? /* @__PURE__ */ o(E, {}) : /* @__PURE__ */ c(H, { children: [
104
- /* @__PURE__ */ o(j, {}),
105
- /* @__PURE__ */ o(E, {})
106
- ] })
90
+ const [E] = Se("Modal", Me()), F = N || E?.okText, W = T || E?.cancelText, b = s(
91
+ () => ({
92
+ // loading: typeof confirmLoading === "boolean" ? confirmLoading : loading,
93
+ ...S
94
+ }),
95
+ [S]
96
+ ), C = s(
97
+ () => ({
98
+ ...k
99
+ }),
100
+ [k]
101
+ ), [de, $] = V(oe), v = typeof x > "u", ue = v ? de : x, y = ge(
102
+ (e) => {
103
+ n || I?.(e);
107
104
  }
105
+ ), q = s(
106
+ () => ({
107
+ okButtonProps: b,
108
+ cancelButtonProps: C,
109
+ onCancel: y,
110
+ onOk: d,
111
+ okType: O,
112
+ confirmLoading: n,
113
+ okTextLocale: F,
114
+ cancelTextLocale: W
115
+ }),
116
+ [
117
+ b,
118
+ C,
119
+ d,
120
+ O,
121
+ n,
122
+ F,
123
+ W,
124
+ y
125
+ ]
126
+ ), pe = s(
127
+ () => /* @__PURE__ */ o(ze, { value: q, children: u ? /* @__PURE__ */ o(X, {}) : p ? /* @__PURE__ */ o(D, {}) : /* @__PURE__ */ m(L, { children: [
128
+ /* @__PURE__ */ o(X, {}),
129
+ /* @__PURE__ */ o(D, {})
130
+ ] }) }),
131
+ [q, u, p]
108
132
  );
109
133
  return /* @__PURE__ */ o(
110
- pe,
134
+ Ce,
111
135
  {
112
136
  closeIcon: !1,
113
- open: ie,
114
- width: re,
115
- style: te,
116
- title: /* @__PURE__ */ c(H, { children: [
117
- /* @__PURE__ */ c(f, { align: "center", gap: 8, className: n("modal-title-wrapper"), children: [
118
- /* @__PURE__ */ o(f.Child, { grow: !0, children: typeof i == "string" ? /* @__PURE__ */ o(we, { children: i }) : i }),
119
- /* @__PURE__ */ c(f.Child, { stack: !0, hug: !0, align: "center", gap: 8, children: [
120
- G,
137
+ open: ue,
138
+ width: ae,
139
+ style: ce,
140
+ title: /* @__PURE__ */ m(L, { children: [
141
+ /* @__PURE__ */ m(w, { align: "center", gap: 8, className: a("modal-title-wrapper"), children: [
142
+ /* @__PURE__ */ o(w.Child, { grow: !0, children: typeof h == "string" ? /* @__PURE__ */ o(ke, { children: h }) : h }),
143
+ /* @__PURE__ */ m(w.Child, { stack: !0, hug: !0, align: "center", gap: 8, children: [
144
+ Y,
121
145
  /* @__PURE__ */ o(
122
- xe,
146
+ Ie,
123
147
  {
124
- onClick: (e) => S(e),
125
- children: oe
148
+ onClick: (e) => y(e),
149
+ children: ne
126
150
  }
127
151
  ),
128
- J
152
+ Z
129
153
  ] })
130
154
  ] }),
131
- x || null
155
+ H || null
132
156
  ] }),
133
- rootClassName: Be(ne, _),
157
+ rootClassName: Te(ie, te),
134
158
  classNames: {
135
- ...$,
136
- wrapper: n(
159
+ ...Q,
160
+ wrapper: a(
137
161
  "modal-wrap",
138
- t == "fullscreen" && "modal-fullscreen",
139
- O && "modal-content-overflow",
140
- Z === !1 && "modal-no-body-scroll",
141
- K || O || t == "fullscreen" ? "modal-fixed" : ""
162
+ l == "fullscreen" && "modal-fullscreen",
163
+ B && "modal-content-overflow",
164
+ le === !1 && "modal-no-body-scroll",
165
+ _ || B || l == "fullscreen" ? "modal-fixed" : ""
142
166
  )
143
167
  },
144
- styles: le,
145
- modalRender: (e) => /* @__PURE__ */ o("div", { ref: se, className: n("modal-inner"), children: e }),
146
- okButtonProps: I,
147
- cancelButtonProps: M,
168
+ styles: me,
169
+ modalRender: (e) => /* @__PURE__ */ o("div", { ref: fe, className: a("modal-inner"), children: e }),
170
+ okButtonProps: b,
171
+ cancelButtonProps: C,
148
172
  onOk: (e) => {
149
- d && N(!1), b?.(e);
173
+ v && $(!1), d?.(e);
150
174
  },
151
175
  onCancel: (e) => {
152
- s || (d && N(!1), C?.(e));
176
+ n || (v && $(!1), I?.(e));
153
177
  },
154
- okText: v,
155
- cancelText: g,
178
+ okText: N,
179
+ cancelText: T,
156
180
  okType: "primary",
157
- confirmLoading: s,
158
- footer: typeof h > "u" ? k && w ? null : de : h,
159
- centered: Q,
160
- loading: X,
161
- ...ee,
162
- children: F
181
+ confirmLoading: n,
182
+ footer: typeof z > "u" ? u && p ? null : pe : z,
183
+ centered: P,
184
+ loading: U,
185
+ ...se,
186
+ children: G
163
187
  }
164
188
  );
165
189
  };
166
190
  export {
167
- Je as Modal
191
+ Ye as Modal
168
192
  };
169
193
  //# sourceMappingURL=Modal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.js","sources":["../../../src/components/modal/Modal.tsx"],"sourcesContent":["\"use client\";\nimport {\n default as AntModal,\n type ModalProps as AntModalProps,\n} from \"antd/es/modal\";\nimport { XIcon } from \"@bioturing/assets\";\nimport React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport { clsx, useCls } from \"../utils\";\nimport { ModalContextProvider } from \"antd/es/modal/context\";\nimport NormalCancelBtn from \"antd/es/modal/components/NormalCancelBtn\";\nimport NormalOkBtn from \"antd/es/modal/components/NormalOkBtn\";\nimport { getConfirmLocale } from \"antd/es/modal/locale\";\nimport { useLocale } from \"antd/es/locale\";\nimport { IconButton } from \"../icon-button\";\nimport { ModalSize } from \"./constants\";\nimport { ModalType } from \"./functions\";\nimport { Truncate } from \"../truncate\";\nimport { Stack } from \"../stack\";\nimport { useTheme } from \"../theme-provider\";\n\n// Define props interface extending Ant Design's ModalProps\nexport interface ModalProps extends Omit<AntModalProps, \"centered\"> {\n /**\n * Predefined sizes for the modal\n * - xsmall: 400px\n * - small: 520px\n * - medium: 640px (default)\n * - large: 840px\n * - xlarge: 1024px\n * - fullscreen: 100vw (takes full screen width with margins)\n * @default \"medium\" for default type, \"xsmall\" for other types\n */\n size?:\n | \"xsmall\"\n | \"small\"\n | \"medium\"\n | \"large\"\n | \"xlarge\"\n | \"xxlarge\"\n | \"fullscreen\";\n /**\n * Mark modal as loading\n * @default false\n */\n loading?: boolean;\n /**\n * Hide Ok button\n * @default false\n */\n hideOkButton?: boolean;\n /**\n * Hide Cancel button\n * @default false\n */\n hideCancelButton?: boolean;\n /**\n * Custom Content Padding\n * @default \"24px\"\n */\n contentPadding?: number | string | boolean;\n /**\n * Add more content below the title\n */\n afterTitle?: React.ReactNode;\n /**\n * Add more actions before close button\n */\n beforeCloseButton?: React.ReactNode;\n /**\n * Add more actions after close button\n */\n afterCloseButton?: React.ReactNode;\n /**\n * Set header and footer to fixed position\n * @default false\n */\n defaultFixedHeaderFooter?: boolean;\n /**\n * Centered Modal\n * @default true\n */\n centered?: boolean;\n /**\n * Modal type\n * @default \"default\"\n */\n type?: ModalType;\n /**\n * Default open state for uncontrolled modal\n * @default true\n */\n defaultOpen?: boolean;\n /**\n * Modal background\n * @default \"elevated\" if size smaller than \"medium\", otherwise \"container\"\n */\n background?: \"elevated\" | \"container\";\n /**\n * Modal old close callback\n * @deprecated use onCancel instead\n */\n onClose?: () => void;\n /**\n * Make modal body scrollable\n * @default true\n */\n bodyScrollable?: boolean;\n}\n\n// Create Modal component\nexport const Modal = ({\n open: externalOpen,\n closeIcon,\n children,\n size: sizeProp,\n footer,\n width,\n style,\n styles,\n classNames,\n okButtonProps,\n cancelButtonProps,\n loading,\n onOk,\n onCancel,\n okText,\n okType = \"primary\",\n confirmLoading,\n cancelText = \"Close\",\n hideOkButton = false,\n hideCancelButton = false,\n contentPadding,\n title,\n afterTitle,\n beforeCloseButton,\n afterCloseButton,\n defaultFixedHeaderFooter = false,\n centered = true,\n type = \"default\",\n defaultOpen = true,\n background: backgroundProp,\n bodyScrollable = true,\n rootClassName,\n ...rest\n}: ModalProps) => {\n // Default close icon with Phosphor icon\n const defaultCloseIcon =\n closeIcon === undefined ? <XIcon size={16} weight=\"bold\" /> : closeIcon;\n\n // Use custom width if provided, otherwise use the size from the map\n const defaultModalSize = type === \"default\" ? \"medium\" : \"xsmall\";\n\n const size: keyof typeof ModalSize = sizeProp || defaultModalSize;\n const modalWidth = width || ModalSize[size];\n\n const background =\n backgroundProp ||\n (size &&\n size in ModalSize &&\n parseInt(ModalSize[size]) <= parseInt(ModalSize.medium)\n ? \"elevated\"\n : \"container\");\n\n // Apply additional styles for fullscreen mode\n const modalStyle = {\n \"--ds-modal-bg\": `var(--ds-color-bg-${background})`,\n ...style,\n ...(size === \"fullscreen\"\n ? { top: 0, maxWidth: \"100%\", height: \"100%\" }\n : {}),\n };\n\n const modalStyles = {\n ...styles,\n body: {\n ...((typeof contentPadding != \"undefined\"\n ? {\n \"--ds-modal-content-padding\":\n contentPadding === false || contentPadding === 0\n ? \"0\"\n : typeof contentPadding == \"number\"\n ? `${contentPadding}px`\n : contentPadding,\n }\n : {}) as React.CSSProperties),\n ...styles?.body,\n },\n };\n\n const [isContentOverflow, setIsContentOverflow] = useState(false);\n\n const cls = useCls();\n\n const { className: themeClassName } = useTheme();\n\n const resizeObserverRef = useRef<ResizeObserver | null>(null);\n\n const modalInnerRef = useCallback(\n (node: HTMLElement | null) => {\n // If the node is null (component unmounting), just return\n if (!node) return;\n\n const modalBody = node.querySelector(\".\" + cls(\"modal-body\"));\n if (!(modalBody instanceof HTMLElement)) return;\n\n // Create ResizeObserver to detect overflow\n const resizeObserver = new ResizeObserver(() => {\n const hasOverflow = modalBody.scrollHeight > modalBody.clientHeight;\n setIsContentOverflow(hasOverflow);\n });\n\n // Store reference to the observer\n resizeObserverRef.current = resizeObserver;\n\n // Start observing\n resizeObserver.observe(modalBody);\n\n // Initial check\n const hasOverflow = modalBody.scrollHeight > modalBody.clientHeight;\n setIsContentOverflow(hasOverflow);\n },\n [cls]\n );\n\n // clean up resize observer\n useEffect(() => {\n return () => {\n if (resizeObserverRef.current) {\n resizeObserverRef.current.disconnect();\n resizeObserverRef.current = null;\n }\n };\n }, []);\n\n const [locale] = useLocale(\"Modal\", getConfirmLocale());\n\n const okTextLocale: React.ReactNode = okText || locale?.okText;\n const cancelTextLocale = cancelText || locale?.cancelText;\n\n const modalOkButtonProps = {\n // loading: typeof confirmLoading === \"boolean\" ? confirmLoading : loading,\n ...okButtonProps,\n };\n\n const modalCancelButtonProps = {\n ...cancelButtonProps,\n };\n\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n\n const uncontrolledOpen = typeof externalOpen === \"undefined\";\n\n const open = uncontrolledOpen ? internalOpen : externalOpen;\n\n const handleCancel = (e: React.MouseEvent<HTMLButtonElement>) => {\n if (confirmLoading) {\n return;\n }\n onCancel?.(e);\n };\n\n const defaultFooter = (\n <ModalContextProvider\n value={{\n okButtonProps: modalOkButtonProps,\n cancelButtonProps: modalCancelButtonProps,\n onCancel: handleCancel,\n onOk,\n okType,\n confirmLoading,\n okTextLocale,\n cancelTextLocale,\n }}\n >\n {hideOkButton ? (\n <NormalCancelBtn />\n ) : hideCancelButton ? (\n <NormalOkBtn />\n ) : (\n <>\n <NormalCancelBtn />\n <NormalOkBtn />\n </>\n )}\n </ModalContextProvider>\n );\n const renderTitle = () => {\n return (\n <>\n <Stack align=\"center\" gap={8} className={cls(\"modal-title-wrapper\")}>\n <Stack.Child grow>\n {typeof title === \"string\" ? <Truncate>{title}</Truncate> : title}\n </Stack.Child>\n <Stack.Child stack hug align=\"center\" gap={8}>\n {beforeCloseButton}\n <IconButton\n onClick={(e: React.MouseEvent<HTMLButtonElement>) =>\n handleCancel(e)\n }\n >\n {defaultCloseIcon}\n </IconButton>\n {afterCloseButton}\n </Stack.Child>\n {}\n </Stack>\n {afterTitle ? afterTitle : null}\n </>\n );\n };\n return (\n <AntModal\n closeIcon={false}\n open={open}\n width={modalWidth}\n style={modalStyle}\n title={renderTitle()}\n rootClassName={clsx(themeClassName, rootClassName)}\n classNames={{\n ...classNames,\n wrapper: cls(\n \"modal-wrap\",\n size == \"fullscreen\" && \"modal-fullscreen\",\n isContentOverflow && \"modal-content-overflow\",\n bodyScrollable === false && \"modal-no-body-scroll\",\n defaultFixedHeaderFooter || isContentOverflow || size == \"fullscreen\"\n ? \"modal-fixed\"\n : \"\"\n ),\n }}\n styles={modalStyles}\n modalRender={(modal) => (\n <div ref={modalInnerRef} className={cls(\"modal-inner\")}>\n {modal}\n </div>\n )}\n okButtonProps={modalOkButtonProps}\n cancelButtonProps={modalCancelButtonProps}\n onOk={(e) => {\n if (uncontrolledOpen) setInternalOpen(false);\n onOk?.(e);\n }}\n onCancel={(e) => {\n if (confirmLoading) return;\n if (uncontrolledOpen) setInternalOpen(false);\n onCancel?.(e);\n }}\n okText={okText}\n cancelText={cancelText}\n okType=\"primary\"\n confirmLoading={confirmLoading}\n footer={\n typeof footer === \"undefined\"\n ? hideOkButton && hideCancelButton\n ? null\n : defaultFooter\n : footer\n }\n centered={centered}\n loading={loading}\n {...rest}\n >\n {children}\n </AntModal>\n );\n};\n"],"names":["Modal","externalOpen","closeIcon","children","sizeProp","footer","width","style","styles","classNames","okButtonProps","cancelButtonProps","loading","onOk","onCancel","okText","okType","confirmLoading","cancelText","hideOkButton","hideCancelButton","contentPadding","title","afterTitle","beforeCloseButton","afterCloseButton","defaultFixedHeaderFooter","centered","type","defaultOpen","backgroundProp","bodyScrollable","rootClassName","rest","defaultCloseIcon","jsx","XIcon","size","modalWidth","ModalSize","modalStyle","modalStyles","isContentOverflow","setIsContentOverflow","useState","cls","useCls","themeClassName","useTheme","resizeObserverRef","useRef","modalInnerRef","useCallback","node","modalBody","resizeObserver","hasOverflow","useEffect","locale","useLocale","getConfirmLocale","okTextLocale","cancelTextLocale","modalOkButtonProps","modalCancelButtonProps","internalOpen","setInternalOpen","uncontrolledOpen","open","handleCancel","defaultFooter","ModalContextProvider","NormalCancelBtn","NormalOkBtn","jsxs","Fragment","AntModal","Stack","Truncate","IconButton","clsx","modal"],"mappings":";;;;;;;;;;;;;;;;;AA8GO,MAAMA,KAAQ,CAAC;AAAA,EACpB,MAAMC;AAAA,EACN,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,MAAMC;AAAA,EACN,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,YAAAC;AAAA,EACA,eAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,SAAAC;AAAA,EACA,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,QAAAC;AAAA,EACA,QAAAC,IAAS;AAAA,EACT,gBAAAC;AAAA,EACA,YAAAC,IAAa;AAAA,EACb,cAAAC,IAAe;AAAA,EACf,kBAAAC,IAAmB;AAAA,EACnB,gBAAAC;AAAA,EACA,OAAAC;AAAA,EACA,YAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,0BAAAC,IAA2B;AAAA,EAC3B,UAAAC,IAAW;AAAA,EACX,MAAAC,IAAO;AAAA,EACP,aAAAC,IAAc;AAAA,EACd,YAAYC;AAAA,EACZ,gBAAAC,IAAiB;AAAA,EACjB,eAAAC;AAAA,EACA,GAAGC;AACL,MAAkB;AAEhB,QAAMC,KACJhC,MAAc,SAAY,gBAAAiC,EAACC,MAAM,MAAM,IAAI,QAAO,OAAA,CAAO,IAAKlC,GAK1DmC,IAA+BjC,MAFZwB,MAAS,YAAY,WAAW,WAGnDU,KAAahC,KAASiC,EAAUF,CAAI,GAWpCG,KAAa;AAAA,IACjB,iBAAiB,qBATjBV,MAEAO,KAAQE,KACR,SAASA,EAAUF,CAAI,CAAC,KAAK,SAASE,EAAU,MAAM,IAClD,aACA,YAI4C;AAAA,IAChD,GAAGhC;AAAA,IACH,GAAI8B,MAAS,e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AA,YACD,gBAAAW;AAAA,cAAC4C;AAAA,cAAA;AAAA,gBACC,SAAS,CAAC,MACRV,EAAa,CAAC;AAAA,gBAGf,UAAAnC;AAAA,cAAA;AAAA,YAAA;AAAA,YAEFT;AAAA,UAAA,EAAA,CACH;AAAA,QAAA,GAEF;AAAA,QACCF,KAA0B;AAAA,MAAA,GAC7B;AAAA,MAUA,eAAeyD,GAAKjC,IAAgBf,CAAa;AAAA,MACjD,YAAY;AAAA,QACV,GAAGvB;AAAA,QACH,SAASoC;AAAA,UACP;AAAA,UACAR,KAAQ,gBAAgB;AAAA,UACxBK,KAAqB;AAAA,UACrBX,MAAmB,MAAS;AAAA,UAC5BL,KAA4BgB,KAAqBL,KAAQ,eACrD,gBACA;AAAA,QAAA;AAAA,MACN;AAAA,MAEF,QAAQI;AAAA,MACR,aAAa,CAACwC,MACZ,gBAAA9C,EAAC,OAAA,EAAI,KAAKgB,IAAe,WAAWN,EAAI,aAAa,GAClD,UAAAoC,EAAA,CACH;AAAA,MAEF,eAAelB;AAAA,MACf,mBAAmBC;AAAA,MACnB,MAAM,CAAC,MAAM;AACX,QAAIG,OAAkC,EAAK,GAC3CtD,IAAO,CAAC;AAAA,MACV;AAAA,MACA,UAAU,CAAC,MAAM;AACf,QAAII,MACAkD,OAAkC,EAAK,GAC3CrD,IAAW,CAAC;AAAA,MACd;AAAA,MACA,QAAAC;AAAA,MACA,YAAAG;AAAA,MACA,QAAO;AAAA,MACP,gBAAAD;AAAA,MACA,QACE,OAAOZ,IAAW,MACdc,KAAgBC,IACd,OACAkD,KACFjE;AAAA,MAEN,UAAAsB;AAAA,MACA,SAAAf;AAAA,MACC,GAAGqB;AAAA,MAEH,UAAA9B;AAAA,IAAA;AAAA,EAAA;AAGP;"}
1
+ {"version":3,"file":"Modal.js","sources":["../../../src/components/modal/Modal.tsx"],"sourcesContent":["\"use client\";\nimport {\n default as AntModal,\n type ModalProps as AntModalProps,\n} from \"antd/es/modal\";\nimport { XIcon } from \"@bioturing/assets\";\nimport React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { useStableCallback } from \"@base-ui/utils/useStableCallback\";\nimport { clsx, useCls } from \"../utils\";\nimport { ModalContextProvider } from \"antd/es/modal/context\";\nimport NormalCancelBtn from \"antd/es/modal/components/NormalCancelBtn\";\nimport NormalOkBtn from \"antd/es/modal/components/NormalOkBtn\";\nimport { getConfirmLocale } from \"antd/es/modal/locale\";\nimport { useLocale } from \"antd/es/locale\";\nimport { IconButton } from \"../icon-button\";\nimport { ModalSize } from \"./constants\";\nimport { ModalType } from \"./functions\";\nimport { Truncate } from \"../truncate\";\nimport { Stack } from \"../stack\";\nimport { useTheme } from \"../theme-provider\";\n\n// Define props interface extending Ant Design's ModalProps\nexport interface ModalProps extends Omit<AntModalProps, \"centered\"> {\n /**\n * Predefined sizes for the modal\n * - xsmall: 400px\n * - small: 520px\n * - medium: 640px (default)\n * - large: 840px\n * - xlarge: 1024px\n * - fullscreen: 100vw (takes full screen width with margins)\n * @default \"medium\" for default type, \"xsmall\" for other types\n */\n size?:\n | \"xsmall\"\n | \"small\"\n | \"medium\"\n | \"large\"\n | \"xlarge\"\n | \"xxlarge\"\n | \"fullscreen\";\n /**\n * Mark modal as loading\n * @default false\n */\n loading?: boolean;\n /**\n * Hide Ok button\n * @default false\n */\n hideOkButton?: boolean;\n /**\n * Hide Cancel button\n * @default false\n */\n hideCancelButton?: boolean;\n /**\n * Custom Content Padding\n * @default \"24px\"\n */\n contentPadding?: number | string | boolean;\n /**\n * Add more content below the title\n */\n afterTitle?: React.ReactNode;\n /**\n * Add more actions before close button\n */\n beforeCloseButton?: React.ReactNode;\n /**\n * Add more actions after close button\n */\n afterCloseButton?: React.ReactNode;\n /**\n * Set header and footer to fixed position\n * @default false\n */\n defaultFixedHeaderFooter?: boolean;\n /**\n * Centered Modal\n * @default true\n */\n centered?: boolean;\n /**\n * Modal type\n * @default \"default\"\n */\n type?: ModalType;\n /**\n * Default open state for uncontrolled modal\n * @default true\n */\n defaultOpen?: boolean;\n /**\n * Modal background\n * @default \"elevated\" if size smaller than \"medium\", otherwise \"container\"\n */\n background?: \"elevated\" | \"container\";\n /**\n * Modal old close callback\n * @deprecated use onCancel instead\n */\n onClose?: () => void;\n /**\n * Make modal body scrollable\n * @default true\n */\n bodyScrollable?: boolean;\n}\n\n// Create Modal component\nexport const Modal = ({\n open: externalOpen,\n closeIcon,\n children,\n size: sizeProp,\n footer,\n width,\n style,\n styles,\n classNames,\n okButtonProps,\n cancelButtonProps,\n loading,\n onOk,\n onCancel,\n okText,\n okType = \"primary\",\n confirmLoading,\n cancelText = \"Close\",\n hideOkButton = false,\n hideCancelButton = false,\n contentPadding,\n title,\n afterTitle,\n beforeCloseButton,\n afterCloseButton,\n defaultFixedHeaderFooter = false,\n centered = true,\n type = \"default\",\n defaultOpen = true,\n background: backgroundProp,\n bodyScrollable = true,\n rootClassName,\n ...rest\n}: ModalProps) => {\n // Default close icon with Phosphor icon\n const defaultCloseIcon =\n closeIcon === undefined ? <XIcon size={16} weight=\"bold\" /> : closeIcon;\n\n // Use custom width if provided, otherwise use the size from the map\n const defaultModalSize = type === \"default\" ? \"medium\" : \"xsmall\";\n\n const size: keyof typeof ModalSize = sizeProp || defaultModalSize;\n const modalWidth = width || ModalSize[size];\n\n const background =\n backgroundProp ||\n (size &&\n size in ModalSize &&\n parseInt(ModalSize[size]) <= parseInt(ModalSize.medium)\n ? \"elevated\"\n : \"container\");\n\n // Memoize modal styles to prevent recreating on every render\n const modalStyle = useMemo(\n () =>\n ({\n \"--ds-modal-bg\": `var(--ds-color-bg-${background})`,\n ...style,\n ...(size === \"fullscreen\"\n ? { top: 0, maxWidth: \"100%\", height: \"100%\" }\n : {}),\n }) as React.CSSProperties,\n [background, style, size],\n );\n\n const modalStyles = useMemo(\n () => ({\n ...styles,\n body: {\n ...((typeof contentPadding != \"undefined\"\n ? {\n \"--ds-modal-content-padding\":\n contentPadding === false || contentPadding === 0\n ? \"0\"\n : typeof contentPadding == \"number\"\n ? `${contentPadding}px`\n : contentPadding,\n }\n : {}) as React.CSSProperties),\n ...styles?.body,\n },\n }),\n [styles, contentPadding],\n );\n\n const [isContentOverflow, setIsContentOverflow] = useState(false);\n\n const cls = useCls();\n\n const { className: themeClassName } = useTheme();\n\n const resizeObserverRef = useRef<ResizeObserver | null>(null);\n\n const modalInnerRef = useCallback(\n (node: HTMLElement | null) => {\n // If the node is null (component unmounting), just return\n if (!node) return;\n\n const modalBody = node.querySelector(\".\" + cls(\"modal-body\"));\n if (!(modalBody instanceof HTMLElement)) return;\n\n // Create ResizeObserver to detect overflow\n const resizeObserver = new ResizeObserver(() => {\n const hasOverflow = modalBody.scrollHeight > modalBody.clientHeight;\n setIsContentOverflow(hasOverflow);\n });\n\n // Store reference to the observer\n resizeObserverRef.current = resizeObserver;\n\n // Start observing\n resizeObserver.observe(modalBody);\n\n // Initial check\n const hasOverflow = modalBody.scrollHeight > modalBody.clientHeight;\n setIsContentOverflow(hasOverflow);\n },\n [cls],\n );\n\n // clean up resize observer\n useEffect(() => {\n return () => {\n if (resizeObserverRef.current) {\n resizeObserverRef.current.disconnect();\n resizeObserverRef.current = null;\n }\n };\n }, []);\n\n const [locale] = useLocale(\"Modal\", getConfirmLocale());\n\n const okTextLocale: React.ReactNode = okText || locale?.okText;\n const cancelTextLocale = cancelText || locale?.cancelText;\n\n const modalOkButtonProps = useMemo(\n () => ({\n // loading: typeof confirmLoading === \"boolean\" ? confirmLoading : loading,\n ...okButtonProps,\n }),\n [okButtonProps],\n );\n\n const modalCancelButtonProps = useMemo(\n () => ({\n ...cancelButtonProps,\n }),\n [cancelButtonProps],\n );\n\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n\n const uncontrolledOpen = typeof externalOpen === \"undefined\";\n\n const open = uncontrolledOpen ? internalOpen : externalOpen;\n\n const handleCancel = useStableCallback(\n (e: React.MouseEvent<HTMLButtonElement>) => {\n if (confirmLoading) {\n return;\n }\n onCancel?.(e);\n },\n );\n\n const modalContextValue = useMemo(\n () => ({\n okButtonProps: modalOkButtonProps,\n cancelButtonProps: modalCancelButtonProps,\n onCancel: handleCancel,\n onOk,\n okType,\n confirmLoading,\n okTextLocale,\n cancelTextLocale,\n }),\n [\n modalOkButtonProps,\n modalCancelButtonProps,\n onOk,\n okType,\n confirmLoading,\n okTextLocale,\n cancelTextLocale,\n handleCancel,\n ],\n );\n\n const defaultFooter = useMemo(\n () => (\n <ModalContextProvider value={modalContextValue}>\n {hideOkButton ? (\n <NormalCancelBtn />\n ) : hideCancelButton ? (\n <NormalOkBtn />\n ) : (\n <>\n <NormalCancelBtn />\n <NormalOkBtn />\n </>\n )}\n </ModalContextProvider>\n ),\n [modalContextValue, hideOkButton, hideCancelButton],\n );\n\n const renderTitle = () => {\n return (\n <>\n <Stack align=\"center\" gap={8} className={cls(\"modal-title-wrapper\")}>\n <Stack.Child grow>\n {typeof title === \"string\" ? <Truncate>{title}</Truncate> : title}\n </Stack.Child>\n <Stack.Child stack hug align=\"center\" gap={8}>\n {beforeCloseButton}\n <IconButton\n onClick={(e: React.MouseEvent<HTMLButtonElement>) =>\n handleCancel(e)\n }\n >\n {defaultCloseIcon}\n </IconButton>\n {afterCloseButton}\n </Stack.Child>\n {}\n </Stack>\n {afterTitle ? afterTitle : null}\n </>\n );\n };\n return (\n <AntModal\n closeIcon={false}\n open={open}\n width={modalWidth}\n style={modalStyle}\n title={renderTitle()}\n rootClassName={clsx(themeClassName, rootClassName)}\n classNames={{\n ...classNames,\n wrapper: cls(\n \"modal-wrap\",\n size == \"fullscreen\" && \"modal-fullscreen\",\n isContentOverflow && \"modal-content-overflow\",\n bodyScrollable === false && \"modal-no-body-scroll\",\n defaultFixedHeaderFooter || isContentOverflow || size == \"fullscreen\"\n ? \"modal-fixed\"\n : \"\",\n ),\n }}\n styles={modalStyles}\n modalRender={(modal) => (\n <div ref={modalInnerRef} className={cls(\"modal-inner\")}>\n {modal}\n </div>\n )}\n okButtonProps={modalOkButtonProps}\n cancelButtonProps={modalCancelButtonProps}\n onOk={(e) => {\n if (uncontrolledOpen) setInternalOpen(false);\n onOk?.(e);\n }}\n onCancel={(e) => {\n if (confirmLoading) return;\n if (uncontrolledOpen) setInternalOpen(false);\n onCancel?.(e);\n }}\n okText={okText}\n cancelText={cancelText}\n okType=\"primary\"\n confirmLoading={confirmLoading}\n footer={\n typeof footer === \"undefined\"\n ? hideOkButton && hideCancelButton\n ? null\n : defaultFooter\n : footer\n }\n centered={centered}\n loading={loading}\n {...rest}\n >\n {children}\n </AntModal>\n );\n};\n"],"names":["Modal","externalOpen","closeIcon","children","sizeProp","footer","width","style","styles","classNames","okButtonProps","cancelButtonProps","loading","onOk","onCancel","okText","okType","confirmLoading","cancelText","hideOkButton","hideCancelButton","contentPadding","title","afterTitle","beforeCloseButton","afterCloseButton","defaultFixedHeaderFooter","centered","type","defaultOpen","backgroundProp","bodyScrollable","rootClassName","rest","defaultCloseIcon","jsx","XIcon","size","modalWidth","ModalSize","background","modalStyle","useMemo","modalStyles","isContentOverflow","setIsContentOverflow","useState","cls","useCls","themeClassName","useTheme","resizeObserverRef","useRef","modalInnerRef","useCallback","node","modalBody","resizeObserver","hasOverflow","useEffect","locale","useLocale","getConfirmLocale","okTextLocale","cancelTextLocale","modalOkButtonProps","modalCancelButtonProps","internalOpen","setInternalOpen","uncontrolledOpen","open","handleCancel","useStableCallback","modalContextValue","defaultFooter","ModalContextProvider","NormalCancelBtn","NormalOkBtn","jsxs","Fragment","AntModal","Stack","Truncate","IconButton","clsx","modal"],"mappings":";;;;;;;;;;;;;;;;;;AAqHO,MAAMA,KAAQ,CAAC;AAAA,EACpB,MAAMC;AAAA,EACN,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,MAAMC;AAAA,EACN,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,YAAAC;AAAA,EACA,eAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,SAAAC;AAAA,E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PopupPanelSize } from './constants';
3
- export type PopupPanelPlacement = "top" | "left" | "right" | "bottom" | "topLeft" | "topRight" | "bottomLeft" | "bottomRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom";
4
- export interface PopupPanelProps extends Omit<React.ComponentPropsWithRef<"div">, "title" | "content" | "children">, Omit<Popover.Root.Props, "children"> {
5
- /** The trigger element that opens the popup panel */
6
- children?: React.ComponentProps<typeof Popover.Trigger>["render"];
7
- /** Placement of the popup panel relative to its trigger */
8
- placement?: PopupPanelPlacement;
9
- /** Whether to open the popup panel on hover */
10
- openOnHover?: boolean;
11
- /** Controls the open state of the popup panel */
12
- open?: boolean;
13
- /** Callback fired when the open state changes */
14
- onOpenChange?: Popover.Root.Props["onOpenChange"];
15
- /** Content to display inside the popup panel */
16
- content?: React.ReactNode;
17
- /** Title text or element to display in the panel header */
18
- title?: React.ReactNode;
19
- /** The event that triggers the popup panel */
20
- /**
21
- * @default "click"
22
- */
23
- trigger?: "click" | "hover";
24
- /** Custom anchor element for positioning the panel */
25
- anchor?: Popover.Positioner.Props["anchor"];
26
- /** Content to display before the close button */
27
- beforeCloseButton?: React.ReactNode;
28
- /** Content to display after the close button */
29
- afterCloseButton?: React.ReactNode;
30
- /** Content to display after the title */
31
- afterTitle?: React.ReactNode;
32
- /**
33
- * Predefined sizes for the popup panel
34
- * - xsmall: 320px
35
- * - small: 400px
36
- * - medium: 480px (default)
37
- * - large: 640px
38
- * - xlarge: 840px
39
- * @default "medium" for default type, "xsmall" for other types
40
- */
41
- size?: keyof typeof PopupPanelSize;
42
- /**
43
- * Footer content for the popup panel
44
- * Can be a React node or a function that returns a React node
45
- */
46
- footer?: React.ReactNode | ((props: {
47
- close: () => void;
48
- }) => React.ReactNode);
49
- /**
50
- * Whether the panel should be open by default when uncontrolled
51
- * @default false
52
- */
53
- defaultOpen?: boolean;
54
- /**
55
- * Whether the panel should be resizable
56
- * @default false
57
- */
58
- resizable?: boolean;
59
- /**
60
- * Whether the panel should be draggable
61
- * @default false
62
- */
63
- draggable?: boolean;
64
- /**
65
- * Whether to maintain aspect ratio when resizing
66
- * Only applies when resizable is true
67
- * @default false
68
- */
69
- maintainAspectRatio?: boolean;
70
- /**
71
- * Custom class names for different parts of the popup panel
72
- * @default {}
73
- */
74
- classNames?: {
75
- root?: string;
76
- trigger?: string;
77
- popup?: string;
78
- header?: string;
79
- title?: string;
80
- content?: string;
81
- footer?: string;
82
- resizeHandle?: string;
83
- };
84
- /**
85
- * Whether to close the panel when clicking outside
86
- * @default true
87
- */
88
- closeOnClickOutside?: boolean;
89
- /**
90
- * Whether to use modal mode
91
- * @default false
92
- */
93
- modal?: Popover.Root.Props["modal"];
94
- /**
95
- * Callback function when the placement changes
96
- */
97
- onPlacementChange?: (placement: PopupPanelPlacement) => void;
98
- /**
99
- * Props to pass to the positioner
100
- */
101
- positionerProps?: Popover.Positioner.Props;
102
- /**
103
- * Props to pass to the trigger
104
- */
105
- triggerProps?: Popover.Trigger.Props;
106
- /**
107
- * Props to pass to the portal
108
- */
109
- portalProps?: Popover.Portal.Props;
110
- }
111
- export declare const PopupPanel: ({ children, placement, openOnHover, open: outsideOpen, onOpenChange: outsideOnOpenChange, content, title, trigger, className, anchor, beforeCloseButton, afterCloseButton, afterTitle, size, footer, defaultOpen, resizable, draggable, maintainAspectRatio, classNames, modal, closeOnClickOutside, onPlacementChange, positionerProps, triggerProps, portalProps, ...rest }: PopupPanelProps) => import("react/jsx-runtime").JSX.Element;
1
+ import { PopupPanelProps } from './types';
2
+ export declare const PopupPanel: ({ children, placement, openOnHover, open: outsideOpen, onOpenChange: outsideOnOpenChange, content, title, trigger, className, anchor, beforeCloseButton, afterCloseButton, afterTitle, size, footer, defaultOpen, resizable, draggable, maintainAspectRatio, classNames, modal, closeOnClickOutside, onPlacementChange, positionerProps, triggerProps, portalProps, offsetFrom, nativeButton, ...rest }: PopupPanelProps) => import("react/jsx-runtime").JSX.Element;
112
3
  //# sourceMappingURL=component.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/popup-panel/component.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAUjD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAI7C,OAAO,aAAa,CAAC;AAGrB,MAAM,MAAM,mBAAmB,GAC3B,KAAK,GACL,MAAM,GACN,OAAO,GACP,QAAQ,GACR,SAAS,GACT,UAAU,GACV,YAAY,GACZ,aAAa,GACb,SAAS,GACT,YAAY,GACZ,UAAU,GACV,aAAa,CAAC;AAElB,MAAM,WAAW,eACf,SAAQ,IAAI,CACR,KAAK,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAClC,OAAO,GAAG,SAAS,GAAG,UAAU,CACjC,EACD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC;IACtC,qDAAqD;IACrD,QAAQ,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC;IAClE,2DAA2D;IAC3D,SAAS,CAAC,EAAE,mBAAmB,CAAC;IAChC,+CAA+C;IAC/C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,iDAAiD;IACjD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,iDAAiD;IACjD,YAAY,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAClD,gDAAgD;IAChD,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,2DAA2D;IAC3D,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,8CAA8C;IAC9C;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IAC5B,sDAAsD;IACtD,MAAM,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC5C,iD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AAC,KAAK,CAAC;IAC3C;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;IACrC;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;CACpC;AAED,eAAO,MAAM,UAAU,GAAI,+WA4BxB,eAAe,4CA0KjB,CAAC"}
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/popup-panel/component.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAI1C,OAAO,aAAa,CAAC;AAoCrB,eAAO,MAAM,UAAU,GAAI,yYA8BxB,eAAe,4CA2SjB,CAAC"}