@jc-times/business-ui 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/Alert.js +5 -1
  3. package/dist/Button.js +1 -1
  4. package/dist/Cascader.js +19 -19
  5. package/dist/Combobox.js +38 -38
  6. package/dist/DataTableIcons.js +25 -25
  7. package/dist/DateInput.js +67 -67
  8. package/dist/DropdownMenu.js +35 -35
  9. package/dist/EmptyState.js +8 -8
  10. package/dist/ExplainableButton.js +11 -11
  11. package/dist/FloatingControls.js +31 -31
  12. package/dist/ModalShell.js +32 -32
  13. package/dist/MultiSelect.js +37 -37
  14. package/dist/Pagination.js +27 -27
  15. package/dist/RecoverableAsyncState.js +8 -8
  16. package/dist/Select.js +17 -17
  17. package/dist/SortableList.js +18 -18
  18. package/dist/Toast.js +30 -30
  19. package/dist/TreeSelect.js +107 -107
  20. package/dist/data-table.js +71 -71
  21. package/dist/document-viewer/PdfToolbar.js +12 -12
  22. package/dist/document-viewer/PdfWorkspace.js +15 -15
  23. package/dist/document-viewer-v2/HeadlessPdfViewer.js +6 -6
  24. package/dist/vendor/embedpdf-zoom-react.js +3 -186
  25. package/dist/vendor/embedpdf-zoom-react10.js +6 -0
  26. package/dist/vendor/embedpdf-zoom-react11.js +30 -0
  27. package/dist/vendor/embedpdf-zoom-react12.js +16 -0
  28. package/dist/vendor/embedpdf-zoom-react13.js +15 -0
  29. package/dist/vendor/embedpdf-zoom-react14.js +33 -0
  30. package/dist/vendor/embedpdf-zoom-react15.js +20 -0
  31. package/dist/vendor/embedpdf-zoom-react16.js +26 -0
  32. package/dist/vendor/embedpdf-zoom-react17.js +25 -0
  33. package/dist/vendor/embedpdf-zoom-react18.js +17 -0
  34. package/dist/vendor/embedpdf-zoom-react19.js +187 -0
  35. package/dist/vendor/embedpdf-zoom-react2.js +13 -0
  36. package/dist/vendor/embedpdf-zoom-react3.js +14 -0
  37. package/dist/vendor/embedpdf-zoom-react4.js +8 -0
  38. package/dist/vendor/embedpdf-zoom-react5.js +4 -0
  39. package/dist/vendor/embedpdf-zoom-react6.js +14 -0
  40. package/dist/vendor/embedpdf-zoom-react7.js +40 -0
  41. package/dist/vendor/embedpdf-zoom-react8.js +17 -0
  42. package/dist/vendor/embedpdf-zoom-react9.js +7 -0
  43. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.3.1
2
+
3
+ - 修复 `form-controls` 中图标从 `lucide-react` 根入口导入导致消费者打入完整图标集的问题。
4
+
1
5
  # 0.3.0
2
6
 
3
7
  - 新增 `@jc-times/business-ui/form-controls` 轻量入口,提供 Alert、Button、LinkButton、FormField、TextInput、TextArea、SelectInput 和 Checkbox,不引入目录、日期、表格或文档查看器依赖图。
package/dist/Alert.js CHANGED
@@ -1,4 +1,8 @@
1
- import { AlertCircle as e, CheckCircle2 as t, Info as n, TriangleAlert as r, X as i } from "lucide-react";
1
+ import e from "./vendor/embedpdf-zoom-react14.js";
2
+ import t from "./vendor/embedpdf-zoom-react15.js";
3
+ import n from "./vendor/embedpdf-zoom-react16.js";
4
+ import r from "./vendor/embedpdf-zoom-react17.js";
5
+ import i from "./vendor/embedpdf-zoom-react18.js";
2
6
  import { jsx as a, jsxs as o } from "react/jsx-runtime";
3
7
  //#region src/Alert.tsx
4
8
  var s = {
package/dist/Button.js CHANGED
@@ -1,4 +1,4 @@
1
- import { LoaderCircle as e } from "lucide-react";
1
+ import e from "./vendor/embedpdf-zoom-react13.js";
2
2
  import { forwardRef as t } from "react";
3
3
  import { jsx as n, jsxs as r } from "react/jsx-runtime";
4
4
  //#region src/Button.tsx
package/dist/Cascader.js CHANGED
@@ -1,19 +1,19 @@
1
1
  import { useOverlayContainer as e } from "./OverlayContainer.js";
2
2
  import { FormField as t } from "./FormField.js";
3
- import { ChevronDown as n, ChevronRight as r, LoaderCircle as i, X as a } from "lucide-react";
4
- import { useCallback as o, useEffect as s, useId as c, useRef as l, useState as u } from "react";
5
- import { jsx as d, jsxs as f } from "react/jsx-runtime";
3
+ import { useCallback as n, useEffect as r, useId as i, useRef as a, useState as o } from "react";
4
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
5
+ import { ChevronDown as l, ChevronRight as u, LoaderCircle as d, X as f } from "lucide-react";
6
6
  import p from "@rc-component/cascader";
7
7
  //#region src/Cascader.tsx
8
8
  function m(m) {
9
- let g = c(), [_, v] = u(!1);
10
- s(() => {
9
+ let g = i(), [_, v] = o(!1);
10
+ r(() => {
11
11
  m.disabled && v(!1);
12
12
  }, [m.disabled]);
13
- let y = !m.disabled && (m.open ?? _), b = m.id ?? m.inputProps?.id ?? g, x = e(), { inputProps: S, inputRef: C, label: w, helpText: T, error: E } = m, D = l(null), O = o((e) => {
13
+ let y = !m.disabled && (m.open ?? _), b = m.id ?? m.inputProps?.id ?? g, x = e(), { inputProps: S, inputRef: C, label: w, helpText: T, error: E } = m, D = a(null), O = n((e) => {
14
14
  D.current = e, typeof C == "function" ? C(e) : C && (C.current = e);
15
15
  }, [C]);
16
- s(() => {
16
+ r(() => {
17
17
  D.current?.setCustomValidity(m.required && !m.value.length ? "请选择一个选项" : "");
18
18
  }, [m.required, m.value.length]);
19
19
  let k = [
@@ -37,12 +37,12 @@ function m(m) {
37
37
  placeholder: m.placeholder ?? "请选择或搜索",
38
38
  notFoundContent: m.emptyText ?? "没有匹配的选项",
39
39
  allowClear: m.allowClear !== !1 && {
40
- clearIcon: /* @__PURE__ */ d(a, { size: 14 }),
40
+ clearIcon: /* @__PURE__ */ s(f, { size: 14 }),
41
41
  label: m.clearLabel ?? "清除选择"
42
42
  },
43
- suffix: /* @__PURE__ */ d(n, { size: 16 }),
44
- expandIcon: /* @__PURE__ */ d(r, { size: 14 }),
45
- loadingIcon: /* @__PURE__ */ d(i, { size: 14 }),
43
+ suffix: /* @__PURE__ */ s(l, { size: 16 }),
44
+ expandIcon: /* @__PURE__ */ s(u, { size: 14 }),
45
+ loadingIcon: /* @__PURE__ */ s(d, { size: 14 }),
46
46
  changeOnSelect: m.changeOnSelect,
47
47
  loadData: m.loadData,
48
48
  showSearch: m.searchable ?? !m.loadData ? {
@@ -61,7 +61,7 @@ function m(m) {
61
61
  shiftX: !0
62
62
  }
63
63
  },
64
- components: { input: /* @__PURE__ */ d("input", {
64
+ components: { input: /* @__PURE__ */ s("input", {
65
65
  ...S,
66
66
  ref: O,
67
67
  id: b,
@@ -71,9 +71,9 @@ function m(m) {
71
71
  "aria-invalid": E ? !0 : S?.["aria-invalid"],
72
72
  "aria-describedby": k
73
73
  }) },
74
- tagRender: ({ label: e, closable: t, onClose: n }) => /* @__PURE__ */ f("span", {
74
+ tagRender: ({ label: e, closable: t, onClose: n }) => /* @__PURE__ */ c("span", {
75
75
  className: "ui-cascader-tag",
76
- children: [/* @__PURE__ */ d("span", { children: e }), t && /* @__PURE__ */ d("button", {
76
+ children: [/* @__PURE__ */ s("span", { children: e }), t && /* @__PURE__ */ s("button", {
77
77
  type: "button",
78
78
  "aria-label": `移除 ${String(e)}`,
79
79
  onMouseDown: (e) => {
@@ -82,27 +82,27 @@ function m(m) {
82
82
  onClick: (e) => {
83
83
  e.stopPropagation(), n();
84
84
  },
85
- children: /* @__PURE__ */ d(a, { size: 12 })
85
+ children: /* @__PURE__ */ s(f, { size: 12 })
86
86
  })]
87
87
  })
88
88
  };
89
- return /* @__PURE__ */ f(t, {
89
+ return /* @__PURE__ */ c(t, {
90
90
  controlId: b,
91
91
  label: w,
92
92
  helpText: T,
93
93
  error: E,
94
94
  required: m.required,
95
- children: [y && /* @__PURE__ */ d("span", {
95
+ children: [y && /* @__PURE__ */ s("span", {
96
96
  hidden: !0,
97
97
  "data-ui-aria-overlay": ""
98
- }), m.multiple ? /* @__PURE__ */ d(p, {
98
+ }), m.multiple ? /* @__PURE__ */ s(p, {
99
99
  ...A,
100
100
  checkable: !0,
101
101
  checkStrictly: m.checkStrictly ?? !0,
102
102
  maxTagCount: m.maxTagCount ?? 3,
103
103
  value: m.value,
104
104
  onChange: (e, t) => m.onValueChange(e ?? [], t ?? [])
105
- }) : /* @__PURE__ */ d(p, {
105
+ }) : /* @__PURE__ */ s(p, {
106
106
  ...A,
107
107
  value: m.value,
108
108
  onChange: (e, t) => m.onValueChange(e ?? [], t ?? [])
package/dist/Combobox.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { useOverlayContainer as e } from "./OverlayContainer.js";
2
- import { Check as t, ChevronDown as n, LoaderCircle as r } from "lucide-react";
3
- import { useContext as i, useEffect as a, useId as o, useMemo as s, useRef as c } from "react";
4
- import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
2
+ import { useContext as t, useEffect as n, useId as r, useMemo as i, useRef as a } from "react";
3
+ import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
4
+ import { Check as l, ChevronDown as u, LoaderCircle as d } from "lucide-react";
5
5
  import { Button as f, Collection as p, ComboBox as m, ComboBoxStateContext as h, Header as g, Input as _, Label as v, ListBox as y, ListBoxItem as b, ListBoxSection as x, Popover as S, Text as C } from "react-aria-components";
6
6
  import { ListLayout as w, Virtualizer as T } from "react-aria-components/Virtualizer";
7
7
  //#region src/Combobox.tsx
@@ -10,8 +10,8 @@ var E = {
10
10
  gap: 2,
11
11
  padding: 4
12
12
  };
13
- function D({ items: i, label: a, placeholder: c = "搜索或选择", inputValue: h, defaultInputValue: D, selectedKey: k, defaultSelectedKey: A, onInputChange: j, onSelectionChange: M, loading: N = !1, disabled: P = !1, required: F = !1, allowsCustomValue: I = !1, emptyText: L = "没有匹配项", helpText: R, error: z, virtualized: B = i.length > 100, className: V = "", inputRef: H, inputProps: U, placement: W = "bottom start", portalContainer: G }) {
14
- let K = `ui-combobox-${o().replaceAll(":", "")}`, q = e(G), J = s(() => Array.from(i), [i]), Y = s(() => {
13
+ function D({ items: t, label: n, placeholder: a = "搜索或选择", inputValue: h, defaultInputValue: D, selectedKey: k, defaultSelectedKey: A, onInputChange: j, onSelectionChange: M, loading: N = !1, disabled: P = !1, required: F = !1, allowsCustomValue: I = !1, emptyText: L = "没有匹配项", helpText: R, error: z, virtualized: B = t.length > 100, className: V = "", inputRef: H, inputProps: U, placement: W = "bottom start", portalContainer: G }) {
14
+ let K = `ui-combobox-${r().replaceAll(":", "")}`, q = e(G), J = i(() => Array.from(t), [t]), Y = i(() => {
15
15
  let e = /* @__PURE__ */ new Map();
16
16
  for (let t of J) {
17
17
  let n = t.group ?? "";
@@ -22,42 +22,42 @@ function D({ items: i, label: a, placeholder: c = "搜索或选择", inputValue:
22
22
  }), e.get(n).items.push(t);
23
23
  }
24
24
  return Array.from(e.values());
25
- }, [J]), X = J.some((e) => e.group !== void 0), Z = (e) => /* @__PURE__ */ u(b, {
25
+ }, [J]), X = J.some((e) => e.group !== void 0), Z = (e) => /* @__PURE__ */ s(b, {
26
26
  id: e.id,
27
27
  textValue: e.label,
28
28
  isDisabled: e.disabled,
29
29
  className: "ui-combobox-item",
30
- children: ({ isSelected: n }) => /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ d("span", { children: [/* @__PURE__ */ u("strong", { children: e.label }), e.description && /* @__PURE__ */ u("small", { children: e.description })] }), n && /* @__PURE__ */ u(t, {
30
+ children: ({ isSelected: t }) => /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ c("span", { children: [/* @__PURE__ */ s("strong", { children: e.label }), e.description && /* @__PURE__ */ s("small", { children: e.description })] }), t && /* @__PURE__ */ s(l, {
31
31
  size: 15,
32
32
  "aria-hidden": "true"
33
33
  })] })
34
- }), Q = () => /* @__PURE__ */ u("div", {
34
+ }), Q = () => /* @__PURE__ */ s("div", {
35
35
  className: "ui-combobox-empty",
36
36
  children: N ? "正在加载…" : L
37
- }), $ = X ? /* @__PURE__ */ u(y, {
37
+ }), $ = X ? /* @__PURE__ */ s(y, {
38
38
  className: "ui-combobox-list",
39
39
  items: Y,
40
40
  layout: "stack",
41
41
  renderEmptyState: Q,
42
- children: (e) => /* @__PURE__ */ d(x, {
42
+ children: (e) => /* @__PURE__ */ c(x, {
43
43
  id: e.id,
44
44
  "aria-label": e.label || "选项",
45
- children: [e.label && /* @__PURE__ */ u(g, {
45
+ children: [e.label && /* @__PURE__ */ s(g, {
46
46
  className: "ui-combobox-group-heading",
47
47
  children: e.label
48
- }), /* @__PURE__ */ u(p, {
48
+ }), /* @__PURE__ */ s(p, {
49
49
  items: e.items,
50
50
  children: Z
51
51
  })]
52
52
  })
53
- }) : /* @__PURE__ */ u(y, {
53
+ }) : /* @__PURE__ */ s(y, {
54
54
  className: "ui-combobox-list",
55
55
  items: J,
56
56
  layout: B ? "grid" : "stack",
57
57
  renderEmptyState: Q,
58
58
  children: Z
59
59
  });
60
- return /* @__PURE__ */ d(m, {
60
+ return /* @__PURE__ */ c(m, {
61
61
  items: J,
62
62
  className: `ui-combobox ${V}`.trim(),
63
63
  inputValue: h,
@@ -70,62 +70,62 @@ function D({ items: i, label: a, placeholder: c = "搜索或选择", inputValue:
70
70
  isRequired: F,
71
71
  allowsCustomValue: I,
72
72
  menuTrigger: "focus",
73
- "aria-label": a === void 0 ? U?.["aria-label"] : void 0,
74
- "aria-labelledby": a === void 0 ? U?.["aria-labelledby"] : void 0,
73
+ "aria-label": n === void 0 ? U?.["aria-label"] : void 0,
74
+ "aria-labelledby": n === void 0 ? U?.["aria-labelledby"] : void 0,
75
75
  children: [
76
- a === void 0 ? null : /* @__PURE__ */ d(v, {
76
+ n === void 0 ? null : /* @__PURE__ */ c(v, {
77
77
  className: "ui-form-label",
78
- children: [a, F && /* @__PURE__ */ u("span", {
78
+ children: [n, F && /* @__PURE__ */ s("span", {
79
79
  className: "ui-form-required",
80
80
  "aria-hidden": "true",
81
81
  children: "*"
82
82
  })]
83
83
  }),
84
- I && /* @__PURE__ */ u(O, {
84
+ I && /* @__PURE__ */ s(O, {
85
85
  count: J.length,
86
86
  loading: N
87
87
  }),
88
- /* @__PURE__ */ d("div", {
88
+ /* @__PURE__ */ c("div", {
89
89
  className: "ui-combobox-control",
90
- children: [/* @__PURE__ */ u(_, {
90
+ children: [/* @__PURE__ */ s(_, {
91
91
  ...U,
92
92
  ref: H,
93
93
  id: K,
94
94
  className: "ui-input",
95
- placeholder: c,
95
+ placeholder: a,
96
96
  "aria-invalid": z ? !0 : U?.["aria-invalid"]
97
- }), /* @__PURE__ */ u(f, {
97
+ }), /* @__PURE__ */ s(f, {
98
98
  className: "ui-combobox-trigger",
99
99
  "aria-label": "展开选项",
100
- children: N ? /* @__PURE__ */ u(r, {
100
+ children: N ? /* @__PURE__ */ s(d, {
101
101
  className: "spin",
102
102
  size: 16
103
- }) : /* @__PURE__ */ u(n, { size: 16 })
103
+ }) : /* @__PURE__ */ s(u, { size: 16 })
104
104
  })]
105
105
  }),
106
- R === void 0 ? null : /* @__PURE__ */ u(C, {
106
+ R === void 0 ? null : /* @__PURE__ */ s(C, {
107
107
  slot: "description",
108
108
  className: "ui-form-help",
109
109
  children: R
110
110
  }),
111
- z === void 0 || z === "" ? null : /* @__PURE__ */ u(C, {
111
+ z === void 0 || z === "" ? null : /* @__PURE__ */ s(C, {
112
112
  slot: "errorMessage",
113
113
  className: "ui-form-error",
114
114
  children: z
115
115
  }),
116
- /* @__PURE__ */ d(S, {
116
+ /* @__PURE__ */ c(S, {
117
117
  className: "ui-combobox-popover",
118
118
  "data-ui-aria-overlay": "",
119
119
  maxHeight: 320,
120
120
  placement: W,
121
121
  UNSTABLE_portalContainer: q,
122
- children: [N && /* @__PURE__ */ d("div", {
122
+ children: [N && /* @__PURE__ */ c("div", {
123
123
  className: "ui-combobox-loading",
124
- children: [/* @__PURE__ */ u(r, {
124
+ children: [/* @__PURE__ */ s(d, {
125
125
  className: "spin",
126
126
  size: 15
127
127
  }), "正在加载"]
128
- }), B ? /* @__PURE__ */ u(T, {
128
+ }), B ? /* @__PURE__ */ s(T, {
129
129
  layout: w,
130
130
  layoutOptions: E,
131
131
  children: $
@@ -134,15 +134,15 @@ function D({ items: i, label: a, placeholder: c = "搜索或选择", inputValue:
134
134
  ]
135
135
  });
136
136
  }
137
- function O({ count: e, loading: t }) {
138
- let n = i(h), r = c(n);
139
- return r.current = n, a(() => {
140
- let n = r.current;
141
- e && !t && n?.isFocused && !n.isOpen && n.open(null, "manual");
137
+ function O({ count: e, loading: r }) {
138
+ let i = t(h), o = a(i);
139
+ return o.current = i, n(() => {
140
+ let t = o.current;
141
+ e && !r && t?.isFocused && !t.isOpen && t.open(null, "manual");
142
142
  }, [
143
143
  e,
144
- t,
145
- n?.collection.size
144
+ r,
145
+ i?.collection.size
146
146
  ]), null;
147
147
  }
148
148
  //#endregion
@@ -1,37 +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";
1
+ import { forwardRef as e } from "react";
2
+ import { jsx as t } from "react/jsx-runtime";
3
+ import { ArrowDown as n, ArrowLeftRight as r, ChevronDown as i, ChevronRight as a, Columns3 as o, EllipsisVertical as s, EyeOff as c, Filter as l, FilterX as u, GripHorizontal as d, Pin as f, RotateCcw as p, Search as m, X as h } from "lucide-react";
4
4
  import g from "@mui/material/SvgIcon";
5
5
  //#region src/DataTableIcons.tsx
6
- function _(e) {
7
- return m((t, n) => /* @__PURE__ */ h(g, {
8
- ...t,
9
- ref: n,
10
- component: e,
6
+ function _(n) {
7
+ return e((e, r) => /* @__PURE__ */ t(g, {
8
+ ...e,
9
+ ref: r,
10
+ component: n,
11
11
  inheritViewBox: !0,
12
12
  sx: [{
13
13
  fontSize: 18,
14
14
  fill: "none"
15
- }, ...Array.isArray(t.sx) ? t.sx : [t.sx ?? {}]]
15
+ }, ...Array.isArray(e.sx) ? e.sx : [e.sx ?? {}]]
16
16
  }));
17
17
  }
18
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)
19
+ SearchIcon: _(m),
20
+ CloseIcon: _(h),
21
+ CancelIcon: _(h),
22
+ ArrowDownwardIcon: _(n),
23
+ ExpandMoreIcon: _(i),
24
+ ArrowRightIcon: _(a),
25
+ SyncAltIcon: _(r),
26
+ MoreVertIcon: _(s),
27
+ ViewColumnIcon: _(o),
28
+ FilterListIcon: _(l),
29
+ FilterAltIcon: _(l),
30
+ FilterListOffIcon: _(u),
31
+ PushPinIcon: _(f),
32
+ DragHandleIcon: _(d),
33
+ RestartAltIcon: _(p),
34
+ VisibilityOffIcon: _(c)
35
35
  };
36
36
  //#endregion
37
37
  export { v as icons };
package/dist/DateInput.js CHANGED
@@ -1,38 +1,38 @@
1
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";
2
+ import { forwardRef as t, useCallback as n, useEffect as r, useId as ee, useRef as i, useState as a } from "react";
3
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
4
+ import { CalendarDays as te, ChevronLeft as ne, ChevronRight as re, X as c } from "lucide-react";
5
+ import * as l from "@radix-ui/react-popover";
6
+ import { Button as u, Calendar as ie, CalendarCell as ae, CalendarGrid as oe, CalendarGridBody as se, CalendarGridHeader as ce, CalendarHeaderCell as le, Heading as ue, I18nProvider as de } from "react-aria-components";
7
+ import { CalendarDate as fe, getLocalTimeZone as d, parseDate as f, today as p } from "@internationalized/date";
8
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(() => {
9
+ var m = "jc-business-ui-date-input-open", h = t(function({ value: t, onValueChange: f, inputRef: h, inputClassName: y, className: x = "", disabled: S, readOnly: C, required: w, inputMode: pe = "numeric", autoComplete: me = "off", onFocus: T, onBlur: he, onKeyDown: ge, min: E, max: D, minDate: _e, maxDate: ve, isDateUnavailable: O, onValidationError: ye, ...k }, A) {
10
+ let j = `ui-date-calendar-${ee().replaceAll(":", "")}`, be = e(), M = i(null), N = i(!1), P = i(!1), F = i(!1), [I, L] = a(!1), [R, z] = a(() => g(t)), [B, V] = a(""), H = _(t), U = _(_e ?? (E === void 0 ? "" : String(E))), W = _(ve ?? (D === void 0 ? "" : String(D))), [G, K] = a(() => H ?? p(d())), q = !!(S || C), xe = n((e) => {
11
+ M.current = e, b(h, e), b(A, e);
12
+ }, [h, A]);
13
+ r(() => {
14
+ z(g(t)), V(""), M.current?.setCustomValidity("");
15
+ }, [t]), r(() => {
16
16
  q && L(!1);
17
- }, [q]), a(() => {
17
+ }, [q]), r(() => {
18
18
  let e = (e) => {
19
19
  e.detail !== j && L(!1);
20
20
  };
21
- return document.addEventListener(h, e), () => document.removeEventListener(h, e);
21
+ return document.addEventListener(m, e), () => document.removeEventListener(m, e);
22
22
  }, [j]);
23
23
  function J(e) {
24
24
  if (!(e && q)) {
25
25
  if (e && !I) {
26
- document.dispatchEvent(new CustomEvent(h, { detail: j }));
27
- let e = H ?? m(f());
26
+ document.dispatchEvent(new CustomEvent(m, { detail: j }));
27
+ let e = H ?? p(d());
28
28
  U && e.compare(U) < 0 && (e = U), W && e.compare(W) > 0 && (e = W), K(e);
29
29
  }
30
30
  L(e);
31
31
  }
32
32
  }
33
33
  function Y(e) {
34
- if (!e) return T ? "请选择日期" : "";
35
- let t = v(e);
34
+ if (!e) return w ? "请选择日期" : "";
35
+ let t = _(e);
36
36
  return t ? U && t.compare(U) < 0 ? `日期不能早于 ${U}` : W && t.compare(W) > 0 ? `日期不能晚于 ${W}` : O?.(t.toString()) ? "该日期不可选择" : "" : "请输入有效日期(YYYY/MM/DD)";
37
37
  }
38
38
  function X(e) {
@@ -40,33 +40,33 @@ var h = "jc-business-ui-date-input-open", g = i(function({ value: i, onValueChan
40
40
  }
41
41
  function Z() {
42
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));
43
+ let e = R.trim() ? v(R) : "", n = e === null ? "请输入有效日期(YYYY/MM/DD)" : Y(e);
44
+ X(n), !n && e !== null && (z(g(e)), e !== t && f(e));
45
45
  }
46
46
  function Q(e) {
47
47
  if (q) return;
48
48
  let t = Y(e);
49
- X(t), !t && (F.current = !0, p(e), z(_(e)), L(!1));
49
+ X(t), !t && (F.current = !0, f(e), z(g(e)), L(!1));
50
50
  }
51
- let $ = m(f()).toString();
52
- return /* @__PURE__ */ l(u.Root, {
51
+ let $ = p(d()).toString();
52
+ return /* @__PURE__ */ s(l.Root, {
53
53
  open: I && !q,
54
54
  onOpenChange: J,
55
55
  children: [
56
- /* @__PURE__ */ c(u.Anchor, {
56
+ /* @__PURE__ */ o(l.Anchor, {
57
57
  asChild: !0,
58
- children: /* @__PURE__ */ l("span", {
59
- className: `ui-date-input${I ? " open" : ""}${S ? ` ${S}` : ""}`,
60
- children: [/* @__PURE__ */ c("input", {
58
+ children: /* @__PURE__ */ s("span", {
59
+ className: `ui-date-input${I ? " open" : ""}${x ? ` ${x}` : ""}`,
60
+ children: [/* @__PURE__ */ o("input", {
61
61
  ...k,
62
62
  ref: xe,
63
- className: b,
63
+ className: y,
64
64
  type: "text",
65
- inputMode: fe,
66
- autoComplete: pe,
67
- disabled: C,
68
- readOnly: w,
69
- required: T,
65
+ inputMode: pe,
66
+ autoComplete: me,
67
+ disabled: S,
68
+ readOnly: C,
69
+ required: w,
70
70
  value: R,
71
71
  placeholder: k.placeholder ?? "YYYY/MM/DD",
72
72
  "aria-haspopup": "dialog",
@@ -75,7 +75,7 @@ var h = "jc-business-ui-date-input-open", g = i(function({ value: i, onValueChan
75
75
  "aria-invalid": B ? !0 : k["aria-invalid"],
76
76
  "aria-describedby": [k["aria-describedby"], B ? `${j}-error` : ""].filter(Boolean).join(" ") || void 0,
77
77
  onFocus: (e) => {
78
- me?.(e), !e.defaultPrevented && !N.current && J(!0);
78
+ T?.(e), !e.defaultPrevented && !N.current && J(!0);
79
79
  },
80
80
  onChange: (e) => {
81
81
  z(e.target.value), B && X("");
@@ -86,7 +86,7 @@ var h = "jc-business-ui-date-input-open", g = i(function({ value: i, onValueChan
86
86
  onKeyDown: (e) => {
87
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
88
  }
89
- }), /* @__PURE__ */ c("button", {
89
+ }), /* @__PURE__ */ o("button", {
90
90
  type: "button",
91
91
  className: "ui-date-trigger",
92
92
  disabled: q,
@@ -96,22 +96,22 @@ var h = "jc-business-ui-date-input-open", g = i(function({ value: i, onValueChan
96
96
  onClick: () => {
97
97
  P.current = !0, J(!I);
98
98
  },
99
- children: /* @__PURE__ */ c(t, {
99
+ children: /* @__PURE__ */ o(te, {
100
100
  size: 17,
101
101
  "aria-hidden": "true"
102
102
  })
103
103
  })]
104
104
  })
105
105
  }),
106
- B && /* @__PURE__ */ c("span", {
106
+ B && /* @__PURE__ */ o("span", {
107
107
  id: `${j}-error`,
108
108
  className: "ui-form-error",
109
109
  role: "alert",
110
110
  children: B
111
111
  }),
112
- /* @__PURE__ */ c(u.Portal, {
112
+ /* @__PURE__ */ o(l.Portal, {
113
113
  container: be,
114
- children: /* @__PURE__ */ l(u.Content, {
114
+ children: /* @__PURE__ */ s(l.Content, {
115
115
  id: j,
116
116
  className: "ui-date-calendar",
117
117
  "aria-label": "选择日期",
@@ -129,9 +129,9 @@ var h = "jc-business-ui-date-input-open", g = i(function({ value: i, onValueChan
129
129
  onInteractOutside: (e) => {
130
130
  M.current?.parentElement?.contains(e.target) && e.preventDefault();
131
131
  },
132
- children: [/* @__PURE__ */ c(ue, {
132
+ children: [/* @__PURE__ */ o(de, {
133
133
  locale: "zh-CN",
134
- children: /* @__PURE__ */ l(re, {
134
+ children: /* @__PURE__ */ s(ie, {
135
135
  "aria-label": "选择日期",
136
136
  value: H,
137
137
  onChange: (e) => Q(e.toString()),
@@ -139,51 +139,51 @@ var h = "jc-business-ui-date-input-open", g = i(function({ value: i, onValueChan
139
139
  maxValue: W ?? void 0,
140
140
  isDateUnavailable: (e) => O?.(e.toString()) ?? !1,
141
141
  focusedValue: G,
142
- onFocusChange: (e) => K(new de(e.year, e.month, e.day)),
142
+ onFocusChange: (e) => K(new fe(e.year, e.month, e.day)),
143
143
  children: [
144
- /* @__PURE__ */ l("header", { children: [
145
- /* @__PURE__ */ c(d, {
144
+ /* @__PURE__ */ s("header", { children: [
145
+ /* @__PURE__ */ o(u, {
146
146
  slot: "previous",
147
147
  "aria-label": "上个月",
148
- children: /* @__PURE__ */ c(n, { size: 18 })
148
+ children: /* @__PURE__ */ o(ne, { size: 18 })
149
149
  }),
150
- /* @__PURE__ */ c(le, {}),
151
- /* @__PURE__ */ c(d, {
150
+ /* @__PURE__ */ o(ue, {}),
151
+ /* @__PURE__ */ o(u, {
152
152
  slot: "next",
153
153
  "aria-label": "下个月",
154
- children: /* @__PURE__ */ c(r, { size: 18 })
154
+ children: /* @__PURE__ */ o(re, { size: 18 })
155
155
  })
156
156
  ] }),
157
- /* @__PURE__ */ l("label", {
157
+ /* @__PURE__ */ s("label", {
158
158
  className: "ui-date-month-jump",
159
- children: ["跳转年月", /* @__PURE__ */ c("input", {
159
+ children: ["跳转年月", /* @__PURE__ */ o("input", {
160
160
  type: "month",
161
161
  "aria-label": "跳转年月",
162
162
  value: `${G.year.toString().padStart(4, "0")}-${String(G.month).padStart(2, "0")}`,
163
163
  min: U?.toString().slice(0, 7),
164
164
  max: W?.toString().slice(0, 7),
165
165
  onChange: (e) => {
166
- let t = v(`${e.target.value}-01`);
166
+ let t = _(`${e.target.value}-01`);
167
167
  t && K(U && t.compare(U) < 0 ? U : W && t.compare(W) > 0 ? W : t);
168
168
  }
169
169
  })]
170
170
  }),
171
- /* @__PURE__ */ l(ae, {
171
+ /* @__PURE__ */ s(oe, {
172
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, {
173
+ children: [/* @__PURE__ */ o(ce, { children: (e) => /* @__PURE__ */ o(le, { children: e }) }), /* @__PURE__ */ o(se, { children: (e) => /* @__PURE__ */ o(ae, {
174
174
  date: e,
175
175
  "data-date": e.toString()
176
176
  }) })]
177
177
  })
178
178
  ]
179
179
  })
180
- }), /* @__PURE__ */ l("footer", { children: [/* @__PURE__ */ l("button", {
180
+ }), /* @__PURE__ */ s("footer", { children: [/* @__PURE__ */ s("button", {
181
181
  type: "button",
182
182
  className: "ui-date-clear",
183
- disabled: !i || T,
183
+ disabled: !t || w,
184
184
  onClick: () => Q(""),
185
- children: [/* @__PURE__ */ c(ee, { size: 14 }), "清除"]
186
- }), /* @__PURE__ */ c("button", {
185
+ children: [/* @__PURE__ */ o(c, { size: 14 }), "清除"]
186
+ }), /* @__PURE__ */ o("button", {
187
187
  type: "button",
188
188
  className: "ui-date-today",
189
189
  disabled: !!Y($),
@@ -195,29 +195,29 @@ var h = "jc-business-ui-date-input-open", g = i(function({ value: i, onValueChan
195
195
  ]
196
196
  });
197
197
  });
198
- function _(e) {
198
+ function g(e) {
199
199
  return /^\d{4}-\d{2}-\d{2}$/.test(e) ? e.replaceAll("-", "/") : e;
200
200
  }
201
- function v(e) {
202
- let t = y(e);
203
- return t ? p(t) : null;
201
+ function _(e) {
202
+ let t = v(e);
203
+ return t ? f(t) : null;
204
204
  }
205
- function y(e) {
205
+ function v(e) {
206
206
  let t = e.trim().match(/^(\d{4})[/.\-](\d{1,2})[/.\-](\d{1,2})$/);
207
207
  if (!t || Number(t[1]) < 1) return null;
208
208
  let n = `${t[1]}-${t[2].padStart(2, "0")}-${t[3].padStart(2, "0")}`;
209
209
  try {
210
- return p(n).toString();
210
+ return f(n).toString();
211
211
  } catch {
212
212
  return null;
213
213
  }
214
214
  }
215
- function b(e, t) {
215
+ function y(e, t) {
216
216
  let n = new Date(e, t, 1), r = new Date(e, t, 1 - n.getDay());
217
217
  return Array.from({ length: 42 }, (e, t) => ({ date: new Date(r.getFullYear(), r.getMonth(), r.getDate() + t) }));
218
218
  }
219
- function x(e, t) {
219
+ function b(e, t) {
220
220
  typeof e == "function" ? e(t) : e && (e.current = t);
221
221
  }
222
222
  //#endregion
223
- export { g as DateInput, b as calendarDays, y as parseDate };
223
+ export { h as DateInput, y as calendarDays, v as parseDate };