@jc-times/business-ui 0.2.43
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/AGENTS.md +6 -0
- package/CHANGELOG.md +267 -0
- package/README.md +55 -0
- package/THIRD_PARTY_NOTICES.md +29 -0
- package/bin/business-ui-gate.mjs +171 -0
- package/dist/Alert.js +47 -0
- package/dist/AsyncDirectoryPicker.js +134 -0
- package/dist/AsyncSearchPicker.js +155 -0
- package/dist/AutoComplete.js +34 -0
- package/dist/Badge.js +14 -0
- package/dist/Button.js +54 -0
- package/dist/Cascader.js +141 -0
- package/dist/Combobox.js +106 -0
- package/dist/ConfirmDialog.js +48 -0
- package/dist/DataTableHorizontalScrollbar.js +38 -0
- package/dist/DataTableIcons.js +37 -0
- package/dist/DataTableMergedRows.js +45 -0
- package/dist/DataTableTheme.js +135 -0
- package/dist/DateInput.js +223 -0
- package/dist/DropdownMenu.js +130 -0
- package/dist/EmptyState.js +27 -0
- package/dist/ExplainableButton.js +68 -0
- package/dist/FileDropzone.js +70 -0
- package/dist/FilePreparationDialog.js +33 -0
- package/dist/FloatingControls.js +120 -0
- package/dist/FormField.js +143 -0
- package/dist/MetricCard.js +38 -0
- package/dist/ModalShell.js +139 -0
- package/dist/MultiSelect.js +137 -0
- package/dist/NumericInput.js +97 -0
- package/dist/OverlayContainer.js +9 -0
- package/dist/PageHeader.js +36 -0
- package/dist/Pagination.js +115 -0
- package/dist/PreparedFileDropzone.js +30 -0
- package/dist/RecoverableAsyncState.js +35 -0
- package/dist/RovingTabs.js +54 -0
- package/dist/SectionCard.js +35 -0
- package/dist/SegmentedControl.js +46 -0
- package/dist/Select.js +73 -0
- package/dist/Skeleton.js +25 -0
- package/dist/SortableList.js +55 -0
- package/dist/StructuredAddressInput.js +157 -0
- package/dist/Toast.js +100 -0
- package/dist/ToggleSwitch.js +34 -0
- package/dist/TreeSelect.js +444 -0
- package/dist/amount-format.js +20 -0
- package/dist/business-ui.js +44 -0
- package/dist/chinese-address-regions.js +15 -0
- package/dist/classNames.js +6 -0
- package/dist/data-table.js +257 -0
- package/dist/document-render-budget.js +22 -0
- package/dist/document-viewer/ContinuousPdfViewer.js +145 -0
- package/dist/document-viewer/DocumentViewer.js +123 -0
- package/dist/document-viewer/DocumentViewerViewport.js +36 -0
- package/dist/document-viewer/ImagePage.js +39 -0
- package/dist/document-viewer/PdfCanvasPage.js +26 -0
- package/dist/document-viewer/PdfThumbnailRail.js +116 -0
- package/dist/document-viewer/PdfToolbar.js +61 -0
- package/dist/document-viewer/PdfWorkspace.js +42 -0
- package/dist/document-viewer/pdf-render-budget.js +7 -0
- package/dist/document-viewer/usePdfCanvas.js +69 -0
- package/dist/document-viewer/usePdfViewport.js +48 -0
- package/dist/document-viewer-v2/DocumentViewerV2.js +171 -0
- package/dist/document-viewer-v2/HeadlessPdfViewer.js +420 -0
- package/dist/document-viewer-v2/HeadlessSearch.js +66 -0
- package/dist/document-viewer-v2.js +13 -0
- package/dist/document-viewer.js +12 -0
- package/dist/pdfium-viewer.js +18 -0
- package/dist/styles.css +2 -0
- package/dist/types/Alert.d.ts +11 -0
- package/dist/types/AmountFormat.d.ts +15 -0
- package/dist/types/AsyncDirectoryPicker.d.ts +32 -0
- package/dist/types/AsyncSearchPicker.d.ts +26 -0
- package/dist/types/AutoComplete.d.ts +9 -0
- package/dist/types/Badge.d.ts +13 -0
- package/dist/types/Button.d.ts +36 -0
- package/dist/types/Cascader.d.ts +57 -0
- package/dist/types/ChineseAddressRegions.d.ts +4 -0
- package/dist/types/Combobox.d.ts +37 -0
- package/dist/types/ConfirmDialog.d.ts +20 -0
- package/dist/types/DataTable.d.ts +68 -0
- package/dist/types/DataTableHorizontalScrollbar.d.ts +8 -0
- package/dist/types/DataTableIcons.d.ts +19 -0
- package/dist/types/DataTableMergedRows.d.ts +11 -0
- package/dist/types/DataTableTheme.d.ts +4 -0
- package/dist/types/DateInput.d.ts +25 -0
- package/dist/types/DocumentRenderBudget.d.ts +9 -0
- package/dist/types/DocumentViewer.d.ts +11 -0
- package/dist/types/DocumentViewerV2.d.ts +10 -0
- package/dist/types/DropdownMenu.d.ts +73 -0
- package/dist/types/EmptyState.d.ts +9 -0
- package/dist/types/ExplainableButton.d.ts +7 -0
- package/dist/types/FileDropzone.d.ts +20 -0
- package/dist/types/FilePreparationDialog.d.ts +12 -0
- package/dist/types/FloatingControls.d.ts +39 -0
- package/dist/types/FormField.d.ts +35 -0
- package/dist/types/MetricCard.d.ts +17 -0
- package/dist/types/ModalShell.d.ts +33 -0
- package/dist/types/MultiSelect.d.ts +12 -0
- package/dist/types/NumericInput.d.ts +54 -0
- package/dist/types/OverlayContainer.d.ts +2 -0
- package/dist/types/PageHeader.d.ts +23 -0
- package/dist/types/Pagination.d.ts +14 -0
- package/dist/types/PdfiumViewer.d.ts +5 -0
- package/dist/types/PreparedFileDropzone.d.ts +7 -0
- package/dist/types/RecoverableAsyncState.d.ts +11 -0
- package/dist/types/RovingTabs.d.ts +21 -0
- package/dist/types/SectionCard.d.ts +18 -0
- package/dist/types/SegmentedControl.d.ts +26 -0
- package/dist/types/Select.d.ts +31 -0
- package/dist/types/Skeleton.d.ts +11 -0
- package/dist/types/SortableList.d.ts +17 -0
- package/dist/types/StructuredAddressInput.d.ts +57 -0
- package/dist/types/Toast.d.ts +22 -0
- package/dist/types/ToggleSwitch.d.ts +15 -0
- package/dist/types/TreeSelect.d.ts +58 -0
- package/dist/types/classNames.d.ts +1 -0
- package/dist/types/document-viewer/ContinuousPdfViewer.d.ts +16 -0
- package/dist/types/document-viewer/DocumentViewer.d.ts +31 -0
- package/dist/types/document-viewer/DocumentViewerViewport.d.ts +23 -0
- package/dist/types/document-viewer/ImagePage.d.ts +9 -0
- package/dist/types/document-viewer/PdfCanvasPage.d.ts +7 -0
- package/dist/types/document-viewer/PdfThumbnailRail.d.ts +12 -0
- package/dist/types/document-viewer/PdfToolbar.d.ts +13 -0
- package/dist/types/document-viewer/PdfWorkspace.d.ts +5 -0
- package/dist/types/document-viewer/pdf-render-budget.d.ts +2 -0
- package/dist/types/document-viewer/usePdfCanvas.d.ts +22 -0
- package/dist/types/document-viewer/usePdfViewport.d.ts +14 -0
- package/dist/types/document-viewer-v2/DocumentViewerV2.d.ts +50 -0
- package/dist/types/document-viewer-v2/HeadlessPdfViewer.d.ts +39 -0
- package/dist/types/document-viewer-v2/HeadlessSearch.d.ts +9 -0
- package/dist/types/index.d.ts +41 -0
- package/dist/types/useDebouncedValue.d.ts +2 -0
- package/dist/types/useFilePreparation.d.ts +28 -0
- package/dist/types/useModalFocusTrap.d.ts +3 -0
- package/dist/useDebouncedValue.js +16 -0
- package/dist/useFilePreparation.js +51 -0
- package/dist/useModalFocusTrap.js +71 -0
- package/docs/agent-guide.md +145 -0
- package/docs/api.md +220 -0
- package/docs/cascader.md +56 -0
- package/docs/component-strategy.md +94 -0
- package/docs/data-table.md +123 -0
- package/docs/dependencies.md +57 -0
- package/docs/document-viewer-v2.md +259 -0
- package/docs/document-viewer.md +28 -0
- package/docs/file-preparation.md +11 -0
- package/docs/maturity-migration.md +62 -0
- package/docs/modal-shell-migration.md +43 -0
- package/docs/mrt-poc.md +205 -0
- package/docs/release.md +32 -0
- package/docs/viewport-qa.md +99 -0
- package/licenses/rc-cascader-MIT.txt +21 -0
- package/package.json +163 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useEffect as e, useRef as t, useState as n } from "react";
|
|
2
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
3
|
+
//#region src/DataTableHorizontalScrollbar.tsx
|
|
4
|
+
function a({ children: a, enabled: o = !1, label: s = "表格横向滚动" }) {
|
|
5
|
+
let c = t(null), l = t(null), [u, d] = n(0);
|
|
6
|
+
return e(() => {
|
|
7
|
+
if (!o) return;
|
|
8
|
+
let e = c.current, t = l.current, n = e?.querySelector(".MuiTableContainer-root"), r = n?.querySelector("table");
|
|
9
|
+
if (!e || !t || !n || !r) return;
|
|
10
|
+
let i = !1, a = () => {
|
|
11
|
+
let e = n.scrollWidth > n.clientWidth + 1;
|
|
12
|
+
d(e ? n.scrollWidth : 0), e && (t.scrollLeft = n.scrollLeft);
|
|
13
|
+
}, s = () => {
|
|
14
|
+
i ||= (i = !0, n.scrollLeft = t.scrollLeft, !1);
|
|
15
|
+
}, u = () => {
|
|
16
|
+
i ||= (i = !0, t.scrollLeft = n.scrollLeft, !1);
|
|
17
|
+
};
|
|
18
|
+
a();
|
|
19
|
+
let f = typeof ResizeObserver > "u" ? null : new ResizeObserver(a);
|
|
20
|
+
return f?.observe(n), f?.observe(r), t.addEventListener("scroll", s, { passive: !0 }), n.addEventListener("scroll", u, { passive: !0 }), () => {
|
|
21
|
+
f?.disconnect(), t.removeEventListener("scroll", s), n.removeEventListener("scroll", u);
|
|
22
|
+
};
|
|
23
|
+
}, [o]), o ? /* @__PURE__ */ i("div", {
|
|
24
|
+
ref: c,
|
|
25
|
+
className: "ui-data-table-scroll-frame",
|
|
26
|
+
children: [a, /* @__PURE__ */ r("div", {
|
|
27
|
+
ref: l,
|
|
28
|
+
className: `ui-data-table-horizontal-scroll${u ? " is-visible" : ""}`,
|
|
29
|
+
role: "region",
|
|
30
|
+
"aria-label": s,
|
|
31
|
+
tabIndex: u ? 0 : -1,
|
|
32
|
+
"aria-hidden": !u,
|
|
33
|
+
children: /* @__PURE__ */ r("div", { style: { width: u } })
|
|
34
|
+
})]
|
|
35
|
+
}) : a;
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { a as DataTableHorizontalScrollbar };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ArrowDown as e, ArrowLeftRight as t, ChevronDown as n, ChevronRight as r, Columns3 as i, EllipsisVertical as a, EyeOff as o, Filter as s, FilterX as c, GripHorizontal as l, Pin as u, RotateCcw as d, Search as f, X as p } from "lucide-react";
|
|
2
|
+
import { forwardRef as m } from "react";
|
|
3
|
+
import { jsx as h } from "react/jsx-runtime";
|
|
4
|
+
import g from "@mui/material/SvgIcon";
|
|
5
|
+
//#region src/DataTableIcons.tsx
|
|
6
|
+
function _(e) {
|
|
7
|
+
return m((t, n) => /* @__PURE__ */ h(g, {
|
|
8
|
+
...t,
|
|
9
|
+
ref: n,
|
|
10
|
+
component: e,
|
|
11
|
+
inheritViewBox: !0,
|
|
12
|
+
sx: [{
|
|
13
|
+
fontSize: 18,
|
|
14
|
+
fill: "none"
|
|
15
|
+
}, ...Array.isArray(t.sx) ? t.sx : [t.sx ?? {}]]
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
var v = {
|
|
19
|
+
SearchIcon: _(f),
|
|
20
|
+
CloseIcon: _(p),
|
|
21
|
+
CancelIcon: _(p),
|
|
22
|
+
ArrowDownwardIcon: _(e),
|
|
23
|
+
ExpandMoreIcon: _(n),
|
|
24
|
+
ArrowRightIcon: _(r),
|
|
25
|
+
SyncAltIcon: _(t),
|
|
26
|
+
MoreVertIcon: _(a),
|
|
27
|
+
ViewColumnIcon: _(i),
|
|
28
|
+
FilterListIcon: _(s),
|
|
29
|
+
FilterAltIcon: _(s),
|
|
30
|
+
FilterListOffIcon: _(c),
|
|
31
|
+
PushPinIcon: _(u),
|
|
32
|
+
DragHandleIcon: _(l),
|
|
33
|
+
RestartAltIcon: _(d),
|
|
34
|
+
VisibilityOffIcon: _(o)
|
|
35
|
+
};
|
|
36
|
+
//#endregion
|
|
37
|
+
export { v as icons };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useRef as e } from "react";
|
|
2
|
+
import { Fragment as t, jsx as n } from "react/jsx-runtime";
|
|
3
|
+
import { MRT_TableBodyCell as r } from "material-react-table";
|
|
4
|
+
import i from "@mui/material/TableRow";
|
|
5
|
+
import a from "@mui/material/TableCell";
|
|
6
|
+
//#region src/DataTableMergedRows.tsx
|
|
7
|
+
function o({ row: a, table: o, index: s, getDetails: c, detailColumnIds: l, getDetailValue: u }) {
|
|
8
|
+
let d = e(null), f = a.getVisibleCells().some((e) => l.includes(e.column.id)), p = c(a.original), m = f && p.length ? p : [null];
|
|
9
|
+
return /* @__PURE__ */ n(t, { children: m.map((e, t) => /* @__PURE__ */ n(i, {
|
|
10
|
+
ref: t === 0 ? d : void 0,
|
|
11
|
+
"data-contract-id": a.id,
|
|
12
|
+
selected: a.getIsSelected(),
|
|
13
|
+
children: a.getVisibleCells().map((i, a) => {
|
|
14
|
+
let c = l.includes(i.column.id);
|
|
15
|
+
if (!c && t > 0) return null;
|
|
16
|
+
let f = c ? u(e, i.column.id) : null, p = c ? {
|
|
17
|
+
...i,
|
|
18
|
+
getValue: () => f,
|
|
19
|
+
renderValue: () => f
|
|
20
|
+
} : i;
|
|
21
|
+
return /* @__PURE__ */ n(r, {
|
|
22
|
+
cell: p,
|
|
23
|
+
table: o,
|
|
24
|
+
rowRef: d,
|
|
25
|
+
staticRowIndex: s,
|
|
26
|
+
staticColumnIndex: a,
|
|
27
|
+
rowSpan: c ? 1 : m.length
|
|
28
|
+
}, i.id);
|
|
29
|
+
})
|
|
30
|
+
}, t)) });
|
|
31
|
+
}
|
|
32
|
+
function s(e) {
|
|
33
|
+
let { table: r, emptyContent: s = "暂无匹配记录" } = e, c = r.getRowModel().rows;
|
|
34
|
+
return /* @__PURE__ */ n(t, { children: c.length ? c.map((t, r) => /* @__PURE__ */ n(o, {
|
|
35
|
+
...e,
|
|
36
|
+
row: t,
|
|
37
|
+
index: r
|
|
38
|
+
}, t.id)) : /* @__PURE__ */ n(i, { children: /* @__PURE__ */ n(a, {
|
|
39
|
+
colSpan: r.getVisibleLeafColumns().length,
|
|
40
|
+
align: "center",
|
|
41
|
+
children: s
|
|
42
|
+
}) }) });
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { s as DataTableMergedRows };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { useOverlayContainer as e } from "./OverlayContainer.js";
|
|
2
|
+
import { useMemo as t } from "react";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
import { ThemeProvider as r, createTheme as i } from "@mui/material/styles";
|
|
5
|
+
//#region src/DataTableTheme.tsx
|
|
6
|
+
var a = {
|
|
7
|
+
primary: "#5965ad",
|
|
8
|
+
text: "#202638",
|
|
9
|
+
muted: "#6e7891",
|
|
10
|
+
border: "#dce0ec",
|
|
11
|
+
canvas: "#f5f5fa",
|
|
12
|
+
surface: "#ffffff",
|
|
13
|
+
radius: "8px",
|
|
14
|
+
"control-height": "40px",
|
|
15
|
+
"touch-height": "44px",
|
|
16
|
+
"border-strong": "#b9c1d6",
|
|
17
|
+
focus: "#dfe3f5",
|
|
18
|
+
"primary-soft": "#eef0fa",
|
|
19
|
+
"primary-hover": "#465194",
|
|
20
|
+
"radius-large": "12px",
|
|
21
|
+
shadow: "0 8px 24px #20263820"
|
|
22
|
+
}, o = (e) => (typeof document > "u" ? "" : getComputedStyle(document.documentElement).getPropertyValue(`--ui-${e}`).trim()) || a[e] || "";
|
|
23
|
+
function s() {
|
|
24
|
+
return i({
|
|
25
|
+
palette: {
|
|
26
|
+
primary: { main: o("primary") },
|
|
27
|
+
text: {
|
|
28
|
+
primary: o("text"),
|
|
29
|
+
secondary: o("muted")
|
|
30
|
+
},
|
|
31
|
+
divider: o("border"),
|
|
32
|
+
background: {
|
|
33
|
+
default: o("canvas"),
|
|
34
|
+
paper: o("surface")
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
typography: {
|
|
38
|
+
fontFamily: "\"Segoe UI\", \"Microsoft YaHei\", sans-serif",
|
|
39
|
+
fontSize: 13,
|
|
40
|
+
button: {
|
|
41
|
+
textTransform: "none",
|
|
42
|
+
fontWeight: 700
|
|
43
|
+
},
|
|
44
|
+
body1: { fontSize: 13 },
|
|
45
|
+
body2: { fontSize: 13 }
|
|
46
|
+
},
|
|
47
|
+
shape: { borderRadius: 8 },
|
|
48
|
+
components: {
|
|
49
|
+
MuiButtonBase: { defaultProps: { disableRipple: !0 } },
|
|
50
|
+
MuiTableCell: { styleOverrides: {
|
|
51
|
+
root: {
|
|
52
|
+
borderColor: o("border"),
|
|
53
|
+
fontSize: 13
|
|
54
|
+
},
|
|
55
|
+
head: {
|
|
56
|
+
fontWeight: 700,
|
|
57
|
+
color: o("muted")
|
|
58
|
+
}
|
|
59
|
+
} },
|
|
60
|
+
MuiOutlinedInput: { styleOverrides: {
|
|
61
|
+
root: {
|
|
62
|
+
background: o("surface"),
|
|
63
|
+
borderRadius: o("radius"),
|
|
64
|
+
minHeight: o("control-height"),
|
|
65
|
+
fontSize: 13,
|
|
66
|
+
"& .MuiOutlinedInput-notchedOutline": { borderColor: o("border") },
|
|
67
|
+
"&:hover .MuiOutlinedInput-notchedOutline": { borderColor: o("border-strong") },
|
|
68
|
+
"&.Mui-focused": { boxShadow: `0 0 0 3px ${o("focus")}` },
|
|
69
|
+
"&.Mui-focused .MuiOutlinedInput-notchedOutline": {
|
|
70
|
+
borderWidth: 1,
|
|
71
|
+
borderColor: o("primary")
|
|
72
|
+
},
|
|
73
|
+
"@media(pointer:coarse)": { minHeight: o("touch-height") }
|
|
74
|
+
},
|
|
75
|
+
input: {
|
|
76
|
+
padding: "9px 10px",
|
|
77
|
+
minWidth: 0
|
|
78
|
+
}
|
|
79
|
+
} },
|
|
80
|
+
MuiIconButton: { styleOverrides: { root: {
|
|
81
|
+
borderRadius: o("radius"),
|
|
82
|
+
color: o("muted"),
|
|
83
|
+
"&:hover": {
|
|
84
|
+
color: o("primary"),
|
|
85
|
+
background: o("primary-soft")
|
|
86
|
+
},
|
|
87
|
+
"&.Mui-focusVisible": {
|
|
88
|
+
outline: `3px solid ${o("focus")}`,
|
|
89
|
+
outlineOffset: 2
|
|
90
|
+
},
|
|
91
|
+
"@media(pointer:coarse)": {
|
|
92
|
+
minWidth: 44,
|
|
93
|
+
minHeight: 44
|
|
94
|
+
}
|
|
95
|
+
} } },
|
|
96
|
+
MuiMenu: { styleOverrides: {
|
|
97
|
+
paper: {
|
|
98
|
+
border: `1px solid ${o("border")}`,
|
|
99
|
+
borderRadius: o("radius-large"),
|
|
100
|
+
boxShadow: o("shadow")
|
|
101
|
+
},
|
|
102
|
+
list: { padding: 5 }
|
|
103
|
+
} },
|
|
104
|
+
MuiMenuItem: { styleOverrides: { root: {
|
|
105
|
+
fontSize: 13,
|
|
106
|
+
borderRadius: 6,
|
|
107
|
+
minHeight: 36,
|
|
108
|
+
"&:hover,&.Mui-selected,&.Mui-focusVisible": {
|
|
109
|
+
color: o("primary-hover"),
|
|
110
|
+
background: o("primary-soft")
|
|
111
|
+
},
|
|
112
|
+
"@media(pointer:coarse)": { minHeight: 44 }
|
|
113
|
+
} } },
|
|
114
|
+
MuiButton: { styleOverrides: { root: {
|
|
115
|
+
fontSize: 12,
|
|
116
|
+
borderRadius: o("radius")
|
|
117
|
+
} } }
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function c({ children: a }) {
|
|
122
|
+
let o = e(), c = t(() => i(s(), { components: {
|
|
123
|
+
MuiPopover: { defaultProps: {
|
|
124
|
+
container: o,
|
|
125
|
+
disableEnforceFocus: !!o
|
|
126
|
+
} },
|
|
127
|
+
MuiPopper: { defaultProps: { container: o } }
|
|
128
|
+
} }), [o]);
|
|
129
|
+
return /* @__PURE__ */ n(r, {
|
|
130
|
+
theme: c,
|
|
131
|
+
children: a
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
//#endregion
|
|
135
|
+
export { c as DataTableTheme };
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { useOverlayContainer as e } from "./OverlayContainer.js";
|
|
2
|
+
import { CalendarDays as t, ChevronLeft as n, ChevronRight as r, X as ee } from "lucide-react";
|
|
3
|
+
import { forwardRef as i, useCallback as te, useEffect as a, useId as ne, useRef as o, useState as s } from "react";
|
|
4
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
5
|
+
import * as u from "@radix-ui/react-popover";
|
|
6
|
+
import { Button as d, Calendar as re, CalendarCell as ie, CalendarGrid as ae, CalendarGridBody as oe, CalendarGridHeader as se, CalendarHeaderCell as ce, Heading as le, I18nProvider as ue } from "react-aria-components";
|
|
7
|
+
import { CalendarDate as de, getLocalTimeZone as f, parseDate as p, today as m } from "@internationalized/date";
|
|
8
|
+
//#region src/DateInput.tsx
|
|
9
|
+
var h = "jc-business-ui-date-input-open", g = i(function({ value: i, onValueChange: p, inputRef: g, inputClassName: b, className: S = "", disabled: C, readOnly: w, required: T, inputMode: fe = "numeric", autoComplete: pe = "off", onFocus: me, onBlur: he, onKeyDown: ge, min: E, max: D, minDate: _e, maxDate: ve, isDateUnavailable: O, onValidationError: ye, ...k }, A) {
|
|
10
|
+
let j = `ui-date-calendar-${ne().replaceAll(":", "")}`, be = e(), M = o(null), N = o(!1), P = o(!1), F = o(!1), [I, L] = s(!1), [R, z] = s(() => _(i)), [B, V] = s(""), H = v(i), U = v(_e ?? (E === void 0 ? "" : String(E))), W = v(ve ?? (D === void 0 ? "" : String(D))), [G, K] = s(() => H ?? m(f())), q = !!(C || w), xe = te((e) => {
|
|
11
|
+
M.current = e, x(g, e), x(A, e);
|
|
12
|
+
}, [g, A]);
|
|
13
|
+
a(() => {
|
|
14
|
+
z(_(i)), V(""), M.current?.setCustomValidity("");
|
|
15
|
+
}, [i]), a(() => {
|
|
16
|
+
q && L(!1);
|
|
17
|
+
}, [q]), a(() => {
|
|
18
|
+
let e = (e) => {
|
|
19
|
+
e.detail !== j && L(!1);
|
|
20
|
+
};
|
|
21
|
+
return document.addEventListener(h, e), () => document.removeEventListener(h, e);
|
|
22
|
+
}, [j]);
|
|
23
|
+
function J(e) {
|
|
24
|
+
if (!(e && q)) {
|
|
25
|
+
if (e && !I) {
|
|
26
|
+
document.dispatchEvent(new CustomEvent(h, { detail: j }));
|
|
27
|
+
let e = H ?? m(f());
|
|
28
|
+
U && e.compare(U) < 0 && (e = U), W && e.compare(W) > 0 && (e = W), K(e);
|
|
29
|
+
}
|
|
30
|
+
L(e);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function Y(e) {
|
|
34
|
+
if (!e) return T ? "请选择日期" : "";
|
|
35
|
+
let t = v(e);
|
|
36
|
+
return t ? U && t.compare(U) < 0 ? `日期不能早于 ${U}` : W && t.compare(W) > 0 ? `日期不能晚于 ${W}` : O?.(t.toString()) ? "该日期不可选择" : "" : "请输入有效日期(YYYY/MM/DD)";
|
|
37
|
+
}
|
|
38
|
+
function X(e) {
|
|
39
|
+
V(e), M.current?.setCustomValidity(e), ye?.(e || null);
|
|
40
|
+
}
|
|
41
|
+
function Z() {
|
|
42
|
+
if (q) return;
|
|
43
|
+
let e = R.trim() ? y(R) : "", t = e === null ? "请输入有效日期(YYYY/MM/DD)" : Y(e);
|
|
44
|
+
X(t), !t && e !== null && (z(_(e)), e !== i && p(e));
|
|
45
|
+
}
|
|
46
|
+
function Q(e) {
|
|
47
|
+
if (q) return;
|
|
48
|
+
let t = Y(e);
|
|
49
|
+
X(t), !t && (F.current = !0, p(e), z(_(e)), L(!1));
|
|
50
|
+
}
|
|
51
|
+
let $ = m(f()).toString();
|
|
52
|
+
return /* @__PURE__ */ l(u.Root, {
|
|
53
|
+
open: I && !q,
|
|
54
|
+
onOpenChange: J,
|
|
55
|
+
children: [
|
|
56
|
+
/* @__PURE__ */ c(u.Anchor, {
|
|
57
|
+
asChild: !0,
|
|
58
|
+
children: /* @__PURE__ */ l("span", {
|
|
59
|
+
className: `ui-date-input${I ? " open" : ""}${S ? ` ${S}` : ""}`,
|
|
60
|
+
children: [/* @__PURE__ */ c("input", {
|
|
61
|
+
...k,
|
|
62
|
+
ref: xe,
|
|
63
|
+
className: b,
|
|
64
|
+
type: "text",
|
|
65
|
+
inputMode: fe,
|
|
66
|
+
autoComplete: pe,
|
|
67
|
+
disabled: C,
|
|
68
|
+
readOnly: w,
|
|
69
|
+
required: T,
|
|
70
|
+
value: R,
|
|
71
|
+
placeholder: k.placeholder ?? "YYYY/MM/DD",
|
|
72
|
+
"aria-haspopup": "dialog",
|
|
73
|
+
"aria-expanded": I && !q,
|
|
74
|
+
"aria-controls": I ? j : void 0,
|
|
75
|
+
"aria-invalid": B ? !0 : k["aria-invalid"],
|
|
76
|
+
"aria-describedby": [k["aria-describedby"], B ? `${j}-error` : ""].filter(Boolean).join(" ") || void 0,
|
|
77
|
+
onFocus: (e) => {
|
|
78
|
+
me?.(e), !e.defaultPrevented && !N.current && J(!0);
|
|
79
|
+
},
|
|
80
|
+
onChange: (e) => {
|
|
81
|
+
z(e.target.value), B && X("");
|
|
82
|
+
},
|
|
83
|
+
onBlur: (e) => {
|
|
84
|
+
Z(), he?.(e);
|
|
85
|
+
},
|
|
86
|
+
onKeyDown: (e) => {
|
|
87
|
+
ge?.(e), !(e.defaultPrevented || e.nativeEvent.isComposing || e.keyCode === 229 || q) && (e.key === "ArrowDown" && (e.preventDefault(), P.current = !0, J(!0), I && document.getElementById(j)?.querySelector("[role=\"gridcell\"] [tabindex=\"0\"]")?.focus()), e.key === "Enter" && (e.preventDefault(), Z()));
|
|
88
|
+
}
|
|
89
|
+
}), /* @__PURE__ */ c("button", {
|
|
90
|
+
type: "button",
|
|
91
|
+
className: "ui-date-trigger",
|
|
92
|
+
disabled: q,
|
|
93
|
+
tabIndex: -1,
|
|
94
|
+
"aria-label": "打开日期选择器",
|
|
95
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
96
|
+
onClick: () => {
|
|
97
|
+
P.current = !0, J(!I);
|
|
98
|
+
},
|
|
99
|
+
children: /* @__PURE__ */ c(t, {
|
|
100
|
+
size: 17,
|
|
101
|
+
"aria-hidden": "true"
|
|
102
|
+
})
|
|
103
|
+
})]
|
|
104
|
+
})
|
|
105
|
+
}),
|
|
106
|
+
B && /* @__PURE__ */ c("span", {
|
|
107
|
+
id: `${j}-error`,
|
|
108
|
+
className: "ui-form-error",
|
|
109
|
+
role: "alert",
|
|
110
|
+
children: B
|
|
111
|
+
}),
|
|
112
|
+
/* @__PURE__ */ c(u.Portal, {
|
|
113
|
+
container: be,
|
|
114
|
+
children: /* @__PURE__ */ l(u.Content, {
|
|
115
|
+
id: j,
|
|
116
|
+
className: "ui-date-calendar",
|
|
117
|
+
"aria-label": "选择日期",
|
|
118
|
+
sideOffset: 8,
|
|
119
|
+
collisionPadding: 12,
|
|
120
|
+
onOpenAutoFocus: (e) => {
|
|
121
|
+
e.preventDefault(), P.current && document.getElementById(j)?.querySelector("[role=\"gridcell\"] [tabindex=\"0\"]")?.focus(), P.current = !1;
|
|
122
|
+
},
|
|
123
|
+
onCloseAutoFocus: (e) => {
|
|
124
|
+
e.preventDefault(), F.current &&= (N.current = !0, M.current?.focus(), N.current = !1, !1);
|
|
125
|
+
},
|
|
126
|
+
onEscapeKeyDown: () => {
|
|
127
|
+
F.current = !0;
|
|
128
|
+
},
|
|
129
|
+
onInteractOutside: (e) => {
|
|
130
|
+
M.current?.parentElement?.contains(e.target) && e.preventDefault();
|
|
131
|
+
},
|
|
132
|
+
children: [/* @__PURE__ */ c(ue, {
|
|
133
|
+
locale: "zh-CN",
|
|
134
|
+
children: /* @__PURE__ */ l(re, {
|
|
135
|
+
"aria-label": "选择日期",
|
|
136
|
+
value: H,
|
|
137
|
+
onChange: (e) => Q(e.toString()),
|
|
138
|
+
minValue: U ?? void 0,
|
|
139
|
+
maxValue: W ?? void 0,
|
|
140
|
+
isDateUnavailable: (e) => O?.(e.toString()) ?? !1,
|
|
141
|
+
focusedValue: G,
|
|
142
|
+
onFocusChange: (e) => K(new de(e.year, e.month, e.day)),
|
|
143
|
+
children: [
|
|
144
|
+
/* @__PURE__ */ l("header", { children: [
|
|
145
|
+
/* @__PURE__ */ c(d, {
|
|
146
|
+
slot: "previous",
|
|
147
|
+
"aria-label": "上个月",
|
|
148
|
+
children: /* @__PURE__ */ c(n, { size: 18 })
|
|
149
|
+
}),
|
|
150
|
+
/* @__PURE__ */ c(le, {}),
|
|
151
|
+
/* @__PURE__ */ c(d, {
|
|
152
|
+
slot: "next",
|
|
153
|
+
"aria-label": "下个月",
|
|
154
|
+
children: /* @__PURE__ */ c(r, { size: 18 })
|
|
155
|
+
})
|
|
156
|
+
] }),
|
|
157
|
+
/* @__PURE__ */ l("label", {
|
|
158
|
+
className: "ui-date-month-jump",
|
|
159
|
+
children: ["跳转年月", /* @__PURE__ */ c("input", {
|
|
160
|
+
type: "month",
|
|
161
|
+
"aria-label": "跳转年月",
|
|
162
|
+
value: `${G.year.toString().padStart(4, "0")}-${String(G.month).padStart(2, "0")}`,
|
|
163
|
+
min: U?.toString().slice(0, 7),
|
|
164
|
+
max: W?.toString().slice(0, 7),
|
|
165
|
+
onChange: (e) => {
|
|
166
|
+
let t = v(`${e.target.value}-01`);
|
|
167
|
+
t && K(U && t.compare(U) < 0 ? U : W && t.compare(W) > 0 ? W : t);
|
|
168
|
+
}
|
|
169
|
+
})]
|
|
170
|
+
}),
|
|
171
|
+
/* @__PURE__ */ l(ae, {
|
|
172
|
+
className: "ui-aria-calendar-grid",
|
|
173
|
+
children: [/* @__PURE__ */ c(se, { children: (e) => /* @__PURE__ */ c(ce, { children: e }) }), /* @__PURE__ */ c(oe, { children: (e) => /* @__PURE__ */ c(ie, {
|
|
174
|
+
date: e,
|
|
175
|
+
"data-date": e.toString()
|
|
176
|
+
}) })]
|
|
177
|
+
})
|
|
178
|
+
]
|
|
179
|
+
})
|
|
180
|
+
}), /* @__PURE__ */ l("footer", { children: [/* @__PURE__ */ l("button", {
|
|
181
|
+
type: "button",
|
|
182
|
+
className: "ui-date-clear",
|
|
183
|
+
disabled: !i || T,
|
|
184
|
+
onClick: () => Q(""),
|
|
185
|
+
children: [/* @__PURE__ */ c(ee, { size: 14 }), "清除"]
|
|
186
|
+
}), /* @__PURE__ */ c("button", {
|
|
187
|
+
type: "button",
|
|
188
|
+
className: "ui-date-today",
|
|
189
|
+
disabled: !!Y($),
|
|
190
|
+
onClick: () => Q($),
|
|
191
|
+
children: "今天"
|
|
192
|
+
})] })]
|
|
193
|
+
})
|
|
194
|
+
})
|
|
195
|
+
]
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
function _(e) {
|
|
199
|
+
return /^\d{4}-\d{2}-\d{2}$/.test(e) ? e.replaceAll("-", "/") : e;
|
|
200
|
+
}
|
|
201
|
+
function v(e) {
|
|
202
|
+
let t = y(e);
|
|
203
|
+
return t ? p(t) : null;
|
|
204
|
+
}
|
|
205
|
+
function y(e) {
|
|
206
|
+
let t = e.trim().match(/^(\d{4})[/.\-](\d{1,2})[/.\-](\d{1,2})$/);
|
|
207
|
+
if (!t || Number(t[1]) < 1) return null;
|
|
208
|
+
let n = `${t[1]}-${t[2].padStart(2, "0")}-${t[3].padStart(2, "0")}`;
|
|
209
|
+
try {
|
|
210
|
+
return p(n).toString();
|
|
211
|
+
} catch {
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function b(e, t) {
|
|
216
|
+
let n = new Date(e, t, 1), r = new Date(e, t, 1 - n.getDay());
|
|
217
|
+
return Array.from({ length: 42 }, (e, t) => ({ date: new Date(r.getFullYear(), r.getMonth(), r.getDate() + t) }));
|
|
218
|
+
}
|
|
219
|
+
function x(e, t) {
|
|
220
|
+
typeof e == "function" ? e(t) : e && (e.current = t);
|
|
221
|
+
}
|
|
222
|
+
//#endregion
|
|
223
|
+
export { g as DateInput, b as calendarDays, y as parseDate };
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { buttonClassName as e } from "./Button.js";
|
|
2
|
+
import { useOverlayContainer as t } from "./OverlayContainer.js";
|
|
3
|
+
import { Check as n, ChevronRight as r } from "lucide-react";
|
|
4
|
+
import { createElement as i, useId as a } from "react";
|
|
5
|
+
import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
6
|
+
import { Button as l, Header as u, Menu as d, MenuItem as f, MenuSection as p, MenuTrigger as m, Popover as h, Separator as g, SubmenuTrigger as _ } from "react-aria-components";
|
|
7
|
+
//#region src/DropdownMenu.tsx
|
|
8
|
+
function v({ trigger: n, triggerLabel: r, triggerVariant: i = "secondary", triggerSize: o = "default", items: u, menuLabel: f, triggerRef: p, triggerProps: g, menuRef: _, menuProps: v, placement: b = "bottom start", portalContainer: S, disabled: C = !1, className: w = "", selectionMode: T = "none", selectedKeys: E, defaultSelectedKeys: D, onSelectionChange: O }) {
|
|
9
|
+
let k = v?.["aria-label"] ?? f, A = t(S), j = a(), M = T === "none" ? { selectionMode: T } : {
|
|
10
|
+
selectionMode: T,
|
|
11
|
+
selectedKeys: E,
|
|
12
|
+
defaultSelectedKeys: D,
|
|
13
|
+
onSelectionChange: O ? (e) => O(x(e)) : void 0
|
|
14
|
+
};
|
|
15
|
+
return /* @__PURE__ */ c(m, { children: [/* @__PURE__ */ s(l, {
|
|
16
|
+
...g,
|
|
17
|
+
ref: p,
|
|
18
|
+
className: e({
|
|
19
|
+
variant: i,
|
|
20
|
+
size: o
|
|
21
|
+
}),
|
|
22
|
+
"aria-label": g?.["aria-label"] ?? r,
|
|
23
|
+
isDisabled: C,
|
|
24
|
+
children: n
|
|
25
|
+
}), /* @__PURE__ */ c(h, {
|
|
26
|
+
className: `ui-dropdown-popover ${w}`.trim(),
|
|
27
|
+
"data-ui-aria-overlay": "",
|
|
28
|
+
placement: b,
|
|
29
|
+
UNSTABLE_portalContainer: A,
|
|
30
|
+
children: [k === void 0 ? null : /* @__PURE__ */ s("span", {
|
|
31
|
+
id: j,
|
|
32
|
+
className: "ui-visually-hidden",
|
|
33
|
+
children: k
|
|
34
|
+
}), /* @__PURE__ */ s(d, {
|
|
35
|
+
...v,
|
|
36
|
+
...M,
|
|
37
|
+
ref: _,
|
|
38
|
+
className: "ui-dropdown-menu",
|
|
39
|
+
"aria-label": k === void 0 ? r ?? "操作菜单" : void 0,
|
|
40
|
+
"aria-labelledby": k === void 0 ? v?.["aria-labelledby"] : j,
|
|
41
|
+
children: y(u, M, A)
|
|
42
|
+
})]
|
|
43
|
+
})] });
|
|
44
|
+
}
|
|
45
|
+
function y(e, t, n) {
|
|
46
|
+
return e.map((e) => e.type === "separator" ? /* @__PURE__ */ s(g, { className: "ui-dropdown-separator" }, e.id) : e.type === "group" ? /* @__PURE__ */ c(p, {
|
|
47
|
+
className: "ui-dropdown-group",
|
|
48
|
+
children: [e.label === void 0 ? null : /* @__PURE__ */ s(u, {
|
|
49
|
+
className: "ui-dropdown-header",
|
|
50
|
+
children: e.label
|
|
51
|
+
}), y(e.items, t, n)]
|
|
52
|
+
}, e.id) : e.type === "submenu" ? /* @__PURE__ */ c(_, { children: [/* @__PURE__ */ s(f, {
|
|
53
|
+
...e.itemProps,
|
|
54
|
+
ref: S(e.current, e.itemRef),
|
|
55
|
+
id: e.id,
|
|
56
|
+
textValue: e.textValue,
|
|
57
|
+
isDisabled: e.disabled,
|
|
58
|
+
"aria-current": e.current,
|
|
59
|
+
className: "ui-dropdown-item",
|
|
60
|
+
children: (t) => /* @__PURE__ */ s(b, {
|
|
61
|
+
item: e,
|
|
62
|
+
selected: t.isSelected,
|
|
63
|
+
fallbackEnd: /* @__PURE__ */ s(r, {
|
|
64
|
+
size: 15,
|
|
65
|
+
"aria-hidden": "true"
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
}), /* @__PURE__ */ s(h, {
|
|
69
|
+
className: "ui-dropdown-popover",
|
|
70
|
+
"data-ui-aria-overlay": "",
|
|
71
|
+
placement: "right top",
|
|
72
|
+
UNSTABLE_portalContainer: n,
|
|
73
|
+
children: /* @__PURE__ */ s(d, {
|
|
74
|
+
...t,
|
|
75
|
+
className: "ui-dropdown-menu",
|
|
76
|
+
"aria-label": e.textValue,
|
|
77
|
+
children: y(e.items, t, n)
|
|
78
|
+
})
|
|
79
|
+
})] }, e.id) : /* @__PURE__ */ i(f, {
|
|
80
|
+
...e.itemProps,
|
|
81
|
+
key: e.id,
|
|
82
|
+
ref: S(e.current, e.itemRef),
|
|
83
|
+
id: e.id,
|
|
84
|
+
textValue: e.textValue,
|
|
85
|
+
isDisabled: e.disabled,
|
|
86
|
+
"aria-current": e.current,
|
|
87
|
+
onAction: e.onAction,
|
|
88
|
+
className: `ui-dropdown-item${e.dangerous ? " dangerous" : ""}`
|
|
89
|
+
}, (t) => /* @__PURE__ */ s(b, {
|
|
90
|
+
item: e,
|
|
91
|
+
selected: t.isSelected
|
|
92
|
+
})));
|
|
93
|
+
}
|
|
94
|
+
function b({ item: e, selected: t, fallbackEnd: r }) {
|
|
95
|
+
let i = e.selectedIcon ?? /* @__PURE__ */ s(n, {
|
|
96
|
+
size: 15,
|
|
97
|
+
"aria-hidden": "true"
|
|
98
|
+
});
|
|
99
|
+
return /* @__PURE__ */ c(o, { children: [
|
|
100
|
+
e.startIcon === void 0 ? null : /* @__PURE__ */ s("span", {
|
|
101
|
+
className: "ui-dropdown-item-icon",
|
|
102
|
+
"aria-hidden": "true",
|
|
103
|
+
children: e.startIcon
|
|
104
|
+
}),
|
|
105
|
+
/* @__PURE__ */ s("span", {
|
|
106
|
+
className: "ui-dropdown-item-label",
|
|
107
|
+
children: e.label
|
|
108
|
+
}),
|
|
109
|
+
e.endSlot === void 0 ? null : /* @__PURE__ */ s("span", {
|
|
110
|
+
className: "ui-dropdown-item-status",
|
|
111
|
+
children: e.endSlot
|
|
112
|
+
}),
|
|
113
|
+
t ? /* @__PURE__ */ s("span", {
|
|
114
|
+
className: "ui-dropdown-item-selected",
|
|
115
|
+
"aria-hidden": "true",
|
|
116
|
+
children: i
|
|
117
|
+
}) : r
|
|
118
|
+
] });
|
|
119
|
+
}
|
|
120
|
+
function x(e) {
|
|
121
|
+
return e === "all" ? e : new Set([...e].map(String));
|
|
122
|
+
}
|
|
123
|
+
function S(e, t) {
|
|
124
|
+
return (n) => {
|
|
125
|
+
n && (e === void 0 ? n.removeAttribute("aria-current") : n.setAttribute("aria-current", String(e))), typeof t == "function" ? t(n) : t && (t.current = n);
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
var C = v;
|
|
129
|
+
//#endregion
|
|
130
|
+
export { v as DropdownMenu, C as Menu };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Inbox as e } from "lucide-react";
|
|
2
|
+
import { jsx as t, jsxs as n } from "react/jsx-runtime";
|
|
3
|
+
//#region src/EmptyState.tsx
|
|
4
|
+
function r({ icon: r, title: i, description: a, action: o, compact: s = !1, className: c = "", ...l }) {
|
|
5
|
+
return /* @__PURE__ */ n("div", {
|
|
6
|
+
...l,
|
|
7
|
+
className: `ui-empty-state${s ? " compact" : ""} ${c}`.trim(),
|
|
8
|
+
children: [
|
|
9
|
+
/* @__PURE__ */ t("div", {
|
|
10
|
+
className: "ui-empty-icon",
|
|
11
|
+
"aria-hidden": "true",
|
|
12
|
+
children: r ?? /* @__PURE__ */ t(e, { size: 24 })
|
|
13
|
+
}),
|
|
14
|
+
/* @__PURE__ */ t("strong", { children: i }),
|
|
15
|
+
a === void 0 ? null : /* @__PURE__ */ t("div", {
|
|
16
|
+
className: "ui-empty-description",
|
|
17
|
+
children: a
|
|
18
|
+
}),
|
|
19
|
+
o === void 0 ? null : /* @__PURE__ */ t("div", {
|
|
20
|
+
className: "ui-empty-action",
|
|
21
|
+
children: o
|
|
22
|
+
})
|
|
23
|
+
]
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { r as EmptyState };
|