@bioturing/components 0.32.3 → 0.33.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.
- package/dist/components/code-block/component.d.ts.map +1 -1
- package/dist/components/code-block/component.js +41 -42
- package/dist/components/code-block/component.js.map +1 -1
- package/dist/components/command-palette/component.d.ts.map +1 -1
- package/dist/components/command-palette/component.js +18 -18
- package/dist/components/command-palette/component.js.map +1 -1
- package/dist/components/data-table/component.d.ts +8 -0
- package/dist/components/data-table/component.d.ts.map +1 -0
- package/dist/components/data-table/component.js +112 -0
- package/dist/components/data-table/component.js.map +1 -0
- package/dist/components/data-table/components/TableBody.d.ts +15 -0
- package/dist/components/data-table/components/TableBody.d.ts.map +1 -0
- package/dist/components/data-table/components/TableBody.js +114 -0
- package/dist/components/data-table/components/TableBody.js.map +1 -0
- package/dist/components/data-table/components/TableHeader.d.ts +11 -0
- package/dist/components/data-table/components/TableHeader.d.ts.map +1 -0
- package/dist/components/data-table/components/TableHeader.js +103 -0
- package/dist/components/data-table/components/TableHeader.js.map +1 -0
- package/dist/components/data-table/components/TablePagination.d.ts +10 -0
- package/dist/components/data-table/components/TablePagination.d.ts.map +1 -0
- package/dist/components/data-table/components/TablePagination.js +38 -0
- package/dist/components/data-table/components/TablePagination.js.map +1 -0
- package/dist/components/data-table/components/index.d.ts +4 -0
- package/dist/components/data-table/components/index.d.ts.map +1 -0
- package/dist/components/data-table/hooks.d.ts +14 -0
- package/dist/components/data-table/hooks.d.ts.map +1 -0
- package/dist/components/data-table/hooks.js +120 -0
- package/dist/components/data-table/hooks.js.map +1 -0
- package/dist/components/data-table/index.d.ts +4 -0
- package/dist/components/data-table/index.d.ts.map +1 -0
- package/dist/components/data-table/style.css +1 -0
- package/dist/components/data-table/types.d.ts +108 -0
- package/dist/components/data-table/types.d.ts.map +1 -0
- package/dist/components/data-table/utils.d.ts +39 -0
- package/dist/components/data-table/utils.d.ts.map +1 -0
- package/dist/components/data-table/utils.js +71 -0
- package/dist/components/data-table/utils.js.map +1 -0
- package/dist/components/dropdown-menu/component.d.ts.map +1 -1
- package/dist/components/dropdown-menu/component.js +60 -56
- package/dist/components/dropdown-menu/component.js.map +1 -1
- package/dist/components/ds-root/component.d.ts.map +1 -1
- package/dist/components/ds-root/component.js +15 -16
- package/dist/components/ds-root/component.js.map +1 -1
- package/dist/components/ds-root/hook.d.ts +5 -0
- package/dist/components/ds-root/hook.d.ts.map +1 -0
- package/dist/components/ds-root/hook.js +7 -0
- package/dist/components/ds-root/hook.js.map +1 -0
- package/dist/components/ds-root/index.d.ts +1 -1
- package/dist/components/ds-root/index.d.ts.map +1 -1
- package/dist/components/field/component.d.ts.map +1 -1
- package/dist/components/field/component.js +22 -21
- package/dist/components/field/component.js.map +1 -1
- package/dist/components/hooks/useBreakpoint.d.ts.map +1 -1
- package/dist/components/hooks/useBreakpoint.js +30 -8
- package/dist/components/hooks/useBreakpoint.js.map +1 -1
- package/dist/components/hooks/useCharts.js +1 -1
- package/dist/components/hooks/useCharts.js.map +1 -1
- package/dist/components/index.d.ts +3 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/modal/Modal.d.ts +1 -1
- package/dist/components/modal/Modal.d.ts.map +1 -1
- package/dist/components/modal/Modal.js +59 -55
- package/dist/components/modal/Modal.js.map +1 -1
- package/dist/components/modal/index.d.ts +1 -1
- package/dist/components/popover/component.d.ts.map +1 -1
- package/dist/components/popover/component.js +22 -9
- package/dist/components/popover/component.js.map +1 -1
- package/dist/components/popup-panel/component.d.ts.map +1 -1
- package/dist/components/popup-panel/component.js +61 -56
- package/dist/components/popup-panel/component.js.map +1 -1
- package/dist/components/scroll-area/component.d.ts.map +1 -1
- package/dist/components/scroll-area/component.js +28 -28
- package/dist/components/scroll-area/component.js.map +1 -1
- package/dist/components/table/component.d.ts.map +1 -1
- package/dist/components/table/component.js.map +1 -1
- package/dist/components/theme-provider/component.d.ts +6 -2
- package/dist/components/theme-provider/component.d.ts.map +1 -1
- package/dist/components/theme-provider/component.js +32 -28
- package/dist/components/theme-provider/component.js.map +1 -1
- package/dist/components/theme-provider/context/index.d.ts +3 -0
- package/dist/components/theme-provider/context/index.d.ts.map +1 -0
- package/dist/components/theme-provider/context/provider.d.ts +7 -0
- package/dist/components/theme-provider/context/provider.d.ts.map +1 -0
- package/dist/components/theme-provider/context/provider.js +11 -0
- package/dist/components/theme-provider/context/provider.js.map +1 -0
- package/dist/components/theme-provider/context/themeStore.d.ts +11 -0
- package/dist/components/theme-provider/context/themeStore.d.ts.map +1 -0
- package/dist/components/theme-provider/context/themeStore.js +15 -0
- package/dist/components/theme-provider/context/themeStore.js.map +1 -0
- package/dist/components/theme-provider/index.d.ts +1 -0
- package/dist/components/theme-provider/index.d.ts.map +1 -1
- package/dist/components/tree/useTreeCommon.d.ts +10 -10
- package/dist/components/tree/useTreeCommon.d.ts.map +1 -1
- package/dist/components/utils/client.d.ts +0 -1
- package/dist/components/utils/client.d.ts.map +1 -1
- package/dist/index.js +223 -219
- package/dist/index.js.map +1 -1
- package/dist/metadata.d.ts +9 -0
- package/dist/metadata.d.ts.map +1 -1
- package/dist/metadata.js +18 -0
- package/dist/metadata.js.map +1 -1
- package/dist/stats.html +1 -1
- package/package.json +3 -2
- package/dist/components/ds-root/context.d.ts +0 -8
- package/dist/components/ds-root/context.d.ts.map +0 -1
- package/dist/components/ds-root/context.js +0 -10
- package/dist/components/ds-root/context.js.map +0 -1
- package/dist/components/utils/WithAntdTokens.d.ts +0 -8
- package/dist/components/utils/WithAntdTokens.d.ts.map +0 -1
- package/dist/components/utils/WithAntdTokens.js +0 -25
- package/dist/components/utils/WithAntdTokens.js.map +0 -1
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as e, jsxs as s } from "react/jsx-runtime";
|
|
3
3
|
import { Popover as o } from "@base-ui-components/react/popover";
|
|
4
|
-
import { useMemo as
|
|
5
|
-
import { X as
|
|
6
|
-
import { PopupPanelSize as
|
|
7
|
-
import { Stack as
|
|
4
|
+
import { useMemo as W, useRef as w, useState as Y, useEffect as Z, useCallback as _ } from "react";
|
|
5
|
+
import { X as B } from "@bioturing/assets";
|
|
6
|
+
import { PopupPanelSize as ee } from "./constants.js";
|
|
7
|
+
import { Stack as te } from "../stack/index.js";
|
|
8
8
|
import './style.css';/* empty css */
|
|
9
|
-
import { parseAntdPlacement as
|
|
10
|
-
import { useDraggable as
|
|
11
|
-
import { Resizable as
|
|
12
|
-
import { useControlledState as
|
|
13
|
-
import { useCls as
|
|
9
|
+
import { parseAntdPlacement as re, buildAntdPlacement as ne } from "../utils/placement.js";
|
|
10
|
+
import { useDraggable as ie } from "../hooks/useDraggable.js";
|
|
11
|
+
import { Resizable as oe } from "../resizable/component.js";
|
|
12
|
+
import { useControlledState as pe } from "../hooks/useControlledState.js";
|
|
13
|
+
import { useCls as ae } from "../utils/antdUtils.js";
|
|
14
|
+
import { useTheme as le } from "../theme-provider/context/themeStore.js";
|
|
14
15
|
import { clsx as p } from "../utils/cn.js";
|
|
15
|
-
import { IconButton as
|
|
16
|
-
const
|
|
16
|
+
import { IconButton as se } from "../icon-button/component.js";
|
|
17
|
+
const Re = ({
|
|
17
18
|
children: z,
|
|
18
19
|
placement: k,
|
|
19
20
|
openOnHover: H = !1,
|
|
@@ -23,15 +24,15 @@ const Oe = ({
|
|
|
23
24
|
title: f,
|
|
24
25
|
trigger: E = "click",
|
|
25
26
|
className: M,
|
|
26
|
-
anchor:
|
|
27
|
-
beforeCloseButton:
|
|
28
|
-
afterCloseButton:
|
|
27
|
+
anchor: T,
|
|
28
|
+
beforeCloseButton: y,
|
|
29
|
+
afterCloseButton: C,
|
|
29
30
|
afterTitle: m,
|
|
30
31
|
size: g = "medium",
|
|
31
32
|
footer: c,
|
|
32
|
-
defaultOpen:
|
|
33
|
-
resizable:
|
|
34
|
-
draggable:
|
|
33
|
+
defaultOpen: D,
|
|
34
|
+
resizable: O = !1,
|
|
35
|
+
draggable: F = !1,
|
|
35
36
|
maintainAspectRatio: U = !1,
|
|
36
37
|
classNames: r,
|
|
37
38
|
modal: V = !1,
|
|
@@ -39,35 +40,35 @@ const Oe = ({
|
|
|
39
40
|
onPlacementChange: h,
|
|
40
41
|
...$
|
|
41
42
|
}) => {
|
|
42
|
-
const [b,
|
|
43
|
+
const [b, R] = pe(
|
|
43
44
|
I,
|
|
44
45
|
K,
|
|
45
|
-
|
|
46
|
+
D ?? !1
|
|
46
47
|
// Always provide a default value to prevent undefined
|
|
47
|
-
), t =
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
if (!
|
|
51
|
-
const d = new MutationObserver((
|
|
52
|
-
let
|
|
53
|
-
if (
|
|
48
|
+
), t = ae(), { className: q } = le(), u = re(k), A = W(() => /* @__PURE__ */ e(B, { size: 16 }), []), S = w(null), v = w(u.side), P = w(u.align), [G, J] = Y(0);
|
|
49
|
+
Z(() => {
|
|
50
|
+
const a = S.current;
|
|
51
|
+
if (!a || !b) return;
|
|
52
|
+
const d = new MutationObserver((l) => {
|
|
53
|
+
let N = !1;
|
|
54
|
+
if (l.forEach((i) => {
|
|
54
55
|
if (i.type === "attributes" && i.attributeName === "data-side") {
|
|
55
|
-
const n =
|
|
56
|
-
n && n !== v.current && (v.current = n,
|
|
56
|
+
const n = a.getAttribute(i.attributeName);
|
|
57
|
+
n && n !== v.current && (v.current = n, N = !0);
|
|
57
58
|
}
|
|
58
59
|
if (i.type === "attributes" && i.attributeName === "data-align") {
|
|
59
|
-
const n =
|
|
60
|
-
n && n !== P.current && (P.current = n,
|
|
60
|
+
const n = a.getAttribute(i.attributeName);
|
|
61
|
+
n && n !== P.current && (P.current = n, N = !0);
|
|
61
62
|
}
|
|
62
|
-
}),
|
|
63
|
-
const i =
|
|
63
|
+
}), N) {
|
|
64
|
+
const i = ne({
|
|
64
65
|
side: v.current,
|
|
65
66
|
align: P.current
|
|
66
67
|
});
|
|
67
|
-
|
|
68
|
+
J((n) => n + 1), h && h(i);
|
|
68
69
|
}
|
|
69
70
|
});
|
|
70
|
-
return d.observe(
|
|
71
|
+
return d.observe(a, {
|
|
71
72
|
attributes: !0,
|
|
72
73
|
attributeFilter: ["data-side", "data-align"],
|
|
73
74
|
attributeOldValue: !0
|
|
@@ -75,9 +76,9 @@ const Oe = ({
|
|
|
75
76
|
d.disconnect();
|
|
76
77
|
};
|
|
77
78
|
}, [h, b]);
|
|
78
|
-
const
|
|
79
|
+
const L = _(() => /* @__PURE__ */ s("div", { className: p(t("popup-panel-header"), r?.header), children: [
|
|
79
80
|
/* @__PURE__ */ s(
|
|
80
|
-
|
|
81
|
+
te,
|
|
81
82
|
{
|
|
82
83
|
align: "center",
|
|
83
84
|
gap: 8,
|
|
@@ -90,29 +91,29 @@ const Oe = ({
|
|
|
90
91
|
}
|
|
91
92
|
),
|
|
92
93
|
/* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
|
|
93
|
-
|
|
94
|
+
y,
|
|
94
95
|
/* @__PURE__ */ e(
|
|
95
96
|
o.Close,
|
|
96
97
|
{
|
|
97
|
-
render: /* @__PURE__ */ e(
|
|
98
|
+
render: /* @__PURE__ */ e(se, { children: A })
|
|
98
99
|
}
|
|
99
100
|
),
|
|
100
|
-
|
|
101
|
+
C
|
|
101
102
|
] })
|
|
102
103
|
]
|
|
103
104
|
}
|
|
104
105
|
),
|
|
105
106
|
m || null
|
|
106
107
|
] }), [
|
|
107
|
-
|
|
108
|
+
C,
|
|
108
109
|
m,
|
|
109
|
-
|
|
110
|
+
y,
|
|
110
111
|
t,
|
|
111
112
|
r?.header,
|
|
112
113
|
r?.title,
|
|
113
|
-
|
|
114
|
+
A,
|
|
114
115
|
f
|
|
115
|
-
]), { ref:
|
|
116
|
+
]), { ref: Q } = ie(F), x = /* @__PURE__ */ s(
|
|
116
117
|
o.Popup,
|
|
117
118
|
{
|
|
118
119
|
className: p(
|
|
@@ -121,11 +122,11 @@ const Oe = ({
|
|
|
121
122
|
M,
|
|
122
123
|
r?.popup
|
|
123
124
|
),
|
|
124
|
-
ref:
|
|
125
|
+
ref: Q,
|
|
125
126
|
children: [
|
|
126
|
-
f &&
|
|
127
|
+
f && L(),
|
|
127
128
|
/* @__PURE__ */ e("div", { className: p(t("popup-panel-content"), r?.content), children: /* @__PURE__ */ e("div", { className: t("popup-panel-content-inner"), children: j }) }),
|
|
128
|
-
c && /* @__PURE__ */ e("div", { className: p(t("popup-panel-footer"), r?.footer), children: typeof c == "function" ? c({ close: () =>
|
|
129
|
+
c && /* @__PURE__ */ e("div", { className: p(t("popup-panel-footer"), r?.footer), children: typeof c == "function" ? c({ close: () => R(!1) }) : c })
|
|
129
130
|
]
|
|
130
131
|
}
|
|
131
132
|
);
|
|
@@ -134,8 +135,8 @@ const Oe = ({
|
|
|
134
135
|
{
|
|
135
136
|
openOnHover: E === "hover" ? !0 : H,
|
|
136
137
|
open: b,
|
|
137
|
-
onOpenChange: (
|
|
138
|
-
(
|
|
138
|
+
onOpenChange: (a, d, l) => {
|
|
139
|
+
(l === "outside-press" || l === "focus-out") && !X || R(a, d, l);
|
|
139
140
|
},
|
|
140
141
|
modal: V,
|
|
141
142
|
...$,
|
|
@@ -151,20 +152,24 @@ const Oe = ({
|
|
|
151
152
|
o.Positioner,
|
|
152
153
|
{
|
|
153
154
|
ref: S,
|
|
154
|
-
className: p(
|
|
155
|
+
className: p(
|
|
156
|
+
t("popup-panel-root"),
|
|
157
|
+
q,
|
|
158
|
+
r?.root
|
|
159
|
+
),
|
|
155
160
|
side: u.side,
|
|
156
161
|
align: u.align,
|
|
157
162
|
sideOffset: 4,
|
|
158
|
-
anchor:
|
|
163
|
+
anchor: T,
|
|
159
164
|
style: {
|
|
160
|
-
"--size-width": g ?
|
|
165
|
+
"--size-width": g ? ee[g] : void 0
|
|
161
166
|
},
|
|
162
|
-
children:
|
|
163
|
-
|
|
167
|
+
children: O ? /* @__PURE__ */ e(
|
|
168
|
+
oe,
|
|
164
169
|
{
|
|
165
|
-
resizable:
|
|
170
|
+
resizable: O,
|
|
166
171
|
absolutePositioning: !0,
|
|
167
|
-
resetKey:
|
|
172
|
+
resetKey: G,
|
|
168
173
|
maintainAspectRatio: U,
|
|
169
174
|
classNames: {
|
|
170
175
|
resizeHandle: r?.resizeHandle
|
|
@@ -179,6 +184,6 @@ const Oe = ({
|
|
|
179
184
|
);
|
|
180
185
|
};
|
|
181
186
|
export {
|
|
182
|
-
|
|
187
|
+
Re as PopupPanel
|
|
183
188
|
};
|
|
184
189
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../../src/components/popup-panel/component.tsx"],"sourcesContent":["\"use client\";\nimport {\n useCls,\n clsx,\n parseAntdPlacement,\n buildAntdPlacement,\n BaseUIPlacement,\n BaseUISide,\n BaseUIAlign,\n} from \"../utils\";\nimport { Popover } from \"@base-ui-components/react/popover\";\n\nimport { type PopoverProps } from \"antd/es/popover\";\nimport { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { IconButton } from \"../icon-button\";\nimport { X } from \"@bioturing/assets\";\nimport { PopupPanelSize } from \"./constants\";\nimport { useControlledState, useDraggable } from \"../hooks\";\nimport { Resizable } from \"../resizable\";\nimport { Stack } from \"../stack\";\n\n// Import component-specific styles\nimport \"./style.css\";\nimport { useRef } from \"react\";\n\nexport interface PopupPanelProps\n extends Omit<\n React.ComponentPropsWithRef<\"div\">,\n \"title\" | \"content\" | \"children\"\n >,\n Omit<Popover.Root.Props, \"children\"> {\n /** The trigger element that opens the popup panel */\n children?: React.ComponentProps<typeof Popover.Trigger>[\"render\"];\n /** Placement of the popup panel relative to its trigger */\n placement?: PopoverProps[\"placement\"];\n /** Whether to open the popup panel on hover */\n openOnHover?: boolean;\n /** Controls the open state of the popup panel */\n open?: boolean;\n /** Callback fired when the open state changes */\n onOpenChange?: Popover.Root.Props[\"onOpenChange\"];\n /** Content to display inside the popup panel */\n content?: React.ReactNode;\n /** Title text or element to display in the panel header */\n title?: React.ReactNode;\n /** The event that triggers the popup panel */\n /**\n * @default \"click\"\n */\n trigger?: \"click\" | \"hover\";\n /** Custom anchor element for positioning the panel */\n anchor?: Popover.Positioner.Props[\"anchor\"];\n /** Content to display before the close button */\n beforeCloseButton?: React.ReactNode;\n /** Content to display after the close button */\n afterCloseButton?: React.ReactNode;\n /** Content to display after the title */\n afterTitle?: React.ReactNode;\n /**\n * Predefined sizes for the popup panel\n * - xsmall: 320px\n * - small: 400px\n * - medium: 480px (default)\n * - large: 640px\n * - xlarge: 840px\n * @default \"medium\" for default type, \"xsmall\" for other types\n */\n size?: keyof typeof PopupPanelSize;\n /**\n * Footer content for the popup panel\n * Can be a React node or a function that returns a React node\n */\n footer?:\n | React.ReactNode\n | ((props: { close: () => void }) => React.ReactNode);\n /**\n * Whether the panel should be open by default when uncontrolled\n * @default false\n */\n defaultOpen?: boolean;\n /**\n * Whether the panel should be resizable\n * @default false\n */\n resizable?: boolean;\n /**\n * Whether the panel should be draggable\n * @default false\n */\n draggable?: boolean;\n /**\n * Whether to maintain aspect ratio when resizing\n * Only applies when resizable is true\n * @default false\n */\n maintainAspectRatio?: boolean;\n /**\n * Custom class names for different parts of the popup panel\n * @default {}\n */\n classNames?: {\n root?: string;\n trigger?: string;\n popup?: string;\n header?: string;\n title?: string;\n content?: string;\n footer?: string;\n resizeHandle?: string;\n };\n /**\n * Whether to close the panel when clicking outside\n * @default true\n */\n closeOnClickOutside?: boolean;\n /**\n * Whether to use modal mode\n * @default false\n */\n modal?: Popover.Root.Props[\"modal\"];\n /**\n * Callback function when the placement changes\n */\n onPlacementChange?: (placement: PopoverProps[\"placement\"]) => void;\n}\n\nexport const PopupPanel = ({\n children,\n placement,\n openOnHover = false,\n open: outsideOpen,\n onOpenChange: outsideOnOpenChange,\n content,\n title,\n trigger = \"click\",\n className,\n anchor,\n beforeCloseButton,\n afterCloseButton,\n afterTitle,\n size = \"medium\",\n footer,\n defaultOpen,\n resizable = false,\n draggable = false,\n maintainAspectRatio = false,\n classNames,\n modal = false,\n closeOnClickOutside = true,\n onPlacementChange,\n ...rest\n}: PopupPanelProps) => {\n // Use controlled state with proper initialization to prevent switching between controlled/uncontrolled\n const [open, setOpen] = useControlledState(\n outsideOpen,\n outsideOnOpenChange,\n defaultOpen ?? false, // Always provide a default value to prevent undefined\n );\n\n const cls = useCls();\n const baseUIPlacement = parseAntdPlacement(placement);\n\n const defaultCloseIcon = useMemo(() => <X size={16} />, []);\n\n const positionerRef = useRef<HTMLDivElement>(null);\n const currentSideRef = useRef<BaseUISide>(baseUIPlacement.side);\n const currentAlignRef = useRef<BaseUIAlign>(baseUIPlacement.align);\n const [placementChangeKey, setPlacementChangeKey] = useState(0);\n\n useEffect(() => {\n const positioner = positionerRef.current;\n if (!positioner || !open) return; // Only observe when popup is open\n\n // Create MutationObserver to watch for data-side changes\n const observer = new MutationObserver((mutations) => {\n let hasPlacementChanged = false;\n\n mutations.forEach((mutation) => {\n if (\n mutation.type === \"attributes\" &&\n mutation.attributeName === \"data-side\"\n ) {\n const newSide = positioner.getAttribute(mutation.attributeName);\n if (newSide && newSide !== currentSideRef.current) {\n currentSideRef.current = newSide as BaseUISide;\n hasPlacementChanged = true;\n }\n }\n if (\n mutation.type === \"attributes\" &&\n mutation.attributeName === \"data-align\"\n ) {\n const newAlign = positioner.getAttribute(mutation.attributeName);\n if (newAlign && newAlign !== currentAlignRef.current) {\n currentAlignRef.current = newAlign as BaseUIAlign;\n hasPlacementChanged = true;\n }\n }\n });\n\n // Only trigger callbacks if placement actually changed\n if (hasPlacementChanged) {\n const newPlacement = buildAntdPlacement({\n side: currentSideRef.current,\n align: currentAlignRef.current,\n });\n\n // Trigger resizable dimensions reset when placement changes\n setPlacementChangeKey((prev) => prev + 1);\n\n if (onPlacementChange) {\n onPlacementChange(newPlacement);\n }\n }\n });\n\n // Start observing\n observer.observe(positioner, {\n attributes: true,\n attributeFilter: [\"data-side\", \"data-align\"],\n attributeOldValue: true,\n });\n\n return () => {\n observer.disconnect();\n };\n }, [onPlacementChange, open]);\n\n const renderTitle = useCallback(() => {\n return (\n <div className={clsx(cls(\"popup-panel-header\"), classNames?.header)}>\n <Stack\n align=\"center\"\n gap={8}\n className={cls(\"popup-panel-title-wrapper\")}\n >\n <Popover.Title\n render={\n <div className={clsx(cls(\"grow\", \"truncate\"), classNames?.title)}>\n {title}\n </div>\n }\n ></Popover.Title>\n <div className=\"flex items-center gap-2\">\n {beforeCloseButton}\n <Popover.Close\n render={<IconButton>{defaultCloseIcon}</IconButton>}\n />\n {afterCloseButton}\n </div>\n </Stack>\n {afterTitle ? afterTitle : null}\n </div>\n );\n }, [\n afterCloseButton,\n afterTitle,\n beforeCloseButton,\n cls,\n classNames?.header,\n classNames?.title,\n defaultCloseIcon,\n title,\n ]);\n\n const { ref: draggableRef } = useDraggable(draggable);\n\n const popup = (\n <Popover.Popup\n className={clsx(\n cls(\"popup-panel\"),\n cls(`popup-panel-size-${size}`),\n className,\n classNames?.popup,\n )}\n ref={draggableRef}\n >\n {title && renderTitle()}\n <div className={clsx(cls(\"popup-panel-content\"), classNames?.content)}>\n <div className={cls(\"popup-panel-content-inner\")}>{content}</div>\n </div>\n {footer && (\n <div className={clsx(cls(\"popup-panel-footer\"), classNames?.footer)}>\n {typeof footer === \"function\"\n ? footer({ close: () => setOpen(false) })\n : footer}\n </div>\n )}\n </Popover.Popup>\n );\n\n return (\n <Popover.Root\n openOnHover={trigger === \"hover\" ? true : openOnHover}\n open={open}\n onOpenChange={(open, event, reason) => {\n if (\n (reason === \"outside-press\" || reason === \"focus-out\") &&\n !closeOnClickOutside\n )\n return;\n setOpen(open, event, reason);\n }}\n modal={modal}\n {...rest}\n >\n <Popover.Trigger\n render={children}\n className={clsx(cls(\"popup-panel-trigger\"), classNames?.trigger)}\n ></Popover.Trigger>\n <Popover.Portal>\n <Popover.Positioner\n ref={positionerRef}\n className={clsx(cls(\"popup-panel-root\"), classNames?.root)}\n side={baseUIPlacement.side}\n align={baseUIPlacement.align}\n sideOffset={4}\n anchor={anchor}\n style={\n {\n \"--size-width\": size ? PopupPanelSize[size] : undefined,\n } as React.CSSProperties\n }\n >\n {resizable ? (\n <Resizable\n resizable={resizable}\n absolutePositioning={true}\n resetKey={placementChangeKey}\n maintainAspectRatio={maintainAspectRatio}\n classNames={{\n resizeHandle: classNames?.resizeHandle,\n }}\n >\n {popup}\n </Resizable>\n ) : (\n popup\n )}\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n );\n};\n"],"names":["PopupPanel","children","placement","openOnHover","outsideOpen","outsideOnOpenChange","content","title","trigger","className","anchor","beforeCloseButton","afterCloseButton","afterTitle","size","footer","defaultOpen","resizable","draggable","maintainAspectRatio","classNames","modal","closeOnClickOutside","onPlacementChange","rest","open","setOpen","useControlledState","cls","useCls","baseUIPlacement","parseAntdPlacement","defaultCloseIcon","useMemo","jsx","X","positionerRef","useRef","currentSideRef","currentAlignRef","placementChangeKey","setPlacementChangeKey","useState","useEffect","positioner","observer","mutations","hasPlacementChanged","mutation","newSide","newAlign","newPlacement","buildAntdPlacement","prev","renderTitle","useCallback","jsxs","clsx","Stack","Popover","IconButton","draggableRef","useDraggable","popup","event","reason","PopupPanelSize","Resizable"],"mappings":";;;;;;;;;;;;;;;AA8HO,MAAMA,KAAa,CAAC;AAAA,EACzB,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,MAAMC;AAAA,EACN,cAAcC;AAAA,EACd,SAAAC;AAAA,EACA,OAAAC;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,WAAAC;AAAA,EACA,QAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,YAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,QAAAC;AAAA,EACA,aAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,WAAAC,IAAY;AAAA,EACZ,qBAAAC,IAAsB;AAAA,EACtB,YAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,qBAAAC,IAAsB;AAAA,EACtB,mBA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A,EAAgB;AAAA,YACvB,YAAY;AAAA,YACZ,QAAApB;AAAA,YACA,OACE;AAAA,cACE,gBAAgBI,IAAOoD,EAAepD,CAAI,IAAI;AAAA,YAAA;AAAA,YAIjD,UAAAG,IACC,gBAAAiB;AAAA,cAACiC;AAAA,cAAA;AAAA,gBACC,WAAAlD;AAAA,gBACA,qBAAqB;AAAA,gBACrB,UAAUuB;AAAA,gBACV,qBAAArB;AAAA,gBACA,YAAY;AAAA,kBACV,cAAcC,GAAY;AAAA,gBAAA;AAAA,gBAG3B,UAAA2C;AAAA,cAAA;AAAA,YAAA,IAGHA;AAAA,UAAA;AAAA,QAAA,EAEJ,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../../src/components/popup-panel/component.tsx"],"sourcesContent":["\"use client\";\nimport {\n useCls,\n clsx,\n parseAntdPlacement,\n buildAntdPlacement,\n BaseUIPlacement,\n BaseUISide,\n BaseUIAlign,\n} from \"../utils\";\nimport { Popover } from \"@base-ui-components/react/popover\";\n\nimport { type PopoverProps } from \"antd/es/popover\";\nimport { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { IconButton } from \"../icon-button\";\nimport { X } from \"@bioturing/assets\";\nimport { PopupPanelSize } from \"./constants\";\nimport { useControlledState, useDraggable } from \"../hooks\";\nimport { Resizable } from \"../resizable\";\nimport { Stack } from \"../stack\";\n\n// Import component-specific styles\nimport \"./style.css\";\nimport { useRef } from \"react\";\nimport { useTheme } from \"../theme-provider\";\n\nexport interface PopupPanelProps\n extends Omit<\n React.ComponentPropsWithRef<\"div\">,\n \"title\" | \"content\" | \"children\"\n >,\n Omit<Popover.Root.Props, \"children\"> {\n /** The trigger element that opens the popup panel */\n children?: React.ComponentProps<typeof Popover.Trigger>[\"render\"];\n /** Placement of the popup panel relative to its trigger */\n placement?: PopoverProps[\"placement\"];\n /** Whether to open the popup panel on hover */\n openOnHover?: boolean;\n /** Controls the open state of the popup panel */\n open?: boolean;\n /** Callback fired when the open state changes */\n onOpenChange?: Popover.Root.Props[\"onOpenChange\"];\n /** Content to display inside the popup panel */\n content?: React.ReactNode;\n /** Title text or element to display in the panel header */\n title?: React.ReactNode;\n /** The event that triggers the popup panel */\n /**\n * @default \"click\"\n */\n trigger?: \"click\" | \"hover\";\n /** Custom anchor element for positioning the panel */\n anchor?: Popover.Positioner.Props[\"anchor\"];\n /** Content to display before the close button */\n beforeCloseButton?: React.ReactNode;\n /** Content to display after the close button */\n afterCloseButton?: React.ReactNode;\n /** Content to display after the title */\n afterTitle?: React.ReactNode;\n /**\n * Predefined sizes for the popup panel\n * - xsmall: 320px\n * - small: 400px\n * - medium: 480px (default)\n * - large: 640px\n * - xlarge: 840px\n * @default \"medium\" for default type, \"xsmall\" for other types\n */\n size?: keyof typeof PopupPanelSize;\n /**\n * Footer content for the popup panel\n * Can be a React node or a function that returns a React node\n */\n footer?:\n | React.ReactNode\n | ((props: { close: () => void }) => React.ReactNode);\n /**\n * Whether the panel should be open by default when uncontrolled\n * @default false\n */\n defaultOpen?: boolean;\n /**\n * Whether the panel should be resizable\n * @default false\n */\n resizable?: boolean;\n /**\n * Whether the panel should be draggable\n * @default false\n */\n draggable?: boolean;\n /**\n * Whether to maintain aspect ratio when resizing\n * Only applies when resizable is true\n * @default false\n */\n maintainAspectRatio?: boolean;\n /**\n * Custom class names for different parts of the popup panel\n * @default {}\n */\n classNames?: {\n root?: string;\n trigger?: string;\n popup?: string;\n header?: string;\n title?: string;\n content?: string;\n footer?: string;\n resizeHandle?: string;\n };\n /**\n * Whether to close the panel when clicking outside\n * @default true\n */\n closeOnClickOutside?: boolean;\n /**\n * Whether to use modal mode\n * @default false\n */\n modal?: Popover.Root.Props[\"modal\"];\n /**\n * Callback function when the placement changes\n */\n onPlacementChange?: (placement: PopoverProps[\"placement\"]) => void;\n}\n\nexport const PopupPanel = ({\n children,\n placement,\n openOnHover = false,\n open: outsideOpen,\n onOpenChange: outsideOnOpenChange,\n content,\n title,\n trigger = \"click\",\n className,\n anchor,\n beforeCloseButton,\n afterCloseButton,\n afterTitle,\n size = \"medium\",\n footer,\n defaultOpen,\n resizable = false,\n draggable = false,\n maintainAspectRatio = false,\n classNames,\n modal = false,\n closeOnClickOutside = true,\n onPlacementChange,\n ...rest\n}: PopupPanelProps) => {\n // Use controlled state with proper initialization to prevent switching between controlled/uncontrolled\n const [open, setOpen] = useControlledState(\n outsideOpen,\n outsideOnOpenChange,\n defaultOpen ?? false // Always provide a default value to prevent undefined\n );\n\n const cls = useCls();\n const { className: themeClassName } = useTheme();\n const baseUIPlacement = parseAntdPlacement(placement);\n\n const defaultCloseIcon = useMemo(() => <X size={16} />, []);\n\n const positionerRef = useRef<HTMLDivElement>(null);\n const currentSideRef = useRef<BaseUISide>(baseUIPlacement.side);\n const currentAlignRef = useRef<BaseUIAlign>(baseUIPlacement.align);\n const [placementChangeKey, setPlacementChangeKey] = useState(0);\n\n useEffect(() => {\n const positioner = positionerRef.current;\n if (!positioner || !open) return; // Only observe when popup is open\n\n // Create MutationObserver to watch for data-side changes\n const observer = new MutationObserver((mutations) => {\n let hasPlacementChanged = false;\n\n mutations.forEach((mutation) => {\n if (\n mutation.type === \"attributes\" &&\n mutation.attributeName === \"data-side\"\n ) {\n const newSide = positioner.getAttribute(mutation.attributeName);\n if (newSide && newSide !== currentSideRef.current) {\n currentSideRef.current = newSide as BaseUISide;\n hasPlacementChanged = true;\n }\n }\n if (\n mutation.type === \"attributes\" &&\n mutation.attributeName === \"data-align\"\n ) {\n const newAlign = positioner.getAttribute(mutation.attributeName);\n if (newAlign && newAlign !== currentAlignRef.current) {\n currentAlignRef.current = newAlign as BaseUIAlign;\n hasPlacementChanged = true;\n }\n }\n });\n\n // Only trigger callbacks if placement actually changed\n if (hasPlacementChanged) {\n const newPlacement = buildAntdPlacement({\n side: currentSideRef.current,\n align: currentAlignRef.current,\n });\n\n // Trigger resizable dimensions reset when placement changes\n setPlacementChangeKey((prev) => prev + 1);\n\n if (onPlacementChange) {\n onPlacementChange(newPlacement);\n }\n }\n });\n\n // Start observing\n observer.observe(positioner, {\n attributes: true,\n attributeFilter: [\"data-side\", \"data-align\"],\n attributeOldValue: true,\n });\n\n return () => {\n observer.disconnect();\n };\n }, [onPlacementChange, open]);\n\n const renderTitle = useCallback(() => {\n return (\n <div className={clsx(cls(\"popup-panel-header\"), classNames?.header)}>\n <Stack\n align=\"center\"\n gap={8}\n className={cls(\"popup-panel-title-wrapper\")}\n >\n <Popover.Title\n render={\n <div className={clsx(cls(\"grow\", \"truncate\"), classNames?.title)}>\n {title}\n </div>\n }\n ></Popover.Title>\n <div className=\"flex items-center gap-2\">\n {beforeCloseButton}\n <Popover.Close\n render={<IconButton>{defaultCloseIcon}</IconButton>}\n />\n {afterCloseButton}\n </div>\n </Stack>\n {afterTitle ? afterTitle : null}\n </div>\n );\n }, [\n afterCloseButton,\n afterTitle,\n beforeCloseButton,\n cls,\n classNames?.header,\n classNames?.title,\n defaultCloseIcon,\n title,\n ]);\n\n const { ref: draggableRef } = useDraggable(draggable);\n\n const popup = (\n <Popover.Popup\n className={clsx(\n cls(\"popup-panel\"),\n cls(`popup-panel-size-${size}`),\n className,\n classNames?.popup\n )}\n ref={draggableRef}\n >\n {title && renderTitle()}\n <div className={clsx(cls(\"popup-panel-content\"), classNames?.content)}>\n <div className={cls(\"popup-panel-content-inner\")}>{content}</div>\n </div>\n {footer && (\n <div className={clsx(cls(\"popup-panel-footer\"), classNames?.footer)}>\n {typeof footer === \"function\"\n ? footer({ close: () => setOpen(false) })\n : footer}\n </div>\n )}\n </Popover.Popup>\n );\n\n return (\n <Popover.Root\n openOnHover={trigger === \"hover\" ? true : openOnHover}\n open={open}\n onOpenChange={(open, event, reason) => {\n if (\n (reason === \"outside-press\" || reason === \"focus-out\") &&\n !closeOnClickOutside\n )\n return;\n setOpen(open, event, reason);\n }}\n modal={modal}\n {...rest}\n >\n <Popover.Trigger\n render={children}\n className={clsx(cls(\"popup-panel-trigger\"), classNames?.trigger)}\n ></Popover.Trigger>\n <Popover.Portal>\n <Popover.Positioner\n ref={positionerRef}\n className={clsx(\n cls(\"popup-panel-root\"),\n themeClassName,\n classNames?.root\n )}\n side={baseUIPlacement.side}\n align={baseUIPlacement.align}\n sideOffset={4}\n anchor={anchor}\n style={\n {\n \"--size-width\": size ? PopupPanelSize[size] : undefined,\n } as React.CSSProperties\n }\n >\n {resizable ? (\n <Resizable\n resizable={resizable}\n absolutePositioning={true}\n resetKey={placementChangeKey}\n maintainAspectRatio={maintainAspectRatio}\n classNames={{\n resizeHandle: classNames?.resizeHandle,\n }}\n >\n {popup}\n </Resizable>\n ) : (\n popup\n )}\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n );\n};\n"],"names":["PopupPanel","children","placement","openOnHover","outsideOpen","outsideOnOpenChange","content","title","trigger","className","anchor","beforeCloseButton","afterCloseButton","afterTitle","size","footer","defaultOpen","resizable","draggable","maintainAspectRatio","classNames","modal","closeOnClickOutside","onPlacementChange","rest","open","setOpen","useControlledState","cls","useCls","themeClassName","useTheme","baseUIPlacement","parseAntdPlacement","defaultCloseIcon","useMemo","jsx","X","positionerRef","useRef","currentSideRef","currentAlignRef","placementChangeKey","setPlacementChangeKey","useState","useEffect","positioner","observer","mutations","hasPlacementChanged","mutation","newSide","newAlign","newPlacement","buildAntdPlacement","prev","renderTitle","useCallback","jsxs","clsx","Stack","Popover","IconButton","draggableRef","useDraggable","popup","event","reason","PopupPanelSize","Resizable"],"mappings":";;;;;;;;;;;;;;;;AA+HO,MAAMA,KAAa,CAAC;AAAA,EACzB,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,MAAMC;AAAA,EACN,cAAcC;AAAA,EACd,SAAAC;AAAA,EACA,OAAAC;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,WAAAC;AAAA,EACA,QAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,YAAAC;AAAA,EAC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AAY,OAAO;AAAA,UAAA;AAAA,QAAA;AAAA,QAEjE,gBAAAgB,EAACyB,EAAQ,QAAR,EACC,UAAA,gBAAAzB;AAAA,UAACyB,EAAQ;AAAA,UAAR;AAAA,YACC,KAAKvB;AAAA,YACL,WAAWqB;AAAA,cACT/B,EAAI,kBAAkB;AAAA,cACtBE;AAAA,cACAV,GAAY;AAAA,YAAA;AAAA,YAEd,MAAMY,EAAgB;AAAA,YACtB,OAAOA,EAAgB;AAAA,YACvB,YAAY;AAAA,YACZ,QAAAtB;AAAA,YACA,OACE;AAAA,cACE,gBAAgBI,IAAOsD,GAAetD,CAAI,IAAI;AAAA,YAAA;AAAA,YAIjD,UAAAG,IACC,gBAAAmB;AAAA,cAACiC;AAAA,cAAA;AAAA,gBACC,WAAApD;AAAA,gBACA,qBAAqB;AAAA,gBACrB,UAAUyB;AAAA,gBACV,qBAAAvB;AAAA,gBACA,YAAY;AAAA,kBACV,cAAcC,GAAY;AAAA,gBAAA;AAAA,gBAG3B,UAAA6C;AAAA,cAAA;AAAA,YAAA,IAGHA;AAAA,UAAA;AAAA,QAAA,EAEJ,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/scroll-area/component.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAA+B,MAAM,OAAO,CAAC;AACpE,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAIzE,OAAO,aAAa,CAAC;AAErB,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC;IACnD,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,UAAU,CAAC,EAAE;QACX;;WAEG;QACH,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB;;WAEG;QACH,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB;;WAEG;QACH,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB;;WAEG;QACH,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF;;OAEG;IACH,MAAM,CAAC,EAAE;QACP;;WAEG;QACH,QAAQ,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;QAC/B;;WAEG;QACH,OAAO,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;QAC9B;;WAEG;QACH,SAAS,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;QAChC;;WAEG;QACH,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;KAC7B,CAAC;IACF;;;OAGG;IACH,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IACxC;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACnC;AAED,eAAO,MAAM,UAAU,GAAI,wFASxB,eAAe,
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/scroll-area/component.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAA+B,MAAM,OAAO,CAAC;AACpE,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAIzE,OAAO,aAAa,CAAC;AAErB,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC;IACnD,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,UAAU,CAAC,EAAE;QACX;;WAEG;QACH,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB;;WAEG;QACH,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB;;WAEG;QACH,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB;;WAEG;QACH,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF;;OAEG;IACH,MAAM,CAAC,EAAE;QACP;;WAEG;QACH,QAAQ,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;QAC/B;;WAEG;QACH,OAAO,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;QAC9B;;WAEG;QACH,SAAS,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;QAChC;;WAEG;QACH,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;KAC7B,CAAC;IACF;;;OAGG;IACH,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IACxC;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACnC;AAED,eAAO,MAAM,UAAU,GAAI,wFASxB,eAAe,4CAoIjB,CAAC"}
|
|
@@ -6,34 +6,34 @@ import './style.css';/* empty css */
|
|
|
6
6
|
import { useCls as j } from "../utils/antdUtils.js";
|
|
7
7
|
import { clsx as b } from "../utils/cn.js";
|
|
8
8
|
const V = ({
|
|
9
|
-
children:
|
|
9
|
+
children: v,
|
|
10
10
|
className: z,
|
|
11
11
|
classNames: S = {},
|
|
12
|
-
orientation:
|
|
12
|
+
orientation: r = "vertical",
|
|
13
13
|
fadeEdges: e = !1,
|
|
14
14
|
onScroll: u,
|
|
15
15
|
styles: m = {},
|
|
16
16
|
...y
|
|
17
17
|
}) => {
|
|
18
|
-
const
|
|
18
|
+
const t = j(), f = T(null), [l, p] = E({
|
|
19
19
|
isAtStart: !0,
|
|
20
20
|
isAtEnd: !1,
|
|
21
21
|
isScrollable: !1
|
|
22
22
|
});
|
|
23
23
|
return L(() => {
|
|
24
24
|
if (!f.current) return;
|
|
25
|
-
const o = f.current, s = (
|
|
26
|
-
if (
|
|
27
|
-
if (
|
|
25
|
+
const o = f.current, s = (w) => {
|
|
26
|
+
if (w && u && u(w), e)
|
|
27
|
+
if (r === "vertical") {
|
|
28
28
|
const { scrollTop: c, scrollHeight: a, clientHeight: i } = o, A = a > i;
|
|
29
|
-
|
|
29
|
+
p({
|
|
30
30
|
isAtStart: c <= 1,
|
|
31
31
|
isAtEnd: c >= a - i - 1,
|
|
32
32
|
isScrollable: A
|
|
33
33
|
});
|
|
34
34
|
} else {
|
|
35
35
|
const { scrollLeft: c, scrollWidth: a, clientWidth: i } = o, A = a > i + 2;
|
|
36
|
-
|
|
36
|
+
p({
|
|
37
37
|
isAtStart: c <= 1,
|
|
38
38
|
isAtEnd: c >= a - i - 1,
|
|
39
39
|
isScrollable: A
|
|
@@ -43,16 +43,16 @@ const V = ({
|
|
|
43
43
|
s();
|
|
44
44
|
const x = setTimeout(s, 0);
|
|
45
45
|
o.addEventListener("scroll", s);
|
|
46
|
-
const
|
|
46
|
+
const d = new ResizeObserver(() => {
|
|
47
47
|
s();
|
|
48
48
|
});
|
|
49
|
-
return
|
|
50
|
-
clearTimeout(x), o.removeEventListener("scroll", s),
|
|
49
|
+
return d.observe(o), () => {
|
|
50
|
+
clearTimeout(x), o.removeEventListener("scroll", s), d.disconnect();
|
|
51
51
|
};
|
|
52
|
-
}, [e,
|
|
52
|
+
}, [e, r, u]), /* @__PURE__ */ R(
|
|
53
53
|
n.Root,
|
|
54
54
|
{
|
|
55
|
-
className: b(
|
|
55
|
+
className: b(t("scroll-area"), z),
|
|
56
56
|
...y,
|
|
57
57
|
children: [
|
|
58
58
|
/* @__PURE__ */ h(
|
|
@@ -60,37 +60,37 @@ const V = ({
|
|
|
60
60
|
{
|
|
61
61
|
ref: f,
|
|
62
62
|
className: b(
|
|
63
|
-
|
|
64
|
-
e && l.isScrollable &&
|
|
65
|
-
e && l.isScrollable &&
|
|
66
|
-
e && l.isScrollable &&
|
|
67
|
-
e && l.isScrollable &&
|
|
68
|
-
e && l.isScrollable &&
|
|
69
|
-
e && l.isScrollable &&
|
|
63
|
+
t("scroll-area-viewport"),
|
|
64
|
+
e && l.isScrollable && r === "vertical" && l.isAtStart && t("scroll-area-fade-bottom-only"),
|
|
65
|
+
e && l.isScrollable && r === "vertical" && l.isAtEnd && t("scroll-area-fade-top-only"),
|
|
66
|
+
e && l.isScrollable && r === "vertical" && !l.isAtStart && !l.isAtEnd && t("scroll-area-fade-both-vertical"),
|
|
67
|
+
e && l.isScrollable && r === "horizontal" && l.isAtStart && t("scroll-area-fade-right-only"),
|
|
68
|
+
e && l.isScrollable && r === "horizontal" && l.isAtEnd && t("scroll-area-fade-left-only"),
|
|
69
|
+
e && l.isScrollable && r === "horizontal" && !l.isAtStart && !l.isAtEnd && t("scroll-area-fade-both-horizontal"),
|
|
70
70
|
S?.viewport
|
|
71
71
|
),
|
|
72
72
|
style: m?.viewport,
|
|
73
|
-
children: /* @__PURE__ */ h(
|
|
73
|
+
children: r == "horizontal" ? /* @__PURE__ */ h(
|
|
74
74
|
n.Content,
|
|
75
75
|
{
|
|
76
|
-
className: b(
|
|
76
|
+
className: b(t("scroll-area-content"), S?.content),
|
|
77
77
|
style: m?.content,
|
|
78
|
-
children:
|
|
78
|
+
children: v
|
|
79
79
|
}
|
|
80
|
-
)
|
|
80
|
+
) : v
|
|
81
81
|
}
|
|
82
82
|
),
|
|
83
83
|
/* @__PURE__ */ h(
|
|
84
84
|
n.Scrollbar,
|
|
85
85
|
{
|
|
86
|
-
className: b(
|
|
87
|
-
orientation:
|
|
88
|
-
"data-orientation":
|
|
86
|
+
className: b(t("scroll-area-scrollbar"), S?.scrollbar),
|
|
87
|
+
orientation: r,
|
|
88
|
+
"data-orientation": r,
|
|
89
89
|
style: m?.scrollbar,
|
|
90
90
|
children: /* @__PURE__ */ h(
|
|
91
91
|
n.Thumb,
|
|
92
92
|
{
|
|
93
|
-
className: b(
|
|
93
|
+
className: b(t("scroll-area-thumb"), S?.thumb),
|
|
94
94
|
style: m?.thumb
|
|
95
95
|
}
|
|
96
96
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../../src/components/scroll-area/component.tsx"],"sourcesContent":["\"use client\";\nimport { type ReactNode, useEffect, useRef, useState } from \"react\";\nimport { ScrollArea as BaseScrollArea } from \"@base-ui-components/react\";\nimport { clsx, useCls } from \"../utils\";\n\n// Import component-specific styles\nimport \"./style.css\";\n\nexport interface ScrollAreaProps\n extends Omit<BaseScrollArea.Root.Props, \"onScroll\"> {\n children: ReactNode;\n /**\n * Additional class name for the root component\n */\n className?: string;\n /**\n * Custom class names for each part of the scroll area\n */\n classNames?: {\n /**\n * Class name for the viewport element\n */\n viewport?: string;\n /**\n * Class name for the content element\n */\n content?: string;\n /**\n * Class name for the scrollbar element\n */\n scrollbar?: string;\n /**\n * Class name for the thumb element\n */\n thumb?: string;\n };\n /**\n * Custom styles for each part of the scroll area\n */\n styles?: {\n /**\n * Styles for the viewport element\n */\n viewport?: React.CSSProperties;\n /**\n * Styles for the content element\n */\n content?: React.CSSProperties;\n /**\n * Styles for the scrollbar element\n */\n scrollbar?: React.CSSProperties;\n /**\n * Styles for the thumb element\n */\n thumb?: React.CSSProperties;\n };\n /**\n * Orientation of the scrollbar\n * @default \"vertical\"\n */\n orientation?: \"vertical\" | \"horizontal\";\n /**\n * Enable fade-out effect at scrollable edges\n * @default false\n */\n fadeEdges?: boolean;\n /**\n * Callback fired when the scroll position changes\n */\n onScroll?: (event: Event) => void;\n}\n\nexport const ScrollArea = ({\n children,\n className,\n classNames = {},\n orientation = \"vertical\",\n fadeEdges = false,\n onScroll,\n styles = {},\n ...rest\n}: ScrollAreaProps) => {\n const cls = useCls();\n const viewportRef = useRef<HTMLDivElement>(null);\n const [scrollState, setScrollState] = useState({\n isAtStart: true,\n isAtEnd: false,\n isScrollable: false,\n });\n\n useEffect(() => {\n if (!viewportRef.current) return;\n\n const viewport = viewportRef.current;\n\n const handleScroll = (event?: Event) => {\n // Call the onScroll callback if provided and event exists\n if (event && onScroll) {\n onScroll(event);\n }\n\n // Handle fade edges state update if enabled\n if (fadeEdges) {\n if (orientation === \"vertical\") {\n const { scrollTop, scrollHeight, clientHeight } = viewport;\n const isScrollable = scrollHeight > clientHeight;\n setScrollState({\n isAtStart: scrollTop <= 1,\n isAtEnd: scrollTop >= scrollHeight - clientHeight - 1,\n isScrollable,\n });\n } else {\n const { scrollLeft, scrollWidth, clientWidth } = viewport;\n // Add a small buffer (2px) to account for rounding errors\n const isScrollable = scrollWidth > clientWidth + 2;\n setScrollState({\n isAtStart: scrollLeft <= 1,\n isAtEnd: scrollLeft >= scrollWidth - clientWidth - 1,\n isScrollable,\n });\n }\n }\n };\n\n // Initial check (without event)\n handleScroll();\n\n // Use a timeout to check again after content might have rendered\n const timeoutId = setTimeout(handleScroll, 0);\n\n viewport.addEventListener(\"scroll\", handleScroll);\n\n // Add resize observer to detect content size changes\n const resizeObserver = new ResizeObserver(() => {\n handleScroll();\n });\n resizeObserver.observe(viewport);\n\n return () => {\n clearTimeout(timeoutId);\n viewport.removeEventListener(\"scroll\", handleScroll);\n resizeObserver.disconnect();\n };\n }, [fadeEdges, orientation, onScroll]);\n return (\n <BaseScrollArea.Root\n className={clsx(cls(\"scroll-area\"), className)}\n {...rest}\n >\n <BaseScrollArea.Viewport\n ref={viewportRef}\n className={clsx(\n cls(\"scroll-area-viewport\"),\n fadeEdges &&\n scrollState.isScrollable &&\n orientation === \"vertical\" &&\n scrollState.isAtStart &&\n cls(\"scroll-area-fade-bottom-only\"),\n fadeEdges &&\n scrollState.isScrollable &&\n orientation === \"vertical\" &&\n scrollState.isAtEnd &&\n cls(\"scroll-area-fade-top-only\"),\n fadeEdges &&\n scrollState.isScrollable &&\n orientation === \"vertical\" &&\n !scrollState.isAtStart &&\n !scrollState.isAtEnd &&\n cls(\"scroll-area-fade-both-vertical\"),\n fadeEdges &&\n scrollState.isScrollable &&\n orientation === \"horizontal\" &&\n scrollState.isAtStart &&\n cls(\"scroll-area-fade-right-only\"),\n fadeEdges &&\n scrollState.isScrollable &&\n orientation === \"horizontal\" &&\n scrollState.isAtEnd &&\n cls(\"scroll-area-fade-left-only\"),\n fadeEdges &&\n scrollState.isScrollable &&\n orientation === \"horizontal\" &&\n !scrollState.isAtStart &&\n !scrollState.isAtEnd &&\n cls(\"scroll-area-fade-both-horizontal\"),\n classNames?.viewport\n )}\n style={styles?.viewport}\n >\n <BaseScrollArea.Content\n
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../../src/components/scroll-area/component.tsx"],"sourcesContent":["\"use client\";\nimport { type ReactNode, useEffect, useRef, useState } from \"react\";\nimport { ScrollArea as BaseScrollArea } from \"@base-ui-components/react\";\nimport { clsx, useCls } from \"../utils\";\n\n// Import component-specific styles\nimport \"./style.css\";\n\nexport interface ScrollAreaProps\n extends Omit<BaseScrollArea.Root.Props, \"onScroll\"> {\n children: ReactNode;\n /**\n * Additional class name for the root component\n */\n className?: string;\n /**\n * Custom class names for each part of the scroll area\n */\n classNames?: {\n /**\n * Class name for the viewport element\n */\n viewport?: string;\n /**\n * Class name for the content element\n */\n content?: string;\n /**\n * Class name for the scrollbar element\n */\n scrollbar?: string;\n /**\n * Class name for the thumb element\n */\n thumb?: string;\n };\n /**\n * Custom styles for each part of the scroll area\n */\n styles?: {\n /**\n * Styles for the viewport element\n */\n viewport?: React.CSSProperties;\n /**\n * Styles for the content element\n */\n content?: React.CSSProperties;\n /**\n * Styles for the scrollbar element\n */\n scrollbar?: React.CSSProperties;\n /**\n * Styles for the thumb element\n */\n thumb?: React.CSSProperties;\n };\n /**\n * Orientation of the scrollbar\n * @default \"vertical\"\n */\n orientation?: \"vertical\" | \"horizontal\";\n /**\n * Enable fade-out effect at scrollable edges\n * @default false\n */\n fadeEdges?: boolean;\n /**\n * Callback fired when the scroll position changes\n */\n onScroll?: (event: Event) => void;\n}\n\nexport const ScrollArea = ({\n children,\n className,\n classNames = {},\n orientation = \"vertical\",\n fadeEdges = false,\n onScroll,\n styles = {},\n ...rest\n}: ScrollAreaProps) => {\n const cls = useCls();\n const viewportRef = useRef<HTMLDivElement>(null);\n const [scrollState, setScrollState] = useState({\n isAtStart: true,\n isAtEnd: false,\n isScrollable: false,\n });\n\n useEffect(() => {\n if (!viewportRef.current) return;\n\n const viewport = viewportRef.current;\n\n const handleScroll = (event?: Event) => {\n // Call the onScroll callback if provided and event exists\n if (event && onScroll) {\n onScroll(event);\n }\n\n // Handle fade edges state update if enabled\n if (fadeEdges) {\n if (orientation === \"vertical\") {\n const { scrollTop, scrollHeight, clientHeight } = viewport;\n const isScrollable = scrollHeight > clientHeight;\n setScrollState({\n isAtStart: scrollTop <= 1,\n isAtEnd: scrollTop >= scrollHeight - clientHeight - 1,\n isScrollable,\n });\n } else {\n const { scrollLeft, scrollWidth, clientWidth } = viewport;\n // Add a small buffer (2px) to account for rounding errors\n const isScrollable = scrollWidth > clientWidth + 2;\n setScrollState({\n isAtStart: scrollLeft <= 1,\n isAtEnd: scrollLeft >= scrollWidth - clientWidth - 1,\n isScrollable,\n });\n }\n }\n };\n\n // Initial check (without event)\n handleScroll();\n\n // Use a timeout to check again after content might have rendered\n const timeoutId = setTimeout(handleScroll, 0);\n\n viewport.addEventListener(\"scroll\", handleScroll);\n\n // Add resize observer to detect content size changes\n const resizeObserver = new ResizeObserver(() => {\n handleScroll();\n });\n resizeObserver.observe(viewport);\n\n return () => {\n clearTimeout(timeoutId);\n viewport.removeEventListener(\"scroll\", handleScroll);\n resizeObserver.disconnect();\n };\n }, [fadeEdges, orientation, onScroll]);\n return (\n <BaseScrollArea.Root\n className={clsx(cls(\"scroll-area\"), className)}\n {...rest}\n >\n <BaseScrollArea.Viewport\n ref={viewportRef}\n className={clsx(\n cls(\"scroll-area-viewport\"),\n fadeEdges &&\n scrollState.isScrollable &&\n orientation === \"vertical\" &&\n scrollState.isAtStart &&\n cls(\"scroll-area-fade-bottom-only\"),\n fadeEdges &&\n scrollState.isScrollable &&\n orientation === \"vertical\" &&\n scrollState.isAtEnd &&\n cls(\"scroll-area-fade-top-only\"),\n fadeEdges &&\n scrollState.isScrollable &&\n orientation === \"vertical\" &&\n !scrollState.isAtStart &&\n !scrollState.isAtEnd &&\n cls(\"scroll-area-fade-both-vertical\"),\n fadeEdges &&\n scrollState.isScrollable &&\n orientation === \"horizontal\" &&\n scrollState.isAtStart &&\n cls(\"scroll-area-fade-right-only\"),\n fadeEdges &&\n scrollState.isScrollable &&\n orientation === \"horizontal\" &&\n scrollState.isAtEnd &&\n cls(\"scroll-area-fade-left-only\"),\n fadeEdges &&\n scrollState.isScrollable &&\n orientation === \"horizontal\" &&\n !scrollState.isAtStart &&\n !scrollState.isAtEnd &&\n cls(\"scroll-area-fade-both-horizontal\"),\n classNames?.viewport\n )}\n style={styles?.viewport}\n >\n {orientation == \"horizontal\" ? (\n <BaseScrollArea.Content\n className={clsx(cls(\"scroll-area-content\"), classNames?.content)}\n style={styles?.content}\n >\n {children}\n </BaseScrollArea.Content>\n ) : (\n children\n )}\n </BaseScrollArea.Viewport>\n <BaseScrollArea.Scrollbar\n className={clsx(cls(\"scroll-area-scrollbar\"), classNames?.scrollbar)}\n orientation={orientation}\n data-orientation={orientation}\n style={styles?.scrollbar}\n >\n <BaseScrollArea.Thumb\n className={clsx(cls(\"scroll-area-thumb\"), classNames?.thumb)}\n style={styles?.thumb}\n />\n </BaseScrollArea.Scrollbar>\n </BaseScrollArea.Root>\n );\n};\n"],"names":["ScrollArea","children","className","classNames","orientation","fadeEdges","onScroll","styles","rest","cls","useCls","viewportRef","useRef","scrollState","setScrollState","useState","useEffect","viewport","handleScroll","event","scrollTop","scrollHeight","clientHeight","isScrollable","scrollLeft","scrollWidth","clientWidth","timeoutId","resizeObserver","jsxs","BaseScrollArea","clsx","jsx"],"mappings":";;;;;;;AAyEO,MAAMA,IAAa,CAAC;AAAA,EACzB,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,YAAAC,IAAa,CAAA;AAAA,EACb,aAAAC,IAAc;AAAA,EACd,WA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YAClB,OAAOG,GAAQ;AAAA,YAEf,UAAA,gBAAAyB;AAAA,cAACF,EAAe;AAAA,cAAf;AAAA,gBACC,WAAWC,EAAKtB,EAAI,mBAAmB,GAAGN,GAAY,KAAK;AAAA,gBAC3D,OAAOI,GAAQ;AAAA,cAAA;AAAA,YAAA;AAAA,UACjB;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/table/component.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,IAAI,QAAQ,EAEnB,KAAK,UAAU,IAAI,aAAa,EAChC,KAAK,QAAQ,EACd,MAAM,eAAe,CAAC;AAKvB,OAAO,EAIL,GAAG,EACH,YAAY,EAGb,MAAM,OAAO,CAAC;AAGf,OAAO,aAAa,CAAC;AAGrB,MAAM,WAAW,UAAU,CAAC,UAAU,SAAS,MAAM,GAAG,MAAM,CAC5D,SAAQ,aAAa,CAAC,UAAU,CAAC;IACjC;;OAEG;IACH,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACnC;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACrC;;OAEG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;CAC/B;AAGD,QAAA,MAAM,kBAAkB,GAAI,UAAU,SAAS,MAAM,GAAG,MAAM,EAC5D,0GAUG,UAAU,CAAC,UAAU,CAAC,EACzB,KAAK,GAAG,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/table/component.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,IAAI,QAAQ,EAEnB,KAAK,UAAU,IAAI,aAAa,EAChC,KAAK,QAAQ,EACd,MAAM,eAAe,CAAC;AAKvB,OAAO,EAIL,GAAG,EACH,YAAY,EA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
|
-
{"version":3,"file":"component.js","sources":["../../../src/components/table/component.tsx"],"sourcesContent":["\"use client\";\nimport {\n default as AntTable,\n type ColumnType,\n type TableProps as AntTableProps,\n type TableRef,\n} from \"antd/es/table\";\nimport { CaretDownIcon, CaretUpIcon, FunnelIcon } from \"@bioturing/assets\";\nimport { clsx, useCls } from \"../utils\";\nimport Empty from \"../empty/component\";\nimport { SpinProps } from \"antd/es/spin\";\nimport {\n useState,\n useEffect,\n forwardRef,\n Ref,\n ForwardedRef,\n useCallback,\n useRef,\n} from \"react\";\n\n// Import component-specific styles\nimport \"./style.css\";\n\n// Define interface with all the generic type parameters from AntTable without any\nexport interface TableProps<RecordType extends object = object>\n extends AntTableProps<RecordType> {\n /**\n * Add empty description for the table\n */\n emptyDescription?: React.ReactNode;\n /**\n * Table ref\n */\n tableRef?: React.Ref<HTMLDivElement>;\n /**\n * Table style\n */\n variant?: \"default\" | \"zebra\";\n}\n\n// Simple wrapper component with proper generics\nconst InnerInternalTable = <RecordType extends object = object>(\n {\n columns,\n locale,\n emptyDescription,\n loading,\n virtual,\n scroll: scrollProp = {},\n className,\n variant,\n ...rest\n }: TableProps<RecordType>,\n ref: Ref<TableRef>\n) => {\n const cls = useCls();\n const [scroll, setScroll] = useState<TableProps[\"scroll\"]>(\n virtual\n ? {}\n : {\n x: \"fit-content\",\n }\n );\n\n const innerRef = useRef<TableRef>(null);\n const tablePaginationHeight = useRef<number>(0);\n\n useEffect(() => {\n if (!innerRef.current || !virtual) return;\n const tableEl = innerRef.current?.nativeElement;\n const parentEl = tableEl?.parentElement;\n if (!parentEl) return;\n const thead = tableEl?.querySelector(\n `.${cls(\"table-thead\")}`\n ) as HTMLElement;\n const tpagination = tableEl?.querySelector(\n `.${cls(\"table-pagination\")}`\n ) as HTMLElement;\n if (tpagination) {\n const mt = getComputedStyle(tpagination).marginTop;\n const mb = getComputedStyle(tpagination).marginBottom;\n tablePaginationHeight.current =\n tpagination.offsetHeight + parseInt(mt) + parseInt(mb);\n }\n const resizeObserver = new ResizeObserver((entries) => {\n for (const entry of entries) {\n if (entry.target) {\n setScroll({\n y:\n parentEl.offsetHeight -\n (thead ? thead?.offsetHeight : 0) -\n tablePaginationHeight.current,\n });\n }\n }\n });\n if (parentEl && virtual) {\n resizeObserver.observe(parentEl);\n }\n return () => {\n if (parentEl && virtual) {\n resizeObserver.disconnect();\n }\n };\n }, [virtual, cls]);\n\n const modifiedColumns = columns\n ? columns.map((column: ColumnType<RecordType>): ColumnType<RecordType> => {\n return {\n sortIcon: ({ sortOrder }) => {\n return (\n <span\n className={cls(\n \"table-column-sort-icon\",\n sortOrder\n ? `table-column-sort-icon-${sortOrder}`\n : `table-column-sort-icon-none`\n )}\n >\n {!sortOrder ? (\n <>\n <CaretUpIcon weight=\"fill\" />{\" \"}\n <CaretDownIcon weight=\"fill\" />\n </>\n ) : sortOrder === \"ascend\" ? (\n <CaretUpIcon weight=\"fill\" />\n ) : (\n <CaretDownIcon weight=\"fill\" />\n )}\n </span>\n );\n },\n filterIcon: (_filtered) => {\n return (\n <span className={cls(\"table-column-filter-icon\")}>\n <FunnelIcon weight=\"fill\" />\n </span>\n );\n },\n ...column,\n };\n })\n : undefined;\n const modifiedLocale = {\n emptyText: <Empty description={emptyDescription} />,\n ...locale,\n };\n let spinProps: SpinProps | undefined;\n if (typeof loading === \"boolean\") {\n spinProps = {\n spinning: loading,\n indicator: <span className={cls(\"spin-loader\")} />,\n };\n } else if (typeof loading === \"object\") {\n spinProps = {\n spinning: true,\n indicator: <span className={cls(\"spin-loader\")} />,\n ...loading,\n };\n }\n const callbackRef = useCallback(\n (tableRef: TableRef) => {\n if (tableRef) {\n if (typeof ref === \"function\") {\n ref(tableRef);\n }\n if (ref && typeof ref === \"object\" && \"current\" in ref) {\n ref.current = tableRef;\n }\n innerRef.current = tableRef;\n }\n },\n [ref]\n );\n\n return (\n <AntTable\n ref={callbackRef}\n columns={modifiedColumns}\n loading={spinProps}\n locale={modifiedLocale}\n virtual={virtual}\n scroll={{ ...scroll, ...scrollProp }}\n className={clsx(variant === \"zebra\" ? cls(\"table-zebra\") : \"\", className)}\n {...rest}\n />\n );\n};\n\nconst InternalTable = forwardRef(InnerInternalTable) as <\n RecordType extends object = object\n>(\n props: TableProps<RecordType> & { ref?: ForwardedRef<TableRef> }\n) => ReturnType<typeof InnerInternalTable>;\n\n// Create the final component with all static properties\nexport const Table = Object.assign(InternalTable, {\n Column: AntTable.Column,\n ColumnGroup: AntTable.ColumnGroup,\n SELECTION_COLUMN: AntTable.SELECTION_COLUMN,\n EXPAND_COLUMN: AntTable.EXPAND_COLUMN,\n SELECTION_ALL: AntTable.SELECTION_ALL,\n SELECTION_INVERT: AntTable.SELECTION_INVERT,\n SELECTION_NONE: AntTable.SELECTION_NONE,\n Summary: AntTable.Summary,\n}) as typeof InternalTable & {\n Column: typeof AntTable.Column;\n ColumnGroup: typeof AntTable.ColumnGroup;\n SELECTION_COLUMN: typeof AntTable.SELECTION_COLUMN;\n EXPAND_COLUMN: typeof AntTable.EXPAND_COLUMN;\n SELECTION_ALL: typeof AntTable.SELECTION_ALL;\n SELECTION_INVERT: typeof AntTable.SELECTION_INVERT;\n SELECTION_NONE: typeof AntTable.SELECTION_NONE;\n Summary: typeof AntTable.Summary;\n};\n"],"names":["InnerInternalTable","columns","locale","emptyDescription","loading","virtual","scrollProp","className","variant","rest","ref","cls","useCls","scroll","setScroll","useState","innerRef","useRef","tablePaginationHeight","useEffect","tableEl","parentEl","thead","tpagination","mt","mb","resizeObserver","entries","entry","modifiedColumns","column","sortOrder","jsx","CaretUpIcon","CaretDownIcon","jsxs","Fragment","_filtered","FunnelIcon","modifiedLocale","Empty","spinProps","callbackRef","useCallback","tableRef","AntTable","clsx","InternalTable","forwardRef","Table"],"mappings":";;;;;;;;;AA0CA,MAAMA,IAAqB,CACzB;AAAA,EACE,SAAAC;AAAA,EACA,QAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,SAAAC;AAAA,EACA,SAAAC;AAAA,EACA,QAAQC,IAAa,CAAA;AAAA,EACrB,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,GAAGC;AACL,GACAC,MACG;AACH,QAAMC,IAAMC,EAAA,
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../../src/components/table/component.tsx"],"sourcesContent":["\"use client\";\nimport {\n default as AntTable,\n type ColumnType,\n type TableProps as AntTableProps,\n type TableRef,\n} from \"antd/es/table\";\nimport { CaretDownIcon, CaretUpIcon, FunnelIcon } from \"@bioturing/assets\";\nimport { clsx, useCls } from \"../utils\";\nimport Empty from \"../empty/component\";\nimport { SpinProps } from \"antd/es/spin\";\nimport {\n useState,\n useEffect,\n forwardRef,\n Ref,\n ForwardedRef,\n useCallback,\n useRef,\n} from \"react\";\n\n// Import component-specific styles\nimport \"./style.css\";\n\n// Define interface with all the generic type parameters from AntTable without any\nexport interface TableProps<RecordType extends object = object>\n extends AntTableProps<RecordType> {\n /**\n * Add empty description for the table\n */\n emptyDescription?: React.ReactNode;\n /**\n * Table ref\n */\n tableRef?: React.Ref<HTMLDivElement>;\n /**\n * Table style\n */\n variant?: \"default\" | \"zebra\";\n}\n\n// Simple wrapper component with proper generics\nconst InnerInternalTable = <RecordType extends object = object>(\n {\n columns,\n locale,\n emptyDescription,\n loading,\n virtual,\n scroll: scrollProp = {},\n className,\n variant,\n ...rest\n }: TableProps<RecordType>,\n ref: Ref<TableRef>\n) => {\n const cls = useCls();\n \n const [scroll, setScroll] = useState<TableProps[\"scroll\"]>(\n virtual\n ? {}\n : {\n x: \"fit-content\",\n }\n );\n\n const innerRef = useRef<TableRef>(null);\n const tablePaginationHeight = useRef<number>(0);\n\n useEffect(() => {\n if (!innerRef.current || !virtual) return;\n const tableEl = innerRef.current?.nativeElement;\n const parentEl = tableEl?.parentElement;\n if (!parentEl) return;\n const thead = tableEl?.querySelector(\n `.${cls(\"table-thead\")}`\n ) as HTMLElement;\n const tpagination = tableEl?.querySelector(\n `.${cls(\"table-pagination\")}`\n ) as HTMLElement;\n if (tpagination) {\n const mt = getComputedStyle(tpagination).marginTop;\n const mb = getComputedStyle(tpagination).marginBottom;\n tablePaginationHeight.current =\n tpagination.offsetHeight + parseInt(mt) + parseInt(mb);\n }\n const resizeObserver = new ResizeObserver((entries) => {\n for (const entry of entries) {\n if (entry.target) {\n setScroll({\n y:\n parentEl.offsetHeight -\n (thead ? thead?.offsetHeight : 0) -\n tablePaginationHeight.current,\n });\n }\n }\n });\n if (parentEl && virtual) {\n resizeObserver.observe(parentEl);\n }\n return () => {\n if (parentEl && virtual) {\n resizeObserver.disconnect();\n }\n };\n }, [virtual, cls]);\n\n const modifiedColumns = columns\n ? columns.map((column: ColumnType<RecordType>): ColumnType<RecordType> => {\n return {\n sortIcon: ({ sortOrder }) => {\n return (\n <span\n className={cls(\n \"table-column-sort-icon\",\n sortOrder\n ? `table-column-sort-icon-${sortOrder}`\n : `table-column-sort-icon-none`\n )}\n >\n {!sortOrder ? (\n <>\n <CaretUpIcon weight=\"fill\" />{\" \"}\n <CaretDownIcon weight=\"fill\" />\n </>\n ) : sortOrder === \"ascend\" ? (\n <CaretUpIcon weight=\"fill\" />\n ) : (\n <CaretDownIcon weight=\"fill\" />\n )}\n </span>\n );\n },\n filterIcon: (_filtered) => {\n return (\n <span className={cls(\"table-column-filter-icon\")}>\n <FunnelIcon weight=\"fill\" />\n </span>\n );\n },\n ...column,\n };\n })\n : undefined;\n const modifiedLocale = {\n emptyText: <Empty description={emptyDescription} />,\n ...locale,\n };\n let spinProps: SpinProps | undefined;\n if (typeof loading === \"boolean\") {\n spinProps = {\n spinning: loading,\n indicator: <span className={cls(\"spin-loader\")} />,\n };\n } else if (typeof loading === \"object\") {\n spinProps = {\n spinning: true,\n indicator: <span className={cls(\"spin-loader\")} />,\n ...loading,\n };\n }\n const callbackRef = useCallback(\n (tableRef: TableRef) => {\n if (tableRef) {\n if (typeof ref === \"function\") {\n ref(tableRef);\n }\n if (ref && typeof ref === \"object\" && \"current\" in ref) {\n ref.current = tableRef;\n }\n innerRef.current = tableRef;\n }\n },\n [ref]\n );\n\n return (\n <AntTable\n ref={callbackRef}\n columns={modifiedColumns}\n loading={spinProps}\n locale={modifiedLocale}\n virtual={virtual}\n scroll={{ ...scroll, ...scrollProp }}\n className={clsx(variant === \"zebra\" ? cls(\"table-zebra\") : \"\", className)}\n {...rest}\n />\n );\n};\n\nconst InternalTable = forwardRef(InnerInternalTable) as <\n RecordType extends object = object\n>(\n props: TableProps<RecordType> & { ref?: ForwardedRef<TableRef> }\n) => ReturnType<typeof InnerInternalTable>;\n\n// Create the final component with all static properties\nexport const Table = Object.assign(InternalTable, {\n Column: AntTable.Column,\n ColumnGroup: AntTable.ColumnGroup,\n SELECTION_COLUMN: AntTable.SELECTION_COLUMN,\n EXPAND_COLUMN: AntTable.EXPAND_COLUMN,\n SELECTION_ALL: AntTable.SELECTION_ALL,\n SELECTION_INVERT: AntTable.SELECTION_INVERT,\n SELECTION_NONE: AntTable.SELECTION_NONE,\n Summary: AntTable.Summary,\n}) as typeof InternalTable & {\n Column: typeof AntTable.Column;\n ColumnGroup: typeof AntTable.ColumnGroup;\n SELECTION_COLUMN: typeof AntTable.SELECTION_COLUMN;\n EXPAND_COLUMN: typeof AntTable.EXPAND_COLUMN;\n SELECTION_ALL: typeof AntTable.SELECTION_ALL;\n SELECTION_INVERT: typeof AntTable.SELECTION_INVERT;\n SELECTION_NONE: typeof AntTable.SELECTION_NONE;\n Summary: typeof AntTable.Summary;\n};\n"],"names":["InnerInternalTable","columns","locale","emptyDescription","loading","virtual","scrollProp","className","variant","rest","ref","cls","useCls","scroll","setScroll","useState","innerRef","useRef","tablePaginationHeight","useEffect","tableEl","parentEl","thead","tpagination","mt","mb","resizeObserver","entries","entry","modifiedColumns","column","sortOrder","jsx","CaretUpIcon","CaretDownIcon","jsxs","Fragment","_filtered","FunnelIcon","modifiedLocale","Empty","spinProps","callbackRef","useCallback","tableRef","AntTable","clsx","InternalTable","forwardRef","Table"],"mappings":";;;;;;;;;AA0CA,MAAMA,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MACE,OAAOlC,KAAQ,cACjBA,EAAIkC,CAAQ,GAEVlC,KAAO,OAAOA,KAAQ,YAAY,aAAaA,MACjDA,EAAI,UAAUkC,IAEhB5B,EAAS,UAAU4B;AAAA,IAEvB;AAAA,IACA,CAAClC,CAAG;AAAA,EAAA;AAGN,SACE,gBAAAsB;AAAA,IAACa;AAAA,IAAA;AAAA,MACC,KAAKH;AAAA,MACL,SAASb;AAAA,MACT,SAASY;AAAA,MACT,QAAQF;AAAA,MACR,SAAAlC;AAAA,MACA,QAAQ,EAAE,GAAGQ,GAAQ,GAAGP,EAAA;AAAA,MACxB,WAAWwC,EAAKtC,MAAY,UAAUG,EAAI,aAAa,IAAI,IAAIJ,CAAS;AAAA,MACvE,GAAGE;AAAA,IAAA;AAAA,EAAA;AAGV,GAEMsC,IAAgBC,EAAWhD,CAAkB,GAOtCiD,IAAQ,OAAO,OAAOF,GAAe;AAAA,EAChD,QAAQF,EAAS;AAAA,EACjB,aAAaA,EAAS;AAAA,EACtB,kBAAkBA,EAAS;AAAA,EAC3B,eAAeA,EAAS;AAAA,EACxB,eAAeA,EAAS;AAAA,EACxB,kBAAkBA,EAAS;AAAA,EAC3B,gBAAgBA,EAAS;AAAA,EACzB,SAASA,EAAS;AACpB,CAAC;"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { ConfigProviderProps } from 'antd/es/config-provider';
|
|
2
|
+
import { StyleProviderProps } from '@ant-design/cssinjs';
|
|
3
|
+
import { Theme } from '../../tokens';
|
|
2
4
|
export interface ThemeProviderProps extends Omit<ConfigProviderProps, "theme" | "prefixCls"> {
|
|
3
|
-
theme: "light" | "dark";
|
|
4
5
|
appendClassesTo?: string | HTMLElement;
|
|
6
|
+
appendClassesToChildren?: boolean;
|
|
7
|
+
styleProviderProps?: StyleProviderProps;
|
|
8
|
+
theme?: Theme;
|
|
5
9
|
}
|
|
6
|
-
export declare const ThemeProvider: ({ theme, appendClassesTo, children, }: ThemeProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare const ThemeProvider: ({ theme, appendClassesTo, appendClassesToChildren, styleProviderProps, children, ...configProviderProps }: ThemeProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
11
|
//# sourceMappingURL=component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/theme-provider/component.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/theme-provider/component.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,yBAAyB,CAAC;AAIjC,OAAO,EAAiB,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAExE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAGrC,OAAO,aAAa,CAAC;AAGrB,MAAM,WAAW,kBACf,SAAQ,IAAI,CAAC,mBAAmB,EAAE,OAAO,GAAG,WAAW,CAAC;IACxD,eAAe,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IACvC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAyCD,eAAO,MAAM,aAAa,GAAI,2GAO3B,kBAAkB,4CAkBpB,CAAC"}
|