@expcat/tigercat-react 2.0.19 → 2.1.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.
- package/README.md +25 -16
- package/dist/chunk-2YOP55OF.mjs +639 -0
- package/dist/{chunk-V6P7ZK6O.mjs → chunk-7EMCZVJ2.mjs} +1 -1
- package/dist/chunk-EW43YBPV.mjs +457 -0
- package/dist/{chunk-QJE3MZBO.mjs → chunk-FSMJLJFL.mjs} +1 -1
- package/dist/{chunk-BOGOQ44C.mjs → chunk-GCY55TBC.mjs} +1 -1
- package/dist/chunk-GR3Y3XWP.mjs +47 -0
- package/dist/chunk-IGBQGR6G.mjs +234 -0
- package/dist/{chunk-D33BIMGK.mjs → chunk-IR7VA6AO.mjs} +11 -1
- package/dist/chunk-J76R2S62.mjs +161 -0
- package/dist/{chunk-2WGEHH5A.mjs → chunk-JQJM65RJ.mjs} +1 -1
- package/dist/{chunk-7AFRHC7P.mjs → chunk-KC55B62J.mjs} +127 -42
- package/dist/chunk-KRDHM5KB.mjs +259 -0
- package/dist/chunk-M5MZWOHF.mjs +180 -0
- package/dist/chunk-MFPVVGNA.mjs +248 -0
- package/dist/chunk-NLGLBTSM.mjs +138 -0
- package/dist/chunk-NT7GW2FD.mjs +40 -0
- package/dist/chunk-OKYMTHFQ.mjs +279 -0
- package/dist/{chunk-HHIW7V7B.mjs → chunk-PFL4HNWM.mjs} +1 -8
- package/dist/chunk-RUAPTIQ7.mjs +181 -0
- package/dist/chunk-SEOG5AGS.mjs +72 -0
- package/dist/chunk-TQ6RIFWR.mjs +135 -0
- package/dist/chunk-U4M3DC2P.mjs +48 -0
- package/dist/{chunk-YIB6ZXZF.mjs → chunk-UETARXIK.mjs} +239 -52
- package/dist/chunk-XT43B7ZI.mjs +58 -0
- package/dist/components/ActivityFeed.mjs +1 -1
- package/dist/components/AreaChart.mjs +2 -2
- package/dist/components/AspectRatio.d.mts +10 -0
- package/dist/components/AspectRatio.mjs +8 -0
- package/dist/components/BarChart.mjs +2 -2
- package/dist/components/Cascader.mjs +1 -1
- package/dist/components/ChatWindow.mjs +1 -1
- package/dist/components/ContextMenu.d.mts +36 -0
- package/dist/components/ContextMenu.mjs +17 -0
- package/dist/components/DataExport.mjs +1 -1
- package/dist/components/DataTableWithToolbar.mjs +5 -5
- package/dist/components/Highlight.d.mts +11 -0
- package/dist/components/Highlight.mjs +8 -0
- package/dist/components/ImageCompare.d.mts +15 -0
- package/dist/components/ImageCompare.mjs +8 -0
- package/dist/components/InputOTP.d.mts +33 -0
- package/dist/components/InputOTP.mjs +12 -0
- package/dist/components/Kbd.d.mts +10 -0
- package/dist/components/Kbd.mjs +8 -0
- package/dist/components/LineChart.mjs +2 -2
- package/dist/components/List.mjs +2 -2
- package/dist/components/LoadingBar.d.mts +8 -0
- package/dist/components/LoadingBar.mjs +138 -0
- package/dist/components/LoadingBarContainer.d.mts +8 -0
- package/dist/components/LoadingBarContainer.mjs +8 -0
- package/dist/components/LoadingBarRoot.d.mts +6 -0
- package/dist/components/LoadingBarRoot.mjs +6 -0
- package/dist/components/Marquee.d.mts +10 -0
- package/dist/components/Marquee.mjs +8 -0
- package/dist/components/MaskInput.d.mts +37 -0
- package/dist/components/MaskInput.mjs +10 -0
- package/dist/components/Masonry.d.mts +10 -0
- package/dist/components/Masonry.mjs +8 -0
- package/dist/components/NavigationMenu.d.mts +84 -0
- package/dist/components/NavigationMenu.mjs +23 -0
- package/dist/components/NotificationCenter.mjs +3 -3
- package/dist/components/PageHeader.d.mts +34 -0
- package/dist/components/PageHeader.mjs +11 -0
- package/dist/components/Pagination.mjs +1 -1
- package/dist/components/RadarChart.mjs +2 -2
- package/dist/components/ScatterChart.mjs +2 -2
- package/dist/components/ScrollArea.d.mts +10 -0
- package/dist/components/ScrollArea.mjs +8 -0
- package/dist/components/SplitButton.d.mts +38 -0
- package/dist/components/SplitButton.mjs +12 -0
- package/dist/components/Table.mjs +2 -2
- package/dist/components/TagsInput.d.mts +41 -0
- package/dist/components/TagsInput.mjs +13 -0
- package/dist/components/TreeSelect.mjs +2 -1
- package/dist/index.d.mts +17 -1
- package/dist/index.mjs +355 -0
- package/package.json +117 -2
- package/dist/{chunk-NCHUEGUW.mjs → chunk-H6MVW5YD.mjs} +3 -3
- package/dist/{chunk-UT5BV2VO.mjs → chunk-I4MWOYJS.mjs} +3 -3
- package/dist/{chunk-E7OTDBI6.mjs → chunk-NWVNTZOP.mjs} +3 -3
- package/dist/{chunk-FYINJRYN.mjs → chunk-RQ4PUK6G.mjs} +3 -3
- package/dist/{chunk-KMP5CVNK.mjs → chunk-UKY2EPS3.mjs} +3 -3
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Button
|
|
3
|
+
} from "./chunk-5TE7KLE5.mjs";
|
|
4
|
+
import {
|
|
5
|
+
Link
|
|
6
|
+
} from "./chunk-XZVQ3PJS.mjs";
|
|
7
|
+
|
|
8
|
+
// src/components/PageHeader.tsx
|
|
9
|
+
import { forwardRef, useCallback, useMemo } from "react";
|
|
10
|
+
import {
|
|
11
|
+
chevronLeftSolidIcon20PathD,
|
|
12
|
+
composeComponentClasses,
|
|
13
|
+
getPageHeaderBackButtonClasses,
|
|
14
|
+
getPageHeaderRootClasses,
|
|
15
|
+
hasPageHeaderHeadingContent,
|
|
16
|
+
icon20ViewBox,
|
|
17
|
+
pageHeaderActionsClasses,
|
|
18
|
+
pageHeaderBackIconClasses,
|
|
19
|
+
pageHeaderBackWrapClasses,
|
|
20
|
+
pageHeaderContentClasses,
|
|
21
|
+
pageHeaderHeadingRowClasses,
|
|
22
|
+
pageHeaderMainClasses,
|
|
23
|
+
pageHeaderStartClasses,
|
|
24
|
+
pageHeaderSubtitleClasses,
|
|
25
|
+
pageHeaderTitleClasses,
|
|
26
|
+
pageHeaderTitleRowClasses,
|
|
27
|
+
resolvePageHeaderBackAriaLabel,
|
|
28
|
+
resolvePageHeaderBackVisibility
|
|
29
|
+
} from "@expcat/tigercat-core";
|
|
30
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
31
|
+
function BackIcon() {
|
|
32
|
+
return /* @__PURE__ */ jsx(
|
|
33
|
+
"svg",
|
|
34
|
+
{
|
|
35
|
+
className: pageHeaderBackIconClasses,
|
|
36
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
37
|
+
viewBox: icon20ViewBox,
|
|
38
|
+
fill: "currentColor",
|
|
39
|
+
"aria-hidden": "true",
|
|
40
|
+
focusable: "false",
|
|
41
|
+
children: /* @__PURE__ */ jsx("path", { fillRule: "evenodd", d: chevronLeftSolidIcon20PathD, clipRule: "evenodd" })
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
var PageHeader = forwardRef(
|
|
46
|
+
({
|
|
47
|
+
showBack,
|
|
48
|
+
backHref,
|
|
49
|
+
backAriaLabel,
|
|
50
|
+
title,
|
|
51
|
+
subTitle,
|
|
52
|
+
breadcrumb,
|
|
53
|
+
actions,
|
|
54
|
+
back,
|
|
55
|
+
onBack,
|
|
56
|
+
className,
|
|
57
|
+
style,
|
|
58
|
+
children,
|
|
59
|
+
...rest
|
|
60
|
+
}, ref) => {
|
|
61
|
+
const hasBackOverride = back != null && back !== false;
|
|
62
|
+
const hasBreadcrumb = breadcrumb != null && breadcrumb !== false;
|
|
63
|
+
const hasTitle = title != null && title !== false && title !== "";
|
|
64
|
+
const hasSubtitle = subTitle != null && subTitle !== false && subTitle !== "";
|
|
65
|
+
const hasActions = actions != null && actions !== false;
|
|
66
|
+
const hasBody = children != null && children !== false;
|
|
67
|
+
const showBackControl = resolvePageHeaderBackVisibility({
|
|
68
|
+
showBack,
|
|
69
|
+
hasHandler: Boolean(onBack),
|
|
70
|
+
hasBackHref: Boolean(backHref),
|
|
71
|
+
hasBackOverride
|
|
72
|
+
});
|
|
73
|
+
const showHeading = hasPageHeaderHeadingContent({
|
|
74
|
+
showBack: showBackControl,
|
|
75
|
+
hasBreadcrumb,
|
|
76
|
+
hasTitle,
|
|
77
|
+
hasSubtitle,
|
|
78
|
+
hasActions
|
|
79
|
+
});
|
|
80
|
+
const resolvedBackAriaLabel = resolvePageHeaderBackAriaLabel(backAriaLabel);
|
|
81
|
+
const rootClasses = useMemo(
|
|
82
|
+
() => composeComponentClasses(getPageHeaderRootClasses(className)),
|
|
83
|
+
[className]
|
|
84
|
+
);
|
|
85
|
+
const backButtonClasses = useMemo(() => getPageHeaderBackButtonClasses(), []);
|
|
86
|
+
const handleBack = useCallback(
|
|
87
|
+
(event) => {
|
|
88
|
+
onBack?.(event);
|
|
89
|
+
},
|
|
90
|
+
[onBack]
|
|
91
|
+
);
|
|
92
|
+
const defaultBackControl = backHref ? /* @__PURE__ */ jsx(
|
|
93
|
+
Link,
|
|
94
|
+
{
|
|
95
|
+
href: backHref,
|
|
96
|
+
underline: false,
|
|
97
|
+
variant: "default",
|
|
98
|
+
className: backButtonClasses,
|
|
99
|
+
"aria-label": resolvedBackAriaLabel,
|
|
100
|
+
onClick: handleBack,
|
|
101
|
+
children: /* @__PURE__ */ jsx(BackIcon, {})
|
|
102
|
+
}
|
|
103
|
+
) : /* @__PURE__ */ jsx(
|
|
104
|
+
Button,
|
|
105
|
+
{
|
|
106
|
+
variant: "ghost",
|
|
107
|
+
size: "sm",
|
|
108
|
+
className: backButtonClasses,
|
|
109
|
+
"aria-label": resolvedBackAriaLabel,
|
|
110
|
+
onClick: handleBack,
|
|
111
|
+
children: /* @__PURE__ */ jsx(BackIcon, {})
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
return /* @__PURE__ */ jsxs("header", { ...rest, ref, "data-page-header": "", className: rootClasses, style, children: [
|
|
115
|
+
showHeading ? /* @__PURE__ */ jsxs("div", { className: pageHeaderHeadingRowClasses, "data-page-header-heading": "", children: [
|
|
116
|
+
/* @__PURE__ */ jsxs("div", { className: pageHeaderStartClasses, children: [
|
|
117
|
+
showBackControl ? /* @__PURE__ */ jsx("div", { className: pageHeaderBackWrapClasses, "data-page-header-back": "", children: hasBackOverride ? back : defaultBackControl }) : null,
|
|
118
|
+
hasBreadcrumb || hasTitle || hasSubtitle ? /* @__PURE__ */ jsxs("div", { className: pageHeaderMainClasses, children: [
|
|
119
|
+
hasBreadcrumb ? breadcrumb : null,
|
|
120
|
+
hasTitle || hasSubtitle ? /* @__PURE__ */ jsxs("div", { className: pageHeaderTitleRowClasses, children: [
|
|
121
|
+
hasTitle ? /* @__PURE__ */ jsx("div", { className: pageHeaderTitleClasses, "data-page-header-title": "", children: title }) : null,
|
|
122
|
+
hasSubtitle ? /* @__PURE__ */ jsx("div", { className: pageHeaderSubtitleClasses, "data-page-header-subtitle": "", children: subTitle }) : null
|
|
123
|
+
] }) : null
|
|
124
|
+
] }) : null
|
|
125
|
+
] }),
|
|
126
|
+
hasActions ? /* @__PURE__ */ jsx("div", { className: pageHeaderActionsClasses, "data-page-header-actions": "", children: actions }) : null
|
|
127
|
+
] }) : null,
|
|
128
|
+
hasBody ? /* @__PURE__ */ jsx("div", { className: pageHeaderContentClasses, children }) : null
|
|
129
|
+
] });
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
PageHeader.displayName = "PageHeader";
|
|
133
|
+
var PageHeader_default = PageHeader;
|
|
134
|
+
|
|
135
|
+
export {
|
|
136
|
+
PageHeader,
|
|
137
|
+
PageHeader_default
|
|
138
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// src/components/AspectRatio.tsx
|
|
2
|
+
import { forwardRef, useMemo } from "react";
|
|
3
|
+
import {
|
|
4
|
+
getAspectRatioContentClasses,
|
|
5
|
+
getAspectRatioRootClasses,
|
|
6
|
+
getAspectRatioStyle,
|
|
7
|
+
ASPECT_RATIO_DEFAULT
|
|
8
|
+
} from "@expcat/tigercat-core";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
var AspectRatio = forwardRef(
|
|
11
|
+
({
|
|
12
|
+
ratio = ASPECT_RATIO_DEFAULT,
|
|
13
|
+
className,
|
|
14
|
+
contentClassName,
|
|
15
|
+
children,
|
|
16
|
+
style: styleProp,
|
|
17
|
+
...rest
|
|
18
|
+
}, ref) => {
|
|
19
|
+
const rootClasses = useMemo(() => getAspectRatioRootClasses(className), [className]);
|
|
20
|
+
const contentClasses = useMemo(
|
|
21
|
+
() => getAspectRatioContentClasses(contentClassName),
|
|
22
|
+
[contentClassName]
|
|
23
|
+
);
|
|
24
|
+
const style = useMemo(
|
|
25
|
+
() => ({
|
|
26
|
+
...getAspectRatioStyle(ratio),
|
|
27
|
+
...styleProp
|
|
28
|
+
}),
|
|
29
|
+
[ratio, styleProp]
|
|
30
|
+
);
|
|
31
|
+
return /* @__PURE__ */ jsx("div", { ref, "data-aspect-ratio": "", className: rootClasses, style, ...rest, children: /* @__PURE__ */ jsx("div", { "data-aspect-ratio-content": "", className: contentClasses, children }) });
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
AspectRatio.displayName = "AspectRatio";
|
|
35
|
+
var AspectRatio_default = AspectRatio;
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
AspectRatio,
|
|
39
|
+
AspectRatio_default
|
|
40
|
+
};
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
// src/components/ImageCompare.tsx
|
|
2
|
+
import { forwardRef, useCallback, useEffect, useRef, useState } from "react";
|
|
3
|
+
import {
|
|
4
|
+
getImageCompareAfterClasses,
|
|
5
|
+
getImageCompareBeforeClasses,
|
|
6
|
+
getImageCompareClipStyle,
|
|
7
|
+
getImageCompareHandleClasses,
|
|
8
|
+
getImageCompareHandleStyle,
|
|
9
|
+
getImageCompareImgClasses,
|
|
10
|
+
getImageCompareKeyboardPosition,
|
|
11
|
+
getImageCompareKnobClasses,
|
|
12
|
+
getImageCompareLineClasses,
|
|
13
|
+
getImageComparePointerClientPoint,
|
|
14
|
+
getImageComparePositionFromPointer,
|
|
15
|
+
getImageCompareRootClasses,
|
|
16
|
+
getImageCompareRootStyle,
|
|
17
|
+
isImageCompareInteractiveTarget,
|
|
18
|
+
isImageCompareVertical,
|
|
19
|
+
resolveImageCompareAriaLabel,
|
|
20
|
+
resolveImageCompareFit,
|
|
21
|
+
resolveImageCompareOrientation,
|
|
22
|
+
resolveImageComparePosition,
|
|
23
|
+
resolveImageCompareStep
|
|
24
|
+
} from "@expcat/tigercat-core";
|
|
25
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
26
|
+
function renderPaneContent(slot, src, alt, fit) {
|
|
27
|
+
if (slot != null) return slot;
|
|
28
|
+
if (!src) return null;
|
|
29
|
+
return /* @__PURE__ */ jsx(
|
|
30
|
+
"img",
|
|
31
|
+
{
|
|
32
|
+
src,
|
|
33
|
+
alt,
|
|
34
|
+
className: getImageCompareImgClasses(resolveImageCompareFit(fit)),
|
|
35
|
+
draggable: false
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
var ImageCompare = forwardRef(
|
|
40
|
+
({
|
|
41
|
+
beforeSrc,
|
|
42
|
+
afterSrc,
|
|
43
|
+
beforeAlt = "",
|
|
44
|
+
afterAlt = "",
|
|
45
|
+
fit,
|
|
46
|
+
position: controlledPosition,
|
|
47
|
+
defaultPosition,
|
|
48
|
+
orientation,
|
|
49
|
+
step,
|
|
50
|
+
disabled = false,
|
|
51
|
+
width,
|
|
52
|
+
height,
|
|
53
|
+
ariaLabel,
|
|
54
|
+
className,
|
|
55
|
+
style,
|
|
56
|
+
before,
|
|
57
|
+
after,
|
|
58
|
+
onChange,
|
|
59
|
+
onMouseDown,
|
|
60
|
+
onTouchStart,
|
|
61
|
+
onKeyDown,
|
|
62
|
+
...rest
|
|
63
|
+
}, ref) => {
|
|
64
|
+
const {
|
|
65
|
+
"aria-label": ariaLabelAttr,
|
|
66
|
+
"aria-labelledby": ariaLabelledby,
|
|
67
|
+
"aria-describedby": ariaDescribedby,
|
|
68
|
+
...domProps
|
|
69
|
+
} = rest;
|
|
70
|
+
const resolvedOrientation = resolveImageCompareOrientation(orientation);
|
|
71
|
+
const resolvedStep = resolveImageCompareStep(step);
|
|
72
|
+
const [uncontrolledPosition, setUncontrolledPosition] = useState(
|
|
73
|
+
() => resolveImageComparePosition(controlledPosition ?? defaultPosition, step)
|
|
74
|
+
);
|
|
75
|
+
const [dragging, setDragging] = useState(false);
|
|
76
|
+
const rootRef = useRef(null);
|
|
77
|
+
const handleRef = useRef(null);
|
|
78
|
+
const draggingRef = useRef(false);
|
|
79
|
+
const isControlled = controlledPosition !== void 0;
|
|
80
|
+
const current = resolveImageComparePosition(
|
|
81
|
+
isControlled ? controlledPosition : uncontrolledPosition,
|
|
82
|
+
step
|
|
83
|
+
);
|
|
84
|
+
const vertical = isImageCompareVertical(resolvedOrientation);
|
|
85
|
+
const resolvedAriaLabel = resolveImageCompareAriaLabel(
|
|
86
|
+
typeof ariaLabelAttr === "string" ? ariaLabelAttr : ariaLabel
|
|
87
|
+
);
|
|
88
|
+
const setRootRef = useCallback(
|
|
89
|
+
(node) => {
|
|
90
|
+
rootRef.current = node;
|
|
91
|
+
if (typeof ref === "function") ref(node);
|
|
92
|
+
else if (ref) ref.current = node;
|
|
93
|
+
},
|
|
94
|
+
[ref]
|
|
95
|
+
);
|
|
96
|
+
const commit = useCallback(
|
|
97
|
+
(next) => {
|
|
98
|
+
const resolved = resolveImageComparePosition(next, step);
|
|
99
|
+
if (!isControlled) setUncontrolledPosition(resolved);
|
|
100
|
+
onChange?.(resolved);
|
|
101
|
+
},
|
|
102
|
+
[isControlled, onChange, step]
|
|
103
|
+
);
|
|
104
|
+
const positionFromEvent = useCallback(
|
|
105
|
+
(event) => {
|
|
106
|
+
const root = rootRef.current;
|
|
107
|
+
const source = "nativeEvent" in event ? event.nativeEvent : event;
|
|
108
|
+
const point = getImageComparePointerClientPoint(source);
|
|
109
|
+
if (!root || !point) return null;
|
|
110
|
+
return getImageComparePositionFromPointer({
|
|
111
|
+
clientX: point.clientX,
|
|
112
|
+
clientY: point.clientY,
|
|
113
|
+
rect: root.getBoundingClientRect(),
|
|
114
|
+
orientation: resolvedOrientation,
|
|
115
|
+
step: resolvedStep
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
[resolvedOrientation, resolvedStep]
|
|
119
|
+
);
|
|
120
|
+
const handleMove = useCallback(
|
|
121
|
+
(event) => {
|
|
122
|
+
if (disabled || !draggingRef.current) return;
|
|
123
|
+
const next = positionFromEvent(event);
|
|
124
|
+
if (next === null) return;
|
|
125
|
+
commit(next);
|
|
126
|
+
},
|
|
127
|
+
[commit, disabled, positionFromEvent]
|
|
128
|
+
);
|
|
129
|
+
const handleEnd = useCallback(() => {
|
|
130
|
+
draggingRef.current = false;
|
|
131
|
+
setDragging(false);
|
|
132
|
+
}, []);
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
if (!dragging) return;
|
|
135
|
+
document.addEventListener("mousemove", handleMove);
|
|
136
|
+
document.addEventListener("mouseup", handleEnd);
|
|
137
|
+
document.addEventListener("touchmove", handleMove);
|
|
138
|
+
document.addEventListener("touchend", handleEnd);
|
|
139
|
+
return () => {
|
|
140
|
+
document.removeEventListener("mousemove", handleMove);
|
|
141
|
+
document.removeEventListener("mouseup", handleEnd);
|
|
142
|
+
document.removeEventListener("touchmove", handleMove);
|
|
143
|
+
document.removeEventListener("touchend", handleEnd);
|
|
144
|
+
};
|
|
145
|
+
}, [dragging, handleEnd, handleMove]);
|
|
146
|
+
const startDrag = useCallback(
|
|
147
|
+
(event) => {
|
|
148
|
+
if (disabled) return;
|
|
149
|
+
if ("button" in event && event.button !== 0) return;
|
|
150
|
+
if (isImageCompareInteractiveTarget(event.target, handleRef.current)) return;
|
|
151
|
+
event.preventDefault();
|
|
152
|
+
draggingRef.current = true;
|
|
153
|
+
setDragging(true);
|
|
154
|
+
const next = positionFromEvent(event);
|
|
155
|
+
if (next !== null) commit(next);
|
|
156
|
+
handleRef.current?.focus();
|
|
157
|
+
},
|
|
158
|
+
[commit, disabled, positionFromEvent]
|
|
159
|
+
);
|
|
160
|
+
const handleMouseDown = useCallback(
|
|
161
|
+
(event) => {
|
|
162
|
+
startDrag(event);
|
|
163
|
+
onMouseDown?.(event);
|
|
164
|
+
},
|
|
165
|
+
[onMouseDown, startDrag]
|
|
166
|
+
);
|
|
167
|
+
const handleTouchStart = useCallback(
|
|
168
|
+
(event) => {
|
|
169
|
+
startDrag(event);
|
|
170
|
+
onTouchStart?.(event);
|
|
171
|
+
},
|
|
172
|
+
[onTouchStart, startDrag]
|
|
173
|
+
);
|
|
174
|
+
const handleKeyDown = useCallback(
|
|
175
|
+
(event) => {
|
|
176
|
+
if (disabled) {
|
|
177
|
+
onKeyDown?.(event);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const next = getImageCompareKeyboardPosition(event.key, current, resolvedStep);
|
|
181
|
+
if (next !== null) {
|
|
182
|
+
event.preventDefault();
|
|
183
|
+
commit(next);
|
|
184
|
+
}
|
|
185
|
+
onKeyDown?.(event);
|
|
186
|
+
},
|
|
187
|
+
[commit, current, disabled, onKeyDown, resolvedStep]
|
|
188
|
+
);
|
|
189
|
+
return /* @__PURE__ */ jsxs(
|
|
190
|
+
"div",
|
|
191
|
+
{
|
|
192
|
+
...domProps,
|
|
193
|
+
ref: setRootRef,
|
|
194
|
+
"data-image-compare": "",
|
|
195
|
+
"data-image-compare-orientation": resolvedOrientation,
|
|
196
|
+
"data-image-compare-position": String(current),
|
|
197
|
+
"data-image-compare-disabled": disabled ? "true" : "false",
|
|
198
|
+
"data-image-compare-dragging": dragging ? "true" : "false",
|
|
199
|
+
className: getImageCompareRootClasses({
|
|
200
|
+
orientation: resolvedOrientation,
|
|
201
|
+
disabled,
|
|
202
|
+
className
|
|
203
|
+
}),
|
|
204
|
+
style: {
|
|
205
|
+
...getImageCompareRootStyle({
|
|
206
|
+
position: current,
|
|
207
|
+
step: resolvedStep,
|
|
208
|
+
width,
|
|
209
|
+
height
|
|
210
|
+
}),
|
|
211
|
+
...style
|
|
212
|
+
},
|
|
213
|
+
onMouseDown: handleMouseDown,
|
|
214
|
+
onTouchStart: handleTouchStart,
|
|
215
|
+
children: [
|
|
216
|
+
/* @__PURE__ */ jsx("div", { className: getImageCompareAfterClasses(), "data-image-compare-after": "", children: renderPaneContent(after, afterSrc, afterAlt, fit) }),
|
|
217
|
+
/* @__PURE__ */ jsx(
|
|
218
|
+
"div",
|
|
219
|
+
{
|
|
220
|
+
className: getImageCompareBeforeClasses(),
|
|
221
|
+
style: getImageCompareClipStyle(current, resolvedOrientation, resolvedStep),
|
|
222
|
+
"data-image-compare-before": "",
|
|
223
|
+
children: renderPaneContent(before, beforeSrc, beforeAlt, fit)
|
|
224
|
+
}
|
|
225
|
+
),
|
|
226
|
+
/* @__PURE__ */ jsxs(
|
|
227
|
+
"div",
|
|
228
|
+
{
|
|
229
|
+
ref: handleRef,
|
|
230
|
+
className: getImageCompareHandleClasses({
|
|
231
|
+
orientation: resolvedOrientation,
|
|
232
|
+
disabled
|
|
233
|
+
}),
|
|
234
|
+
style: getImageCompareHandleStyle(current, resolvedOrientation, resolvedStep),
|
|
235
|
+
"data-image-compare-handle": "",
|
|
236
|
+
role: "slider",
|
|
237
|
+
tabIndex: disabled ? -1 : 0,
|
|
238
|
+
"aria-label": resolvedAriaLabel,
|
|
239
|
+
"aria-labelledby": ariaLabelledby,
|
|
240
|
+
"aria-describedby": ariaDescribedby,
|
|
241
|
+
"aria-valuemin": 0,
|
|
242
|
+
"aria-valuemax": 100,
|
|
243
|
+
"aria-valuenow": current,
|
|
244
|
+
"aria-valuetext": `${current}%`,
|
|
245
|
+
"aria-orientation": vertical ? "vertical" : "horizontal",
|
|
246
|
+
"aria-disabled": disabled,
|
|
247
|
+
onKeyDown: handleKeyDown,
|
|
248
|
+
children: [
|
|
249
|
+
/* @__PURE__ */ jsx(
|
|
250
|
+
"div",
|
|
251
|
+
{
|
|
252
|
+
className: getImageCompareLineClasses(resolvedOrientation),
|
|
253
|
+
"data-image-compare-line": "",
|
|
254
|
+
"aria-hidden": "true"
|
|
255
|
+
}
|
|
256
|
+
),
|
|
257
|
+
/* @__PURE__ */ jsx(
|
|
258
|
+
"div",
|
|
259
|
+
{
|
|
260
|
+
className: getImageCompareKnobClasses(),
|
|
261
|
+
"data-image-compare-knob": "",
|
|
262
|
+
"aria-hidden": "true"
|
|
263
|
+
}
|
|
264
|
+
)
|
|
265
|
+
]
|
|
266
|
+
}
|
|
267
|
+
)
|
|
268
|
+
]
|
|
269
|
+
}
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
);
|
|
273
|
+
ImageCompare.displayName = "ImageCompare";
|
|
274
|
+
var ImageCompare_default = ImageCompare;
|
|
275
|
+
|
|
276
|
+
export {
|
|
277
|
+
ImageCompare,
|
|
278
|
+
ImageCompare_default
|
|
279
|
+
};
|
|
@@ -135,14 +135,7 @@ var Pagination = ({
|
|
|
135
135
|
}
|
|
136
136
|
onPageSizeChange?.(newPage, newPageSize);
|
|
137
137
|
},
|
|
138
|
-
[
|
|
139
|
-
disabled,
|
|
140
|
-
total,
|
|
141
|
-
validatedCurrentPage,
|
|
142
|
-
controlledPageSize,
|
|
143
|
-
controlledCurrent,
|
|
144
|
-
onPageSizeChange
|
|
145
|
-
]
|
|
138
|
+
[disabled, total, validatedCurrentPage, controlledPageSize, controlledCurrent, onPageSizeChange]
|
|
146
139
|
);
|
|
147
140
|
const handleQuickJumperSubmit = useCallback(() => {
|
|
148
141
|
quickJumperValidationSchedulerRef.current?.cancel();
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useFormItemControlContext
|
|
3
|
+
} from "./chunk-F6T3OLTQ.mjs";
|
|
4
|
+
import {
|
|
5
|
+
useControlledState
|
|
6
|
+
} from "./chunk-MEFARVQI.mjs";
|
|
7
|
+
|
|
8
|
+
// src/components/MaskInput.tsx
|
|
9
|
+
import { useEffect, useId, useLayoutEffect, useMemo, useRef } from "react";
|
|
10
|
+
import {
|
|
11
|
+
applyMaskInput,
|
|
12
|
+
classNames,
|
|
13
|
+
formatMaskValue,
|
|
14
|
+
getInputClasses,
|
|
15
|
+
getInputClearButtonClasses,
|
|
16
|
+
getInputErrorClasses,
|
|
17
|
+
getInputWrapperClasses,
|
|
18
|
+
injectShakeStyle,
|
|
19
|
+
parseMask,
|
|
20
|
+
SHAKE_CLASS
|
|
21
|
+
} from "@expcat/tigercat-core";
|
|
22
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
23
|
+
var MaskInput = ({
|
|
24
|
+
size,
|
|
25
|
+
status: statusProp,
|
|
26
|
+
errorMessage: errorMessageProp,
|
|
27
|
+
_shakeTrigger: shakeTriggerProp,
|
|
28
|
+
mask,
|
|
29
|
+
tokens,
|
|
30
|
+
value,
|
|
31
|
+
defaultValue,
|
|
32
|
+
placeholder = "",
|
|
33
|
+
disabled = false,
|
|
34
|
+
readonly = false,
|
|
35
|
+
clearable = false,
|
|
36
|
+
name,
|
|
37
|
+
id,
|
|
38
|
+
autoComplete,
|
|
39
|
+
autoFocus = false,
|
|
40
|
+
onChange,
|
|
41
|
+
onComplete,
|
|
42
|
+
onFocus,
|
|
43
|
+
onBlur,
|
|
44
|
+
onClear,
|
|
45
|
+
className,
|
|
46
|
+
style,
|
|
47
|
+
...rest
|
|
48
|
+
}) => {
|
|
49
|
+
injectShakeStyle();
|
|
50
|
+
const formItemControl = useFormItemControlContext();
|
|
51
|
+
const effectiveSize = size ?? "md";
|
|
52
|
+
const status = statusProp ?? formItemControl?.status ?? "default";
|
|
53
|
+
const errorMessage = errorMessageProp ?? formItemControl?.errorMessage;
|
|
54
|
+
const shakeTrigger = shakeTriggerProp ?? formItemControl?.shakeTrigger;
|
|
55
|
+
const wrapperRef = useRef(null);
|
|
56
|
+
const inputRef = useRef(null);
|
|
57
|
+
const isComposing = useRef(false);
|
|
58
|
+
const pendingCaret = useRef(null);
|
|
59
|
+
const reactId = useId();
|
|
60
|
+
const errorMsgId = `tiger-mask-input-error-${reactId}`;
|
|
61
|
+
const spec = useMemo(() => parseMask(mask, tokens), [mask, tokens]);
|
|
62
|
+
const [rawValue, setRawValue] = useControlledState(value, defaultValue ?? "");
|
|
63
|
+
const formatted = useMemo(() => formatMaskValue(rawValue, spec), [rawValue, spec]);
|
|
64
|
+
const maskedValue = formatted.maskedValue;
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (status === "error" && wrapperRef.current) {
|
|
67
|
+
const el = wrapperRef.current;
|
|
68
|
+
el.classList.remove(SHAKE_CLASS);
|
|
69
|
+
void el.offsetWidth;
|
|
70
|
+
el.classList.add(SHAKE_CLASS);
|
|
71
|
+
}
|
|
72
|
+
}, [status, shakeTrigger]);
|
|
73
|
+
useLayoutEffect(() => {
|
|
74
|
+
if (pendingCaret.current !== null && inputRef.current) {
|
|
75
|
+
const caret = pendingCaret.current;
|
|
76
|
+
inputRef.current.setSelectionRange(caret, caret);
|
|
77
|
+
pendingCaret.current = null;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
const commit = (raw, detail, previousMasked) => {
|
|
81
|
+
setRawValue(raw);
|
|
82
|
+
onChange?.(raw, detail);
|
|
83
|
+
if (detail.completed && !formatMaskValue(previousMasked, spec).completed) {
|
|
84
|
+
onComplete?.(raw, detail.maskedValue);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const applyValue = (inputValue, caret) => {
|
|
88
|
+
const previousMasked = maskedValue;
|
|
89
|
+
const result = applyMaskInput(inputValue, caret, spec, previousMasked);
|
|
90
|
+
if (inputRef.current) inputRef.current.value = result.maskedValue;
|
|
91
|
+
pendingCaret.current = result.caret;
|
|
92
|
+
commit(
|
|
93
|
+
result.rawValue,
|
|
94
|
+
{ maskedValue: result.maskedValue, completed: result.completed },
|
|
95
|
+
previousMasked
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
const handleInput = (event) => {
|
|
99
|
+
if (isComposing.current) return;
|
|
100
|
+
const target = event.currentTarget;
|
|
101
|
+
applyValue(target.value, target.selectionStart ?? target.value.length);
|
|
102
|
+
};
|
|
103
|
+
const handlePaste = (event) => {
|
|
104
|
+
if (disabled || readonly) return;
|
|
105
|
+
event.preventDefault();
|
|
106
|
+
const input = event.currentTarget;
|
|
107
|
+
const text = event.clipboardData.getData("text");
|
|
108
|
+
const start = input.selectionStart ?? input.value.length;
|
|
109
|
+
const end = input.selectionEnd ?? input.value.length;
|
|
110
|
+
applyValue(input.value.slice(0, start) + text + input.value.slice(end), start + text.length);
|
|
111
|
+
};
|
|
112
|
+
const handleCompositionStart = () => {
|
|
113
|
+
isComposing.current = true;
|
|
114
|
+
};
|
|
115
|
+
const handleCompositionEnd = (event) => {
|
|
116
|
+
isComposing.current = false;
|
|
117
|
+
const target = event.currentTarget;
|
|
118
|
+
applyValue(target.value, target.selectionStart ?? target.value.length);
|
|
119
|
+
};
|
|
120
|
+
const handleClear = () => {
|
|
121
|
+
setRawValue("");
|
|
122
|
+
onChange?.("", { maskedValue: "", completed: false });
|
|
123
|
+
onClear?.();
|
|
124
|
+
inputRef.current?.focus();
|
|
125
|
+
};
|
|
126
|
+
const hasSuffix = clearable;
|
|
127
|
+
const activeError = status === "error" && !!errorMessage;
|
|
128
|
+
const showClear = clearable && !disabled && !readonly && rawValue.length > 0;
|
|
129
|
+
const inputClasses = getInputClasses({
|
|
130
|
+
size: effectiveSize,
|
|
131
|
+
status,
|
|
132
|
+
hasPrefix: false,
|
|
133
|
+
hasSuffix
|
|
134
|
+
});
|
|
135
|
+
return /* @__PURE__ */ jsxs("div", { ref: wrapperRef, className: classNames(getInputWrapperClasses(), className), style, children: [
|
|
136
|
+
/* @__PURE__ */ jsx(
|
|
137
|
+
"input",
|
|
138
|
+
{
|
|
139
|
+
...rest,
|
|
140
|
+
ref: inputRef,
|
|
141
|
+
className: inputClasses,
|
|
142
|
+
type: "text",
|
|
143
|
+
value: maskedValue,
|
|
144
|
+
placeholder,
|
|
145
|
+
disabled,
|
|
146
|
+
readOnly: readonly,
|
|
147
|
+
name,
|
|
148
|
+
id,
|
|
149
|
+
autoComplete,
|
|
150
|
+
autoFocus,
|
|
151
|
+
...status === "error" ? { "aria-invalid": true } : {},
|
|
152
|
+
...activeError ? { "aria-describedby": errorMsgId } : {},
|
|
153
|
+
onInput: handleInput,
|
|
154
|
+
onChange: () => {
|
|
155
|
+
},
|
|
156
|
+
onPaste: handlePaste,
|
|
157
|
+
onCompositionStart: handleCompositionStart,
|
|
158
|
+
onCompositionEnd: handleCompositionEnd,
|
|
159
|
+
onFocus,
|
|
160
|
+
onBlur
|
|
161
|
+
}
|
|
162
|
+
),
|
|
163
|
+
activeError ? /* @__PURE__ */ jsx("div", { id: errorMsgId, className: getInputErrorClasses(effectiveSize), children: errorMessage }) : showClear && /* @__PURE__ */ jsx(
|
|
164
|
+
"button",
|
|
165
|
+
{
|
|
166
|
+
type: "button",
|
|
167
|
+
className: getInputClearButtonClasses(effectiveSize),
|
|
168
|
+
onClick: handleClear,
|
|
169
|
+
"aria-label": "Clear input",
|
|
170
|
+
tabIndex: -1,
|
|
171
|
+
children: "\u2715"
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
] });
|
|
175
|
+
};
|
|
176
|
+
var MaskInput_default = MaskInput;
|
|
177
|
+
|
|
178
|
+
export {
|
|
179
|
+
MaskInput,
|
|
180
|
+
MaskInput_default
|
|
181
|
+
};
|